SystemPerformance

View as Markdown

Definition

The SystemPerformance object holds all trades and trade performance data generated by a strategy.

Notes:

  • A NinjaScript strategy can generate both synthetic trades (historical backtest trades) and real-time trades executed on a real-time data stream. If you wish to access only real-time trades, access the RealTimeTrades collection.
  • The first trade of the RealTimeTrades collection will contain a synthetic entry execution if the strategy was NOT flat at the time you start the strategy.
  • These properties require that IncludeTradeHistoryInBacktest be set to true.

Methods and Properties

Method/PropertyDescription
AllTradesGets a TradeCollection object of all trades generated by the strategy
LongTradesGets a TradeCollection object of long trades generated by the strategy
RealTimeTradesGets a TradeCollection object of real-time trades generated by the strategy
ShortTradesGets a TradeCollection object of short trades generated by the strategy

Examples

1protected override void OnBarUpdate()
2{
3 // Print out the number of long trades
4 Print("The strategy has taken " + SystemPerformance.LongTrades.Count + " long trades.");
5}