TriggerLines_SigAlertEmailSounds_cw

Download script
TriggerLines_SigAlertEmailSounds_cw

This indicator, known as the "Trigger Line," is designed to help traders visualize price momentum and identify potential trend reversals through a dual-line tracking system. It functions by comparing a smoothed moving average against a dynamic weighted calculation to signal whether the market is gaining or losing strength.

Core Logic and Visuals

The script calculates two primary components on your chart:

  1. The Weighted Trend: This is a modified moving average that gives different importance (weights) to price data points. Unlike a standard average, it helps emphasize recent price action to provide a more responsive view of the current trend.
  2. The Signal Line (LSMA): The script calculates a "Least Squares" inspired smoothing of the weighted trend. This acts as the baseline.

By plotting these two lines together, you can see the relationship between current momentum and the smoothed average. When the weighted line sits above the signal line, it suggests bullish sentiment; when it falls below, it indicates bearish sentiment.

Signal Generation

The tool is designed to detect "crosses"—specific moments where the weighted trend shifts from one side of the signal line to the other:

  • Bullish Signals: When the weighted trend moves from below to above the signal line, the script identifies a potential upward shift. Depending on your settings, this can be shown as a specific color change or an upward-pointing arrow.
  • Bearish Signals: Conversely, when the trend drops from above to below the signal line, it identifies a potential downward shift, marked by a corresponding color change or a downward-pointing arrow.

Smart Alerts and Notifications

To ensure you don't have to watch the charts constantly, the script includes a comprehensive notification system. It monitors the relationship between the lines in real-time and triggers an alert only at the exact moment the "cross" occurs. These notifications can be customized to provide:

  • On-Screen Pop-ups: Instant visual alerts on your trading platform.
  • Email Notifications: Sending a summary of the trend change directly to your inbox.
  • Audio Alerts: Playing specific sound files (like "alert.wav" or "timeout.wav") to provide an audible cue for entries or exits.

Summary for the User

In simple terms, this script acts as a "momentum filter." It smooths out market noise so you can see the underlying trend more clearly. By watching where the weighted price action crosses the signal line, you can identify high-probability areas for potential trend changes, supported by real-time alerts to keep you informed of every move.

Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1It sends emailsIt plays sound alerts
7 Views
0 Downloads
0 Favorites
TriggerLines_SigAlertEmailSounds_cw
//+------------------------------------------------------------------+
//|                                                     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 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] = High[shift]+arrowDist*iATR(NULL,0,7,shift);

         if (wt[shift]>lsma_ma[shift] && wt[shift+1]<=lsma_ma[shift+1])
         ExtMapBuffer3[shift] =  Low[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;
         }
      }
   }
}
//+------------------------------------------------------------------+

Comments