//+------------------------------------------------------------------+ //| Gann high low activator.mq5 | //| mladen | //+------------------------------------------------------------------+ #property copyright "mladen" #property link "mladenfx@gmail.com" #property indicator_separate_window #property indicator_buffers 2 #property indicator_plots 1 #property indicator_label1 "Gann high low" #property indicator_type1 DRAW_COLOR_HISTOGRAM #property indicator_color1 DeepSkyBlue,PaleVioletRed #property indicator_style1 STYLE_SOLID #property indicator_width1 2 #property indicator_minimum 0 #property indicator_maximum 1 // // // // // input int LookBack = 10; // // // // // double gannBuffer[]; double colorBuffer[]; double trend[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int OnInit() { SetIndexBuffer(0,gannBuffer, INDICATOR_DATA); SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX); IndicatorSetString(INDICATOR_SHORTNAME,"Gann high low activator("+string(LookBack)+")"); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // 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 &TickVolume[], const long &Volume[], const int &Spread[]) { if (ArraySize(trend)!=rates_total) ArrayResize(trend,rates_total); // // // // // for (int i=(int)MathMax(prev_calculated-1,0); i 0) trend[i] = trend[i-1]; if (Close[i] > high) trend[i] = 1; if (Close[i] < low) trend[i] = -1; if (trend[i] == 1) colorBuffer[i]=0; if (trend[i] ==-1) colorBuffer[i]=1; } return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // double iSma(const double& array[], int length, int i) { double avg = 0; for (int k=0; k=0; k++) avg += array[i-k]; return(avg/length); }