이 전략은 쌍MACD 지표와 무작위 지표 StochRSI를 결합하여 거래 신호 판단을 한다. 쌍MACD는 다른 파라미터 설정을 사용하여 빠른 느린 효과를 실현하고, StochRSI는 강도 뒷면 검증을 위해 사용된다. 전략은 또한 트렌드 판단과 손실 조건 제어 위험을 추가한다.
이 전략의 거래 신호 판단은 다음과 같은 지표에 기반합니다.
쌍MACD: 빠른MACD는 단기주기 파라미터를 사용하며, 느린MACD는 긴주기 파라미터를 사용하며, 서로 다른 평준화 효과를 달성한다.
StochRSI: RSI의 최저값을 계산하여 RSI가 과매매 상태인지 판단한다.
거래 신호 판단 규칙:
더 많이: 빠른 MACD에서 0축을 통과하고 느린 MACD에서 0축을 통과, StochRSI는 과매매 상태이며 K선에서 D선을 통과하고 상승 추세에 있습니다.
공백: 빠른 MACD는 0축을 통과하고 느린 MACD는 0축을 통과합니다. StochRSI는 과매매 상태이며 K선 아래 D선을 통과하며 하향 추세에 있습니다.
이중 MACD 검증은 가짜 침입을 방지하고 신호 품질을 향상시킵니다.
StochRSI는 과매매를 판단하고, 하락을 추적하는 것을 피한다.
큰 트렌드 방향에 대해 고려하여 역동적인 거래 손실을 줄여주세요.
지표의 다중 시간 프레임 검증을 구현하여 신호의 효과를 높인다.
스톱 손실 조건 제어 위험을 설정한다.
MACD는 가짜 신호를 발생시킬 수 있으며, 추가적인 필터링 검증이 필요합니다.
StochRSI 파라미터를 잘못 설정하면 거래 기회를 놓칠 수 있습니다.
이럴 경우, 이치에 맞지 않는 스톱포인트 설정이 너무 보수적이거나 극단적일 수 있습니다.
지분 관리 전략이 없고, 손실을 동적으로 막을 수 없다.
다음의 관점에서 최적화할 수 있습니다.
거래량을 늘리거나 평평한 각도와 같은 필터 조건
StochRSI 변수를 최적화하거나 다른 무작위 지표를 도입하십시오.
동적으로 정지점을 조정하고, 정지를 추적한다.
포지션 관리 모듈을 추가하여 전략에 따라 포지션을 동적으로 조정합니다.
이 전략의 주요 최적화 방향은 다음과 같습니다.
지표 매개 변수를 최적화하여 지표 효과를 높인다.
필터링 조건을 추가하여 가짜 신호를 필터링합니다.
역동적인 상쇄를 실현하기 위한 상쇄 전략을 최적화한다.
포지션 관리를 도입하여 전략 효과에 따라 포지션을 조정한다.
기계 학습 모듈을 추가하여 빅데이터를 활용하여 자동적으로 최적화하십시오.
이 전략은 다양한 지표를 종합적으로 고려하여 강력한 거래 신호를 형성한다. 그러나 여전히 파라미터 설정을 최적화하고, 불필요한 거래를 줄이고, 수익을 얻는 가능성을 높이기 위해 신호 및 동적 손실을 추가적으로 필터링해야 한다. 전체적으로 전략 아이디어는 합리적이며, 좋은 최적화 공간이 있다.
/*backtest
start: 2023-09-14 00:00:00
end: 2023-09-21 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
//This strategy is an ongoing work in progress. Last updated 8/6/16.
//Feel free to modify it as you see fit, if you do borrow code then send me a link so I
//can see and maybe borrow some of your code to improve this.
//Thanks to ChrisMoody who I stole the code for setting custom resolution from.
//
//more info in comments at end of script
strategy("MACDouble & StochRSI w/ safeties v0.3", overlay=true)
source = close
useCurrentRes = input(true, title="Uncheck to use custom res./intrv. for 2nd MACD indicator")
resCustom = input(title="Resolution/interval to use for 2nd MACD:", defval="45")
res = useCurrentRes ? timeframe.period : resCustom
useCurrentRes2 = input(true, title="Uncheck to use custom res/intrv for StochRSI")
resCustom2 = input(title="Resolution to use for StochRSI indicator:", defval="45")
res2 = useCurrentRes2 ? timeframe.period : resCustom2
//MACD1
fastLength = input(10, title="MACD fast length")
slowlength = input(21, title="MACD slow length")
sigLength = input(9, title="MACD signal length")
MACD = ema(source, fastLength) - ema(source, slowlength)
signal = sma(MACD, sigLength)
delta = MACD - signal
//MACD2
fastLength2 = input(31, title= "2nd MACD fast length")
slowlength2 = input(63, title= "2nd MACD slow length")
sigLength2 = input(30, title= "2nd MACD signal length")
MACD2 = ema(source, fastLength2) - ema(source, slowlength2)
signal2 = sma(MACD2, sigLength2)
delta2 = MACD2 - signal2
MACDRes = security(syminfo.tickerid, res, MACD2)
signalRes = security(syminfo.tickerid,res, signal2)
deltaRes = security(syminfo.tickerid, res, delta2)
uptrend = (close + high)/(close[1] + high[2])
downtrend = (close + low)/(close[1] + low[2])
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(11, minval=1)
lengthStoch = input(11, minval=1)
src = close
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
RSI_buyTrig = input(90)
RSI_sellTrig = input(20)
kRes = security(syminfo.tickerid, res2, k)
dRes = security(syminfo.tickerid, res2, d)
if (delta > 0) and (year>2012) and (deltaRes > 0) and (uptrend > 1) and ( kRes and dRes < RSI_buyTrig) and (kRes > dRes)
strategy.entry("buy", strategy.long, comment="buy")
if (delta < 0) and (year>2012) and (deltaRes < 0) and (downtrend < 1) and ( kRes and dRes > RSI_sellTrig) and (kRes < dRes)
strategy.entry("sell", strategy.short, comment="sell")
strategy.exit("sell", loss = 9000)
// RELEASE NOTES, ETC
//
// The core starting idea for this backtesting script came from the desire to have two traditional
//MACD indicators: one 'fast' and one 'slow'. The slow one is to pretty much smooth out noisy signals
//so that short term changes in price are ignored (ideally).
// A brief version history
// v0.1 - Basic two MACD indicators script
// v0.2 - Added StochRSI indicator
// v0.21- Added primitive uptrend/downtrend safety condition
// v0.22- Added changable time resolution for MACDslow
// v0.23- Added exit safeties conditional on loss threshold
// v0.3 - Added changeable resolution for StochRSI
// Future changes planned for next release:
// -Fine tuning exit safeties
// -Major overhaul of trade logic/triggers (may be forked as a different script)
//
//I am more than happy to discuss any difficulties you are having, questions about the script, or improvement suggestions.
//I am not a coder and my background is actually in economics, so feel free to debug ;)
//Feel free to tip me on the indcluded bitcoin address on TV as well
// tradingview.com/u/RyanMartin
// [email protected]