该策略是一个基于多时框随机震荡指标(Stochastic)的交易系统,结合了趋势确认和价格形态分析。策略使用15分钟、30分钟和60分钟三个时间周期,通过随机指标的交叉信号以及更高高点(Higher High)和更低低点(Lower Low)的形态确认来识别交易机会。同时,策略采用了固定百分比的止损和获利设置,以控制风险和锁定利润。
策略的核心逻辑包括以下几个关键部分: 1. 使用三个不同时间周期(15分钟、30分钟、60分钟)的随机指标来分析市场动向 2. 在主要时间周期(15分钟)上,当K线突破D线且处于超卖区域时,结合更高低点形态确认买入信号 3. 同样,当K线跌破D线且处于超买区域时,结合更低高点形态确认卖出信号 4. 采用3.7%的止损和1.8%的获利目标来管理每笔交易的风险和收益
这是一个结合了多时间周期分析和趋势确认的完整交易系统。通过随机指标和价格形态的配合使用,能够较好地捕捉市场的转折点。固定的风险管理参数虽然简单,但保证了交易的一致性。该策略适合波动性较大的市场,但仍需要交易者根据具体市场环境进行参数优化。
/*backtest
start: 2025-01-19 00:00:00
end: 2025-02-18 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Swing Fairas Oil", overlay=true)
// Pilih Timeframe Utama & 2 Timeframe Konfirmasi
tf_main = "15"
tf_mid = "30"
tf_high = "60"
// Parameter Stochastic
length = input(15, title="Stochastic Length")
k_smooth = input(4, title="K Smoothing")
d_smooth = input(5, title="D Smoothing")
// Overbought & Oversold Levels
overbought = input(85, title="Overbought Level")
oversold = input(15, title="Oversold Level")
// Stochastic pada Timeframe Utama
k1 = ta.sma(ta.stoch(close, high, low, length), k_smooth)
d1 = ta.sma(k1, d_smooth)
// Stochastic pada Timeframe Menengah
k2 = request.security(syminfo.tickerid, tf_mid, ta.sma(ta.stoch(close, high, low, length), k_smooth))
d2 = request.security(syminfo.tickerid, tf_mid, ta.sma(k2, d_smooth))
// Stochastic pada Timeframe Tinggi
k3 = request.security(syminfo.tickerid, tf_high, ta.sma(ta.stoch(close, high, low, length), k_smooth))
d3 = request.security(syminfo.tickerid, tf_high, ta.sma(k3, d_smooth))
// **Konfirmasi Higher High & Lower Low**
hh = ta.highest(high, 5) // Highest High dalam 5 candle terakhir
ll = ta.lowest(low, 5) // Lowest Low dalam 5 candle terakhir
// **Kondisi Buy**
confirm_buy = ta.crossover(k1, d1) and k1 < oversold // Stochastic Bullish
higher_low = low > ta.lowest(low[1], 5) // Higher Low terbentuk
longCondition = confirm_buy and higher_low
// **Kondisi Sell**
confirm_sell = ta.crossunder(k1, d1) and k1 > overbought // Stochastic Bearish
lower_high = high < ta.highest(high[1], 5) // Lower High terbentuk
shortCondition = confirm_sell and lower_high
// Stop Loss & Take Profit
sl = input(3.7, title="Stop Loss (%)") / 100
tp = input(1.8, title="Take Profit (%)") / 100
longStopLoss = close * (1 - sl)
longTakeProfit = close * (1 + tp)
shortStopLoss = close * (1 + sl)
shortTakeProfit = close * (1 - tp)
// Eksekusi Order
if longCondition
strategy.entry("Buy", strategy.long)
strategy.exit("Sell TP/SL", from_entry="Buy", stop=longStopLoss, limit=longTakeProfit)
if shortCondition
strategy.entry("Sell", strategy.short)
strategy.exit("Cover TP/SL", from_entry="Sell", stop=shortStopLoss, limit=shortTakeProfit)
// Label Buy & Sell
if longCondition
label.new(bar_index, low, "BUY", color=color.green, textcolor=color.white, size=size.small, style=label.style_label_down)
if shortCondition
label.new(bar_index, high, "SELL", color=color.red, textcolor=color.white, size=size.small, style=label.style_label_up)
// Label Stop Loss & Take Profit
if longCondition
label.new(bar_index, longStopLoss, "SL: " + str.tostring(longStopLoss, "#.##"), color=color.red, textcolor=color.white, size=size.small, style=label.style_label_left)
label.new(bar_index, longTakeProfit, "TP: " + str.tostring(longTakeProfit, "#.##"), color=color.green, textcolor=color.white, size=size.small, style=label.style_label_left)
if shortCondition
label.new(bar_index, shortStopLoss, "SL: " + str.tostring(shortStopLoss, "#.##"), color=color.red, textcolor=color.white, size=size.small, style=label.style_label_left)
label.new(bar_index, shortTakeProfit, "TP: " + str.tostring(shortTakeProfit, "#.##"), color=color.green, textcolor=color.white, size=size.small, style=label.style_label_left)