- Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6.
- Questions from Beginners MQL5 MT5 MetaTrader 5
- Looking for: RSI value from several timeframe in one oscillator
I'd like to check the value of an indicator on a different timeframe to verify a trade. Let's just assume that it's ANY indicator, custom or not. How can this be done?
Hi Kenneth,
Here's an example. You would normally call an MA in your working timeframe something like this:
double FastMABar1=iMA(NULL,0,FastMAPeriod,FastMAShift,FastMAMethod,FastMAEnumeration,1);
Now, if you wanted to see it in a different timeframe the only thing you need to do is change the timeframe variable in the call. For instance, if you wanted to see the 15 minute MA value it would look like this:
double FastMABar1=iMA(NULL,15,FastMAPeriod,FastMAShift,FastMAMethod,FastMAEnumeration,1);
Hope this helps.
- Tovan
What would be the easiest way to check the next highest timeframe from the current one?
Kenneth,
Try putting something like this in the Init() section:
switch(Period()) { case 1: FastMaHigherTimeframe = 5; break; case 5: FastMaHigherTimeframe = 15; break; case 15: FastMaHigherTimeframe = 30; break; case 30: FastMaHigherTimeframe = 60; break; case 60: FastMaHigherTimeframe = 240; break; case 240: FastMaHigherTimeframe = 1440; break; case 1440: FastMaHigherTimeframe = 10080; break; case 10080: FastMaHigherTimeframe = 43200; break; }
FastMAHigherTimeframe will be set to the next higher timeframe. Then you can call the indicator as I suggested above using this variable for the timeframe.
- Tovan
Kenneth,
Try putting something like this in the Init() section:
FastMAHigherTimeframe will be set to the next higher timeframe. Then you can call the indicator as I suggested above using this variable for the timeframe.
- Tovan
Thanks Tovan. You've been a great help as usual.
Hi Kenneth,
Here's an example. You would normally call an MA in your working timeframe something like this:
Now, if you wanted to see it in a different timeframe the only thing you need to do is change the timeframe variable in the call. For instance, if you wanted to see the 15 minute MA value it would look like this:
Hope this helps.
- Tovan
iMA function returns the handles not the values, how to get the values please??
After 11 years ....!
I think you are studying only MT5
this section for MT4
so they easily get values
- Don't resurrect old threads without a very good reason. A lot has changed since Build 600 and Higher. 2014.02.03
- This is the MQL4 section, (bottom of the Root page.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. You are off-topic here. - Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (after the indicator has updated its buffers,) you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to call indicators in MQL5 - MQL5 Articles 12 March 2010Also see my example for encapsulating calls
Detailed explanation of iCustom - MQL4 programming forum 2017.05.23

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use