Author: MVS © 2020
2 Views
0 Downloads
0 Favorites
i-HideBar
ÿþ//+------------------------------------------------------------------+

//|                                                    i-HideBar.mq5 |

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

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

#property copyright "MVS © 2020"

#property version "1.1"

#property indicator_buffers 5

#property indicator_plots   1

#property indicator_type1   DRAW_COLOR_CANDLES

#property indicator_width1  3

#property indicator_label1  "Open;High;Low;Close"

#property indicator_chart_window



input int  UseHideBar = 3;    // Count of hidden bars

input bool UseHideBid = true; // Hide line Bid



// Buffers

double _open[],_high[],_low[],_close[],_color[];



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

//| Expert initialization function                                   |

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

int OnInit()

  {

   SetIndexBuffer(0,_open,INDICATOR_DATA);

   ArraySetAsSeries(_open,true);

   SetIndexBuffer(1,_high,INDICATOR_DATA);

   ArraySetAsSeries(_high,true);

   SetIndexBuffer(2,_low,INDICATOR_DATA);

   ArraySetAsSeries(_low,true);

   SetIndexBuffer(3,_close,INDICATOR_DATA);

   ArraySetAsSeries(_close,true);

   SetIndexBuffer(4,_color,INDICATOR_COLOR_INDEX);

   ArraySetAsSeries(_color,true);

// 

   color ClChart=(color)ChartGetInteger(0,CHART_COLOR_BACKGROUND,0);

   PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,2);

   PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,ClChart);

   PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,clrNONE);

//

   ChartSetInteger(0,CHART_SHOW_BID_LINE,!UseHideBid);

//

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

   ChartSetInteger(0,CHART_SHOW_BID_LINE,UseHideBid);

  }

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

//|                                                                  |

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

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

  {

   if(prev_calculated==0)

     {

      ArrayInitialize(_open,EMPTY_VALUE);

      ArrayInitialize(_high,EMPTY_VALUE);

      ArrayInitialize(_low,EMPTY_VALUE);

      ArrayInitialize(_close,EMPTY_VALUE);

      ArrayInitialize(_color,EMPTY_VALUE);

     }

   ArraySetAsSeries(open,true);

   ArraySetAsSeries(high,true);

   ArraySetAsSeries(low,true);

   ArraySetAsSeries(close,true);



   for(int i=0; i<UseHideBar; i++)

     {

      _open[i]=open[i];

      _high[i]=high[i];

      _low[i]=low[i];

      _close[i]=close[i];

      _color[i]=0;

      if(i==UseHideBar-1)

         _color[i+1]=1;

     }



   return(rates_total);

  }

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

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