Indicator adding to the chart
Click or drag to resize

Indicator adding to the chart

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

private RithmicTrader _trader;
private Security _security;

private CandleManager _candleManager;
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 };
_candleManager = new CandleManager(_trader);
_candleManager.Processing += Draw;


_candleSeries = new CandleSeries(typeof(TimeFrameCandle), _security, _timeFrame);


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