주말 스윙 트레이딩 전략


생성 날짜: 2023-11-16 10:53:01 마지막으로 수정됨: 2023-11-16 10:53:01
복사: 0 클릭수: 601
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

주말 스윙 트레이딩 전략

개요

이 전략은 금요일 종결 가격에 따라 장점과 공백점의 입시 조건을 설정하고, 토요일과 일요일 개시 시에는 더 많은 코피를 하고, 월요일 개시 전에는 평점이다. 이 전략은 금요일 종결 가격 인근의 가격 변동을 포착하여 수익을 창출한다.

원칙

  1. 금일 종점 가격을 기준으로 기록한 것
  2. 토요일, 일요일에는:
    • 금요일에 4.5%가 넘는 가격으로 거래가 종료될 경우,
    • 금요일에 4.5%가 넘는 가격에 더 많은 것을 할 수 있습니다.
  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()