int counted_bars=IndicatorCounted(); if(counted_bars > 0) counted_bars -= 10; limit = Bars - counted_bars;
Do your lookback properlyint counted = IndicatorCounted(); int lookback = ... // iMA(period) has look back of period. // buffer[i+2] has look back of 2 // use maximum of all. for(int iBar = Bars - MathMax(lookback, counted); iBar >= 0; --iBar) ...
- int bar = iBarShift(NULL, userTimeFrame, time[i]); /************ THE LINE THAT BREAKS IT. within it I've replaced old "Time[i]" with updated time[i] ***********/There is the parameters high[] and the The predefined Variables - MQL4 Documentation High[]. Don't get them confused. high[] can be ordered either direction; High[0] is the current bar always. Your limit/lowLimit implies series arrays but you didn't set time[] as series.
limit = WindowFirstVisibleBar(); lowLimit = limit - WindowBarsPerChart();
You don't take chart shift into account so lowLimit will go negativeiLeft = WindowFirstVisibleBar(); iRight = MathMax(0,iLeft-WindowBarsPerChart() );
Thanks WHRoeder, that's a lot of points. I will look at each one in detail now.
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
Hello, I'm in the process of porting some old code (start(), init(), etc) to the updated MQL4. I've gotten rid of all the compiler warnings and replaced start() with OnCalculate() and so on. Now without this one line, the chart window stays open (desired operation), but with the line, it crashes as if it thinks something in the line is legacy code. Please point out how this line should be updated (See bottom of code).