Table of Contents

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

volumeProfile VolumeProfileBuilder

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

volumeProfile VolumeProfileBuilder

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

source IEnumerable<CandleMessage>

Smaller time-frame candles.

compressor BiggerTimeFrameCandleCompressor

Compressor of candles from smaller time-frames to bigger.

includeLastCandle bool

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

candleMsg ICandleMessage

Candle.

volumeStep decimal

Volume step.

decimals int

The number of decimal places for the volume.

ticks (Sides? side, decimal price, decimal volume, DateTimeOffset time)[]

Array to tick trades.

Delta(VolumeProfileBuilder)

public static decimal Delta(this VolumeProfileBuilder volumeProfile)

Parameters

volumeProfile VolumeProfileBuilder

Volume profile.

Returns

decimal

Delta.

DeltaAbovePoC(VolumeProfileBuilder)

The total Delta which was above PoC(VolumeProfileBuilder).

public static decimal DeltaAbovePoC(this VolumeProfileBuilder volumeProfile)

Parameters

volumeProfile VolumeProfileBuilder

Volume profile.

Returns

decimal

Delta.

DeltaBelowPoC(VolumeProfileBuilder)

The total Delta which was below PoC(VolumeProfileBuilder).

public static decimal DeltaBelowPoC(this VolumeProfileBuilder volumeProfile)

Parameters

volumeProfile VolumeProfileBuilder

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

timeFrames IEnumerable<TimeSpan>

All time-frames.

original TimeSpan

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

candle ICandleMessage

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

candle ICandleMessage

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

timeFrame TimeSpan

The time frame for which you need to get time range.

currentTime DateTimeOffset

The current time within the range of time frames.

board ExchangeBoard

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

timeFrame TimeSpan

The time frame for which you need to get time range.

currentTime DateTimeOffset

The current time within the range of time frames.

board BoardMessage

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

candle ICandleMessage

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

candle ICandleMessage

The candle for which you need to get a length.

priceStep decimal?

PriceStep

Returns

decimal

The candle length.

GetSeries<TCandle>(ISubscriptionProvider, Security, object)

To get a candles series by the specified parameters.

public static CandleSeries GetSeries<TCandle>(this ISubscriptionProvider subscriptionProvider, Security security, object arg) where TCandle : ICandleMessage

Parameters

subscriptionProvider ISubscriptionProvider

The subscription provider.

security Security

The instrument by which trades should be filtered for the candles creation.

arg object

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

range Range<DateTimeOffset>

The specified time range for which you need to get the number of time frames.

timeFrame TimeSpan

The time frame size.

board ExchangeBoard

ExchangeBoard.

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

range Range<DateTimeOffset>

The specified time range for which you need to get the number of time frames.

timeFrame TimeSpan

The time frame size.

board BoardMessage

BoardMessage.

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

candle ICandleMessage

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 : ICandleMessage

Parameters

candles IEnumerable<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.

public static bool IsCandlesRegistered<TCandle>(this ISubscriptionProvider subscriptionProvider, Security security, object arg) where TCandle : ICandleMessage

Parameters

subscriptionProvider ISubscriptionProvider

The subscription provider.

security Security

The instrument for which the grouping is registered.

arg object

Candle arg.

Returns

bool

true if registered. Otherwise, false.

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 : ICandleMessage

Parameters

candle1 TCandle

First.

candle2 TCandle

Second.

Returns

bool

Check result.

Type Parameters

TCandle

ICandleMessage

MaxPriceLevel(ICandleMessage)

PriceLevels with maximum TotalVolume.

public static CandlePriceLevel? MaxPriceLevel(this ICandleMessage candle)

Parameters

candle ICandleMessage

ICandleMessage

Returns

CandlePriceLevel?

PriceLevels with maximum TotalVolume.

MinPriceLevel(ICandleMessage)

PriceLevels with minimum TotalVolume.

public static CandlePriceLevel? MinPriceLevel(this ICandleMessage candle)

Parameters

candle ICandleMessage

ICandleMessage

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

volumeProfile VolumeProfileBuilder

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

volumeProfile VolumeProfileBuilder

Volume profile.

Returns

CandlePriceLevel

CandlePriceLevel.

PriceLevelOfMinDelta(VolumeProfileBuilder)

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

public static CandlePriceLevel PriceLevelOfMinDelta(this VolumeProfileBuilder volumeProfile)

Parameters

volumeProfile VolumeProfileBuilder

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

volumeProfile VolumeProfileBuilder

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

volumeProfile VolumeProfileBuilder

Volume profile.

Returns

decimal

The total volume of asks.

Start<TCandle>(ISubscriptionProvider, CandleSeries)

To start candles getting.

public static void Start<TCandle>(this ISubscriptionProvider subscriptionProvider, CandleSeries series) where TCandle : ICandleMessage

Parameters

subscriptionProvider ISubscriptionProvider

The subscription provider.

series CandleSeries

Candles series.

Type Parameters

TCandle

ICandleMessage

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

depths IEnumerable<MarketDepth>

Market depths.

series CandleSeries

Candles series.

type Level1Fields

Type of candle depth based data.

candleBuilderProvider CandleBuilderProvider

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

trades IEnumerable<Trade>

Tick trades.

series CandleSeries

Candles series.

Returns

IEnumerable<Candle>

Candles.

ToCandles(IEnumerable<ExecutionMessage>, CandleSeries, CandleBuilderProvider)

To create candles from the tick trades collection.

public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<ExecutionMessage> trades, CandleSeries series, CandleBuilderProvider candleBuilderProvider = null)

Parameters

trades IEnumerable<ExecutionMessage>

Tick trades.

series CandleSeries

Candles series.

candleBuilderProvider CandleBuilderProvider

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

executions IEnumerable<ExecutionMessage>

Tick data.

mdMsg MarketDataMessage

Market data subscription.

candleBuilderProvider CandleBuilderProvider

Candle builders provider.

Returns

IEnumerable<CandleMessage>

Candles.

ToCandles(IEnumerable<QuoteChangeMessage>, CandleSeries, Level1Fields, CandleBuilderProvider)

To create candles from the order books collection.

public static IEnumerable<CandleMessage> ToCandles(this IEnumerable<QuoteChangeMessage> depths, CandleSeries series, Level1Fields type = Level1Fields.SpreadMiddle, CandleBuilderProvider candleBuilderProvider = null)

Parameters

depths IEnumerable<QuoteChangeMessage>

Market depths.

series CandleSeries

Candles series.

type Level1Fields

Type of candle depth based data.

candleBuilderProvider CandleBuilderProvider

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

depths IEnumerable<QuoteChangeMessage>

Market depths.

mdMsg MarketDataMessage

Market data subscription.

type Level1Fields

Type of candle depth based data.

candleBuilderProvider CandleBuilderProvider

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 : Candle

Parameters

trades IEnumerable<Trade>

Tick trades.

arg object

Candle arg.

onlyFormed bool

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.

securityId SecurityId

SecurityId

localTime DateTimeOffset

LocalTime

Returns

ExecutionMessage

ExecutionMessage

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 : ICandleMessage

Parameters

candles IEnumerable<TCandle>

Candles.

volumeStep decimal

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

volumeProfile VolumeProfileBuilder

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

volumeProfile VolumeProfileBuilder

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

volumeProfile VolumeProfileBuilder

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

volumeProfile VolumeProfileBuilder

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

adapter IMessageAdapter

Adapter.

subscription MarketDataMessage

Subscription.

provider CandleBuilderProvider

Candle builders provider.

Returns

DataType

Which market-data type is used as a source value. null is compression is impossible.

Update(VolumeProfileBuilder, ICandleBuilderValueTransform)

To update the profile with new value.

public static void Update(this VolumeProfileBuilder volumeProfile, ICandleBuilderValueTransform transform)

Parameters

volumeProfile VolumeProfileBuilder

Volume profile.

transform ICandleBuilderValueTransform

The data source transformation.

VolumeAbovePoC(VolumeProfileBuilder)

The total volume which was above PoC(VolumeProfileBuilder).

public static decimal VolumeAbovePoC(this VolumeProfileBuilder volumeProfile)

Parameters

volumeProfile VolumeProfileBuilder

Volume profile.

Returns

decimal

Total volume.

VolumeBelowPoC(VolumeProfileBuilder)

The total volume which was below PoC(VolumeProfileBuilder).

public static decimal VolumeBelowPoC(this VolumeProfileBuilder volumeProfile)

Parameters

volumeProfile VolumeProfileBuilder

Volume profile.

Returns

decimal

Total volume.