Opening Range Breakout Lines

tretgothacks · study · 37 行 · 点赞 1,855 · TradingView 原页

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

Pine Script

//@version=3
study(title='Opening Range Breakout Lines', shorttitle='Opening Range Breakout Lines', overlay=true)
 
// Based on "[STRATEGY][RS]Open Session Breakout Trader" by RicardoSantos Published Jul 10, 2017
// All credit for the base coding of this script goes to Ricardo
// His script can be viewed at https://www.tradingview.com/script/mIvVYU42-STRATEGY-RS-Open-Session-Breakout-Trader/
 
use_trade_session = true
trade_session = input(title='Trade Session(xxxx-xxxx to define a interval):', type=session, defval='1800-1600', confirm=false)
isinsession = use_trade_session ? not na(time('1', trade_session)) : true
 
percent_range_multiplier = input(0.15)
r = security(tickerid, 'D', atr(100)[1])
open_price = open
open_price := change(use_trade_session and isinsession ? 1 : 0) > 0 ? open : open_price[1]
buy_line = open_price + r * percent_range_multiplier
sel_line = open_price - r * percent_range_multiplier
plot(series=not isinsession ? na : open_price, title='Session Open Price', color=black, linewidth=4, style=linebr, transp=0)
plot(series=not isinsession ? na : buy_line, title='Buy Line', color=green, linewidth=4, style=linebr, transp=0)
plot(series=not isinsession ? na : sel_line, title='Sell Line', color=maroon, linewidth=4, style=linebr, transp=0)
 
//  Conditions to buy/sell on the first bar, since cross's arent detected.
buy_on_1st_bar = change(open_price) != 0 and high > buy_line
sel_on_1st_bar = change(open_price) != 0 and low < sel_line
 
buy_trigger = crossover(close, buy_line) and isinsession
sel_trigger = crossunder(close, sel_line) and isinsession
 
plotshape(buy_trigger, style=shape.labelup, color=green, location=location.belowbar, textcolor=white, text="Buy", title="Buy")
plotshape(sel_trigger, style=shape.labeldown, color=red, location=location.abovebar, textcolor=white, text="Sell", title="Sell")
 
plotarrow(sel_trigger?-1:na, title="SELL Arrow", colordown=red, maxheight=100, minheight=50, transp=20)
plotarrow(buy_trigger?1:na, title="BUY Arrow", colordown=green, maxheight=100, minheight=50, transp=20)
 
 
alertcondition(buy_trigger, title="Buy Alert", message="Possible Buy")
alertcondition(sel_trigger, title="Sell Alert", message="Possible Sell")

← 返回列表