该策略是基于海鸥指标的加密货币趋势追踪策略。它使用两个不同周期的指数移动平均线以及海鸥指标结合多种条件来生成交易信号。该策略旨在识别中长线的价格趋势,在趋势发生转折的时候及时入场。
该策略使用50周期和100周期的EMA均线。同时,它计算海鸥线,这是一种能够过滤市场噪音的特殊蜡烛线。策略使用海鸥线的开盘价、收盘价、最高价和最低价并应用到100周期的EMA线上,以发生更准确的交易信号。
具体来说,当100周期海鸥线的开盘价高于收盘价,并且上一根K线的开盘价低于收盘价时,就是做多的信号。相反,当100周期海鸥线的开盘价低于收盘价,并且上一根K线的开盘价高于收盘价时,就是做空的信号。
该策略结合双EMA系统和海鸥指标,旨在在中长线趋势形成的时候及时捕捉机会。它使用海鸥指标来过滤掉短期市场噪音,使得交易信号更加可靠。
为了降低风险,可以适当缩小止损幅度,或考虑结合其他指标判断趋势反转。当市场进入震荡区间时,也可以暂停该策略,等待新的趋势产生。
该策略还可以从以下几个方向进行优化:
基于海鸥指标的加密货币趋势追踪策略,综合考虑了趋势判断、入场时机、止损控制多个方面,对加密货币这种高波动品种具有很好的适应性。该策略通过使用海鸥指标过滤噪音,采用稳健的风险控制方法,能够有效抓住中长线价格趋势带来的交易机会。如果进一步优化参数设置、指标选择和风险控制方法,该策略的表现还具有很大的提升空间。
/*backtest
start: 2023-01-12 00:00:00
end: 2024-01-18 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
//@SoftKill21
strategy(title="CRYPTO HA Strategy", shorttitle="CRYPTO HA Strategy", overlay=true , default_qty_type =strategy.percent_of_equity, default_qty_value =100, commission_type= strategy.commission.percent,commission_value =0.1 )
ma1_len = input(50)
ma2_len = input(100)
fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2020, title = "From Year", minval = 1970)
//monday and session
// To Date Inputs
toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2020, title = "To Year", minval = 1970)
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true
//First Moving Average data
o = ema(open, ma1_len)
c = ema(close, ma1_len)
h = ema(high, ma1_len)
l = ema(low, ma1_len)
// === HA calculator ===
ha_t = heikinashi(syminfo.tickerid)
ha_o = security(ha_t, timeframe.period, o)
ha_c = security(ha_t, timeframe.period, c)
ha_h = security(ha_t, timeframe.period, h)
ha_l = security(ha_t, timeframe.period, l)
//Second Moving Average data
o2 = ema(ha_o, ma2_len)
c2 = ema(ha_c, ma2_len)
h2 = ema(ha_h, ma2_len)
l2 = ema(ha_l, ma2_len)
// === Color def ===
ha_col = o2 > c2 ? color.white : color.lime
sell = o2 > c2 and o2[1] < c2[1] and time_cond
buy = o2 < c2 and o2[1] > c2[1] and time_cond
plotshape(buy, color=color.green, text= "Buy", location= location.belowbar,style= shape.labelup, textcolor=color.white, size = size.tiny, title="Buy Alert",editable=false, transp=60)
plotshape(sell, color=color.red, text= "Sell", location= location.abovebar,style= shape.labeldown, textcolor=color.white, size = size.tiny, title="Sell Alert", editable=false, transp=60)
trendColor = buy ? color.red : sell ? color.green : na
plot( buy ? close: sell ? close : na , color=trendColor, style=plot.style_line, linewidth=4, editable=false)
onlylong=input(true)
original=input(false)
if(onlylong)
strategy.entry("long",1,when=buy)
strategy.close("long",when=sell)
if(original)
strategy.entry("long",1,when=buy)
strategy.entry("short",0,when=sell)
sl = input(0.075)
strategy.exit("closelong", "long" , loss = close * sl / syminfo.mintick, alert_message = "sl point")
strategy.exit("closeshort", "short" , loss = close * sl / syminfo.mintick, alert_message = "sl point")