EA will backtest but won't trade

 

Hi there,

I've written an EA (Probably badly... but I did it!!) and when I run it through backtests I see all the trades it would have taken.

Then I go to trade live, I've ticked all the right boxes and I even get a smile face on the top right, however the EA won't take any trades.

Does anyone have an idea why this may be the case? Ta.

 
Melymoo:

Hi there,

I've written an EA (Probably badly... but I did it!!) and when I run it through backtests I see all the trades it would have taken.

Then I go to trade live, I've ticked all the right boxes and I even get a smile face on the top right, however the EA won't take any trades.

Does anyone have an idea why this may be the case? Ta.


Need to be more specific, your asking people to guess. Have you looked in the journal and expert tabs in MT4 are there any error? Do you have any print statements in the code to help you debug? did you check the log files? Thats where I would start. The tester is more forgiving then a demo acct.
 
danjp:

Need to be more specific, your asking people to guess. Have you looked in the journal and expert tabs in MT4 are there any error? Do you have any print statements in the code to help you debug? did you check the log files? Thats where I would start. The tester is more forgiving then a demo acct.

Ok, thanks. You raise a good point. I didn't give you guys anything to go with. The journal says that the EA loads successfully. I'm going to recompile the EA and put more Alerts around what's happening to make it easier to debug. Apart from this do you have an general ideas of reasons, just to name a few and perhaps get me looking...? Interestly I didn't realise the tester was more forgiving than a demo account, so I'll need to tighten up my code. Cheers, M
 
Melymoo:

Ok, thanks. You raise a good point. I didn't give you guys anything to go with. The journal says that the EA loads successfully. I'm going to recompile the EA and put more Alerts around what's happening to make it easier to debug. Apart from this do you have an general ideas of reasons, just to name a few and perhaps get me looking...? Interestly I didn't realise the tester was more forgiving than a demo account, so I'll need to tighten up my code. Cheers, M


Is your broker an ECN broker? If they are make sure you have the correct OrderSend(), OrderModify logic, lots of examples of that on this site.

Restart MT4 and reload your EA. Software can be buggy. I have had this happen to me on a vitual server, on both a demo and a real account. Wasted a night before I did the easy check first.

Put a print statements in your init() section with your Magic Number or something else in it. I do that on all my EA's, every now and then I see that is incorrect and I know I have most likely screwed something up, even though I have a smiley in the coror.

Print statement are your friend. Start() trade logic... OrderSend() if it is running you need to figure out if your logic is correct or your orders are comming back with errors.

Make sure you check the return codes of all trading functions!

 
danjp:


Is your broker an ECN broker? If they are make sure you have the correct OrderSend(), OrderModify logic, lots of examples of that on this site.

Restart MT4 and reload your EA. Software can be buggy. I have had this happen to me on a vitual server, on both a demo and a real account. Wasted a night before I did the easy check first.

Put a print statements in your init() section with your Magic Number or something else in it. I do that on all my EA's, every now and then I see that is incorrect and I know I have most likely screwed something up, even though I have a smiley in the coror.

Print statement are your friend. Start() trade logic... OrderSend() if it is running you need to figure out if your logic is correct or your orders are comming back with errors.

Make sure you check the return codes of all trading functions!

Hey Mr,

Just wanted to let you know that I got this to work in the end. Did some research on what an ECN broker is and fixed my code to modify orders. Then the little bubbles started showing up! So thanks for your help. Haven't quite managed to incorporate the proper 5 digit/3 digit codes stuff that WHRoeder always posts up but I working on it now. At least this thing takes trades now and I can let my demo run. M

Reason: