snowgray
snowgray
Friends

Add friends via their profile or user search and you will be able to see if they are online

snowgray
Added topic I need a programmer who can edit my indicator source code
I developed an indicator which include EMA SHIFT= - 2 but each time I run it on a tester I get this error ( array out of range ). Bellow are attached image of the indicator 
Enrique Enguix
Enrique Enguix 2020.09.22
/+------------------------------------------------------------------+
//| 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[]) { int limit = rates_total - prev_calculated; //--- counting from 0 to rates_total ArraySetAsSeries(Buffer1, true); //--- initial zero if(prev_calculated < 1) { ArrayInitialize(Buffer1, EMPTY_VALUE); } else limit++; //--- main loop for(int i = limit-1; i >= 0; i--) { if (i >= MathMin(5000-1, rates_total-1-50)) continue; //omit some old rates to prevent "Array out of range" or slow calculation //Indicator Buffer 1 if(iMACD(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1+i) <= iMACD(NULL, PERIOD_CURRENT, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, i) //MACD <= MACD ) { Buffer1[i] = Low[i]; //Set indicator value at Candlestick Low } else { Buffer1[i] = EMPTY_VALUE; } } return(rates_total); }
//+-----------------------------
Enrique Enguix
Enrique Enguix 2020.09.22
The array out of range error is very easy to fix. To begin with, I hope you have set EMA shift 2, not -2. If you want, send me the code and I'll solve it for you tomorrow as soon as I can.
Enrique Enguix
Enrique Enguix 2020.09.22
I send you an example that I have here at hand as an example of how you can define the limit
snowgray
Registered at MQL5.community