내부 진폭 중지 손실을 기반으로 하는 모멘텀 브레이크업 전략

저자:차오장날짜: 2023-11-23 14:14:58
태그:

img

전반적인 설명

이 전략은 폭발적인 변동성을 가진 일방적인 시장이 있는지 판단하기 위해 비정상적으로 급증하는 K 라인을 식별합니다. 비정상적으로 급증하는 K 라인이 확인되면 해당 K 라인의 최고 수준 근처에서 수익 제한 주문을 설정하고, 또한 이전 K 라인의 최저 수준 근처에서 스톱 로스를 설정하여 높은 레버리지 리스크 통제를 가진 긴 포지션을 형성합니다. 전략은 지속적으로 스톱 로스 라인을 모니터링하고, 가격이 스톱 로스 라인을 넘으면 즉시 스톱 로스 주문을 취소합니다.

전략 원칙

이 전략은 주로 비정상적으로 급증하는 K 라인의 형성을 판단합니다. 닫> 개방 및 높은 <높은 [1] 및 낮은> 낮은 [1] K 라인이 나타나면 현재 비정상적으로 급증하는 시장이 있다고 믿습니다. 현재 K 라인의 가장 높은 가격 근처에 엔트리 가격이있는 긴 엔트리 신호가 생성됩니다. 또한 높은 레버리지 리스크 제어 모델을 형성하기 위해 이전 K 라인의 가장 낮은 가격 근처에 스톱 로스 가격이 설정됩니다. 위험 통제는 스톱 로스 라인의 가격 돌파를 지속적으로 모니터링함으로써 달성됩니다.

이점 분석

이 전략의 가장 큰 장점은 초고 주파수 거래를 달성하기 위해 시장에서 단기적인 폭발적인 변동성을 포착 할 수 있다는 것입니다. 동시에 더 큰 스톱 손실 범위를 설정함으로써 더 큰 수익을 얻기 위해 위험 제어 거래에 높은 레버리지를 사용할 수 있습니다. 또한 전략은 스톱 손실 라인의 자동 모니터링을 실현합니다. 가격이 스톱 손실 라인을 아래로 돌파하면 거래 위험을 효과적으로 제어하기 위해 신속하게 스톱 손실을 멈출 수 있습니다.

위험 분석

이 전략의 주요 위험은 비정상적인 급증의 판단이 정확하지 않으며 시장의 폭발적인 변동성을 효과적으로 파악할 수 없기 때문에 거래 신호에 대한 잘못된 판단의 확률이 높다는 것입니다. 또한 스톱 로스 포지션의 설정은 거래 위험과 수익에도 큰 영향을 미칩니다. 스톱 로스가 너무 느슨하다면 거래 손실 위험이 증가합니다. 스톱 로스가 너무 긴다면 시장에서 이익을 효과적으로 추적 할 수 없을 수 있습니다. 스톱 로스 포지션을 최적화하기 위해 많은 백테스팅이 필요합니다.

최적화 방향

이 전략은 다음과 같은 측면에서 최적화 될 수 있습니다.

  1. 비정상적인 급증을 판단하는 기준은 전략에서 거래 신호 판단의 정확성을 향상시키기 위해 판단에 도움이되는 더 많은 지표 또는 딥 러닝 모델을 도입 할 수 있습니다.

  2. 스톱 로스 포지션의 설정은 거래 위험과 수익 수준을 균형을 맞추기 위해 더 나은 스톱 로스 포지션을 찾기 위해 많은 통계 및 최적화 분석을 할 수 있습니다.

  3. 거래량 필터링, 범위 파업 확인 등과 같은 더 높은 빈도 거래 위험 관리 메커니즘을 도입하여 함락될 가능성을 피할 수 있습니다.

  4. 전략의 입시 기준은 조정 될 수 있으며 비정상적으로 급증하는 K 라인에만 국한될 필요가 없습니다. 더 많은 지표와 모델을 결합하여 판단을 내리고 복수 검증 메커니즘을 형성 할 수 있습니다.

요약

이 전략은 단기 브레이크아웃 전략에 속하는 전형적인 고주파 거래 전략이다. 그것은 초고주파 거래를 달성하기 위해 시장 움직임의 폭발적인 변동성을 포착한다. 동시에, 그것은 위험 통제를 위해 스톱 로스 리스크 컨트롤과 높은 레버리지 메커니즘을 사용합니다. 전략은 최적화 할 수있는 넓은 공간을 가지고 있으며 여러 각도에서 조정 및 최적화 할 수 있습니다. 궁극적인 목표는 위험을 제어하면서 초고주파 거래에서 더 높은 수익을 얻는 것입니다.


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

// LOVE JOY PEACE PATIENCE KINDNESS GOODNESS FAITHFULNESS GENTLENESS SELF-CONTROL 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © JoshuaMcGowan
// I needed to test/verify the functionality for canceling an open limit order in a strategy and also work thru the pieces needed to set the position sizing so each loss is a set amount. 
// This is not meant to be dropped into a chart but rather gives the code/logic in order to use in your own script w/alerts or strategy. Hope it helps. 
 
//@version=4
strategy("Strategy Test - Cancel Limit Order and Position Sizing", overlay=true, precision=4)
 
/////////////////
// Backtest Period Selection
 
testStartYear = input(2020, "Backtest Start Year",minval=1980)
testStartMonth = input(2, "Backtest Start Month",minval=1,maxval=12)
testStartDay = input(1, "Backtest Start Day",minval=1,maxval=31)
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
 
testStopYear = input(2020, "Backtest Stop Year",minval=1980)
testStopMonth = input(12, "Backtest Stop Month",minval=1,maxval=12)
testStopDay = input(31, "Backtest Stop Day",minval=1,maxval=31)
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
 
testPeriod() => time >= true
 
//////////////
// Inside Bar
bull_inside_bar = close>open and high<high[1] and low>low[1]

// Set Levels
bull_inside_bar_sl = valuewhen(bull_inside_bar, low[1], 0) - (1*syminfo.mintick)
bull_breakout_price = valuewhen(bull_inside_bar, high, 0) + (1*syminfo.mintick)
entry_buy   = high
inside_bar_dist = entry_buy - bull_inside_bar_sl
inside_bar_be = entry_buy + (inside_bar_dist * 1)
inside_bar_tgt = entry_buy + (inside_bar_dist * 2)

///////////////////
// Position Sizing 
//////////////////
// For each trade setup that fires in this scenario we want to set our total loss amount in USD, so every trade that loses is lets say $1 and the 2:1 target would be $2 in this example. 
// The math logic for this take the risk amount and divide by the stop percentage, take that number and divide by leverage amount chosen. Stop percentage is a variable below if questions on that. 
//
// Taken from @JoshuaMorris (shout out to the UK peeps) position sizing google doc so thank you sir. 
// Would be used if risking based on percentage of a portfolio. Leaving code snippets here in case that's the direction someone wants to go. 
// xbt_price = security("BITMEX:XBTUSD", "D", close)
// account_size_xbt = input(1, "Account Size (XBT)", type=input.float)
// account_size_usd = (account_size_xbt * xbt_price)
// percentage_risk = input(0.01, "Personal Risk Percent - Default is 1%", type=input.float)
// personal_risk = (account_size_usd * percentage_risk)
// position_size_usd = (personal_risk) / risk_percent
// leverage_req = position_size_usd / account_size_usd

// Will want to hard code leverage as 1x, 5x, 10x etc and dont need it to automagically be set as is above. If you're doing 100x you are gnarly haha. 
leverage_amount = input(title="Leverage Amount Desired", type=input.integer, defval=10, options=[1, 2, 3, 5, 10, 25, 50, 100])
risk_amount = input(title="Risk Total Per Trade in USD", type=input.integer, defval=1, minval=1, step=1)

// Reminder this is for Longs. Math needs to be changed a bit for Shorts. This is the information using the long/short tool would give us if doing manually. 
stop_percent = inside_bar_dist / (entry_buy)
pos_size_no_lev = risk_amount / stop_percent
pos_size_with_lev = pos_size_no_lev / leverage_amount 

//////////////
// Strategy Section

if testPeriod()
    strategy.entry(id="Long", long=true, qty=1, limit=9320.00, when=bull_inside_bar)
    strategy.cancel(id="Long", when = low < 9310)
// as a test swap the price to be above the limit or below to see the cancel in play.
 
//////////////
// Plot Section
plotchar(bull_inside_bar, title="bull_inside_bar", char="🐂", location=location.belowbar, offset=-0, color=color.green, transp=25)
plot(bull_inside_bar_sl, title="bull_inside_bar_sl", transp=100)
plot(entry_buy, title="entry_buy", transp=100)
plot(inside_bar_dist, title="inside_bar_dist", transp=100)
plot(stop_percent, title="stop_percent", transp=100)
plot(pos_size_no_lev, title="pos_size_no_lev", transp=100)
plot(pos_size_with_lev, title="pos_size_with_lev", transp=100)

// Hidden Plots // For Data Window Eyes Only // 
// plot(longCondition==true?1:0, title="Long Condition", transp=100)
// plot(xbt_price, title="XBT Price", transp=100)
// plot(account_size_usd, title="Account Size USD", transp=100)
// plot(risk_percent, title="risk_percent", transp=100)
// plot(position_size_usd, title="position_size_usd", transp=100)
// plot(leverage_req, title="leverage_req", transp=100)

// END //

더 많은