This tool is designed to provide traders with a visual representation of market momentum and price trends by calculating two distinct dynamic lines. Instead of simply following the price exactly, it uses a smoothing logic to help identify the underlying "flow" of the market, filtering out minor fluctuations to reveal broader movements.
How the Logic Works
1. Dynamic Price Tracking The script monitors the closing price of each candlestick in real-time. It identifies the direction of the market by comparing the current price to the previous one. Depending on whether the price is moving upward or downward, the tool calculates a new position for its tracking lines.
2. Smoothing Mechanism (The "ki" Factor) A key feature of this logic is how it handles price updates. Rather than jumping instantly to every new price point—which can create a jagged and noisy visual—it uses a mathematical smoothing constant (defined by the "ki" value). When the price moves, the tool only incorporates a small fraction of that change into its calculation. This results in a smoother, more fluid line that reacts to trends while ignoring insignificant "noise."
3. Dual-Line Comparison The script actually maintains two separate tracking paths:
- One path responds to standard price movements.
- The second path is designed to react differently to specific reversals or continuations (specifically tracking when prices move in the opposite direction of their immediate previous trend).
By calculating these two different paths simultaneously, the tool creates a measurable "gap" or difference between them.
4. Visual Output The final result presented on your chart is the distance between these two smoothed lines.
- When the lines are close together, it suggests a period of consolidation or low volatility.
- When the distance between the lines widens, it indicates a strengthening trend in one direction.
Summary for the User
In plain terms, this script acts as a sophisticated "momentum gauge." It smooths out the erratic movements of the market to show you two different perspectives of price action. By watching how these two lines diverge or converge, you can better visualize the strength and stability of the current market trend without being distracted by every minor tick in price.
//+------------------------------------------------------------------+
//| ang_AZad(Osc).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