RV- Opening Range Breakout (ORB) V1.1

rupatil · study · 46 行 · 点赞 322 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=5
indicator(title='Day First Candle Breakout', shorttitle='R-DFCB V1.5', overlay=true)
 
// User Inputs
timeframe_option = input.string('15', title='Select Day First Candle (in minutes)', options=['5', '15', '60'])
[dayLow, dayHigh] = request.security(syminfo.tickerid, "D", [low, high])
[WLow, WHigh] = request.security(syminfo.tickerid, "W", [low, high])
 
// Convert string option to integer
selected_timeframe = timeframe_option == '5' ? 5 : timeframe_option == '15' ? 15 : 60
 
// Other Inputs
UpORB = input(true, title='Show Opening Range High')
DownORB = input(true, title='Show Opening Range Low')
 
// Helper Functions
is_newbar(res) =>
    ta.change(time(res)) != 0
adopt(r, s) =>
    request.security(syminfo.tickerid, r, s)
 
// Variables
high_range = ta.valuewhen(is_newbar('D'), high, 0)
low_range = ta.valuewhen(is_newbar('D'), low, 0)
 
FH = UpORB ? adopt(str.tostring(selected_timeframe), high_range) : na
FL = DownORB ? adopt(str.tostring(selected_timeframe), low_range) : na
 
// Plotting
FHP = plot(FH, color=color.rgb(76, 175, 80), style=plot.style_circles, display=display.none, title="First Bar High")
FLP = plot(FL, color=color.red, style=plot.style_circles, display=display.none, title="First Bar Low")
 
// Fill Day's Range
fill(FHP, FLP, color=color.new(#aacfff, 70), title="First Bar H-L Fill")
 
pdh = plot(dayHigh, display=display.none, color=color.green, title="Day's High")
pdl = plot(dayLow, display=display.none, color=color.red, title="Day's Low")
 
// Fill Day's Range
fill(pdh, pdl, color=color.new(#fca0a0, 70), title="Day H-L Fill")
 
pwh = plot(WHigh, display=display.none, color=color.green, title="Week High")
pwl = plot(WLow, display=display.none,color=color.red, title="Week Low")
 
// Fill Day's Range
fill(pwh, pwl, color=color.new(#96faab, 70), title="Day H-L Fill")

← 返回列表