Table of Contents

Equity curve

The S# provides the possibility to plot equity curves for further analysis of the trading algorithm work. The data for the curve obtained using the PnLManager class. This class calculates the current value, informing the algorithm about the changes through the Strategy.PnLChanged event.

To calculate the curve parameters (maximum drawdown, Sharpe ratio, etc.) StatisticManager used. These parameters are stored in the StatisticManager.Parameters property. Each parameter implements IPnLStatisticParameter, ITradeStatisticParameter, IOrderStatisticParameter or IPositionStatisticParameter interfaces. If you want a particular calculation parameter, you must implement one of these interfaces and add the parameter to the StatisticManager.Parameters.

The use of the Strategy.PnLChanged is shown in the backtesting section in the context of trading strategies:

_strategy.PnLChanged += () =>
{
	var data = new EquityData
	{
		Time = _strategy.Trader.MarketTime,
		Value = _strategy.PnL,
	};
	this.GuiAsync(() => _curveItems.Add(data));
};      
      

The statistics manager is obtained through the Strategy.StatisticManager property.

When the new data occur, the curve is drawn on the special EquityCurveChart chart. To start drawing a curve on this chart, you must call the EquityCurveChart.CreateCurve(System.String title, System.Windows.Media.Color color, System.Windows.Media.Color secondColor, StockSharp.Xaml.Charting.LineChartStyles style, System.Guid id**)** method. The resulting collection is filled with data that is passed during processing the Strategy.PnLChanged event.

The EquityCurveChart chart allows to draw multiple curves to be able to compare their profitability with each other. An example of this approach is shown in the optimization section.

The use of the StatisticParameterGrid visual panel, which allows to display StatisticParameterGrid.Parameters parameters, is shown in the backtesting section.