
MACD 밸리 디텍터 전략은 MACD 지표에 기반한 거래 전략이다. 이 전략은 MACD 지표의 골짜기를 탐지하여 구매 신호를 생성한다. MACD 지표가 골짜기를 형성하고 MACD 값이 -0.4보다 작고, MACD와 신호 라인의 차이는 0보다 작으면, 전략은 구매 신호를 발송하며 동시에 정지 가격을 설정한다.
MACD 밸리 디텍터 (MACD Valley Detector) 전략의 핵심은 MACD 지표를 사용하여 잠재적인 반전 기회를 잡는 것입니다. MACD 지표는 두 지표의 이동 평균 (EMA) 의 차로 계산되어 가격의 동력 변화를 반영합니다. MACD 지표가 계곡 바닥을 형성 할 때, 가격의 하향 움직임이 약해질 수 있음을 나타냅니다. 반전이 있을 가능성이 있습니다.
이 전략은 아래의 조건들을 사용하여 MACD 바닥을 판단합니다.
위 조건이 동시에 충족되면, 전략은 MACD 하위가 나타났다고 생각하고 구매 신호를 발송합니다. 동시에, 전략은 고정된 스톱 가격을 설정합니다. 즉, 구매 가격에 고정된 가격 차이가 추가됩니다.
MACD 밸리 디텍터 전략은 MACD 지표의 골짜기 바닥을 탐지하는 거래 전략이다. MACD 지표의 골짜기를 잡음으로써 잠재적인 반전 기회를 찾고 구매를 시도한다. 전략은 신호를 확인하기 위해 여러 조건을 사용하며 고정된 스톱 가격을 설정한다. 이 전략은 널리 사용되는 MACD 지표와 다중 조건 확인을 이용하는 것과 같은 장점이 있지만, 지연성, 고정 파라미터, 명확한 스톱 손실의 부재 등과 같은 위험과 제한이 있습니다.
/*backtest
start: 2024-03-12 00:00:00
end: 2024-04-11 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/
// © freditansari
//@version=5
//@version=5
strategy("MACD Valley Detector", overlay=true)
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)
aMACD = ta.ema(MACD, MACDLength)
delta = MACD - aMACD
rsi = ta.rsi(close, 14)
atr = ta.atr(14)
qty=1
takeProfitValue =7
// stopLossValue = 1
// close[0] < close[1] and close[1] > close[2]
is_valley= delta[0] > delta[1] and delta[1]<delta[2]? 1:0
// plot(is_valley , "valley?")
if(is_valley==1 and MACD<=-0.4 and delta <0)
takeProfit = close +takeProfitValue
action = "buy"
// strategy.entry("long", strategy.long, qty=qty)
// // strategy.exit("exit", "long", stop=stopLoss, limit=takeProfit)
// strategy.exit("exit", "long", limit=takeProfit)
alert('{"TICKER":"'+syminfo.ticker+'","ACTION":"'+action+'","PRICE":"'+str.tostring(close)+'","TAKEPROFIT":"'+str.tostring(takeProfit)+'","QTY":"'+str.tostring(qty)+'"}')
if (ta.crossover(delta, 0))
stopLoss = low -0.3
takeProfit = high +0.3
strategy.entry("MacdLE", strategy.long,qty=qty, comment="MacdLE")
strategy.exit("exit long", "MacdLE", limit=takeProfit)
// strategy.exit("exit long", "MacdLE", stop=stopLoss, limit=takeProfit)
if (ta.crossunder(delta, 0))
stopLoss = high + 0.3
takeProfit = low - 0.3
strategy.entry("MacdSE", strategy.short,qty=qty, comment="MacdSE")
strategy.exit("exit long", "MacdLE", limit=takeProfit)
// strategy.exit("exit short", "MacdSE", stop=stopLoss, limit=takeProfit)
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)