-
for(int i = limit; i < rates_total; i++) int i_bar_shift = iBarShift(Symbol(), inpTimeFrame, time[i], false); buffer[i] = arr_ma[0];
You did not set the time[] array and your buffer[] to match your loop direction. In MT5, you must set the direction.To define the indexing direction in the time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call the ArrayGetAsSeries() function. In order not to depend on defaults, call the ArraySetAsSeries() function for the arrays to work with.
Event Handling / OnCalculate - Reference on algorithmic/automated trading language for MetaTrader 5 -
int limit = rates_total - prev_calculated; if(prev_calculated > 0) limit++; for(int i = limit; i < rates_total; i++)
First run, prev_calculated is zero, therefor limit is rates_total+1 and your loop does nothing.
How to do your lookbacks correctly #9 — #14 & #19 (2016)
Hi WIlliam, Thanks for your help, greatly appreciated.
I've set my time to ArraySetAsSeries(time, true) now. The Buffer was already set to ArraySeries 'true' at the top in the OnInit() funciton, was that what you were refering to?
I see what you mean about the limit never being smaller than rates_total;
If I understand the rest of your post correctly; these 2 components are counting in different directions is that the case?
Thanks
if(prev_calculated > 0) limit++; //for loop for(int i = limit; i < rates_total; i++) {

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I've been coding in MQL4 for a while, and am 'reasonably' good at it. Recently I have switched to MQL5 and having difficulty converting my higher timeframe indicators over.
This is a Higher Timeframe Moving average. I think the issue is I am referencing the shift from the curent timeframe but I cannot see how to fix it.
Any help you could offer would be greatly appreacisted as really racking my brains with this.
This is what it looks like on the chart:
https://screenrec.com/share/vDUFsz6J31
Thanks in Advance: