sar_color
Download scriptThis tool is designed to provide traders with a visual and auditory signal regarding market momentum by monitoring the relationship between price movement and the Parabolic Sar indicator. Instead of just showing a standard line, this script dynamically categorizes market trends into two distinct visual channels based on specific price thresholds.
Core Functionality
The logic operates by continuously calculating the Parabolic Sar value and comparing it against the highest price reached during a specific period. The goal is to identify "breakouts" or shifts in trend direction.
- Trend Identification: The script looks for moments where the current price interacts with the calculated Parabolic Sar value.
- Directional Filtering: It differentiates between upward and downward momentum by checking if the price remains above or falls below the indicator's threshold. This creates a clear visual distinction on the chart, using two different colors to represent "Up Channels" and "Down Channels."
Visual and Audio Alerts
To ensure that traders do not have to watch the charts constantly, the script includes an automated notification system:
- Color Coding: The indicator renders dots on the chart that change appearance based on whether the market is favoring an upward or downward trajectory.
- Real-Time Notifications: When the logic detects a definitive shift in the trend—specifically when the Sar channel flips from one state to another—the script triggers an instant audio alert.
- Smart Alerting: The system is designed to be "intelligent" regarding notifications; it ensures that you only receive one alert per new bar, preventing repetitive sounds and ensuring the trader is notified of the initial trend change without unnecessary noise.
Key Parameters
The behavior of the script can be fine-tuned through several user-defined settings:
- Step & Maximum: These values determine the sensitivity and acceleration of the Parabolic Sar calculation, allowing users to decide how quickly the indicator reacts to price changes.
- Precision: This ensures the calculations are rounded to a specific decimal point for consistency across different currency pairs.
- Sound Toggle: A simple switch that allows traders to enable or disable the audio alerts based on their personal trading preference.
//+------------------------------------------------------------------+
//| 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