이 전략은 이동 평균 집적 차수 지표 ((MACD) 와 상대 강도 지수 ((RSI) 를 기반으로 암호화폐의 매매점을 판단하는 거래 전략이다. 이는 단기 및 장기 이동 평균의 차수를 계산하여 RSI와 결합하여 시장 추세와 오버 바이 오버 소드를 판단하여 거래 의사 결정에 신호를 제공합니다.
12 일 EMA와 26 일 EMA를 각각 단기 및 장기 이동 평균으로 계산합니다.
MACD 기둥 그래프로 단기 및 장기 EMA의 차이를 계산합니다.
MACD의 9일 EMA를 신호선으로 계산합니다.
14일 RSI를 계산하여 과매매를 판단합니다.
MACD 상의 신호선을 통과하고 RSI가 81보다 크면 구매 신호가 표시됩니다.
MACD 아래의 신호선을 통과하고 RSI가 27보다 작으면 판매 신호를 표시합니다.
내장된 정책 모듈을 사용하여 입출장
MACD 지표는 트렌드 및 트렌드 변화를 식별하고, RSI 지표는 오버 바이 오버 소드를 표시하며, 둘을 결합하면 거래 신호의 정확성을 향상시킬 수 있습니다.
MACD 0축의 위아래 변화는 단기 및 장기 동향의 변화 방향과 강도를 나타내며 시장 방향을 판단하는 데 기초를 제공합니다.
높은 RSI 영역은 과열과 과매매의 가능성을 나타냅니다. 낮은 RSI 영역은 과매매의 가능성을 나타냅니다.
거래 신호는 간단하고 명확하며 규칙에 따라 거래하는 것이 쉽습니다.
다른 시장 환경에 적응하기 위해 최적화 가능한 구성 요소
MACD와 RSI의 데이터에 근거한 데이터는 가짜 돌파구와 비정상적인 데이터의 영향을 받아 잘못된 신호를 보낼 수 있습니다.
고정된 매개 변수 설정은 시장의 변화에 적응할 수 없으며 최적화가 필요합니다.
구매 및 판매 신호가 지연되어 전환점에서 구매 및 판매가 불가능할 수 있습니다.
지위는 비어 있고, 2번째 선택이 있어, 충격적인 상황을 활용할 수 없다.
다양한 변수 조합을 테스트하여 최적의 변수를 찾습니다.
추가적인 필터링 조건을 추가하여 가짜 돌파구를 방지합니다.
한방적인 거래에서 손실을 줄이기 위해 손실을 막는 전략을 강화합니다.
포지션 관리를 늘리고, 트렌드에서 포지션을 늘리고, 변동 중에 포지션을 줄입니다.
다른 지표들과 함께 더 정확한 매매 지점을 찾습니다.
다양한 품종과 시간대에서 효과를 테스트하는 방법
이 전략은 MACD와 RSI 두 지표의 상호 보완적 장점을 사용하여 트렌드 방향과 시가점을 식별한다. 최적화 파라미터를 추가하여 필터링 조건을 개선하여 전략의 안정성과 수익 요소를 개선할 수 있다. 적절한 스톱 로스 및 포지션 관리를 조정하는 것도 수익 수준을 높이고 위험을 줄이는 데 도움이 된다. MACD와 RSI의 장단점은 이 전략이 짧은 라인 거래보다 중선 트렌드를 식별하는 데 더 적합하다는 것을 결정한다.
/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-12 04:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
// Revision: 5
// Author: @Hugo_Moriceau
//study("Thesis_EMLYON_Withdate-strategies-Daily_Crypto_Moriceau_indicator",overlay=true)
// Pyramide 10 order size 100, every tick
strategy("Daily_Crypto_Moriceau_indicator",overlay=true)
// === GENERAL INPUTS ===
fast = 12, slow = 26
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
rsi = rsi(close,14)
tradeInvert = input(defval = false, title = "Invert Trade Direction?")
// === LOGIC ===
// is fast ma above slow ma?
aboveBelow = fastMA >= slowMA ? true : false
// are we inverting our trade direction?
tradeDirection = tradeInvert ? aboveBelow ? false : true : aboveBelow ? true : false
// === Plot Setting ===
//plot(fastMA,color=red)
//plot(slowMA,color=blue)
//barcolor(color=iff(fastMA > slowMA, yellow, na))
//barcolor(color=iff(fastMA < slowMA, black, na))
barcolor(color=iff(macd > 0.12*close , fuchsia, na))
barcolor(color=iff(macd < -0.1*close , lime, na))
dataS= macd > 0.125 and rsi>81 and fastMA > slowMA
dataB= macd < -0.1 and rsi<27 and fastMA< slowMA
plotchar(dataB, char='B',color=black,size = size.tiny,location = location.belowbar,transp= 0)
plotchar(dataS, char='S',color=black,size = size.tiny,location = location.abovebar,transp= 0)
// === BACKTEST RANGE ===
FromMonth = input(defval = 01, title = "From Month", minval = 1)
FromDay = input(defval = 01, title = "From Day", minval = 1)
FromYear = input(defval = 2017, title = "From Year", minval = 2014)
ToMonth = input(defval = 2, title = "To Month", minval = 1)
ToDay = input(defval = 10, title = "To Day", minval = 1)
ToYear = input(defval = 2019, title = "To Year", minval = 2018)
// === STRATEGY RELATED INPUTS ===+
// the risk management inputs
inpTakeProfit = input(defval = 20000, title = "Take Profit", minval = 0)
inpStopLoss = input(defval = 1500, title = "Stop Loss", minval = 0)
inpTrailStop = input(defval = 100, title = "Trailing Stop Loss", minval = 0)
inpTrailOffset = input(defval = 0, title = "Trailing Stop Loss Offset", minval = 0)
// === RISK MANAGEMENT VALUE PREP ===
// if an input is less than 1, assuming not wanted so we assign 'na' value to disable it.
useTakeProfit = inpTakeProfit >= 1 ? inpTakeProfit : na
useStopLoss = inpStopLoss >= 1 ? inpStopLoss : na
useTrailStop = inpTrailStop >= 1 ? inpTrailStop : na
useTrailOffset = inpTrailOffset >= 1 ? inpTrailOffset : na
// === STRATEGY - LONG POSITION EXECUTION ===
enterLong() => not tradeDirection[1] and tradeDirection
exitLong() => tradeDirection[1] and not tradeDirection
strategy.entry(id = "Long", long = true, when = enterLong()) // use function or simple condition to decide when to get in
strategy.close(id = "Long", when = exitLong()) // ...and when to get out
// === STRATEGY - SHORT POSITION EXECUTION ===
enterShort() => tradeDirection[1] and not tradeDirection
exitShort() => not tradeDirection[1] and tradeDirection
strategy.entry(id = "Short", long = false, when = enterShort())
strategy.close(id = "Short", when = exitShort())
// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
strategy.exit("Exit Long", from_entry = "Long", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Short", from_entry = "Short", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)