//+------------------------------------------------------------------+ //| NonLag ma.mq5 | //| mladen | //+------------------------------------------------------------------+ #property copyright "www.forex-tsd.com" #property link "www.forex-tsd.com" #property indicator_chart_window #property indicator_buffers 3 #property indicator_plots 1 #property indicator_label1 "NonLag ma" #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 DeepSkyBlue,PaleVioletRed,DimGray #property indicator_style1 STYLE_SOLID #property indicator_width1 2 // // // // // input int Length = 25; // // // // // double nonlagma[]; double colorBuffer[]; //+------------------------------------------------------------------ //| //+------------------------------------------------------------------ // // // // // int OnInit() { SetIndexBuffer(0,nonlagma,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,3); SetIndexBuffer(1,colorBuffer,INDICATOR_COLOR_INDEX); IndicatorSetString(INDICATOR_SHORTNAME,"NonLag ma ("+string(Length)+")"); return(0); } // // // // // int OnCalculate (const int rates_total, const int prev_calculated, const int begin, const double& price[] ) { for (int i=(int)MathMax(prev_calculated-1,0); i0) { colorBuffer[i] = 2; if (nonlagma[i]>nonlagma[i-1]) colorBuffer[i]=0; if (nonlagma[i]0) { double sum = 0; for (int k=0; k < nlm_values[_len][forValue] && (r-k)>=0; k++) sum += nlm_alphas[k][forValue]*nlm_prices[r-k][forValue]; return( sum / nlm_values[_weight][forValue]); } else return(0); }