0% found this document useful (0 votes)
44 views

DGC LEVELS Updated

The document describes a technical indicator for displaying open range breakout levels on charts. It defines variables for the high and low of the current bar and previous bars. Lines and levels are plotted including the open range breakout high and low, and resistance and support levels calculated based on the open range.

Uploaded by

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

DGC LEVELS Updated

The document describes a technical indicator for displaying open range breakout levels on charts. It defines variables for the high and low of the current bar and previous bars. Lines and levels are plotted including the open range breakout high and low, and resistance and support levels calculated based on the open range.

Uploaded by

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

//@version=5

indicator('[DGC LEVELS]', 'ॐ', overlay=true, max_lines_count=500,


max_labels_count=500, max_bars_back=5000)
show_labels = input.bool(title="Show Labels", defval=true, group='Settings ॐ')
Round_it(valu) =>
a = 0
num = syminfo.mintick
s = valu
if na(s)
s := syminfo.mintick
s
if num < 1
for i = 1 to 20 by 1
num *= 10
if num > 1
break
a += 1
a

for x = 1 to a by 1
s *= 10
s
s := math.round(s)
for x = 1 to a by 1
s /= 10
s
s := s < syminfo.mintick ? syminfo.mintick : s
s

///////===============ORB ===OPEN RANGE BREAKOUT 15 MIN


show15highlow = input.bool(title='ORB ON', defval=true, inline='orb', group='ORB
ॐ')
inputMax = input(15, title= "ORB total time (minutes)", group='ORB ॐ')
sess = input.session('0915-0930', title='Time Period', inline='orb', group='ORB
ॐ')
t = time(timeframe.period, sess + ':1234567')
hide = timeframe.isintraday and timeframe.multiplier <= inputMax

is_newbar(res) => ta.change(time(res)) != 0


in_session = not na(t)
is_first = in_session and not in_session[1]

orb_high = float(na)
orb_low = float(na)

if is_first
orb_high := high
orb_low := low
else
orb_high := orb_high[1]
orb_low := orb_low[1]

if high > orb_high and in_session


orb_high := high
if low < orb_low and in_session
orb_low := low

//plot(show15highlow ? orb_high : na , style=plot.style_line, color=orb_high[1] !=


orb_high ? na : color.navy, title="ORB High", linewidth=2, trackprice=true)
//plot(show15highlow ? orb_low : na , style=plot.style_line, color=orb_low[1] !=
orb_low ? na : color.navy, title="ORB Low", linewidth=2, trackprice=true)
orbh = plot(show15highlow ? orb_high : na , style=plot.style_line,
color=orb_high[1] != orb_high ? na : color.navy, title="ORB High", linewidth=2,
trackprice=true)
orbl = plot(show15highlow ? orb_low : na , style=plot.style_line,
color=orb_low[1] != orb_low ? na : color.navy, title="ORB Low", linewidth=2,
trackprice=true)
//fill(orbh, orbl, title = "ORB_Background", color=color.new(#2f02f6, 70),
transp=10)
Background_ORB = input.bool(true)
fill(orbh, orbl, title = "Background_ORB", color=Background_ORB? color.new(#2f02f6,
70) : na, transp=10)//, display=display.none)
//
===================================================================================
===========================
candle_range = (orb_high - orb_low)
half_candle_range = (orb_high - orb_low) / 2

R2 = orb_high + candle_range
R1 = orb_high + half_candle_range
R2_C = plot(show15highlow ? R2: na , title='R2', color=color.red ,
style=plot.style_line , linewidth=2, trackprice=true)
R1_C = plot(show15highlow ? R1: na , title='R1', color=color.red ,
style=plot.style_line , linewidth=2, trackprice=true)

S2 = orb_low - candle_range
S1 = orb_low - half_candle_range
S1_C = plot(show15highlow ? S1: na , title='S1', color=color.green ,
style=plot.style_line , linewidth=2, trackprice=true)
S2_C = plot(show15highlow ? S2: na , title='S2', color=color.green ,
style=plot.style_line , linewidth=2, trackprice=true)

//===================labels
label_orb_high = show15highlow and show_labels ? label.new(bar_index, orb_high,
text=show_labels ? (" ORB_HIGH" + "•" +
str.tostring(Round_it(orb_high))) : "orb_high", style= label.style_none,
textcolor=color.red, size=size.normal) : na
label.delete(label_orb_high[1])

label_orb_low = show15highlow and show_labels ? label.new(bar_index, orb_low,


text=show_labels ? (" ORB_LOW" + "•" +
str.tostring(Round_it(orb_low))) : "orb_low", style= label.style_none,
textcolor=color.green, size=size.normal) : na
label.delete(label_orb_low[1])

label_R1 = show15highlow and show_labels ? label.new(bar_index, R1,


text=show_labels ? (" R1_DGC" + "•" +
str.tostring(Round_it(R1))) : "R1", style= label.style_none, textcolor=color.red,
size=size.normal) : na
label.delete(label_R1[1])

label_R2 = show15highlow and show_labels ? label.new(bar_index, R2,


text=show_labels ? (" R2_DGC" + "•" +
str.tostring(Round_it(R2))) : "R2", style= label.style_none, textcolor=color.red,
size=size.normal) : na
label.delete(label_R2[1])

label_S1 = show15highlow and show_labels ? label.new(bar_index, S1,


text=show_labels ? (" S1_DGC" + "•" +
str.tostring(Round_it(S1))) : "S1", style= label.style_none,
textcolor=color.green, size=size.normal) : na
label.delete(label_S1[1])

label_S2 = show15highlow and show_labels ? label.new(bar_index, S2,


text=show_labels ? (" S2_DGC" + "•" +
str.tostring(Round_it(S2))) : "S2", style= label.style_none,
textcolor=color.green, size=size.normal) : na
label.delete(label_S2[1])

//DAY_HIGH_LOW LEVELS=========Daily high and low


dailylevelsshow = input.bool(title='DAY_HIGH_LOW LEVELS ON', defval=true,
inline='dailylevelsshow', group='DAY_HIGH_LOW LEVELS LEVELS ॐ')
dailyhigh = request.security(syminfo.tickerid, 'D', high, barmerge.gaps_off,
lookahead=barmerge.lookahead_on)
dailylow = request.security(syminfo.tickerid, 'D', low, barmerge.gaps_off,
lookahead=barmerge.lookahead_on)
plot(dailylevelsshow ? dailyhigh : na, style=plot.style_line,title="DAY HIGH",
color=#b71c1c, linewidth=2, offset=0,trackprice=true) //trackprice=true
plot(dailylevelsshow ? dailylow: na, style=plot.style_line,title="DAY
LOW",color=#1b5e20, linewidth=2, offset=0, trackprice=true) // trackprice=true,
dh = dailylevelsshow and show_labels ? label.new(bar_index+5, dailyhigh,
text=show_labels ? ("DAY HIGH" + "•" + str.tostring(Round_it(dailyhigh))) :
"dailyhigh", style= label.style_label_left, color=color.new(#b71c1c, 40),
textcolor=color.white, size=size.normal, textalign=text.align_right) : na
//style= label.style_none
label.delete(dh[1])
dl = dailylevelsshow and show_labels ? label.new(bar_index+5, dailylow,
text=show_labels ? ("DAY LOW" + "•" + str.tostring(Round_it(dailylow))) :
"dailylow", style= label.style_label_left, color=color.new(#1b5e20, 40),
textcolor=color.white, size=size.normal, textalign=text.align_right) : na
//style= label.style_none
label.delete(dl[1])

day_range = (dailyhigh - dailylow)


half_day_range = dailylow + (day_range / 2)
PERC_25_BELOW_DAY_HIGH = half_day_range + (dailyhigh - half_day_range) / 2
PERC_25_ABOVE_DAY_HIGH = dailylow + (half_day_range - dailylow) / 2

plot(dailylevelsshow ? PERC_25_BELOW_DAY_HIGH : na ,
title='PERC_25_BELOW_DAY_HIGH', color=color.red , style=plot.style_line ,
linewidth=1, trackprice=true)
PERC_25_BELOW_DAY_HIGH_l = dailylevelsshow and show_labels ? label.new(bar_index +
5, PERC_25_BELOW_DAY_HIGH, text=show_labels ? ("25% BELOW DAY HIGH" + "•" +
str.tostring(Round_it(PERC_25_BELOW_DAY_HIGH))) : "PERC_25_BELOW_DAY_HIGH",
style= label.style_label_left, color=color.red, textcolor=color.white,
size=size.small, textalign=text.align_right) : na //style= label.style_none
label.delete(PERC_25_BELOW_DAY_HIGH_l[1])

plot(dailylevelsshow ? half_day_range : na , title='half_day_range',


color=color.blue , style=plot.style_line , linewidth=2, trackprice=true)
half_day_range_l = dailylevelsshow and show_labels ? label.new(bar_index + 5,
half_day_range, text=show_labels ? ("HALF_DAY_HIGH_LOW" + "•" +
str.tostring(Round_it(half_day_range))) : "half_day_range", style=
label.style_label_left, color=color.blue, textcolor=color.white, size=size.normal,
textalign=text.align_right) : na //style= label.style_none
label.delete(half_day_range_l[1])
plot(dailylevelsshow ? PERC_25_ABOVE_DAY_HIGH : na ,
title='PERC_25_ABOVE_DAY_HIGH', color=color.green , style=plot.style_line ,
linewidth=1, trackprice=true)
PERC_25_ABOVE_DAY_HIGH_l = dailylevelsshow and show_labels ? label.new(bar_index +
5, PERC_25_ABOVE_DAY_HIGH, text=show_labels ? ("25% ABOVE DAY LOW" + "•" +
str.tostring(Round_it(PERC_25_ABOVE_DAY_HIGH))) : "PERC_25_ABOVE_DAY_HIGH",
style= label.style_label_left, color=color.green, textcolor=color.white,
size=size.small, textalign=text.align_right) : na //style= label.style_none
label.delete(PERC_25_ABOVE_DAY_HIGH_l[1])

dhigh = plot(dailylevelsshow ? PERC_25_BELOW_DAY_HIGH : na , style=plot.style_line,


color=PERC_25_BELOW_DAY_HIGH[1] != PERC_25_BELOW_DAY_HIGH ? na : color.red,
title="PERC_25_BELOW_DAY_HIGH", linewidth=2, trackprice=true)
dlow = plot(dailylevelsshow ? PERC_25_ABOVE_DAY_HIGH : na , style=plot.style_line,
color=PERC_25_ABOVE_DAY_HIGH[1] != PERC_25_ABOVE_DAY_HIGH ? na : color.green,
title="PERC_25_ABOVE_DAY_HIGH", linewidth=2, trackprice=true)
//fill(dhigh, dlow, title = "daily high low Background", color=color.orange,
transp=80) //, display=display.none)
Background_DAY_HIGH_LOW = input.bool(true)
fill(dhigh, dlow, title = "Background_DAY_HIGH_LOW",
color=Background_DAY_HIGH_LOW ? color.rgb(236, 228, 200) : na, transp=80) //,
display=display.none)

////PREVIOUS DAY LEVELS=========PREVIOUS Day high, low & close, Current Day open
levelsshow = input.bool(title='PREVIOUS DAY LEVELS ON', defval=true,
inline='levelsshow', group='PREVIOUS DAY LEVELS ॐ')
phhtf = request.security(syminfo.tickerid, 'D', high[1],
lookahead=barmerge.lookahead_on)
plhtf = request.security(syminfo.tickerid, 'D', low[1],
lookahead=barmerge.lookahead_on)
pchtf = request.security(syminfo.tickerid, 'D', close[1],
lookahead=barmerge.lookahead_on)

pohtf = request.security(syminfo.tickerid, 'D', open[0],


lookahead=barmerge.lookahead_on)

plot(levelsshow ? phhtf : na, style=plot.style_line,title="PDH",


color=color.orange, linewidth=2, offset=0,trackprice=true) //trackprice=true
plot(levelsshow ? plhtf : na, style=plot.style_line,title="PDL",
color=color.orange, linewidth=2, offset=0,trackprice=true) //trackprice=true
plot(levelsshow ? pchtf : na, style=plot.style_line,title="PDC", color=color.blue,
linewidth=2, offset=0,trackprice=true) //trackprice=true
plot(levelsshow ? pohtf : na, style=plot.style_line,title="CDO",
color=color.silver, linewidth=2, offset=0,trackprice=true) //trackprice=true

pdhhlabel = levelsshow and show_labels ? label.new(bar_index+15, phhtf,


text=show_labels ? ("PDH" + "•" + str.tostring(phhtf)) : "phhtf", style=
label.style_label_left, color=color.new(color.orange, 40), textcolor=color.black,
size=size.normal, textalign=text.align_right) : na //style= label.style_none
label.delete(pdhhlabel[1])
pdlllabel = levelsshow and show_labels ? label.new(bar_index+15, plhtf,
text=show_labels ? ("PDL" + "•" + str.tostring(plhtf)) : "plhtf", style=
label.style_label_left, color=color.new(color.orange, 40), textcolor=color.black,
size=size.normal, textalign=text.align_right) : na //style= label.style_none
label.delete(pdlllabel[1])
pdcclabel = levelsshow and show_labels ? label.new(bar_index+15, pchtf,
text=show_labels ? ("PDC" + "•" + str.tostring(pchtf)) : "pchtf", style=
label.style_label_left, color=color.blue, textcolor=color.white, size=size.normal,
textalign=text.align_right) : na //style= label.style_none
label.delete(pdcclabel[1])
cdolabel = levelsshow and show_labels ? label.new(bar_index+15, pohtf,
text=show_labels ? ("CDO" + "•" + str.tostring(pohtf)) : "pohtf", style=
label.style_label_left, color=color.silver, textcolor=color.black,
size=size.normal, textalign=text.align_right) : na //style= label.style_none
label.delete(cdolabel[1])
//=====CPR DAILY===================================================================
//indicator(title='dgc CPR + VWAP', overlay=true)
//tfi = input.string("D",options=["D","W","M"])
cprplot = input.bool(title='CPR ON', defval=false, inline='cprplot', group='CPR
ॐ')
// tf = timeframe.isintraday ? 'D' : timeframe.isdaily ? 'W' : timeframe.isweekly ?
'M' : ''
cpr_tf = "D"
//nr = input.float(0.50,title="Narrow Range",minval=0.01, step=0.01)

d_high = request.security(syminfo.tickerid, cpr_tf, high[1], barmerge.gaps_off,


barmerge.lookahead_on)
d_low = request.security(syminfo.tickerid, cpr_tf, low[1], barmerge.gaps_off,
barmerge.lookahead_on)
d_close = request.security(syminfo.tickerid, cpr_tf, close[1], barmerge.gaps_off,
barmerge.lookahead_on)

cpr_pivot = (d_high + d_low + d_close) / 3


TC = (d_high + d_low) / 2
BC = cpr_pivot - TC + cpr_pivot

plot(cprplot ? cpr_pivot : na, title='CP', color= color.blue,


style=plot.style_circles , linewidth=1,trackprice=true)
bc = plot(cprplot ? BC : na, title='BC', color=color.green ,
style=plot.style_line , linewidth=2,trackprice=true)
tc = plot(cprplot ? TC : na, title='TC', color=color.red , style=plot.style_line ,
linewidth=2,trackprice=true)
fill(bc, tc, title = "CPR Background", color=color.new(#f21515, 70), transp=10)//,
display=display.none)
//CPR_Background = input.bool(true)
//fill(bc, tc, title = "CPR Background", color=CPR_Background ? color.new(#f21515,
70) : na, transp=10)

label_TC = cprplot ? label.new(bar_index, TC, text=show_labels ? ("


TC" + "•" + str.tostring(Round_it(TC))) : "cpr_tf", style= label.style_none,
textcolor=color.red, size=size.small) : na
label.delete(label_TC[1])
label_cpr_pivot = cprplot ? label.new(bar_index, cpr_pivot, text=show_labels ? ("
CPR_PIVOT" + "•" + str.tostring(Round_it(cpr_pivot))) : "cpr_tf", style=
label.style_none, textcolor=color.blue, size=size.small) : na
label.delete(label_cpr_pivot[1])
label_BC = cprplot ? label.new(bar_index, BC, text=show_labels ? ("
BC" + "•" + str.tostring(Round_it(BC))) : "cpr_tf", style= label.style_none,
textcolor=color.green, size=size.small) : na
label.delete(label_BC[1])
///-------------PLOT MARKET STATUS BASED ON CPR
high_val = BC
low_val = TC
percentage_diff = math.abs((high_val - low_val) / low_val) * 100
NARROWCPR = percentage_diff < 0.25 ///HIGHER CHANCES OF TRENDING MARKET
PNARROWCPR = percentage_diff < 0.5 and percentage_diff > 0.25 // POSSIBLE TRENDING
MARKET
PWIDECPR = percentage_diff < 0.75 and percentage_diff > 0.5 // POSSIBLE SIDEWAYS
MARKET
WIDECPR = percentage_diff > 0.75 // HIGHER CHANCES OF SIDEWAYS MARKET

NCPR=cprplot ? label.new(barstate.islast ? bar_index -1 :na, y=cpr_pivot,


text="NARROWCPR", color=color.white, textcolor=NARROWCPR? color.green : na,
style=label.style_label_right, size=size.normal) : na
//style=label.style_label_right
label.delete(NCPR[1])
PNCPR=cprplot ? label.new(barstate.islast ? bar_index -1 :na, y=cpr_pivot,
text="PNARROWCPR", color=color.white, textcolor=PNARROWCPR? color.green : na,
style=label.style_label_right, size=size.normal) : na
//style=label.style_label_right
label.delete(PNCPR[1])
PWCPR=cprplot ? label.new(barstate.islast ? bar_index -1 :na, y=cpr_pivot,
text="PWIDECPR", color=color.white, textcolor=PWIDECPR? color.red : na,
style=label.style_label_right, size=size.normal) : na
//style=label.style_label_right
label.delete(PWCPR[1])
WCPR=cprplot ? label.new(barstate.islast ? bar_index -1 :na, y=cpr_pivot,
text="WIDECPR", color=color.white, textcolor=WIDECPR? color.red : na,
style=label.style_label_right, size=size.normal) : na
//style=label.style_label_right
label.delete(WCPR[1])

////////////////////////////////SWING
showswing = input.bool(title='SWING ON', defval=true, inline='showswing',
group='SWING ॐ')
prd = input.int(defval=10, title='Period', inline='Swing', group='SWING ॐ')
ColorSelector(c_) =>
c_ == 'aqua' ? color.aqua : c_ == 'black' ? color.black : c_ == 'blue' ?
color.blue : c_ == 'fuchsia' ? color.fuchsia : c_ == 'gray' ? color.gray : c_ ==
'green' ? color.green : c_ == 'lime' ? color.lime : c_ == 'maroon' ? color.maroon :
c_ == 'navy' ? color.navy : c_ == 'olive' ? color.olive : c_ == 'orange' ?
color.orange : c_ == 'purple' ? color.purple : c_ == 'red' ? color.red : c_ ==
'silver' ? color.silver : c_ == 'teal' ? color.teal : c_ == 'white' ? color.white :
c_ == 'yellow' ? color.yellow : color.black

Hi_color = input.string(title='HH', defval='navy', options=['aqua', 'black',


'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange',
'purple', 'red', 'silver', 'teal', 'white', 'yellow'],inline='Swing',group='SWING
ॐ')
Lo_color = input.string(title='LL', defval='navy', options=['aqua', 'black',
'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange',
'purple', 'red', 'silver', 'teal', 'white', 'yellow'],inline='Swing',group='SWING
ॐ')

hih = ta.pivothigh(high, prd, prd)


lol = ta.pivotlow(low, prd, prd)

top = ta.valuewhen(hih, high[prd], 0)


bot = ta.valuewhen(lol, low[prd], 0)

plot(showswing ? top : na, color=top != top[1] ? na : ColorSelector(Hi_color),


offset=-prd, editable=false, linewidth=3,trackprice=true)
plot(showswing ? bot : na, color=bot != bot[1] ? na : ColorSelector(Lo_color),
offset=-prd, editable=false, linewidth=3,trackprice=true)

swingtop = showswing and show_labels ? label.new(bar_index +15, top,


text=show_labels ? ("TOP SWING" + "•" + str.tostring(top)) : "top", style=
label.style_label_left, color=color.new(#3106f2, 40), textcolor=color.white ,
size=size.normal, textalign=text.align_right) : na //style= label.style_none
label.delete(swingtop[1])
swingbottom = showswing and show_labels ? label.new(bar_index +15, bot,
text=show_labels ? ("BOTTOM SWING" + "•" + str.tostring(bot)) : "bot", style=
label.style_label_left, color=color.new(#3106f2, 40), textcolor=color.white ,
size=size.normal, textalign=text.align_right) : na //style= label.style_none
label.delete(swingbottom[1])

//======================ATR Trailing SL
ATRTsl = input.bool(title='ATRTsl ON', defval=true, inline='atr', group='ATR
Trailing SL ॐ')
nATRPeriod = input.int(5, 'Period', inline='atr', group='ATR Trailing SL ॐ')
nATRMultip = input.float(2, 'Multi', inline='atr', group='ATR Trailing SL ॐ')
xATR = ta.atr(nATRPeriod)
nLoss = nATRMultip * xATR
xATRTrailingStop = 0.0
iff_1 = close > nz(xATRTrailingStop[1], 0) ? close - nLoss : close + nLoss
iff_2 = close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1],
0) ? math.min(nz(xATRTrailingStop[1]), close + nLoss) : iff_1
xATRTrailingStop := close > nz(xATRTrailingStop[1], 0) and close[1] >
nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), close - nLoss) :
iff_2
col = close < xATRTrailingStop[1] ? #f90808 : #0af71b
plot(ATRTsl ? xATRTrailingStop[1] : na, color=col, title='ATR Trailing Stop')

///////VWAP & PREVIOUS DAY VWAP


isNewSession = ta.change(time("D")) ? 1 : 0
getVWAP(ns) =>
var float p = na
var float vol = na
var float v = na
var float Sn = na
var float std = na

p := ns ? hlc3 * volume : p[1] + hlc3 * volume


vol := ns ? volume : vol[1] + volume
v := p / vol
Sn := ns ? 0 : Sn[1] + volume * (hlc3 - v[1]) * (hlc3 - v)
std := math.sqrt(Sn / vol)

[v, std]

[vD, stdevD] = getVWAP(isNewSession)

vwap_pwap_labels = input.bool(title="VWAP & PWAP ON", defval=false,


group='VWAP_PVWAP ॐ')
vDplot = plot(vwap_pwap_labels? vD : na, title = "Today's VWAP", color=#c229ff,
linewidth=3)
//VWAP = label.new(x=time + mndr * 20, y=vD, text='VWAP •' +
str.tostring(Round_it(vD)), color=color.new(#000000, 100), textcolor=#c229ff,
size=size.normal, style=label.style_label_left, xloc=xloc.bar_time,
yloc=yloc.price)
VWAP = vwap_pwap_labels and show_labels ? label.new(bar_index, vD, text=show_labels
? (" VWAP" + "•" + str.tostring(Round_it(vD))) :
"vwap", style= label.style_none, textcolor=color.fuchsia, size=size.normal) : na
label.delete(VWAP[1])
previousVWAP = ta.valuewhen(isNewSession, vD[1], 0)
pvDplot = plot(vwap_pwap_labels? previousVWAP : na, title = "Previous day VWAP",
color=#aa1cf7, linewidth=3,trackprice=true)
label_previousVWAP = vwap_pwap_labels and show_labels ? label.new(bar_index,
previousVWAP, text=show_labels ? (" PVWAP" + "•" +
str.tostring(Round_it(previousVWAP))) : "pvwap", style= label.style_none,
textcolor=color.fuchsia, size=size.normal) : na
label.delete(label_previousVWAP[1])

//=============================EMA OM POINT
emaplot = input.bool(title='EMA ON', defval=false, inline='emaplot', group='EMA
ॐ')
EMA5 = input.int(5, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA8 = input.int(8, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA9 = input.int(9, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA13 = input.int(13, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA20 = input.int(20, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA50 = input.int(50, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA100 = input.int(100, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA200 = input.int(200, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')

plot(emaplot ? ta.ema(close, EMA5) : na, title='5 EMA',


color=color.new(color.yellow, 0), linewidth=1, display=display.none)
plot(emaplot ? ta.ema(close, EMA8) : na, title='8 EMA',
color=color.new(color.orange, 0), linewidth=1,display=display.none)
plot(emaplot ? ta.ema(close, EMA9) : na, title='9 EMA',
color=color.new(color.rgb(51, 8, 238), 0), linewidth=1)
plot(emaplot ? ta.ema(close, EMA13) : na, title='13 EMA',
color=color.new(color.olive, 0), linewidth=2, display=display.none)
//plot(emaplot ? ta.ema(close, EMA20) : na, title='20 EMA',
color=color.new(color.rgb(51, 8, 238), 0), linewidth=1)
plot(emaplot ? ta.ema(close, EMA20) : na, title='20
EMA',color=color.new(color.orange, 0), linewidth=1)
plot(emaplot ? ta.ema(close, EMA50) : na, title='50 EMA',
color=color.new(color.black, 0), linewidth=2)
plot(emaplot ? ta.ema(close, EMA100) : na, title='100 EMA',
color=color.new(color.gray, 0), linewidth=2, display=display.none)
plot(emaplot ? ta.ema(close, EMA200) : na, title='200 EMA',
color=color.new(color.maroon, 0), linewidth=4)

ema13channelplot = input.bool(false, title='ema13channelfill on ', tooltip='Turns


On 3 5a\'s On Chart, Levels can be Edited')
EMA13_H = plot(ema13channelplot ? ta.ema(high, EMA13) : na, title='13
EMA',color=color.new(color.orange, 90), linewidth=1)
EMA13_L = plot(ema13channelplot ? ta.ema(low, EMA13) : na, title='13
EMA',color=color.new(color.orange, 90), linewidth=1)
fill(EMA13_H, EMA13_L, title='ema13channelfill on', color= close > ta.ema(high,
EMA13) ? color.new(color.lime,40) : close < ta.ema(low, EMA13) ? color.new(#f04343,
40) : color.new(color.gray,0) )

ema20channelplot = input.bool(false, title='ema20channelfill on ', tooltip='Turns


On 3 5a\'s On Chart, Levels can be Edited')
EMA20_H = plot(ema20channelplot ? ta.ema(high, EMA20) : na, title='20
EMA',color=color.new(color.orange, 90), linewidth=1)
EMA20_L = plot(ema20channelplot ? ta.ema(low, EMA20) : na, title='20
EMA',color=color.new(color.orange, 90), linewidth=1)
fill(EMA20_H, EMA20_L, title='ema20channelfill', color= close > ta.ema(high, EMA20)
? color.new(color.lime,40) : close < ta.ema(low, EMA20) ? color.new(#f04343, 40) :
color.new(color.gray,0) )

//===========================Ompoint======================
ema5 =ta.ema(close, EMA5)
ema8 = ta.ema(close, EMA8)
ema9 = ta.ema(close, EMA9)
ema13 = ta.ema(close, EMA13)
ema20 = ta.ema(close, EMA20)
ema50 = ta.ema(close, EMA50)
ema100 = ta.ema(close, EMA100)
ema200 = ta.ema(close, EMA200)

//EMA1_C = plot(ema9, title = "EMA1", color=color.new(color.rgb(51, 8, 238), 0))


//EMA2_C = plot(ema20, title = "EMA2", color=color.new(color.orange, 0))
//fill(EMA1_C, EMA2_C, color= ema9 > ema20 ? color.new(color.green,40) : ema9 <
ema20 ? color.new(color.red,40) : color.new(color.gray,0) , title ="colorfill
ema1320 cross")

// Label the value of the EMA at the last bar


E9 = emaplot ? label.new(bar_index, ema9, text=show_labels ? ("
EMA9" + "•" + str.tostring(Round_it(ema9))) : "EMA9", style= label.style_none,
textcolor=color.new(color.rgb(51, 8, 238), 0), size=size.normal) : na
label.delete(E9[1])
E20 = emaplot ? label.new(bar_index, ema20, text=show_labels ? ("
EMA20" + "•" + str.tostring(Round_it(ema20))) : "EMA20", style= label.style_none,
textcolor=color.new(color.orange, 0), size=size.normal) : na
label.delete(E20[1])
E50 = emaplot ? label.new(bar_index, ema50, text=show_labels ? ("
EMA50" + "•" + str.tostring(Round_it(ema50))) : "EMA50", style= label.style_none,
textcolor=color.new(color.black, 0), size=size.normal) : na
label.delete(E50[1])
E200 = emaplot ? label.new(bar_index, ema200, text=show_labels ? ("
EMA200" + "•" + str.tostring(Round_it(ema200))) : "EMA200", style=
label.style_none, textcolor=color.new(color.maroon, 0), size=size.normal) : na
label.delete(E200[1])
//E200 = label.new(x=time + mndr * 20, y=ema200, text='EMA200 •' +
str.tostring(Round_it(ema200)), color=color.new(#000000, 100),
textcolor=color.new(color.maroon, 0), size=size.normal,
style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
//label.delete(E200[1])

//longCondcross = bool(na)
//shortCondcross = bool(na)
//longCondcross := ema5 > ema8 and ema8 > ema13 and ema13 > ema20 and ema20 > ema50
and ema50 > ema100
//shortCondcross := ema5 < ema8 and ema8 < ema13 and ema13 < ema20 and ema20 <
ema50 and ema50 < ema100

//CondIniema = 0
//CondIniema := longCondcross ? 1 : shortCondcross ? -1 : CondIniema[1]
//longCondcrossition = longCondcross and CondIniema[1] == -1
//shortCondcrossition = shortCondcross and CondIniema[1] == 1

/////plotshape(longCondcrossition, title="OM long", text="OM\nPOINT\nBUY",


textcolor=color.green, style=shape.arrowup, location=location.belowbar,
color=color.green, transp=0, size=size.small)
////plotshape(shortCondcrossition, title="OM short", text="OM\nPOINT\nSELL",
textcolor=color.red, style=shape.arrowdown, location=location.abovebar,
color=color.red, transp=0, size=size.small)

//alertcondition(longCondcrossition, title='OmPointBuy', message='OmPointBuy')


//alertcondition(shortCondcrossition, title='OmPointSell', message='OmPointSell')
//changegrah = longCondcrossition != shortCondcrossition
//alertcondition(changegrah, title="OmPoint Direction Change", message="OmPoint has
changed direction!")
//50EMA VS 20EMA
Crossover==========================================================================
=======================================
i2050 = input.bool(true, title="20ema vs 50ema Crossover")
cross2050 = ta.cross(ema20, ema50) and i2050 ? ema50 : na
plotchar(cross2050, title='20vs50ema Cross Char', text='20vs50\nCross',
textcolor=color.black, location=location.absolute, size=size.small, color=ema20 >
ema50 ? #0af71b : #f90808)

////////////HULLMA13
hull_ma = input.bool(title='HMA13 ON', defval=false, inline='hull_ma',
group='HULLMA13 ॐ')
useCurrentRes = input(true, title="Use Current Chart Resolution?")
smoothe = input.int(1, minval=1, maxval=10, title="Extra Smooth [1 = None]")
res = useCurrentRes ? timeframe.period : "0"
HMA_L = input.int(title="HMA", defval= 13, minval=1, maxval=300, step =1)
//HMA = ta.hma(close, HMA_L)
HMA = ta.wma(2 * ta.wma(close, HMA_L / 2) - ta.wma(close, HMA_L),
math.round(math.sqrt(HMA_L)))

out1 = request.security(syminfo.tickerid, res, HMA)


ma_up = out1 >= out1[smoothe]
ma_down = out1 < out1[smoothe]
colorfilter = ma_up ? #0af71b : ma_down ? #f90808 : color.aqua
plot(hull_ma ? out1 : na, style=plot.style_line, linewidth=2, color=colorfilter)

//bool maRising = ta.rising(out1, 1)


//plot(hull_ma ? out1 : na, "HMA", colorfilter, 4)

////////////HULLMA TREND
hma_trend = input.bool(true, 'HMA TREND ON', inline='hma_trend', group='HMA_TREND
ॐ')
HMA18_L = input.int(18, 'HMA 18', inline='HMA 18', group='HMA_TREND ॐ')
HMA21_L = input.int(21, 'HMA 21', inline='HMA 21', group='HMA_TREND ॐ')

hma18 = ta.wma(2 * ta.wma(close, HMA18_L / 2) - ta.wma(close, HMA18_L),


math.round(math.sqrt(HMA18_L)))
hma21 = ta.wma(2 * ta.wma(close, HMA21_L / 2) - ta.wma(close, HMA21_L),
math.round(math.sqrt(HMA21_L)))
HMA18_C = plot(hma_trend ? hma18 : na, color=color.new(color.white, 100))
HMA21_C = plot(hma_trend ? hma21 : na, color=color.new(color.white, 100))
fill(HMA18_C, HMA21_C, color= hma18 > hma21 ? color.new(color.lime,40) : hma18 <
hma21 ? color.new(#f04343,40) : na , title ="colorfill Hma18_21 cross")

/////////////////////CANDLES-PRICE Action
Doji = input.float(0.05, minval=0.01, title='Doji size', step=0.01)
data = math.abs(open - close) <= (high - low) * Doji
plotshape(data, title='Doji', style=shape.diamond, text='Doji', color= color.black,
size=size.tiny)
///////(open == low) AND (open == high)
open_low = (open == low) //and (close > open)
//plotshape(open_low, title= "open_low", location=location.belowbar,
color=color.orange, style=shape.triangleup, size=size.tiny, textcolor=color.green,
text="O=L")
open_high = (open == high)// and (close < open)
//plotshape(open_high, title= "open_high", location=location.abovebar,
color=color.orange, style=shape.triangledown, size=size.tiny, textcolor=color.red,
text="O=H")

//////////////////////RSI VS BB CROSS OVER SIGNALS


rsibb_plot = input.bool(title='RSI CROSS BB SIGNAL ON', defval=true,
inline='rsibb_plot', group='RSI_BB ॐ')
src_rsi = input(close, 'source')
length_rsi = input(title='RSI Length', defval=5)
mult = input(title='Multiplier of Length Bars in Percent', defval=100)

current_rsi = ta.rsi(src_rsi, length_rsi)


previous_rsi = ta.rsi(src_rsi[1], length_rsi)

basis = ta.ema(current_rsi, 15)


dev = 1 * ta.stdev(current_rsi, 15)
upper = basis + dev
lower = basis - dev

rsi_above_upper = current_rsi > upper and current_rsi > 50 and current_rsi >
current_rsi[1] and upper > upper[1] and upper > 50// and open_low
rsi_below_lower = current_rsi < lower and current_rsi < 50 and current_rsi <
current_rsi[1] and lower < lower[1] and lower < 50// and open_high

plotshape(rsibb_plot ? rsi_above_upper : na, series=rsi_above_upper,


style=shape.triangleup, location=location.belowbar, color=#0af71b ,
size=size.tiny)//, textcolor=#0af71b, text="RSI\nBB")
plotshape(rsibb_plot ? rsi_below_lower : na,series=rsi_below_lower,
style=shape.triangledown, location=location.abovebar, color=#f90808,
size=size.tiny)//, textcolor=#f90808, text="RSI\nBB")

//BAR COLORS RSI above upper BB and RSI below lower BB


color_bar = rsi_above_upper ? #00c3ff : rsi_below_lower ? color.maroon : na
barcolor(rsibb_plot ? color_bar : na)

//////diplus, diminus, adx SIGNALS //workin progress///


[diplus, diminus, adxValue] = ta.dmi(8, 8) ////default value 14
//adxMom = adxValue > adxValue[1] and adxValue[1] > adxValue[2] ? ' : RISING\n-
' : ' : FALLING\n- '
//diplusMom = diplus > diplus[1] and diplus[1] > diplus[2] ? ' & DIplus : RISING\
n- ' : ' & DIplus : FALLING\n- '
//diminusMom = diminus > diminus[1] and diminus[1] > diminus[2] ? ' & DIminus :
RISING\n- ' : ' & DIminus : FALLING\n- '

//diadxStat = diplus > adxValue and diplus >= 20 and adxValue >= 20? 'DIplus(' +
str.tostring(math.round(diplus)) + ') > ADX(' + str.tostring(math.round(adxValue))
+ ')' : na ////'DIminus(' + str.tostring(math.round(diminus)) + ') > ADXvalue(' +
str.tostring(math.round(adxValue)) + ')'
//dmiadxStat = diminus > adxValue and diminus >= 20 and adxValue >= 20 ?
'DIminus(' + str.tostring(math.round(diminus)) + ') > ADX(' +
str.tostring(math.round(adxValue)) + ')' : na
//per_diff_diplus_adx = diplus > adxValue and diplus >= 20 and adxValue >= 20 ?
'Diff.Increasing(DIplus & ADX) %' + str.tostring(math.abs((adxValue - diplus) /
diplus) * 100, '#.##') + '' : na
//per_diff_diminus_adx = diminus > adxValue and diminus >= 20 and adxValue >= 20 ?
'Diff.Increasing(DIminus & ADX) %' + str.tostring(math.abs((adxValue - diminus) /
diminus) * 100, '#.##') + '' : na
//percentage_difference = '\n\- Diff.(DIplus & DIminus) %' +
str.tostring(math.abs((diplus - diminus) / diminus) * 100, '#.##') + ''

diplus_above_diminus = diplus > diminus and diplus > adxValue and diplus >= 20 and
adxValue >= 20 and diplus > diplus[1] and diplus[1] > diplus[2] and adxValue >
adxValue[1] //and adxValue[1] > adxValue[2]
diminus_above_diplus = diminus > diplus and diminus > adxValue and diminus >= 20
and adxValue >= 20 and diminus > diminus[1] and diminus[1] > diminus[2] and
adxValue > adxValue[1] //and adxValue[1] > adxValue[2]

plotshape(rsibb_plot ? diplus_above_diminus : na, series=diplus_above_diminus,


style=shape.arrowup, location=location.belowbar, color=color.orange ,
size=size.small, textcolor=color.orange, text="RDX")
plotshape(rsibb_plot ? diminus_above_diplus : na, series=diminus_above_diplus,
style=shape.arrowdown, location=location.abovebar, color=color.orange,
size=size.small, textcolor=color.orange, text="RDX")

//barcolor(rsibb_plot and rsi_above_upper and diplus_above_diminus ? #0af71b : na,


title = "rsi_above_upper")
//barcolor(rsibb_plot and rsi_below_lower and diminus_above_diplus ? #fd0606 : na,
title = "rsi_below_lower")

////////////////////////////ALERTS
//diplus_rising = diplus > diplus[1] and diplus >= 20
//diminus_rising = diminus > diminus[1] and diminus >= 20
//adx_rising = adxValue > adxValue[1] and adxValue >= 20

CondInirsibb = 0
CondInirsibb := rsi_above_upper and diplus >= 20 ? 1 : rsi_below_lower and diminus
>= 20 ? -1 : CondInirsibb[1]
RSI_BB_UPCROSS = rsi_above_upper and diplus >= 20 and CondInirsibb[1] == -1
RSI_BB_DNCROSS = rsi_below_lower and diminus >= 20 and CondInirsibb[1] == 1

/////plotshape(RSI_BB_UPCROSS, title="OM long", text="OM\nPOINT\nBUY",


textcolor=color.green, style=shape.arrowup, location=location.belowbar,
color=color.green, transp=0, size=size.small)
////plotshape(RSI_BB_DNCROSS, title="OM short", text="OM\nPOINT\nSELL",
textcolor=color.red, style=shape.arrowdown, location=location.abovebar,
color=color.red, transp=0, size=size.small)

// Send out an alert if this candle meets our conditions


//alertcondition(RSI_BB_UPCROSS, title='OmPointBuy', message='OmPointBuy')
//alertcondition(RSI_BB_DNCROSS, title='OmPointSell', message='OmPointSell')
RSI_BB_CROSSOVER = RSI_BB_UPCROSS != RSI_BB_DNCROSS
alertcondition(RSI_BB_CROSSOVER, title="RSI_BB_CROSSOVER",
message="RSI_BB_CROSSOVER Alert! {{ticker}} at {{time}}" )
//if RSI_BB_CROSSOVER
// alert("RSI_BB_CROSSOVER at {{time}}:", freq = alert.freq_once_per_bar_close )

//===========================================
EEMA_plot = input.bool(title='EEMA ON', defval=false, inline='EEMA_plot',
group='EEMA ON ॐ')
srcHA=ohlc4
EEMAlength = input(65, "EEMA LENGTH")

var float haOpen = na


haOpen := na(haOpen[1]) ? (srcHA + srcHA[1]) / 2 : (haOpen[1] + srcHA[1]) / 2

haC = (ohlc4 + haOpen + math.max(high, haOpen) + math.min(low, haOpen)) / 4


EEMA1 = ta.ema(haC, EEMAlength)
EEMA2 = ta.ema(EEMA1, EEMAlength)
EEMA3 = ta.ema(EEMA2, EEMAlength)

TMA1 = 3 * EEMA1 - 3 * EEMA2 + EEMA3


EEMA4 = ta.ema(TMA1, EEMAlength)
EEMA5 = ta.ema(EEMA4, EEMAlength)
EEMA6 = ta.ema(EEMA5, EEMAlength)
TMA2 = 3 * EEMA4 - 3 * EEMA5 + EEMA6
IPEK = TMA1 - TMA2
YASIN = TMA1 + IPEK

EEMA7 = ta.ema(hlc3, EEMAlength)


EEMA8 = ta.ema(EEMA7, EEMAlength)
EEMA9 = ta.ema(EEMA8, EEMAlength)
TMA3 = 3 * EEMA7 - 3 * EEMA8 + EEMA9
EEMA10 = ta.ema(TMA3, EEMAlength)
EEMA11 = ta.ema(EEMA10, EEMAlength)
EEMA12 = ta.ema(EEMA11, EEMAlength)
TMA4 = 3 * EEMA10 - 3 * EEMA11 + EEMA12
IPEK1 = TMA3 - TMA4
YASIN1 = TMA3 + IPEK1

plot(EEMA_plot? YASIN : na, color = color.red, linewidth = 2)


plot(EEMA_plot? YASIN1 : na, color = color.blue, linewidth = 2)

//======ALL HIGH WEIGHTAGE STOCKS


SCREENER=======================================================
screen() =>
cci8 = ta.cci(close, 8)
rsi5 = ta.rsi(close, 5)
rsi9 = ta.rsi(close, 9)
rsi14 = ta.rsi(close, 14)
hma5 = ta.hma(close, 5)
hma8 = ta.hma(close, 8)
hma13 = ta.hma(close, 13)
hma21 = ta.hma(close, 21)
//hma50 = ta.hma(close, 50)
//hma100 = ta.hma(close, 100)
//hma200 = ta.hma(close, 200)
//-----BB
//basis = ta.sma(close, 15)
//dev = 1 * ta.stdev(close, 15)
basis = ta.ema(rsi5, 15)
dev = 1 * ta.stdev(rsi5, 15)
upper = basis + dev
lower = basis - dev

//bc = close > upper


bc = rsi5 > upper and rsi5 > 62 and rsi5 > rsi5[1] and upper > upper[1] and
upper > 50
bc1 = rsi5 > 60 and rsi9 > 55 and rsi14 > 50
bc2 = hma5 > hma8 and hma8 > hma13 and hma13 > hma21 //and hma21 > hma50
bc3 = cci8 > 0
bc4 = close > open and close[1] > open[1]
bc5 = high[1] > high[2] and high[2] > high[3] and low[1] > low[2] and low[2] >
low[3]

bull = bc and bc2 and bc3 and bc4 //and bc1 //

//sc = close < lower


sc = rsi5 < lower and rsi5 < 38 and rsi5 < rsi5[1] and lower < lower[1] and
lower < 50
sc1 = rsi5 < 40 and rsi9 < 45 and rsi14 < 50
sc2 = hma5 < hma8 and hma8 < hma13 and hma13 < hma21 //and hma21 < hma50
sc3 = cci8 < 0
sc4 = close < open and close[1] < open[1]
sc5 = high[1] < high[2] and high[2] < high[3] and low[1] < low[2] and low[2] <
low[3]

bear = sc and sc2 and sc3 and sc4 //and sc1 //


[bull, bear]
//========================================================================
tf = timeframe.period
ss1 = input.symbol('NSE:NIFTY1!','Symbol 1', inline = '1', group = 'STOCK LIST')
ss2 = input.symbol('NSE:BANKNIFTY1!','Symbol 2', inline = '1', group = 'STOCK
LIST')
ss3 = input.symbol('NSE:HDFCBANK','Symbol 3', inline = '1', group = 'STOCK LIST')
ss4 = input.symbol('NSE:ICICIBANK','Symbol 4', inline = '1', group = 'STOCK LIST')
ss5 = input.symbol('NSE:KOTAKBANK','Symbol 5', inline = '1', group = 'STOCK LIST')
ss6 = input.symbol('NSE:AXISBANK','Symbol 6', inline = '1', group = 'STOCK LIST')
ss7 = input.symbol('BSE:SENSEX','Symbol 7', inline = '1', group = 'STOCK LIST')
ss8 = input.symbol('NSE:SBIN','Symbol 8', inline = '1', group = 'STOCK LIST')
ss9 = input.symbol('NSE:RELIANCE','Symbol 9', inline = '1', group = 'STOCK LIST')
ss10 = input.symbol('NSE:INFY','Symbol 10', inline = '1', group = 'STOCK LIST')
ss11 = input.symbol('NSE:TCS','Symbol 11', inline = '1', group = 'STOCK LIST')
ss12 = input.symbol('NSE:BAJFINANCE','Symbol 12', inline = '1', group = 'STOCK
LIST')
ss13 = input.symbol('NSE:BAJAJFINSV','Symbol 13', inline = '1', group = 'STOCK
LIST')
ss14 = input.symbol('MCX:CRUDEOIL1!','Symbol 14', inline = '1', group = 'STOCK
LIST')
ss15 = input.symbol('NSE:FINNIFTY1!','Symbol 15', inline = '1', group = 'STOCK
LIST')
ss16 = input.symbol('NSE:NIFTY','Symbol 16', inline = '1', group = 'STOCK LIST')
ss17 = input.symbol('TVC:USOIL','Symbol 17', inline = '1', group = 'STOCK LIST')

[c1,v1] = request.security(ss1,tf,screen())
[c2,v2] = request.security(ss2,tf,screen())
[c3,v3] = request.security(ss3,tf,screen())
[c4,v4] = request.security(ss4,tf,screen())
[c5,v5] = request.security(ss5,tf,screen())
[c6,v6] = request.security(ss6,tf,screen())
[c7,v7] = request.security(ss7,tf,screen())
[c8,v8] = request.security(ss8,tf,screen())
[c9,v9] = request.security(ss9,tf,screen())
[c10,v10] = request.security(ss10,tf,screen())
[c11,v11] = request.security(ss11,tf,screen())
[c12,v12] = request.security(ss12,tf,screen())
[c13,v13] = request.security(ss13,tf,screen())
[c14,v14] = request.security(ss14,tf,screen())
[c15,v15] = request.security(ss15,tf,screen())
[c16,v16] = request.security(ss16,tf,screen())
[c17,v17] = request.security(ss17,tf,screen())
//========================================================================

buy_label = ' =====BUY======\n'


buy_label := c1 ? buy_label + str.tostring(ss1) + '\n' : buy_label
buy_label := c2 ? buy_label + str.tostring(ss2) + '\n' : buy_label
buy_label := c3 ? buy_label + str.tostring(ss3) + '\n' : buy_label
buy_label := c4 ? buy_label + str.tostring(ss4) + '\n' : buy_label
buy_label := c5 ? buy_label + str.tostring(ss5) + '\n' : buy_label
buy_label := c6 ? buy_label + str.tostring(ss6) + '\n' : buy_label
buy_label := c7 ? buy_label + str.tostring(ss7) + '\n' : buy_label
buy_label := c8 ? buy_label + str.tostring(ss8) + '\n' : buy_label
buy_label := c9 ? buy_label + str.tostring(ss9) + '\n' : buy_label
buy_label := c10 ? buy_label + str.tostring(ss10) + '\n' : buy_label
buy_label := c11 ? buy_label + str.tostring(ss11) + '\n' : buy_label
buy_label := c12 ? buy_label + str.tostring(ss12) + '\n' : buy_label
buy_label := c13 ? buy_label + str.tostring(ss13) + '\n' : buy_label
buy_label := c14 ? buy_label + str.tostring(ss14) + '\n' : buy_label
buy_label := c15 ? buy_label + str.tostring(ss15) + '\n' : buy_label
buy_label := c16 ? buy_label + str.tostring(ss16) + '\n' : buy_label
buy_label := c17 ? buy_label + str.tostring(ss17) + '\n' : buy_label

lab_buy = label.new(bar_index+30, close, buy_label, color=color.new(color.lime,70),


textcolor=color.green, style=label.style_label_up,
yloc=yloc.price,textalign=text.align_left)
label.delete(lab_buy[1])

sell_label = ' =====SELL======\n'


sell_label := v1 ? sell_label + str.tostring(ss1) + '\n' : sell_label
sell_label := v2 ? sell_label + str.tostring(ss2) + '\n' : sell_label
sell_label := v3 ? sell_label + str.tostring(ss3) + '\n' : sell_label
sell_label := v4 ? sell_label + str.tostring(ss4) + '\n' : sell_label
sell_label := v5 ? sell_label + str.tostring(ss5) + '\n' : sell_label
sell_label := v6 ? sell_label + str.tostring(ss6) + '\n' : sell_label
sell_label := v7 ? sell_label + str.tostring(ss7) + '\n' : sell_label
sell_label := v8 ? sell_label + str.tostring(ss8) + '\n' : sell_label
sell_label := v9 ? sell_label + str.tostring(ss9) + '\n' : sell_label
sell_label := v10 ? sell_label + str.tostring(ss10) + '\n' : sell_label
sell_label := v11 ? sell_label + str.tostring(ss11) + '\n' : sell_label
sell_label := v12 ? sell_label + str.tostring(ss12) + '\n' : sell_label
sell_label := v13 ? sell_label + str.tostring(ss13) + '\n' : sell_label
sell_label := v14 ? sell_label + str.tostring(ss14) + '\n' : sell_label
sell_label := v15 ? sell_label + str.tostring(ss15) + '\n' : sell_label
sell_label := v16 ? sell_label + str.tostring(ss16) + '\n' : sell_label
sell_label := v17 ? sell_label + str.tostring(ss17) + '\n' : sell_label

lab_sell = label.new(bar_index+30, close, sell_label,


color=color.new(color.red,70), textcolor=color.red, style=label.style_label_down,
yloc=yloc.price,textalign=text.align_left)
label.delete(lab_sell[1])

///////////DEMAND & SUPPLY LEVELS INDICATOR SETTINGS


swing_length = input.int(10, title = 'Swing High/Low Length', group = 'DEMAND &
SUPPLY Settings', minval = 1, maxval = 50)
history_of_demand_to_keep = input.int(20, title = 'History To Keep', minval = 5,
maxval = 50, group = 'DEMAND & SUPPLY Settings')
box_width = input.float(2.5, title = 'Supply/Demand Box Width', group = 'DEMAND &
SUPPLY Settings', minval = 1, maxval = 10, step = 0.5)

// INDICATOR VISUAL SETTINGS


show_zigzag = input.bool(false, title = 'Show Zig Zag', group = 'DEMAND & SUPPLY
Settings', inline = '1')
show_price_action_labels = input.bool(true, title = 'Show Price Action Labels',
group = 'DEMAND & SUPPLY Settings', inline = '2')

supply_color = input.color(color.new(#ea4250, 1), title = 'Supply', group = 'DEMAND


& SUPPLY Settings', inline = '3')
supply_outline_color = input.color(color.new(#ea4250, 1), title = 'Outline', group
= 'DEMAND & SUPPLY Settings', inline = '3')

demand_color = input.color(color.new(#399d3e, 1), title = 'Demand', group = 'DEMAND


& SUPPLY Settings', inline = '4')
demand_outline_color = input.color(color.new(#399d3e, 1), title = 'Outline', group
= 'DEMAND & SUPPLY Settings', inline = '4')

bos_label_color = input.color(color.blue, title = 'BOS Label', group = 'DEMAND &


SUPPLY Settings', inline = '5')
poi_label_color = input.color(color.blue, title = 'POI Label', group = 'DEMAND &
SUPPLY Settings', inline = '7')

swing_type_color_red = input.color(color.red, title = 'Price Action Label', group =


'DEMAND & SUPPLY Settings', inline = '8')
swing_type_color_green = input.color(color.green, title = 'Price Action Label',
group = 'DEMAND & SUPPLY Settings', inline = '8')
zigzag_color = input.color(color.blue, title = 'Zig Zag', group = 'DEMAND & SUPPLY
Settings', inline = '9')
//END SETTINGS
//FUNCTIONS
// FUNCTION TO ADD NEW AND REMOVE LAST IN ARRAY
f_array_add_pop(array, new_value_to_add) =>
array.unshift(array, new_value_to_add)
array.pop(array)

// FUNCTION SWING H & L LABELS


f_sh_sl_labels(array, swing_type) =>

var string label_text = na


if swing_type == 1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HH'
else
label_text := 'LH'
label.new(bar_index - swing_length, array.get(array,0), text = label_text,
style=label.style_label_down, textcolor = swing_type_color_red, color =
color.new(swing_type_color_red, 100), size = size.normal)

else if swing_type == -1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array,0), text = label_text,
style=label.style_label_up, textcolor = swing_type_color_green, color =
color.new(swing_type_color_green, 100), size = size.normal)
// FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING
f_check_overlapping(new_poi, box_array, atr) =>

atr_threshold = atr * 2
okay_to_draw = true

for i = 0 to array.size(box_array) - 1
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2

upper_boundary = poi + atr_threshold


lower_boundary = poi - atr_threshold

if new_poi >= lower_boundary and new_poi <= upper_boundary


okay_to_draw := false
break
else
okay_to_draw := true
okay_to_draw

// FUNCTION TO DRAW SUPPLY OR DEMAND ZONE


f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atr) =>

atr_buffer = atr * (box_width / 10)


box_left = array.get(bn_array, 0)
box_right = bar_index

var float box_top = 0.00


var float box_bottom = 0.00
var float poi = 0.00

if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2

okay_to_draw = f_check_overlapping(poi, box_array, atr)


// okay_to_draw = true
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw
box.delete( array.get(box_array, array.size(box_array) - 1) )
f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right =
box_right, bottom = box_bottom, border_color = supply_outline_color,
bgcolor = supply_color, extend = extend.right, text = 'SUPPLY',
text_halign = text.align_center, text_valign = text.align_center, text_color =
poi_label_color, text_size = size.small, xloc = xloc.bar_index))

box.delete( array.get(label_array, array.size(label_array) - 1) )


f_array_add_pop(label_array, box.new( left = box_left, top = poi, right =
box_right, bottom = poi, border_color = color.new(poi_label_color,90),
bgcolor = color.new(poi_label_color,90), extend = extend.right, text =
'POI', text_halign = text.align_left, text_valign = text.align_center, text_color =
poi_label_color, text_size = size.small, xloc = xloc.bar_index))
else if box_type == -1 and okay_to_draw
box.delete( array.get(box_array, array.size(box_array) - 1) )
f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right =
box_right, bottom = box_bottom, border_color = demand_outline_color,
bgcolor = demand_color, extend = extend.right, text = 'DEMAND',
text_halign = text.align_center, text_valign = text.align_center, text_color =
poi_label_color, text_size = size.small, xloc = xloc.bar_index))

box.delete( array.get(label_array, array.size(label_array) - 1) )


f_array_add_pop(label_array, box.new( left = box_left, top = poi, right =
box_right, bottom = poi, border_color = color.new(poi_label_color,90),
bgcolor = color.new(poi_label_color,90), extend = extend.right, text
= 'POI', text_halign = text.align_left, text_valign = text.align_center, text_color
= poi_label_color, text_size = size.small, xloc = xloc.bar_index))

// FUNCTION TO CHANGE SUPPLY/DEMAND TO A BOS IF BROKEN


f_sd_to_bos(box_array, bos_array, label_array, zone_type) =>

if zone_type == 1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_top(array.get(box_array,i))
// if ta.crossover(close, level_to_break)
if close >= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))

if zone_type == -1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_bottom(array.get(box_array,i))
// if ta.crossunder(close, level_to_break)
if close <= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
// FUNCTION MANAGE CURRENT BOXES BY CHANGING ENDPOINT
f_extend_box_endpoint(box_array) =>

for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 100)

//END FUNCTIONS
//CALCULATIONS
// CALCULATE ATR
atr = ta.atr(50)

// CALCULATE SWING HIGHS & SWING LOWS


swing_high = ta.pivothigh(high, swing_length, swing_length)
swing_low = ta.pivotlow(low, swing_length, swing_length)

// ARRAYS FOR SWING H/L & BN


var swing_high_values = array.new_float(5,0.00)
var swing_low_values = array.new_float(5,0.00)

var swing_high_bns = array.new_int(5,0)


var swing_low_bns = array.new_int(5,0)

// ARRAYS FOR SUPPLY / DEMAND


var current_supply_box = array.new_box(history_of_demand_to_keep, na)
var current_demand_box = array.new_box(history_of_demand_to_keep, na)

// ARRAYS FOR SUPPLY / DEMAND POI LABELS


var current_supply_poi = array.new_box(history_of_demand_to_keep, na)
var current_demand_poi = array.new_box(history_of_demand_to_keep, na)

// ARRAYS FOR BOS


var supply_bos = array.new_box(5, na)
var demand_bos = array.new_box(5, na)
//
//END CALCULATIONS
//
// NEW SWING HIGH
if not na(swing_high)

//MANAGE SWING HIGH VALUES


f_array_add_pop(swing_high_values, swing_high)
f_array_add_pop(swing_high_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_high_values, 1)

f_supply_demand(swing_high_values, swing_high_bns, current_supply_box,


current_supply_poi, 1, atr)

// NEW SWING LOW


else if not na(swing_low)

//MANAGE SWING LOW VALUES


f_array_add_pop(swing_low_values, swing_low)
f_array_add_pop(swing_low_bns, bar_index[swing_length])
if show_price_action_labels
f_sh_sl_labels(swing_low_values, -1)
f_supply_demand(swing_low_values, swing_low_bns, current_demand_box,
current_demand_poi, -1, atr)

f_sd_to_bos(current_supply_box, supply_bos, current_supply_poi, 1)


f_sd_to_bos(current_demand_box, demand_bos, current_demand_poi, -1)

f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)

//ZIG ZAG
h = ta.highest(high, swing_length * 2 + 1)
l = ta.lowest(low, swing_length * 2 + 1)
f_isMin(len) =>
l == low[len]
f_isMax(len) =>
h == high[len]

var dirUp = false


var lastLow = high * 100
var lastHigh = 0.0
var timeLow = bar_index
var timeHigh = bar_index
var line li = na

f_drawLine() =>
_li_color = show_zigzag ? zigzag_color : color.new(#faeb46, 100)
//_li_color = show_zigzag ? zigzag_color : color.new(#ffffff,100)
line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow,
xloc.bar_index, color=_li_color, width=2)

if dirUp
if f_isMin(swing_length) and low[swing_length] < lastLow
lastLow := low[swing_length]
timeLow := bar_index
line.delete(li)
li := f_drawLine()
li

if f_isMax(swing_length) and high[swing_length] > lastLow


lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li

if not dirUp
if f_isMax(swing_length) and high[swing_length] > lastHigh
lastHigh := high[swing_length]
timeHigh := bar_index
line.delete(li)
li := f_drawLine()
li
if f_isMin(swing_length) and low[swing_length] < lastHigh
lastLow := low[swing_length]
timeLow := bar_index
dirUp := true
li := f_drawLine()
if f_isMax(swing_length) and high[swing_length] > lastLow
lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy