stratester.com

Indicators · condition block

Volatility (average candle range)

The volatility block averages the high-to-low range of the last N candles, each as a percentage of its close, and compares that average with a threshold. It is a simple, transparent volatility gauge.

How the engine evaluates it

For each candle the engine computes (high − low) / close × 100. The block averages that value over the last N candles and compares it strictly with your threshold.

Unlike ATR it ignores gaps between candles and uses a plain average rather than Wilder smoothing, so it reacts to a quiet or wild stretch as soon as it enters the window.

Formula
range %[t] = (high − low) / close × 100
volatility = average of range % over the last N candles

Botscript syntax

In the Lab you pick this block from the Indicators group and fill in its fields. In the code view the same condition is written like this:

volatility(24) > 1.5%
volatility(24) < 0.6%

Settings

SettingValuesDefaultNotes
Comparison>, <>—
Threshold0 – 1,000%1.5%—
Lookback1 – 1,00024—
Timeframethe run's candles, or 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1wthe run's candlesOptional. At least the run's candle size and a whole multiple of it.

On a higher timeframe

Add a timeframe at the end to read Volatility from bigger candles than the run uses, for example volatility(20) > 2% on 1d. The engine builds those candles from the run's own candles (UTC, weeks start on Monday) and evaluates the block only on candles that have closed, so there is no look-ahead. Lengths and lookbacks count the bigger candles.

Volatility is a state on a higher timeframe: the result from the last completed bigger candle holds on every run candle until the next one closes.

The timeframe must be at least the run's candle size and a whole multiple of it; otherwise the run stops with an error and is not charged. Multi-timeframe conditions covers the details, including warm-up.

How traders use it

  • Squeeze setups: volatility(48) < 0.5% before a breakout entry.
  • Risk-off filter: skip entries while volatility(24) > 3%.

Example bot

botscript
bot "Quiet Then Breakout"

when volatility(48) < 0.6% and breakout high 48
then buy 100%

when pnl down 4%
then sell 100%
  • Buys a 48-candle breakout that comes out of a quiet stretch.
  • Cuts the trade 4% below the average entry.

Pitfalls

  • The threshold depends on the candle size.
  • A single huge candle lifts the average for N candles.

Volatility: frequently asked questions

Is this standard deviation of returns?

No. It is the average high-to-low range of the candles as a percentage of their close, which is easier to reason about on a chart.

Does it include gaps?

No. Use ATR if gaps between candles should count.

What is a normal value for Bitcoin?

It depends on the candle size and the period. Look at a few runs on your timeframe before picking a threshold.

Can I require low volatility?

Yes: volatility(24) < 0.8%.

Simulated results are hypothetical. They include only the fee and slippage you set on the bot, not every real-world cost or market condition, and past performance does not guarantee future results. Nothing here is financial advice.