Problem with return of ChartTimePriceToXY when chart is not active

 

When I use ChartTimePriceToXY and the chart is not active  the X and Y values ​​extrapolate the chart size values ​​obtained through the CHART_WIDTH_IN_PIXELS and CHART_HEIGHT_IN_PIXELS properties.


Is this a bug?


The result of the code below for active and non-active charts is:

width=1578 height=700 x=1392 y=615 top=true

width=195 height=77 x=1536 y=-25 top=false


Note that the value of X is greater than the value of width, and the value of Y is less than  height

void getXY()
  {

        MqlRates candles[];
        long width, height;
        int x = 0;
        int y = 0;
        bool top;

        CopyRates(_Symbol, _Period, 0, 5, candles);
        ArraySetAsSeries(candles, true);
        
        width   = ChartGetInteger(0, CHART_WIDTH_IN_PIXELS);
        height  = ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS);
        top     = ChartGetInteger(0, CHART_BRING_TO_TOP);

        ResetLastError();
        
        if(!ChartTimePriceToXY(0, 0, candles[0].time, candles[0].close, x, y))
          {
           Print("Error to get X and Y positions - error n.", GetLastError());
          }

        Print(" width=", width, " height=", height, " x=", x, " y=", y, " top=", top);
  
  } 
Documentation on MQL5: Chart Operations / ChartTimePriceToXY
Documentation on MQL5: Chart Operations / ChartTimePriceToXY
  • www.mql5.com
ChartTimePriceToXY - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: