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