strategy · own pane · open source
Chande Momentum Strategy
Running…
Loading chart…
About
Chande Momentum Oscillator trend strategy: long when the CMO crosses above zero (momentum turns bullish), exit on the cross below zero.
- CMO ranges from -100 to +100 and is more responsive than Stochastic.
- Combine with a trend filter for confirmation.
- 14-period is the canonical CMO lookback.
Source code
//@version=5
strategy("Chande Momentum Strategy", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05)
len = input.int(14, "CMO Length", minval=5, maxval=50, step=1)
stopPct = input.float(2, "Stop Loss %", minval=0.5, maxval=10, step=0.1)
tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
up = math.max(close - close[1], 0)
dn = math.max(close[1] - close, 0)
sumUp = math.sum(up, len)
sumDn = math.sum(dn, len)
cmo = 100 * (sumUp - sumDn) / (sumUp + sumDn)
longSignal = strategy.position_size == 0 and ta.crossover(cmo, 0)
exitSignal = strategy.position_size > 0 and ta.crossunder(cmo, 0)
if longSignal
strategy.entry("Long", strategy.long)
if strategy.position_size > 0
strategy.exit("Risk", stop=stopPct > 0 ? strategy.position_avg_price * (1 - stopPct / 100) : na, limit=tpPct > 0 ? strategy.position_avg_price * (1 + tpPct / 100) : na)
if exitSignal
strategy.close("Long", comment="CMO cross down")
hline(50, "Strong Up", color=color.gray, linestyle=hline.style_dashed)
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
hline(-50, "Strong Down", color=color.gray, linestyle=hline.style_dashed)
p_Chande_MOM = plot(cmo, "Chande MOM", color=color.blue, linewidth=2)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=color.green, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=color.red, text="X")
alertcondition(longSignal, "Chande long entry", "CMO crossed above zero")
alertcondition(exitSignal, "Chande exit", "CMO crossed below zero")
No comments yet.
Sign in to comment.