ta.cmo() - Pine Script Function
ta.cmo()
Section titled “ta.cmo()”Overview
Section titled “Overview”Chande Momentum Oscillator. Calculates the difference between the sum of recent gains and the sum of recent losses and then divides the result by the sum of all price movement over the same period.
Syntax
Section titled “Syntax”ta.cmo(series, length) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| series | series int/float | Series of values to process. |
Returns
Section titled “Returns”Chande Momentum Oscillator.
Remarks
Section titled “Remarks”- na values in the source series are ignored.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("ta.cmo")plot(ta.cmo(close, 5), color=color.yellow)// the same on pinef_cmo(src, length) => float mom = ta.change(src)float sm1 = math.sum((mom >= 0) ? mom : 0.0, length)float sm2 = math.sum((mom >= 0) ? 0.0 : -mom, length) 100 * (sm1 - sm2) / (sm1 + sm2)plot(f_cmo(close, 5))