Laguerre+Alert_modified

Download script
Author: mladen modified by TIMEX, modified by WSAStartup
Laguerre+Alert_modified

The Laguerre RSI is a specialized technical analysis tool designed to monitor market momentum and price velocity. By leveraging the Laguerre filter—a mathematical approach known for reducing "noise" while maintaining responsiveness—this script provides traders with a clearer view of market trends compared to standard oscillators.

Core Functionality

The primary purpose of this script is to track the relative strength of an asset's price movements and identify specific momentum shifts. It operates on a scale of 0 to 1, providing a condensed visual representation of whether the current price action is accelerating in an upward or downward direction.

Key Logic Components

1. Signal Identification (Crossings) The script is programmed to detect specific "breakout" moments where the momentum changes direction relative to predefined thresholds:

  • Downward Pressure: When the indicator value drops below a high threshold (Level 1), the script identifies a significant shift in bearish momentum.
  • Upward Pressure: When the indicator value rises above a low threshold (Level 3), the script identifies a significant shift in bullish momentum.

2. Visual Markers To make these shifts easy for the user to see, the script uses dynamic visual cues:

  • It can display specific arrows on the chart to pinpoint exactly where these momentum crossings occurred.
  • Depending on the settings, it can also draw visual "zones" or boundaries on the indicator window to help traders quickly identify overbought or oversold territory at a glance.

3. Automated Notifications One of the primary features of this script is its proactive alert system. Rather than requiring a trader to watch the screen constantly, the logic includes an automated monitoring sequence:

  • Detection: The script continuously scans every new price tick for crossings of the defined levels.
  • Execution: Once a crossing is detected, it triggers a multi-channel notification system. This can include pop-up alerts on the trading platform, audible sound signals, or even direct emails (if configured), ensuring the trader is notified of momentum shifts in real-time.

4. Customization and Stability The script is designed to be modular. It allows for adjustments in "Gamma" (which controls the smoothness of the calculation) and custom threshold levels. Additionally, it includes a unique naming system that prevents conflicts with other indicators on the same chart, ensuring that the visual data remains clean and organized.

Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt sends emailsIt plays sound alerts
9 Views
0 Downloads
0 Favorites
Laguerre+Alert_modified
//+------------------------------------------------------------------+
//|                                           LaGuerre RSI v1.00.mq4 |
//|                                                           mladen |
//+------------------------------------------------------------------+
#property copyright "mladen modified by TIMEX, modified by WSAStartup"
#property link      ""

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_width1 2
#property indicator_width2 1
#property indicator_width3 1
#property indicator_color2 White
#property indicator_color3 White


extern string strLaguerreName="Laguerre-ACS1";
extern double Gama          = 0.55;
extern int    PriceType     = 0;
extern double Level1        = 0.85;
extern double Level2        = 0.45;
extern double Level3        = 0.15;
extern bool   ShowLevels    = false; 
extern bool   ShowCrossings = true; 
extern bool   alertsOn      = true;
extern bool   alertsMessage = true;
extern bool   alertsSound   = false;
extern bool   alertsEmail   = false;
extern color  LevelsColor   = C'30,33,36';

//
//
//
//
//

double MainBuffer[];
double CUpBuffer[];
double CDnBuffer[];
double L0[];
double L1[];
double L2[];
double L3[];
string ShortName;


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
{
   IndicatorBuffers(7);
   SetIndexBuffer(0, MainBuffer);
   SetIndexBuffer(1, CUpBuffer);
   SetIndexBuffer(2, CDnBuffer);
   SetIndexBuffer(3, L0);
   SetIndexBuffer(4, L1);
   SetIndexBuffer(5, L2);
   SetIndexBuffer(6, L3);

   //
   //
   //
   //
   //
   
   if (ShowCrossings)
      {
         SetIndexStyle(1,DRAW_ARROW);         
         SetIndexStyle(2,DRAW_ARROW);         
         SetIndexArrow(1,233);
         SetIndexArrow(2,234);
        
      }
   else
      {
         SetIndexStyle(1,DRAW_NONE);
         SetIndexStyle(2,DRAW_NONE);
      }      

   //
   //
   //
   //
   //
   
   ShortName=MakeUniqueName("Laguerre Alert "," ("+DoubleToStr(Gama,2)+")");
   IndicatorShortName(ShortName);
   SetIndexLabel(0,"Laguerre RSI");
   return(0);
}
int deinit()
{
   DeleteBounds();
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int start()
{
   int    counted_bars=IndicatorCounted();
   int    i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = Bars - counted_bars;

   //
   //
   //
   //
   //
   
   for(i = limit; i >= 0 ; i--)
      {
         MainBuffer[i] = iCustom(NULL, 0, strLaguerreName,Gama,1000000000,2,0,i);
         CUpBuffer[i]  = EMPTY_VALUE;
         CDnBuffer[i]  = EMPTY_VALUE;
               if (MainBuffer[i] < Level1 && MainBuffer[i+1] > Level1) CDnBuffer[i] = Level1;
               if (MainBuffer[i] > Level3 && MainBuffer[i+1] < Level3) CUpBuffer[i] = Level3;
      }            
   
   //
   //
   //
   //
   //

   if (ShowLevels) UpdateBounds();
   if (alertsOn) CheckCrossings();
   return(0);
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void CheckCrossings()
{
   
   if (CDnBuffer[0] == Level1) doAlert("level "+DoubleToStr(Level1,2)+" crossed down");
   if (CUpBuffer[0] == Level3) doAlert("level "+DoubleToStr(Level3,2)+" crossed up");
   
}

//
//
//
//
//

void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];

          //
          //
          //
          //
          //

          message =  StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Laguerre ",doWhat);
             if (alertsMessage) Alert(message);
             if (alertsEmail)   SendMail(StringConcatenate(Symbol()," Laguerre line crossing"),message);
             if (alertsSound)   PlaySound("alert2.wav");
      }
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

string MakeUniqueName(string first, string rest)
{
   string result = first+(MathRand()%1001)+rest;

   while (WindowFind(result)> 0)
          result = first+(MathRand()%1001)+rest;
   return(result);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void DeleteBounds()
{
   ObjectDelete(ShortName+"-1");
   ObjectDelete(ShortName+"-2");
   ObjectDelete(ShortName+"-3");
}
void UpdateBounds()
{
   if (Level1 > 0) SetUpBound(ShortName+"-1",1.0000     ,Level1);
   if (Level2 > 0) SetUpBound(ShortName+"-2",Level2*1.01,Level2*0.99);
   if (Level3 > 0) SetUpBound(ShortName+"-3",Level3     ,     0.0000);
}
void SetUpBound(string name, double up, double down,int objType=OBJ_RECTANGLE)
{
   if (ObjectFind(name) == -1)
      {
         ObjectCreate(name,objType,WindowFind(ShortName),0,0);
         ObjectSet(name,OBJPROP_PRICE1,up);
         ObjectSet(name,OBJPROP_PRICE2,down);
         ObjectSet(name,OBJPROP_COLOR,LevelsColor);
         ObjectSet(name,OBJPROP_BACK,true);
         ObjectSet(name,OBJPROP_TIME1,iTime(NULL,0,Bars-1));
      }
   if (ObjectGet(name,OBJPROP_TIME2) != iTime(NULL,0,0))
       ObjectSet(name,OBJPROP_TIME2,    iTime(NULL,0,0));
}

Comments