High[], Low[] or Close[] for another timeframe?!

 

Hello,

I have an Indicator, which use the Functions High, Low and Close.

Now I want to change it. I want to add the parameter "Timeframe", so that I can put the indicator on the H1 chart and see the indicator for the M30 oder D1 Timeframe.

Is this possible? How can I do it?!

 

Instead of using High[i], Close[i] etc, you need to use iHigh(...), iClose(...). These functions can return values for any TF.

Here is the book;) -> https://docs.mql4.com/series/iClose

 

Lot's of thanks!!! That was a great help!

 
sunshineh:

Hello,

I have an Indicator, which use the Functions High, Low and Close.

Now I want to change it. I want to add the parameter "Timeframe", so that I can put the indicator on the H1 chart and see the indicator for the M30 oder D1 Timeframe.

Is this possible? How can I do it?!

hasayama:

Instead of using High[i], Close[i] etc, you need to use iHigh(...), iClose(...). These functions can return values for any TF.

Here is the book;) -> https://docs.mql4.com/series/iClose

Hello,

you can use iHigh, iClose but you should also have in mind that there are some intricacies.  For example, when you are e.g. in a 1 hour TF, calling a 30 min iHigh(), history for that TF may not be available immediately (you may see https://www.mql5.com/en/forum/157343 ). What you can possibly do is to first call all TFs in OnInit() (using, for example, iHigh() ) and Sleep() for some seconds, as to allow for history to get downloaded. Then, you may check the return values of some functions to be sure about

best regards 

 
Welcome to 2010 everyone 
 
oops :) but really, how? is this a by-product of the "similar" button that appeared beneath poster's messages?
 

No, I think a poster went on a resurrection rampage, posting solutions to very old threads. I think the intentions were good but it did bring a lot of old threads back up to the top.

Either a mod or the poster have deleted their content, but I guess a few got replied to before then. 

Reason: