
이 전략은 원유 선물 시장의 변동성을 활용하기 위한 체계화된 방법이다. 그것은 빠른 이동 평균이 느린 이동 평균보다 높으면 더 큰 것을 의미하며, 느린 이동 평균이 빠른 이동 평균보다 높으면 더 작은 것을 의미한다.
이 원칙에 따라 잠재적인 장입점과 단입점들을 식별한다. 입장은 오직 특정 수의 ?? 을 유지하며, 이 파라미터는 Exit after bars ?? 의 입력으로 제어된다.
이 전략은 파격과 회귀를 이용한 단기 트렌드를 판단하는 변동성 전략이다. 최적화된 매개 변수 설정과 추가 변동률 지표 판단을 통해 가짜 파격 확률을 줄이고 수익 수준을 높일 수 있다. 동시에 고정 루트 K 라인의 빠른 퇴출 메커니즘은 특정 수익을 잠금하고 위험을 효과적으로 제어할 수 있다. 이 전략은 짧은 라인 운영의 보조 도구로 사용될 수 있으며, 매개 변수를 조정하여 더 긴 주기 운영 신호를 얻을 수 있다.
/*backtest
start: 2024-02-01 00:00:00
end: 2024-02-29 23:59:59
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Celestial_Logic
//@version=5
strategy("Crudeoil Breakout strategy", overlay = true, initial_capital = 20000, default_qty_type = strategy.fixed, default_qty_value = 1)
highestCloseLookback = input(9 , title = 'Highest Close lookback')
lowestCloseLookback = input(50, title = 'Lowest Close lookback' )
exitAfter = input(10, title = 'Exit after bars')
hc = ta.highest(close,highestCloseLookback)
lc = ta.lowest(close,lowestCloseLookback)
rangeFilter = (ta.sma( (high - low), 5 ) > ta.sma((high-low), 20) ) // Candles getting bigger.
longCondition = (close == hc ) and not rangeFilter
shortCondition = (close == lc ) and not rangeFilter
if longCondition
strategy.entry(id = 'long', direction = strategy.long)
if shortCondition
strategy.entry(id = 'short', direction = strategy.short)
var int longsince = 0
var int shortsince = 0
if strategy.position_size > 0
longsince += 1
else
longsince := 0
if strategy.position_size < 0
shortsince += 1
else
shortsince := 0
if longsince >= exitAfter
strategy.close(id = 'long', comment = 'long close')
if shortsince >= exitAfter
strategy.close(id = 'short', comment = 'short close')