Master this unique momentum oscillator in TradingView's Pinescript for identifying trend strength, overbought/oversold conditions, and divergence.
The Chande Momentum Oscillator (CMO), developed by Tushar Chande, is a technical momentum indicator that measures the difference between the sum of recent gains and the sum of recent losses, divided by the sum of all price changes over a specific period. Unlike other oscillators like RSI or Stochastic which limit their range, CMO ranges from -100 to +100. This broad range allows it to directly quantify pure momentum without being skewed by fixed scaling, providing a clearer picture of trend strength and potential turning points.
In Pinescript, CMO is a valuable tool for traders seeking to identify the underlying directional bias and conviction of price movements, as well as classic overbought/oversold and divergence signals.
The calculation of CMO involves tracking positive and negative price changes:
//@version=5
indicator("My Chande Momentum Oscillator", overlay=false) // overlay=false to plot in a separate pane
// Input for CMO length
length = input.int(9, title="CMO Length", minval=1)
// Calculate CMO value using the built-in function
cmoValue = ta.cmo(close, length)
// Plot the CMO line
plot(cmoValue, title="CMO", color=color.new(color.blue, 0), linewidth=2)
// Plot horizontal lines for overbought and oversold levels
h_overbought = hline(50, "Overbought (+50)", color=color.new(color.red, 0), linestyle=hline.style_dashed)
h_oversold = hline(-50, "Oversold (-50)", color=color.new(color.green, 0), linestyle=hline.style_dashed)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted)
// Fill background between CMO and levels for visual clarity
fill(h_overbought, h_oversold, color=color.new(color.gray, 90))
Typical overbought levels are +50 and oversold levels are -50, though these can be adjusted.
When CMO moves significantly above +50, the asset is considered overbought, indicating strong bullish momentum that might be nearing exhaustion. Conversely, a move significantly below -50 is oversold, suggesting strong bearish momentum that might be nearing exhaustion.
//@version=5
strategy("CMO Overbought/Oversold Strategy", overlay=true)
// Inputs for CMO
length = input.int(9, title="CMO Length", minval=1)
overboughtLevel = input.int(50, title="Overbought Level")
oversoldLevel = input.int(-50, title="Oversold Level")
// Calculate CMO
cmoValue = ta.cmo(close, length)
// Define conditions for entries and exits
// Buy when CMO moves below oversold and then crosses back above it
longCondition = ta.crossunder(cmoValue, oversoldLevel) // CMO goes oversold
longExitCondition = ta.crossover(cmoValue, oversoldLevel) // CMO exits oversold (potential buy)
// Sell when CMO moves above overbought and then crosses back below it
shortCondition = ta.crossover(cmoValue, overboughtLevel) // CMO goes overbought
shortExitCondition = ta.crossunder(cmoValue, overboughtLevel) // CMO exits overbought (potential sell)
// Strategy entries/exits (entry upon exiting extreme zones)
if (longExitCondition)
strategy.entry("Long", strategy.long)
if (shortExitCondition)
strategy.entry("Short", strategy.short)
The zero line in CMO serves as a crucial indicator of momentum bias. A crossover suggests a shift in the short-term trend.
//@version=5
strategy("CMO Zero Line Crossover Strategy", overlay=true)
// Inputs for CMO
length = input.int(9, title="CMO Length", minval=1)
zeroLine = 0
// Calculate CMO
cmoValue = ta.cmo(close, length)
// Define conditions for entries
longSignal = ta.crossover(cmoValue, zeroLine)
shortSignal = ta.crossunder(cmoValue, zeroLine)
// Strategy entries/exits
if (longSignal)
strategy.entry("Long", strategy.long)
if (shortSignal)
strategy.entry("Short", strategy.short)
Divergence between price and CMO can signal potential trend reversals. This occurs when price makes a new high/low, but CMO fails to confirm it, indicating weakening momentum.
//@version=5
indicator("CMO Divergence Scanner", overlay=true)
// Inputs for CMO
length = input.int(9, title="CMO Length", minval=1)
overboughtLevel = input.int(50, title="Overbought Level")
oversoldLevel = input.int(-50, title="Oversold Level")
centerLine = input.int(0, title="Zero Line")
// Calculate CMO
cmoValue = ta.cmo(close, length)
// Plot CMO in a separate pane
plot(cmoValue, "CMO", color.blue)
hline(overboughtLevel, "Overbought (+50)", color.red)
hline(oversoldLevel, "Oversold (-50)", color.green)
hline(centerLine, "Zero Line", color.gray)
// Simple divergence detection (conceptual, robust detection requires advanced pivot logic)
// This is a simplified example focusing on price vs CMO divergence.
// Bullish Divergence (Price lower low, CMO higher low)
bullishDivergence = close[2] > close[1] and close[1] > close and cmoValue[2] < cmoValue[1] and cmoValue[1] < cmoValue
// Bearish Divergence (Price higher high, CMO lower high)
bearishDivergence = close[2] < close[1] and close[1] < close and cmoValue[2] > cmoValue[1] and cmoValue[1] > cmoValue
plotshape(bullishDivergence, title="Bullish Divergence", location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.small)
plotshape(bearishDivergence, title="Bearish Divergence", location=location.abovebar, color=color.new(color.red, 0), style=shape.triangledown, size=size.small)
alertcondition(bullishDivergence, "Bullish CMO Divergence", "Potential bullish reversal based on CMO divergence.")
alertcondition(bearishDivergence, "Bearish CMO Divergence", "Potential bearish reversal based on CMO divergence.")
To get the most from the Chande Momentum Oscillator in Pinescript:
CMO measures the relative strength of positive vs. negative price changes. A strong CMO (near +100 or -100) indicates high conviction in the current direction.
The Chande Momentum Oscillator (CMO) is a unique and highly effective momentum indicator in Pinescript for TradingView. Its distinct calculation provides a clear measure of directional conviction and trend strength, making it valuable for identifying overbought/oversold conditions, shifts across the zero line, and potential reversals through divergence. By understanding its calculation, thoughtfully tuning its parameters, and integrating it strategically within your comprehensive trading approach, you can leverage the CMO to gain deeper insights into market dynamics and enhance your trading decisions.
Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.
This strategy runs in live mode on TradingView, helping you identify potential opportunities.
Get Pinescript Strategy