Hans_Indicator_x22_Cloud_Heo

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

//|                                 Hans_Indicator_x22_Cloud_Heo.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 >48==04F0BLN :>@84>@0<8."

#property description "!D>@<8@>20==K9 :>@84>@ @025= G5BK@Q< G0A0<, @0AH8@5=8O :>@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 29

#property indicator_buffers 29

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

#property indicator_plots   27

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

//|  >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_x22 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_x22 cloud"

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

//|  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_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 4       |

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

//---- >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 5       |

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

//---- >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= Lime F25B

#property indicator_color5 clrLime

//---- ;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 6       |

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

//---- >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 7       |

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

//---- >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= Green F25B

#property indicator_color7 clrGreen

//---- ;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 3

#property indicator_width7 3

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

#property indicator_label7  "Upper Hans_Indicator 3"

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

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

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

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

#property indicator_type8   DRAW_LINE

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

#property indicator_color8 clrIndigo

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

#property indicator_style8  STYLE_SOLID

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

#property indicator_width8  3

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

#property indicator_label8  "Lower Hans_Indicator 3"

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

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

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

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

#property indicator_type9   DRAW_LINE

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

#property indicator_color9 clrGreen

//---- ;8=8O 8=48:0B>@0 - ?C=:B8@

#property indicator_style9  STYLE_DASH

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

#property indicator_width9 1

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

#property indicator_label9  "Upper Hans_Indicator 4"

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

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

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

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

#property indicator_type10   DRAW_LINE

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

#property indicator_color10 clrIndigo

//---- ;8=8O 8=48:0B>@0 - ?C=:B8@

#property indicator_style10  STYLE_DASH

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

#property indicator_width10  1

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

#property indicator_label10  "Lower Hans_Indicator 4"

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

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

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

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

#property indicator_type11   DRAW_LINE

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

#property indicator_color11 clrGreen

//---- ;8=8O 8=48:0B>@0 - HB@8E-?C=:B8@

#property indicator_style11  STYLE_DASHDOTDOT

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

#property indicator_width11 1

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

#property indicator_label11  "Upper Hans_Indicator 5"

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

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

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

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

#property indicator_type12   DRAW_LINE

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

#property indicator_color12 clrIndigo

//---- ;8=8O 8=48:0B>@0 - HB@8E-?C=:B8@

#property indicator_style12  STYLE_DASHDOTDOT

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

#property indicator_width12  1

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

#property indicator_label12  "Lower Hans_Indicator 5"

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

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

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

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

#property indicator_type13   DRAW_LINE

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

#property indicator_color13 clrGreen

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

#property indicator_style13  STYLE_SOLID

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

#property indicator_width13  1

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

#property indicator_label13  "Upper Hans_Indicator 6"

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

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

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

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

#property indicator_type14   DRAW_LINE

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

#property indicator_color14 clrIndigo

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

#property indicator_style14  STYLE_SOLID

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

#property indicator_width14  1

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

#property indicator_label14  "Lower Hans_Indicator 6"

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

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

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

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

#property indicator_type15   DRAW_LINE

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

#property indicator_color15 clrLime

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

#property indicator_style15  STYLE_SOLID

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

#property indicator_width15 3

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

#property indicator_label15  "Upper Hans_Indicator 7"

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

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

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

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

#property indicator_type16   DRAW_LINE

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

#property indicator_color16 clrRed

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

#property indicator_style16  STYLE_SOLID

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

#property indicator_width16  3

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

#property indicator_label16  "Lower Hans_Indicator 7"

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

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

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

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

#property indicator_type17   DRAW_LINE

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

#property indicator_color17 clrGreen

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

#property indicator_style17  STYLE_SOLID

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

#property indicator_width17 3

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

#property indicator_label17  "Upper Hans_Indicator 8"

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

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

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

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

#property indicator_type18   DRAW_LINE

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

#property indicator_color18 clrIndigo

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

#property indicator_style18  STYLE_SOLID

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

#property indicator_width18  3

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

#property indicator_label18  "Lower Hans_Indicator 8"

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

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

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

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

#property indicator_type19   DRAW_LINE

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

#property indicator_color19 clrGreen

//---- ;8=8O 8=48:0B>@0 - ?C=:B8@

#property indicator_style19  STYLE_DASH

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

#property indicator_width19 1

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

#property indicator_label19  "Upper Hans_Indicator 8"

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

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

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

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

#property indicator_type20   DRAW_LINE

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

#property indicator_color20 clrIndigo

//---- ;8=8O 8=48:0B>@0 - ?C=:B8@

#property indicator_style20  STYLE_DASH

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

#property indicator_width20  1

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

#property indicator_label20  "Lower Hans_Indicator 8"

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

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

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

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

#property indicator_type21   DRAW_LINE

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

#property indicator_color21 clrGreen

//---- ;8=8O 8=48:0B>@0 - HB@8E-?C=:B8@

#property indicator_style21  STYLE_DASHDOTDOT

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

#property indicator_width21 1

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

#property indicator_label21  "Upper Hans_Indicator 10"

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

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

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

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

#property indicator_type22   DRAW_LINE

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

#property indicator_color22 clrIndigo

//---- ;8=8O 8=48:0B>@0 - HB@8E-?C=:B8@

#property indicator_style22  STYLE_DASHDOTDOT

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

#property indicator_width22  1

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

#property indicator_label22  "Lower Hans_Indicator 10"

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

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

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

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

#property indicator_type23   DRAW_LINE

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

#property indicator_color23 clrGreen

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

#property indicator_style23  STYLE_SOLID

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

#property indicator_width23  1

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

#property indicator_label23  "Upper Hans_Indicator 11"

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

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

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

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

#property indicator_type24   DRAW_LINE

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

#property indicator_color24 clrIndigo

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

#property indicator_style24  STYLE_SOLID

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

#property indicator_width24  1

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

#property indicator_label24  "Lower Hans_Indicator 11"



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

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

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

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

#property indicator_type25   DRAW_LINE

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

#property indicator_color25 clrLime

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

#property indicator_style25  STYLE_SOLID

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

#property indicator_width25 3

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

#property indicator_label25  "Upper Hans_Indicator 12"

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

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

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

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

#property indicator_type26   DRAW_LINE

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

#property indicator_color26 clrRed

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

#property indicator_style26  STYLE_SOLID

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

#property indicator_width26  3

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

#property indicator_label26  "Lower Hans_Indicator 12"

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

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

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

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

#property indicator_type27   DRAW_LINE

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

#property indicator_color27 clrSlateGray

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

#property indicator_style27  STYLE_SOLID

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

#property indicator_width27 2

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

#property indicator_label27  "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 PipsForEntryStep=50;     // AB0@B>2K9 H03 @0AH8@5=8O 3@0=8F :064>3> AD>@<8@>20==>3> :>@84>@0 2 ?C=:B0E

input double Kf=1.309;              // :>MDD8F85=B 87<5=5=8O H030 (?> C<>;G0=8N - ?>;>28=0 7>;>B>3> A5G5=8O)

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 UpUpBuffer[],UpDnBuffer[],DnUpBuffer[],DnDnBuffer[];

double Zone1Upper[],Zone2Upper[],Zone3Upper[],Zone4Upper[],Zone5Upper[],Zone6Upper[];

double Zone1Lower[],Zone2Lower[],Zone3Lower[],Zone4Lower[],Zone5Lower[],Zone6Lower[];

double Zone7Upper[],Zone8Upper[],Zone9Upper[],Zone10Upper[],Zone11Upper[],Zone12Upper[];

double Zone7Lower[],Zone8Lower[],Zone9Lower[],Zone10Lower[],Zone11Lower[],Zone12Lower[];

double MiddleBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

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

   min_rates_total=100;



//---- =8F80;870F8O 8=48:0B>@=KE 1CD5@>2 

   IndBufferInit(0,UpUpBuffer);

   IndBufferInit(1,UpDnBuffer);

   //----

   IndBufferInit(2,DnUpBuffer);

   IndBufferInit(3,DnDnBuffer);

   //----

    

   IndBufferInit(4,Zone1Upper);

   IndBufferInit(5,Zone1Lower);

   //----

   IndBufferInit(6,Zone2Upper);

   IndBufferInit(7,Zone2Lower);

   //----

   IndBufferInit(8,Zone3Upper);

   IndBufferInit(9,Zone3Lower);

   //----

   IndBufferInit(10,Zone4Upper);

   IndBufferInit(11,Zone4Lower);

   //----

   IndBufferInit(12,Zone5Upper);

   IndBufferInit(13,Zone5Lower);

   //----

   IndBufferInit(14,Zone6Upper);

   IndBufferInit(15,Zone6Lower);

   //----

   IndBufferInit(16,Zone7Upper);

   IndBufferInit(17,Zone7Lower);

   //----

   IndBufferInit(18,Zone8Upper);

   IndBufferInit(19,Zone8Lower);

   //----

   IndBufferInit(20,Zone9Upper);

   IndBufferInit(21,Zone9Lower);

   //----

   IndBufferInit(22,Zone10Upper);

   IndBufferInit(23,Zone10Lower);

   //----

   IndBufferInit(24,Zone11Upper);

   IndBufferInit(25,Zone11Lower);

   //----

   IndBufferInit(26,Zone12Upper);

   IndBufferInit(27,Zone12Lower);

   //----

   IndBufferInit(28,MiddleBuffer);



//---- =8F80;870F8O 8=48:0B>@>2  

   //for(int count=0; count<2; count++) IndCldInit(count,min_rates_total,Shift);

   for(int count=0; count<2; count++) IndInit(count,EMPTY_VALUE,min_rates_total,Shift);

   for(int count=2; count<27; count++) IndInit(count,NULL,min_rates_total,Shift);

  

//--- 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_x22_Cloud("+string(LocalTimeZone)+","+ string(DestTimeZone)+","+string(PipsForEntryStep)+","+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);

  }

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

//| =8F80;870F8O 8=48:0B>@=>3> 1CD5@0                               |

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

void IndBufferInit(int BuffNumber,double &Buffer[])

  {

//---- ?@52@0I5=85 48=0<8G5A:8E <0AA82>2 2 8=48:0B>@=K5 1CD5@K

   SetIndexBuffer(BuffNumber,Buffer,INDICATOR_DATA);

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

   ArraySetAsSeries(Buffer,true);

//----

  }

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

//| =8F80;870F8O 8=48:0B>@0                                         |

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

void IndCldInit(int PlotNumber,int Draw_Begin,int nShift)

  {

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

   PlotIndexSetInteger(PlotNumber,PLOT_DRAW_BEGIN,Draw_Begin);

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

   PlotIndexSetInteger(PlotNumber,PLOT_SHIFT,nShift);

//---- 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(PlotNumber,PLOT_SHOW_DATA,false);

//----

  }

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

//| =8F80;870F8O 8=48:0B>@0                                         |

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

void IndInit(int PlotNumber,double Empty_Value,int Draw_Begin,int nShift)

  {

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

   PlotIndexSetInteger(PlotNumber,PLOT_DRAW_BEGIN,Draw_Begin);

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

   PlotIndexSetDouble(PlotNumber,PLOT_EMPTY_VALUE,Empty_Value);

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

   PlotIndexSetInteger(PlotNumber,PLOT_SHIFT,nShift);

//---- 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(PlotNumber,PLOT_SHOW_DATA,false);

//----

  }

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

//| 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]={ DBL_MAX,DBL_MAX };

   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]= thigh[j-1];

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

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

                       }



                     if(j-1==1)

                       {

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

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

                        MiddleBuffer[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]= thigh[0]+MathPow(Kf,0)*PipsForEntryStep*_Point;

         Zone1Lower[i]= tlow[0]-MathPow(Kf,0)*PipsForEntryStep*_Point;

         MiddleBuffer[i]=UpDnBuffer[i]=DnUpBuffer[i]=(Zone1Upper[i]+Zone1Lower[i])/2;

         Zone2Upper[i]= thigh[0]+MathPow(Kf,0)*PipsForEntryStep*_Point;

         Zone2Lower[i]= tlow[0]-MathPow(Kf,0)*PipsForEntryStep*_Point;         

         Zone3Upper[i]= Zone2Upper[i]+MathPow(Kf,0)*PipsForEntryStep*_Point;

         Zone3Lower[i]= Zone2Lower[i]-MathPow(Kf,0)*PipsForEntryStep*_Point;

         Zone4Upper[i]= Zone3Upper[i]+MathPow(Kf,1)*PipsForEntryStep*_Point;

         Zone4Lower[i]= Zone3Lower[i]-MathPow(Kf,1)*PipsForEntryStep*_Point;

         Zone5Upper[i]= Zone4Upper[i]+MathPow(Kf,2)*PipsForEntryStep*_Point;

         Zone5Lower[i]= Zone4Lower[i]-MathPow(Kf,2)*PipsForEntryStep*_Point;

         Zone6Upper[i]= Zone5Upper[i]+MathPow(Kf,3)*PipsForEntryStep*_Point;

         Zone6Lower[i]= Zone5Lower[i]-MathPow(Kf,3)*PipsForEntryStep*_Point;

         Zone7Upper[i]= Zone6Upper[i]+MathPow(Kf,4)*PipsForEntryStep*_Point;

         Zone7Lower[i]= Zone6Lower[i]-MathPow(Kf,4)*PipsForEntryStep*_Point;

         Zone8Upper[i]= Zone7Upper[i]+MathPow(Kf,5)*PipsForEntryStep*_Point;

         Zone8Lower[i]= Zone7Lower[i]-MathPow(Kf,5)*PipsForEntryStep*_Point;

         Zone9Upper[i]= Zone8Upper[i]+MathPow(Kf,6)*PipsForEntryStep*_Point;

         Zone9Lower[i]= Zone8Lower[i]-MathPow(Kf,6)*PipsForEntryStep*_Point;

         Zone10Upper[i]= Zone9Upper[i]+MathPow(Kf,7)*PipsForEntryStep*_Point;

         Zone10Lower[i]= Zone9Lower[i]-MathPow(Kf,7)*PipsForEntryStep*_Point;

         Zone11Upper[i]= Zone10Upper[i]+MathPow(Kf,8)*PipsForEntryStep*_Point;

         Zone11Lower[i]= Zone10Lower[i]-MathPow(Kf,8)*PipsForEntryStep*_Point;

         Zone12Upper[i]=UpUpBuffer[i]= Zone11Upper[i]+MathPow(Kf,9)*PipsForEntryStep*_Point;

         Zone12Lower[i]=DnDnBuffer[i]= Zone11Lower[i]-MathPow(Kf,9)*PipsForEntryStep*_Point;

        }

      else

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

         Zone1Upper[i]=Zone1Lower[i]=Zone2Upper[i]=Zone2Lower[i]=Zone3Upper[i]=Zone3Lower[i]=Zone4Upper[i]=Zone4Lower[i]=Zone5Upper[i]=Zone5Lower[i]=NULL;

         Zone6Upper[i]=Zone6Lower[i]=Zone7Upper[i]=Zone7Lower[i]=Zone8Upper[i]=Zone8Lower[i]=Zone9Upper[i]=Zone9Lower[i]=Zone10Upper[i]=Zone10Lower[i]=NULL;

         Zone11Upper[i]=Zone11Lower[i]=Zone12Upper[i]=Zone12Lower[i]=NULL;

         MiddleBuffer[i]=UpDnBuffer[i]=DnUpBuffer[i]=UpUpBuffer[i]=DnDnBuffer[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