//+------------------------------------------------------------------+ //| Didi Index.mq5 | //| Rudinei Felipetto | //| http://www.conttinua.com | //+------------------------------------------------------------------+ #property copyright "Rudinei Felipetto" #property link "http://www.conttinua.com" #property version "1.00" #property indicator_separate_window #property indicator_buffers 3 #property indicator_plots 3 //--- plot Curta #property indicator_label1 "Curta" #property indicator_type1 DRAW_LINE #property indicator_color1 clrLime #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot Media #property indicator_label2 "Media" #property indicator_type2 DRAW_LINE #property indicator_color2 clrWhite #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- plot Longa #property indicator_label3 "Longa" #property indicator_type3 DRAW_LINE #property indicator_color3 clrYellow #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- input parameters input int Curta=3; input int Media=8; input int Longa=20; //--- indicator buffers double CurtaBuffer[]; double MediaBuffer[]; double LongaBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,CurtaBuffer,INDICATOR_DATA); SetIndexBuffer(1,MediaBuffer,INDICATOR_DATA); SetIndexBuffer(2,LongaBuffer,INDICATOR_DATA); IndicatorSetInteger(INDICATOR_DIGITS,4); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { if(rates_total=Media) { CurtaBuffer[i] /= MediaBuffer[i]; if(i>=Longa) { LongaBuffer[i] /= MediaBuffer[i]; } else { LongaBuffer[i] = 1; } } else { CurtaBuffer[i] = 1; } MediaBuffer[i] = 1; } }