Rainbow Bars 2.ru

Author: Copyright 2018, Rakovsergey && Tor
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Rainbow Bars 2.ru
ÿþ//+------------------------------------------------------------------+

//|                                                 Rainbow Bars.mq4 |

//|                                                      Rakovsergey |

//|                                           rakov-sergey@yandex.ru |

//|                                                              Tor |

//|                          https://www.mql5.com/ru/users/tormovies |

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

#property copyright "Copyright 2018, Rakovsergey && Tor"

#property link      "https://www.mql5.com/ru/users/tormovies"

#property strict



#property indicator_chart_window

#property indicator_buffers 21

#property indicator_color1 clrYellow

#property indicator_color2 clrYellow

#property indicator_color3 clrOrange

#property indicator_color4 clrOrange

#property indicator_color5 clrChocolate

#property indicator_color6 clrChocolate

#property indicator_color7 clrRed

#property indicator_color8 clrRed



#property indicator_color9 clrAqua

#property indicator_color10 clrAqua

#property indicator_color11 clrDodgerBlue

#property indicator_color12 clrDodgerBlue

#property indicator_color13 clrBlue

#property indicator_color14 clrBlue

#property indicator_color15 clrMidnightBlue

#property indicator_color16 clrMidnightBlue



#property indicator_color17 clrNONE

#property indicator_color18 clrNONE

#property indicator_color19 clrNONE

#property indicator_color20 clrNONE

#property indicator_color21 clrNONE

#property indicator_width17 1

#property indicator_width18 1

#property indicator_width19 1

#property indicator_width20 1

#property indicator_width21 1

#property indicator_style17 STYLE_SOLID

#property indicator_style18 STYLE_SOLID

#property indicator_style19 STYLE_SOLID

#property indicator_style20 STYLE_SOLID

#property indicator_style21 STYLE_SOLID



//---- buffers



input int MA_Period1=3; // 5@8>4 MA1

input int MA_Period2=8; // 5@8>4 MA2

input int MA_Period3=21; // 5@8>4 MA3

input int MA_Period4=55; // 5@8>4 MA4

input int MA_Period5=81; // 5@8>4 MA5

input ENUM_APPLIED_PRICE MAApp=PRICE_OPEN; // &5=0 ?@8<5=5=8O

input ENUM_MA_METHOD MAMethod=MODE_EMA; // "8? ?>AB@>5=8O ;8=89

input int Shift=0; // C :0:>9 A25G8 15@5BAO A83=0; (1/0)

input color clrMA1=clrRed; // &25B  1

input color clrMA2 = clrOrange; // &25B  2

input color clrMA3 = clrYellow; // &25B  3

input color clrMA4=clrYellowGreen; // &25B  4

input color clrMA5=clrAqua; // &25B  5

input int MAWidth=1; // ">;I8=0 ;8=88 

input ENUM_LINE_STYLE MAStyle=STYLE_SOLID; // !B8;L ;8=88

input int HGWidth=2; // ">;I8=0 ;8=89 38AB>3@0<<



input color clrHist10 = clrYellow;     // &25B ?>;>68B5;L=>3> @0A:@KB8O ma1, ma2

input color clrHist20 = clrOrange;     // &25B ?>;>68B5;L=>3> @0A:@KB8O ma1,ma2,ma3

input color clrHist30 = clrChocolate;  // &25B ?>;>68B5;L=>3> @0A:@KB8O ma1,ma2,ma3,ma4

input color clrHist40 = clrRed;        // &25B ?>;>68B5;L=>3> @0A:@KB8O ma1,ma2,ma3,ma4,ma5



input color clrHist12 = clrAqua;          // &25B >B@8F0B5;L=>3> @0A:@KB8O ma1, ma2

input color clrHist22 = clrDodgerBlue;    // &25B >B@8F0B5;L=>3> @0A:@KB8O ma1,ma2,ma3

input color clrHist32 = clrBlue;          // &25B >B@8F0B5;L=>3> @0A:@KB8O ma1,ma2,ma3,ma4

input color clrHist42 = clrMidnightBlue;  // &25B >B@8F0B5;L=>3> @0A:@KB8O ma1,ma2,ma3,ma4,ma5



input int ExtCountedBars=1000; // 8<8B 10@>2 ?> 8AB>@88 (0 = 2K:;NG5=)



double ExtMapBuffer10[],ExtMapBuffer20[],ExtMapBuffer30[],ExtMapBuffer40[],ExtMapBuffer11[],ExtMapBuffer21[],ExtMapBuffer31[],ExtMapBuffer41[];

double ExtMapBufferM10[],ExtMapBufferM20[],ExtMapBufferM30[],ExtMapBufferM40[],ExtMapBufferM11[],ExtMapBufferM21[],ExtMapBufferM31[],ExtMapBufferM41[];



double ma1[],ma2[],ma3[],ma4[],ma5[];

color clrRma1,clrRma2,clrRma3,clrRma4,clrRma5;

int w1,w2,w3,w4,w5;

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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators

   if(indicator_color17!=clrNONE){ clrRma1 = indicator_color17; }else{  clrRma1 = clrMA1; }

   if(indicator_color18!=clrNONE){ clrRma2 = indicator_color18; }else{ clrRma2 = clrMA2; }

   if(indicator_color19!=clrNONE){ clrRma3 = indicator_color19; }else{ clrRma3 = clrMA3; }

   if(indicator_color20!=clrNONE){ clrRma4 = indicator_color20; }else{ clrRma4 = clrMA4; }

   if(indicator_color21!=clrNONE){ clrRma5 = indicator_color21; }else{ clrRma5 = clrMA5; }



   if(indicator_width17>1){ w1 = indicator_width17; }else{ w1 = MAWidth; }

   if(indicator_width18>1){ w2 = indicator_width18; }else{ w2 = MAWidth; }

   if(indicator_width19>1){ w3 = indicator_width19; }else{ w3 = MAWidth; }

   if(indicator_width20>1){ w4 = indicator_width20; }else{ w4 = MAWidth; }

   if(indicator_width21>1){ w5 = indicator_width21; }else{ w5 = MAWidth; }

   SetIndexBuffer(0,ExtMapBuffer10);

   SetIndexBuffer(1,ExtMapBuffer11);

   SetIndexBuffer(2,ExtMapBuffer20);

   SetIndexBuffer(3,ExtMapBuffer21);

   SetIndexBuffer(4,ExtMapBuffer30);

   SetIndexBuffer(5,ExtMapBuffer31);

   SetIndexBuffer(6,ExtMapBuffer40);

   SetIndexBuffer(7,ExtMapBuffer41);

   SetIndexBuffer(8,ExtMapBufferM10);

   SetIndexBuffer(9,ExtMapBufferM11);

   SetIndexBuffer(10,ExtMapBufferM20);

   SetIndexBuffer(11,ExtMapBufferM21);

   SetIndexBuffer(12,ExtMapBufferM30);

   SetIndexBuffer(13,ExtMapBufferM31);

   SetIndexBuffer(14,ExtMapBufferM40);

   SetIndexBuffer(15,ExtMapBufferM41);

   SetIndexBuffer(16,ma1);

   SetIndexBuffer(17,ma2);

   SetIndexBuffer(18,ma3);

   SetIndexBuffer(19,ma4);

   SetIndexBuffer(20,ma5);

   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist10);

   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist10);

   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist20);

   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist20);

   SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist30);

   SetIndexStyle(5,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist30);

   SetIndexStyle(6,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist40);

   SetIndexStyle(7,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist40);

   SetIndexStyle(8,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist12);

   SetIndexStyle(9,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist12);

   SetIndexStyle(10,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist22);

   SetIndexStyle(11,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist22);

   SetIndexStyle(12,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist32);

   SetIndexStyle(13,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist32);

   SetIndexStyle(14,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist42);

   SetIndexStyle(15,DRAW_HISTOGRAM,STYLE_SOLID,HGWidth,clrHist42);

   SetIndexStyle(16,DRAW_LINE,MAStyle,w1,clrRma1);

   SetIndexStyle(17,DRAW_LINE,MAStyle,w2,clrRma2);

   SetIndexStyle(18,DRAW_LINE,MAStyle,w3,clrRma3);

   SetIndexStyle(19,DRAW_LINE,MAStyle,w4,clrRma4);

   SetIndexStyle(20,DRAW_LINE,MAStyle,w5,clrRma5);

   SetIndexEmptyValue(0,0.0);

   SetIndexEmptyValue(1,0.0);

   SetIndexEmptyValue(2,0.0);

   SetIndexEmptyValue(3,0.0);

   SetIndexEmptyValue(4,0.0);

   SetIndexEmptyValue(5,0.0);

   SetIndexEmptyValue(6,0.0);

   SetIndexEmptyValue(7,0.0);

   SetIndexEmptyValue(8,0.0);

   SetIndexEmptyValue(9,0.0);

   SetIndexEmptyValue(10,0.0);

   SetIndexEmptyValue(11,0.0);

   SetIndexEmptyValue(12,0.0);

   SetIndexEmptyValue(13,0.0);

   SetIndexEmptyValue(14,0.0);

   SetIndexEmptyValue(15,0.0);

   SetIndexLabel(0," 0A:@KB85 + ma1,ma2");

   SetIndexLabel(1," 0A:@KB85 + ma1,ma2");

   SetIndexLabel(2," 0A:@KB85 + ma1,ma2,ma3");

   SetIndexLabel(3," 0A:@KB85 + ma1,ma2,ma3");

   SetIndexLabel(4," 0A:@KB85 + ma1,ma2,ma3,ma4");

   SetIndexLabel(5," 0A:@KB85 + ma1,ma2,ma3,ma4");

   SetIndexLabel(6," 0A:@KB85 + ma1,ma2,ma3,ma4,ma5");

   SetIndexLabel(7," 0A:@KB85 + ma1,ma2,ma3,ma4,ma5");

   SetIndexLabel(8," 0A:@KB85 - ma1,ma2");

   SetIndexLabel(9," 0A:@KB85 - ma1,ma2");

   SetIndexLabel(10," 0A:@KB85 - ma1,ma2,ma3");

   SetIndexLabel(11," 0A:@KB85 - ma1,ma2,ma3");

   SetIndexLabel(12," 0A:@KB85 - ma1,ma2,ma3,ma4");

   SetIndexLabel(13," 0A:@KB85 - ma1,ma2,ma3,ma4");

   SetIndexLabel(14," 0A:@KB85 - ma1,ma2,ma3,ma4,ma5");

   SetIndexLabel(15," 0A:@KB85 - ma1,ma2,ma3,ma4,ma5");

//----

   return(0);

  }

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

//----



//----

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                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[])

  {



   int limit;

//---

   if(rates_total<=1)

      return(0);

//--- last counted bar will be recounted

   limit=rates_total-prev_calculated;

   if(prev_calculated>0)

      limit=limit+1;



   if(ExtCountedBars>0 && limit>ExtCountedBars){ limit=ExtCountedBars; }



   for(int i=limit-1; i>=0; i--)

     {



      ma1[i] = iMA(NULL, 0, MA_Period1, 0, MAMethod, MAApp, i+Shift);

      ma2[i] = iMA(NULL, 0, MA_Period2, 0, MAMethod, MAApp, i+Shift);

      ma3[i] = iMA(NULL, 0, MA_Period3, 0, MAMethod, MAApp, i+Shift);

      ma4[i] = iMA(NULL, 0, MA_Period4, 0, MAMethod, MAApp, i+Shift);

      ma5[i] = iMA(NULL, 0, MA_Period5, 0, MAMethod, MAApp, i+Shift);



      if(ma1[i]>ma2[i])

        {

         ExtMapBuffer10[i]=Open[i]; ExtMapBuffer11[i]=Close[i]; ExtMapBuffer20[i]=0; ExtMapBuffer21[i]=0;

         ExtMapBuffer30[i]=0; ExtMapBuffer31[i]=0;  ExtMapBuffer40[i]=0; ExtMapBuffer41[i]=0;

         ExtMapBufferM10[i]=0; ExtMapBufferM11[i]=0; ExtMapBufferM20[i]=0; ExtMapBufferM21[i]=0;

         ExtMapBufferM30[i]=0; ExtMapBufferM31[i]=0; ExtMapBufferM40[i]=0; ExtMapBufferM41[i]=0;

        }



      if(ma1[i]<ma2[i])

        {

         ExtMapBufferM10[i]=Open[i]; ExtMapBufferM11[i]=Close[i]; ExtMapBufferM20[i]=0; ExtMapBufferM21[i]=0;

         ExtMapBufferM30[i]=0; ExtMapBufferM31[i]=0; ExtMapBufferM40[i]=0; ExtMapBufferM41[i]=0;

         ExtMapBuffer10[i]=0; ExtMapBuffer11[i]=0; ExtMapBuffer20[i]=0; ExtMapBuffer21[i]=0;

         ExtMapBuffer30[i]=0; ExtMapBuffer31[i]=0;  ExtMapBuffer40[i]=0; ExtMapBuffer41[i]=0;

        }



      if(ma1[i]>ma2[i] && ma1[i]>ma3[i] && ma2[i]>ma3[i])

        {

         ExtMapBuffer20[i]=Open[i]; ExtMapBuffer21[i]=Close[i]; ExtMapBuffer10[i]=0; ExtMapBuffer11[i]=0;

         ExtMapBuffer30[i]=0; ExtMapBuffer31[i]=0;  ExtMapBuffer40[i]=0; ExtMapBuffer41[i]=0;

         ExtMapBufferM10[i]=0; ExtMapBufferM11[i]=0; ExtMapBufferM20[i]=0; ExtMapBufferM21[i]=0;

         ExtMapBufferM30[i]=0; ExtMapBufferM31[i]=0; ExtMapBufferM40[i]=0; ExtMapBufferM41[i]=0;

        }



      if(ma1[i]<ma2[i] && ma1[i]<ma3[i] && ma2[i]<ma3[i])

        {

         ExtMapBufferM20[i]=Open[i]; ExtMapBufferM21[i]=Close[i]; ExtMapBufferM10[i]=0; ExtMapBufferM11[i]=0;

         ExtMapBufferM30[i]=0; ExtMapBufferM31[i]=0; ExtMapBufferM40[i]=0; ExtMapBufferM41[i]=0;

         ExtMapBuffer10[i]=0; ExtMapBuffer11[i]=0; ExtMapBuffer20[i]=0; ExtMapBuffer21[i]=0;

         ExtMapBuffer30[i]=0; ExtMapBuffer31[i]=0;  ExtMapBuffer40[i]=0; ExtMapBuffer41[i]=0;

        }



      if(ma1[i]>ma2[i] && ma1[i]>ma3[i] && ma1[i]>ma4[i] && ma2[i]>ma3[i] && ma2[i]>ma4[i] && ma3[i]>ma4[i])

        {

         ExtMapBuffer30[i]=Open[i]; ExtMapBuffer31[i]=Close[i]; ExtMapBuffer10[i]=0; ExtMapBuffer11[i]=0;

         ExtMapBuffer20[i]=0; ExtMapBuffer21[i]=0;  ExtMapBuffer40[i]=0; ExtMapBuffer41[i]=0;

         ExtMapBufferM10[i]=0; ExtMapBufferM11[i]=0; ExtMapBufferM20[i]=0; ExtMapBufferM21[i]=0;

         ExtMapBufferM30[i]=0; ExtMapBufferM31[i]=0; ExtMapBufferM40[i]=0; ExtMapBufferM41[i]=0;

        }



      if(ma1[i]<ma2[i] && ma1[i]<ma3[i] && ma1[i]<ma4[i] && ma2[i]<ma3[i] && ma2[i]<ma4[i] && ma3[i]<ma4[i])

        {

         ExtMapBufferM30[i]=Open[i]; ExtMapBufferM31[i]=Close[i]; ExtMapBufferM20[i]=0; ExtMapBufferM21[i]=0;

         ExtMapBufferM10[i]=0; ExtMapBufferM11[i]=0; ExtMapBufferM40[i]=0; ExtMapBufferM41[i]=0;

         ExtMapBuffer10[i]=0; ExtMapBuffer11[i]=0; ExtMapBuffer20[i]=0; ExtMapBuffer21[i]=0;

         ExtMapBuffer30[i]=0; ExtMapBuffer31[i]=0;  ExtMapBuffer40[i]=0; ExtMapBuffer41[i]=0;

        }



      if(ma1[i]>ma2[i] && ma1[i]>ma3[i] && ma1[i]>ma4[i] && ma1[i]>ma5[i] && ma2[i]>ma3[i]

         && ma2[i]>ma4[i] && ma2[i]>ma5[i] && ma3[i]>ma4[i] && ma3[i]>ma5[i] && ma4[i]>ma5[i])

        {

         ExtMapBuffer40[i]=Open[i]; ExtMapBuffer41[i]=Close[i]; ExtMapBuffer10[i]=0; ExtMapBuffer11[i]=0;

         ExtMapBuffer30[i]=0; ExtMapBuffer31[i]=0;  ExtMapBuffer20[i]=0; ExtMapBuffer21[i]=0;

         ExtMapBufferM10[i]=0; ExtMapBufferM11[i]=0; ExtMapBufferM20[i]=0; ExtMapBufferM21[i]=0;

         ExtMapBufferM30[i]=0; ExtMapBufferM31[i]=0; ExtMapBufferM40[i]=0; ExtMapBufferM41[i]=0;

        }



      if(ma1[i]<ma2[i] && ma1[i]<ma3[i] && ma1[i]<ma4[i] && ma1[i]<ma5[i] && ma2[i]<ma3[i]

         && ma2[i]<ma4[i] && ma2[i]<ma5[i] && ma3[i]<ma4[i] && ma3[i]<ma5[i] && ma4[i]<ma5[i])

        {

         ExtMapBufferM40[i]=Open[i]; ExtMapBufferM41[i]=Close[i]; ExtMapBufferM20[i]=0; ExtMapBufferM21[i]=0;

         ExtMapBufferM30[i]=0; ExtMapBufferM31[i]=0; ExtMapBufferM10[i]=0; ExtMapBufferM11[i]=0;

         ExtMapBuffer10[i]=0; ExtMapBuffer11[i]=0; ExtMapBuffer20[i]=0; ExtMapBuffer21[i]=0;

         ExtMapBuffer30[i]=0; ExtMapBuffer31[i]=0;  ExtMapBuffer40[i]=0; ExtMapBuffer41[i]=0;

        }



     }



//----



//----

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