Download MetaTrader 5
To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
yrydr
72
yrydr 2014.12.10 16:06 

Hi everyone,

First of all let me tell you that I am pretty new to coding and I read a lot of stuff and spent a lot of time before asking this question... This forum really helps a lot, thanks to all contributors.

I have written an EA that is more like a scalper. I say "like" because it's not exactly a scalper. So on average it opens 5-6 trades daily (per pair) and closes on a profit level when reached. It works with 4 different indicators (rsi, atr, etc.). Anyway, these are not really important as the problem, I guess, is not related to these.

So what happens: I launch MT4 and load the EA to the chart and turn on trading, within the first 24 hours or so, it opens all orders it needs to open (I check it with strategy tester later in the day and the orders that I see on tester were also all opened and closed in real time as well, so all in blotter even at exactly same price as tester suggests). However after some time (usually after that initial 24 hours) the EA starts opening noticeably less trades. I run the EA on 20 different pairs so normally I have around 90-100 traders per day and this number drops to 40-50 after that first 24 hours. When I run it in the tester for that time frame, I also see that some trades that are opened in tester were not opened (in real time) at all. EA is not stuck as it does open some of the trades it should open... I don't see any errors in the logs as well.  

I believe the code is not the problem, as sometimes it works perfectly and opens all trades as they should be opened. Is there anyone who can suggest a solution or at least a way to track down what's going on?

Many thanks in advance... 

whroeder1
13602
whroeder1 2014.12.10 17:23  
demirozyurek: I believe the code is not the problem, as sometimes it works perfectly and opens all trades as they should be opened. Is there anyone who can suggest a solution or at least a way to track down what's going on?
Nothing but the code opens orders. If it doesn't do what you want, your code is broken. Fix your code. Print your variables before the ifs and add a print inside the ifs so you find out why.
yrydr
72
yrydr 2014.12.10 20:12  
WHRoeder:
Nothing but the code opens orders. If it doesn't do what you want, your code is broken. Fix your code. Print your variables before the ifs and add a print inside the ifs so you find out why.

Appreciate the comments WHRoeder. 

Thou (maybe I am too dumb to figure it out but) I really cannot understand how the code is broken, as for example it worked just fine from Sunday market open thru Monday evening and suddenly switched to a state that it opens some of the orders and ignores the others from then on. In case it's broken, shouldn't it just react the same all the time? And also in tester it goes all well. 

I'll put prints in the ifs as per your suggestion although, as I said before that the code is not very professional and there are too many ifs inside. But I'll try... 

Can you think of any other cause rather than the code itself?

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.12.11 02:36  
Last time my ea won't open orders. Turns out that the spread is the culprit. Smaller spread gap is good but it is precise. So, if the condition is not met, ea wouldn't open orders.
yrydr
72
yrydr 2014.12.11 07:56  
deysmacro:
Last time my ea won't open orders. Turns out that the spread is the culprit. Smaller spread gap is good but it is precise. So, if the condition is not met, ea wouldn't open orders.
I didn't understand what you mean by spread; but in case you meant slippage, I thought about it and put a quite toleranced slippage in order to make sure it doesn't prevent the EA from opening orders...
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.12.11 08:12  
Then, use Print() before opening orders so that you will know what happens. Use Print() also if opening new orders fails.
cpr
23
cpr 2016.10.18 04:00  
I have the same problem. How did you solve it?
/
To add comments, please log in or register