iMAXalert2
Download scriptThe iMAXalert tool is a custom technical analysis indicator designed to help traders identify trend shifts by smoothing out market "noise." It utilizes sophisticated mathematical filtering—specifically a variation of the Optimal Detrending method—to visualize price action more clearly on your trading chart.
How it Works
1. Trend Smoothing and Calculation The script processes the high and low prices of the market to create two distinct visual lines:
- The Primary Line (Aqua): This is the main moving indicator that calculates a smoothed path of the current price. It uses a weighted mathematical formula to balance past price data with current movements, helping to filter out minor fluctuations that might otherwise trigger "false" signals.
- The Signal Line (Red): This line follows the primary line but is slightly shifted forward in time. By creating this offset, the tool allows for a visual comparison between current momentum and recent history.
2. Smart Threshold Awareness One of the key features of this script is its ability to adapt to different trading timeframes. The tool automatically detects whether you are looking at a 1-minute chart, a 4-hour chart, or a Monthly chart. It then applies a specific "Threshold" (a minimum distance required for a signal) based on that timeframe. This ensures that the indicator remains sensitive enough for fast-moving scalping while remaining stable enough for long-term swing trading.
3. Automated Alert System The script is designed to act as an automated lookout for the trader. It monitors the relationship between the Aqua and Red lines:
- Upward Trend Signal: When the Aqua line crosses above the Red line by a specific distance, it identifies a potential bullish shift.
- Downward Trend Signal: When the Aqua line crosses below the Red line by a specific distance, it identifies a potential bearish shift.
4. Alert Management To prevent "alert fatigue" (where the software sends dozens of notifications for the same move), the script includes a built-in cooldown timer. Once an alert is triggered, the system will wait for a user-defined amount of time before sounding another notification, ensuring you only receive meaningful updates as the market evolves.
Summary for the User
Essentially, this tool acts as a sophisticated filter that "cleans" the price chart so you can see the underlying trend more clearly. It watches the relationship between two calculated lines and sends you a notification exactly when those lines cross significantly, providing a clear signal for potential trend reversals or continuations across various timeframes.
/*+-------------------------------------------------------------------+
| iMAXalert.mq4 |
| |
| "Modified Optimum Elliptic Filter" |
| Source of calculations: |
| Stocks & Commodities vol 18:7 p20-29 |
| Optimal Detrending by John F. Ehlers |
| |
| Crafted by Wylie |
| dazzle.html@live.com |
+-------------------------------------------------------------------+*/
#property copyright "Wylie"
#property link "dazzle.html@live.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_width1 1
#property indicator_width2 1
/*+-------------------------------------------------------------------+
| iMAXalert Parameters |
+-------------------------------------------------------------------+*/
extern int Ph2shiftRed = 1;
extern bool EnableAlerts = true;
extern string a_ = "Stop Alerts from sounding more than";
extern string b_ = "once every ? seconds (+ 1 tick time).";
extern int AlertStopTime = 20;
int buffers = 2,
Threshold, // Pips above crossing up, or pips below crossing down.
// Change the values in the init() function if you need to.
MinBars,c;
double ExtMapBuffer0[],
ExtMapBuffer1[];
string Chart;
static datetime AlertX[2];
/*+-------------------------------------------------------------------+
| iMAXalert Initialization |
+-------------------------------------------------------------------+*/
int init()
{
IndicatorBuffers(2);
// Index Buffer 0
SetIndexBuffer(0,ExtMapBuffer0);
SetIndexShift(0,0);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,Aqua);
// Index Buffer 1
SetIndexBuffer(1,ExtMapBuffer1);
SetIndexShift(1,0);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Red);
IndicatorShortName("iMAX");
MinBars = 20;
switch(Period())
{case 1: Chart = "M1"; Threshold = 1;break;
case 2: Chart = "M5"; Threshold = 1;break;
case 3: Chart = "M15"; Threshold = 2;break;
case 4: Chart = "M30"; Threshold = 2;break;
case 5: Chart = "H1"; Threshold = 5;break;
case 6: Chart = "H4"; Threshold = 10;break;
case 7: Chart = "D1"; Threshold = 10;break;
case 8: Chart = "W5"; Threshold = 30;break;
case 9: Chart = "MN"; Threshold = 30;break;}
return (0);
} // int init()
/*+-------------------------------------------------------------------+
| iMAXalert Main cycle |
+-------------------------------------------------------------------+*/
int start()
{
if(Bars <= MinBars){return (0);}
double b0 = ExtMapBuffer0[0],
b1 = ExtMapBuffer0[1],
r0 = ExtMapBuffer1[0],
r1 = ExtMapBuffer1[1];
int countedBars = IndicatorCounted();
if(countedBars < 0){return (-1);}
if(countedBars > 0){countedBars--;}
int c,limit = Bars - countedBars - 1;
double x = 0.5;
for(c = limit;c >= 0;c--)
{ExtMapBuffer0[c] = (0.13785 * (2 * ((High[c] + Low[c]) * x) - ((High[c+1] + Low[c+1]) * x)))
+ (0.0007 * (2 * ((High[c+1] + Low[c+1]) * x) - ((High[c+2] + Low[c+2]) * x)))
+ (0.13785 * (2 * ((High[c+2] + Low[c+2]) * x) - ((High[c+3] + Low[c+3]) * x)))
+ (1.2103 * ExtMapBuffer0[c + 1] - 0.4867 * ExtMapBuffer0[c + 2]);
ExtMapBuffer1[c] = ExtMapBuffer0[c+Ph2shiftRed];
} // for(c = limit;c >= 0;c--)
if(EnableAlerts)
{if(b0 > r0 + (Threshold * Point) && b1 < r1 + (Threshold * Point))
{sendAlert(0,(getDateTime()+" "+Symbol()+" "+Chart+" iMAX signals up trend crossing."));}
if(b0 < r0 - (Threshold * Point) && b1 > r1 - (Threshold * Point))
{sendAlert(1,(getDateTime()+" "+Symbol()+" "+Chart+" iMAX signals down trend crossing."));}}
return (0);
} // int start()
/*+-------------------------------------------------------------------+
| End iMAXalert Main cycle |
+-------------------------------------------------------------------+*/
/*+-------------------------------------------------------------------+
| iMAXalert support functions |
+-------------------------------------------------------------------+*/
/*+-------------------------------------------------------------------+
| *** Alert processing function |
+-------------------------------------------------------------------+*/
void sendAlert(int AlertNum,string AlertText)
{
if(TimeCurrent() > AlertX[AlertNum] + AlertStopTime)
{AlertX[AlertNum] = TimeCurrent();
/* Add a sound file here if you want another form of alert...
The sound file must be located in the MT4 "sounds" file folder
and must be a .wav format file. */
// PlaySound("alert.wav");
Alert(AlertText);}
return(0);
} //
/*+-------------------------------------------------------------------+
| *** Date/Time display function |
+-------------------------------------------------------------------+*/
string getDateTime()
{
string dsplyDateTime = TimeToStr(TimeCurrent(),TIME_DATE|TIME_DATE)+" "+
TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);
return(dsplyDateTime);
} // datetime getTime()
/*+-------------------------------------------------------------------+
| End iMAXalert support functions |
+-------------------------------------------------------------------+*/
Comments