I get error 4024 when i run my EA

 

I just finished making an EA run it on demo account and suddently when it initializes it shows error 4024 for no reason.

I`ve checked the code, it has no bugs or compile errors, and it didnt do anything yet.Either the MT4 is bugged here or am i missing something, i read the documentation it says "internal error" ,what does that mean and how can i avoid this error?

Help please!

 
You'll have to post the code 
 
4024 is the not very helpful "internal error" error. You might try to run it in debugger and try to isolate the code block that causes it.
 
SDC:
4024 is the not very helpful "internal error" error. You might try to run it in debugger and try to isolate the code block that causes it.
Yes but i have no idea what causes it, my EA is 1000 lines long how am i going to find out what causes it?
 

Hello Proximus,

Could you know when this error occurs? Is it when you create an order? When you move your stops?...

 
Hollas:

Hello Proximus,

Could you know when this error occurs? Is it when you create an order? When you move your stops?...

Right after the initialization finishes, nothing is done until then, no order is put no if testing no nothing, just right after the init is finished the error is done.

Or shall i say after the first tick is processed since my error testing code is right at the end of the start like this:

int start()
  {
//.....other stuff
error=GetLastError();
if(error!=0){ Print("~~ERROR CODE: ",error); }

   return(0);
  }

Where the "error" is a global int

Of course the code is before that but a separate function is called in the start, and its not called until either an order is active to manage risk/sl or until a BUY/SELL condition just happened, so it doesnt get activated at the first tick, and also when i tested it in the demo account the orders were managed ok, so there was no problem with that section, so my guess is that either its in the init() or the EA itself has some other problems.

And my init() is this:

MathSrand(TimeLocal()+TimeCurrent()*VAR);  
magic=StringGetChar(Symbol(),5)+StringGetChar(Symbol(),4)*10+StringGetChar(Symbol(),3)*100+StringGetChar(Symbol(),2)*1000+StringGetChar(Symbol(),1)*10000+StringGetChar(Symbol(),0)*100000;
Comment("");

there is a custom random initialization, and my magic number which is unique to each pair

 

Pretty hard to answer...moreover considering that i'm not really skilled yet...:)

Have you tried to temporarily remove the supposed problematic sections (or replace them by more simple ones), in order to spot which one creates the error (by elimination)?

 
Proximus:
Yes but i have no idea what causes it, my EA is 1000 lines long how am i going to find out what causes it?

First thing I would try is open it in MetaEditor put a break point at the very top of your code where the preprocessors are. (when you run the debugger it will reposition the break point to the first valid place) Then start the debugger, use F11 to step through the code line by line and see if you can find where it might trigger the error. (Probably something in  your OnInit code).
Reason: