FuturaDevelopers

First steps

The anatomy of a NeuroScript indicator and your first script.

Every NeuroScript indicator follows the same structure: a version line, the indicator declaration and the calculation + plotting.

Anatomy of a script

//@version=6
indicator("My Average", shorttitle="MA", overlay=true)

length = input.int(14, "Length")
avg = ta.sma(close, length)

plot(avg, "SMA", color=color.blue)
  1. //@version=6 — declares the language version. Always the first line.
  2. indicator(...) — sets the name, short title and whether the indicator is drawn over the price chart (overlay=true) or in a separate pane (overlay=false).
  3. Calculationta.sma(close, length) computes the simple moving average of the close.
  4. plot(...) — draws the result on the chart.

Use overlay=true for indicators on the same scale as price (averages, bands). Use overlay=false for oscillators (RSI, MACD), which get their own pane.

Your first indicator

An average that changes color with the trend — green when price is above, red when below:

//@version=6
indicator("Trend Average", shorttitle="TA", overlay=true)

length = input.int(20, "Length", minval=1)
avg = ta.sma(close, length)

col = close >= avg ? color.green : color.red
plot(avg, "Average", color=col, linewidth=2)
  • input.int(...) creates a length field editable by the user.
  • close >= avg ? color.green : color.red is a ternary: it picks the color based on the condition.
  • linewidth=2 thickens the line.

Accessing history

Every series (like close) keeps the values of previous candles. Use [n] to look n candles back:

variacao = close - close[1]   // difference from the previous candle

Where to write it

You write NeuroScript in the chart's indicator editor, or generate a starting point with NeuroChart AI (natural language) and tweak the code. The result appears on the chart on every candle.

Next

On this page