ang_Zad (C)

Download script
ang_Zad (C)

This technical indicator is designed to provide a visual representation of price trends by calculating and plotting two distinct dynamic lines on your trading chart. The core objective of the script is to smooth out market noise while identifying the underlying momentum of the asset's price movement.

Core Mechanics and Logic

The script functions by analyzing historical closing prices and comparing them against previously calculated values. It uses a specific mathematical smoothing factor (defined by the "ki" setting) to determine how aggressively the indicator should react to new price changes.

The Primary Trend Line: The first line tracks the general direction of the market. It updates its position based on two conditions:

  • When the current price is higher than the previous closing price and exceeds the current calculated value, the line moves upward.
  • Conversely, if the price is lower than the previous close and falls below the calculated value, the line moves downward. By using a proportional calculation rather than simply following the price directly, this line creates a "lagging" effect that helps filter out minor price fluctuations, making it easier to see the broader trend.

The Secondary Trend Line: The script also calculates a second dynamic line that operates on different logic. While the first line looks for consistent momentum in one direction, the second line reacts to shifts and crossovers:

  • It identifies points where the price moves against the established trend of the primary line.
  • It captures instances where the price is trending upward but remains below the secondary value, or downward but remains above it.

How it appears on your chart

When you apply this script, you will see two moving lines (traditionally displayed in Blue and Red).

  1. Smoothing: Because of the division logic applied to the price differences, the lines do not "teleport" to new prices; they move smoothly, providing a cleaner visual path for traders to follow.
  2. Initialization: The script includes a safeguard that ensures it begins accurately by anchoring its starting values to the most recent available data points.
  3. Visual Interpretation: By observing the relationship between these two lines and the current price action, users can better distinguish between temporary market "noise" and significant trend reversals.
Miscellaneous
Implements a curve of type %1
6 Views
2 Downloads
0 Favorites
ang_Zad (C)
//+------------------------------------------------------------------+
//|                                                   ang_Zad(C).mq4 |
//|                           Copyright © 2006, ANG3110@latchess.com |
//+------------------------------------------------------------------+

#property  copyright "ANG3110@latchess.com"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//----
extern double ki = 2;
//----
double za[], z, za2[], z2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0, za);
   SetIndexBuffer(1, za2);
   SetIndexStyle(0, DRAW_LINE, 0, 2);
   SetIndexStyle(1, DRAW_LINE, 0, 2);
   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