MQL5 Indicator Not Plotting Arrows on Chart - Help Debugging

 

I’m working on an MQL5 custom indicator and I’ve extracted this part of the code to test why the arrows aren’t showing up on the chart. The main logic of the indicator is working as expected, but the plotting is not.

Note that this is just a part I extracted from my indicator and I’ve given random names for testing purposes. The logic of where the arrows are meant to plot in the full indicator is not relevant for this issue. I’m just wondering why this specific code is not plotting anything.


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2

#property indicator_label1 "Up Arrow"
#property indicator_color1 clrLime

#property indicator_label2 "Down Arrow"
#property indicator_color2 clrRed

double miArrowBuffer[];
double maArrowBuffer[];

int OnInit()
{
   SetIndexBuffer(0, miArrowBuffer);
   SetIndexBuffer(1, maArrowBuffer);
   
   ArraySetAsSeries(miArrowBuffer, true);
   ArraySetAsSeries(maArrowBuffer, true);

   PlotIndexSetInteger(0, PLOT_ARROW, 233);
   PlotIndexSetInteger(1, PLOT_ARROW, 234);
   
   return(INIT_SUCCEEDED);
}

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 (rates_total == prev_calculated) {
      return(rates_total);
   }
   
   int start = prev_calculated == 0 ? rates_total - 1 : rates_total - prev_calculated;
   int end = 0;
   
   for (int barIndex = start; barIndex > end; barIndex--) {
      miArrowBuffer[barIndex] = low[barIndex];
      maArrowBuffer[barIndex] = high[barIndex];
   }
   
   return(rates_total);
}


What I’ve done so far:

  • I’m using  miArrowBuffer[]  and  maArrowBuffer[]  to plot arrows with the  PLOT_ARROW  property.

  • I’ve set the buffers as series with  ArraySetAsSeries .

I’m just curious if there’s something in this specific section of code that’s causing the arrows not to plot, what is missing?

 

You are a newbie I guess, so why trying to build your indicator from the scratch?

Take a working one e.g. from the SourceBase or from the article section that is similar to your idea and amend it according to your ideas? It's faster als a lot less frustrating!

Search here for "indicator plot symbols"

MQL5 Code Base
MQL5 Code Base
  • www.mql5.com
MQL5 Source Code Library for MetaTrader 5
 

because while you gave the arrow code, you didn't specify the drawing type for the buffers


so you need this

#property indicator_type1   DRAW_ARROW
#property indicator_width1  2

#property indicator_type2   DRAW_ARROW
#property indicator_width2  2