좁은 마일리지 전략


생성 날짜: 2023-09-14 16:59:35 마지막으로 수정됨: 2023-09-14 16:59:35
복사: 0 클릭수: 677
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

전략 원칙

이 전략은 좁은 폭 ((NR7) 과 마일리지를 결합하여 공백 시간을 결정한다.

거래의 논리는 다음과 같습니다.

  1. 가장 높은 가격과 가장 낮은 가격의 범위가 7일 만에 가장 좁아진 NR7을 확인합니다.

  2. 1일 전보다 높은 가격, 1일 전보다 낮은 가격의 마일리스를 확인합니다.

  3. NR7과 마일리지가 같은 날 출현하고, 영업가격보다 영업가격이 낮은 경우

  4. 이동 평균이 아래로 향할 때,

  5. 다음 거래일에는 매각 가격이 오픈 가격보다 낮아지면 매각한다.

이 전략은 좁은 폭과 마일리지를 최대한 활용하여 종식 상황을 나타냅니다. 평균선 판단과 종식 가격 위치를 결합하여 공백 효율을 높일 수 있습니다.

전략적 이점

  • 좁고 긴 거리는 역전 시기를 결정합니다.

  • 조건 조합은 잘못된 신호를 피합니다.

  • 선택 가능한 다공간 동작

전략적 위험

  • NR7과 마일리지 조합은 좀 더 드물다

  • 평균선 변수를 최적화해야 합니다.

  • “이런 기회는 그냥 공백을 뚫고 얻을 수 없다”.

요약하다

이 전략은 고효율의 역전식 및 검증 방식으로 공백을 수행한다. 그러나 거래 빈도가 낮아 전략의 효과를 평가해야 한다. 변수 최적화 및 다공간 거래는 확장 가능한 전략이다.

전략 소스 코드
/*backtest
start: 2023-08-14 00:00:00
end: 2023-09-13 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("NR7ID: Narrow Range + Inside Day, Short Only Strategy (by ChartArt)", shorttitle="CA_-_NR7ID_Short_Strat", overlay=true) // max_bars_back=5000


// ChartArt's Narrow Range + Inside Day Strategy (Short Only)
//
// Version 1.1
// Idea by ChartArt on Oktober 22, 2016.
//
// This short only strategy determines when there is both
// a NR7 (narrow range 7, a trading day in which the range
// is narrower than any of the previous six days), plus a
// inside day (high of the current day is lower than the high
// of the previous day and the low of the current day is higher
// than the low of the previous day) both on the same trading day
// and enters a short trade when the close is lower than the
// open and the slope of the simple moving average is downwards, too.
//
// The strategy exits the short trade next time the close is
// lower than the open in any of the next trading days.
//
// In addition the NR7ID can be colored (if close lower open
// colored in red, else in green) and the SMA can be drawn
// with a color based on the direction of the SMA slope.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 


// NR7 Identifier
show_NR7=input(true, type=bool,title="Show Narrow Range 7 (NR7) ?")
range=(high-low)
nr7=(range < range[1]) and (range < range[2]) and (range < range[3]) and (range < range[4]) and (range < range[5]) and (range < range[6])
plotchar(show_NR7?nr7:na, char="7", location=location.abovebar, color=blue)

// Inside Day Identifier
show_insidebar = input(true, type=bool,title="Show Inside Day (I) ?")
insidebar =  (high < high[1] and low > low[1])
plotchar(show_insidebar?insidebar:na, char="i", location=location.abovebar, color=blue)

// NR7 + Inside Day Identifier
show_NR7ID_bear = input(true, type=bool,title="Show NR7ID (NR7 + Inside Day) bear color ?")
NR7ID = nr7 and insidebar
NR7ID_bear_color = NR7ID and open > close ? red : na
barcolor(show_NR7ID_bear?NR7ID_bear_color:na)
show_NR7ID_bull = input(false, type=bool,title="Show NR7ID (NR7 + Inside Day) bull color ?")
NR7ID_bull_color = NR7ID and open < close ? green : na
barcolor(show_NR7ID_bull?NR7ID_bull_color:na)

// Simple Moving Average
show_ma = input(true, type=bool,title="Show SMA ?")
ma_length = input(14,title="SMA Length")
ma = sma(close,ma_length)
ma_change = change(ma) > 0
ma_change_color = change(ma) > 0 ? green : change(ma) < 0 ? red : blue
plot(show_ma?ma:na,color=ma_change_color,linewidth=3)

// Short Strategy: NR7 + Inside Day + close is smaller than open + change of SMA is downwards
strategy.entry("sell", strategy.short, when = NR7ID and open > close and ma_change == false, comment="Short")
strategy.close("sell", when = open > close )

// (not enabled) Long Strategy: NR7 + Inside Day + close is larger than open + change of SMA is upwards
//strategy.entry("long", strategy.long, when = NR7ID and open < close and ma_change == true, comment="Long")
//strategy.close("long", when = open < close )