Parabolic SAR Color - Alert
Download scriptThis tool is designed to provide a visual and audible signal based on the Parabolic SAR (Stop and Reverse) indicator, a popular technical analysis tool used to identify potential trend reversals in financial markets.
Core Functionality
The script functions by monitoring price movement and comparing it against the calculated values of the Parabolic SAR. Instead of just showing a standard line, this script categorizes the SAR data into two distinct visual channels: an "Up Channel" and a "Down Channel."
How the Logic Works
The tool constantly scans the market data to determine where the current price sits in relation to the Parabolic SAR value:
- Downward Trend Identification: When the Parabolic SAR value is higher than the high price of a candle, the script identifies this as a downward movement. It highlights this data in one color (Magenta) to alert the user that the trend is currently bearish.
- Upward Trend Identification: Conversely, when the Parabolic SAR value falls below the high price of a candle, the script recognizes this as an upward movement. It highlights this data in a different color (Yellow) to indicate a bullish trend.
Automated Notifications
Beyond just changing colors on your chart, the script includes an optional alert system. If you enable the alerts in the settings:
- It detects the exact moment the Parabolic SAR "flips" from one state to another.
- It sends a real-time notification pop-up on your platform.
- It specifies which currency pair and timeframe the shift occurred on, allowing you to react quickly to potential trend changes without needing to watch the screen constantly.
Key Features for the User
- Visual Clarity: By separating the data into two distinct colored dots, it makes it much easier to see at a glance whether the current momentum is shifting up or down.
- Customizable Sensitivity: The logic uses specific "Step" and "Maximum" parameters which determine how aggressively the indicator reacts to price changes.
- Smart Alerting: The script is designed to trigger an alert only once per trend shift, preventing your screen from being flooded with repetitive notifications during a single move.
//+------------------------------------------------------------------+
//| SAR_COLOR.mq4 |
//| Kalenzo |
//| http://www.foreksik.prv.pl |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link "http://www.foreksik.prv.pl"
#property indicator_color1 Magenta
#property indicator_color2 Yellow
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 2
#property indicator_width2 2
double sarUp[],sarDn[];//buffers
extern bool AlertsEnabled=false;
extern double Step = 0.04;//was .01
extern double Maximum = 0.5;
extern int Precision = 7;
double alertBar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,STYLE_DOT);
SetIndexStyle(1,DRAW_ARROW,STYLE_DOT);
SetIndexBuffer(0,sarUp);
SetIndexBuffer(1,sarDn);
SetIndexArrow(0,115);
SetIndexArrow(1,115);
IndicatorShortName("SAR COLORED");
SetIndexLabel(0,"SAR Up Channel");
SetIndexLabel(1,"SAR Down Channel");
SetIndexDrawBegin(0,2);
SetIndexDrawBegin(1,2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//----
for(int i = 0; i<limit ;i++)
{
double sar = NormalizeDouble(iSAR(Symbol(),0,Step,Maximum,i),Precision);
if(sar >= iHigh(Symbol(),0,i))
{
if(AlertsEnabled==true && sarUp[i] == 0 && Bars>alertBar)
{
Alert("Parabolic SAR Going Down on ",Symbol(),"-",Period());
alertBar = Bars;
}
sarUp[i] = sar;
sarDn[i] = 0;
}
else
{
if(AlertsEnabled==true && sarDn[i] == 0 && Bars>alertBar)
{
Alert("Parabolic SAR Channel Going Up on ",Symbol(),"-",Period());
alertBar = Bars;
}
sarUp[i] = 0;
sarDn[i] = sar;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments