Download MetaTrader 5

Momersion indicator

To add comments, please log in or register
chrisdk2015
70
chrisdk2015  

Hi,

Is anyone up for coding the momersion indicator for mt4?

http://www.priceactionlab.com/Blog/2015/08/momersion-indicator/

I have used this for ETFs in C# but I'm not sure how to code it in MQL.

It is good for signaling a shift in the market mean reversion to trending/momentom and reverse.

I tried converting the current Momentum indicator but failed.

Best

Chris 

chrisdk2015
70
chrisdk2015  
double Mc = 0;
   double MRc = 0;
   double r1;
   double r1_1;
   for(i=limit+2; i<rates_total+1; i++)
   //for(i=2; i<limit+1; i++)
   {
      r1 = close[i]/close[i-1]-1;
      r1_1 = close[i-1]/close[i-2]-1;
      if (r1*r1_1 > 0) Mc++;
      if (r1 * r1_1 < 0) MRc++;
   }
   Print("Mc=",Mc," MRc=",MRc);
   ExtMomBuffer[i]=100*Mc/(Mc+MRc);
is what I got currently...not sure what I am doing wrong here.
Stanislav Korotky
19854
Stanislav Korotky  
Don't you think this is yet another variant of the conventional ADX indicator? BTW, ADX seems more precise.
chrisdk2015
70
chrisdk2015  
Stanislav Korotky:
Don't you think this is yet another variant of the conventional ADX indicator? BTW, ADX seems more precise.
I am not sure ADX is the same? 
This one ranges between 0 and 100. 50 and above then it is trending, below we are in mean reversion. 
How would you do this with ADX? Just set a threshold maybe of 30-40 to signal above this it would be trending?
Stanislav Korotky
19854
Stanislav Korotky  
chrisdk2015:

ADX is different of course, but it also provides an estimation of directional movement (which is called momentum in the new indicator). Actually ADX is also between 0 and 100, but it rarely goes above 50 because its values are normalized against ATR. You should probably select a scale for ADX to have approximately the same effective levels.

14-period DiReverse (Momersion) with ADX side by side on EURUSD H1 

I'm not sure the author's strategy for this indicator is correct. It suggests to buy when the value is below 0.5 with some threshold and sell when the value is above 0.5 with some threshold. But values less than 0.5 mean actually undecided market so why it should be buy and not sell? Why not to wait at this moment? Also values greater 0.5 can equally mean up or down trend, so why should we sell and not buy? Moreover, how do we know if the trend will continue or reverse? Can you clarify the matter?

chrisdk2015
70
chrisdk2015  

Thanks for explaining ADX.

I haven't used it much in trading.

The momersion indicator as you says doesn't contain direction of the trend. You need a relative return to get the direction or use another indicator.

I was just interested in it because I used it in a mean reversion strategy where I filtered out trending ETFs.

I will look more into ADX now.

Lorentzos Roussos
11022
Lorentzos Roussos  
Try this 
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
//---
   int    i,limit;
   limit=rates_total-prev_calculated;
   double Mc,MRc;
   int sta,ent;
   double division,full;
   double return_previous,return_now,merge;
   for(i=limit-1; i>=0; i--)
     {   
     if(i<Bars-MomersionPeriod-3)
     {
     //Reset 
       Mc=0;
       MRc=0;
       sta=i+MomersionPeriod;
       ent=i;
       //Period Loop
         for(int per=sta;per>=ent;per--)
         {
         return_previous=Close[per+1]-Open[per+1];
         return_now=Close[per]-Open[per];
         merge=return_now*return_previous;
         if(merge>0) Mc++;
         if(merge<0) MRc++;
         }
       //Period Loop Ends Here
       full=Mc+MRc;
       if(full==0)
        {
        Momersion[i]=Momersion[i+1];
        }
       if(full>0)
        {
        division=Mc/full;
        division=division*100;
        Momersion[i]=division;
        }
     }
     }     
//--- return value of prev_calculated for next call
   return(rates_total);
  }
To add comments, please log in or register