本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("PrathikFX - Custom Prop Sessions IST", overlay=true, max_boxes_count=500, max_labels_count=500)
string tz = "Asia/Kolkata"
// GENERAL SETTINGS
borderWidth = input.int(1, "Border Width", minval=0, maxval=5, group="General Settings")
borderStyle = input.string("Solid", "Border Style", options=["Solid", "Dashed", "Dotted"], group="General Settings")
labelSize = input.string("Normal", "Name Size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group="General Settings")
getLabelSize() =>
switch labelSize
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
=> size.huge
getBorderStyle() =>
switch borderStyle
"Dashed" => line.style_dashed
"Dotted" => line.style_dotted
=> line.style_solid
// SESSION INPUTS
showBG = input.bool(true, "Show Session", group="Blue Guardian")
nameBG = input.string("BLUE GUARDIAN", "Session Name", group="Blue Guardian")
bgFill = input.color(color.new(color.blue, 85), "Background", group="Blue Guardian")
bgBorder = input.color(color.blue, "Border", group="Blue Guardian")
bgText = input.color(color.blue, "Name Colour", group="Blue Guardian")
showGFT = input.bool(true, "Show Session", group="GFT")
nameGFT = input.string("GFT", "Session Name", group="GFT")
gftFill = input.color(color.new(color.purple, 85), "Background", group="GFT")
gftBorder = input.color(color.purple, "Border", group="GFT")
gftText = input.color(color.purple, "Name Colour", group="GFT")
showFIN = input.bool(true, "Show Session", group="Finotive")
nameFIN = input.string("FINOTIVE", "Session Name", group="Finotive")
finFill = input.color(color.new(color.orange, 85), "Background", group="Finotive")
finBorder = input.color(color.orange, "Border", group="Finotive")
finText = input.color(color.orange, "Name Colour", group="Finotive")
showBEM = input.bool(true, "Show Session", group="BEM")
nameBEM = input.string("BEM", "Session Name", group="BEM")
bemFill = input.color(color.new(color.green, 85), "Background", group="BEM")
bemBorder = input.color(color.green, "Border", group="BEM")
bemText = input.color(color.green, "Name Colour", group="BEM")
showALPHA = input.bool(true, "Show Session", group="Alpha")
nameALPHA = input.string("ALPHA", "Session Name", group="Alpha")
alphaFill = input.color(color.new(color.red, 85), "Background", group="Alpha")
alphaBorder = input.color(color.red, "Border", group="Alpha")
alphaText = input.color(color.red, "Name Colour", group="Alpha")
showFW = input.bool(true, "Show Session", group="Funded Way")
nameFW = input.string("FUNDED WAY", "Session Name", group="Funded Way")
fwFill = input.color(color.new(color.yellow, 85), "Background", group="Funded Way")
fwBorder = input.color(color.yellow, "Border", group="Funded Way")
fwText = input.color(color.yellow, "Name Colour", group="Funded Way")
// SESSION FUNCTION
drawSession(enabled, startHour, endHour, sessionName, fillColor, borderColor, textColor) =>
var box sessionBox = na
var label sessionLabel = na
startTime = timestamp(tz, year(time, tz), month(time, tz), dayofmonth(time, tz), startHour, 0)
endTime = timestamp(tz, year(time, tz), month(time, tz), dayofmonth(time, tz), endHour, 0)
inSession = time >= startTime and time < endTime
newSession = inSession and not inSession[1]
if enabled and newSession
sessionBox := box.new(left=startTime, top=high, right=time_close, bottom=low, xloc=xloc.bar_time, bgcolor=fillColor, border_color=borderColor, border_width=borderWidth, border_style=getBorderStyle())
sessionLabel := label.new(x=startTime, y=low, text=sessionName, xloc=xloc.bar_time, yloc=yloc.price, style=label.style_label_upper_left, color=color.new(color.black, 100), textcolor=textColor, size=getLabelSize())
if enabled and inSession and not na(sessionBox)
box.set_right(sessionBox, time_close)
box.set_top(sessionBox, math.max(box.get_top(sessionBox), high))
box.set_bottom(sessionBox, math.min(box.get_bottom(sessionBox), low))
label.set_y(sessionLabel, box.get_bottom(sessionBox))
label.set_text(sessionLabel, sessionName)
label.set_textcolor(sessionLabel, textColor)
label.set_size(sessionLabel, getLabelSize())
// DRAW SESSIONS (IST)
drawSession(showBG, 8, 9, nameBG, bgFill, bgBorder, bgText)
drawSession(showGFT, 10, 11, nameGFT, gftFill, gftBorder, gftText)
drawSession(showFIN, 13, 14, nameFIN, finFill, finBorder, finText)
drawSession(showBEM, 15, 16, nameBEM, bemFill, bemBorder, bemText)
drawSession(showALPHA, 18, 19, nameALPHA, alphaFill, alphaBorder, alphaText)
drawSession(showFW, 19, 20, nameFW, fwFill, fwBorder, fwText)