Practical guide
Pine runs once for each historical bar and recalculates on ticks of an open bar. close is a series, not a single constant. ta.sma(close, 20) calculates a rolling average. close[1] is the previous bar. Use barstate.isconfirmed when a decision should only use closed bars. This avoids a changing open-bar signal but does not fix all repainting issues, especially higher-timeframe requests.
Verification steps
- Read the related source and write down data assumptions.
- Test in an isolated environment with public data.
- Check timeouts, missing data and open candles.
- Log events without credentials.
Common mistakes
Confusing seconds with milliseconds, treating open candles as confirmed signals, and unbounded retries. Stop and report an error when inputs are invalid.
References
https://www.tradingview.com/pine-script-docs/ https://developers.binance.com/ https://bybit-exchange.github.io/docs/v5/intro
FAQ
Is the source code free?
Yes. Examples use the MIT license and can be modified and shared with attribution.
Does this guarantee profit?
No. This is educational material. Independently validate assumptions, costs and risks.