PINE LIBRARY
已更新 SessionBox

Library "SessionBox"
This library provides functions to manage and visualize session boxes and labels on chart. A session box is a visual representation of a trading session with properties like time, name, color and the ability to track the high and low price within that session.
SessionBox
SessionBox: stores session data and provides methods to manage that data and visualize it on the chart.
Fields:
session_time (series bool)
session_name (series string)
session_color (series color)
This library provides functions to manage and visualize session boxes and labels on chart. A session box is a visual representation of a trading session with properties like time, name, color and the ability to track the high and low price within that session.
SessionBox
SessionBox: stores session data and provides methods to manage that data and visualize it on the chart.
Fields:
session_time (series bool)
session_name (series string)
session_color (series color)
發行說明
v2Added:
method setTime(this, _time)
Sets the session_time property based on the provide boolean value
Namespace types: createSessionBox
Parameters:
this (createSessionBox)
_time (bool)
Returns: void
method setName(this, _name)
sets the session_name property with a provided string.
Namespace types: createSessionBox
Parameters:
this (createSessionBox)
_name (string)
Returns: void
method setColor(this, _color)
sets the session_color with a provided color value
Namespace types: createSessionBox
Parameters:
this (createSessionBox)
_color (color)
Returns: void
method getHighLowPrice(this)
Calculates and returns the high and low price within the current session.
Namespace types: createSessionBox
Parameters:
this (createSessionBox)
Returns: the high and low price within the current session as a two-element array.
method drawBox(this, _priceHigh, _priceLow)
Draws a session box on the chart based on the provided high and low prices for the current session.
Namespace types: createSessionBox
Parameters:
this (createSessionBox)
_priceHigh (float): High of the current session
_priceLow (float): Low of the current session
Returns: void
createSessionBox
Stores session data and provides methods to manage that data and visualize it on the chart.
Fields:
session_time (series bool)
session_name (series string)
session_color (series color)
Removed:
SessionBox
SessionBox: stores session data and provides methods to manage that data and visualize it on the chart.
發行說明
v3Added:
drawSessionBox(sessionName, sessionTime, sessionZone, boxColor, boxBorderSize)
Draws a custom session box with specified parameters.
Parameters:
sessionName (string): (string) - Name of the session (default: "").
sessionTime (string): (string) - The session time range in "HHMM-HHMM" format.
sessionZone (string): (string) - The session's time zone (default: "GMT+0").
boxColor (color): (color) - The color of the session box (default: color.blue).
boxBorderSize (int): (int) - The thickness of the box border (default: 2).
drawAsiaSession(sessionTime, sessionZone, boxColor, boxBorderSize)
Draws a session box for the Asian session with default or customized parameters.
Parameters:
sessionTime (string): (string) - The session time range (default: "0000-0900").
sessionZone (string): (string) - The session's time zone (default: "GMT+0").
boxColor (color): (color) - The color of the session box (default: color.green).
boxBorderSize (int): (int) - The thickness of the box border (default: 2).
drawLondonSession(sessionTime, sessionZone, boxColor, boxBorderSize)
Draws a session box for the London session with default or customized parameters.
Parameters:
sessionTime (string): (string) - The session time range (default: "0700-1600").
sessionZone (string): (string) - The session's time zone (default: "GMT+0").
boxColor (color): (color) - The color of the session box (default: color.blue).
boxBorderSize (int): (int) - The thickness of the box border (default: 2).
drawNewYorkSession(sessionTime, sessionZone, boxColor, boxBorderSize)
Draws a session box for the New York session with default or customized parameters.
Parameters:
sessionTime (string): (string) - The session time range (default: "1300-2200").
sessionZone (string): (string) - The session's time zone (default: "GMT+0").
boxColor (color): (color) - The color of the session box (default: color.purple).
boxBorderSize (int): (int) - The thickness of the box border (default: 2).
Removed:
method setTime(this, _time)
Sets the session_time property based on the provide boolean value
method setName(this, _name)
sets the session_name property with a provided string.
method setColor(this, _color)
sets the session_color with a provided color value
method getHighLowPrice(this)
Calculates and returns the high and low price within the current session.
method drawBox(this, _priceHigh, _priceLow)
Draws a session box on the chart based on the provided high and low prices for the current session.
createSessionBox
Stores session data and provides methods to manage that data and visualize it on the chart.
----------
### Quick Example:
```pinescript
//version=5
import "SessionBox" as sb
indicator("Session Box Example", overlay=true)
// Function arguments explained:
// drawSessionBox(
// string sessionName: Label for the session (default: ""),
// string sessionTime: Time range in "HHMM-HHMM" format (required),
// string sessionZone: Time zone (default: "GMT+0"),
// color boxColor: Box background color (default: color.blue),
// int boxBorderSize: Border thickness (default: 2)
// )
// Default session boxes
sb.drawAsiaSession() // Default Asia session: "0000-0900", GMT+0
sb.drawLondonSession() // Default London session: "0700-1600", GMT+0
sb.drawNewYorkSession() // Default New York session: "1300-2200", GMT+0
// Customized default session
sb.drawAsiaSession("0100-0800", "GMT+2", color.new(color.green, 50), 1)
// Custom session box
sb.drawSessionBox("My Custom Session", "05:00-14:00", "GMT+2", color.orange, 2)
```
This will create default session boxes, a customized default Asia session, and a completely custom session. Simple and intuitive!
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
Pine腳本庫
秉持 TradingView 一貫的共享精神,作者將此 Pine 程式碼發佈為開源庫,讓社群中的其他 Pine 程式設計師能夠重複使用。向作者致敬!您可以在私人專案或其他開源發佈中使用此庫,但在公開發佈中重複使用該程式碼需遵守社群規範。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。