OPEN-SOURCE SCRIPT

[SGM Ordinal Patterns]

Sigaud의
업데이트됨
An ordinal pattern is a concept used in mathematics and time series analysis. It is a way of describing the relative order of values ​​in a sequence. Rather than focusing on the exact values, we are interested in how they compare to each other.

An ordinal pattern will tell you how these values ​​are positioned relative to each other.
We do not look at the exact values, but only their order.

Concrete Example

• 4 (position 1 in the original sequence) is in position 2 in the ordered sequence.
• 7 (position 2 in the original sequence) is in position 3 in the ordered sequence.
• 2 (position 3 in the original sequence) is in position 1 in the ordered sequence.
The ordinal pattern for this sequence is then (2,3,1)(2, 3, 1)(2,3,1).

스냅샷

Script Explanation

This script analyzes ordinal patterns based on the closing prices of the last three bars and calculates the future gains associated with each ordinal pattern.

The main elements of the script are:

1. ordinal_pattern Function:

o Determines the ordinal pattern based on three past closing values.
o Returns an index (from 0 to 5) corresponding to one of the six possible ordinal patterns.

2. Calculations and Storage:

o For each new bar, the last three closes are used to identify the ordinal pattern.
o Future gains are calculated and associated with the previous ordinal pattern.
o Return statistics (mean, standard deviation and Sharpe ratio) are calculated for each pattern.

3. Visualization:

o Draws lines connecting the last three closes.
o Tables displaying the number of occurrences, distributions, and return statistics for each ordinal pattern.

What the Script Shows:

• Table motifs_table : Number of occurrences and distribution of each ordinal pattern. An uneven distribution between patterns (different by one sixth for each pattern) can indicate market inefficiency.
• Table pattern_analysis : Analysis of returns (mean, standard deviation, Sharpe ratio) for each ordinal pattern.
• Table current_motif_table : Ordinal pattern of the last bar.
This script helps to understand and visualize how ordinal patterns influence future returns of financial asset prices. An uneven distribution of patterns can indicate market inefficiencies.
릴리즈 노트
adding the previous pattern in the table
Chart patternsordinalstatistics
Sigaud
Sigaud | Junior Quantitative Trader & Developer

Combining technical expertise with analytical precision.
Gaining experience and growing in the field.

📧 Contact: from the website

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항