sar_color_v2
Download scriptThis tool is designed to enhance your trading charts by providing a visual and audible signal based on the Parabolic SAR (Stop and Reverse) indicator. It simplifies how you interpret market trends by identifying the shift between upward and downward momentum in real-time.
Core Functionality
The script monitors price movements and calculates the "SAR" value—a series of dots that trail the price to help determine potential trend reversals. Instead of just showing a single stream of data, this tool categorizes these signals into two distinct visual paths: one for upward momentum and one for downward momentum.
How it Works
The logic operates by constantly comparing the current market high against the calculated SAR value. It evaluates the relationship between these two points to determine the direction of the trend:
- Trend Identification: When the tool detects that the price has moved above or below a specific threshold relative to the SAR calculation, it identifies a shift in the market's direction.
- Visual Differentiation: The script plots different colored dots (Magenta and Yellow) on your chart. These colors act as visual cues, allowing you to see at a glance whether the tool perceives the current trend as moving up or down.
- Real-Time Alerts: One of the primary features of this script is its notification system. When the trend flips—for example, switching from an upward trend to a downward trend—the script will trigger an instant audio alert.
- Smart Notifications: To ensure you aren't overwhelmed by constant noise, the tool includes logic to prevent repetitive alerts. It is designed to notify you only once per trend change on a specific bar, ensuring that you receive a clear signal the moment a reversal occurs.
Customization and Precision
The tool provides several adjustable parameters to tailor it to your specific trading style:
- Sensitivity: You can adjust the "Step" and "Maximum" values, which dictate how quickly or slowly the indicator reacts to price fluctuations.
- Precision: This ensures that the calculations are rounded to a specific decimal place, providing clean data on your screen.
- Audio Toggle: You have the option to turn the sound alerts on or off depending on your preference for manual chart monitoring versus automated notifications.
//+------------------------------------------------------------------+
//| 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 double Step=0.05;//was .01
extern double Maximum=0.2;
extern int Precision=4;
extern bool SoundON=true;
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,108);
SetIndexArrow(1,108);
//
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(SoundON==true && sarUp[i]==0 && Bars>alertBar)
{
Alert("Sar Channel Going Down on ",Symbol(),"-",Period());
alertBar=Bars;
}
sarUp[i]=sar;
sarDn[i]=0;
}
else
{
if(SoundON==true && sarDn[i]==0 && Bars>alertBar)
{
Alert("Sar Channel Going Up on ",Symbol(),"-",Period());
alertBar=Bars;
}
sarUp[i]=0;
sarDn[i]=sar;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments