ang_AZad_Css[sw]
Download scriptThis indicator is designed to provide a visual representation of market trends by calculating and plotting two distinct smoothed price lines. Its primary goal is to help traders identify the underlying direction of price movement while filtering out minor fluctuations.
Core Logic and Functionality
The script operates by analyzing the closing prices of the market and applying a specific mathematical smoothing technique to generate two separate lines on a dedicated sub-window. Here is how the logic flows:
1. Dual Trend Tracking The indicator produces two separate lines (colored Indigo and DarkSlateBlue). These lines act as "moving anchors" for the price. Instead of following every tiny tick of the market, they calculate a smoothed average based on a user-defined sensitivity factor (the "ki" value).
2. Dynamic Price Adjustment The logic works by comparing the current closing price against the previous value of the indicator's line.
- If the price is moving upward and exceeds the current smooth value, the line adjusts slightly upward.
- If the price is moving downward and falls below the current smooth value, the line adjusts slightly downward.
By using a division factor, the script ensures that the lines do not jump instantly to the current price. Instead, they "glide" toward the price, creating a smoother curve that makes it easier to see the prevailing trend.
3. Symmetry and Shift The second line is calculated using a similar logic but can be visually offset from the first. This allows users to view the relationship between two different smoothing levels or time offsets simultaneously. By looking at the gap or the crossing of these two lines, traders can get a clearer sense of momentum changes.
4. Initialization and Smoothing When the indicator first loads, it performs a "handshake" with the most recent historical data to ensure the lines start at the correct price level. From that point forward, it continuously recalculates every new price candle, updating the lines in real-time to reflect the most current market behavior.
Summary for the Trader
In simple terms, this tool transforms raw, jagged market prices into two smooth, flowing curves. It effectively "slows down" the market's movements so that you can see whether the overall trend is bullish or bearish without being distracted by minor price noise.
//+------------------------------------------------------------------+
//| ang_AZad_Css[sw].mq4 |
//| Copyright © 2006, ANG3110@latchess.com |
//+------------------------------------------------------------------+
#property copyright "ANG3110@latchess.com"
//----
#property indicator_separate_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[sw]");
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