Гистограмма на трех буферах

 

Как нарисовать в индикаторе такую гистограмму: чтобы на каждом баре отображались три значения - максимальное, текущее и минимальное. В виде картинки попытался изобразить так:

Три буфера 

 
В чем сложность возникла? Максимальная самая большая, она первая. Минимальная самая маленькая, она третья. Текущая между первой и третьей.
 
Dmitry Fedoseev:
В чем сложность возникла? Максимальная самая большая, она первая. Минимальная самая маленькая, она третья. Текущая между первой и третьей.
Что-то у меня не вышло. Пробовал DRAW_HISTOGRAM и DRAW_HISTOGRAM2.
 
Karputov Vladimir:
Что-то у меня не вышло. Пробовал DRAW_HISTOGRAM и DRAW_HISTOGRAM2.
DRAW_HISTOGRAM в подокне
 

Владимир, а значения от нулевой линии?

Насколько понимаю, будет 3 гистограммы, каждая - это отдельное графическое отображение...

Имхо, для Вашей задачи нужно сделать DRAW_HISTOGRAM2 - для максимума и минимума. А текущие значения рисовать линией - DRAW_LINE. Так будет информативнее...

 
Dmitry Fedoseev:
DRAW_HISTOGRAM в подокне

 Что-то не выходит...

//+------------------------------------------------------------------+
//|                                        Session Orders Volume.mq5 |
//|                              Copyright © 2016, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.000"
#property description "Session Orders Volume: Open and Sell"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot Max
#property indicator_label1  "Max"
#property indicator_type1   DRAW_HISTOGRAM 
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3
//--- plot Min
#property indicator_label2  "Сurrent"
#property indicator_type2   DRAW_HISTOGRAM
#property indicator_color2  clrYellow
#property indicator_style2  STYLE_SOLID
#property indicator_width2  3
//--- plot Сurrent
#property indicator_label3  "Min"
#property indicator_type3   DRAW_HISTOGRAM
#property indicator_color3  clrRed
#property indicator_style3  STYLE_SOLID
#property indicator_width3  3
//--- indicator buffers
double         BufferMax[];
double         BufferCurrent[];
double         BufferMin[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   Print(__FUNCTION__);
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferMax,INDICATOR_DATA);
   SetIndexBuffer(1,BufferCurrent,INDICATOR_DATA);
   SetIndexBuffer(2,BufferMin,INDICATOR_DATA);
   ArraySetAsSeries(BufferMax,true);
   ArraySetAsSeries(BufferCurrent,true);
   ArraySetAsSeries(BufferMin,true);
//--- construct a short indicator name based on input parameters 
   IndicatorSetInteger(INDICATOR_DIGITS,0);
//---
   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[])
  {
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(close,true);
   ArraySetAsSeries(low,true);
//---
   if(prev_calculated==0)
     {
      //Print(__FUNCTION__,",prev_calculated==0");
      ArrayInitialize(BufferMax,0.0);
      ArrayInitialize(BufferCurrent,0.0);
      ArrayInitialize(BufferMin,0);
      //ArrayInitialize(BufferMin,0.0);
     }
   BufferMax[0]=high[0];
   BufferCurrent[0]=close[0];
   BufferMin[0]=low[0];
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Файлы:
test.mq5  4 kb
 

Вот это - 

 IndicatorSetInteger(INDICATOR_DIGITS,0);

 может мешать. Убрать.

Еще может просто не видно, разница между значениями не значительна, по сравнению с их абсолютными значениям

Если так: 

   BufferMax[0]=high[0]-low[0]+(high[0]-low[0]);
   BufferCurrent[0]=close[0]-low[0]+(high[0]-low[0]);
   BufferMin[0]=low[0]-low[0]+(high[0]-low[0]);
то будет видно.
 
Можно с гистограммой 2, может будет лучше, тогда график будет вписываться в подокно по вертикали. Тут для каждой гистограммы два буфера используется, для минимального значения и максимального, все в явном виде.  
 
Dmitry Fedoseev:

Вот это - 

 может мешать. Убрать.

Еще может просто не видно, разница между значениями не значительна, по сравнению с их абсолютными значениям

Если так: 

то будет видно.
Да, это помогает. Проблема в построении гистограммы от нуля - поэтому малые изменения не видны.
 

Тогда гистограмму 2

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_plots   3
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_HISTOGRAM2
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Label2
#property indicator_label2  "Label2"
#property indicator_type2   DRAW_HISTOGRAM2
#property indicator_color2  clrLime
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot Label3
#property indicator_label3  "Label3"
#property indicator_type3   DRAW_HISTOGRAM2
#property indicator_color3  clrYellow
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- input parameters
input int      Input1;
//--- indicator buffers
double         Label1Buffer1[];
double         Label1Buffer2[];
double         Label2Buffer1[];
double         Label2Buffer2[];
double         Label3Buffer1[];
double         Label3Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer1,INDICATOR_DATA);
   SetIndexBuffer(1,Label1Buffer2,INDICATOR_DATA);
   SetIndexBuffer(2,Label2Buffer1,INDICATOR_DATA);
   SetIndexBuffer(3,Label2Buffer2,INDICATOR_DATA);
   SetIndexBuffer(4,Label3Buffer1,INDICATOR_DATA);
   SetIndexBuffer(5,Label3Buffer2,INDICATOR_DATA);
   
//---
   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[])
  {
//---
   
   Label1Buffer1[rates_total-1]=1;
   Label1Buffer2[rates_total-1]=2;
   
   Label2Buffer1[rates_total-1]=2;
   Label2Buffer2[rates_total-1]=3;
   
   Label3Buffer1[rates_total-1]=3;
   Label3Buffer2[rates_total-1]=4; 
   
   
     

//--- return value of prev_calculated for next call
   return(rates_total);
  }

 

Прототип:

//+------------------------------------------------------------------+
//|                                        Session Orders Volume.mq5 |
//|                              Copyright © 2016, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.001"
#property description "Session Orders Volume: Open and Sell"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_plots   3
//--- plot Max
#property indicator_label1  "Max"
#property indicator_type1   DRAW_HISTOGRAM2
#property indicator_color1  clrBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3
//--- plot Min
#property indicator_label2  "Сurrent"
#property indicator_type2   DRAW_HISTOGRAM2
#property indicator_color2  clrYellow
#property indicator_style2  STYLE_SOLID
#property indicator_width2  3
//--- plot Сurrent
#property indicator_label3  "Min"
#property indicator_type3   DRAW_HISTOGRAM2
#property indicator_color3  clrRed
#property indicator_style3  STYLE_SOLID
#property indicator_width3  3
//--- indicator buffers
double         BufferMax1[];
double         BufferMax2[];
double         BufferCurrent1[];
double         BufferCurrent2[];
double         BufferMin1[];
double         BufferMin2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   Print(__FUNCTION__);
//--- indicator buffers mapping
   SetIndexBuffer(0,BufferMax1,INDICATOR_DATA);
   SetIndexBuffer(1,BufferMax2,INDICATOR_DATA);
   SetIndexBuffer(2,BufferCurrent1,INDICATOR_DATA);
   SetIndexBuffer(3,BufferCurrent2,INDICATOR_DATA);
   SetIndexBuffer(4,BufferMin1,INDICATOR_DATA);
   SetIndexBuffer(5,BufferMin2,INDICATOR_DATA);
   ArraySetAsSeries(BufferMax1,true);
   ArraySetAsSeries(BufferMax2,true);
   ArraySetAsSeries(BufferCurrent1,true);
   ArraySetAsSeries(BufferCurrent2,true);
   ArraySetAsSeries(BufferMin1,true);
   ArraySetAsSeries(BufferMin2,true);
//---
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,0);
   PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,0);
//---
   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[])
  {
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);
//---
   if(prev_calculated==0)
     {
      ArrayInitialize(BufferMax1,0.0);
      ArrayInitialize(BufferMax2,0.0);
      ArrayInitialize(BufferCurrent1,0.0);
      ArrayInitialize(BufferCurrent2,0.0);
      ArrayInitialize(BufferMin1,0);
      ArrayInitialize(BufferMin2,0);
     }

   if(close[0]>open[0])
     {
      BufferMax1[0]=high[0];
      BufferMax2[0]=close[0];
      BufferCurrent1[0]=close[0];
      BufferCurrent2[0]=open[0];
      BufferMin1[0]=open[0];
      BufferMin2[0]=low[0];
     }
   else
     {
      BufferMax1[0]=high[0];
      BufferMax2[0]=open[0];
      BufferCurrent1[0]=open[0];
      BufferCurrent2[0]=close[0];
      BufferMin1[0]=close[0];
      BufferMin2[0]=low[0];
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

Спасибо за наводку.

Файлы:
test.mq5  5 kb
Причина обращения: