
이 전략은 MACD, EMA, RSI의 세 가지 지표를 통합하여 트렌드 추적 및 반전 거래를 수행합니다. MACD가 신호선을 상향으로 통과하고 EMA 평균보다 높은 가격으로 종료되면 구매 신호를 생성합니다. MACD가 신호선을 넘어 내려가 EMA 평균보다 낮은 가격으로 종료되면 판매 신호를 생성하여 트렌드를 캡처합니다. 또한 RSI가 오버 바이 오버 셀 영역에 도달하면 반전 거래를 수행합니다.
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
ema = ema(close, input(200))
delta = macd - signal
buy_entry= close>ema and delta > 0
sell_entry = close<ema and delta<0
if (rsi > 70 or rsi < 30)
reversal := true
해결책:
이 전략은 MACD, EMA 및 RSI 지표를 통합하여 트렌드 추적과 반전 거래를 유기적으로 결합합니다. MACD는 주요 트렌드 방향을 판단하고, EMA는 파동 소음을 감지하고, RSI 지표는 반전 지점을 포착합니다. 이러한 다중 지표 조합은 시장 움직임을 더 정확하게 판단하고, 잘못된 거래를 줄임과 동시에 수익률을 높일 수 있습니다.
/*backtest
start: 2023-11-17 00:00:00
end: 2023-12-17 00:00:00
period: 1h
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/
// © mbuthiacharles4
//Good with trending markets
//@version=4
strategy("CHARL MACD EMA RSI")
fast = 12, slow = 26
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
ema = ema(close, input(200))
rsi = rsi(close, input(14))
//when delta > 0 and close above ema buy
delta = macd - signal
buy_entry= close>ema and delta > 0
sell_entry = close<ema and delta<0
var bought = false
var sold = false
var reversal = false
if (buy_entry and bought == false and rsi <= 70)
strategy.entry("Buy",true , when=buy_entry)
bought := true
strategy.close("Buy",when= delta<0 or rsi > 70)
if (delta<0 and bought==true)
bought := false
//handle sells
if (sell_entry and sold == false and rsi >= 30)
strategy.entry("Sell",false , when=sell_entry)
sold := true
strategy.close("Sell",when= delta>0 or rsi < 30)
if (delta>0 and sold==true)
sold := false
if (rsi > 70 or rsi < 30)
reversal := true
placing = rsi > 70 ? high :low
label.new(bar_index, placing, style=label.style_flag, color=color.blue, size=size.tiny)
if (reversal == true)
if (rsi < 70 and sold == false and delta < 0)
strategy.entry("Sell",false , when= delta < 0)
sold := true
reversal := false
else if (rsi > 30 and bought == false and delta > 0)
strategy.entry("Buy",true , when= delta > 0)
bought := true
reversal := false