New Text Document
New Text Document
if condition
count := 0
vol := 0.
else
if intraPrecision
if n > length
if array.size(v[length]) > 0
for [index, element] in v[length]
vol += array.get(llq[length], index) < top and
array.get(hlq[length], index) > btm ? element : 0
else
vol += low[length] < top and high[length] > btm ? volume[length] : 0
[count, vol]
if ta.crossover(target, filterValue)
lbl := label.new(x, y, str.tostring(vol, format.volume)
, style = lbl_style
, size = label_size
, color = #00000000
, textcolor = css)
if condition
if target[1] < filterValue[1]
line.delete(lvl[1])
else if not crossed[1]
line.set_x2(lvl, n - length)
if not crossed[1]
line.set_x2(lvl, n+3)
if ta.crossover(target, filterValue)
bx := box.new(x, top, x + count, btm
, border_color = na
, bgcolor = css)
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
//Pivot high
var float ph_top = na
var float ph_btm = na
var bool ph_crossed = na
var ph_x1 = 0
var box ph_bx = box.new(na,na,na,na
, bgcolor = color.new(topAreaCss, 80)
, border_color = na)
//Pivot low
var float pl_top = na
var float pl_btm = na
var bool pl_crossed = na
var pl_x1 = 0
var box pl_bx = box.new(na,na,na,na
, bgcolor = color.new(btmAreaCss, 80)
, border_color = na)
//-----------------------------------------------------------------------------}
//Display pivot high levels/blocks
//-----------------------------------------------------------------------------{
ph = ta.pivothigh(length, length)
//Get ph counts
[ph_count, ph_vol] = get_counts(ph, ph_top, ph_btm)
ph_x1 := n - length
ph_crossed := false
if ph_crossed
box.set_right(ph_bx, ph_x1)
else
box.set_right(ph_bx, n+3)
if showTop
//Set ph zone
set_zone(ph, ph_x1, ph_top, ph_btm, ph_count, ph_vol, topAreaCss)
//Set ph level
set_level(ph, ph_crossed, ph_top, ph_count, ph_vol, topCss)
//-----------------------------------------------------------------------------}
//Display pivot low levels/blocks
//-----------------------------------------------------------------------------{
pl = ta.pivotlow(length, length)
//Get pl counts
[pl_count, pl_vol] = get_counts(pl, pl_top, pl_btm)
pl_x1 := n - length
pl_crossed := false
if pl_crossed
box.set_right(pl_bx, pl_x1)
else
box.set_right(pl_bx, n+3)
if showBtm
//Set pl zone
set_zone(pl, pl_x1, pl_top, pl_btm, pl_count, pl_vol, btmAreaCss)
//Set pl level
set_level(pl, pl_crossed, pl_btm, pl_count, pl_vol, btmCss)
//Settings
//-----------------------------------------------------------------------------{
//Session A
show_sesa = input(true, '', inline = 'sesa', group = 'Session A')
sesa_txt = input('M?', '', inline = 'sesa', group = 'Session A')
sesa_ses = input.session('1959-2159', '', inline = 'sesa', group = 'Session A')
sesa_css = input.color(#ff5d00, '', inline = 'sesa', group = 'Session A')
sesa_range = input(true, 'Range', inline = 'sesa_overlays', group = 'Session A')
sesa_maxmin = input(false, 'Max/Min', inline = 'sesa_overlays', group = 'Session
A')
//Timezones
tz_incr = input.int(7, 'UTC (+/-)', group = 'Timezone')
use_exchange = input(false, 'Use Exchange Timezone', group = 'Timezone')
//Ranges Options
bg_transp = input.float(90, 'Range Area Transparency', group = 'Ranges Settings')
show_outline = input(true, 'Range Outline', group = 'Ranges Settings')
show_txt = input(true, 'Range Label', group = 'Ranges Settings')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Set session range
get_range(session, session_name, session_css)=>
var t = 0
var max = high
var min = low
var box bx = na
var label lbl = na
if session > session[1]
t := time
max := high
min := low
if show_txt
lbl := label.new(t, max, session_name
, xloc = xloc.bar_time
, textcolor = session_css
, style = label.style_label_down
, color = color.new(color.white, 100)
, size = size.tiny)
box.set_top(bx, max)
box.set_rightbottom(bx, n, min)
if show_txt
label.set_xy(lbl, int(math.avg(t, time)), max)
//-----------------------------------------------------------------------------}
//Sessions
//-----------------------------------------------------------------------------{
tf = timeframe.period
var tz = use_exchange ? syminfo.timezone :
str.format('UTC{0}{1}', 7 >= 0 ? '+' : '-', math.abs(7))
int tempTime = 0
timeinrange(res, sess) =>
time(res, sess,timezone) != 0
_resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60. :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 1440. :
timeframe.isweekly ? 10080. :
timeframe.ismonthly ? 43800. : na)
//--khaibao--//
var extending1 = 15
if extendLeft1
extending1 := 200
if(showTime9)
tempTime := timeDay + (hourTime9*3600 + minuteTime9*60)*1000
if (time == tempTime)
array.push(zoneskupo, box.new(left=bar_index , top = high,
right=bar_index + extending1 , bottom = low ,extend=extend.none , bgcolor= col,
border_width=0,
text =lb9, text_size = size.small, text_halign = text.align_right,
text_valign = text.align_center, text_color = coltex, text_font_family =
font.family_monospace))
alert('Entry Time', alert.freq_once_per_bar)
if array.size(zoneskupo) > numberOfZonesInput
box.delete(array.shift(zoneskupo))
//-- Gian
//-----Input-------
customTF = input.timeframe(defval="",title = "Show Other TimeFrame")
GroupGann = "Gann"
showGann = input.bool(true, 'Show Gann/Style', group = GroupGann,inline =
"Gann/Style")
lineGann = input.string(title="",options=['(─)', '(╌)', '(┈)'],defval='(╌)', group
= GroupGann, inline = "Gann/Style")
lineStyleGann = lineGann == "(┈)" ? line.style_dotted : lineGann == "(╌)" ?
line.style_dashed : line.style_solid
colorGann = input.color(color.white, 'Color/Width', group = GroupGann, inline =
"Color/Width")
widthGann = input.int(defval=1,title = "",minval=1, step=1, group = GroupGann,
inline = "Color/Width")
ignoreISB = input.bool(true, 'Ignore Inside Bar', group = GroupGann, inline =
"ignoreISB")
GroupSGann = "Swing of Gann"
showSGann = input.bool(true, 'Show Swing/Style', group = GroupSGann, inline =
"Swing/Style")
lineSGann = input.string(title="",options=["(─)", "(╌)", "(┈)"],defval="(─)", group
= GroupSGann, inline = "Swing/Style")
lineStyleSGann = lineSGann == "(┈)" ? line.style_dotted : lineSGann == "(╌)" ?
line.style_dashed : line.style_solid
colorSGann = input.color(color.aqua, 'Color/Width', group = GroupSGann, inline =
"Color/Width")
widthSGann = input.int(defval=1,title = "",minval=1,step=1, group = GroupSGann,
inline = "Color/Width")
showChoCh = input.bool(false, 'Show ChoCh', group = GroupSGann,inline = "Choch")
show2ChoCh = input.bool(true, 'Show 2Choch/Color', group = GroupSGann,inline =
"2Choch")
color2Choch = input.color(color.aqua, '', group = GroupSGann,inline = "2Choch")
showLabel = input.bool(true, 'Show Label TimeFrame',group = GroupSGann)
//////////////////////////Global//////////////////////////
var arrayLineTemp = array.new_line()
// Converts a resolution expressed in minutes into a string usable by "security()"
f_resFromMinutes(_minutes) =>
_minutes < 1 ? str.tostring(math.round(_minutes*60)) + "S" :
_minutes < 60 ? str.tostring(math.round(_minutes)) + "m" :
_minutes < 1440 ? str.tostring(math.round(_minutes/60)) + "H" :
_minutes < 10080 ? str.tostring(math.round(math.min(_minutes / 1440,
7))) + "D" :
_minutes < 43800 ? str.tostring(math.round(math.min(_minutes /
10080, 4))) + "W" :
str.tostring(math.round(math.min(_minutes / 43800, 12))) + "M"
secondCustomTF =
request.security(syminfo.tickerid,customTF,timeframe.in_seconds(),lookahead=barmerg
e.lookahead_on)
_high =
request.security(syminfo.tickerid,customTF,high,lookahead=barmerge.lookahead_on)
_low =
request.security(syminfo.tickerid,customTF,low,lookahead=barmerge.lookahead_on)
_close =
request.security(syminfo.tickerid,customTF,close,lookahead=barmerge.lookahead_on)
_open =
request.security(syminfo.tickerid,customTF,open,lookahead=barmerge.lookahead_on)
highPrev = _high
lowPrev = _low
// drawLineGann => 2:Tiếp tục 1:Đảo chiều; // Outsidebar 2:Tiếp tục 3:Tiếp tục và
Đảo chiều 4 : Đảo chiều 2 lần
drawLineGann := 0
if(_high[0] > highPrev[1] and _low[0] > lowPrev[1])
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(_high[0] > array.get(arrayYGann,0))
if(_high[0] <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high[0])
drawLineGann := 2
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
drawLineGann := 1
else if(_high[0] < highPrev[1] and _low[0] < lowPrev[1])
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
drawLineGann := 1
else
if(_low[0] < array.get(arrayYGann,0))
if(_low[0] >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low[0])
drawLineGann := 2
else if((_high[0] >= highPrev[1] and _low[0] < lowPrev[1]) or (_high[0] >
highPrev[1] and _low[0] <= lowPrev[1]))
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(_high[0] >= array.get(arrayYGann,0) and array.get(arrayYGann,1) <=
_low[0])
if(_high[0] <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high[0])
drawLineGann := 2
else if(_high[0] >= array.get(arrayYGann,0) and array.get(arrayYGann,1) >=
_low[0])
if(_close < _open)
if(_high[0] <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
drawLineGann := 3
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
drawLineGann := 4
else if(array.get(arrayYGann,0) < array.get(arrayYGann,1))
if(_low[0] <= array.get(arrayYGann,0) and _high[0] <=
array.get(arrayYGann,1))
if(_low[0] >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low[0])
drawLineGann := 2
else if(_low[0] <= array.get(arrayYGann,0) and _high[0] >=
array.get(arrayYGann,1))
if(_close > _open)
if(_low[0] >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
drawLineGann := 3
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
drawLineGann := 4
else if((_high[0] <= highPrev[1] and _low[0] >= lowPrev[1]) and ignoreISB)
highPrev := highPrev[1]
lowPrev := lowPrev[1]
if(timeframe.in_seconds() < secondCustomTF and drawLineGann == 0)
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(array.get(arrayYGann,0) <= high)
array.set(arrayXGann, 0, time)
drawLineGann := 2
else
if(array.get(arrayYGann,0) >= low)
array.set(arrayXGann, 0, time)
drawLineGann := 2
if(showGann and timeframe.in_seconds() <= secondCustomTF)
if(drawLineGann == 2)
if(array.size(arrayLineGann) >0)
line.set_xy2(array.get(arrayLineGann,0),array.get(arrayXGann,0),array.get(arrayYGan
n,0))
else
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1
),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleGann))
else if(drawLineGann == 1)
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1
),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleGann))
else if(drawLineGann == 3)
if(array.size(arrayLineGann) >0)
line.set_xy2(array.get(arrayLineGann,0),array.get(arrayXGann,1),array.get(arrayYGan
n,1))
else
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,2),array.get(arrayYGann,2
),array.get(arrayXGann,1),array.get(arrayYGann,1), color = colorGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleGann))
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1
),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleGann))
else if(drawLineGann == 4)
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,2),array.get(arrayYGann,2
),array.get(arrayXGann,1),array.get(arrayYGann,1), color = colorGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleGann))
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1
),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleGann))
//////////////////////////Swing Gann//////////////////////////
var arrayXSGann = array.new_int(5,time)
var arrayYSGann = array.new_float(5,close)
var arrayLineSGann = array.new_line()
int drawLineSGann = 0
int drawLineSGann1 = 0
bool runCheckChoChSGann = false
runCheckChoChSGann := runCheckChoChSGann[1]
if(showSGann)
if(math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1)) <
math.min(array.get(arrayYGann,0),array.get(arrayYGann,1)) or
math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1)) >
math.max(array.get(arrayYGann,0),array.get(arrayYGann,1)))
//Khởi tạo bắt đầu
drawLineSGann1 := 5
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
array.set(arrayYSGann, 0, array.get(arrayYGann,1))
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
// drawLineSGann kiểm tra điểm 1 => 13:Tiếp tục có sóng hồi // 12|
19(reDraw):Tiếp tục không có sóng hồi // 14:Đảo chiều
if(array.get(arrayXGann,0) == array.get(arrayXGann,1))
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,2) and
array.get(arrayYSGann,0) != array.get(arrayYGann,1) and ((array.get(arrayYGann,1) >
array.get(arrayYGann,2) and array.get(arrayYSGann,0) > array.get(arrayYSGann,1)) or
(array.get(arrayYGann,1) < array.get(arrayYGann,2) and array.get(arrayYSGann,0) <
array.get(arrayYSGann,1))))
drawLineSGann1 := 12
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
array.set(arrayYSGann, 0, array.get(arrayYGann,1))
else if(array.get(arrayXSGann,0) <= array.get(arrayXGann,2))
if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and
array.get(arrayYGann,1) < array.get(arrayYSGann,1)) or (array.get(arrayYSGann,0) <
array.get(arrayYSGann,1) and array.get(arrayYGann,1) > array.get(arrayYSGann,1)))
drawLineSGann1 := 14
runCheckChoChSGann := true
array.unshift(arrayXSGann,array.get(arrayXGann,1))
array.unshift(arrayYSGann,array.get(arrayYGann,1))
else if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and
array.get(arrayYGann,1) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) <
array.get(arrayYSGann,1) and array.get(arrayYGann,1) < array.get(arrayYSGann,0)))
drawLineSGann1 := 13
_max =
math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_min =
math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_max_idx = 0
_min_idx = 0
for i = 2 to array.size(arrayXGann)
if(array.get(arrayXSGann,0) >=
array.get(arrayXGann,i))
break
if(_min > array.get(arrayYGann,i))
_min := array.get(arrayYGann,i)
_min_idx := array.get(arrayXGann,i)
if(_max < array.get(arrayYGann,i))
_max := array.get(arrayYGann,i)
_max_idx := array.get(arrayXGann,i)
if(array.get(arrayYSGann,0) > array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_min_idx)
array.unshift(arrayYSGann,_min)
else if(array.get(arrayYSGann,0) <
array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_max_idx)
array.unshift(arrayYSGann,_max)
array.unshift(arrayXSGann,array.get(arrayXGann,1))
array.unshift(arrayYSGann,array.get(arrayYGann,1))
line.set_xy2(array.get(arrayLineSGann,0),array.get(arrayXSGann,0),array.get(arrayYS
Gann,0))
else
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGan
n,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann1 == 14)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGan
n,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann1 == 13)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGan
n,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGan
n,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
if(runCheckChoChSGann)
runCheckChoChSGann := false
// ChoCh Trường hợp chữ N ngược, chữ N
if((array.get(arrayYSGann,3) > array.get(arrayYSGann,2) and
array.get(arrayYSGann,3) < array.get(arrayYSGann,1) and array.get(arrayYSGann,0) <
array.get(arrayYSGann,2)) or (array.get(arrayYSGann,3) < array.get(arrayYSGann,2)
and array.get(arrayYSGann,3) > array.get(arrayYSGann,1) and
array.get(arrayYSGann,0) > array.get(arrayYSGann,2)))
alert(syminfo.ticker + " : " + timeframe.period + "
=> Swing of Gann ChoCh" + (array.get(arrayYSGann,0) > array.get(arrayYSGann,1) ? "+
⇑" : "- ⇓"))
if(showChoCh)
array.unshift(arrayLineChoCh,line.new(x1=
array.get(arrayXSGann,2) , y1=array.get(arrayYSGann,2),x2=array.get(arrayXSGann,0),
y2=array.get(arrayYSGann,2),color = colorSGann,xloc = xloc.bar_time,style =
line.style_dotted))
// ChoCh 2 Đầu Trường hợp chữ N ngược, chữ N
if(show2ChoCh and ((array.get(arrayYSGann,1) >
array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,4)
and array.get(arrayYSGann,4) > array.get(arrayYSGann,2) and
array.get(arrayYSGann,2) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) >
array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,4)
and array.get(arrayYSGann,4) > array.get(arrayYSGann,3) and
array.get(arrayYSGann,3) > array.get(arrayYSGann,1))))
line.set_width(array.get(arrayLineSGann,1),widthGann
+ 1)
line.set_style(array.get(arrayLineSGann,1),line.style_dashed)
line.set_color(array.get(arrayLineSGann,1),color2Choch)
alert('Choc2d', alert.freq_once_per_bar)
// drawLineSGann kiểm tra điểm 0 => 3:Tiếp tục có sóng hồi // 2|
9(reDraw):Tiếp tục không có sóng hồi // 4:Đảo chiều
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,1) and
array.get(arrayYSGann,0) != array.get(arrayYGann,0) and ((array.get(arrayYGann,0) >
array.get(arrayYGann,1) and array.get(arrayYSGann,0) > array.get(arrayYSGann,1)) or
(array.get(arrayYGann,0) < array.get(arrayYGann,1) and array.get(arrayYSGann,0) <
array.get(arrayYSGann,1))))
drawLineSGann := 2
array.set(arrayXSGann, 0, array.get(arrayXGann,0))
array.set(arrayYSGann, 0, array.get(arrayYGann,0))
else if(array.get(arrayXSGann,0) <= array.get(arrayXGann,1))
if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and
array.get(arrayYGann,0) < array.get(arrayYSGann,1)) or (array.get(arrayYSGann,0) <
array.get(arrayYSGann,1) and array.get(arrayYGann,0) > array.get(arrayYSGann,1)))
drawLineSGann := 4
runCheckChoChSGann := true
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
else if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and
array.get(arrayYGann,0) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) <
array.get(arrayYSGann,1) and array.get(arrayYGann,0) < array.get(arrayYSGann,0)))
drawLineSGann := 3
_max =
math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_min =
math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_max_idx = 0
_min_idx = 0
for i = 1 to array.size(arrayXGann)
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,i))
break
if(_min > array.get(arrayYGann,i))
_min := array.get(arrayYGann,i)
_min_idx := array.get(arrayXGann,i)
if(_max < array.get(arrayYGann,i))
_max := array.get(arrayYGann,i)
_max_idx := array.get(arrayXGann,i)
if(array.get(arrayYSGann,0) > array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_min_idx)
array.unshift(arrayYSGann,_min)
else if(array.get(arrayYSGann,0) < array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_max_idx)
array.unshift(arrayYSGann,_max)
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGan
n,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann == 4)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGan
n,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann == 3)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGan
n,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGan
n,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc =
xloc.bar_time,width = widthGann,style=lineStyleSGann))
if(runCheckChoChSGann)
runCheckChoChSGann := false
// ChoCh Trường hợp chữ N ngược, chữ N
if((array.get(arrayYSGann,3) > array.get(arrayYSGann,2) and
array.get(arrayYSGann,3) < array.get(arrayYSGann,1) and array.get(arrayYSGann,0) <
array.get(arrayYSGann,2)) or (array.get(arrayYSGann,3) < array.get(arrayYSGann,2)
and array.get(arrayYSGann,3) > array.get(arrayYSGann,1) and
array.get(arrayYSGann,0) > array.get(arrayYSGann,2)))
alert(syminfo.ticker + " : " + timeframe.period + " =>
Swing of Gann ChoCh" + (array.get(arrayYSGann,0) > array.get(arrayYSGann,1) ? "+ ⇑"
: "- ⇓"))
if(showChoCh)
array.unshift(arrayLineChoCh,line.new(x1=
array.get(arrayXSGann,2) , y1=array.get(arrayYSGann,2),x2=array.get(arrayXSGann,0),
y2=array.get(arrayYSGann,2),color = colorSGann,xloc = xloc.bar_time,style =
line.style_dotted))
// ChoCh 2 Đầu Trường hợp chữ N ngược, chữ N
if(show2ChoCh and ((array.get(arrayYSGann,1) >
array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,4)
and array.get(arrayYSGann,4) > array.get(arrayYSGann,2) and
array.get(arrayYSGann,2) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) >
array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,4)
and array.get(arrayYSGann,4) > array.get(arrayYSGann,3) and
array.get(arrayYSGann,3) > array.get(arrayYSGann,1))))
line.set_width(array.get(arrayLineSGann,1),widthGann+1)
line.set_style(array.get(arrayLineSGann,1),line.style_dashed)
line.set_color(array.get(arrayLineSGann,1),color2Choch)
alert('Choc2d', alert.freq_once_per_bar)
///////////////////////Other//////////////////////////////////
if(timeframe.in_seconds() <= secondCustomTF)
if(showSGann)
if(showLabel and (barstate.islast or barstate.islastconfirmedhistory))
texLabel = timeframe.in_seconds() == secondCustomTF ?
f_resFromMinutes(timeframe.in_seconds()/60) : f_resFromMinutes(secondCustomTF/60)
label.set_xy(labelTF,array.get(arrayXSGann,0),array.get(arrayYSGann,0))
label.set_text(labelTF,texLabel)
label.set_style(labelTF,array.get(arrayYSGann,0) <
array.get(arrayYSGann,1) ? label.style_label_upper_right :
label.style_label_lower_right)
else if(showGann)
if(showLabel and (barstate.islast or barstate.islastconfirmedhistory))
texLabel = timeframe.in_seconds() == secondCustomTF ?
f_resFromMinutes(timeframe.in_seconds()/60) : f_resFromMinutes(secondCustomTF/60)
label.set_xy(labelTF,array.get(arrayXGann,0),array.get(arrayYGann,0))
label.set_text(labelTF,texLabel)
label.set_style(labelTF,array.get(arrayYGann,0) <
array.get(arrayYGann,1) ? label.style_label_upper_right :
label.style_label_lower_right)
if(showSGann and showGann and array.size(arrayLineGann) > 9 and
array.size(arrayLineSGann) > 9 and drawLineGann != 2 and drawLineSGann != 2 and
drawLineSGann != 9 and drawLineSGann != 12 and drawLineSGann != 19)
for i = 1 to 9
if(line.get_x1(array.get(arrayLineGann,i)) ==
line.get_x1(array.get(arrayLineSGann,0)) and
line.get_y1(array.get(arrayLineGann,i)) == line.get_y1(array.get(arrayLineSGann,0))
and line.get_x2(array.get(arrayLineGann,i)) ==
line.get_x2(array.get(arrayLineSGann,0)) and
line.get_y2(array.get(arrayLineGann,i)) ==
line.get_y2(array.get(arrayLineSGann,0)))
line.delete(array.get(arrayLineGann,i))
array.remove(arrayLineGann,i)
break
else if(line.get_x1(array.get(arrayLineGann,i)) ==
line.get_x1(array.get(arrayLineSGann,1)) and
line.get_y1(array.get(arrayLineGann,i)) == line.get_y1(array.get(arrayLineSGann,1))
and line.get_x2(array.get(arrayLineGann,i)) ==
line.get_x2(array.get(arrayLineSGann,1)) and
line.get_y2(array.get(arrayLineGann,i)) ==
line.get_y2(array.get(arrayLineSGann,1)))
line.delete(array.get(arrayLineGann,i))
array.remove(arrayLineGann,i)
break
else if(line.get_x1(array.get(arrayLineGann,i)) ==
line.get_x1(array.get(arrayLineSGann,2)) and
line.get_y1(array.get(arrayLineGann,i)) == line.get_y1(array.get(arrayLineSGann,2))
and line.get_x2(array.get(arrayLineGann,i)) ==
line.get_x2(array.get(arrayLineSGann,2)) and
line.get_y2(array.get(arrayLineGann,i)) ==
line.get_y2(array.get(arrayLineSGann,2)))
line.delete(array.get(arrayLineGann,i))
array.remove(arrayLineGann,i)
break
// ema
len = input.int(21, minval=1, title="Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500, display =
display.data_window)
out = ta.ema(src, len)
plot(out, title="EMA", color=color.blue, offset=offset)