Hans_Indicator_Cloud

Author: Copyright © 2014, Shimodax
0 Views
0 Downloads
0 Favorites
Hans_Indicator_Cloud
ÿþ//+------------------------------------------------------------------+ 

//|                                         Hans_Indicator_Cloud.mq5 | 

//|                                       Copyright © 2014, Shimodax | 

//|   http://www.strategybuilderfx.com/forums/showthread.php?t=15439 | 

//+------------------------------------------------------------------+ 

/* Introduction:



   Draw ranges for "Simple Combined Breakout System for EUR/USD and GBP/USD" thread

   (see http://www.strategybuilderfx.com/forums/showthread.php?t=15439)



   LocalTimeZone: TimeZone for which MT5 shows your local time, 

                  e.g. 1 or 2 for Europe (GMT+1 or GMT+2 (daylight 

                  savings time).  Use zero for no adjustment.

                  

                  The MetaQuotes demo server uses GMT +2.   

   Enjoy  :-)

   

   Markus



*/

#property copyright "Copyright © 2014, Shimodax"

#property link "http://www.strategybuilderfx.com/forums/showthread.php?t=15439"

#property description "=48:0B>@ @0AH8@ONI8EAO :>@84>@>2 2@5<5==KE 7>= A D>=>2K< F25B>2K< 70?>;=5=85< 8 A@54=59 ;8=859 :>@84>@0."

#property description "!D>@<8@>20==K9 :>@84>@ @025= G5BK@Q< G0A0<, @0AH8@5=85 :>@84>@0 - H5AB=04F0BL G0A>2."

//---- =><5@ 25@A88 8=48:0B>@0

#property version   "1.00"

//---- >B@8A>2:0 8=48:0B>@0 2 3;02=>< >:=5

#property indicator_chart_window  

//---- :>;8G5AB2> 8=48:0B>@=KE 1CD5@>2 9

#property indicator_buffers 9 

//---- 8A?>;L7>20=> A5<L 3@0D8G5A:8E ?>AB@>5=89

#property indicator_plots   7

//+-----------------------------------------+

//|  >1JO2;5=85 :>=AB0=B                    |

//+-----------------------------------------+

#define RESET  0 // >=AB0=B0 4;O 2>72@0B0 B5@<8=0;C :><0=4K =0 ?5@5AGQB 8=48:0B>@0

//+-----------------------------------------+

//| 0@0<5B@K >B@8A>2:8 25@E=53> >1;0:0     |

//+-----------------------------------------+

//---- >B@8A>2:0 8=48:0B>@0 2 2845 >1;0:0

#property indicator_type1   DRAW_FILLING

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= F25B C'232,255,247'

#property indicator_color1 C'232,255,247'

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label1  "Upper Hans_Indicator cloud"

//+-----------------------------------------+

//| 0@0<5B@K >B@8A>2:8 =86=53> >1;0:0      |

//+-----------------------------------------+

//---- >B@8A>2:0 8=48:0B>@0 2 2845 >1;0:0

#property indicator_type2   DRAW_FILLING

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= F25B C'255,240,255'

#property indicator_color2 C'255,240,255'

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label2  "Lower Hans_Indicator cloud"

//+-----------------------------------------+

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 1       |

//+-----------------------------------------+

//---- >B@8A>2:0 8=48:0B>@0 2 2845 ;8=88

#property indicator_type3   DRAW_LINE

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= Blue F25B

#property indicator_color3 clrBlue

//---- ;8=8O 8=48:0B>@0 - A?;>H=0O

#property indicator_style3  STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 @02=0 1

#property indicator_width3  1

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label3  "Upper Hans_Indicator 1"

//+-----------------------------------------+

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 2       |

//+-----------------------------------------+

//---- >B@8A>2:0 8=48:0B>@0 2 2845 ;8=88

#property indicator_type4   DRAW_LINE

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= Magenta F25B

#property indicator_color4 clrMagenta

//---- ;8=8O 8=48:0B>@0 - A?;>H=0O

#property indicator_style4  STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 @02=0 1

#property indicator_width4  1

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label4  "Lower Hans_Indicator 1"

//+-----------------------------------------+

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 3       |

//+-----------------------------------------+

//---- >B@8A>2:0 8=48:0B>@0 2 2845 ;8=88

#property indicator_type5   DRAW_LINE

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= LimeGreen F25B

#property indicator_color5 clrLimeGreen

//---- ;8=8O 8=48:0B>@0 - A?;>H=0O

#property indicator_style5  STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 @02=0 3

#property indicator_width5 3

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label5  "Upper Hans_Indicator 2"

//+-----------------------------------------+

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 4       |

//+-----------------------------------------+

//---- >B@8A>2:0 8=48:0B>@0 2 2845 ;8=88

#property indicator_type6   DRAW_LINE

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= Red F25B

#property indicator_color6 clrRed

//---- ;8=8O 8=48:0B>@0 - A?;>H=0O

#property indicator_style6  STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 @02=0 3

#property indicator_width6  3

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label6  "Lower Hans_Indicator 2"

//+-----------------------------------------+

//|  0@0<5B@K >B@8A>2:8 8=48:0B>@0 5       |

//+-----------------------------------------+

//---- >B@8A>2:0 8=48:0B>@0 2 2845 ;8=88

#property indicator_type7   DRAW_LINE

//---- 2 :0G5AB25 F25B0 ;8=88 8=48:0B>@0 8A?>;L7>20= SlateGray F25B

#property indicator_color7 clrSlateGray

//---- ;8=8O 8=48:0B>@0 - A?;>H=0O

#property indicator_style7  STYLE_SOLID

//---- B>;I8=0 ;8=88 8=48:0B>@0 @02=0 2

#property indicator_width7 2

//---- >B>1@065=85 <5B:8 8=48:0B>@0

#property indicator_label7  "Middle Hans_Indicator"



//+-----------------------------------------+

//|  %+  " + "            |

//+-----------------------------------------+

input uint LocalTimeZone=0;         // G0A =0G0;0 >BAGQB0 8AE>4=>3> :>@84>@0

input uint DestTimeZone=4;          // A4283 :>@84>@0 2;52> 2 10@0E

input uint PipsForEntry=500;        // @0AH8@5=85 3@0=8F AD>@<8@>20==>3> :>@84>@0 2 ?C=:B0E

input int  Shift=0;                 // !4283 8=48:0B>@0 ?> 3>@87>=B0;8 2 10@0E

//+-----------------------------------------+



//---- 1JO2;5=85 F5;KE ?5@5<5==KE =0G0;0 >BAGQB0 40==KE

int  min_rates_total;

//---- >1JO2;5=85 48=0<8G5A:8E <0AA82>2, :>B>@K5 1C4CB 2 40;L=59H5< 8A?>;L7>20=K 2 :0G5AB25 8=48:0B>@=KE 1CD5@>2

double UpUp2Buffer[],UpDn2Buffer[],DnUp2Buffer[],DnDn2Buffer[];

double Zone1Upper[],Zone2Upper[];

double Zone1Lower[],Zone2Lower[];

double MiddleBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//---- =8F80;870F8O ?5@5<5==KE =0G0;0 >BAGQB0 40==KE

   min_rates_total=100;

   

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(0,UpUp2Buffer,INDICATOR_DATA);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   //PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,NULL);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8

   PlotIndexSetInteger(0,PLOT_SHIFT,Shift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(0,PLOT_SHOW_DATA,false);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(UpUp2Buffer,true);

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(1,UpDn2Buffer,INDICATOR_DATA);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(UpDn2Buffer,true);



//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(2,DnUp2Buffer,INDICATOR_DATA);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   //PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,NULL);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8

   PlotIndexSetInteger(1,PLOT_SHIFT,Shift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(1,PLOT_SHOW_DATA,false);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(DnUp2Buffer,true);

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(3,DnDn2Buffer,INDICATOR_DATA);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(DnDn2Buffer,true);

  

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(4,Zone1Upper,INDICATOR_DATA);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,NULL);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8

   PlotIndexSetInteger(2,PLOT_SHIFT,Shift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(2,PLOT_SHOW_DATA,false);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(Zone1Upper,true);

   

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(5,Zone1Lower,INDICATOR_DATA);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,NULL);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8

   PlotIndexSetInteger(3,PLOT_SHIFT,Shift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(3,PLOT_SHOW_DATA,false);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(Zone1Lower,true);



//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(6,Zone2Upper,INDICATOR_DATA);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,NULL);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8

   PlotIndexSetInteger(4,PLOT_SHIFT,Shift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(4,PLOT_SHOW_DATA,false);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(Zone2Upper,true);

   

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(7,Zone2Lower,INDICATOR_DATA);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(5,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,NULL);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8

   PlotIndexSetInteger(5,PLOT_SHIFT,Shift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(5,PLOT_SHOW_DATA,false);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(Zone2Lower,true);

  

//---- ?@52@0I5=85 48=0<8G5A:>3> <0AA820 2 8=48:0B>@=K9 1CD5@

   SetIndexBuffer(8,MiddleBuffer,INDICATOR_DATA);

//---- >ACI5AB2;5=85 A42830 =0G0;0 >BAGQB0 >B@8A>2:8 8=48:0B>@0

   PlotIndexSetInteger(6,PLOT_DRAW_BEGIN,min_rates_total);

//---- CAB0=>2:0 7=0G5=89 8=48:0B>@0, :>B>@K5 =5 1C4CB 2848<K =0 3@0D8:5

   PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,NULL);

//---- >ACI5AB2;5=85 A42830 8=48:0B>@0 ?> 3>@87>=B0;8

   PlotIndexSetInteger(6,PLOT_SHIFT,Shift);

//---- 70?@5B =0 >B>1@065=85 7=0G5=89 8=48:0B>@0 2 ;52>< 25@E=5< C3;C >:=0 8=48:0B>@0

   PlotIndexSetInteger(6,PLOT_SHOW_DATA,false);

//---- 8=45:A0F8O M;5<5=B>2 2 1CD5@5 :0: 2 B09<A5@88

   ArraySetAsSeries(MiddleBuffer,true);



//--- A>740=85 8<5=8 4;O >B>1@065=8O 2 >B45;L=>< ?>4>:=5 8 2> 2A?;K20NI59 ?>4A:07:5

   IndicatorSetString(INDICATOR_SHORTNAME,"Hans_Indicator_Cloud("+string(LocalTimeZone)+","+

                                     string(DestTimeZone)+","+string(PipsForEntry)+","+string(Shift)+")");

//--- >?@545;5=85 B>G=>AB8 >B>1@065=8O 7=0G5=89 8=48:0B>@0

   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

//---- 7025@H5=85 8=8F80;870F88

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+  

//| Custom indicator iteration function                              | 

//+------------------------------------------------------------------+  

int OnCalculate(

                const int rates_total,    // :>;8G5AB2> 8AB>@88 2 10@0E =0 B5:CI5< B8:5

                const int prev_calculated,// :>;8G5AB2> 8AB>@88 2 10@0E =0 ?@54K4CI5< B8:5

                const datetime &Time[],

                const double &Open[],

                const double &High[],

                const double &Low[],

                const double &Close[],

                const long &Tick_Volume[],

                const long &Volume[],

                const int &Spread[]

                )

  {

//---- ?@>25@:0 :>;8G5AB20 10@>2 =0 4>AB0B>G=>ABL 4;O @0AGQB0

   if(rates_total<min_rates_total) return(RESET);



//---- >1JO2;5=8O ;>:0;L=KE ?5@5<5==KE

   int limit;

   

//---- @0AG5B AB0@B>2>3> =><5@0 limit 4;O F8:;0 ?5@5AG5B0 10@>2

   if(prev_calculated>rates_total || prev_calculated<=0)// ?@>25@:0 =0 ?5@2K9 AB0@B @0AG5B0 8=48:0B>@0

     {

      limit=rates_total-min_rates_total-1; // AB0@B>2K9 =><5@ 4;O @0AG5B0 2A5E 10@>2

     }

   else limit=rates_total-prev_calculated; // AB0@B>2K9 =><5@ 4;O @0AG5B0 =>2KE 10@>2

//---- 8=45:A0F8O M;5<5=B>2 2 <0AA820E :0: 2 B09<A5@8OE  

   ArraySetAsSeries(Time,true);

   ArraySetAsSeries(High,true);

   ArraySetAsSeries(Low,true);



//---- >A=>2=>9 F8:; @0AGQB0 8=48:0B>@0

   BreakoutRanges(0,limit,LocalTimeZone,DestTimeZone,rates_total,Time,High,Low);

//----    

   return(rates_total);

  }

//+------------------------------------------------------------------+

//| Compute index of first/last bar of yesterday and today           |

//+------------------------------------------------------------------+

int BreakoutRanges(int offset,int &lastbar,int tzlocal,int tzdest,

                 const int rates_total_,const datetime &Time_[],const double &High_[],const double &Low_[])

  {

//----

   int i,j,k,

   tzdiff=tzlocal-tzdest,

   tzdiffsec=tzdiff*3600,

   tidxstart[2]={ 0,0},

   tidxend[2]={ 0,0 };

   double thigh[2]= { 0.0, 0.0 },

   tlow[2]= { 99999.9, 99999.9 };

   string tfrom[3]= { "04:00", "08:00" ,  /*rest of day: */ "12:00"},

   tto[3]=   { "08:00", "12:00",   /*rest of day: */ "24:00" },

   tday;

   bool inperiod=-1;

   datetime timet;



//

// search back for the beginning of the day

//

   tday=TimeToString(Time_[lastbar]-tzdiffsec,TIME_DATE);

   for(; lastbar<rates_total_-1; lastbar++)

     {

      if(TimeToString(Time_[lastbar]-tzdiffsec,TIME_DATE)!=tday)

        {

         lastbar--;

         break;

        }

     }





//

// find the high/low for the two periods and carry them forward through the day

//

   tday="XXX";

   for(i=lastbar; i>=offset; i--)

     {



      timet=Time_[i]-tzdiffsec;   // time of this bar



      string timestr= TimeToString(timet, TIME_MINUTES),    // current time HH:MM

      thisday= TimeToString(timet, TIME_DATE);       // current date





                                                  //

      // for all three periods (first period, second period, rest of day)

      //

      for(j=0; j<2; j++)

        {

         if(tfrom[j]<=timestr && timestr<tto[j])

           {   // Bar[i] in this period

            if(inperiod!=j) 

              { // entered new period, so last one is completed



               if(j>0)

                 {      // now draw high/low back over the recently completed period

                  for(k=tidxstart[j-1]; k>=tidxend[j-1]; k--)

                    {

                     if(j-1==0)

                       {

                        Zone1Upper[k]=UpUp2Buffer[k]=thigh[j-1];

                        Zone1Lower[k]=DnDn2Buffer[k]=tlow[j-1];

                        MiddleBuffer[k]=UpDn2Buffer[k]=DnUp2Buffer[k]=(Zone1Upper[k]+Zone1Lower[k])/2;

                       }



                     if(j-1==1)

                       {

                        Zone2Upper[k]=UpUp2Buffer[k]=thigh[j-1];

                        Zone2Lower[k]=DnDn2Buffer[k]=tlow[j-1];

                        MiddleBuffer[k]=UpDn2Buffer[k]=DnUp2Buffer[k]=(Zone1Upper[k]+Zone1Lower[k])/2;

                       }

                    }

                 }



               inperiod=j;   // remember current period

              }



            if(inperiod==2) // inperiod==2 (end of day) is just to check completion of zone 2

               break;



            // for the current period find idxstart, idxend and compute high/low

            if(tidxstart[j]==0)

              {

               tidxstart[j]=i;

               tday=thisday;

              }



            tidxend[j]=i;



            thigh[j]=MathMax(thigh[j],High_[i]);

            tlow[j]=MathMin(tlow[j],Low_[i]);

           }

        }



      // 

      // carry forward the periods for which we have definite high/lows

      //

      if(inperiod>=1 && tday==thisday) 

        { // first time period completed

         Zone1Upper[i]=UpUp2Buffer[i]=thigh[0]+PipsForEntry*_Point;

         Zone1Lower[i]=DnDn2Buffer[i]=tlow[0]-PipsForEntry*_Point;

         MiddleBuffer[i]=UpDn2Buffer[i]=DnUp2Buffer[i]=(Zone1Upper[i]+Zone1Lower[i])/2;

         Zone2Upper[i]=Zone2Lower[i]=NULL;

         Zone2Upper[i]= thigh[0]+PipsForEntry*_Point;

         Zone2Lower[i]= tlow[0]-PipsForEntry*_Point;



         if(inperiod>=2) 

           {   // second period completed

            Zone2Upper[i]=UpUp2Buffer[i]=thigh[1]+PipsForEntry*_Point;

            Zone2Lower[i]=DnDn2Buffer[i]=tlow[1]-PipsForEntry*_Point;

            MiddleBuffer[i]=UpDn2Buffer[i]=DnUp2Buffer[i]=(Zone1Upper[i]+Zone1Lower[i])/2;

           }

        }

      else 

        {   // none yet to carry forward (zero to clear old values, e.g. from switching timeframe)

         Zone1Upper[i]=Zone1Lower[i]=Zone2Upper[i]=Zone2Lower[i]=MiddleBuffer[i]=UpDn2Buffer[i]=DnUp2Buffer[i]=UpUp2Buffer[i]=DnDn2Buffer[i]=NULL;

        }



      //

      // at the beginning of a new day reset everything

      //

      if(tday!="XXX" && tday!=thisday)

        {

         //Print("#",i,"new day ",thisday,"/",tday);



         tday="XXX";



         inperiod=-1;



         for(j=0; j<2; j++)

           {

            tidxstart[j]=0;

            tidxend[j]=0;



            thigh[j]=0;

            tlow[j]=99999;

           }

        }

     }

//----

   return (0);

  }

//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---