Hi, i sent the attached code to be published but the moderator has stated the following :
Programs should not contain critical errors that lead to immediate termination:
- division by zero
- going beyond array boundary
- using an incorrect object pointer
Start your program on a chart and try to change it timeframe or symbol. Restart the terminal with an indicator/Expert Advisor attached to it. Such actions should not lead to program errors.
Not enough history data or vice versa too many bars on the chart should not hinder the client terminal operation or cause excessive use of computer resources.
When i look for myself to find the problem i cant see what hes talking about. I try to change timeframe, chart but it appears okay?
Seems all ok. But try add after OnCalculate(...){
if(Bars<20) return(0);
double iMacdHist2 = iMACD(_Symbol,_Period,FastPeriod,SlowPeriod,SignalPeriod,iMacPrice,MODE_MAIN,i+1);
when i=rates_total - 1
index i+1 does not exist
static int highBars = TimeMinute(TimeCurrent());
highBars++;
static int lowBars = TimeMinute(TimeCurrent());
lowBars++;
int lowest = iLowest(_Symbol,_Period,MODE_LOW,lowBars,i);
double lowestLow = Low[lowest];
int highest = iHighest(_Symbol,_Period,MODE_HIGH,highBars,i);
double highestHigh = High[highest];
Your use of this static inside the for loop looks suspect.
highBars/lowBars don't always get reset each tick and could extend beyond the size of the array on subsequent ticks. If this happens then lowest and highest call will return -1 and the subsequent Low and High array accesses will cause a critical out of bounds error
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 sent the attached code to be published but the moderator has stated the following :
Programs should not contain critical errors that lead to immediate termination:
Start your program on a chart and try to change it timeframe or symbol. Restart the terminal with an indicator/Expert Advisor attached to it. Such actions should not lead to program errors.
Not enough history data or vice versa too many bars on the chart should not hinder the client terminal operation or cause excessive use of computer resources.
When i look for myself to find the problem i cant see what hes talking about. I try to change timeframe, chart but it appears okay?