Chande Momentum Oscillator (cmo)

[[cmo]] measures the balance between recent gains and losses on a scale from -100 to +100. You can use it to read momentum intensity, filter signals, or compare several settings in a grid search.

A positive value means bullish moves dominate over the observed window. A negative value means bearish moves dominate. The closer CMO gets to its extremes, the stronger the imbalance between buying pressure and selling pressure. A value near 0 indicates a more mixed market, without a clear dominance over the period.

Block declaration

A strategy can contain multiple [[cmo]] blocks. Each block produces one numeric series: the CMO value.

Examples

Minimal setup

This block computes CMO from the default close source. Since length is omitted, the block uses the default length 20.

[[cmo]]
id = "cmo"

Custom fixed setup

This block uses a custom length value.

[[cmo]]
id     = "cmo"
length = 18

Finding the optimal length

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

[[cmo]]
id           = "cmo"
length.start = 10
length.stop  = 30

Searching for overbought and oversold zones

This example combines the [[cmo]] block with two [[constant]] blocks to optimize overbought and oversold thresholds. The condition becomes true when CMO moves above the overbought threshold or below the oversold threshold.

[[cmo]]
id = "cmo"

[[constant]]
id    = "overbought"
start = 50
stop  = 70

[[constant]]
id    = "oversold"
start = -70
stop  = -50

[[condition]]
id            = "momentum_extreme"
condition     = "cmo > overbought or cmo < oversold"
next_block_id = "..."

Parameters

ParameterDescription
id
 String
 Required
Unique name for the CMO series.
source
 String
 or Array
 Optional
Input series used for the calculation.
Accepted forms: source = "hl2" or source = ["close", "hl2"].
Each value can be either a standard price source (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume) or the id of another indicator.
Default value: "close"
length
 Integer
 Optional
Observation window; must be ≥ 2 when specified.
If length is omitted, the default value is 20.

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(s) used when source only consists of standard prices (open, close, high, low, hl2, hlc3, ohlc4, hlcc4, volume).
If source mixes standard prices and indicator ids, symbol is applied only to combinations based on standard prices.
If source contains only indicator ids, symbol is ignored.
If symbol is omitted, the block inherits the symbol defined in [backtest].
For symbol format, arrays, 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

Use the identifiers below directly in your expressions. The CMO block exposes one numeric series and its length, as well as the input source, symbol, and timeframe.

Assume the block is configured as:

[[cmo]]
id = "cmo"

Then:

VariableDescription
cmo or cmo[0]
Decimal
Current CMO value.
cmo[n]
Decimal
CMO value from n candles ago.
cmo.length
Decimal
Length in use.
cmo.source
String
Input series name.
cmo.symbol
String
Symbol used.
cmo.timeframe
String
Timeframe used.

Notes

  • Numeric variables support arithmetic, comparisons, and logical operators.
  • Text variables are strings intended for equality/inequality checks only.