PINE LIBRARY

libTF

Library "libTF"
libTF: Find higher/lower TF automatically
This library to find higher/lower TF from current timeframe(timeframe.period) for Pine Script version6(or higher).

Basic Algorithm
Using a timeframe scale Array and timeframe.in_seconds() function to find higher/lower timeframe.
Return value is na if could not find TF in the timeframe scale.
The timeframe scale could be changed by the parameter 'scale'(CSV).

How to use
1. Set higher/lower TF
higher()/lower() function returns higher/lower TF.
Default timeframe scale is "1, 5, 15, 60, 240, 1D, 1M, 3M, 12M".
example:


2. Set higher/lower TF using your timeframe scale
The timeframe scale could be changed by the parameter.
example:


3. How to use with request.*() function
na value is set if no higher/lower TF in timeframe scale.
It returns current timeframe's value, when na value as timeframe parameter in request.*().
As bellow, if it should be na when timeframe is na.
example:



higher(tf, scale)
  higher: find higher TF from TF string.
  Parameters:
    tf (string): default value is timeframe.period.
    scale (string): TF scale in CSV. default is "1,5,15,60,240,1D,1W,1M,3M,12M".
  Returns: higher TF string.

lower(tf, scale)
  lower: find lower TF from TF string.
  Parameters:
    tf (string): default value is timeframe.period.
    scale (string): TF scale in CSV. defalut is "1,5,15,60,240,1D,1W,1M,3M,12M".
  Returns: lower TF string.
highertimeframeHTFlowertimeframeLTFmtftimeframeversion6

Pine腳本庫

在真正的TradingView精神中,作者將這段Pine程式碼發佈為開源程式庫,以便我們社群的其他Pine程式設計師可以重複使用它。請向作者致敬!您可以私下使用這個函式庫,或在其他開源出版品中使用,但在出版物中再次使用這段程式碼將受到網站規則的約束。

免責聲明