KioseffTrading

Cross Correlation [Kioseff Trading]

KioseffTrading Wizard Cập nhật   
Hello!

This script "Cross Correlation" calculates up to ~10,000 lag-symbol pair cross correlation values simultaneously!

  • Cross correlation calculation for 20 symbols simultaneously
  • +/- Lag Range is theoretically infinite (configurable min/max)
  • Practically, calculate up to 10000 lag-symbol pairs
  • Results can be sorted by greatest absolute difference or greatest sum
  • Ability to "isolate" the symbol on your chart and check for cross correlation against a list of symbols
  • Script defaults to stock pairs when on a stock, Forex pairs when on a Forex pair, crypto when on a crypto coin, futures when on a futures contract.
  • A custom symbol list can be used for cross correlation checking
  • Can check any number of available historical data points for cross correlation

Practical Assessment

Ideally, we can calculate cross correlation to determine if, in a list of assets, any of the assets frequently lead or lag one another.

Example

Say we are comparing the log returns for the previous 10 days for SPY and XLU.

*A single time-interval corresponds to the timeframe of your chart i.e. 1-minute chart = 1-minute time interval. We're using days for this example.

(Example Results)

A lag value (k) +/-3 is used.

The cross correlation (normalized) for k = +3 is -0.787
The cross correlation (normalized) for k = -3 is 0.216

A positive "k" value indicates the correlation when Asset A (SPY) leads Asset B (XLU)

A negative "k" value indicates the correlation when Asset B (XLU) leads Asset A (SPY)

A normalized cross correlation of -0.787 for k = +3 indicates an "adequately strong" negative relationship when SPY leads XLU by 3 days.

When SPY increases or decreases - XLU frequently moves in the opposite direction 3 days later.

A cross correlation value of 0.216 at k = −3 indicates a "weak" positive correlation when XLU leads SPY by 3 days.

There's a slight tendency for SPY to move in the same direction as XLU 3 days later.

After the cross-correlation score is normalized it will fall between -1 and 1.

A cross-correlation score of 1 indicates a perfect directional relationship between asset A and asset B at the corresponding lag (k).

A cross correlation of -1 indicates a perfect inverse relationship between asset A and asset B at the corresponding lag (k).

A cross correlation of 0 indicates no correlation at the corresponding lag (k).


The image above shows the primary usage for the script!


The image above further explains the data points located in the table!


The image above shows the script "isolating" the symbol on my chart and checking the cross correlation between the symbol and a list of symbols!

Wrapping Up

With this information, hopefully you can find some meaningful lead-lag relationships amongst assets!

Thank you for checking this out (:
Phát hành các Ghi chú:
Further improved efficiency!

•Access to Next-Gen Optimization Tools: www.kiosefftrading.com

•Discord Server: discord.gg/3cKVU28Z9Z
Mã nguồn mở

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

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

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

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