多时框随机震荡指标策略与趋势确认交易系统

STOCH MTF HH/LL SL/TP KDJ
创建日期: 2025-02-19 10:53:25 最后修改: 2025-02-19 10:53:25
复制: 1 点击次数: 78
1
关注
1196
关注者

多时框随机震荡指标策略与趋势确认交易系统

概述

该策略是一个基于多时框随机震荡指标(Stochastic)的交易系统,结合了趋势确认和价格形态分析。策略使用15分钟、30分钟和60分钟三个时间周期,通过随机指标的交叉信号以及更高高点(Higher High)和更低低点(Lower Low)的形态确认来识别交易机会。同时,策略采用了固定百分比的止损和获利设置,以控制风险和锁定利润。

策略原理

策略的核心逻辑包括以下几个关键部分: 1. 使用三个不同时间周期(15分钟、30分钟、60分钟)的随机指标来分析市场动向 2. 在主要时间周期(15分钟)上,当K线突破D线且处于超卖区域时,结合更高低点形态确认买入信号 3. 同样,当K线跌破D线且处于超买区域时,结合更低高点形态确认卖出信号 4. 采用3.7%的止损和1.8%的获利目标来管理每笔交易的风险和收益

策略优势

  1. 多时间周期分析提供了更全面的市场视角,能够更好地过滤假信号
  2. 结合价格形态分析增加了交易信号的可靠性
  3. 固定的风险管理参数使得交易结果更加稳定可控
  4. 策略适用于波动性较大的市场环境
  5. 自动化的进出场信号降低了主观判断带来的情绪影响

策略风险

  1. 在震荡市场中可能产生频繁的假信号
  2. 固定的止损和获利设置可能不适合所有市场环境
  3. 多时间周期的信号可能产生滞后
  4. 在快速趋势市场中,止盈设置可能过早锁定利润
  5. 需要较大的资金管理以承受3.7%的止损幅度

策略优化方向

  1. 可以考虑根据市场波动率动态调整止损和获利目标
  2. 增加成交量指标作为辅助确认信号
  3. 引入趋势强度指标来改善震荡市场中的表现
  4. 优化多时间周期之间的权重设置
  5. 考虑加入市场情绪指标来提高信号的准确性

总结

这是一个结合了多时间周期分析和趋势确认的完整交易系统。通过随机指标和价格形态的配合使用,能够较好地捕捉市场的转折点。固定的风险管理参数虽然简单,但保证了交易的一致性。该策略适合波动性较大的市场,但仍需要交易者根据具体市场环境进行参数优化。

策略源码
/*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)
相关推荐
更多内容