0% found this document useful (0 votes)
14 views29 pages

SatyATR, 123, VolumeProfile, Liqheatmap, DoubleTB

Uploaded by

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

SatyATR, 123, VolumeProfile, Liqheatmap, DoubleTB

Uploaded by

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

;

;
;;
;;
;
;;
;/
;
;/Thi
sPi
neScr
ipt
™ codei
ssubj
ectt
othet
ermsoft
heMozi
l
laPubl
i
c
License2.
0atht
tps:
//mozi
l
la.
org/
MPL/
2.0/
//©NewLi f
eRi
pon

/
/SatyATRLev els
/
/Copy r
ight( C)2022Sat yMahaj an
/
/Authorisnotr esponsiblefory ourtradingusi ngthi
sscr i
pt.
/
/Datapr ovidedi nthi
sscr i
ptisnotf i
nancial advi
ce.
/
/
/
/Features:
/
/-Day ,
Mul tiday,Swing,Posi t
ion,Long- ter
m, Kel
tnertr
adingmodes
/
/-Rangeagai nstATRf oreachper iod
/
/-Putandcal ltri
ggeridealev els
/
/-I
ntermedi at
el evel
s
/
/-Full
-rangel evels
/
/-Extensionl evels
/
/-Trendl abel basedont he8- 21-34Pi votRibbon
/
/
/
/Specialthankst oGabrielViana.
/
/Basedonmyowni deasandi deasfrom Ri pster,dr
ippy2har
d,
/
/Adam Sl iver,andothers.

/
/@ver
sion=5
i
ndi
cat
or(Sat
yATRLev
els'
,shor
tt
it
le=Sat
yATRLev
els'
,ov
erl
ay=t
rue)

//Opt i
ons
day_trading=Day '
multiday_tradi ng=Mul tiday '
swing_ t
radi ng=Swi ng'
positi
on_ tradi ng=Posi tion'
l
ongt erm_ tradi ng=Long- term'
tr
ading_ t
y pe=i nput .string( day _trading, TradingTy pe',options=[ day_t
rading,
multiday_tradi ng, swi ng_ trading, posi t
ion_trading, longter
m_ tr
adi ng])
use_opt i
ons_ label s=i nput (
true, UseOpt i
onsLabel s'
)
atr_
length=i nput (14, ATRLengt h')
tr
igger_per cent age=i nput (0.236, TriggerPer cent age')
previ
ous_ cl ose_ l
ev el_col or=i nput (color .
whi t
e, Prev i
ousCl oseLev elColor'
)
l
ower _tri
gger _lev el_col or=i nput (color.yell
ow, LowerTr i
ggerLev elColor'
)
upper _t
ri
gger _ level_col or=i nput (col or.
aqua, UpperTr iggerLev elColor'
)
key_target_ lev el_color=i nput (color.silver,KeyTar getLev elCol or')
atr_
target_ lev el_color=i nput (color .
whi te,ATRTar getLev elCol or'
)
i
ntermedi at e_ target _lev el_color=i nput (color.gray, I
ntermedi ateTar getLevel
Color')
show_ all
_ fi
bonacci _lev els=i nput (true,ShowAl lFibonacci Lev els')
show_ extensi ons=i nput (
false, ShowEx t
ensions' )
l
ev el
_si
ze=input(
2,LevelSize'
)
show_ i
nfo=input
(tr
ue,ShowI nfoLabel
'
)
use_curr
ent_
close=input(
false,UseCurr
entCl
ose'
)
fast_
ema=i nput(
8,FastEMA' )
pivot
_ema=i nput
(21,Pi
votEMA' )
slow_ema=i nput
(34,Sl
owEMA' )

/
/Settheappr opri
atet
imefr
amebasedont radi
ngmode
t
imefr
ame_ func()=>
ti
mef r
ame=D'
i
ftrading_type==day_
trading
ti
mef r
ame: =D'
el
seift r
ading_t
ype==mul tiday_tr
ading
ti
mef r
ame: =W'
el
seift r
ading_t
ype==swi ng_ t
rading
ti
mef r
ame: =M'
el
seift r
ading_t
ype==posi t
ion_ t
rading
ti
mef r
ame: =3M'
el
seift r
ading_t
ype==longt erm_trading
ti
mef r
ame: =12M'
el
se
ti
mef r
ame: =D'

//Trend
price=close
fast_ema_value=ta. ema( pri
ce, fast_
ema)
pivot_ema_value=t a.ema( pr
ice, piv
ot_ema)
slow_ ema_value=ta. ema( pr
ice, sl
ow_ ema)
bulli
sh=pr i
ce>=f ast _ema_ v
al ueandf ast_
ema_value>=piv
ot_
ema_valueand
pivot_ema_value>=sl ow_ ema_ val
ue
bearish=price<=f ast _ema_v alueandf ast
_ema_
v alue<=pi
vot
_ema_
v alue
andpi vot
_ema_ val
ue<=sl ow_ ema_ value

//Dat a
period_index=use_ cur r
ent_cl
ose?0: 1
ti
cker=t i
cker.new( sy minfo.pref
ix,syminfo.t
icker,session=sessi
on.extended)
previous_close=r equest .securi
ty(t
icker,
timef r
ame_ func(),
close[peri
od_ i
ndex ]
, gaps=bar merge.gaps_off,
l
ookahead=bar mer ge.lookahead_ on)
atr=r equest.secur i
ty (
ticker,t
imeframe_ f
unc( ),t
a.atr
(atr_l
ength)
[peri
od_index
],
gaps=bar mer ge.gaps_ off,l
ookahead=bar mer ge.
lookahead_ on)
period_high=r equest .securi
ty(t
icker,t
imeframe_ func(),hi
gh,
gaps=bar mer ge.gaps_ off,l
ookahead=bar mer ge.
lookahead_ on)
period_low=r equest .securit
y(ti
cker,ti
mef r
ame_ func(),low,
gaps=bar mer ge.gaps_ off,l
ookahead=bar mer ge.
lookahead_ on)
range_1=per i
od_high-per i
od_ l
ow
tr_
percent_of_
atr=r ange_1/at r*100
l
ower _tr
igger=previous_cl
ose-t rigger_percentage*atr
upper_tr
igger=previous_close+t rigger_percentage*at
r
l
ower _0382=pr evi
ous_ cl
ose-at r*0. 382
upper_0382=pr evi
ous_ cl
ose+at r*0. 382
l
ower _0500=pr evi
ous_ cl
ose-at r*0. 5
upper_0500=pr evi
ous_ cl
ose+at r*0. 5
l
ower _0618=pr evi
ous_ cl
ose-at r*0. 618
upper_0618=pr evi
ous_ cl
ose+at r*0. 618
l
ower _0786=pr evi
ous_ cl
ose-at r*0. 786
upper_0786=pr evi
ous_ cl
ose+at r*0. 786
l
ower _1000=pr evi
ous_ cl
ose-at r
upper_1000=pr evi
ous_ cl
ose+at r
l
ower _1236=l ower_1000-at r*0.236
upper_1236=upper _ 1000+at r*0. 236
l
ower _1382=l ower_1000-at r*0.382
upper_1382=upper _ 1000+at r*0. 382
l
ower _1500=l ower_1000-at r*0.5
upper_1500=upper _ 1000+at r*0. 5
l
ower _1618=l ower_1000-at r*0.618
upper_1618=upper _ 1000+at r*0. 618
l
ower _1786=l ower_1000-at r*0.786
upper_1786=upper _ 1000+at r*0. 786
l
ower _2000=l ower_1000-at r
upper_2000=upper _ 1000+at r
l
ower _2236=l ower_2000-at r*0.236
upper_2236=upper _ 2000+at r*0. 236
l
ower _2382=l ower_2000-at r*0.382
upper_2382=upper _ 2000+at r*0. 382
l
ower _2500=l ower_2000-at r*0.5
upper_2500=upper _ 2000+at r*0. 5
l
ower _2618=l ower_2000-at r*0.618
upper_2618=upper _ 2000+at r*0. 618
l
ower _2786=l ower_2000-at r*0.786
upper_2786=upper _ 2000+at r*0. 786
l
ower _3000=l ower_2000-at r
upper_3000=upper _ 2000+at r

//AddLabel s
tr
_ v
s_atr_col
or=col or.gr
een
i
ft r
_percent_of_atr<=70
tr_
vs_ at
r_color:=color
.green
elseiftr
_percent_of_atr>=90
tr_
vs_ at
r_color:=color
.red
el
se
tr
_vs_
atr
_col
or:
=col
or.
orange

tr
ading_ mode=Day '
i
ftrading_ t
y pe==day_t
rading
trading_ mode:
=Day '
el
sei ftrading_ty
pe==mul tiday_tr
ading
trading_ mode:
=Mul ti
day '
el
sei ftrading_ty
pe==swi ng_ t
rading
trading_ mode:
=Swi ng'
el
sei ftrading_ty
pe==posi t
ion_ t
rading
trading_ mode:
=Posi t
ion'
el
sei ftrading_ty
pe==longt erm_trading
trading_ mode:
=Long- term'
el
se
trading_ mode:
=

l
ong_label=
shor
t_label=
i
fuse_ opt
ions_l
abel
s
long_ l
abel:
=Call
s'
shor t
_label
:=Puts'
el
se
long_ l
abel:
=Long'
shor t
_label
:=Short
'

tr
end_color=col
or.
orange
i
fbull
ish
trend_col
or:
=color.
green
el
seifbearish
trend_col
or:
=color.
red
el
se
trend_col
or:
=color.
orange

vartbl=t able.new( posit


ion. t
op_ ri
ght,1,
4)
i
fbar st
at e.i
slastandshow_ info
table.cell
(tbl,0,0,SatyATRLev el
s',
bgcolor=tr
end_ color
)
table.cell
(tbl,0,1,tr
adi ng_mode+ Range( $'
+st r
.tostr
ing(range_1,#.##'
)
+)is' +st r.
tostring(tr
_percent _of_atr
,#.#'
)+%ofATR( $'+st r
.tostr
ing(atr
,
#.##')+) ',
bgcol or=tr_
vs_at r_color)
table.cell
(tbl,0,2,l
ong_ l
abel + >$' +str.
tostri
ng(upper_tri
gger, #.
##')+
|+1ATR$' +st r.
tostri
ng(upper _
1000, #.
##'),
bgcolor=upper _trigger_l
ev el_col
or)
table.cell
(tbl,0,3,shor t_l
abel + <$' +str.
tostr
ing(lower_tr
igger,#.##'
)+
|-1ATR: $'+st r
.tostri
ng(lower _1000,#.##')
,bgcolor=l
ower _t
rigger_level
_color
)
//Addl evels
plot(show_ ex tensi ons?l ower _3000: na,
color=color .new( at r
_tar get _lev el_color ,40),li
newi dt h=l evel_size,ti
tl
e=-300.0%'
,
style=plot.
st yle_st epline)
//plot(show_ all
_fibonacci _
lev el sandshow_ extensi ons?l ower _2786: na,
color=color .new( intermedi at e_ target _l
ev el_
col or,40) ,li
newi dth=level
_size,
ti
tle='-
278. 6%' ,style=pl ot.sty l
e_ stepl i
ne)
plot(show_ ex tensi ons?l ower _2618: na,
color=color .new( key _tar get _lev el
_ color, 40),l
inewi dt h=l evel_si
ze,
ti
tle=-261.8%' ,sty l
e=pl ot .style_ stepl i
ne)
//plot(show_ all
_fibonacci _
lev el sandshow_ extensi ons?l ower _2500: na,
color=color .new( intermedi at e_ target _l
ev el_
col or,40) ,li
newi dth=level
_size,
ti
tle='-
250. 0%' ,style=pl ot.sty l
e_ stepl i
ne)
//plot(show_ all
_fibonacci _
lev el sandshow_ extensi ons?l ower _2382: na,
color=color .new( intermedi at e_ target _l
ev el_
col or,40) ,li
newi dth=level
_size,
ti
tle='-
238. 2%' ,style=pl ot.sty l
e_ stepl i
ne)
plot(show_ ex tensi ons?l ower _2236: na,
color=color .new( key _tar get _lev el
_ color, 40),l
inewi dt h=l evel_si
ze,
ti
tle=-223.6%' ,sty l
e=pl ot .style_ stepl i
ne)
plot(show_ ex tensi ons?l ower _2000: na,
color=color .new( at r
_tar get _lev el_color ,40),li
newi dt h=l evel_size,ti
tl
e=-200.0%'
,
style=plot.
st yle_st epline)
plot(show_ al l
_fibonacci _lev elsandshow_ extensi ons?l ower _1786: na,
color=color .new( intermedi at e_ target _l
ev el_
col or,40) ,li
newi dth=level
_size,
ti
tle=-178.6%' ,sty l
e=pl ot .style_ stepl i
ne)
plot(show_ ex tensi ons?l ower _1618: na,
color=color .new( key _tar get _lev el
_ color, 40),l
inewi dt h=l evel_si
ze,
ti
tle=-161.8%' ,sty l
e=pl ot .style_ stepl i
ne)
plot(show_ al l
_fibonacci _lev elsandshow_ extensi ons?l ower _1500: na,
color=color .new( intermedi at e_ target _l
ev el_
col or,40) ,li
newi dth=level
_size,
ti
tle=-150.0%' ,sty l
e=pl ot .style_ stepl i
ne)
plot(show_ al l
_fibonacci _lev elsandshow_ extensi ons?l ower _1382: na,
color=color .new( intermedi at e_ target _l
ev el_
col or,40) ,li
newi dth=level
_size,
ti
tle=-138.2%' ,sty l
e=pl ot .style_ stepl i
ne)
plot(show_ ex tensi ons?l ower _1236: na,
color=color .new( key _tar get _lev el
_ color, 40),l
inewi dt h=l evel_si
ze,
ti
tle=-123.6%' ,sty l
e=pl ot .style_ stepl i
ne)
plot(l
ower _ 1000, col or =color .new( atr_target_level_ col or,40),
l
inewi dth=lev el_size, ti
t l
e=- 100%' ,st y
le=pl ot.
sty l
e_ st epline)
plot(show_ al l
_fibonacci _lev els?l ower _0786: na,
color=color .new( intermedi at e_ target _l
ev el_
col or,40) ,li
newi dth=level
_size,
ti
tle=-78.6%' ,style=pl ot .
st y
le_ st epline)
plot(l
ower _ 0618, col or =color .new( key_ target_level_ col or,40),
l
inewi dth=lev el_size, ti
t l
e=- 61. 8%', style=plot.style_ stepl i
ne)
plot(show_ all
_ f
ibonacci _level s?l ower _0500: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=-50.0%' ,style=pl ot .style_ st epl ine)
plot(show_ all
_ f
ibonacci _level s?l ower _0382: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=-38.2%' ,style=pl ot .style_ st epl ine)
plot(l
ower _ tri
gger , color =col or .new( lower _trigger _lev el_ col or,40) ,
l
inewi dth=lev el_size, t
itle=LowerTr igger ',st yle=pl ot .st yle_ stepline)
plot(previous_ close, col or=col or .new( pr ev ious_ close_ l
ev el _color,40) ,
l
inewi dth=lev el_size, t
itle=Pr ev iousCl ose' , sty l
e=pl ot .sty l
e_ stepline)
plot(upper _tri
gger ,color =col or.new( upper _ trigger _ lev el_ color ,
40) ,
l
inewi dth=lev el_size, t
itle=UpperTr igger '
, st yle=pl ot .st yle_st epli
ne)
plot(show_ all
_ f
ibonacci _level s?upper _
0382: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=38.2%' ,st y
le=pl ot.st yl
e_ st epl ine)
plot(show_ all
_ f
ibonacci _level s?upper _
0500: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=50.0%' ,st y
le=pl ot.st yl
e_ st epl ine)
plot(upper _0618, col or=col or .new( key _target _lev el_ col or ,40),
l
inewi dth=lev el_size, t
itle=61. 8%' , sty le=pl ot .sty l
e_ st epl ine)
plot(show_ all
_ f
ibonacci _level s?upper _
0786: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=78.6%' ,st y
le=pl ot.st yl
e_ st epl ine)
plot(upper _1000, col or=col or .new( at r_target _lev el_col or ,40) ,
l
inewi dth=lev el_size, t
itle=100%' ,st yle=pl ot .sty le_st epl ine)
plot(show_ extensi ons?upper _1236: na,
color=color .new( key _target _ l
ev el _col or,40) ,linewi dt h=l ev el_si
ze, ti
tle=123.6%'
,
style=plot.style_st epl i
ne)
plot(show_ all
_ f
ibonacci _level sandshow_ ex tensi ons?upper _1382: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=138.2%' ,style=pl ot .style_ st epl ine)
plot(show_ all
_ f
ibonacci _level sandshow_ ex tensi ons?upper _1500: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=150.0%' ,style=pl ot .style_ st epl ine)
plot(show_ extensi ons?upper _1618: na,
color=color .new( key _target _ l
ev el _col or,40) ,linewi dt h=l ev el_si
ze, ti
tle=161.8%'
,
style=plot.style_st epl i
ne)
plot(show_ all
_ f
ibonacci _level sandshow_ ex tensi ons?upper _1786: na,
color=color .new( int ermedi at e_ tar get _ l
ev el_ col or, 40) , l
inewi dth=level_size,
ti
tle=178.6%' ,style=pl ot .style_ st epl ine)
plot(show_ extensi ons?upper _2000: na,
color=color .new( at r_target _lev el _col or,40) ,linewi dt h=l ev el_size,tit
le=200.0%',
style=plot.style_st epl i
ne)
plot(show_ extensi ons?upper _2236: na,
color=color .new( key _target _ l
ev el _col or,40) ,linewi dt h=l ev el_si
ze, ti
tle=223.6%'
,
style=plot.
style_stepline)
//plot(show_ all
_fibonacci_levelsandshow_ extensions?upper _2382: na,
color=color.new( i
nt er
medi ate_target _l
evel_
col or
,40),li
newidth=level
_size,
ti
tle='238.2%',style=plot.
style_stepline)
//plot(show_ all
_fibonacci_levelsandshow_ extensions?upper _2500: na,
color=color.new( i
nt er
medi ate_target _l
evel_
col or
,40),li
newidth=level
_size,
ti
tle='250.0%',style=plot.
style_stepline)
pl
ot (show_ extensi ons?upper _2618: na,
color=color.new( key _
target_level_color,40),l
inewidth=level
_si
ze, t
itl
e=261.8%',
style=plot.
style_stepline)
//plot(show_ all
_fibonacci_levelsandshow_ extensions?upper _2786: na,
color=color.new( i
nt er
medi ate_target _l
evel_
col or
,40),li
newidth=level
_size,
ti
tle='278.6%',style=plot.
style_stepline)
pl
ot (show_ extensi ons?upper _3000: na,
color=color.new( atr_t
arget_level_color,40),li
newidth=level_
size,ti
tl
e=300%' ,
style=plot.
style_stepline)

//ThisworkislicensedunderaAttr
ibut
ion-NonCommerci
al-
Shar
eAl
i
ke4.
0
I
nternati
onal(
CCBY- NC-
SA4. 0)
htt
ps://
creat
ivecommons. or
g/ l
i
censes/
by-nc-sa/
4.0/
//©Zei i
erman

/
/@v
ersi
on=5

//~~Tool Tips{
t1="Pivotper i
od"
t2="Showpat ter
nbr eak, setthesize,andcol
ori
ng"
t3="Showt he1- 2-3Patt ern"
t4="Enablet heHH/ HL/ LL/ LHlabel
s"
//~~}
//~~Inputs{
prd=input.i
nt (
10,t
it
le="Per i
od",t
oolt
ip=t1)

showBreak =i nput.
bool(
true,"
ShowBreak",inli
ne="break"
)
showPatter
n=input.
bool(
true,"
ShowPattern",
toolt
ip=t3)
showPvts =input
.bool
(false,
"ShowPi
v ots"
,toolt
ip=t4)

vi
suel
l=
i
nput.
stri
ng("Di
amond" ,
"",
opti
ons=["Diamond" ,
"XCr
oss",
"Cross"
,"
Flag"
,"
Squar
e"]
,
i
nli
ne="
break")
col
Bull=input.
col or(
#34fa03,"
",
inli
ne=" break")
col
Bear=i nput.color
(#fc0303,
"",
inl
ine=" break"
)
si
ze =
i
nput.
stri
ng(size.ti
ny,
"",
opti
ons=[size.
tiny ,
size.
small
,si
ze.nor
mal,si
ze.
lar
ge,
si
ze.
huge]
,
inl
i
ne="
break"
,t
ool
ti
p=t
2)

shape=swi t
chv i
suell
"Diamond"=>l abel .
st yle_diamond
"XCross" =>l abel .
st yle_xcross
"Cross" =>l abel .sty l
e_ cross
"Fl
ag" =>l abel.st yle_flag
"Squar e" =>l abel.st yl
e_ square
//~~}
//~~Ar rays{
varpv t
s=ar ray
.new<f loat >(3,0.0)
varidx =ar ray.
new<i nt >(3,0)
//~~}
//~~Pi vots{
pvtHi=t a.pivot
high(high, prd,prd)
pvtLo=t a.pivotl
ow( l
ow, pr d,prd)
varpos=0

i
fnotna(
pvt
Hi)andpos<=0
i
fshowPvts

l
abel
.new(bar_i
ndex-prd,
high[
prd],
text=pvt
Hi>ar
ray.get
(pvts,
1)?
"HH"
:"
LH"
,st
yle=
l
abel
.styl
e_l
abel_down,color
=color
( na),
text
col
or=chart
.fg_
color)
array.
pop(pvts)
array.
pop(idx)
array.
unshift
(pvts,
hi
gh[prd]
)
array.
unshift
(idx
,bar_
index-
prd)
pos:=1
i
fnotna(pvtLo)andpos>=0
i
fshowPv t
s

l
abel.new( bar_index- prd,low[prd],
text=pv tLo>ar r
ay.get(pv
ts,1)
?"HL":
"LL",
sty
le=l
abel
.style_label_up, col or=color(na),t
ext color=chart.fg_
color)
array.pop( pvts)
array.pop( i
dx )
array.unshi f
t(pv ts,low[ pr
d])
array.unshi f
t(idx ,bar _i
ndex-prd)
pos: =- 1
//~~}
//~~I dent i
fy1- 2-3Pat tern&Al erts{
varpattern=t rue
i
fta.crossov er(high, array .get
(pvts,1))andpat tern
ifarray.get(pvt s,0)>ar ray
.get(pvts,2)andar ray.
get(pvts,
0)<ar
ray.get
(pvts,
1)
i
fshowBr eak
label.new( bar_i
ndex,high,sty l
e=shape, color
=colBull
,
size=si
ze)
l
i
ne.new(ar
ray.
get(
idx,
1),
array
.get(
pvt
s,1)
,bar
_index,
arr
ay.
get
(pv
ts,
1),
col
or=cha
r
t.
fg_col
or,
sty
le=l
i
ne.sty
le_dashed)
i
fshowPatter
n

l
abel.
new(ar
ray.
get(
idx,
2),
arr
ay.get
(pv
ts,
2),
text
="1"
,col
or=col
or(
na)
,t
ext
col
or=c
har
t.
fg_col
or,
sty
le=l
abel.
sty
le_l
abel
_up)

l
abel.
new(ar
ray.
get(
idx,
1),
arr
ay.get
(pv
ts,
1),
text
="2"
,col
or=col
or(
na)
,t
ext
col
or=c
har
t.
fg_col
or,
sty
le=l
abel.
sty
le_l
abel
_down)

l
abel.
new(ar
ray.
get(
idx,
0),
arr
ay.get
(pv
ts,
0),
text
="3"
,col
or=col
or(
na)
,t
ext
col
or=c
har
t.
fg_col
or,
sty
le=l
abel.
sty
le_l
abel
_up)

l
i
ne.new(ar
ray.
get(i
dx,
2),
arr
ay.
get
(pv
ts,
2),
arr
ay.
get
(i
dx,
1),
arr
ay.
get
(pv
ts,
1),
col
o
r
=color
.r
gb(78,254,3,
2))

l
i
ne.new(array.
get (idx ,
1) ,
arr
ay.get(pvts,1)
,arr
ay.get
(idx,0),
arr
ay.get(pvts,
0),
col
o
r
=color.
rgb(78,255, 3, 2))
alert
("Bullish1- 2-
3Pat ternIdentifi
edon:
"
+syminfo.ti
cker,alert.freq_once_ per_bar_cl
ose)
pattern: =f alse
i
fta.
crossunder (
low, ar ray.
get(pvts,1))andpat t
ern
ifarray.
get(pv ts,0)<array.
get (pvts,
2)andar ray
.get(pvts,
0)>array.get
(pvt
s,1)
ifshowBr eak
label .
new( bar_i
ndex, low,sty
le=shape,color=col
Bear,size=si
ze)

l
i
ne.new(ar
ray.
get(
idx,
1),
array
.get(
pvt
s,1)
,bar
_index,
arr
ay.
get
(pv
ts,
1),
col
or=cha
r
t.
fg_col
or,
sty
le=l
i
ne.sty
le_dashed)
i
fshowPatter
n

l
abel.
new(ar
ray.
get(
idx,
2),
arr
ay.get
(pv
ts,
2),
text
="1"
,col
or=col
or(
na)
,t
ext
col
or=c
har
t.
fg_col
or,
sty
le=l
abel.
sty
le_l
abel
_down)

l
abel.
new(ar
ray.
get(
idx,
1),
arr
ay.get
(pv
ts,
1),
text
="2"
,col
or=col
or(
na)
,t
ext
col
or=c
har
t.
fg_col
or,
sty
le=l
abel.
sty
le_l
abel
_up)

l
abel.
new(ar
ray.
get(
idx,
0),
arr
ay.get
(pv
ts,
0),
text
="3"
,col
or=col
or(
na)
,t
ext
col
or=c
har
t.
fg_col
or,
sty
le=l
abel.
sty
le_l
abel
_down)

l
ine.new(ar
ray
.get
(idx
,2)
,ar
ray
.get
(pv
ts,
2),
arr
ay.
get
(i
dx,
1),
arr
ay.
get
(pv
ts,
1),
color=#f
a0303fa)

l
i
ne.
new(ar
ray
.get
(i
dx,
1),
arr
ay.
get
(pv
ts,
1),
arr
ay.
get
(i
dx,
0),
arr
ay.
get
(pv
ts,
0),
col
o
r
=#f
a0303f
a)
al
ert(
"Beari
sh1- 2-
3Patter
nIdent
if
iedon:
"
+syminfo.
ti
cker,
alert
.fr
eq_once_
per_bar
_cl
ose)
pat
tern:=false
/
/~~}
/
/~~Debuggeronl ycheckbreakonce{
i
fta.
change(ar
ray.
get(pvts,
1))
patt
ern:=true
/
/~~}

//Thi
ssour
cecodeissubj
ectt
othet
ermsoft
heMozi
l
laPubl
i
cLi
cense2.
0at
htt
ps:
//mozi
l
la.
org/
MPL/2.
0/
//©HSAF

/
/@v
ersi
on=5

//==========================
//I
nputs
//==========================
sessionType=input.
str
ing(
Dail
y',
Sessi
onTy
pe'
,opt
ions=[
Toky
o',
London'
,
New
York'
,Dail
y'
,Weekl
y',
Mont hl
y'
])

showPr of=i nput.bool(t


rue, ShowVol umePr of
ile',
gr oup=Display'
)
showPoc=i nput.bool (
true,ShowPOC' ,group=Di splay')
showVA=i nput .
bool (
true,ShowVal ueArea',group=Di spl
ay'
)
showCur=i nput.bool(t
rue, ShowLi veZone', gr
oup=Di splay'
)
resol
ution=i nput.int(
30, Resolution'
,minval=5,tool t
ip=Thehi gherthev al
ue,
themor eref i
nedofapr of i
l
e, butlessprofil
esshownonchar t'
,group=Volume
Profi
leSettings')
smoot hVol=i nput .
bool(fal
se, Smoot hVolumeDat a',t
oolti
p=Usef ulf
orassets
thathavever ylargespi kesi nv ol
umeov erlargebar s,helpscreatebetter
profi
les'
,group=Vol umePr of i
leSetti
ngs')
dataTf=

bullCol=input.color(color.rgb(76, 175, 79, 50) ,UpVolume' ,


group=Appear ance' )
bear Col=input.color(color.rgb(255, 82,82, 50),DownVol ume',
group=Appear ance' )
pocCol =input.color(color.red,POC' ,inli
ne=p' ,
group=Appearance'
)
pocWi d=i nput.i
nt(1,Thickness' ,inline=p', gr oup=Appearance'
)
vahCol =input.color(color.aqua, VAH' ,i
nline=h' ,gr
oup=Appearance'
)
vahWi d=i nput.
int(1,Thickness' ,inline=h', group=Appearance')
valCol =i
nput .
color(color.aqua, VAL' ,i
nli
ne=l '
,group=Appearance'
)
valWi d=input.
int(1,Thickness' ,inline=l '
,gr oup=Appearance')
box Wid=i nput.i
nt(1,Sessi onBoxThi ckness' ,group=Appearance'
)
/
/==========================
/
/Constants/Vari
ableDeclar
ati
on
/
/==========================
v
arintzoneStar
t=0
i
ntl
ookback=bar _i
ndex-zoneStar
t
v
aracti
v eZone=fal
se

//Defini
ngarr
ayst hatst
oretheinformati
on
varvpGreen=array.new_fl
oat(
resoluti
on,0)/
/Sum ofvol
umeonl ongbars
varvpRed=array.new_fl
oat(r
esoluti
on,0)//Samethi
ngbutwithredbars
varzoneBounds=ar ray.
new_fl
oat(resol
uti
on,0)/
/arr
aythatst
oresthe
highestval
uethatcanbei naz one

/
/Val
uestostor
ecur
renti ntrabardat a
v
arfl
oat
[]l
tf
Open= ar ray .
new_ f
loat(0)
v
arfl
oat
[]l
tf
Close= array .new_fl
oat (
0)
v
arfl
oat
[]l
tf
High= array .new_fl
oat (
0)
v
arfl
oat
[]l
tf
Low= ar r
ay .new_ f
loat(0)
v
arfl
oat
[]l
tf
Volume=arr ay .
new_float(0)

v
ol(
)=>
smoot
hVol
?ta.
ema(
vol
ume,
5):
vol
ume

//Gett
ingint
rabarint
ialdata
[dO,dC,dH,dL,dV]=r equest
.secur
it
y_l
ower
_tf
(sy
minf
o.t
icker
id,
dat
aTf
,[open,
close,
high,l
ow, v
ol()
])

/
/==========================
/
/Functions
/
/==========================
r
esetProfil
e(enable)=>
ifenable
ar
ray.fi
l
l(vpGreen,0)
ar
ray.fi
l
l(vpRed, 0)
ar
ray.cl
ear(l
tfOpen)
ar
ray.cl
ear(l
tfHigh)
ar
ray.cl
ear(l
tfLow)
ar
ray.cl
ear(l
tfClose)
ar
ray.cl
ear(l
tfVolume)

pr
ofHigh=t
a.hi
ghest(hi
gh,lookback+1)[
1]
pr
ofLow=ta.
lowest(
low,lookback+1)[1]

t
r=t
a.at
r(1)
get
_vol
(y11,y12,
y21,y22,hei
ght,v
ol)=>
nz(math.
max (math.
min(math.
max (
y11,y
12),math.
max(y21,y
22))-
math.
max (math.
min(y
11,y12),math.
min(y
21,y22)
),0)*vol
/height)

prof
ileAdd( o,h,
l,c,v,g,w)=>
//Arraytostor ehowmucht odistr
ibut
eineachzone,
onscal
eof1f
orf
ull
gapsi zeto0
zoneDi st=array.new_ f
loat(r
esolut
ion,0)
distSum =0. 0
//Goi ngovereachz one
fori =0t oarray.
size(vpGreen)-1
//Checkingt oseei fcurbarisinzone
zoneTop=ar r
ay.get(zoneBounds,i)
zoneBot=zoneTop-g

body_
top=mat
h.max(
c,o)
body_
bot=mat
h.mi
n(c,o)
i
tsgr
een=c>=o

topwi
ck=h-body_t
op
bott
omwick=body_bot-l
body=body_
top-body_bot

bodyvol
=body*v/( 2*topwi
ck+2*bott
omwick+body
)
topwi
ckvol =2*topwick*v/(
2*topwi
ck+2*bottomwi
ck+body)
bott
omwi ckvol
=2*bot tomwi
ck*v/(2*topwi
ck+2*bott
omwick+
body
)

ar r
ay.
set(
vpGr een,i,
array .
get(vpGr een,i
)+( itsgreen?
get_
vol(
zoneBot,zoneTop, body_ bot,body _top,body ,body vol
):0)+
get_
vol(
zoneBot,zoneTop, body_ top,h, t
opwi ck,topwickv ol
)/2+
get_
vol(
zoneBot,zoneTop, body_ bot,l
, bottomwi ck,bot t
omwi ckvol)/2)
ar r
ay.
set(
vpRed, i,ar
ray.get(vpRed, i)+(itsgr
een?0: get
_v ol
(zoneBot,
zoneTop,body_bot,body_top,body ,body vol))+get _v
ol (
zoneBot ,
zoneTop,
body_t
op, h,t
opwick,topwickvol)/2+get _vol(
zoneBot ,
zoneTop, body _
bot,l
,
bott
omwi ck,bot
tomwi ckvol)/2)

cal
cSessi
on(update)=>
array
.fi
ll
(vpGreen,0)
array
.fi
ll
(vpRed,0)
ifbar_
index>l ookbackandupdat
e
gap=( profHigh-pr
ofLow)/r
esol
uti
on

/
/Def
ini
ngpr
ofi
l
ebounds
f
ori
=0t oresol
uti
on-1
arr
ay.set
(zoneBounds,
i,pr
ofHi
gh-gap*i
)

//Put ti
ngeachbari nsi dez onei nt
othev olumeprofi
lear r
ay
ifarray.si
ze(l
tfOpen)>0
forj=0t oarray.si
z e(
ltfOpen)-1
prof
il
eAdd( array.get(l
tfOpen,j)
,array
.get
(l
tf
Hi gh,j
),
ar
ray
.get
(l
tfLow, j)
,arr
ay .
get(
ltfClose, j
),arr
ay.get
(lt
fVolume,j
),gap,1)

pocLevel(
)=>
f
loatmax Vol=0
i
ntlevel
Ind=0
f
ori =0toar r
ay.size(
vpRed)-1
i
farray.
get(
v pRed,i
)+array
.get
(vpGr
een,i)>maxVol
maxVol :=arr
ay.
get(
vpRed,i
)+array
.get(
vpGr
een,i
)
l
evel
Ind: =i

floatout Level
=na
i
fl evelI
nd! =arr
ay.
size(
vpRed)-1
outLevel:
=array.
get(
zoneBounds,l
evel
Ind)-(
arr
ay.
get
(zoneBounds,
l
evel
Ind)-ar ray.
get(
zoneBounds,l
evel
Ind+1)
)/2
out Level

v
alueLevels(
poc)=>
floatgap=(prof
High-prof
Low)/resolut
ion
floatvol
Sum =array
.sum(v
pRed)+array.
sum(v
pGr
een)
floatvol
Cnt=0

f
loatv
ah=profHi
gh
f
loatv
al=pr
ofLow

//Fi
ndingpocindex
intpocInd=0
fori=0t oarr
ay.
size(
zoneBounds)
-2
i
far r
ay.
get(
zoneBounds,i
)>=pocandar
ray
.get
(zoneBounds,
i+1)<
poc
pocI
nd:=i

volCnt+=( arr
ay.get
(vpRed,pocI
nd)+ar
ray.
get(v
pGreen,pocInd)
)
fori=1t oar r
ay.si
ze(vpRed)
ifpocInd+i >=0andpocI nd+i<arr
ay.
size(
vpRed)
volCnt+=( ar
ray.
get(
vpRed,
pocI
nd+i )+arr
ay.get(
vpGreen,
pocI
nd+i ))
ifvol
Cnt>=v olSum *0.
7
break
else
val:=ar
ray.get(
zoneBounds, pocI nd+i )-gap
i
fpocInd-i>=0andpocI nd-i<ar r
ay .
size(v pRed)
volCnt+=(array.
get(vpRed,pocInd-i )+ar ray
.get
(vpGr
een,
pocI
nd-i
))
ifvol
Cnt>=v olSum *0.7
break
else
vah:=array.get
(zoneBounds, pocI nd-i)

[
val
,vah]

drawNewZone( updat e)=>


ifbar_index>l ookbackandupdat eandar ray .
sum( v pGreen)+
array .
sum( v pRed)>0
gap=( profHigh-pr of Low)/r esol ution
fl
oatl ef t
Max=bar _ i
ndex[ l
ookback]
fl
oatr i
ght Max=bar _index[ i
nt( l
ookback/1. 4) ]
fl
oatr i
ght MaxVol =ar ray .max (v pGr een) +ar r
ay .max (vpRed)
fl
oatbuf fer=gap/10
i
fshowPr of
fori =0t oar ray .size( vpRed)-1
greenEnd=i nt (leftMax+( right Max-l ef tMax)*
(array .
get
(v pGr een, i
)/r ightMax Vol ))
redEnd=i nt (greenEnd+( ri
ght Max-l eftMax)*
(array .
get
(v pRed, i)/r i
ght Max Vol ))
box .
new( int( l
ef tMax ), array .get(zoneBounds, i
)-buffer,
greenEnd, arr ay.get(zoneBounds, i)-gap+buf f
er,bgcol or=bullCol,
border _width=0)
box .
new( gr eenEnd, arr ay.get (zoneBounds, i)-buffer,r
edEnd,
array .
get(
z oneBounds, i)-gap+buf f
er ,bgcol or=bear Col ,border_width=0)
box .new( int(
leftMax ) ,pr ofHigh, bar_ index -1,pr ofLow, chart.
fg_col
or,
box Wi d,l
i
ne. style_dashed, bgcol or=col or .r
gb( 0,0,0,100) )
poc=pocLev el()
[val, vah]=v alueLev el s(poc)
i
fshowPoc
li
ne.new( int (
left Max ),poc, bar _index -1,poc, color=pocCol,
widt h=pocWi d)
i
fshowVA
li
ne.new( int (
left Max ),vah, bar_ i
ndex -1,v ah, col
or=v ahCol,
widt h=vahWi d)
li
ne.new( int (
left Max ),val, bar _i
ndex -1, val,color=valCol,
widt h=val
Wi d)
/
/ifupdate
/
/ r eset
Prof
il
e(t
rue)

dr
awCur
Zone(update)=>
v
arl
inepocLine=na
v
arl
inevahLine=na
v
arl
inevalLi
ne=na
v
arboxoutBox=na

v
arredBoxes=arr
ay.new_box(ar
ray.
size(
v pRed),na)
v
argreenBoxes=arr
ay .
new_box(ar
ray.
size(vpRed),na)

i
fbar_i
ndex>l ookbackandupdateandarray
.sum(
vpGr
een)+
ar
ray
.sum(vpRed)>0
/
/Clearingthepr evi
ousboxesandar
ray
i
fnotna( pocLine)
l
ine.del
ete(pocLine)
i
fnotna( vahLine)
l
ine.del
ete(vahLine)
i
fnotna( valLi
ne)
l
ine.del
ete(val
Line)
i
fnotna( outBox)
box.del
ete(outBox )

f
ori
=0t oarr
ay.
size(r
edBox es)-1
ifnotna(
arr
ay.get(
redBox es,
i))
box.
del
ete(ar
ray.get(
redBoxes,i
))
box.
del
ete(ar
ray.get(
greenBoxes,i
))

gap=( profHigh-pr of Low)/r esoluti


on
fl
oatleftMax=bar _index[ l
ookback]
fl
oatrightMax=bar _ i
ndex[ int(l
ookback/1. 4) ]
fl
oatrightMaxVol =ar ray.max (vpGreen)+array.max(vpRed)
fl
oatbuf f
er=gap/10
i
fshowPr of
f
ori =0t oar r
ay .size(vpRed)-1
greenEnd=i nt (
leftMax+( ri
ghtMax-l ef
tMax)*
(ar
ray.get(vpGreen, i
)/rightMax Vol) )
redEnd=i nt (greenEnd+( r
ightMax-l eft
Max)*
(ar
ray.get(vpRed, i
)/r i
ghtMax Vol))
array.
set(greenBox es,i
,box .
new(int(l
eftMax),
arr
ay.get(zoneBounds, i
)-buf fer ,
gr eenEnd, arr
ay.get(zoneBounds,i
)-gap+
buff
er, bgcolor
=bul lCol
,border _ width=0) )
array.
set(redBox es, i
,box .
new(greenEnd,
arr
ay.get
(zoneBounds,i)-buff
er,redEnd,arr
ay.
get(
zoneBounds,i
)-gap+
buff
er,bgcolor
=bearCol,bor
der_width=0))
out
Box:=box .
new( i
nt(
leftMax),
profHi
gh,bar_
index-
1,pr
ofLow,
chart
.fg_
color,
boxWi d,
line.
styl
e_dashed,bgcol
or=col
or.
rgb(
0,0,
0,
100))

poc=pocLev el(
)
[
val,v
ah]=v al
ueLev el
s(poc)
i
fshowPoc
l
ine.
new(int
(lef
tMax )
,poc,bar
_index-
1,poc,color
=pocCol,
wi
dth=pocWid)
i
fshowVA
l
ine.
new(int
(lef
tMax )
,vah,bar
_index-
1,vah,col
or=vahCol
,
wi
dth=vahWid)
l
ine.
new(int
(lef
tMax )
,val
,bar_
index-
1,val,col
or=val
Col,
wi
dth=val
Wid)

combArr
ay (
ar r1,ar
r2)=>
out=ar ray .
copy(arr
1)
i
farray.size(ar
r2)>0
f ori =0t oarray.
siz
e(ar
r2)-1
arr
ay.push(out
,arr
ay.
get(
arr
2,i
))
out

updateI
ntr
a(o,h,l
,c,v)=>
i
farr
ay.si
ze(o)>0
fori=0t oarray
.si
ze(o)-1
arr
ay.push(
ltf
Open, array.get(o,i)
)
arr
ay.push(
ltf
High,arr
ay .
get (h,i)
)
arr
ay.push(
ltf
Low,array .
get(l,i)
)
arr
ay.push(
ltf
Close,array.get(c,i
))
arr
ay.push(
ltf
Volume, array.get(v,i
))

//==========================
//Calcul
ati
ons
//==========================
//Detect
ingdif
ferentstartdates
newDai l
y=day of
week! =day ofweek[
1]
newWeekl y=(day ofweek!=day of
week[
1]+1)and(day
ofweek!
=
dayofweek[1]
)
newMont hly=(day ofmonth!=dayofmont
h[1]+1)and(
dayof
month!
=
dayofmonth[1]
)

ut
cHour=hour
(ti
me(
ti
mef
rame.
per
iod,
0000-
2400'
,GMT'
),
GMT'
)
newTokyo=ut
cHour!=ut
cHour
[1]+1andut
cHour!
=ut
cHour
[1]
endToky
o=utcHour>=9andut
cHour[
1]<9

newLondon=utcHour>=7andut
cHour[
1]<7
endLondon=ut
cHour>=16andutcHour
[1]<16

newNewYork=ut
cHour>=13andutcHour
[1]<13
endNewYor
k=utcHour>=22andut
cHour[
1]<22

newSessi
on=swi tchsessionType
Tokyo'=>newToky o
London'=>newLondon
NewYor k'=>newNewYor k
Dail
y'=>newDaily
Weekly'=>newWeekl y
Monthly'=>newMont hly

zoneEnd=swi t
chsessi
onType
Tokyo'=>endTokyo
London'=>endLondon
NewYor k'=>endNewYork
Dail
y'=>newDaily
Weekly'=>newWeekly
Monthly'=>newMonthl
y

//Recalculat
inganddr awingzones
calcSession(
zoneEndor( barst
ate.
isl
astandshowCur))
drawNewZone( zoneEnd)
drawCur Zone(barst
ate.
isl
astandnotz oneEndandshowCurandact
iveZone)

/
/Reset
ingprof
ieatst
artofnewzone
r
esetPr
ofi
le(
newSessi
on)

//
Updatingdataarr
ays
updat
eIntr
a(dO,dH,dL,
dC,
dV)

/
/Reseti
ngzonestartval
ue
i
fzoneEnd
acti
veZone:
=f al
se

i
fnewSession
zoneStar
t:=bar_
index
acti
veZone:=tr
ue

/
/Thi
sPi
neScr
ipt
™ codei
ssubj
ectt
othet
ermsoft
heMozi
l
laPubl
i
cLi
cense
2.0atht
tps:
//mozil
la.
org/
MPL/
2.0/
//©NewLi f
eRipon

//Thi
ssour
cecodeissubj
ectt
othet
ermsoft
heMozi
l
laPubl
i
cLi
cense2.
0at
htt
ps:
//mozi
l
la.
org/
MPL/2.
0/
//©Nephew_Sam_

/
/@v
ersi
on=5

/
/---
--
--
---
--
--
-INPUTS- -
--
--
---
---
--
-
v
arGRP1=" •••
•••
••••INTRADAYTI MEFRAMES• ••
•••
•••
•"
/
/1
l
ti
mef r
ame1Show=i nput.
bool (
true,ti
tle=,i
nli
ne=1',group=GRP1)
l
ti
mef r
ame1=i nput.t
imeframe( 15',t
itl
e=,inl
ine=1',group=GRP1)
l
l
eftBars1=input .
int(
defval=7,t
itle=Left'
,minval=2,max val
=20, gr
oup=GRP1,
i
nli
ne=1')
l
ri
ghtBars1=input .i
nt(
defval=7,titl
e=Right'
,minv al
=2, maxval=20,gr
oup=GRP1,
i
nli
ne=1',t
oolt
ip="Highest/l
owestpoi ntinxrightandl eftbars."
)

/
/2
l
ti
mef r
ame2Show=i nput
.bool(
true,ti
tle=,i
nli
ne=2',gr
oup=GRP1)
l
ti
mef r
ame2=i nput.t
imefr
ame( 30',t
itl
e=,inl
ine=2',
group=GRP1)
l
l
eftBars2=input.
int(
defv
al=7,t
itle=Left'
,minval=2,maxval
=20, gr
oup=GRP1,
i
nli
ne=2')
l
ri
ghtBars2=input.i
nt(
defval
=7,titl
e=Right'
,minv al
=2,maxval=20,gr
oup=GRP1,
i
nli
ne=2',t
ool
ti
p="Highest/
lowestpoi ntinxrightandleftbars."
)

/
/3
l
ti
mef r
ame3Show=i nput
.bool(
true,ti
tle=,i
nli
ne=3',gr
oup=GRP1)
l
ti
mef r
ame3=i nput.t
imefr
ame( 60',t
itl
e=,inl
ine=3',
group=GRP1)
l
l
eftBars3=input.
int(
defv
al=7,t
itle=Left'
,minval=2,maxval
=20, gr
oup=GRP1,
i
nli
ne=3')
l
ri
ghtBars3=input.i
nt(
defval
=6,titl
e=Right'
,minv al
=2,maxval=20,gr
oup=GRP1,
i
nli
ne=3',t
ool
ti
p="Highest/
lowestpoi ntinxrightandleftbars."
)

/
/4
l
ti
mef r
ame4Show=i nput
.bool(
true,ti
tle=,inli
ne=4',group=GRP1)
l
ti
mef r
ame4=i nput.t
imefr
ame( 120',ti
tle=,inl
ine=4',group=GRP1)
l
l
eftBars4=input.
int(
defv
al=7,t
itle=Left',
mi nval=2,max val
=20, gr
oup=GRP1,
i
nli
ne=4')
l
ri
ghtBars4=input.i
nt(
defval
=6,titl
e=Right',minv al
=2,max val=20,gr
oup=GRP1,
i
nli
ne=4',t
ool
ti
p="Highest/
lowestpoi ntinxr i
ghtandl eftbars."
)

/
/5
l
ti
mef r
ame5Show=i nput
.bool(
true,ti
tle=,inli
ne=5',group=GRP1)
l
ti
mef r
ame5=i nput.t
imefr
ame( 240',ti
tle=,inl
ine=5',group=GRP1)
l
l
eftBars5=input.
int(
defv
al=6,t
itle=Left',
mi nval=2,max val
=20, gr
oup=GRP1,
i
nli
ne=5')
l
ri
ghtBars5=input.i
nt(
defval
=6,titl
e=Right',minv al
=2,max val=20,gr
oup=GRP1,
i
nli
ne=5',t
ool
ti
p="Highest/
lowestpoi ntinxr i
ghtandl eftbars."
)

/
/6
l
ti
mef r
ame6Show=i nput
.bool(
true,ti
tle=,i
nli
ne=6',group=GRP1)
l
ti
mef r
ame6=i nput.t
imefr
ame( D',ti
tl
e=, i
nli
ne=6',gr
oup=GRP1)
l
l
eftBars6=input.
int(
defv
al=5,t
itle=Left'
,minval=2,max val
=20, gr
oup=GRP1,
i
nli
ne=6')
l
ri
ghtBars6=input.i
nt(
defval
=5,titl
e=Right'
,minv al
=2,max val=20,gr
oup=GRP1,
i
nli
ne=6',t
ool
ti
p="Highest/
lowestpoi ntinxr i
ghtandl eftbars."
)

varGRP2=" •••
•••
•••
•HI GHERTI MEFRAMES( >4HR)• ••
•••
••••"
//1
htimef r
ame1Show=i nput.
bool(true,ti
tl
e=, i
nli
ne=1',group=GRP2)
htimef r
ame1=i nput.t
imeframe( 480',t
it
le=,inl
ine=1',group=GRP2)
hleftBars1=input.
int(
defval=7,t
itle=Lef
t',minval=2,max val=20,gr
oup=GRP2,
i
nline=1')
hrightBars1=input.i
nt(
defval=7,titl
e=Ri
ght '
,minv al
=2, maxv al
=20,
group=GRP2, inl
ine=1',
toolt
ip="Highest/lowestpoi ntinxrightandlef
tbars.
")

//2
htimef r
ame2Show=i nput.
bool(true,ti
tl
e=, i
nli
ne=2',group=GRP2)
htimef r
ame2=i nput.t
imeframe( D',ti
tl
e=,inl
ine=2',group=GRP2)
hleftBars2=input.
int(
defval=7,t
itle=Left'
,minval=2,max val=20,gr
oup=GRP2,
i
nline=2')
hrightBars2=input.i
nt(
defval=7,titl
e=Right'
,minv al
=2, maxv al
=20,
group=GRP2, inl
ine=2',
toolt
ip="Highest/lowestpoi ntinxrightandlef
tbars.
")

//3
htimef r
ame3Show=i nput.
bool(true,ti
tl
e=, i
nli
ne=3'
,gr
oup=GRP2)
htimef r
ame3=i nput.t
imeframe( 3D',ti
tl
e=,inl
ine=3'
,gr
oup=GRP2)
hleftBars3=input.
int(
defval=7,t
itle=Left'
,minval
=2,maxval=20,gr
oup=GRP2,
i
nline=3')
hrightBars3=input.i
nt(
defval=6,titl
e=Right'
,minval
=2,maxv al
=20,
group=GRP2, inl
ine=3',
toolt
ip="Highest/lowestpointi
nxrightandlef
tbars.
")

//4
htimefr
ame4Show=i nput
.bool
(t
rue,ti
tle=,i
nli
ne=4'
,group=GRP2)
htimefr
ame4=input.
timefr
ame(W' ,
tit
le=,i
nli
ne=4'
,group=GRP2)
hleft
Bars4=i
nput.
int
(defv
al=7,
tit
le=Left'
,minval
=2,max val
=20,
group=GRP2,
i
nli
ne=4'
)
hr
ight
Bars4=i
nput.
int
(defv
al=6,t
it
le=Ri
ght'
,minv
al=2,maxv
al=20,
gr
oup=GRP2,i
nli
ne=4'
,tool
ti
p="Hi
ghest/
lowestpointi
nxri
ghtandlef
tbar
s."
)

//5
htimef r
ame5Show=i nput.
bool(true,ti
tle=,i
nli
ne=5'
,group=GRP2)
htimef r
ame5=i nput.t
imeframe( M' ,
tit
le=,i
nli
ne=5',
group=GRP2)
hleftBars5=input.
int(
defval=6,t
itle=Left'
,minval
=2,max val=20,gr
oup=GRP2,
i
nline=5')
hrightBars5=input.i
nt(
defval=6,titl
e=Right'
,minval
=2,max v al
=20,
group=GRP2, inl
ine=5',
toolt
ip="Highest /l
owestpointi
nxr ightandlef
tbars.
")

//6
htimef r
ame6Show=i nput.
bool(false,ti
tle=,
inl
ine=6'
,group=GRP2)
htimef r
ame6=i nput.t
imeframe( 2M' ,
tit
le=,i
nli
ne=6',
group=GRP2)
hleftBars6=input.
int(
defval=5,t
itl
e=Lef t'
,minval
=2,max val=20,gr
oup=GRP2,
i
nline=6')
hrightBars6=input.i
nt(
defval=5,ti
tle=Right'
,minval
=2, maxv al
=20,
group=GRP2, inl
ine=6',
toolt
ip="Highest/ l
owestpointinxrightandlef
tbars.
")

varGRP3=" •
•••
•••
•••Ot herSetti
ngs••
•••
•••
••"
hideLTF=input.bool(
true,"Hideli
nesl
owerthanenabl
edt
imef
rames?
",gr
oup
=GRP3)
//---
--
--
--
--
--
--I
NPUTS- ----
--
--
---
--
-

//--
---
--
--
--
--
--COLORSANDLENGTH- -
--
--
--
--
--
--
-
topColor1=color
.new(col
or.
red,70)
bottomColor1=color.
new(color
.gr
een,70)
l
ineLength1=6

topColor
2=color
.new(col
or.
red,60)
bottomColor
2=color.
new(color
.gr
een,
60)
l
ineLength2=10

topColor
3=color
.new(col
or.
red,50)
bottomColor
3=color.
new(color
.gr
een,
50)
l
ineLength3=10

topColor
4=color
.new(col
or.
red,40)
bottomColor
4=color.
new(color
.gr
een,
40)
l
ineLength4=10

topColor
5=color
.new(col
or.
red,30)
bottomColor
5=color.
new(color
.gr
een,
30)
l
i
neLengt
h5=15

topColor6=color
.new(col
or.
red,20)
bottomColor6=color.
new(color
.gr
een,20)
l
ineLength6=15
//--
---
--
--
--
--
--COLORSANDLENGTH- -
--
--
--
--
--
--
-

//-
--
--
--
--
--
--
--FUNCTIONS---
--
---
---
--
--
get
Pivot
Data(lb,r
b)=>
ph=t a.pi
vothi
gh(
lb,
rb)
phti
mest art=ph?ti
me[rb-1]:na

pl
=t a.
piv
otl
ow(l
b,r
b)
pl
ti
mestart=pl
?time[
rb-
1]:
na

[
ph,
pht
imest
art
,pl
,pl
ti
mest
art
]

getLineStyl
e(_
styl
e)=>
_li
nestyl
e=_ st
yle=="Soli
d"?li
ne.
sty
le_
sol
i
d:_
sty
le=="
Dashed"?
l
ine.styl
e_dashed:li
ne.
sty
le_dott
ed
_li
nestyl
e

resol
ut i
onInMinutes(t
f=" "
)=>
chartTf=timef r
ame. mult
ipl
ier*(ti
meframe.i
sseconds?1./60:
ti
mef rame.isminutes?1.: t
imeframe.i
sdail
y?60.*24: ti
mef r
ame.isweekl
y?
60.*24*7: t
imeframe.ismonthly?60.*24*30. 4375:na)
floatresul
t=t f==""?char t
Tf:request
.secur
it
y(syminf
o.t
icker
id,t
f,
chartTf)

f
_ti
meFrom( length,_uni
ts)=>
int_ti
meFr om =na
_unit=st r
.r
eplace_all
(_uni
ts,
s',
)
_ti
meFr om :=int(t
ime+r esol
uti
onI
nMi
nut
es(
)*60*1000*l
engt
h)
_ti
meFr om

not
LowerTi
mefr
ame(t
f)=>
_cond=hi
deLTF?resol
uti
onI
nMi
nut
es(
)<r
esol
uti
onI
nMi
nut
es(
tf):
true
_cond

/
/ ▓▒░░

generat
eText
(_n=5,_
lar
ge=f
alse)=>
_
symbol=" ░"
_
text=""
f
ori=_ nto0
_text:
=_text+""
f
ori=_ nto0
_text:
=_text+_symbol
i
f_l
arge
_text:
=_text+"\n"+_
text

_t
ext
/
/--
--
--
--
--
--
--
-FUNCTI
ONS-
--
--
--
--
--
--
--

i
sLt
f=r
esol
uti
onI
nMi
nut
es(
)<r
esol
uti
onI
nMi
nut
es(
"240"
)

//--
--
--
--
--
---
--Cal
culat
ePi v
ot s--
--
--
--
---
--
--
[
phchart,phti
mestart
chart,plchar
t,plt
imest
art
chart
]=
request
.securi
ty(
syminfo.t
ickeri
d,"5",
getPi
vot
Data(
6,6)
,lookahead=
barmerge.l
ookahead_on)

[
lph1,l
phti
mest art
1,l
pl1,
lpl
ti
mestart
1]=r equest.
securi
ty(
symi
nfo.
ti
cker
id,
l
timef
rame1, getPi
votDat
a(l
lef
tBar
s1,lr
ightBars1)
,lookahead=
barmerge.
lookahead_on)
[
lph2,l
phti
mest art
2,l
pl2,
lpl
ti
mestart
2]=r equest.
securi
ty(
symi
nfo.
ti
cker
id,
l
timef
rame2, getPi
votDat
a(l
lef
tBar
s2,lr
ightBars2)
,lookahead=
barmerge.
lookahead_on)
[
lph3,l
phti
mest art
3,l
pl3,
lpl
ti
mestart
3]=r equest.
securi
ty(
symi
nfo.
ti
cker
id,
l
timef
rame3, getPi
votDat
a(l
lef
tBar
s3,lr
ightBars3)
,lookahead=
barmerge.
lookahead_on)
[
lph4,l
phti
mest art
4,l
pl4,
lpl
ti
mestart
4]=r equest.
securi
ty(
symi
nfo.
ti
cker
id,
l
timef
rame4, getPi
votDat
a(l
lef
tBar
s4,lr
ightBars4)
,lookahead=
barmerge.
lookahead_on)
[
lph5,l
phti
mest art
5,l
pl5,
lpl
ti
mestart
5]=r equest.
securi
ty(
symi
nfo.
ti
cker
id,
l
timef
rame5, getPi
votDat
a(l
lef
tBar
s5,lr
ightBars5)
,lookahead=
barmerge.
lookahead_on)
[
lph6,l
phti
mest art
6,l
pl6,
lpl
ti
mestart
6]=r equest.
securi
ty(
symi
nfo.
ti
cker
id,
l
timef
rame6, getPi
votDat
a(l
lef
tBar
s6,lr
ightBars6)
,lookahead=
barmerge.
lookahead_on)

[
hph1,hphti
mestart
1,hpl
1,hplt
imestar
t1]=request
.secur
it
y(symi
nfo.
ti
cker
id,
hti
meframe1,get
Pivot
Data(
hleft
Bars1,hr
ight
Bars1)
, l
ookahead=
barmer
ge.l
ookahead_on)
[
hph2,hphti
mestart
2,hpl
2,hplt
imestar
t2]=request
.secur
it
y(symi
nfo.
ti
cker
id,
hti
meframe2,get
Pivot
Data(
hleft
Bars2,hr
ight
Bars2)
, l
ookahead=
barmer
ge.l
ookahead_on)
[
hph3,hphti
mestart
3,hpl
3,hplt
imestar
t3]=request
.secur
it
y(symi
nfo.
ti
cker
id,
hti
meframe3,get
Pivot
Data(
hleft
Bars3,hr
ight
Bars3)
, l
ookahead=
barmer
ge.l
ookahead_on)
[
hph4,hphti
mestart
4,hpl
4,hplt
imestar
t4]=request
.secur
it
y(symi
nfo.
ti
cker
id,
hti
meframe4,get
Pivot
Data(
hleft
Bars4,hr
ight
Bars4)
, l
ookahead=
barmer
ge.l
ookahead_on)
[
hph5,hphti
mestart
5,hpl
5,hplt
imestar
t5]=request
.secur
it
y(symi
nfo.
ti
cker
id,
hti
meframe5,get
Pivot
Data(
hleft
Bars5,hr
ight
Bars5)
, l
ookahead=
barmer
ge.l
ookahead_on)
[
hph6,hphti
mestart
6,hpl
6,hplt
imestar
t6]=request
.secur
it
y(symi
nfo.
ti
cker
id,
hti
meframe6,get
Pivot
Data(
hleft
Bars6,hr
ight
Bars6)
, l
ookahead=
barmer
ge.l
ookahead_on)

ph1=isLtf?lph1:hph1
pht
imestart
1=i sLtf?lpht
imest
art
1: hpht
imest
art
1
pl
1=isLtf?lpl1:hpl1
pl
ti
mestart1=isLtf?lplt
imest
art
1: hpl
ti
mestar
t1

ph2=isLtf?lph2:hph2
pht
imestart
2=i sLtf?lpht
imest
art
2: hpht
imest
art
2
pl
2=isLtf?lpl2:hpl2
pl
ti
mestart2=isLtf?lplt
imest
art
2: hpl
ti
mestar
t2

ph3=isLtf?lph3:hph3
pht
imestart
3=i sLtf?lpht
imest
art
3: hpht
imest
art
3
pl
3=isLtf?lpl3:hpl3
pl
ti
mestart3=isLtf?lplt
imest
art
3: hpl
ti
mestar
t3

ph4=isLtf?lph4:hph4
pht
imestart
4=i sLtf?lpht
imest
art
4: hpht
imest
art
4
pl
4=isLtf?lpl4:hpl4
pl
ti
mestart4=isLtf?lplt
imest
art
4: hpl
ti
mestar
t4

ph5=isLtf?lph5:hph5
pht
imestart
5=i sLtf?lpht
imest
art
5: hpht
imest
art
5
pl
5=isLtf?lpl5:hpl5
pl
ti
mestart5=isLtf?lplt
imest
art
5: hpl
ti
mestar
t5

ph6=isLtf?lph6:hph6
pht
imestart
6=i sLtf?lpht
imest
art
6: hpht
imest
art
6
pl
6=isLtf?lpl6:hpl6
pl
ti
mestart6=isLtf?lplt
imest
art
6: hpl
ti
mestar
t6

pi
vot
highchar
t=na(phchar
t[
1])andphchart?phchart:na
pi
vot
lowchart =na(pl
char
t[1]
)andplchar
t?plchart:na

pi
vot
high1=na(
ph1[
1])andph1?ph1:
na
pi
vot
low1 =na(
pl1[
1])andpl
1?pl
1:na

pi
vot
high2=na(
ph2[
1])andph2?ph2:na
pi
vot
low2 =na(pl
2[1]
)andpl2?pl
2:na

pi
vot
high3=na(
ph3[
1])andph3?ph3:na
pi
vot
low3 =na(pl
3[1]
)andpl3?pl
3:na

pi
vot
high4=na(
ph4[
1])andph4?ph4:na
pi
vot
low4 =na(pl
4[1]
)andpl4?pl
4:na

pi
vot
high5=na(
ph5[
1])andph5?ph5:na
pi
vot
low5 =na(pl
5[1]
)andpl5?pl
5:na

piv
othigh6=na(ph6[1]
)andph6?ph6: na
piv
otlow6 =na( pl
6[1]
)andpl6?pl6:na
//--
--
---
--
--
--
--Cal
cul
atePiv
ots-
---
--
--
--
--
--
-

/
/ -
---
--
--
--
--
--
-Addtoarr
ay- -
--
---
--
--
--
--
v
arf
loat[
]pi
vothi
ghs1=array.new_fl
oat
(0)
v
arf
loat[
]pi
votl
ows1=array.new_fl
oat(
0)

v
arf
loat
[]pi
vot
highs2=ar
ray
.new_
float
(0)
v
arf
loat
[]pi
vot
lows2=arr
ay.
new_f
loat(
0)

v
arf
loat
[]pi
vot
highs3=ar
ray
.new_
float
(0)
v
arf
loat
[]pi
vot
lows3=arr
ay.
new_f
loat(
0)

v
arf
loat
[]pi
vot
highs4=ar
ray
.new_
float
(0)
v
arf
loat
[]pi
vot
lows4=arr
ay.
new_f
loat(
0)

v
arf
loat
[]pi
vot
highs5=ar
ray
.new_
float
(0)
v
arf
loat
[]pi
vot
lows5=arr
ay.
new_f
loat(
0)

v
arf
loat[
]pi
vothi
ghs6=array.new_fl
oat
(0)
v
arf
loat[
]pi
votl
ows6=array.new_fl
oat(
0)
/
/ -
---
--
--
--
--
--
-Addtoarr
ay- -
--
---
--
--
--
--

//--
--
--
--
---
--
--Plotpivotpoi
nts----
--
---
--
--
--
//i
fbarstate.i
slast
// label.
new( bar_i
ndex,high,str
.t
ostr
ing(
resol
uti
onI
nMi
nut
es(
))+"
\n"
+
str
.t
ostri
ng(resoluti
onInMinutes("
3")))

/
/ONLYLOW TI
MEFRAME>3
showTimeframe1=isLtf?l
ti
meframe1Show:ht
imef
rame1Show
val
idTi
meframe1=isLtf?notLower
Timefr
ame(l
ti
mef
rame1):
notLower
Timeframe(ht
imef
rame1)

i
fshowTimef r
ame1andpi vot
highchar tandr esoluti
onInMi nutes()<=
r
esoluti
onInMinut
es("3"
)
l
abel.
new(phti
mest ar
tchart
, phchart,xl
oc=x l
oc.bar_ti
me,
t
ext=generat
eText(12),
styl
e=label.st
yle_none, t
extcolor=topCol or1)
i
fshowTimef r
ame1andpi vot
lowchar tandr esoluti
onInMi nutes()<=
r
esoluti
onInMinut
es("3"
)
l
abel.
new(plt
imestart
chart,plchart,
xloc=x l
oc.bar_ti
me,
t
ext=generat
eText(12),
styl
e=label.st
yle_none, t
extcolor=bottomCol or1)

/
/Timef r
ame1
i
fshowTimef r
ame1andpi v othi
gh1andv al
idTimeframe1
l
abel.
new(pht
imestart1,ph1,xl
oc=xl
oc.bar_ti
me,
t
ext=generat
eText(
li
neLengt h1)
,styl
e=l
abel.st
yle_
none,t
ext
col
or=t
opCol
or1)
i
fshowTimef r
ame1andpi v otl
ow1andv ali
dTimeframe1
l
abel.
new(pl
ti
mestart1,pl1,xl
oc=xl
oc.bar_t
ime,
t
ext=generat
eText(
li
neLengt h1)
,styl
e=l
abel.st
yle_
none,
t
extcolor
=bott
omCol or
1)

//Timefr
ame2
showTimeframe2=i sLtf?lti
mef rame2Show: hti
mef rame2Show
val
idTi
mef r
ame2=i sLtf?not LowerTimeframe( l
ti
mef rame2):
notLowerTi
mef rame( ht
imeframe2)
i
fshowTimef rame2andpi vothigh2andv al
idTimef rame2
l
abel.
new( pht
imest ar
t2,ph2, xl
oc=xl
oc.bar_ti
me,
text
=generateText(
li
neLengt h2),styl
e=l
abel.st
y l
e_none,text
color
=topCol
or2)
i
fshowTimef rame2andpi votlow2andv ali
dTimef rame2
l
abel.
new( pl
ti
mest art
2,pl2, xl
oc=xl
oc.bar_ti
me,
text
=generateText(
li
neLengt h2),styl
e=l
abel.st
y l
e_none,
text
color
=bot t
omCol or2)

//Timefr
ame3
showTimeframe3=i sLtf?lti
mef rame3Show: hti
mef rame3Show
val
idTi
mef r
ame3=i sLtf?not LowerTimeframe( l
ti
mef rame3):
notLowerTi
mef rame( ht
imeframe3)
i
fshowTimef rame3andpi vothigh3andv al
idTimef rame3
l
abel.
new( pht
imest ar
t3,ph3, xl
oc=xl
oc.bar_ti
me,
text
=generateText(
li
neLengt h3),styl
e=l
abel.st
y l
e_none,text
color
=topCol
or3)
i
fshowTimef rame3andpi votlow3andv ali
dTimef rame3
l
abel.
new( pl
ti
mest art
3,pl3, xl
oc=xl
oc.bar_ti
me,
text
=generateText(
li
neLengt h3),styl
e=l
abel.st
y l
e_none,
text
color
=bot t
omCol or3)
//Timefr
ame4
showTimeframe4=i sLtf?lti
mef rame4Show: hti
mef rame4Show
val
idTi
mef r
ame4=i sLtf?not LowerTimeframe( l
ti
mef rame4):
notLowerTi
mef rame( ht
imeframe4)
i
fshowTimef rame4andpi vothigh4andv al
idTimef rame4
l
abel.
new( pht
imest ar
t4,ph4, xl
oc=xl
oc.bar_ti
me,
text
=generateText(
li
neLengt h4),styl
e=l
abel.st
y l
e_none,text
color
=topCol
or4)
i
fshowTimef rame4andpi votlow4andv ali
dTimef rame4
l
abel.
new( pl
ti
mest art
4,pl4, xl
oc=xl
oc.bar_ti
me,
text
=generateText(
li
neLengt h4),styl
e=l
abel.st
y l
e_none,
text
color
=bot t
omCol or4)

//Timefr
ame5
showTimeframe5=i sLtf?lti
mef rame5Show: ht
imeframe5Show
val
idTi
mef r
ame5=i sLtf?not Lower Ti
mef rame( l
ti
mef r
ame5):
notLowerTi
mef rame( ht
imeframe5)
i
fshowTimef rame5andpi vothigh5andv al
idTimeframe5
l
abel.
new( phti
mest ar
t5,ph5, xl
oc=x l
oc.bar_ti
me,
text
=generateTex t
(li
neLengt h5, t
rue),
style=label
.styl
e_none,
text
color
=topCol or5)
i
fshowTimef rame5andpi votlow5andv ali
dTimef r
ame5
l
abel.
new( pl
timest art
5,pl5, xl
oc=xloc.bar_ti
me,
text
=generateTex t
(li
neLengt h5, t
rue),
style=label
.styl
e_none,
text
color
=bot t
omCol or5)

//Timeframe6
showTimef rame6=i sLtf?lti
mef rame6Show: ht
imeframe6Show
val
idTi
mef r
ame6=i sLtf?not Lower Ti
mef r
ame( l
ti
mef r
ame6):
notLowerTimef rame( ht
imeframe6)
i
fshowTi mef rame6andpi vothigh6andv alidTimeframe6
l
abel.new( phti
mest ar
t6,ph6, xl
oc=x loc.bar_ti
me,
text
=gener ateTex t
(li
neLengt h6, t
rue),styl
e=l abel
.styl
e_none,
text
color=topCol or6)
i
fshowTi mef rame6andpi votlow6andv alidTimef r
ame6
l
abel.new( pl
timest art
6,pl6, xl
oc=x l
oc.bar _ti
me,
text
=gener ateTex t
(li
neLengt h6, t
rue),styl
e=l abel
.styl
e_none,
text
color=bot t
omCol or6)
//-
---
--
---
--
---
-Plotpi votpoints- --
--
--
--
---
---

/
/--
--
--
--
--
--
--
-Equal
highs-
--
--
--
--
--
--
--

/
/WATERMARK
i
fbarstate.i
slast
_table=t able.
new("bottom_left
",1,
1)
table.cell
(_t
able,
0, 0,t
ex t
="@Nephew_Sam_
",t
ext
_si
ze=si
ze.
smal
l
,
t
ext_
col or=color
.new(color
.gray,50)
)

//Thi
ssourcecodei ssubj
ectt
othet
ermsoft
heMozi
l
laPubl
i
cLi
cense2.
0at
htt
ps:
//mozil
la.
org/MPL/2.
0/
//©protr
adingart

/
/@v
ersi
on=5

pi
vot
Leg=i
nput
.i
nt(
10,
"Pi
votLengt
h")

v
artop=ar
ray.
new_fl
oat
(na)
v
arbott
om =ar
ray.
new_f
loat
(na)

v
artopI
ndex=arr
ay.
new_int
(na)
v
arbott
omIndex=ar
ray.
new_ i
nt(
na)

ph=ta.pi
vot
high(
piv
otLeg,pi
vot
Leg)
pl=t
a.piv
otl
ow(pi
votLeg,pi
vot
Leg)

/
///
////
//////Top//
/ /
///
///
////
/////
i
fnotna(ph)
arr
ay.push(t
op,ph)
arr
ay.push(t
opI
ndex,bar_
index-pi
vot
Leg)

i
far
ray.
size(
top)>3
ar
ray.
shift
(top)
ar
ray.
shift
(topI
ndex)

/
///
////
//////Bott
om //
/////
/////
/////
//
i
fnotna(pl
)
arr
ay.push(bot
tom,pl)
arr
ay.push(bot
tomIndex,bar
_index-
piv
otLeg)

i
far
ray.
size(
bottom)>3
ar
ray.
shift
(bott
om)
ar
ray.
shift
(bott
omI
ndex)

i
nRange=ar r
ay.si
ze(t
op)>=3andar r
ay.si
ze(bott
om)>=3
/
///
////
////
/////
////
////
/TopCalcul
ation
/
///
////
////
/////
////
////
///
///
///
////
/////
////
/////
//
t
opPri
ce=0. 0
i
sTop=f al
se
i
finRange
t
opSt
art=ar
ray.
get(
topIndex,arr
ay.
size(
topI
ndex
)-1)
t
opPri
ce:
=array
.get
(top,arr
ay.si
ze(
top)-
1)

i
ftopPri
ce<ar r
ay.get
(top,ar
ray.si
ze(
top)-2)andarray.
get(
topI
ndex
,
ar
ray
.si
ze(t
opIndex)-
2)>array.
get(bott
omIndex ,arr
ay.
size(
bott
omIndex)
-3)
topPrice:
=ar r
ay.
get(t
op, ar
ray.
size(
top)-2)
topStart:
=array.
get(t
opIndex,ar
ray.
size(topI
ndex)-
2)

max_index=ar r
ay.i
ndexof(top,ar
r ay.
max(top))
i
ftopPrice<ar ray.
max (t
op)andar ray
.get
(topI
ndex
,max
_index)>
ar
ray
.get
(bottomI ndex,ar
ray.si
ze(bottomIndex)-3)
topPr ice:=arr
ay.max (t
op)
topSt art:=arr
ay.get
( t
opIndex, max_i
ndex)

i
sTop:=high>=topPri
ceandhigh[
1]<topPri
ceandlow<topPri
ceand
ar
ray
.get
(bot
tom,ar
ray.si
ze(
top)
-1)>ar
ray.
get(
bottom,
array
.si
ze(
top)
-2)

v
art
opEnd=0

i
fisTop
topEnd: =bar _i
ndex
topLine=l i
ne.new(x1=topSt art,y1=topPrice,x2=topEnd,y2=t
opPri
ce,
col
or=color.l
ime, wi dth=1)
topA=l abel .
new(x=topStart,y=topPr i
ce,text="Top1",
col
or=color.l
ime, sty l
e=label
.styl
e_label_down, textcolor=col
or.bl
ack,
si
ze=size.smal l
)
topB=l abel .new(x=topEnd, y=topPr i
ce,text="Top2",color
=col
or.
li
me,
sty
le=l
abel .
style_label_down, t
extcolor=col or.
black,size=si
ze.small
)
aler
t("Doubl eTopI n:"+str
.tostring(syminfo.ti
cker),
al
ert.
fr
eq_ once_ per_ bar_cl
ose)

//
/////
///
/////
///
///
///
//Bott
om Calcul
ati
on
//
/////
///
/////
///
///
///
///
///
////
///
/////
///
///
///
///
bott
omPr i
ce=0.0
i
sBottom =fal
se

i
finRange
bot
tomSt
art=ar
ray.
get(
bott
omIndex,arr
ay.
size(bot
tomIndex
)-1)
bot
tomPr
ice:
=array
.get
(bot
tom,arr
ay.si
ze(
bot t
om)-1)

i
fbottomPr ice>array
.get(
bot
tom,ar
ray.
size(
bot
tom)-
2)and
ar
ray
.get
(bottomI ndex,
arr
ay.si
ze(
bott
omIndex)
-2)>arr
ay.
get
(topI
ndex
,
ar
ray
.si
ze(topIndex)-
3)
bot
tomPr
ice:
=ar
ray.
get
(bot
tom,ar
ray
.si
ze(bottom)-
2)
bot
tomSt
art:
=ar
ray
.get
(bot
tomI
ndex,ar
ray
.size(bot
tomI
ndex
)-2)

min_index=arr ay.i
ndexof(bot t
om, ar
ray.min(
bottom))
i
fbot t
omPr i
ce>ar ray.
min( bottom)andar r
ay.get
(bott
omI
ndex,
min_
index)
>ar
ray.
get(topI
ndex ,
array.
size(topIndex)-3)
bottomPrice: =arr
ay.mi n(bottom)
bottomStar t:
=ar r
ay.get(bottomI ndex,min_i
ndex)

i
sBott
om :
=low<=bottomPri
ceandlow[1]>bot
tomPri
ceandhi
gh>
bott
omPr i
ceandarr
ay.
get
(top,
arr
ay.
size(
top)-
1)<ar
ray.
get
(top,
arr
ay.si
ze(
top)
-2)

v
arbot
tomEnd=0

i
fisBot t
om
bottomEnd: =bar _index
bottomLi ne=l i
ne. new( x1=bot t
omSt art,
y1=bottomPr ice,
x2=bottomEnd, y2=bottomPr i
ce,col or=col
or.
red, wi
dth=1)
bottomA=l abel.new( x=bot tomStart,y=bot
tomPr ice,text="Bottom 1"
,
col
or=color.red,styl
e=label .
style_label_up,
tex t
color
=color.black,size=size.
ti
ny)
bottomB=l abel.new( x=bot tomEnd, y=bott
omPr ice,text="Bottom 2",
col
or=color.red,styl
e=label .
style_label_up,
tex t
color
=color.black,size=size.
ti
ny)
alert(
"DoubleBot tom I n:"+st r
.t
ostr
ing(syminfo.
ticker),
al
ert.
fr
eq_ once_ per_bar_close)

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