PresentTrend 트렌드 추종 전략


생성 날짜: 2023-09-21 15:00:08 마지막으로 수정됨: 2023-09-21 15:00:08
복사: 0 클릭수: 615
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

개요

현재 트렌드 전략은 독특한 사용자 정의 트렌드 추적 전략이다. 이 전략은 단기 및 장기 시장 추세를 결합하여 다른 시장 조건에 적합합니다.

전략 원칙

이 전략은 두 부분으로 구성되어 있습니다.

  1. 사용자 정의 RSI 또는 MFI 지표: 이 지표는 RSI 또는 MFI에 의해 계산된 PresentTrend 값에 따라 해당 값에 따라 골드 포크 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리 사다리

  2. ATR 지표: 이것은 일반적인 트렌드를 따르는 지표로, 평균 실제 변동 범위를 사용한다.

두 전략의 구매 및 판매 신호가 동시에 트리거되면, 그 전략은 상장 또는 상장한다. 이것은 거래가 단기 및 장기 동향이 일치하는 경우에만 발생하도록 보장하여 전략의 신뢰성을 높인다.

전략적 이점

  • 단기 및 장기 동향을 결합하여 다양한 시장 조건에 적용됩니다.
  • 사용자 정의 지표와 ATR을 사용하여 신호 신뢰성을 향상
  • 다양한 거래 스타일에 맞게 다중, 다중 또는 양방향으로 거래할 수 있습니다.
  • 기본 매개 변수는 감수성과 안정성을 균형을 맞추기 위해 최적화되었습니다.
  • 개인 취향에 따라 변수를 조정할 수 있고, 최적화 전략을 사용할 수 있습니다.

전략적 위험과 해결책

  • 모든 트렌드는 전략에 따라 운용될 위험이 있습니다.
  • 다공간 쌍방향 거래는 거래 수와 수수료를 증가시킬 수 있습니다.
  • 잘못 설정된 파라미터는 너무 많은 오류 신호를 발생시킬 수 있습니다.
  • 거래지점주기를 적절히 단축하여 마이너스 리스크를 줄일 수 있습니다.
  • 선택적으로 상장하거나 상장하여 거래량을 줄일 수 있습니다.
  • 충분히 테스트하고, 적절하게 조정하여, 합리적인 파라미터를 보장한다.

전략 최적화 방향

  • 단독 손실을 통제하기 위한 손해 방지 장치의 증강
  • 다른 지표와 함께 필터링 신호를 사용하여 잘못된 거래를 줄이십시오.
  • 다양한 포지션 주기 변수를 테스트하여 최적의 변수를 찾습니다.
  • 기계 학습에 기반한 자동 최적화 매개 변수를 시도합니다.
  • 더 많은 데이터 소스, 예를 들어 주문 흐름 정보
  • 정책 코드를 최적화하여 실행 효율성을 높여라

요약하다

PresentTrend 전략은 전체적으로 매우 효과적인 트렌드 추적 전략이다. 그것은 단기 및 장기 트렌드 지표를 동시에 결합하여 민감성을 유지하면서 신호의 신뢰성을 높인다. 방향, 매개 변수 및 추가 논리를 조정함으로써 전략은 다양한 시장 환경과 거래자의 요구에 적응할 수 있다.

전략 소스 코드
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading

//@version=5

// Define the strategy settings
strategy('PresentTrend - Strategy [presentTrading]' , overlay=true, precision=3, default_qty_type=strategy.cash, 
 commission_value= 0.1, commission_type=strategy.commission.percent, slippage= 1, 
  currency=currency.USD, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, initial_capital= 10000)

// Define the input parameters
priceSource  = input.source(title='Source', defval=hlc3, group='PresentTrend') // The price source to use
lengthParam  = input.int(title='Length', defval=14, group='PresentTrend') // The length of the moving average
multiplier = input.float(title='Multiplier', defval=1.618, step=0.1, group='PresentTrend') // The multiplier for the ATR
indicatorChoice  = input.bool(title='Whether to use RSI or MFI', defval=false, group='PresentTrend') // Whether to use RSI or MFI

// Add a parameter for choosing Long or Short
tradeDirection = input.string(title="Trade Direction", defval="Both", options=["Long", "Short", "Both"])

// Calculate the ATR and the upT and downT values
ATR = ta.sma(ta.tr, lengthParam)
upperThreshold = low - ATR * multiplier 
lowerThreshold  = high + ATR * multiplier 

// Initialize the PresentTrend indicator
PresentTrend = 0.0

// Calculate the PresentTrend indicator
PresentTrend := (indicatorChoice ? ta.rsi(priceSource, lengthParam) >= 50 : ta.mfi(hlc3, lengthParam) >= 50) ? upperThreshold < nz(PresentTrend[1]) ? nz(PresentTrend[1]) : upperThreshold : lowerThreshold > nz(PresentTrend[1]) ? nz(PresentTrend[1]) : lowerThreshold

// Calculate the buy and sell signals
longSignal  = ta.crossover(PresentTrend, PresentTrend[2])
shortSignal  = ta.crossunder(PresentTrend, PresentTrend[2])

// Calculate the number of bars since the last buy and sell signals
barsSinceBuy = ta.barssince(longSignal)
barsSinceSell = ta.barssince(shortSignal)
previousBuy = ta.barssince(longSignal[1])
previousSell = ta.barssince(shortSignal[1])

// Initialize the direction variable
trendDirection = 0

// Calculate the direction of the trend
trendDirection := longSignal and previousBuy > barsSinceSell ? 1 : shortSignal and previousSell > barsSinceBuy ? -1 : trendDirection[1]

// Check the trade direction parameter before entering a trade
if (trendDirection == 1 and (tradeDirection == "Long" or tradeDirection == "Both"))
    strategy.entry("Buy", strategy.long) 
if (trendDirection == -1 and (tradeDirection == "Short" or tradeDirection == "Both"))
    strategy.entry("Sell", strategy.short) 

// Add a stop mechanism when the tradeDirection is one-sided
if (tradeDirection == "Long" and trendDirection == -1)
    strategy.close("Buy")
if (tradeDirection == "Short" and trendDirection == 1)
    strategy.close("Sell")

// Visualization
plot(PresentTrend, color=color.blue, title="PresentTrend")
plotshape(series=longSignal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=shortSignal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")