OPEN-SOURCE SCRIPT

[SGM Markov Chain]

Theo Sigaud
Cập nhật
Introduction

A Markov chain is a mathematical model that describes a system evolving over time among a finite number of states. This model is based on the assumption that the future state of the system depends only on the current state and not on previous states, the so-called Markov property. In the context of financial markets, Markov chains can be used to model transitions between different market conditions, for example, the probability of a price going up after going up, or going down after going down.

ảnh chụp nhanh

Script Description

This script uses a Markov chain to calculate closing price transition probabilities across the entire accessible chart. It displays the probabilities of the following transitions:

- Up after Up (HH): Probability that the price rises after going up.
- Down after Down (BB): Probability that the price will go down after going down.
- Up after Down (HB): Probability that the price goes up after going down.
- Down after Up (BH): Probability that the price will go down after going up.

Features

- Color customization: Choose colors for each transition type.
- Table Position: Select the position of the probability display table (top/left, top/right, bottom/left, bottom/right).
Phát hành các Ghi chú
correction, probability measured on the total candles for a total probability of 100% (instead of 200% for the previous version)
Phát hành các Ghi chú
added chi square test

Chi Square Test
Objective: Evaluate the independence between two categorical variables or the conformity of an observed distribution to an expected distribution.

Types:

Fit: Compare an observed distribution to a theoretical distribution.
Independence: Test the association between two categorical variables.

Methodology :

Calculation of expected frequencies.
Application of the formula:

𝜒2=∑ ((𝑂𝑖−𝐸𝑖)^2 / 𝐸𝑖)

Comparison with a critical value to determine significance.

ảnh chụp nhanh

- addition of the choice of level of significance

ảnh chụp nhanh
Phát hành các Ghi chú
The script now calculates transition probabilities after an up or down movement, updates the table format to show these probabilities correctly, adjusts chi-square calculations to match the new probabilities, and ensures proper display of significance based on updated chi-square critical values.
Phát hành các Ghi chú
option to change table color
markovmarkovchainstatistics
Sigaud
Sigaud | Junior Quantitative Trader & Developer

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

📧 Contact: from the website

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Thông báo miễn trừ trách nhiệm