Download MetaTrader 5

momentum on an indicators values

To add comments, please log in or register
pash0603 2015.07.23 06:48 


 i am trying to draw a momentum graph based on the values of another indicator and not the open/close prices. This indicator may change so i would like something which would work on different indicators :)

 is there any such indicator out there or could someone please help me figure out how to do this?

 all help is appreciated! Thank you!

Alain Verleyen
Alain Verleyen 2015.07.23 18:29  
JD4 2015.07.23 19:29  
You could also learn MQL5 and try to code it yourself.  If you go that route and ask questions in the forum, use SRC to show the part of the code you are having trouble with and specifically your problem is.  "Doesn't work" is not specific and will likely get an equally unspecific answer.
Stanislav Korotky
Stanislav Korotky 2015.07.24 13:40  

You may use something like this:

//|                                            MomentumUniversal.mq4 |
//|                                       Copyright 2015, Marketeer. |
//|                 |
#property copyright "Copyright 2015, Marketeer"
#property link      ""
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1

#property indicator_label1  "Momentum"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2

extern int MomentumPeriod = 7;

// indicator buffers
double MomentumBuffer[];

//| Custom indicator initialization function                         |
int OnInit()
  SetIndexBuffer(0, MomentumBuffer);
//| Custom indicator iteration function                              |
int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double& price[])
  for(int i = rates_total - 1; i >= prev_calculated; i--)
    if(i - MomentumPeriod >= 0)
      MomentumBuffer[i] = price[i] - price[i - MomentumPeriod];
      MomentumBuffer[i] = EMPTY_VALUE;

 It works in MT5, but MT4 does not fully support this feature.

You may apply this on any indicator in a separate window (please note - it is NOT applicable for indicators running in the main window). Just open "Parameters" tab in the momentum properties dialog (don't confuse with "Inputs" tab) and choose appropriate element in the "Apply to" combobox (for example, choose "Previous Indicator's Data").

You'll get something like this:

Universal Momentum indicator applied on MACD 

Disclaimer: This was just created from scratch and may contain bugs.

To add comments, please log in or register