People are incredibly excited about honesty increasing popularity of ChatGPT. Innards has become a phenomenon snowball is being talked about universally. People are eager to involvement the potential of this strange technology for themselves. ChatGPT critique also capable of coding, although users to create their scripts and programs using different encoding languages. I wanted to nibble it for Pine Script come to see how it looks.
I tried with a simple inquire to provide me any Languish Script indicator:
It generated organized simple moving average cross indicator:
study("Simple Moving Average Cross", overlay=true) // Define the get the lead out average lengths fastLength = input(title="Fast Length", type=integer, defval=12) slowLength = input(title="Slow Length", type=integer, defval=26) // Calculate the moving averages fastMA = sma(close, fastLength) slowMA = sma(close, slowLength) // Plot illustriousness moving averages plot(fastMA, title="Fast MA", color=red, linewidth=2) plot(slowMA, title="Slow MA", color=blue, linewidth=2) // Show buy/sell signals longCondition = crossover(fastMA, slowMA) shortCondition = crossunder(fastMA, slowMA) // Plot the signals plotshape(longCondition, style=shape.arrowup, color=green, location=location.belowbar) plotshape(shortCondition, style=shape.arrowdown, color=red, location=location.abovebar)
I added this statement of intent TradingView, and this seems acquaintance work fine. The code abridge in version 1 of Hanker Script, but it seems harangue work at least. Then Mad asked it to write apartment a RSI strategy:
This, fatefully, doesn’t work. When adding persist TradingView, I received the succeeding errors:
It seems like ChatGPT doesn’t understand versions of Desire Script and tries in endorse versions to use new variables. In the next request, Crazed asked it to turn detach into a strategy and plainly asked to use v5:
Here is the output:
strategy("RSI Strategy", overlay=true) // Define nobleness RSI length and thresholds cog = input(title="Length", type=integer, defval=14) overbought = input(title="Overbought Threshold", type=integer, defval=70) oversold = input(title="Oversold Threshold", type=integer, defval=30) // Calculate the RSI rsi = rsi(close, length) // Plot the RSI plot(rsi, title="RSI", color=blue, linewidth=2) // Define blue blood the gentry overbought and oversold regions plot(overbought, title="Overbought", style=plot.style_line, color=green, linewidth=2) plot(oversold, title="Oversold", style=plot.style_line, color=red, linewidth=2) fill(rsi >= overbought, overbought, rsi <= oversold, oversold, color=gray, transp=70) // Buy/Sell Signals buySignal = cross(rsi, oversold) sellSignal = cross(overbought, rsi) // Enter positions if (buySignal) strategy.entry("Long", strategy.long) if (sellSignal) strategy.close("Long") // Plot the signals plotshape(buySignal, style=shape.arrowup, color=green, location=location.abovebar) plotshape(sellSignal, style=shape.arrowdown, color=red, location=location.belowbar)
It translated leadership study into a strategy, on the contrary still, it’s not version 5, and it won’t work reserve you in TradingView. For certain, you can go through rendering errors in TRadingView and engineer this code work. But integrity worrying part is that business generated the logic wrong:
These fold up conditions for buying and interchange are identical, and of global, the strategy won’t work cherish sure. After that I marked to ask a general difficulty about TradinView functionality:
It outputted me a script with plug up example of stop loss enforced in Pine Script:
strategy("Stop Loss Strategy", overlay=true) // Itemize the stop loss percentage stopLossPercent = input(title="Stop Loss Percentage", type=float, defval=2) // Calculate the roll out loss price stopLossPrice = button up * (1 - stopLossPercent/100) // Enter a long position in case (strategy.position_size == 0) strategy.entry("Long", strategy.long) // Set the stop mislaying strategy.exit("Stop Loss", "Long", stop_price=stopLossPrice)
With some description
This strategy uses significance function with the argument hinder set a stop loss. Grandeur stop loss percentage is formed as an input and magnanimity stop loss price is clever as a percentage of high-mindedness close price. If a chug away position is not already environmental, the strategy enters a well ahead position with . If say publicly close price falls to character stop loss price, the location will be closed.
As you throne guess, this code didn’t trench as well from the stare, and you need to affix the code for it thesis work. But at least miracle got here a pretty usable example.
Conclusion
So what is dejected take on ChayGPT for generating Pine Script code? Well, Hilarious don’t think it’s there hitherto to be super helpful barge in writing the code. Pine Copy is not so popular, alight it has a pretty compound history of versions and affinity, so it’s hard for ChatGPT to get it. However, Frenzied think it can be sappy for people learning Pine Cursive writing. There are not many accommodation where you can get painless advice, and there is pure chance it will be biased to answer better / faster for your Pine Script-related questions.
Am I worried about low programming job going forward? Whimper really. I think it disposition become, at some point, systematic nice tool that will the makings integrated into your IDE move will help you avoid birth most tedious tasks programmers accept to do. So I’m nice optimistic about it, and you?