How to store High-Low values in an Array[] using a "jumping for-loop"? - page 2

 
deVries:


I don't get you want the highest and lowest of all bars      why not choose a long period (24) and longer period (72)

 

This way you see the highest value of the chosen periods in one time

red line is zigzag period 24 

 

 

 


tell me what kind of indicator on the chart except the zigzag?please share
 
disis:

tell me what kind of indicator on the chart except the zigzag?please share

It is a indicator pointing out highest/lowest value for the periods you have chosen

//+------------------------------------------------------------------+
//|                                               i-HighLow3Tjip.mq4 |
//|                                        Copyright © 2010, deVries |    
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "© 2010 deVries"
#property link      ""
//----
#define minor 0
#define major 1
#define minorM 2
#define majorM 3
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1  Gold
#property indicator_color2  DodgerBlue
#property indicator_color3  Yellow
#property indicator_color4  MediumTurquoise
//----
extern int ShortPeriod = 24;
extern int LongPeriod = 72;
extern bool ShowComment = true;

//----
double UpperBuf[];
double LowerBuf[];
double UpperBufSlow[];
double LowerBufSlow[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {       
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 1);
//----   
   SetIndexDrawBegin(0, ShortPeriod);
   SetIndexDrawBegin(1, ShortPeriod);
   SetIndexDrawBegin(2, LongPeriod);
   SetIndexDrawBegin(3, LongPeriod);
//----
   SetIndexBuffer(0, UpperBuf);
   SetIndexBuffer(1, LowerBuf);
   SetIndexBuffer(2, UpperBufSlow);
   SetIndexBuffer(3, LowerBufSlow);
   return(0);
  }
//----


  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit() 
  {
   Comment("");
   return(0);  
  }  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void start() 
  {
   int counted = IndicatorCounted();
   int counthighshortperiod,counthighlongperiod ;
   int countlowshortperiod,countlowlongperiod ;
   bool UpperLongHigh=false,UpperShortHigh=false,
        LowerLongLow=false,LowerShortLow=false;
//----
   if(counted < 0) 
       return (-1);
//----  
   if(counted > 0) 
       counted--;
   int limit = Bars - counted;
//----  
   for(int i = 0; i < limit; i++) 
     {
       UpperBuf[i] = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, ShortPeriod,i));
       LowerBuf[i] = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, ShortPeriod, i));
       UpperBufSlow[i] = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, LongPeriod,i));
       LowerBufSlow[i] = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, LongPeriod, i));
     }


   int    Index = 0;
   
if(ShowComment)
 {
 while(!UpperLongHigh || !UpperShortHigh || !LowerLongLow || !LowerShortLow)
   {
   if(!UpperLongHigh)   //  check for LongPeriodHigh
      {
      counthighlongperiod = Index;
      if( iHigh(NULL,0,Index)==UpperBufSlow[0])UpperLongHigh = true;
      }
   if(!UpperShortHigh)   //  check for ShortPeriodHigh
      {
      counthighshortperiod = Index;
      if( iHigh(NULL,0,Index)==UpperBuf[0])UpperShortHigh = true;
      }
   if(!LowerLongLow)   //  check for LongPeriodLow
      {
      countlowlongperiod = Index;
      if( iLow(NULL,0,Index)==LowerBufSlow[0])LowerLongLow = true;
      } 
   if(!LowerShortLow)   //  check for ShortPeriodLow
      {
      countlowshortperiod = Index;
      if( iLow(NULL,0,Index)==LowerBuf[0])LowerShortLow = true;
      }    
   Index++; 
   }
   
   Comment("\n Bar HighLongPeriod = ",counthighlongperiod,
            "  value : ",High[counthighlongperiod],
            "      Bar HighShortPeriod = ",counthighshortperiod,
            "  value : ",High[counthighshortperiod],
           "\n Bar LowLongPeriod = ",countlowlongperiod,
            "  value : ",Low[countlowlongperiod],
            "       Bar LowShortPeriod = ",countlowshortperiod,
            "  value : ",Low[countlowshortperiod]);     
 }
} 
//+------------------------------------------------------------------+


Take also a look to .....

 https://www.mql5.com/en/code/10920        ( een ZigZag met aparte buffers voor hoog en laag )