Hi all,

I've been doing MT4 programming for a few months now, and I've started work on a new indicator that acts similarly to a moving average, but with some new additions I've added.

One thing thing that I would like to add to this indicator though, is the ability to set the timeframe regardless of what timeframe the chart is. Currently the indicator I'm programming relies on another indicator, which I use the iCustom() function to access.

Basically what I need is some way of converting the bar index of one timeframe to another, since I use iCustom to get particular values. So if the chart was an H1 and the current bar was 4000, and I set the indicator to use a H4 value, it would know that it needs to pull the value from bar 1000 in an H4 period. (I hope that all makes sense).

I could just make a function that does a rough conversion by simply working out differences in timeframe (i.e. if going from H1 to H4, divide by 4, or something like that), but of course accuracy is important with this kind of thing, so I was wondering if someone here knew a more accurate and efficient means of accomplishing what I'm trying to do.

Any help will be greatly appreciated.