//+------------------------------------------------------------------+ //| DynamicBufferShowHide.mq5 | //| Copyright 2022, Alain Verleyen | //| https://login.mql5.com/en/users/angevoyageur | //+------------------------------------------------------------------+ #property copyright "Copyright 2022, Alain Verleyen" #property link "https://login.mql5.com/en/users/angevoyageur" #property version "1.00" #property indicator_separate_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot Label1 #property indicator_label1 "Label1" #property indicator_color1 clrLime #property indicator_width1 1 //--- plot Label2 #property indicator_label2 "Label2" #property indicator_color2 clrRed #property indicator_width2 1 #property indicator_level1 0 #property indicator_levelstyle STYLE_DOT #property indicator_levelwidth 1 #property indicator_levelcolor clrLightSkyBlue //--- indicator buffers double Label1Buffer[]; double Label2Buffer[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void SetIndexStyle(int p, int type, int style, int width, color colour) { PlotIndexSetInteger(p, PLOT_DRAW_TYPE, type); PlotIndexSetInteger(p, PLOT_LINE_STYLE, style); PlotIndexSetInteger(p, PLOT_LINE_WIDTH, width); PlotIndexSetInteger(p, PLOT_LINE_COLOR, colour); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA); SetIndexBuffer(1,Label2Buffer,INDICATOR_DATA); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrLime); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,clrRed); MathSrand(GetTickCount()); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| 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[]) { //--- for(int i=prev_calculated,j=0; i