0% found this document useful (0 votes)
230 views2 pages

Script 2

Uploaded by

CMR C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
230 views2 pages

Script 2

Uploaded by

CMR C
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

//@version=5

indicator("Current Week High/Low, Previous Day High/Low, Daily Open with Bollinger Bands",
shorttitle="Current Week High/Low & Prev HL & Daily Open", overlay=true)

// Current Week High and Low


currentWeekHigh = request.security(syminfo.tickerid, "W", high, lookahead=barmerge.lookahead_on)
currentWeekLow = request.security(syminfo.tickerid, "W", low, lookahead=barmerge.lookahead_on)

// Previous Day High and Low


prevDayHigh = request.security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
prevDayLow = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)

// Daily Open
dailyOpen = request.security(syminfo.tickerid, "D", open, lookahead=barmerge.lookahead_on)

// EMA
emaLength = input.int(20, minval=1, title="EMA Length")
ema = ta.ema(close, emaLength)

// Bollinger Bands
length = input.int(20, minval=1, title="Bollinger Bands Length")
src = close
mult = input.float(2.0, minval=0.001, maxval=50, title="Bollinger Bands StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev

// Determine bullish or bearish tilt


bullishTilt = basis > basis[1]
bearishTilt = basis < basis[1]

// Determine breakout conditions for previous day's high and low


breakoutConditionHigh = close > prevDayHigh
breakoutConditionLow = close < prevDayLow

// Change color based on breakout conditions


prevHighColor = breakoutConditionHigh ? color.green : color.blue
prevLowColor = breakoutConditionLow ? color.red : color.orange

// Determine color based on daily open's relationship with Bollinger Bands


openColor = dailyOpen > upper ? color.green : dailyOpen < lower ? color.red : color.black

// Determine color for EMA price coiling


coilingColor = ta.crossover(close, ema) ? color.purple : ta.crossunder(close, ema) ? color.yellow : color.black

// Plotting
plot(currentWeekHigh, color=color.green, style=plot.style_stepline, linewidth=2, title="Current Week High")
plot(currentWeekLow, color=color.red, style=plot.style_stepline, linewidth=2, title="Current Week Low")
plot(prevDayHigh, color=prevHighColor, style=plot.style_stepline, linewidth=2, title="Previous Day High")
plot(prevDayLow, color=prevLowColor, style=plot.style_stepline, linewidth=2, title="Previous Day Low")
plot(dailyOpen, color=openColor, style=plot.style_stepline, linewidth=2, title="Daily Open")
plot(upper, color=bullishTilt ? color.green : color.red, linewidth=2, title="Upper Bollinger Band")
plot(lower, color=bearishTilt ? color.red : color.green, linewidth=2, title="Lower Bollinger Band")
plot(basis, color=color.blue, linewidth=2, title="Bollinger Band Basis")
plot(ema, color=coilingColor, style=plot.style_line, linewidth=2, title="EMA Price Coiling")

t = time("1440", session.extended) // 1440=60*24 is the number of minutes in a whole day. You may use "0930-
1600" as second session parameter
//plot(t, style=linebr) // debug
is_first = na(t[1]) and not na(t) or t[1] < t
plotshape(is_first, color=color.red, style=shape.arrowdown)

var float day_high = na


var float day_low = na

if (is_first and barstate.isnew)


day_high := high
day_low := low
else
day_high := day_high[1]
day_low := day_low[1]

if (high > day_high)


day_high := high

if (low < day_low)


day_low := low

plot(day_high, color=color.lime)
plot(day_low, color=color.red)

You might also like