Pattern functions are mostly used for detecting patterns and accessing pattern script instances. For performance reasons patterns should only be created from the OnInitialize function and never from the OnBarUpdate function or any other frequently called function.


Read more: Pattern Scripts


Sections


Functions

Function Details


Functions


Name

Description

int PatternMatch(Pattern, int)

Determines whether a specified pattern that ends with the specified bar of the underlying symbol was found, which is equivalent to patternIdentifier[barshift].

PatternRemove(Pattern)

Removes a specified pattern so that it no longer takes up memory. Note that calling this function is rarely required since memory will be freed when the script shuts down.

Pattern PatternSetSymbol(Pattern, int)

Creates a copy of a specified OnInitialize pattern parameter while assigning the copy an underlying symbol. Note that this is required since the OnInitialize pattern parameter in a Multi-Symbol Trading Strategy doesn't have an underlying symbol assigned to it by default.

int PatternSymbolIndex(Pattern)

Gets the underlying symbol index of a specified pattern.

int PatternValueCount()

Gets the number of bars processed so far by the pattern.


Function Details


int PatternMatch(Pattern pattern, int barShift)

Determines whether a specified pattern that ends with the specified bar of the underlying symbol was found, which is equivalent to patternIdentifier[barshift].


Returns


The number of bars in the pattern that ends with the specified bar of the underlying symbol, zero if the pattern was not found.


Parameters


Type

Identifier

Description

Pattern

pattern

The pattern to search for

int

barShift

The shift relative to the last bar, such that 0 is the latest bar, 1 is the bar preceding it, etc.


Scripts


TradeManagementStrategy, Drawing, Indicator, MultiSymbolTradingStrategy, Pattern, PositionSizing, Signal, TradingStrategy


PatternRemove(Pattern pattern)

Removes a specified pattern so that it no longer takes up memory. Note that calling this function is rarely required since memory will be freed when the script shuts down.


Parameters


Type

Identifier

Description

Pattern

pattern

The pattern to remove


Scripts


TradeManagementStrategy, Drawing, Indicator, MultiSymbolTradingStrategy, Pattern, PositionSizing, Signal, TradingStrategy


Pattern PatternSetSymbol(Pattern pattern, int symbolIndex)

Creates a copy of a specified OnInitialize pattern parameter while assigning the copy an underlying symbol. Note that this is required since the OnInitialize pattern parameter in a Multi-Symbol Trading Strategy doesn't have an underlying symbol assigned to it by default.


Returns


The pattern of the new pattern copy.


Parameters


Type

Identifier

Description

Pattern

pattern

The pattern to copy

int

symbolIndex

The symbol index to reset the pattern arguments with


Scripts


MultiSymbolTradingStrategy


int PatternSymbolIndex(Pattern pattern)

Gets the underlying symbol index of a specified pattern.


Returns


The underlying symbol index of the specified pattern.


Parameters


Type

Identifier

Description

Pattern

pattern

The pattern


Scripts


TradeManagementStrategy, Drawing, Indicator, MultiSymbolTradingStrategy, Pattern, PositionSizing, Signal, TradingStrategy


int PatternValueCount()

Gets the number of bars processed so far by the pattern.


Returns


The number of bars processed so far by the pattern.


Parameters


Type

Identifier

Description

Pattern

pattern

The pattern


Scripts


Pattern