本策略基于通道突破原理,并利用均线交叉作为退出信号,适用于期货和指数交易。
计算一定周期内的最高价和最低价,构建上下通道。
当价格突破上通道时,做多;当价格突破下通道时,做空。
计算快速期和慢速期两条SMA均线。
做多时,快速期SMA上穿慢速期SMA,平多仓;做空时,快速期SMA下穿慢速期SMA,平空仓。
结合通道和均线系统,可以提高获利概率。
利用通道判断轮动ankel定阶段,利用均线判断趋势结束。
均线过滤可以避免whipsaw,减少不必要交易。
通道范围参数可调,适应不同周期和波动率市场。
通道范围设定不当,可能错过突破机会或产生更多假突破。
均线参数设定不当,可能过早或过晚退出仓位。
需考虑合理仓位规模管理,避免单笔损失过大。
需留意突破后是否有效,防止追高杀跌。
测试不同参数下策略收益率和胜率,优化通道范围和均线周期。
结合趋势指标过滤突破信号,提高突破成功率。
增加仓位管理机制,比如固定份额、马丁格尔等。
增加止损机制来控制单笔损失。
本策略利用通道判断市场轮动和热点,均线判断趋势结束,合理参数设定可以在强势市场实现稳定收益。但需要防止whipsaw可能带来的亏损,同时优化仓位和风险管理非常关键。通过参数调整、信号过滤及风险控制手段的运用,可以进一步增强策略稳定性。
/*backtest
start: 2023-10-01 00:00:00
end: 2023-10-13 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © anshuanshu333
//@version=4
// strategy("ChBrkOutStrategySMA", overlay=true, initial_capital = 200000)
length = input(title="Length", type=input.integer, minval=1, maxval=1000, defval=7)
fastSMA = sma(close,9)
slowSMA = sma(close,21)
upBound = highest(high, length)
downBound = lowest(low, length)
boundLongEntry = ((close >= upBound) or (high >= upBound)) and fastSMA>slowSMA and (close > open)
boundShortEntry =((close <= downBound) or (low <= downBound)) and fastSMA<slowSMA and (close <open)
u=plot(upBound, title = "Upper Bound",color=color.blue, linewidth=1)
l=plot(downBound, title = "Lower Bound",color=color.red, linewidth=1)
plot(fastSMA,title = "Fast SMA", color = color.red, linewidth =2)
plot(slowSMA,title = "Slow SMA" ,color = color.green, linewidth =1)
fill(u,l, transp=95)
plot(avg(upBound,downBound), title = "Avg", color=color.gray,linewidth =1)
if (boundLongEntry )
strategy.entry("LE", long = true)
if (boundShortEntry)
strategy.entry("SE", long = false)
SmaLongExit = crossunder(fastSMA,slowSMA)
SmaShortExit = crossover(fastSMA,slowSMA)
//Close TRades
if (strategy.position_size > 0)
strategy.close(id="LE",when= SmaLongExit)
if (strategy.position_size < 0)
strategy.close(id="SE",when= SmaShortExit)