Strategy Codeinformational intent | 4 min read

How to Generate a TradingView Indicator With AI (Full Walkthrough)

Describe an indicator in plain English and get Pine Script that runs on TradingView. A full worked example, from prompt to chart, with the checks that matter.

Written by

Murali Komanduri

Founder, SkillCandle

Published

August 30, 2026

Updated August 30, 2026

Reviewed by

SkillCandle Editorial Team

Research & Editorial Review

  • Describe the rules precisely and the generated script will match them.
  • Paste into the Pine Editor, save, add to chart. No paid plan needed.
  • Check that something draws on the price pane, not only in the data window.
  • Verify the script stays quiet on bars where your rule should not fire.
  • Compiling is not the same as doing what you meant.

You have an idea for an indicator. Maybe it marks the previous day's high and low, or flags when price breaks a session range with volume behind it. Writing it in Pine Script means learning a language you will otherwise never use.

You no longer have to. Describe it in plain English, get the script, paste it into TradingView. Here is exactly how that goes, using a real example end to end.

Step 1: Describe what you want

The description does most of the work. Here is one that produces a clean result:

Plot the previous day's high and low as horizontal lines that extend across today's session. Colour the high red and the low green. When price closes above the previous day high, put a small green triangle below that bar. When price closes below the previous day low, put a red triangle above the bar. Add an input to turn the triangles off. Show the current values in a small table in the top right.

Notice what it specifies: which levels, how they are drawn, what colour, where the markers sit relative to the bar, which parts are adjustable, and what appears on screen. That is why it comes back right.

Compare it with "show me previous day levels". That produces something, but it will be somebody else's interpretation of your idea.

Step 2: Read what comes back

You get Pine Script. Even without knowing the language, the shape of it is readable:

//@version=6
indicator("Previous Day Range", overlay = true)

showMarkers = input.bool(true, "Show break markers")

// Previous day's completed high and low
[prevHigh, prevLow] = request.security(syminfo.tickerid, "1D", [high[1], low[1]], lookahead = barmerge.lookahead_on)

plot(prevHigh, "Prev Day High", color = color.red,   style = plot.style_linebr)
plot(prevLow,  "Prev Day Low",  color = color.green, style = plot.style_linebr)

breakUp   = ta.crossover(close, prevHigh)
breakDown = ta.crossunder(close, prevLow)

plotshape(showMarkers and breakUp,   style = shape.triangleup,   location = location.belowbar, color = color.green, size = size.tiny)
plotshape(showMarkers and breakDown, style = shape.triangledown, location = location.abovebar, color = color.red,   size = size.tiny)

You can check this against your description without writing code. The colours match. The markers are below and above the bar as asked. showMarkers is the input you requested. [high[1], low[1]] is the previous day rather than today's forming values, which is the detail most hand-written versions get wrong.

Step 3: Put it on your chart

This part takes about thirty seconds and works on the free TradingView plan.

Practice workflow

Adding a script to TradingView

  1. Open any chart on tradingview.com
  2. Click Pine Editor along the bottom of the window
  3. Select the placeholder code that appears and delete all of it
  4. Paste your script
  5. Click Save, give it a name, and confirm
  6. Click Add to chart

If it compiles, it appears immediately. If it does not, the editor shows the error at the bottom with a line number.

Step 4: Check it actually does what you meant

This is the step people skip, and it is the one that matters. A script can compile perfectly and still be wrong.

Does anything appear on the price pane? If the values show in the data window but nothing draws on the chart, the script is computing correctly and displaying to the wrong place. It is a one-line fix and a common one.

Are the levels where you expect? Find yesterday on your chart and confirm the red line sits at yesterday's high. If your indicator has its own scale rather than sharing the price scale, levels can appear wildly off — right-click the price axis and pin the indicator to it.

Does it mark the right bars? Find a bar where price clearly closed above the previous day high and confirm a triangle appears.

Does it stay quiet when it should? This is the check almost nobody does. Find a bar where price poked above the level intraday but closed below it. There should be no marker, because you asked for closes. If a marker appears anyway, the condition is looser than you described — and you would never notice from the signals that did fire.

When something goes wrong

Three problems account for most of it.

It says an identifier is unknown. The generator produced a function name that does not exist in Pine. Search the exact name in TradingView's Pine reference. If it is not there, regenerating usually fixes it faster than editing, because the whole approach needs replacing rather than the line.

It works for weeks and then errors mid-chart. Usually a loop over an empty list. Scripts that manage collections of levels or zones can build cleanly and then fail hundreds of bars later, the first time the list happens to be empty. The message mentions an index out of bounds. Regenerate and mention that empty cases must be handled.

You get every alert twice. Two different alert mechanisms both got included. Harmless, and worth fixing before you rely on notifications.

Where AI stops helping

It writes the script. It cannot tell you whether the script is worth trading.

We tested a session range break strategy that compiled with zero errors and did precisely what its description said. It finished with a profit factor of 0.939 — slightly worse than breaking even — because the rule closing positions at the session end cut winners short at values like +119.2 while losers still ran the full stop distance. The code was correct. The idea was lopsided.

No generator catches that, because it is not a property of the code. It only shows up when you test the rules, and then when you practise reading them on charts you have not already studied — committing to a decision before you can see the outcome, and finding out where your judgement was off rather than where your syntax was.

Review checklist

Before you trade a generated script

  • It compiles with no errors
  • Something visible appears on the price pane
  • Levels line up with the bars they describe
  • It fires on the bars you expected
  • It stays silent on the near-misses you did not want
  • For strategies, the exit reasons in the trade list match what you intended
  • You have watched it behave on history you had not already studied

Try it

SkillCandle's Algo Studio takes a description like the one above and returns the full Pine v6 source, validated before you see it. Copy it or download the .pine file, paste it into TradingView, and it runs. Free during the open beta, and you always get the whole source rather than a locked script.

Replay strategy code setups inside SkillCandle

Move from reading about the setup to actually practicing it with a partial chart, replay reveal, and tracked review notes.

Murali Komanduri

Murali builds SkillCandle around replay-based trading practice, chart review, and measurable improvement instead of vague market content.

Experience: Product-led trading workflow design, replay systems, review-first practice tooling, and public educational content for chart practice.

View author page

Questions traders ask about this topic

Can AI write Pine Script that actually works?

Yes. Describing an indicator in plain English and getting working Pine Script is reliable today for most retail setups, including moving averages, breakouts, session levels, order blocks and full strategies with stops and targets. What still needs your attention is checking that the script does what you meant, which is a different question from whether it compiles.

How do I add generated Pine Script to TradingView?

Open any chart, click Pine Editor at the bottom of the screen, select all the placeholder code and delete it, paste your script, click Save and give it a name, then click Add to chart. It appears immediately. You do not need a paid TradingView plan.

Do I need to know how to code?

No, but you do need to describe your rules precisely. The generator turns your description into code faithfully, so anything vague in the description becomes a guess in the script. Being specific about entries, exits and what you want drawn matters more than any coding knowledge.

What if the generated script does not work?

Check three things in order. Did it compile without errors. Does anything appear on the price pane rather than only in the data window. Does it mark the bars you expected. Most problems are the third one, and they are fixed by making your description more specific rather than by editing code.

Is there a free AI Pine Script generator?

SkillCandle's Algo Studio is free during the open beta and returns the full source, which you copy or download and paste into TradingView. Nothing is locked behind a compiled black box.

Keep building the cluster