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
Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?