단기 거래 전략

저자:차오장, 날짜: 2023-10-25 14:40:21
태그:

img

전반적인 설명

이것은 채널 브레이크아웃을 기반으로 한 단기 거래 전략입니다. 트렌드의 시작과 끝을 결정하고 그에 따라 거래 결정을 내리기 위해 채널의 상부 및 하부 레일의 브레이크아웃을 사용합니다. 강한 트렌딩 시장에서이 브레이크아웃 전략은 괜찮은 이익을 창출 할 수 있습니다.

전략 논리

  1. 이 전략은 먼저 채널의 상부와 하부 레일을 만들기 위해 특정 기간 동안 가장 높은 높기와 가장 낮은 낮은 것을 계산합니다.

  2. 만약 가격이 상위 레일을 넘어서면, 롱가, 하위 레일을 넘어서면, 쇼트가 됩니다.

  3. 이동 스톱 손실을 사용하여 위험을 제어합니다. 스톱 손실은 채널의 중간 선에 설정됩니다.

  4. 두 가지 선택적인 출구 규칙이 있습니다: 중간선으로 돌아가거나 이동 스톱 손실을 따르십시오. 전자는 빠르게 이익을 실현하고 후자는 위험을 제어합니다.

  5. 채널 기간과 다른 매개 변수를 조정하여 다른 시장 조건에 대한 전략을 최적화 할 수 있습니다.

이점 분석

  1. 간단하게 실행할 수 있습니다. 가격 채널 관계를 모니터링하고 거래 규칙을 따르십시오.

  2. 트렌드를 따라 거래하면 트렌드 반대 위험이 없습니다.

  3. 명확하고 직관적인 채널은 뚜렷한 입력 신호를 제공합니다.

  4. 좋은 수익률은 대부분의 경우 만족스러운 수익을 얻을 수 있습니다.

  5. 다양한 시장에서 최적화를 위해 많은 조정 가능한 매개 변수.

위험 분석

  1. 탈출이 실패할 수도 있고 함락될 수도 있습니다.

  2. 채널은 형성 기간이 필요하고, 범주형 시장에는 적합하지 않습니다.

  3. 중간 스톱 로스로 돌아가는 것은 너무 보수적이어서 트렌드를 유지할 수 없습니다.

  4. 매개 변수 최적화는 역사적인 데이터를 필요로 합니다. 실시간 거래에서 너무 적합할 수 있습니다.

  5. 브레이크오프 포인트의 기계적 거래는 거래 빈도와 슬라이프 비용의 증가를 초래할 수 있습니다.

최적화 방향

  1. 다양한 기간의 채널을 평가하고 최적의 채널을 선택하세요.

  2. 중간에 돌아와 더 나은 출구 메커니즘을 찾기 위해 이동 중지 손실을 테스트합니다.

  3. 스톱 로스 비율을 최적화하여 스톱 아웃의 가능성을 줄이세요.

  4. 부적절한 브레이크오웃 트레이드를 피하기 위해 트렌드 필터를 추가합니다.

  5. 포지션 크기를 늘려도 위험을 조절하는 것이 좋습니다.

요약

전체적으로 이것은 성숙한 단기 브레이크아웃 전략이다. 명확한 진입 규칙과 적절한 위험 통제를 가지고 있으며 일반적으로 잘 작동한다. 파라미터 튜닝을 통해 추가 개선이 이루어질 수 있다. 그러나 고유 한 한계, 다른 시장에 대한 조정이 필요하다는 점에 유의해야 한다. 체계적으로 사용되면 일관된 전반적인 이윤을 가져야 한다.


/*backtest
start: 2022-10-18 00:00:00
end: 2023-10-24 00:00:00
period: 1d
basePeriod: 1h
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/
// Strategy testing and optimisation for free Bitmex trading bot 
// © algotradingcc 

//@version=4
strategy("Channel Break [for free bot]", overlay=true, default_qty_type= strategy.percent_of_equity, initial_capital = 1000, default_qty_value = 20, commission_type=strategy.commission.percent, commission_value=0.075)

//Options
buyPeriod = input(13, "Channel Period for Long position")
sellPeriod = input(18, "Channel Period for Short position")
isMiddleExit = input(true, "Is exit on Base Line?")
takeProfit = input(46, "Take Profit (%) for position")
stopLoss = input(9, "Stop Loss (%) for position")

// Test Start
startYear = input(2005, "Test Start Year")
startMonth = input(1, "Test Start Month")
startDay = input(1, "Test Start Day")
startTest = timestamp(startYear,startMonth,startDay,0,0)

//Test End
endYear = input(2050, "Test End Year")
endMonth = input(12, "Test End Month")
endDay = input(30, "Test End Day")
endTest = timestamp(endYear,endMonth,endDay,23,59)

timeRange = time > startTest and time < endTest ? true : false

// Long&Short Levels
BuyEnter = highest(buyPeriod)
BuyExit = isMiddleExit ? (highest(buyPeriod) + lowest(buyPeriod)) / 2: lowest(buyPeriod)

SellEnter = lowest(sellPeriod)
SellExit = isMiddleExit ? (highest(sellPeriod) + lowest(sellPeriod)) / 2: highest(sellPeriod)

// Plot Data
plot(BuyEnter, style=plot.style_line, linewidth=2, color=color.blue, title="Buy Enter")
plot(BuyExit, style=plot.style_line, linewidth=1, color=color.blue, title="Buy Exit", transp=50)
plot(SellEnter, style=plot.style_line, linewidth=2, color=color.red, title="Sell Enter")
plot(SellExit, style=plot.style_line, linewidth=1, color=color.red, title="Sell Exit", transp=50)

// Calc Take Profits & Stop Loss
TP = 0.0
SL = 0.0
if strategy.position_size > 0
    TP := strategy.position_avg_price*(1 + takeProfit/100)
    SL := strategy.position_avg_price*(1 - stopLoss/100)

if strategy.position_size > 0 and SL > BuyExit
    BuyExit := SL
    
if strategy.position_size < 0
    TP := strategy.position_avg_price*(1 - takeProfit/100)
    SL := strategy.position_avg_price*(1 + stopLoss/100)

if strategy.position_size < 0 and SL < SellExit
    SellExit := SL
    
    
// Long Position    
if timeRange and strategy.position_size <= 0
    strategy.entry("Long", strategy.long, stop = BuyEnter)
strategy.exit("Long Exit", "Long", stop=BuyExit, limit = TP, when = strategy.position_size > 0)


// Short Position
if timeRange and strategy.position_size >= 0
    strategy.entry("Short", strategy.short, stop = SellEnter)
    
strategy.exit("Short Exit", "Short", stop=SellExit, limit = TP, when = strategy.position_size < 0)

// Close & Cancel when over End of the Test
if time > endTest
    strategy.close_all()
    strategy.cancel_all()


더 많은