У меня есть скрипт, и я хочу отображать предупреждения с нескольких таймфреймов на одном графике, поэтому 1 час и 4 часа - это то, что у меня есть, проблема в том, что я перехожу с 15 минут на 30 минут на например, 8-часовой предупреждающий сигнал выглядит перемещающимся. 4-часовой сигнал на 15-м графике отличается от 4-часового оповещения на 30-минутном графике.
show_buysell= input(true, "Show Buy Sell")
sources = input(defval=close, title="Source")
per = input(defval=27, minval=1, title="Sampling Period")
mult = input(defval=1.0, minval=0.1, title="Range Multiplier")
isHA = input(true, "HA Candles?", input.bool)
heikenashi_1 = heikinashi(syminfo.tickerid)
security_1 = security(heikenashi_1, timeframe.period, sources)
security_1h = security(heikenashi_1, potf2, sources)
security_4h = security(heikenashi_1, potf3, sources)
po_src = isHA ? security_1 : sources
po_src_1h = isHA ? security_1h : sources
po_src_4h = isHA ? security_4h : sources
//Current TimeFrame
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ema(abs(x - x[1]), t)
smoothrng = ema(avrng, wper) * m
smoothrng
smrng = smoothrng(po_src, per, mult)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(po_src, smrng)
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])
longCond = bool(na)
shortCond = bool(na)
longCond := po_src > filt and po_src > po_src[1] and upward > 0 or
po_src > filt and po_src < po_src[1] and upward > 0
shortCond := po_src < filt and po_src < po_src[1] and downward > 0 or
po_src < filt and po_src > po_src[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1
plotshape(show_potato and longCondition, title="CTF Buy", text="CTF buy", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=color.green, transp=0)
plotshape(show_potato and shortCondition, title="CTF Sell", text="CTF sell️", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=color.red, transp=0)
//1Hr Timeframe
smoothrng_1h(x, t, m) =>
wper_1h = t * 2 - 1
avrng_1h = security(tick, potf3, ema(abs(x - x[1]), t))
smoothrng_1h = security(tick, potf2, ema(avrng_1h, wper_1h) * m)
smoothrng_1h
smrng_1h = smoothrng_1h(po_src_1h, per, mult)
rngfilt_1h(x, r) =>
rngfilt_1h = x
rngfilt_1h := x > nz(rngfilt_1h[1]) ? x - r < nz(rngfilt_1h[1]) ? nz(rngfilt_1h[1]) : x - r :
x + r > nz(rngfilt_1h[1]) ? nz(rngfilt_1h[1]) : x + r
rngfilt_1h
filt_1h = rngfilt_1h(po_src_1h, smrng_1h)
upward_1h = 0.0
upward_1h := filt_1h > filt_1h[1] ? nz(upward_1h[1]) + 1 : filt_1h < filt_1h[1] ? 0 : nz(upward_1h[1])
downward_1h = 0.0
downward_1h := filt_1h < filt_1h[1] ? nz(downward_1h[1]) + 1 : filt_1h > filt_1h[1] ? 0 : nz(downward_1h[1])
longCond_1h = bool(na)
shortCond_1h = bool(na)
longCond_1h := po_src_1h > filt_1h and po_src_1h > po_src_1h[1] and upward_1h > 0 or
po_src_1h > filt_1h and po_src_1h < po_src_1h[1] and upward_1h > 0
shortCond_1h := po_src_1h < filt_1h and po_src_1h < po_src_1h[1] and downward_1h > 0 or
po_src_1h < filt_1h and po_src_1h > po_src_1h[1] and downward_1h > 0
CondIni_1h = 0
CondIni_1h := longCond_1h ? 1 : shortCond_1h ? -1 : CondIni_1h[1]
longCondition_1h = longCond_1h and CondIni_1h[1] == -1
shortCondition_1h = shortCond_1h and CondIni_1h[1] == 1
plotshape(show_buysell and longCondition_1h, title="1H Buy", text="1H", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=color.blue, transp=0)
plotshape(show_buysell and shortCondition_1h, title="1H Sell", text="1H", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=color.yellow, transp=0)
//4Hr Timeframe
smoothrng_4h(x, t, m) =>
wper_4h = t * 2 - 1
avrng_4h = security(tick, potf3, ema(abs(x - x[1]), t))
smoothrng_4h = security(tick, potf3, ema(avrng_4h, wper_4h) * m)
smoothrng_4h
smrng_4h = smoothrng_4h(po_src_4h, per, mult)
rngfilt_4h(x, r) =>
rngfilt_4h = x
rngfilt_4h := x > nz(rngfilt_4h[1]) ? x - r < nz(rngfilt_4h[1]) ? nz(rngfilt_4h[1]) : x - r :
x + r > nz(rngfilt_4h[1]) ? nz(rngfilt_4h[1]) : x + r
rngfilt_4h
filt_4h = rngfilt_4h(po_src_4h, smrng_4h)
upward_4h = 0.0
upward_4h := filt_4h > filt_4h[1] ? nz(upward_4h[1]) + 1 : filt_4h < filt_4h[1] ? 0 : nz(upward_4h[1])
downward_4h = 0.0
downward_4h := filt_4h < filt_4h[1] ? nz(downward_4h[1]) + 1 : filt_4h > filt_4h[1] ? 0 : nz(downward_4h[1])
longCond_4h = bool(na)
shortCond_4h = bool(na)
longCond_4h := po_src_4h > filt_4h and po_src_4h > po_src_4h[1] and upward_4h > 0 or
po_src_4h > filt_4h and po_src_4h < po_src_4h[1] and upward_4h > 0
shortCond_4h := po_src_4h < filt_4h and po_src_4h < po_src_4h[1] and downward_4h > 0 or
po_src_4h < filt_4h and po_src_4h > po_src_4h[1] and downward_4h > 0
CondIni_4h = 0
CondIni_4h := longCond_4h ? 1 : shortCond_4h ? -1 : CondIni_4h[1]
longCondition_4h = longCond_4h and CondIni_4h[1] == -1
shortCondition_4h = shortCond_4h and CondIni_4h[1] == 1
plotshape(show_buysell and longCondition_4h, title="4H Buy", text="4H", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=color.blue, transp=0)
plotshape(show_buysell and shortCondition_4h, title="4H Sell", text="4H", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=color.yellow, transp=0)