이 전략은 ZZ 지표의 가격 통로를 기반으로 거래하며, 가격이 통로의 상한을 상향으로 돌파하거나 통로의 하위 경계를 넘어가는 신호를 사용하여 상반 또는 상반 포지션을 설정합니다. 이 전략은 가격 통로의 범위를 벗어난 추세 폭파를 잡으려고합니다.
구체적으로, 이 전략은 ZZ 지표를 통해 가격 통로의 상하계를 계산한다. 가격이 아래에서 상하계를 돌파할 때, 더 많은 입장을 취한다. 위에서 하하계를 돌파할 때, 더 많은 입장을 취한다. 더 많은 입장을 취한 후에도 손실 서명을 사용하여 가격 통로의 상하계를 손실 지점으로 삼는다. 또한 날짜의 시간 범위를 설정하고, 거래의 범위 내에서, 매일 시장이 닫기 전에 매장을 청산하여 밤새의 위험을 피한다.
이러한 위험은 채널 간격을 넓히고, 손실을 막는 전략을 최적화하고, 트렌드 강도를 판단함으로써 감소시킬 수 있습니다.
이 전략은 가격 통로 판단 트렌드 폭파점을 기반으로 거래한다. 장점은 거래 신호가 간단하고, 손해가 명확하고, 조작이 쉽다는 것이다. 단점은 빈번한 공백과 미흡한 트렌드가 존재한다는 것이다. 매개 변수 최적화, 전략 조합 등의 방법으로 우위를 유지하면서 위의 단점을 극복할 수 있다. 이 전략은 거래자가 가격 통로의 응용 기술을 습득할 수 있도록 돕는다.
/*backtest
start: 2022-09-14 00:00:00
end: 2023-09-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//Noro
//2019
//@version=4
strategy(title = "Noro's ZZ-4 Strategy", shorttitle = "Noro's ZZ-4 Strategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
len = input(7, minval = 1, title = "Length")
showll = input(true, defval = true, title = "Show Levels")
showbg = input(false, defval = false, title = "Show Background")
showpc = input(false, defval = false, title = "Show Price Channel")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//Price channel
h = highest(ohlc4, len)
l = lowest(ohlc4, len)
pccol = showpc ? color.blue : na
plot(h, color = pccol, transp = 0)
plot(l, color = pccol, transp = 0)
//Levels
ml = 0
ml := l > l[1] ? 1 : l < l[1] ? -1 : ml[1]
ll = 0.0
ll := ml == 1 and ml[1] == -1 ? l[1] : ll[1]
mh = 0
mh := h > h[1] ? 1 : h < h[1] ? -1 : mh[1]
hl = 0.0
hl := mh == -1 and mh[1] == 1 ? h[1] : hl[1]
//Lines
colorh = showll and hl == hl[1] ? color.lime : na
colorl = showll and ll == ll[1] ? color.red : na
plot(hl, color = colorh, linewidth = 2, transp = 0, title = "Long")
plot(ll, color = colorl, linewidth = 2, transp = 0, title = "Short")
//Background
size = strategy.position_size
trend = 0
trend := size > 0 ? 1 : size < 0 ? -1 : high >= hl ? 1 : low <= ll ? -1 : trend[1]
bgcol = showbg == false ? na : trend == 1 ? color.lime : trend == -1 ? color.red : na
bgcolor(bgcol, transp = 80)
//Trading
truetime = time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)
lot = 0.0
lot := size != size[1] ? strategy.equity / close * capital / 100 : lot[1]
if ll > 0 and hl > 0
strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, stop = hl, when=(truetime))
strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, stop = ll, when=(truetime))
if time > timestamp(toyear, tomonth, today, 23, 59)
strategy.close_all()
strategy.cancel("Long")
strategy.cancel("Short")