shift is not the indicator buffer. They are totally different things and unrelated in this context.
shift is the bar index.
So, for MQL4:
shift 0 = the current bar
shift 1 = the previous bar
shift 2 = the bar before that
and so on.
You may be getting confused with iCustom.
shift is not the indicator buffer. They are totally different things and unrelated in this context.
shift is the bar index.
So, for MQL4:
shift 0 = the current bar
shift 1 = the previous bar
shift 2 = the bar before that
and so on.
You may be getting confused with iCustom.
Thanks a lot honest_knave!
I was confused because of the explanation of this variable:
[in] Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).
That means then, I can pick up all the single values within an (e.g.) 20 day EMA using this shift function?
OK, I see what they have done there in the documentation, and I can see why it is confusing if you then read up on indicator_buffers.
This may help:
[in] Index of the value taken from the iMA buffer (shift relative to the current bar the given amount of periods ago).
To cut straight to your answer: Yes, you can e.g. the last 3 bars' 20 EMA values
double MA1 = iMA(_Symbol,0,20,0,MODE_EMA,PRICE_CLOSE,1);
double MA2 = iMA(_Symbol,0,20,0,MODE_EMA,PRICE_CLOSE,2);
OK, I see what they have done there in the documentation, and I can see why it is confusing if you then read up on indicator_buffers.
This may help:
[in] Index of the value taken from the iMA buffer (shift relative to the current bar the given amount of periods ago).
To cut straight to your answer: Yes, you can e.g. the last 3 bars' 20 EMA values
double MA1 = iMA(_Symbol,0,20,0,MODE_EMA,PRICE_CLOSE,1);
double MA2 = iMA(_Symbol,0,20,0,MODE_EMA,PRICE_CLOSE,2);
Hello honest_knave,
thanks for your quick reply. That helps a lot!
Regards,
Marko
How can I customized this EA so It can enter and exit trade with my preferred indicator
What EA?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am currently working on scripting an EA. I came to the point, where I need to know, what exactly the indicator buffer stands for.
Here is an example:
double iMA(string symbol, // symbol
int timeframe, // timeframe
int ma_period, // MA averaging period
int ma_shift, // MA shift
int ma_method, // averaging method
int applied_price, // applied price
int shift // shift
);
The last variable "shift" indicates the indicator buffer. I couldn't find a proper definition yet.
I would be very happy, if you could help me.
Thanks a lot in advance!
Regards,
Marko