I started backtesting a simple strategy using FDAX 12-09 on 1Minute bar time frame.
My strategy has a stoploss handling which in this example allows 0,25% loss per trade.
I set up the Backtest to run my Strategy to run from 20.00 to 20.30 from 1.1.2009 until 23.9.2009
ExitOnClose is set to true, hence strategies exit after the 20.30 bar.
Most results are OK, but there are a few places where the backtest gives a very strange behaviour:
Have a look at trade 26:
This trade has a loss of 4,7%, much more than my stoploss would allow.
And StrategyAnalyzer reports an entry@3897 and an exit@3713 both happened at 20.02 on 5march2009 (pricesarebackajusted).
Obviously something is wrong here:
1. First point striking is that entry and exit happen on the same bar. Looking at the chart I cannot find a condition within the timespan in question that would trigger such a scenario
2. I started checking the data: My data is OK, but I find out that the entry price od 3897 corresponds to the price of the day before at the same time, 4march2009 20.02
3. I started Visual Studio 2008 debugger and had a look at my code:
Under the debugger I find out that my entryOrder=EntryLongLimit(..) is triggered and filled and entryOrder.Filled=1.
However I do a code check for Positions[0].MarketPosition, which should give me LONG as a result then (and it does in real trading) , but this Positions[0].MarketPosition returns flat all the time.
Questions:
1. What is going on here in the StrategyAnalyzer?
2. Why is exit and entry taken in one single bar, but the entry price is taken from the previous day bar.
3. Is it allowed to use Positions[0].MarketData in StrategyAnalyzer?
Best regards
Andreas
Comment