ang_AZad_Css[cw]_v1
Download scriptThis script functions as a visual trend-tracking tool designed to map out price movements on a trading chart. Rather than simply plotting the raw price, it calculates two distinct smoothed lines that attempt to capture the momentum and direction of the market.
Core Logic and Functionality
The primary objective of this indicator is to filter out "market noise" and provide a clearer picture of the underlying trend. It achieves this through several logical steps:
1. Dual Trend Tracking The script generates two separate lines on your chart. These are not merely copies of one another; they serve to provide different perspectives on price action. By plotting two lines, the indicator allows traders to see how closely the current price is following a specific mathematical trend versus its historical movement.
2. Dynamic Price Smoothing The logic relies on a "smoothing factor" (defined by the sensitivity settings). Instead of jumping instantly to every new price change, the script calculates the difference between the current closing price and the previous value of the line. It then adds a fraction of that difference to the existing line. This prevents the indicator from reacting erratically to tiny, insignificant price flickers, resulting in a smoother, more readable curve.
3. Directional Validation The script evaluates the price movement based on two main conditions:
- Momentum Check: It looks at whether the current closing price is higher or lower than the previous one.
- Positioning: It compares the current price against the value of the calculated trend line.
Depending on whether the market is moving upward or downward, the script applies specific mathematical adjustments to update the lines. This ensures that if the price is trending strongly in one direction, the line follows that momentum, but it does so in a controlled, gradual manner.
4. Initialization and Reset To ensure accuracy on new charts, the script includes a built-in "reset" mechanism. When the data begins (at the far edge of the historical chart), it anchors both trend lines to the actual market price. This provides a stable starting point, ensuring that the calculations for the rest of the history are grounded in real price data.
Summary for the Trader
In simple terms, this tool acts like a "weighted average" of the market's path. It takes the raw, jagged movements of price and converts them into two flowing lines. By observing these lines, you can better identify whether the market is in a sustained trend or if it is experiencing temporary volatility, helping to provide a clearer visual guide for navigation.
//+------------------------------------------------------------------+
//| ang_AZad_Css[cw].mq4|
//| Copyright © 2006, ANG3110@latchess.com |
//+------------------------------------------------------------------+
#property copyright "ANG3110@latchess.com"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Indigo
#property indicator_color2 DarkSlateBlue
//----
extern double ki=2;
extern int Shift=0;
extern int zShift=0;
//----
double za[], z, za2[], z2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, za);
SetIndexShift(0, Shift);
SetIndexBuffer(1, za2);
SetIndexShift(1, Shift+zShift);
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
SetIndexLabel(0,"ang_AZad(C)Z"+ki+",s"+Shift+"");
SetIndexLabel(1,"ang_AZad(C)Z2"+ki+",s"+Shift+"ss"+zShift+"");
IndicatorShortName("ang_AZad_Css[cw]");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator start function |
//+------------------------------------------------------------------+
int start()
{
int i, cbi;
int n, ai, bi, f, ai2, bi2, f2;
cbi=Bars - IndicatorCounted() - 1;
//----
for(i=cbi; i>=0; i--)
{
if(Close[i] > z && Close[i] > Close[i+1])
z=za[i+1] + (Close[i] - za[i+1])/ki;
if(Close[i] < z && Close[i] < Close[i+1])
z=za[i+1] + (Close[i] - za[i+1])/ki;
if(Close[i] > z2 && Close[i] < Close[i+1])
z2=za2[i+1] + (Close[i] - za2[i+1])/ki;
if(Close[i] < z2 && Close[i] > Close[i+1])
z2=za2[i+1] + (Close[i] - za2[i+1])/ki;
if(i > Bars - 5)
{
z=Close[i];
z2=z;
}
za[i]=z;
za2[i]=z2;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments