Laguerre1Alert
Download scriptThis tool is designed as a custom technical indicator for the MetaTrader platform, specifically engineered to provide traders with a visual representation of price momentum and trend direction. It operates by calculating a specialized rhythmic movement based on historical price data, helping users identify whether the market is leaning toward an overbought or oversold state.
How the Logic Works
The core functionality of this script revolves around three main stages: calculation, normalization, and notification.
1. Data Smoothing and Movement Instead of looking at raw price jumps, which can be erratic and noisy, the script uses a mathematical smoothing technique (based on Laguerre principles). It takes the current closing price and blends it with previous data points to create a fluid "flow." This helps filter out minor market vibrations, allowing the trader to see the underlying trend more clearly.
2. Momentum Tracking The script tracks the relationship between four different layers of this smoothed data. By measuring the distance between these layers, it determines the intensity of the price movement:
- If the layers are moving upward together, it indicates positive momentum.
- If they are moving downward, it indicates negative momentum. The tool then calculates a ratio based on these movements, resulting in a single value that fluctuates within a specific range (typically between 0 and 1).
3. Visual Boundaries and Signal Zones The indicator is displayed in a separate window below the main price chart. It features pre-defined horizontal levels that act as "zones of interest":
- High Levels (Sell Zone): When the indicator reaches these upper thresholds, it suggests that upward momentum may be exhausted, potentially signaling a cooling-off period or a downward turn.
- Low Levels (Buy Zone): When the indicator drops to the lower thresholds, it suggests that downward pressure may be weakening, potentially indicating a floor for the price.
User Features
The script is configured with several adjustable parameters to customize the experience:
- Sensitivity Adjustment: Users can fine-tune how "fast" or "slow" the indicator reacts to price changes via the smoothing factor.
- Historical Depth: It can be set to analyze a specific amount of past bars to ensure the calculations are based on relevant data.
- Automated Alerts: The script includes an optional audio notification system. If the momentum crosses from a "Sell Zone" back down, or from a "Buy Zone" back up, the platform will trigger a sound alert to notify the trader in real-time without them needing to watch the screen constantly.
//+------------------------------------------------------------------+
//| Laguerre.mq4 |
//| Emerald King |
//| mailto:info@emerald-king.com |
//+------------------------------------------------------------------+
#property copyright "Emerald King"
#property link "mailto:info@emerald-king.com"
#property indicator_separate_window
#property indicator_minimum -0.1
#property indicator_maximum 1.1
#property indicator_color1 DodgerBlue
#property indicator_width1 3
#property indicator_level2 0.85
#property indicator_level3 0.45
#property indicator_level4 0.15
//---- input parameters
extern double gamma=0.55;
extern int CountBars=9500;
extern double BuyLevel=0.15;
extern double SellLevel=0.85;
extern bool UseAlertSound=false;
datetime TimeStamp;
double L0 = 0;
double L1 = 0;
double L2 = 0;
double L3 = 0;
double L0A = 0;
double L1A = 0;
double L2A = 0;
double L3A = 0;
double LRSI = 0;
double CU = 0;
double CD = 0;
double val1[],
ValBar1=0;
double alertBar;
double prev;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
SetIndexBuffer(0,val1);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars);
int i;
int counted_bars=IndicatorCounted();
i=CountBars-1;
while(i>=0)
{
L0A = L0;
L1A = L1;
L2A = L2;
L3A = L3;
L0 = (1 - gamma)*Close[i] + gamma*L0A;
L1 = - gamma *L0 + L0A + gamma *L1A;
L2 = - gamma *L1 + L1A + gamma *L2A;
L3 = - gamma *L2 + L2A + gamma *L3A;
CU = 0;
CD = 0;
if (L0 >= L1) CU = L0 - L1; else CD = L1 - L0;
if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1;
if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2;
if (CU + CD != 0) LRSI = CU / (CU + CD);
val1[i] = LRSI;
if(i==1) ValBar1=LRSI;
if(UseAlertSound == true && prev != 1 && i==0 && ValBar1>SellLevel && LRSI<=SellLevel && Bars>alertBar)
{
Alert("Lagerre Sell "+ Symbol()+" Curr: ", LRSI," on ",Period());
alertBar = Bars;prev = 2;
}
if(UseAlertSound == true && prev != 2 && i==0 && ValBar1<BuyLevel && LRSI>=BuyLevel && Bars>alertBar)
{
Alert("Lagerre Buy "+ Symbol()+" Curr: ", LRSI," On ",Period());
alertBar = Bars;prev = 1;
}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments