modifiyHigh_Low v2 (ZigZag)

Download script
Author: rewritten by CrazyChart, modify by prasxz www.freefxsystem.com
modifiyHigh_Low v2 (ZigZag)

This tool is designed to analyze price action on a trading chart by identifying significant structural turning points, specifically focusing on the highs and lows of price movements. Rather than just showing every minor fluctuation, the logic works to filter out "noise" to highlight meaningful peaks and valleys.

Core Logic Overview

The script processes historical price data starting from a specific point in the past (defined by a user-set limit). It moves through each candle one by one to determine whether the current price movement is forming a new high, a new low, or if it is transitioning between different market phases.

How it Identifies Key Points

The system uses a comparison method to track "Swings." Here is how that works in simple terms:

  • Trend Detection: It looks at whether the current price is breaking above the previous highs or dropping below the previous lows.
  • Switching Logic: When the market stops moving in one direction and begins to pivot (for example, shifting from making higher highs to forming a lower low), the script marks this as a "Swing."
  • Peak and Valley Capture: Once a shift in momentum is detected, the tool identifies the exact coordinates of that peak or valley. It remembers these specific locations to distinguish between a minor price wiggle and a significant structural change in the market.

Visual Output

The final result of this logic is a visual representation on your chart (a "Section" line). It maps out these identified structural points, connecting them to show the broader "skeleton" of the market's movement. By highlighting these specific high and low coordinates, it helps traders see the underlying structure of the price action more clearly than a standard candlestick chart might allow.

Key Features for the User

  • Automated Scanning: The script automatically handles the heavy lifting of comparing every candle in the history to find relevant turning points.
  • Structural Clarity: By focusing on "Swings," it helps eliminate the distraction of minor price volatility, allowing for a clearer view of where the market is actually pivoting.
  • Customizable Range: Users can define how far back into the past the script should look to build its analysis.
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
modifiyHigh_Low v2 (ZigZag)
//+------------------------------------------------------------------+
//|                                         High_Low v2 (ZigZag).mq4 |
//|                                          rewritten by CrazyChart |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "rewritten by CrazyChart, modify by prasxz www.freefxsystem.com"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
//extern double    TakeProfit=250.0;
//extern double    Lots=1;
extern int       barn=1300;
extern int       Length=1;
//---- buffers
double ExtMapBuffer1[];
//double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexEmptyValue(0,0.0);
  //SetIndexDrawBegin(0, barn);
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(0,ExtMapBuffer1);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    cnt,ticket,counted_bars=IndicatorCounted();
   int shift,Swing,Swing_n,uzl,i,zu,zd,mv;
   double LL,HH,BH,BL,NH,NL; 
   double Uzel[10000][3]; 
   string text;
    
if (High[1]> High[0]) {Comment("SELL !!");}
 
 else if (High[1]< High[0]) {Comment("BUY !!");}
// loop from first bar to current bar (with shift=0) 
      Swing_n=0;Swing=0;uzl=0; 
      BH =High[barn];BL=Low[barn];zu=barn;zd=barn; 

for (shift=barn;shift>=0;shift--) { 
      LL=10000000;HH=-100000000; 
   for (i=shift+Length;i>=shift+1;i--) { 
         if (Low[i]< LL) {LL=Low[i];} 
         if (High[i]>HH) {HH=High[i];} 
         //====
        // if (High[1]> High[0]) {Comment("SELL !!"); {
         //  ticket=OrderSend(Symbol(),OP_SELL,Lots,Ask,3,0,Ask+TakeProfit*Point,"My EA",12345,0,Green);
         //  if(ticket>0)
         //    {
         //    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
          //    }
        //   else Print("Error opening BUY order : ",GetLastError()); 
      //     return(0);
     //   }}
  //=====
   } 
//If (High[i]< High[i-1]) Comment(High[i],High[i-1]," ","STAY AWAY !!");

         
         //

   if (Low[shift]<LL && High[shift]>HH){ 
      Swing=2; 
      if (Swing_n==1) {zu=shift+1;} 
      if (Swing_n==-1) {zd=shift+1;} 
   } else { 
      if (Low[shift]<LL) {Swing=-1;} 
      if (High[shift]>HH) {Swing=1;} 
   } 

   if (Swing!=Swing_n && Swing_n!=0) { 
   if (Swing==2) {
      Swing=-Swing_n;BH = High[shift];BL = Low[shift]; 
   } 
      uzl=uzl+1; 
   if (Swing==1) {
      Uzel[uzl][1]=zd;
      Uzel[uzl][2]=BL;
   } 
   if (Swing==-1) {
      Uzel[uzl][1]=zu;
      Uzel[uzl][2]=BH; 
   } 
      BH = High[shift];
      BL = Low[shift]; 
   } 

   if (Swing==1) { 
      if (High[shift]>=BH) {BH=High[shift];zu=shift;}} 
      if (Swing==-1) {
          if (Low[shift]<=BL) {BL=Low[shift]; zd=shift;}} 
      Swing_n=Swing; 
   } 
   for (i=1;i<=uzl;i++) { 
      //text=DoubleToStr(Uzel[i][1],0);
      //text=;
         mv=StrToInteger(DoubleToStr(Uzel[i][1],0));
      ExtMapBuffer1[mv]=Uzel[i][2];
   } 





   return(0);
  }
//+------------------------------------------------------------------+

Comments