ChartXYToTimePrice is only working for one OBJ_CHART out of the 4 i have

To add comments, please log in or register
Chye Thiam Tan
155
Chye Thiam Tan  

hi guys,

i need to ask for some guidance on ChartXYToTimePrice. my code with ChartXYToTimePrice seems to only work with the first OBJ_CHART. i have created 4 OBJ_CHARTs (tiled) and would like to use ChartXYToTimePrice on each of them to get the Time and Price of current clicked chart. its able to determine the chart that i clicked correctly, but ChartXYToTimePrice is giving me ERR_CHART_WRONG_PARAMETER (4107) for the 2nd, 3rd and 4th one. Below is my code and my results..  Appreciate if anyone can help. 

int subwindow = 0;
datetime datetimeclick = TimeCurrent();; 
double priceclick = 0;
bool clicksuccess = false;
long clickchartid;

 case CHARTEVENT_OBJECT_CLICK:             
         Print("CHARTEVENT_OBJECT_CLICK: ", sparam); 
         clickchartid = ObjectGetInteger(0,sparam,OBJPROP_CHART_ID); 
         Print("Before ChartXYToTimePrice: ", clickchartid," ", CWnd::MouseX()," ", CWnd::MouseY()," ", subwindow," ", datetimeclick, " ", priceclick);  
         ResetLastError();       
         clicksuccess = ChartXYToTimePrice(clickchartid,CWnd::MouseX(),CWnd::MouseY(),subwindow,datetimeclick, priceclick);         
         if(!clicksuccess) Print(GetLastError());
         Print("After ChartXYToTimePrice: ", clicksuccess, " " ,clickchartid, " ", CWnd::MouseX(), " ", CWnd::MouseY(), " " , subwindow, " ", datetimeclick, " ", priceclick);
         ChartRedraw();                       
         return;

2017.11.12 13:27:04.985 FRXMine_v1p2 (GOLD,D1) CHARTEVENT_OBJECT_CLICK: FRXChart0

2017.11.12 13:27:04.986 FRXMine_v1p2 (GOLD,D1) Before ChartXYToTimePrice: 131536218319501975 583 122 0 2017.11.10 23:59:59 0.0

2017.11.12 13:27:04.986 FRXMine_v1p2 (GOLD,D1) After ChartXYToTimePrice: true 131536218319501975 583 122 0 2017.10.16 21:00:00 1286.59 <-Only FRXChart0 is successful in ChartXYToTimePrice

2017.11.12 13:27:07.353 FRXMine_v1p2 (GOLD,D1) CHARTEVENT_OBJECT_CLICK: FRXChart1

2017.11.12 13:27:07.354 FRXMine_v1p2 (GOLD,D1) Before ChartXYToTimePrice: 131536218319501976 573 347 0 2017.11.10 23:59:59 0.0

2017.11.12 13:27:07.354 FRXMine_v1p2 (GOLD,D1) 4107

2017.11.12 13:27:07.354 FRXMine_v1p2 (GOLD,D1) After ChartXYToTimePrice: false 131536218319501976 573 347 0 2017.11.10 23:59:59 0.0

2017.11.12 13:27:11.469 FRXMine_v1p2 (GOLD,D1) CHARTEVENT_OBJECT_CLICK: FRXChart2

2017.11.12 13:27:11.470 FRXMine_v1p2 (GOLD,D1) Before ChartXYToTimePrice: 131536218319501977 1071 211 0 2017.11.10 23:59:59 0.0

2017.11.12 13:27:11.470 FRXMine_v1p2 (GOLD,D1) 4107

2017.11.12 13:27:11.470 FRXMine_v1p2 (GOLD,D1) After ChartXYToTimePrice: false 131536218319501977 1071 211 0 2017.11.10 23:59:59 0.0

2017.11.12 13:27:12.415 FRXMine_v1p2 (GOLD,D1) CHARTEVENT_OBJECT_CLICK: FRXChart3

2017.11.12 13:27:12.416 FRXMine_v1p2 (GOLD,D1) Before ChartXYToTimePrice: 131536218319501978 1094 378 0 2017.11.10 23:59:59 0.0

2017.11.12 13:27:12.416 FRXMine_v1p2 (GOLD,D1) 4107

2017.11.12 13:27:12.416 FRXMine_v1p2 (GOLD,D1) After ChartXYToTimePrice: false 131536218319501978 1094 378 0 2017.11.10 23:59:59 0.0


fxsaber
10291
fxsaber  
https://www.mql5.com/ru/code/viewcode/16753/123673/chartobject_chart.mqh
MQL5 Site / chartobject_chart.mqh - Скачать бесплатно индикатор 'Тиковый индикатор ZoomPrice' от 'fxsaber' для MetaTrader 5 в MQL5 Code Base
  • www.mql5.com
#property strict #include "ChartObject.mqh" #define OBJ_CHART_BORDER_SIZE 3 // Размер рамки чарта в пикселах class CHARTOBJECT_CHART : public CHARTOBJECT { protected:   virtual bool ChartXYToTimePrice( const int x, const int y, int &sub_window, datetime &time, double &price, const bool Add = true ) const   {...
Chye Thiam Tan
155
Chye Thiam Tan  
fxsaber:
https://www.mql5.com/ru/code/viewcode/16753/123673/chartobject_chart.mqh

works perfectly.. thanks :)

To add comments, please log in or register