Click or drag to resize

Indicator adding to the chart

The following example shows adding of indicator to draw on the chart:

private readonly Connector _connector = new Connector();
private Security _security;

private CandleSeries _candleSeries;
private SimpleMovingAverage _sma;

readonly TimeSpan _timeFrame = TimeSpan.FromMinutes(1);

private ChartArea _area;
private ChartCandleElement _candlesElem;
private ChartIndicatorElement _longMaElem;


// _chart - StockSharp.Xaml.Charting.Chart
// new chart area
_area = new ChartArea();

// Special chart element to draw a candles
_candlesElem = new ChartCandleElement();

// Special chart element to draw an indicator
_longMaElem = new ChartIndicatorElement
    Title = "Long"

_sma = new SimpleMovingAverage() { Length = 80 };
_connector.CandleSeriesProcessing += DrawCandle;


_candleSeries = new CandleSeries(typeof(TimeFrameCandle), _security, _timeFrame);
_connector.SubscribeCandles(_candleSeries, DateTime.Today.Subtract(TimeSpan.FromDays(30)), DateTime.Now);


private void Draw(CandleSeries series, Candle candle)
   if (candle.State != CandleStates.Finished)

    var longValue = _sma.Process(candle);
    var data = new ChartDrawData();

            .Add(_candlesElem, candle)
            .Add(_longElem, longValue);


indicators chart
See Also

Other Resources