IncludeTradeHistoryInBacktest

View as Markdown

Definition

Determines if the strategy will save orders, trades, and execution history. When this property is set to false you will see significant memory savings at the expense of having access to the detailed trading information.

  • Since trade information is not stored you will only see entry/exit executions plotted on the chart with no connecting PnL trade lines.

  • This property is always defaulted to true, except when the strategy is running on the strategy tab.

Property Value

This property returns true if the strategy will include trade history; otherwise, false. Default is set to true.

This property should ONLY be set from the OnStateChange() method during State.Configure (or State.SetDefaults when adding the script from the strategy tab).

Syntax

IncludeTradeHistoryInBacktest

Examples

1protected override void OnStateChange()
2{
3 if (State == State.Configure)
4 {
5 // Exclude trade history in a backtest to benefit from memory savings
6 IncludeTradeHistoryInBacktest = false;
7 }
8}
9
10protected override void OnBarUpdate()
11{
12 // Stop taking trades after 10 trades have been taken since the strategy was enabled
13 if(SystemPerformance.AllTrades.Count >= 10)
14 return;
15}