Pine script conversion using ChatGPT 4

Forums ProRealTime English forum General trading discussions Pine script conversion using ChatGPT 4

Viewing 15 posts - 1 through 15 (of 42 total)
  • #220818

    Spent few hours with chatgpt helping me (or maybe i was helping him?:-)) to translate an indicator from tradingview.

    Finally we did it, but it tooks twice or 3 times more times than if i did it alone…

    Original code : https://fr.tradingview.com/script/5zoE62bC-TKP-T3-Trend-With-Psar-Barcolor/

    3 users thanked author for this post.
    #220930

    Thanks a lot Lucas! I’m adding this indicator into the Library. Don’t hesitate to add more! 😉

     

    #220934

    manque la variable : long

    #220964

    Variables have been added directly to the code… You can add the variables in the input table of probuilder if you want to.

    #220967

    manque la variable : long

    Sorry, don”t know how it was working without…
    Nevermind, you can add line 14 : long = 25

    #221026

    Thanks a lot; what prompt did you use?

    #221145

    Whatever the prompt i use at the begining Chatgpt does a lot of errors, syntax errors and confusion between the different languages (for example, it sometimes creats new instruction when it does not know how to translate to probuilder…)

    What i don’t like is that sometimes it seems to forget all i’ve said before and does simple syntax errors it did not before… Weird! AI they said? Then Ai is dumb from time to time…

    For functions, the prompt that seems to work is to tell him : whenever you meet a function, do not translate it because probuilder dos not support functions yet, but instead apply the logic of the function each time the pine script will call the function later in the code.

    Also, chatgpt (v4) is not comfortable with probuilder when it comes to ploting… So it often needs some hints to know which instructions to use for plotting (Drawsegment, drawcandle, drawpoint, drawtext or simply return…)

    When it comes to color, i tell him to split colors in 3 differents variables with r g and b values.

    I tried to feed him with a list of all instructions that exist in probuilder, but his level in prorealtime coding remain the same from my point of view…

    1 user thanked author for this post.
    #221154

    For example, for the conversion of this code which is rather simple, i had to help him a lot, as it was lost with nz() and na() instructions and how to translate them (even with using if then else). It tooks more than 3 hours while i would have need only 1h to do it without chatgpt…

    #221158

    Hola Lucas

    I don’t see a yellow candle for entry in position ? have you  an example please

    this indicator feel good !

    have a nice day.

    #221159

    Hola Lucas

    I don’t see a yellow candle for entry in position ? have you an example please

    this indicator feel good !

    have a nice day.

    I made the conversion yesteerday of 3 or 4 indicators, so i had no time to test them yet.
    But, i think yellow candle does not appears very often also in the original post on tradingview :
    https://www.tradingview.com/script/791WkWcm-blackcat-L3-Banker-Fund-Flow-Trend-Oscillator/

    As you can see, even while scrolling left and right the chart, yellow candle appears only once.

    It is because of line 62 :
    bankerentry = (fundtrend crosses over bullbearline) AND bullbearline < 25 You need to have a cross over while bullbearline is below 25. What you can do is to add a variable call it SupertitiThrshold = 25 (by default) Change line 62 : bankerentry = (fundtrend crosses over bullbearline) AND bullbearline < SupertitiThrshold Then play in configuration table with that SupertitiThrshold until you see as much yellow candle as you would like

    #221161

    Hola a todos,

    Here is the screener for the white candlesticks above 80…

    Que disfruteis

     

    // L3 BANKER WHITE SCREENER by DID 17.09.2023

    // L3 BANKER FUND FLOW TREND OSCILLATOR by Lucasbest 17.09.2023

    // defparam calculateonlastbars = 150

    If Barindex >35 then

    // First xsa call:

    srcValue1 = 100*(close – Lowest[27](low)) / (Highest[27](high) – Lowest[27](low))
    lenValue1 = 5
    weiValue1 = 1

    sumf1 = 0
    ma1 = 0
    out1 = 0

    sumf1 = (not (sumf1[1] = undefined)) * sumf1[1] – ((not (srcValue1[lenValue1] = undefined)) * srcValue1[lenValue1] + srcValue1)

    ma1 = not (srcValue1[lenValue1] = undefined) * (sumf1 / lenValue1)

    IF out1[1] = 0 THEN
    out1 = ma1
    ELSE
    out1 = (srcValue1 * weiValue1 + out1[1] * (lenValue1 – weiValue1)) / lenValue1
    ENDIF

    // Now, ‘out1’ is the result of the first xsa.

    // Second xsa call with out1 as the input:

    srcValue2 = out1
    lenValue2 = 3
    weiValue2 = 1
    sumf2 = 0
    ma2 = 0
    out2 = 0

    sumf2 = (NOT (sumf2[1] = UNDEFINED)) * sumf2[1] – ((NOT (srcValue2[lenValue2] = UNDEFINED)) * srcValue2[lenValue2] + srcValue2)

    ma2 = not (srcValue2[lenValue2] = UNDEFINED) * (sumf2 / lenValue2)

    IF out2[1] = UNDEFINED THEN
    out2 = ma2
    ELSE
    out2 = (srcValue2 * weiValue2 + out2[1] * (lenValue2 – weiValue2)) / lenValue2
    ENDIF

    // Now, ‘out2’ is the result of the second xsa.

    // Fund trend final calculation:
    fundtrend = (3 * out1 – 2 * out2 – 50) * 1.032 + 50

    // Defining typical price for banker fund
    typ = (2*close + high + low + open) / 5

    // Lowest low with mid term fib # 34
    lol = lowest[34](low)

    // Highest high with mid term fib # 34
    hoh = highest[34](high)

    // Define banker fund flow bull bear line
    bullbearline = exponentialaverage[13]((typ – lol) / (hoh – lol) * 100)

    // Define banker entry signal using ‘crosses over’
    bankerentry = (fundtrend crosses over bullbearline) AND bullbearline < 25

    //banker fund entry with yellow candle
    IF bankerentry THEN
    //DRAWCANDLE(0, 50, 0, 50) COLOURED(255,255,0)// Yellow color
    ENDIF

    //banker increase position with green candle
    IF fundtrend > bullbearline THEN
    //DRAWCANDLE(fundtrend, bullbearline, fundtrend, bullbearline) COLOURED(0,255,0) // Green color
    ENDIF

    //banker decrease position with white candle
    IF fundtrend < (fundtrend[1] * 0.95) THEN
    //DRAWCANDLE(fundtrend, bullbearline, fundtrend, bullbearline) COLOURED(255,255,255)// White color
    ENDIF

    //banker fund exit/quit with red candle
    IF fundtrend < bullbearline THEN
    //DRAWCANDLE(fundtrend, bullbearline, fundtrend, bullbearline) COLOURED(255,0,0) // Red color
    ENDIF

    //banker fund Weak rebound with blue candle
    IF fundtrend < bullbearline AND fundtrend > (fundtrend[1]*0.95) THEN
    //DRAWCANDLE(fundtrend, bullbearline, fundtrend, bullbearline) COLOURED(0,0,255) // Blue color
    ENDIF

    //h1 = 80
    //h2 = 20
    //h3 = 10
    //h4 = 90

    // Coloring between the lines
    //colorbetween(h1, h4, 255, 0, 255, 100) // Fuchsia shade between 80 and 90
    //colorbetween(h2, h3, 255, 255, 0, 100) // Yellow shade between 20 and 10

    Endif

    //RETURN h1 style(line,1) coloured(255,0,0), h2 style(line,1) coloured(255,255,0), h3 style(line,1) coloured(0,255,0), h4 style(line,1) coloured(255,0,255)

    //Entrée du banquier dans le fonds avec une bougie jaune

    //augmentation de la position de la banque avec la bougie verte

    //Banker diminue sa position avec une bougie blanche

    //Sortie du fonds bancaire/quit avec la bougie rouge

    //Fonds bancaire Faible rebond avec la bougie bleue

    C1 = fundtrend >80
    C2 = fundtrend < (fundtrend[1] * 0.95)

    SCREENER [C1 and C2 ]

    #221167

    Sometimes ChatGPT is funny… Or maybe upset as i made him work to much ? See below his last answer :
    “If you’re serious about porting this over to ProBuilder, you might consider working with a developer familiar with both Pine Script and ProBuilder to ensure accurate and functional translation.”

    2 users thanked author for this post.
    #221185

    Just a tip, this kind of “direct” translation from Pinescript is not accurate :
    ma1 = not (srcValue1[lenValue1] = undefined) * (sumf1 / lenValue1)
    (in this case you are multiplying the result of the boolean with (sumf1 / lenValue1) )

    The original code was using a single conditional statement within a single line, and with (na) testing:
    ma  :=  na(src[len]) ? na : sumf/len

    IMO, it should be coded as below:
    ma = undefined
    if srcValue1[lenValue1] >0 then
    ma = sumf/len
    endif

    1 user thanked author for this post.
    #221186

    You are right Nicolas, with my convrsion ma would be equal to 0 or equal to sumf/len, in yours ma would be undfined or equal to sumf/len

    #221190

    To be clear, think of this:

    ma  :=  na(src[len]) ? na : sumf/len

    as this:

    if IsNaN(src[len]) then ma = NaN else ma = sumf / len

    in ProBuilder, there is no “NaN” state (Not a Number) by default, until you declare a variable as UNDEFINED. So it is better to test if it’s equal to 0, because all variables equal to 0 at start of code.

    Sometimes it is useful to set a variable to UNDEFINED, to make it not visible on chart until its first calculation for instance, but keep in mind, that UNDEFINED can only be assign once.

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 42 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login