이 전략은 255 주기의 EMA와 MACD 지표를 사용하여 반전 거래 기회를 찾습니다. 가격이 255 EMA에서 멀리 떨어져있을 때, MACD의 황금 포크 또는 사각지대가 발생했을 때 반전 입력을 수행합니다.
255주기 EMA를 사용하여 중장기 트렌드를 판단하십시오. EMA에서 벗어나는 것은 초과 구매 및 초과 판매 영역에 들어가는 것을 의미합니다.
EMA 위쪽은 올라가는 궤도를 설정하고, EMA 아래쪽은 내려가는 궤도를 설정하며, 궤도 너비는 ATR 지표를 통해 동적으로 조정된다.
가격이 상반기보다 높을 때 초상구역이며, 가격이 하반기보다 낮을 때 초상 판매구역이다. 이러한 경우에는 반전 신호가 나타나기를 기다린다.
MACD 지표는 표준 변수를 사용한다 ((12,26,9) ᄅ. MACD 황금 포크는 다중 머리 신호, 사다리 포크는 빈 머리 신호 ᄅ.
EMA 과잉구매와 MACD 신호를 결합하여, 가격이 EMA에서 멀리 떨어져 있고 MACD가 역전되면 역전으로 들어갑니다.
255주기 EMA를 사용하면 중장기 트렌드 방향을 더 잘 판단할 수 있다.
MACD 황금 포크는 짧은 시간 반전 기회를 더 민감하게 포착할 수 있다.
EMA 상하 궤도장은 오버 바이 오버 세일 영역을 판단하여 트렌드에 따라 파동하는 흐름을 피합니다.
반전 거래 전략, 가격 반전 전에 들어갈 수 있고, 일정 계획성이 있다.
동적 ATR 정지는 위험을 효과적으로 통제할 수 있다.
MACD 신호는 가짜 반전으로 인해 불필요한 손실이 발생할 수 있습니다.
강한 추세 상황에서는 반전이 실패할 가능성이 높으며, 맹목적인 반전을 피해야 한다.
스톱가스 설정이 너무 작으면 스톱가스가 트리거될 수 있고, 너무 커면 리스크가 통제되지 않을 수 있다.
변수 설정이 잘못되면 전략 효과에 영향을 미치며, 반복적으로 테스트를 거쳐 최적화해야 한다.
거래 비용도 최종 수익에 영향을 미치므로 전략에 미치는 영향을 고려해야 합니다.
다양한 EMA 주기적 변수를 테스트하여 더 적합한 중장기 트렌드 판단 지표를 찾을 수 있다.
다른 지표와 EMA를 결합하여 오버 바이 오버 셀 영역을 판단 할 수 있습니다. 예를 들어, 브린 밴드, KD, RSI 등.
MACD 파라미터는 또한 더 민감하거나 안정적인 조합 파라미터를 찾기 위해 최적화 될 수 있습니다.
이윤을 잠금하기 위해 trailing stop 같은 다른 손실을 방지하는 방법을 테스트 할 수 있습니다.
다른 품종에 따라 다른 주기에 따라 매개 변수를 최적화하여 전략을 더 적응시킬 수 있다.
동향 강도 지표와 결합하여 강력한 동향에서 역전되는 것을 피할 수 있다.
이 전략은 EMA에서 장기 동향 판단과 MACD 단기 역전 신호를 통합하고, 과매매 지역에서의 역전 거래는 기본 역전 전략이다. 이 전략에는 장점이 있지만, 또한 몇 가지 위험이 있습니다. 파라미터를 계속 최적화하고 위험을 통제함으로써 이 전략은 효율적인 양적 거래 전략이 될 수 있습니다. 그러나 모든 전략은 시장 환경에 따라 조정되어야하며, 화되지 않으며, 맹목적으로 따라야합니다.
/*backtest
start: 2023-09-12 00:00:00
end: 2023-09-19 00:00:00
period: 15m
basePeriod: 5m
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/
// © bufirolas
//--- From 15 Trading Examples by Trader Alyx ---
// Seems like this strategy works better if we reverse the EMA filter logic.
// "Description: This basic scalping strategy allows you to enter the market based upon sentiment
// provided by the EMA, set at 255 periods. When price is trading below the 255 EMA, you would
// look to enter a LONG BUY positions, and when price is trading above the 255 EMA, you would
// look to enter a SELL SHORT position. The MACD lagging indicator will show you clear signals for
// when to do this. When the MACD lines cross in a bullish manner and price is below the 255
// EMA, buy. When the MACD lines cross in a bearish manner and price is above the 255 EMA,
// sell.
// NOTE: Make sure that price is trading away from the 255EMA before entering a LONG or SHORT
// position. As you can see in the chart below, the clearest signs for trade entry were presented
// when price was trading AWAY from the 255EMA"
//@version=4
// strategy("255 EMA Strategy", overlay=true, pyramiding=1, default_qty_type=strategy.cash, default_qty_value=100, commission_value = 0.04, initial_capital=100)
//Inputs
i_reverse=input(false, title="Trade Reverse")
i_EMAreverse=input(true, title="EMA Reverse Entry")
i_EMAlength=input(defval=255, title="EMA Length")
i_EMAexpander=input(defval=5, title="EMA Expander")
i_MACDmult=input(defval=1, minval=1, title="MACD Mult")
//SL & TP Calculations
i_SL=input(true, title="Use Swing Lo/Hi Stop Loss & Take Profit")
i_SwingLookback=input(20, title="Swing Lo/Hi Lookback")
i_SLExpander=input(defval=0, step=.2, title="SL Expander")*.01
i_TPExpander=input(defval=0, step=.2, title="TP Expander")*.01
//Strategy Variables
EMA=ema(close,i_EMAlength)
[macdLine, signalLine, histLine]=macd(close, 12*i_MACDmult, 26*i_MACDmult, 9*i_MACDmult)
EMAupper=EMA+((atr(100))*i_EMAexpander)
EMAlower=EMA-((atr(100))*i_EMAexpander)
//SL & TP Variables
SwingLow=lowest(i_SwingLookback)
SwingHigh=highest(i_SwingLookback)
//Calculations
EMAbuy=i_EMAreverse ? close > EMAupper : close < EMAlower
EMAsell=i_EMAreverse ? close < EMAlower : close > EMAupper
MACDbuy=crossover(macdLine, signalLine)
MACDsell=crossunder(macdLine, signalLine)
//SL & TP Calculations
bought=strategy.position_size != strategy.position_size[1]
lSL=valuewhen(bought, SwingLow, 0)*(1-i_SLExpander)
sSL=valuewhen(bought, SwingHigh, 0)*(1+i_SLExpander)
lTP=strategy.position_avg_price + (strategy.position_avg_price-(valuewhen(bought, SwingLow, 0))*(1-i_TPExpander))
sTP=strategy.position_avg_price - (valuewhen(bought, SwingHigh, 0) - strategy.position_avg_price)*(1+i_TPExpander*100)
islong=strategy.position_size > 0
isshort=strategy.position_size < 0
SL= islong ? lSL : isshort ? sSL : na
TP= islong ? lTP : isshort ? sTP : na
//Entries
strategy.entry("long", long=not i_reverse?true:false, when=EMAbuy and MACDbuy)
strategy.entry("short", long=not i_reverse?false:true, when=EMAsell and MACDsell)
//Exits
if i_SL
strategy.exit("longexit", "long", stop=SL, limit=TP)
strategy.exit("shortexit", "short", stop=SL, limit=TP)
//Plots
plot(EMA, "EMA", color=color.white, linewidth=2)
plot(EMAupper, "EMA Upper Band")
plot(EMAlower, "EMA Lower Band")
plot(i_SL ? SL : na, color=color.red, style=plot.style_cross, title="SL")
plot(i_SL ? TP : na, color=color.green, style=plot.style_cross, title="TP")