스토카스틱 모멘텀 이중 지표 전략

저자:차오장, 날짜: 2023-10-07 16:45:25
태그:

전반적인 설명

이 전략은 중장기 트렌드 및 가격 변동을 파악하기 위해 장기 및 단기 신호에 대한 이중 스토카스틱 모멘텀 지표 (SMI 및 RSI) 와 마틴게일 및 몸 필터를 거래 신호 선택에 사용합니다.

전략 논리

이 전략은 두 개의 스토카스틱 지표인 SMI와 RSI를 사용하여 장기 및 단기를 판단합니다. SMI는 바 범위 및 폐쇄 가격의 이동 평균에 기초하여 계산되며 반전 지점을 잘 파악합니다. RSI는 과반 구매 및 과반 판매 상태를 결정하기 위해 황소와 곰의 힘을 비교합니다. SMI가 -50 이하이고 RSI가 20 이하일 때 전략이 길어집니다. SMI가 50 이상이고 RSI가 80 이상일 때 짧습니다.

가짜 브레이크아웃을 필터링하기 위해 전략은 또한 10주기 신체 SMA의 1/3을 돌파 필터 조건으로 사용합니다. 신체가 SMA의 1/3을 돌파하면 브레이크아웃이 유효한 것으로 간주됩니다.

또한, 전략은 선택적인 마틴게일 (Martingale) 을 채택하고, 이는 이전 손실을 복구하기 위해 손실 트레이드에 대한 롯을 확장하는 것입니다.

백테스트 기능은 날짜 범위를 입력하여 전략을 백테스트합니다.

이점 분석

이 전략은 이중 스토카스틱 지표와 필터를 결합하여 반전 지점을 효과적으로 식별하고 중장기 트렌드를 파악하고 가격 변동을 추적 할 수 있습니다.

  • SMI는 강력한 반전 지점 인식 능력을 가지고 있으며 과잉 구매 및 과잉 판매 조건을 효과적으로 결정할 수 있습니다.
  • RSI를 추가하면 트레이드를 놓치지 않습니다.
  • 시체 필터는 가짜 파장을 제거하고 신호 정확도를 향상시킵니다.
  • 선택적인 마틴게일 전략은 손실의 일부를 회수할 수 있습니다.

위험 분석

  • SMI와 RSI는 뒤떨어진 지표로서 최고치를 추격하고 최저치를 죽이는 위험이 있습니다.
  • 마틴게일은 손실을 가속화시킬 위험이 있습니다.
  • 필터는 다양한 시장에서 유효한 신호를 필터링할 수 있습니다.

위험은 SMI와 RSI 매개 변수를 최적화하여 추격/살인 확률을 낮추고, 확장 비율과 시간을 제어함으로써 전략적으로 마틴게일 (Martingale) 을 사용하여 시장 조건에 따라 자율적으로 필터를 활성화함으로써 완화 될 수 있습니다.

최적화 방향

  • 가장 좋은 판단 효과를 위해 SMI와 RSI 매개 변수를 최적화합니다.
  • 유효한 신호를 필터하는 확률을 낮추기 위해 필터 매개 변수를 조정합니다.
  • 마틴게일 스케일업 시간과 비율을 최적화하세요.
  • 트렌드에 반대되는 거래를 피하기 위해 트렌드 지표를 포함합니다.
  • 한 번의 거래에서 손실을 제한하기 위해 Stop Loss를 추가합니다.

요약

이 전략은 전환점을 포착하기 위해 이중 스토카스틱 지표를 결합하고, 무역 신호 선택과 추격을위한 필터와 마틴게일과 함께합니다. 중장기 트렌드를 효과적으로 식별하고 높은 승률을 추구하는 투자자에게 적합한 가격 변동을 추적 할 수 있습니다. 지표 지체 및 범위 시장 위험에주의를 기울이고 매개 변수 최적화 및 스톱 로스로 위험을 관리하십시오.


/*backtest
start: 2022-09-30 00:00:00
end: 2023-10-06 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
// strategy(title = "CS Basic Scripts - Stochastic Special (Strategy)", shorttitle = "Stochastic Special", overlay = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)

//Settings 
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usemar = input(false, defval = false, title = "Use Martingale")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
usesmi = input(true, defval = true, title = "Use SMI Strategy")
usersi = input(true, defval = true, title = "Use RSI Strategy")
usebod = input(true, defval = true, title = "Use Body-Filter")
a = input(5, "SMI Percent K Length")
b = input(3, "SMI Percent D Length")
limit = input(50, defval = 50, minval = 1, maxval = 100, title = "SMI Limit")

//Backtesting Input Range
fromyear = input(2017, defval = 2017, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//Fast RSI
fastup = rma(max(change(close), 0), 7)
fastdown = rma(-min(change(close), 0), 7)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))

//Stochastic Momentum Index
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
SMIsignal = ema(SMI,b)

//Lines
plot(SMI, color = blue, linewidth = 3, title = "Stochastic Momentum Index")
plot(SMIsignal, color = red, linewidth = 3, title = "SMI Signal Line")
plot(limit, color = black, title = "Over Bought")
plot(-1 * limit, color = black, title = "Over Sold")
plot(0, color = blue, title = "Zero Line")

//Body Filter
nbody = abs(close - open)
abody = sma(nbody, 10)
body = nbody > abody / 3 or usebod == false

//Signals
up1 = SMI < -1 * limit and close < open and body and usesmi
dn1 = SMI > limit and close > open and body and usesmi
up2 = fastrsi < 20 and close < open and body and usersi
dn2 = fastrsi > 80 and close > open and body and usersi
exit = ((strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open)) and body

//Trading
profit = exit ? ((strategy.position_size > 0 and close > strategy.position_avg_price) or (strategy.position_size < 0 and close < strategy.position_avg_price)) ? 1 : -1 : profit[1]
mult = usemar ? exit ? profit == -1 ? mult[1] * 2 : 1 : mult[1] : 1
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 * mult : lot[1]

if up1 or up2
    if strategy.position_size < 0
        strategy.close_all()
        
    strategy.entry("long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

if dn1 or dn2
    if strategy.position_size > 0
        strategy.close_all()
        
    strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
    
if time > timestamp(toyear, tomonth, today, 23, 59) or exit
    strategy.close_all()

더 많은