//+------------------------------------------------------------------+ //| MTF_NonLagMA_v7.1.mq4 | //| Copyright © 2007, TrendLaboratory | //| http://finance.groups.yahoo.com/group/TrendLaboratory | //| mtf:FXTSD.com E-mail: igorad2003@yahoo.co.uk | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, TrendLaboratory" #property link "http://finance.groups.yahoo.com/group/TrendLaboratory" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Orange #property indicator_width1 2 #property indicator_color2 SkyBlue #property indicator_width2 2 #property indicator_color3 Tomato #property indicator_width3 2 //---- input parameters /***************************************************************** PERIOD_M1 1 PERIOD_M5 5 PERIOD_M15 15 PERIOD_M30 30 PERIOD_H1 60 PERIOD_H4 240 PERIOD_D1 1440 PERIOD_W1 10080 PERIOD_MN1 43200 You must use the numeric value of the timeframe that you want to use when you set the TimeFrame' value with the indicator inputs. ********************************************************************/ //---- extern int TimeFrame=0; extern int Price = 0; //Apply to Price(0-Close;1-Open;2-High;3-Low;4-Median price;5-Typical price;6-Weighted Close) extern int Length = 9; //Period of NonLagMA extern int Displace = 0; //DispLace or Shift extern double PctFilter = 0; //Dynamic filter in decimal extern int Color = 1; //Switch of Color mode (1-color) extern int ColorBarBack = 1; //Bar back for color mode extern double Deviation = 0; //Up/down deviation extern int AlertMode = 0; //Sound Alert switch (0-off,1-on) extern int WarningMode = 0; //Sound Warning switch(0-off,1-on) extern string note1 = "Price(OCHLMTF)Length(period)Displace(shift)Color(0/1)"; //---- indicator buffers double MABuffer[]; double UpBuffer[]; double DnBuffer[]; double trend[]; double Del[]; double AvgDel[]; double alfa[]; int i, Phase, Len,Cycle=4; double Coeff, beta, t, Sum, Weight, g; double pi = 3.1415926535; bool UpTrendAlert=false, DownTrendAlert=false; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(6); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,MABuffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,UpBuffer); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,DnBuffer); SetIndexBuffer(3,trend); SetIndexBuffer(4,Del); SetIndexBuffer(5,AvgDel); string short_name; //---- indicator line IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); //---- name for DataWindow and indicator subwindow label short_name="NonLagMA["+Length+"]TF("+TimeFrame+")"; IndicatorShortName(short_name); SetIndexLabel(0,""+short_name+""); SetIndexLabel(1,""+short_name+""); SetIndexLabel(2,""+short_name+""); //---- SetIndexShift(0,Displace*TimeFrame/Period()); SetIndexShift(1,Displace*TimeFrame/Period()); SetIndexShift(2,Displace*TimeFrame/Period()); SetIndexEmptyValue(0,EMPTY_VALUE); SetIndexEmptyValue(1,EMPTY_VALUE); SetIndexEmptyValue(2,EMPTY_VALUE); SetIndexDrawBegin(0,Length*Cycle+Length+1); SetIndexDrawBegin(1,Length*Cycle+Length+1); SetIndexDrawBegin(2,Length*Cycle+Length+1); //---- Coeff = 3*pi; Phase = Length-1; Len = Length*4 + Phase; ArrayResize(alfa,Len); Weight=0; for (i=0;iPeriod()) { int PerINT=TimeFrame/Period()+1; datetime TimeArr[]; ArrayResize(TimeArr,PerINT); ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); for(i=0;i=TimeArray[0]) { //---- /*********************************************************** Refresh buffers: buffer[i] = buffer[0]; ************************************************************/ MABuffer[i]= MABuffer[0]; UpBuffer[i]= UpBuffer[0]; DnBuffer[i]= DnBuffer[0]; //---- } } } //+++++++++++++++++++++++++++++++++++++++++++++ Raff ++++++ return(0); }