at_ZDnsw
Download scriptThis technical indicator is designed to provide a smoothed visual representation of price movements on a trading chart, helping traders filter out "market noise" to identify clearer trends. By analyzing historical price data over a specific window, the script calculates a refined path that represents the underlying momentum of the asset.
Core Logic and Methodology
The script operates through a multi-step mathematical process to transform raw price action into a smoother trajectory:
1. Data Input and Smoothing The tool begins by looking at a specific number of previous closing prices (defined by your settings). It uses a weighted smoothing formula—similar to how a moving average works—to calculate a preliminary trend line. Instead of reacting instantly to every minor price tick, this calculation helps stabilize the data.
2. Dual-Directional Refinement To ensure the resulting line is as accurate as possible, the script performs a unique "two-way" calculation:
- Forward Smoothing: It processes the data from the past toward the present to establish a baseline trend.
- Backward Refinement: It then takes that baseline and smooths it again from the present back toward the past. By blending these two directions, the indicator creates a balanced curve that attempts to stay as close to the "true" price action as possible while removing erratic fluctuations.
3. Peak and Trough Identification Once the smoothed path is established, the logic identifies specific turning points in the market. It monitors the direction of the smoothed line:
- When the line moves upward and then begins to curve downward, the script marks the high point (the peak).
- Conversely, when the line moves downward and begins to curve upward, it marks the low point (the trough).
Visual Output
The final result is displayed in a separate window on your trading platform. You will see two distinct components:
- The Main Trend: A primary line representing the smoothed price movement.
- The Signal Points: Specific markers or points that highlight where the trend has shifted from upward to downward (or vice versa).
By using this logic, the indicator aims to help traders ignore insignificant price "jitters" and focus on the significant shifts in market direction.
//**********************************
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSkyBlue
#property indicator_color2 Pink
#property indicator_width1 2
#property indicator_width2 2
//==================================
extern int p=6;
extern int s=3;
extern int cb=300;
//==================================
double fx[],fxL[],za[];
double z1,z2,ki;
int fs;
//**********************************
int init()
{
IndicatorBuffers(3);
//-------------------
SetIndexBuffer(0,fx); SetIndexEmptyValue(0,0.0);
SetIndexBuffer(1,fxL); SetIndexEmptyValue(1,0.0);
//-------------------
SetIndexBuffer(2,za);
//--------------------------
ki=2.0/(p+1);
//--------------------------
return(0);
}
//***************************************************************************
int start()
{
SetIndexDrawBegin(0,Bars-cb);
SetIndexDrawBegin(1,Bars-cb);
for (int i=cb; i>=0; i--) {fx[i]=Close[i];}
for (int m=0; m<=s; m++)
{
z1=fx[0];
for (i=0; i<=cb; i++) {z1=z1+(fx[i]-z1)*ki; za[i]=z1;}
z2=fx[cb];
for (i=cb; i>=0; i--) {z2=z2+(fx[i]-z2)*ki; fx[i]=(za[i]+z2)/2;}
}
fs=0;
for (i=cb; i>=0; i--)
{
if (fx[i]>fx[i+1]) fs=1;
if (fx[i]<fx[i+1]) {if (fs==1) fxL[i+1]=fx[i+1]; fs=2;}
if (fs==2) fxL[i]=fx[i]; else fxL[i]=0.0;
}
return(0);
}
//************************************************************
Comments