ZigZagCorrect

Download script
Author: lowphat
ZigZagCorrect

This tool is designed to provide a visual representation of market trends by identifying key price turning points. It simplifies the complex movements of the financial markets into a clear, readable path, helping traders see where the "peaks" and "valleys" occur in real-time.

Core Functionality

The script works by analyzing historical price data to map out major fluctuations. Rather than showing every minor price wiggle, it focuses on significant structural changes. It identifies these points and marks them on your chart with distinct visual indicators (arrows), allowing you to see the primary direction of the market more clearly.

Key Logic & Features

  • Timeframe Synchronization: The tool is capable of "forcing" a specific timeframe for its calculations. This means that even if you are looking at a very small, fast-moving chart (like 1-minute bars), the script can be set to calculate the ZigZag trend based on a larger, more stable timeframe (such as 60 minutes). This helps filter out "market noise" and focuses on the bigger picture.
  • Dynamic Trend Mapping: By pulling data from an underlying ZigZag calculation, the script determines the depth of price movements. It uses specific parameters—Depth, Deviation, and Backstep—to decide how much a price must move before it considers a new trend point to be "significant."
  • Automated Time Alignment: The logic includes a sophisticated way of aligning historical data. It automatically calculates where different time periods begin and end on your chart, ensuring that the trend lines remain accurate and consistent regardless of which candle you are currently viewing.
  • Visual Clarity: The script outputs two separate visual streams. These represent the different "legs" of the market movement, marked with arrows to clearly highlight the transition from upward momentum to downward momentum (and vice versa).

Summary for the User

Essentially, this script acts as a filter. It looks at the chaotic movement of prices and draws a simplified "map" of where the market has actually turned around. By using the "Forced Time" feature, it allows you to stay focused on the major trends while ignoring the distracting small fluctuations of shorter timeframes.

Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
ZigZagCorrect
//+------------------------------------------------------------------+ 
//|                                                                  | 
//+------------------------------------------------------------------+ 
#property copyright "lowphat" 
#property link      "forextrash@yahoo.com" 

#property indicator_chart_window 
#property indicator_buffers 2 
#property indicator_color1 Lime 
#property indicator_color2 Red
//---- input parameters 
extern int ForcedZigTime=60; 
extern int ExtDepth=15; 
extern int ExtDeviation=5; 
extern int ExtBackstep=3; 
extern bool ShowSettingsOnChart=false;
//---- buffers 
double ExtMapBuffer1[]; 
double ExtMapBuffer2[]; 
datetime daytimes[]; 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
//---- indicators 
   SetIndexStyle(0,DRAW_ARROW); 
   SetIndexArrow(0,163); 
   SetIndexBuffer(0,ExtMapBuffer1); 
   
   SetIndexStyle(1,DRAW_ARROW,EMPTY,0);
   SetIndexArrow(1, 163);   
   SetIndexBuffer(1,ExtMapBuffer2);  
   SetIndexEmptyValue(0,0.0); 
   


      IndicatorShortName("ZigZagPhat ("+ForcedZigTime+")"); 
   
  if (ShowSettingsOnChart==true){
   Comment("\nZigZag Forced Time ("+ForcedZigTime+")\nZigZag Exit Depth ("+ExtDepth+")\nZigZag Exit Deviation ("+ExtDeviation+")\nZigZag Exit Backstep ("+ExtBackstep+")");
   
}
   

   ArrayCopySeries(daytimes,MODE_TIME,Symbol(),ForcedZigTime); 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 
//---- 

//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
  { 
   int    limit, bigshift; 
   int    counted_bars=IndicatorCounted(); 
//---- 
   if (counted_bars<0) return(-1); 
    
   if (counted_bars>0) counted_bars--; 
    
   limit=Bars-counted_bars; 
    
   for (int i=0; i<limit; i++) 
   { 
   if(Time[i]>=daytimes[0]) bigshift=0; 
   else 
     { 
      bigshift = ArrayBsearch(daytimes,Time[i-1],WHOLE_ARRAY,0,MODE_DESCEND); 
      if(Period()<=ForcedZigTime) bigshift++; 
     } 
  ExtMapBuffer1[i]=iCustom(NULL,ForcedZigTime,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,0,bigshift); 
  ExtMapBuffer2[i]=iCustom(NULL,ForcedZigTime,"ZigZag",ExtDepth,ExtDeviation,ExtBackstep,1,bigshift); 
   } 

   return(0); 
  } 

Comments