EA is selling live but not in backtester

 

Hi guys,

My EA is running live fine, both buying and selling, but when i run it through the backtester it will only take long/buy trades, it never takes a sell trade, even though all the criterion have been met.

It's driving me mad, can anyone please help out,

Thanks in advance,

AK

Files:
tryhthis.mq4  8 kb
 
there aresetting in tester-->expert properties-->testing tab--> position
 
kelly wrote >>
there aresetting in tester-->expert properties-->testing tab--> position

Unfortunately it has nothing to do with the properites, in a previous form, the EA made longs and shorts, but i added a few things, ie, stoploss, and it no longer takes short positions in the strategy tester, even when i strip it back it won't take short positions

 
The_AK:

Unfortunately it has nothing to do with the properites, in a previous form, the EA made longs and shorts, but i added a few things, ie, stoploss, and it no longer takes short positions in the strategy tester, even when i strip it back it won't take short positions

Probably your sell conditions are never met and result is zero short trades. Go through your code and check carefully your sell signals and conditions.

 

Hi AK

A good debug technique for this kind of probelm is to comment out the buy part and see if sells work. This can be taken further until a sell works then you will see what is stopping them. In the attached file I did this and it started trading after cutting the buy trigger and the first sell test

if (SellCount <= SetUpLength)

So there must be something wrong with the values here. I am sure you can figure it out.

Files:
 
Ruptor wrote >>

Hi AK

A good debug technique for this kind of probelm is to comment out the buy part and see if sells work. This can be taken further until a sell works then you will see what is stopping them. In the attached file I did this and it started trading after cutting the buy trigger and the first sell test

if (SellCount <= SetUpLength)

So there must be something wrong with the values here. I am sure you can figure it out.

This did provide one sell in the strategy tester, but that was it. The problem i have is that everything is running fine live, it's only when i run the backtester that problems with shorts start to occur. What's more fustrating is that the code for a long and short are exactly the same, just with different variables, ie, sell instead of buy, high instead of low, ask instead of bid, etc. Why would the buy be working perfectly in live and backtester, but sell only working live, i can't see a logical reason or bug in the code that would be causing this

 
The_AK:

This did provide one sell in the strategy tester, but that was it. The problem i have is that everything is running fine live, it's only when i run the backtester that problems with shorts start to occur. What's more fustrating is that the code for a long and short are exactly the same, just with different variables, ie, sell instead of buy, high instead of low, ask instead of bid, etc. Why would the buy be working perfectly in live and backtester, but sell only working live, i can't see a logical reason or bug in the code that would be causing this

Many times I have written code and thought it was correct but it only appeared to work. For instance in MT4 your EA will run without accessing the indicators and still trade at reasonable points but be completely wrong. Are you sure the trade points live are 100% correct?

If you look at the test cut journal it shows the code trying to close trades and even getting requote errors all when it has only made one trade. Also alert and sellcount=100 comes up many times prior to the error 138 so there is plenty of things to investigate. You will probably come across other faults in the logic and then straighten your code out.

Code can be frustrating especially when the system misinterprets the problem and gives misleading errors but you have to persevere and change things until you get a pointer to the real problem.

Reason: