Parabolic_Alert_Mod
Download scriptThis script is designed to function as a specialized technical analysis tool that identifies potential trend reversals in financial markets. It uses a "Parabolic" logic, which is often used by traders to determine when a market movement has lost its momentum and is likely to head in the opposite direction.
Core Logic Overview
The primary purpose of this script is to track price action and plot dynamic visual markers on a chart. These markers act as "trailing" indicators that follow the price. When the price breaks through these markers, the logic identifies a reversal of the current trend and triggers an alert.
How the System Functions
1. Trend Identification and Tracking The script constantly monitors the high and low prices of each candle. It establishes a "state" for the market—determining whether the current momentum is trending upwards (Long) or downwards (Short). As the price moves, the script calculates a dynamic boundary line based on two primary factors:
- Acceleration: A "Step" value that determines how quickly the indicator reacts to new price extremes.
- Maximum Limit: A cap on acceleration to prevent the indicator from moving too erratically during high-volatility spikes.
2. Dynamic Boundary Calculation Instead of a fixed line, the script calculates a floating point based on the distance between the current price and the highest (or lowest) point reached during the current trend move.
- In an uptrend, it focuses on capturing new highs to project a trailing support level.
- In a downtrend, it focuses on capturing new lows to project a trailing resistance level.
3. Reversal Detection (The "Alert" Logic) The script is specifically looking for "breakout" moments.
- Sell Signals: If the market is in an upward trend and the price drops below the calculated support boundary, the script recognizes this as a potential reversal to a downtrend.
- Buy Signals: If the market is in a downward trend and the price rises above the calculated resistance boundary, it recognizes a potential reversal to an uptrend.
User Notifications
One of the key features of this specific version is its automated notification system. When a reversal is detected in real-time (on the most recent candle), the script can perform three actions simultaneously:
- Audio Alerts: It plays specific sound files (such as a "thunder" sound) to notify the trader immediately.
- Visual On-Screen Comments: It displays text directly on the trading chart indicating whether it is a "Buy Alert" or a "Sell Alert," along with the exact time of the occurrence.
- Email Notifications: If enabled, the script can automatically send an email to the user containing the specific signal type, the current price (Ask/Bid), the date, and the specific trading symbol/timeframe.
Summary for the User
Essentially, this tool acts as an automated "lookout." It calculates where the trend boundaries should be based on historical highs and lows; the moment the price "breaks" through those boundaries, it sounds an alarm and sends a message to tell you that the trend may have flipped.
//+------------------------------------------------------------------+
//| Parabolic_Alert.mq4 |
//| Original file name: Parabolic.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//| Modified to give audible alarm on reversal |
//| Modified by Jim Arner, Sr. |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow
#property indicator_width1 4
#property indicator_width2 4
//---- input parameters
extern double Step=0.02;
extern double Maximum=0.2;
extern bool Enable_Alert=false;
//---- buffers
double SarBuffer[];
double SarBuffer1[];
//----
int save_lastreverse;
bool save_dirlong, save_dirshort;
double save_start;
double save_last_high;
double save_last_low;
double save_ep;
double save_sar;
extern bool mailalert = true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorDigits(Digits);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,158);
SetIndexBuffer(0,SarBuffer);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,159);
SetIndexBuffer(1,SarBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void SaveLastReverse(int last,int dir_l,int dir_s,double start,double low,double high,double ep,double sar)
{
save_lastreverse=last;
save_dirlong=dir_l;
save_dirshort=dir_s;
save_start=start;
save_last_low=low;
save_last_high=high;
save_ep=ep;
save_sar=sar;
}
//+------------------------------------------------------------------+
//| Parabolic Sell And Reverse system |
//+------------------------------------------------------------------+
int start()
{
static bool first=true;
bool dirlong, dirshort;
double start,last_high,last_low;
double ep,sar,price_low,price_high,price;
int i,counted_bars=IndicatorCounted();
string TradeTime;
//----
if(Bars<3) return(0);
//---- initial settings
i=Bars-2;
if(counted_bars==0 || first)
{
first=true;
dirlong=true;
dirshort=true;
start=Step;
last_high=-10000000.0;
last_low=10000000.0;
while(i>0)
{
save_lastreverse=i;
price_low=Low[i];
if(last_low>price_low) last_low=price_low;
price_high=High[i];
if(last_high<price_high) last_high=price_high;
if(price_high>High[i+1] && price_low>Low[i+1]) break;
if(price_high<High[i+1] && price_low<Low[i+1]) { dirlong=false; break; }
i--;
}
//---- initial zero
int k=i;
while(k<Bars)
{
SarBuffer[k]=0.0;
SarBuffer[k]=0.0;
k++;
}
//---- check further
if(dirlong) { SarBuffer[i]=Low[i+1]; ep=High[i]; }
i--;
}
else
{
i=save_lastreverse+1;
start=save_start;
dirlong=save_dirlong;
dirshort=save_dirshort;
last_high=save_last_high;
last_low=save_last_low;
ep=save_ep;
sar=save_sar;
}
//----
while(i>=0)
{
price_low=Low[i];
price_high=High[i];
//--- check for reverse
if(dirlong==true && price_low<SarBuffer[i+1])
if(dirlong==true && price_low>SarBuffer1[i+1])
{
// Print("Section 1 Code executing"," I= ",i," DirLong= ",dirlong," DirShort= ",dirshort);
SaveLastReverse(i,true,false,start,price_low,last_high,ep,sar);
start=Step; dirlong=false; dirshort=true;
// Comment("I= ",i);
if(Enable_Alert==true)
{
if (i==0)
{
PlaySound("gbpusd crash!.wav");
TradeTime = TimeToStr(CurTime(),TIME_SECONDS);
Comment("\nSell Alert","\nChart Time= ", TradeTime);
if (mailalert) SendMail("Parabolic Alert", "Buy signal at Ask="+Ask+", Bid="+Bid+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
}
}
ep=price_low; last_low=price_low;
SarBuffer[i]=last_high;
i--;
continue;
}
if(dirshort==true && price_high>SarBuffer1[i+1])
{
// Print("Section 2 Code executing"," I= ",i," DirLong= ",dirlong," DirShort= ",dirshort);
SaveLastReverse(i,false,true,start,last_low,price_high,ep,sar);
start=Step; dirlong=true; dirshort=false;
// Comment("I= ",i);
if(Enable_Alert==true)
{
if (i==0)
{
PlaySound("thunder_1.wav");
TradeTime = TimeToStr(CurTime(),TIME_SECONDS);
Comment("\nBuy Alert","\nChart Time= ", TradeTime);
if (mailalert) SendMail("Parabolic Alert", "Buy signal at Ask="+Ask+", Bid="+Bid+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
}
}
ep=price_high; last_high=price_high;
SarBuffer1[i]=last_low;
i--;
continue;
}
//---
price=SarBuffer[i+1];
sar=price+start*(ep-price);
if(dirlong)
{
/*
Comment("DirLong","\nI= ",i,"\nDirL ",dirlong,"\nDirS ",dirshort,
"\nStart= ",start,"\nLow= ",last_low,"\nHigh= ",last_high,
"\nEP= ",ep,"\nSAR= ",sar,"\nMinute= ",Minute());
*/
// Print("Section 3 Code executing"," I= ",i," DirLong= ",dirlong," DirShort= ",dirshort);
if(ep<price_high && (start+Step)<=Maximum) start+=Step;
if(price_high<High[i+1] && i==Bars-2) sar=SarBuffer[i+1];
price=Low[i+1];
if(sar>price) sar=price;
price=Low[i+2];
if(sar>price) sar=price;
if(sar>price_low)
{
SaveLastReverse(i,true,false,start,price_low,last_high,ep,sar);
start=Step; dirlong=false; dirshort=true; ep=price_low;
last_low=price_low;
SarBuffer[i]=last_high;
i--;
/*
if (i == 0)
{
Print("Section 3a Code executing"," I= ",i," DirLong= ",dirlong," DirShort= ",dirshort);
}
*/
if (dirshort && i == 0)
{
PlaySound("thunder_1.wav");
TradeTime = TimeToStr(CurTime(),TIME_SECONDS);
Comment("\nSell Alert","\nChart Time= ", TradeTime);
}
continue;
}
if(ep<price_high) { last_high=price_high; ep=price_high; }
}
if(dirshort)
{
/*
Comment("DirShort","\nI= ",i,"\nDirL ",dirlong,"\nDirS ",dirshort,
"\nStart= ",start,"\nLow= ",last_low,"\nHigh= ",last_high,
"\nEP= ",ep,"\nSAR= ",sar,"\nMinute= ",Minute());
*/
// Print("Section 4 Code executing"," I= ",i," DirLong= ",dirlong," DirShort= ",dirshort);
if(ep>price_low && (start+Step)<=Maximum) start+=Step;
if(price_low<Low[i+1] && i==Bars-2) sar=SarBuffer1[i+1];
price=High[i+1];
if(sar<price) sar=price;
price=High[i+2];
if(sar<price) sar=price;
if(sar<price_high)
{
SaveLastReverse(i,false,true,start,last_low,price_high,ep,sar);
start=Step; dirlong=true; dirshort=false; ep=price_high;
last_high=price_high;
SarBuffer1[i]=last_low;
i--;
/*
if (i == 0)
{
Print("Section 4a Code executing"," I= ",i," DirLong= ",dirlong," DirShort= ",dirshort);
}
*/
if (dirlong && i == 0)
{
PlaySound("thunder_1.wav");
TradeTime = TimeToStr(CurTime(),TIME_SECONDS);
Comment("\nBuy Alert","\nChart Time= ", TradeTime);
}
continue;
}
if(ep>price_low) { last_low=price_low; ep=price_low; }
}
SarBuffer[i]=sar;
i--;
}
// sar=SarBuffer[0];
// price=iSAR(NULL,0,Step,Maximum,0);
// if(sar!=price) Print("custom=",sar," SAR=",price," counted=",counted_bars);
// if(sar==price) Print("custom=",sar," SAR=",price," counted=",counted_bars);
//----
return(0);
}
//+------------------------------------------------------------------+
Comments