//+------------------------------------------------------------------+ //| Trigger Line | //| Copyright © 2005 dwt5 and adoleh2000 | //|mtf 2008forexTSD.com ml ki http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005 dwt5 and adoleh2000 " #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Red #property indicator_color2 Red #property indicator_color3 Blue #property indicator_color4 Blue #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; //int width; extern int Rperiod = 15; extern int LSMA_Period = 5; extern int Shift_=0; extern int TimeFrame = 0; extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN"; int Draw4HowLong; int shift; int i; int j; int loopbegin; int length; int lsma_length; double lengthvar; double tmp ; double tmp2 ; double wt[]; double sum[]; double lsma_sum[]; double lsma_ma[]; double middle[]; int c; string IndicatorFileName; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 7 additional buffers are used for counting. IndicatorBuffers(7); //---- drawing settings SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(3,ExtMapBuffer4); SetIndexStyle(3,DRAW_LINE); if(TimeFrame==0) TimeFrame = Period(); // SetIndexShift(0,Shift_*TimeFrame/Period()); SetIndexShift(1,Shift_*TimeFrame/Period()); SetIndexShift(2,Shift_*TimeFrame/Period()); SetIndexShift(3,Shift_*TimeFrame/Period()); SetIndexLabel(1,"TL("+Rperiod+"|"+LSMA_Period+")["+TimeFrame+"]"); SetIndexLabel(2,"TL("+Rperiod+"|"+LSMA_Period+")["+TimeFrame+"]"); SetIndexBuffer(4,sum); SetIndexBuffer(5,wt); SetIndexBuffer(6,lsma_ma); IndicatorShortName("TriggL ("+Rperiod+"|"+LSMA_Period+")["+TimeFrame+"] "); if (TimeFrame < Period()) TimeFrame = Period(); IndicatorFileName = WindowExpertName(); //---- initialization done return(0); } int start() { int counted_bars=IndicatorCounted(); int limit,i; if(counted_bars < 0) return(-1); limit = Bars-counted_bars; if (TimeFrame != Period()) { limit = MathMax(limit,TimeFrame/Period()); datetime TimeArray[]; ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame); for(i=0,int y=0; i<limit; i++) { if(Time[i]<TimeArray[y]) y++; ExtMapBuffer1 [i] = iCustom(NULL,TimeFrame,IndicatorFileName,Rperiod,LSMA_Period,0,0,y); ExtMapBuffer2 [i] = iCustom(NULL,TimeFrame,IndicatorFileName,Rperiod,LSMA_Period,0,1,y); ExtMapBuffer3 [i] = iCustom(NULL,TimeFrame,IndicatorFileName,Rperiod,LSMA_Period,0,2,y); ExtMapBuffer4 [i] = iCustom(NULL,TimeFrame,IndicatorFileName,Rperiod,LSMA_Period,0,3,y); } return(0); } Draw4HowLong = Bars-Rperiod - 5; //Rperiod = 20 length = Rperiod; //length now = 20 lsma_length = LSMA_Period; loopbegin = Draw4HowLong - length - 1; for(shift = loopbegin; shift >= 0; shift--) // MAIN For Loop { sum[1] = 0; for(i = length; i >= 1 ; i--) //LSMA loop { lengthvar = length + 1; //lengthvar = 21 lengthvar /= 3; //lengthvar = 7 tmp = 0; tmp = ( i - lengthvar)*Close[length-i+shift]; //tmp = 20 - 7 * close[20-i+shift] sum[1]+=tmp; } wt[shift] = sum[1]*6/(length*(length+1)); j = shift; lsma_ma[shift] = wt[j+1] + (wt[j]-wt[j+1])* 2/(lsma_length+1); //========== COLOR CODING =========================================== ExtMapBuffer1[shift] = wt[shift]; ExtMapBuffer2[shift] = lsma_ma[shift]; ExtMapBuffer3[shift] = wt[shift]; ExtMapBuffer4[shift] = lsma_ma[shift]; if (wt[shift] < lsma_ma[shift]) { ExtMapBuffer4[shift] = EMPTY_VALUE; ExtMapBuffer3[shift] = EMPTY_VALUE; } } } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Custom Indicators Used:
IndicatorFileName
Order Management characteristics:
Other Features: