Sometimes my strategy will still have open positions when the backtest is finished. Is there a way to "delete" these open positions (and the stop orders in place for them), as if they never existed in the first place? I don't want these to count in my backtest results (since these trades could not complete within the backtest window). In other words, I want there to be only trades that completed on the chart (and BT results) when the BT completed.
This is motivated by the pending stop orders that these positions have in place when the backtest finishes. They confuse me and I would like them gone :)
This is motivated by the pending stop orders that these positions have in place when the backtest finishes. They confuse me and I would like them gone :)
Rename
You cannot hide existing positions as if they never existed but you can close them out at the last bar in your strategy.
QUOTE:You can remove this motivation by removing all the signals like this -
This is motivated by the pending stop orders that these positions have in place when the backtest finishes. They confuse me and I would like them gone :)
Caution! You will not get Signals for ANY new trades if you add this.
CODE:
public override void BacktestComplete() { Backtester.Orders.Clear(); }
Or if you want to just remove the Stop orders -
CODE:
public override void BacktestComplete() { for (int n = Backtester.Orders.Count - 1; n >= 0; n--) { Transaction t = Backtester.Orders[n]; if (t.OrderType == OrderType.Stop) Backtester.Orders.RemoveAt(n); } }
Your Response
Post
Edit Post
Login is required