동적 상자 비율 추적 전략

저자:차오장, 날짜: 2023-11-23 10:32:39
태그:

img

전반적인 설명

이 전략은 엔트리 라인과 스톱 로스 라인을 설정하기 위해 비율 가격 변화를 사용합니다. 가격이 엔트리 라인을 통과하고 가격이 스톱 로스 라인을 넘어설 때 포지션을 입력하고 가격이 스톱 로스 라인을 넘어설 때 포지션을 종료합니다. 주요 특징은 하나의 리스크 단위만을 취한다는 것입니다. 즉 이전 포지션이 미리 설정된 수익 목표에 도달 한 후에만 새로운 포지션을 추가 할 것입니다.

원칙

이 전략은 먼저 기준 가격을 설정하고 그 가격의 10%를 가격 범위로 사용합니다. 상한은 엔트리 라인, 하한은 스톱 로스 라인입니다. 가격이 엔트리 라인을 넘을 때 고정된 양이 구매됩니다. 가격이 스톱 로스 라인 아래에 떨어지면 포지션은 종료됩니다. 이윤을 창출 한 후 엔트리 및 스톱 로스 라인은 수익 범위를 확장하기 위해 비율로 조정됩니다. 이것은 전략이 트렌드 러닝을 추적 할 수있게합니다.

전략의 또 다른 핵심 포인트는 하나의 리스크 단위만을 취한다는 것입니다. 즉, 새로운 포지션은 현재 포지션이 수익 목표에 도달 한 후에 추가 될 것입니다. 새로운 포지션은 또한 새로운 엔트리 및 스톱 로스 라인을 따를 것입니다. 이것은 위험을 제한합니다.

이점 분석

이 전략은 트레일링 스톱과 포지션 사이즈의 장점을 결합하여 수익성있는 동시에 효과적인 위험 통제를 가능하게합니다.

  1. 엔트리 및 스톱 로스 라인 % 범위를 사용하면 자동 트렌드 추적이 가능합니다.
  2. 위험은 1자리로 제한되어 큰 손실을 피합니다.
  3. 새로운 포지션은 이익 이후만 추가되며, 추세를 추구하고 있는 것을 피합니다.
  4. 손익을 기록한 후 손익을 기록한 후 손익을 기록한 후

위험 분석

또한 몇 가지 위험이 있습니다.

  1. 만약 비율 범위가 너무 넓다면 위험은 커질 수 있습니다.
  2. 범위가 너무 좁으면 수익 잠재력이 제한됩니다.
  3. 잘못된 스톱 로스 투입은 조기 종료로 이어질 수 있습니다.
  4. 공격적인 추가는 손실을 증폭시킬 수 있습니다.

이러한 위험은 범위 크기, 입력 필터 등과 같은 매개 변수를 조정함으로써 피할 수 있습니다.

최적화

더 많은 최적화를 할 수 있습니다.

  1. 추세 지표와 결합하여 추세 방향을 결정합니다.
  2. 더 적응력 있는 라인을 위한 기계 학습 모델을 추가합니다.
  3. 다른 추가 조건을 테스트하여 위험을 줄이십시오
  4. 테스트를 통해 최적의 유지 기간을 찾는 방법

결론

이것은 간단하고 실용적인 비율 범위 기반 시스템입니다. 매개 변수 조정 및 모델 최적화를 통해이 전략은 투자자에게 안정적인 우수 성과를 창출하는 신뢰할 수있는 트렌드 추적 도구가 될 수 있습니다.


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

//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HermanBrummer 4 April 2021

strategy ("The Box Percent Strat", shorttitle="The Box", overlay = true)

///     Designed for LONG only on Daily, 2D or 3D Charts
///     Uses fixed investment risk amount, meaning you're willing to lose that amount per trade
///     Limit buy to not overpay

RiskPerTrade            = input(10000, "Risk losing this much per trade", tooltip="This calculates how much you will lose based on difference between the entry price and stop loss price")
TradeAboveMAFilterPer   = input(50, "The System won't trade if price is below this MA")

UpBoxSize               = (input(10, "Box size in %") * 0.01)+1 // 1.1 == 10% up
DnBoxSize               = 1-(input(10, "Box size in %") * 0.01) // 0.9 == 10% dn


var FirstBar            = close > 0 ? close : na
var FirstTop            = FirstBar * UpBoxSize
var FirstBot            = FirstBar * DnBoxSize


var top                 = sma(FirstTop, 1)
var bot                 = sma(FirstBot, 1)

///     The Box Calcs
if  high[2] > top
    top                 := top * UpBoxSize
    bot                 := bot * UpBoxSize
if  low[1]  < bot
    top                 := top * DnBoxSize
    bot                 := bot * DnBoxSize

 
plot(bot,   "Bot",      #ff0000) // Green
plot(top,   "Top",      #00ff00) // Red

mid                     = ((top-bot)/2)+bot 
plot(mid,   "Mid", color.gray)

TradeAboveMAFilter      = sma(close, TradeAboveMAFilterPer)
plot(TradeAboveMAFilter, "Trade AboveMAF Filter", color.yellow, 3, style=plot.style_circles)

// col = high[1] < top and high >= top ? color.white : na
// bgcolor(col)


///     Shares
RiskRange                   = close * abs(DnBoxSize - 1) // 0.9 - 1 == 1.10 // 10% abs so you don't get a neg number NB NB
Shares                      = RiskPerTrade / RiskRange 
//plot(close-RiskRange, "RiskRange", color.fuchsia)

Enter   =   high >= top
             and close[1] > TradeAboveMAFilter
             and strategy.opentrades[0] == strategy.opentrades[1]
             and strategy.opentrades[1] == strategy.opentrades[2] 
             and strategy.opentrades[2] == strategy.opentrades[3]
             and strategy.opentrades[3] == strategy.opentrades[4] 
             and strategy.opentrades[4] == strategy.opentrades[5]
             and strategy.opentrades[5] == strategy.opentrades[6]
             // won't enter if new positon was taken in the last 6 bars
             // need better code for this.

///     Buy & Sell
//  (new highs)    and  (Close above moving average filter) and (No new trades were taken receently)
if  Enter //(high >= top)  and  (close[1] > TradeAboveMAFilter) and strategy.opentrades[0] == strategy.opentrades[1] 
    strategy.order("En", strategy.long, qty=Shares, limit=top)//, stop=top)
    
//barcolor(strategy.position_size != 0 ? #00ff00 : color.gray)


// ///     If ONE Position THEN this Stop Because: 
// if  strategy.position_size == 1
//     strategy.exit("Ex", "En", stop=bot)
///     If it has more than one trad OPEN
if  strategy.position_size > 0
    strategy.exit("Ex", "En", stop=bot[2] )   // puts stop on old bot

//plot(strategy.position_avg_price, "Avg Price", color.yellow)





더 많은