0% found this document useful (0 votes)
26 views20 pages

New Text Document

This document is a TradingView Pine Script that defines an indicator for plotting swing highs and lows, volume analysis, and session ranges on price charts. It includes customizable parameters for visual styles, filtering options, and session settings, allowing users to analyze market behavior effectively. The script also incorporates alerts for significant volume changes and provides the ability to display specific time markers on the chart.

Uploaded by

s2.cauchu
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)
26 views20 pages

New Text Document

This document is a TradingView Pine Script that defines an indicator for plotting swing highs and lows, volume analysis, and session ranges on price charts. It includes customizable parameters for visual styles, filtering options, and session settings, allowing users to analyze market behavior effectively. The script also incorporates alerts for significant volume changes and provides the ability to display specific time markers on the chart.

Uploaded by

s2.cauchu
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/ 20

//@version=5

indicator("Inid_1", overlay = true, max_lines_count = 500, max_labels_count = 500,


max_boxes_count = 500)

length = input(6, 'Pivot Lookback')


area = input.string('Wick Extremity', 'Swing Area', options = ['Wick Extremity',
'Full Range'])
intraPrecision = input(false, 'Intrabar Precision', inline = 'intrabar')
intrabarTf = input.timeframe('1', '' , inline = 'intrabar')
filterOptions = input.string('Count', 'Filter Areas By', options = ['Count',
'Volume'], inline = 'filter')
filterValue = input.float(0, '' ,
inline = 'filter')
//Style
showTop = input(true, 'Swing High' , inline = 'top', group =
'Style')
topCss = input(color.red, '' , inline = 'top', group =
'Style')
topAreaCss = input(color.new(color.red, 50), 'Area', inline = 'top', group =
'Style')
showBtm = input(true, 'Swing Low' , inline = 'btm', group =
'Style')
btmCss = input(color.teal, '' , inline = 'btm', group =
'Style')
btmAreaCss = input(color.new(color.teal, 50), 'Area', inline = 'btm', group =
'Style')
labelSize = input.string('Tiny', 'Labels Size', options = ['Tiny', 'Small',
'Normal'], group = 'Style')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index
get_data()=> [high, low, volume]
[hlq, llq, v] = request.security_lower_tf(syminfo.tickerid, intrabarTf, get_data())
get_counts(condition, top, btm)=>
var count = 0
var vol = 0.

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 += low[length] < top and high[length] > btm ? 1 : 0

[count, vol]

set_label(count, vol, x, y, css, lbl_style)=>


var label lbl = na
var label_size = switch labelSize
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal

target = switch filterOptions


'Count' => count
'Volume' => 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 target > filterValue


label.set_text(lbl, str.tostring(vol, format.volume))

set_level(condition, crossed, value, count, vol, css)=>


var line lvl = na

target = switch filterOptions


'Count' => count
'Volume' => vol

if condition
if target[1] < filterValue[1]
line.delete(lvl[1])
else if not crossed[1]
line.set_x2(lvl, n - length)

lvl := line.new(n - length, value, n, value


, color = na )

if not crossed[1]
line.set_x2(lvl, n+3)

if crossed and not crossed[1]


line.set_x2(lvl, n)
line.set_style(lvl, line.style_dashed)
alert('Pha LQ', alert.freq_once_per_bar)
if target > filterValue
line.set_color(lvl, css)

set_zone(condition, x, top, btm, count, vol, css)=>


var box bx = na

target = switch filterOptions


'Count' => count
'Volume' => vol

if ta.crossover(target, filterValue)
bx := box.new(x, top, x + count, btm
, border_color = na
, bgcolor = css)

if target > filterValue


box.set_right(bx, x + count)

//-----------------------------------------------------------------------------}
//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)

//Set ph area and level


if ph and showTop
ph_top := high[length]
ph_btm := switch area
'Wick Extremity' => math.max(close[length], open[length])
'Full Range' => low[length]

ph_x1 := n - length
ph_crossed := false

box.set_lefttop(ph_bx, ph_x1, ph_top)


box.set_rightbottom(ph_bx, ph_x1, ph_btm)
else
ph_crossed := close > ph_top ? true : ph_crossed

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)

//Set pl area and level


if pl and showBtm
pl_top := switch area
'Wick Extremity' => math.min(close[length], open[length])
'Full Range' => high[length]
pl_btm := low[length]

pl_x1 := n - length
pl_crossed := false

box.set_lefttop(pl_bx, pl_x1, pl_top)


box.set_rightbottom(pl_bx, pl_x1, pl_btm)
else
pl_crossed := close < pl_btm ? true : pl_crossed

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

bx := box.new(n, max, n, min


, bgcolor = color.new(session_css, bg_transp)
, border_color = show_outline ? session_css : na
, border_style = line.style_dotted)

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)

if session and session == session[1]


max := math.max(high, max)
min := math.min(low, min)

box.set_top(bx, max)
box.set_rightbottom(bx, n, min)

if show_txt
label.set_xy(lbl, int(math.avg(t, time)), max)

[session ? na : max, session ? na : min]

//-----------------------------------------------------------------------------}
//Sessions
//-----------------------------------------------------------------------------{
tf = timeframe.period
var tz = use_exchange ? syminfo.timezone :
str.format('UTC{0}{1}', 7 >= 0 ? '+' : '-', math.abs(7))

is_sesa = math.sign(nz(time(tf, sesa_ses, tz)))


//-----------------------------------------------------------------------------}
//Overlays
//-----------------------------------------------------------------------------{
var float max_sesa = na
var float min_sesa = na
//Ranges
if show_sesa and sesa_range
[max, min] = get_range(is_sesa, sesa_txt, sesa_css)
max_sesa := max
min_sesa := min
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
//Plot max/min
plot(sesa_maxmin ? max_sesa : na, 'Session A Maximum', sesa_css, 1,
plot.style_linebr)
plot(sesa_maxmin ? min_sesa : na, 'Session A Minimum', sesa_css, 1,
plot.style_linebr)
//-- high Volume --
// Code ----------------------------------------------------Hight Volume ///
bearishcolor = input(#e9da09, "Màu Hight Vol", group="Ch?nh M?u", inline = "4")
vr = input.int(defval=100, title='Volume Ratio', minval=1)
createalert = input(false, "Create Alerts")
// Variables
hv = ta.highest(volume, vr)
vabs = volume * 100 / hv * 4 / 5
smoothing = ta.ema(vabs, 21)
equal = vabs - smoothing
cz = ta.highest(equal, vr) * 0.618
cum = equal > 0 and equal >= cz
volbeardir = close < open
volbulldir = close > open
// Calculations
bearvol = volbeardir and cum ? -1 : 0
bullvol = volbulldir and cum ? 1 : 0
// Plot volume indication
barcolor(bullvol ? bearishcolor : bearvol? bearishcolor : na, title = "Màu High
Vol")

timezone = input.string(defval = "GMT+7", title = "Time zone", inline = "Zone")


numberOfZonesInput = input.int(10, "# Zones", group="Cản", inline = "Zone")
extendLeft1 = input.bool(title="extend ", defval=false, group="Cản", inline =
"Zone")
col = input.color(color.white, ' box', inline = "zone")
coltex = input.color(color.white, ' Text', inline = "zone")
//---
showTime = input.bool(true, 'HH:MM/Color',inline = "Time")
hourTime = input.int(defval=08,title = "",inline = "Time")
minuteTime = input.int(defval=30,title = "",inline = "Time")
lb= input.string(defval = "8h30" ,title="Text",inline = "Time")
//----
showTime1 = input.bool(true, 'HH:MM/Color',inline = "Time1")
hourTime1 = input.int(defval=09,title = "",inline = "Time1")
minuteTime1 = input.int(defval=00,title = "",inline = "Time1")
lb1= input.string(defval = "9h" ,title="Text",inline = "Time1")
//----
showTime2 = input.bool(true, 'HH:MM/Color',inline = "Time2")
hourTime2 = input.int(defval=12,title = "",inline = "Time2")
minuteTime2 = input.int(defval=30,title = "",inline = "Time2")
lb2= input.string(defval = "12h30" ,title="Text",inline = "Time2")
//----
showTime3 = input.bool(true, 'HH:MM/Color',inline = "Time3")
hourTime3 = input.int(defval=13,title = "",inline = "Time3")
minuteTime3 = input.int(defval=00,title = "",inline = "Time3")
lb3= input.string(defval = "13h" ,title="Text",inline = "Time3")
//----
showTime4 = input.bool(true, 'HH:MM/Color',inline = "Time4")
hourTime4 = input.int(defval=14,title = "",inline = "Time4")
minuteTime4 = input.int(defval=30,title = "",inline = "Time4")
lb4= input.string(defval = "14h30" ,title="Text",inline = "Time4")
//----
showTime5 = input.bool(true, 'HH:MM/Color',inline = "Time5")
hourTime5 = input.int(defval=16,title = "",inline = "Time5")
minuteTime5 = input.int(defval=30,title = "",inline = "Time5")
lb5= input.string(defval = "16h30" ,title="Text",inline = "Time5")
//----
showTime6 = input.bool(true, 'HH:MM/Color',inline = "Time6")
hourTime6 = input.int(defval=19,title = "",inline = "Time6")
minuteTime6 = input.int(defval=30,title = "",inline = "Time6")
lb6= input.string(defval = "19h30" ,title="Text",inline = "Time6")
//----
showTime7 = input.bool(true, 'HH:MM/Color',inline = "Time7")
hourTime7 = input.int(defval=20,title = "",inline = "Time7")
minuteTime7 = input.int(defval=30,title = "",inline = "Time7")
lb7= input.string(defval = "20h30" ,title="Text",inline = "Time7")
//----
showTime8 = input.bool(true, 'HH:MM/Color',inline = "Time8")
hourTime8 = input.int(defval=00,title = "",inline = "Time8")
minuteTime8 = input.int(defval=30,title = "",inline = "Time8")
lb8= input.string(defval = "00h30" ,title="Text",inline = "Time8")
//----
showTime9 = input.bool(true, 'HH:MM/Color',inline = "Time9")
hourTime9 = input.int(defval=07,title = "",inline = "Time9")
minuteTime9 = input.int(defval=00,title = "",inline = "Time9")
lb9= input.string(defval = "07h0" ,title="Text",inline = "Time9")

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

var box[] zoneskupo = array.new_box()


if(_resInMinutes < 1440 and barstate.isconfirmed)
timeDay =
timestamp(timezone,year(time,timezone),month(time,timezone),dayofmonth(time,timezon
e))
if(showTime)
tempTime := timeDay + (hourTime*3600 + minuteTime*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 =lb, 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(showTime1)
tempTime := timeDay + (hourTime1*3600 + minuteTime1*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 =lb1, 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(showTime2)
tempTime := timeDay + (hourTime2*3600 + minuteTime2*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 =lb2, 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(showTime3)
tempTime := timeDay + (hourTime3*3600 + minuteTime3*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 =lb3, 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(showTime4)
tempTime := timeDay + (hourTime4*3600 + minuteTime4*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 =lb4, 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(showTime5)
tempTime := timeDay + (hourTime5*3600 + minuteTime5*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 =lb5, 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(showTime6)
tempTime := timeDay + (hourTime6*3600 + minuteTime6*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 =lb6, 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(showTime7)
tempTime := timeDay + (hourTime7*3600 + minuteTime7*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 =lb7, 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(showTime8)
tempTime := timeDay + (hourTime8*3600 + minuteTime8*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 =lb8, 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(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"

var arrayLineChoCh = array.new_line()


var label labelTF = label.new(time, close, text = "",color = color.new(showSGann ?
colorSGann : colorGann,95), textcolor = showSGann ? colorSGann : colorGann,xloc =
xloc.bar_time, textalign = text.align_left)
//////////////////////////Gann//////////////////////////

styleGann = showSGann ? line.style_dashed : line.style_solid


var arrayXGann = array.new_int(5,time)
var arrayYGann = array.new_float(5,close)
var arrayLineGann = array.new_line()
int drawLineGann = 0

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))

if(timeframe.in_seconds() < secondCustomTF)


if(array.get(arrayYSGann,0) == array.get(arrayYGann,1) and
array.get(arrayXSGann,0) != array.get(arrayXGann,1))
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
drawLineSGann1 := 19
if(timeframe.in_seconds() <= secondCustomTF)
if(drawLineSGann1 == 12 or drawLineSGann1 == 19)
if(array.size(arrayLineSGann) >0)

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))

if(timeframe.in_seconds() < secondCustomTF)


if(array.get(arrayYSGann,0) == array.get(arrayYGann,0) and
array.get(arrayXSGann,0) != array.get(arrayXGann,0))
array.set(arrayXSGann, 0, array.get(arrayXGann,0))
drawLineSGann := 9
if(timeframe.in_seconds() <= secondCustomTF)
if(drawLineSGann == 2 or drawLineSGann == 9)
if(array.size(arrayLineSGann) >0)
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(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)

ma(source, length, type) =>


switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)

typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA",


"SMMA (RMA)", "WMA", "VWMA"], group="Smoothing", display = display.data_window)
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100,
group="Smoothing", display = display.data_window)

smoothingLine = ma(out, smoothingLength, typeMA)


plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset,
display=display.none)

conversionPeriods = input.int(9, minval=1, title="Conversion Line Length")


basePeriods = input.int(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length")
displacement = input.int(26, minval=1, title="Lagging Span")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=#2962FF, title="Conversion Line")
plot(baseLine, color=#B71C1C, title="Base Line")
plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,
title="Leading Span A")
p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,
title="Leading Span B")
plot(leadLine1 > leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1,
title = "Kumo Cloud Upper Line", display = display.none)
plot(leadLine1 < leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1,
title = "Kumo Cloud Lower Line", display = display.none)
fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) :
color.rgb(244, 67, 54, 90))

// Mẫu nến entry đệp


vol19 = ta.ema(volume,20)
nen_xanh = close > open
nen_do = close < open
h_ = high
l_ = low
o_ = open
c_ = close
max_nen = math.max(close,open)
min_nen = math.min(close,open)
bodySize = math.abs(open - close)
sha_h = math.abs(high - max_nen)
sha_l = math.abs(min_nen - low)
body_tren = math.abs(high - min_nen)
body_duoi = math.abs(max_nen - low)
rau_tren = math.abs(high - max_nen)
rau_duoi = math.abs(min_nen - low)
rang = math.abs(high - low)
vol = ta.ema(volume,20)
/////////////////////////////////////////////////////////////////////
// 0: nosd hoặc insbreak volume lone . 1 sk pin
nen_tc = input.float(0.5,title ="Tc",step = 0.1)
nn = input.float(2.7,title ="Rau con lai",step = 0.1)
chuot_up = rau_duoi / rang > nen_tc and rau_duoi > rau_tren* nn and volume[0] >=
vol
chuot_dow = rau_tren / rang > nen_tc and rau_tren > rau_duoi* nn and volume[0] >=
vol
chuot_up_1 = rau_duoi / rang > 0.6 and rau_duoi > rau_tren* nn
chuot_dow_1 = rau_tren / rang > 0.6 and rau_tren > rau_duoi* nn
/// Sk
sk_up = nen_do[2] and nen_xanh[1] and max_nen[1] > max_nen[2] and volume[1] <=
volume[2]
sk_dow = nen_do[1] and nen_xanh[2] and min_nen[2] > min_nen[1] and volume[1] <=
volume[2]
// sk + mentum
sk_moment_up = nen_do[3] and nen_do[2] and nen_xanh[1] and bodySize[3] >
bodySize[2] and min_nen[3] > min_nen[2] and max_nen[1] > max_nen[2] and volume[1] <
volume[2]
sk_moment_dow = nen_xanh[3] and nen_xanh[2] and nen_do[1] and bodySize[3] >
bodySize[2] and max_nen[3] < max_nen[2] and min_nen[1] < min_nen[2] and volume[1] <
volume[2]

plotchar(sk_up ,title = "sku", location = location.belowbar, offset = -1)


plotchar(sk_dow ,title = "skd", location = location.abovebar, offset = -1)
plotchar(chuot_up or chuot_up_1 ,title = "cu", location = location.belowbar, offset
=0)
plotchar(chuot_dow or chuot_dow_1,title = "cu", location = location.abovebar,
offset =0)

// ============= Tmining ==============


dopenColor = input.color(color.rgb(110, 4, 231), ' D open ')

import boitoki/Utilities/3 as util

gema = '//Other Settings'


g0 = '//Session Settings//'
g1_01 = '// ♯1 SESSION //'
g1_02 = '// ♯2 SESSION //'
g1_03 = '// ♯3 SESSION //'
g1_04 = '// ♯4 SESSION //'
g1_05 = '// ♯5 SESSION //'
g1_06 = '// ♯6 SESSION //'
g1_07 = '// ♯7 SESSION //'
g1_08 = '// ♯8 SESSION //'
g1_09 = '// ♯9 SESSION //'
g1_10 = '// ♯10 SESSION //'
g4 = '// BOX TYPE //'

bool showPrev = input(true, 'Day open price',group = gema,inline='dopen')


daily_open(x) =>
trigger = na(time('D')) or ta.change(time('D'))
ta.valuewhen(trigger, open, x)

plot(showPrev ? daily_open(0):na, 'Daily Open', dopenColor, 1, plot.style_circles)

snr= input.float(defval = 10, minval= 10, maxval= 100, title="SNR",inline =


's1',group = "SNR")
colsnr = input.color(color.rgb(110, 4, 231), ' Color SNR ',group="SNR", inline =
"s1")
snr1 = math.abs(close - open) / (high - low) * 100 > snr
bar = math.abs(open - close)
bar1 = math.abs(open[1] - close[1])
bodysnr = bar > bar1
volsnr = volume < volume[1]
snrup =bodysnr and volsnr and close > open and close[1] > open[1] and snr1 and
close > close[1] and open > open[1] and high > high[1]
snrdow = bodysnr and volsnr and close < open and close[1] < open[1] and snr1 and
close < close[1] and open < open[1] and low < low[1]
barcolor(snrup ? colsnr : na or snrdow? colsnr : na, title = "snr")

You might also like