Getting error 4107 when using ChartTimePriceToXY

 

Hi,


I've an indicator which, in a given moment, has the following code:

void updateSigns(const double topValue
      , const double botValue
      , ...)
{
   //Text: placement
   int xPos, yPosTop, yPosBot;
   
   if (!ChartTimePriceToXY(glChartID,0,0,topValue,xPos,yPosTop))
   {
      Print("Error getting coordinates from top value (",topValue,") (error code: ",GetLastError(),")");
      
      return;
   }

So as you can see, I've interest in getting the Y coordinate of a given price, the X being irrelevant for me.

Now I've already tested this indicator quite a lot and it worked fine. Today, though, I open the terminal (the market already running) and I got the error message:

PR      0       09:02:27.645    XXX (WINQ21,M1) Error getting coordinates from top value (123070.0) (error code: 4107)

I did some research on error 4107 and found it's commonly associated with misconfigured OrderSend errors when the price given is invalid. The problem is, not only I'm not sending any orders here, but the price given, 123070.0, is a perfectly viable price for the symbol, WINQ21:

example

Someone could argue about the problem being in providing a 0 value for the X point, a 0 datetime, but I've tested and used this function a lot with this same indicator giving a 0 datetime and it always worked fine :T

So where is the problem? T_T



 

ERR_CHART_WRONG_PARAMETER

4107

Error value of the parameter for the function of working with charts

Documentation on MQL5: Chart Operations
Documentation on MQL5: Chart Operations
  • www.mql5.com
Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Alain Verleyen:

ERR_CHART_WRONG_PARAMETER

4107

Error value of the parameter for the function of working with charts

Well, thanks, but that doesn't really tell much xD

But I think I figured out why this error is ocurring: it only happens when I open the terminal with the indicator already loaded. Since then, everything runs fine. So it would seem that even though in general the parameters I pass the function are, as I sad previously, correct, when the terminal is opening the graph/chart may have not yet properly loaded, so the function doesn't work properly. Only some msecs after, when the window is properly adjusted and the data is properly fill in the chart, that it start to work fine, ending the error and the error message.

So what I did was just removed the error message; now it only does the "return;" and that's it. Working fine.