PINE LIBRARY

Session

Cập nhật
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]
Phát hành các Ghi chú
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

Thư viện Pine

Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ.


I release TradingView indicators and libraries designed to make you a better trader. For detailed info about them, head over to improve.trading
Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm