진짜 거북이암 거북이 처럼 굳건 한 전략

저자:차오장, 날짜: 2024-02-18 14:34:40
태그:

img

전반적인 설명

로크 거북이 전략 (Steadfast as a Rock Turtle strategy) 은 브래디 거북이 거래 방법론의 규칙을 따르는 양적 거래 전략이다. 포지션을 입력하기 위해 가격 브레이크오프를 사용하고 출구에 대한 추적 스톱을 중지합니다. 진정한 변동성에 따라 포지션 사이즈를 계산하고 거래 당 손실을 엄격하게 제어합니다. 전략은 장기적인 안정성을 가지고 있으며 안정적인 바위와 마찬가지로 드래운드에 대한 강한 관용을 가지고 있습니다.

원칙

출입규칙

로크 거북이 전략처럼 안정적인 전략은 브레이크오웃을 입력합니다. 구체적으로, 그것은 지정된 룩백 기간 동안 가장 높은 최고와 가장 낮은 최저를 계산합니다. 가격이 가장 높은 최고 이상으로 넘으면 길게됩니다. 가격이 가장 낮은 최저 아래로 넘으면 짧게됩니다.

예를 들어, 20 바로 설정된 엔트리 기간으로, 전략은 지난 20 바에서 가장 높은 최고와 가장 낮은 최저를 추출합니다. 현재 바의 종료가 지난 20 바의 가장 높은 최고를 초과하면 전략은 가장 높은 최고 이상의 브레이크에 대비하기 위해 그 가까운 가격에 긴 스톱 주문을합니다.

출입규칙

로크 거북이 전략으로 안정적으로 종료 중지 추적 중지. 그것은 동적으로 지정된 출구 기간 동안 가장 높은 높고 가장 낮은 낮을 계산하고 출구 채널을 결정하는 데 사용합니다.

장기간 유지하면, 가격이 출구 채널의 최저 하위 밑으로 떨어지면, 포지션이 멈출 것입니다.

또한, 전략은 진정한 변동성에 기초한 스톱 로스 수준을 계산하여 최종 스톱으로 작용합니다. 가격이 출구 채널 이상으로 유지되는 한, 스톱 로스는 추적 및 조정을 계속하며, 스톱이 불필요한 스톱 아웃을 위해 너무 단단하지 않고 위험 통제를 위해 너무 느슨하지 않도록 적절한 거리에 설정되어 있는지 확인하십시오.

위치 크기

로크 거북이 전략으로 안정적 인 전략은 진정한 변동성에 따라 포지션을 크게합니다. 구체적으로, 먼저 입시 가격 근처의 잠재적 인 손실 비율을 추정하고, 예상 위험 매개 변수에서 포지션 크기를 역으로 계산합니다. 이것은 거래당 최대 손실을 효과적으로 제어합니다.

이점 분석

안정적인 운영

바위 거북이 전략처럼 견고한 전략은 임의의 수정 없이 입구와 출구에 대한 고전적인 거북이 거래 규칙을 엄격히 준수합니다. 이것은 일시적인 판단력 부족으로 인한 시스템 장애없이 장기간 안정적으로 실행 할 수 있습니다.

마감 회복력

브레이크아웃에 들어가면서 전략은 과대평가된 엔트리를 효과적으로 피하고 시스템 손실의 가능성을 줄입니다. 그리고 스톱 추적 스톱으로 출퇴함으로써 거래당 최대 손실이 통제되도록 보장하여 크게 연속 손실을 방지하여 깊은 마감으로 이어집니다.

위험 감축성

진정한 변동성에 기초한 크기를 측정함으로써 전략은 허용 범위 내에서 거래당 최대 손실을 엄격히 제어합니다. 그리고 정지 거리를 추적함으로써 위험을 효과적으로 억제하기 위해 적시에 손실을 줄일 수 있습니다.

위험 분석

분해 실패 위험

가격이 낮은 추진력으로 돌파되면 잘못된 입력 손실을 유발하는 잘못된 신호가 될 수 있습니다. 불효율적인 돌파 소음을 피하기 위해 더 많은 입력 확인 규칙으로 매개 변수를 조정해야합니다.

매개 변수 최적화 위험

입시/출시 기간과 같은 정적 전략 매개 변수는 시장 체제가 급격하게 변화하면 무효가 될 수 있습니다. 이러한 매개 변수는 적응을 위해 재평가 및 재 최적화가 필요합니다.

기술 지표 고장 위험

가격 브레이크업 플래그처럼 사용되는 지표는 트렌드 또는 변동성이 크게 변할 때 실패 할 수 있습니다. 전략 신뢰성을 향상시키기 위해 더 많은 기술이 통합되어야합니다.

최적화 방향

트렌드 필터를 추가합니다

MA, MACD와 같은 일반적인 트렌드 지표가 추가 될 수 있습니다. 반 트렌드 윙사 (whipsaws) 를 피하기 위해 상승 추세에서만 길고 하락 추세에서만 짧습니다.

시간 프레임 합성

더 높은 시간 프레임 지표, 예를 들어 일일 MA 수준은 더 낮은 시간 프레임 신호를 보완하기 위해 전반적인 방향을 확인하는 데 도움이 될 수 있습니다.

동적 매개 변수 조정

기계 학습은 변화하는 시장 역학에서 효율성을 유지하기 위해 최신 데이터를 기반으로 전략 매개 변수를 지속적으로 자동으로 업데이트 할 수 있습니다.

요약

로크 거북이 전략처럼 확고한 전략은 고전적인 거북이 거래 방법론을 엄격히 따르고 있으며, 엄격한 위험 통제와 함께 브레이크아웃 진입 및 추적 스톱 출출을 수행합니다. 이것은 강력한 드라우다운 탄력성을 가진 장기간 안정적인 운영을 허용합니다. 잘못된 브레이크아웃, 매개 변수 실패 등과 같은 위험에도 불구하고 트렌드 필터, 타임프레임 합성, 동적 튜닝 등과 같은 추가로 효과적으로 완화되어 전략 안정성을 크게 향상시킬 수 있습니다. 전반적으로 신뢰하고 유지하는 가치가있는 우수한 견고한 전략입니다.


/*backtest
start: 2024-01-18 00:00:00
end: 2024-02-17 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Real Turtle", shorttitle = "Real Turtle", overlay=true, pyramiding=1, default_qty_type= strategy.percent_of_equity,calc_on_order_fills=false, slippage=25,commission_type=strategy.commission.percent,commission_value=0.075)
//////////////////////////////////////////////////////////////////////
// Testing Start dates
testStartYear = input(2016, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
//Stop date if you want to use a specific range of dates
testStopYear = input(2030, "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
// Use if using a specific date range
testPeriodBackground = input(title="Color Background?", type=bool, defval=false)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)

testPeriod() => true
// Component Code Stop
//////////////////////////////////////////////////////////////////////

//How many candles we want to determine our position entry
enterTrade = input(20, minval=1, title="Entry Channel Length")
//How many candles we want ot determine our position exit
exitTrade = input(10, minval=1, title="Exit Channel Length")

//True Range EMA Length
trLength = input(13, minval=1, title="True Range Length")
//Go all in on every trade
allIn = input(false, title="Use whole position on every trade")
dRisk = input(2, "Use Desired Risk %")
//How much of emaTR to use for TS offset
multiEmaTR = input(2, "Desired multiple of ema Tr (N)")
//absolute value (highest high of of this many candles - lowest high of this many candles) . This is used if we want to change our timeframe to a higher timeframe otherwise just works like grabbing high o r low of a candle
//True range is calculated as just high - low. Technically this should be a little more complicated but with 24/7 nature of crypto markets high-low is fine.
trueRange = max(high - low, max(high - close[1], close[1] - low))
//Creates an EMA of the true range by our custom length
emaTR = ema(trueRange, trLength)
//Highest high of how many candles back we want to look as specified in entry channel for long
longEntry = highest(enterTrade)
//loweest low of how many candles back we want to look as specified in exit channel for long
exitLong = lowest(exitTrade)
//lowest low of how many candles back want to look as specified in entry channel for short
shortEntry = lowest(enterTrade)
//lowest low of how many candles back want to look as specified in exit channel for short
exitShort = highest(exitTrade)
//plots the longEntry as a green line
plot(longEntry[1], title="Long Entry",color=green)
//plots the short entry as a purple line
plot(shortEntry[1], title="Short Entry",color=purple)

howFar = barssince(strategy.position_size == 0)
actualLExit = strategy.position_size > 0 ? strategy.position_avg_price - (emaTR[howFar] * multiEmaTR) : longEntry - (emaTR * multiEmaTR)
actualLExit2 = actualLExit > exitLong ? actualLExit : exitLong
actualSExit = strategy.position_size < 0 ? strategy.position_avg_price + (emaTR[howFar] * multiEmaTR) : shortEntry + (emaTR * multiEmaTR)
actualSExit2 = actualSExit < exitShort ? actualSExit : exitShort

//plots the long exit as a red line
plot(actualLExit2[1], title="Long Exit",color=red)
//plots the short exit as a blue line
plot(actualSExit2[1], title="Short Exit",color=yellow)


//Stop loss in ticks
SLLong =(emaTR * multiEmaTR)/ syminfo.mintick
SLShort = (emaTR * multiEmaTR)/ syminfo.mintick


//Calculate our potential loss as a whole percentage number. Example 1 instead of 0.01 for 1% loss. We have to convert back from ticks to whole value, then divided by close
PLLong = ((SLLong * syminfo.mintick) * 100) / longEntry
PLShort = ((SLShort * syminfo.mintick) * 100) / shortEntry
//Calculate our risk by taking our desired risk / potential loss. Then multiple by our equity to get position size. we divide by close because we are using percentage size of equity for quantity in this script as not actual size.
//we then floor the value. which is just to say we round down so instead of say 201.54 we would just input 201 as TV only supports whole integers for quantity.
qtyLong = floor(((dRisk / PLLong) * strategy.equity) /longEntry )
qtyShort = floor(((dRisk / PLShort) * strategy.equity) /shortEntry )
qtyLong2 = allIn ? 100 : qtyLong
qtyShort2 = allIn ? 100 : qtyShort
//Only open long or short positions if we are inside the test period specified earlier
if testPeriod()
    //Open a stop market order at our long entry price and keep it there at the quantity specified. This order is updated/changed on each new candlestick until a position is opened
    strategy.entry("long", strategy.long, stop = longEntry, qty = qtyLong2) 
    //sets up or stop loss order by price specified in our actualLExit2 variable
    strategy.exit("Stoploss-Long", "long", stop=actualLExit2)
    
     //Open a stop market order at our short entry price and keep it there at the quantity specified. This order is updated/changed on each new candlestick until a position is opened
    strategy.entry("short", strategy.short, stop = shortEntry, qty = qtyShort2)
    //sets up or stop loss order by price specified in our actualLExit2 variable
    strategy.exit("Stoploss-Short", "short", stop=actualSExit2)



더 많은