
本策略名为“低波动定向买入止盈止损策略”。它利用移动平均线的交叉作为买入信号,结合止盈止损来锁定盈利,适用于低波动区间的币种。
该策略使用3条不同周期的移动平均线:50周期、100周期和200周期。其买入逻辑是:当50周期线上穿100周期线,并且100周期线上穿200周期线时,做多入场。
该信号表示市场正在从低波动区间突破,开始进入趋势状态。50周期快速上涨代表短期内部力量突然增强,开始带动中长线向上;100周期线也开始向上表示中期力量加入,稳定趋势上行。
入场后,策略采用止盈止损方式锁定利润。止盈目标为入场价的8%,止损线为入场价的4%。设置止盈大于止损,有利于获利超过亏损,确保策略整体盈利性。
该策略具有以下优势:
该策略也存在一些风险:
对策:
该策略可从以下方面进行优化:
1.测试不同移动平均线周期参数,找到最佳组合。 2.加入成交量等指标来确认趋势突破。 3.动态调整止盈止损幅度。 4.结合机器学习等手段来预测突破成功率。 5.针对不同市场条件和币种进行参数调整。
综上所述,该策略整体运行逻辑清晰,通过配置移动平均线周期及止盈止损幅度来获得低风险收益,可灵活应用于量化交易。后续可从入场信号、止损方式等方面进行优化,配合参数调整寻找最佳效果。
/*backtest
start: 2023-12-10 00:00:00
end: 2023-12-17 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy(shorttitle='Low volatility Buy w/ TP & SL (by Coinrule)',title='Low volatility Buy w/ TP & SL', overlay=true, initial_capital = 1000, process_orders_on_close=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
//Backtest dates
fromMonth = input(defval = 1, title = "From Month", type = input.integer, minval = 1, maxval = 12)
fromDay = input(defval = 10, title = "From Day", type = input.integer, minval = 1, maxval = 31)
fromYear = input(defval = 2019, title = "From Year", type = input.integer, minval = 1970)
thruMonth = input(defval = 1, title = "Thru Month", type = input.integer, minval = 1, maxval = 12)
thruDay = input(defval = 1, title = "Thru Day", type = input.integer, minval = 1, maxval = 31)
thruYear = input(defval = 2112, title = "Thru Year", type = input.integer, minval = 1970)
showDate = input(defval = true, title = "Show Date Range", type = input.bool)
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function "within window of time"
//MA inputs and calculations
movingaverage_fast = sma(close, input(50))
movingaverage_slow = sma(close, input(200))
movingaverage_normal= sma(close, input(100))
//Entry
strategy.entry(id="long", long = true, when = movingaverage_slow > movingaverage_normal and movingaverage_fast > movingaverage_normal)
//Exit
longStopPrice = strategy.position_avg_price * (1 - 0.04)
longTakeProfit = strategy.position_avg_price * (1 + 0.08)
strategy.close("long", when = close < longStopPrice or close > longTakeProfit and window())
//PLOT
plot(movingaverage_fast, color=color.orange, linewidth=2)
plot(movingaverage_slow, color=color.purple, linewidth=3)
plot(movingaverage_normal, color=color.blue, linewidth=2)