Pine script conversion using ChatGPT 4
Forums › ProRealTime English forum › General trading discussions › Pine script conversion using ChatGPT 4
- This topic has 41 replies, 7 voices, and was last updated 1 year ago by LucasBest.
-
-
09/18/2023 at 9:36 AM #221191
So the code you wrote above is correct or not ?
ma = undefined
if srcValue1[lenValue1] >0 then
ma = sumf/len
endifIf UNDEFINED can only be assign once, can we write “ma = undefined” ?
Or we should write “once ma = undefined” ?09/18/2023 at 9:55 AM #221198Hello
in
//banker increase position with green candle
IF fundtrend > bullbearline THEN
DRAWCANDLE(fundtrend, bullbearline, fundtrend, bullbearline) COLOURED(0,255,0) // Green color
ENDIFadd
IF fundtrend > bullbearline and not bankerentry THEN
DRAWCANDLE(fundtrend, bullbearline, fundtrend, bullbearline) COLOURED(0,255,0) // Green color
ENDIFthen the yellow candle will appair …
09/18/2023 at 10:33 AM #221201Hi @lucasbest
« Whatever the prompt i use at the begining Chatgpt does a lot of errors, syntax errors and confusion between the different languages »
If you believe in the power of a leveraging by working with others, can I propose you share the prompt you used?
So that we can build a step by step translation process that could maybe have better final results?09/18/2023 at 10:52 AM #221204I used th prompt of Nicolas first times, and then i tried to feed chatgpt with list of all instructions of probuilder. Now i don”t use any long prompt but just say “can you translate this pine script code to probuilder language ?”.
Sometimes chatgpt remember what i said and what it did before and do a good job with colors (splitting them in 3 variables) and with function…
But what i don’t understand is that sometimes chatgpt go completly wrong, using new instructions, like “function(…)” or “x = IF… THEN… EDNDIF” or even “color = RGB(colorR,colorG,colorB)” in the same discussion like if it forget everything (CHATGPT have alzheimer?) we did or said before…It is like if probuilder language is not yet anchored in his DNA, it tries to learn but if a prompt makes it doubt about what it learned previously, then it delete all and become dumb! It is very frustrating… as i accept to loose more time helping him because i thought it will become more and more accurate in translating codes from pine script to probuilder, but i can tell after more than 15-20 indicators conversion that it isn’t the case.
Maybe best way is to use it partilly for the things it does the best and convert the rest alone?
1 user thanked author for this post.
09/19/2023 at 8:11 AM #221251An other Pine script indicator convrsion.
Original script here below :
https://www.tradingview.com/script/y80r44fM-Advanced-GET-Tom-Joseph-s-XTL-DMA-Cloud-Breakout-Signals/DMA Cloud & Breakout Signals123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245// Advanced GET XTL + DMA CloudcolR1 = 0colG1 = 135colB1 = 225colR2 = 255colG2 = 0colB2 = 0colR3 = 255colG3 = 255colB3 = 30colR4 = 50colG4 = 125colB4 = 255colR5 = 250colG5 = 0colB5 = 0colR6 = 255colG6 = 255colB6 = 255colREntryBull = 0colGEntryBull = 0colBEntryBull = 255colREntryBear = 255colGEntryBear = 0colBEntryBear = 0colRStopBull = 255colGStopBull = 0colBStopBull = 0colRStopBear = 0colGStopBear = 0colBStopBear = 255// Expert Trend Locator (XTL)len = 34 // XTL PeriodhLmt = 34 // Threshold Valuextlsrc = (high + low + close) / 3XTL = CCI[len](xtlsrc)bull = XTL > hLmtbear = XTL < -hLmtneutral = (XTL <= hLmt) AND (XTL >= -hLmt)// Colors for barsif bull THENR = colR1G = colG1B = colB1ELSIF neutral THENR = colR3G = colG3B = colB3ELSER = colR2G = colG2B = colB2ENDIFDRAWCANDLE(open,high,low,close) COLOURED(R,G,B) BORDERCOLOR(R,G,B)//Displaced Moving Average (DMA)showdma = 1 // 1 for Yes, 0 for No: Show DMA?malength = 8 // DMA Lengthdisplacement = 5 // DMA DisplacementDMA1 = Average[malength](low)DMA2 = Average[malength](high)// Colors for DMAif DMA1 > DMA1[1] THENRR2 = colR4G2 = colG4B2 = colB4ELSIF DMA1 <= DMA1[1] THENRR2 = colR5G2 = colG5B2 = colB5ELSERR2 = colR6G2 = colG6B2 = colB6ENDIFIF showdma THENDrawsegment(barindex-1,DMA1[1],barindex,DMA1) coloured(RR2,G2,B2,100)Drawsegment(barindex-1,DMA2[1],barindex,DMA2) coloured(RR2,G2,B2,100)Colorbetween(DMA1,DMA2,RR2,G2,B2,20)endif// Breakout Bar Entry & Stopshowbbar = 1 // 1 for Yes, 0 for No: Show Breakout Bar Signalscont = 0 // 1 for Yes, 0 for No: Levels as Lines// State DeterminationIF bear THENstate = 0ELSIF bull THENstate = 1ELSEstate = state[1]ENDIFprevstate = state[1]// Settings for Breakout Barbbarstop = 0.5 // Stop Loss Ratiobbaentry = 1.5 // Entry Ratio// Target Settingstar1 = 1 // 1 for Yes, 0 for No: Show Target 1tar2 = 0 // 1 for Yes, 0 for No: Show Target 2bbartgt1 = 3 // Target Ratio 1bbartgt2 = 4 // Target Ratio 2myrange = high - low// Continuous stop, entry, and target levelsIF state > prevstate THENcstop = low - myrange * bbarstopELSIF state < prevstate THENcstop = high + myrange * bbarstopELSEcstop = cstop[1]ENDIFIF state > prevstate THENcentry = low + myrange * bbaentryELSIF state < prevstate THENcentry = high - myrange * bbaentryELSEcentry = centry[1]ENDIFIF state > prevstate THENctgt1 = low + myrange * bbartgt1ELSIF state < prevstate THENctgt1 = high - myrange * bbartgt1ELSEctgt1 = ctgt1[1]ENDIFIF state > prevstate THENctgt2 = low + myrange * bbartgt2ELSIF state < prevstate THENctgt2 = high - myrange * bbartgt2ELSEctgt2 = ctgt2[1]ENDIF// Non-continuous stop, entry, and target levelsIF state > prevstate THENncstop = low - myrange * bbarstopELSIF state < prevstate THENncstop = high + myrange * bbarstopELSEncstop = UNDEFINEDENDIFIF state > prevstate THENncentry = low + myrange * bbaentryELSIF state < prevstate THENncentry = high - myrange * bbaentryELSEncentry = UNDEFINEDENDIFIF state > prevstate THENnctgt1 = low + myrange * bbartgt1ELSIF state < prevstate THENnctgt1 = high - myrange * bbartgt1ELSEnctgt1 = UNDEFINEDENDIFIF state > prevstate THENnctgt2 = low + myrange * bbartgt2ELSIF state < prevstate THENnctgt2 = high - myrange * bbartgt2ELSEnctgt2 = UNDEFINEDENDIFIF cont THENpstop = cstoppentry = centryptgt1 = ctgt1ptgt2 = ctgt2displ = -1ELSEpstop = ncstoppentry = ncentryptgt1 = nctgt1ptgt2 = nctgt2displ = 0ENDIF// Define the colbar variableIF bull THENcolbar = 1ELSIF bear THENcolbar = 0ELSEcolbar = colbar[1]ENDIF// Define colors for entry and stopIF colbar = 1 THENREntry = colREntryBullGEntry = colGEntryBullBEntry = colBEntryBullRStop = colRStopBullGStop = colGStopBullBStop = colBStopBullELSEREntry = colREntryBearGEntry = colGEntryBearBEntry = colBEntryBearRStop = colRStopBearGStop = colGStopBearBStop = colBStopBearENDIF// Plot StopIF showbbar then //AND pstop=pstop[1] THENDrawsegment(barindex, pstop, barindex+5, pstop) style(dottedline,2) coloured(RStop, GStop, BStop,255)ENDIF// Plot EntryIF showbbar then //AND pentry=pentry[1] THENDrawsegment(barindex, pentry, barindex+5, pentry) style(line,5) coloured(REntry, GEntry, BEntry, 255)ENDIF// Assuming you also want to plot Targets, here's an example for Target 1 (based on ptgt1 variable)Drawsegment(barindex, ptgt1, barindex+5, ptgt1) style(dottedline1,5) coloured("gold",255)Drawsegment(barindex, ptgt2, barindex+5, ptgt2) style(dottedline1,5) coloured("gold",255)Return2 users thanked author for this post.
09/19/2023 at 8:49 AM #221255If UNDEFINED can only be assign once, can we write “ma = undefined” ? Or we should write “once ma = undefined” ?
Whatever, it will have the same effect.
1 user thanked author for this post.
09/19/2023 at 8:57 AM #221257What you need to understand with ChatGPT is that generative AI will do everything to satisfy you, even if it means inventing new instructions, as you’ve seen. Since it doesn’t have all the necessary notions to completely translate code from one language to another (here for ProBuilder), it will do its best to help you, even if it means generating code that isn’t compatible. That’s its purpose, that’s why it was created.
When ChatGPT tells you that you should talk to someone more accustomed to doing translations, rather than him, it’s again not to disappoint you, it’s a bit like his “soul” talking to you. I also think he detects your insistence and annoyance in the prompt you used at the time 🙂*** Thanks again for sharing the indicators you’ve translated, it’s a lot of effort to help the community and I really appreciate it! ***
09/19/2023 at 9:13 AM #22125809/19/2023 at 11:39 AM #22126609/19/2023 at 1:08 PM #221275I also think he detects your insistence and annoyance in the prompt you used at the time 🙂
*** Thanks again for sharing the indicators you’ve translated, it’s a lot of effort to help the community and I really appreciate it! ***
It’s true, I admit I’ve been a little hard on him sometimes and even called him a dumb once or twice… 😳
No problem for helping the community. I learned a lot here too, and still learning every day.
09/19/2023 at 1:13 PM #221276Hi @LucasBest,
you see this answer right?
Are you using GPT4?
Just saw it. I have same issue after few hours of using it…
It is v4 yes.09/19/2023 at 1:25 PM #221277a Lucasbest
Would it be possible to create the “L3 Banker fund flow osci” indicator in the form of a curve (moving average type) that would be applied directly to the price graph.
Thanks for sharing.
From same author, there is this swing indicator on price :
https://www.tradingview.com/script/ZkAray4F/Is that what you want ?
09/19/2023 at 1:50 PM #22127809/21/2023 at 7:21 AM #221361For those who have tradingview and can try those 2 indicators below, which one is the best/more accurate ?
https://fr.tradingview.com/script/CapG3ivf-Bjorgum-Key-Levels/
https://fr.tradingview.com/script/iOrhpIqc-Support-and-Resistance-Signals-MTF-LuxAlgo/Both do almost the same work, both are long and hard to convert… Can you vote and tell me which one worth to be translated more than th other ?
09/21/2023 at 11:35 AM #221382to Lucas,
I’m sorry, but the last two indicators you suggested don’t appeal to me.
The one that catches my eye, on the other hand, is the Banker Fund Swing. Translated into a curve, it would be the best, and in colours identical to the candlesticks, it would be impossible.
But the impossible is impossible.
Nicolas might be able to help you with that.
Thanks for your help.
Have a nice day. -
AuthorPosts
Find exclusive trading pro-tools on