timeFilter = input.timeframe(title = "Cutoff time for indentifying HOD/LOD zone (EST). Recommended 9:30-11:30 AM EST", defval = "0930-1130", options = ['0930-1100', '0930-1130'])
fastMAInput = input(title='Fast EMA Period', defval=9)
slowMAInput = input(title='Slow EMA Period', defval=21)
midMAInput = input(title='Mid EMA Period', defval=13)
srcHi = input(high, "Source for Highs")
srcLo = input(low, "Source for Lows")
showHi = input(true, "Show HOD breakout zone")
showLo = input(true, "Show LOD breakdown zone")
showCloud = input(true, "Show cloud for breakout and breakdown")
showTrendArrow = input(true, "Show trend arrows for breakout and breakdown")
showCandleMomentum = input(true, "Show candlesticks with strong upside/downside momentum")
upConvictionArrow = showTrendArrow
downConvictionArrow = showTrendArrow
[dOpen,dh,dl] = request.security(syminfo.ticker, "D", [open,high,low], lookahead=barmerge.lookahead_on)
rsi = ta.rsi(close[1], 14)
rsi5m = request.security(syminfo.tickerid, '5', rsi)
// Check to see if we are in allowed hours using session info on all 7 days of the week.
timeIsBeforeCriteria = time('1', timeFilter + ":1234567", timezone = "America/New_York")
var hiBeforeCriteria = 10e-10
var loBeforeCriteria = 10e10
var startCounting = false
if timeIsBeforeCriteria
// We are entering allowed hours; reset hi/lo.
if not timeIsBeforeCriteria[1]
hiBeforeCriteria := srcHi
loBeforeCriteria := srcLo
else
// We are in allowed hours; track hi/lo.
hiBeforeCriteria := math.max(srcHi,hiBeforeCriteria)
loBeforeCriteria := math.min(srcLo,loBeforeCriteria)
remainingSession = switch timeFilter
'0930-1100' => '1100-1600'
'0930-1130' => '1130-1600'
// Calculate the fast and slow moving averages
fastMA = ta.ema(close, fastMAInput)
slowMA = ta.ema(close, slowMAInput)
midMA = ta.ema(close, midMAInput)
// Average Directional Index (ADX)
[th, tl, adx] = ta.dmi(7, 3)
// Identify sideways market using ADX
sideways = adx < 30
uptrend = th > 30 and th < 70
downtrend = tl >30 and tl < 70
// Fill the price bars with a specific color when ADX is below 20
// barcolor(sideways ? color.purple : na)
barcolor(uptrend and showCandleMomentum? color.rgb(145, 255, 0) : na)
barcolor(downtrend and showCandleMomentum? color.rgb(255, 0, 200) : na)
t1 = time(timeframe.period, remainingSession, "America/New_York")
// Check if the stock is trading above ...
condition1 = close > slowMA and close > dOpen
// Check if the stock is making a new high after time specified by user
condition2 = time >= t1 and close > (hiBeforeCriteria * 1.001) and close[1] > (hiBeforeCriteria * 1.001)
upConvictionArrow := showTrendArrow and th > 25 and condition1 and condition2 and (close > fastMA)
//upConvictionArrow := showTrendArrow and th > 25 and condition1 and condition2 and (close > fastMA) and (low > low[1])
// plot hi and low at 11
resistanceLowerBound = plot(t1 and showHi ? hiBeforeCriteria: na, style=plot.style_linebr, linewidth=1, color= color.red, title = "HOD lower limit")
resistanceUpperBound = plot(t1 and showHi ? hiBeforeCriteria * 1.001: na, style=plot.style_linebr, linewidth=1, color= color.red, title = "HOD upper limit")
fill(resistanceLowerBound, resistanceUpperBound, color = color.new(color.red, 80), title = "HOD breakout zone")
supportLowerBound = plot(t1 and showLo ? loBeforeCriteria*0.999 : na, style=plot.style_linebr, linewidth=0, color= color.green, title = "LOD lower limit")
supportUpperBound = plot(t1 and showLo ? loBeforeCriteria : na, style=plot.style_linebr, linewidth=0, color= color.green, title = "LOD upper limit")
fill(supportLowerBound, supportUpperBound, color = color.new(color.green, 80), title = "LOD breakdown zone")
fastPlot = plot(condition1 and condition2 and showCloud ? slowMA : na, color=color.new(color.green, 100), style = plot.style_linebr, linewidth = 1, title = "Fast EMA support line")
slowPlot = plot(condition1 and condition2 and showCloud ? fastMA : na, color=color.new(color.green, 100), style = plot.style_linebr, linewidth = 2, title = "Slow EMA support line")
fill(fastPlot, slowPlot, color=color.new(#30ff4c, 75), title = "Breakout support cloud")
plotshape(upConvictionArrow ? 1: 0, style = shape.triangleup, color = color.green, size = size.tiny, location = location.belowbar, title = "Breakout conviction arrow")
// Check if the stock is trading below both moving averages
condition3 = close < slowMA and close < dOpen
condition4 = time >= t1 and close < (loBeforeCriteria * 0.999) and close[1] < (loBeforeCriteria * 0.999)
downConvictionArrow := downConvictionArrow and tl > 25 and condition3 and condition4 and (close < fastMA)
//downConvictionArrow := downConvictionArrow and tl > 25 and condition3 and condition4 and (close < fastMA) and (low < low[1])
// Combine the conditions and plot the result
fastPlot1 = plot(condition3 and condition4 and showCloud? slowMA : na, color=color.new(color.red, 100), style = plot.style_linebr, linewidth = 1, title = "Fast EMA resistance line")
slowPlot1 = plot(condition3 and condition4 and showCloud? fastMA : na, color=color.new(color.red, 100), style = plot.style_linebr, linewidth = 2, title = "Slow EMA resistance line")
fill(fastPlot1, slowPlot1, color=color.new(#ff0202, 75), title = "Breakdown resistance cloud")
plotshape(downConvictionArrow ? 1: 0, style = shape.triangledown, color = color.red, size = size.tiny, location = location.abovebar, title = "Breakdown conviction arrow")Pine Script® Pine Script®
fastMAInput = input(title='Fast EMA Period', defval=9)
slowMAInput = input(title='Slow EMA Period', defval=21)
midMAInput = input(title='Mid EMA Period', defval=13)
srcHi = input(high, "Source for Highs")
srcLo = input(low, "Source for Lows")
showHi = input(true, "Show HOD breakout zone")
showLo = input(true, "Show LOD breakdown zone")
showCloud = input(true, "Show cloud for breakout and breakdown")
showTrendArrow = input(true, "Show trend arrows for breakout and breakdown")
showCandleMomentum = input(true, "Show candlesticks with strong upside/downside momentum")
upConvictionArrow = showTrendArrow
downConvictionArrow = showTrendArrow
[dOpen,dh,dl] = request.security(syminfo.ticker, "D", [open,high,low], lookahead=barmerge.lookahead_on)
rsi = ta.rsi(close[1], 14)
rsi5m = request.security(syminfo.tickerid, '5', rsi)
// Check to see if we are in allowed hours using session info on all 7 days of the week.
timeIsBeforeCriteria = time('1', timeFilter + ":1234567", timezone = "America/New_York")
var hiBeforeCriteria = 10e-10
var loBeforeCriteria = 10e10
var startCounting = false
if timeIsBeforeCriteria
// We are entering allowed hours; reset hi/lo.
if not timeIsBeforeCriteria[1]
hiBeforeCriteria := srcHi
loBeforeCriteria := srcLo
else
// We are in allowed hours; track hi/lo.
hiBeforeCriteria := math.max(srcHi,hiBeforeCriteria)
loBeforeCriteria := math.min(srcLo,loBeforeCriteria)
remainingSession = switch timeFilter
'0930-1100' => '1100-1600'
'0930-1130' => '1130-1600'
// Calculate the fast and slow moving averages
fastMA = ta.ema(close, fastMAInput)
slowMA = ta.ema(close, slowMAInput)
midMA = ta.ema(close, midMAInput)
// Average Directional Index (ADX)
[th, tl, adx] = ta.dmi(7, 3)
// Identify sideways market using ADX
sideways = adx < 30
uptrend = th > 30 and th < 70
downtrend = tl >30 and tl < 70
// Fill the price bars with a specific color when ADX is below 20
// barcolor(sideways ? color.purple : na)
barcolor(uptrend and showCandleMomentum? color.rgb(145, 255, 0) : na)
barcolor(downtrend and showCandleMomentum? color.rgb(255, 0, 200) : na)
t1 = time(timeframe.period, remainingSession, "America/New_York")
// Check if the stock is trading above ...
condition1 = close > slowMA and close > dOpen
// Check if the stock is making a new high after time specified by user
condition2 = time >= t1 and close > (hiBeforeCriteria * 1.001) and close[1] > (hiBeforeCriteria * 1.001)
upConvictionArrow := showTrendArrow and th > 25 and condition1 and condition2 and (close > fastMA)
//upConvictionArrow := showTrendArrow and th > 25 and condition1 and condition2 and (close > fastMA) and (low > low[1])
// plot hi and low at 11
resistanceLowerBound = plot(t1 and showHi ? hiBeforeCriteria: na, style=plot.style_linebr, linewidth=1, color= color.red, title = "HOD lower limit")
resistanceUpperBound = plot(t1 and showHi ? hiBeforeCriteria * 1.001: na, style=plot.style_linebr, linewidth=1, color= color.red, title = "HOD upper limit")
fill(resistanceLowerBound, resistanceUpperBound, color = color.new(color.red, 80), title = "HOD breakout zone")
supportLowerBound = plot(t1 and showLo ? loBeforeCriteria*0.999 : na, style=plot.style_linebr, linewidth=0, color= color.green, title = "LOD lower limit")
supportUpperBound = plot(t1 and showLo ? loBeforeCriteria : na, style=plot.style_linebr, linewidth=0, color= color.green, title = "LOD upper limit")
fill(supportLowerBound, supportUpperBound, color = color.new(color.green, 80), title = "LOD breakdown zone")
fastPlot = plot(condition1 and condition2 and showCloud ? slowMA : na, color=color.new(color.green, 100), style = plot.style_linebr, linewidth = 1, title = "Fast EMA support line")
slowPlot = plot(condition1 and condition2 and showCloud ? fastMA : na, color=color.new(color.green, 100), style = plot.style_linebr, linewidth = 2, title = "Slow EMA support line")
fill(fastPlot, slowPlot, color=color.new(#30ff4c, 75), title = "Breakout support cloud")
plotshape(upConvictionArrow ? 1: 0, style = shape.triangleup, color = color.green, size = size.tiny, location = location.belowbar, title = "Breakout conviction arrow")
// Check if the stock is trading below both moving averages
condition3 = close < slowMA and close < dOpen
condition4 = time >= t1 and close < (loBeforeCriteria * 0.999) and close[1] < (loBeforeCriteria * 0.999)
downConvictionArrow := downConvictionArrow and tl > 25 and condition3 and condition4 and (close < fastMA)
//downConvictionArrow := downConvictionArrow and tl > 25 and condition3 and condition4 and (close < fastMA) and (low < low[1])
// Combine the conditions and plot the result
fastPlot1 = plot(condition3 and condition4 and showCloud? slowMA : na, color=color.new(color.red, 100), style = plot.style_linebr, linewidth = 1, title = "Fast EMA resistance line")
slowPlot1 = plot(condition3 and condition4 and showCloud? fastMA : na, color=color.new(color.red, 100), style = plot.style_linebr, linewidth = 2, title = "Slow EMA resistance line")
fill(fastPlot1, slowPlot1, color=color.new(#ff0202, 75), title = "Breakdown resistance cloud")
plotshape(downConvictionArrow ? 1: 0, style = shape.triangledown, color = color.red, size = size.tiny, location = location.abovebar, title = "Breakdown conviction arrow")
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.