Backtest seems to ignore Trade Close Conditions
Backtest seems to ignore Trade Close Conditions
19 Jun 2013, 03:35
Hi,
I have coded my bot so that if for example a SELL trade is entered and the price closes above the SMA it closes the position(vice versa with BUY, except closes below).
This seems to work when I forward test the bot, however when backtesting it seems to ignore this condition and go on to hit the 100 pip stop loss I set, this of course skews the results of the backtest significantly.
Please see attached pic for an example of this. As you can see, the trade goes on to close much later instead of closing above the SMA.
Is there any explanation for this? I worry that it will happen in the forward test randomly.
Thanks for the help.
this is the Close Position code:
foreach (Position position in _listPosition)
{
if
(position.TradeType == TradeType.Buy && Functions.HasCrossedBelow(MarketSeries.Close,WELL.Result,0))
{
ClosePosition(position);
}
if (position.TradeType == TradeType.Sell && Functions.HasCrossedAbove(MarketSeries.Close,WELL.Result,0))
{
ClosePosition(position);
}
}
Replies
Delta_Gamma
23 Jun 2013, 07:01
Ah that worked! dunno why I didn't think of that lol.
Thanks mate.
@Delta_Gamma
daemon
19 Jun 2013, 13:07
Try using period 1:
@daemon