조커를 추종하는 수익 전략

저자:차오장, 날짜: 2023-09-23 15:04:20
태그:

전반적인 설명

조커 트레일링 테이크프리트 전략은 유동 평균에 기반한 트렌드 다음 전략이다. 트렌드가 반전될 때 손실을 절감하면서 시장이 유리한 방향으로 움직일 때 수익을 극대화하기 위해 트레일링 스톱 손실과 트레일링 테이크프리트의 특징을 결합한다.

전략 논리

이 전략은 전체 트렌드를 식별하기 위해 빠르고 느린 이동 평균을 사용합니다. 빠른 MA가 느린 MA를 넘을 때 길고 빠른 MA가 느린 MA를 넘을 때 짧습니다.

이 전략은 먼저 포지션을 개설한 후 구성된 비율에 기초하여 초기 영업이익 가격을 계산합니다. 후속 영업이익이 활성화되면 기호의 최소 틱 크기와 구성된 후속 비율에 기초하여 후속 단계를 계산합니다.

포지션 방향이 신호와 일치하면 트레일링이 비활성화되면 리미트 오더가 사용된다. 트레일링이 활성화되면 단계 크기에 따라 리미트 오더가 사용된다.

이점 분석

  • 이동 평균은 시장 소음을 필터링하고 잘못된 신호를 피합니다.

  • 후속 수익은 가격 행동에 따라 수익 수준을 동적으로 조정합니다. 이것은 고정된 수익 가격보다 더 유연합니다.

  • 이윤을 취득하는 후속은 더 많은 이윤을 확보하고 수익을 반환 할 가능성을 줄입니다. 또한 고정된 이윤을 취득하는 수준으로 너무 일찍 빠져 나가는 것을 피합니다.

  • 스톱 로스 함수는 트렌드가 역전될 때 전략이 일찍 종료되도록 허용합니다.

위험 분석

  • 이동 평균은 거대한 가격 변동 중에 잘못된 신호 또는 지연을 일으킬 수 있습니다. 이것은 잘못된 방향으로 거래로 손실을 초래할 수 있습니다. MA 매개 변수 최적화 및 필터를 추가하는 것이 도움이 될 수 있습니다.

  • 너무 높게 설정된 취득 비율은 보유 기간과 실제 및 예상 취득 가격 사이의 오차를 증가시킵니다. 비율을 낮추면이 위험이 감소합니다.

  • 후속 단계 세트가 너무 작으면 과도한 주문 업데이트가 발생하고 수수료와 미끄러짐이 증가합니다. 후속 오프셋의 최적화가 필요합니다.

  • 후속 TP는 상승만 하고 마감액을 고려하지 않는다. 이것은 실제와 예상되는 영업가격 사이의 오차를 일으킬 수 있다. 양방향 후속 메커니즘은 도움이 될 수 있다.

최적화 방향

  • 변동성에 기초한 MA 매개 변수들의 동적 조정을 고려하십시오. 변동성이 증가하는 더 큰 기간과 변동성이 감소하는 더 작은 기간.

  • 연구 최적의 취득 비율을 다른 제품과 시장에서 오차 위험을 최소화하기 위해.

  • 상향과 하향을 모두 추적하는 쌍방향 추행 메커니즘을 탐구하십시오. 이것은 수익을 가격에 더 가깝게 유지할 것입니다.

  • 트렌드 강도 지표를 포함하여 약한 트렌드에서 수익률을 줄이고 강한 트렌드에서 수익률을 증가시킵니다.

  • 기계 학습 모델과 결합하여 예측된 가격 범위에 따라 수익률을 동적으로 설정합니다.

결론

조커 트레일링 테이크프로프트 전략은 명확한 구조를 가지고 있으며 트렌드 방향을 정의하고 수익을 잠금하기 위해 트레일링을 사용하는 이동 평균을 사용합니다. 리스크를 제어하면서 트렌드를 원활하게 따라가기 위해 트레일링 스톱과 트레일링 테이크프로프트의 장점을 결합합니다. 매개 변수 최적화와 더 복잡한 시장 환경에 적응하기 위해 수익을 취하는 메커니즘을 향상시킴으로써 추가 개선이 가능합니다. 전반적으로 이것은 추가 연구와 응용 가치가있는 전략입니다.


/*backtest
start: 2023-08-23 00:00:00
end: 2023-09-22 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(title='Joker Trailing TP Bot', shorttitle='Joker TTP Bot', overlay=true, pyramiding=0, process_orders_on_close=false, close_entries_rule='ANY', calc_on_every_tick=false, calc_on_order_fills=false, commission_type=strategy.commission.percent, commission_value=0.07, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=1000, currency=currency.USD) //, max_labels_count=500)

fromDate = input(timestamp('01 Jan 2021 00:00 UTC'), 'From Date')
toDate = input(timestamp('31 Dec 2121 23:59 UTC'), 'To Date')
fastMALen = input.int(23, 'Fast SMA Length')
slowMALen = input.int(50, 'Slow SMA Length')
longTakeProfitPerc = input.float(0.5, 'Long Take Profit %', minval=0.05, step=0.05) * 0.01
shortTakeProfitPerc = input.float(0.5, 'Short Take Profit %', minval=0.05, step=0.05) * 0.01
enableTrailing = input.bool(true, 'Enable Trailing')
trailingTakeProfitPerc = input.float(0.01, 'Trailing Take Profit %', minval=0.01, maxval=100, step=0.01) * 0.01

float fastMA = ta.sma(close, fastMALen)
float slowMA = ta.sma(close, slowMALen)
bool isWithinPeriod = true
bool openLongPosition = isWithinPeriod and ta.crossover(fastMA, slowMA)
bool openShortPosition = isWithinPeriod and ta.crossunder(fastMA, slowMA)
bool longIsActive = openLongPosition or strategy.position_size > 0
bool shortIsActive = openShortPosition or strategy.position_size < 0

float longTakeProfitPrice = na
longTakeProfitPrice := if longIsActive
    if openLongPosition and not (strategy.position_size > 0)
        close * (1 + longTakeProfitPerc)
    else
        nz(longTakeProfitPrice[1], close * (1 + longTakeProfitPerc))
else
    na

float shortTakeProfitPrice = na
shortTakeProfitPrice := if shortIsActive
    if openShortPosition and not (strategy.position_size < 0)
        close * (1 - shortTakeProfitPerc)
    else
        nz(shortTakeProfitPrice[1], close * (1 - shortTakeProfitPrice))
else
    na

float longTrailingTakeProfitStepTicks = longTakeProfitPrice * trailingTakeProfitPerc / syminfo.mintick
float shortTrailingTakeProfitStepTicks = shortTakeProfitPrice * trailingTakeProfitPerc / syminfo.mintick

strategy.entry(id = 'Long Entry', direction = strategy.long, when = openLongPosition, alert_message = 'Long(' + syminfo.ticker + '): Started')
strategy.entry(id = 'Short Entry', direction = strategy.short, when = openShortPosition, alert_message = 'Short(' + syminfo.ticker + '): Started')
strategy.exit(id = 'Long Take Profit', from_entry = 'Long Entry', limit = enableTrailing ? na : longTakeProfitPrice, trail_price = enableTrailing ? longTakeProfitPrice : na, trail_offset = enableTrailing ? longTrailingTakeProfitStepTicks : na, when = longIsActive, alert_message = 'Long(' + syminfo.ticker + '): Take Profit activated')
strategy.exit(id = 'Short Take Profit', from_entry = 'Short Entry', limit = enableTrailing ? na : shortTakeProfitPrice, trail_price = enableTrailing ? shortTakeProfitPrice : na, trail_offset = enableTrailing ? shortTrailingTakeProfitStepTicks : na, when = shortIsActive, alert_message = 'Short(' + syminfo.ticker + '): Take Profit activated')

plot(series = fastMA, title='Fast SMA', color = color.blue, linewidth = 1, style = plot.style_line)
plot(series = slowMA, title='Slow SMA', color = color.orange, linewidth = 1, style = plot.style_line)
plot(series = longTakeProfitPrice, title='Long Take Profit', color = color.green, linewidth = 1, style = plot.style_cross, offset = 1)
plot(series = shortTakeProfitPrice, title='Short Take Profit', color = color.red, linewidth = 1, style = plot.style_cross, offset = 1)
plot(series = strategy.position_avg_price, title='Position', color = color.white, linewidth = 1, style = plot.style_linebr)


더 많은