大涨大跌策略是一种通过检测巨额阳线阴线来进行入场的策略。当检测到一个巨量的阳线时做空,检测到一个巨量的阴线时做多。止损位于触发信号的柱线低点(做多则反之),止盈为止损的1倍。用户可以定义阳线阴线的最小体积,以及相对于之前某段时间的平均柱体积的倍数。
该策略的核心逻辑是:
计算当前K线的总波动范围(高点-低点)和实体的大小(收盘价比开盘价大则为正,反之为负)
计算过去N根K线内波动幅度的平均值
判断当前K线是否满足:波动范围>=平均波动幅度x倍数 且 实体大小>=波动范围x最小实体系数
满足上述条件即触发信号:阳线做空,阴线做多
可选择是否开启止损止盈:止损为信号柱低点加上止损系数倍的波动幅度;止盈为止损的1倍
在实体判断上过滤了线段,确保有足够的力量;通过动态计算平均波动幅度,避免固定阈值无法适应市场变化;止损止盈设置合理回撤率,可通过系数调整。
该策略最大的优势在于捕捉了高质量的趋势反转信号,这主要基于两个判断:
巨量阳线阴线表示该趋势前期已经表现强劲,所以大概率是整个趋势的结构性转折点
通过动态计算平均波动幅度,确保捕捉到超出正常水平的异常波动,从而过滤普通回调行情
此外,止损止盈设置也非常合理,可以有效控制单笔止损,同时止盈回报率为1,不会过于追涨杀跌。
总体来说,该策略成功定位了高质量结构性转折点,实现高效率操作。这对于趋势跟踪交易者非常适合,可以避免在中间过程被套住。
该策略的主要风险来自两个方面:
大涨大跌可能是止损猝发,从而形成了无效信号
止损设置过于宽松,无法有效控制损失
针对第一个风险,可以通过增加最小波动幅度和实体大小来过滤误判率,但是也会错过一些机会。需要根据回测结果找到平衡点。
第二个风险可以通过调整止损系数来优化,使止损更接近支持位,但不能过于紧密。同时也要考虑加大止盈回报率,以补偿止损带来的损失。
该策略还有以下几点可以进一步优化:
增加对趋势方向的判断,避免逆势操作
优化参数设置,找到最佳的参数组合
增加成交量的过滤,确保大阳线大阴线成交量足够高
考虑加入更多过滤条件,例如平台,布林带等,减少误判概率
测试不同品种参数效果,进行参数优化
增加止损追踪,让止损可以根据价位走势进行动态调整
考虑加入重新入场机会,即在首次止损后再次入场
通过以上几点优化,可以使该策略更具有效性,从而真正提高盈利概率。需要充分回测和优化找到最佳参数。
大涨大跌策略通过捕捉巨量阳线阴线来实现高效盈利,具有止损止盈设置。它成功定位了高质量的结构性反转机会,可以为趋势交易者提供非常有价值的信息。通过参数优化和规则优化,该策略可以成为一个非常实用的辅助决策工具。它简单的交易逻辑和直接的经济含义,也让它容易被人理解和掌握。总体来说,该策略为我们提供了一个非常好的策略框架,值得深入研究和应用。
/*backtest
start: 2023-10-06 00:00:00
end: 2023-11-05 00:00:00
period: 1h
basePeriod: 15m
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/
// © tweakerID
// This strategy detects and uses big bars to enter a position. When the Big Bar
// is bearish (red candle) the position will be long and viceversa
// for short positions. The stop loss (optional) is placed on the low of the
// candle used to trigger the position and user inputs allow you to modify the
// size of the SL. Take profit is placed on a reward ratio of 1. User can also modify
// the size of the bar body used to determine if we have a real Big Bar and
// filter out Doji bars. Big Bars are determined relative to the previous X period size,
// which can also be modified, as well as the required size of the Big Bar relative to this period average.
//@version=4
strategy("Big Bar Strategy", overlay=false)
direction = input(0, title = "Direction (Long=1, Both=0, Short=-1 ", type=input.integer, minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))
//Inputs
barsizemult=input(1, step=.1, title="SL Mult")
TPbarsizemult=input(1, step=.1, title="TP Mult")
barsizeThreshold=input(.5, step=.1, minval=.5, maxval=.9, title="Bar Body Size")
period=input(10)
mult=input(2, step=.2, title="Big Size Avg Mult to determine Big Bar")
i_reverse=input(false, title="Reverse Trades")
SLon=input(false, title="Use SL / TP")
//Calculations
barsize=high-low
barbodysize=close>open?(open-close)*-1:(open-close)
barsizeavg=sum(barsize, period)/period
bigbar=barsize >= barsizeavg*mult and barbodysize>barsize*barsizeThreshold
//Entry Logic
longCondition = close < open and bigbar //and strategy.position_size==0
shortCondition = close > open and bigbar //and strategy.position_size==0
//SL & TP Calculations
longTP=strategy.position_avg_price + (valuewhen(longCondition,barsize,0)*TPbarsizemult)
longSL=strategy.position_avg_price - (valuewhen(longCondition,barsize,0)*barsizemult)
shortTP=strategy.position_avg_price - (valuewhen(shortCondition,barsize,0)*TPbarsizemult)
shortSL=strategy.position_avg_price + (valuewhen(shortCondition,barsize,0)*barsizemult)
TP=strategy.position_size>0?longTP:shortTP
SL=strategy.position_size>0?longSL:shortSL
//Entries
if (longCondition)
strategy.entry("long", long=not i_reverse?true:false)
alert("Big Bar")
if (shortCondition)
strategy.entry("short", long=not i_reverse?false:true)
alert("Big Bar")
if SLon
strategy.exit("SL & TP", "long", stop=SL, limit=TP)
strategy.exit("SL & TP", "short", stop=SL, limit=TP)
// Plots
barcolor(bigbar ? color.white : na)
plot(barsizeavg, transp=100, title="Barsize Avg")
plot(barsize, transp=100, title="Bar Size")
plot(barbodysize, transp=100, title="Bar Body Size")
plot(SLon?TP:na, color=color.green, style=plot.style_cross, title="TP")
plot(SLon?SL:na, color=color.red, style=plot.style_cross, title="SL")
plotshape(longCondition ? 1 : na, style=shape.triangleup, location=location.belowbar, color=color.green, title="Bullish Setup")
plotshape(shortCondition ? 1 : na, style=shape.triangledown, location=location.abovebar, color=color.red, title="Bearish Setup")