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)
Информация о релизе
v2

Added:
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.
Информация о релизе
v3

Added:
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!
colorsdisplaytimesessions

Библиотека Pine

В истинном духе TradingView автор опубликовал этот код Pine как библиотеку с открытым исходным кодом, чтобы другие программисты Pine из нашего сообщества могли им воспользоваться. Вы можете использовать эту библиотеку в приватных или других публикациях с открытым исходным кодом, но повторное использование этого кода в публикации регулируется Правилами поведения.

Отказ от ответственности