ZigZagCorrect.1
Download scriptThis tool is designed to enhance the visual analysis of market trends by integrating specialized "ZigZag" price action data into your trading charts. It acts as a secondary lens, allowing you to view significant structural movements (peaks and valleys) from a different timeframe than the one you are currently viewing.
Core Functionality
The primary purpose of this script is to fetch historical trend data from a higher timeframe and project it onto your active chart. In technical trading, a "ZigZag" is a common way to filter out market "noise"—the small, constant ups and downs—to highlight the major structural turns in price. This script automates that process by pulling these specific data points and displaying them as clear visual markers.
How it Works
The logic operates through three main mechanisms:
- Multi-Timeframe Synchronization: Instead of just showing you the current price movement, the script looks at a larger time window (defined by the "ForcedZigTime" setting). It identifies major price swings on that larger scale and aligns them with your current screen. This helps traders see the "big picture" while they are looking at smaller, more detailed price movements.
- Dynamic Data Mapping: The script performs a constant search through historical time data to ensure that the markers appear in the correct chronological positions. It calculates where these major turns occurred and "maps" them onto your current view, ensuring the visual indicators stay synced even as the market moves forward.
- Dual-Layer Visualization: It captures two different sets of data from the standard ZigZag calculations. By plotting these as distinct colored markers (Lime and Red), it provides a clearer visual representation of trend transitions, making it easier to identify where a move might be losing momentum or where a new direction is forming.
Key Features for the User
- Customizable Sensitivity: Through the settings, you can adjust the "Depth," "Deviation," and "Backstep." These controls determine how much price movement is required before the script recognizes a new peak or valley, allowing you to filter out more or less market volatility based on your personal trading style.
- Automated Timeframes: You can set a specific time interval for the trend analysis, allowing you to keep your chart clean while still being informed by the trends of higher time periods.
- Optional On-Screen Display: The script includes an optional feature that displays your current settings directly on the chart, providing a quick reference for your configuration without needing to open the settings menu.
In summary, this tool serves as a bridge between short-term price action and long-term trend analysis, highlighting major market pivots to help you stay aligned with the overall direction of the market.
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#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,177);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_ARROW,EMPTY,0);
SetIndexArrow(1, 177);
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