Gatekeeper
Member
// TASC Issue: December 2022 - Vol. 40, Issue 13
// Article: Short-Term Continuation And Reversal Signals
// Article By: Barbara Star
// Language: TradingView's Pine Script™ v5
// Provided By: PineCoders, for tradingview.com
//@version=5
string title = 'TASC 2022.12 ' +
'Short-Term Continuation And Reversal Signals'
string stitle = 'TASC 2022.12'
indicator(title, stitle, false)
// Constant variables:
string XP0 = shape.arrowdown, string XP5 = shape.flag
string XP1 = shape.arrowup , string XP6 = shape.square
string XP2 = shape.circle , string XP7 = shape.triangledown
string XP3 = shape.cross , string XP8 = shape.triangleup
string XP4 = shape.diamond , string XP9 = shape.xcross
string LTOP= location.top , string LABAR = location.abovebar
string LBOT= location.bottom, string LBBAR = location.belowbar
string SZ = size.tiny , string LDASH = line.style_dashed
PH = plot.style_histogram
color CGRAY = #555522
// Input panel groups, titles and inline references:
string g00 = 'Input Options:'
string g01 = 'Style Options:'
string it0 = 'Continuity Signals:'
string it1 = 'CCI Signals: '
string it2 = 'Oscillator Mode:'
string it3 = 'DMI Colors: '
string it4 = 'DMI Multiplier: '
string MD0 = 'DMI', string MD2 = 'Dual'
string MD1 = 'CCI', string MD3 = 'Overlay'
// Input options:
string mode = input.string(MD2, it2,
[MD0, MD1, MD2, MD3], group=g00)
float DMIMult = input.float(1.0, it4, step=0.25, group=g00)
int diLength = input.int(10, 'DMI Length:', group=g00)
int maLength = input.int(18, 'MA Length:', group=g00)
int cciLength = input.int(13, 'CCI Length:', group=g00)
// Style options:
color colDMIUp = input.color(#22AA22,it3,'',it3,g01)
color colDMIDo = input.color(#AA2222,'','',it3,g01)
string shapeCon = input.string(XP2, it0,
[XP0,XP1,XP2,XP3,XP4,XP5,XP6,XP7,XP8,XP9],'',it0,g01)
color colConUpTrend = input.color(#5188FF,'','',it0,g01)
color colConDoTrend = input.color(#771515,'','',it0,g01)
string shapeCCI = input.string(XP4, it1,
[XP0,XP1,XP2,XP3,XP4,XP5,XP6,XP7,XP8,XP9],'',it1,g01)
color colCCITop = input.color(#BB00FF,'','',it1,g01)
color colCCIBot = input.color(#FFBB00,'','',it1,g01)
// Indicators:
float ma = ta.sma(close, maLength)
[dp, dm, _] = ta.dmi(diLength, 1)
float DMI = dp - dm
float mDMI = DMIMult * DMI
float CCI = ta.cci(close, cciLength)
float uCCI = CCI > +100.0 ? CCI : na
float lCCI = CCI < -100.0 ? CCI : na
// Boolean Signals:
bool pGTma = close > ma, bool pLTma = close < ma
bool cciGTp100 = CCI > 100 , bool cciLTm100 = CCI < -100
bool dmiGT0 = DMI > 0 , bool dmiLT0 = DMI < 0
bool risingL = low > low[1] and low[1] > low[2]
bool falingH = high < high[1] and high[1] < high[2]
bool conUpTrend = pGTma and dmiGT0 and risingL
bool conDoTrend = pLTma and dmiLT0 and falingH
bool cciTop = (not cciGTp100) and cciGTp100[1] and cciGTp100[2]
bool cciBot = (not cciLTm100) and cciLTm100[1] and cciLTm100[2]
bool useDMI = mode == MD0 or mode == MD2
bool useCCI = mode == MD1 or mode == MD2
bool isOverlay = mode == MD3
// Color variation:
color colDMI = switch
dmiGT0 => colDMIUp
dmiLT0 => colDMIDo
=> CGRAY
color colCCI = switch
cciGTp100 => colCCITop
cciLTm100 => colCCIBot
=> CGRAY
// Output:
showDMI = useDMI ? display.all : display.none
showCCI = useCCI ? display.all : display.none
showLVL = isOverlay ? display.none : display.all
showOverlay = isOverlay ? display.all : display.none
// Oscillator signals:
plotshape(conUpTrend, it0, shapeCon, LBOT, colConUpTrend,
size=SZ, display=showLVL)
plotshape(conDoTrend, it0, shapeCon, LTOP, colConDoTrend,
size=SZ, display=showLVL)
plotshape(cciTop, it1, shapeCCI, LTOP, colCCITop,
size=SZ, display=showLVL)
plotshape(cciBot, it1, shapeCCI, LBOT, colCCIBot,
size=SZ, display=showLVL)
// Overlaid signals:
plotshape(conUpTrend, it0, shapeCon, LBBAR, colConUpTrend,
size=SZ, display=showOverlay)
plotshape(conDoTrend, it0, shapeCon, LABAR, colConDoTrend,
size=SZ, display=showOverlay)
plotshape(cciTop, it1, shapeCCI, LABAR, colCCITop,
size=SZ, display=showOverlay)
plotshape(cciBot, it1, shapeCCI, LBBAR, colCCIBot,
size=SZ, display=showOverlay)
// Plots:
plot(mDMI, 'DMI Histogram', colDMI, 4, PH, display=showDMI)
plot(mDMI, 'DMI', CGRAY, display=showDMI)
plot(uCCI, 'CCI+', colCCI, 2, PH, false,+100, display=showCCI)
plot(lCCI, 'CCI-', colCCI, 2, PH, false,-100, display=showCCI)
plot(CCI, 'CCI', #BBFFFF, 2, display=showCCI)
hline(0, 'LVL0', CGRAY, display=showLVL)
h1 = hline(+100, "100", CGRAY, display = showCCI)
h2 = hline(-100, "100", CGRAY, display = showCCI)
fill(h1, h2, color.new(CGRAY, 90))
barcolor(colDMI, editable=true, title='barcolor')
// Article: Short-Term Continuation And Reversal Signals
// Article By: Barbara Star
// Language: TradingView's Pine Script™ v5
// Provided By: PineCoders, for tradingview.com
//@version=5
string title = 'TASC 2022.12 ' +
'Short-Term Continuation And Reversal Signals'
string stitle = 'TASC 2022.12'
indicator(title, stitle, false)
// Constant variables:
string XP0 = shape.arrowdown, string XP5 = shape.flag
string XP1 = shape.arrowup , string XP6 = shape.square
string XP2 = shape.circle , string XP7 = shape.triangledown
string XP3 = shape.cross , string XP8 = shape.triangleup
string XP4 = shape.diamond , string XP9 = shape.xcross
string LTOP= location.top , string LABAR = location.abovebar
string LBOT= location.bottom, string LBBAR = location.belowbar
string SZ = size.tiny , string LDASH = line.style_dashed
PH = plot.style_histogram
color CGRAY = #555522
// Input panel groups, titles and inline references:
string g00 = 'Input Options:'
string g01 = 'Style Options:'
string it0 = 'Continuity Signals:'
string it1 = 'CCI Signals: '
string it2 = 'Oscillator Mode:'
string it3 = 'DMI Colors: '
string it4 = 'DMI Multiplier: '
string MD0 = 'DMI', string MD2 = 'Dual'
string MD1 = 'CCI', string MD3 = 'Overlay'
// Input options:
string mode = input.string(MD2, it2,
[MD0, MD1, MD2, MD3], group=g00)
float DMIMult = input.float(1.0, it4, step=0.25, group=g00)
int diLength = input.int(10, 'DMI Length:', group=g00)
int maLength = input.int(18, 'MA Length:', group=g00)
int cciLength = input.int(13, 'CCI Length:', group=g00)
// Style options:
color colDMIUp = input.color(#22AA22,it3,'',it3,g01)
color colDMIDo = input.color(#AA2222,'','',it3,g01)
string shapeCon = input.string(XP2, it0,
[XP0,XP1,XP2,XP3,XP4,XP5,XP6,XP7,XP8,XP9],'',it0,g01)
color colConUpTrend = input.color(#5188FF,'','',it0,g01)
color colConDoTrend = input.color(#771515,'','',it0,g01)
string shapeCCI = input.string(XP4, it1,
[XP0,XP1,XP2,XP3,XP4,XP5,XP6,XP7,XP8,XP9],'',it1,g01)
color colCCITop = input.color(#BB00FF,'','',it1,g01)
color colCCIBot = input.color(#FFBB00,'','',it1,g01)
// Indicators:
float ma = ta.sma(close, maLength)
[dp, dm, _] = ta.dmi(diLength, 1)
float DMI = dp - dm
float mDMI = DMIMult * DMI
float CCI = ta.cci(close, cciLength)
float uCCI = CCI > +100.0 ? CCI : na
float lCCI = CCI < -100.0 ? CCI : na
// Boolean Signals:
bool pGTma = close > ma, bool pLTma = close < ma
bool cciGTp100 = CCI > 100 , bool cciLTm100 = CCI < -100
bool dmiGT0 = DMI > 0 , bool dmiLT0 = DMI < 0
bool risingL = low > low[1] and low[1] > low[2]
bool falingH = high < high[1] and high[1] < high[2]
bool conUpTrend = pGTma and dmiGT0 and risingL
bool conDoTrend = pLTma and dmiLT0 and falingH
bool cciTop = (not cciGTp100) and cciGTp100[1] and cciGTp100[2]
bool cciBot = (not cciLTm100) and cciLTm100[1] and cciLTm100[2]
bool useDMI = mode == MD0 or mode == MD2
bool useCCI = mode == MD1 or mode == MD2
bool isOverlay = mode == MD3
// Color variation:
color colDMI = switch
dmiGT0 => colDMIUp
dmiLT0 => colDMIDo
=> CGRAY
color colCCI = switch
cciGTp100 => colCCITop
cciLTm100 => colCCIBot
=> CGRAY
// Output:
showDMI = useDMI ? display.all : display.none
showCCI = useCCI ? display.all : display.none
showLVL = isOverlay ? display.none : display.all
showOverlay = isOverlay ? display.all : display.none
// Oscillator signals:
plotshape(conUpTrend, it0, shapeCon, LBOT, colConUpTrend,
size=SZ, display=showLVL)
plotshape(conDoTrend, it0, shapeCon, LTOP, colConDoTrend,
size=SZ, display=showLVL)
plotshape(cciTop, it1, shapeCCI, LTOP, colCCITop,
size=SZ, display=showLVL)
plotshape(cciBot, it1, shapeCCI, LBOT, colCCIBot,
size=SZ, display=showLVL)
// Overlaid signals:
plotshape(conUpTrend, it0, shapeCon, LBBAR, colConUpTrend,
size=SZ, display=showOverlay)
plotshape(conDoTrend, it0, shapeCon, LABAR, colConDoTrend,
size=SZ, display=showOverlay)
plotshape(cciTop, it1, shapeCCI, LABAR, colCCITop,
size=SZ, display=showOverlay)
plotshape(cciBot, it1, shapeCCI, LBBAR, colCCIBot,
size=SZ, display=showOverlay)
// Plots:
plot(mDMI, 'DMI Histogram', colDMI, 4, PH, display=showDMI)
plot(mDMI, 'DMI', CGRAY, display=showDMI)
plot(uCCI, 'CCI+', colCCI, 2, PH, false,+100, display=showCCI)
plot(lCCI, 'CCI-', colCCI, 2, PH, false,-100, display=showCCI)
plot(CCI, 'CCI', #BBFFFF, 2, display=showCCI)
hline(0, 'LVL0', CGRAY, display=showLVL)
h1 = hline(+100, "100", CGRAY, display = showCCI)
h2 = hline(-100, "100", CGRAY, display = showCCI)
fill(h1, h2, color.new(CGRAY, 90))
barcolor(colDMI, editable=true, title='barcolor')