English · 한국어
Start with a small display tool rather than a trading strategy. This example plots a 20-close simple moving average without assuming a particular asset or ICT pattern.

Add the example in Pine Editor
Paste the code into TradingView’s Pine Editor, save it, and add it to a chart. The default length is 20 and can be changed in settings. The initial bars may not have enough observations to display an average.
//@version=6
indicator("Close average — learning example", overlay=true)
length = input.int(20, "Length", minval=1)
average = ta.sma(close, length)
plot(average, "SMA", color=color.blue)
indicator declares a display script. input.int exposes the length setting, ta.sma calculates the simple average, and plot draws it. This code does not place orders or calculate strategy performance.
When does it recalculate?
Historical calculations generally proceed bar by bar. A realtime indicator recalculates on price updates, so its current-bar average can change. Distinguish this from a confirmed closing value.
Strategies execute at bar close by default, with behavior affected by settings. Do not assume historical bars contain equivalent tick information.
Before adding more features
Display a condition and compare it manually with the chart before adding alerts or a strategy. Higher-timeframe requests, pivot confirmation, and backdated drawings require checks on when the information first became available.
A strategy also needs fees, slippage, fill assumptions, and evaluation periods. A correctly drawn line is not evidence of a profitable rule.
Sources and documentation
www.tradingview.com — execution-model
Continue with common foundations
TradingView guide · Python data workflow · Trading Journal · Position Size & Risk Calculator
Research methods and reporting standards
For education and research. Numerical examples are teaching assumptions unless explicitly identified otherwise. Historical results do not guarantee future performance.