Problem with ChartTimePriceToXY

 

Hello everyone,

I am writing the expert, which is used ChartTimePriceToXY. When I tested it, this function work incorrect. Every time it returns 2147483647. I realise that it is 2^31 - 1, which is mean EMPTY_VALUE in this system, but I absolutely dont know why it happens. 

Part of my code:

double lips = iAlligator(Symbol(), Period(), 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, i);

double teeth = iAlligator(Symbol(), Period(), 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, i);

double jaw = iAlligator(Symbol(), Period(), 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, i);

double alligatorPoint = (lips + teeth + jaw) / 3; 

double barPoint = (Low[i] + High[i]) / 2; 

int alligatorX, alligatorY; 

ChartTimePriceToXY(0, 0, Time[i], alligatorPoint, alligatorX, alligatorY); 

 

And the most weard thing is, that if I try to run this code in the indicator, everything is good (function return valid values).

Guys, I need your help. Thank you.

 
Alankras: Every time it returns 2147483647.
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. ChartTimePriceToXY - MQL4 Documentation returns a bool. it can't return EMPTY_VALUE

 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. ChartTimePriceToXY - MQL4 Documentation returns a bool. it can't return EMPTY_VALUE



You are right, but I meant that the value of alligatorX, alligatorY are not valid after.

 

I already did that. For example, GetLastError() return 0 everytime, ChartTimePriceToXY return true. 

Anyway, thank you for your help.

 

I find solution. In the expert tester, some function doesnt work, e.g. graphical fucntion, that is why ChartTimePriceToXY  return bad values. To avoid this, I use tester with visualization and everything is fine.

Hope it helps anyone.

 

I am facing the same issue but on an offline-chart :(

I put an object on that chart and moved it around and run each time a script with this part:

   double   DOT_P = ObjectGetDouble( 0,"DOT",OBJPROP_PRICE );
   datetime DOT_B = (datetime)ObjectGetInteger(0,"DOT",OBJPROP_TIME );
   int      DOT_x,DOT_y;
   bool ok = ChartTimePriceToXY(0,0,DOT_B,DOT_B,DOT_x,DOT_y);
   Print("OffLineChart: BarTime: ",DOT_B,"  BarPrice: ",DoubleToString(DOT_P,Digits),
         "  x,y: ",DOT_x,", ",DOT_y,"   Error: ",_LastError,"  ok: ",ok);

This is the result:

2018.05.11 10:02:16.108 KopI EURUSD,Weekly: OffLineChart: BarTime: 2007.07.08 00:00:00  BarPrice: 1.22715  x,y: 188, -2147483129   Error: 0  ok: true
2018.05.11 10:01:59.933 KopI EURUSD,Weekly: OffLineChart: BarTime: 2012.02.05 00:00:00  BarPrice: 1.80440  x,y: 666, -2147483129   Error: 0  ok: true
2018.05.11 10:01:47.631 KopI EURUSD,Weekly: OffLineChart: BarTime: 2016.02.07 00:00:00  BarPrice: 0.99372  x,y: 1084, -2147483129   Error: 0  ok: true
 
Could be a typo in
bool ok = ChartTimePriceToXY(0,0,DOT_B,DOT_B,DOT_x,DOT_y)

Two dot_b and no dot_p.

 
kypa:
Could be a typo in

Two dot_b and no dot_p.

YES - thanks that was it!

I need to get better glasses :(
Reason: