Strategy Tester Randomly Ignoring Take Profits

 

Hello All,

I was back testing a very simple EA on the "Every Tick" mode with the M1 time period and I noticed that the tester was randomly overlooking times when my take profit price hit.

It is completely random. Most times it closes out the order properly. I suspected that there was a data integrity issue so I checked the data in the history center, but the data is correct.

I even was able to see the problem in visual mode. As you will see in the attached chart the tester had 2 opportunities to take profit but ignored them both (I was short in this instance and the red line is my take profit).

I have attached the code. It is very simple, just learning how to write EAs at this point so I based it on an existing EA.

Am I doing something wrong? Is this a bug? Is the tester simply not reliable?

Thank you so much!

-nbalance



Files:
 
Am I doing something wrong? Is this a bug? Is the tester simply not reliable? Can't say without seeing the codes.
 
ubzen:
Am I doing something wrong? Is this a bug? Is the tester simply not reliable? Can't say without seeing the codes.

I have attached the code. It is very simple, just learning how to write EAs at this point so I based it on an existing EA.

Thanks!

Files:
 
So far my test does not duplicate the behavior you described. Does your broker have a FreezeLevel > or = to 5? Also, what are the spreads at the time of testing?
 
ubzen:
So far my test does not duplicate the behavior you described. Does your broker have a FreezeLevel > or = to 5? Also, what are the spreads at the time of testing?

I am using OANDA which supposedly has a freezelevel of 0 and they typically have spreads around 2 pips at the time of that chart.
 
Currently, its the weekend, and I wouldn't be surprised if the spreads were higher then you'd expect. Could you Print() the spreads within the Init() and report the results?
 
nbalance:

I was back testing a very simple EA on the "Every Tick" mode with the M1 time period and I noticed that the tester was randomly overlooking times when my take profit price hit.

It is completely random. Most times it closes out the order properly.

...

Am I doing something wrong? Is this a bug? Is the tester simply not reliable?

The strategy tester is very reliable and I suspect you are misinterpreting what you are seeing. You have shown a plot and seem to be suggesting that because the price line is below the TP line the strategy tester is wrong. Look again. The grid lines are 1.5 pips apart and you are saying the spread is 2 pips. Remember that when you go Short you first sell at the Bid price then you need to buy back at the Ask price to close the position. The strategy tester chart is displaying the Bid price only. So the Bid price has to be lower than the TP line by the spread before the order will close.

EDIT: As Raptor points out (below) this suggests the spread is higher than 2 pips.

 
dabbler:
So the Bid price has to be lower than the TP line by the spread before the order will close. As your plot shows it has not yet done that!
TP = 1.33780 (approx from the chart), lowest price on chart looks like 1.33735 . . . difference of 4.5 pips, I suspect you are correct about the spread and that the spread at the time of the test was not 2 pips.
 
Turn on the Ask line to see the maginitude of the spread.
 
The strat tester has some black box algo. its designed to give you the same results when you run your EA over the same time period with the same parameters. That said, just because your target price was hit, TP/SL or Limit or Stop price, its not guranteed to open/close a deal. This is designed to reflect market reality. If the chart shows a price being "touched", that doesnt mean your order will be affected. There are no gurantees in the real market. MT designed this "feature" into the product. Nothing you can do about it.
Reason: