I have a little problem with iHighest, I have to find the highest Close between candles 6 and 4. the code error of the closing index but the result is not correct
Inserted Code
#property version "1.00" #property description "" #include <stdlib.mqh> #include <stderror.mqh> //--- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_type1 DRAW_ARROW #property indicator_width1 1 #property indicator_color1 White #property indicator_label1 "Sell" #property indicator_type2 DRAW_ARROW #property indicator_width2 1 #property indicator_color2 White #property indicator_label2 "Buy" int N; int FTimeFrame = 0; //--- indicator buffers double Buffer1[]; double Buffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorBuffers(2); SetIndexBuffer (0, Buffer1); SetIndexEmptyValue(0, 0); SetIndexArrow (0, 242); SetIndexBuffer (1, Buffer2); SetIndexEmptyValue(1, 0); SetIndexArrow (1, 241); 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[]) { int limit = rates_total - prev_calculated; //--- counting from 0 to rates_total ArraySetAsSeries(Buffer1, true); ArraySetAsSeries(Buffer2, true); //--- initial zero if(prev_calculated < 1) { ArrayInitialize(Buffer1, 0); ArrayInitialize(Buffer2, 0); } else limit++; //--- main loop for(int i = limit-1; i >= 0; i--) { if (i >= MathMin(5000-1, rates_total-1-50)) continue; bool Pattern = Open [1+i] > Close[1+i] && Open [2+i] > Close[2+i] && Open [3+i] > Close[3+i] && Open [4+i] < Close[4+i]; if( Pattern == true ) { N = iHighest(Symbol(),PERIOD_CURRENT,MODE_CLOSE,6+i,4+i); Buffer1[N] = High[N] +30*Point ; Assing Buffer1 with higher closure } } return (0); } //+------------------------------------------------------------------+