Program historical iMA

 

My algo looks at candlestick data from 5 bars ago and compares it with the moving average using the iMA function and Open[4].

I've just realised that comparing that data is wrong because iMA will always be using data from the current tick (not from 5 bars ago).

I figure I either need to somehow call iMA data that corresponds to the open, or save historical numbers to an array so they can be called?

Is there a simpler way to do this?


Thanks in advance

C

 
charlie.cooper:

I've just realised that comparing that data is wrong because iMA will always be using data from the current tick (not from 5 bars ago).

You set the shift in iMA to the bar that you require the data from.

 
Keith Watford:

You set the shift in iMA to the bar that you require the data from.

Thanks for your reply; I see - MA Shift. Do you know what units the shift is measured in? Bars?
 
charlie.cooper Do you know what units the shift is measured in? Bars?

Yes he does. You do not. Read the documentation.
          iMA - Technical Indicators - MQL4 Reference

 
William Roeder:

Yes he does. You do not. Read the documentation.
          iMA - Technical Indicators - MQL4 Reference

Hi Keith,

Thanks for your reply - I did read this beforehand but it doesn't specify exactly which timeframe which confused me.

I do make an effort to read docs before posting and I wanted clarification.
 
charlie.cooper:
Hi Keith,

Thanks for your reply - I did read this beforehand but it doesn't specify exactly which timeframe which confused me.

I do make an effort to read docs before posting and I wanted clarification.

It doesn't specify the timeframe, you do in the code. The 2nd parameter for iMA.

 
charlie.cooper: I do make an effort to read docs before posting and I wanted clarification.

You did? What part of

shift

[in]  Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

was unclear? Why did you ask:

charlie.cooper: . Do you know what units the shift is measured in? Bars?
 
Keith Watford:

It doesn't specify the timeframe, you do in the code. The 2nd parameter for iMA.

Ahh thanks - I see now :) You guys are right - I should have read this more closely, thanks again. I was confused because timeframe can be anything but I didn't spot the other part.

Reason: