TradingView
Peter_O
27 Nov 2021 pukul 18.44

MTFindicators 

Bitcoin / U.S. dollarBitstamp

Deskripsi

Quite recently TradingView added the possibility to create and use Libraries in PineScript. With this feature PineScript became higher quality of coding language overnight. Libraries enable splitting your code into multiple files, providing easier access to code reusability.

I was working on a script which included 3000 lines of code, which was recompiling 1:30 min, and recalculating over 1 minute as well. So I split it into 2 parts: main part + library containing "main logic", which I reuse in variety of scripts, but don't change too often. Result? Now recompilation of my main script takes 10 and recalculation 8 seconds!!!. I instantly fell in love with libraries.

Having said that, and being dedicated hater of security() calls, I have decided to publish a library of MTF indicators created with my own approach: "dig into formula". I have explained reasons for such approach in desription to this script: tradingview.com/script/JwWWwZOD-RSI-MTF-by-PeterO/

So this library script will be a set of indicators reaching to higher timeframes. Just include one line at the beginning of the script you are creating:
import Peter_O/MTFindicators/1 as LIB

and then somewhere is the code add this line:
rsimtf=LIB.rsi_mtf(close,5,14)

All of a sudden you have access to rsimtf from 5x higher timeframe without any hassle :)

I start with RSI MTF, next ones will be ADX, Stochastic and some more. I will update this library with them here as well. Feel free to request particular indicators in comments. Maybe PSAR? Maybe Bollinger Bands?

Catatan Rilis

v2

Added:
adx()

More to come...

Catatan Rilis

v3

Added:
stoch_mtf()

Catatan Rilis

v4

Added:
moving_average_mtf()

Catatan Rilis

v5

Added:
bollingerbands_mtf()

Catatan Rilis

v6

Updated:
rsi_mtf()

Catatan Rilis

v7

Added:
keltnerchannels()

macd_mtf()

Catatan Rilis

v8

Renamed:
keltnerchannels() => keltnerchannels_mtf()
Komentar
avmarko
DannyBaker
Hi this is amazing!! could you add vwap
Duyck
Thanks a million, Buddy!!!!

Gr, JD.
SiddWolf
rsi_mtf(close, 4, 14)
If I'm correct, above line was supposed to give 4 times higher timeframe rsi value. So in 1 hour chart, it should give 4 hours rsi value for each candles. But I've manually checked the values
For example, look at "SOLUSDT" (time in utc)

RSI (actual) in 4 hour tf:
2021-11-30 04:00 == 51.14
2021-11-30 08:00 == 57.34

RSI with the above formula in 1 hour tf: (supposed to give 4 hour rsi vals)
2021-11-30 00:00 == 54.53
2021-11-30 01:00 == 53.93
2021-11-30 02:00 == 53.87
2021-11-30 03:00 == 53.76
2021-11-30 04:00 == 53.39
2021-11-30 05:00 == 52.49
2021-11-30 06:00 == 52.16
2021-11-30 07:00 == 51.58
2021-11-30 08:00 == 50.78
2021-11-30 09:00 == 50.69
2021-11-30 10:00 == 50.72
2021-11-30 11:00 == 52.25
2021-11-30 12:00 == 55.68
2021-11-30 13:00 == 58.70

As it can be clearly seen, at 08:00 utc the actual rsi in 4 hour timeframe is 57.34 but with above formula it goes nowhere near 57.34 from 00:00 to 12:00.
So have I misunderstood this library or is there a bug in that code. any help would be highly appreciated. Thanks.
Peter_O
@sidcry9, 2021-11-30 08:00 rsi value is actually being calculated at the close of the candle, so at 12:00. Those values will almost never be the same, only similar and surely my formula will work better than request.security() at fast turns of the market.
kakola
@Peter_O, Well there's quite a difference between getting an actual higher-timeframe indicator value, versus using a lower timeframe's chart and multiplying by a factor.
Hutmacher42
Nice, I love you for sharing this with the community!!!
IdeasSJ
Hi Peter, Thanks for sharing. Request you to enhance the MTF Indicator Library with Laguerre RSI.
dtrade23
I'm trying to use mtf4macd() but it cannot find the function, the only on one I've got to work is rsi_mtf() from the example, am I doing something wrong?
Peter_O
@dtrade23, function name is macd_mtf(), not mtf4macd()
Lebih lanjut