//+------------------------------------------------------------------+ //| GANN_HILO.mq5 | //| Copyright 2012, . | //| m100shiri@yahoo.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2012," #property link "m100shiri@yahoo.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 3 #property indicator_plots 3 #property indicator_label1 "GANN_HI-LO_SHIRI" #property indicator_type1 DRAW_LINE #property indicator_style1 STYLE_SOLID #property indicator_width1 3 #property indicator_color1 Gold #property indicator_label2 "GANN_HI-LO_SHIRI_UP" #property indicator_type2 DRAW_ARROW #property indicator_width2 3 #property indicator_color2 Blue #property indicator_label3 "GANN_HI-LO_SHIRI_DOWN" #property indicator_type3 DRAW_ARROW #property indicator_width3 3 #property indicator_color3 Red input int Lb=10; int bars; double ssl[],Hld,Hlv,ssl_ima_h[],ssl_ima_l[]; int ssl_handle; int ssl_handle_h,ssl_handle_l; double Upper_Arrow_Buffer[]; double Down_Arrow_Buffer[]; //--- 10 pixels upper from high price int ArrowShift=10; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ssl,INDICATOR_DATA); ssl_handle_h=iMA(NULL,0,Lb,0,MODE_SMA,PRICE_HIGH); ssl_handle_l=iMA(NULL,0,Lb,0,MODE_SMA,PRICE_LOW); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); bars=Bars(_Symbol,_Period); // int number=MathRand(); //int shift=100-number%41; //PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,shift); SetIndexBuffer(1,Upper_Arrow_Buffer,INDICATOR_DATA); PlotIndexSetInteger(1,PLOT_ARROW,217); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,ArrowShift); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); SetIndexBuffer(2,Down_Arrow_Buffer,INDICATOR_DATA); PlotIndexSetInteger(2,PLOT_ARROW,218); PlotIndexSetInteger(2,PLOT_ARROW_SHIFT,-ArrowShift); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE); //--- return(0); } //+------------------------------------------------------------------+ //| 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 pos; if(prev_calculated>2) pos=prev_calculated; else pos=2; int ssl_handle_h_copied=CopyBuffer(ssl_handle_h,0,0,rates_total,ssl_ima_h); int ssl_handle_l_copied=CopyBuffer(ssl_handle_l,0,0,rates_total,ssl_ima_l); for(int i=pos; issl_ima_h[i-1]) Hld=1; else { if(close[i]bars) PlaySound("alert.wav"); } else Upper_Arrow_Buffer[i]=EMPTY_VALUE; //---- GANN_HI-LO_SHIRI_DOWN if(ssl[i-1]>ssl[i-2] && ssl[i-1]>ssl[i] ) { Down_Arrow_Buffer[i-1]=high[i-1]; if (prev_calculated >bars) PlaySound("alert.wav"); } else Down_Arrow_Buffer[i]=EMPTY_VALUE; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+