ObjectsTotal() does not work in ExpertAdvisors???

 
Hi all,
I tried the function successfully for indicators but it always returns 0 for experts. Anybody has some idea?

Regards,
PQDzung
 
I would like to add that I ran in strategy tester mode!
 
For me it works perfectly in experts and in STester, but be carefull with reading ObjectsTotal() value when you handle with objects (deleting for example mess with value terribly)

Rafael
 
You begin test with 0 objects on the chart. backtesting uses empty virtual chart. if You add some object then ObjectsTotal returns 1
 
Hm, thank you all. Anyway I thought it should have used the objects I drew manually on the charts.
Then I must add some codes for that to create objects (useless when I am live)?
Or I misunderstood your statement, Slawa?
 
yeah. you need to create objects in your case. use IsTesting function in the initialization
 
Thanks Slawa, however I seem to be in a jam. I suspect if it's due to installation as I copied the MT4 over from other PC, however I did reinstall to overwrite and problems remain.

Now another mystery, the WindowsTotal() returned 0 as well. This is impossible???

Please have a look at my code:


//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
Print("WIN"+WindowsTotal());
if(true==ObjectCreate("Level01_001",OBJ_HLINE,WindowFind("EURUSD,M15"),D'2005.07.20 12:30',1.22))
Print(ObjectsTotal(OBJ_HLINE)+"xya"+ObjectName(1));
else
Print("No creation");

//----
return(0);
}


and the messages logged:

10:17:24 2005.07.29 22:59 test EURJPY,M15: unknown subwindow number -1 for ObjectCreate function
10:17:24 2005.07.29 22:59 test EURJPY,M15: No creation
10:17:24 2005.07.29 22:59 test EURJPY,M15: WIN0
10:17:24 2005.07.29 22:59 test EURJPY,M15: unknown subwindow number -1 for ObjectCreate function
10:17:24 2005.07.29 22:59 test EURJPY,M15: No creation
10:17:24 2005.07.29 22:59 test EURJPY,M15: WIN0
10:17:24 2005.07.29 22:59 test EURJPY,M15: unknown subwindow number -1 for ObjectCreate function
10:17:24 2005.07.29 22:59 test EURJPY,M15: No creation
 
do not use WindowFind when testing "Testing Features and Limits in MetaTrader 4"
You do not need to find your own window. if You work in the EURJPY,M15 chart then window "EURJPY,M15" has number 0
 
do not use WindowFind when testing "Testing Features and Limits in MetaTrader 4"
You do not need to find your own window. if You work in the EURJPY,M15 chart then window "EURJPY,M15" has number 0


OK Thanks, but the keypoint is that WindowsTotal() returned 0, isn't it?
Reason: