Custom MA creation - how to get/reference "correct" previous higher interval?

 

Hello boys and girls! First post, so yay and stuff.

Yes.. yet another topic about custom MA's and arrays and stuff.. I have been searching a considerable time but can't seem to find any relevant info.

So what I am trying to do is create a custom SMA calc - that in itself seems pretty simple. The problem comes in that I can't seem to wrap my head around how to properly get all the values required for my calculation.

What I need to be able to do, is that, while looping through the usual o/h/l/c values of specific period, I also need to be getting the "correct" offset value from a previous higher period.

 

So if I'm looping through getting my combo of PERIOD_M5 o/h/l/c values, how could I also pull in the correct (for example)..

iOpen(NULL, PERIOD_H1, 2);

..offset from the current PERIOD_M5 in the loop?

 

This cannot simply be the lower period multiplied to the same value as the higher period - It must be the 'actual' higher period bar open value. Need to end up with something along the lines of..

for(i = amount; i >= 0; i--){ EndCalc[i] = LowPeriodValues[i] /* -- < calc with > -- */ iOpen(NULL, PERIOD_H1, ProperRelationalOffset) ; }

 ..any ideas or suggestions greatly appreciated - sorry I cannot provide any more code, and sorry for clogging the place up if this has a really simple solution lol.

 

Thanks! 

 
Use iTime() and iBarShift() to synchronise your different time-frames!
 
FMIC:
Use iTime() and iBarShift() to synchronise your different time-frames!

Thankyou!

No idea how to go about it, but you've given me a starting point sir. Much appreciated. 

Reason: