Kurbelklaus

KK_Average Directional Index (ADX) Higher TF

Hey guys,

sometimes you just want to plot an Indicator value from a higher Timeframe on your Chart. For most Indicators this is pretty straightforward however there is one Indicator that has been giving me quite a headache while trying to do this: The Average Directional Index. Anyway after going through almost 200 versions of this script I finally found a solution that works and thought I would share this with you, since I'm sure some of you have encountered the same problem.

How it works
  • Go to your desired Instrument/Timeframe and add the Script
  • Under Settings in the field for "Higher ADX TF" put the Timeframe-code you want to pull the ADX Values from.
    - Codes: Monthly - M, Weekly W, Daily - D
    - Codes Intraday: The amount of hours in minutes, e.g. if you want to pull values from the 4h-Chart the code is 240 (60 for 1h, 15 for 15m ...)
  • In some cases (see below) the calculation might not be correct. So make sure the values are correct:
    a) Write down the latest ADX of the higher TF while you are on the lower TF
    b) Switch the Resolution to the higher TF
    c) Compare the value you have just written down to the next to last value. They should be the same.
    d) Switch back the Resolution to the lower TF and you're good to go.

Limitations
  • You can only pull values from higher Timeframes, e.g. you're on a 4h Chart, so you can only pull values from the Daily, Weekly and Monthly Chart. You can't pull values from the 1h Chart.
  • You can only pull values from Timeframes, where the higher Timeframe Close always has a corresponding Close on the lower Timeframe, e.g. you can't pull values from the 3h Chart when you are on a 2h Chart. This should be pretty rare.
  • The Script needs a certain amount of Data from the Higher TF before the calculated values are correct. I have tested this on several Instruments and the Script usually needs approximately 100 Bars on the higher Timeframe (often less) for the values to be correct (error < 1%).
    So when the difference between your lower Timeframe and you higher Timeframe is large, e.g. you want to pull the Daily ADX value on a 15m-Chart, the calculation can be wrong. This can lead to errors in 2 Cases:
    a) Backtesting: When you go over old data and get close to the last available Bar the Data will be wrong. This will limit the amount of data you can backtest.
    b) Live values: When the difference between the two Timeframes is too large, it is possible that even live values are wrong, e.g. this will be the case when you are trying to pull the Daily ADX value on a 5 minute Chart. Always check if the calculation works with your desired combination of Timeframes before using it (see above).

I hope this is useful for you and whish all of you successful trading!
Best regards
Kurbelklaus
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 đồ?