//+------------------------------------------------------------------+ //| 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_chart_window #property indicator_buffers 5 #property indicator_color1 Maroon #property indicator_color2 Blue #property indicator_color3 Yellow #property indicator_color4 Red #property indicator_color5 DodgerBlue #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 1 #property indicator_width4 1 #property indicator_width5 1 //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double ExtMapBuffer0[]; int width; extern int Rperiod = 15; extern int LSMA_Period = 5; 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"; 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; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 7 additional buffers are used for counting. IndicatorBuffers(8); //---- drawing settings SetIndexBuffer(3,ExtMapBuffer1); SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer2); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(4,ExtMapBuffer3); SetIndexStyle(4,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer4); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer0); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(5,sum); SetIndexBuffer(6,wt); SetIndexBuffer(7,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 =========================================== ExtMapBuffer0[shift] = wt[shift]; ExtMapBuffer2[shift] = lsma_ma[shift]; ExtMapBuffer1[shift] = EMPTY_VALUE; ExtMapBuffer3[shift] = EMPTY_VALUE; ExtMapBuffer4[shift] = EMPTY_VALUE; if (wt[shift] < lsma_ma[shift]) ExtMapBuffer1[shift] = wt[shift]; if (wt[shift] > lsma_ma[shift]) { ExtMapBuffer3[shift] = wt[shift]; ExtMapBuffer4[shift] = lsma_ma[shift]; } } if (Alerts) { if (wt[1] > lsma_ma[1]) { if (!TurnedUp) { if (AlertBox) Alert ("Triggerlines turned up on ",Symbol(),"-",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(),"-",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
Indicators Used:
Custom Indicators Used:
Order Management characteristics:
Other Features:
It sends emails
It plays sound alerts