Click or drag to resize

Candles

S# supports the following types:

  • TimeFrameCandle - a candle based on the time interval, timeframe. You can set both popular intervals (minutely, hourly, daily), and customized. For example, 21 seconds, 4.5 minutes, etc.
  • RangeCandle - a candle of price range. A new candle is created when a trade appears with a price that goes outside allowable limits. The allowable limit is formed each time based on the price of the first trade.
  • VolumeCandle - the candle is formed until the total volume of trades is not exceeded. If the new trade exceeds the allowable volume, then it falls into a new candle.
  • TickCandle - the same as VolumeCandle, only the number of trades is taken into account as a limit instead of the volume.
  • PnFCandle - a candle of point-and-figure chart.
  • RenkoCandle - Renko candle.

How to operate with candles is shown in the SampleCandle sample, which is located in the Samples/Quik/SampleCandles folder.

TimeFrameCandle and RangeCandle charts are presented in the following figures:

sample timeframecandles
sample rangecandles

Running the data acquisition

  1. 1. All the necessary methods for obtaining candles are implemented in the Connector class.

    We create a connector and configure it through the Connection settings window,as described in the clause Connection settings window

    C#
    ...
    
    private readonly Connector _connector = new Connector();
    
    ...
    
    if (_connector.Configure(this))
                {
                    new XmlSerializer<SettingsStorage>().Serialize(_connector.Save(), _connectorFile);
                }
    
    ...
  2. Next, you need to subscribe to the ConnectorCandleSeriesProcessing, event, informing the appearance of a new value for processing:

    C#
    _connector.CandleSeriesProcessing += Connector_CandleSeriesProcessing;
    ...
    
    private void Connector_CandleSeriesProcessing(CandleSeries candleSeries, Candle candle)
    {
        Chart.Draw(_candleElement, candle);
    }
    
    ...
    Note Note
    The graphic component Chart is used to display the candles.
  3. 3. It is necessary to declare which candles are required and to start receiving data using SubscribeCandles:

    C#
    ...
    
    //var _candleSeries = new CandleSeries(typeof(TimeFrameCandle), security, TimeSpan.FromMinutes(5))
    //var _candleSeries = new CandleSeries(typeof(VolumeCandle), security, 10000m)
    //var _candleSeries = new CandleSeries(typeof(TickCandle), security, 1000)
    //var _candleSeries = new CandleSeries(typeof(RangeCandle), security, new Unit(0.1m))
    //var _candleSeries = new CandleSeries(typeof(RenkoCandle), security, new Unit(0.1m))
    //var _candleSeries = new CandleSeries(typeof(PnFCandle), security, new PnFArg() { BoxSize = 0.1m, ReversalAmount =1})
    //{
    //    BuildCandlesMode = MarketDataBuildModes.Build,
    //    IsCalcVolumeProfile = true
    //};
    
    _candleSeries =
        new CandleSeries(CandleSettingsEditor.Settings.CandleType, security, CandleSettingsEditor.Settings.Arg)
        {
            BuildCandlesMode = MarketDataBuildModes.Build,
            BuildCandlesFrom = MarketDataTypes.Trades,
            IsCalcVolumeProfile = true,
    
        };
    
    ...
    
    _connector.SubscribeCandles(_candleSeries, DateTime.Today.Subtract(TimeSpan.FromDays(30)), DateTime.Now);

    After this step, the ConnectorCandleSeriesProcessing event will be called.

Operation with candles

Next Steps