ang_AZad_(C)
Download scriptThis custom technical indicator is designed to track and visualize specific price movements within a trading platform. Rather than simply following the market price exactly, it utilizes a smoothing logic to identify underlying trends and potential shifts in momentum.
Core Functionality
The script works by calculating two distinct moving values that react differently to market fluctuations:
- Primary Trend Tracking: The indicator monitors whether the current price is moving up or down relative to its previous position. If the price continues in its current direction, the indicator updates its baseline value using a weighted calculation. This "smoothing" factor (defined by a user-adjustable setting) determines how quickly or slowly the indicator reacts to new price data.
- Secondary Dynamic Mapping: Alongside the primary trend, the script tracks a second secondary value. This component is designed to capture specific nuances in price action—specifically looking for moments where the current price interacts with the established baseline.
How the Logic Works
The system processes market history from oldest to newest, applying a set of mathematical rules at every price candle:
- Trend Identification: The script checks if the current price is higher or lower than the previous close. Depending on the direction, it adjusts the primary baseline. This ensures that the line doesn't "jump" erratically but instead flows smoothly with the market trend.
- Adjustment Logic: By dividing the difference between the current price and the baseline by a specific constant (the smoothing factor), the tool filters out minor "noise" or insignificant fluctuations, allowing for a clearer view of the prevailing direction.
- Gap Measurement: The indicator calculates the distance between these two primary moving values. This difference is converted into a numerical format that represents the spread or volatility between the two signals.
Visual Representation
The final output provides the user with a visual representation of these calculations, typically displayed in a separate window from the main price chart. By observing the relationship and the "spread" between these two moving components, traders can better gauge the strength of a trend and identify potential areas of market exhaustion or acceleration.
//+------------------------------------------------------------------+
//| ang_AZad(C).mq4 |
//| Copyright © 2006, ANG3110@latchess.com |
//+------------------------------------------------------------------+
#property copyright "ANG3110@latchess.com"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//----
extern double ki = 4;
//--------------------
double za[], z, za2[], z2, aza[], a0[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
SetIndexBuffer(0, aza);
SetIndexBuffer(1, a0);
SetIndexBuffer(2, za);
SetIndexBuffer(3, za2);
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;
aza[i] = (za[i] - za2[i]) / Point;
a0[i] = 0.00000001;
}
//----
return(0);}
//+------------------------------------------------------------------+
Comments