Class CandleHelper
- Namespace
- StockSharp.Algo.Candles
- Assembly
- StockSharp.Algo.dll
Extension class for candles.
public static class CandleHelper- Inheritance
- 
      
      CandleHelper
- Inherited Members
Methods
BuyVolAbovePoC(VolumeProfileBuilder)
The total volume of bids which was above PoC(VolumeProfileBuilder).
public static decimal BuyVolAbovePoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total volume of bids. 
BuyVolBelowPoC(VolumeProfileBuilder)
The total volume of bids which was below PoC(VolumeProfileBuilder).
public static decimal BuyVolBelowPoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total volume of bids. 
Compress(IEnumerable<CandleMessage>, BiggerTimeFrameCandleCompressor, bool)
Compress candles to bigger time-frame candles.
public static IEnumerable<CandleMessage> Compress(this IEnumerable<CandleMessage> source, BiggerTimeFrameCandleCompressor compressor, bool includeLastCandle)Parameters
- sourceIEnumerable<CandleMessage>
- Smaller time-frame candles. 
- compressorBiggerTimeFrameCandleCompressor
- Compressor of candles from smaller time-frames to bigger. 
- includeLastCandlebool
- Output last active candle as finished. 
Returns
- IEnumerable<CandleMessage>
- Bigger time-frame candles. 
ConvertToTrades(ICandleMessage, decimal, int, (Sides? side, decimal price, decimal volume, DateTimeOffset time)[])
To create tick trades from candle.
public static void ConvertToTrades(this ICandleMessage candleMsg, decimal volumeStep, int decimals, (Sides? side, decimal price, decimal volume, DateTimeOffset time)[] ticks)Parameters
- candleMsgICandleMessage
- Candle. 
- volumeStepdecimal
- Volume step. 
- decimalsint
- The number of decimal places for the volume. 
- ticks(Sides? side, decimal price, decimal volume, DateTimeOffset time)[]
- Array to tick trades. 
Delta(VolumeProfileBuilder)
The difference between TotalBuyVolume(VolumeProfileBuilder) and TotalSellVolume(VolumeProfileBuilder).
public static decimal Delta(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- Delta. 
DeltaAbovePoC(VolumeProfileBuilder)
The total Delta which was above PoC(VolumeProfileBuilder).
public static decimal DeltaAbovePoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- Delta. 
DeltaBelowPoC(VolumeProfileBuilder)
The total Delta which was below PoC(VolumeProfileBuilder).
public static decimal DeltaBelowPoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- Delta. 
FilterSmallerTimeFrames(IEnumerable<TimeSpan>, TimeSpan)
Filter time-frames to find multiple smaller time-frames.
public static IEnumerable<TimeSpan> FilterSmallerTimeFrames(this IEnumerable<TimeSpan> timeFrames, TimeSpan original)Parameters
- timeFramesIEnumerable<TimeSpan>
- All time-frames. 
- originalTimeSpan
- Original time-frame. 
Returns
- IEnumerable<TimeSpan>
- Multiple smaller time-frames. 
GetBody(ICandleMessage)
To get the candle body.
public static decimal GetBody(this ICandleMessage candle)Parameters
- candleICandleMessage
- The candle for which you need to get the body. 
Returns
- decimal
- The candle body. 
GetBottomShadow(ICandleMessage)
To get the candle lower shadow length.
public static decimal GetBottomShadow(this ICandleMessage candle)Parameters
- candleICandleMessage
- The candle for which you need to get the lower shadow length. 
Returns
- decimal
- The candle lower shadow length. If 0, there is no shadow. 
GetCandleBounds(TimeSpan, DateTimeOffset, ExchangeBoard)
To get candle time frames relatively to the exchange working hours.
public static Range<DateTimeOffset> GetCandleBounds(this TimeSpan timeFrame, DateTimeOffset currentTime, ExchangeBoard board)Parameters
- timeFrameTimeSpan
- The time frame for which you need to get time range. 
- currentTimeDateTimeOffset
- The current time within the range of time frames. 
- boardExchangeBoard
- The information about the board from which WorkingTime working hours will be taken. 
Returns
- Range<DateTimeOffset>
- The candle time frames. 
GetCandleBounds(TimeSpan, DateTimeOffset, BoardMessage)
To get candle time frames relatively to the exchange working hours.
public static Range<DateTimeOffset> GetCandleBounds(this TimeSpan timeFrame, DateTimeOffset currentTime, BoardMessage board)Parameters
- timeFrameTimeSpan
- The time frame for which you need to get time range. 
- currentTimeDateTimeOffset
- The current time within the range of time frames. 
- boardBoardMessage
- The information about the board from which WorkingTime working hours will be taken. 
Returns
- Range<DateTimeOffset>
- The candle time frames. 
GetLength(ICandleMessage)
To get the candle length.
public static decimal GetLength(this ICandleMessage candle)Parameters
- candleICandleMessage
- The candle for which you need to get a length. 
Returns
- decimal
- The candle length. 
GetMiddlePrice(ICandleMessage, decimal?)
To get the candle middle price.
public static decimal GetMiddlePrice(this ICandleMessage candle, decimal? priceStep)Parameters
- candleICandleMessage
- The candle for which you need to get a length. 
- priceStepdecimal?
Returns
- decimal
- The candle length. 
GetSeries<TCandle>(ISubscriptionProvider, Security, object)
To get a candles series by the specified parameters.
[Obsolete]
public static CandleSeries GetSeries<TCandle>(this ISubscriptionProvider subscriptionProvider, Security security, object arg) where TCandle : ICandleMessageParameters
- subscriptionProviderISubscriptionProvider
- The subscription provider. 
- securitySecurity
- The instrument by which trades should be filtered for the candles creation. 
- argobject
- Candle arg. 
Returns
- CandleSeries
- The candles series. null if this series is not registered. 
Type Parameters
- TCandle
- Candles type. 
GetTimeFrameCount(Range<DateTimeOffset>, TimeSpan, ExchangeBoard)
To get the number of time frames within the specified time range.
public static long GetTimeFrameCount(this Range<DateTimeOffset> range, TimeSpan timeFrame, ExchangeBoard board)Parameters
- rangeRange<DateTimeOffset>
- The specified time range for which you need to get the number of time frames. 
- timeFrameTimeSpan
- The time frame size. 
- boardExchangeBoard
Returns
- long
- The received number of time frames. 
GetTimeFrameCount(Range<DateTimeOffset>, TimeSpan, BoardMessage)
To get the number of time frames within the specified time range.
public static long GetTimeFrameCount(this Range<DateTimeOffset> range, TimeSpan timeFrame, BoardMessage board)Parameters
- rangeRange<DateTimeOffset>
- The specified time range for which you need to get the number of time frames. 
- timeFrameTimeSpan
- The time frame size. 
- boardBoardMessage
Returns
- long
- The received number of time frames. 
GetTopShadow(ICandleMessage)
To get the candle upper shadow length.
public static decimal GetTopShadow(this ICandleMessage candle)Parameters
- candleICandleMessage
- The candle for which you need to get the upper shadow length. 
Returns
- decimal
- The candle upper shadow length. If 0, there is no shadow. 
GetValueArea<TCandle>(IEnumerable<TCandle>)
To calculate the area for the candles group.
public static VolumeProfileBuilder GetValueArea<TCandle>(this IEnumerable<TCandle> candles) where TCandle : ICandleMessageParameters
- candlesIEnumerable<TCandle>
- Candles. 
Returns
- VolumeProfileBuilder
- The area. 
Type Parameters
- TCandle
IsCandlesRegistered<TCandle>(ISubscriptionProvider, Security, object)
Whether the grouping of candles by the specified attribute is registered.
[Obsolete]
public static bool IsCandlesRegistered<TCandle>(this ISubscriptionProvider subscriptionProvider, Security security, object arg) where TCandle : ICandleMessageParameters
- subscriptionProviderISubscriptionProvider
- The subscription provider. 
- securitySecurity
- The instrument for which the grouping is registered. 
- argobject
- Candle arg. 
Returns
Type Parameters
- TCandle
- Candles type. 
IsSame<TCandle>(TCandle, TCandle)
Determines the specified candles are same.
public static bool IsSame<TCandle>(this TCandle candle1, TCandle candle2) where TCandle : ICandleMessageParameters
- candle1TCandle
- First. 
- candle2TCandle
- Second. 
Returns
- bool
- Check result. 
Type Parameters
- TCandle
MaxPriceLevel(ICandleMessage)
PriceLevels with maximum TotalVolume.
public static CandlePriceLevel? MaxPriceLevel(this ICandleMessage candle)Parameters
- candleICandleMessage
Returns
- CandlePriceLevel?
- PriceLevels with maximum TotalVolume. 
MinPriceLevel(ICandleMessage)
PriceLevels with minimum TotalVolume.
public static CandlePriceLevel? MinPriceLevel(this ICandleMessage candle)Parameters
- candleICandleMessage
Returns
- CandlePriceLevel?
- PriceLevels with minimum TotalVolume. 
PoC(VolumeProfileBuilder)
POC (Point Of Control) returns CandlePriceLevel which had the maximum volume.
public static CandlePriceLevel PoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- CandlePriceLevel
- The CandlePriceLevel which had the maximum volume. 
PriceLevelOfMaxDelta(VolumeProfileBuilder)
It returns the price level at which the maximum Delta(VolumeProfileBuilder) is passed.
public static CandlePriceLevel PriceLevelOfMaxDelta(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
PriceLevelOfMinDelta(VolumeProfileBuilder)
It returns the price level at which the minimum Delta(VolumeProfileBuilder) is passed.
public static CandlePriceLevel PriceLevelOfMinDelta(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- CandlePriceLevel
- The price level. 
SellVolAbovePoC(VolumeProfileBuilder)
The total volume of asks which was above PoC(VolumeProfileBuilder).
public static decimal SellVolAbovePoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total volume of asks. 
SellVolBelowPoC(VolumeProfileBuilder)
The total volume of asks which was below PoC(VolumeProfileBuilder).
public static decimal SellVolBelowPoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total volume of asks. 
Start<TCandle>(ISubscriptionProvider, CandleSeries)
To start candles getting.
[Obsolete]
public static void Start<TCandle>(this ISubscriptionProvider subscriptionProvider, CandleSeries series) where TCandle : ICandleMessageParameters
- subscriptionProviderISubscriptionProvider
- The subscription provider. 
- seriesCandleSeries
- Candles series. 
Type Parameters
- TCandle
ToCandles(IEnumerable<MarketDepth>, CandleSeries, Level1Fields, CandleBuilderProvider)
To create candles from the order books collection.
[Obsolete("Use IOrderBookMessage.")]
public static IEnumerable<Candle> ToCandles(this IEnumerable<MarketDepth> depths, CandleSeries series, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)Parameters
- depthsIEnumerable<MarketDepth>
- Market depths. 
- seriesCandleSeries
- Candles series. 
- typeLevel1Fields
- Type of candle depth based data. 
- candleBuilderProviderCandleBuilderProvider
- Candle builders provider. 
Returns
- IEnumerable<Candle>
- Candles. 
ToCandles(IEnumerable<Trade>, CandleSeries)
To create candles from the tick trades collection.
[Obsolete("Use ITickTradeMessage.")]
public static IEnumerable<Candle> ToCandles(this IEnumerable<Trade> trades, CandleSeries series)Parameters
- tradesIEnumerable<Trade>
- Tick trades. 
- seriesCandleSeries
- Candles series. 
Returns
- IEnumerable<Candle>
- Candles. 
ToCandles(IEnumerable<ExecutionMessage>, CandleSeries, CandleBuilderProvider)
To create candles from the tick trades collection.
[Obsolete]
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<ExecutionMessage> trades, CandleSeries series, CandleBuilderProvider candleBuilderProvider = null)Parameters
- tradesIEnumerable<ExecutionMessage>
- Tick trades. 
- seriesCandleSeries
- Candles series. 
- candleBuilderProviderCandleBuilderProvider
- Candle builders provider. 
Returns
- IEnumerable<CandleMessage>
- Candles. 
ToCandles(IEnumerable<ExecutionMessage>, Subscription, CandleBuilderProvider)
To create candles from the tick trades collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<ExecutionMessage> executions, Subscription subscription, CandleBuilderProvider candleBuilderProvider = null)Parameters
- executionsIEnumerable<ExecutionMessage>
- Tick data. 
- subscriptionSubscription
- Market data subscription. 
- candleBuilderProviderCandleBuilderProvider
- Candle builders provider. 
Returns
- IEnumerable<CandleMessage>
- Candles. 
ToCandles(IEnumerable<ExecutionMessage>, MarketDataMessage, CandleBuilderProvider)
To create candles from the tick trades collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<ExecutionMessage> executions, MarketDataMessage mdMsg, CandleBuilderProvider candleBuilderProvider = null)Parameters
- executionsIEnumerable<ExecutionMessage>
- Tick data. 
- mdMsgMarketDataMessage
- Market data subscription. 
- candleBuilderProviderCandleBuilderProvider
- Candle builders provider. 
Returns
- IEnumerable<CandleMessage>
- Candles. 
ToCandles(IEnumerable<QuoteChangeMessage>, CandleSeries, Level1Fields, CandleBuilderProvider)
To create candles from the order books collection.
[Obsolete]
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<QuoteChangeMessage> depths, CandleSeries series, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)Parameters
- depthsIEnumerable<QuoteChangeMessage>
- Market depths. 
- seriesCandleSeries
- Candles series. 
- typeLevel1Fields
- Type of candle depth based data. 
- candleBuilderProviderCandleBuilderProvider
- Candle builders provider. 
Returns
- IEnumerable<CandleMessage>
- Candles. 
ToCandles(IEnumerable<QuoteChangeMessage>, Subscription, Level1Fields, CandleBuilderProvider)
To create candles from the order books collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<QuoteChangeMessage> depths, Subscription subscription, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)Parameters
- depthsIEnumerable<QuoteChangeMessage>
- Market depths. 
- subscriptionSubscription
- Market data subscription. 
- typeLevel1Fields
- Type of candle depth based data. 
- candleBuilderProviderCandleBuilderProvider
- Candle builders provider. 
Returns
- IEnumerable<CandleMessage>
- Candles. 
ToCandles(IEnumerable<QuoteChangeMessage>, MarketDataMessage, Level1Fields, CandleBuilderProvider)
To create candles from the order books collection.
public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<QuoteChangeMessage> depths, MarketDataMessage mdMsg, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)Parameters
- depthsIEnumerable<QuoteChangeMessage>
- Market depths. 
- mdMsgMarketDataMessage
- Market data subscription. 
- typeLevel1Fields
- Type of candle depth based data. 
- candleBuilderProviderCandleBuilderProvider
- Candle builders provider. 
Returns
- IEnumerable<CandleMessage>
- Candles. 
ToCandles<TCandle>(IEnumerable<Trade>, object, bool)
To create candles from the tick trades collection.
[Obsolete("Use ITickTradeMessage.")]
public static IEnumerable<TCandle> ToCandles<TCandle>(this IEnumerable<Trade> trades, object arg, bool onlyFormed = true) where TCandle : CandleParameters
- tradesIEnumerable<Trade>
- Tick trades. 
- argobject
- Candle arg. 
- onlyFormedbool
- Send only formed candles. 
Returns
- IEnumerable<TCandle>
- Candles. 
Type Parameters
- TCandle
- Candles type. 
ToTickMessage((Sides? side, decimal price, decimal volume, DateTimeOffset time), SecurityId, DateTimeOffset)
Convert tick info into ExecutionMessage.
public static ExecutionMessage ToTickMessage(this (Sides? side, decimal price, decimal volume, DateTimeOffset time) tick, SecurityId securityId, DateTimeOffset localTime)Parameters
- tick(Sides? side, decimal price, decimal volume, DateTimeOffset time)
- Tick info. 
- securityIdSecurityId
- localTimeDateTimeOffset
Returns
ToTrades<TCandle>(IEnumerable<TCandle>, decimal)
To create tick trades from candles.
public static IEnumerable<ExecutionMessage> ToTrades<TCandle>(this IEnumerable<TCandle> candles, decimal volumeStep) where TCandle : ICandleMessageParameters
- candlesIEnumerable<TCandle>
- Candles. 
- volumeStepdecimal
- Volume step. 
Returns
- IEnumerable<ExecutionMessage>
- Tick trades. 
Type Parameters
- TCandle
TotalBuyCount(VolumeProfileBuilder)
The total number of bids in the VolumeProfileBuilder.
public static decimal TotalBuyCount(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total number of bids. 
TotalBuyVolume(VolumeProfileBuilder)
The total volume of bids in the VolumeProfileBuilder.
public static decimal TotalBuyVolume(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total volume of bids. 
TotalSellCount(VolumeProfileBuilder)
The total number of asks in the VolumeProfileBuilder.
public static decimal TotalSellCount(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total number of asks. 
TotalSellVolume(VolumeProfileBuilder)
The total volume of asks in the VolumeProfileBuilder.
public static decimal TotalSellVolume(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- The total volume of asks. 
TryGetCandlesBuildFrom(IMessageAdapter, MarketDataMessage, CandleBuilderProvider)
Try get suitable market-data type for candles compression.
public static DataType TryGetCandlesBuildFrom(this IMessageAdapter adapter, MarketDataMessage subscription, CandleBuilderProvider provider)Parameters
- adapterIMessageAdapter
- Adapter. 
- subscriptionMarketDataMessage
- Subscription. 
- providerCandleBuilderProvider
- Candle builders provider. 
Returns
Update(VolumeProfileBuilder, ICandleBuilderValueTransform)
To update the profile with new value.
public static void Update(this VolumeProfileBuilder volumeProfile, ICandleBuilderValueTransform transform)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
- transformICandleBuilderValueTransform
- The data source transformation. 
VolumeAbovePoC(VolumeProfileBuilder)
The total volume which was above PoC(VolumeProfileBuilder).
public static decimal VolumeAbovePoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- Total volume. 
VolumeBelowPoC(VolumeProfileBuilder)
The total volume which was below PoC(VolumeProfileBuilder).
public static decimal VolumeBelowPoC(this VolumeProfileBuilder volumeProfile)Parameters
- volumeProfileVolumeProfileBuilder
- Volume profile. 
Returns
- decimal
- Total volume.