Click or drag to resize

Candles creating by instrument basket

To create ContinuousSecurity and WeightedIndexSecurity candles the same procedure used as for creating the Security candles.

For example, create a 1 min candle for APM5 - ESM5 spread:

private QuikTrader _trader;

private Security _instr1;
private Security _instr2;
private WeightedIndexSecurity _indexInstr;

private const string _secCode1 = "APM5";
private const string _secCode2 = "ESM5";

private CandleManager _candleManager;
private CandleSeries _indexSeries;

readonly TimeSpan _timeFrame = TimeSpan.FromMinutes(1);

private ChartArea _area;
private ChartCandleElement _candlesElem;


_area = new ChartArea();

_candlesElem = new ChartCandleElement();


_candleManager = new CandleManager(_trader);
_candleManager.Processing += DrawCandles;


_indexInstr = new WeightedIndexSecurity() { Exchange = Exchange.Associated, Id = "IndexInstr" };
_indexInstr.Weights.Add(_instr1, 1);
_indexInstr.Weights.Add(_instr2, -1);
_indexSeries = new CandleSeries(typeof(TimeFrameCandle), _indexInstr, _timeFrame);



After that, candles will come to the event handler Processing - DrawCandles. These candles can be displayed on the chart:

private void DrawCandles(CandleSeries series, Candle candle)
    if (series == _indexSeries) this.GuiAsync(() => _chart.ProcessCandle(_candlesElem, candle) );
See Also