트렌드 추적 전략

저자:차오장, 날짜: 2023-12-19 11:04:27
태그:

img

전반적인 설명

이 전략은 트렌드 방향을 결정하기 위해 RSI, MACD, 스토카스틱과 같은 여러 지표를 통합하여 다중 요소 모델을 구축합니다. 한편, ATR을 기반으로 스토플로스 가격을 동적으로 조정하는 적응력 있는 트레일링 스토플로스 메커니즘을 갖추고 있습니다.

원칙

이 전략은 트렌드를 판단하는 모델을 구축하기 위해 여러 지표를 활용합니다. 첫째, 트렌드 방향을 결정하기 위해 RSI와 MACD를 결합합니다. 그 다음에는 과도하게 과잉 구매 또는 과잉 판매 신호를 필터하기 위해 스토카스틱스를 사용합니다. 주문을 입력 한 후 ATR을 사용하여 위험 매개 변수를 계산하고 적응 스톱 로스를 구현합니다.

특히, RSI가 52보다 높고 MACD 황금 교차가 발생하면 구매 신호를 생성하고, RSI가 48보다 낮고 MACD 죽은 교차가 발생하면 판매 신호를 생성합니다. 가짜 신호를 필터하기 위해 스토카스틱이 과소매 또는 과소매인지도 감지합니다. 스토플로스를 위해, 적응적 스토플로스를 실현하기 위해 ATR에 기반한 매개 변수를 계산하여 단일 스토플로스 위험을 효과적으로 제어 할 수 있습니다.

장점

이 전략의 가장 큰 장점은 강력한 리스크 제어 능력에 있다. 다중 요인 모델로 트렌드 방향을 판단함으로써 약간의 소음을 필터하고 신호 품질을 향상시킬 수 있다. 한편, 적응 스톱 로스 메커니즘은 단일 손실을 효과적으로 제어하기 위해 시장 변동성에 따라 스톱 로스 범위를 조정할 수 있다.

또한, 이 전략의 매개 변수는 좋은 백테스팅 결과로 합리적으로 설정된다. 다른 사이클 자산은 매개 변수 조정을 통해 최적화를 달성할 수 있다. 매개 변수 최적화를 통해 더 많은 시장 환경에 맞을 수 있다.

위험성

이 전략의 주요 위험은 다중 요소 모델 구축의 품질이다. 모델이 트렌드를 효과적으로 결정하지 못하면 대규모 가짜 신호를 생성 할 것입니다. 또한, 스톱 로스 전략은 본질적으로 사냥 될 위험이 있습니다.

이러한 위험을 완화하기 위해 모델 무게를 조정, 매개 변수 설정을 최적화, 다른 스톱 로스 전략과 결합하는 등의 측면에서 개선이 가능합니다. 비정상적인 시장이 발생하면 수동 개입도 필요합니다.

최적화 방향

이 전략은 다음과 같은 측면에서 최적화 될 수 있습니다.

  1. 최적의 조합을 찾기 위해 멀티 팩터 모델의 지표의 무게를 조정합니다.

  2. CCI, 변동성 등과 같은 더 많은 지표를 테스트하여 다중 요인 모델을 풍부하게하십시오.

  3. 더 많은 제품과 사이클에 맞게 매개 변수 설정을 최적화

  4. 최적의 조합을 찾기 위해 다른 stoploss 전략을 시도

  5. 기계 학습 드라이브를 가능하게 모델 훈련 및 전략 평가 모듈을 추가

요약

이 전략은 트렌드 판단과 위험 통제의 유기적인 조합을 달성하기 위해 다중 요소 모델과 적응적 인 스톱 로스 메커니즘을 통합합니다. 좋은 백테스팅 결과와 확장성을 가지고 있습니다. 지속적인 최적화로 장기 보유에 가치가있는 양적 전략이 될 수 있습니다.


/*backtest
start: 2022-12-12 00:00:00
end: 2023-12-18 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title="TradersAI_UTBot", overlay = true)
// CREDITS to @HPotter for the orginal code. 
// CREDITS to @Yo_adriiiiaan for recently publishing the UT Bot study based on the original code - 
// I just added some simple code to turn it into a strategy so that you all can backtest it to see the results for yourself! 
// Use this strategy on your favorite instrumnet and timeframe, with your favorite settings
// While @Yo_adriiiiaan mentions it works best on a 4-hour timeframe or above, 
// I am  happy to share here this working on a 15-minute chart on e-mini S&P 500 Index (using the KeyValue setting at 10)
// I am sure different people would discover different settings that work best for their preferred instrumnet/timeframe etc. 
// Play with it and enjoy! And, don't forget to share any positive results you might get! Good luck with your trading!

SOURCE = input(hlc3)
RSILENGTH = input(14, title = "RSI LENGTH")
RSICENTERLINE = input(52, title = "RSI CENTER LINE")
MACDFASTLENGTH = input(7, title = "MACD FAST LENGTH")
MACDSLOWLENGTH = input(12, title = "MACD SLOW LENGTH")
MACDSIGNALSMOOTHING = input(12, title = "MACD SIGNAL SMOOTHING")
a = input(10, title = "Key Vaule. 'This changes the sensitivity'") 
SmoothK = input(3)
SmoothD = input(3)
LengthRSI = input(14)
LengthStoch = input(14)
RSISource = input(close) 
c = input(10, title="ATR Period")
xATR = atr(c)
nLoss = a * xATR
xATRTrailingStop = iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss),
     iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), 
     iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss)))
pos =	iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1,
     iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) 
color = pos == -1 ? red: pos == 1 ? green : blue 
ema= ema(close,1)
above = crossover(ema,xATRTrailingStop )
below = crossover(xATRTrailingStop,ema)
buy = close > xATRTrailingStop and above 
sell = close < xATRTrailingStop and below
barbuy = close > xATRTrailingStop 
barsell = close < xATRTrailingStop 
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= green,textcolor = white, transp = 0, size = size.tiny)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= red,textcolor = white, transp = 0, size = size.tiny)
barcolor(barbuy? green:na)
barcolor(barsell? red:na)
alertcondition(buy, title='Buy', message='Buy')
alertcondition(sell, title='Sell', message='Sell')

if(buy)
    strategy.entry("UTBotBuy",strategy.long)
if(sell)
    strategy.entry("UTBotSell",strategy.short)

더 많은