- OpenBacktesting
- Use indicators in a strategy
Use indicators in a strategy¶
Register formulas in init() through self.ta. Consume their current values in next() only after checking the selected channel's validity. The complete indicator strategy demonstrates EMA, MACD, and composition.
Common recipes¶
During next(), self.average[-1] is the latest value and self.average.valid[-1] says whether it can be consumed. Multi-output indicators require a channel, e.g. self.macd.histogram. Use self.ta.is_crossover(a, b) for a current boolean rather than registering a series inside next().
Avoid future information¶
The full input is available in init(). Use causal calculations; negative shifts or saving a future scalar can leak data. Indicator handles constrain visible history during next() but cannot repair a noncausal function. Arrays created by arithmetic or .s conversions are snapshots; retain handles for dynamic reads.
Confirmed pivots are published after the right-hand window finishes. Anchored formulas require an explicit 0/1 anchor series. Pattern score zero can mean a valid non-event; validity is separate from direction or strength.
Find a formula¶
Every catalog page includes a complete script, parameter descriptions, and output names. Start with EMA, RSI, ATR, or Bollinger Bands.
All shared arguments and handle operations · Custom indicators
