Forum on trading, automated trading systems and testing trading strategies
If you can't find what you need in the Codebase or the Market, then create a request in Freelance Service.
You may use something like this:
//+------------------------------------------------------------------+ //| MomentumUniversal.mq4 | //| Copyright 2015, Marketeer. | //| https://www.mql5.com/en/users/marketeer | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, Marketeer" #property link "https://www.mql5.com/en/users/marketeer" #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); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| 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]; } else { MomentumBuffer[i] = EMPTY_VALUE; } } return(rates_total); } //+------------------------------------------------------------------+
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:
Disclaimer: This was just created from scratch and may contain bugs.
Files:
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello!
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!