//+------------------------------------------------------------------+ //| Moving Average Robot.mq5 | //| Copyright 2017, Joao Luiz Sa Marchioro | //| JLSM | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Thanks to friends Nurudeen Amedu and whroeder1 members of the | //| MQL5 community for the overwhelming support in developing this | //| Indicator. | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, Joao Luiz Sa Marchioro" #property link "JLSM" #property version "1.00" //--- input int Candle = 10; #property indicator_separate_window #property indicator_buffers 4 #property indicator_plots 2 #property indicator_type1 DRAW_LINE #property indicator_type2 DRAW_LINE #property indicator_color1 LightSeaGreen #property indicator_color2 Red #property indicator_level1 -100.0 #property indicator_level2 100.0 #property indicator_applied_price PRICE_TYPICAL double Close[]; double ExtBuffer[]; double ExtBuffer1[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ExtBuffer); SetIndexBuffer(1,ExtBuffer1); //--- 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 begin = 0; int x = 0; double y = 0; int StartCalcPosition=0; //--- check for bars count if(rates_total0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0); if(begin>0) PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,0); PlotIndexSetInteger(1,PLOT_SHIFT,1); //--- calculate position int pos=prev_calculated-1; if(posclose[i+iRight]){x++;y++;} if(close[i+iLeft]0 && index