Hi
I noticed that in MT4 the index [0] is the current bar(on the extreme RIGHT position).
But in MT5, the index [0] is the FIRST bar(on the extreme LEFT position).
When I tried to convert indicator from MT4 to MT5 the indexing made the converted indicator plots differently.
Is there any way to use the same indexing on MT5 as MT4?
Thanks
I noticed that in MT4 the index [0] is the current bar(on the extreme RIGHT position).
But in MT5, the index [0] is the FIRST bar(on the extreme LEFT position).
- In MT4, only the predefined arrays and buffers are as-series by default.
- In MT5, there is no default direction. You must set the direction.
Both false.
- In MT4, only the predefined arrays and buffers are as-series by default.
- In MT5, there is no default direction. You must set the direction.
In MT5, there is no default direction. You must set the direction.
How do I do that?
My example is based on ArrayIsSeries help.
I added the input parameter "AS_SERIES flag" - the flag value is displayed in the "Data WIndow")
Result:
Code:
//+------------------------------------------------------------------+ //| ArraySetAsSeries.mq5 | //| Copyright © 2013, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2013, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.002" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //---- plot Numeration #property indicator_label1 "Numeration" #property indicator_type1 DRAW_LINE #property indicator_color1 CLR_NONE //--- input parametrs input bool InpArraySetAsSeries = true; // AS_SERIES flag //--- indicator buffers double NumerationBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,NumerationBuffer,INDICATOR_DATA); //--- set indexing for the buffer like in input parameter "AS_SERIES flag" ArraySetAsSeries(NumerationBuffer,InpArraySetAsSeries); //--- set accuracy of showing in DataWindow IndicatorSetInteger(INDICATOR_DIGITS,0); //--- how the name of the indicator array is displayed in DataWindow string text="flag false"; if(InpArraySetAsSeries) text="flag true"; PlotIndexSetString(0,PLOT_LABEL,"("+text+") "+"Bar #"); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- we'll store the time of the current zero bar opening static datetime currentBarTimeOpen=0; //--- revert access to array time[] - do it like in timeseries ArraySetAsSeries(time,true); //--- If time of zero bar differs from the stored one if(currentBarTimeOpen!=time[0]) { //--- enumerate all bars from the current to the chart depth for(int i=rates_total-1; i>=0; i--) NumerationBuffer[i]=i; currentBarTimeOpen=time[0]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+

- www.mql5.com
Both false.
- In MT4, only the predefined arrays and buffers are as-series by default.
- In MT5, there is no default direction. You must set the direction.
Thanks man.
My example is based on ArrayIsSeries help.
I added the input parameter "AS_SERIES flag" - the flag value is displayed in the "Data WIndow")
Result:
Code:
Your 2nd statement doesn't make any sense at all. "no default direction" ? really? That's just ridicules.
Of course there is a default direction, but the documentation says it could be changed anytime, so you can't rely on it. That's the theory.
In practice, using mql5 the last 7 years the default direction was never changed and is "indexed not as serie".
Of course there is a default direction, but the documentation says it could be changed anytime, so you can't rely on it. That's the theory.
In practice, using mql5 the last 7 years the default direction was never changed and is "indexed not as serie".
Yes, your reply makes more sense.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I noticed that in MT4 the index [0] is the current bar(on the extreme RIGHT position).
But in MT5, the index [0] is the FIRST bar(on the extreme LEFT position).
When I tried to convert indicator from MT4 to MT5 the indexing made the converted indicator plots differently.
Is there any way to use the same indexing on MT5 as MT4?
Thanks