하이킨-아시 매매 전략

저자:차오장, 날짜: 2023-10-07 15:01:06
태그:

전반적인 설명

이 전략은 단일 지표 - 평형 하이킨-아시 (Smoothed Heikin-Ashi) 를 기반으로 구매 및 판매 작업을 따르는 간단한 트렌드를 구현합니다. 평형 하이킨-아시 지표를 통해 트렌드 방향을 식별하고 수익 출구를 위해 역사적인 촛불 패턴과 결합한 입시 시기를 결정합니다.

전략 논리

이 전략은 평탄한 하이킨아시를 만들기 위해 오픈, 하위, 하위 및 폐쇄 가격의 이동 평균을 계산합니다.

구매 조건: 현재 바르은 닫습니다 > 이전 바르은 닫습니다, 이전 바르은 닫습니다 > 2 바르 전에 바르은 닫습니다, 최근 3 바르는 상승합니다.

판매 조건: 현재 바가 닫히고 < 이전 바가 닫히고, 이전 바가 닫히고 < 2바 전에 닫히고, 최근 3바가 하락하고 있습니다.

구매 및 판매 조건 모두 마지막 신호가 0 또는 반대 신호가 되어야 합니다. 같은 방향의 연속 거래를 피하기 위해서입니다.

이점 분석

  • 단일 지표로 간단한 논리
  • 하이킨-아시의 추종 능력을 활용하라
  • 트렌드를 놓치거나 촛불 패턴을 통해 역으로 거래하는 것을 피하십시오.
  • 중복 신호를 필터링하여 불필요한 거래를 줄이십시오.

위험 분석

  • 하이킨-아시가 뒤쳐지는 효과, 트렌드 전환점을 놓칠 수 있습니다.
  • 최신 3 바만 고려, 장기 트렌드 판단 부족
  • 스톱 로스 설정이 없으므로 손실을 증가시킬 위험이 있습니다
  • 시스템적 위험에 취약한 전체 시장 상황을 무시합니다.

장기적인 트렌드에 대한 다른 지표를 결합하고, 스톱 로스 전략을 최적화하고, 전체 시장에 관심을 기울여 개선이 가능합니다.

최적화 방향

  • 장기적 경향을 결정하기 위해 다른 지표를 추가합니다.
  • 트레일링 스톱 또는 퍼센트 기반 스톱 손실과 같은 스톱 손실을 최적화하십시오.
  • 범위를 제한 시장에서 거래를 피하기 위해 전체 시장 지수를 고려
  • 이동 평균 기간과 같은 매개 변수를 최적화
  • 거래량 지원을 보장하기 위한 부피 지표를 추가합니다.

요약

이 전략은 하이킨-아시의 트렌드 추적 능력을 활용하고 출입 시기를 결정하기 위해 촛불 패턴을 결합하며, 중복 신호를 필터링하여 거래 빈도를 제어합니다. 논리는 간단하고 구현하기가 쉽습니다. 그러나 여러 지표 조합을 사용하여 더 견고하게 향상시킬 수 있습니다.


/*backtest
start: 2022-09-30 00:00:00
end: 2023-10-06 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Masoud Abdoli
//Heikin Ashi Smoothed Buy & Sell Strategy Rev.4
//Date: 01-Oct-2021
//@version=4

strategy(title="Abdoli's Heikin Ashi Smoothed Buy & Sell Strategy Rev.4", shorttitle="Heikin-Ashi Smoothed Rev.4", overlay=true,
 initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

MaPeriod = input (title="Moving Average Period?", type=input.integer, defval=65, minval=5, maxval=100, step=5)

maOpen  = ema(open , MaPeriod)
maHigh  = ema(high , MaPeriod)
maLow   = ema(low  , MaPeriod)
maClose = ema(close, MaPeriod)

haClose = (maOpen+maHigh+maLow+maClose)/4
haOpen = 0.0
haOpen:= na(haOpen[1]) ? (maOpen[1]+maClose[1])/2 : (haOpen[1]+haClose[1])/2
haHigh = max(maHigh, max(haClose, haOpen))
haLow  = min(maLow , max(haClose, haOpen))

plotcandle(haOpen, haHigh, haLow, haClose, title="heikin-Ashi smoothed", color=haOpen>haClose ? color.orange : color.blue)

B0 = haClose    - haOpen
B1 = haClose[1] - haOpen[1]
B2 = haClose[2] - haOpen[2]
BuyCondition = B0 > 0.0 and B1 > 0.0 and B2 > 0.0 and haClose > haClose[1] and haClose[1] > haClose[2]
SellCondition= B0 < 0.0 and B1 < 0.0 and B2 < 0.0 and haClose < haClose[1] and haClose[1] < haClose[2]

last_signal = 0
Buy_final  = BuyCondition  and (nz(last_signal[1]) == 0 or nz(last_signal[1]) ==-1)
Sell_final = SellCondition and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 1)
last_signal := Buy_final ? 1 : Sell_final ? -1 : last_signal[1]

plotshape(Buy_final , style=shape.labelup  , location=location.belowbar, color=color.blue, title="Buy label" , text="BUY" , textcolor=color.white)
plotshape(Sell_final, style=shape.labeldown, location=location.abovebar, color=color.red , title="Sell label", text="SELL", textcolor=color.white)

strategy.entry("Buy", strategy.long, when=Buy_final)
strategy.close("Buy", when=Sell_final)

더 많은