Demarker Indicator (dm)

The Demarker Indicator measures the balance between rising highs and falling lows from one candle to the next. It produces a series ranging from 0 to 1. The value approaches 1 when rising highs dominate, 0 when falling lows dominate, and 0.5 when the two components are balanced over recent candles.

Only increases in high contribute to the positive component, and only decreases in low contribute to the negative component; all other changes count as zero. length sets the horizon over which the two components are averaged before they are compared. The output represents their relative share, not the total size of the movement. If both components remain zero, the ratio is undefined and the block produces NaN.

Block declaration

A strategy can contain multiple [[dm]] blocks. Each block produces a distinct series identified by its id field.

The [[dm]] block does not expose a source parameter because the Demarker Indicator is always computed from the candle high and low prices.

Examples

Minimal setup

This block uses the default length of 14 and reads high and low from the main symbol and timeframe defined in [backtest].

[[dm]]
id = "dm"

Custom fixed setup

This block uses a custom length value.

[[dm]]
id     = "dm"
length = 21

Finding the optimal length

This block explores a range of values for length to identify the best-performing length.

[[dm]]
id           = "dm"
length.start = 10
length.stop  = 20

Filter with an optimizable threshold

This example uses the Demarker Indicator as a filter. The [[constant]] block defines a threshold named dm_threshold that ranges from 0.6 to 0.8 during the grid search, with one backtest run for each value. On each candle, the [[condition]] block compares dm with this threshold and only lets the strategy continue to the next block when dm > dm_threshold, meaning that the upward component represents a sufficiently large share of the measured movement. Ranking the results then shows which threshold performs best.

[[constant]]
id    = "dm_threshold"
start = 0.6
stop  = 0.8
step  = 0.05

[[dm]]
id = "dm"

[[condition]]
id            = "dm_filter"
condition     = "dm > dm_threshold"
next_block_id = "..."

Dedicated symbol and timeframe

This block uses the daily candles from BINANCE:ETHUSDT. The high and low prices come from this symbol and timeframe, independently of the primary symbol and timeframe defined in [backtest]. See Exchanges, Symbols and Timeframes for alignment rules.

[[dm]]
id        = "dm"
symbol    = "BINANCE:ETHUSDT"
timeframe = "D"

Parameters

ParameterDescription
id
 String
 Required
Unique name identifying the Demarker Indicator series.
length
 Integer
 Optional
Number of candles over which the upward and downward components are averaged; must be ≥ 1 when specified.
If length is omitted, the default value is 14.

Usage:
• Fixed: length = value
• Grid search:
 – length.start = min_value
 – length.stop = max_value
 – length.step = value (optional, default 1)
symbol
 String
 or Array
 Optional
Market symbol from which the Demarker Indicator reads its candles (high and low prices). For symbol format and alignment rules, see Exchanges, Symbols and Timeframes.
timeframe
 String
 or Array
 Optional
Timeframe on which this indicator is computed.
If timeframe is omitted, the computation uses the grid’s main timeframe defined in [backtest].
For accepted formats and timeframe alignment rules, see Exchanges, Symbols and Timeframes.

Available variables

The DM block exposes its numeric series and, as read-only values, its calculation length, input sources, symbol, and timeframe.

Assume the block is configured as follows:

[[dm]]
id = "dm"

Then:

VariableDescription
dm or dm[0]
Decimal
Current Demarker Indicator value.
dm[n]
Decimal
Demarker Indicator value from n candles ago.
dm.length
Decimal
Calculation window used for dm.
dm.high_source
dm.low_source
String
Names of the high and low input series used by the DM series.
dm.symbol
String
Symbol used by the DM series.
dm.timeframe
String
Timeframe used by the DM series.

Notes

  • Numeric variables support arithmetic, comparisons, and logical operators.
  • Text variables are strings intended for equality/inequality checks only.
  • DeMark® is a registered trademark of DeMark Analytics, LLC.