PROTECTED SOURCE SCRIPT
My script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © AlgoTrade_Pro
//version=5
indicator(title='Twin Range Filter [ATP🤖]', overlay=true, timeframe='')
//Inputs
TRsource = input(defval=close, title='Source')
TRper1 = input.int(defval=27, minval=1, title='Fast period')
TRmult1 = input.float(defval=1.6, minval=0.1, title='Fast range')
TRper2 = input.int(defval=55, minval=1, title='Slow period')
TRmult2 = input.float(defval=2, minval=0.1, title='Slow range')
//Calculations
smoothrng(TRx, TRt, TRm) =>
TRwper = TRt * 2 - 1
TRavrng = ta.ema(math.abs(TRx - TRx[1]), TRt)
TRsmoothrng = ta.ema(TRavrng, TRwper) * TRm
TRsmoothrng
TRsmrng1 = smoothrng(TRsource, TRper1, TRmult1)
TRsmrng2 = smoothrng(TRsource, TRper2, TRmult2)
TRsmrng = (TRsmrng1 + TRsmrng2) / 2
rngfilt(TRx, TRr) =>
TRrngfilt = TRx
TRrngfilt := TRx > nz(TRrngfilt[1]) ? TRx - TRr < nz(TRrngfilt[1]) ? nz(TRrngfilt[1]) : TRx - TRr : TRx + TRr > nz(TRrngfilt[1]) ? nz(TRrngfilt[1]) : TRx + TRr
TRrngfilt
TRfilt = rngfilt(TRsource, TRsmrng)
TRupward = 0.0
TRupward := TRfilt > TRfilt[1] ? nz(TRupward[1]) + 1 : TRfilt < TRfilt[1] ? 0 : nz(TRupward[1])
TRdownward = 0.0
TRdownward := TRfilt < TRfilt[1] ? nz(TRdownward[1]) + 1 : TRfilt > TRfilt[1] ? 0 : nz(TRdownward[1])
TRSTR = TRfilt + TRsmrng
TRSTS = TRfilt - TRsmrng
TRFUB = 0.0
TRFUB := TRSTR < nz(TRFUB[1]) or close[1] > nz(TRFUB[1]) ? TRSTR : nz(TRFUB[1])
TRFLB = 0.0
TRFLB := TRSTS > nz(TRFLB[1]) or close[1] < nz(TRFLB[1]) ? TRSTS : nz(TRFLB[1])
TRTRF = 0.0
TRTRF := nz(TRTRF[1]) == TRFUB[1] and close <= TRFUB ? TRFUB : nz(TRTRF[1]) == TRFUB[1] and close >= TRFUB ? TRFLB : nz(TRTRF[1]) == TRFLB[1] and close >= TRFLB ? TRFLB : nz(TRTRF[1]) == TRFLB[1] and close <= TRFLB ? TRFUB : TRFUB
//Entry Signals
TRlong = ta.crossover(close, TRTRF)
TRshort = ta.crossunder(close, TRTRF)
//Plots
plotshape(TRlong, title='Long', text='BUY', style=shape.labelup, textcolor=color.white, size=size.tiny, location=location.belowbar, color=#1be600)
plotshape(TRshort, title='Short', text='SELL', style=shape.labeldown, textcolor=color.white, size=size.tiny, location=location.abovebar, color=#e60000)
Trfff = plot(TRTRF, color=color.white)
mPlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0)
longFillColor = close > TRTRF ? color.green : na
shortFillColor = close < TRTRF ? color.red : na
fill(mPlot, Trfff, title='UpTrend Highligter', color=longFillColor, transp=90)
fill(mPlot, Trfff, title='DownTrend Highligter', color=shortFillColor, transp=90)
//Alerts
alertcondition(TRlong, title='Long', message='Long')
alertcondition(TRshort, title='Short', message='Short')
//End
// © AlgoTrade_Pro
//version=5
indicator(title='Twin Range Filter [ATP🤖]', overlay=true, timeframe='')
//Inputs
TRsource = input(defval=close, title='Source')
TRper1 = input.int(defval=27, minval=1, title='Fast period')
TRmult1 = input.float(defval=1.6, minval=0.1, title='Fast range')
TRper2 = input.int(defval=55, minval=1, title='Slow period')
TRmult2 = input.float(defval=2, minval=0.1, title='Slow range')
//Calculations
smoothrng(TRx, TRt, TRm) =>
TRwper = TRt * 2 - 1
TRavrng = ta.ema(math.abs(TRx - TRx[1]), TRt)
TRsmoothrng = ta.ema(TRavrng, TRwper) * TRm
TRsmoothrng
TRsmrng1 = smoothrng(TRsource, TRper1, TRmult1)
TRsmrng2 = smoothrng(TRsource, TRper2, TRmult2)
TRsmrng = (TRsmrng1 + TRsmrng2) / 2
rngfilt(TRx, TRr) =>
TRrngfilt = TRx
TRrngfilt := TRx > nz(TRrngfilt[1]) ? TRx - TRr < nz(TRrngfilt[1]) ? nz(TRrngfilt[1]) : TRx - TRr : TRx + TRr > nz(TRrngfilt[1]) ? nz(TRrngfilt[1]) : TRx + TRr
TRrngfilt
TRfilt = rngfilt(TRsource, TRsmrng)
TRupward = 0.0
TRupward := TRfilt > TRfilt[1] ? nz(TRupward[1]) + 1 : TRfilt < TRfilt[1] ? 0 : nz(TRupward[1])
TRdownward = 0.0
TRdownward := TRfilt < TRfilt[1] ? nz(TRdownward[1]) + 1 : TRfilt > TRfilt[1] ? 0 : nz(TRdownward[1])
TRSTR = TRfilt + TRsmrng
TRSTS = TRfilt - TRsmrng
TRFUB = 0.0
TRFUB := TRSTR < nz(TRFUB[1]) or close[1] > nz(TRFUB[1]) ? TRSTR : nz(TRFUB[1])
TRFLB = 0.0
TRFLB := TRSTS > nz(TRFLB[1]) or close[1] < nz(TRFLB[1]) ? TRSTS : nz(TRFLB[1])
TRTRF = 0.0
TRTRF := nz(TRTRF[1]) == TRFUB[1] and close <= TRFUB ? TRFUB : nz(TRTRF[1]) == TRFUB[1] and close >= TRFUB ? TRFLB : nz(TRTRF[1]) == TRFLB[1] and close >= TRFLB ? TRFLB : nz(TRTRF[1]) == TRFLB[1] and close <= TRFLB ? TRFUB : TRFUB
//Entry Signals
TRlong = ta.crossover(close, TRTRF)
TRshort = ta.crossunder(close, TRTRF)
//Plots
plotshape(TRlong, title='Long', text='BUY', style=shape.labelup, textcolor=color.white, size=size.tiny, location=location.belowbar, color=#1be600)
plotshape(TRshort, title='Short', text='SELL', style=shape.labeldown, textcolor=color.white, size=size.tiny, location=location.abovebar, color=#e60000)
Trfff = plot(TRTRF, color=color.white)
mPlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0)
longFillColor = close > TRTRF ? color.green : na
shortFillColor = close < TRTRF ? color.red : na
fill(mPlot, Trfff, title='UpTrend Highligter', color=longFillColor, transp=90)
fill(mPlot, Trfff, title='DownTrend Highligter', color=shortFillColor, transp=90)
//Alerts
alertcondition(TRlong, title='Long', message='Long')
alertcondition(TRshort, title='Short', message='Short')
//End
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
受保護腳本
此腳本以閉源形式發佈。 不過,您可以自由且不受任何限制地使用它 — 在此處了解更多資訊。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。