Parabolic SAR Color - Alert(2)
Download scriptThis tool is a visual trading assistant designed for the MetaTrader platform. It automates the tracking of the Parabolic SAR (Stop and Reverse) indicator, a common technical analysis tool used to identify potential trend reversals in financial markets.
Core Functionality
The primary purpose of this script is to provide clear, color-coded visual cues on your trading charts to help distinguish between "Up" trends and "Down" trends. Instead of relying on the standard Parabolic SAR dots alone, this tool categorizes the market movement into two distinct visual channels:
- Upward Trend Identification: When the market logic suggests a bullish move, the script identifies these points and marks them using a specific visual style (Dark Green).
- Downward Trend Identification: When the logic shifts to suggest a bearish move, the script highlights these points with a different visual style (Red).
How the Logic Works
The script continuously scans the price data of your chosen currency pair or asset. It calculates the Parabolic SAR value based on three customizable parameters: Step, Maximum, and Precision.
For every new price movement, the script performs a comparison:
- Trend Shift Detection: It checks if the calculated SAR value has moved above or below the current high price of the asset.
- Color Assignment: Based on that comparison, it "assigns" the data point to either the Up Channel or the Down Channel.
- Visual Rendering: It then draws dots on your chart at those specific prices, allowing you to see the trend flow intuitively through color changes rather than just numerical values.
Automated Alerts
Beyond visual cues, the script includes a notification system. It is programmed to monitor the market in real-time and trigger an instant alert (pop-up message) the moment the Parabolic SAR channel flips direction.
- It will notify you when the trend moves from "Down" to "Up."
- It will notify you when the trend moves from "Up" to "Down."
This ensures that even if you are not looking at your charts constantly, you can receive immediate feedback on significant trend shifts, helping you react more quickly to market volatility.
//+------------------------------------------------------------------+
//| SAR_COLOR.mq4 |
//| Kalenzo |
//| http://www.foreksik.prv.pl |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link "http://www.foreksik.prv.pl"
#property indicator_color1 DarkGreen
#property indicator_color2 Red
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 2
#property indicator_width2 2
double sarUp[],sarDn[];//buffers
extern bool AlertsEnabled=true;
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