I am having an issue when backtesting where if I have my strategy manage the position size then it will stop executing trades on a particular instrument at a seemingly random point of the back test. If I back test the same instrument with a default position size selected then it continues to execute trades throughout the backtest period as expected.
I'm using this code to determine my position size, and according to the number of shares traded throughout the back test, it appears to work fine until a certain point, after which all trades stop.
if (((AccountSize/100) / price) >= 1)
{
EnterShortLimit(0, true, Convert.ToInt32(((AccountSize/100) / price)), (Close[0] * (1 + ((NATR1[0] * EntryFx) / 100))), @"shortOrder");
}
If I backtest on a basket of stocks, there will be a large number of stocks that stop trading at a seemingly random point in the backtest, and many other stocks that never stop trading throughout the backtest. The results are the same if I re-run the test, or if I then run backtests on each stock of the basket test individually. But like I said, if I then change the backtest parameters to manage position size my default and set it to any number, then all stocks trade throughout the entire backtest period without any issues...
Thoughts??
Thank you.
Comment