이 전략은 일일 거래에 적용되는 슈퍼 트렌드 지표에 기반한 단선 전략이다. 사용자는 일일 거래 시간을 정의할 수 있으며, 전략은 그 시간 동안만 작동한다. 전략은 두 배의 수를 역으로 포지션을 개설하여 신호 반전을 실현한다. 일일 거래 기간이 끝나고 포지션을 매매하지 않은 경우 필리 포지션을 강제한다.
슈퍼 트렌드 지표를 계산한다. 슈퍼 트렌드 라인은 사용자 정의의 곱과 ATR 주기에 따라 계산한다.
슈퍼 트렌드 라인을 그리십시오. 슈퍼 트렌드 라인을 지지선과 저항선으로 그리십시오.
긴 조건과 짧은 조건을 결정한다. 종결가는 슈퍼 트렌드 라인보다 높고, 종결가는 슈퍼 트렌드 라인보다 낮다.
거래시간 판단. 사용자가 정의한 일간 거래시간에 따라 현재 가격표가 거래시간 내에 있는지 판단한다.
거래 신호를 발신한다. 거래 기간 내에만 추가 공백 조건이 충족되면, 거래 신호를 발신한다.
반전 포지션 . 슈퍼 트렌드 지표 방향이 바뀌면 두 배의 수를 사용하여 반전 포지션 .
평형 포지션 퇴장. 슈퍼 트렌드 신호가 변하지 않고 거래 시기가 끝나면 평형 포지션을 강제한다.
슈퍼 트렌드 지표를 사용하여 트렌드를 식별하여 잘못된 신호를 줄일 수 있습니다.
슈퍼 트렌드 지표와 종전 가격과 함께 거래하여, 허리 을 피하십시오.
역투자는 적자를 줄일 수 있다.
낮 시간 거래는 밤새의 위험을 피할 수 있습니다.
평준화 메커니즘을 강제하는 것은 평준화를 잊는 위험을 피할 수 있습니다.
슈퍼 트렌드 지표의 매개 변수를 잘못 설정하면 전략의 효과가 떨어질 수 있다.
반전 포지션은 거래 빈도와 거래 비용을 증가시킵니다.
일간시간이 끝나면 강제적으로 매출을 치르는 것은 손실을 초래할 수 있다.
위험 1은 변수 최적화를 통해 최적의 변수 조합을 찾을 수 있다.
리스크 2는 손실을 통제하기 위해 스톱로스를 설정할 수 있다.
리스크 3는 스톱로드를 설정하거나 트렌드 필터를 사용하여 강등 손실을 피할 수 있습니다.
MA, KDJ 등과 같은 다양한 트렌드 지표를 시도하십시오.
스탠포드 로직을 추가합니다.
트렌드 필터링을 추가하여 강등 손실을 피하십시오.
배수 및 ATR 주기 파라미터를 최적화한다.
다양한 종류의 거래를 시험해보세요.
이 전략은 슈퍼 트렌드 지표와 일일 거래 시간 관리를 통합하여 단선 트렌드 돌파구를 포착하기 위해 고안되었다. 반전 포지션 개시 및 강제 평소 포지션 메커니즘은 위험을 효과적으로 제어할 수 있다. 이후 파라미터 최적화, 중지 손실 및 트렌드 필터링을 통해 전략 효과를 더 향상시킬 수 있다.
/*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 **********