Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 and start trading today!
Ian Flanagan
549
Ian Flanagan 2014.10.28 04:05 

I've been away a while.. lots changed!

But today I'm getting ObjectFind return "true" when there is no object with that name...

void OnStart() {
   if(ObjectFind(0,"456")) Alert("found: 456");
   else Alert("not found: 456");
   return;
}

 You get the same? 

Keith Watford
Moderator
7897
Keith Watford 2014.10.28 04:36  
Read the documentation - ObjectFind is not a boolean function, it returns a negative number if it doesn't exist and anything other than 0 equates to true.
rod178
276
rod178 2014.10.28 04:46  
GumRai:
Read the documentation - ObjectFind is not a boolean function, it returns a negative number if it doesn't exist and anything other than 0 equates to true.

0 means that the object has been found in the main window of the chart

it returns an integer of less than 0 if not found

Keith Watford
Moderator
7897
Keith Watford 2014.10.28 05:20  
GumRai:
Read the documentation - ObjectFind is not a boolean function, it returns a negative number if it doesn't exist and anything other than 0 equates to true.
rod178:

0 means that the object has been found in the main window of the chart

it returns an integer of less than 0 if not found

I didn't word that very well did I  :)

 ObjectFind is not a boolean function

If the object is not found, the function returns a negative number

As the object does not exist a negative number is returned

As Alladir is testing a number as a boolean ,and anything other than 0 equates to true, Alladir's code will return true if the object does not exist.

If it does exist and is in the main window, Alladir would have found it return false, because the main window is expressed as 0 

rod178
276
rod178 2014.10.28 05:25  
GumRai:

I didn't word that very well did I  :)

 ObjectFind is not a boolean function

If the object is not found, the function returns a negative number

As the object does not exist a negative number is returned

As Alladir is testing a number as a boolean ,and anything other than 0 equates to true, Alladir's code will return true if the object does not exist.

If it does exist and is in the main window, Alladir would have found it return false, because the main window is expressed as 0 

LOL I knew what you meant, although only because I'm familiar with that function  :P
/
To add comments, please log in or register