Implementing SuperTrend and Trading Its Direction Changes
Summary
The document presents a JavaScript implementation of SuperTrend, built from the Average True Range and upper and lower bands around the candle midpoint. It carries forward band values according to prior closes, then labels the active line as upward or downward. The author compares the calculation with a charting platform’s indicator and observes differences that remain unexplained, so implementations may not match exactly.
A sample futures strategy opens long when the indicator changes from bearish to bullish and opens short on the reverse change, closing the existing position first. The article includes position checks, order handling, and a backtest configuration using 15-minute candles, with a stated parameter setting and single-contract trades. It provides a performance chart but no detailed numerical results in the text. The author notes low capital utilization and advises against treating the example as ready for live trading.
Key ideas
- SuperTrend is calculated from ATR-based bands around the midpoint of each candle.
- The example strategy changes direction when the indicator switches between bullish and bearish states.
- Position and order routines handle opening and closing futures trades around those signals.
- The author reports discrepancies between this calculation and a charting platform’s version.
- The backtest uses a single contract per trade and provides limited performance detail.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.