주말 변동성 거래 전략

저자:차오장, 날짜: 2023-11-16 10:53:01
태그:

img

전반적인 설명

이 전략은 금요일의 종료 가격에 기초하여 긴 및 짧은 입시 조건을 설정하고 토요일과 일요일의 개시 후 긴 또는 짧은 지점을 설정하여 월요일의 개시 전에 모든 포지션을 종료합니다. 전략은 주말 동안 금요일의 종료 가격 주위 가격 변동에서 이익을 얻는 것을 목표로합니다.

원칙

  1. 레퍼런스 가격으로 금요일의 종료 가격을 기록합니다.
  2. 토요일과 일요일 개장:
    • 만약 가격이 금요일 종료의 105% 이상이라면, 단축
    • 만약 가격이 금요일 종료의 95% 이하라면, 긴 거래가 됩니다.
  3. 이윤은 초기 자본의 3%로 설정됩니다.
  4. 월요일 개장 전에 모든 포지션을 닫습니다

이점 분석

  1. 시장 위험을 줄이기 위해 주말에 거래하는 저용량과 변동성
  2. 명확한 출입 및 출입 규칙은 전략 실행을 단순화합니다
  3. 단기 거래로 일정 한 작은 이윤 을 추구
  4. 짧은 주기로 높은 자본 매출

위험 분석

  1. 주말 가격 변동은 예상보다 작을 수 있으며 포지션을 열 수 없습니다.
  2. 과도한 변동성이 스톱 로드를 유발할 수 있습니다.
  3. 월요일의 중요한 사건은 가격 격차를 유발할 수 있습니다. 시간 내에 손실을 막을 수 없습니다.

위험 해결 방법:

  1. 항목에 대한 변동 범위를 조정
  2. 적절한 스톱 손실 지점을 설정
  3. 조기 포지션을 닫고 주말에 보유하지 마십시오.

최적화 지침

  1. 각기 다른 제품 특성에 따라 진입 기준을 조정
  2. 백테스트 결과를 기반으로 수익을 취하는 규칙을 최적화
  3. 자본 규모에 따라 레버리지를 선택
  4. 이동 평균과 같은 지표 필터를 시간 항목에 추가합니다

요약

이 단기 거래 전략은 매우 명확한 논리와 위험 관리 조치가 있습니다. 적절한 매개 변수 조정 및 지속적인 테스트 및 최적화로 안정적인 투자 수익을 창출 할 수 있습니다. 동시에 과도한 변동성으로 인한 큰 주말 손실의 위험은 적절한 위험 통제를 통해 관리해야합니다.


/*backtest
start: 2023-10-16 00:00:00
end: 2023-11-15 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
//Copyright Boris Kozak 
strategy("XBT Weekend Trade Strategy", overlay=true, default_qty_type=strategy.percent_of_equity,initial_capital=20000)
leverage = input(1,"Leverage")
profitTakingPercentThreshold = input(0.03,"Profit Taking Percent Threshold")

//****Code used for setting up backtesting.****///
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(12, "Backtest Start Month")
testStartDay = input(10, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2025, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FFFF : na
bgcolor(testPeriodBackgroundColor, transp=50)

testPeriod() => true
    
//****END Code used for setting up backtesting.****///


//*** Main entry point is here***//
// Figure out how many days since the Friday close 
days_since_friday = if dayofweek == 6
    0
else 
    if dayofweek == 7
        1
    else
        if dayofweek == 1
            2
        else
            if dayofweek == 2
                3
            else
                if dayofweek == 3
                    4
                else
                    if dayofweek == 4
                        5
                    else
                        6
    
// Grab the Friday close price
fridaycloseprice = request.security(syminfo.tickerid,'D',close[days_since_friday])
plot(fridaycloseprice)
strategy.initial_capital = 50000
// Only perform backtesting during the window specified 
if testPeriod()
    // If we've reached out profit threshold, exit all positions 
    if ((strategy.openprofit/strategy.initial_capital) > profitTakingPercentThreshold)
        strategy.close_all()
    // Only execute this trade on saturday and sunday (UTC)
    if (dayofweek == 7.0 or dayofweek == 1.0)
        // Begin - Empty position (no active trades)
        if (strategy.position_size == 0)
            // If current close price > threshold, go short 
            if ((close>fridaycloseprice*1.045))
                strategy.entry("Short Entry", strategy.short, leverage)
            else
                // If current close price < threshold, go long
                if (close<(fridaycloseprice*0.955))
                    strategy.entry("Long Entry",strategy.long, leverage)
        // Begin - we already have a position
        if (abs(strategy.position_size) > 0)
            // We are short 
            if (strategy.position_size < 0)
                if ((close>strategy.position_avg_price*1.045))
                    // Add to the position
                    strategy.entry("Adding to Short Entry", strategy.short, leverage)
            else
                strategy.entry("Long Entry",strategy.long,leverage)
    // On Monday, if we have any open positions, close them 
    if (dayofweek==2.0)
        strategy.close_all()
 






더 많은