기하급수적인 이동 평균 반등 전략

저자:차오장, 날짜: 2023-12-08 16:47:39
태그:

img

전략 개요

기하급수적 이동 평균 (EMA) 반등 전략은 이동 평균 라인의 가격 돌파를 추적하는 전략이다. 촛불이 이동 평균 라인의 아래에서 반등하는지 여부를 확인합니다. 그렇다면 상승 신호입니다. 촛불이 이동 평균 라인의 위에서 아래로 반등하면 하락 신호입니다.

전략 이름

기하급수적인 이동 평균 반등 전략

전략 논리

이 전략은 기하급수적인 이동 평균 (EMA) 라인을 기반으로 합니다. 이 전략은 EMA 라인을 실시간으로 계산합니다. 그 다음 가격이 EMA 라인에서 반등하는지 확인합니다.

  • 가격이 EMA 라인을 먼저 뚫고 EMA 라인을 다시 뛰어 넘으면 상승 신호입니다.
  • 가격이 먼저 EMA 라인을 뚫고 EMA 라인 아래로 떨어지면 하향 신호입니다.

이러한 반향은 전략의 시작 신호입니다.

이점 분석

트렌드에 따라 거래하고 함정에 빠지지 않도록

EMA 반등 전략은 가격 반전을 확인한 후에야 시작됩니다. 이는 트렌드 반대 거래와 함정에 빠지는 것을 피합니다.

소액 수요, 좋은 역사적인 수익

기하급수적인 이동 평균을 사용함으로써 전략은 가격 데이터를 효율적으로 부드럽게하고 시장 소음을 필터링하여 작은 마감과 좋은 역사적 수익을 얻을 수 있습니다.

이해하기 쉬운, 유연한 매개 변수 조정

EMA 반등 전략은 단순히 이동 평균에 의존하며 초보자도 쉽게 이해할 수 있습니다. 한편, EMA 기간은 다양한 제품에 적응하도록 유연하게 조정 될 수 있습니다.

위험 분석

잘못된 신호에 취약합니다.

EMA 라인 주위에는 종종 밀도가 높은 가짜 브레이크가 발생하여 잘못된 신호를 일으킬 수 있습니다. EMA 매개 변수를 조정하여 소음을 필터링해야합니다.

트렌드에 따라 거래, 전환점을 예측할 수 없습니다.

이 전략은 본질적으로 추세와 함께 거래합니다. 가격 전환점을 예측할 수 없으며 추세를 따라 할 수 있습니다. 이것은 순환 조정 중에 가장 좋은 진입 기회를 놓칠 수 있습니다.

손해가 발생하기 쉬운 중지 손실

이동 평균 라인 근처의 스톱 로스는 때때로 타격되어 손실이 커집니다. 이것은 더 유연한 스톱 로스 방법을 요구합니다.

최적화

신호 필터링을 위한 다른 지표를 포함합니다.

RSI와 MACD와 같은 지표는 가격 반전을 확인하고 잘못된 신호를 필터링하기 위해 추가 될 수 있습니다.

스톱 로스 방법을 최적화

더 유연한 스톱 로스 방법인 타임 스톱과 변동성 스톱을 사용해서 탈환 위험을 줄일 수 있습니다.

매개 변수 최적화

가장 좋은 매개 변수 조합을 찾기 위해 EMA 기간 매개 변수를 최적화하십시오. 시장 주기를 추적하기 위해 EMA 매개 변수를 동적으로 만들 수도 있습니다.

결론

EMA 반등 전략은 트렌드를 따르는 전략으로 간단하고 실용적입니다. 그것은 작은 드라우다운을 가지고 있으며 이해하기 쉽습니다. 동시에 잘못된 신호 및 중단되는 몇 가지 위험이 있습니다. 우리는 더 나은 지표 조합, 중지 손실 방법 및 매개 변수 선택을 사용하여 전략을 최적화하여 안정적이고 신뢰할 수있는 양적 전략을 만들 수 있습니다.


/*backtest
start: 2022-12-01 00:00:00
end: 2023-12-07 00:00:00
period: 1d
basePeriod: 1h
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/
// © tweakerID

// Simple strategy that checks for price bounces over an Exponential Moving Average. If the CLOSE of the candle bounces
// back from having it's LOW below the EMA, then it's a Bull Bounce. If the CLOSE of the candle bounces down from having it's
// high above the EMA, then it's a Bear Bounce. This logic can be reverted.

//@version=4
strategy("EMA Bounce", overlay=true, 
     default_qty_type=strategy.percent_of_equity, 
     default_qty_value=100, 
     initial_capital=10000, 
     commission_value=0.04, 
     calc_on_every_tick=false, 
     slippage=0)

direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))

/////////////////////// STRATEGY INPUTS ////////////////////////////////////////
title1=input(true, "-----------------Strategy Inputs-------------------")  

i_EMA=input(20, title="EMA Length")

/////////////////////// BACKTESTER /////////////////////////////////////////////
title2=input(true, "-----------------General Inputs-------------------")  

// Backtester General Inputs
i_SL=input(true, title="Use Swing Stop Loss and Take Profit")
i_SPL=input(defval=10, title="Swing Point Loopback")
i_PercIncrement=input(defval=.2, step=.1, title="Swing Point SL Perc Increment")*0.01
i_TPRRR = input(1.2, step=.1, title="Take Profit Risk Reward Ratio")

// Bought and Sold Boolean Signal
bought = strategy.position_size > strategy.position_size[1] 
 or strategy.position_size < strategy.position_size[1]

// Price Action Stop and Take Profit
LL=(lowest(i_SPL))*(1-i_PercIncrement)
HH=(highest(i_SPL))*(1+i_PercIncrement)
LL_price = valuewhen(bought, LL, 0)
HH_price = valuewhen(bought, HH, 0)
entry_LL_price = strategy.position_size > 0 ? LL_price : na 
entry_HH_price = strategy.position_size < 0 ? HH_price : na 
tp=strategy.position_avg_price + (strategy.position_avg_price - entry_LL_price)*i_TPRRR
stp=strategy.position_avg_price - (entry_HH_price - strategy.position_avg_price)*i_TPRRR


/////////////////////// STRATEGY LOGIC /////////////////////////////////////////

EMA=ema(close, i_EMA)
LowAboveEMA=low > EMA
LowBelowEMA=low < EMA
HighAboveEMA=high > EMA
HighBelowEMA=high < EMA
BullBounce=LowAboveEMA[1] and LowBelowEMA and close > EMA //and close > open
BearBounce=HighBelowEMA[1] and HighAboveEMA and close < EMA //and close < open
plot(EMA)

BUY=BullBounce
SELL=BearBounce

//Inputs
DPR=input(false, "Allow Direct Position Reverse")
reverse=input(false, "Reverse Trades")

// Entries
if reverse
    if not DPR
        strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)
        strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)
    else     
        strategy.entry("long", strategy.long, when=SELL)
        strategy.entry("short", strategy.short, when=BUY)
else
    if not DPR 
        strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)
        strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)
    else
        strategy.entry("long", strategy.long, when=BUY)
        strategy.entry("short", strategy.short, when=SELL)


SL=entry_LL_price
SSL=entry_HH_price
TP=tp
STP=stp

strategy.exit("TP & SL", "long", limit=TP, stop=SL, when=i_SL)
strategy.exit("TP & SL", "short", limit=STP, stop=SSL, when=i_SL)

/////////////////////// PLOTS //////////////////////////////////////////////////

plot(strategy.position_size > 0 ? SL : na , title='SL', style=plot.style_cross, color=color.red)
plot(strategy.position_size < 0 ? SSL : na , title='SSL', style=plot.style_cross, color=color.red)
plot(strategy.position_size > 0 ? TP : na, title='TP', style=plot.style_cross, color=color.green)
plot(strategy.position_size < 0 ? STP : na, title='STP', style=plot.style_cross, color=color.green)
// Draw price action setup arrows
plotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar, 
 color=color.green, title="Bullish Setup", transp=80, size=size.auto)
plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar, 
 color=color.red, title="Bearish Setup", transp=80, size=size.auto)


더 많은