200 EMA에서 거리를 기반으로 전략에 따라 월넛 트렌드

저자:차오장, 날짜: 2024-03-01 10:50:03
태그:

수익 목표에 도달합니다.

단축 출구:마감 <= 200 EMA는 하루 끝으로 수익 목표에 도달합니다.

스톱 로스는 옵션 프리미엄의 20%입니다.

II. 장점

이 전략의 주요 장점은 다음과 같습니다.

  1. 중장기 동향을 결정하기 위해 200일 이동평균을 사용하여 단기 시장 소음을 피합니다.
  2. 중장기 가격 동향을 추적하기 위한 메커니즘에 따라 동향을 설정
  3. 마지막 촛불 방향이 주요 추세와 일치할 때 입시 시기를 최적화
  4. 더 큰 손실을 피하기 위해 합리적인 스톱 로스 및 영업이익

위험성

이 전략의 주요 위험은 다음과 같습니다.

  1. 이동평균을 중심으로 시장 통합 시 여러 손실이 발생할 수 있습니다.
  2. 갑작스러운 트렌드 역전으로 인해 손실을 멈추게 됩니다.
  3. 이동 평균 기간과 같은 부적절한 매개 변수 선택은 추세 판단이 정확하지 않습니다.

다음 측면은 위 위험을 줄이기 위해 최적화 될 수 있습니다.

  1. 이동 평균 매개 변수를 조정하거나 주요 트렌드를 결정하기 위해 다른 지표를 추가하십시오.
  2. 가격 변화에 따라 중지 거리를 조정하는 것과 같은 중지 손실 메커니즘을 최적화하십시오.
  3. 더 많은 판단 지표로 입시 조건을 최적화

IV. 최적화 방향

이 전략의 주요 최적화 방향은 다음과 같습니다.

  1. 이동 평균 매개 변수를 최적화, 다른 기간 매개 변수의 테스트 영향
  2. 주요 트렌드를 결정하기 위해 볼링거 밴드, KDJ와 같은 다른 지표를 추가하십시오.
  3. 가격 동적으로 추적 중지 손실 전략을 조정
  4. 단기 수정으로 인한 잘못된 항목을 피하기 위해 입력 조건을 최적화합니다.

결론

이 기사에서는 가격과 200일 이동 평균 사이의 거리를 기반으로 트렌드를 따르는 전략의 논리, 강점, 약점 및 최적화 방향을 상세히 분석했습니다. 이 전략은 장기 이동 평균에서 가격 오차를 추적함으로써 중장기 트렌드를 판단합니다. 오차가 한 임계치를 초과하고 스톱 로스 또는 영업 목표를 달성 할 때 포지션을 설정하고 닫습니다. 이 전략은 중장기 트렌드를 잘 추적 할 수 있지만 여전히 몇 가지 매개 변수 최적화 공간을 가지고 있습니다. 미래 개선은 다양한 관점에서 수행하여 다른 시장 조건에서 전략을 더 견고하게 할 수 있습니다.


/*backtest
start: 2024-02-22 00:00:00
end: 2024-02-24 06:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Intraday Price Away from 200 EMA Strategy", overlay=true)

// Define inputs
emaPeriod = input(200, title="EMA Period")
thresholdPercent = input(0.75, title="Threshold Percent", minval=0)  // Define the threshold percentage

// Calculate 200 EMA
ema = ema(close, emaPeriod)

// Calculate distance from 200 EMA as a percentage
distance_percent = ((close - ema) / ema) * 100

// Track average entry price
var float avgEntryPrice = na

// Buy conditions
buy_condition = close < ema and abs(distance_percent) >= thresholdPercent and close[1] < close[2]

// Exit conditions for buy
exit_buy_condition = close >= ema or time_close(timeframe.period) or (avgEntryPrice * 1.5) <= close

// Sell conditions
sell_condition = close > ema and abs(distance_percent) >= thresholdPercent and close[1] > close[2]

// Exit conditions for sell
exit_sell_condition = close <= ema or time_close(timeframe.period) or (avgEntryPrice * 1.5) >= close

// Execute buy and sell orders only if there are no open trades
if strategy.opentrades == 0
    strategy.entry("Buy", strategy.long, when=buy_condition)
    strategy.entry("Sell", strategy.short, when=sell_condition)

// Update average entry price for buy condition
if buy_condition
    avgEntryPrice := close

// Update average entry price for sell condition
if sell_condition
    avgEntryPrice := close

// Close buy position if exit condition is met
strategy.close("Buy", when=exit_buy_condition)

// Close sell position if exit condition is met
strategy.close("Sell", when=exit_sell_condition)

// Plot 200 EMA
plot(ema, color=color.blue, linewidth=2)

// Plot buy and sell signals
plotshape(buy_condition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(sell_condition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)


더 많은