Skip to content

TomDemarkSequential

QuantConnect.Indicators.TomDemarkSequential

TomDemarkSequential(name: str = 'TomDemarkSequential')

Bases: WindowIndicator[IBaseDataBar]

Represents the Tom Demark Sequential indicator, which is used to identify potential trend exhaustion points. This implementation tracks both the setup and countdown phases, and can be extended to handle bullish and bearish setups, as well as qualifiers such as Perfect Setups and Countdown completions.

  • Setup Phase: Detects a trend by counting 9 consecutive bars where the close is less than (Buy Setup) or greater than (Sell Setup) the close 4 bars earlier.
  • TDST Support/Resistance: After a valid 9-bar setup completes, the indicator records the lowest low (for Sell Setup) or highest high (for Buy Setup) among the 9 bars. These are referred to as Support Price(for Buy Setup) and Resistance Price (for Sell Setup), and serve as critical thresholds that validate the continuation of the countdown phase.
  • Countdown Phase: Once a valid setup is completed, the indicator attempts to count 13 qualifying bars (not necessarily consecutive) where the close is less than (Buy Countdown) or greater than (Sell Countdown) the low/high 2 bars earlier. During this phase, the TDST Support/Resistance levels are checked — if the price breaks these levels, the countdown phase is reset, as the trend reversal condition is considered invalidated.

Initializes a new instance of the TomDemarkSequential indicator.

Parameters:

Name Type Description Default
name str

The name of the indicator.

'TomDemarkSequential'

resistance_price

resistance_price: float

Gets the current resistance price calculated during a Tom Demark Sequential buy setup. This is the highest high of the 9-bar setup and can act as a resistance level.

support_price

support_price: float

Gets the current support price calculated during a Tom Demark Sequential sell setup. This is the lowest low of the 9-bar setup and can act as a support level.

setup_phase_step_count

setup_phase_step_count: int

Gets the current Setup step count in the active Tom Demark Sequential (Buy/Sell) Setup phase (e.g., 1 to 9 in Setup), 0 if not in setup phase.

countdown_phase_step_count

countdown_phase_step_count: int

Gets the current Countdown step count in the active TomDemark Sequential (Buy/Sell) Countdown phase (e.g., 1 to 13 in Setup), 0 if bar is not in Countdown phase.

is_ready

is_ready: bool

Gets a value indicating whether the indicator is ready and fully initialized. Returns true when at least 6 bars have been received, which is the minimum required for checking for pre-requisite price flips and for comparing the current close price to the close price 4 bars ago (used in the setup logic).

warm_up_period

warm_up_period: int

Gets the number of data points (bars) required before the indicator is considered ready. The TomDemark Sequential setup logic requires at least 6 bars to begin evaluating valid setups.

consolidators

consolidators: ISet[IDataConsolidator]

The data consolidators associated with this indicator if any

current

Gets the current state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

previous

Gets the previous state of this indicator. If the state has not been updated then the time on the value will equal DateTime.MinValue.

name

name: str

Gets a name for this indicator

samples

samples: int

Gets the number of samples processed by this indicator

updated

updated: _EventContainer[
    Callable[[Object, IndicatorDataPoint], Any], Any
]

Event handler that fires after this indicator is updated

window

A rolling window keeping a history of the indicator values of a given period

period

period: int

Gets the period of this window indicator

compute_next_value

compute_next_value(
    window: IReadOnlyWindow[IBaseDataBar],
    current: IBaseDataBar,
) -> float

Computes the next value of the TD Sequential indicator based on the provided TradeBar.

This codeEntityType is protected.

Parameters:

Name Type Description Default
window IReadOnlyWindow[IBaseDataBar]

The window of data held in this indicator

required
current IBaseDataBar

The current input value to this indicator on this time step

required

Returns:

Type Description
float

The TomDemarkSequentialPhase state of the TD Sequential indicator for the current bar.

reset

reset() -> None

Resets the indicator to its initial state by clearing all internal counters, flags, and historical bar data. This allows the indicator to be reused from a clean state.

__eq__

__eq__(right: float) -> bool
__eq__(right: IndicatorBase) -> bool
__eq__(right: float) -> bool
__eq__(right: IndicatorBase) -> bool
__eq__(right: int) -> bool
__eq__(right: IndicatorBase) -> bool
__eq__(right: int) -> bool
__eq__(right: IndicatorBase) -> bool

Signature descriptions:

  • Determines if the indicator's current value is equal to the specified value

  • Determines if the specified value is equal to the indicator's current value

__ge__

__ge__(right: float) -> bool
__ge__(right: IndicatorBase) -> bool
__ge__(right: float) -> bool
__ge__(right: IndicatorBase) -> bool
__ge__(right: int) -> bool
__ge__(right: IndicatorBase) -> bool
__ge__(right: int) -> bool
__ge__(right: IndicatorBase) -> bool

Signature descriptions:

  • Determines if the indicator's current value is greater than or equal to the specified value

  • Determines if the specified value is greater than or equal to the indicator's current value

__gt__

__gt__(right: float) -> bool
__gt__(right: IndicatorBase) -> bool
__gt__(right: float) -> bool
__gt__(right: IndicatorBase) -> bool
__gt__(right: int) -> bool
__gt__(right: IndicatorBase) -> bool
__gt__(right: int) -> bool
__gt__(right: IndicatorBase) -> bool

Signature descriptions:

  • Determines if the indicator's current value is greater than the specified value

  • Determines if the specified value is greater than the indicator's current value

__le__

__le__(right: float) -> bool
__le__(right: IndicatorBase) -> bool
__le__(right: float) -> bool
__le__(right: IndicatorBase) -> bool
__le__(right: int) -> bool
__le__(right: IndicatorBase) -> bool
__le__(right: int) -> bool
__le__(right: IndicatorBase) -> bool

Signature descriptions:

  • Determines if the indicator's current value is less than or equal to the specified value

  • Determines if the specified value is less than or equal to the indicator's current value

__lt__

__lt__(right: float) -> bool
__lt__(right: IndicatorBase) -> bool
__lt__(right: float) -> bool
__lt__(right: IndicatorBase) -> bool
__lt__(right: int) -> bool
__lt__(right: IndicatorBase) -> bool
__lt__(right: int) -> bool
__lt__(right: IndicatorBase) -> bool

Signature descriptions:

  • Determines if the indicator's current value is less than the specified value

  • Determines if the specified value is less than the indicator's current value

__ne__

__ne__(right: float) -> bool
__ne__(right: IndicatorBase) -> bool
__ne__(right: float) -> bool
__ne__(right: IndicatorBase) -> bool
__ne__(right: int) -> bool
__ne__(right: IndicatorBase) -> bool
__ne__(right: int) -> bool
__ne__(right: IndicatorBase) -> bool

Signature descriptions:

  • Determines if the indicator's current value is not equal to the specified value

  • Determines if the specified value is not equal to the indicator's current value

compare_to

compare_to(obj: Any) -> int
compare_to(other: IIndicator) -> int

Signature descriptions:

  • Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

  • Compares the current object with another object of the same type.

Parameters:

Name Type Description Default
obj Optional[Any]

An object to compare with this instance.

None
other Optional[IIndicator]

An object to compare with this object.

None

Returns:

Type Description
int

Depends on the signature used. Case 1: [A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj. Greater than zero This instance follows obj in the sort order.]; Case 2: [A value that indicates the relative order of the objects being compared. The return value has the following meanings: Value Meaning Less than zero This object is less than the other parameter.Zero This object is equal to other. Greater than zero This object is greater than other.]

update

update(input: IBaseData) -> bool
update(time: Union[datetime, date], value: float) -> bool

Updates the state of this indicator with the given value and returns true if this indicator is ready, false otherwise

Parameters:

Name Type Description Default
input Optional[IBaseData]

The value to use to update this indicator

None
time Optional[Union[datetime, date]]

The time associated with the value

None
value Optional[float]

The value to use to update this indicator

None

Returns:

Type Description
bool

True if this indicator is ready, false otherwise.

__getitem__

__getitem__(i: int) -> IndicatorDataPoint

Indexes the history windows, where index 0 is the most recent indicator value. If index is greater or equal than the current count, it returns null. If the index is greater or equal than the window size, it returns null and resizes the windows to i + 1.

Parameters:

Name Type Description Default
i int

The index

required

Returns:

Type Description
IndicatorDataPoint

the ith most recent indicator value.

__iter__

__iter__() -> Iterator[IndicatorDataPoint]

equals

equals(obj: Any) -> bool

Determines whether the specified object is equal to the current object.

Parameters:

Name Type Description Default
obj Any

The object to compare with the current object.

required

Returns:

Type Description
bool

true if the specified object is equal to the current object; otherwise, false.

get_enumerator

get_enumerator() -> IEnumerator[IndicatorDataPoint]

Returns an enumerator that iterates through the history window.

Returns:

Type Description
IEnumerator[IndicatorDataPoint]

A System.Collections.Generic.IEnumerator`1 that can be used to iterate through the history window.

get_hash_code

get_hash_code() -> int

Get Hash Code for this Object

Returns:

Type Description
int

Integer Hash Code.

on_updated

on_updated(consolidated: IndicatorDataPoint) -> None

Event invocator for the Updated event

This codeEntityType is protected.

Parameters:

Name Type Description Default
consolidated IndicatorDataPoint

This is the new piece of data produced by this indicator

required

to_detailed_string

to_detailed_string() -> str

Provides a more detailed string of this indicator in the form of {Name} - {Value}

Returns:

Type Description
str

A detailed string of this indicator's current state.

to_string

to_string() -> str

ToString Overload for Indicator Base

Returns:

Type Description
str

String representation of the indicator.

validate_and_compute_next_value

validate_and_compute_next_value(
    input: QuantConnect_Indicators_IndicatorBase_T,
) -> IndicatorResult

Computes the next value of this indicator from the given state and returns an instance of the IndicatorResult class

This codeEntityType is protected.

Parameters:

Name Type Description Default
input QuantConnect_Indicators_IndicatorBase_T

The input given to the indicator

required

Returns:

Type Description
IndicatorResult

An IndicatorResult object including the status of the indicator.