trying to get a histogram

 
Hello iam trying to get a simple histogram , it opens the indicator window but there is no value shown.
//+------------------------------------------------------------------+
//|                                                     MyIndicator.mq5|
//|                        Copyright 2023, MetaQuotes Software Corp.|
//|                                             https://www.mql5.com|
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_width2 2

//--- indicator buffers
double OpenCloseDifferenceBuffer[];
double HistogramBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   //--- indicator buffers mapping
   SetIndexBuffer(0, OpenCloseDifferenceBuffer, INDICATOR_CALCULATIONS);
   SetIndexBuffer(1, HistogramBuffer, INDICATOR_CALCULATIONS);

   //--- indicator label
   IndicatorSetString(INDICATOR_SHORTNAME, "Open-Close Difference Histogram");

   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[])
{
   int limit = rates_total - prev_calculated;

   for(int i = 0; i < limit; i++)
   {
      OpenCloseDifferenceBuffer[i] = open[i] - close[i];
      HistogramBuffer[i] = OpenCloseDifferenceBuffer[i];
   }

   return(rates_total);
}
//+------------------------------------------------------------------+
 

Copy what exists! Look at ...\Indicators\Examples\MACD.mq5

It creates a histogram in its own window and an average line.

 
Kaschalot98 Ponomareff:
Hello iam trying to get a simple histogram , it opens the indicator window but there is no value shown.
You are using the wrong buffer type

   SetIndexBuffer(0, OpenCloseDifferenceBuffer, INDICATOR_CALCULATIONS);
 
Kaschalot98 Ponomareff:
Hello iam trying to get a simple histogram , it opens the indicator window but there is no value shown.
No plots.