강세 망치 거래 전략


생성 날짜: 2023-09-18 15:30:15 마지막으로 수정됨: 2023-09-18 15:48:15
복사: 0 클릭수: 680
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

이 전략은 K선 다중 머리 형 선 신호를 식별하여 MACD 지표와 결합하여 트렌드 방향을 판단하여 주식 가격의 추적 거래를 구현한다. 황소 시장에서 다중 머리 형 선 형태가 나타나고 MACD 배경에 다중 머리 상태일 때 더 많은 입력을 한다. MACD가 공백으로 바뀌면 평점 상태에서 퇴출한다.

전략 원칙

실물 라인 부분 크기의 비율을 계산하고, 다중 헤드 형 라인을 결정한다. MACD 지표를 계산하여 트렌드 방향을 판단한다. MACD가 다중 헤드일 때, 다중 헤드 형 라인 신호가 발생하면, 더 많은 입장을 한다.

우위 분석

  • 다중 머리 모양 선의 식별은 간단하고 명확하다.
  • MACD는 공백 트렌드 전환을 효과적으로 판단합니다.
  • 트렌드에 따라 움직여서 함정을 피하십시오.
  • 전략적 논리는 간단하고 직설적이며 실행하기 쉽습니다.

위험 분석

  • 형상 인식이 정확하지 않아 신호를 놓치고 있습니다.
  • MACD는 트렌드 전환이 늦어졌다고 판단했습니다.
  • 낮은 거래 빈도, 높은 거래 빈도에는 적합하지 않습니다.
  • “이런 일이 벌어질 수 있는 이유는 어떤 상황인지 알 수 없기 때문입니다.

적절히 형상 인식 조건을 완화하고 MACD 파라미터를 줄여서 다른 지표를 보조하여 위험을 제어 할 수 있습니다.

최적화 방향

  • 도형선 식별을 최적화하기 위한 매개변수 규칙
  • MACD의 다른 파라미터 설정을 테스트합니다.
  • 다른 지표와 함께 추세 전환을 고려합니다.
  • 다양한 품종에서 테스트 파라미터 강도

요약하다

이 전략은 형태와 지표를 통합하여 트렌드 판단을 통해 안정적인 수익을 달성할 수 있다. 파라미터 조정 등으로 더욱 개선되어 실용적인 정량화 거래 전략이 될 수 있다.

전략 소스 코드
/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 3h
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/
// © FenixCapital

//@version=4
strategy("Starbux", overlay=true)


//VARIABLES

//Candlestick Variables
body=close-open
range=high-low
middle=(open+close)/2
abody=abs(body)
arange=abs(range)
ratio=abody/range
longcandle= (ratio>0.6)
bodytop=max(open, close)
bodybottom=min(open, close)
shadowtop=high-bodytop
shadowbottom=bodybottom-low

//Closing Variables

macd=macd(close,12,26,9)
[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
//plot(macdLine, color=color.blue)
//plot(signalLine, color=color.orange)
//plot(histLine, color=color.red, style=plot.style_histogram)

rsi=rsi(close,14)

sma50= sma(close,50)
sma200= sma(close,200)

exitrsi=rsi > 76
exitmacd=macdLine >0 and signalLine>0
//exitmacd=crossunder(macdLine,signalLine)
stopprice= crossunder(sma50,sma200)

//Candlestick Plotting
blh = (arange*0.33>=abody and close>open and shadowbottom>=abody*2 and shadowtop<=arange*0.1)
plotshape(blh, title= "Bullish Hammer", location=location.belowbar, color=color.lime, style=shape.arrowup, text="Bull\nHammer")

//beh = (arange*0.25>=abody and close<open and shadowtop>=abody*2 and shadowbottom<=arange*0.05)
//plotshape(beh, title= "Bearish Hammer", color=color.orange, style=shape.arrowdown, text="Bear\nHammer")

//bpu = (open>close and close>low and shadowbottom>2*abody)
//plotshape(bpu, title= "Black Paper Umbrella", color=color.red, style=shape.arrowdown, text="Black\nPaper\nUmbrella")

//Trend Signal
bull5= sma50 > sma200
bullmacd=macdLine>=0 and signalLine>=0
bearmacd=macdLine<= 0 and signalLine<=0

//Trading Algorithm
longCondition = blh and bearmacd and volume>volume[1]

if (longCondition)
    strategy.order("Buy", true, 1, when=longCondition)
strategy.risk.max_position_size(10)
//strategy.risk.max_drawdown(25,strategy.percent_of_equity)

exitlong = exitmacd
if (exitlong)
    strategy.close_all()