PINE LIBRARY

Session

已更新
Library "Session"

Helper functions for trading sessions. TradingView doesn't provide correct data when
calling some of the convenience methods like session.ismarket when you are looking at futures charts. This library corrects those mistakes by providing functions with the same names as the TradingView default properties. that reference a custom defined set of session hours for futures. It also provides a way for consumers to customize the map values by calling getSessionMap() and then overwriting (or adding) custom session definitions.

getSessionMap()
  Returns a map of the futures rth & eth session hours. The map is keyed with symbol:session format (eg. ES:market or ES:overnight).
  Returns: A map of futures symbols and their associated session hours.

getSessionString(session, symbol, sessionMap)
  Returns a session string representing the session hours (and days) for the requested symbol (or the chart's symbol if the symbol value is not provided). If the session string is not found in the collection, it will return a blank string.
  Parameters:
    session (string): A string representing the session hour being requested. One of: market (regular trading hours), overnight (extended/electronic trading hours), postmarket (after-hours), premarket
    symbol (string): The symbol to check. Optional. Defaults to chart symbol.
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.

inSession(session, sessionMap, barsBack)
  Returns true if the current symbol is currently in the session parameters defined by sessionString.
  Parameters:
    session (string): A string representing the session hour being requested. One of: market (regular trading hours), overnight (extended/electronic trading hours), postmarket (after-hours), premarket
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
    barsBack (int): Private. Only used by futures to check islastbar. Optional. The default is 0.

ismarket(sessionMap)
  Returns true if the current bar is a part of the regular trading hours (i.e. market hours), false otherwise. Works for futures (TradingView's methods do not).
  Parameters:
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: bool

isfirstbar()
  Returns true if the current bar is the first bar of the day's session, false otherwise. If extended session information is used, only returns true on the first bar of the pre-market bars. Works for futures (TradingView's methods do not).
  Returns: bool

islastbar()
  Returns true if the current bar is the last bar of the day's session, false otherwise. If extended session information is used, only returns true on the last bar of the post-market bars. Works for futures (TradingView's methods do not).
  Returns: bool

ispremarket(sessionMap)
  Returns true if the current bar is a part of the pre-market, false otherwise. On non-intraday charts always returns false. Works for futures (TradingView's methods do not).
  Parameters:
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: bool

ispostmarket(sessionMap)
  Returns true if the current bar is a part of the post-market, false otherwise. On non-intraday charts always returns false. Works for futures (TradingView's methods do not).
  Parameters:
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: bool

isfirstbar_regular(sessionMap)
  Returns true on the first regular session bar of the day, false otherwise. The result is the same whether extended session information is used or not. Works for futures (TradingView's methods do not).
  Parameters:
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: bool

islastbar_regular(sessionMap)
  Returns true on the last regular session bar of the day, false otherwise. The result is the same whether extended session information is used or not. Works for futures (TradingView's methods do not).
  Parameters:
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: bool

isovernight(sessionMap)
  Returns true if the current bar is a part of the pre-market or post-market, false otherwise. On non-intraday charts always returns false.
  Parameters:
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: bool

getSessionHighAndLow(session, sessionMap)
  Returns a tuple containing the high and low print during the specified session.
  Parameters:
    session (string): The session for which to get the high & low prints. Defaults to market.
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: A tuple containing [high, low]
發布通知
v2

Added:
getSessionHigh(session, sessionMap)
  Convenience function to return the session high. Necessary if you want to call this function from within a request.security expression where you can't return a tuple.
  Parameters:
    session (string): The session for which to get the high & low prints. Defaults to market.
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: The high of the session

getSessionLow(session, sessionMap)
  Convenience function to return the session low. Necessary if you want to call this function from within a request.security expression where you can't return a tuple.
  Parameters:
    session (string): The session for which to get the high & low prints. Defaults to market.
    sessionMap (map<string, string>): The map of futures session hours. Optional. Uses default if not provided.
  Returns: The low of the session
futuressessionstimesessions

Pine腳本庫

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


I release TradingView indicators and libraries designed to make you a better trader. For detailed info about them, head over to improve.trading
更多:

免責聲明