Chande Momentum Oscillator Enhanced For ThinkOrSwim

antwerks

Well-known member
VIP
VIP Enthusiast
The RSI is awesome, but the Chande Momentum Oscillator is awesomer!!! The Chande Momentum Oscillator (CMO) is a technical analysis indicator created by Tushar Chande that measures pure momentum in a security’s price, oscillating between +100 and -100.
It’s similar in spirit to RSI, but instead of comparing average gains and losses, it adds up all price changes (up and down) over a period and divides the net change by the total absolute changes — giving a percentage measure of net momentum.

In the chart below of TSLA, I have marked areas in the dashed lines of an aggressive entry/exit and solid lines a more conservative entry/exit examples using the supply and demand zones as final criterias
shared chart link: https://tos.mx/!CadtYHzG
Script for this indicator can found below
1754978114900.png

mod note:

Oscillator Formula
For a chosen period n:

CMO=100×Sum of Gains over n−Sum of Losses

Where the formula calculates the Sum of Gains = sum of all positive price changes during n and divides by the Sum of Losses = sum of absolute values of all negative price changes during n.

Key Characteristics
  1. Bounded Range:
+100 = extreme upward momentum (all periods were up)

-100 = extreme downward momentum (all periods were down)

0 = equal gains and losses over the period
  1. Faster than RSI:
The CMO doesn’t smooth data as much as the standard RSI, so it reacts, I think, more sharply to price changes.
  1. Interpretation Zones:
Above +50 → strong bullish momentum

Below -50 → strong bearish momentum

Crosses above 0 → momentum turning bullish

Crosses below 0 → momentum turning bearish
  1. Overbought/Oversold:
+50 to +100 can be overbought
-50 to -100 can be oversold
But thresholds can be adjusted depending on volatility.

How I use it to trade:
  • Trend Confirmation: If CMO is above zero during an uptrend, momentum is aligned.
  • Overbought/Oversold Reversals: Look for extreme readings followed by a cross back toward zero.
  • Divergence: When price makes new highs/lows but CMO fails to confirm.
Code:
# ------------------------------------------------
# adapted from Charles Schwab TOS
# Enhanced Chande Momentum Oscillator with Bias & Slope Alerts
# v.1 08/12/2025 enhanced by antwerks
# ------------------------------------------------
declare lower;

input length = 20;
input neutralZone = 5;  # Near zero tolerance

def inc = Max(close - close[1], 0);
def dec = Max(close[1] - close, 0);
def sumInc = Sum(inc, length);
def sumDec = Sum(dec, length);
def CMOvalue = if (sumInc + sumDec) == 0 then 0 else (sumInc - sumDec) / (sumInc + sumDec) * 100;

plot CMO = CMOvalue;
CMO.SetLineWeight(2);
CMO.AssignValueColor(
    if CMOvalue > neutralZone then Color.GREEN
    else if CMOvalue < -neutralZone then Color.RED
    else Color.YELLOW
);

plot ZeroLine = 0; ZeroLine.SetDefaultColor(Color.GRAY);
plot UpperLevel = 50; UpperLevel.SetDefaultColor(Color.GRAY);
plot LowerLevel = -50; LowerLevel.SetDefaultColor(Color.GRAY);

# --- Trend slope detection ---
def slopeUp = CMOvalue > CMOvalue[1];
def slopeDown = CMOvalue < CMOvalue[1];

# --- Labels based on momentum + slope ---
AddLabel(
    yes,
    if CMOvalue >= 50 then "VERY BULLISH"
    else if CMOvalue > 0 and slopeUp then "BULLISH"
    else if CMOvalue > 0 and slopeDown then "BULLISH BUT TRENDING DOWN"
    else if CMOvalue <= -50 then "STRONGLY BEARISH"
    else if CMOvalue < 0 and slopeDown then "BEARISH"
    else if CMOvalue < 0 and slopeUp then "BEARISH BUT TRENDING UP"
    else "NEUTRAL",
    if CMOvalue >= 50 then Color.DARK_GREEN
    else if CMOvalue > 0 and slopeUp then Color.GREEN
    else if CMOvalue > 0 and slopeDown then Color.ORANGE
    else if CMOvalue <= -50 then Color.RED
    else if CMOvalue < 0 and slopeDown then Color.RED
    else if CMOvalue < 0 and slopeUp then Color.CYAN
    else Color.YELLOW
);

# --- Alerts ---
Alert(CMOvalue > 0 and slopeDown, "Bullish but trending down", Alert.BAR, Sound.Chimes);
Alert(CMOvalue < 0 and slopeUp, "Bearish but trending up", Alert.BAR, Sound.Bell);
 
Last edited by a moderator:
The RSI is awesome, but the Chande Momentum Oscillator is awesomer!!! The Chande Momentum Oscillator (CMO) is a technical analysis indicator created by Tushar Chande that measures pure momentum in a security’s price, oscillating between +100 and -100.
It’s similar in spirit to RSI, but instead of comparing average gains and losses, it adds up all price changes (up and down) over a period and divides the net change by the total absolute changes — giving a percentage measure of net momentum.
Oscillator Formula
For a chosen period n:

CMO=100×Sum of Gains over n−Sum of Losses

Where the formula calculates the Sum of Gains = sum of all positive price changes during n and divides by the Sum of Losses = sum of absolute values of all negative price changes during n.

Key Characteristics
  1. Bounded Range:
+100 = extreme upward momentum (all periods were up)

-100 = extreme downward momentum (all periods were down)

0 = equal gains and losses over the period
  1. Faster than RSI:
The CMO doesn’t smooth data as much as the standard RSI, so it reacts, I think, more sharply to price changes.
  1. Interpretation Zones:
Above +50 → strong bullish momentum

Below -50 → strong bearish momentum

Crosses above 0 → momentum turning bullish

Crosses below 0 → momentum turning bearish
  1. Overbought/Oversold:
+50 to +100 can be overbought
-50 to -100 can be oversold
But thresholds can be adjusted depending on volatility.

How I use it to trade:
  • Trend Confirmation: If CMO is above zero during an uptrend, momentum is aligned.
  • Overbought/Oversold Reversals: Look for extreme readings followed by a cross back toward zero.
  • Divergence: When price makes new highs/lows but CMO fails to confirm.
https://tos.mx/!CadtYHzG
In the chart below of TSLA, I have marked areas in the dashed lines of an aggressive entry/exit and solid lines a more conservative entry/exit examples using the supply and demand zones as final criterias
View attachment 25450

Another great post from @antwerks!!! Super clear breakdown of CMO and the example makes it click. Thanks for sharing!
 
The RSI is awesome, but the Chande Momentum Oscillator is awesomer!!! The Chande Momentum Oscillator (CMO) is a technical analysis indicator created by Tushar Chande that measures pure momentum in a security’s price, oscillating between +100 and -100.
It’s similar in spirit to RSI, but instead of comparing average gains and losses, it adds up all price changes (up and down) over a period and divides the net change by the total absolute changes — giving a percentage measure of net momentum.
Oscillator Formula
For a chosen period n:

CMO=100×Sum of Gains over n−Sum of Losses

Where the formula calculates the Sum of Gains = sum of all positive price changes during n and divides by the Sum of Losses = sum of absolute values of all negative price changes during n.

Key Characteristics
  1. Bounded Range:
+100 = extreme upward momentum (all periods were up)

-100 = extreme downward momentum (all periods were down)

0 = equal gains and losses over the period
  1. Faster than RSI:
The CMO doesn’t smooth data as much as the standard RSI, so it reacts, I think, more sharply to price changes.
  1. Interpretation Zones:
Above +50 → strong bullish momentum

Below -50 → strong bearish momentum

Crosses above 0 → momentum turning bullish

Crosses below 0 → momentum turning bearish
  1. Overbought/Oversold:
+50 to +100 can be overbought
-50 to -100 can be oversold
But thresholds can be adjusted depending on volatility.

How I use it to trade:
  • Trend Confirmation: If CMO is above zero during an uptrend, momentum is aligned.
  • Overbought/Oversold Reversals: Look for extreme readings followed by a cross back toward zero.
  • Divergence: When price makes new highs/lows but CMO fails to confirm.
https://tos.mx/!CadtYHzG
In the chart below of TSLA, I have marked areas in the dashed lines of an aggressive entry/exit and solid lines a more conservative entry/exit examples using the supply and demand zones as final criterias
View attachment 25450
Your chart looks very interesting, but when I use the link, my chart looks nothing like yours. Do you mind posting the code?
 
Your chart looks very interesting, but when I use the link, my chart looks nothing like yours. Do you mind posting the code?
Sorry I am guilty of posting charts where I have made personal additions that are not coded. The colors and the “SUPPLY” and the “DEMAND “ wide bands are hand drawn off historical chart fail to drop and fail to increase zones that I have witnessed and the GEX infor I get off of BarChart.com
 
Your chart looks very interesting, but when I use the link, my chart looks nothing like yours. Do you mind posting the code?
When I get back in front of my computer I can send something that is just as good and it will be automatic
 
Your chart looks very interesting, but when I use the link, my chart looks nothing like yours. Do you mind posting the code?
Here is a Demand and Supply zone auto-calculated for you and is about as acurrate as they come- you will not be sorry. You will see price hit and bounce off these "zones" like magic and you can set your buys and sells and stops to this like religion. You can see the tests and retests and breakouts at these bars that are already there for you - it is a good visual check for resistance and support!!!
https://tos.mx/!XWqlzW2v
1755822420582.png
 
Your chart looks very interesting, but when I use the link, my chart looks nothing like yours. Do you mind posting the code?
Combine the demand supply code above with the QTA volume profile for even more accurate price stages - I drew the white lines to show where the price action zones are and where volume gets stronger and weaker- weak volume is like an empty highway where you can cross very easily!!! heavy trafic (lots of volume) is choppy and difficult to move rapidly... if you get me drift. (no pun intended ;) ) These areas correlate very well to open interest and gamma levels by the way...
https://tos.mx/!Kj5lye6L
1755823341307.png
 
Last edited:
Combine the demand supply code above with the QTA volume profile for even more accurate price stages - I drew the white lines to show where the price action zones are and where volume gets stronger and weaker- weak volume is like an empty highway where you can cross very easily!!! heavy trafic (lots of volume) is choppy and difficult to move rapidly... if you get me drift. (no pun intended ;) ) These areas correlate very well to open interest and gamma levels by the way...
https://tos.mx/!Kj5lye6L
View attachment 25530
Thanks. Looks useful.
 
@antwerks
“Can you make a scan script for a green candle crossing up a resistance line?”
you can but TOS is mainly binary so you will have to be somewhat specific or use ranges to find your resistance or supports - In this instance we will define Green Candle as a candle that is considered green if the close is greater than the open (close > open). Define a Resistance Line as resistance that is the highest high over a user-defined lookback period (e.g., 20 bars), representing a key level to break through. As a Crossover the scan will check if the current candle’s close crosses above this resistance level, comparing the current close to the previous close relative to the resistance. Scan Compatibility will be the script using plot to output 1 when the condition is met, suitable for the TOS "Scan" tab.

Code:
# Green Candle Crossing Resistance Scan
# Created by antwerks
# Date: August 23, 2025

# User input for resistance lookback period
input lookbackPeriod = 20;

# Define resistance as the highest high over the lookback period
def resistance = Highest(high, lookbackPeriod)[1];

# Define a green candle (close > open)
def isGreenCandle = close > open;

# Check for crossover: current close crosses above previous resistance
def crossover = close > resistance and close[1] <= resistance;

# Plot 1 if conditions are met, 0 otherwise
plot scan = if isGreenCandle and crossover then 1 else 0;
 
Last edited by a moderator:
The RSI is awesome, but the Chande Momentum Oscillator is awesomer!!! The Chande Momentum Oscillator (CMO) is a technical analysis indicator created by Tushar Chande that measures pure momentum in a security’s price, oscillating between +100 and -100.
It’s similar in spirit to RSI, but instead of comparing average gains and losses, it adds up all price changes (up and down) over a period and divides the net change by the total absolute changes — giving a percentage measure of net momentum.

In the chart below of TSLA, I have marked areas in the dashed lines of an aggressive entry/exit and solid lines a more conservative entry/exit examples using the supply and demand zones as final criterias
shared chart link: https://tos.mx/!CadtYHzG
Script for this indicator can found below
View attachment 25450
mod note:


Oscillator Formula
For a chosen period n:

CMO=100×Sum of Gains over n−Sum of Losses

Where the formula calculates the Sum of Gains = sum of all positive price changes during n and divides by the Sum of Losses = sum of absolute values of all negative price changes during n.

Key Characteristics
  1. Bounded Range:
+100 = extreme upward momentum (all periods were up)

-100 = extreme downward momentum (all periods were down)

0 = equal gains and losses over the period
  1. Faster than RSI:
The CMO doesn’t smooth data as much as the standard RSI, so it reacts, I think, more sharply to price changes.
  1. Interpretation Zones:
Above +50 → strong bullish momentum

Below -50 → strong bearish momentum

Crosses above 0 → momentum turning bullish

Crosses below 0 → momentum turning bearish
  1. Overbought/Oversold:
+50 to +100 can be overbought
-50 to -100 can be oversold
But thresholds can be adjusted depending on volatility.

How I use it to trade:
  • Trend Confirmation: If CMO is above zero during an uptrend, momentum is aligned.
  • Overbought/Oversold Reversals: Look for extreme readings followed by a cross back toward zero.
  • Divergence: When price makes new highs/lows but CMO fails to confirm.
Code:
# ------------------------------------------------
# adapted from Charles Schwab TOS
# Enhanced Chande Momentum Oscillator with Bias & Slope Alerts
# v.1 08/12/2025 enhanced by antwerks
# ------------------------------------------------
declare lower;

input length = 20;
input neutralZone = 5;  # Near zero tolerance

def inc = Max(close - close[1], 0);
def dec = Max(close[1] - close, 0);
def sumInc = Sum(inc, length);
def sumDec = Sum(dec, length);
def CMOvalue = if (sumInc + sumDec) == 0 then 0 else (sumInc - sumDec) / (sumInc + sumDec) * 100;

plot CMO = CMOvalue;
CMO.SetLineWeight(2);
CMO.AssignValueColor(
    if CMOvalue > neutralZone then Color.GREEN
    else if CMOvalue < -neutralZone then Color.RED
    else Color.YELLOW
);

plot ZeroLine = 0; ZeroLine.SetDefaultColor(Color.GRAY);
plot UpperLevel = 50; UpperLevel.SetDefaultColor(Color.GRAY);
plot LowerLevel = -50; LowerLevel.SetDefaultColor(Color.GRAY);

# --- Trend slope detection ---
def slopeUp = CMOvalue > CMOvalue[1];
def slopeDown = CMOvalue < CMOvalue[1];

# --- Labels based on momentum + slope ---
AddLabel(
    yes,
    if CMOvalue >= 50 then "VERY BULLISH"
    else if CMOvalue > 0 and slopeUp then "BULLISH"
    else if CMOvalue > 0 and slopeDown then "BULLISH BUT TRENDING DOWN"
    else if CMOvalue <= -50 then "STRONGLY BEARISH"
    else if CMOvalue < 0 and slopeDown then "BEARISH"
    else if CMOvalue < 0 and slopeUp then "BEARISH BUT TRENDING UP"
    else "NEUTRAL",
    if CMOvalue >= 50 then Color.DARK_GREEN
    else if CMOvalue > 0 and slopeUp then Color.GREEN
    else if CMOvalue > 0 and slopeDown then Color.ORANGE
    else if CMOvalue <= -50 then Color.RED
    else if CMOvalue < 0 and slopeDown then Color.RED
    else if CMOvalue < 0 and slopeUp then Color.CYAN
    else Color.YELLOW
);

# --- Alerts ---
Alert(CMOvalue > 0 and slopeDown, "Bullish but trending down", Alert.BAR, Sound.Chimes);
Alert(CMOvalue < 0 and slopeUp, "Bearish but trending up", Alert.BAR, Sound.Bell);
Thank you Antwerks! Love the oscillator. By the way, how are the vertical lines (Red/Green) generated on the lower portion of the grid. My grid is not showing it. Also, is it possible for you to share the upper version of your grid, showing the Supply and Demand lines. Appreciate it!
 
Thank you Antwerks! Love the oscillator. By the way, how are the vertical lines (Red/Green) generated on the lower portion of the grid. My grid is not showing it. Also, is it possible for you to share the upper version of your grid, showing the Supply and Demand lines. Appreciate it!
The vert lines are repainting and use them as past references for retest against supply and demand https://tos.mx/!JpQSyIEs
https://tos.mx/!QrnKdCCc
the supply and demand is one of my favorite
 
The RSI is awesome, but the Chande Momentum Oscillator is awesomer!!! The Chande Momentum Oscillator (CMO) is a technical analysis indicator created by Tushar Chande that measures pure momentum in a security’s price, oscillating between +100 and -100.
It’s similar in spirit to RSI, but instead of comparing average gains and losses, it adds up all price changes (up and down) over a period and divides the net change by the total absolute changes — giving a percentage measure of net momentum.

In the chart below of TSLA, I have marked areas in the dashed lines of an aggressive entry/exit and solid lines a more conservative entry/exit examples using the supply and demand zones as final criterias
shared chart link: https://tos.mx/!CadtYHzG
Script for this indicator can found below
View attachment 25450
mod note:


Oscillator Formula
For a chosen period n:

CMO=100×Sum of Gains over n−Sum of Losses

Where the formula calculates the Sum of Gains = sum of all positive price changes during n and divides by the Sum of Losses = sum of absolute values of all negative price changes during n.

Key Characteristics
  1. Bounded Range:
+100 = extreme upward momentum (all periods were up)

-100 = extreme downward momentum (all periods were down)

0 = equal gains and losses over the period
  1. Faster than RSI:
The CMO doesn’t smooth data as much as the standard RSI, so it reacts, I think, more sharply to price changes.
  1. Interpretation Zones:
Above +50 → strong bullish momentum

Below -50 → strong bearish momentum

Crosses above 0 → momentum turning bullish

Crosses below 0 → momentum turning bearish
  1. Overbought/Oversold:
+50 to +100 can be overbought
-50 to -100 can be oversold
But thresholds can be adjusted depending on volatility.

How I use it to trade:
  • Trend Confirmation: If CMO is above zero during an uptrend, momentum is aligned.
  • Overbought/Oversold Reversals: Look for extreme readings followed by a cross back toward zero.
  • Divergence: When price makes new highs/lows but CMO fails to confirm.
Code:
# ------------------------------------------------
# adapted from Charles Schwab TOS
# Enhanced Chande Momentum Oscillator with Bias & Slope Alerts
# v.1 08/12/2025 enhanced by antwerks
# ------------------------------------------------
declare lower;

input length = 20;
input neutralZone = 5;  # Near zero tolerance

def inc = Max(close - close[1], 0);
def dec = Max(close[1] - close, 0);
def sumInc = Sum(inc, length);
def sumDec = Sum(dec, length);
def CMOvalue = if (sumInc + sumDec) == 0 then 0 else (sumInc - sumDec) / (sumInc + sumDec) * 100;

plot CMO = CMOvalue;
CMO.SetLineWeight(2);
CMO.AssignValueColor(
    if CMOvalue > neutralZone then Color.GREEN
    else if CMOvalue < -neutralZone then Color.RED
    else Color.YELLOW
);

plot ZeroLine = 0; ZeroLine.SetDefaultColor(Color.GRAY);
plot UpperLevel = 50; UpperLevel.SetDefaultColor(Color.GRAY);
plot LowerLevel = -50; LowerLevel.SetDefaultColor(Color.GRAY);

# --- Trend slope detection ---
def slopeUp = CMOvalue > CMOvalue[1];
def slopeDown = CMOvalue < CMOvalue[1];

# --- Labels based on momentum + slope ---
AddLabel(
    yes,
    if CMOvalue >= 50 then "VERY BULLISH"
    else if CMOvalue > 0 and slopeUp then "BULLISH"
    else if CMOvalue > 0 and slopeDown then "BULLISH BUT TRENDING DOWN"
    else if CMOvalue <= -50 then "STRONGLY BEARISH"
    else if CMOvalue < 0 and slopeDown then "BEARISH"
    else if CMOvalue < 0 and slopeUp then "BEARISH BUT TRENDING UP"
    else "NEUTRAL",
    if CMOvalue >= 50 then Color.DARK_GREEN
    else if CMOvalue > 0 and slopeUp then Color.GREEN
    else if CMOvalue > 0 and slopeDown then Color.ORANGE
    else if CMOvalue <= -50 then Color.RED
    else if CMOvalue < 0 and slopeDown then Color.RED
    else if CMOvalue < 0 and slopeUp then Color.CYAN
    else Color.YELLOW
);

# --- Alerts ---
Alert(CMOvalue > 0 and slopeDown, "Bullish but trending down", Alert.BAR, Sound.Chimes);
Alert(CMOvalue < 0 and slopeUp, "Bearish but trending up", Alert.BAR, Sound.Bell);
I get some interesting results when looking at the CMO value, vs. its moving average. Using a fast moving average, like the Laguerre function, gives you a good indication of when the CMO is strong and weak.

Something like the below.

Code:
# ------------------------------------------------
# adapted from Charles Schwab TOS
# Enhanced Chande Momentum Oscillator with Bias & Slope Alerts
# v.1 08/12/2025 enhanced by antwerks
# ------------------------------------------------
declare lower;

input length = 20;
input neutralZone = 5;  # Near zero tolerance
input gamma = 0.70;     # Laguerre gamma

def inc = Max(close - close[1], 0);
def dec = Max(close[1] - close, 0);
def sumInc = Sum(inc, length);
def sumDec = Sum(dec, length);
def CMOvalue = if (sumInc + sumDec) == 0 then 0 else (sumInc - sumDec) / (sumInc + sumDec) * 100;

plot CMO = CMOvalue;
CMO.SetLineWeight(2);
CMO.AssignValueColor(
    if CMOvalue > neutralZone then Color.GREEN
    else if CMOvalue < -neutralZone then Color.RED
    else Color.YELLOW
);

# Laguerre filter
def L0 = (1 - gamma) * CMO + (gamma * L0[1]);
def L1 = (-1 * gamma * L0) + L0[1] + (gamma * L1[1]);
def L2 = (-1 * gamma * L1) + L1[1] + (gamma * L2[1]);
def L3 = (-1 * gamma * L2) + L2[1] + (gamma * L3[1]);

def L_CMO = (L0 + (2 * L1) + (2 * L2) + L3) / 6;

plot Laguerre_CMO = L_CMO;

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
plot UpperLevel = 50;
UpperLevel.SetDefaultColor(Color.GRAY);
plot LowerLevel = -50;
LowerLevel.SetDefaultColor(Color.GRAY);

# --- Trend slope detection ---
def slopeUp = CMOvalue > CMOvalue[1];
def slopeDown = CMOvalue < CMOvalue[1];

# --- Labels based on momentum + slope ---
AddLabel(
    yes,
    if CMOvalue >= 50 then "VERY BULLISH"
    else if CMOvalue > 0 and slopeUp then "BULLISH"
    else if CMOvalue > 0 and slopeDown then "BULLISH BUT TRENDING DOWN"
    else if CMOvalue <= -50 then "STRONGLY BEARISH"
    else if CMOvalue < 0 and slopeDown then "BEARISH"
    else if CMOvalue < 0 and slopeUp then "BEARISH BUT TRENDING UP"
    else "NEUTRAL",
    if CMOvalue >= 50 then Color.DARK_GREEN
    else if CMOvalue > 0 and slopeUp then Color.GREEN
    else if CMOvalue > 0 and slopeDown then Color.ORANGE
    else if CMOvalue <= -50 then Color.RED
    else if CMOvalue < 0 and slopeDown then Color.RED
    else if CMOvalue < 0 and slopeUp then Color.CYAN
    else Color.YELLOW
);

# --- Alerts ---
Alert(CMOvalue > 0 and slopeDown, "Bullish but trending down", Alert.BAR, Sound.Chimes);
Alert(CMOvalue < 0 and slopeUp, "Bearish but trending up", Alert.BAR, Sound.Bell);
 
I get some interesting results when looking at the CMO value, vs. its moving average. Using a fast moving average, like the Laguerre function, gives you a good indication of when the CMO is strong and weak.

Something like the below.

Code:
# ------------------------------------------------
# adapted from Charles Schwab TOS
# Enhanced Chande Momentum Oscillator with Bias & Slope Alerts
# v.1 08/12/2025 enhanced by antwerks
# ------------------------------------------------
declare lower;

input length = 20;
input neutralZone = 5;  # Near zero tolerance
input gamma = 0.70;     # Laguerre gamma

def inc = Max(close - close[1], 0);
def dec = Max(close[1] - close, 0);
def sumInc = Sum(inc, length);
def sumDec = Sum(dec, length);
def CMOvalue = if (sumInc + sumDec) == 0 then 0 else (sumInc - sumDec) / (sumInc + sumDec) * 100;

plot CMO = CMOvalue;
CMO.SetLineWeight(2);
CMO.AssignValueColor(
    if CMOvalue > neutralZone then Color.GREEN
    else if CMOvalue < -neutralZone then Color.RED
    else Color.YELLOW
);

# Laguerre filter
def L0 = (1 - gamma) * CMO + (gamma * L0[1]);
def L1 = (-1 * gamma * L0) + L0[1] + (gamma * L1[1]);
def L2 = (-1 * gamma * L1) + L1[1] + (gamma * L2[1]);
def L3 = (-1 * gamma * L2) + L2[1] + (gamma * L3[1]);

def L_CMO = (L0 + (2 * L1) + (2 * L2) + L3) / 6;

plot Laguerre_CMO = L_CMO;

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
plot UpperLevel = 50;
UpperLevel.SetDefaultColor(Color.GRAY);
plot LowerLevel = -50;
LowerLevel.SetDefaultColor(Color.GRAY);

# --- Trend slope detection ---
def slopeUp = CMOvalue > CMOvalue[1];
def slopeDown = CMOvalue < CMOvalue[1];

# --- Labels based on momentum + slope ---
AddLabel(
    yes,
    if CMOvalue >= 50 then "VERY BULLISH"
    else if CMOvalue > 0 and slopeUp then "BULLISH"
    else if CMOvalue > 0 and slopeDown then "BULLISH BUT TRENDING DOWN"
    else if CMOvalue <= -50 then "STRONGLY BEARISH"
    else if CMOvalue < 0 and slopeDown then "BEARISH"
    else if CMOvalue < 0 and slopeUp then "BEARISH BUT TRENDING UP"
    else "NEUTRAL",
    if CMOvalue >= 50 then Color.DARK_GREEN
    else if CMOvalue > 0 and slopeUp then Color.GREEN
    else if CMOvalue > 0 and slopeDown then Color.ORANGE
    else if CMOvalue <= -50 then Color.RED
    else if CMOvalue < 0 and slopeDown then Color.RED
    else if CMOvalue < 0 and slopeUp then Color.CYAN
    else Color.YELLOW
);

# --- Alerts ---
Alert(CMOvalue > 0 and slopeDown, "Bullish but trending down", Alert.BAR, Sound.Chimes);
Alert(CMOvalue < 0 and slopeUp, "Bearish but trending up", Alert.BAR, Sound.Bell);
There are several strong correlations between CMO and moving averages that can create powerful trading strategies, here are some key correlations identified.
1) CMO-WMA Signal Line Strategy: The most direct correlation is using a Weighted Moving Average (WMA) of the CMO itself as a signal line. When CMO crosses above/below its WMA, it generates buy/sell signals.
2) Laguerre Filter Smoothing: Your code uses a Laguerre filter with gamma = 0.70, which creates a smoothed version of the CMO that acts like an adaptive moving average, reducing false signals while maintaining responsiveness.
3) Momentum-Price Divergence: CMO oscillations often lead price movements, making it an excellent early warning system when combined with price-based moving averages.
4) Trend Strength Confirmation: CMO slope direction (your slopeUp/slopeDown variables) combined with moving average crossovers provides powerful trend confirmation signals.
Some strategy applications could be CMO + Moving Average Crossover Strategy:
1) Enter long when CMO > 0 AND price crosses above its moving average
2) Enter short when CMO < 0 AND price crosses below its moving average
3) Exit when CMO slope reverses (your trending down/up alerts)

A Laguerre-Filtered CMO Strategy might look something like this-

1) Use your L_CMO (Laguerre-filtered CMO) crossovers with the raw CMO as entry signals
2) Combine with price moving average for trend direction filter
3) Your neutralZone = 5 provides excellent noise reduction

A Divergence Strategy could be -
1) Look for CMO making new highs/lows while price moving average shows opposite direction
2) Your slope detection captures these momentum shifts early

The mathematical relationships are that CMO leads moving averages by approximately 1-3 periods due to its momentum-based calculation. Laguerre filter gamma (0.70) creates smoothing equivalent to approximately a 10-period EMA • CMO extreme levels (±50) correlate with moving average trend exhaustion points. But you have to remember the CMO is a fast actor like the RSI so a shorter length is required.

8 Periods instead of 20 (SUGGESTION)

Optimal responsiveness while filtering noise
Works well with Laguerre smoothing (gamma 0.70)
Reliable slope detection for your trend alerts
Matches your neutralZone = 5 threshold effectively
Good for swing trading (2-10 day holds)

Supporting Evidence is the CMO(8) + Laguerre(0.70) is similarly effective smoothing of 11-12 periods. This creates similar responsiveness to RSI(14) but with better momentum detection. Your slope alerts will trigger 1-2 days earlier than standard setups.

Practical Trading could be that 8 periods capture 1.5-2 weeks of price action (perfect for momentum shifts). This reduces false breakouts above/below your ±50 levels and maintains early warning capability for your divergence alerts.

This is a good improvement. I think I would still use the upper and lower levels but use the MA cross overs as validations. I probably would use some upper price action indicators to cross reference and then look to a volume indicator to again validate the moves and the strength of any trends.
1757305098045.png
 
Combine the demand supply code above with the QTA volume profile for even more accurate price stages - I drew the white lines to show where the price action zones are and where volume gets stronger and weaker- weak volume is like an empty highway where you can cross very easily!!! heavy trafic (lots of volume) is choppy and difficult to move rapidly... if you get me drift. (no pun intended ;) ) These areas correlate very well to open interest and gamma levels by the way...
https://tos.mx/!Kj5lye6L
View attachment 25530
These are great. I've been tinkering with different Supply and Demand (as well as Support and Resistance) auto-calculated indicators and I really appreciate you sharing. Even the volume levels will be interesting to track across different time frames. Thanx so much!!
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1002 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top