내일 트렌드 브레이크 전략

저자:차오장, 날짜: 2023-09-18 13:11:51
태그:

전반적인 설명

이것은 슈퍼트렌드 지표에 기반한 전략에 따른 하루 내 단기 트렌드입니다. 사용자는 전략이 실행되는 하루 내 거래 세션을 정의할 수 있습니다.

이 전략은 신호가 변할 때 두 배의 양을 사용하여 포지션을 역전합니다. 모든 오픈 포지션은 내일 세션의 끝에서 제곱됩니다.

전략 논리

  1. 사용자가 정의한 곱자와 ATR 기간을 기반으로 슈퍼트렌드 지표를 계산합니다.

  2. 수퍼트렌드 라인을 지지와 저항으로 그려보세요.

  3. 긴 / 짧은 조건을 결정합니다. 슈퍼 트렌드 라인의 위의 닫는 것은 긴 조건입니다. 슈퍼 트렌드 라인의 아래에 닫는 것은 짧은 조건입니다.

  4. 현재 바가 사용자가 정의한 내일 세션 내에 있는지 확인합니다.

  5. 내일 세션이 활성화되고 긴/단계 조건이 충족될 때만 긴/단계 신호를 발송합니다.

  6. 슈퍼트렌드 방향이 변할 때 두 배의 양으로 반대 트레이드를 취함으로써 포지션을 역전합니다.

  7. 슈퍼트렌드 방향이 변하지 않고 내일 세션이 종료될 때 오픈 포지션을 정분화합니다.

이점 분석

  1. 슈퍼트렌드는 트렌드를 식별하고 잘못된 신호를 줄입니다.

  2. 슈퍼트렌드와 밀접한 가격을 결합하면 조기에 중단되는 것을 피할 수 있습니다.

  3. 적시에 위치를 뒤집으면 손실을 줄일 수 있습니다.

  4. 일내 세션은 하루 하루 위험을 피합니다.

  5. 강제 출입은 정렬을 잊을 위험을 피합니다.

위험 분석

  1. 부적절한 슈퍼트렌드 매개 변수는 전략 성과가 떨어질 수 있습니다.

  2. 포지션이 역전되면 거래 빈도와 비용이 증가합니다.

  3. 세션 종료 후 강제 출퇴는 손실로 이어질 수 있습니다.

  • 위험 1은 매개 변수 최적화를 통해 완화 될 수 있습니다.

  • 리스크 2는 스톱 로스를 통해 제어할 수 있습니다.

  • 리스크 3는 스톱 로스 또는 트렌드 필터를 사용하여 피할 수 있습니다.

더 나은 기회

  1. MA, KDJ 등과 같은 다른 트렌드 지표를 테스트합니다.

  2. 스톱 손실 논리를 추가합니다.

  3. 강제 출구 손실을 피하기 위해 트렌드 필터를 추가합니다.

  4. 곱셈과 ATR 기간 매개 변수를 최적화합니다.

  5. 다른 기기로 테스트

결론

이 전략은 단기 트렌드 브레이크를 활용하기 위해 슈퍼트렌드와 내일 세션 관리를 결합합니다. 포지션 역전 및 강제 출구는 위험을 효과적으로 제어합니다. 매개 변수 최적화, 스톱 로스 및 트렌드 필터링을 통해 추가 개선이 가능합니다.


/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 1h
basePeriod: 15m
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/
// © Pritesh-StocksDeveloper

//@version=4
strategy("Supertrend - Intraday", overlay=true, calc_on_every_tick = true)

// ********** Strategy inputs - Start **********

// Used for intraday handling
// Session value should be from market start to the time you want to square-off 
// your intraday strategy
// Important: The end time should be at least 2 minutes before the intraday
// square-off time set by your broker
var i_marketSession = input(title="Market session", type=input.session, 
     defval="0915-1455", confirm=true)

var float i_multiplier = input(title = "Multiplier", type = input.float, 
     defval = 4, confirm=true)

var int i_atrPeriod = input(title = "ATR Period", type = input.integer, 
     defval = 14, confirm=true)

// ********** Strategy inputs - End **********


// ********** Supporting functions - Start **********

// A function to check whether the bar or period is in intraday session
barInSession(sess) => time(timeframe.period, sess) != 0

// ********** Supporting functions - End **********


// ********** Strategy - Start **********

[superTrend, dir] = supertrend(i_multiplier, i_atrPeriod)

colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) : color.new(color.green, 100)

plot(superTrend, color = colResistance, linewidth=2)
plot(superTrend, color = colSupport, linewidth=2)

// Long/short condition
longCondition = close > superTrend
shortCondition = close < superTrend

// See if intraday session is active
bool intradaySession = barInSession(i_marketSession)

// Trade only if intraday session is active
 
// Long position
// When longCondition and intradaySession both are true
strategy.entry(id = "Long", long = strategy.long, 
     when = longCondition and intradaySession)
 
// Short position
// When shortCondition and intradaySession both are true
strategy.entry(id = "Short", long = strategy.short, 
     when = shortCondition and intradaySession)
 
// Square-off position (when session is over and position is open)
squareOff = (not intradaySession) and (strategy.position_size != 0)
strategy.close_all(when = squareOff, comment = "Square-off")

// ********** Strategy - End **********

더 많은