What causes stack overflow error in mql4?

 

What causes stack overflow error in mql4 during compiling? Im suspecting using a function to create objects. Below is the function that has been called over a hundred times to create objects.

int ObCreate(string ObName,double Xdist,double Ydist,double Zoom)
 {
 
   ObjectCreate(ObName, OBJ_LABEL, 0, 0, 0);  // Creating obj.
   ObjectSet(ObName, OBJPROP_CORNER, 0);    // Reference corner
   ObjectSet(ObName, OBJPROP_XDISTANCE, Xdist*ZoomTimes);// X coordinate   
   ObjectSet(ObName, OBJPROP_YDISTANCE, ZoomTimes*Ydist);// Y coordinate
 return(0);
 }

Below is one usage example

   ObCreate("EURUSD",Column1x,15,ZoomTimes);

Ive created other same number of objects the normal way without getting this error but when i introduced and used this function to create the remaining objects is when the error popped out. See the sample below that doesnt introduce the error even though its more labour intensive for the number of objects.

   ObjectCreate("EURUSD", OBJ_LABEL, 0, 0, 0);  // Creating obj.
   ObjectSet("EURUSD", OBJPROP_CORNER, 0);    // Reference corner
   ObjectSet("EURUSD", OBJPROP_XDISTANCE, Column1x*ZoomTimes);// X coordinate   
   ObjectSet("EURUSD", OBJPROP_YDISTANCE, ZoomTimes*15);// Y coordinate
 
tonny:

What causes stack overflow error in mql4? Im suspecting using a function to create objects. Below is the function that has been called over a hundred times to create objects.

Below is one usage example

Ive created other same number of objects the normal way without getting this error but when i introduced and used this function to create the remaining objects is when the error popped out. See the sample below that doesnt introduce the error even though its more labour intensive for the number of objects.

I've never had a stack overflow, from what I have read they are often caused by recursion but I don't see that in the code you have posted . . . why is your function type int ? what is the point in passing the variable double zoom when you don't use it ?

One more thing, the values for OBJPROP_XDISTANCE and OBJPROP_YDISTANCE are supposed to int not double.
 
RaptorUK:
I've never had a stack overflow, from what I have read they are often caused by recursion but I don't see that in the code you have posted . . . why is your function type int ? what is the point in passing the variable double zoom when you don't use it ?

One more thing, the values for OBJPROP_XDISTANCE and OBJPROP_YDISTANCE are supposed to int not double.


Thats what puzzles me.

RaptorUK:
I've never had a stack overflow, from what I have read they are often caused by recursion but I don't see that in the code you have posted . . . why is your function type int ? what is the point in passing the variable double zoom when you don't use it ?

One more thing, the values for OBJPROP_XDISTANCE and OBJPROP_YDISTANCE are supposed to int not double.

I did some find and replace and im yet to correct the lower part of the indicator.

RaptorUK:
I've never had a stack overflow, from what I have read they are often caused by recursion but I don't see that in the code you have posted . . . why is your function type int ? what is the point in passing the variable double zoom when you don't use it ?

One more thing, the values for OBJPROP_XDISTANCE and OBJPROP_YDISTANCE are supposed to int not double.

Man please read more book on ObjectSet(). Wait let me help. Below is an excerpt.

bool ObjectSet( string name, int index, double value)
 
tonny:


Man please read more book on ObjectSet(). Wait let me help. Below is an excerpt.

I'll see your quote and raise you with this . . .

OBJPROP_XDISTANCE102intInteger value to set/get anchor X distance object property in pixels.
OBJPROP_YDISTANCE103intInteger value is to set/get anchor Y distance object property in pixels.

would you use a double for these ?

OBJPROP_BACK9boolBoolean value to set/get background drawing flag for object.
OBJPROP_RAY10boolBoolean value to set/get ray flag of object.
OBJPROP_ELLIPSE11boolBoolean value to set/get ellipse flag for fibo arcs.


 
tonny: I really got lost in what you expected. I never got the "stack overflow" error during compilation either. Could you give us exact guidelines how we should reproduce the issue?
 
Ovo:
tonny: I really got lost in what you expected. I never got the "stack overflow" error during compilation either. Could you give us exact guidelines how we should reproduce the issue?
How were you trying to reproduce it? The above is just part of the code i said clearly ive called the function over a hundred times so if you wana reproduce it you might wana simulate the 108 calls of the function.
 
RaptorUK:

I'll see your quote and raise you with this . . .

would you use a double for these ?

In what im doing it makes no difference there is more to it than the little ive posted here.
 
tonny:
In what im doing it makes no difference there is more to it than the little ive posted here.
If you don't want to post all the code, so that the error can be reproduced, please code something that you can post in full that will reproduce the same error.
 
RaptorUK:
If you don't want to post all the code, so that the error can be reproduced, please code something that you can post in full that will reproduce the same error.

Okay.
 

I did an experiment and replaced some of this kind of objects

ObjectCreate("EURUSD", OBJ_LABEL, 0, 0, 0);  // Creating obj.
   ObjectSet("EURUSD", OBJPROP_CORNER, 0);    // Reference corner
   ObjectSet("EURUSD", OBJPROP_XDISTANCE, Column1x*ZoomTimes);// X coordinate   
   ObjectSet("EURUSD", OBJPROP_YDISTANCE, ZoomTimes*15);// Y coordinate

And used function style like below and the error went away. Its like the IDE can take fewer of the above than of the below. Ill try replacing all of the above style with the below style and see if something else might pop up.

ObCreate("EURUSD",Column1x,15,ZoomTimes);
 
Ive attached here the script which produces the error and the neutralized version that doesnt. Maybe someone might get a different solution. Man this big bug.