SimpleCryptoLife

TimeframeToMinutes

SimpleCryptoLife מעודכן   
Library "TimeframeToMinutes"
The timeframeToMinutes() function returns the number of minutes in an arbitrary timeframe string.

timeframeToMinutes()
Returns the number of minutes in the supplied timeframe string, which is arbitrary, i.e. it doesn't have to be the timeframe of the current chart but can be taken from an input.
The sole advantage over the short and neat Pinecoders f_resInMinutes function from their excellent MTF Selection Framework (at www.tradingview.com/...work-PineCoders-FAQ/) is that this one doesn't use up a security() call.
To convert the other way, from minutes to timeframe.period format, I would use the f_resFromMinutes function from the Pinecoders' MTF Selection Framework, which does not use security().
ERROR-CHECKING: It has light error-checking to try to make sure the string is in the format timeframe.period, e.g. 15S, 1 (minute), 60 (1H), 1D, 1W, 1M.
It will throw an error for some non-standard timeframes such as 30 hours (1800 minutes). Above 1440 minutes, only whole numbers of days are allowed. This is to be consistent with the security() function.
But it will allow some non-standard timeframes such as 7 hours (420 minutes). Such timeframes must still be supplied in the standard timeframe.period format.
param _tf
The timeframe to convert to minutes. Must be in timeframe.period format.
returns
An integer representing the number of minutes that the timeframe period is equivalent to.
הערות שחרור:
Correction to the description: it returns a float, not an int.
הערות שחרור:
Minor update to improve error messages.
הערות שחרור:
v4
Updates:
Added a specific error condition if the input timeframe is empty, not just "Badly formed".
Added a commented-out example of how to prevent this error when calling the function.

ספריית Pine

ברוח TradingView אמיתית, המחבר פרסם את קוד Pine זה כספריית קוד פתוח כך שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומים אחרים בקוד פתוח, אך השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בספרייה זו?

העתק את השורה הבאה והדבק אותה בסקריפט שלך.