Mar 11 (edited) in 🔧量化相關
ORB作業
因為直播時間沒有跟上,所以收看回放直播參與XD
首先看到ORB思考了一下,開盤價對上策略的影響,其實在我的主觀交易上來說(日內短線交易),這是非常重要的一部分!
把他擴展置程式交易策略上,趕在教作業之前趕快來回測一下,這個效果真的不錯
以下是程式碼,使用tradingview平台
//@version=5
strategy("Open Range Breakout - Long Strategy with SL, TP, and ATR Entry", overlay=true)
// 設定參數
startHour = input(9, "Start Hour")
startMinute = input(30, "Start Minute")
endHour = input(10, "End Hour")
endMinute = input(30, "End Minute")
stopLossPercent = input(1, title="Stop Loss (%)") / 100
takeProfitPercent = input(2, title="Take Profit (%)") / 100
atrLength = input(14, title="ATR Length")
rangeSize = endHour * 60 + endMinute - startHour * 60 - startMinute
// 計算ATR
atrValue = ta.atr(atrLength)
// 計算開盤範圍
rangeStart = timestamp(year, month, dayofmonth, startHour, startMinute)
rangeEnd = timestamp(year, month, dayofmonth, endHour, endMinute)
isRangeTime = (time >= rangeStart and time <= rangeEnd)
highestRange = request.security(syminfo.tickerid, "D", high[1])
lowestRange = request.security(syminfo.tickerid, "D", low[1])
rangeHigh = ta.highest(highestRange, rangeSize)
rangeLow = ta.lowest(lowestRange, rangeSize)
// 執行做多策略
if (close > rangeHigh + atrValue)
strategy.entry("ORB Long", strategy.long)
strategy.exit("Exit ORB Long", "ORB Long", stop=close * (1 - stopLossPercent), limit=close * (1 + takeProfitPercent))
9
2 comments
Poyen Kuo
3
ORB作業
炒股黑客 (Free)
skool.com/stockhacker
一個價值屌打高價付費課程的免費金融社群🔥
Leaderboard (30-day)
powered by