양적 거래 신호 추적 및 다각화된 종료 전략 최적화 시스템


생성 날짜: 2024-12-13 11:39:06 마지막으로 수정됨: 2024-12-13 11:39:06
복사: 2 클릭수: 367
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

양적 거래 신호 추적 및 다각화된 종료 전략 최적화 시스템

개요

이 전략은 LuxAlgo® 신호와 중첩 지표에 기반한 정량 거래 시스템이다. 이 시스템은 주로 사용자 정의 경고 조건을 캡처하여 다중 포지션을 열고, 여러 탈퇴 신호와 결합하여 포지션을 관리한다. 이 시스템은 모듈화된 디자인을 채택하여, 지능적인 추적 중지, 트렌드 반전 확인, 그리고 전통적인 비율 중지 등의 여러 탈퇴 조건의 조합 사용을 지원한다.

전략 원칙

전략의 핵심 논리는 다음과 같은 핵심 부분으로 구성됩니다.

  1. 입국 신호 시스템: 사용자 정의 LuxAlgo® 경보 조건으로 다중 입국 신호를 트리거한다.
  2. 부채 관리: 부채 기능을 선택적으로 활성화하여 기존 지분을 기반으로 입장을 증가시킵니다.
  3. 다단계 탈퇴 메커니즘
    • 스마트 트래킹 스톱: 모니터링 가격과 스마트 트래킹 라인의 관계
    • 트렌드 확인 종료: 기본 및 강화 버전의 공중 확인 신호
    • 내장된 탈퇴 신호: 지표 자판의 여러 탈퇴 조건을 활용
    • 전통적인 스톱: 퍼센티지 기반의 고정 스톱 설정을 지원
  4. 시간 창 관리: 유연한 재검토 날짜 범위 설정 기능을 제공합니다.

전략적 이점

  1. 체계화된 위험 관리: 여러 계층의 탈퇴 메커니즘을 통해 하향 위험을 효과적으로 제어한다.
  2. 유연한 포지션 관리: 시장 상황에 따라 동적으로 조정할 수 있는 다양한 포지션 추가 및 제거 전략을 지원합니다.
  3. 고도의 사용자 정의: 사용자가 자유롭게 다른 탈퇴 조건을 조합하여 개인화 된 거래 시스템을 만들 수 있습니다.
  4. 모듈화 설계: 각 기능 모듈은 상대적으로 독립되어 유지 및 최적화를 용이하게 한다.
  5. 완전한 회귀 지원: 상세한 회귀 파라미터 설정을 제공하고, 역사 데이터 검증을 지원한다.

전략적 위험

  1. 신호 의존성 위험: 전략은 LuxAlgo® 지표의 신호 품질에 크게 의존한다.
  2. 시장 환경 적응성 위험: 다른 시장 환경에서는 전략 성능이 큰 차이가 있을 수 있다.
  3. 변수 감수성 위험: 여러 탈퇴 조건의 조합은 조기 탈퇴 또는 놓친 기회를 초래할 수 있다.
  4. 유동성 위험: 시장의 유동성이 부족할 때, 입출금의 실행 효과에 영향을 미칠 수 있다.
  5. 기술 실현 위험: 기술 장애를 방지하기 위해 지표와 전략의 안정적인 운영을 보장해야 합니다.

전략 최적화 방향

  1. 신호 시스템 최적화:
    • 더 많은 기술 지표를 도입하여 신호를 확인합니다.
    • 자율적 신호 경량 조정 장치를 개발
  2. 위험 통제 강화:
    • 변동율에 적응하는 손해 방지 장치를 추가합니다
    • 동적인 포지션 관리 시스템을 개발
  3. 성능 최적화:
    • 컴퓨팅 효율을 최적화하고 자원 소모를 줄입니다.
    • 신호 처리 논리를 개선하고 지연을 줄입니다.
  4. 기능 확장:
    • 더 많은 시장 분석 도구
    • 더 유연한 변수 최적화 프레임워크 개발

요약하다

이 전략은 LuxAlgo®의 고품질 신호와 다단계 위험 관리 시스템을 결합하여 양적 거래에 대한 전체적인 솔루션을 제공합니다. 모듈화 된 디자인과 유연한 구성 옵션으로 인해 훌륭한 적응력과 확장성이 있습니다. 일부 고유한 위험이 있지만 지속적인 최적화 및 개선으로 전략의 전체적인 성능은 여전히 향상될 수 있습니다.

전략 소스 코드
/*backtest
start: 2024-11-12 00:00:00
end: 2024-12-11 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Chart0bserver
// This strategy is NOT from the LuxAlgo® developers.  We created this to compliment their hard work.  No association with LuxAlgo® is intended nor implied.

// Please visit https://chart.observer to test your Tradingview Strategies in our paper-trading sandbox environment. Webhook your alerts to our API.
// Past performance does not ensure future results.  This strategy provided with absolutely no warranty and is for educational purposes only

// The goal of this strategy is to enter a long position using the Custom Alert condition feature of LuxAlgo® Signals & Overlays™ indicator
// To trigger an exit from the long position, use one or more of the common exit signals which the Signals & Overlays™ indicator provides.
// You will need to connect those signals to this strategy in the dialog box.  
// We're calling this a "piggyback" strategy because the LuxAlgo® Signals & Overlays indicator must be present, and remain on the chart.
// The Signals and Overlays™ indicator is invite-only, and requires a paid subscription from LuxAlgo® - https://luxalgo.com/?rfsn=8404759.b37a73

//@version=6
strategy("Simple Backtester for LuxAlgo® Signals & Overlays™", "Simple Backtester for LuxAlgo® S&O ", true, pyramiding=3, default_qty_type = 'percent_of_equity', calc_on_every_tick = true, process_orders_on_close=false, calc_on_order_fills=true, default_qty_value = 33, initial_capital = 10000, currency = currency.USD, commission_type = format.percent, commission_value = 0.10 )

// Initialize a flag to track order placement
var bool order_placed = false

// Reset the flag at the start of each new bar
if (not na(bar_index) and bar_index != bar_index[1])
    order_placed := false

// === Inputs which the user needs to change in the configuration dialog to point to the corresponding LuxAlgo alerts === //
// === The Signals & Overlays indicator must be present on the chart in order for this to work === //
la_EntryAlert = input.source(close, "LuxAlgo® Custom Alert signal", "Replace 'close' with your LuxAlgo® entry signal. For example, try using their Custom Alert.", display=display.none, group="Enter Long Position")
useAddOnTrades = input.bool(false, "Add to your long position on LuxAlgo® signals", display=display.none, group="Add-On Trade Signal for Longs")
la_AddOnAlert = input.source(close, "Add to open longs with this signal", "Replace 'close' with your desired Add-On Trade Signal", display=display.none, group="Add-On Trade Signal for Longs")
la_SmartTrail = input.source(close, "LuxAlgo® Smart Trail", "Replace close with LuxAlgo® Smart Trail", display=display.none, group="LuxAlgo® Signals & Overlays™ Alerts")
la_BearishConfirm = input.source(close, "LuxAlgo® Any Bearish Confirmation", "Replace close with LuxAlgo® Any Bearish Confirmation", display=display.none, group="LuxAlgo® Signals & Overlays™ Alerts")
la_BearishConfirmPlus = input.source(close, "LuxAlgo® Bearish Confirmation+", "Replace close with LuxAlgo® Bearish Confirmation+", display=display.none, group="LuxAlgo® Signals & Overlays™ Alerts")
la_BuiltInExits = input.source(close, "LuxAlgo® Bullish Exit", "Replace close with LuxAlgo® Bullish Exit", display=display.none, group="LuxAlgo® Signals & Overlays™ Alerts")
la_TrendCatcherDn = input.source(close, "LuxAlgo® Trend Catcher Down", "Replace close with LuxAlgo® Trend Catcher Down", display=display.none, group="LuxAlgo® Signals & Overlays™ Alerts")

// === Check boxes alowing the user to select exit criteria from th long position === //
exitOnSmartTrail = input.bool(true, "Exit long trade on Smart Trail Switch Bearish", group="Exit Long Conditions")
exitOnBearishConf = input.bool(false, "Exit on Any Bearish Confirmation", group="Exit Long Conditions")
exitOnBearishConfPlus = input.bool(true, "Exit on Bearish Confirmation+", group="Exit Long Conditions")
exitOnBuiltInExits = input.bool(false, "Exit on Bullish Exits", group="Exit Long Conditions")
exitOnTrendCatcher = input.bool(false, "Exit on Trend Catcher Down", group="Exit Long Conditions")

// === Optional Stop Loss ===//
useStopLoss = input.bool(false, "Use a Stop Loss", group="Optional Stop Loss")
stopLossPercent = input.float(0.25, "Stop Loss %", minval=0.25, step=0.25, group="Optional Stop Loss")

// Use Lux Algo's signals as part of your strategy logic
buyCondition = la_EntryAlert > 0 

if useAddOnTrades and la_AddOnAlert > 0 and strategy.opentrades > 0 and not buyCondition
    buyCondition := true

sellCondition = false
sellComment = ""

if exitOnSmartTrail and ta.crossunder(close, la_SmartTrail)
    sellCondition := true
    sellComment := "Smart Trail"

if exitOnBearishConf and la_BearishConfirm == 1
    sellCondition := true
    sellComment := "Bearish"

if exitOnBearishConfPlus and la_BearishConfirmPlus == 1
    sellCondition := true
    sellComment := "Bearish+"

if exitOnBuiltInExits and la_BuiltInExits == 1
    sellCondition := true
    sellComment := "Bullish Exit"

if exitOnTrendCatcher and la_TrendCatcherDn == 1
    sellCondition := true
    sellComment := "Trnd Over"

// Stop Loss Calculation
stopLossMultiplyer = 1 - (stopLossPercent / 100)
float stopLossPrice = na
if strategy.position_size > 0
    stopLossPrice := strategy.position_avg_price * stopLossMultiplyer

// -----------------------------------------------------------------------------------------------------------//
// Back-testing Date Range code  ----------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------------------------------//
fromMonth = input.int(defval=1, title='From Month', minval=1, maxval=12, group='Back-Testing Date Range')
fromDay = input.int(defval=1, title='From Day', minval=1, maxval=31, group='Back-Testing Date Range')
fromYear = input.int(defval=2024, title='From Year', minval=1970, group='Back-Testing Date Range')
thruMonth = 1 
thruDay = 1 
thruYear = 2112 

// === START/FINISH FUNCTION ===
start = timestamp(fromYear, fromMonth, fromDay, 00, 00)  // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59)  // backtest finish window
window() =>  // create function "within window of time
    time >= start and time <= finish ? true : false
// End Date range code -----//

if buyCondition and window() and not order_placed
    strategy.entry("Long", strategy.long)
    order_placed := true

if sellCondition and window() and not order_placed
    strategy.close("Long", comment=sellComment)
    order_placed := true

if useStopLoss and window()
    strategy.exit("Stop", "Long", stop=stopLossPrice)