PineGPT is a custom GPT inside ChatGPT that helps you write, debug and explain TradingView Pine Script indicators and strategies. You describe the trading logic in plain English, and it returns Pine Script code that you paste into the Pine Editor, test and refine. Below are the prompts I use, links to code it generated, and tips to get reliable scripts from it.
PineGPT is a customGPT for ChatGPT4 users designed to provide expert guidance on creating and understanding TradingView Pine Script indicators and trading strategies. PineGPT specializes in Pine Script Version 5, the language used for creating custom indicators and strategies on the TradingView platform. This includes the ability to understand, analyze, and offer advice on Pine Script coding, functionality, and optimization.

Key Takeaways
- PineGPT was built for Pine Script v5. TradingView released Pine Script v6 on 10 December 2024, so ask for v6 explicitly or convert the output with the Pine Editor’s converter.
- Custom GPTs are no longer limited to paid ChatGPT plans; free users got access to GPTs from May 2024, with usage limits.
- The more precise the prompt (entry rule, exit rule, stop and target logic, plot colours), the better the code.
- Always compile, read and backtest the generated code before using it; AI tools can produce scripts that run but do not match your rules.
What PineGPT Can Do for Pine Script Coders
Build custom indicators and strategies
It assists in developing custom indicators and strategies that align with specific trading goals or ideas. This includes providing guidance on logic implementation, technical analysis concepts, and script optimization.
Troubleshoot and improve existing code
PineGPT helps with troubleshooting and improving existing Pine Script codes. This might involve identifying errors, suggesting performance improvements, or refactoring code for better efficiency and readability.
Learn Pine Script concepts
PineGPT Offers explanations and teaches the fundamentals and advanced concepts of Pine Script. This is useful for both beginners learning Pine Script from scratch and experienced users looking to deepen their knowledge.
PineGPT Sample Prompts for TradingView Pine Script
Sample Prompts 1:
Task :
1)Build EMA Crossover Strategy with Target and Stoploss.
2)Use Percentage Base Stoploss. By default use 0.25% as Stoploss and 0.5% as Target
3)Calculate the Stoploss and Target value when the entry condition triggered
4)Place Stoploss and Target orders immediately after placing the entry orders
5)Finally Plot the Stoploss and Target Levels in a style circle format.
6)Stoploss levels in red color and Target Levels in Green Color.
7)Use line thickness as two while plotting EMA values , stoploss and target
Sample Prompts 2:
Task: Build a Pinescript Strategy and achieve the following goals
1)Generate the Supertrend Strategy and plot supertrend
2)Plot Supertend in color green when direction = -1 and
plot supertrend in color red when direction = 1
2)longcondition when supertrend direction = -1
3)shortcondition when supertrend direction = 1
4)It is a stop and reverse strategy
Sample Prompts 3:
Task
1)Create a Simple Donchian Channel Trading Strategy
2)Place Stop Limit Orders exactly at the 1bar back Donchian Channel for Entry Signal
3)Plot the Lower Donchian Channel in Color Red
4)Plot the Upper Donchian Channel in Color Green
5)Avoid using entry/exit conditions directly place orders with stop limit orders
How to write a good Pine Script prompt
- State the version: “Use Pine Script v6” (or v5 if you need to match older code).
- Say whether it is an indicator or a strategy, and whether it is long only, short only or stop and reverse.
- Give exact entry and exit rules with numbers (lengths, percentages, which bar the order is placed on).
- Describe what to plot: lines, colours, styles and thickness.
- Ask it to add inputs for every number, so you can optimise later without editing code.
Reference Codes Generated by PineGPT
Here are Some of the Reference Codes Generated by PineGPT
Generate a Simple Supertrend Strategy
Generate a Simple EMA Crossover with Stoploss and Target Levels
Create a Simple Donchian Channel Trading Strategy
Example: EMA crossover with stoploss and target (Pine Script v6)
This is a reviewed v6 version of the strategy described in Sample Prompt 1: a 9/21 EMA crossover, stop and reverse, with a 0.25% stoploss and 0.5% target calculated from the entry price and plotted as red and green circles. Paste it into the Pine Editor, add it to a chart and check the Strategy Tester.
//@version=6
strategy("EMA Crossover with Stoploss and Target", overlay = true)
fastLen = input.int(9, "Fast EMA")
slowLen = input.int(21, "Slow EMA")
slPct = input.float(0.25, "Stoploss %") / 100
tpPct = input.float(0.5, "Target %") / 100
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
if ta.crossover(fastEMA, slowEMA)
strategy.entry("Long", strategy.long)
if ta.crossunder(fastEMA, slowEMA)
strategy.entry("Short", strategy.short)
// Stoploss and target from the average entry price
longSL = strategy.position_avg_price * (1 - slPct)
longTP = strategy.position_avg_price * (1 + tpPct)
shortSL = strategy.position_avg_price * (1 + slPct)
shortTP = strategy.position_avg_price * (1 - tpPct)
if strategy.position_size > 0
strategy.exit("Long Exit", "Long", stop = longSL, limit = longTP)
if strategy.position_size < 0
strategy.exit("Short Exit", "Short", stop = shortSL, limit = shortTP)
plot(fastEMA, "Fast EMA", color.blue, 2)
plot(slowEMA, "Slow EMA", color.orange, 2)
plot(strategy.position_size > 0 ? longSL : strategy.position_size < 0 ? shortSL : na, "Stoploss", color.red, 2, plot.style_circles)
plot(strategy.position_size > 0 ? longTP : strategy.position_size < 0 ? shortTP : na, "Target", color.green, 2, plot.style_circles)
PineGPT and Pine Script v6
When I launched PineGPT it specialised in Pine Script version 5. Pine Script v6, released by TradingView on 10 December 2024, brought dynamic requests (request.*() calls with symbols that change bar by bar), lazy evaluation of and/or, stricter boolean handling, text size and formatting options, and negative array indices. Older v5 scripts keep working, and the Pine Editor has a built-in converter to v6, but a few scripts need manual fixes after conversion. If the code PineGPT returns starts with //@version=5, you can either run it as is or convert it.
ChatGPT itself has also changed. When this post was written PineGPT needed a ChatGPT Plus (GPT-4) account; since OpenAI’s May 2024 update, free ChatGPT users can also use custom GPTs, though paid plans get higher limits.
Limitations: Check Before You Trade AI Generated Code
- Compile errors: AI models sometimes mix v4, v5 and v6 syntax. Paste any error message back into the chat and ask for a fix.
- Logic errors: code can compile and still differ from your rules, for example calculating the stop from the signal bar close instead of the fill price. Read every line.
- Repainting: watch for
request.security()calls that use future data, and for signals that change on the live bar. - Backtest realism: set commission and slippage in the strategy properties before trusting results.
If you want to learn the language properly rather than rely only on AI, start with my practical approach to TradingView Pine Script programming and creating and backtesting a Pine Script trading strategy. I also wrote about reasons you should not be using ChatGPT for backtesting.
Frequently Asked Questions
Can ChatGPT write Pine Script?
Yes. ChatGPT and custom GPTs like PineGPT can write Pine Script indicators and strategies from a plain English description. The code usually needs testing and small fixes, especially for version-specific syntax.
Is PineGPT free?
PineGPT itself is free to use. You need a ChatGPT account; free accounts can use custom GPTs with usage limits, and paid plans get higher limits.
Does PineGPT support Pine Script v6?
It was built for v5. Ask for v6 in your prompt, or convert the v5 output with the converter in TradingView’s Pine Editor and fix any remaining errors.
How do I add PineGPT code to TradingView?
Open the Pine Editor at the bottom of a TradingView chart, create a new script, paste the code, click Save and then Add to chart. Strategies show their results in the Strategy Tester tab.
Learn by watching: free videos every week
Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

