Skip to content

Doji

Doji is a single-bar candlestick pattern where open and close price are virtually identical, representing market indecision. [Discuss] 💬

csharp
// C# usage syntax
IReadOnlyList<CandleResult> results =
  bars.ToDoji(maxPriceChangePercent);

Parameters

paramtypedescription
maxPriceChangePercentdoubleOptional. Maximum absolute percent difference in open and close price. Example: 0.3% would be entered as 0.3 (not 0.003). Must be between 0 and 0.5 percent, if specified. Default is 0.1 (0.1%).

Historical price bars requirements

You must have at least one historical bar; however, more is typically provided since this is a chartable candlestick pattern.

bars is a collection of generic TBar historical price bars. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.

Response

csharp
IReadOnlyList<CandleResult>
  • This method returns a time series of all available indicator values for the bars provided.
  • It always returns the same number of elements as there are in the historical price bars.
  • It does not return a single incremental indicator value.
  • The candlestick pattern is indicated on dates where Match is Match.Neutral.
  • Price is Close price; however, all OHLCV elements are included in CandleProperties.
  • There is no intrinsic basis or confirmation signal provided for this pattern.

CandleResult

propertytypedescription
TimestampDateTimeDate from evaluated TBar
PricedecimalPrice of the most relevant OHLC candle element when a signal is present
MatchMatchIndicates a matching signal type for this candlestick pattern
CandleCandlePropertiesCharacteristics of the candle body and wicks

Match

When a candlestick pattern is recognized, it produces a matching signal. In some cases, an intrinsic confirmation is also available after the signal. In cases where previous bars were used to identify a pattern, they are indicated as the basis for the signal. This enum can also be referenced as an int value. Documentation for each candlestick pattern will indicate whether confirmation and/or basis information is produced.

typeintdescription
Match.BullConfirmed200Confirmation of a prior bull signal
Match.BullSignal100Bullish signal
Match.BullBasis10Bars supporting a bullish signal
Match.Neutral1Signal for non-directional patterns
Match.None0No match
Match.BearBasis-10Bars supporting a bearish signal
Match.BearSignal-100Bearish signal
Match.BearConfirmed-200Confirmation of a prior bear signal

CandleProperties

The CandleProperties record class extends the basic Bar type with calculated properties.

propertytypedescription
TimestampDateTimeClose date
OpendecimalOpen price
HighdecimalHigh price
LowdecimalLow price
ClosedecimalClose price
VolumedecimalVolume
SizedecimalHigh-Low
Bodydecimal|Open-Close|
UpperWickdecimalUpper wick size
LowerWickdecimalLower wick size
BodyPctdoubleBody/Size
UpperWickPctdoubleUpperWick/Size
LowerWickPctdoubleLowerWick/Size
IsBullishboolClose>Open direction
IsBearishboolClose<Open direction

Utilities

See Utilities and helpers for more information.

Streaming

Use the buffer-style List<T> when you need incremental calculations without a hub:

csharp
DojiList dojiList = new(maxPriceChangePercent);

foreach (IBar bar in bars)  // simulating stream
{
  dojiList.Add(bar);
}

// based on `ICollection<CandleResult>`
IReadOnlyList<CandleResult> results = dojiList;

Subscribe to a BarHub for advanced streaming scenarios:

csharp
BarHub barHub = new();
DojiHub observer = barHub.ToDojiHub(maxPriceChangePercent);

foreach (IBar bar in bars)  // simulating stream
{
  barHub.Add(bar);
}

IReadOnlyList<CandleResult> results = observer.Results;

See Buffer lists and Stream hubs for full usage guides.