Professional Documents
Culture Documents
study("5EMA-BB-Dem&Sup-VW-Bu&Se-_2.35&48&PD", overlay=true)
//BB-Dem&Sup-VW-Bu&Se-_2.35&48&PD
Long = close > Trend1 and close > Trend2 and close > Trend3 and
crossover(rsi(close,14),60) and volume > sma(volume,20)
Short = close < Trend1 and close < Trend2 and close < Trend3 and
crossunder(rsi(close,14),40) and volume > sma(volume,20)
//high_range = valuewhen(is_newbar('D'),high,0)
//low_range = valuewhen(is_newbar('D'),low,0)
high_rangeL = valuewhen(is_newbar('D'),high,0)
low_rangeL = valuewhen(is_newbar('D'),low,0)
diff = (high_rangeL-low_rangeL)/2.35
up15 = plot(up15on ? adopt('15', high_rangeL): na, color = #009900,
linewidth=1,style=plot.style_line)
down15 = plot(down15on ? adopt('15', low_rangeL): na, color = #ff0000,
linewidth=1,style=plot.style_line)
//@version=4
///study(title="Supply and Demand Zones",shorttitle="Supply / Demand",overlay=true)
//Daily zones
//daily = input(title = "Daily",type = input.bool,defval=true)
//dopen =
security(syminfo.tickerid,'D',open,barmerge.gaps_off,barmerge.lookahead_on)
//dayrange=(high-low)
//dcol = color.red
//r1 = security(syminfo.tickerid,'D',dayrange)
//r2 = security(syminfo.tickerid, 'D', dayrange[1])
//r3 = security(syminfo.tickerid, 'D', dayrange[2])
//r4= security(syminfo.tickerid, 'D', dayrange[3])
//r5= security(syminfo.tickerid, 'D', dayrange[4])
//r6 = security(syminfo.tickerid, 'D', dayrange[5])
//r7 = security(syminfo.tickerid, 'D', dayrange[6])
//r8 = security(syminfo.tickerid, 'D', dayrange[7])
//r9= security(syminfo.tickerid, 'D', dayrange[8])
//r10= security(syminfo.tickerid, 'D', dayrange[9])
//adrhigh10 = dopen+(adr_10/2)
//adrhigh5 = dopen+(adr_5/2)
//adrlow5 = dopen-(adr_5/2)
//adrlow10 = dopen-(adr_10/2)
//Weekly zones
weekly = input(title = "Weekly",type = input.bool,defval=true)
wopen = security(syminfo.tickerid,'W',open,barmerge.gaps_off,barmerge.lookahead_on)
weekrange=(high-low)
wcol = color.blue
wr1 = security(syminfo.tickerid,'W',weekrange)
wr2 = security(syminfo.tickerid, 'W', weekrange[1])
wr3 = security(syminfo.tickerid, 'W', weekrange[2])
wr4= security(syminfo.tickerid, 'W', weekrange[3])
wr5= security(syminfo.tickerid, 'W', weekrange[4])
wr6 = security(syminfo.tickerid, 'W', weekrange[5])
wr7 = security(syminfo.tickerid, 'W', weekrange[6])
wr8 = security(syminfo.tickerid, 'W', weekrange[7])
wr9= security(syminfo.tickerid, 'W', weekrange[8])
wr10= security(syminfo.tickerid, 'W', weekrange[9])
awrhigh10 = wopen+(awr_10/2)
awrhigh5 = wopen+(awr_5/2)
awrlow5 = wopen-(awr_5/2)
awrlow10 = wopen-(awr_10/2)
//Monthly zones
monthly = input(title = "Monthly",type = input.bool,defval=true)
mopen = security(syminfo.tickerid,'M',open,barmerge.gaps_off,barmerge.lookahead_on)
monthrange=(high-low)
mcol = color.green
mr1 = security(syminfo.tickerid,'M',monthrange)
mr2 = security(syminfo.tickerid, 'M', monthrange[1])
mr3 = security(syminfo.tickerid, 'M', monthrange[2])
mr4= security(syminfo.tickerid, 'M', monthrange[3])
mr5= security(syminfo.tickerid, 'M', monthrange[4])
mr6 = security(syminfo.tickerid, 'M', monthrange[5])
mr7 = security(syminfo.tickerid, 'M', monthrange[6])
mr8 = security(syminfo.tickerid, 'M', monthrange[7])
mr9= security(syminfo.tickerid, 'M', monthrange[8])
mr10= security(syminfo.tickerid, 'M', monthrange[9])
amrhigh10 = mopen+(amr_10/2)
amrhigh5 = mopen+(amr_5/2)
amrlom5 = mopen-(amr_5/2)
amrlom10 = mopen-(amr_10/2)
//@version=4
quickEMA = ema(close, 9)
plot(series=quickEMA, color=color.green, linewidth=1)
per1 = input(defval=27, minval=1, title="Fast period")
mult1 = input(defval=1.6, minval=0.1, title="Fast range")
per2 = input(defval=55, minval=1, title="Slow period")
mult2 = input(defval=2, minval=0.1, title="Slow range")
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ema(abs(x - x[1]), t)
smoothrng = ema(avrng, wper) * m
smoothrng
smrng1 = smoothrng(source, per1, mult1)
smrng2 = smoothrng(source, per2, mult2)
smrng = (smrng1 + smrng2) / 2
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(source, 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])
hband = filt + smrng
lband = filt - smrng
longCond = bool(na)
shortCond = bool(na)
longCond := source > filt and source > source[1] and upward > 0 or source > filt
and source < source[1] and upward > 0
shortCond := source < filt and source < source[1] and downward > 0 or source < filt
and source > source[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
long = longCond and CondIni[1] == -1
short = shortCond and CondIni[1] == 1
plotshape(long, title="BUY", text="BUY", style=shape.labelup,
textcolor=color.white, size=size.auto, location=location.belowbar,
color=color.green, transp=0)
plotshape(short, title="SELL", text="SELL", style=shape.labeldown,
textcolor=color.white, size=size.auto, location=location.abovebar, color=color.red,
transp=0)
alertcondition(long, title="BUY", message="BUY")
alertcondition(short, title="SELL", message="SELL")
anchor = input(defval = "Session", title="Anchor Period", type=input.string)
MILLIS_IN_DAY = 86400000
dwmBarTime = timeframe.isdwm ? time : time("D")
if na(dwmBarTime)
dwmBarTime := nz(dwmBarTime[1])
var periodStart = time - time // zero
makeMondayZero(dayOfWeek) => (dayOfWeek + 5) % 7
isMidnight(t) =>
hour(t) == 0 and minute(t) == 0
isSameDay(t1, t2) =>
dayofmonth(t1) == dayofmonth(t2) and
month(t1) == month(t2) and
year(t1) == year(t2)
isOvernight() =>
not (isMidnight(dwmBarTime) or security(syminfo.tickerid, "D", isSameDay(time,
time_close), lookahead=true))
tradingDayStart(t) =>
y = year(t)
m = month(t)
d = dayofmonth(t)
timestamp(y, m, d, 0, 0)
numDaysBetween(time1, time2) =>
y1 = year(time1)
m1 = month(time1)
d1 = dayofmonth(time1)
y2 = year(time2)
m2 = month(time2)
d2 = dayofmonth(time2)
diff = abs(timestamp("GMT", y1, m1, d1, 0, 0) - timestamp("GMT", y2, m2, d2, 0,
0))
diff / MILLIS_IN_DAY
tradingDay = isOvernight() ? tradingDayStart(dwmBarTime + MILLIS_IN_DAY) :
tradingDayStart(dwmBarTime)
isNewPeriod() =>
isNew = false
if tradingDay != nz(tradingDay[1])
if anchor == "Session"
isNew := na(tradingDay[1]) or tradingDay > tradingDay[1]
if anchor == "Week"
DAYS_IN_WEEK = 7
isNew := makeMondayZero(dayofweek(periodStart)) +
numDaysBetween(periodStart, tradingDay) >= DAYS_IN_WEEK
if anchor == "Month"
isNew := month(periodStart) != month(tradingDay) or year(periodStart) !
= year(tradingDay)
if anchor == "Year"
isNew := year(periodStart) != year(tradingDay)
isNew
src = hlc3
sumSrc = float(na)
sumVol = float(na)
sumSrc := nz(sumSrc[1], 0)
sumVol := nz(sumVol[1], 0)
if isNewPeriod()
periodStart := tradingDay
sumSrc := 0.0
sumVol := 0.0
GLlabel=label.new(x=bar_index,y=close,text=" \n\n\n\n\n\n "+" stock setup" ,
style=label.style_label_up,
color=color.new(color.aqua,transp=100),
textcolor=color.new(color.aqua,transp=30),
size=size.normal)
label.delete(GLlabel[1])
if not na(src) and not na(volume)
sumSrc := sumSrc + src * volume
sumVol := sumVol + volume
vwapValue = sumSrc / sumVol
plot(vwapValue, title="VWAP", color=color.red, linewidth=3)
//EOS
// EMA
ema_01_len = input(10, title='Ema 1', step=1, type=input.integer)
ema_02_len = input(20, title='Ema 2', step=1, type=input.integer)
// E moving average
ema_01 = ema(ema_src, ema_01_len)
ema_02 = ema(ema_src, ema_02_len)
//EMAs in Chart
plot(ema_01, title='ema_01', color=#00FF00, transp=0, style=plot.style_line,
linewidth=1)
plot(ema_02, title='ema_02', color=#ff0040, transp=0, style=plot.style_line,
linewidth=1)
// MA
ma_01_len = input(9, title='ma 1', step=1, type=input.integer)
ma_02_len = input(26, title='ma 2', step=1, type=input.integer)
ma_src = input(title="Source", type=input.source, defval=close)
// Moving Average
ma_01 = sma(ma_src, ma_01_len)
ma_02 = sma(ma_src, ma_02_len)
//MAs in Chart
plot(ma_01, title='ma_01', color=#00FF00, transp=0, style=plot.style_line,
linewidth=1)
plot(ma_02, title='ma_02', color=#ff0040, transp=0, style=plot.style_line,
linewidth=1)
//@version=3
//
// @mrSebastienC
// 2018-10-5
//study(title="Double Bollinger Bands", shorttitle="DBB", overlay=true)
color_gray = #eeeeee
color_green = #3fbe53
color_red = #ff4e3e
transp_bb_1 = 98
transp_bb_2 = 94
//color_gray = #eeeeee
//color_green = #3fbe53
//color_red = #ff4e3e
transp_bb_HTF = 94
//@version=4
//study("SBER EMA Channel", overlay=true)
//plot(ema(high, 48), color=color.blue)
///plot(ema(low, 48), color=color.red)
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © FX365_Thailand
//Revision History
//v31.0
//Added label for each High/Low
//Added alert for crossing each High/Low
//v32.0
//Minor correction on labels
//@version=4
//Define indicator name
//study("High Low Yesterday & Today & Last week & Last
month",overlay=true,shorttitle="High Low Yesterday/Today/Last week/Last month")
//Users input
chk_yh = input(title="PDH", defval=true)
chk_yl = input(title="PDL", defval=true)