Author: Copyright � 2006, TrendLaboratory Ltd.
CMO_v1

This technical tool is designed to measure the "momentum" of a financial asset by evaluating the strength and direction of market movement over a specific period. Instead of simply looking at whether a price is going up or down, it attempts to quantify how much pressure the "bulls" (buyers) are exerting compared to the "bears" (sellers).

How the Logic Works

The script operates through a three-step calculation process to determine the current market sentiment:

1. Identifying Movement Intensity The tool first looks at two consecutive points in time. By comparing these points, it calculates the raw change in price. It uses a customizable setting to decide which price point to focus on (such as the closing price, the high/low of the period, or an average of those prices).

2. Separating Bullish vs. Bearish Pressure Once the movement between two points is identified, the script splits that movement into two distinct components:

  • Bullish Strength: It extracts the positive component of the price change.
  • Bearish Strength: It extracts the negative component of the price change.

By doing this, the tool can distinguish between a steady, strong move in one direction and volatile, choppy price action where the price might be fluctuating but not gaining significant ground.

3. Calculating the Final Momentum Score Finally, the script looks back over a user-defined number of periods (the "Length"). It sums up all the Bullish strength and all the Bearish strength over that timeframe.

The final result is expressed as a percentage score:

  • It subtracts the total Bearish strength from the total Bullish strength.
  • It then divides that difference by the total combined strength of both sides.
  • This is multiplied by 100 to create a value that oscillates between -100 and +100.

Interpreting the Results

The final output provides a clear visual representation of market dominance:

  • Positive Scores: Indicate that the buyers (bulls) have been more aggressive over the chosen period. The higher the number, the stronger the upward momentum.
  • Negative Scores: Indicate that the sellers (bears) have been more dominant. The lower the number, the stronger the downward momentum.
  • Near Zero: Suggests a neutral market where neither side has gained a clear advantage, or where opposing forces are canceling each other out.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
CMO_v1
//+------------------------------------------------------------------+
//|                                                       CMO_v1.mq4 |
//|                           Copyright © 2006, TrendLaboratory Ltd. |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                       E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

#property indicator_separate_window
#property indicator_buffers   1
#property indicator_color1    LightBlue
#property indicator_width1    2
#property indicator_level1    0
#property indicator_level2   50
#property indicator_level3  -50 
#property indicator_maximum  100
#property indicator_minimum -100 
//---- input parameters
extern int       Length = 14; // Period of evaluation
extern int       Price  =  0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted

//---- buffers
double CMO[];
double Bulls[];
double Bears[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,CMO);
   SetIndexBuffer(1,Bulls);
   SetIndexBuffer(2,Bears);
//---- name for DataWindow and indicator subwindow label
   string short_name="CMO("+Length+","+Price+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"CMO");
//----
   SetIndexDrawBegin(0,Length);
  
   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int      shift, limit, counted_bars=IndicatorCounted();
   double   Price1, Price2;
//---- 
   if ( counted_bars < 0 ) return(-1);
   if ( counted_bars ==0 ) limit=Bars-Length-1;
   if ( counted_bars < 1 ) 
   for(int i=1;i<Length;i++) 
   {
   Bulls[Bars-i]=0;    
   Bears[Bars-i]=0;  
   CMO[Bars-i]=0; 
   }
   
   
   
   if(counted_bars>0) limit=Bars-counted_bars;
   limit--;
   
   for( shift=limit; shift>=0; shift--)
   {
   Price1 = iMA(NULL,0,1,0,0,Price,shift);
   Price2 = iMA(NULL,0,1,0,0,Price,shift+1); 
      
   Bulls[shift] = 0.5*(MathAbs(Price1-Price2)+(Price1-Price2));
   Bears[shift] = 0.5*(MathAbs(Price1-Price2)-(Price1-Price2));
   
   double SumBulls = 0, SumBears=0;
      for (i=0;i<Length;i++) 
      {
      SumBulls += Bulls[shift+i];
      SumBears += Bears[shift+i];
      }  
   CMO[shift] = (SumBulls-SumBears)/(SumBulls+SumBears)*100;
   }
   /*   
   for( shift=limit; shift>=0; shift--)
   {
   double AvgBulls=iMAOnArray(Bulls,0,Length,0,0,shift);     
   double AvgBears=iMAOnArray(Bears,0,Length,0,0,shift);
   
   CMO[shift] = (AvgBulls-AvgBears)/(AvgBulls+AvgBears)*100;
   }
   */
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments