该策略通过分析海因-阿契蜡烛的颜色变化,判断市场趋势,实现自动买入卖出。当蜡烛颜色从红变绿时发出买入信号,当蜡烛颜色从绿变红时发出卖出信号,属于趋势跟踪策略。
首先计算海银-阿契蜡烛的开盘价、收盘价、最高价、最低价。蜡烛的颜色根据收盘价和开盘价判断,如果收盘价大于开盘价则为绿色,否则为红色。当本根K线的收盘价大于开盘价,且上一根K线的收盘价小于等于上一根K线的开盘价时,产生买入信号。当本根K线的收盘价小于等于开盘价,且上一根K线的收盘价大于上一根K线的开盘价时,产生卖出信号。
这样通过海银-阿契蜡烛颜色的变化判断趋势,当颜色从红变绿时进入多头市场,从绿变红时进入空头市场,以捕捉市场趋势的变化。
解决方法:
海银-阿契蜡烛颜色变化策略通过分析蜡烛颜色的变化判断趋势,在红变绿时做多,绿变红时做空,属于较为简单的趋势跟踪策略。该策略优势是识别趋势变化点的能力较强,但入场时机存在滞后,需要进一步优化,在策略框架合理的情况下,参数优化和严格的风险控制是该策略成功的关键。总体来说,该策略思路清晰易操作,值得进一步研究与应用。
/*backtest start: 2022-10-08 00:00:00 end: 2023-10-08 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 strategy("Kozlod - Heikin-Ashi Bar Color Change Strategy", overlay = true) // // author: Kozlod // date: 2018-09-03 // https://www.tradingview.com/u/Kozlod/ // // Calculation HA Values haopen = 0.0 haclose = ((open + high + low + close)/4) haopen := na(haopen[1]) ? (open + close)/2 : (haopen[1] + haclose[1]) / 2 hahigh = max(high, max(haopen, haclose)) halow = min(low, min(haopen, haclose)) // HA colors hacolor = haclose > haopen ? green : red // Signals turnGreen = haclose > haopen and haclose[1] <= haopen[1] turnRed = haclose <= haopen and haclose[1] > haopen[1] // Plotting bgcolor(hacolor) plotshape(turnGreen, style = shape.arrowup, location = location.belowbar, color = green) plotshape(turnRed, style = shape.arrowdown, location = location.abovebar, color = red) // Alerts strategy.entry("long", true, when = turnGreen) strategy.entry("short", false, when = turnRed)