//+------------------------------------------------------------------+ //| Trigger Line | //| Copyright © 2005 dwt5 and adoleh2000 | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ //mod #property copyright "Copyright © 2005 dwt5 and adoleh2000 " #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 DodgerBlue #property indicator_color4 Tomato #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; int width; extern int Rperiod = 15; extern int LSMA_Period = 5; extern int LineSigMode = 1; extern double arrowDist =0.55; extern bool Alerts = false; extern bool AlertBox = true; extern bool AlertEmail = false; extern bool playSoundfiles = true; extern string soundfileUpSig = "alert.wav"; extern string soundfileDnSig = "timeout.wav"; extern string LineSignalMode = "lines-0, lines&sig-1, sig-2"; 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; bool TurnedUp = false; bool TurnedDown = false; double arrplot,arrplot1; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 7 additional buffers are used for counting. IndicatorBuffers(7); //---- drawing settings SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer(1,ExtMapBuffer2); if (LineSigMode!=2){ SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); } else { SetIndexStyle(0,DRAW_NONE); SetIndexStyle(1,DRAW_NONE); } SetIndexBuffer(2,ExtMapBuffer3); SetIndexBuffer(3,ExtMapBuffer4); SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE); if (LineSigMode>0){ SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,233); SetIndexEmptyValue(2,EMPTY_VALUE); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,234); SetIndexEmptyValue(3,EMPTY_VALUE); } SetIndexBuffer(4,sum); SetIndexBuffer(5,wt); SetIndexBuffer(6,lsma_ma); //---- initialization done return(0); } int start() { 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; } if (LineSigMode>0) { ExtMapBuffer3[shift]= EMPTY_VALUE; ExtMapBuffer4[shift]= EMPTY_VALUE; if (wt[shift]<lsma_ma[shift] && wt[shift+1]>=lsma_ma[shift+1]) ExtMapBuffer4[shift] = lsma_ma[shift]+arrowDist*iATR(NULL,0,7,shift); if (wt[shift]>lsma_ma[shift] && wt[shift+1]<=lsma_ma[shift+1]) ExtMapBuffer3[shift] = lsma_ma[shift]-arrowDist*iATR(NULL,0,7,shift); } } if (Alerts) { if (wt[1] > lsma_ma[1]) { if (!TurnedUp) { if (AlertBox) Alert ("Triggerlines turned up on ",Symbol()," M",Period()); if (AlertEmail)SendMail("Triggerlines turned up on ",Symbol()+" M"+Period()+" at"+Bid ); if (playSoundfiles) PlaySound(soundfileUpSig); TurnedUp = true; TurnedDown = false; } } if (wt[1] < lsma_ma[1]) { if (!TurnedDown) { if (AlertBox) Alert ("Triggerlines turned down on ",Symbol()," M",Period()); if (AlertEmail)SendMail("Triggerlines turned down on ",Symbol()+" M"+Period()+" at"+Bid ); if (playSoundfiles) PlaySound(soundfileDnSig); TurnedDown = true; TurnedUp = false; } } } } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_NONE
Implements a curve of type DRAW_ARROW
Indicators Used:
Indicator of the average true range
Custom Indicators Used:
Order Management characteristics:
Other Features:
It sends emails
It plays sound alerts