Author: neo
cd

This tool is designed to identify specific momentum shifts in the market by analyzing the relationship between two different moving averages. Instead of simply looking at price, it focuses on the "velocity" and "acceleration" of price movements to highlight potential turning points.

The Core Logic

The script operates through three distinct layers of calculation:

1. Establishing a Momentum Ratio First, the tool compares a fast-moving average (representing short-term trends) against a slow-moving average (representing long-term trends). By dividing the short-term value by the long-term value, it creates a percentage-based ratio. This allows the tool to see not just where the price is, but how much "strength" the current trend has compared to its historical baseline.

2. Smoothing the Data To prevent the tool from reacting to minor market noise or "jitter," it takes that momentum ratio and applies a second layer of smoothing. This creates a refined curve that tracks the underlying sentiment of the market, filtering out insignificant fluctuations so only significant movements are captured.

3. Identifying Signal Crosses The final step is the detection of specific "crossover" events. The tool looks for moments where the momentum ratio breaks through the smoothed curve. These are visualized on your chart as distinct arrows:

  • Upcross Signals: These occur when the momentum ratio moves from below the smoothed curve to above it. This suggests that short-term strength is accelerating faster than the historical average, potentially indicating a bullish shift.
  • Downcross Signals: These occur when the momentum ratio moves from above the smoothed curve to below it. This suggests that short-term strength is cooling off or dropping faster than the historical average, potentially indicating a bearish shift.

Summary for the User

In plain terms, this script acts as a "trend detective." It monitors how aggressively the price is moving relative to its past behavior. When the current momentum "breaks out" in either direction, it marks that moment on your chart with an arrow, helping you identify where the market's energy might be shifting from one direction to another.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
cd
//+------------------------------------------------------------------+
//|                                                           cd.mq4 |
//|                                                              neo |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "neo"
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 MediumSeaGreen

extern int SHORTPERIOD=20;
extern int LONGPERIOD=200;

//---- buffers
double KK[];
double MM[];
double JC[];
double SC[];

int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexBuffer(0,JC);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1,SC);
   SetIndexArrow(0,233);
   SetIndexArrow(1,234); 
   SetIndexLabel(0,"upcross");
   SetIndexLabel(1,"downcross");  

   return(0);
  }

int deinit()
  {
//----
   
//----
   return(0);
  }

int start()
  {
   int counted_bars=IndicatorCounted();
   int limit;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

//-----------------------------------------------------------------
   for(int i=0; i<limit; i++)
     {
       KK[i]=100*iMA(NULL,0,SHORTPERIOD,0,MODE_EMA,PRICE_CLOSE,i)/iMA(NULL,0,LONGPERIOD,0,MODE_EMA,PRICE_CLOSE,i);   
     }
     
   for(int h=0; h<limit; h++)
     {
       MM[h]=iMAOnArray(KK,0,7,0,MODE_SMA,h);
     }    
   for(int n=limit-1; n>0; n--)
     {
       if(KK[n]>100 && KK[n+1]<MM[n+1] && KK[n]>MM[n]) JC[n]=Close[n];
       if(KK[n]>100 && KK[n+1]>MM[n+1] && KK[n]<MM[n]) SC[n]=Close[n];       
     }
     
     
    Print(KK[1]); 
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments