I am not setting arrow buffers values but Indicator is ploting arrows on every bar

 

Hi Everyone!
The indicator is showing arrows, but i have commented the ( buffer[i]=value; ) line.
i dont know what is setting the values of buffer and why arrows are showing on the chart.
Thanks!
REX (Hassan Bilal)

Files:
 

Explicitly set the required empty value for each indicator buffer using PLOT_EMPTY_VALUE.

There is a mention of this in the DRAW_CANDLES documentation. Even though you don't need DRAW_CANDLES, what was said there about the empty value still holds true.

Link

The indicator is drawn only to those bars, for which non-empty values of all four indicator buffers are set. (This is for DRAW_CANDLES)

The indicator is drawn only for those bars for which non-empty indicator buffer values are specified.

To specify what value should be considered as "empty", set this value in the PLOT_EMPTY_VALUE property:

//--- The 0 (empty) value will mot participate in drawing
   PlotIndexSetDouble(index_of_plot_DRAW_CANDLES,PLOT_EMPTY_VALUE,0);

Always explicitly fill in the values ​​of the indicator buffers, set an empty value in a buffer to skip bars.

That is, if arrows are displayed, then the buffer contains values other than empty.

If you do not explicitly specify an empty value for the buffer, then the empty value for the buffer will depend on the terminal defaults.

 

Your arrow buffers contain zeros. Most likely, the terminal by default considers EMPTY_VALUE to be an empty value for this buffer, and not 0


 
Vladislav Boyko #:

Explicitly set the required empty value for each indicator buffer using PLOT_EMPTY_VALUE.

There is a mention of this in the DRAW_CANDLES documentation. Even though you don't need DRAW_CANDLES, what was said there about the empty value still holds true.

That is, if arrows are displayed, then the buffer contains values other than empty.

If you do not explicitly specify an empty value for the buffer, then the empty value for the buffer will depend on the terminal defaults.I have 

I have tried this brother but still it is showing so many arrows. Please help. Thankyou !

Files:
request.JPG  116 kb
 
rex1122r #:

I have tried this brother but still it is showing so many arrows. Please help. Thankyou !

What exactly did you try? Attach source code

 
Vladislav Boyko #:

What exactly did you try? Attach source code

I have tried PLOT_EMPTY_VALUE but still it is ploting so many false arrows, please run it on Daily chart timeframe. Thanks!
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

if you're trying to make one arrow appear on the states of line color change, then you should modify this part of the code:


      for(i = j - Periods; i >= 0; i--)
        {
        
         b2[i] = EMPTY_VALUE;
         b3[i] = EMPTY_VALUE;
  
         lda_20[i] = lda_20[i + 1];
         if(noPlotBuffer[i] > noPlotBuffer[i + 1])
            lda_20[i] = 1;
         if(noPlotBuffer[i] < noPlotBuffer[i + 1])
            lda_20[i] = -1;

         if(lda_20[i] > 0.0)
           {
            aquaLineBuffer[i] = noPlotBuffer[i];
            if(lda_20[i + 1] < 0.0)
               aquaLineBuffer[i + 1] = noPlotBuffer[i + 1];
            redLineBuffer[i] = EMPTY_VALUE;
            
                 if (Previous_Signal != "Buy")
                    {
                        b3[i] = low[i];
                        Previous_Signal = "Buy";
                        Print(Previous_Signal, "  ", i);
                    }
           }
         else
           {
            if(lda_20[i] < 0.0)
              {
               redLineBuffer[i] = noPlotBuffer[i];
               if(lda_20[i + 1] > 0.0)
                  redLineBuffer[i + 1] = noPlotBuffer[i + 1];
               aquaLineBuffer[i] = EMPTY_VALUE;
               
               
                    if (Previous_Signal != "Sell")
                    {
                        b2[i] = high[i];
                        Previous_Signal = "Sell";
                        //  Print(Previous_Signal,"  ", i);
                    }
              }
           }
        }



and take away the arrow buffer code from there:

      for(int i=TotalBars-2  && !IsStopped() ; i>=1; i--)
        {

         if(aquaLineBuffer[i+1]!=EMPTY_VALUE && redLineBuffer[i+1]!=EMPTY_VALUE && aquaLineBuffer[i]!=EMPTY_VALUE && redLineBuffer[i]==EMPTY_VALUE&& Previous_Signal!="Buy")
           {
           // b3[i] = low[i]-Arrow_PointGap*Point(); //REMOVE
            Previous_Signal="Buy";
            Print(Previous_Signal,"  ", i);
           }
         //Print(i+2,"  bufer Size : ",ArraySize(aquaLineBuffer));

         if(aquaLineBuffer[i+2]!=EMPTY_VALUE && aquaLineBuffer[i+1]!=EMPTY_VALUE && redLineBuffer[i+1]!=EMPTY_VALUE && redLineBuffer[i]!=EMPTY_VALUE && Previous_Signal!="Sell")
           {
            // b2[i] = high[i]+Arrow_PointGap*Point();  //REMOVE
            Previous_Signal="Sell";
            //  Print(Previous_Signal,"  ", i);
           }

        }


All the other initialization code is fine

 
rex1122r #:
I have tried PLOT_EMPTY_VALUE but still it is ploting so many false arrows, please run it on Daily chart timeframe. Thanks!

Zeros for arrows in the data window are no longer displayed. This means that the arrows now contain empty values. (Compare this to the previous screenshot where you could see zeros in the data window)


Now the empty values for the arrows seem to be ok. As for the extra arrows, now this is only caused by a logical error in your code. I haven't studied the logic of your code.

 
Conor Mcnamara #:

As I said above, I did not study the logic of the code. But considering this

PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,0);
PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,0);

empty values from the quote below should be replaced with zeros

Conor Mcnamara #:
for(i = j - Periods; i >= 0; i--)
        {
        
         b2[i] = EMPTY_VALUE;
         b3[i] = EMPTY_VALUE;
 
Conor Mcnamara #:

if you're trying to make one arrow appear on the states of line color change, then you should modify this part of the code:




and take away the arrow buffer code from there:


All the other initialization code is fine

Thankyou so much it worked XD
 
Vladislav Boyko #:

As I said above, I did not study the logic of the code. But considering this

empty values from the quote below should be replaced with zeros

Thanksyou so much it is working now XD
Reason: