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提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。