Arrows don't follow candles

 
Good morning

I started studying MQL about a month ago and I have had a problem in which I have tried to solve in many ways and not succeed.

The problem itself would be to make the arrows plotted on the chart (with the market open) track the candles when these are in the opposite direction (image below).



My code is as follows, if anyone can help me thank me very much.

int OnCalculate( ... )
 {
  if(IsSell() && Time[0] != sendOnce)
    {
      downArrow[0] = High[0] + arrowIndent * 10 * Point;

      //--- Move sell arrow
      activeSell = true;

      sendOnce = Time[0];
    }

  //--- Move sell arrow
  if(activeSell && !IsItNewBar())
     downArrow[0] = High[0] + arrowIndent * 10 * Point;
  else
     activeSell = false;
 }

//---
bool IsItNewBar()
  {
   static datetime lastTime;
   bool IsNewBar = (Time[0] != lastTime);
   lastTime = Time[0];

   return(IsNewBar);
  }
 
The picture is not clear. The arrow is simply drawn in the figure. What does the arrow show? What is the condition for the arrow to appear?
 
Vladimir Karputov:
The picture is not clear. The arrow is simply drawn in the figure. What does the arrow show? What is the condition for the arrow to appear?

The condition of sale is in the isSell() function.

The arrow shows the following below.


What I wish is that the arrow will always be above the maximum of the candle where a sale was indicated.

 
Jeovane Reges:

The condition of sale is in the isSell() function.

The arrow shows the following below.


What I wish is that the arrow will always be above the maximum of the candle where a sale was indicated.

1. Use new function: OnCalculate

int  OnCalculate(
   const int        rates_total,       // size of input time series
   const int        prev_calculated,   // number of handled bars at the previous call
   const datetime&  time{},            // Time array
   const double&    open[],            // Open array
   const double&    high[],            // High array
   const double&    low[],             // Low array
   const double&    close[],           // Close array
   const long&      tick_volume[],     // Tick Volume array
   const long&      volume[],          // Real Volume array
   const int&       spread[]           // Spread array
   );
2. Help example: DRAW_ARROW
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_ARROW
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_ARROW
  • www.mql5.com
//|                                                   DRAW_ARROW.mq5 | //|                        Copyright 2011, MetaQuotes Software Corp. | //|                                              https://www.mql5.com | "The color, size, shift and symbol code of the arrow are changed in a random way...
Reason: