Average True Range
The ATR is widely used to assess the volatility of financial instruments.
Role in the strategy
| Slot | Available | Role |
|---|---|---|
| Entry Point | No | — |
| Entry Rule | Yes | Filters entries by the ATR direction or its level position. |
| Exit Point | No | — |
| Exit Rule | Yes | Triggers exits by the ATR direction or its level position. |
The ATR produces conditions, not order prices. As an entry rule it is ANDed with the entry point and the other entry rules; as an exit rule it is ORed with the other exit rules. See Indicators for the slot semantics.
Logic rules
The indicator offers the standard oscillator rule set, evaluated on the ATR value:
| Rule | Signal is 1 when |
|---|---|
| ATR rises | ATR rose on the previous bar |
| ATR falls | ATR fell on the previous bar |
| ATR is higher than the Level line | ATR is above Level |
| ATR is lower than the Level line | ATR is below Level |
| ATR crosses the Level line upward | ATR crossed above Level from below |
| ATR crosses the Level line downward | ATR crossed below Level from above |
| ATR changes its direction upward | ATR formed a valley (down then up) |
| ATR changes its direction downward | ATR formed a peak (up then down) |
The ATR measures volatility without a direction: the same signal is written for both the long and the short side (noDirectionOscillator).
Parameters
| Parameter | Type | Default | Range | Purpose |
|---|---|---|---|---|
| Period | number | 14 | 1 to 1000 | Bars over which the true range is averaged |
| Level | number | 0.01 | 0 to 10000 | Threshold for the level rules |
Calculation
tech.ATR in engine/indicator-engine/tech.ts computes:
- True Range = the greatest of: High − Low, |High − previous Close|, |Low − previous Close|.
- ATR = simple moving average of the True Range over the Period.
The ATR line is drawn in a separate chart pane and is expressed in price units.
Backtesting
- The rule is evaluated on the previous (closed) bar with the standard dead zone (
SIGMA = 0.000001). - The indicator contributes only a single signal array copied to both directions — it never changes the entry or exit order price.
- An entry happens only when the entry point allows the direction and every entry rule passes; an exit happens when the exit point is reached and any exit rule passes.