Hi, friend,
I got a problem, explained in following example.
For example, I attach an EA to EURUSD chart only, then use following codes to add OBJ_ARROW_BUY to [USDJPY chart](https://www.mql5.com/en/blogs/tags/usdjpy). The EA is NOT attached to USDJPY. The system replies error 4202, cannot find object.
Your help is appreciated.
-
I tried to unattach EA from EURUSD, and then attach EA to USDJPY, run my codes. Everything works just fine to draw ARROWS to USDJPY chart.
-
codes in MQL4
-
I use OANDA MT4 version 4.00, build 1170. The error happens in this line of code. Thanks to Seng Joo Thio, it seems the code works fine on his platform.
ObjectSet("TEST",OBJPROP_ARROWCODE,233)
*** PART OF MY CODE GENERATES ERROR MESSAGE ***
long chartID=ChartFirst();
string obj_name = "USDJPY";
string outside_order = "BUY";
// find chart
while (chartID>0)
{
if (ChartSymbol(chartID)== "USDJPY")
{
Print("Current chartID = " + (string)(chartID) + ChartSymbol(chartID));
ChartRedraw(chartID);
break;
}
else chartID = ChartNext(chartID);
continue;
}
// BUY SIDE
if (outside_order=="BUY")
{
if (ObjectCreate(chartID,"TEST",OBJ_ARROW_BUY,0,datetime(D'2019.7.17 00:00:00'),108.00)) // price may need to be changed to reproduce the error
{
Print("Ready to draw arrows.");
if (ObjectSet("TEST",OBJPROP_ARROWCODE,233) && ObjectSet("TEST",OBJPROP_COLOR,clrRed))
{
ObjectSet("TEST",OBJPROP_TIMEFRAMES,OBJ_PERIOD_D1|OBJ_PERIOD_H4);
InformPullClient(pSocket,"Sign is put on chart.");
}
else Print(GetLastError());
}
else
Print(GetLastError());
}
*** THE RIGHT CODE FOR ANYONE ****
// BUY SIDE
if (outside_order=="BUY")
{
if (ObjectCreate(chartID,"TEST",OBJ_ARROW_BUY,0,datetime(D'2019.7.17 00:00:00'),108.00)) // price may need to be changed to reproduce the error
{
Print("Ready to draw arrows.");
if (ObjectSetInteger(chartID,"TEST",OBJPROP_ARROWCODE,233) && ObjectSetInteger(chartID, "TEST",OBJPROP_COLOR,clrRed))
{
ObjectSetInteger(chartID,"TEST",OBJPROP_TIMEFRAMES,OBJ_PERIOD_D1|OBJ_PERIOD_H4);
InformPullClient(pSocket,"Sign is put on chart.");
}
else Print(GetLastError());
}
else
Print(GetLastError());
}