CandleHelper

StockSharp.Algo.Candles

Extension class for candles.

Methods

BuyVolAbovePoC
public static decimal BuyVolAbovePoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.BuyVolAbovePoC(volumeProfile)

The total volume of bids which was above VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: The total volume of bids.

BuyVolBelowPoC
public static decimal BuyVolBelowPoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.BuyVolBelowPoC(volumeProfile)

The total volume of bids which was below VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: The total volume of bids.

Compress
public static IAsyncEnumerable<CandleMessage> Compress(IAsyncEnumerable<CandleMessage> source, BiggerTimeFrameCandleCompressor compressor, bool includeLastCandle)
result = CandleHelper.Compress(source, compressor, includeLastCandle)

Compress candles to bigger time-frame candles.

source
Smaller time-frame candles.
compressor
Compressor of candles from smaller time-frames to bigger.
includeLastCandle
Output last active candle as finished.

Returns: Bigger time-frame candles.

Compress
public static IEnumerable<CandleMessage> Compress(IEnumerable<CandleMessage> source, BiggerTimeFrameCandleCompressor compressor, bool includeLastCandle)
result = CandleHelper.Compress(source, compressor, includeLastCandle)

Compress candles to bigger time-frame candles.

source
Smaller time-frame candles.
compressor
Compressor of candles from smaller time-frames to bigger.
includeLastCandle
Output last active candle as finished.

Returns: Bigger time-frame candles.

ConvertToTrades
public static void ConvertToTrades(ICandleMessage candleMsg, decimal volumeStep, int decimals, ValueTuple<Sides?, decimal, decimal, DateTime>[] ticks)
CandleHelper.ConvertToTrades(candleMsg, volumeStep, decimals, ticks)

To create tick trades from candle.

candleMsg
Candle.
volumeStep
Volume step.
decimals
The number of decimal places for the volume.
ticks
Array to tick trades.
Delta
public static decimal Delta(VolumeProfileBuilder volumeProfile)
result = CandleHelper.Delta(volumeProfile)

The difference between VolumeProfileBuilder) and VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: Delta.

DeltaAbovePoC
public static decimal DeltaAbovePoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.DeltaAbovePoC(volumeProfile)

The total Delta which was above VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: Delta.

DeltaBelowPoC
public static decimal DeltaBelowPoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.DeltaBelowPoC(volumeProfile)

The total Delta which was below VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: Delta.

FilterSmallerTimeFrames
public static IEnumerable<TimeSpan> FilterSmallerTimeFrames(IEnumerable<TimeSpan> timeFrames, TimeSpan original)
result = CandleHelper.FilterSmallerTimeFrames(timeFrames, original)

Filter time-frames to find multiple smaller time-frames.

timeFrames
All time-frames.
original
Original time-frame.

Returns: Multiple smaller time-frames.

GetBody
public static decimal GetBody(ICandleMessage candle)
result = CandleHelper.GetBody(candle)

To get the candle body.

candle
The candle for which you need to get the body.

Returns: The candle body.

GetBottomShadow
public static decimal GetBottomShadow(ICandleMessage candle)
result = CandleHelper.GetBottomShadow(candle)

To get the candle lower shadow length.

candle
The candle for which you need to get the lower shadow length.

Returns: The candle lower shadow length. If 0, there is no shadow.

GetCandleBounds
public static Range<DateTime> GetCandleBounds(TimeSpan timeFrame, DateTime currentTime, BoardMessage board)
result = CandleHelper.GetCandleBounds(timeFrame, currentTime, board)

To get candle time frames relatively to the exchange working hours.

timeFrame
The time frame for which you need to get time range.
currentTime
The current time within the range of time frames.
board
The information about the board from which WorkingTime working hours will be taken.

Returns: The candle time frames.

GetCandleBounds
public static Range<DateTime> GetCandleBounds(TimeSpan timeFrame, DateTime currentTime, ExchangeBoard board)
result = CandleHelper.GetCandleBounds(timeFrame, currentTime, board)

To get candle time frames relatively to the exchange working hours.

timeFrame
The time frame for which you need to get time range.
currentTime
The current time within the range of time frames.
board
The information about the board from which WorkingTime working hours will be taken.

Returns: The candle time frames.

GetLength
public static decimal GetLength(ICandleMessage candle)
result = CandleHelper.GetLength(candle)

To get the candle length.

candle
The candle for which you need to get a length.

Returns: The candle length.

GetMiddlePrice
public static decimal GetMiddlePrice(ICandleMessage candle, decimal? priceStep)
result = CandleHelper.GetMiddlePrice(candle, priceStep)

To get the candle middle price.

candle
The candle for which you need to get a length.
priceStep
PriceStep

Returns: The candle length.

GetTimeFrameCount
public static long GetTimeFrameCount(Range<DateTime> range, TimeSpan timeFrame, BoardMessage board)
result = CandleHelper.GetTimeFrameCount(range, timeFrame, board)

To get the number of time frames within the specified time range.

range
The specified time range for which you need to get the number of time frames.
timeFrame
The time frame size.
board
BoardMessage.

Returns: The received number of time frames.

GetTimeFrameCount
public static long GetTimeFrameCount(Range<DateTime> range, TimeSpan timeFrame, ExchangeBoard board)
result = CandleHelper.GetTimeFrameCount(range, timeFrame, board)

To get the number of time frames within the specified time range.

range
The specified time range for which you need to get the number of time frames.
timeFrame
The time frame size.
board
ExchangeBoard.

Returns: The received number of time frames.

GetTopShadow
public static decimal GetTopShadow(ICandleMessage candle)
result = CandleHelper.GetTopShadow(candle)

To get the candle upper shadow length.

candle
The candle for which you need to get the upper shadow length.

Returns: The candle upper shadow length. If 0, there is no shadow.

GetValueArea``1
public static VolumeProfileBuilder GetValueArea<TCandle>(IEnumerable<TCandle> candles)
result = CandleHelper.GetValueArea(candles)

To calculate the area for the candles group.

candles
Candles.

Returns: The area.

IsSame``1
public static bool IsSame<TCandle>(TCandle candle1, TCandle candle2)
result = CandleHelper.IsSame(candle1, candle2)

Determines the specified candles are same.

candle1
First.
candle2
Second.

Returns: Check result.

MaxPriceLevel
public static CandlePriceLevel? MaxPriceLevel(ICandleMessage candle)
result = CandleHelper.MaxPriceLevel(candle)

PriceLevels with maximum TotalVolume.

candle
ICandleMessage

Returns: PriceLevels with maximum TotalVolume.

MinPriceLevel
public static CandlePriceLevel? MinPriceLevel(ICandleMessage candle)
result = CandleHelper.MinPriceLevel(candle)

PriceLevels with minimum TotalVolume.

candle
ICandleMessage

Returns: PriceLevels with minimum TotalVolume.

PoC
public static CandlePriceLevel PoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.PoC(volumeProfile)

POC (Point Of Control) returns CandlePriceLevel which had the maximum volume.

volumeProfile
Volume profile.

Returns: The CandlePriceLevel which had the maximum volume.

PriceLevelOfMaxDelta
public static CandlePriceLevel PriceLevelOfMaxDelta(VolumeProfileBuilder volumeProfile)
result = CandleHelper.PriceLevelOfMaxDelta(volumeProfile)

It returns the price level at which the maximum VolumeProfileBuilder) is passed.

volumeProfile
Volume profile.

Returns: CandlePriceLevel.

PriceLevelOfMinDelta
public static CandlePriceLevel PriceLevelOfMinDelta(VolumeProfileBuilder volumeProfile)
result = CandleHelper.PriceLevelOfMinDelta(volumeProfile)

It returns the price level at which the minimum VolumeProfileBuilder) is passed.

volumeProfile
Volume profile.

Returns: The price level.

SellVolAbovePoC
public static decimal SellVolAbovePoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.SellVolAbovePoC(volumeProfile)

The total volume of asks which was above VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: The total volume of asks.

SellVolBelowPoC
public static decimal SellVolBelowPoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.SellVolBelowPoC(volumeProfile)

The total volume of asks which was below VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: The total volume of asks.

ToCandles
public static IEnumerable<CandleMessage> ToCandles(IEnumerable<ExecutionMessage> executions, MarketDataMessage mdMsg, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(executions, mdMsg, candleBuilderProvider)

To create candles from the tick trades collection.

executions
Tick data.
mdMsg
Market data subscription.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

ToCandles
public static IAsyncEnumerable<CandleMessage> ToCandles(IAsyncEnumerable<ExecutionMessage> executions, Subscription subscription, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(executions, subscription, candleBuilderProvider)

To create candles from the tick trades collection.

executions
Tick data.
subscription
Market data subscription.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

ToCandles
public static IAsyncEnumerable<CandleMessage> ToCandles(IAsyncEnumerable<ExecutionMessage> executions, MarketDataMessage mdMsg, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(executions, mdMsg, candleBuilderProvider)

To create candles from the tick trades collection.

executions
Tick data.
mdMsg
Market data subscription.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

ToCandles
public static IEnumerable<CandleMessage> ToCandles(IEnumerable<QuoteChangeMessage> depths, MarketDataMessage mdMsg, Level1Fields type, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(depths, mdMsg, type, candleBuilderProvider)

To create candles from the order books collection.

depths
Market depths.
mdMsg
Market data subscription.
type
Type of candle depth based data.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

ToCandles
public static IAsyncEnumerable<CandleMessage> ToCandles(IAsyncEnumerable<QuoteChangeMessage> depths, Subscription subscription, Level1Fields type, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(depths, subscription, type, candleBuilderProvider)

To create candles from the order books collection.

depths
Market depths.
subscription
Market data subscription.
type
Type of candle depth based data.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

ToCandles
public static IEnumerable<CandleMessage> ToCandles(IEnumerable<QuoteChangeMessage> depths, Subscription subscription, Level1Fields type, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(depths, subscription, type, candleBuilderProvider)

To create candles from the order books collection.

depths
Market depths.
subscription
Market data subscription.
type
Type of candle depth based data.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

ToCandles
public static IAsyncEnumerable<CandleMessage> ToCandles(IAsyncEnumerable<QuoteChangeMessage> depths, MarketDataMessage mdMsg, Level1Fields type, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(depths, mdMsg, type, candleBuilderProvider)

To create candles from the order books collection.

depths
Market depths.
mdMsg
Market data subscription.
type
Type of candle depth based data.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

ToCandles
public static IEnumerable<CandleMessage> ToCandles(IEnumerable<ExecutionMessage> executions, Subscription subscription, CandleBuilderProvider candleBuilderProvider)
result = CandleHelper.ToCandles(executions, subscription, candleBuilderProvider)

To create candles from the tick trades collection.

executions
Tick data.
subscription
Market data subscription.
candleBuilderProvider
Candle builders provider.

Returns: Candles.

TotalBuyCount
public static decimal TotalBuyCount(VolumeProfileBuilder volumeProfile)
result = CandleHelper.TotalBuyCount(volumeProfile)

The total number of bids in the VolumeProfileBuilder.

volumeProfile
Volume profile.

Returns: The total number of bids.

TotalBuyVolume
public static decimal TotalBuyVolume(VolumeProfileBuilder volumeProfile)
result = CandleHelper.TotalBuyVolume(volumeProfile)

The total volume of bids in the VolumeProfileBuilder.

volumeProfile
Volume profile.

Returns: The total volume of bids.

TotalSellCount
public static decimal TotalSellCount(VolumeProfileBuilder volumeProfile)
result = CandleHelper.TotalSellCount(volumeProfile)

The total number of asks in the VolumeProfileBuilder.

volumeProfile
Volume profile.

Returns: The total number of asks.

TotalSellVolume
public static decimal TotalSellVolume(VolumeProfileBuilder volumeProfile)
result = CandleHelper.TotalSellVolume(volumeProfile)

The total volume of asks in the VolumeProfileBuilder.

volumeProfile
Volume profile.

Returns: The total volume of asks.

ToTickMessage
public static ExecutionMessage ToTickMessage(ValueTuple<Sides?, decimal, decimal, DateTime> tick, SecurityId securityId, DateTime localTime)
result = CandleHelper.ToTickMessage(tick, securityId, localTime)

Convert tick info into ExecutionMessage.

tick
Tick info.
securityId
SecurityId
localTime
LocalTime

Returns: ExecutionMessage

ToTrades``1
public static IEnumerable<ExecutionMessage> ToTrades<TCandle>(IEnumerable<TCandle> candles, decimal volumeStep)
result = CandleHelper.ToTrades(candles, volumeStep)

To create tick trades from candles.

candles
Candles.
volumeStep
Volume step.

Returns: Tick trades.

ToTrades``1
public static IAsyncEnumerable<ExecutionMessage> ToTrades<TCandle>(IAsyncEnumerable<TCandle> candles, decimal volumeStep)
result = CandleHelper.ToTrades(candles, volumeStep)

To create tick trades from candles.

candles
Candles.
volumeStep
Volume step.

Returns: Tick trades.

TryGetCandlesBuildFromAsync
public static ValueTask<DataType> TryGetCandlesBuildFromAsync(IMessageAdapter adapter, MarketDataMessage subscription, CandleBuilderProvider provider, CancellationToken cancellationToken)
result = CandleHelper.TryGetCandlesBuildFromAsync(adapter, subscription, provider, cancellationToken)

Try get suitable market-data type for candles compression.

adapter
Adapter.
subscription
Subscription.
provider
Candle builders provider.
cancellationToken
CancellationToken

Returns: Which market-data type is used as a source value. if compression is impossible.

Update
public static void Update(VolumeProfileBuilder volumeProfile, ICandleBuilderValueTransform transform)
CandleHelper.Update(volumeProfile, transform)

To update the profile with new value.

volumeProfile
Volume profile.
transform
The data source transformation.
VolumeAbovePoC
public static decimal VolumeAbovePoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.VolumeAbovePoC(volumeProfile)

The total volume which was above VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: Total volume.

VolumeBelowPoC
public static decimal VolumeBelowPoC(VolumeProfileBuilder volumeProfile)
result = CandleHelper.VolumeBelowPoC(volumeProfile)

The total volume which was below VolumeProfileBuilder).

volumeProfile
Volume profile.

Returns: Total volume.