EA Cannot find another chart --SOLVED

 

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. The EA is NOT attached to USDJPY.  The system replies error 4202, cannot find object. 

Your help is appreciated.

*** UPDATE : QUESTION SOLVED***

1) 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. 

2) codes in MQL4

3)  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());
               }

        

 
Phoebe Hj:

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 find USDJPY chart and re-draw it but not attach the same EA to USDJPY.  The system replies error 4202, cannot find object. 

Your help is appreciated.


        

if (ChartSymbol(chartID)== "EURUSD")

You are looking for "EURUSD" chart in your code

 
Keith Watford:

You are looking for "EURUSD" chart in your code 

ha.. my fault. Thank you for pointing out. I extracted part of my coed to simplize my question.

It's not the issue. I updated my code in orignal question. 

Thank you all the same. 

 
Phoebe Hj:

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. The EA is NOT attached to USDJPY.  The system replies error 4202, cannot find object. 

This is MQL4, right?

This line:

               if (ObjectCreate(chartID,"TEST",OBJ_ARROW_BUY,0,TimeSeconds("2019-7-17 00:00:00"),108.00))  // price may need to be changed to reproduce the error

should change to (otherwise it'll draw the object at a time you cannot see):

               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

And instead of using ObjectSet(), use ObjectSetInteger() so you can include ChartID as the first parameter.


 
Seng Joo Thio:

This is MQL4, right?

This line:

should change to (otherwise it'll draw the object at a time you cannot see):

And instead of using ObjectSet(), use ObjectSetInteger() so you can include ChartID as the first parameter.


Thank you. Changed in my codes. Not this issue. 
 
Phoebe Hj:
Thank you. Changed in my codes. Not this issue. 

That's strange, because I don't normally suggest something without testing it myself (unless it's 5 plus in the morning...LOL).


 
Seng Joo Thio:

That's strange, because I don't normally suggest something without testing it myself (unless it's 5 plus in the morning...LOL).


Your result is amazing.... I don't know I ought to be happy or sad..... Let me check my codes....

***UPDATE***

I am using OANDA MT4 version 4.00, build 1170.

I located the error in this code, it can not find the obj_name

ObjectSet("TEST",OBJPROP_ARROWCODE,233)

Any idea on this ? 

 
Phoebe Hj:

Your result is amazing.... I don't know I ought to be happy or sad..... Let me check my codes....

***UPDATE***

I am using OANDA MT4 version 4.00, build 1170.

I located the error in this code, it can not find the obj_name

Any idea on this ? 

Now I get it... you missed this part in my earlier post: "instead of using ObjectSet(), use ObjectSetInteger() so you can include ChartID as the first parameter".

edit: should be chartID, not ChartID...
 
Seng Joo Thio:

Now I get it... you missed this part in my earlier post: "instead of using ObjectSet(), use ObjectSetInteger() so you can include ChartID as the first parameter".

edit: should be chartID, not ChartID...

Thank you very much. Problem solved. I did not know there is such a good function. 

Reason: