트렌드 다음 전략 후속 스톱 손실과 거리를 기반으로

저자:차오장, 날짜: 2023-11-15 11:24:16
태그:

img

전반적인 설명

이 전략은 가격 트렌드를 결정하기 위해 거리 클로즈 바스 (DCB) 지표와 필터로 빠른 RSI 지표를 활용하고, 거래를 따르는 트렌드에 대한 트레이일링 스톱 로스를 구현합니다. 또한 포지션 사이징을 위해 마틴게일 원리를 사용합니다. 중장기 트렌드 거래에 적합합니다.

원칙

  1. 마지막 녹색 막대기 닫고 마지막 빨간 막대기 닫는 것을 나타내는 lastg와 lastr를 계산합니다.

  2. lastg와 lastr의 차이로 dist를 계산합니다.

  3. 30주기 SMA로 계산합니다.

  4. Dist가 2배나 커지면 트레이딩 신호를 생성합니다.

  5. 신호를 필터링하기 위해 빠른 RSI 지표를 사용해서 가짜 브레이크를 피하세요.

  6. 신호가 포지션이 없는 경우 자본의 일정한 비율로 거래를 합니다.

  7. 마틴게일은 패배 후 규모를 조정합니다.

  8. 스톱 로스 (Stop Loss) 또는 리프트 (Take Profit) 가 발생하면 포지션을 닫습니다.

장점

  1. DCB 지표는 중장기 동향을 효과적으로 파악합니다.

  2. 빠른 RSI 필터는 가짜 파업으로 인한 손실을 방지합니다.

  3. 트레일링 스톱은 수익을 확보하고 위험을 통제합니다.

  4. 마틴게일 (Martingale) 은 손실 후 더 높은 수익을 위해 포지션을 증가시킵니다.

  5. 합리적인 파라미터 설정은 다른 시장 환경에 적합합니다.

위험성

  1. DCB는 잘못된 신호를 생성할 수 있습니다. 다른 필터가 필요합니다.

  2. 마틴게일은 손실을 증폭시킬 수 있고 엄격한 위험 관리도 요구합니다.

  3. 잘못된 스톱 로스 설정은 과도한 손실로 이어질 수 있습니다.

  4. 포지션 크기는 과도한 레버링을 방지하기 위해 제한되어야 합니다.

  5. 부적절한 계약 설정은 극단적인 시장에서 엄청난 손실을 초래할 수 있습니다.

최적화

  1. 가장 좋은 조합을 위해 DCB 매개 변수를 최적화해

  2. 빠른 RSI 필터를 대체하기 위해 다른 지표를 시도하십시오.

  3. 스톱 로스를 최적화하고 더 높은 승률을 위해 수익을 취하십시오.

  4. 위험을 줄이기 위해 마틴게일 매개 변수를 최적화하세요.

  5. 가장 좋은 자산 할당을 위해 다른 제품 테스트.

  6. 매개 변수를 동적으로 최적화하기 위해 기계 학습을 사용하세요.

요약

이것은 전체적으로 성숙한 트렌드 다음 전략입니다. DCB는 트렌드 방향을 결정하고 잘못된 입력을 피하기 위해 빠른 RSI 신호를 필터합니다. 스톱 손실 및 수익을 취하는 것은 단일 거래 손실을 효과적으로 제어합니다. 그러나 여전히 위험이 있으며, 매개 변수는 위험을 줄이고 안정성을 향상시키기 위해 추가 최적화가 필요합니다. 논리는 명확하고 이해하기 쉽습니다. 중장기 트렌드 거래자에게 적합합니다.


/*backtest
start: 2023-11-07 00:00:00
end: 2023-11-14 00:00:00
period: 3m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//Noro
//2018

//@version=2
strategy(title = "Noro's Distance Strategy v1.0", shorttitle = "Distance str 1.0", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 10)

//Settings 
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usemar = input(true, defval = true, title = "Use Martingale")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
usersi = input(true, defval = true, title = "Use RSI-Filter")
periodrsi = input(7, defval = 7, minval = 2, maxval = 50, title = "RSI Period")
limitrsi = input(30, defval = 30, minval = 1, maxval = 50, title = "RSI Limit")
fromyear = input(2018, defval = 2018, 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), periodrsi)
fastdown = rma(-min(change(close), 0), periodrsi)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))

//Distance
bar = close > open ? 1 : close < open ? -1 : 0
lastg = bar == 1 ? close : lastg[1]
lastr = bar == -1 ? close : lastr[1]
dist = lastg - lastr
adist = sma(dist, 30)
plot(lastg, linewidth = 3, color = lime)
plot(lastr, linewidth = 3, color = red)
up = bar == -1 and dist > adist * 2
dn = bar == 1 and dist > adist * 2

//RSI Filter
rsidn = fastrsi < limitrsi or usersi == false
rsiup = fastrsi > 100 - limitrsi or usersi == false

//Signals
up1 = up and rsidn
dn1 = dn and rsiup
exit = ((strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open))

//Arrows
plotarrow(up1 ? 1 : na, colorup = blue, colordown = blue)
plotarrow(dn1 ? -1 : na, colorup = blue, colordown = blue)

//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]

signalup = up1
if signalup
    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)))

signaldn = dn1
if signaldn
    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()

더 많은