Click or drag to resize

Profit-loss

For the total profit-loss calculation (P&L) in a trading algorithm it is necessary to use the IPnLManager interface implementation, by way of PnLManager.

Prerequisites

The profit-loss calculation adding to the SampleSMA

  1. You should add the text box for the P&L in the information output window:

    C#
    <Label Grid.Column="0" Grid.Row="3" Content="P&amp;L:" />
    <Label x:Name="PnL" Grid.Column="1" Grid.Row="3" />
  2. Next, you need to extend the event method-handler of the strategy parameter change:

    C#
    this.Sync(() =>
    {
        Status.Content = _strategy.ProcessState;
        PnL.Content = _strategy.PnLManager.PnL;
        Slippage.Content = _strategy.SlippageManager.Slippage;
    });
Next Steps