name
stringlengths 1
64
| url
stringlengths 44
135
| author
stringlengths 3
30
| author_url
stringlengths 34
61
| likes_count
int64 0
33.2k
| kind
stringclasses 3
values | pine_version
int64 1
5
| license
stringclasses 3
values | source
stringlengths 177
279k
|
---|---|---|---|---|---|---|---|---|
Fan Projections [theEccentricTrader] | https://www.tradingview.com/script/vGA2Qf3G-Fan-Projections-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 72 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Fan Projections [theEccentricTrader]', overlay = true, max_bars_back = 5000, max_lines_count = 500)
//////////// anchor points ////////////
selectAnchor = input.string(title = 'Anchor Point Type', defval = 'Swing High', options = ['Swing High', 'Swing Low', 'Swing High (HTF)', 'Swing Low (HTF)',
'Highest High', 'Lowest Low', 'Intraday Highest High', 'Intraday Lowest Low'], group = 'Anchor Points')
shslOccurrence = input(title = 'Swing High/Low Occurrence (Current Timeframe)', defval = 0, group = 'Anchor Points')
htf = input.timeframe(title = 'Higher Timeframe Resolution', defval = '1D', group = 'Anchor Points')
lookbackHHLL = input(title = 'Lookback for Highest High/Lowest Low', defval = 100, group = 'Anchor Points')
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
shPriceBarIndex = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? bar_index :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? bar_index - 1 : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
slPriceBarIndex = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? bar_index :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? bar_index - 1 : na
shPricePassThrough = close[1] >= open[1] and close < open and high >= high[1] ? high : close[1] >= open[1] and close < open and high <= high[1] ? high[1] : na
slPricePassThrough = close[1] < open[1] and close >= open and low <= low[1] ? low : close[1] < open[1] and close >= open and low >= low[1] ? low[1] : na
[shPriceHTF, slPriceHTF, closeHTF] = request.security(syminfo.tickerid, htf, [shPricePassThrough[1], slPricePassThrough[1], close[1]], lookahead = barmerge.lookahead_on)
shOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
shCloseBarIndexHTF = ta.valuewhen(shPriceHTF and not shPriceHTF[1], bar_index, 0)
slOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
slCloseBarIndexHTF = ta.valuewhen(slPriceHTF and not slPriceHTF[1], bar_index, 0)
htfLookback = shPriceHTF ? bar_index - shOpenBarIndexHTF : slPriceHTF ? bar_index - slOpenBarIndexHTF : na
highestHigh = ta.highest(high, lookbackHHLL)
highestHighBarIndex = bar_index + ta.highestbars(high, lookbackHHLL)
lowestLow = ta.lowest(low, lookbackHHLL)
lowestLowBarIndex = bar_index + ta.lowestbars(low, lookbackHHLL)
dailyClose = request.security(syminfo.tickerid, 'D', close[1], lookahead = barmerge.lookahead_on)
dailyStartBarIndex = ta.valuewhen(ta.change(dailyClose), bar_index, 0)
intradayHighestHigh = ta.highest(high, nz(bar_index - dailyStartBarIndex) + 1)
intradayLowestLow = ta.lowest(low, nz(bar_index - dailyStartBarIndex) + 1)
intradayHighestHighBarIndexcalc = high == intradayHighestHigh
intradayHighestHighBarIndex = ta.valuewhen(intradayHighestHighBarIndexcalc, bar_index, 0)
intradayLowestLowBarIndexcalc = low == intradayLowestLow
intradayLowestLowBarIndex = ta.valuewhen(intradayLowestLowBarIndexcalc, bar_index, 0)
anchorPointHTF = selectAnchor == 'Swing High (HTF)' ? shPriceHTF : selectAnchor == 'Swing Low (HTF)' ? slPriceHTF : na
variableAnchorBarIndexHTF = selectAnchor == 'Swing High (HTF)' ? shCloseBarIndexHTF : selectAnchor == 'Swing Low (HTF)' ? slCloseBarIndexHTF : na
variableAnchorSourceHTF = selectAnchor == 'Swing High (HTF)' ? high : selectAnchor == 'Swing Low (HTF)' ? low : na
variableAnchorSourcePassThroughHTF = variableAnchorSourceHTF[1]
anchorPoint = selectAnchor == 'Swing High' ? shPrice : selectAnchor == 'Swing Low' ? slPrice : selectAnchor == 'Highest High' ? highestHigh : selectAnchor == 'Lowest Low' ? lowestLow :
selectAnchor == 'Intraday Highest High' ? intradayHighestHigh : selectAnchor == 'Intraday Lowest Low' ? intradayLowestLow :
selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)' ? anchorPointHTF and not anchorPointHTF[1] : na
variableAnchorPrice = selectAnchor == 'Swing High' ? ta.valuewhen(shPrice, shPrice, shslOccurrence) : selectAnchor == 'Swing Low' ? ta.valuewhen(slPrice, slPrice, shslOccurrence) :
selectAnchor == 'Highest High' ? highestHigh : selectAnchor == 'Lowest Low' ? lowestLow : selectAnchor == 'Intraday Highest High' ? intradayHighestHigh :
selectAnchor == 'Intraday Lowest Low' ? intradayLowestLow : selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)' ? anchorPointHTF : na
variableAnchorBarIndex = selectAnchor == 'Swing High' ? ta.valuewhen(shPriceBarIndex, shPriceBarIndex, shslOccurrence) : selectAnchor == 'Swing Low' ? ta.valuewhen(slPriceBarIndex, slPriceBarIndex, shslOccurrence) :
selectAnchor == 'Highest High' ? highestHighBarIndex : selectAnchor == 'Lowest Low' ? lowestLowBarIndex : selectAnchor == 'Intraday Highest High' ? intradayHighestHighBarIndex :
selectAnchor == 'Intraday Lowest Low' ? intradayLowestLowBarIndex : selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)' ? variableAnchorBarIndexHTF : na
symbolMintickIntegerConversion = syminfo.mintick >= 0.1 ? 1 : syminfo.mintick == 0.01 ? 10 : syminfo.mintick == 0.001 ? 100 : syminfo.mintick == 0.0001 ? 1000 :
syminfo.mintick == 0.00001 ? 10000 : syminfo.mintick == 0.000001 ? 100000 : syminfo.mintick == 0.0000001 ? 1000000 : syminfo.mintick == 0.00000001 ? 10000000 : na
//////////// lines ////////////
angleInput = input.float(title = 'Angle Degree', defval = 1, group = 'Lines')
numberLines = input.int(title = 'Number of Lines', defval = 2, minval = 1, maxval = 500, group = 'Lines')
lineColour = input(title = 'Line Colour', defval = color.blue, group = 'Line Coloring')
selectExtend = input.string(title = 'Extend Line Type', defval = 'Right', options = ['None', 'Right', 'Left', 'Both'], group = "Line Extension")
extendLines = selectExtend == 'None' ? extend.none : selectExtend == 'Right' ? extend.right : selectExtend == 'Left' ? extend.left : selectExtend == 'Both' ? extend.both : na
angle = angleInput / symbolMintickIntegerConversion
if anchorPoint
for y = 1 to numberLines by 1
for i = 2 to htfLookback by 1
highLowPassThroughHTF = selectAnchor == 'Swing High (HTF)' ? variableAnchorSourceHTF[i] > variableAnchorSourcePassThroughHTF : variableAnchorSourceHTF[i] < variableAnchorSourcePassThroughHTF
if highLowPassThroughHTF
variableAnchorSourcePassThroughHTF := variableAnchorSourceHTF[i]
htfLookback := i
line1 = line.new(not(selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)') ? variableAnchorBarIndex : variableAnchorBarIndex - htfLookback, variableAnchorPrice,
bar_index + 100, variableAnchorPrice + math.todegrees((y - 1) * angle), extend = extendLines, color = lineColour)
var myArray = array.new_line()
array.push(myArray, line1)
if array.size(myArray) > numberLines
firstLine = array.remove(myArray, 0)
line.delete(firstLine)
|
Astro: Solar System | https://www.tradingview.com/script/imTCXik2-Astro-Solar-System/ | BarefootJoey | https://www.tradingview.com/u/BarefootJoey/ | 75 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© BarefootJoey
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ _____ __ _ _______ _____ _______ _______ _______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | | \ | |______ |_____] |_____| | |______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ __|__ | \_| ______| | | | |_____ |______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//@version=5
indicator("Astro: Solar System",overlay=true,max_lines_count=500,scale=scale.none)
width = input.int(40,step=10, minval=40)
spacing = input.float(4.,minval=1)
thickness = input.int(3)
offset = input.int(10)
src = input(close)
orb_col = input.color(color.new(color.gray,100), "Orbit Color")
grp = "πͺ Planets πͺ"
plut_col = input(color.black,'Plu',inline='inline1',group=grp)
nept_col = input(color.purple,'Nep',inline='inline1',group=grp) // #366896
uran_col = input(color.blue,'Ura',inline='inline1',group=grp) // #5580aa
satu_col = input(color.gray,'Sat',inline='inline2',group=grp) // #e6b01e
jupi_col = input(color.orange,'Jup',inline='inline2',group=grp) // #f38d52
mars_col = input(color.red,'Mar',inline='inline2',group=grp) // #b32e06
eart_col = input(color.silver,'Ear',inline='inline3',group=grp) // #2f6a69
venu_col = input(color.green,'Ven',inline='inline3',group=grp) // #ffc5c5
merc_col = input(color.maroon,'Mer',inline='inline3',group=grp) // #854f4f
//------------------------------------------------------------------------------
import BarefootJoey/AstroLib/1 as AL
grtm = "π Time Machine π"
gsd = input.bool(false, "Activate Time Machine", group=grtm)
sdms = input.time(timestamp("2022-04-20T00:00:00"), "Select Date", group=grtm)
gt = gsd ? sdms : time
grol = "π Observer Location π"
htz = input.float(0, "Timezone Hour", step=0.5, inline="2", group=grol)
mtz = input.int(0, "Minute", minval=0, maxval=45, inline="2", group=grol)
tz = htz + math.round(mtz / 60, 4)
latitude = input.float(0, "Latitude", inline="1", group=grol)
longitude = input.float(0, "Longitude", inline="1", group=grol)
geo = false
geoout = geo ? 1 : 0
day = AL.J2000(AL.JDN(gt, 0, tz))
dayr = AL.J2000(AL.JDN(gt, 1, tz))
//------------------------------------------------------------------------------
n = bar_index+width+offset
lset(l,x1,y1,x2,y2,col,width)=>
line.set_xy1(l,x1,y1)
line.set_xy2(l,x2,y2)
line.set_color(l,col)
line.set_width(l,width)
var plut_line = array.new_line(0)
var nept_line = array.new_line(0)
var uran_line = array.new_line(0)
var satu_line = array.new_line(0)
var jupi_line = array.new_line(0)
var astb_line = array.new_line(0)
var mars_line = array.new_line(0)
var eart_line = array.new_line(0)
var venu_line = array.new_line(0)
var merc_line = array.new_line(0)
if barstate.isfirst
for i = 0 to 360 by 10
array.push(plut_line,line.new(na,na,na,na))
array.push(nept_line,line.new(na,na,na,na))
array.push(uran_line,line.new(na,na,na,na))
array.push(satu_line,line.new(na,na,na,na))
array.push(jupi_line,line.new(na,na,na,na))
array.push(astb_line,line.new(na,na,na,na,style=line.style_dotted))
array.push(mars_line,line.new(na,na,na,na))
array.push(eart_line,line.new(na,na,na,na))
array.push(venu_line,line.new(na,na,na,na))
array.push(merc_line,line.new(na,na,na,na))
l(Line,r,len,col_a,col_b,width_a,width_b)=>
int prev_x = na
float prev_y = na
nl = 0
for i = 0 to 360 by 10
x = r*math.sin(math.toradians(i))
y = r*math.cos(math.toradians(i))
css = col_a
lset(array.get(Line,nl),prev_x,prev_y,n+math.round(x),y,
i > len ? col_b : css,
i > len ? width_b : width_a)
prev_x := n+math.round(x)
prev_y := y
nl += 1
//------------------------------------------------------------------------------
angle_plut = AL.getplanet(9,geoout, day, dayr, latitude, longitude,tz)
angle_nept = AL.getplanet(8,geoout, day, dayr, latitude, longitude,tz)
angle_uran = AL.getplanet(7,geoout, day, dayr, latitude, longitude,tz)
angle_satu = AL.getplanet(6,geoout, day, dayr, latitude, longitude,tz)
angle_jupi = AL.getplanet(5,geoout, day, dayr, latitude, longitude,tz)
angle_astb = 360 //AL.getplanet(5,geoout, day, dayr, latitude, longitude,tz)
angle_mars = AL.getplanet(4,geoout, day, dayr, latitude, longitude,tz)
angle_eart = AL.getplanet(3,geoout, day, dayr, latitude, longitude,tz)
angle_venu = AL.getplanet(2,geoout, day, dayr, latitude, longitude,tz)
angle_merc = AL.getplanet(1,geoout, day, dayr, latitude, longitude,tz)
//------------------------------------------------------------------------------
if barstate.islast
//Circular Plot
l(plut_line,width,angle_plut,plut_col,orb_col,thickness,1)
l(nept_line,width-spacing*.8,angle_nept,nept_col,orb_col,thickness,1)
l(uran_line,width-spacing*1.6,angle_uran,uran_col,orb_col,thickness,1)
l(satu_line,width-spacing*2.4,angle_satu,satu_col,orb_col,thickness,1)
l(jupi_line,width-spacing*3.2,angle_jupi,jupi_col,orb_col,thickness,1)
l(astb_line,width-spacing*4.25,angle_astb,#856c44,orb_col,thickness,1)
l(mars_line,width-spacing*5.7,angle_mars,mars_col,orb_col,thickness,1)
l(eart_line,width-spacing*6.4,angle_eart,eart_col,orb_col,thickness,1)
l(venu_line,width-spacing*7.2,angle_venu,venu_col,orb_col,thickness,1)
l(merc_line,width-spacing*8,angle_merc,merc_col,orb_col,thickness,1)
label.delete(label.new(n,0,"π",color=color.new(color.yellow,100),
style=label.style_label_center,textcolor=color.white,textalign=text.align_center,size=size.huge)[1])
// EoS made w/ β€ by @BarefootJoey βππ |
Parallel Projections [theEccentricTrader] | https://www.tradingview.com/script/pdLNWjFb-Parallel-Projections-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 147 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Parallel Projections [theEccentricTrader]', overlay = true, max_bars_back = 5000, max_lines_count = 500)
//////////// anchor points ////////////
selectAnchor = input.string(title = 'Anchor Point Type', defval = 'Swing High', options = ['Swing High', 'Swing Low', 'Swing High (HTF)', 'Swing Low (HTF)',
'Highest High', 'Lowest Low', 'Intraday Highest High', 'Intraday Lowest Low'], group = 'Anchor Points')
shslOccurrence = input(title = 'Swing High/Low Occurrence (Current Timeframe)', defval = 0, group = 'Anchor Points')
htf = input.timeframe(title = 'Higher Timeframe Resolution', defval = '1D', group = 'Anchor Points')
lookbackHHLL = input(title = 'Lookback for Highest High/Lowest Low', defval = 100, group = 'Anchor Points')
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
shPriceBarIndex = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? bar_index :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? bar_index - 1 : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
slPriceBarIndex = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? bar_index :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? bar_index - 1 : na
shPricePassThrough = close[1] >= open[1] and close < open and high >= high[1] ? high : close[1] >= open[1] and close < open and high <= high[1] ? high[1] : na
slPricePassThrough = close[1] < open[1] and close >= open and low <= low[1] ? low : close[1] < open[1] and close >= open and low >= low[1] ? low[1] : na
[shPriceHTF, slPriceHTF, closeHTF] = request.security(syminfo.tickerid, htf, [shPricePassThrough[1], slPricePassThrough[1], close[1]], lookahead = barmerge.lookahead_on)
shOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
shCloseBarIndexHTF = ta.valuewhen(shPriceHTF and not shPriceHTF[1], bar_index, 0)
slOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
slCloseBarIndexHTF = ta.valuewhen(slPriceHTF and not slPriceHTF[1], bar_index, 0)
htfLookback = shPriceHTF ? bar_index - shOpenBarIndexHTF : slPriceHTF ? bar_index - slOpenBarIndexHTF : na
highestHigh = ta.highest(high, lookbackHHLL)
highestHighBarIndex = bar_index + ta.highestbars(high, lookbackHHLL)
lowestLow = ta.lowest(low, lookbackHHLL)
lowestLowBarIndex = bar_index + ta.lowestbars(low, lookbackHHLL)
dailyClose = request.security(syminfo.tickerid, 'D', close[1], lookahead = barmerge.lookahead_on)
dailyStartBarIndex = ta.valuewhen(ta.change(dailyClose), bar_index, 0)
intradayHighestHigh = ta.highest(high, nz(bar_index - dailyStartBarIndex) + 1)
intradayLowestLow = ta.lowest(low, nz(bar_index - dailyStartBarIndex) + 1)
intradayHighestHighBarIndexcalc = high == intradayHighestHigh
intradayHighestHighBarIndex = ta.valuewhen(intradayHighestHighBarIndexcalc, bar_index, 0)
intradayLowestLowBarIndexcalc = low == intradayLowestLow
intradayLowestLowBarIndex = ta.valuewhen(intradayLowestLowBarIndexcalc, bar_index, 0)
anchorPointHTF = selectAnchor == 'Swing High (HTF)' ? shPriceHTF : selectAnchor == 'Swing Low (HTF)' ? slPriceHTF : na
variableAnchorBarIndexHTF = selectAnchor == 'Swing High (HTF)' ? shCloseBarIndexHTF : selectAnchor == 'Swing Low (HTF)' ? slCloseBarIndexHTF : na
variableAnchorSourceHTF = selectAnchor == 'Swing High (HTF)' ? high : selectAnchor == 'Swing Low (HTF)' ? low : na
variableAnchorSourcePassThroughHTF = variableAnchorSourceHTF[1]
anchorPoint = selectAnchor == 'Swing High' ? shPrice : selectAnchor == 'Swing Low' ? slPrice : selectAnchor == 'Highest High' ? highestHigh : selectAnchor == 'Lowest Low' ? lowestLow :
selectAnchor == 'Intraday Highest High' ? intradayHighestHigh : selectAnchor == 'Intraday Lowest Low' ? intradayLowestLow :
selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)' ? anchorPointHTF and not anchorPointHTF[1] : na
variableAnchorPrice = selectAnchor == 'Swing High' ? ta.valuewhen(shPrice, shPrice, shslOccurrence) : selectAnchor == 'Swing Low' ? ta.valuewhen(slPrice, slPrice, shslOccurrence) :
selectAnchor == 'Highest High' ? highestHigh : selectAnchor == 'Lowest Low' ? lowestLow : selectAnchor == 'Intraday Highest High' ? intradayHighestHigh :
selectAnchor == 'Intraday Lowest Low' ? intradayLowestLow : selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)' ? anchorPointHTF : na
variableAnchorBarIndex = selectAnchor == 'Swing High' ? ta.valuewhen(shPriceBarIndex, shPriceBarIndex, shslOccurrence) : selectAnchor == 'Swing Low' ? ta.valuewhen(slPriceBarIndex, slPriceBarIndex, shslOccurrence) :
selectAnchor == 'Highest High' ? highestHighBarIndex : selectAnchor == 'Lowest Low' ? lowestLowBarIndex : selectAnchor == 'Intraday Highest High' ? intradayHighestHighBarIndex :
selectAnchor == 'Intraday Lowest Low' ? intradayLowestLowBarIndex : selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)' ? variableAnchorBarIndexHTF : na
symbolMintickIntegerConversion = syminfo.mintick >= 0.1 ? 1 : syminfo.mintick == 0.01 ? 10 : syminfo.mintick == 0.001 ? 100 : syminfo.mintick == 0.0001 ? 1000 :
syminfo.mintick == 0.00001 ? 10000 : syminfo.mintick == 0.000001 ? 100000 : syminfo.mintick == 0.0000001 ? 1000000 : syminfo.mintick == 0.00000001 ? 10000000 : na
//////////// lines ////////////
angleInput = input.float(title = 'Angle Degree', defval = 1, group = 'Lines')
projectionRatioInput = input.float(title = 'Projection Ratio', defval = 1, group = 'Lines')
numberLines = input.int(title = 'Number of Lines', defval = 2, minval = 1, maxval = 500, group = 'Lines')
lineColour = input(title = 'Line Colour', defval = color.blue, group = 'Line Coloring')
selectExtend = input.string(title = 'Extend Line Type', defval = 'Right', options = ['None', 'Right', 'Left', 'Both'], group = "Line Extension")
extendLines = selectExtend == 'None' ? extend.none : selectExtend == 'Right' ? extend.right : selectExtend == 'Left' ? extend.left : selectExtend == 'Both' ? extend.both : na
angle = angleInput / symbolMintickIntegerConversion
projectionRatio = projectionRatioInput / symbolMintickIntegerConversion
if anchorPoint
for y = 1 to numberLines by 1
for i = 2 to htfLookback by 1
highLowPassThroughHTF = selectAnchor == 'Swing High (HTF)' ? variableAnchorSourceHTF[i] > variableAnchorSourcePassThroughHTF : variableAnchorSourceHTF[i] < variableAnchorSourcePassThroughHTF
if highLowPassThroughHTF
variableAnchorSourcePassThroughHTF := variableAnchorSourceHTF[i]
htfLookback := i
line1 = line.new(not(selectAnchor == 'Swing High (HTF)' or selectAnchor == 'Swing Low (HTF)') ? variableAnchorBarIndex : variableAnchorBarIndex - htfLookback, variableAnchorPrice + (projectionRatio * (y - 1)),
bar_index + 100, variableAnchorPrice + (projectionRatio * (y - 1)) + math.todegrees(angle), extend = extendLines, color = lineColour)
var myArray = array.new_line()
array.push(myArray, line1)
if array.size(myArray) > numberLines
firstLine = array.remove(myArray, 0)
line.delete(firstLine)
|
Intra-Candles | https://www.tradingview.com/script/MtdVvx6V-Intra-Candles/ | EsIstTurnt | https://www.tradingview.com/u/EsIstTurnt/ | 65 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© EsIstTurnt
//@version=5
indicator("Intra-Bars",overlay=true)
//Inputs
numbers = input.bool(false,"Count Levels")
Sections = input.int(6,"# of Lower Timeframe Candles",minval=2,maxval=6)
upCol = input.color(#acfb00)
dnCol = input.color(#ff0000)
candleTransparency=input.int(50)
textTransparency =input.int(30)
tf=timeframe.multiplier/Sections<=1? timeframe.isseconds?na:
timeframe.isminutes?str.tostring(math.round(timeframe.multiplier/Sections*60))+"S":
timeframe.isintraday?str.tostring(math.round(timeframe.multiplier/Sections*60)):
timeframe.isdaily?str.tostring(math.round(timeframe.multiplier/Sections*24))+"H" :
timeframe.isweekly?str.tostring(math.round(timeframe.multiplier/Sections*7))+"D":
str.tostring(math.round(timeframe.multiplier/Sections*4.3))+"W": timeframe.isseconds?str.tostring(math.round(timeframe.multiplier/Sections))+"S":
timeframe.isminutes?str.tostring(math.round(timeframe.multiplier/Sections)):
timeframe.isintraday?str.tostring(math.round(timeframe.multiplier/Sections)*60):
timeframe.isdaily?str.tostring(math.round(timeframe.multiplier/Sections))+"D" :
timeframe.isweekly?str.tostring(math.round(timeframe.multiplier/Sections))+"W":
str.tostring(math.round(timeframe.multiplier/Sections))+"M"
//Script
[IntraOpen,intraHigh,intraLow,intraClose] = request.security_lower_tf( // \β¦ - Lower timeframe is selected according
syminfo.tickerid, // \ to the current timeframe.multiplier value
tf, [open,high,low,close] // \ Candles" selected in settings.
) // \
Close_0 = if array.size(intraClose)>0// \
array.get(intraClose,0) // \
Close_1 = if array.size(intraClose)>1// \
array.get(intraClose,1) // \
Close_2 = if array.size(intraClose)>2// Get the closing price for each Intrabar---------- β¦ - Check if array size is large enough
array.get(intraClose,2) // / then get the closing value from each
Close_3 = if array.size(intraClose)>3// / Intra-Bar from the array created
array.get(intraClose,3) // /
Close_4 = if array.size(intraClose)>4// /
array.get(intraClose,4) // /
Close_5 = if array.size(intraClose)>5// /
array.get(intraClose,5) // /
Close_6 = if array.size(intraClose)>6// /
array.get(intraClose,6) // /
//Do the same for high and low values
High_0 = if array.size(intraHigh)>0//
array.get(intraHigh,0) //
High_1 = if array.size(intraHigh)>1//
array.get(intraHigh,1) //
High_2 = if array.size(intraHigh)>2//
array.get(intraHigh,2) //
High_3 = if array.size(intraHigh)>3//
array.get(intraHigh,3) //
High_4 = if array.size(intraHigh)>4//
array.get(intraHigh,4) //
High_5 = if array.size(intraHigh)>5//
array.get(intraHigh,5) //
High_6 = if array.size(intraHigh)>6//
array.get(intraHigh,6) //
Low_0 = if array.size(intraLow)>0//
array.get(intraLow,0) //
Low_1 = if array.size(intraLow)>1//
array.get(intraLow,1) //
Low_2 = if array.size(intraLow)>2//
array.get(intraLow,2) //
Low_3 = if array.size(intraLow)>3//
array.get(intraLow,3) //
Low_4 = if array.size(intraLow)>4//
array.get(intraLow,4) //
Low_5 = if array.size(intraLow)>5//
array.get(intraLow,5) //
Low_6 = if array.size(intraLow)>6//
array.get(intraLow,6) //
color(o,c,t)=> color.new(o<c?upCol:dnCol,t)//-Color Function
//
plotchar(numbers?array.size(intraClose)>=0?Close_0:na:na,"Close #1",size=size.tiny,// \
char="1",location=location.absolute,color=color(open,Close_0,textTransparency))// \
plotchar(numbers?array.size(intraClose)>=1?Close_1:na:na,"Close #2",size=size.tiny,// \
char="2",location=location.absolute,color=color(Close_0 ,Close_1,textTransparency))// \
plotchar(numbers?array.size(intraClose)>=2?Close_2:na:na,"Close #3",size=size.tiny,// \
char="3",location=location.absolute,color=color(Close_1 ,Close_2,textTransparency))// \
plotchar(numbers?array.size(intraClose)>=3?Close_3:na:na,"Close #4",size=size.tiny,// - Check the input.bool "numbers"
char="4",location=location.absolute,color=color(Close_2 ,Close_3,textTransparency))// / and if true mark each of the close
plotchar(numbers?array.size(intraClose)>=4?Close_4:na:na,"Close #5",size=size.tiny,// / values with it's corresponding #
char="5",location=location.absolute,color=color(Close_3 ,Close_4,textTransparency))// /
plotchar(numbers?array.size(intraClose)>=5?Close_5:na:na,"Close #6",size=size.tiny,// /
char="6",location=location.absolute,color=color(Close_4 ,Close_5,textTransparency))// /
plotchar(numbers?array.size(intraClose)>=6?Close_6:na:na,"Close #7",size=size.tiny,// /
char="7",location=location.absolute,color=color(Close_5 ,Close_6,textTransparency))// /
//Candle Plots for each lower time frame candle
plotcandle(
open,High_0,Low_0,Close_0,color=color(open,Close_0,candleTransparency)
,wickcolor=color(open ,Close_0,candleTransparency),
bordercolor=color(open ,Close_0,candleTransparency/1.25)
)
plotcandle(
Close_0,High_1,Low_1,Close_1 ,color=color(Close_0 ,Close_1,candleTransparency)
,wickcolor=color(Close_0 ,Close_1,candleTransparency),
bordercolor=color(Close_0 ,Close_1,candleTransparency/1.25)
)
plotcandle(
Close_1,High_2,Low_2,Close_2 ,color=color(Close_1 ,Close_2,candleTransparency)
,wickcolor=color(Close_1 ,Close_2,candleTransparency),
bordercolor=color(Close_1 ,Close_2,candleTransparency/1.25)
)
plotcandle(
Close_2,High_3,Low_3,Close_3 ,color=color(Close_2 ,Close_3,candleTransparency)
,wickcolor=color(Close_2 ,Close_3,candleTransparency),
bordercolor=color(Close_2 ,Close_3,candleTransparency/1.25)
)
plotcandle(
Close_3,High_4,Low_4,Close_4 ,color=color(Close_3 ,Close_4,candleTransparency)
,wickcolor=color(Close_3 ,Close_4,candleTransparency),
bordercolor=color(Close_3 ,Close_4,candleTransparency/1.25)
)
plotcandle(
Close_4,High_5,Low_5,Close_5 ,color=color(Close_4 ,Close_5,candleTransparency)
,wickcolor=color(Close_4 ,Close_5,candleTransparency),
bordercolor=color(Close_4 ,Close_5,candleTransparency/1.25)
)
plotcandle(
Close_5,High_6,Low_6,Close_6 ,color=color(Close_5 ,Close_6,candleTransparency)
,wickcolor=color(Close_5 ,Close_6,candleTransparency),
bordercolor=color(Close_5 ,Close_6,candleTransparency/1.25)
)
|
Astro: Planetary Speed | https://www.tradingview.com/script/h85p2NJP-Astro-Planetary-Speed/ | BarefootJoey | https://www.tradingview.com/u/BarefootJoey/ | 64 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© BarefootJoey
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ _____ __ _ _______ _____ _______ _______ _______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | | \ | |______ |_____] |_____| | |______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ __|__ | \_| ______| | | | |_____ |______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//@version=5
indicator("Astro: Planetary Speed", overlay=false)
import BarefootJoey/AstroLib/1 as AL
planet_in = input.string("βΏ Mercury", "Which planet?", options=["βοΈ Sun", "β½οΈ Moon", "βΏ Mercury", "β Venus", "π¨ Earth", "β Mars", "β Jupiter", "β Saturn", "β’ Uranus", "β Neptune", "β Pluto"])
showlast = input.int(1000, "Show last?", minval=1, tooltip="Number of historical plots to display. The fewer plots, the faster the load time (especially on loweer timeframes). Use the Time Machine feature for distant historical analysis.")
iTxtSize=input.string("Small", title="Label Size", options=["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], inline="4l")
col_lab = input.color(color.white, "Label Color")
d_t = input.bool(false, "Date & Time?", tooltip="Leave this unchecked to display date only.", inline="4l")
vTxtSize=iTxtSize == "Auto" ? size.auto : iTxtSize == "Tiny" ? size.tiny : iTxtSize == "Small" ? size.small : iTxtSize == "Normal" ? size.normal : iTxtSize == "Large" ? size.large : size.huge
grtm = "π Time Machine π"
gsd = input.bool(false, "Activate Time Machine", group=grtm)
sdms = input.time(timestamp("2022-04-20T00:00:00"), "Select Date", group=grtm)
gt = gsd ? sdms : time
grol = "π Observer Location π"
htz = input.float(0, "Timezone Hour", step=0.5, inline="2", group=grol)
mtz = input.int(0, "Minute", minval=0, maxval=45, inline="2", group=grol)
tz = htz + math.round(mtz / 60, 4)
latitude = input.float(0, "Latitude", inline="1", group=grol)
longitude = input.float(0, "Longitude", inline="1", group=grol)
geo = true // input.bool(true, "Geocentric?", tooltip="Leave this box unchecked for heliocentric.")
geoout = geo ? 1 : 0
J2000(JDN) => JDN - 2451545.0 //J2000
JDN(t, d) => d == 0 ? (t / 86400000) + 2440587.5 + (tz / 24) : int((t / 86400000) + 2440587.5 + (tz / 24) - 1) + 0.5
day = J2000(JDN(gt, 0))
dayr = J2000(JDN(gt, 1))
planetspeed(planetlong) => AL.AngToCirc(planetlong - planetlong[1])
moonspeed = planetspeed(AL.getmoon(geoout, day, dayr, latitude, longitude))
sunspeed = planetspeed(AL.getsun(geoout, day, dayr, latitude, longitude, tz))
mercspeed = planetspeed(AL.getplanet(1,geoout, day, dayr, latitude, longitude, tz))
venuspeed = planetspeed(AL.getplanet(2,geoout, day, dayr, latitude, longitude, tz))
eartspeed = planetspeed(AL.getplanet(3,geoout, day, dayr, latitude, longitude, tz))
marsspeed = planetspeed(AL.getplanet(4,geoout, day, dayr, latitude, longitude, tz))
jupispeed = planetspeed(AL.getplanet(5,geoout, day, dayr, latitude, longitude, tz))
satuspeed = planetspeed(AL.getplanet(6,geoout, day, dayr, latitude, longitude, tz))
uranspeed = planetspeed(AL.getplanet(7,geoout, day, dayr, latitude, longitude, tz))
neptspeed = planetspeed(AL.getplanet(8,geoout, day, dayr, latitude, longitude, tz))
plutspeed = planetspeed(AL.getplanet(9,geoout, day, dayr, latitude, longitude, tz))
speed_out = planet_in == "βοΈ Sun" ? sunspeed : planet_in == "β½οΈ Moon" ? moonspeed : planet_in == "βΏ Mercury" ? mercspeed : planet_in == "β Venus" ? venuspeed : planet_in == "π¨ Earth" ? eartspeed : planet_in == "β Mars" ? marsspeed : planet_in == "β Jupiter" ? jupispeed : planet_in == "β Saturn" ? satuspeed : planet_in == "β’ Uranus" ? uranspeed : planet_in == "β Neptune" ? neptspeed : planet_in == "β Pluto" ? plutspeed : na
col_out = planet_in == "βοΈ Sun" ? color.yellow : planet_in == "β½οΈ Moon" ? color.silver : planet_in == "βΏ Mercury" ? color.maroon : planet_in == "β Venus" ? color.green : planet_in == "π¨ Earth" ? color.blue : planet_in == "β Mars" ? color.red : planet_in == "β Jupiter" ? color.orange : planet_in == "β Saturn" ? color.gray : planet_in == "β’ Uranus" ? color.navy : planet_in == "β Neptune" ? color.fuchsia : planet_in == "β Pluto" ? color.black : na
transp=0
plot(speed_out, color=color.new(col_out,transp), style=plot.style_line, show_last=showlast, linewidth=2)
var label speed = na
if barstate.islast
speed := label.new(bar_index, y=speed_out, text=planet_in, size=vTxtSize, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(col_out,0), tooltip=planet_in + " Speed:\n" + str.tostring(speed_out, "#.##") + "Β° per bar") //AL.deg_to_time(speed_out))
label.delete(speed[1])
//-------------------------------Pivots---------------------------------------//
pivot_in = speed_out
left = 3
right = left
ms_per_bar = time[1] - time[2]
pivot_time(now_time) => (time - (left * ms_per_bar))
time_out = str.format_time(pivot_time(time), d_t?"MM-dd-yyyy\nHH:mm":"MM-dd-yyyy", syminfo.timezone)
p_hi = ta.pivothigh(pivot_in, left, right)
var label hi_lab = na
if p_hi
hi_lab:= label.new(x=bar_index-left, y=p_hi, text=time_out, size=size.small, color=color.new(color.gray, 100), textcolor=col_lab, style=label.style_label_down, tooltip=planet_in + " Speed:\n" + str.tostring(speed_out, "#.##") + "Β° per bar\n" + "Perihelion")
p_lo = ta.pivotlow(pivot_in, left, right)
var label lo_lab = na
if p_lo
lo_lab:= label.new(x=bar_index-left, y=p_lo, text=time_out, size=size.small, color=color.new(color.gray, 100), textcolor=col_lab, style=label.style_label_up, tooltip=planet_in + " Speed:\n" + str.tostring(speed_out, "#.##") + "Β° per bar\n" + "Aphelion")
// EoS made w/ β€ by @BarefootJoey βππ |
Astro: Celestial Coordinates | https://www.tradingview.com/script/enTi32zi-Astro-Celestial-Coordinates/ | BarefootJoey | https://www.tradingview.com/u/BarefootJoey/ | 130 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© BarefootJoey
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ _____ __ _ _______ _____ _______ _______ _______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | | \ | |______ |_____] |_____| | |______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ __|__ | \_| ______| | | | |_____ |______
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//@version=5
indicator("Astro: Celestial Coordinates", overlay=false)
import BarefootJoey/AstroLib/1 as AL
planet_in = input.string("βΏ Mercury", "Which planet?", options=["βοΈ Sun", "β½οΈ Moon", "βΏ Mercury", "β Venus", "π¨ Earth", "β Mars", "β Jupiter", "β Saturn", "β’ Uranus", "β Neptune", "β Pluto"])
orbital_in = input.string("Declination", "Which Orbital Element?", options=["Longitude", "Latitude", "RA", "Altitude", "Declination"])
showlast = input.int(2000, "Show last?", minval=1, tooltip="Number of historical plots to display. The fewer plots, the faster the load time (especially on loweer timeframes). Use the Time Machine feature for distant historical analysis.")
iTxtSize=input.string("Normal", title="Label Size", options=["Auto", "Tiny", "Small", "Normal", "Large"], inline="4l")
vTxtSize=iTxtSize == "Auto" ? size.auto : iTxtSize == "Tiny" ? size.tiny : iTxtSize == "Small" ? size.small : iTxtSize == "Normal" ? size.normal : iTxtSize == "Large" ? size.large : size.small
d_t = input.bool(false, "Date & Time?", tooltip="Leave this unchecked to display date only.", inline="4l")
lookback = input.int(3, "Lookback", minval=3)
col_info = input.color(color.white, "Info Color")
position = input.string(position.top_center, "Info Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left])
grtm = "π Time Machine π"
gsd = input.bool(false, "Activate Time Machine", group=grtm)
sdms = input.time(timestamp("2022-04-20T00:00:00"), "Select Date", group=grtm)
gt = gsd ? sdms : time
grol = "π Observer Location π"
htz = input.float(0, "Timezone Hour", step=0.5, inline="2", group=grol)
mtz = input.int(0, "Minute", minval=0, maxval=45, inline="2", group=grol)
tz = htz + math.round(mtz / 60, 4)
latitude = input.float(0, "Latitude", inline="1", group=grol)
longitude = input.float(0, "Longitude", inline="1", group=grol)
geo = input.bool(true, "Geocentric?", tooltip="Leave this box unchecked for heliocentric. Only applies to Longitude calculations.")
geoout = geo ? 1 : 0
day = AL.J2000(AL.JDN(gt, 0, tz))
dayr = AL.J2000(AL.JDN(gt, 1, tz))
orbital_out = orbital_in == "Longitude" ? geoout : orbital_in == "Latitude" ? 2 : orbital_in == "RA" ? 5 : orbital_in == "Altitude" ? 4 : orbital_in == "Declination" ? 3 : na
moonout = AL.getmoon(orbital_out, day, dayr, latitude, longitude)
sunout = AL.getsun(orbital_out, day, dayr, latitude, longitude, tz)
mercout = AL.getplanet(1,orbital_out, day, dayr, latitude, longitude, tz)
venuout = AL.getplanet(2,orbital_out, day, dayr, latitude, longitude, tz)
eartout = AL.getplanet(3,orbital_out, day, dayr, latitude, longitude, tz)
marsout = AL.getplanet(4,orbital_out, day, dayr, latitude, longitude, tz)
jupiout = AL.getplanet(5,orbital_out, day, dayr, latitude, longitude, tz)
satuout = AL.getplanet(6,orbital_out, day, dayr, latitude, longitude, tz)
uranout = AL.getplanet(7,orbital_out, day, dayr, latitude, longitude, tz)
neptout = AL.getplanet(8,orbital_out, day, dayr, latitude, longitude, tz)
plutout = AL.getplanet(9,orbital_out, day, dayr, latitude, longitude, tz)
planet_out = planet_in == "βοΈ Sun" ? sunout : planet_in == "β½οΈ Moon" ? moonout : planet_in == "βΏ Mercury" ? mercout : planet_in == "β Venus" ? venuout : planet_in == "π¨ Earth" ? eartout : planet_in == "β Mars" ? marsout : planet_in == "β Jupiter" ? jupiout : planet_in == "β Saturn" ? satuout : planet_in == "β’ Uranus" ? uranout : planet_in == "β Neptune" ? neptout : planet_in == "β Pluto" ? plutout : na
col_out = planet_in == "βοΈ Sun" ? color.yellow : planet_in == "β½οΈ Moon" ? color.silver : planet_in == "βΏ Mercury" ? color.maroon : planet_in == "β Venus" ? color.green : planet_in == "π¨ Earth" ? color.blue : planet_in == "β Mars" ? color.red : planet_in == "β Jupiter" ? color.orange : planet_in == "β Saturn" ? color.gray : planet_in == "β’ Uranus" ? color.navy : planet_in == "β Neptune" ? color.fuchsia : planet_in == "β Pluto" ? color.black : na
post_tt_out = orbital_in == "Longitude" ? "Β°" : orbital_in == "Latitude" ? "Β°" : orbital_in == "RA" ? "" : orbital_in == "Altitude" ? "Β°" : orbital_in == "Declination" ? "Β°" : na
hi = planet_out[2]<planet_out[1] and planet_out[1]>planet_out
lo = planet_out[2]>planet_out[1] and planet_out[1]<planet_out
hi_out = ta.valuewhen(hi, planet_out, 0)
lo_out = ta.valuewhen(lo, planet_out, 0)
transp=0
plot(planet_out, color=color.new(col_out,transp), style=plot.style_line, show_last=showlast, linewidth=2)
var label orbital = na
if barstate.islast
orbital := label.new(bar_index, y=planet_out, text=planet_in, size=size.small, style=label.style_label_left, color=color.new(color.white,100), textcolor=color.new(col_out,0), tooltip=planet_in + "\n" + orbital_in + "\n" + str.tostring(planet_out, "#.##") + post_tt_out) //AL.deg_to_time(speed_out))
label.delete(orbital[1])
geo_tt = geo ? " (Geo)" : " (Helio)"
long_tt = orbital_in == "Longitude" ? geo_tt : ""
var table Info = na
table.delete(Info)
Info := table.new(position, 1, 1)
if barstate.islast
table.cell(Info, 0, 0,
text = planet_in + " " + orbital_in + long_tt,
text_size = vTxtSize,
text_color = color.new(col_info,0))
//-------------------------------Pivots---------------------------------------//
pivot_in = planet_out
left = lookback
right = left
ms_per_bar = time[1] - time[2]
pivot_time(now_time) => (time - (left * ms_per_bar))
time_out = str.format_time(pivot_time(time), d_t?"MM-dd-yyyy\nHH:mm":"MM-dd-yyyy", syminfo.timezone)
p_hi = ta.pivothigh(pivot_in, left, right)
var label hi_lab = na
if p_hi
hi_lab:= label.new(x=bar_index-left, y=p_hi, text=time_out, size=size.small, color=color.new(color.gray, 100), textcolor=col_info, style=label.style_label_down, tooltip=orbital_in + ": " + str.tostring(planet_out[left], "#.##") + post_tt_out)
p_lo = ta.pivotlow(pivot_in, left, right)
var label lo_lab = na
if p_lo
lo_lab:= label.new(x=bar_index-left, y=p_lo, text=time_out, size=size.small, color=color.new(color.gray, 100), textcolor=col_info, style=label.style_label_up, tooltip=orbital_in + ": " + str.tostring(planet_out[left], "#.##") + post_tt_out)
// EoS made w/ β€ by @BarefootJoey βππ |
Rangemeter [theEccentricTrader] | https://www.tradingview.com/script/4hqInPpN-Rangemeter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 19 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theexotictrader
//@version=5
indicator('Rangemeter [theEccentricTrader]', overlay = true)
//////////// shsl ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high : close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low : close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
peak = ta.valuewhen(shPrice, shPrice, 0)
trough = ta.valuewhen(slPrice, slPrice, 0)
shPriceUnconfirmed = close[1] >= open[1] and close < open and high >= high[1] ? high : close[1] >= open[1] and close < open and high <= high[1] ? high[1] : na
slPriceUnconfirmed = close[1] < open[1] and close >= open and low <= low[1] ? low : close[1] < open[1] and close >= open and low >= low[1] ? low[1] : na
openPeak = ta.valuewhen(shPriceUnconfirmed, shPriceUnconfirmed, 0)
openTrough = ta.valuewhen(slPriceUnconfirmed, slPriceUnconfirmed, 0)
//////////// ranges ////////////
symbolMintickIntegerConversion = syminfo.mintick >= 0.1 ? 1 : syminfo.mintick == 0.01 ? 10 : syminfo.mintick == 0.001 ? 100 : syminfo.mintick == 0.0001 ? 1000 :
syminfo.mintick == 0.00001 ? 10000 : syminfo.mintick == 0.000001 ? 100000 : syminfo.mintick == 0.0000001 ? 1000000 : syminfo.mintick == 0.00000001 ? 10000000 : na
showACR = input(defval = true, title = 'Show Average Candle Range', group = 'Candle Ranges')
showBiggestSmallestCandles = input(defval = true, title = 'Show Largest and Smallest Candle Ranges', group = 'Candle Ranges')
showRange = input(defval = true, title = 'Show Range', group = 'Ranges')
showBiggestSmallestRanges = input(defval = true, title = 'Show Largest and Smallest Ranges', group = 'Ranges')
ACRlookback = input(title = 'Average Candle Range Lookback', defval = 10, group = 'Candle Ranges')
ARlookback = input(title = 'Average Range Lookback', defval = 10, group = 'Ranges')
averageCandleRange = ta.sma(high - low, ACRlookback) * symbolMintickIntegerConversion
openCandleRange = (high - low) * symbolMintickIntegerConversion
smallestCandleRange = ta.lowest(high - low, ACRlookback) * symbolMintickIntegerConversion
largestCandleRange = ta.highest(high - low, ACRlookback) * symbolMintickIntegerConversion
averageRange = ta.sma(peak - trough, ARlookback) * symbolMintickIntegerConversion
range_1 = (peak - trough) * symbolMintickIntegerConversion
openRange = (openPeak - openTrough) * symbolMintickIntegerConversion
smallestRange = ta.lowest(peak - trough, ARlookback) * symbolMintickIntegerConversion
largestRange = ta.highest(peak - trough, ARlookback) * symbolMintickIntegerConversion
//////////// table ////////////
tablePositionInput = input.string(title = 'Position', defval = 'Top Right', options = ['Top Right', 'Top Center', 'Top Left', 'Bottom Right', 'Bottom Center', 'Bottom Left',
'Middle Right', 'Middle Center', 'Middle Left'], group = 'Table Positioning')
tablePosition = tablePositionInput == 'Top Right' ? position.top_right : tablePositionInput == 'Top Center' ? position.top_center : tablePositionInput == 'Top Left' ? position.top_left :
tablePositionInput == 'Bottom Right' ? position.bottom_right : tablePositionInput == 'Bottom Center' ? position.bottom_center : tablePositionInput == 'Bottom Left' ? position.bottom_left :
tablePositionInput == 'Middle Right' ? position.middle_right : tablePositionInput == 'Middle Center' ? position.middle_center : tablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval = 'Normal', options = ['Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Small' ? size.small : textSizeInput == 'Large' ? size.large : na
var rangemeterTable = table.new(tablePosition, 100, 100, border_width = 1)
if showACR
table.cell(rangemeterTable, 0, 0, text = 'Average Candle Range', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 0, 1, text = 'Previous Candle Range', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 0, 2, text = 'Open Candle Range', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 0, text = str.tostring(math.round(averageCandleRange[1], 1)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 1, text = str.tostring(math.round(openCandleRange[1], 1)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 2, text = str.tostring(math.round(openCandleRange, 1)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
if showBiggestSmallestCandles
table.cell(rangemeterTable, 0, 3, text = 'Smallest Candle Range', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 0, 4, text = 'Largest Candle Range', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 3, text = str.tostring(math.round(smallestCandleRange, 1)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 4, text = str.tostring(math.round(largestCandleRange, 1)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
if showRange
table.cell(rangemeterTable, 0, 5, text = 'Average Range', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 0, 6, text = 'Previous Range', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 0, 7, text = 'Open Range', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 5, text = str.tostring(math.round(averageRange[1], 1)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 6, text = str.tostring(math.round(range_1, 1)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 7, text = str.tostring(math.round(openRange, 1)), bgcolor = color.green, text_color = color.white, text_size = textSize)
if showBiggestSmallestRanges
table.cell(rangemeterTable, 0, 8, text = 'Smallest Range', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 0, 9, text = 'Largest Range', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 8, text = str.tostring(math.round(smallestRange, 1)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(rangemeterTable, 1, 9, text = str.tostring(math.round(largestRange, 1)), bgcolor = color.green, text_color = color.white, text_size = textSize)
|
[SM] Bitcoin cycles bull market | https://www.tradingview.com/script/NyfFOTU8-SM-Bitcoin-cycles-bull-market/ | Strateg_maker | https://www.tradingview.com/u/Strateg_maker/ | 23 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Strateg_maker
//@version=5
indicator("[SM] Bitcoin cycles bull market", "[SM] Bitcoin cycles", overlay=true)
//======================================================================
// Seting input
//======================================================================
mode = input.bool(defval=false, title="Do you have a TW black theme?", group="Color theme")
table_on = input.bool(defval=true, title="Show the table?", group="Table")
number_month = input.int(defval=12, title="How many months to show in the table?", group="Table")
time_1m_s = input.bool(defval=false, title="On/off 1 month Summer", group="Select a period 1 month summer")
day_1m_s_in = input.int(defval=10, title="Day in begin", group="Select a period 1 month summer", inline="5")
month_1m_s_in = input.int(defval=07, title="Month in begin", group="Select a period 1 month summer", inline="5")
day_1m_s_in_ = input.int(defval=20, title="Day in end...", group="Select a period 1 month summer", inline="6")
month_1m_s_in_ = input.int(defval=07, title="Month in end...", group="Select a period 1 month summer", inline="6")
day_1m_s_out = input.int(defval=10, title="Day out begin", group="Select a period 1 month summer", inline="7")
month_1m_s_out = input.int(defval=08, title="Month out begin", group="Select a period 1 month summer", inline="7")
day_1m_s_out_ = input.int(defval=20, title="Day out end...", group="Select a period 1 month summer", inline="8")
month_1m_s_out_ = input.int(defval=08, title="Month out end...", group="Select a period 1 month summer", inline="8")
time_1m_a = input.bool(defval=false, title="On/off 1 month Autumn", group="Select a period 1 month autumn")
day_1m_a_in = input.int(defval=25, title="Day in begin", group="Select a period 1 month autumn", inline="9")
month_1m_a_in = input.int(defval=09, title="Month in begin", group="Select a period 1 month autumn", inline="9")
day_1m_a_in_ = input.int(defval=05, title="Day in end...", group="Select a period 1 month autumn", inline="10")
month_1m_a_in_ = input.int(defval=10, title="Month in end...", group="Select a period 1 month autumn", inline="10")
day_1m_a_out = input.int(defval=20, title="Day out begin", group="Select a period 1 month autumn", inline="11")
month_1m_a_out = input.int(defval=10, title="Month out begin", group="Select a period 1 month autumn", inline="11")
day_1m_a_out_ = input.int(defval=30, title="Day out end...", group="Select a period 1 month autumn", inline="12")
month_1m_a_out_ = input.int(defval=10, title="Month out end...", group="Select a period 1 month autumn", inline="12")
time_1m_w = input.bool(defval=false, title="On/off 1 month Winter", group="Select a period 1 month winter")
day_1m_w_in = input.int(defval=01, title="Day in begin", group="Select a period 1 month winter", inline="1")
month_1m_w_in = input.int(defval=12, title="Month in begin", group="Select a period 1 month winter", inline="1")
day_1m_w_in_ = input.int(defval=31, title="Day in end...", group="Select a period 1 month winter", inline="2")
month_1m_w_in_ = input.int(defval=12, title="Month in end...", group="Select a period 1 month winter", inline="2")
day_1m_w_out = input.int(defval=01, title="Day out begin", group="Select a period 1 month winter", inline="3")
month_1m_w_out = input.int(defval=01, title="Month out begin", group="Select a period 1 month winter", inline="3")
day_1m_w_out_ = input.int(defval=10, title="Day out end...", group="Select a period 1 month winter", inline="4")
month_1m_w_out_ = input.int(defval=01, title="Month out end...", group="Select a period 1 month winter", inline="4")
time_3m = input.bool(defval=false, title="On/off 3 month", group="Select a period 3 month")
day_3m_in = input.int(defval=01, title="Day in begin", group="Select a period 3 month", inline="13")
month_3m_in = input.int(defval=03, title="Month in begin", group="Select a period 3 month", inline="13")
day_3m_in_ = input.int(defval=31, title="Day in end...", group="Select a period 3 month", inline="14")
month_3m_in_ = input.int(defval=03, title="Month in end...", group="Select a period 3 month", inline="14")
day_3m_out = input.int(defval=01, title="Day out begin", group="Select a period 3 month", inline="15")
month_3m_out = input.int(defval=05, title="Month out begin", group="Select a period 3 month", inline="15")
day_3m_out_ = input.int(defval=30, title="Day out end...", group="Select a period 3 month", inline="16")
month_3m_out_ = input.int(defval=05, title="Month out end...", group="Select a period 3 month", inline="16")
time_6m = input.bool(defval=false, title="On/off 6 month", group="Select a period 6 month")
day_6m_in = input.int(defval=01, title="Day in begin", group="Select a period 6 month", inline="17")
month_6m_in = input.int(defval=12, title="Month in begin", group="Select a period 6 month", inline="17")
day_6m_in_ = input.int(defval=31, title="Day in end...", group="Select a period 6 month", inline="18")
month_6m_in_ = input.int(defval=12, title="Month in end...", group="Select a period 6 month", inline="18")
day_6m_out = input.int(defval=01, title="Day out begin", group="Select a period 6 month", inline="19")
month_6m_out = input.int(defval=06, title="Month out begin", group="Select a period 6 month", inline="19")
day_6m_out_ = input.int(defval=30, title="Day out end...", group="Select a period 6 month", inline="20")
month_6m_out_ = input.int(defval=06, title="Month out end...", group="Select a period 6 month", inline="20")
time_18m = input.bool(defval=true, title="On/off 18 month", group="Select a period 18 month")
day_18m_in = input.int(defval=01, title="Day in begin", group="Select a period 18 month", inline="21")
month_18m_in = input.int(defval=03, title="Month in begin", group="Select a period 18 month", inline="21")
day_18m_in_ = input.int(defval=31, title="Day in end...", group="Select a period 18 month", inline="22")
month_18m_in_ = input.int(defval=03, title="Month in end...", group="Select a period 18 month", inline="22")
day_18m_out = input.int(defval=01, title="Day out begin", group="Select a period 18 month", inline="23")
month_18m_out = input.int(defval=11, title="Month out begin", group="Select a period 18 month", inline="23")
day_18m_out_ = input.int(defval=30, title="Day out end...", group="Select a period 18 month", inline="24")
month_18m_out_ = input.int(defval=11, title="Month out end...", group="Select a period 18 month", inline="24")
//======================================================================
// Data preparation
//======================================================================
// FOR ALL
var years_array = array.from(2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030)
var years_array_3m = array.from(2012, 2013, 2015, 2016, 2017, 2019, 2020, 2021, 2023, 2024, 2025, 2027, 2028, 2029) // minus 2014, 2018, 2022, 2026, 2030
var years_array_6m1 = array.from(2010, 2014, 2018, 2022, 2026, 2030)
var years_array_6m2 = array.from(2011, 2015, 2019, 2023, 2027, 2031)
var years_array_18m1 = array.from(2012, 2016, 2020, 2024, 2028, 2032)
var years_array_18m2 = array.from(2013, 2017, 2021, 2025, 2029, 2033)
// FOR TABLE
var int[] date_1m_s_in_1 = array.new_int()
var int[] date_1m_s_in_2 = array.new_int()
var int[] date_1m_s_out_1 = array.new_int()
var int[] date_1m_s_out_2 = array.new_int()
var int[] date_1m_a_in_1 = array.new_int()
var int[] date_1m_a_in_2 = array.new_int()
var int[] date_1m_a_out_1 = array.new_int()
var int[] date_1m_a_out_2 = array.new_int()
var int[] date_1m_w_in_1 = array.new_int()
var int[] date_1m_w_in_2 = array.new_int()
var int[] date_1m_w_out_1 = array.new_int()
var int[] date_1m_w_out_2 = array.new_int()
var int[] date_3m_in_1 = array.new_int()
var int[] date_3m_in_2 = array.new_int()
var int[] date_3m_out_1 = array.new_int()
var int[] date_3m_out_2 = array.new_int()
var int[] date_6m_in_1 = array.new_int()
var int[] date_6m_in_2 = array.new_int()
var int[] date_6m_out_1 = array.new_int()
var int[] date_6m_out_2 = array.new_int()
var int[] date_18m_in_1 = array.new_int()
var int[] date_18m_in_2 = array.new_int()
var int[] date_18m_out_1 = array.new_int()
var int[] date_18m_out_2 = array.new_int()
// prepare years and months
var months = array.new_int()
var year_array = array.new_int()
var month_array = array.new_int()
if barstate.isfirst
// prepare months for table
for i = 0 to number_month - 1
array.push(months, i)
// prepare dates for table
for elem in months
array.push(year_array, year(timestamp(year(timenow), month(timenow) + elem, 1, 0, 0, 0)))
array.push(month_array, month(timestamp(year(timenow), month(timenow) + elem, 1, 0, 0, 0)))
// prepare dates for periods
for elem in years_array
array.push(date_1m_s_in_1, timestamp(year=elem, month=month_1m_s_in, day=day_1m_s_in))
array.push(date_1m_s_in_2, timestamp(year=elem, month=month_1m_s_in_, day=day_1m_s_in_))
array.push(date_1m_s_out_1, timestamp(year=elem, month=month_1m_s_out, day=day_1m_s_out))
array.push(date_1m_s_out_2, timestamp(year=elem, month=month_1m_s_out_, day=day_1m_s_out_))
array.push(date_1m_a_in_1, timestamp(year=elem, month=month_1m_a_in, day=day_1m_a_in))
array.push(date_1m_a_in_2, timestamp(year=elem, month=month_1m_a_in_, day=day_1m_a_in_))
array.push(date_1m_a_out_1, timestamp(year=elem, month=month_1m_a_out, day=day_1m_a_out))
array.push(date_1m_a_out_2, timestamp(year=elem, month=month_1m_a_out_, day=day_1m_a_out_))
array.push(date_1m_w_in_1, timestamp(year=elem, month=month_1m_w_in, day=day_1m_w_in))
array.push(date_1m_w_in_2, timestamp(year=elem, month=month_1m_w_in_, day=day_1m_w_in_))
array.push(date_1m_w_out_1, timestamp(year=elem, month=month_1m_w_out, day=day_1m_w_out))
array.push(date_1m_w_out_2, timestamp(year=elem, month=month_1m_w_out_, day=day_1m_w_out_))
for elem in years_array_3m
array.push(date_3m_in_1, timestamp(year=elem, month=month_3m_in, day=day_3m_in))
array.push(date_3m_in_2, timestamp(year=elem, month=month_3m_in_, day=day_3m_in_))
array.push(date_3m_out_1, timestamp(year=elem, month=month_3m_out, day=day_3m_out))
array.push(date_3m_out_2, timestamp(year=elem, month=month_3m_out_, day=day_3m_out_))
for elem in years_array_6m1
array.push(date_6m_in_1, timestamp(year=elem, month=month_6m_in, day=day_6m_in))
array.push(date_6m_in_2, timestamp(year=elem, month=month_6m_in_, day=day_6m_in_))
for elem in years_array_6m2
array.push(date_6m_out_1, timestamp(year=elem, month=month_6m_out, day=day_6m_out))
array.push(date_6m_out_2, timestamp(year=elem, month=month_6m_out_, day=day_6m_out_))
for elem in years_array_18m1
array.push(date_18m_in_1, timestamp(year=elem, month=month_18m_in, day=day_18m_in))
array.push(date_18m_in_2, timestamp(year=elem, month=month_18m_in_, day=day_18m_in_))
for elem in years_array_18m2
array.push(date_18m_out_1, timestamp(year=elem, month=month_18m_out, day=day_18m_out))
array.push(date_18m_out_2, timestamp(year=elem, month=month_18m_out_, day=day_18m_out_))
//======================================================================
// Color theme
//======================================================================
var color_bg_tabel = color.new(color.gray, 90)
var color_bd_tabel = color.new(color.black, 40)
var color_tx_tabel = color.new(color.black, 20)
if mode
color_bg_tabel := color.new(color.gray, 90)
color_bd_tabel := color.new(color.white, 40)
color_tx_tabel := color.new(color.white, 20)
//======================================================================
// Backgrond color
//======================================================================
check_tf(startTimeArray, endTimeArray) =>
// condition for bgcolor
isInTimeFrame = false
for i=0 to array.size(startTimeArray) - 1
isInTimeFrame := time >= array.get(startTimeArray, i) and time <= array.get(endTimeArray, i)
if isInTimeFrame
break
isInTimeFrame
// summer
bgcolor(time_1m_s == true ? check_tf(date_1m_s_in_1, date_1m_s_in_2) ? color.new(color.green, 85) : na : na)
bgcolor(time_1m_s == true ? check_tf(date_1m_s_out_1, date_1m_s_out_2) ? color.new(color.red, 85) : na : na)
// autumn
bgcolor(time_1m_a == true ? check_tf(date_1m_a_in_1, date_1m_a_in_2) ? color.new(color.green, 85) : na : na)
bgcolor(time_1m_a == true ? check_tf(date_1m_a_out_1, date_1m_a_out_2) ? color.new(color.red, 85) : na : na)
// winter
bgcolor(time_1m_w == true ? check_tf(date_1m_w_in_1, date_1m_w_in_2) ? color.new(color.green, 85) : na : na)
bgcolor(time_1m_w == true ? check_tf(date_1m_w_out_1, date_1m_w_out_2) ? color.new(color.red, 85) : na : na)
// 3 month
bgcolor(time_3m == true ? check_tf(date_3m_in_1, date_3m_in_2) ? color.new(color.green, 85) : na : na)
bgcolor(time_3m == true ? check_tf(date_3m_out_1, date_3m_out_2) ? color.new(color.red, 85) : na : na)
// 6 month
bgcolor(time_6m == true ? check_tf(date_6m_in_1, date_6m_in_2) ? color.new(color.green, 85) : na : na)
bgcolor(time_6m == true ? check_tf(date_6m_out_1, date_6m_out_2) ? color.new(color.red, 85) : na : na)
// 18 month
bgcolor(time_18m == true ? check_tf(date_18m_in_1, date_18m_in_2) ? color.new(color.green, 85) : na : na)
bgcolor(time_18m == true ? check_tf(date_18m_out_1, date_18m_out_2) ? color.new(color.red, 85) : na : na)
//======================================================================
// Table
//======================================================================
var tbl = table.new(position.bottom_right, number_month + 1, 8, bgcolor = color_bg_tabel, border_color = color_bd_tabel, border_width = 1)
future_tf(_curent_year, _curent_month, startTimeArray, endTimeArray) =>
// condition for bgcolor (table)
isInTimeFrame = false
_curent_day = timestamp(year = _curent_year, month = _curent_month, day = 1)
for i = 0 to array.size(startTimeArray) - 1
_start_day = timestamp(year = year(array.get(startTimeArray, i)), month = month(array.get(startTimeArray, i)), day = 1)
_and_day = timestamp(year = year(array.get(endTimeArray, i)), month = month(array.get(endTimeArray, i)), day = 1)
isInTimeFrame := _curent_day >= _start_day and _curent_day <= _and_day
if isInTimeFrame
break
isInTimeFrame
if table_on and barstate.islast
// column 1
table.cell(tbl, 0, 0, "Year", text_halign = text.align_left, text_color = color_tx_tabel)
table.cell(tbl, 0, 1, "Month", text_halign = text.align_left, text_color = color_tx_tabel)
table.cell(tbl, 0, 2, "1 month Summer", text_halign = text.align_left, text_color = color_tx_tabel)
table.cell(tbl, 0, 3, "1 month Autumn", text_halign = text.align_left, text_color = color_tx_tabel)
table.cell(tbl, 0, 4, "1 month Winter", text_halign = text.align_left, text_color = color_tx_tabel)
table.cell(tbl, 0, 5, "3 month", text_halign = text.align_left, text_color = color_tx_tabel)
table.cell(tbl, 0, 6, "6 month", text_halign = text.align_left, text_color = color_tx_tabel)
table.cell(tbl, 0, 7, "18 month", text_halign = text.align_left, text_color = color_tx_tabel)
// columns 2 - 12...
for i=0 to number_month - 1
_curent_year = array.get(year_array, i)
_curent_month = array.get(month_array, i)
// row 1 and row 2
table.cell(tbl, 1 + i, 0, str.tostring(_curent_year), text_size=size.small, text_halign = text.align_center, text_color = color_tx_tabel)
table.cell(tbl, 1 + i, 1, str.tostring(_curent_month), text_halign = text.align_center, text_color = color_tx_tabel)
// row 3 - 8
if future_tf(_curent_year, _curent_month, date_1m_s_in_1, date_1m_s_out_2)
table.cell_set_bgcolor(tbl, 1 + i, 2, bgcolor = color.new(color.green, 25))
if time_1m_s
table.cell_set_text_color(tbl, 0, 2, text_color = color.blue)
if future_tf(_curent_year, _curent_month, date_1m_a_in_1, date_1m_a_out_2)
table.cell_set_bgcolor(tbl, 1 + i, 3, bgcolor = color.new(color.green, 25))
if time_1m_a
table.cell_set_text_color(tbl, 0, 3, text_color = color.blue)
if future_tf(_curent_year, _curent_month, date_1m_w_in_1, date_1m_w_in_2) or future_tf(_curent_year, _curent_month, date_1m_w_out_1, date_1m_w_out_2)
table.cell_set_bgcolor(tbl, 1 + i, 4, bgcolor = color.new(color.green, 25))
if time_1m_w
table.cell_set_text_color(tbl, 0, 4, text_color = color.blue)
if future_tf(_curent_year, _curent_month, date_3m_in_1, date_3m_out_2)
table.cell_set_bgcolor(tbl, 1 + i, 5, bgcolor = color.new(color.green, 25))
if time_3m
table.cell_set_text_color(tbl, 0, 5, text_color = color.blue)
if future_tf(_curent_year, _curent_month, date_6m_in_1, date_6m_out_2)
table.cell_set_bgcolor(tbl, 1 + i, 6, bgcolor = color.new(color.green, 25))
if time_6m
table.cell_set_text_color(tbl, 0, 6, text_color = color.blue)
if future_tf(_curent_year, _curent_month, date_18m_in_1, date_18m_out_2)
table.cell_set_bgcolor(tbl, 1 + i, 7, bgcolor = color.new(color.green, 25))
if time_18m
table.cell_set_text_color(tbl, 0, 7, text_color = color.blue)
|
Rate Of Change [Hyperbolic] | https://www.tradingview.com/script/phamIEZT-Rate-Of-Change-Hyperbolic/ | akikostas | https://www.tradingview.com/u/akikostas/ | 45 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© akikostas
//@version=5
indicator(title="Rate Of Change [Log] ", shorttitle="ROC-L", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
length = input.int(9, minval=1)
source = input(close, "Source")
exotic = input.bool(false, title = "Exotic Calculations")
logarithmic(src)=> math.sign(src) * math.log(math.abs(src) + 1)
roc = 100 * (source - source[length])/source[length]
if (exotic)
roc := logarithmic(source) - logarithmic(source[length])
plot(roc, color=#2962FF, title="ROC")
hline(0, color=#787B86, title="Zero Line") |
Impulse Momentum MACD - Slow and Fast | https://www.tradingview.com/script/F2HTaudO/ | DOC-STRATEGY | https://www.tradingview.com/u/DOC-STRATEGY/ | 127 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© DOC-STRATEGY
//βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
//ππ»πβ ππβπΈππΌπΎππ
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//@version=5
indicator('Impulse Momentum MACD - Slow and Fast', shorttitle='Impulse Momentum MACD - Slow and Fast', timeframe='')
DOC_Strategy = "MA IMPULSE MACD - SLOW"
DOC_Strategy_II = "MA IMPULSE MACD - FAST"
ma(sourceXD, lengthXD, type) =>
type == "SMA" ? ta.sma (sourceXD, lengthXD) :
type == "EMA" ? ta.ema (sourceXD, lengthXD) :
type == "SMMA (RMA)" ? ta.rma (sourceXD, lengthXD) :
type == "WMA" ? ta.wma (sourceXD, lengthXD) :
type == "VWMA" ? ta.vwma(sourceXD, lengthXD) :
type == "HMA" ? ta.wma (2 * ta.wma(sourceXD, lengthXD / 2) - ta.wma(sourceXD, lengthXD), math.floor(math.sqrt(lengthXD))) :
na
// Data Entry///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define the length of the momentum indicator
Momentum_Length = input.int (title='Momentum Length' , minval=1, defval= 14, group='Momentum')
Momentum_Source = input.source(close , "Momentum Source", group='Momentum')
ColorMomentumL = input.color (#0ebb9e, 'Momentum Line', group='Momentum')
ColorMomentumS = input.color (#cd0a68 , 'Momentum Line', group='Momentum')
ColorMomentumLLL = input.color (#0ebb8426, 'Momentum Area', group='Momentum')
ColorMomentumSSS = input.color (#bb0e6424 ,'Momentum Area', group='Momentum')
// Calculate the momentum indicator using the ta.mom function
Momentum = ta.mom(Momentum_Source, Momentum_Length)/2.6
// Color - Momentum
Color_Momentum = Momentum >= 0 ? ColorMomentumL : ColorMomentumS
Color_Momentum_Area = Momentum >= 0 ? ColorMomentumLLL : ColorMomentumSSS
// Plot the momentum indicator using the plot function
plot(Momentum, color=Color_Momentum, linewidth=1, title='Standard Momentum Indicator', display=display.all)
plot(Momentum, color=Color_Momentum_Area, linewidth=2, title='Momentum Indicator - Area', style=plot.style_areabr, display=display.all)
// Data Entry////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Period to calculate main line value
Calculation_Period_For_Line = input.int(defval=10, title='Period to calculate the Trend Line', minval=1, group='Trend Line')
Line_ColorLB = input.color (color.rgb(15, 200, 139), "Long/Buy" , group='Trend Line')
Line_ColorSS = input.color (color.rgb(202, 15, 121), "Short/Sell" , group='Trend Line')
TFTL = input.timeframe('', title='Time Frame the Trend Line - Tickets (Minutes: 1=5, 3=15, 5=30, 15=60)', group='Trend Line')
o = request.security (syminfo.tickerid, TFTL, open, barmerge.gaps_off, barmerge.lookahead_on)
c = request.security (syminfo.tickerid, TFTL, close, barmerge.gaps_off, barmerge.lookahead_on)
h = request.security (syminfo.tickerid, TFTL, high, barmerge.gaps_off, barmerge.lookahead_on)
l = request.security (syminfo.tickerid, TFTL, low, barmerge.gaps_off, barmerge.lookahead_on)
// Function to calculate line value////////////////////////////////////////////////////////////////////////////////////////////
Calculate_Line(Period) =>
float highS = ta.highest(Period) or h > c ? h : na
float lowS = ta.lowest (Period) or l < c ? l : na
int trend = 0
trend := c > h[1] ? 1 : c < l[1] ? -1 : nz(trend[1])
trend
// Function to draw line on chart//////////////////////////////////////////////////////////////////////////////////////////////
Draw_Line(Period, Main_Trend) =>
float highS = ta.highest(Period) or h > c ? h : na
float lowS = ta.lowest (Period) or l < c ? l : na
int trend = 0
trend := c > h[1] ? 1 : c < l[1] ? -1 : nz(trend[1])
Main_Trend == 1 ? trend == 1 ? Line_ColorLB : Line_ColorLB : Main_Trend == -1 ? trend == -1 ? Line_ColorSS : Line_ColorSS : na
// Calculate main line value///////////////////////////////////////////////////////////////////////////////////////////////////
Main_Trend = Calculate_Line(Calculation_Period_For_Line)
// Lines - UP and Down////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Line - Up
hline(0.050, title='Up level', linestyle=hline.style_dotted, color=#f60c0c, display=display.none)
hline(0.1, title='Up level', linestyle=hline.style_dotted, color=#989898, display=display.none)
// Line - Down
hline(-0.050, title='Down Level', linestyle=hline.style_dotted, color=#2b9f1e, display=display.none)
hline(-0.1, title='Down Level', linestyle=hline.style_dotted, color=#989898, display=display.none)
// Data Entry/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ma1_type = input.string("SMA" , " " , inline="MAS #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "HMA"], group=DOC_Strategy )
ma2_type = input.string("EMA" , " " , inline="MAS #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "HMA"], group=DOC_Strategy )
ma3_type = input.string("HMA" , " " , inline="MAS #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "HMA"], group=DOC_Strategy )
ma4_type = input.string("SMA" , " " , inline="MAF #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "HMA"], group=DOC_Strategy_II)
ma5_type = input.string("SMA" , " " , inline="MAF #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "HMA"], group=DOC_Strategy_II)
ma6_type = input.string("WMA" , " " , inline="MAF #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "HMA"], group=DOC_Strategy_II)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
lengthMA = input (34, title='Impulse MACD - Slow', group='Impulse MACD - Slow')
lengthSignal = input (9, title='Signal Impulse MACD - Slow', group='Impulse MACD - Slow')
colorLookback = input.int (2, minval=0, title='Color Look Back', group='Impulse MACD - Slow')
hist_color0 = input.color (color.new(#22ff00, 20), 'Positive Rising', group='Histogram: Impulse MACD - Slow') // positive rising
hist_color1 = input.color (color.new(#2ff7f7, 30), 'Positive Falling', group='Histogram: Impulse MACD - Slow') // positive falling
hist_color2 = input.color (color.new(#f82e71, 30), 'Negative Falling', group='Histogram: Impulse MACD - Slow') // negative falling
hist_color3 = input.color (color.new(#ff0000, 20), 'Negative Rising', group='Histogram: Impulse MACD - Slow') // negative rising
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
lengthMAS = input (15, title='Impulse MACD - Fast', group='Impulse MACD - Fast')
lengthSignalS = input (5, title='Signal Impulse MACD - Fast', group='Impulse MACD - Fast')
colorLookbackS = input.int (2, minval=0, title='Color Look Back', group='Impulse MACD - Fast')
hist_color0S = input.color (color.new(#0800ff, 20), 'Positive Rising', group='Histogram: Impulse MACD - Fast') // positive rising
hist_color1S = input.color (color.new(#000000, 30), 'Positive Falling', group='Histogram: Impulse MACD - Fast') // positive falling
hist_color2S = input.color (color.new(#000000, 31), 'Negative Falling', group='Histogram: Impulse MACD - Fast') // negative falling
hist_color3S = input.color (color.new(#0800ff, 21), 'Negative Rising', group='Histogram: Impulse MACD - Fast') // negative rising
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Impulse MACD - Slow
calc_smma(src, len) =>
smma = 0.0
sma_1 = ma(src, len, ma1_type)
smma := na(smma[1]) ? sma_1 : (smma[1] * (len - 1) + src) / len
smma
//Impulse MACD - Fast
calc_smmaS(srcS, lenS) =>
smmaS = 0.0
sma_1S = ma(srcS, lenS, ma4_type)
smmaS := na(smmaS[1]) ? sma_1S : (smmaS[1] * (lenS - 1) + srcS) / lenS
smmaS
//Impulse MACD - Slow
calc_zlema(src, length) =>
ema1 = ma(src, length, ma2_type)
ema2 = ma(ema1, length, ma2_type)
d = ema1 - ema2
ema1 + d
//Impulse MACD - Fast
calc_zlemaS(srcS, lengthS) =>
ema1S = ma(srcS, lengthS, ma5_type)
ema2S = ma(ema1S, lengthS, ma5_type)
dS = ema1S - ema2S
ema1S + dS
//Impulse MACD - Slow
srcWW = hlc3
hi = calc_smma(high, lengthMA)
lo = calc_smma(low, lengthMA)
mi = calc_zlema(srcWW, lengthMA)
//Impulse MACD - Fast
srcWWS = hlc3
hiS = calc_smma(high, lengthMAS)
loS = calc_smma(low, lengthMAS)
miS = calc_zlema(srcWWS, lengthMAS)
//Impulse MACD - Slow
md = mi > hi ? mi - hi : mi < lo ? mi - lo : 0
sb = ma(md, lengthSignal, ma3_type)
sh = md - sb
is_rising = ta.rising(sh, colorLookback)
is_falling = ta.falling(sh, colorLookback)
//Impulse MACD - Fast
mdS = miS > hiS ? miS - hiS : miS < loS ? miS - loS : 0
sbS = ma(mdS, lengthSignalS, ma6_type)
shS = mdS - sbS
is_risingS = ta.rising(shS, colorLookbackS)
is_fallingS = ta.falling(shS, colorLookbackS)
//Impulse MACD - Slow
histColor = colorLookback == 0 ? sh > 0 ? hist_color0 : hist_color3 : sh > 0 ? is_rising ? hist_color0 : hist_color1 : is_falling ? hist_color3 : hist_color2
mdc = srcWW > mi ? srcWW > hi ? color.rgb(4, 255, 0) : color.rgb(2, 252, 164, 30) : srcWW < lo ? color.rgb(255, 2, 133) : color.rgb(255, 4, 163, 30)
//Impulse MACD - Fast
histColorS = colorLookbackS == 0 ? shS > 0 ? hist_color0S : hist_color3S : shS > 0 ? is_risingS ? hist_color0S : hist_color1S : is_fallingS ? hist_color3S : hist_color2S
mdcS = srcWWS > miS ? srcWWS > hiS ? color.rgb(21, 0, 255) : color.rgb(0, 140, 255, 30) : srcWWS < loS ? color.rgb(255, 0, 238) : color.rgb(255, 0, 217, 30)
//GRAPHICS/////////////////////////////////////////////////////////////////////////////
//Plot - Middle Line
plot(0, color=color.new(#65665c, 0), linewidth=1, title='Mid Line')
//Plot - Columns Slow And Fast
//Fast
plot(shS, style=plot.style_columns, color=histColorS)
//Slow
plot(sh, style=plot.style_columns, color=histColor)
//Plot - Fast Lines
plot(mdS, color=mdcS, linewidth=3, title='Impulse MACD - Fast', style=plot.style_line)
plot(sbS, color=color.new(#ffffff, 0), linewidth=3, title='Impulse MACD Signal - Fast')
//Plot - Slow Lines
plot(md, color=mdc, linewidth=3, title='Impulse MACD - Slow', style=plot.style_line)
plot(sb, color=color.new(#ccf309, 0), linewidth=3, title='Impulse MACD Signal - Slow')
//Plot Line Zero
plot( 0, color=Draw_Line(Calculation_Period_For_Line - 9, Main_Trend), title="Zero Trend Line π", style=plot.style_stepline, histbase= 0, linewidth=4)
//Bar Colors - Slow and Fast///////////////////////////////////////////////////////////
//Slow
ebc = input(false, title='Enable Bar Colors: Impulse MACD - Slow', group='Impulse MACD - Slow')
barcolor(ebc ? mdc : na)
//Fast
ebcS = input(false, title='Enable Bar Colors: Impulse MACD - Fast', group='Impulse MACD - Fast')
barcolor(ebcS ? mdcS : na)
//////////////////////////////////////////////////////////////////////////////////////
//The End//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Percent Change of Day [ilovealgotrading] | https://www.tradingview.com/script/Cx3VPe4t-Percent-Change-of-Day-ilovealgotrading/ | projeadam | https://www.tradingview.com/u/projeadam/ | 100 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Baby_whale_to_moon
//@version=5
indicator('Percent Change of Day [ilovealgotrading]', overlay=false, max_labels_count = 500)
TimeFrame = input.timeframe('D')
more_then0 = input.color(defval =color.rgb(37, 128, 60) ,title = "Line Colour More 0" )
less_then0 = input.color(defval =color.rgb(185, 60, 60) ,title = "Line Colour Less 0" )
is_new_day = ta.change(time(TimeFrame)) != 0 ? 1 : 0
var float per_change = 0
bar_per_change = math.round_to_mintick(ta.roc(close,1))
per_change := is_new_day ? bar_per_change : per_change + bar_per_change
color_per_change = color(na)
if (math.round_to_mintick(ta.roc(close,1))) >= 0
color_per_change := color.lime
color_per_change
else
color_per_change := color.red
color_per_change
bgcolor(is_new_day ? color.new(#f5ff3c, 42) : na)
plot(per_change, 'Daily Percent Change', per_change >= 0 ? more_then0 : color.rgb(185, 60, 60), linewidth = 2)
plot(math.round_to_mintick(ta.roc(close,1)), color = color_per_change, style=plot.style_columns)
|
Double Trend Counter [theEccentricTrader] | https://www.tradingview.com/script/gObq9z0t-Double-Trend-Counter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 4 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Double Trend Counter [theEccentricTrader]', overlay = true)
//////////// sample period filter ////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input.time(timestamp('1 Jan 1800 00:00'), title = 'Start Date', group = 'Sample Period')
end = input.time(timestamp('1 Jan 3000 00:00'), title = 'End Date', group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
str.tostring(dayofmonth(_t), '00') + '.' + str.tostring(month(_t), '00') + '.' + str.tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
//////////// double trend counters ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
onePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
twoPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
threePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
fourPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
fivePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
sixPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
sevenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
eightPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8)
ninePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8) and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9)
tenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10)
elevenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) > ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8) and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9)
and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10) and ta.valuewhen(shPrice, shPrice, 10) > ta.valuewhen(shPrice, shPrice, 11)
twelvePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) > ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(slPrice, slPrice, 11) > ta.valuewhen(slPrice, slPrice, 12)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) > ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(shPrice, shPrice, 11) > ta.valuewhen(shPrice, shPrice, 12)
thirteenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) > ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(slPrice, slPrice, 11) > ta.valuewhen(slPrice, slPrice, 12)
and ta.valuewhen(slPrice, slPrice, 12) > ta.valuewhen(slPrice, slPrice, 13) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8) and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9)
and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10) and ta.valuewhen(shPrice, shPrice, 10) > ta.valuewhen(shPrice, shPrice, 11)
and ta.valuewhen(shPrice, shPrice, 11) > ta.valuewhen(shPrice, shPrice, 12) and ta.valuewhen(shPrice, shPrice, 12) > ta.valuewhen(shPrice, shPrice, 13)
onePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
twoPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
threePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
fourPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
fivePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
sixPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
sevenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
eightPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8)
ninePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8) and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9)
tenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10)
elevenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) < ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8) and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9)
and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10) and ta.valuewhen(slPrice, slPrice, 10) < ta.valuewhen(slPrice, slPrice, 11)
twelvePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) < ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(shPrice, shPrice, 11) < ta.valuewhen(shPrice, shPrice, 12)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) < ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(slPrice, slPrice, 11) < ta.valuewhen(slPrice, slPrice, 12)
thirteenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) < ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(shPrice, shPrice, 11) < ta.valuewhen(shPrice, shPrice, 12)
and ta.valuewhen(shPrice, shPrice, 12) < ta.valuewhen(shPrice, shPrice, 13) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8) and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9)
and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10) and ta.valuewhen(slPrice, slPrice, 10) < ta.valuewhen(slPrice, slPrice, 11)
and ta.valuewhen(slPrice, slPrice, 11) < ta.valuewhen(slPrice, slPrice, 12) and ta.valuewhen(slPrice, slPrice, 12) < ta.valuewhen(slPrice, slPrice, 13)
var onePartPeakTroughDoubleUptrendCounter = 0
var twoPartPeakTroughDoubleUptrendCounter = 0
var threePartPeakTroughDoubleUptrendCounter = 0
var fourPartPeakTroughDoubleUptrendCounter = 0
var fivePartPeakTroughDoubleUptrendCounter = 0
var sixPartPeakTroughDoubleUptrendCounter = 0
var sevenPartPeakTroughDoubleUptrendCounter = 0
var eightPartPeakTroughDoubleUptrendCounter = 0
var ninePartPeakTroughDoubleUptrendCounter = 0
var tenPartPeakTroughDoubleUptrendCounter = 0
var elevenPartPeakTroughDoubleUptrendCounter = 0
var twelvePartPeakTroughDoubleUptrendCounter = 0
var thirteenPartPeakTroughDoubleUptrendCounter = 0
var onePartTroughPeakDoubleDowntrendCounter = 0
var twoPartTroughPeakDoubleDowntrendCounter = 0
var threePartTroughPeakDoubleDowntrendCounter = 0
var fourPartTroughPeakDoubleDowntrendCounter = 0
var fivePartTroughPeakDoubleDowntrendCounter = 0
var sixPartTroughPeakDoubleDowntrendCounter = 0
var sevenPartTroughPeakDoubleDowntrendCounter = 0
var eightPartTroughPeakDoubleDowntrendCounter = 0
var ninePartTroughPeakDoubleDowntrendCounter = 0
var tenPartTroughPeakDoubleDowntrendCounter = 0
var elevenPartTroughPeakDoubleDowntrendCounter = 0
var twelvePartTroughPeakDoubleDowntrendCounter = 0
var thirteenPartTroughPeakDoubleDowntrendCounter = 0
if onePartPeakTroughDoubleUptrend and not twoPartPeakTroughDoubleUptrend and samplePeriodFilter
onePartPeakTroughDoubleUptrendCounter += 1
if twoPartPeakTroughDoubleUptrend and not threePartPeakTroughDoubleUptrend and samplePeriodFilter
twoPartPeakTroughDoubleUptrendCounter += 1
if threePartPeakTroughDoubleUptrend and not fourPartPeakTroughDoubleUptrend and samplePeriodFilter
threePartPeakTroughDoubleUptrendCounter += 1
if fourPartPeakTroughDoubleUptrend and not fivePartPeakTroughDoubleUptrend and samplePeriodFilter
fourPartPeakTroughDoubleUptrendCounter += 1
if fivePartPeakTroughDoubleUptrend and not sixPartPeakTroughDoubleUptrend and samplePeriodFilter
fivePartPeakTroughDoubleUptrendCounter += 1
if sixPartPeakTroughDoubleUptrend and not sevenPartPeakTroughDoubleUptrend and samplePeriodFilter
sixPartPeakTroughDoubleUptrendCounter += 1
if sevenPartPeakTroughDoubleUptrend and not eightPartPeakTroughDoubleUptrend and samplePeriodFilter
sevenPartPeakTroughDoubleUptrendCounter += 1
if eightPartPeakTroughDoubleUptrend and not ninePartPeakTroughDoubleUptrend and samplePeriodFilter
eightPartPeakTroughDoubleUptrendCounter += 1
if ninePartPeakTroughDoubleUptrend and not tenPartPeakTroughDoubleUptrend and samplePeriodFilter
ninePartPeakTroughDoubleUptrendCounter += 1
if tenPartPeakTroughDoubleUptrend and not elevenPartPeakTroughDoubleUptrend and samplePeriodFilter
tenPartPeakTroughDoubleUptrendCounter += 1
if elevenPartPeakTroughDoubleUptrend and not twelvePartPeakTroughDoubleUptrend and samplePeriodFilter
elevenPartPeakTroughDoubleUptrendCounter += 1
if twelvePartPeakTroughDoubleUptrend and not thirteenPartPeakTroughDoubleUptrend and samplePeriodFilter
twelvePartPeakTroughDoubleUptrendCounter += 1
if thirteenPartPeakTroughDoubleUptrend and samplePeriodFilter
thirteenPartPeakTroughDoubleUptrendCounter += 1
if onePartTroughPeakDoubleDowntrend and not twoPartTroughPeakDoubleDowntrend and samplePeriodFilter
onePartTroughPeakDoubleDowntrendCounter += 1
if twoPartTroughPeakDoubleDowntrend and not threePartTroughPeakDoubleDowntrend and samplePeriodFilter
twoPartTroughPeakDoubleDowntrendCounter += 1
if threePartTroughPeakDoubleDowntrend and not fourPartTroughPeakDoubleDowntrend and samplePeriodFilter
threePartTroughPeakDoubleDowntrendCounter += 1
if fourPartTroughPeakDoubleDowntrend and not fivePartTroughPeakDoubleDowntrend and samplePeriodFilter
fourPartTroughPeakDoubleDowntrendCounter += 1
if fivePartTroughPeakDoubleDowntrend and not sixPartTroughPeakDoubleDowntrend and samplePeriodFilter
fivePartTroughPeakDoubleDowntrendCounter += 1
if sixPartTroughPeakDoubleDowntrend and not sevenPartTroughPeakDoubleDowntrend and samplePeriodFilter
sixPartTroughPeakDoubleDowntrendCounter += 1
if sevenPartTroughPeakDoubleDowntrend and not eightPartTroughPeakDoubleDowntrend and samplePeriodFilter
sevenPartTroughPeakDoubleDowntrendCounter += 1
if eightPartTroughPeakDoubleDowntrend and not ninePartTroughPeakDoubleDowntrend and samplePeriodFilter
eightPartTroughPeakDoubleDowntrendCounter += 1
if ninePartTroughPeakDoubleDowntrend and not tenPartTroughPeakDoubleDowntrend and samplePeriodFilter
ninePartTroughPeakDoubleDowntrendCounter += 1
if tenPartTroughPeakDoubleDowntrend and not elevenPartTroughPeakDoubleDowntrend and samplePeriodFilter
tenPartTroughPeakDoubleDowntrendCounter += 1
if elevenPartTroughPeakDoubleDowntrend and not twelvePartTroughPeakDoubleDowntrend and samplePeriodFilter
elevenPartTroughPeakDoubleDowntrendCounter += 1
if twelvePartTroughPeakDoubleDowntrend and not thirteenPartTroughPeakDoubleDowntrend and samplePeriodFilter
twelvePartTroughPeakDoubleDowntrendCounter += 1
if thirteenPartTroughPeakDoubleDowntrend and samplePeriodFilter
thirteenPartTroughPeakDoubleDowntrendCounter += 1
twoPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(twoPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
threePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(threePartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
fourPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(fourPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
fivePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(fivePartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
sixPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(sixPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
sevenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(sevenPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
eightPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(eightPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
ninePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(ninePartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
tenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(tenPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
elevenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(elevenPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
twelvePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(twelvePartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
thirteenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend = str.tostring(math.round(thirteenPartPeakTroughDoubleUptrendCounter / onePartPeakTroughDoubleUptrendCounter * 100, 2))
twoPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(twoPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
threePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(threePartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
fourPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(fourPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
fivePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(fivePartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
sixPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(sixPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
sevenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(sevenPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
eightPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(eightPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
ninePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(ninePartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
tenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(tenPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
elevenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(elevenPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
twelvePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(twelvePartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
thirteenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend = str.tostring(math.round(thirteenPartTroughPeakDoubleDowntrendCounter / onePartTroughPeakDoubleDowntrendCounter * 100, 2))
twoThreeUpPeakTrough = str.tostring(math.round(threePartPeakTroughDoubleUptrendCounter / twoPartPeakTroughDoubleUptrendCounter * 100, 2))
threeFourUpPeakTrough = str.tostring(math.round(fourPartPeakTroughDoubleUptrendCounter / threePartPeakTroughDoubleUptrendCounter * 100, 2))
fourFiveUpPeakTrough = str.tostring(math.round(fivePartPeakTroughDoubleUptrendCounter / fourPartPeakTroughDoubleUptrendCounter * 100, 2))
fiveSixUpPeakTrough = str.tostring(math.round(sixPartPeakTroughDoubleUptrendCounter / fivePartPeakTroughDoubleUptrendCounter * 100, 2))
sixSevenUpPeakTrough = str.tostring(math.round(sevenPartPeakTroughDoubleUptrendCounter / sixPartPeakTroughDoubleUptrendCounter * 100, 2))
sevenEightUpPeakTrough = str.tostring(math.round(eightPartPeakTroughDoubleUptrendCounter / sevenPartPeakTroughDoubleUptrendCounter * 100, 2))
eightNineUpPeakTrough = str.tostring(math.round(ninePartPeakTroughDoubleUptrendCounter / eightPartPeakTroughDoubleUptrendCounter * 100, 2))
nineTenUpPeakTrough = str.tostring(math.round(tenPartPeakTroughDoubleUptrendCounter / ninePartPeakTroughDoubleUptrendCounter * 100, 2))
tenElevenUpPeakTrough = str.tostring(math.round(elevenPartPeakTroughDoubleUptrendCounter / tenPartPeakTroughDoubleUptrendCounter * 100, 2))
elevenTwelveUpPeakTrough = str.tostring(math.round(twelvePartPeakTroughDoubleUptrendCounter / elevenPartPeakTroughDoubleUptrendCounter * 100, 2))
twelveThirteenUpPeakTrough = str.tostring(math.round(thirteenPartPeakTroughDoubleUptrendCounter / twelvePartPeakTroughDoubleUptrendCounter * 100, 2))
twoThreeDownTroughPeak = str.tostring(math.round(threePartTroughPeakDoubleDowntrendCounter / twoPartTroughPeakDoubleDowntrendCounter * 100, 2))
threeFourDownTroughPeak = str.tostring(math.round(fourPartTroughPeakDoubleDowntrendCounter / threePartTroughPeakDoubleDowntrendCounter * 100, 2))
fourFiveDownTroughPeak = str.tostring(math.round(fivePartTroughPeakDoubleDowntrendCounter / fourPartTroughPeakDoubleDowntrendCounter * 100, 2))
fiveSixDownTroughPeak = str.tostring(math.round(sixPartTroughPeakDoubleDowntrendCounter / fivePartTroughPeakDoubleDowntrendCounter * 100, 2))
sixSevenDownTroughPeak = str.tostring(math.round(sevenPartTroughPeakDoubleDowntrendCounter / sixPartTroughPeakDoubleDowntrendCounter * 100, 2))
sevenEightDownTroughPeak = str.tostring(math.round(eightPartTroughPeakDoubleDowntrendCounter / sevenPartTroughPeakDoubleDowntrendCounter * 100, 2))
eightNineDownTroughPeak = str.tostring(math.round(ninePartTroughPeakDoubleDowntrendCounter / eightPartTroughPeakDoubleDowntrendCounter * 100, 2))
nineTenDownTroughPeak = str.tostring(math.round(tenPartTroughPeakDoubleDowntrendCounter / ninePartTroughPeakDoubleDowntrendCounter * 100, 2))
tenElevenDownTroughPeak = str.tostring(math.round(elevenPartTroughPeakDoubleDowntrendCounter / tenPartTroughPeakDoubleDowntrendCounter * 100, 2))
elevenTwelveDownTroughPeak = str.tostring(math.round(twelvePartTroughPeakDoubleDowntrendCounter / elevenPartTroughPeakDoubleDowntrendCounter * 100, 2))
twelveThirteenDownTroughPeak = str.tostring(math.round(thirteenPartTroughPeakDoubleDowntrendCounter / twelvePartTroughPeakDoubleDowntrendCounter * 100, 2))
//////////// table ////////////
doubleTrendTableInput = input.string(title = 'Position', defval = 'Top Right', options = ['Top Right', 'Top Center', 'Top Left', 'Bottom Right', 'Bottom Center', 'Bottom Left',
'Middle Right', 'Middle Center', 'Middle Left'], group = 'Table Positioning')
doubleTrendTablePosition = doubleTrendTableInput == 'Top Right' ? position.top_right : doubleTrendTableInput == 'Top Center' ? position.top_center : doubleTrendTableInput == 'Top Left' ? position.top_left :
doubleTrendTableInput == 'Bottom Right' ? position.bottom_right : doubleTrendTableInput == 'Bottom Center' ? position.bottom_center : doubleTrendTableInput == 'Bottom Left' ? position.bottom_left :
doubleTrendTableInput == 'Middle Right' ? position.middle_right : doubleTrendTableInput == 'Middle Center' ? position.middle_center : doubleTrendTableInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
var doubleTrendTable = table.new(doubleTrendTablePosition, 100, 100, border_width = 1)
table.cell(doubleTrendTable, 1, 0, text = 'Double Uptrends', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 0, text = '% Total', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 0, text = '% Last', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 0, text = 'Double Downtrends', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 0, text = '% Total', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 0, text = '% Last', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 0, 1, text = '1-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 1, text = str.tostring(onePartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 1, text = str.tostring(onePartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twoPartPeakTroughDoubleUptrendCounter >= 1 or twoPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 2, text = '2-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 2, text = str.tostring(twoPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 2, text = str.tostring(twoPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 2, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 2, text = str.tostring(twoPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 2, text = str.tostring(twoPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 2, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (threePartPeakTroughDoubleUptrendCounter >= 1 or threePartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 3, text = '3-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 3, text = str.tostring(threePartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 3, text = str.tostring(threePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 3, text = str.tostring(twoThreeUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 3, text = str.tostring(threePartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 3, text = str.tostring(threePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 3, text = str.tostring(twoThreeDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourPartPeakTroughDoubleUptrendCounter >= 1 or fourPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 4, text = '4-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 4, text = str.tostring(fourPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 4, text = str.tostring(fourPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 4, text = str.tostring(threeFourUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 4, text = str.tostring(fourPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 4, text = str.tostring(fourPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 4, text = str.tostring(threeFourDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fivePartPeakTroughDoubleUptrendCounter >= 1 or fivePartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 5, text = '5-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 5, text = str.tostring(fivePartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 5, text = str.tostring(fivePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 5, text = str.tostring(fourFiveUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 5, text = str.tostring(fivePartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 5, text = str.tostring(fivePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 5, text = str.tostring(fourFiveDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixPartPeakTroughDoubleUptrendCounter >= 1 or sixPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 6, text = '6-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 6, text = str.tostring(sixPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 6, text = str.tostring(sixPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 6, text = str.tostring(fiveSixUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 6, text = str.tostring(sixPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 6, text = str.tostring(sixPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 6, text = str.tostring(fiveSixDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sevenPartPeakTroughDoubleUptrendCounter >= 1 or sevenPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 7, text = '7-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 7, text = str.tostring(sevenPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 7, text = str.tostring(sevenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 7, text = str.tostring(sixSevenUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 7, text = str.tostring(sevenPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 7, text = str.tostring(sevenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 7, text = str.tostring(sixSevenDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eightPartPeakTroughDoubleUptrendCounter >= 1 or eightPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 8, text = '8-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 8, text = str.tostring(eightPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 8, text = str.tostring(eightPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 8, text = str.tostring(sevenEightUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 8, text = str.tostring(eightPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 8, text = str.tostring(eightPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 8, text = str.tostring(sevenEightDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (ninePartPeakTroughDoubleUptrendCounter >= 1 or ninePartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 9, text = '9-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 9, text = str.tostring(ninePartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 9, text = str.tostring(ninePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 9, text = str.tostring(eightNineUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 9, text = str.tostring(ninePartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 9, text = str.tostring(ninePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 9, text = str.tostring(eightNineDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (tenPartPeakTroughDoubleUptrendCounter >= 1 or tenPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 10, text = '10-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 10, text = str.tostring(tenPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 10, text = str.tostring(tenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 10, text = str.tostring(nineTenUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 10, text = str.tostring(tenPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 10, text = str.tostring(tenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 10, text = str.tostring(nineTenDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (elevenPartPeakTroughDoubleUptrendCounter >= 1 or elevenPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 11, text = '11-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 11, text = str.tostring(elevenPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 11, text = str.tostring(elevenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 11, text = str.tostring(tenElevenUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 11, text = str.tostring(elevenPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 11, text = str.tostring(elevenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 11, text = str.tostring(tenElevenDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twelvePartPeakTroughDoubleUptrendCounter >= 1 or twelvePartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 12, text = '12-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 12, text = str.tostring(twelvePartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 12, text = str.tostring(twelvePartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 12, text = str.tostring(elevenTwelveUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 12, text = str.tostring(twelvePartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 12, text = str.tostring(twelvePartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 12, text = str.tostring(elevenTwelveDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirteenPartPeakTroughDoubleUptrendCounter >= 1 or thirteenPartTroughPeakDoubleDowntrendCounter >= 1)
table.cell(doubleTrendTable, 0, 13, text = '13-Part', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 1, 13, text = str.tostring(thirteenPartPeakTroughDoubleUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 2, 13, text = str.tostring(thirteenPartPeakTroughDoubleUptrendPercentageTotalDoubleUptrend), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 3, 13, text = str.tostring(twelveThirteenUpPeakTrough), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 5, 13, text = str.tostring(thirteenPartTroughPeakDoubleDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 6, 13, text = str.tostring(thirteenPartTroughPeakDoubleDowntrendPercentageTotalDoubleDowntrend), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleTrendTable, 7, 13, text = str.tostring(twelveThirteenDownTroughPeak), bgcolor = color.red, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(doubleTrendTable, 0, 14, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
|
Opening Hour/Closing Hour Indices Statistics: high/low times; 5m | https://www.tradingview.com/script/IXXjCb5w-Opening-Hour-Closing-Hour-Indices-Statistics-high-low-times-5m/ | twingall | https://www.tradingview.com/u/twingall/ | 60 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//Designed for use on US indices: ES, NQ (S&P, SPY; US100, etc etc)
// Idea is to get some statistics of time of high & time of low in both the opening hour (9:30-10:30am NY time) and the closing hour (15:00-1600 NY time)
// ES1! 77 days of history; SPX or SPY circa 250 days of history (all besed on 5min chart)
// Designed for use on 5min chart so we can get more meaningful comparison of % occurence of a certain time of high / time of low within said hour (i.e. group them in 5min buckets in stead of 1min buckets, for more meaningful statisitcal comparison)
// simplified using counters instead of looping array function =>> much faster load time with same results
// 31st March 2023
// Β© twingall
//@version=5
indicator(title='Opening Hour & Closing Hour Indices Statistics', shorttitle='Indices Stats: opening Hr & closing hr', overlay=true, max_bars_back =5000)
//user inputs:
showStats = input.bool(true, "show Statistics", group = 'Statistics, Sessions, Timezones', inline = '1',tooltip = "only works on the 5 minute timeframe")
showOpenHrStats = input.bool(true, "USER HOUR #1", group = 'Statistics, Sessions, Timezones', inline = '2')
showCloseHrStats = input.bool(true, "USER HOUR #2", group = 'Statistics, Sessions, Timezones', inline = '2')
showRealtime = input.bool(false, "// also show latest (last 2 sessions)",group = 'Statistics, Sessions, Timezones',inline ='3')
timeZone = input.string("America/New_York", group = 'Statistics, Sessions, Timezones', inline = '7', options =["America/New_York", "GMT-10", "GMT-9", "GMT-8", "GMT-7", "GMT-6", "GMT-5", "GMT-4", "GMT-3", "GMT-2", "GMT-1", "GMT", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11", "GMT+12", "GMT+13"], tooltip = "Note that when changing timezone; the data WILL represent the hour in the newly shifted vertical background highlighted areas; but the 'title time' in the statistics box will still show the New York Time\n\n you can verify this by toggling on 'also show latest (last 2 sessions)' amd checking timings/prices of recent highest/lowest of the highlighted hour")
showTable = input.bool(true, "Table", group = "Display Settings", inline ='1' )
tabPos = input.string(position.top_right, "|| Position:", group = "Display Settings", inline ='1', options = [ position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right])
tabCol = input.color(color.new(color.gray, 74), "|| Bg Color:", group = "Display Settings", inline ='1')
txtCol = input.color(color.red, "|| txt Color:", group = "Display Settings", inline ='1')
showOpeningHour= input(defval=true, title='USER HOUR #1 background highlight',group = "Display Settings", inline = '4')
openingHrCol = input.color(color.new(color.fuchsia, 67), "",group = "Display Settings", inline = '4')
showClosingHour = input(defval=true, title='USER HOUR #2 background highlight',group = "Display Settings", inline = '5')
closingHrCol = input.color(color.new(color.blue, 67), "",group = "Display Settings", inline = '5')
precision = input.int(0, "decimal precision for %", minval = 0 ,group = "Display Settings", inline = '6')
is5min = timeframe.period == "5"
is1min = timeframe.period == "1"
// ~~ highlight opening hour & closing hour
openHr = input.session("0930-1030", "User Hour #1 (format: 'XX:30-XX:30')", group = 'Statistics, Sessions, Timezones', inline = '5', options = ["0030-0130","0130-0230","0230-0330","0330-0430","0430-0530","0530-0630","0630-0730", "0730-0830", "0830-0930","0930-1030","1030-1130","1130-1230","1230-1330", "1330-1430", "1430-1530","1530-1630","1630-1730","1730-1830", "1830-1930", "1930-2030","2030-2130","2130-2230","2230-2330", "2330-0030"],
tooltip = "Defaults to NY Opening hour (9:30-10:30am)\n\nCan be user-defined to any ##:30-##:30 hour of the day to find the high/low stats for that hour period")
openHrSess=time(timeframe.period, openHr, timeZone )
inOpenHr = nz(openHrSess)
closeHr = input.session("1500-1600", "User Hour #2 (format: 'XX:00-XX:00')", group = 'Statistics, Sessions, Timezones', inline = '6', options = ["0000-0100","0100-0200","0200-0300","0300-0400","0400-0500","0500-0600","0600-0700","0700-0800","0800-0900","0900-1000","1000-1100", "1100-1200","1200-1300","1300-1400","1400-1500","1500-1600", "1600-1700","1700-1800", "1800-1900","1900-2000","2000-2100","2100-2200","2200-2300", "2300-0000"],
tooltip = "Defaults to NY Closing hour (15:00-16:00)\n\nCan be user-defined to any ##:00-##:00 hour of the day to find the high/low stats for that hour period")
closeHrSess=time(timeframe.period, closeHr, timeZone )
incloseHr = nz(closeHrSess)
timeTitleHr(string sess, int rank)=>
string strTime = na
if str.substring(sess, 2,4) == "00"
strTime :=rank ==0?str.substring(sess, 0, 2) +":"+ str.substring(sess, 2,4):rank ==1?str.substring(sess, 0, 2) +":05":rank ==2?str.substring(sess, 0, 2) +":10":rank ==3?str.substring(sess, 0, 2) +":15":
rank ==4?str.substring(sess, 0, 2) +":20":rank ==5?str.substring(sess, 0, 2)+":25":rank ==6?str.substring(sess, 0, 2) +":30":rank ==7?str.substring(sess, 0, 2) +":35": rank ==8?str.substring(sess, 0, 2) +":40":
rank ==9?str.substring(sess, 0, 2) +":45":rank ==10?str.substring(sess, 0, 2) +":50":rank ==11?str.substring(sess, 0, 2) +":55":na
if str.substring(sess, 2,4) == "30"
strTime :=rank ==0?str.substring(sess, 0, 2) +":"+ str.substring(sess, 2,4):rank ==1?str.substring(sess, 0, 2) +":35":rank ==2?str.substring(sess, 0, 2) +":40":rank ==3?str.substring(sess, 0, 2) +":45":
rank ==4?str.substring(sess, 0, 2) +":50":rank ==5?str.substring(sess, 0, 2)+":55":rank ==6?str.substring(sess, 5, 7) +":00":rank ==7?str.substring(sess, 5, 7) +":05": rank ==8?str.substring(sess, 5, 7) +":10":
rank ==9?str.substring(sess, 5, 7) +":15":rank ==10?str.substring(sess, 5, 7) +":20":rank ==11?str.substring(sess, 5, 7) +":25":na
strTime
bgcolor(showOpeningHour and (is5min or is1min) and inOpenHr? openingHrCol : na)
bgcolor(showClosingHour and (is5min or is1min) and incloseHr? closingHrCol : na)
openHrCond5 = inOpenHr and inOpenHr [11] and not inOpenHr[12]
closeHrCond5 = showClosingHour and incloseHr and incloseHr[11] and not incloseHr[12]
openHrCond1 = inOpenHr and inOpenHr [59] and not inOpenHr[60]
closeHrCond1 = showClosingHour and incloseHr and incloseHr[59] and not incloseHr[60]
highest5min = ta.highest(high, 12)
lowest5min = ta.lowest(low, 12)
//only applying to 1min chart
highest1min = ta.highest(high, 60)
lowest1min = ta.lowest(low, 60)
var float h5op = na, var float h5cl = na
var float l5op = na, var float l5cl = na
var float h1op = na, var float h1cl = na
var float l1op = na, var float l1cl = na
var int th_5op = na, var int th_5cl = na
var int tl_5op = na, var int tl_5cl = na
var int th_1op = na, var int th_1cl = na
var int tl_1op = na, var int tl_1cl = na
offset_h5op = ta.highestbars(high,12)
offset_l5op = ta.lowestbars(low, 12)
offset_h1op = ta.highestbars(high,60)
offset_l1op = ta.lowestbars(low, 60)
offset_h5cl = ta.highestbars(high,12)
offset_l5cl = ta.lowestbars(low, 12)
offset_h1cl = ta.highestbars(high,60)
offset_l1cl = ta.lowestbars(low, 60)
_bar = timeframe.in_seconds(timeframe.period)*1000
var int cnt930h =0, var int cnt935h =0, var int cnt940h =0, var int cnt945h =0, var int cnt950h =0, var int cnt955h =0, var int cnt1000h =0, var int cnt1005h =0, var int cnt1010h =0, var int cnt1015h =0, var int cnt1020h =0, var int cnt1025h =0
var int cnt930l =0, var int cnt935l =0, var int cnt940l =0, var int cnt945l =0, var int cnt950l =0, var int cnt955l =0, var int cnt1000l =0, var int cnt1005l =0, var int cnt1010l =0, var int cnt1015l =0, var int cnt1020l =0, var int cnt1025l =0
var int cnt1500h =0, var int cnt1505h =0, var int cnt1510h =0, var int cnt1515h =0, var int cnt1520h =0, var int cnt1525h =0, var int cnt1530h =0, var int cnt1535h =0, var int cnt1540h =0, var int cnt1545h =0, var int cnt1550h =0, var int cnt1555h =0
var int cnt1500l =0, var int cnt1505l =0, var int cnt1510l =0, var int cnt1515l =0, var int cnt1520l =0, var int cnt1525l =0, var int cnt1530l =0, var int cnt1535l =0, var int cnt1540l =0, var int cnt1545l =0, var int cnt1550l =0, var int cnt1555l =0
var int cntTotOp =0, var int cntTotCl =0
if openHrCond5 and is5min
cntTotOp+=1
h5op:= highest5min
th_5op:=time - (-offset_h5op*_bar)
l5op:=lowest5min
tl_5op:=time - (-offset_l5op*_bar)
//increment the counters for highs
cnt930h+=(offset_h5op==-11?1:0), cnt935h+=(offset_h5op==-10?1:0), cnt940h+=(offset_h5op==-9?1:0), cnt945h+=(offset_h5op==-8?1:0),cnt950h+=(offset_h5op==-7?1:0),cnt955h+=(offset_h5op==-6?1:0)
cnt1000h+=(offset_h5op==-5?1:0),cnt1005h+=(offset_h5op==-4?1:0), cnt1010h+=(offset_h5op==-3?1:0), cnt1015h+=(offset_h5op==-2?1:0), cnt1020h+=(offset_h5op==-1?1:0),cnt1025h+=(offset_h5op==0?1:0)
//increment the counters for lows
cnt930l+=(offset_l5op==-11?1:0), cnt935l+=(offset_l5op==-10?1:0), cnt940l+=(offset_l5op==-9?1:0), cnt945l+=(offset_l5op==-8?1:0),cnt950l+=(offset_l5op==-7?1:0),cnt955l+=(offset_l5op==-6?1:0)
cnt1000l+=(offset_l5op==-5?1:0),cnt1005l+=(offset_l5op==-4?1:0), cnt1010l+=(offset_l5op==-3?1:0), cnt1015l+=(offset_l5op==-2?1:0), cnt1020l+=(offset_l5op==-1?1:0),cnt1025l+=(offset_l5op==0?1:0)
if closeHrCond5 and is5min
cntTotCl+=1
h5cl:= highest5min
th_5cl:=time - (-offset_h5cl*_bar)
l5cl:=lowest5min
tl_5cl:=time - (-offset_l5cl*_bar)
//increment the counters for highs
cnt1500h+=(offset_h5cl==-11?1:0), cnt1505h+=(offset_h5cl==-10?1:0), cnt1510h+=(offset_h5cl==-9?1:0), cnt1515h+=(offset_h5cl==-8?1:0),cnt1520h+=(offset_h5cl==-7?1:0),cnt1525h+=(offset_h5cl==-6?1:0)
cnt1530h+=(offset_h5cl==-5?1:0),cnt1535h+=(offset_h5cl==-4?1:0), cnt1540h+=(offset_h5cl==-3?1:0), cnt1545h+=(offset_h5cl==-2?1:0), cnt1550h+=(offset_h5cl==-1?1:0),cnt1555h+=(offset_h5cl==0?1:0)
//increment the counters for lows
cnt1500l+=(offset_l5cl==-11?1:0), cnt1505l+=(offset_l5cl==-10?1:0), cnt1510l+=(offset_l5cl==-9?1:0), cnt1515l+=(offset_l5cl==-8?1:0),cnt1520l+=(offset_l5cl==-7?1:0),cnt1525l+=(offset_l5cl==-6?1:0)
cnt1530l+=(offset_l5cl==-5?1:0),cnt1535l+=(offset_l5cl==-4?1:0), cnt1540l+=(offset_l5cl==-3?1:0), cnt1545l+=(offset_l5cl==-2?1:0), cnt1550l+=(offset_l5cl==-1?1:0),cnt1555l+=(offset_l5cl==0?1:0)
//only for realtime on 1min chart, not for 5min chart statistics panel
if openHrCond1 and is1min
h1op:= highest1min
th_1op:=time - (-offset_h1op*_bar)
l1op:=lowest1min
tl_1op:=time - (-offset_l1op*_bar)
if closeHrCond1 and is1min
h1cl:= highest1min
th_1cl:=time - (-offset_h1cl *_bar)
l1cl:=lowest1min
tl_1cl:=time - (-offset_l1cl *_bar)
// Percent Function
pct(countSum, int _int)=>
float pct = 0
if countSum>0
pct:= math.round((_int/countSum)*100,precision)
pct
//// ~ Display Table ~
var Table = table.new(tabPos, columns = 8, rows =18, bgcolor = tabCol, border_width = 1)
if barstate.islast and showTable and showRealtime and (is5min or is1min)
table.cell(Table, 1, 0, "User Hour #1\n" + openHr, text_color = txtCol, bgcolor = openingHrCol)
table.cell(Table, 3, 0, "User Hour #2\n"+closeHr, text_color = txtCol, bgcolor = closingHrCol)
table.cell(Table, 0, 1, "[latest] high =", text_color = txtCol, bgcolor = closingHrCol)
table.cell(Table, 0, 2, "[latest] low =", text_color = txtCol, bgcolor = closingHrCol)
table.cell(Table, 2, 0, " When? ", text_color = txtCol)
table.cell(Table, 4, 0, " When? ", text_color = txtCol)
table.cell(Table, 0, 0, "Timeframe =\n"+ (is5min?"5 min":"1 min"), text_color = txtCol)
if is5min
table.cell(Table, 1, 1,str.tostring(h5op, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 2, str.tostring(l5op, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 1, str.format_time(th_5op , "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 2, str.format_time(tl_5op, "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 3, 1, str.tostring(h5cl, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 3, 2, str.tostring(l5cl, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 1, str.format_time(th_5cl, "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 2, str.format_time(tl_5cl, "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
if is1min
table.cell(Table, 1, 1, str.tostring(h1op, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 2, "low = " +str.tostring(l1op, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 1, str.format_time(th_1op, "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 2, str.format_time(tl_1op, "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 3, 1, str.tostring(h1cl, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 3, 2, str.tostring(l1cl, format.mintick),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 1, str.format_time(th_1cl, "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 2, str.format_time(tl_1cl, "HH:mm", "America/New_York"),bgcolor = tabCol, text_color = txtCol)
if barstate.islast and showTable and is5min and showStats
table.cell(Table, 0, 3, "~~STATISTICS~~\n"+ str.tostring(cntTotOp) + " = Trading Days of history | NYtime", text_color = txtCol, bgcolor = color.yellow, text_halign = text.align_center, text_size = size.large)
table.merge_cells(Table, 0, 3, 5, 3)
if showOpenHrStats
table.cell(Table, 0, 4, "USER HOUR #1:",bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 1, 4, " HIGH ",bgcolor = color.new(color.green,70), text_color = txtCol)
table.cell(Table, 2, 4, " LOW ",bgcolor = color.new(color.red,70), text_color = txtCol)
table.cell(Table, 0, 5, timeTitleHr(openHr, 0),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 6, timeTitleHr(openHr, 1),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 7, timeTitleHr(openHr, 2),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 8, timeTitleHr(openHr, 3),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 9, timeTitleHr(openHr, 4),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 10, timeTitleHr(openHr, 5),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 11, timeTitleHr(openHr, 6),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 12, timeTitleHr(openHr, 7),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 13, timeTitleHr(openHr, 8),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 14, timeTitleHr(openHr, 9),bgcolor = openingHrCol, text_color = txtCol)
table.cell(Table, 0, 15, timeTitleHr(openHr, 10),bgcolor= openingHrCol, text_color = txtCol)
table.cell(Table, 0, 16, timeTitleHr(openHr, 11),bgcolor= openingHrCol, text_color = txtCol)
table.cell(Table, 1, 5, str.tostring(pct(cntTotOp,cnt930h)) +" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 6, str.tostring(pct(cntTotOp,cnt935h)) +" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 7, str.tostring(pct(cntTotOp,cnt940h)) +" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 8, str.tostring(pct(cntTotOp,cnt945h)) +" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 9, str.tostring(pct(cntTotOp,cnt950h)) +" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 10, str.tostring(pct(cntTotOp,cnt955h)) +" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 11, str.tostring(pct(cntTotOp,cnt1000h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 12, str.tostring(pct(cntTotOp,cnt1005h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 13, str.tostring(pct(cntTotOp,cnt1010h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 14, str.tostring(pct(cntTotOp,cnt1015h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 15, str.tostring(pct(cntTotOp,cnt1020h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 1, 16, str.tostring(pct(cntTotOp,cnt1025h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 5, str.tostring(pct(cntTotOp,cnt930l))+ " %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 6, str.tostring(pct(cntTotOp,cnt935l))+ " %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 7, str.tostring(pct(cntTotOp,cnt940l))+ " %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 8, str.tostring(pct(cntTotOp,cnt945l))+ " %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 9, str.tostring(pct(cntTotOp,cnt950l))+ " %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 10, str.tostring(pct(cntTotOp,cnt955l))+ " %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 11, str.tostring(pct(cntTotOp,cnt1000l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 12, str.tostring(pct(cntTotOp,cnt1005l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 13, str.tostring(pct(cntTotOp,cnt1010l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 14, str.tostring(pct(cntTotOp,cnt1015l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 15, str.tostring(pct(cntTotOp,cnt1020l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 2, 16, str.tostring(pct(cntTotOp,cnt1025l))+" %",bgcolor = tabCol, text_color = txtCol)
if showCloseHrStats
table.cell(Table, 3, 4, "USER HOUR #2:",bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 4, 4, " HIGH ",bgcolor = color.new(color.green,70), text_color = txtCol)
table.cell(Table, 5, 4, " LOW ",bgcolor = color.new(color.red,70), text_color = txtCol)
table.cell(Table, 3, 5, timeTitleHr(closeHr, 0), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 6, timeTitleHr(closeHr, 1), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 7, timeTitleHr(closeHr, 2), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 8, timeTitleHr(closeHr, 3), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 9, timeTitleHr(closeHr, 4), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 10, timeTitleHr(closeHr, 5), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 11, timeTitleHr(closeHr, 6), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 12, timeTitleHr(closeHr, 7), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 13, timeTitleHr(closeHr, 8), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 14, timeTitleHr(closeHr, 9), bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 15, timeTitleHr(closeHr, 10),bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 3, 16, timeTitleHr(closeHr, 11),bgcolor = closingHrCol, text_color = txtCol)
table.cell(Table, 4, 5, str.tostring(pct(cntTotCl,cnt1500h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 6, str.tostring(pct(cntTotCl,cnt1505h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 7, str.tostring(pct(cntTotCl,cnt1510h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 8, str.tostring(pct(cntTotCl,cnt1515h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 9, str.tostring(pct(cntTotCl,cnt1520h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 10, str.tostring(pct(cntTotCl,cnt1525h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 11, str.tostring(pct(cntTotCl,cnt1530h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 12, str.tostring(pct(cntTotCl,cnt1535h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 13, str.tostring(pct(cntTotCl,cnt1540h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 14, str.tostring(pct(cntTotCl,cnt1545h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 15, str.tostring(pct(cntTotCl,cnt1550h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 4, 16, str.tostring(pct(cntTotCl,cnt1555h))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 5, str.tostring(pct(cntTotCl,cnt1500l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 6, str.tostring(pct(cntTotCl,cnt1505l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 7, str.tostring(pct(cntTotCl,cnt1510l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 8, str.tostring(pct(cntTotCl,cnt1515l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 9, str.tostring(pct(cntTotCl,cnt1520l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 10, str.tostring(pct(cntTotCl,cnt1525l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 11, str.tostring(pct(cntTotCl,cnt1530l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 12, str.tostring(pct(cntTotCl,cnt1535l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 13, str.tostring(pct(cntTotCl,cnt1540l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 14, str.tostring(pct(cntTotCl,cnt1545l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 15, str.tostring(pct(cntTotCl,cnt1550l))+" %",bgcolor = tabCol, text_color = txtCol)
table.cell(Table, 5, 16, str.tostring(pct(cntTotCl,cnt1555l))+" %",bgcolor = tabCol, text_color = txtCol) |
Fibonacci Ratios [theEccentricTrader] | https://www.tradingview.com/script/tIVkvl5I-Fibonacci-Ratios-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 63 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Fibonacci Ratios [theEccentricTrader]', overlay = true)
//////////// shsl ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
peak = ta.valuewhen(shPrice, shPrice, 0)
trough = ta.valuewhen(slPrice, slPrice, 0)
shCloseBarIndex = ta.valuewhen(shPrice, bar_index, 0)
slCloseBarIndex = ta.valuewhen(slPrice, bar_index, 0)
//////////// lines and labels ////////////
addExtensions = input(defval = true, title = 'Show Fibonacci Extensions', group = "Fibonacci Extensions")
zeroLineColor = input(defval = color.blue, title = '00.0% Color', inline = '1', group = "Line Coloring")
twoThreeSixLineColor = input(defval = color.green, title = '23.6% Color', inline = '2', group = "Line Coloring")
threeEightTwoLineColor = input(defval = color.orange, title = '38.2% Color', inline = '3', group = "Line Coloring")
fiveHundredLineColor = input(defval = color.red, title = '50.0% Color', inline = '4', group = "Line Coloring")
sixOneEightLineColor = input(defval = color.yellow, title = '61.8% Color', inline = '5', group = "Line Coloring")
sevenEightSixLineColor = input(defval = color.maroon, title = '78.6% Color', inline = '6', group = "Line Coloring")
oneHundredLineColor = input(defval = color.purple, title = '100.0% Color', inline = '1', group = "Line Coloring")
oneSixOneEightLineColor = input(defval = color.yellow, title = '161.8% Color', inline = '2', group = "Line Coloring")
twoSixOneEightLineColor = input(defval = color.blue, title = '261.8% Color', inline = '3', group = "Line Coloring")
threeSixOneEightLineColor = input(defval = color.green, title = '361.8% Color', inline = '4', group = "Line Coloring")
fourTwoThreeSixLineColor = input(defval = color.orange, title = '423.6% Color', inline = '5', group = "Line Coloring")
fourSixOneEightLineColor = input(defval = color.red, title = '461.8% Color', inline = '6', group = "Line Coloring")
selectExtend = input.string(title = 'Extend Line Type', defval = 'Right', options = ['None', 'Right', 'Left', 'Both'], group = "Line Extension")
extendLines = selectExtend == 'None' ? extend.none : selectExtend == 'Right' ? extend.right : selectExtend == 'Left' ? extend.left : selectExtend == 'Both' ? extend.both : na
symbolRoundNumber = syminfo.mintick >= 0.1 ? 1 : syminfo.mintick == 0.01 ? 2 : syminfo.mintick == 0.001 ? 3 : syminfo.mintick == 0.0001 ? 4 : syminfo.mintick == 0.00001 ? 5 :
syminfo.mintick == 0.000001 ? 6 : syminfo.mintick == 0.0000001 ? 7 : syminfo.mintick == 0.00000001 ? 8 : na
addLabels = input(defval = true, title = 'Show Labels', group = "Labels")
labelTextColor = input(defval = color.white, title = 'Label Text Color', group = "Label Coloring")
labelTextOutlineColor = input(defval = color.black, title = 'Label Text Outline Color', group = "Label Coloring")
var zeroLine = line.new(na, na, na, na, color = zeroLineColor, style = line.style_solid, extend = extendLines)
var twoThreeSixLine = line.new(na, na, na, na, color = twoThreeSixLineColor, style = line.style_solid, extend = extendLines)
var threeEightTwoLine = line.new(na, na, na, na, color = threeEightTwoLineColor, style = line.style_solid, extend = extendLines)
var fiftyLine = line.new(na, na, na, na, color = fiveHundredLineColor, style = line.style_solid, extend = extendLines)
var sixOneEightLine = line.new(na, na, na, na, color = sixOneEightLineColor, style = line.style_solid, extend = extendLines)
var sevenEightSixLine = line.new(na, na, na, na, color = sevenEightSixLineColor, style = line.style_solid, extend = extendLines)
var oneHundredLine = line.new(na, na, na, na, color = oneHundredLineColor, style = line.style_solid, extend = extendLines)
var oneSixOneEightLine = line.new(na, na, na, na, color = oneSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var twoSixOneEightLine = line.new(na, na, na, na, color = twoSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var threeSixOneEightLine = line.new(na, na, na, na, color = threeSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var fourTwoThreeSixLine = line.new(na, na, na, na, color = fourTwoThreeSixLineColor, style = line.style_solid, extend = extendLines)
var fourSixOneEightLine = line.new(na, na, na, na, color = fourSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var zeroLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var twoThreeSixLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var threeEightTwoLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var fiftyLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var sixOneEightLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var sevenEightSixLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var oneHundredLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var oneSixOneEightLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var twoSixOneEightLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var threeSixOneEightLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var fourTwoThreeSixLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var fourSixOneEightLabel = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
if slPrice
line.set_xy1(zeroLine, shCloseBarIndex - 1, trough)
line.set_xy2(zeroLine, bar_index, trough)
line.set_xy1(twoThreeSixLine, shCloseBarIndex - 1, trough + (peak - trough) * 0.236)
line.set_xy2(twoThreeSixLine, bar_index, trough + (peak - trough) * 0.236)
line.set_xy1(threeEightTwoLine, shCloseBarIndex - 1, trough + (peak - trough) * 0.382)
line.set_xy2(threeEightTwoLine, bar_index, trough + (peak - trough) * 0.382)
line.set_xy1(fiftyLine, shCloseBarIndex - 1, trough + (peak - trough) * 0.5)
line.set_xy2(fiftyLine, bar_index, trough + (peak - trough) * 0.5)
line.set_xy1(sixOneEightLine, shCloseBarIndex - 1, trough + (peak - trough) * 0.618)
line.set_xy2(sixOneEightLine, bar_index, trough + (peak - trough) * 0.618)
line.set_xy1(sevenEightSixLine, shCloseBarIndex - 1, trough + (peak - trough) * 0.786)
line.set_xy2(sevenEightSixLine, bar_index, trough + (peak - trough) * 0.786)
line.set_xy1(oneHundredLine, shCloseBarIndex - 1, peak)
line.set_xy2(oneHundredLine, bar_index, peak)
line.set_xy1(oneSixOneEightLine, addExtensions ? shCloseBarIndex - 1 : na, addExtensions ? peak + (peak - trough) * 0.618 : na)
line.set_xy2(oneSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? peak + (peak - trough) * 0.618 : na)
line.set_xy1(twoSixOneEightLine, addExtensions ? shCloseBarIndex - 1 : na, addExtensions ? peak + (peak - trough) * 1.618 : na)
line.set_xy2(twoSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? peak + (peak - trough) * 1.618 : na)
line.set_xy1(threeSixOneEightLine, addExtensions ? shCloseBarIndex - 1 : na, addExtensions ? peak + (peak - trough) * 2.618 : na)
line.set_xy2(threeSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? peak + (peak - trough) * 2.618 : na)
line.set_xy1(fourTwoThreeSixLine, addExtensions ? shCloseBarIndex - 1 : na, addExtensions ? peak + (peak - trough) * 3.236 : na)
line.set_xy2(fourTwoThreeSixLine, addExtensions ? bar_index : na, addExtensions ? peak + (peak - trough) * 3.236 : na)
line.set_xy1(fourSixOneEightLine, addExtensions ? shCloseBarIndex - 1 : na, addExtensions ? peak + (peak - trough) * 3.618 : na)
line.set_xy2(fourSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? peak + (peak - trough) * 3.618 : na)
zeroPrice = line.get_price(zeroLine, bar_index)
label.set_x(zeroLabel, addLabels ? shCloseBarIndex - 1 : na)
label.set_y(zeroLabel, addLabels ? trough : na)
label.set_text(zeroLabel, text = '0.00%\n' + str.tostring(math.round(zeroPrice, symbolRoundNumber)))
twoThreeSixPrice = line.get_price(twoThreeSixLine, bar_index)
label.set_x(twoThreeSixLabel, addLabels ? shCloseBarIndex - 1 : na)
label.set_y(twoThreeSixLabel, addLabels ? trough + (peak - trough) * 0.236 : na)
label.set_text(twoThreeSixLabel, text = '23.6%\n' + str.tostring(math.round(twoThreeSixPrice, symbolRoundNumber)))
threeEightTwoPrice = line.get_price(threeEightTwoLine, bar_index)
label.set_x(threeEightTwoLabel, addLabels ? shCloseBarIndex - 1 : na)
label.set_y(threeEightTwoLabel, addLabels ? trough + (peak - trough) * 0.382 : na)
label.set_text(threeEightTwoLabel, text = '38.2%\n' + str.tostring(math.round(threeEightTwoPrice, symbolRoundNumber)))
fiftyPrice = line.get_price(fiftyLine, bar_index)
label.set_x(fiftyLabel, addLabels ? shCloseBarIndex - 1 : na)
label.set_y(fiftyLabel, addLabels ? trough + (peak - trough) * 0.5 : na)
label.set_text(fiftyLabel, text = '50.0%\n' + str.tostring(math.round(fiftyPrice, symbolRoundNumber)))
sixOneEightPrice = line.get_price(sixOneEightLine, bar_index)
label.set_x(sixOneEightLabel, addLabels ? shCloseBarIndex - 1 : na)
label.set_y(sixOneEightLabel, addLabels ? trough + (peak - trough) * 0.618 : na)
label.set_text(sixOneEightLabel, text = '61.8%\n' + str.tostring(math.round(sixOneEightPrice, symbolRoundNumber)))
sevenEightSixPrice = line.get_price(sevenEightSixLine, bar_index)
label.set_x(sevenEightSixLabel, addLabels ? shCloseBarIndex - 1 : na)
label.set_y(sevenEightSixLabel, addLabels ? trough + (peak - trough) * 0.786 : na)
label.set_text(sevenEightSixLabel, text = '78.6%\n' + str.tostring(math.round(sevenEightSixPrice, symbolRoundNumber)))
oneHundredPrice = line.get_price(oneHundredLine, bar_index)
label.set_x(oneHundredLabel, addLabels ? shCloseBarIndex - 1 : na)
label.set_y(oneHundredLabel, addLabels ? peak : na)
label.set_text(oneHundredLabel, text = '100.0%\n' + str.tostring(math.round(oneHundredPrice, symbolRoundNumber)))
oneSixOneEightPrice = line.get_price(oneSixOneEightLine, bar_index)
label.set_x(oneSixOneEightLabel, addExtensions and addLabels ? shCloseBarIndex - 1 : na)
label.set_y(oneSixOneEightLabel, addExtensions and addLabels ? peak + (peak - trough) * 0.618 : na)
label.set_text(oneSixOneEightLabel, text = '161.8%\n' + str.tostring(math.round(oneSixOneEightPrice, symbolRoundNumber)))
twoSixOneEightPrice = line.get_price(twoSixOneEightLine, bar_index)
label.set_x(twoSixOneEightLabel, addExtensions and addLabels ? shCloseBarIndex - 1 : na)
label.set_y(twoSixOneEightLabel, addExtensions and addLabels ? peak + (peak - trough) * 1.618 : na)
label.set_text(twoSixOneEightLabel, text = '261.8%\n' + str.tostring(math.round(twoSixOneEightPrice, symbolRoundNumber)))
threeSixOneEightPrice = line.get_price(threeSixOneEightLine, bar_index)
label.set_x(threeSixOneEightLabel, addExtensions and addLabels ? shCloseBarIndex - 1 : na)
label.set_y(threeSixOneEightLabel, addExtensions and addLabels ? peak + (peak - trough) * 2.618 : na)
label.set_text(threeSixOneEightLabel, text = '361.8%\n' + str.tostring(math.round(threeSixOneEightPrice, symbolRoundNumber)))
fourTwoThreeSixPrice = line.get_price(fourTwoThreeSixLine, bar_index)
label.set_x(fourTwoThreeSixLabel, addExtensions and addLabels ? shCloseBarIndex - 1 : na)
label.set_y(fourTwoThreeSixLabel, addExtensions and addLabels ? peak + (peak - trough) * 3.236 : na)
label.set_text(fourTwoThreeSixLabel, text = '423.6%\n' + str.tostring(math.round(fourTwoThreeSixPrice, symbolRoundNumber)))
fourSixOneEightPrice = line.get_price(fourSixOneEightLine, bar_index)
label.set_x(fourSixOneEightLabel, addExtensions and addLabels ? shCloseBarIndex - 1 : na)
label.set_y(fourSixOneEightLabel, addExtensions and addLabels ? peak + (peak - trough) * 3.618 : na)
label.set_text(fourSixOneEightLabel, text = '461.8%\n' + str.tostring(math.round(fourSixOneEightPrice, symbolRoundNumber)))
if shPrice
line.set_xy1(zeroLine, slCloseBarIndex - 1, peak)
line.set_xy2(zeroLine, bar_index, peak)
line.set_xy1(twoThreeSixLine, slCloseBarIndex - 1, peak - (peak - trough) * 0.236)
line.set_xy2(twoThreeSixLine, bar_index, peak - (peak - trough) * 0.236)
line.set_xy1(threeEightTwoLine, slCloseBarIndex - 1, peak - (peak - trough) * 0.382)
line.set_xy2(threeEightTwoLine, bar_index, peak - (peak - trough) * 0.382)
line.set_xy1(fiftyLine, slCloseBarIndex - 1, peak - (peak - trough) * 0.5)
line.set_xy2(fiftyLine, bar_index, peak - (peak - trough) * 0.5)
line.set_xy1(sixOneEightLine, slCloseBarIndex - 1, peak - (peak - trough) * 0.618)
line.set_xy2(sixOneEightLine, bar_index, peak - (peak - trough) * 0.618)
line.set_xy1(sevenEightSixLine, slCloseBarIndex - 1, peak - (peak - trough) * 0.786)
line.set_xy2(sevenEightSixLine, bar_index, peak - (peak - trough) * 0.786)
line.set_xy1(oneHundredLine, slCloseBarIndex - 1, trough)
line.set_xy2(oneHundredLine, bar_index, trough)
line.set_xy1(oneSixOneEightLine, addExtensions ? slCloseBarIndex - 1 : na, addExtensions ? trough - (peak - trough) * 0.618 : na)
line.set_xy2(oneSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? trough - (peak - trough) * 0.618 : na)
line.set_xy1(twoSixOneEightLine, addExtensions ? slCloseBarIndex - 1 : na, addExtensions ? trough - (peak - trough) * 1.618 : na)
line.set_xy2(twoSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? trough - (peak - trough) * 1.618 : na)
line.set_xy1(threeSixOneEightLine, addExtensions ? slCloseBarIndex - 1 : na, addExtensions ? trough - (peak - trough) * 2.618 : na)
line.set_xy2(threeSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? trough - (peak - trough) * 2.618 : na)
line.set_xy1(fourTwoThreeSixLine, addExtensions ? slCloseBarIndex - 1 : na, addExtensions ? trough - (peak - trough) * 3.236 : na)
line.set_xy2(fourTwoThreeSixLine, addExtensions ? bar_index : na, addExtensions ? trough - (peak - trough) * 3.236 : na)
line.set_xy1(fourSixOneEightLine, addExtensions ? slCloseBarIndex - 1 : na, addExtensions ? trough - (peak - trough) * 3.618 : na)
line.set_xy2(fourSixOneEightLine, addExtensions ? bar_index : na, addExtensions ? trough - (peak - trough) * 3.618 : na)
zeroPrice = line.get_price(zeroLine, bar_index)
label.set_x(zeroLabel, addLabels ? slCloseBarIndex - 1 : na)
label.set_y(zeroLabel, addLabels ? peak : na)
label.set_text(zeroLabel, text = '00.0%\n' + str.tostring(math.round(zeroPrice, symbolRoundNumber)))
twoThreeSixPrice = line.get_price(twoThreeSixLine, bar_index)
label.set_x(twoThreeSixLabel, addLabels ? slCloseBarIndex - 1 : na)
label.set_y(twoThreeSixLabel, addLabels ? peak - (peak - trough) * 0.236 : na)
label.set_text(twoThreeSixLabel, text = '23.6%\n' + str.tostring(math.round(twoThreeSixPrice, symbolRoundNumber)))
threeEightTwoPrice = line.get_price(threeEightTwoLine, bar_index)
label.set_x(threeEightTwoLabel, addLabels ? slCloseBarIndex - 1 : na)
label.set_y(threeEightTwoLabel, addLabels ? peak - (peak - trough) * 0.382 : na)
label.set_text(threeEightTwoLabel, text = '38.2%\n' + str.tostring(math.round(threeEightTwoPrice, symbolRoundNumber)))
fiftyPrice = line.get_price(fiftyLine, bar_index)
label.set_x(fiftyLabel, addLabels ? slCloseBarIndex - 1 : na)
label.set_y(fiftyLabel, addLabels ? peak - (peak - trough) * 0.5 : na)
label.set_text(fiftyLabel, text = '50.0%\n' + str.tostring(math.round(fiftyPrice, symbolRoundNumber)))
sixOneEightPrice = line.get_price(sixOneEightLine, bar_index)
label.set_x(sixOneEightLabel, addLabels ? slCloseBarIndex - 1 : na)
label.set_y(sixOneEightLabel, addLabels ? peak - (peak - trough) * 0.618 : na)
label.set_text(sixOneEightLabel, text = '61.8%\n' + str.tostring(math.round(sixOneEightPrice, symbolRoundNumber)))
sevenEightSixPrice = line.get_price(sevenEightSixLine, bar_index)
label.set_x(sevenEightSixLabel, addLabels ? slCloseBarIndex - 1 : na)
label.set_y(sevenEightSixLabel, addLabels ? peak - (peak - trough) * 0.786 : na)
label.set_text(sevenEightSixLabel, text='78.6%\n' + str.tostring(math.round(sevenEightSixPrice, symbolRoundNumber)))
oneHundredPrice = line.get_price(oneHundredLine, bar_index)
label.set_x(oneHundredLabel, addLabels ? slCloseBarIndex - 1 : na)
label.set_y(oneHundredLabel, addLabels ? trough : na)
label.set_text(oneHundredLabel, text = '100.0%\n' + str.tostring(math.round(oneHundredPrice, symbolRoundNumber)))
oneSixOneEightPrice = line.get_price(oneSixOneEightLine, bar_index)
label.set_x(oneSixOneEightLabel, addExtensions and addLabels ? slCloseBarIndex - 1 : na)
label.set_y(oneSixOneEightLabel, addExtensions and addLabels ? trough - (peak - trough) * 0.618 : na)
label.set_text(oneSixOneEightLabel, text = '161.8%\n' + str.tostring(math.round(oneSixOneEightPrice, symbolRoundNumber)))
twoSixOneEightPrice = line.get_price(twoSixOneEightLine, bar_index)
label.set_x(twoSixOneEightLabel, addExtensions and addLabels ? slCloseBarIndex - 1 : na)
label.set_y(twoSixOneEightLabel, addExtensions and addLabels ? trough - (peak - trough) * 1.618 : na)
label.set_text(twoSixOneEightLabel, text = '261.8%\n' + str.tostring(math.round(twoSixOneEightPrice, symbolRoundNumber)))
threeSixOneEightPrice = line.get_price(threeSixOneEightLine, bar_index)
label.set_x(threeSixOneEightLabel, addExtensions and addLabels ? slCloseBarIndex - 1 : na)
label.set_y(threeSixOneEightLabel, addExtensions and addLabels ? trough - (peak - trough) * 2.618 : na)
label.set_text(threeSixOneEightLabel, text = '361.8%\n' + str.tostring(math.round(threeSixOneEightPrice, symbolRoundNumber)))
fourTwoThreeSixPrice = line.get_price(fourTwoThreeSixLine, bar_index)
label.set_x(fourTwoThreeSixLabel, addExtensions and addLabels ? slCloseBarIndex - 1 : na)
label.set_y(fourTwoThreeSixLabel, addExtensions and addLabels ? trough - (peak - trough) * 3.236 : na)
label.set_text(fourTwoThreeSixLabel, text = '423.6%\n' + str.tostring(math.round(fourTwoThreeSixPrice, symbolRoundNumber)))
fourSixOneEightPrice = line.get_price(fourTwoThreeSixLine, bar_index)
label.set_x(fourSixOneEightLabel, addExtensions and addLabels ? slCloseBarIndex - 1 : na)
label.set_y(fourSixOneEightLabel, addExtensions and addLabels ? trough - (peak - trough) * 3.618 : na)
label.set_text(fourSixOneEightLabel, text = '461.8%\n' + str.tostring(math.round(fourSixOneEightPrice, symbolRoundNumber)))
|
Fibonacci Ratios HTF [theEccentricTrader] | https://www.tradingview.com/script/nR1d9Kx6-Fibonacci-Ratios-HTF-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 182 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Fibonacci Ratios HTF [theEccentricTrader]', overlay = true)
//////////// shsl ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] ? high :
close[1] >= open[1] and close < open and high <= high[1] ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] ? low :
close[1] < open[1] and close >= open and low >= low[1] ? low[1] : na
htf = input.timeframe(title = 'HTF Resolution', defval = '1D')
[shPriceHTF, slPriceHTF, closeHTF] = request.security(syminfo.tickerid, htf, [shPrice[1], slPrice[1], close[1]], lookahead = barmerge.lookahead_on)
peakHTF = ta.valuewhen(shPriceHTF, shPriceHTF, 0)
shOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
shCloseBarIndexHTF = ta.valuewhen(shPriceHTF and not shPriceHTF[1], bar_index, 0)
troughHTF = ta.valuewhen(slPriceHTF, slPriceHTF, 0)
slOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
slCloseBarIndexHTF = ta.valuewhen(slPriceHTF and not slPriceHTF[1], bar_index, 0)
var shAnchorForSL = 0
var slAnchorForSH = 0
//////////// lines and labels ////////////
addExtensions = input(defval = true, title = 'Show Fibonacci Extensions', group = "Fibonacci Extensions")
zeroLineColor = input(defval = color.blue, title = '00.0% Color', inline = '1', group = "Line Coloring")
twoThreeSixLineColor = input(defval = color.green, title = '23.6% Color', inline = '2', group = "Line Coloring")
threeEightTwoLineColor = input(defval = color.orange, title = '38.2% Color', inline = '3', group = "Line Coloring")
fiveHundredLineColor = input(defval = color.red, title = '50.0% Color', inline = '4', group = "Line Coloring")
sixOneEightLineColor = input(defval = color.yellow, title = '61.8% Color', inline = '5', group = "Line Coloring")
sevenEightSixLineColor = input(defval = color.maroon, title = '78.6% Color', inline = '6', group = "Line Coloring")
oneHundredLineColor = input(defval = color.purple, title = '100.0% Color', inline = '1', group = "Line Coloring")
oneSixOneEightLineColor = input(defval = color.yellow, title = '161.8% Color', inline = '2', group = "Line Coloring")
twoSixOneEightLineColor = input(defval = color.blue, title = '261.8% Color', inline = '3', group = "Line Coloring")
threeSixOneEightLineColor = input(defval = color.green, title = '361.8% Color', inline = '4', group = "Line Coloring")
fourTwoThreeSixLineColor = input(defval = color.orange, title = '423.6% Color', inline = '5', group = "Line Coloring")
fourSixOneEightLineColor = input(defval = color.red, title = '461.8% Color', inline = '6', group = "Line Coloring")
selectExtend = input.string(title = 'Extend Line Type', defval = 'Right', options = ['None', 'Right', 'Left', 'Both'], group = "Line Extension")
extendLines = selectExtend == 'None' ? extend.none : selectExtend == 'Right' ? extend.right : selectExtend == 'Left' ? extend.left : selectExtend == 'Both' ? extend.both : na
symbolRoundNumber = syminfo.mintick >= 0.1 ? 1 : syminfo.mintick == 0.01 ? 2 : syminfo.mintick == 0.001 ? 3 : syminfo.mintick == 0.0001 ? 4 : syminfo.mintick == 0.00001 ? 5 :
syminfo.mintick == 0.000001 ? 6 : syminfo.mintick == 0.0000001 ? 7 : syminfo.mintick == 0.00000001 ? 8 : na
addLabels = input(defval = true, title = 'Show Labels', group = "Labels")
labelTextColor = input(defval = color.white, title = 'Label Text Color', group = "Label Coloring")
labelTextOutlineColor = input(defval = color.black, title = 'Label Text Outline Color', group = "Label Coloring")
var zeroLineHTF = line.new(na, na, na, na, color = zeroLineColor, style = line.style_solid, extend = extendLines)
var twoThreeSixLineHTF = line.new(na, na, na, na, color = twoThreeSixLineColor, style = line.style_solid, extend = extendLines)
var threeEightTwoLineHTF = line.new(na, na, na, na, color = threeEightTwoLineColor, style = line.style_solid, extend = extendLines)
var fiftyLineHTF = line.new(na, na, na, na, color = fiveHundredLineColor, style = line.style_solid, extend = extendLines)
var sixOneEightLineHTF = line.new(na, na, na, na, color = sixOneEightLineColor, style = line.style_solid, extend = extendLines)
var sevenEightSixLineHTF = line.new(na, na, na, na, color = sevenEightSixLineColor, style = line.style_solid, extend = extendLines)
var oneHundredLineHTF = line.new(na, na, na, na, color = oneHundredLineColor, style = line.style_solid, extend = extendLines)
var oneSixOneEightLineHTF = line.new(na, na, na, na, color = oneSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var twoSixOneEightLineHTF = line.new(na, na, na, na, color = twoSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var threeSixOneEightLineHTF = line.new(na, na, na, na, color = threeSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var fourTwoThreeSixLineHTF = line.new(na, na, na, na, color = fourTwoThreeSixLineColor, style = line.style_solid, extend = extendLines)
var fourSixOneEightLineHTF = line.new(na, na, na, na, color = fourSixOneEightLineColor, style = line.style_solid, extend = extendLines)
var zeroLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var twoThreeSixLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var threeEightTwoLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var fiftyLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var sixOneEightLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var sevenEightSixLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var oneHundredLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var oneSixOneEightLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var twoSixOneEightLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var threeSixOneEightLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var fourTwoThreeSixLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
var fourSixOneEightLabelHTF = label.new(na, na, style = label.style_text_outline, color = labelTextOutlineColor, textcolor = labelTextColor, size = size.small)
if slPriceHTF
lowerTimeFrameLookbackLowestLowBars = (bar_index - slOpenBarIndexHTF)
lowestLowPassThrough = low[1]
for e = 2 to lowerTimeFrameLookbackLowestLowBars by 1
if low[e] == slPriceHTF
lowestLowPassThrough := low[e]
lowerTimeFrameLookbackLowestLowBars := e
slAnchorForSH := bar_index - lowerTimeFrameLookbackLowestLowBars
line.set_xy1(zeroLineHTF, shAnchorForSL, slPriceHTF)
line.set_xy2(zeroLineHTF, bar_index, slPriceHTF)
line.set_xy1(twoThreeSixLineHTF, shAnchorForSL, slPriceHTF + (peakHTF - slPriceHTF) * 0.236)
line.set_xy2(twoThreeSixLineHTF, bar_index, slPriceHTF + (peakHTF - slPriceHTF) * 0.236)
line.set_xy1(threeEightTwoLineHTF, shAnchorForSL, slPriceHTF + (peakHTF - slPriceHTF) * 0.382)
line.set_xy2(threeEightTwoLineHTF, bar_index, slPriceHTF + (peakHTF - slPriceHTF) * 0.382)
line.set_xy1(fiftyLineHTF, shAnchorForSL, slPriceHTF + (peakHTF - slPriceHTF) * 0.5)
line.set_xy2(fiftyLineHTF, bar_index, slPriceHTF + (peakHTF - slPriceHTF) * 0.5)
line.set_xy1(sixOneEightLineHTF, shAnchorForSL, slPriceHTF + (peakHTF - slPriceHTF) * 0.618)
line.set_xy2(sixOneEightLineHTF, bar_index, slPriceHTF + (peakHTF - slPriceHTF) * 0.618)
line.set_xy1(sevenEightSixLineHTF, shAnchorForSL, slPriceHTF + (peakHTF - slPriceHTF) * 0.786)
line.set_xy2(sevenEightSixLineHTF, bar_index, slPriceHTF + (peakHTF - slPriceHTF) * 0.786)
line.set_xy1(oneHundredLineHTF, shAnchorForSL, peakHTF)
line.set_xy2(oneHundredLineHTF, bar_index, peakHTF)
line.set_xy1(oneSixOneEightLineHTF, addExtensions ? shAnchorForSL : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 0.618 : na)
line.set_xy2(oneSixOneEightLineHTF, addExtensions ? bar_index : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 0.618 : na)
line.set_xy1(twoSixOneEightLineHTF, addExtensions ? shAnchorForSL : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 1.618 : na)
line.set_xy2(twoSixOneEightLineHTF, addExtensions ? bar_index : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 1.618 : na)
line.set_xy1(threeSixOneEightLineHTF, addExtensions ? shAnchorForSL : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 2.618 : na)
line.set_xy2(threeSixOneEightLineHTF, addExtensions ? bar_index : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 2.618 : na)
line.set_xy1(fourTwoThreeSixLineHTF, addExtensions ? shAnchorForSL : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 3.236 : na)
line.set_xy2(fourTwoThreeSixLineHTF, addExtensions ? bar_index : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 3.236 : na)
line.set_xy1(fourSixOneEightLineHTF, addExtensions ? shAnchorForSL : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 3.618 : na)
line.set_xy2(fourSixOneEightLineHTF, addExtensions ? bar_index : na, addExtensions ? peakHTF + (peakHTF - troughHTF) * 3.618 : na)
zeroPriceHTF = line.get_price(zeroLineHTF, bar_index)
label.set_x(zeroLabelHTF, addLabels ? shAnchorForSL : na)
label.set_y(zeroLabelHTF, addLabels ? troughHTF : na)
label.set_text(zeroLabelHTF, text = '0.00%\n' + str.tostring(math.round(zeroPriceHTF, symbolRoundNumber)))
twoThreeSixPriceHTF = line.get_price(twoThreeSixLineHTF, bar_index)
label.set_x(twoThreeSixLabelHTF, addLabels ? shAnchorForSL : na)
label.set_y(twoThreeSixLabelHTF, addLabels ? troughHTF + (peakHTF - troughHTF) * 0.236 : na)
label.set_text(twoThreeSixLabelHTF, text = '23.6%\n' + str.tostring(math.round(twoThreeSixPriceHTF, symbolRoundNumber)))
threeEightTwoPriceHTF = line.get_price(threeEightTwoLineHTF, bar_index)
label.set_x(threeEightTwoLabelHTF, addLabels ? shAnchorForSL : na)
label.set_y(threeEightTwoLabelHTF, addLabels ? troughHTF + (peakHTF - troughHTF) * 0.382 : na)
label.set_text(threeEightTwoLabelHTF, text = '38.2%\n' + str.tostring(math.round(threeEightTwoPriceHTF, symbolRoundNumber)))
fiftyPriceHTF = line.get_price(fiftyLineHTF, bar_index)
label.set_x(fiftyLabelHTF, addLabels ? shAnchorForSL : na)
label.set_y(fiftyLabelHTF, addLabels ? troughHTF + (peakHTF - troughHTF) * 0.5 : na)
label.set_text(fiftyLabelHTF, text = '50.0%\n' + str.tostring(math.round(fiftyPriceHTF, symbolRoundNumber)))
sixOneEightPriceHTF = line.get_price(sixOneEightLineHTF, bar_index)
label.set_x(sixOneEightLabelHTF, addLabels ? shAnchorForSL : na)
label.set_y(sixOneEightLabelHTF, addLabels ? troughHTF + (peakHTF - troughHTF) * 0.618 : na)
label.set_text(sixOneEightLabelHTF, text = '61.8%\n' + str.tostring(math.round(sixOneEightPriceHTF, symbolRoundNumber)))
sevenEightSixPriceHTF = line.get_price(sevenEightSixLineHTF, bar_index)
label.set_x(sevenEightSixLabelHTF, addLabels ? shAnchorForSL : na)
label.set_y(sevenEightSixLabelHTF, addLabels ? troughHTF + (peakHTF - troughHTF) * 0.786 : na)
label.set_text(sevenEightSixLabelHTF, text = '78.6%\n' + str.tostring(math.round(sevenEightSixPriceHTF, symbolRoundNumber)))
oneHundredPriceHTF = line.get_price(oneHundredLineHTF, bar_index)
label.set_x(oneHundredLabelHTF, addLabels ? shAnchorForSL : na)
label.set_y(oneHundredLabelHTF, addLabels ? peakHTF : na)
label.set_text(oneHundredLabelHTF, text = '100.0%\n' + str.tostring(math.round(oneHundredPriceHTF, symbolRoundNumber)))
oneSixOneEightPriceHTF = line.get_price(oneSixOneEightLineHTF, bar_index)
label.set_x(oneSixOneEightLabelHTF, addExtensions and addLabels ? shAnchorForSL : na)
label.set_y(oneSixOneEightLabelHTF, addExtensions and addLabels ? peakHTF + (peakHTF - troughHTF) * 0.618 : na)
label.set_text(twoSixOneEightLabelHTF, text = '161.8%\n' + str.tostring(math.round(oneSixOneEightPriceHTF, symbolRoundNumber)))
twoSixOneEightPriceHTF = line.get_price(twoSixOneEightLineHTF, bar_index)
label.set_x(twoSixOneEightLabelHTF, addExtensions and addLabels ? shAnchorForSL : na)
label.set_y(twoSixOneEightLabelHTF, addExtensions and addLabels ? peakHTF + (peakHTF - troughHTF) * 1.618 : na)
label.set_text(twoSixOneEightLabelHTF, text = '261.8%\n' + str.tostring(math.round(twoSixOneEightPriceHTF, symbolRoundNumber)))
threeSixOneEightPriceHTF = line.get_price(threeSixOneEightLineHTF, bar_index)
label.set_x(threeSixOneEightLabelHTF, addExtensions and addLabels ? shAnchorForSL : na)
label.set_y(threeSixOneEightLabelHTF, addExtensions and addLabels ? peakHTF + (peakHTF - troughHTF) * 2.618 : na)
label.set_text(threeSixOneEightLabelHTF, text = '361.8%\n' + str.tostring(math.round(threeSixOneEightPriceHTF, symbolRoundNumber)))
fourTwoThreeSixPriceHTF = line.get_price(fourTwoThreeSixLineHTF, bar_index)
label.set_x(fourTwoThreeSixLabelHTF, addExtensions and addLabels ? shAnchorForSL : na)
label.set_y(fourTwoThreeSixLabelHTF, addExtensions and addLabels ? peakHTF + (peakHTF - troughHTF) * 3.236 : na)
label.set_text(fourTwoThreeSixLabelHTF, text = '423.6%\n' + str.tostring(math.round(fourTwoThreeSixPriceHTF, symbolRoundNumber)))
fourSixOneEightPriceHTF = line.get_price(fourSixOneEightLineHTF, bar_index)
label.set_x(fourSixOneEightLabelHTF, addExtensions and addLabels ? shAnchorForSL : na)
label.set_y(fourSixOneEightLabelHTF, addExtensions and addLabels ? peakHTF + (peakHTF - troughHTF) * 3.618 : na)
label.set_text(fourSixOneEightLabelHTF, text = '461.8%\n' + str.tostring(math.round(fourSixOneEightPriceHTF, symbolRoundNumber)))
if shPriceHTF
lowerTimeFrameLookbackHighestHighBars = (bar_index - shOpenBarIndexHTF)
highestHighPassThrough = high[1]
for i = 2 to lowerTimeFrameLookbackHighestHighBars by 1
if high[i] == shPriceHTF
highestHighPassThrough := high[i]
lowerTimeFrameLookbackHighestHighBars := i
shAnchorForSL := bar_index - lowerTimeFrameLookbackHighestHighBars
line.set_xy1(zeroLineHTF, slAnchorForSH, peakHTF)
line.set_xy2(zeroLineHTF, bar_index, peakHTF)
line.set_xy1(twoThreeSixLineHTF, slAnchorForSH, peakHTF - (peakHTF - troughHTF) * 0.236)
line.set_xy2(twoThreeSixLineHTF, bar_index, peakHTF - (peakHTF - troughHTF) * 0.236)
line.set_xy1(threeEightTwoLineHTF, slAnchorForSH, peakHTF - (peakHTF - troughHTF) * 0.382)
line.set_xy2(threeEightTwoLineHTF, bar_index, peakHTF - (peakHTF - troughHTF) * 0.382)
line.set_xy1(fiftyLineHTF, slAnchorForSH, peakHTF - (peakHTF - troughHTF) * 0.5)
line.set_xy2(fiftyLineHTF, bar_index, peakHTF - (peakHTF - troughHTF) * 0.5)
line.set_xy1(sixOneEightLineHTF, slAnchorForSH, peakHTF - (peakHTF - troughHTF) * 0.618)
line.set_xy2(sixOneEightLineHTF, bar_index, peakHTF - (peakHTF - troughHTF) * 0.618)
line.set_xy1(sevenEightSixLineHTF, slAnchorForSH, peakHTF - (peakHTF - troughHTF) * 0.786)
line.set_xy2(sevenEightSixLineHTF, bar_index, peakHTF - (peakHTF - troughHTF) * 0.786)
line.set_xy1(oneHundredLineHTF, slAnchorForSH, troughHTF)
line.set_xy2(oneHundredLineHTF, bar_index, troughHTF)
line.set_xy1(oneSixOneEightLineHTF, addExtensions ? slAnchorForSH : na, addExtensions ? troughHTF - (peakHTF - troughHTF) * 0.618 : na)
line.set_xy2(oneSixOneEightLineHTF, addExtensions ? bar_index : na, troughHTF - (peakHTF - troughHTF) * 0.618)
line.set_xy1(twoSixOneEightLineHTF, addExtensions ? slAnchorForSH : na, addExtensions ? troughHTF - (peakHTF - troughHTF) * 1.618 : na)
line.set_xy2(twoSixOneEightLineHTF, addExtensions ? bar_index : na, troughHTF - (peakHTF - troughHTF) * 1.618)
line.set_xy1(threeSixOneEightLineHTF, addExtensions ? slAnchorForSH : na, addExtensions ? troughHTF - (peakHTF - troughHTF) * 2.618 : na)
line.set_xy2(threeSixOneEightLineHTF, addExtensions ? bar_index : na, troughHTF - (peakHTF - troughHTF) * 2.618)
line.set_xy1(fourTwoThreeSixLineHTF, addExtensions ? slAnchorForSH : na, addExtensions ? troughHTF - (peakHTF - troughHTF) * 3.236 : na)
line.set_xy2(fourTwoThreeSixLineHTF, addExtensions ? bar_index : na, troughHTF - (peakHTF - troughHTF) * 3.236)
line.set_xy1(fourSixOneEightLineHTF, addExtensions ? slAnchorForSH : na, addExtensions ? troughHTF - (peakHTF - troughHTF) * 3.618 : na)
line.set_xy2(fourSixOneEightLineHTF, addExtensions ? bar_index : na, troughHTF - (peakHTF - troughHTF) * 3.618)
zeroPriceHTF = line.get_price(zeroLineHTF, bar_index)
label.set_x(zeroLabelHTF, addLabels ? slAnchorForSH : na)
label.set_y(zeroLabelHTF, addLabels ? peakHTF : na)
label.set_text(zeroLabelHTF, text = '0.00%\n' + str.tostring(math.round(zeroPriceHTF, symbolRoundNumber)))
twoThreeSixPriceHTF = line.get_price(twoThreeSixLineHTF, bar_index)
label.set_x(twoThreeSixLabelHTF, addLabels ? slAnchorForSH : na)
label.set_y(twoThreeSixLabelHTF, addLabels ? peakHTF - (peakHTF - troughHTF) * 0.236 : na)
label.set_text(twoThreeSixLabelHTF, text = '23.6%\n' + str.tostring(math.round(twoThreeSixPriceHTF, symbolRoundNumber)))
threeEightTwoPriceHTF = line.get_price(threeEightTwoLineHTF, bar_index)
label.set_x(threeEightTwoLabelHTF, addLabels ? slAnchorForSH : na)
label.set_y(threeEightTwoLabelHTF, addLabels ? peakHTF - (peakHTF - troughHTF) * 0.382 : na)
label.set_text(threeEightTwoLabelHTF, text = '38.2%\n' + str.tostring(math.round(threeEightTwoPriceHTF, symbolRoundNumber)))
fiftyPriceHTF = line.get_price(fiftyLineHTF, bar_index)
label.set_x(fiftyLabelHTF, addLabels ? slAnchorForSH : na)
label.set_y(fiftyLabelHTF, addLabels ? peakHTF - (peakHTF - troughHTF) * 0.5 : na)
label.set_text(fiftyLabelHTF, text = '50.0%\n' + str.tostring(math.round(fiftyPriceHTF, symbolRoundNumber)))
sixOneEightPriceHTF = line.get_price(sixOneEightLineHTF, bar_index)
label.set_x(sixOneEightLabelHTF, addLabels ? slAnchorForSH : na)
label.set_y(sixOneEightLabelHTF, addLabels ? peakHTF - (peakHTF - troughHTF) * 0.618 : na)
label.set_text(sixOneEightLabelHTF, text = '61.8%\n' + str.tostring(math.round(sixOneEightPriceHTF, symbolRoundNumber)))
sevenEightSixPriceHTF = line.get_price(sevenEightSixLineHTF, bar_index)
label.set_x(sevenEightSixLabelHTF, addLabels ? slAnchorForSH : na)
label.set_y(sevenEightSixLabelHTF, addLabels ? peakHTF - (peakHTF - troughHTF) * 0.786 : na)
label.set_text(sevenEightSixLabelHTF, text = '78.6%\n' + str.tostring(math.round(sevenEightSixPriceHTF, symbolRoundNumber)))
oneHundredPriceHTF = line.get_price(oneHundredLineHTF, bar_index)
label.set_x(oneHundredLabelHTF, addLabels ? slAnchorForSH : na)
label.set_y(oneHundredLabelHTF, addLabels ? troughHTF : na)
label.set_text(oneHundredLabelHTF, text = '100.0%\n' + str.tostring(math.round(oneHundredPriceHTF, symbolRoundNumber)))
oneSixOneEightPriceHTF = line.get_price(oneSixOneEightLineHTF, bar_index)
label.set_x(oneSixOneEightLabelHTF, addExtensions and addLabels ? slAnchorForSH : na)
label.set_y(oneSixOneEightLabelHTF, addExtensions and addLabels ? troughHTF - (peakHTF - troughHTF) * 0.618 : na)
label.set_text(oneSixOneEightLabelHTF, text = '161.8%\n' + str.tostring(math.round(oneSixOneEightPriceHTF, symbolRoundNumber)))
twoSixOneEightPriceHTF = line.get_price(twoSixOneEightLineHTF, bar_index)
label.set_x(twoSixOneEightLabelHTF, addExtensions and addLabels ? slAnchorForSH : na)
label.set_y(twoSixOneEightLabelHTF, addExtensions and addLabels ? troughHTF - (peakHTF - troughHTF) * 1.618 : na)
label.set_text(twoSixOneEightLabelHTF, text = '261.8%\n' + str.tostring(math.round(twoSixOneEightPriceHTF, symbolRoundNumber)))
threeSixOneEightPriceHTF = line.get_price(threeSixOneEightLineHTF, bar_index)
label.set_x(threeSixOneEightLabelHTF, addExtensions and addLabels ? slAnchorForSH : na)
label.set_y(threeSixOneEightLabelHTF, addExtensions and addLabels ? troughHTF - (peakHTF - troughHTF) * 2.618 : na)
label.set_text(threeSixOneEightLabelHTF, text = '361.8%\n' + str.tostring(math.round(threeSixOneEightPriceHTF, symbolRoundNumber)))
fourTwoThreeSixPriceHTF = line.get_price(fourTwoThreeSixLineHTF, bar_index)
label.set_x(fourTwoThreeSixLabelHTF, addExtensions and addLabels ? slAnchorForSH : na)
label.set_y(fourTwoThreeSixLabelHTF, addExtensions and addLabels ? troughHTF - (peakHTF - troughHTF) * 3.236 : na)
label.set_text(fourTwoThreeSixLabelHTF, text = '423.6%\n' + str.tostring(math.round(fourTwoThreeSixPriceHTF, symbolRoundNumber)))
fourSixOneEightPriceHTF = line.get_price(fourTwoThreeSixLineHTF, bar_index)
label.set_x(fourSixOneEightLabelHTF, addExtensions and addLabels ? slAnchorForSH : na)
label.set_y(fourSixOneEightLabelHTF, addExtensions and addLabels ? troughHTF - (peakHTF - troughHTF) * 3.618 : na)
label.set_text(fourSixOneEightLabelHTF, text = '461.8%\n' + str.tostring(math.round(fourSixOneEightPriceHTF, symbolRoundNumber)))
|
LNL Simple Hedging Tool | https://www.tradingview.com/script/Xg3rfLH2-LNL-Simple-Hedging-Tool/ | lnlcapital | https://www.tradingview.com/u/lnlcapital/ | 74 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// LNL Simple Hedging Tool
//
// Simple Hedging Tool was created for traders who struggle with hedging. This tool helps to spot the ideal moments to put the hedges on. There are two versions: "VIX"
// is specifically for the VIX (Volatility Index), and "SPX" can be used on any stock since it is calculated from the SPX benchmark.
//
// Signals from this tool WILL NOT TELL YOU where to buy or sell! But rather when is a good time TO NOT buy or TO NOT sell.
//
// Created by L&L Capital
//
indicator("LNL Simple Hedging Tool",shorttitle = "Simple Hedging Tool", overlay = true)
// Inputs
string Type = input.string("SPX", "Type", options = ["VIX", "SPX"])
// Internals Calculations
[middle, upper, lower] = ta.bb(close,20,2)
Bband = low < lower
Bband2 = high > upper
VolSpd = request.security("USI:VOLD", "D", ta.sma(close,10))
Add = request.security("USI:ADD", "D", ta.sma(close,10))
BullishVolSpd = VolSpd < -210000000
BearishVolSpd = VolSpd > 170000000
BullishAdd = Add < -650
BearishAdd = Add > 650
// VIX vs. SPX Switch
BullishSignal = if Type == "VIX"
Bband
else if Type == "SPX"
(BullishVolSpd or BullishAdd)
BearishSignal = if Type == "VIX"
Bband2
else if Type == "SPX"
(BearishVolSpd or BearishAdd)
// Plots
barcolor(BullishSignal ? color.yellow : BearishSignal ? color.aqua : na, title= 'Color Bars')
plotshape(BullishSignal,title='Hedge Shorts!',style=shape.triangleup,location=location.belowbar,color=(color.yellow),size=size.tiny)
plotshape(BearishSignal,title='Hedge Longs!',style=shape.triangledown,location=location.abovebar,color=(color.aqua),size=size.tiny)
|
Zero-lag TEMA Crosses [Loxx] | https://www.tradingview.com/script/sjkyqVmc-Zero-lag-TEMA-Crosses-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 359 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© loxx
//@version=5
indicator("Zero-lag TEMA Crosses [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
import loxx/loxxexpandedsourcetypes/4
zlagtema(float src, simple int len)=>
float ema1 = ta.ema(src, len)
float ema2 = ta.ema(ema1, len)
float ema3 = ta.ema(ema2, len)
float out = 3 * (ema1 - ema2) + ema3
float ema1a = ta.ema(out, len)
float ema2a = ta.ema(ema1a, len)
float ema3a = ta.ema(ema2a, len)
float outf = 3 * (ema1a - ema2a) + ema3a
outf
smthtype = input.string("Kaufman", "HAB Calc Type", options = ["AMA", "T3", "Kaufman"], group='Source Settings')
srcin = input.string("Close", "Source",
options =
["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average", "Average Median Body", "Trend Biased", "Trend Biased (Extreme)",
"HA Close", "HA Open", "HA High", "HA Low", "HA Median", "HA Typical", "HA Weighted", "HA Average", "HA Average Median Body", "HA Trend Biased", "HA Trend Biased (Extreme)",
"HAB Close", "HAB Open", "HAB High", "HAB Low", "HAB Median", "HAB Typical", "HAB Weighted", "HAB Average", "HAB Average Median Body", "HAB Trend Biased", "HAB Trend Biased (Extreme)"],
group='Source Settings')
inpPeriodFast = input.int(22, "Fast Period", group = "Basic Settings")
inpPeriodSlow = input.int(144, "Slow Period", group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showSigs = input.bool(true, "Show Signals?", group = "UI Options")
kfl = input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl = input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")
t3hot = input.float(.7, "* T3 Only - T3 Hot", group = "Moving Average Inputs")
t3swt = input.string("T3 New", "* T3 Only - T3 Type", options = ["T3 New", "T3 Original"], group = "Moving Average Inputs")
haclose = ohlc4
haopen = float(na)
haopen := na(haopen[1]) ? (open + close) / 2 : (nz(haopen[1]) + nz(haclose[1])) / 2
hahigh =math.max(high, math.max(haopen, haclose))
halow = math.min(low, math.min(haopen, haclose))
hamedian = (hahigh + halow) / 2
hatypical = (hahigh + halow + haclose) / 3
haweighted = (hahigh + halow + haclose + haclose)/4
haaverage = (haopen + hahigh + halow + haclose)/4
sourceout(smthtype, srcin)=>
src = switch srcin
"Close" => close
"Open" => open
"High" => high
"Low" => low
"Median" => hl2
"Typical" => hlc3
"Weighted" => hlcc4
"Average" => ohlc4
"Average Median Body" => (open + close)/2
"Trend Biased" => loxxexpandedsourcetypes.rtrendb()
"Trend Biased (Extreme)" => loxxexpandedsourcetypes.rtrendbext()
"HA Close" => loxxexpandedsourcetypes.haclose(haclose)
"HA Open" => loxxexpandedsourcetypes.haopen(haopen)
"HA High" => loxxexpandedsourcetypes.hahigh(hahigh)
"HA Low" => loxxexpandedsourcetypes.halow(halow)
"HA Median" => loxxexpandedsourcetypes.hamedian(hamedian)
"HA Typical" => loxxexpandedsourcetypes.hatypical(hatypical)
"HA Weighted" => loxxexpandedsourcetypes.haweighted(haweighted)
"HA Average" => loxxexpandedsourcetypes.haaverage(haaverage)
"HA Average Median Body" => loxxexpandedsourcetypes.haavemedbody(haclose, haopen)
"HA Trend Biased" => loxxexpandedsourcetypes.hatrendb(haclose, haopen, hahigh, halow)
"HA Trend Biased (Extreme)" => loxxexpandedsourcetypes.hatrendbext(haclose, haopen, hahigh, halow)
"HAB Close" => loxxexpandedsourcetypes.habclose(smthtype, amafl, amasl, kfl, ksl)
"HAB Open" => loxxexpandedsourcetypes.habopen(smthtype, amafl, amasl, kfl, ksl)
"HAB High" => loxxexpandedsourcetypes.habhigh(smthtype, amafl, amasl, kfl, ksl)
"HAB Low" => loxxexpandedsourcetypes.hablow(smthtype, amafl, amasl, kfl, ksl)
"HAB Median" => loxxexpandedsourcetypes.habmedian(smthtype, amafl, amasl, kfl, ksl)
"HAB Typical" => loxxexpandedsourcetypes.habtypical(smthtype, amafl, amasl, kfl, ksl)
"HAB Weighted" => loxxexpandedsourcetypes.habweighted(smthtype, amafl, amasl, kfl, ksl)
"HAB Average" => loxxexpandedsourcetypes.habaverage(smthtype, amafl, amasl, kfl, ksl)
"HAB Average Median Body" => loxxexpandedsourcetypes.habavemedbody(smthtype, amafl, amasl, kfl, ksl)
"HAB Trend Biased" => loxxexpandedsourcetypes.habtrendb(smthtype, amafl, amasl, kfl, ksl)
"HAB Trend Biased (Extreme)" => loxxexpandedsourcetypes.habtrendbext(smthtype, amafl, amasl, kfl, ksl)
=> close
temafast = zlagtema(sourceout(smthtype, srcin), inpPeriodFast)
temaslow = zlagtema(sourceout(smthtype, srcin), inpPeriodSlow)
colorout = temafast > temaslow ? greencolor : redcolor
plot(temafast, "Zero-lag TEMA Crosses Fast", color = colorout, linewidth = 2)
plot(temaslow, "Zero-lag TEMA Crosses Slow", color = color.white, linewidth = 1)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(temafast, temaslow)
goShort = ta.crossunder(temafast, temaslow)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goLong, title="Long", message="Zero-lag TEMA Crosses [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Zero-lag TEMA Crosses [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}") |
Moving Average Resting Point [theEccentricTrader] | https://www.tradingview.com/script/Vne4vw11-Moving-Average-Resting-Point-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 20 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator("Moving Average Resting Point [theEccentricTrader]", shorttitle = 'MARP [theEccentricTrader]', overlay = true)
//////////// shsl ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
peak = ta.valuewhen(shPrice, shPrice, 0)
trough = ta.valuewhen(slPrice, slPrice, 0)
//////////// moving average resting points ////////////
showMARP1 = input(defval = true, title = "Show MARP 1", group = 'MARP Plots')
showMARP2 = input(defval = false, title = "Show MARP 2", group = 'MARP Plots')
showMARP3 = input(defval = false, title = "Show MARP 3", group = 'MARP Plots')
marp1Length = input(defval = 10, title = "MARP 1 Length", group = 'MARP Lengths')
marp2Length = input(defval = 20, title = "MARP 2 Length", group = 'MARP Lengths')
marp3Length = input(defval = 30, title = "MARP 3 Length", group = 'MARP Lengths')
marp1Color = input(defval = color.green, title = "MARP 1 Color", group = 'MARP Coloring')
marp2Color = input(defval = color.orange, title = "MARP 2 Color", group = 'MARP Coloring')
marp3Color = input(defval = color.red, title = "MARP 3 Color", group = 'MARP Coloring')
marp1High = ta.sma(peak, marp1Length)
marp1Low = ta.sma(trough, marp1Length)
marp1 = marp1Low + ((marp1High - marp1Low) / 2)
marp2High = ta.sma(peak, marp2Length)
marp2Low = ta.sma(trough, marp2Length)
marp2 = marp2Low + ((marp2High - marp2Low) / 2)
marp3High = ta.sma(peak, marp3Length)
marp3Low = ta.sma(trough, marp3Length)
marp3 = marp3Low + ((marp3High - marp3Low) / 2)
//////////// plots ////////////
plot(showMARP1 ? marp1 : na, color = marp1Color)
plot(showMARP2 ? marp2 : na, color = marp2Color)
plot(showMARP3 ? marp3 : na, color = marp3Color)
|
OBV-MACD | https://www.tradingview.com/script/DHoMV0CV-OBV-MACD/ | starduckz | https://www.tradingview.com/u/starduckz/ | 86 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© rewbuglag
//@version=5
indicator(title="OBV-MACD", shorttitle="OBV-MACD", timeframe="", timeframe_gaps=true, format=format.volume) // , format=format.volume
// indicator(title="OBV-MACD", shorttitle="OBV-MACD", timeframe="", timeframe_gaps=true, format=format.percent) // , format=format.volume
// OBV-MACD
i_obv_macd_timeframe = input.timeframe("", "Timeframe", group="OBV-MACD")
i_obv_mode = input.string("Default", "OBV Mode", options=["Default", "Price Chg."], group="OBV-MACD")
i_obv_macd_ma_type = input.string("EMA", "Method", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="OBV-MACD")
i_obv_macd_fast_ma_length = input.int(12, "Fast Length", minval=1, group="OBV-MACD")
i_obv_macd_slow_ma_length = input.int(26, "Slow Length", minval=1, group="OBV-MACD")
i_obv_macd_signal_ma_length = input.int(9, "Signal Length", minval=1, group="OBV-MACD")
// OBV-MACD-Donchian
i_obv_macd_high_breakout_length = input.int(20, "MACD High Breakout Length", minval=1, group="OBV-MACD Donchian")
i_obv_macd_low_breakout_length = input.int(10, "MACD Low Breakout Length", minval=1, group="OBV-MACD Donchian")
// Calculation
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)
var cumVol = 0.
cumVol += math.abs(nz(volume))
if barstate.islast and cumVol == 0
runtime.error("No volume is provided by the data vendor.")
obv = (i_obv_mode == "Default" ? ta.cum(math.sign(ta.change(close)) * math.abs(volume)) : ta.cum(ta.change(close) * math.abs(volume)))
obv_macd_fast_ma = ma(obv, i_obv_macd_fast_ma_length, i_obv_macd_ma_type)
obv_macd_slow_ma = ma(obv, i_obv_macd_slow_ma_length, i_obv_macd_ma_type)
obv_macd = obv_macd_fast_ma - obv_macd_slow_ma
obv_macd_signal_ma = ma(obv_macd, i_obv_macd_signal_ma_length, i_obv_macd_ma_type)
obv_macd_signal_hist = obv_macd - obv_macd_signal_ma
obv_macd_high = request.security(syminfo.tickerid, i_obv_macd_timeframe, ta.highest(obv_macd, i_obv_macd_high_breakout_length), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
obv_macd_low = request.security(syminfo.tickerid, i_obv_macd_timeframe, ta.lowest(obv_macd, i_obv_macd_low_breakout_length), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
var obv_macd_ath = 0.0
obv_macd_ath := obv_macd > obv_macd_ath ? obv_macd : obv_macd_ath
var obv_macd_atl = 0.0
obv_macd_atl := obv_macd < obv_macd_atl ? obv_macd : obv_macd_atl
obv_macd_breakout_high = ta.crossover(obv_macd, obv_macd_high[1])
obv_macd_breakout_low = ta.crossunder(obv_macd, obv_macd_low[1])
// Visualization
// Plot colors
col_grow_above = input(#26A69A, "Aboveβββ
Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "BelowβGrow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
// plot(obv_chg, "OBV Change", obv_chg >= 0 ? color.green : color.red)
hline(0, "Zero Line", color=color.new(#787B86, 50), display=display.none)
plot(obv_macd_signal_hist, "Signal Line Histogram", (obv_macd_signal_hist>=0 ? (obv_macd_signal_hist[1] < obv_macd_signal_hist ? col_grow_above : col_fall_above) : (obv_macd_signal_hist[1] < obv_macd_signal_hist ? col_grow_below : col_fall_below)), style=plot.style_columns)
plot(obv_macd, "OBV-MACD Line", obv_macd >= 0 ? color.lime : color.red, 2)
plot(obv_macd_signal_ma, "OBV-MACD Signal Line", color.orange)
plot(obv_macd, "Zero Line Histogram", (obv_macd>=0 ? (obv_macd[1] < obv_macd ? col_grow_above : col_fall_above) : (obv_macd[1] < obv_macd ? col_grow_below : col_fall_below)), style=plot.style_columns, display=display.none)
// plot(obv, "OBV Line", obv_macd >= 0 ? color.lime : color.red, 2, display=display.none)
plot(obv, "OBV Line", (obv_macd>=0 ? (obv_macd_signal_hist >= 0 ? col_grow_above : col_fall_above) : (obv_macd_signal_hist >= 0 ? col_grow_below : col_fall_below)), 2, display=display.none)
plot(obv_macd_fast_ma, "OBV Fast MA", color.aqua, display=display.none)
plot(obv_macd_slow_ma, "OBV Slow MA", color.orange, display=display.none)
plot(obv_macd_high, title="OBV-MACD High", color=color.green, display=display.none)
plot(obv_macd_low, title="OBV-MACD Low", color=color.red, display=display.none)
plot(obv_macd_ath, title="OBV-MACD ATH", color=color.green, display=display.none)
plot(obv_macd_atl, title="OBV-MACD ATL", color=color.red, display=display.none)
plotshape(obv_macd_breakout_high or obv_macd_breakout_low, "OBV-MACD High/Low Breakout", shape.cross, location.bottom, (obv_macd_breakout_high ? color.teal : color.red), size=size.tiny)
plotshape(obv_macd_signal_hist, "Histogram Slope Up/Down", shape.square, location.top, obv_macd_signal_hist >= 0 ? (obv_macd_signal_hist > obv_macd_signal_hist[1] ? #26A69A : #B2DFDB) : (obv_macd_signal_hist < obv_macd_signal_hist[1] ? #FF5252 : #FFCDD2), display=display.none)
|
Wavemeter [theEccentricTrader] | https://www.tradingview.com/script/uvjyD6K7-Wavemeter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 57 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator("Wavemeter [theEccentricTrader]", overlay = true, max_lines_count = 500)
//////////// sample period filter ////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input.time(timestamp('1 Jan 1800 00:00'), title = 'Start Date', group = 'Sample Period')
end = input.time(timestamp('1 Jan 3000 00:00'), title = 'End Date', group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
str.tostring(dayofmonth(_t), '00') + '.' + str.tostring(month(_t), '00') + '.' + str.tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
//////////// shsl ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
shPriceBarIndex = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? bar_index :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? bar_index[1] : na
slPriceBarIndex = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? bar_index :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? bar_index[1] : na
peak = ta.valuewhen(shPrice,shPrice,0)
trough = ta.valuewhen(slPrice,slPrice,0)
shsl = shPrice or slPrice
waveCycle = shsl and (ta.valuewhen(shsl, bar_index, 0) > ta.valuewhen(shsl, bar_index, 1))
shslBarIndex = ta.valuewhen(shsl, bar_index, 1)
symbolMintickIntegerConversion = syminfo.mintick >= 0.1 ? 1 : syminfo.mintick == 0.01 ? 10 : syminfo.mintick == 0.001 ? 100 :
syminfo.mintick == 0.0001 ? 1000 : syminfo.mintick == 0.00001 ? 10000 : syminfo.mintick == 0.000001 ? 100000 : syminfo.mintick == 0.0000001 ? 1000000 : syminfo.mintick == 0.00000001 ? 10000000 : na
//////////// table ////////////
candleTablePositionInput = input.string(title = 'Position', defval = 'Top Right', options = ['Top Right', 'Top Center', 'Top Left', 'Bottom Right', 'Bottom Center', 'Bottom Left',
'Middle Right', 'Middle Center', 'Middle Left'], group = 'Table Positioning')
candleTablePosition = candleTablePositionInput == 'Top Right' ? position.top_right : candleTablePositionInput == 'Top Center' ? position.top_center :
candleTablePositionInput == 'Top Left' ? position.top_left : candleTablePositionInput == 'Bottom Right' ? position.bottom_right :
candleTablePositionInput == 'Bottom Center' ? position.bottom_center : candleTablePositionInput == 'Bottom Left' ? position.bottom_left :
candleTablePositionInput == 'Middle Right' ? position.middle_right : candleTablePositionInput == 'Middle Center' ? position.middle_center :
candleTablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
showCurrent = input(defval = true, title = "Show Current", group = 'Current Wave Measurements')
var candleCounter = 0.
var waveCycleCounter = 0.
var heightCounter = 0.
var amplitudeCounter = 0.
var wavemeterTable = table.new(candleTablePosition, 100, 100, border_width = 1)
if close and barstate.isconfirmed
candleCounter += 1
if waveCycle and samplePeriodFilter
waveCycleCounter += 1
heightCounter += (peak - trough) * symbolMintickIntegerConversion
amplitudeCounter += ((peak - trough) * symbolMintickIntegerConversion) / 2
table.cell(wavemeterTable, 0, 0, text = "Wave Cycles", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 0, text = str.tostring(math.round(waveCycleCounter, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 0, 1, text = "Average Wave Length", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 1, text = str.tostring(math.round(candleCounter / waveCycleCounter, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 0, 2, text = "Average Wave Height", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 2, text = str.tostring(math.round(heightCounter / waveCycleCounter, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 0, 3, text = "Average Amplitude", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 3, text = str.tostring(math.round(amplitudeCounter / waveCycleCounter, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 0, 4, text = "Average Frequency", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 4, text = str.tostring(math.round(waveCycleCounter / (candleCounter * ((time[1] - time[2]) / 1000)), 10)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
if waveCycle and showCurrent and samplePeriodFilter
table.cell(wavemeterTable, 0, 5, text = "Current Wave Length", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 5, text = str.tostring(math.round(bar_index - shslBarIndex + 1, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 0, 6, text = "Current Wave Height", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 6, text = str.tostring(math.round((peak - trough) * symbolMintickIntegerConversion, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 0, 7, text = "Current Amplitude", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 7, text = str.tostring(math.round(((peak - trough) * symbolMintickIntegerConversion) / 2, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 0, 8, text = "Current Frequency", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(wavemeterTable, 1, 8, text = str.tostring(math.round(((bar_index - shslBarIndex + 1) / ((time[1] - time[2]) / 1000)), 10)), bgcolor = color.green, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(wavemeterTable, 0, 9, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
//////////// lines ////////////
showLines = input(defval = true, title = "Show Lines", group = 'Lines')
line1 = line.new(na, na, na, na, width = 3)
line2 = line.new(na, na, na, na, width = 3)
if shsl and showLines
line.set_xy1(line1, ta.valuewhen(slPrice, slPriceBarIndex, 0), ta.valuewhen(slPrice, slPrice, 0))
line.set_xy2(line1, shPriceBarIndex, ta.valuewhen(shPrice, shPrice, 0))
line.set_xy1(line2, ta.valuewhen(shPrice, shPriceBarIndex, 0), ta.valuewhen(shPrice, shPrice, 0))
line.set_xy2(line2, slPriceBarIndex, ta.valuewhen(slPrice, slPrice, 0))
var myArray = array.new_line()
array.push(myArray, line1)
array.push(myArray, line2)
if array.size(myArray) > 500
firstLine = array.remove(myArray, 0)
line.delete(firstLine)
|
Variety MA Cluster Filter Crosses [Loxx] | https://www.tradingview.com/script/fnYaYfso-Variety-MA-Cluster-Filter-Crosses-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 127 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© loxx
//@version=5
indicator("Variety MA Cluster Filter Crosses [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
color greencolor = #2DD204
color redcolor = #D2042D
color bluecolor = #042dd2
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Source Settings")
srcin = input.string("Close", "Source", group = "Source Settings",
options =
["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average", "Average Median Body", "Trend Biased", "Trend Biased (Extreme)",
"HA Close", "HA Open", "HA High", "HA Low", "HA Median", "HA Typical", "HA Weighted", "HA Average", "HA Average Median Body", "HA Trend Biased", "HA Trend Biased (Extreme)",
"HAB Close", "HAB Open", "HAB High", "HAB Low", "HAB Median", "HAB Typical", "HAB Weighted", "HAB Average", "HAB Average Median Body", "HAB Trend Biased", "HAB Trend Biased (Extreme)"])
ext_period_MAf = input.int(12, "Fast Period", group = "Basic Settings")
ext_period_MA = input.int(26, "Slow Period", group = "Basic Settings")
typeout= input.string("Exponential Moving Average - EMA", "Filter Type", options = ["ADXvma - Average Directional Volatility Moving Average", "Ahrens Moving Average"
, "Alexander Moving Average - ALXMA", "Double Exponential Moving Average - DEMA", "Double Smoothed Exponential Moving Average - DSEMA"
, "Exponential Moving Average - EMA", "Fast Exponential Moving Average - FEMA", "Fractal Adaptive Moving Average - FRAMA"
, "Hull Moving Average - HMA", "IE/2 - Early T3 by Tim Tilson", "Integral of Linear Regression Slope - ILRS"
, "Instantaneous Trendline", "Laguerre filt", "Leader Exponential Moving Average", "Linear Regression Value - LSMA (Least Squares Moving Average)"
, "Linear Weighted Moving Average - LWMA", "McGinley Dynamic", "McNicholl EMA", "Non-Lag Moving Average", "Parabolic Weighted Moving Average"
, "Recursive Moving Trendline", "Simple Moving Average - SMA", "Sine Weighted Moving Average", "Smoothed Moving Average - SMMA"
, "Smoother", "Super Smoother", "Three-pole Ehlers Butterworth", "Three-pole Ehlers Smoother"
, "Triangular Moving Average - TMA", "Triple Exponential Moving Average - TEMA", "Two-pole Ehlers Butterworth", "Two-pole Ehlers smoother"
, "Volume Weighted EMA - VEMA", "Zero-Lag DEMA - Zero Lag Double Exponential Moving Average", "Zero-Lag Moving Average"
, "Zero Lag TEMA - Zero Lag Triple Exponential Moving Average"],
group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showSigs = input.bool(true, "Show Signals?", group = "UI Options")
frama_FC = input.int(defval=1, title="* Fractal Adjusted (FRAMA) Only - FC", group = "Moving Average Inputs")
frama_SC = input.int(defval=200, title="* Fractal Adjusted (FRAMA) Only - SC", group = "Moving Average Inputs")
instantaneous_alpha = input.float(defval=0.07, minval = 0, title="* Instantaneous Trendline (INSTANT) Only - Alpha", group = "Moving Average Inputs")
_laguerre_alpha = input.float(title="* Laguerre filt (LF) Only - Alpha", minval=0, maxval=1, step=0.1, defval=0.7, group = "Moving Average Inputs")
lsma_offset = input.int(defval=0, title="* Least Squares Moving Average (LSMA) Only - Offset", group = "Moving Average Inputs")
_pwma_pwr = input.int(2, "* Parabolic Weighted Moving Average (PWMA) Only - Power", minval=0, group = "Moving Average Inputs")
kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")
variant(type, src, len) =>
sig = 0.0
trig = 0.0
special = false
if type == "ADXvma - Average Directional Volatility Moving Average"
[t, s, b] = loxxmas.adxvma(src, len)
sig := s
trig := t
special := b
else if type == "Ahrens Moving Average"
[t, s, b] = loxxmas.ahrma(src, len)
sig := s
trig := t
special := b
else if type == "Alexander Moving Average - ALXMA"
[t, s, b] = loxxmas.alxma(src, len)
sig := s
trig := t
special := b
else if type == "Double Exponential Moving Average - DEMA"
[t, s, b] = loxxmas.dema(src, len)
sig := s
trig := t
special := b
else if type == "Double Smoothed Exponential Moving Average - DSEMA"
[t, s, b] = loxxmas.dsema(src, len)
sig := s
trig := t
special := b
else if type == "Exponential Moving Average - EMA"
[t, s, b] = loxxmas.ema(src, len)
sig := s
trig := t
special := b
else if type == "Fast Exponential Moving Average - FEMA"
[t, s, b] = loxxmas.fema(src, len)
sig := s
trig := t
special := b
else if type == "Fractal Adaptive Moving Average - FRAMA"
[t, s, b] = loxxmas.frama(src, len, frama_FC, frama_SC)
sig := s
trig := t
special := b
else if type == "Hull Moving Average - HMA"
[t, s, b] = loxxmas.hma(src, len)
sig := s
trig := t
special := b
else if type == "IE/2 - Early T3 by Tim Tilson"
[t, s, b] = loxxmas.ie2(src, len)
sig := s
trig := t
special := b
else if type == "Integral of Linear Regression Slope - ILRS"
[t, s, b] = loxxmas.ilrs(src, len)
sig := s
trig := t
special := b
else if type == "Instantaneous Trendline"
[t, s, b] = loxxmas.instant(src, instantaneous_alpha)
sig := s
trig := t
special := b
else if type == "Laguerre filt"
[t, s, b] = loxxmas.laguerre(src, _laguerre_alpha)
sig := s
trig := t
special := b
else if type == "Leader Exponential Moving Average"
[t, s, b] = loxxmas.leader(src, len)
sig := s
trig := t
special := b
else if type == "Linear Regression Value - LSMA (Least Squares Moving Average)"
[t, s, b] = loxxmas.lsma(src, len, lsma_offset)
sig := s
trig := t
special := b
else if type == "Linear Weighted Moving Average - LWMA"
[t, s, b] = loxxmas.lwma(src, len)
sig := s
trig := t
special := b
else if type == "McGinley Dynamic"
[t, s, b] = loxxmas.mcginley(src, len)
sig := s
trig := t
special := b
else if type == "McNicholl EMA"
[t, s, b] = loxxmas.mcNicholl(src, len)
sig := s
trig := t
special := b
else if type == "Non-Lag Moving Average"
[t, s, b] = loxxmas.nonlagma(src, len)
sig := s
trig := t
special := b
else if type == "Parabolic Weighted Moving Average"
[t, s, b] = loxxmas.pwma(src, len, _pwma_pwr)
sig := s
trig := t
special := b
else if type == "Recursive Moving Trendline"
[t, s, b] = loxxmas.rmta(src, len)
sig := s
trig := t
special := b
else if type == "Simple Moving Average - SMA"
[t, s, b] = loxxmas.sma(src, len)
sig := s
trig := t
special := b
else if type == "Sine Weighted Moving Average"
[t, s, b] = loxxmas.swma(src, len)
sig := s
trig := t
special := b
else if type == "Smoothed Moving Average - SMMA"
[t, s, b] = loxxmas.smma(src, len)
sig := s
trig := t
special := b
else if type == "Smoother"
[t, s, b] = loxxmas.smoother(src, len)
sig := s
trig := t
special := b
else if type == "Super Smoother"
[t, s, b] = loxxmas.super(src, len)
sig := s
trig := t
special := b
else if type == "Three-pole Ehlers Butterworth"
[t, s, b] = loxxmas.threepolebuttfilt(src, len)
sig := s
trig := t
special := b
else if type == "Three-pole Ehlers Smoother"
[t, s, b] = loxxmas.threepolesss(src, len)
sig := s
trig := t
special := b
else if type == "Triangular Moving Average - TMA"
[t, s, b] = loxxmas.tma(src, len)
sig := s
trig := t
special := b
else if type == "Triple Exponential Moving Average - TEMA"
[t, s, b] = loxxmas.tema(src, len)
sig := s
trig := t
special := b
else if type == "Two-pole Ehlers Butterworth"
[t, s, b] = loxxmas.twopolebutter(src, len)
sig := s
trig := t
special := b
else if type == "Two-pole Ehlers smoother"
[t, s, b] = loxxmas.twopoless(src, len)
sig := s
trig := t
special := b
else if type == "Volume Weighted EMA - VEMA"
[t, s, b] = loxxmas.vwema(src, len)
sig := s
trig := t
special := b
else if type == "Zero-Lag DEMA - Zero Lag Double Exponential Moving Average"
[t, s, b] = loxxmas.zlagdema(src, len)
sig := s
trig := t
special := b
else if type == "Zero-Lag Moving Average"
[t, s, b] = loxxmas.zlagma(src, len)
sig := s
trig := t
special := b
else if type == "Zero Lag TEMA - Zero Lag Triple Exponential Moving Average"
[t, s, b] = loxxmas.zlagtema(src, len)
sig := s
trig := t
special := b
trig
haclose = ohlc4
haopen = float(na)
haopen := na(haopen[1]) ? (open + close) / 2 : (nz(haopen[1]) + nz(haclose[1])) / 2
hahigh =math.max(high, math.max(haopen, haclose))
halow = math.min(low, math.min(haopen, haclose))
hamedian = (hahigh + halow) / 2
hatypical = (hahigh + halow + haclose) / 3
haweighted = (hahigh + halow + haclose + haclose)/4
haaverage = (haopen + hahigh + halow + haclose)/4
sourceout(smthtype, srcin)=>
src = switch srcin
"Close" => close
"Open" => open
"High" => high
"Low" => low
"Median" => hl2
"Typical" => hlc3
"Weighted" => hlcc4
"Average" => ohlc4
"Average Median Body" => (open + close)/2
"Trend Biased" => loxxexpandedsourcetypes.rtrendb()
"Trend Biased (Extreme)" => loxxexpandedsourcetypes.rtrendbext()
"HA Close" => loxxexpandedsourcetypes.haclose(haclose)
"HA Open" => loxxexpandedsourcetypes.haopen(haopen)
"HA High" => loxxexpandedsourcetypes.hahigh(hahigh)
"HA Low" => loxxexpandedsourcetypes.halow(halow)
"HA Median" => loxxexpandedsourcetypes.hamedian(hamedian)
"HA Typical" => loxxexpandedsourcetypes.hatypical(hatypical)
"HA Weighted" => loxxexpandedsourcetypes.haweighted(haweighted)
"HA Average" => loxxexpandedsourcetypes.haaverage(haaverage)
"HA Average Median Body" => loxxexpandedsourcetypes.haavemedbody(haclose, haopen)
"HA Trend Biased" => loxxexpandedsourcetypes.hatrendb(haclose, haopen, hahigh, halow)
"HA Trend Biased (Extreme)" => loxxexpandedsourcetypes.hatrendbext(haclose, haopen, hahigh, halow)
"HAB Close" => loxxexpandedsourcetypes.habclose(smthtype, amafl, amasl, kfl, ksl)
"HAB Open" => loxxexpandedsourcetypes.habopen(smthtype, amafl, amasl, kfl, ksl)
"HAB High" => loxxexpandedsourcetypes.habhigh(smthtype, amafl, amasl, kfl, ksl)
"HAB Low" => loxxexpandedsourcetypes.hablow(smthtype, amafl, amasl, kfl, ksl)
"HAB Median" => loxxexpandedsourcetypes.habmedian(smthtype, amafl, amasl, kfl, ksl)
"HAB Typical" => loxxexpandedsourcetypes.habtypical(smthtype, amafl, amasl, kfl, ksl)
"HAB Weighted" => loxxexpandedsourcetypes.habweighted(smthtype, amafl, amasl, kfl, ksl)
"HAB Average" => loxxexpandedsourcetypes.habaverage(smthtype, amafl, amasl, kfl, ksl)
"HAB Average Median Body" => loxxexpandedsourcetypes.habavemedbody(smthtype, amafl, amasl, kfl, ksl)
"HAB Trend Biased" => loxxexpandedsourcetypes.habtrendb(smthtype, amafl, amasl, kfl, ksl)
"HAB Trend Biased (Extreme)" => loxxexpandedsourcetypes.habtrendbext(smthtype, amafl, amasl, kfl, ksl)
=> close
ExtBuffer_EMA = variant(typeout, sourceout(smthtype, srcin), ext_period_MAf)
ExtBuffer_MA = variant(typeout, sourceout(smthtype, srcin), ext_period_MA)
ExtBuffer_CF = 0.
if nz(ExtBuffer_CF[1]) > nz(ExtBuffer_CF[2])
if nz(ExtBuffer_CF[1]) < ExtBuffer_MA and nz(ExtBuffer_CF[1]) < ExtBuffer_EMA
ExtBuffer_CF := math.min(ExtBuffer_MA, ExtBuffer_EMA)
if nz(ExtBuffer_CF[1]) < ExtBuffer_MA and nz(ExtBuffer_CF[1]) > ExtBuffer_EMA
ExtBuffer_CF := ExtBuffer_MA
if nz(ExtBuffer_CF[1]) > ExtBuffer_MA and nz(ExtBuffer_CF[1]) < ExtBuffer_EMA
ExtBuffer_CF := ExtBuffer_EMA
ExtBuffer_CF := math.max(ExtBuffer_MA, ExtBuffer_EMA)
else
if nz(ExtBuffer_CF[1]) > ExtBuffer_MA and nz(ExtBuffer_CF[1]) > ExtBuffer_EMA
ExtBuffer_CF := math.max(ExtBuffer_MA, ExtBuffer_EMA)
if nz(ExtBuffer_CF[1]) > ExtBuffer_MA and nz(ExtBuffer_CF[1]) < ExtBuffer_EMA
ExtBuffer_CF := ExtBuffer_MA
if nz(ExtBuffer_CF[1]) < ExtBuffer_MA and nz(ExtBuffer_CF[1]) > ExtBuffer_EMA
ExtBuffer_CF := ExtBuffer_EMA
ExtBuffer_CF := math.min(ExtBuffer_MA, ExtBuffer_EMA)
colorout =
ExtBuffer_EMA < ExtBuffer_MA and ExtBuffer_CF == ExtBuffer_EMA ? redcolor :
ExtBuffer_EMA < ExtBuffer_MA and ExtBuffer_CF == ExtBuffer_MA ? color.white :
ExtBuffer_EMA > ExtBuffer_MA and ExtBuffer_CF == ExtBuffer_EMA ? greencolor :
ExtBuffer_EMA > ExtBuffer_MA and ExtBuffer_CF == ExtBuffer_MA ? color.white : na
goLong = ta.crossover(ExtBuffer_EMA, ExtBuffer_MA) and colorout != color.white
goShort = ta.crossunder(ExtBuffer_EMA, ExtBuffer_MA) and colorout != color.white
plot(ExtBuffer_MA, color = color.white, linewidth = 1)
plot(ExtBuffer_EMA, color = colorout, linewidth = 3)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goLong, title="Long", message="Variety MA Cluster Filter Crosses [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Variety MA Cluster Filter Crosses [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
barcolor(colorbars ? colorout : na) |
Adaptive Fusion ADX Vortex | https://www.tradingview.com/script/jQKu8fOU-Adaptive-Fusion-ADX-Vortex/ | simwai | https://www.tradingview.com/u/simwai/ | 99 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© simwai
//@version=5
indicator('Adaptive Fusion ADX Vortex', 'A_FAV')
// -- Colors --
color maximumYellowRed = color.rgb(255, 203, 98) // yellow
color rajah = color.rgb(242, 166, 84) // orange
color magicMint = color.rgb(171, 237, 198)
color lightPurple = color.rgb(193, 133, 243)
color languidLavender = color.rgb(232, 215, 255)
color maximumBluePurple = color.rgb(181, 161, 226)
color skyBlue = color.rgb(144, 226, 244)
color lightGray = color.rgb(214, 214, 214)
color quickSilver = color.rgb(163, 163, 163)
color mediumAquamarine = color.rgb(104, 223, 153)
color carrotOrange = color.rgb(239, 146, 46)
color lightOrange = color.rgb(241, 205, 167)
color peachPuff = color.rgb(244, 215, 184)
// -- Inputs --
indicatorMode = input.string('Fusion', 'Choose Indicator Mode', ['ADX DI', 'Vortex', 'Fusion'], group='General', inline='1')
resolution = input.timeframe('', 'Resolution', group='General', inline='2')
adaptiveMode = input.string('None', 'Choose Adaptive Mode', options=['Inphase-Quadrature Transform', 'Median', 'Homodyne Discriminator', 'VHF', 'None'], tooltip='Used for CCI and MA length calculation', group='General', inline='3')
minLength = input.int(2, minval=2, title='Min Length', group='General', inline='3')
smoothingMode = input.string('Hann Window', 'Choose Smoothing Mode', options=['T3', 'T3 New', 'Hann Window', 'Super Smoother', 'None'], group='General', inline='4')
_smoothing = input.int(9, minval=2, title='Smoothing Length', group = 'General', inline='4')
isSpecialRuleEnabled = input.bool(false, 'Enable Special Enter Filter Rule', group='General', inline='5', tooltip='Either + or - plot needs to be unter ADX/Vortex/Fusion')
exitsGroup = 'Exits'
useCross = input.bool(title='Use DI/Vortex/Fusion Cross', defval=true, group=exitsGroup, inline='2')
useThreshold = input.bool(title='Use Threshold', defval=true, group=exitsGroup, inline='2')
_length = input.int(34, minval=2, maxval=499, title='Length', group = 'ADX DI/Vortex', inline='1', tooltip='Acts as max length when adaptive mode is on')
_threshold = input.float(0.2, minval=0, maxval=1.0, step=0.1, title='Threshold', group = 'ADX DI/Vortex', inline='2')
isThresholdColored = input.bool(false, 'Enable Threshold Coloring', group='ADX DI/Vortex', inline='3', tooltip='Applies a lighter color to threshold when ADX DI/Vortex/Fusion value is above it')
isThresholdDynamic = input.bool(false, 'Enable Dynamic Threshold', group='ADX DI/Vortex', inline='4')
dynamicThresholdLookback = input.int(34, 'Dynamic Threshold Lookback', group='ADX DI/Vortex', inline='4', tooltip='EXPERIMENTAL')
adxWeight = input.float(0.3, 'ADX Weight', group='Fusion', inline='1')
vortexWeight = input.float(0.7, 'Vortex Weight', group='Fusion', inline='1')
isHurstExponentFilterEnabled = input.bool(false, 'Enable Hurst Exponent Filter', group='Hurst Exponent Filter', inline='1')
isHurstExponentFilterSmoothed = input.bool(false, 'Enable Smoothing', group='Hurst Exponent Filter', inline='1')
len = input.int(300, 'Sample Size', minval=40, group='Hurst Exponent Filter', tooltip='lookback period for HE, Optimal Size > 50, Larger Size More Accurate and More lag', inline='2')
Bsc = input.int(16, 'Base Scale', options=[4, 8, 16], inline='3', group='Hurst Exponent Filter')
Msc = input.int(2, 'Max Scale', options=[2, 4], inline='3', group='Hurst Exponent Filter', tooltip='Select larger Value(Max and Base scale) when Sample Size is larger')
// -- Global States --
isVortexEnabled = indicatorMode == 'Vortex'
isFusionEnabled = indicatorMode == 'Fusion'
isAdxEnabled = indicatorMode == 'ADX DI'
[_close, _low, _high] = request.security(symbol = syminfo.tickerid, timeframe = resolution, expression = [close[1], low[1], high[1]], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)
// -- Functions --
// Get dominant cyber cycle β Median β Credits to @blackcat1402
getMedianDc(float Price, float alpha=0.07, simple float CycPart=0.5) =>
Smooth = 0.00
Cycle = 0.00
Q1 = 0.00
I1 = 0.00
DeltaPhase = 0.00
MedianDelta = 0.00
DC = 0.00
InstPeriod = 0.00
Period = 0.00
I2 = 0.00
Q2 = 0.00
IntPeriod = 0.0
Smooth := (Price + 2 * nz(Price[1]) + 2 * nz(Price[2]) + nz(Price[3])) / 6
Cycle := (1 - .5 * alpha) * (1 - .5 * alpha) * (Smooth - 2 * nz(Smooth[1]) + nz(Smooth[2])) + 2 * (1 - alpha) * nz(Cycle[1]) - (1 - alpha) * (1 - alpha) * nz(Cycle[2])
Cycle := bar_index < 7 ? (Price - 2 * nz(Price[1]) + nz(Price[2])) / 4 : Cycle
Q1 := (.0962 * Cycle + .5769 * nz(Cycle[2]) - .5769 * nz(Cycle[4]) - .0962 * nz(Cycle[6])) * (.5 + .08 * nz(InstPeriod[1]))
I1 := nz(Cycle[3])
DeltaPhase := Q1 != 0 and nz(Q1[1]) != 0 ? (I1 / Q1 - nz(I1[1]) / nz(Q1[1])) / (1 + I1 * nz(I1[1]) / (Q1 * nz(Q1[1]))) : DeltaPhase
DeltaPhase := DeltaPhase < 0.1 ? 0.1 : DeltaPhase
DeltaPhase := DeltaPhase > 1.1 ? 1.1 : DeltaPhase
MedianDelta := ta.median(DeltaPhase, 5)
DC := MedianDelta == 0.00 ? 15.00 : 6.28318 / MedianDelta + .5
InstPeriod := .33 * DC + .67 * nz(InstPeriod[1])
Period := .15 * InstPeriod + .85 * nz(Period[1])
//it can add filter to Period here
//IntPeriod := round((4*Period + 3*nz(Period[1]) + 2*nz(Period[3]) + nz(Period[4])) / 20)
IntPeriod := math.round(Period * CycPart) > 34 ? 34 : math.round(Period * CycPart) < 1 ? 1 : Period * CycPart
// Get dominant cyber cycle β Inphase-Quadrature -- Credits to @DasanC
getIqDc(float src, int min, int max) =>
PI = 3.14159265359
P = src - src[7]
lenIQ = 0.0
lenC = 0.0
imult = 0.635
qmult = 0.338
inphase = 0.0
quadrature = 0.0
re = 0.0
im = 0.0
deltaIQ = 0.0
instIQ = 0.0
V = 0.0
inphase := 1.25 * (P[4] - imult * P[2]) + imult * nz(inphase[3])
quadrature := P[2] - qmult * P + qmult * nz(quadrature[2])
re := 0.2 * (inphase * inphase[1] + quadrature * quadrature[1]) + 0.8 * nz(re[1])
im := 0.2 * (inphase * quadrature[1] - inphase[1] * quadrature) + 0.8 * nz(im[1])
if re != 0.0
deltaIQ := math.atan(im / re)
deltaIQ
for i = 0 to max by 1
V += deltaIQ[i]
if V > 2 * PI and instIQ == 0.0
instIQ := i
instIQ
if instIQ == 0.0
instIQ := nz(instIQ[1])
instIQ
lenIQ := 0.25 * instIQ + 0.75 * nz(lenIQ[1], 1)
length = lenIQ < min ? min : lenIQ
// Get Dominant Cyber Cycle - Homodyne Discriminator With Hilbert Dominant Cycle β Credits to @blackcat1402
getHdDc(float Price, int min, int max, simple float CycPart = 0.5) =>
Smooth = 0.00
Detrender = 0.00
I1 = 0.00
Q1 = 0.00
jI = 0.00
jQ = 0.00
I2 = 0.00
Q2 = 0.00
Re = 0.00
Im = 0.00
Period = 0.00
SmoothPeriod = 0.00
pi = 2 * math.asin(1)
DomCycle = 0.0
//Hilbert Transform
Smooth := bar_index > 7 ? (4 * Price + 3 * nz(Price[1]) + 2 * nz(Price[2]) + nz(Price[3])) / 10 : Smooth
Detrender := bar_index > 7 ? (.0962 * Smooth + .5769 * nz(Smooth[2]) - .5769 * nz(Smooth[4]) - .0962 * nz(Smooth[6])) * (.075 * nz(Period[1]) + .54) : Detrender
//Compute InPhase and Quadrature components
Q1 := bar_index > 7 ? (.0962 * Detrender + .5769 * nz(Detrender[2]) - .5769 * nz(Detrender[4]) - .0962 * nz(Detrender[6])) * (.075 * nz(Period[1]) + .54) : Q1
I1 := bar_index > 7 ? nz(Detrender[3]) : I1
//Advance the phase of I1 and Q1 by 90 degrees
jI := (.0962 * I1 + .5769 * nz(I1[2]) - .5769 * nz(I1[4]) - .0962 * nz(I1[6])) * (.075 * nz(Period[1]) + .54)
jQ := (.0962 * Q1 + .5769 * nz(Q1[2]) - .5769 * nz(Q1[4]) - .0962 * nz(Q1[6])) * (.075 * nz(Period[1]) + .54)
//Phasor addition for 3 bar averaging
I2 := I1 - jQ
Q2 := Q1 + jI
//Smooth the I and Q components before applying the discriminator
I2 := .2 * I2 + .8 * nz(I2[1])
Q2 := .2 * Q2 + .8 * nz(Q2[1])
//Homodyne Discriminator
Re := I2 * nz(I2[1]) + Q2 * nz(Q2[1])
Im := I2 * nz(Q2[1]) - Q2 * nz(I2[1])
Re := .2 * Re + .8 * nz(Re[1])
Im := .2 * Im + .8 * nz(Im[1])
Period := Im != 0 and Re != 0 ? 2 * pi / math.atan(Im / Re) : Period
Period := Period > 1.5 * nz(Period[1]) ? 1.5 * nz(Period[1]) : Period
Period := Period < .67 * nz(Period[1]) ? .67 * nz(Period[1]) : Period
Period := Period < min ? min : Period
Period := Period > max ? max : Period
Period := .2 * Period + .8 * nz(Period[1])
SmoothPeriod := .33 * Period + .67 * nz(SmoothPeriod[1])
//it can add filter to Period here
DomCycle := math.ceil(CycPart * SmoothPeriod) > 34 ? 34 : math.ceil(CycPart * SmoothPeriod) < 1 ? 1 : math.ceil(CycPart * SmoothPeriod)
// Limit dominant cycle
DomCycle := DomCycle < min ? min : DomCycle
DomCycle := DomCycle > max ? max : DomCycle
// Hann Window Smoothing β Credits to @cheatcountry
doHannWindow(float _series, float _hannWindowLength) =>
sum = 0.0, coef = 0.0
for i = 1 to _hannWindowLength
cosine = 1 - math.cos(2 * math.pi * i / (_hannWindowLength + 1))
sum := sum + (cosine * nz(_series[i - 1]))
coef := coef + cosine
h = coef != 0 ? sum / coef : 0
// T3 - Credits to @loxx
t3(float _src, float _length, float hot=0.5, string clean='T3')=>
a = hot
_c1 = -a * a * a
_c2 = 3 * a * a + 3 * a * a * a
_c3 = -6 * a * a - 3 * a - 3 * a * a * a
_c4 = 1 + 3 * a + a * a * a + 3 * a * a
alpha = 0.
if (clean == 'T3 New')
alpha := 2.0 / (2.0 + (_length - 1.0) / 2.0)
else
alpha := 2.0 / (1.0 + _length)
_t30 = _src, _t31 = _src
_t32 = _src, _t33 = _src
_t34 = _src, _t35 = _src
_t30 := nz(_t30[1]) + alpha * (_src - nz(_t30[1]))
_t31 := nz(_t31[1]) + alpha * (_t30 - nz(_t31[1]))
_t32 := nz(_t32[1]) + alpha * (_t31 - nz(_t32[1]))
_t33 := nz(_t33[1]) + alpha * (_t32 - nz(_t33[1]))
_t34 := nz(_t34[1]) + alpha * (_t33 - nz(_t34[1]))
_t35 := nz(_t35[1]) + alpha * (_t34 - nz(_t35[1]))
out =
_c1 * _t35 + _c2 * _t34 +
_c3 * _t33 + _c4 * _t32
out
// Super Smoother Function - Credits to @balipour
ss(Series, Period) => // Super Smoother Function
var PI = 2.0 * math.asin(1.0)
var SQRT2 = math.sqrt(2.0)
lambda = PI * SQRT2 / Period
a1 = math.exp(-lambda)
coeff2 = 2.0 * a1 * math.cos(lambda)
coeff3 = -math.pow(a1, 2.0)
coeff1 = 1.0 - coeff2 - coeff3
filt1 = 0.0
filt1 := coeff1 * (Series + nz(Series[1])) * 0.5 + coeff2 * nz(filt1[1]) + coeff3 * nz(filt1[2])
filt1
doSmoothing(float _input, float length) =>
t3Hot = 0.5
switch smoothingMode
'Hann Window' => doHannWindow(_input, length)
'T3' => t3(_input, length, t3Hot, 'T3')
'T3 New' => t3(_input, length, t3Hot, 'T3 New')
'Super Smoother' => ss(_input, length)
=> _input
// VHF - Credits to @loxx
getVhf(float _close, int length) =>
if (bar_index > length)
vhfNoise = 0.
vhfDiff = (_close > nz(_close[1])) ? _close - nz(_close[1]) : nz(_close[1]) - _close
vhfNoise := nz(vhfNoise[1]) - nz(vhfDiff[length]) + vhfDiff
HCP = ta.highest(_close, length)
LCP = ta.lowest(_close, length)
vhf = (HCP - LCP) / vhfNoise
int peradapt = math.round(length * vhf * 2.0)
sma(source, length) =>
if bar_index > length
sum = 0.0
for i = 0 to length - 1
sum := sum + source[i]
sum / length
tr() =>
math.max(math.max(_high - _low, math.abs(_high - _close[1])), math.abs(_low - _close[1]))
rma(src, length) =>
if bar_index > length
alpha = 1/length
sum = 0.0
sum := na(sum[1]) ? sma(src, length) : alpha * src + (1 - alpha) * nz(sum[1])
dirmov(len, smoothing) =>
up = ta.change(_high)
down = -ta.change(_low)
truerange = rma(tr(), len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
plus := doSmoothing(plus, smoothing)
minus:= doSmoothing(minus, smoothing)
[plus, minus]
adx(length, smoothing) =>
[plus, minus] = dirmov(length, smoothing)
sum = plus + minus
part = math.abs(plus - minus) / (sum == 0 ? 1 : sum)
adx = 100 * t3(part, smoothing)
[adx, plus, minus]
atr(atrLength) =>
float tr = tr()
doSmoothing(tr, atrLength)
vortex(int len, smoothing) =>
tr = atr(smoothing)
part = math.max(_high - _high[1], 0)
part2 = math.max(_low[1] - _low, 0)
pdm = isFusionEnabled ? part : doSmoothing(part, smoothing)
mdm = isFusionEnabled ? part2 : doSmoothing(part2, smoothing)
plus = pdm / tr
minus = mdm / tr
absdiff = math.abs(plus - minus)
vortex = absdiff / (plus + minus)
[vortex, plus, minus]
length_to_alpha(length) =>
2 / (length + 1)
ema(source, length) =>
alpha = length_to_alpha(length)
ema = 0.0
ema := alpha * source + (1 - alpha) * nz(ema[1])
normalize(float _src, int _min, int _max) =>
var float _historicMin = 1.0
var float _historicMax = -1.0
_historicMin := math.min(nz(_src, _historicMin), _historicMin)
_historicMax := math.max(nz(_src, _historicMax), _historicMax)
_min + (_max - _min) * (_src - _historicMin) / math.max(_historicMax - _historicMin, 1)
// Convert length to alpha
getAlpha(float _length) => 2 / (_length + 1)
getDynamicThreshold(threshold, _length, fusion, _close) =>
// Calculate the dynamic threshold
dynamicThreshold = switch adaptiveMode
'Inphase-Quadrature Transform' => getIqDc(_close, 2, _length)
'Median' => getMedianDc(_close, getAlpha(_length))
'Homodyne Discriminator' => getHdDc(_close, 2, _length)
'VHF' => getVhf(_close, _length)
=> ta.highest(fusion, dynamicThresholdLookback) * 0.5
// Normalize the dynamic threshold
dynamicThreshold := normalize(dynamicThreshold, 0, 1)
// -- Calculation --
// Adaptive Length
length = switch adaptiveMode
'Inphase-Quadrature Transform' => math.round(getIqDc(_close, minLength, _length))
'Median' => math.round(getMedianDc(_close, getAlpha(_length)))
'Homodyne Discriminator' => math.round(getHdDc(_close, minLength, _length))
'VHF' => math.round(getVhf(_close, _length))
=> _length
smoothing = switch adaptiveMode
'Inphase-Quadrature Transform' => length
'Median' => length
'Homodyne Discriminator' => length
'VHF' => length
=> _smoothing
if (adaptiveMode != 'None' and minLength > length)
length := minLength
smoothing := minLength
// ADX DI
adx = 0.0
plus = 0.0
minus = 0.0
if (isAdxEnabled or isFusionEnabled)
[_adx, _plus, _minus] = adx(length, smoothing)
adx := _adx
plus := _plus
minus := _minus
// Vortex
vortex = 0.0
vortexPlus = 0.0
vortexMinus = 0.0
if (isVortexEnabled or isFusionEnabled)
[_vortex, _vortexPlus, _vortexMinus] = vortex(length, smoothing)
vortex := _vortex
vortexPlus := _vortexPlus
vortexMinus := _vortexMinus
// Fusion Mode
fusionMinus = 0.0
fusionPlus = 0.0
fusion = 0.0
if (isFusionEnabled)
fusionMinus := doSmoothing((minus * adxWeight + vortexMinus * vortexWeight) / (adxWeight + vortexWeight), length)
fusionPlus := doSmoothing((plus * adxWeight + vortexPlus * vortexWeight) / (adxWeight + vortexWeight), length)
fusion := (adx * adxWeight + vortex * vortexWeight) / (adxWeight + vortexWeight)
// Normalize ADX DI, Vortex and Fusion
max = 1
min = 0
if (isFusionEnabled)
adx := normalize(adx, min, max)
plus := normalize(plus, min, max)
minus := normalize(minus, min, max)
vortex := normalize(vortex, min, max)
vortexPlus := normalize(vortexPlus, min, max)
vortexMinus := normalize(vortexMinus, min, max)
fusion := normalize(fusion, min, max)
fusionPlus := normalize(fusionPlus, min, max)
fusionMinus := normalize(fusionMinus, min, max)
if (isAdxEnabled)
adx := normalize(adx, min, max)
plus := normalize(plus, min, max)
minus := normalize(minus, min, max)
if (isVortexEnabled)
vortex := normalize(vortex, min, max)
vortexPlus := normalize(vortexPlus, min, max)
vortexMinus := normalize(vortexMinus, min, max)
// Adaptive Threshold
threshold = isThresholdDynamic ? getDynamicThreshold(_threshold, length, fusion, _close) : _threshold
thresholdPlot = plot(threshold, color=fusion > threshold ? color.new(lightGray, 25) : color.new(lightGray, 75), title='Threshold')
// Plot Fusion Mode
fusionPlot = plot(isFusionEnabled ? fusion : na, color=color.new(maximumBluePurple, 90), style=plot.style_area, title='FUSION')
plot(isFusionEnabled ? fusionPlus : na, color=magicMint, title='+FUSION')
plot(isFusionEnabled ? fusionMinus : na, color=rajah, title='-FUSION')
// Plot ADX and DI
adxPlot = plot(isAdxEnabled ? adx : na, color=color.new(maximumBluePurple, 90), style=plot.style_area, title='ADX')
plot(isAdxEnabled ? plus : na, color=magicMint, title='+DI ADX')
plot(isAdxEnabled ? minus : na, color=rajah, title='-DI ADX')
// Plot Vortex
vortexPlot = plot(isVortexEnabled ? vortex : na, color=color.new(maximumBluePurple, 90), style=plot.style_area, title='VORTEX')
plot(isVortexEnabled ? vortexPlus : na, color=magicMint, title='+VORTEX')
plot(isVortexEnabled ? vortexMinus : na, color=rajah, title='-VORTEX')
fill(thresholdPlot, fusionPlot, color=isThresholdColored and isFusionEnabled and fusion > threshold ? color.new(lightGray, 50) : na)
fill(thresholdPlot, adxPlot, color=isThresholdColored and isAdxEnabled and adx > threshold ? color.new(lightGray, 50) : na)
fill(thresholdPlot, vortexPlot, color=isThresholdColored and isVortexEnabled and vortex > threshold ? color.new(lightGray, 50) : na)
// Hurst Exponent - Credits to @balipour
// Declaration
int Min = Bsc
int Max = Msc
var fluc = array.new_float(10)
var scale = array.new_float(10)
float slope = na
// Log Return
r = math.log(_close / _close[1])
// Mean of Log Return
mean = ta.sma(r, len)
// Cumulative Sum
var csum = array.new_float(len)
sum = 0.0
for i = 0 to len - 1 by 1
sum := r[i] - mean + sum
array.set(csum, i, sum)
// Root Mean Sum (FLuctuation) function linear trend to calculate error between linear trend and cumulative sum
RMS(N1, N) =>
// Slicing the array into different segments
var seq = array.new_float(N)
int count = 0
for i = 0 to N - 1 by 1
count += 1
array.set(seq, i, count)
y = array.slice(csum, N1, N1 + N)
// Linear regression measuing trend (N/(N-1) for sample unbiased adjustedment)
sdx = array.stdev(seq) * math.sqrt(N / (N - 1))
sdy = array.stdev(y) * math.sqrt(N / (N - 1))
cov = array.covariance(seq, y) * (N / (N - 1))
// Linear Regression Root Mean Square Error (Detrend)
r2 = math.pow(cov / (sdx * sdy), 2)
rms = math.sqrt(1 - r2) * sdy
rms
// Average of Root Mean Sum Measured each block (Log Scale)
Arms(bar) =>
num = math.floor(len / bar)
sumr = 0.0
for i = 0 to num - 1 by 1
sumr += RMS(i * bar, bar)
sumr
// Log Scale
avg = math.log10(sumr / num)
avg
// Approximating Log Scale Function (Saves Sample Size)
fs(x) => math.round(Min * math.pow(math.pow(len / (Max * Min), 0.1111111111), x))
// Set Ten points of Root Mean Square Average along the Y log axis
array.set(fluc, 0, Arms(fs(0)))
array.set(fluc, 1, Arms(fs(1)))
array.set(fluc, 2, Arms(fs(2)))
array.set(fluc, 3, Arms(fs(3)))
array.set(fluc, 4, Arms(fs(4)))
array.set(fluc, 5, Arms(fs(5)))
array.set(fluc, 6, Arms(fs(6)))
array.set(fluc, 7, Arms(fs(7)))
array.set(fluc, 8, Arms(fs(8)))
array.set(fluc, 9, Arms(fs(9)))
// Set Ten Points of data scale along the X log axis
for i = 0 to 9 by 1
array.set(scale, i, math.log10(fs(i)))
// Slope Measured From RMS and Scale on Log log plot using linear regression
slope := array.covariance(scale, fluc) / array.variance(scale)
// Signals
enterLong = (isAdxEnabled ? adx > threshold and ta.crossover(plus, minus) and adx > adx[5] : false) or (isVortexEnabled ? vortex > threshold and ta.crossover(vortexPlus, vortexMinus) and vortex > vortex[5] : false) or (isFusionEnabled ? fusion > threshold and ta.crossover(fusionPlus, fusionMinus) and fusion > fusion[5] : false)
enterShort = (isAdxEnabled ? adx > threshold and ta.crossunder(plus, minus) and adx > adx[5] : false) or (isVortexEnabled ? vortex > threshold and ta.crossunder(vortexPlus, vortexMinus) and vortex > vortex[5] : false) or (isFusionEnabled ? fusion > threshold and ta.crossunder(fusionPlus, fusionMinus) and fusion > fusion[5] : false)
exitLong = false
exitShort = false
if (isSpecialRuleEnabled)
specialRule = (isAdxEnabled ? plus < adx or minus < adx : true) and (isVortexEnabled ? vortexPlus < vortex or vortexMinus < vortex : true) and (isFusionEnabled ? fusionPlus < fusion or fusionMinus < fusion : true)
enterLong := enterLong and specialRule
enterShort := enterShort and specialRule
if (useCross)
exitLong := exitLong or (isAdxEnabled ? ta.crossover(minus, plus) : false) or (isVortexEnabled ? ta.crossover(vortexMinus, vortexPlus) : false) or (isFusionEnabled ? ta.crossover(fusionMinus, fusionPlus) : false)
exitShort := exitShort or (isAdxEnabled ? ta.crossunder(minus, plus) : false) or (isVortexEnabled ? ta.crossunder(vortexMinus, vortexPlus) : false) or (isFusionEnabled ? ta.crossunder(fusionMinus, fusionPlus) : false)
if (useThreshold)
exitLong := exitLong or (isAdxEnabled ? ta.cross(adx, threshold) : false) or (isVortexEnabled ? ta.cross(vortex, threshold) : false) or (isFusionEnabled ? ta.cross(fusion, threshold) : false)
exitShort := exitShort or (isAdxEnabled ? ta.cross(adx, threshold) : false) or (isVortexEnabled ? ta.cross(vortex, threshold) : false) or (isFusionEnabled ? ta.cross(fusion, threshold) : false)
// Apply Hurst Exponent Filter
hurst = 0.0
if (isHurstExponentFilterEnabled)
// Calculate super smoothed Hurst Exponent
if (isHurstExponentFilterSmoothed)
hurst := doSmoothing(slope, smoothing)
hurstExponentThreshold = 0.4
if (hurst < hurstExponentThreshold)
enterLong := false
exitLong := false
enterShort := false
exitShort := false
// Plot Hurst Exponent
plot(hurst, title='HURST EXPONENT', color=color.new(lightGray, 75))
// -- Signal Cache --
// It shouldn't happen that multiple signals are executed in one instance
// The cache tries to order the signals correctly
var string openTrade = ''
var string signalCache = ''
if (signalCache == 'long entry')
signalCache := ''
enterLong := true
else if (signalCache == 'short entry')
signalCache := ''
enterShort := true
// -- Signal Cache --
// It shouldn't happen that multiple signals are executed in one instance
// The cache tries to order the signals correctly
if (signalCache == 'long entry')
signalCache := ''
enterLong := true
else if (signalCache == 'short entry')
signalCache := ''
enterShort := true
else if (signalCache == 'long exit')
signalCache := ''
exitLong := true
else if (signalCache == 'short exit')
signalCache := ''
exitShort := true
if (openTrade == '')
if (exitShort and (not enterLong))
exitShort := false
if (exitLong and (not enterShort))
exitLong := false
if (enterLong and exitShort)
openTrade := 'long'
exitShort := false
else if (enterShort and exitLong)
openTrade := 'short'
exitLong := false
else if (enterLong)
openTrade := 'long'
else if (enterShort)
openTrade := 'short'
else if (openTrade == 'long')
if (exitShort)
exitShort := false
if (enterLong)
enterLong := false
if (enterShort)
enterShort := false
signalCache := 'short entry'
if (exitLong)
openTrade := ''
else if (openTrade == 'short')
if (exitLong)
exitLong := false
if (enterShort)
enterShort := false
if (enterLong)
enterLong := false
signalCache := 'long entry'
if (exitShort)
openTrade := ''
bottomLevel = min
topLevel = max
plotshape(max, color=openTrade == 'short' ? color.new(rajah, 50) : color.new(quickSilver, 75), title='SHORT', location=location.absolute)
plotshape(min, color=openTrade == 'long' ? color.new(magicMint, 50) : color.new(quickSilver, 75), title='LONG', location=location.absolute)
plotshape(enterLong ? bottomLevel : na, title='ENTER LONG', text='B', style=shape.labelup, color=mediumAquamarine, textcolor=color.white, size=size.tiny, location=location.absolute)
plotshape(enterShort ? topLevel : na, title='ENTER SHORT', text='S', style=shape.labeldown, color=carrotOrange, textcolor=color.white, size=size.tiny, location=location.absolute)
plotshape(exitLong ? bottomLevel : na, title='EXIT LONG', text='BE', style=shape.labelup, color=mediumAquamarine, textcolor=color.white, size=size.tiny, location=location.absolute)
plotshape(exitShort ? topLevel : na, title='EXIT SHORT', text='SE', style=shape.labeldown, color=carrotOrange, textcolor=color.white, size=size.tiny, location=location.absolute)
// Try to fix scale with hidden plots
plot(1.6, 'Scale fix', color.rgb(0, 0, 0, 100), editable=false)
plot(-0.6, 'Scale fix', color.rgb(0, 0, 0, 100), editable=false)
// -- Alerts --
alertcondition(enterLong, title='ENTER LONG', message='ENTER LONG')
alertcondition(exitLong, title='EXIT LONG', message='EXIT LONG')
alertcondition(enterShort, title='ENTER SHORT', message='ENTER SHORT')
alertcondition(exitShort, title='EXIT SHORT', message='EXIT SHORT') |
Quad RS | https://www.tradingview.com/script/99b74MJm-Quad-RS/ | InvestIn10 | https://www.tradingview.com/u/InvestIn10/ | 23 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© InvestIn10
//@version=5
indicator("Quad RS", shorttitle="Quad RS", timeframe="")
sym = input.symbol("NSE:NIFTY", "Relative Symbol")
period1 = input.int(500, "Period 1")
period2 = input.int(250, "Period 2")
period3 = input.int(125, "Period 3")
period4 = input.int(63, "Period 4")
baseSym = request.security(syminfo.tickerid, timeframe.period, close)
rel = request.security(sym, timeframe.period, close)
rs1 = (baseSym / baseSym[period1]) / (rel / rel[period1]) - 1
rs2 = (baseSym / baseSym[period2]) / (rel / rel[period2]) - 1
rs3 = (baseSym / baseSym[period3]) / (rel / rel[period3]) - 1
rs4 = (baseSym / baseSym[period4]) / (rel / rel[period4]) - 1
hline(0)
plot(rs1, color=color.rgb(12, 107, 202), title="RS 1")
plot(rs2, color=color.rgb(25, 143, 12), title="RS 2")
plot(rs3, color=color.orange, title="RS 3")
plot(rs4, color=color.red, title="RS 4")
|
Double Trends [theEccentricTrader] | https://www.tradingview.com/script/yUqQcSHM-Double-Trends-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 8 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Double Trends [theEccentricTrader]', overlay = true)
//////////// double trends ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
onePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
twoPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
threePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
fourPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
fivePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
sixPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
sevenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
eightPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8)
ninePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8) and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9)
tenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10)
elevenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) > ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8) and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9)
and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10) and ta.valuewhen(shPrice, shPrice, 10) > ta.valuewhen(shPrice, shPrice, 11)
twelvePartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) > ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(slPrice, slPrice, 11) > ta.valuewhen(slPrice, slPrice, 12)
and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) > ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(shPrice, shPrice, 11) > ta.valuewhen(shPrice, shPrice, 12)
thirteenPartPeakTroughDoubleUptrend = slPrice and ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) > ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(slPrice, slPrice, 11) > ta.valuewhen(slPrice, slPrice, 12)
and ta.valuewhen(slPrice, slPrice, 12) > ta.valuewhen(slPrice, slPrice, 13) and ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2) and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4) and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6) and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8) and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9)
and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10) and ta.valuewhen(shPrice, shPrice, 10) > ta.valuewhen(shPrice, shPrice, 11)
and ta.valuewhen(shPrice, shPrice, 11) > ta.valuewhen(shPrice, shPrice, 12) and ta.valuewhen(shPrice, shPrice, 12) > ta.valuewhen(shPrice, shPrice, 13)
onePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
twoPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
threePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
fourPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
fivePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
sixPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
sevenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
eightPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8)
ninePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8) and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9)
tenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10)
elevenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) < ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8) and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9)
and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10) and ta.valuewhen(slPrice, slPrice, 10) < ta.valuewhen(slPrice, slPrice, 11)
twelvePartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) < ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(shPrice, shPrice, 11) < ta.valuewhen(shPrice, shPrice, 12)
and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1) and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3) and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5) and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7) and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8)
and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9) and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10)
and ta.valuewhen(slPrice, slPrice, 10) < ta.valuewhen(slPrice, slPrice, 11) and ta.valuewhen(slPrice, slPrice, 11) < ta.valuewhen(slPrice, slPrice, 12)
thirteenPartTroughPeakDoubleDowntrend = shPrice and ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1) and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3) and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5) and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7) and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9) and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
and ta.valuewhen(shPrice, shPrice, 10) < ta.valuewhen(shPrice, shPrice, 11) and ta.valuewhen(shPrice, shPrice, 11) < ta.valuewhen(shPrice, shPrice, 12)
and ta.valuewhen(shPrice, shPrice, 12) < ta.valuewhen(shPrice, shPrice, 13) and ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2) and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4) and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6) and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8) and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9)
and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10) and ta.valuewhen(slPrice, slPrice, 10) < ta.valuewhen(slPrice, slPrice, 11)
and ta.valuewhen(slPrice, slPrice, 11) < ta.valuewhen(slPrice, slPrice, 12) and ta.valuewhen(slPrice, slPrice, 12) < ta.valuewhen(slPrice, slPrice, 13)
//////////// plots ////////////
plotshape(slPrice and onePartPeakTroughDoubleUptrend and not twoPartPeakTroughDoubleUptrend and low <= low[1] ? onePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '1', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and twoPartPeakTroughDoubleUptrend and not threePartPeakTroughDoubleUptrend and low <= low[1] ? twoPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '2', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and threePartPeakTroughDoubleUptrend and not fourPartPeakTroughDoubleUptrend and low <= low[1] ? threePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '3', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and fourPartPeakTroughDoubleUptrend and not fivePartPeakTroughDoubleUptrend and low <= low[1] ? fourPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '4', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and fivePartPeakTroughDoubleUptrend and not sixPartPeakTroughDoubleUptrend and low <= low[1] ? fivePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '5', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and sixPartPeakTroughDoubleUptrend and not sevenPartPeakTroughDoubleUptrend and low <= low[1] ? sixPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '6', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and sevenPartPeakTroughDoubleUptrend and not eightPartPeakTroughDoubleUptrend and low <= low[1] ? sevenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '7', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and eightPartPeakTroughDoubleUptrend and not ninePartPeakTroughDoubleUptrend and low <= low[1] ? eightPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '8', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and ninePartPeakTroughDoubleUptrend and not tenPartPeakTroughDoubleUptrend and low <= low[1] ? ninePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '9', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and tenPartPeakTroughDoubleUptrend and not elevenPartPeakTroughDoubleUptrend and low <= low[1] ? tenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '10', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and elevenPartPeakTroughDoubleUptrend and not twelvePartPeakTroughDoubleUptrend and low <= low[1] ? elevenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '11', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and twelvePartPeakTroughDoubleUptrend and not thirteenPartPeakTroughDoubleUptrend and low <= low[1] ? twelvePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '12', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and thirteenPartPeakTroughDoubleUptrend and low <= low[1] ? thirteenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '13', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and onePartPeakTroughDoubleUptrend and not twoPartPeakTroughDoubleUptrend and low > low[1] ? onePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '1', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and twoPartPeakTroughDoubleUptrend and not threePartPeakTroughDoubleUptrend and low > low[1] ? twoPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '2', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and threePartPeakTroughDoubleUptrend and not fourPartPeakTroughDoubleUptrend and low > low[1] ? threePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '3', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and fourPartPeakTroughDoubleUptrend and not fivePartPeakTroughDoubleUptrend and low > low[1] ? fourPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '4', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and fivePartPeakTroughDoubleUptrend and not sixPartPeakTroughDoubleUptrend and low > low[1] ? fivePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '5', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and sixPartPeakTroughDoubleUptrend and not sevenPartPeakTroughDoubleUptrend and low > low[1] ? sixPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '6', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and sevenPartPeakTroughDoubleUptrend and not eightPartPeakTroughDoubleUptrend and low > low[1] ? sevenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '7', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and eightPartPeakTroughDoubleUptrend and not ninePartPeakTroughDoubleUptrend and low > low[1] ? eightPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '8', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and ninePartPeakTroughDoubleUptrend and not tenPartPeakTroughDoubleUptrend and low > low[1] ? ninePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '9', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and tenPartPeakTroughDoubleUptrend and not elevenPartPeakTroughDoubleUptrend and low > low[1] ? tenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '10', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and elevenPartPeakTroughDoubleUptrend and not twelvePartPeakTroughDoubleUptrend and low > low[1] ? elevenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '11', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and twelvePartPeakTroughDoubleUptrend and not thirteenPartPeakTroughDoubleUptrend and low > low[1] ? twelvePartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '12', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and thirteenPartPeakTroughDoubleUptrend and low > low[1] ? thirteenPartPeakTroughDoubleUptrend : na,
style = shape.triangleup, color = color.green, text = '13', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(shPrice and onePartTroughPeakDoubleDowntrend and not twoPartTroughPeakDoubleDowntrend and high >= high[1] ? onePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '1', textcolor = color.red)
plotshape(shPrice and twoPartTroughPeakDoubleDowntrend and not threePartTroughPeakDoubleDowntrend and high >= high[1] ? twoPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '2', textcolor = color.red)
plotshape(shPrice and threePartTroughPeakDoubleDowntrend and not fourPartTroughPeakDoubleDowntrend and high >= high[1] ? threePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '3', textcolor = color.red)
plotshape(shPrice and fourPartTroughPeakDoubleDowntrend and not fivePartTroughPeakDoubleDowntrend and high >= high[1] ? fourPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '4', textcolor = color.red)
plotshape(shPrice and fivePartTroughPeakDoubleDowntrend and not sixPartTroughPeakDoubleDowntrend and high >= high[1] ? fivePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '5', textcolor = color.red)
plotshape(shPrice and sixPartTroughPeakDoubleDowntrend and not sevenPartTroughPeakDoubleDowntrend and high >= high[1] ? sixPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '6', textcolor = color.red)
plotshape(shPrice and sevenPartTroughPeakDoubleDowntrend and not eightPartTroughPeakDoubleDowntrend and high >= high[1] ? sevenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '7', textcolor = color.red)
plotshape(shPrice and eightPartTroughPeakDoubleDowntrend and not ninePartTroughPeakDoubleDowntrend and high >= high[1] ? eightPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '8', textcolor = color.red)
plotshape(shPrice and ninePartTroughPeakDoubleDowntrend and not tenPartTroughPeakDoubleDowntrend and high >= high[1] ? ninePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '9', textcolor = color.red)
plotshape(shPrice and tenPartTroughPeakDoubleDowntrend and not elevenPartTroughPeakDoubleDowntrend and high >= high[1] ? tenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '10', textcolor = color.red)
plotshape(shPrice and elevenPartTroughPeakDoubleDowntrend and not twelvePartTroughPeakDoubleDowntrend and high >= high[1] ? elevenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '11', textcolor = color.red)
plotshape(shPrice and twelvePartTroughPeakDoubleDowntrend and not thirteenPartTroughPeakDoubleDowntrend and high >= high[1] ? twelvePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '12', textcolor = color.red)
plotshape(shPrice and thirteenPartTroughPeakDoubleDowntrend and high >= high[1] ? thirteenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '13', textcolor = color.red)
plotshape(shPrice and onePartTroughPeakDoubleDowntrend and not twoPartTroughPeakDoubleDowntrend and high < high[1] ? onePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '1', textcolor = color.red, offset = -1)
plotshape(shPrice and twoPartTroughPeakDoubleDowntrend and not threePartTroughPeakDoubleDowntrend and high < high[1] ? twoPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '2', textcolor = color.red, offset = -1)
plotshape(shPrice and threePartTroughPeakDoubleDowntrend and not fourPartTroughPeakDoubleDowntrend and high < high[1] ? threePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '3', textcolor = color.red, offset = -1)
plotshape(shPrice and fourPartTroughPeakDoubleDowntrend and not fivePartTroughPeakDoubleDowntrend and high < high[1] ? fourPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '4', textcolor = color.red, offset = -1)
plotshape(shPrice and fivePartTroughPeakDoubleDowntrend and not sixPartTroughPeakDoubleDowntrend and high < high[1] ? fivePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '5', textcolor = color.red, offset = -1)
plotshape(shPrice and sixPartTroughPeakDoubleDowntrend and not sevenPartTroughPeakDoubleDowntrend and high < high[1] ? sixPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '6', textcolor = color.red, offset = -1)
plotshape(shPrice and sevenPartTroughPeakDoubleDowntrend and not eightPartTroughPeakDoubleDowntrend and high < high[1] ? sevenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '7', textcolor = color.red, offset = -1)
plotshape(shPrice and eightPartTroughPeakDoubleDowntrend and not ninePartTroughPeakDoubleDowntrend and high < high[1] ? eightPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '8', textcolor = color.red, offset = -1)
plotshape(shPrice and ninePartTroughPeakDoubleDowntrend and not tenPartTroughPeakDoubleDowntrend and high < high[1] ? ninePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '9', textcolor = color.red, offset = -1)
plotshape(shPrice and tenPartTroughPeakDoubleDowntrend and not elevenPartTroughPeakDoubleDowntrend and high < high[1] ? tenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '10', textcolor = color.red, offset = -1)
plotshape(shPrice and elevenPartTroughPeakDoubleDowntrend and not twelvePartTroughPeakDoubleDowntrend and high < high[1] ? elevenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '11', textcolor = color.red, offset = -1)
plotshape(shPrice and twelvePartTroughPeakDoubleDowntrend and not thirteenPartTroughPeakDoubleDowntrend and high < high[1] ? twelvePartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '12', textcolor = color.red, offset = -1)
plotshape(shPrice and thirteenPartTroughPeakDoubleDowntrend and high < high[1] ? thirteenPartTroughPeakDoubleDowntrend : na,
style = shape.triangledown, color = color.red, text = '13', textcolor = color.red, offset = -1) |
Double Candle Trend Counter [theEccentricTrader] | https://www.tradingview.com/script/uuBGLWN7-Double-Candle-Trend-Counter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 30 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Double Candle Trend Counter [theEccentricTrader]', overlay = true)
//////////// sample period filter ////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input.time(timestamp('1 Jan 1800 00:00'), title = 'Start Date', group = 'Sample Period')
end = input.time(timestamp('1 Jan 3000 00:00'), title = 'End Date', group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
str.tostring(dayofmonth(_t), '00') + '.' + str.tostring(month(_t), '00') + '.' + str.tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
//////////// upper and lower candle trend counters ////////////
oneDUT = high > high[1] and low > low[1] and (high[1] <= high[2] or low[1] <= low[2]) and barstate.isconfirmed and samplePeriodFilter
twoDUT = oneDUT[1] and high > high[1] and oneDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
threeDUT = twoDUT[1] and high > high[1] and twoDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fourDUT = threeDUT[1] and high > high[1] and threeDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fiveDUT = fourDUT[1] and high > high[1] and fourDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
sixDUT = fiveDUT[1] and high > high[1] and fiveDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
sevenDUT = sixDUT[1] and high > high[1] and sixDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
eightDUT = sevenDUT[1] and high > high[1] and sevenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
nineDUT = eightDUT[1] and high > high[1] and eightDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
tenDUT = nineDUT[1] and high > high[1] and nineDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
elevenDUT = tenDUT[1] and high > high[1] and tenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twelveDUT = elevenDUT[1] and high > high[1] and elevenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
thirteenDUT = twelveDUT[1] and high > high[1] and twelveDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fourteenDUT = thirteenDUT[1] and high > high[1] and thirteenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fifteenDUT = fourteenDUT[1] and high > high[1] and fourteenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
sixteenDUT = fifteenDUT[1] and high > high[1] and fifteenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
seventeenDUT = sixteenDUT[1] and high > high[1] and sixteenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
eighteenDUT = seventeenDUT[1] and high > high[1] and seventeenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
nineteenDUT = eighteenDUT[1] and high > high[1] and eighteenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyDUT = nineteenDUT[1] and high > high[1] and nineteenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyoneDUT = twentyDUT[1] and high > high[1] and twentyDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentytwoDUT = twentyoneDUT[1] and high > high[1] and twentyoneDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentythreeDUT = twentytwoDUT[1] and high > high[1] and twentytwoDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfourDUT = twentythreeDUT[1] and high > high[1] and twentythreeDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfiveDUT = twentyfourDUT[1] and high > high[1] and twentyfourDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentysixDUT = twentyfiveDUT[1] and high > high[1] and twentyfiveDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentysevenDUT = twentysixDUT[1] and high > high[1] and twentysixDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyeightDUT = twentysevenDUT[1] and high > high[1] and twentysevenDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentynineDUT = twentyeightDUT[1] and high > high[1] and twentyeightDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
thirtyDUT = twentynineDUT[1] and high > high[1] and twentynineDUT[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
oneDDT = high < high[1] and low < low[1] and (high[1] >= high[2] or low[1] >= low[2]) and barstate.isconfirmed and samplePeriodFilter
twoDDT = oneDDT[1] and high < high[1] and oneDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
threeDDT = twoDDT[1] and high < high[1] and twoDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fourDDT = threeDDT[1] and high < high[1] and threeDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fiveDDT = fourDDT[1] and high < high[1] and fourDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
sixDDT = fiveDDT[1] and high < high[1] and fiveDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
sevenDDT = sixDDT[1] and high < high[1] and sixDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
eightDDT = sevenDDT[1] and high < high[1] and sevenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
nineDDT = eightDDT[1] and high < high[1] and eightDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
tenDDT = nineDDT[1] and high < high[1] and nineDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
elevenDDT = tenDDT[1] and high < high[1] and tenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twelveDDT = elevenDDT[1] and high < high[1] and elevenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
thirteenDDT = twelveDDT[1] and high < high[1] and twelveDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fourteenDDT = thirteenDDT[1] and high < high[1] and thirteenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fifteenDDT = fourteenDDT[1] and high < high[1] and fourteenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
sixteenDDT = fifteenDDT[1] and high < high[1] and fifteenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
seventeenDDT = sixteenDDT[1] and high < high[1] and sixteenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
eighteenDDT = seventeenDDT[1] and high < high[1] and seventeenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
nineteenDDT = eighteenDDT[1] and high < high[1] and eighteenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyDDT = nineteenDDT[1] and high < high[1] and nineteenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyoneDDT = twentyDDT[1] and high < high[1] and twentyDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentytwoDDT = twentyoneDDT[1] and high < high[1] and twentyoneDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentythreeDDT = twentytwoDDT[1] and high < high[1] and twentytwoDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfourDDT = twentythreeDDT[1] and high < high[1] and twentythreeDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfiveDDT = twentyfourDDT[1] and high < high[1] and twentyfourDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentysixDDT = twentyfiveDDT[1] and high < high[1] and twentyfiveDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentysevenDDT = twentysixDDT[1] and high < high[1] and twentysixDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyeightDDT = twentysevenDDT[1] and high < high[1] and twentysevenDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentynineDDT = twentyeightDDT[1] and high < high[1] and twentyeightDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
thirtyDDT = twentynineDDT[1] and high < high[1] and twentynineDDT[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
var oneDUTcounter = 0
var twoDUTcounter = 0
var threeDUTcounter = 0
var fourDUTcounter = 0
var fiveDUTcounter = 0
var sixDUTcounter = 0
var sevenDUTcounter = 0
var eightDUTcounter = 0
var nineDUTcounter = 0
var tenDUTcounter = 0
var elevenDUTcounter = 0
var twelveDUTcounter = 0
var thirteenDUTcounter = 0
var fourteenDUTcounter = 0
var fifteenDUTcounter = 0
var sixteenDUTcounter = 0
var seventeenDUTcounter = 0
var eighteenDUTcounter = 0
var nineteenDUTcounter = 0
var twentyDUTcounter = 0
var twentyoneDUTcounter = 0
var twentytwoDUTcounter = 0
var twentythreeDUTcounter = 0
var twentyfourDUTcounter = 0
var twentyfiveDUTcounter = 0
var twentysixDUTcounter = 0
var twentysevenDUTcounter = 0
var twentyeightDUTcounter = 0
var twentynineDUTcounter = 0
var thirtyDUTcounter = 0
var oneDDTcounter = 0
var twoDDTcounter = 0
var threeDDTcounter = 0
var fourDDTcounter = 0
var fiveDDTcounter = 0
var sixDDTcounter = 0
var sevenDDTcounter = 0
var eightDDTcounter = 0
var nineDDTcounter = 0
var tenDDTcounter = 0
var elevenDDTcounter = 0
var twelveDDTcounter = 0
var thirteenDDTcounter = 0
var fourteenDDTcounter = 0
var fifteenDDTcounter = 0
var sixteenDDTcounter = 0
var seventeenDDTcounter = 0
var eighteenDDTcounter = 0
var nineteenDDTcounter = 0
var twentyDDTcounter = 0
var twentyoneDDTcounter = 0
var twentytwoDDTcounter = 0
var twentythreeDDTcounter = 0
var twentyfourDDTcounter = 0
var twentyfiveDDTcounter = 0
var twentysixDDTcounter = 0
var twentysevenDDTcounter = 0
var twentyeightDDTcounter = 0
var twentynineDDTcounter = 0
var thirtyDDTcounter = 0
if oneDUT
oneDUTcounter += 1
if twoDUT
twoDUTcounter += 1
if threeDUT
threeDUTcounter += 1
if fourDUT
fourDUTcounter += 1
if fiveDUT
fiveDUTcounter += 1
if sixDUT
sixDUTcounter += 1
if sevenDUT
sevenDUTcounter += 1
if eightDUT
eightDUTcounter += 1
if nineDUT
nineDUTcounter += 1
if tenDUT
tenDUTcounter += 1
if elevenDUT
elevenDUTcounter += 1
if twelveDUT
twelveDUTcounter += 1
if thirteenDUT
thirteenDUTcounter += 1
if fourteenDUT
fourteenDUTcounter += 1
if fifteenDUT
fifteenDUTcounter += 1
if sixteenDUT
sixteenDUTcounter += 1
if seventeenDUT
seventeenDUTcounter += 1
if eighteenDUT
eighteenDUTcounter += 1
if nineteenDUT
nineteenDUTcounter += 1
if twentyDUT
twentyDUTcounter += 1
if twentyoneDUT
twentyoneDUTcounter += 1
if twentytwoDUT
twentytwoDUTcounter += 1
if twentythreeDUT
twentythreeDUTcounter += 1
if twentyfourDUT
twentyfourDUTcounter += 1
if twentyfiveDUT
twentyfiveDUTcounter += 1
if twentysixDUT
twentysixDUTcounter += 1
if twentysevenDUT
twentysevenDUTcounter += 1
if twentyeightDUT
twentyeightDUTcounter += 1
if twentynineDUT
twentynineDUTcounter += 1
if thirtyDUT
thirtyDUTcounter += 1
if oneDDT
oneDDTcounter += 1
if twoDDT
twoDDTcounter += 1
if threeDDT
threeDDTcounter += 1
if fourDDT
fourDDTcounter += 1
if fiveDDT
fiveDDTcounter += 1
if sixDDT
sixDDTcounter += 1
if sevenDDT
sevenDDTcounter += 1
if eightDDT
eightDDTcounter += 1
if nineDDT
nineDDTcounter += 1
if tenDDT
tenDDTcounter += 1
if elevenDDT
elevenDDTcounter += 1
if twelveDDT
twelveDDTcounter += 1
if thirteenDDT
thirteenDDTcounter += 1
if fourteenDDT
fourteenDDTcounter += 1
if fifteenDDT
fifteenDDTcounter += 1
if sixteenDDT
sixteenDDTcounter += 1
if seventeenDDT
seventeenDDTcounter += 1
if eighteenDDT
eighteenDDTcounter += 1
if nineteenDDT
nineteenDDTcounter += 1
if twentyDDT
twentyDDTcounter += 1
if twentyoneDDT
twentyoneDDTcounter += 1
if twentytwoDDT
twentytwoDDTcounter += 1
if twentythreeDDT
twentythreeDDTcounter += 1
if twentyfourDDT
twentyfourDDTcounter += 1
if twentyfiveDDT
twentyfiveDDTcounter += 1
if twentysixDDT
twentysixDDTcounter += 1
if twentysevenDDT
twentysevenDDTcounter += 1
if twentyeightDDT
twentyeightDDTcounter += 1
if twentynineDDT
twentynineDDTcounter += 1
if thirtyDDT
thirtyDDTcounter += 1
//////////// table ////////////
doubleCandleTrendTablePositionInput = input.string(title = 'Position', defval = 'Top Right', options=['Top Right', 'Top Center'], group = 'Table Positioning')
doubleCandleTrendTablePosition = doubleCandleTrendTablePositionInput == 'Top Right' ? position.top_right : doubleCandleTrendTablePositionInput == 'Top Center' ? position.top_center :
doubleCandleTrendTablePositionInput == 'Top Left' ? position.top_left : doubleCandleTrendTablePositionInput == 'Bottom Right' ? position.bottom_right :
doubleCandleTrendTablePositionInput == 'Bottom Center' ? position.bottom_center : doubleCandleTrendTablePositionInput == 'Bottom Left' ? position.bottom_left :
doubleCandleTrendTablePositionInput == 'Middle Right' ? position.middle_right : doubleCandleTrendTablePositionInput == 'Middle Center' ? position.middle_center :
doubleCandleTrendTablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
var doubleCandleTrendTable = table.new(doubleCandleTrendTablePosition, 100, 100, border_width=1)
table.cell(doubleCandleTrendTable, 1, 0, text = 'Double Uptrend Candle Trends', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 0, text = '% Total', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 0, text = '% Last', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 0, 1, text = '1-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 1, text = str.tostring(oneDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 0, text = 'Double Downtrend Candle Trends', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 0, text = '% Total', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 0, text = '% Last', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 1, text = str.tostring(oneDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twoDUTcounter >= 1 or twoDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 2, text = '2-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 2, text = str.tostring(twoDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 2, text = str.tostring(math.round(twoDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 2, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 2, text = str.tostring(twoDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 2, text = str.tostring(math.round(twoDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 2, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (threeDUTcounter >= 1 or threeDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 3, text = '3-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 3, text = str.tostring(threeDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 3, text = str.tostring(math.round(threeDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 3, text = str.tostring(math.round(threeDUTcounter / twoDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 3, text = str.tostring(threeDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 3, text = str.tostring(math.round(threeDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 3, text = str.tostring(math.round(threeDDTcounter / twoDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourDUTcounter >= 1 or fourDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 4, text = '4-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 4, text = str.tostring(fourDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 4, text = str.tostring(math.round(fourDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 4, text = str.tostring(math.round(fourDUTcounter / threeDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 4, text = str.tostring(fourDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 4, text = str.tostring(math.round(fourDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 4, text = str.tostring(math.round(fourDDTcounter / threeDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fiveDUTcounter >= 1 or fiveDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 5, text = '5-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 5, text = str.tostring(fiveDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 5, text = str.tostring(math.round(fiveDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 5, text = str.tostring(math.round(fiveDUTcounter / fourDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 5, text = str.tostring(fiveDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 5, text = str.tostring(math.round(fiveDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 5, text = str.tostring(math.round(fiveDDTcounter / fourDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixDUTcounter >= 1 or sixDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 6, text = '6-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 6, text = str.tostring(sixDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 6, text = str.tostring(math.round(sixDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 6, text = str.tostring(math.round(sixDUTcounter / fiveDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 6, text = str.tostring(sixDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 6, text = str.tostring(math.round(sixDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 6, text = str.tostring(math.round(sixDDTcounter / fiveDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sevenDUTcounter >= 1 or sevenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 7, text = '7-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 7, text = str.tostring(sevenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 7, text = str.tostring(math.round(sevenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 7, text = str.tostring(math.round(sevenDUTcounter / sixDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 7, text = str.tostring(sevenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 7, text = str.tostring(math.round(sevenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 7, text = str.tostring(math.round(sevenDDTcounter / sixDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eightDUTcounter >= 1 or eightDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 8, text = '8-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 8, text = str.tostring(eightDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 8, text = str.tostring(math.round(eightDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 8, text = str.tostring(math.round(eightDUTcounter / sevenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 8, text = str.tostring(eightDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 8, text = str.tostring(math.round(eightDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 8, text = str.tostring(math.round(eightDDTcounter / sevenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineDUTcounter >= 1 or nineDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 9, text = '9-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 9, text = str.tostring(nineDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 9, text = str.tostring(math.round(nineDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 9, text = str.tostring(math.round(nineDUTcounter / eightDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 9, text = str.tostring(nineDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 9, text = str.tostring(math.round(nineDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 9, text = str.tostring(math.round(nineDDTcounter / eightDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (tenDUTcounter >= 1 or tenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 10, text = '10-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 10, text = str.tostring(tenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 10, text = str.tostring(math.round(tenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 10, text = str.tostring(math.round(tenDUTcounter / nineDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 10, text = str.tostring(tenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 10, text = str.tostring(math.round(tenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 10, text = str.tostring(math.round(tenDDTcounter / nineDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (elevenDUTcounter >= 1 or elevenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 11, text = '11-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 11, text = str.tostring(elevenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 11, text = str.tostring(math.round(elevenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 11, text = str.tostring(math.round(elevenDUTcounter / tenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 11, text = str.tostring(elevenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 11, text = str.tostring(math.round(elevenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 11, text = str.tostring(math.round(elevenDDTcounter / tenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twelveDUTcounter >= 1 or twelveDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 12, text = '12-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 12, text = str.tostring(twelveDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 12, text = str.tostring(math.round(twelveDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 12, text = str.tostring(math.round(twelveDUTcounter / elevenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 12, text = str.tostring(twelveDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 12, text = str.tostring(math.round(twelveDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 12, text = str.tostring(math.round(twelveDDTcounter / elevenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirteenDUTcounter >= 1 or thirteenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 13, text = '13-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 13, text = str.tostring(thirteenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 13, text = str.tostring(math.round(thirteenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 13, text = str.tostring(math.round(thirteenDUTcounter / twelveDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 13, text = str.tostring(thirteenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 13, text = str.tostring(math.round(thirteenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 13, text = str.tostring(math.round(thirteenDDTcounter / twelveDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourteenDUTcounter >= 1 or fourteenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 14, text = '14-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 14, text = str.tostring(fourteenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 14, text = str.tostring(math.round(fourteenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 14, text = str.tostring(math.round(fourteenDUTcounter / thirteenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 14, text = str.tostring(fourteenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 14, text = str.tostring(math.round(fourteenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 14, text = str.tostring(math.round(fourteenDDTcounter / thirteenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fifteenDUTcounter >= 1 or fifteenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 15, text = '15-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 15, text = str.tostring(fifteenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 15, text = str.tostring(math.round(fifteenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 15, text = str.tostring(math.round(fifteenDUTcounter / fourteenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 15, text = str.tostring(fifteenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 15, text = str.tostring(math.round(fifteenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 15, text = str.tostring(math.round(fifteenDDTcounter / fourteenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixteenDUTcounter >= 1 or sixteenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 16, text = '16-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 16, text = str.tostring(sixteenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 16, text = str.tostring(math.round(sixteenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 16, text = str.tostring(math.round(sixteenDUTcounter / fifteenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 16, text = str.tostring(sixteenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 16, text = str.tostring(math.round(sixteenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 16, text = str.tostring(math.round(sixteenDDTcounter / fifteenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (seventeenDUTcounter >= 1 or seventeenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 17, text = '17-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 17, text = str.tostring(seventeenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 17, text = str.tostring(math.round(seventeenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 17, text = str.tostring(math.round(seventeenDUTcounter / sixteenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 17, text = str.tostring(seventeenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 17, text = str.tostring(math.round(seventeenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 17, text = str.tostring(math.round(seventeenDDTcounter / sixteenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eighteenDUTcounter >= 1 or eighteenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 18, text = '18-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 18, text = str.tostring(eighteenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 18, text = str.tostring(math.round(eighteenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 18, text = str.tostring(math.round(eighteenDUTcounter / seventeenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 18, text = str.tostring(eighteenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 18, text = str.tostring(math.round(eighteenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 18, text = str.tostring(math.round(eighteenDDTcounter / seventeenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineteenDUTcounter >= 1 or nineteenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 19, text = '19-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 19, text = str.tostring(nineteenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 19, text = str.tostring(math.round(nineteenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 19, text = str.tostring(math.round(nineteenDUTcounter / eighteenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 19, text = str.tostring(nineteenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 19, text = str.tostring(math.round(nineteenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 19, text = str.tostring(math.round(nineteenDDTcounter / eighteenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyDUTcounter >= 1 or twentyDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 20, text = '20-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 20, text = str.tostring(twentyDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 20, text = str.tostring(math.round(twentyDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 20, text = str.tostring(math.round(twentyDUTcounter / nineteenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 20, text = str.tostring(twentyDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 20, text = str.tostring(math.round(twentyDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 20, text = str.tostring(math.round(twentyDDTcounter / nineteenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyoneDUTcounter >= 1 or twentyoneDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 21, text = '21-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 21, text = str.tostring(twentyoneDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 21, text = str.tostring(math.round(twentyoneDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 21, text = str.tostring(math.round(twentyoneDUTcounter / twentyDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 21, text = str.tostring(twentyoneDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 21, text = str.tostring(math.round(twentyoneDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 21, text = str.tostring(math.round(twentyoneDDTcounter / twentyDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentytwoDUTcounter >= 1 or twentytwoDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 22, text = '22-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 22, text = str.tostring(twentytwoDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 22, text = str.tostring(math.round(twentytwoDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 22, text = str.tostring(math.round(twentytwoDUTcounter / twentyoneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 22, text = str.tostring(twentytwoDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 22, text = str.tostring(math.round(twentytwoDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 22, text = str.tostring(math.round(twentytwoDDTcounter / twentyoneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentythreeDUTcounter >= 1 or twentythreeDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 23, text = '23-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 23, text = str.tostring(twentythreeDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 23, text = str.tostring(math.round(twentythreeDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 23, text = str.tostring(math.round(twentythreeDUTcounter / twentytwoDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 23, text = str.tostring(twentythreeDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 23, text = str.tostring(math.round(twentythreeDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 23, text = str.tostring(math.round(twentythreeDDTcounter / twentytwoDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfourDUTcounter >= 1 or twentyfourDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 24, text = '24-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 24, text = str.tostring(twentyfourDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 24, text = str.tostring(math.round(twentyfourDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 24, text = str.tostring(math.round(twentyfourDUTcounter / twentythreeDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 24, text = str.tostring(twentyfourDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 24, text = str.tostring(math.round(twentyfourDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 24, text = str.tostring(math.round(twentyfourDDTcounter / twentythreeDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfiveDUTcounter >= 1 or twentyfiveDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 25, text = '25-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 25, text = str.tostring(twentyfiveDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 25, text = str.tostring(math.round(twentyfiveDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 25, text = str.tostring(math.round(twentyfiveDUTcounter / twentyfourDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 25, text = str.tostring(twentyfiveDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 25, text = str.tostring(math.round(twentyfiveDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 25, text = str.tostring(math.round(twentyfiveDDTcounter / twentyfourDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysixDUTcounter >= 1 or twentysixDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 26, text = '26-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 26, text = str.tostring(twentysixDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 26, text = str.tostring(math.round(twentysixDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 26, text = str.tostring(math.round(twentysixDUTcounter / twentyfiveDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 26, text = str.tostring(twentysixDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 26, text = str.tostring(math.round(twentysixDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 26, text = str.tostring(math.round(twentysixDDTcounter / twentyfiveDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysevenDUTcounter >= 1 or twentysevenDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 27, text = '27-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 27, text = str.tostring(twentysevenDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 27, text = str.tostring(math.round(twentysevenDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 27, text = str.tostring(math.round(twentysevenDUTcounter / twentysixDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 27, text = str.tostring(twentysevenDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 27, text = str.tostring(math.round(twentysevenDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 27, text = str.tostring(math.round(twentysevenDDTcounter / twentysixDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyeightDUTcounter >= 1 or twentyeightDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 28, text = '28-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 28, text = str.tostring(twentyeightDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 28, text = str.tostring(math.round(twentyeightDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 28, text = str.tostring(math.round(twentyeightDUTcounter / twentysevenDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 28, text = str.tostring(twentyeightDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 28, text = str.tostring(math.round(twentyeightDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 28, text = str.tostring(math.round(twentyeightDDTcounter / twentysevenDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentynineDUTcounter >= 1 or twentynineDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 29, text = '29-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 29, text = str.tostring(twentynineDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 29, text = str.tostring(math.round(twentynineDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 29, text = str.tostring(math.round(twentynineDUTcounter / twentyeightDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 29, text = str.tostring(twentynineDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 29, text = str.tostring(math.round(twentynineDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 29, text = str.tostring(math.round(twentynineDDTcounter / twentyeightDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirtyDUTcounter >= 1 or thirtyDDTcounter >= 1)
table.cell(doubleCandleTrendTable, 0, 30, text = '30-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 1, 30, text = str.tostring(thirtyDUTcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 2, 30, text = str.tostring(math.round(thirtyDUTcounter / oneDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 3, 30, text = str.tostring(math.round(thirtyDUTcounter / twentynineDUTcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 4, 30, text = str.tostring(thirtyDDTcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 5, 30, text = str.tostring(math.round(thirtyDDTcounter / oneDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(doubleCandleTrendTable, 6, 30, text = str.tostring(math.round(thirtyDDTcounter / twentynineDDTcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(doubleCandleTrendTable, 0, 31, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
//////////// plots ////////////
showPlots = input(defval = true, title = "Show Plots")
plotshape(oneDUT and showPlots, style = shape.triangleup, color = color.green, text = '1', textcolor = color.green, location = location.belowbar)
plotshape(twoDUT and showPlots, style = shape.triangleup, color = color.green, text = '2', textcolor = color.green, location = location.belowbar)
plotshape(threeDUT and showPlots, style = shape.triangleup, color = color.green, text = '3', textcolor = color.green, location = location.belowbar)
plotshape(fourDUT and showPlots, style = shape.triangleup, color = color.green, text = '4', textcolor = color.green, location = location.belowbar)
plotshape(fiveDUT and showPlots, style = shape.triangleup, color = color.green, text = '5', textcolor = color.green, location = location.belowbar)
plotshape(sixDUT and showPlots, style = shape.triangleup, color = color.green, text = '6', textcolor = color.green, location = location.belowbar)
plotshape(sevenDUT and showPlots, style = shape.triangleup, color = color.green, text = '7', textcolor = color.green, location = location.belowbar)
plotshape(eightDUT and showPlots, style = shape.triangleup, color = color.green, text = '8', textcolor = color.green, location = location.belowbar)
plotshape(nineDUT and showPlots, style = shape.triangleup, color = color.green, text = '9', textcolor = color.green, location = location.belowbar)
plotshape(tenDUT and showPlots, style = shape.triangleup, color = color.green, text = '10', textcolor = color.green, location = location.belowbar)
plotshape(elevenDUT and showPlots, style = shape.triangleup, color = color.green, text = '11', textcolor = color.green, location = location.belowbar)
plotshape(twelveDUT and showPlots, style = shape.triangleup, color = color.green, text = '12', textcolor = color.green, location = location.belowbar)
plotshape(thirteenDUT and showPlots, style = shape.triangleup, color = color.green, text = '13', textcolor = color.green, location = location.belowbar)
plotshape(fourteenDUT and showPlots, style = shape.triangleup, color = color.green, text = '14', textcolor = color.green, location = location.belowbar)
plotshape(fifteenDUT and showPlots, style = shape.triangleup, color = color.green, text = '15', textcolor = color.green, location = location.belowbar)
plotshape(sixteenDUT and showPlots, style = shape.triangleup, color = color.green, text = '16', textcolor = color.green, location = location.belowbar)
plotshape(seventeenDUT and showPlots, style = shape.triangleup, color = color.green, text = '17', textcolor = color.green, location = location.belowbar)
plotshape(eighteenDUT and showPlots, style = shape.triangleup, color = color.green, text = '18', textcolor = color.green, location = location.belowbar)
plotshape(nineteenDUT and showPlots, style = shape.triangleup, color = color.green, text = '19', textcolor = color.green, location = location.belowbar)
plotshape(twentyDUT and showPlots, style = shape.triangleup, color = color.green, text = '20', textcolor = color.green, location = location.belowbar)
plotshape(twentyoneDUT and showPlots, style = shape.triangleup, color = color.green, text = '21', textcolor = color.green, location = location.belowbar)
plotshape(twentytwoDUT and showPlots, style = shape.triangleup, color = color.green, text = '22', textcolor = color.green, location = location.belowbar)
plotshape(twentythreeDUT and showPlots, style = shape.triangleup, color = color.green, text = '23', textcolor = color.green, location = location.belowbar)
plotshape(twentyfourDUT and showPlots, style = shape.triangleup, color = color.green, text = '24', textcolor = color.green, location = location.belowbar)
plotshape(twentyfiveDUT and showPlots, style = shape.triangleup, color = color.green, text = '25', textcolor = color.green, location = location.belowbar)
plotshape(twentysixDUT and showPlots, style = shape.triangleup, color = color.green, text = '26', textcolor = color.green, location = location.belowbar)
plotshape(twentysevenDUT and showPlots, style = shape.triangleup, color = color.green, text = '27', textcolor = color.green, location = location.belowbar)
plotshape(twentyeightDUT and showPlots, style = shape.triangleup, color = color.green, text = '28', textcolor = color.green, location = location.belowbar)
plotshape(twentynineDUT and showPlots, style = shape.triangleup, color = color.green, text = '29', textcolor = color.green, location = location.belowbar)
plotshape(thirtyDUT and showPlots, style = shape.triangleup, color = color.green, text = '30', textcolor = color.green, location = location.belowbar)
plotshape(oneDDT and showPlots, style = shape.triangledown, color = color.red, text = '1', textcolor = color.red)
plotshape(twoDDT and showPlots, style = shape.triangledown, color = color.red, text = '2', textcolor = color.red)
plotshape(threeDDT and showPlots, style = shape.triangledown, color = color.red, text = '3', textcolor = color.red)
plotshape(fourDDT and showPlots, style = shape.triangledown, color = color.red, text = '4', textcolor = color.red)
plotshape(fiveDDT and showPlots, style = shape.triangledown, color = color.red, text = '5', textcolor = color.red)
plotshape(sixDDT and showPlots, style = shape.triangledown, color = color.red, text = '6', textcolor = color.red)
plotshape(sevenDDT and showPlots, style = shape.triangledown, color = color.red, text = '7', textcolor = color.red)
plotshape(eightDDT and showPlots, style = shape.triangledown, color = color.red, text = '8', textcolor = color.red)
plotshape(nineDDT and showPlots, style = shape.triangledown, color = color.red, text = '9', textcolor = color.red)
plotshape(tenDDT and showPlots, style = shape.triangledown, color = color.red, text = '10', textcolor = color.red)
plotshape(elevenDDT and showPlots, style = shape.triangledown, color = color.red, text = '11', textcolor = color.red)
plotshape(twelveDDT and showPlots, style = shape.triangledown, color = color.red, text = '12', textcolor = color.red)
plotshape(thirteenDDT and showPlots, style = shape.triangledown, color = color.red, text = '13', textcolor = color.red)
plotshape(fourteenDDT and showPlots, style = shape.triangledown, color = color.red, text = '14', textcolor = color.red)
plotshape(fifteenDDT and showPlots, style = shape.triangledown, color = color.red, text = '15', textcolor = color.red)
plotshape(sixteenDDT and showPlots, style = shape.triangledown, color = color.red, text = '16', textcolor = color.red)
plotshape(seventeenDDT and showPlots, style = shape.triangledown, color = color.red, text = '17', textcolor = color.red)
plotshape(eighteenDDT and showPlots, style = shape.triangledown, color = color.red, text = '18', textcolor = color.red)
plotshape(nineteenDDT and showPlots, style = shape.triangledown, color = color.red, text = '19', textcolor = color.red)
plotshape(twentyDDT and showPlots, style = shape.triangledown, color = color.red, text = '20', textcolor = color.red)
plotshape(twentyoneDDT and showPlots, style = shape.triangledown, color = color.red, text = '21', textcolor = color.red)
plotshape(twentytwoDDT and showPlots, style = shape.triangledown, color = color.red, text = '22', textcolor = color.red)
plotshape(twentythreeDDT and showPlots, style = shape.triangledown, color = color.red, text = '23', textcolor = color.red)
plotshape(twentyfourDDT and showPlots, style = shape.triangledown, color = color.red, text = '24', textcolor = color.red)
plotshape(twentyfiveDDT and showPlots, style = shape.triangledown, color = color.red, text = '25', textcolor = color.red)
plotshape(twentysixDDT and showPlots, style = shape.triangledown, color = color.red, text = '26', textcolor = color.red)
plotshape(twentysevenDDT and showPlots, style = shape.triangledown, color = color.red, text = '27', textcolor = color.red)
plotshape(twentyeightDDT and showPlots, style = shape.triangledown, color = color.red, text = '28', textcolor = color.red)
plotshape(twentynineDDT and showPlots, style = shape.triangledown, color = color.red, text = '29', textcolor = color.red)
plotshape(thirtyDDT and showPlots, style = shape.triangledown, color = color.red, text = '30', textcolor = color.red)
|
Upper and Lower Candle Trend Counter [theEccentricTrader] | https://www.tradingview.com/script/ZI3u0pXy-Upper-and-Lower-Candle-Trend-Counter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 16 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Upper and Lower Candle Trend Counter [theEccentricTrader]', overlay = true)
//////////// sample period filter ////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input.time(timestamp('1 Jan 1800 00:00'), title = 'Start Date', group = 'Sample Period')
end = input.time(timestamp('1 Jan 3000 00:00'), title = 'End Date', group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
str.tostring(dayofmonth(_t), '00') + '.' + str.tostring(month(_t), '00') + '.' + str.tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
//////////// upper and lower candle trend counters ////////////
oneHH = high[1] <= high[2] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twoHH = oneHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
threeHH = twoHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
fourHH = threeHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
fiveHH = fourHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
sixHH = fiveHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
sevenHH = sixHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
eightHH = sevenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
nineHH = eightHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
tenHH = nineHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
elevenHH = tenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twelveHH = elevenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
thirteenHH = twelveHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
fourteenHH = thirteenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
fifteenHH = fourteenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
sixteenHH = fifteenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
seventeenHH = sixteenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
eighteenHH = seventeenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
nineteenHH = eighteenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentyHH = nineteenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentyoneHH = twentyHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentytwoHH = twentyoneHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentythreeHH = twentytwoHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentyfourHH = twentythreeHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentyfiveHH = twentyfourHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentysixHH = twentyfiveHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentysevenHH = twentysixHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentyeightHH = twentysevenHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
twentynineHH = twentyeightHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
thirtyHH = twentynineHH[1] and high > high[1] and barstate.isconfirmed and samplePeriodFilter
oneHL = low[1] <= low[2] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twoHL = oneHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
threeHL = twoHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fourHL = threeHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fiveHL = fourHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
sixHL = fiveHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
sevenHL = sixHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
eightHL = sevenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
nineHL = eightHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
tenHL = nineHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
elevenHL = tenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twelveHL = elevenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
thirteenHL = twelveHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fourteenHL = thirteenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
fifteenHL = fourteenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
sixteenHL = fifteenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
seventeenHL = sixteenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
eighteenHL = seventeenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
nineteenHL = eighteenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyHL = nineteenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyoneHL = twentyHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentytwoHL = twentyoneHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentythreeHL = twentytwoHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfourHL = twentythreeHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfiveHL = twentyfourHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentysixHL = twentyfiveHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentysevenHL = twentysixHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentyeightHL = twentysevenHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
twentynineHL = twentyeightHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
thirtyHL = twentynineHL[1] and low > low[1] and barstate.isconfirmed and samplePeriodFilter
oneLH = high[1] >= high[2] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twoLH = oneLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
threeLH = twoLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
fourLH = threeLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
fiveLH = fourLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
sixLH = fiveLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
sevenLH = sixLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
eightLH = sevenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
nineLH = eightLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
tenLH = nineLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
elevenLH = tenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twelveLH = elevenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
thirteenLH = twelveLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
fourteenLH = thirteenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
fifteenLH = fourteenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
sixteenLH = fifteenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
seventeenLH = sixteenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
eighteenLH = seventeenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
nineteenLH = eighteenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentyLH = nineteenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentyoneLH = twentyLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentytwoLH = twentyoneLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentythreeLH = twentytwoLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentyfourLH = twentythreeLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentyfiveLH = twentyfourLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentysixLH = twentyfiveLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentysevenLH = twentysixLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentyeightLH = twentysevenLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
twentynineLH = twentyeightLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
thirtyLH = twentynineLH[1] and high < high[1] and barstate.isconfirmed and samplePeriodFilter
oneLL = low[1] >= low[2] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twoLL = oneLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
threeLL = twoLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fourLL = threeLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fiveLL = fourLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
sixLL = fiveLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
sevenLL = sixLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
eightLL = sevenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
nineLL = eightLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
tenLL = nineLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
elevenLL = tenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twelveLL = elevenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
thirteenLL = twelveLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fourteenLL = thirteenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
fifteenLL = fourteenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
sixteenLL = fifteenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
seventeenLL = sixteenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
eighteenLL = seventeenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
nineteenLL = eighteenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyLL = nineteenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyoneLL = twentyLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentytwoLL = twentyoneLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentythreeLL = twentytwoLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfourLL = twentythreeLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyfiveLL = twentyfourLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentysixLL = twentyfiveLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentysevenLL = twentysixLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentyeightLL = twentysevenLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
twentynineLL = twentyeightLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
thirtyLL = twentynineLL[1] and low < low[1] and barstate.isconfirmed and samplePeriodFilter
var oneHHcounter = 0
var twoHHcounter = 0
var threeHHcounter = 0
var fourHHcounter = 0
var fiveHHcounter = 0
var sixHHcounter = 0
var sevenHHcounter = 0
var eightHHcounter = 0
var nineHHcounter = 0
var tenHHcounter = 0
var elevenHHcounter = 0
var twelveHHcounter = 0
var thirteenHHcounter = 0
var fourteenHHcounter = 0
var fifteenHHcounter = 0
var sixteenHHcounter = 0
var seventeenHHcounter = 0
var eighteenHHcounter = 0
var nineteenHHcounter = 0
var twentyHHcounter = 0
var twentyoneHHcounter = 0
var twentytwoHHcounter = 0
var twentythreeHHcounter = 0
var twentyfourHHcounter = 0
var twentyfiveHHcounter = 0
var twentysixHHcounter = 0
var twentysevenHHcounter = 0
var twentyeightHHcounter = 0
var twentynineHHcounter = 0
var thirtyHHcounter = 0
var oneHLcounter = 0
var twoHLcounter = 0
var threeHLcounter = 0
var fourHLcounter = 0
var fiveHLcounter = 0
var sixHLcounter = 0
var sevenHLcounter = 0
var eightHLcounter = 0
var nineHLcounter = 0
var tenHLcounter = 0
var elevenHLcounter = 0
var twelveHLcounter = 0
var thirteenHLcounter = 0
var fourteenHLcounter = 0
var fifteenHLcounter = 0
var sixteenHLcounter = 0
var seventeenHLcounter = 0
var eighteenHLcounter = 0
var nineteenHLcounter = 0
var twentyHLcounter = 0
var twentyoneHLcounter = 0
var twentytwoHLcounter = 0
var twentythreeHLcounter = 0
var twentyfourHLcounter = 0
var twentyfiveHLcounter = 0
var twentysixHLcounter = 0
var twentysevenHLcounter = 0
var twentyeightHLcounter = 0
var twentynineHLcounter = 0
var thirtyHLcounter = 0
var oneLHcounter = 0
var twoLHcounter = 0
var threeLHcounter = 0
var fourLHcounter = 0
var fiveLHcounter = 0
var sixLHcounter = 0
var sevenLHcounter = 0
var eightLHcounter = 0
var nineLHcounter = 0
var tenLHcounter = 0
var elevenLHcounter = 0
var twelveLHcounter = 0
var thirteenLHcounter = 0
var fourteenLHcounter = 0
var fifteenLHcounter = 0
var sixteenLHcounter = 0
var seventeenLHcounter = 0
var eighteenLHcounter = 0
var nineteenLHcounter = 0
var twentyLHcounter = 0
var twentyoneLHcounter = 0
var twentytwoLHcounter = 0
var twentythreeLHcounter = 0
var twentyfourLHcounter = 0
var twentyfiveLHcounter = 0
var twentysixLHcounter = 0
var twentysevenLHcounter = 0
var twentyeightLHcounter = 0
var twentynineLHcounter = 0
var thirtyLHcounter = 0
var oneLLcounter = 0
var twoLLcounter = 0
var threeLLcounter = 0
var fourLLcounter = 0
var fiveLLcounter = 0
var sixLLcounter = 0
var sevenLLcounter = 0
var eightLLcounter = 0
var nineLLcounter = 0
var tenLLcounter = 0
var elevenLLcounter = 0
var twelveLLcounter = 0
var thirteenLLcounter = 0
var fourteenLLcounter = 0
var fifteenLLcounter = 0
var sixteenLLcounter = 0
var seventeenLLcounter = 0
var eighteenLLcounter = 0
var nineteenLLcounter = 0
var twentyLLcounter = 0
var twentyoneLLcounter = 0
var twentytwoLLcounter = 0
var twentythreeLLcounter = 0
var twentyfourLLcounter = 0
var twentyfiveLLcounter = 0
var twentysixLLcounter = 0
var twentysevenLLcounter = 0
var twentyeightLLcounter = 0
var twentynineLLcounter = 0
var thirtyLLcounter = 0
if oneHH
oneHHcounter += 1
if twoHH
twoHHcounter += 1
if threeHH
threeHHcounter += 1
if fourHH
fourHHcounter += 1
if fiveHH
fiveHHcounter += 1
if sixHH
sixHHcounter += 1
if sevenHH
sevenHHcounter += 1
if eightHH
eightHHcounter += 1
if nineHH
nineHHcounter += 1
if tenHH
tenHHcounter += 1
if elevenHH
elevenHHcounter += 1
if twelveHH
twelveHHcounter += 1
if thirteenHH
thirteenHHcounter += 1
if fourteenHH
fourteenHHcounter += 1
if fifteenHH
fifteenHHcounter += 1
if sixteenHH
sixteenHHcounter += 1
if seventeenHH
seventeenHHcounter += 1
if eighteenHH
eighteenHHcounter += 1
if nineteenHH
nineteenHHcounter += 1
if twentyHH
twentyHHcounter += 1
if twentyoneHH
twentyoneHHcounter += 1
if twentytwoHH
twentytwoHHcounter += 1
if twentythreeHH
twentythreeHHcounter += 1
if twentyfourHH
twentyfourHHcounter += 1
if twentyfiveHH
twentyfiveHHcounter += 1
if twentysixHH
twentysixHHcounter += 1
if twentysevenHH
twentysevenHHcounter += 1
if twentyeightHH
twentyeightHHcounter += 1
if twentynineHH
twentynineHHcounter += 1
if thirtyHH
thirtyHHcounter += 1
if oneHL
oneHLcounter += 1
if twoHL
twoHLcounter += 1
if threeHL
threeHLcounter += 1
if fourHL
fourHLcounter += 1
if fiveHL
fiveHLcounter += 1
if sixHL
sixHLcounter += 1
if sevenHL
sevenHLcounter += 1
if eightHL
eightHLcounter += 1
if nineHL
nineHLcounter += 1
if tenHL
tenHLcounter += 1
if elevenHL
elevenHLcounter += 1
if twelveHL
twelveHLcounter += 1
if thirteenHL
thirteenHLcounter += 1
if fourteenHL
fourteenHLcounter += 1
if fifteenHL
fifteenHLcounter += 1
if sixteenHL
sixteenHLcounter += 1
if seventeenHL
seventeenHLcounter += 1
if eighteenHL
eighteenHLcounter += 1
if nineteenHL
nineteenHLcounter += 1
if twentyHL
twentyHLcounter += 1
if twentyoneHL
twentyoneHLcounter += 1
if twentytwoHL
twentytwoHLcounter += 1
if twentythreeHL
twentythreeHLcounter += 1
if twentyfourHL
twentyfourHLcounter += 1
if twentyfiveHL
twentyfiveHLcounter += 1
if twentysixHL
twentysixHLcounter += 1
if twentysevenHL
twentysevenHLcounter += 1
if twentyeightHL
twentyeightHLcounter += 1
if twentynineHL
twentynineHLcounter += 1
if thirtyHL
thirtyHLcounter += 1
if oneLH
oneLHcounter += 1
if twoLH
twoLHcounter += 1
if threeLH
threeLHcounter += 1
if fourLH
fourLHcounter += 1
if fiveLH
fiveLHcounter += 1
if sixLH
sixLHcounter += 1
if sevenLH
sevenLHcounter += 1
if eightLH
eightLHcounter += 1
if nineLH
nineLHcounter += 1
if tenLH
tenLHcounter += 1
if elevenLH
elevenLHcounter += 1
if twelveLH
twelveLHcounter += 1
if thirteenLH
thirteenLHcounter += 1
if fourteenLH
fourteenLHcounter += 1
if fifteenLH
fifteenLHcounter += 1
if sixteenLH
sixteenLHcounter += 1
if seventeenLH
seventeenLHcounter += 1
if eighteenLH
eighteenLHcounter += 1
if nineteenLH
nineteenLHcounter += 1
if twentyLH
twentyLHcounter += 1
if twentyoneLH
twentyoneLHcounter += 1
if twentytwoLH
twentytwoLHcounter += 1
if twentythreeLH
twentythreeLHcounter += 1
if twentyfourLH
twentyfourLHcounter += 1
if twentyfiveLH
twentyfiveLHcounter += 1
if twentysixLH
twentysixLHcounter += 1
if twentysevenLH
twentysevenLHcounter += 1
if twentyeightLH
twentyeightLHcounter += 1
if twentynineLH
twentynineLHcounter += 1
if thirtyLH
thirtyLHcounter += 1
if oneLL
oneLLcounter += 1
if twoLL
twoLLcounter += 1
if threeLL
threeLLcounter += 1
if fourLL
fourLLcounter += 1
if fiveLL
fiveLLcounter += 1
if sixLL
sixLLcounter += 1
if sevenLL
sevenLLcounter += 1
if eightLL
eightLLcounter += 1
if nineLL
nineLLcounter += 1
if tenLL
tenLLcounter += 1
if elevenLL
elevenLLcounter += 1
if twelveLL
twelveLLcounter += 1
if thirteenLL
thirteenLLcounter += 1
if fourteenLL
fourteenLLcounter += 1
if fifteenLL
fifteenLLcounter += 1
if sixteenLL
sixteenLLcounter += 1
if seventeenLL
seventeenLLcounter += 1
if eighteenLL
eighteenLLcounter += 1
if nineteenLL
nineteenLLcounter += 1
if twentyLL
twentyLLcounter += 1
if twentyoneLL
twentyoneLLcounter += 1
if twentytwoLL
twentytwoLLcounter += 1
if twentythreeLL
twentythreeLLcounter += 1
if twentyfourLL
twentyfourLLcounter += 1
if twentyfiveLL
twentyfiveLLcounter += 1
if twentysixLL
twentysixLLcounter += 1
if twentysevenLL
twentysevenLLcounter += 1
if twentyeightLL
twentyeightLLcounter += 1
if twentynineLL
twentynineLLcounter += 1
if thirtyLL
thirtyLLcounter += 1
//////////// table ////////////
upperLowerCandleTrendTablePositionInput = input.string(title = 'Position', defval = 'Top Right', options=['Top Right', 'Top Center'], group = 'Table Positioning')
upperLowerCandleTrendTablePosition = upperLowerCandleTrendTablePositionInput == 'Top Right' ? position.top_right : upperLowerCandleTrendTablePositionInput == 'Top Center' ? position.top_center :
upperLowerCandleTrendTablePositionInput == 'Top Left' ? position.top_left : upperLowerCandleTrendTablePositionInput == 'Bottom Right' ? position.bottom_right :
upperLowerCandleTrendTablePositionInput == 'Bottom Center' ? position.bottom_center : upperLowerCandleTrendTablePositionInput == 'Bottom Left' ? position.bottom_left :
upperLowerCandleTrendTablePositionInput == 'Middle Right' ? position.middle_right : upperLowerCandleTrendTablePositionInput == 'Middle Center' ? position.middle_center :
upperLowerCandleTrendTablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval = 'Tiny', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
var upperLowerCandleTrendTable = table.new(upperLowerCandleTrendTablePosition, 100, 100, border_width=1)
table.cell(upperLowerCandleTrendTable, 1, 0, text = 'Higher Highs', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 0, text = '% Total', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 0, text = '% Last', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 0, 1, text = '1-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 1, text = str.tostring(oneHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 0, text = 'Lower Highs', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 0, text = '% Total', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 0, text = '% Last', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 1, text = str.tostring(oneLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twoHHcounter >= 1 or twoLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 2, text = '2-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 2, text = str.tostring(twoHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 2, text = str.tostring(math.round(twoHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 2, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 2, text = str.tostring(twoLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 2, text = str.tostring(math.round(twoLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 2, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (threeHHcounter >= 1 or threeLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 3, text = '3-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 3, text = str.tostring(threeHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 3, text = str.tostring(math.round(threeHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 3, text = str.tostring(math.round(threeHHcounter / twoHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 3, text = str.tostring(threeLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 3, text = str.tostring(math.round(threeLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 3, text = str.tostring(math.round(threeLHcounter / twoLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourHHcounter >= 1 or fourLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 4, text = '4-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 4, text = str.tostring(fourHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 4, text = str.tostring(math.round(fourHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 4, text = str.tostring(math.round(fourHHcounter / threeHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 4, text = str.tostring(fourLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 4, text = str.tostring(math.round(fourLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 4, text = str.tostring(math.round(fourLHcounter / threeLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fiveHHcounter >= 1 or fiveLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 5, text = '5-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 5, text = str.tostring(fiveHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 5, text = str.tostring(math.round(fiveHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 5, text = str.tostring(math.round(fiveHHcounter / fourHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 5, text = str.tostring(fiveLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 5, text = str.tostring(math.round(fiveLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 5, text = str.tostring(math.round(fiveLHcounter / fourLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixHHcounter >= 1 or sixLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 6, text = '6-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 6, text = str.tostring(sixHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 6, text = str.tostring(math.round(sixHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 6, text = str.tostring(math.round(sixHHcounter / fiveHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 6, text = str.tostring(sixLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 6, text = str.tostring(math.round(sixLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 6, text = str.tostring(math.round(sixLHcounter / fiveLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sevenHHcounter >= 1 or sevenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 7, text = '7-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 7, text = str.tostring(sevenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 7, text = str.tostring(math.round(sevenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 7, text = str.tostring(math.round(sevenHHcounter / sixHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 7, text = str.tostring(sevenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 7, text = str.tostring(math.round(sevenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 7, text = str.tostring(math.round(sevenLHcounter / sixLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eightHHcounter >= 1 or eightLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 8, text = '8-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 8, text = str.tostring(eightHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 8, text = str.tostring(math.round(eightHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 8, text = str.tostring(math.round(eightHHcounter / sevenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 8, text = str.tostring(eightLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 8, text = str.tostring(math.round(eightLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 8, text = str.tostring(math.round(eightLHcounter / sevenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineHHcounter >= 1 or nineLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 9, text = '9-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 9, text = str.tostring(nineHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 9, text = str.tostring(math.round(nineHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 9, text = str.tostring(math.round(nineHHcounter / eightHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 9, text = str.tostring(nineLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 9, text = str.tostring(math.round(nineLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 9, text = str.tostring(math.round(nineLHcounter / eightLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (tenHHcounter >= 1 or tenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 10, text = '10-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 10, text = str.tostring(tenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 10, text = str.tostring(math.round(tenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 10, text = str.tostring(math.round(tenHHcounter / nineHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 10, text = str.tostring(tenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 10, text = str.tostring(math.round(tenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 10, text = str.tostring(math.round(tenLHcounter / nineLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (elevenHHcounter >= 1 or elevenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 11, text = '11-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 11, text = str.tostring(elevenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 11, text = str.tostring(math.round(elevenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 11, text = str.tostring(math.round(elevenHHcounter / tenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 11, text = str.tostring(elevenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 11, text = str.tostring(math.round(elevenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 11, text = str.tostring(math.round(elevenLHcounter / tenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twelveHHcounter >= 1 or twelveLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 12, text = '12-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 12, text = str.tostring(twelveHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 12, text = str.tostring(math.round(twelveHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 12, text = str.tostring(math.round(twelveHHcounter / elevenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 12, text = str.tostring(twelveLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 12, text = str.tostring(math.round(twelveLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 12, text = str.tostring(math.round(twelveLHcounter / elevenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirteenHHcounter >= 1 or thirteenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 13, text = '13-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 13, text = str.tostring(thirteenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 13, text = str.tostring(math.round(thirteenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 13, text = str.tostring(math.round(thirteenHHcounter / twelveHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 13, text = str.tostring(thirteenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 13, text = str.tostring(math.round(thirteenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 13, text = str.tostring(math.round(thirteenLHcounter / twelveLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourteenHHcounter >= 1 or fourteenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 14, text = '14-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 14, text = str.tostring(fourteenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 14, text = str.tostring(math.round(fourteenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 14, text = str.tostring(math.round(fourteenHHcounter / thirteenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 14, text = str.tostring(fourteenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 14, text = str.tostring(math.round(fourteenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 14, text = str.tostring(math.round(fourteenLHcounter / thirteenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fifteenHHcounter >= 1 or fifteenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 15, text = '15-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 15, text = str.tostring(fifteenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 15, text = str.tostring(math.round(fifteenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 15, text = str.tostring(math.round(fifteenHHcounter / fourteenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 15, text = str.tostring(fifteenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 15, text = str.tostring(math.round(fifteenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 15, text = str.tostring(math.round(fifteenLHcounter / fourteenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixteenHHcounter >= 1 or sixteenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 16, text = '16-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 16, text = str.tostring(sixteenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 16, text = str.tostring(math.round(sixteenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 16, text = str.tostring(math.round(sixteenHHcounter / fifteenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 16, text = str.tostring(sixteenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 16, text = str.tostring(math.round(sixteenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 16, text = str.tostring(math.round(sixteenLHcounter / fifteenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (seventeenHHcounter >= 1 or seventeenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 17, text = '17-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 17, text = str.tostring(seventeenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 17, text = str.tostring(math.round(seventeenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 17, text = str.tostring(math.round(seventeenHHcounter / sixteenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 17, text = str.tostring(seventeenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 17, text = str.tostring(math.round(seventeenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 17, text = str.tostring(math.round(seventeenLHcounter / sixteenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eighteenHHcounter >= 1 or eighteenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 18, text = '18-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 18, text = str.tostring(eighteenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 18, text = str.tostring(math.round(eighteenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 18, text = str.tostring(math.round(eighteenHHcounter / seventeenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 18, text = str.tostring(eighteenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 18, text = str.tostring(math.round(eighteenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 18, text = str.tostring(math.round(eighteenLHcounter / seventeenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineteenHHcounter >= 1 or nineteenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 19, text = '19-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 19, text = str.tostring(nineteenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 19, text = str.tostring(math.round(nineteenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 19, text = str.tostring(math.round(nineteenHHcounter / eighteenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 19, text = str.tostring(nineteenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 19, text = str.tostring(math.round(nineteenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 19, text = str.tostring(math.round(nineteenLHcounter / eighteenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyHHcounter >= 1 or twentyLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 20, text = '20-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 20, text = str.tostring(twentyHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 20, text = str.tostring(math.round(twentyHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 20, text = str.tostring(math.round(twentyHHcounter / nineteenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 20, text = str.tostring(twentyLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 20, text = str.tostring(math.round(twentyLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 20, text = str.tostring(math.round(twentyLHcounter / nineteenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyoneHHcounter >= 1 or twentyoneLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 21, text = '21-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 21, text = str.tostring(twentyoneHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 21, text = str.tostring(math.round(twentyoneHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 21, text = str.tostring(math.round(twentyoneHHcounter / twentyHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 21, text = str.tostring(twentyoneLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 21, text = str.tostring(math.round(twentyoneLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 21, text = str.tostring(math.round(twentyoneLHcounter / twentyLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentytwoHHcounter >= 1 or twentytwoLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 22, text = '22-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 22, text = str.tostring(twentytwoHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 22, text = str.tostring(math.round(twentytwoHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 22, text = str.tostring(math.round(twentytwoHHcounter / twentyoneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 22, text = str.tostring(twentytwoLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 22, text = str.tostring(math.round(twentytwoLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 22, text = str.tostring(math.round(twentytwoLHcounter / twentyoneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentythreeHHcounter >= 1 or twentythreeLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 23, text = '23-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 23, text = str.tostring(twentythreeHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 23, text = str.tostring(math.round(twentythreeHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 23, text = str.tostring(math.round(twentythreeHHcounter / twentytwoHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 23, text = str.tostring(twentythreeLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 23, text = str.tostring(math.round(twentythreeLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 23, text = str.tostring(math.round(twentythreeLHcounter / twentytwoLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfourHHcounter >= 1 or twentyfourLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 24, text = '24-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 24, text = str.tostring(twentyfourHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 24, text = str.tostring(math.round(twentyfourHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 24, text = str.tostring(math.round(twentyfourHHcounter / twentythreeHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 24, text = str.tostring(twentyfourLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 24, text = str.tostring(math.round(twentyfourLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 24, text = str.tostring(math.round(twentyfourLHcounter / twentythreeLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfiveHHcounter >= 1 or twentyfiveLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 25, text = '25-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 25, text = str.tostring(twentyfiveHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 25, text = str.tostring(math.round(twentyfiveHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 25, text = str.tostring(math.round(twentyfiveHHcounter / twentyfourHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 25, text = str.tostring(twentyfiveLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 25, text = str.tostring(math.round(twentyfiveLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 25, text = str.tostring(math.round(twentyfiveLHcounter / twentyfourLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysixHHcounter >= 1 or twentysixLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 26, text = '26-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 26, text = str.tostring(twentysixHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 26, text = str.tostring(math.round(twentysixHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 26, text = str.tostring(math.round(twentysixHHcounter / twentyfiveHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 26, text = str.tostring(twentysixLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 26, text = str.tostring(math.round(twentysixLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 26, text = str.tostring(math.round(twentysixLHcounter / twentyfiveLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysevenHHcounter >= 1 or twentysevenLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 27, text = '27-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 27, text = str.tostring(twentysevenHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 27, text = str.tostring(math.round(twentysevenHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 27, text = str.tostring(math.round(twentysevenHHcounter / twentysixHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 27, text = str.tostring(twentysevenLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 27, text = str.tostring(math.round(twentysevenLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 27, text = str.tostring(math.round(twentysevenLHcounter / twentysixLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyeightHHcounter >= 1 or twentyeightLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 28, text = '28-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 28, text = str.tostring(twentyeightHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 28, text = str.tostring(math.round(twentyeightHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 28, text = str.tostring(math.round(twentyeightHHcounter / twentysevenHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 28, text = str.tostring(twentyeightLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 28, text = str.tostring(math.round(twentyeightLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 28, text = str.tostring(math.round(twentyeightLHcounter / twentysevenLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentynineHHcounter >= 1 or twentynineLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 29, text = '29-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 29, text = str.tostring(twentynineHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 29, text = str.tostring(math.round(twentynineHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 29, text = str.tostring(math.round(twentynineHHcounter / twentyeightHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 29, text = str.tostring(twentynineLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 29, text = str.tostring(math.round(twentynineLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 29, text = str.tostring(math.round(twentynineLHcounter / twentyeightLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirtyHHcounter >= 1 or thirtyLHcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 30, text = '30-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 30, text = str.tostring(thirtyHHcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 30, text = str.tostring(math.round(thirtyHHcounter / oneHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 30, text = str.tostring(math.round(thirtyHHcounter / twentynineHHcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 30, text = str.tostring(thirtyLHcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 30, text = str.tostring(math.round(thirtyLHcounter / oneLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 30, text = str.tostring(math.round(thirtyLHcounter / twentynineLHcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 31, text = 'Higher Lows', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 31, text = '% Total', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 31, text = '% Last', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 0, 32, text = '1-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 32, text = str.tostring(oneHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 32, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 32, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 31, text = 'Lower Lows', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 31, text = '% Total', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 31, text = '% Last', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 32, text = str.tostring(oneLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 32, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 32, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twoHLcounter >= 1 or twoLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 33, text = '2-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 33, text = str.tostring(twoHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 33, text = str.tostring(math.round(twoHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 33, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 33, text = str.tostring(twoLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 33, text = str.tostring(math.round(twoLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 33, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (threeHLcounter >= 1 or threeLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 34, text = '3-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 34, text = str.tostring(threeHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 34, text = str.tostring(math.round(threeHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 34, text = str.tostring(math.round(threeHLcounter / twoHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 34, text = str.tostring(threeLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 34, text = str.tostring(math.round(threeLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 34, text = str.tostring(math.round(threeLLcounter / twoLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourHLcounter >= 1 or fourLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 35, text = '4-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 35, text = str.tostring(fourHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 35, text = str.tostring(math.round(fourHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 35, text = str.tostring(math.round(fourHLcounter / threeHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 35, text = str.tostring(fourLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 35, text = str.tostring(math.round(fourLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 35, text = str.tostring(math.round(fourLLcounter / threeLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fiveHLcounter >= 1 or fiveLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 36, text = '5-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 36, text = str.tostring(fiveHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 36, text = str.tostring(math.round(fiveHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 36, text = str.tostring(math.round(fiveHLcounter / fourHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 36, text = str.tostring(fiveLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 36, text = str.tostring(math.round(fiveLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 36, text = str.tostring(math.round(fiveLLcounter / fourLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixHLcounter >= 1 or sixLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 37, text = '6-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 37, text = str.tostring(sixHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 37, text = str.tostring(math.round(sixHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 37, text = str.tostring(math.round(sixHLcounter / fiveHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 37, text = str.tostring(sixLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 37, text = str.tostring(math.round(sixLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 37, text = str.tostring(math.round(sixLLcounter / fiveLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sevenHLcounter >= 1 or sevenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 38, text = '7-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 38, text = str.tostring(sevenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 38, text = str.tostring(math.round(sevenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 38, text = str.tostring(math.round(sevenHLcounter / sixHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 38, text = str.tostring(sevenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 38, text = str.tostring(math.round(sevenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 38, text = str.tostring(math.round(sevenLLcounter / sixLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eightHLcounter >= 1 or eightLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 39, text = '8-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 39, text = str.tostring(eightHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 39, text = str.tostring(math.round(eightHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 39, text = str.tostring(math.round(eightHLcounter / sevenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 39, text = str.tostring(eightLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 39, text = str.tostring(math.round(eightLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 39, text = str.tostring(math.round(eightLLcounter / sevenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineHLcounter >= 1 or nineLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 40, text = '9-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 40, text = str.tostring(nineHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 40, text = str.tostring(math.round(nineHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 40, text = str.tostring(math.round(nineHLcounter / eightHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 40, text = str.tostring(nineLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 40, text = str.tostring(math.round(nineLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 40, text = str.tostring(math.round(nineLLcounter / eightLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (tenHLcounter >= 1 or tenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 41, text = '10-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 41, text = str.tostring(tenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 41, text = str.tostring(math.round(tenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 41, text = str.tostring(math.round(tenHLcounter / nineHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 41, text = str.tostring(tenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 41, text = str.tostring(math.round(tenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 41, text = str.tostring(math.round(tenLLcounter / nineLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (elevenHLcounter >= 1 or elevenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 42, text = '11-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 42, text = str.tostring(elevenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 42, text = str.tostring(math.round(elevenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 42, text = str.tostring(math.round(elevenHLcounter / tenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 42, text = str.tostring(elevenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 42, text = str.tostring(math.round(elevenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 42, text = str.tostring(math.round(elevenLLcounter / tenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twelveHLcounter >= 1 or twelveLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 43, text = '12-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 43, text = str.tostring(twelveHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 43, text = str.tostring(math.round(twelveHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 43, text = str.tostring(math.round(twelveHLcounter / elevenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 43, text = str.tostring(twelveLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 43, text = str.tostring(math.round(twelveLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 43, text = str.tostring(math.round(twelveLLcounter / elevenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirteenHLcounter >= 1 or thirteenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 44, text = '13-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 44, text = str.tostring(thirteenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 44, text = str.tostring(math.round(thirteenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 44, text = str.tostring(math.round(thirteenHLcounter / twelveHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 44, text = str.tostring(thirteenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 44, text = str.tostring(math.round(thirteenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 44, text = str.tostring(math.round(thirteenLLcounter / twelveLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourteenHLcounter >= 1 or fourteenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 45, text = '14-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 45, text = str.tostring(fourteenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 45, text = str.tostring(math.round(fourteenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 45, text = str.tostring(math.round(fourteenHLcounter / thirteenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 45, text = str.tostring(fourteenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 45, text = str.tostring(math.round(fourteenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 45, text = str.tostring(math.round(fourteenLLcounter / thirteenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fifteenHLcounter >= 1 or fifteenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 46, text = '15-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 46, text = str.tostring(fifteenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 46, text = str.tostring(math.round(fifteenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 46, text = str.tostring(math.round(fifteenHLcounter / fourteenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 46, text = str.tostring(fifteenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 46, text = str.tostring(math.round(fifteenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 46, text = str.tostring(math.round(fifteenLLcounter / fourteenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixteenHLcounter >= 1 or sixteenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 47, text = '16-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 47, text = str.tostring(sixteenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 47, text = str.tostring(math.round(sixteenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 47, text = str.tostring(math.round(sixteenHLcounter / fifteenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 47, text = str.tostring(sixteenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 47, text = str.tostring(math.round(sixteenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 47, text = str.tostring(math.round(sixteenLLcounter / fifteenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (seventeenHLcounter >= 1 or seventeenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 48, text = '17-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 48, text = str.tostring(seventeenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 48, text = str.tostring(math.round(seventeenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 48, text = str.tostring(math.round(seventeenHLcounter / sixteenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 48, text = str.tostring(seventeenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 48, text = str.tostring(math.round(seventeenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 48, text = str.tostring(math.round(seventeenLLcounter / sixteenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eighteenHLcounter >= 1 or eighteenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 49, text = '18-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 49, text = str.tostring(eighteenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 49, text = str.tostring(math.round(eighteenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 49, text = str.tostring(math.round(eighteenHLcounter / seventeenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 49, text = str.tostring(eighteenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 49, text = str.tostring(math.round(eighteenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 49, text = str.tostring(math.round(eighteenLLcounter / seventeenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineteenHLcounter >= 1 or nineteenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 50, text = '19-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 50, text = str.tostring(nineteenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 50, text = str.tostring(math.round(nineteenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 50, text = str.tostring(math.round(nineteenHLcounter / eighteenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 50, text = str.tostring(nineteenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 50, text = str.tostring(math.round(nineteenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 50, text = str.tostring(math.round(nineteenLLcounter / eighteenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyHLcounter >= 1 or twentyLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 51, text = '20-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 51, text = str.tostring(twentyHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 51, text = str.tostring(math.round(twentyHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 51, text = str.tostring(math.round(twentyHLcounter / nineteenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 51, text = str.tostring(twentyLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 51, text = str.tostring(math.round(twentyLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 51, text = str.tostring(math.round(twentyLLcounter / nineteenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyoneHLcounter >= 1 or twentyoneLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 52, text = '21-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 52, text = str.tostring(twentyoneHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 52, text = str.tostring(math.round(twentyoneHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 52, text = str.tostring(math.round(twentyoneHLcounter / twentyHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 52, text = str.tostring(twentyoneLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 52, text = str.tostring(math.round(twentyoneLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 52, text = str.tostring(math.round(twentyoneLLcounter / twentyLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentytwoHLcounter >= 1 or twentytwoLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 53, text = '22-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 53, text = str.tostring(twentytwoHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 53, text = str.tostring(math.round(twentytwoHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 53, text = str.tostring(math.round(twentytwoHLcounter / twentyoneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 53, text = str.tostring(twentytwoLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 53, text = str.tostring(math.round(twentytwoLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 53, text = str.tostring(math.round(twentytwoLLcounter / twentyoneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentythreeHLcounter >= 1 or twentythreeLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 54, text = '23-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 54, text = str.tostring(twentythreeHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 54, text = str.tostring(math.round(twentythreeHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 54, text = str.tostring(math.round(twentythreeHLcounter / twentytwoHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 54, text = str.tostring(twentythreeLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 54, text = str.tostring(math.round(twentythreeLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 54, text = str.tostring(math.round(twentythreeLLcounter / twentytwoLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfourHLcounter >= 1 or twentyfourLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 55, text = '24-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 55, text = str.tostring(twentyfourHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 55, text = str.tostring(math.round(twentyfourHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 55, text = str.tostring(math.round(twentyfourHLcounter / twentythreeHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 55, text = str.tostring(twentyfourLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 55, text = str.tostring(math.round(twentyfourLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 55, text = str.tostring(math.round(twentyfourLLcounter / twentythreeLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfiveHLcounter >= 1 or twentyfiveLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 56, text = '25-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 56, text = str.tostring(twentyfiveHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 56, text = str.tostring(math.round(twentyfiveHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 56, text = str.tostring(math.round(twentyfiveHLcounter / twentyfourHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 56, text = str.tostring(twentyfiveLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 56, text = str.tostring(math.round(twentyfiveLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 56, text = str.tostring(math.round(twentyfiveLLcounter / twentyfourLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysixHLcounter >= 1 or twentysixLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 57, text = '26-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 57, text = str.tostring(twentysixHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 57, text = str.tostring(math.round(twentysixHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 57, text = str.tostring(math.round(twentysixHLcounter / twentyfiveHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 57, text = str.tostring(twentysixLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 57, text = str.tostring(math.round(twentysixLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 57, text = str.tostring(math.round(twentysixLLcounter / twentyfiveLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysevenHLcounter >= 1 or twentysevenLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 58, text = '27-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 58, text = str.tostring(twentysevenHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 58, text = str.tostring(math.round(twentysevenHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 58, text = str.tostring(math.round(twentysevenHLcounter / twentysixHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 58, text = str.tostring(twentysevenLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 58, text = str.tostring(math.round(twentysevenLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 58, text = str.tostring(math.round(twentysevenLLcounter / twentysixLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyeightHLcounter >= 1 or twentyeightLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 59, text = '28-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 59, text = str.tostring(twentyeightHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 59, text = str.tostring(math.round(twentyeightHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 59, text = str.tostring(math.round(twentyeightHLcounter / twentysevenHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 59, text = str.tostring(twentyeightLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 59, text = str.tostring(math.round(twentyeightLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 59, text = str.tostring(math.round(twentyeightLLcounter / twentysevenLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentynineHLcounter >= 1 or twentynineLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 60, text = '29-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 60, text = str.tostring(twentynineHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 60, text = str.tostring(math.round(twentynineHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 60, text = str.tostring(math.round(twentynineHLcounter / twentyeightHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 60, text = str.tostring(twentynineLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 60, text = str.tostring(math.round(twentynineLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 60, text = str.tostring(math.round(twentynineLLcounter / twentyeightLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirtyHLcounter >= 1 or thirtyLLcounter >= 1)
table.cell(upperLowerCandleTrendTable, 0, 60, text = '30-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 1, 60, text = str.tostring(thirtyHLcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 2, 60, text = str.tostring(math.round(thirtyHLcounter / oneHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 3, 60, text = str.tostring(math.round(thirtyHLcounter / twentynineHLcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 4, 60, text = str.tostring(thirtyLLcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 5, 60, text = str.tostring(math.round(thirtyLLcounter / oneLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(upperLowerCandleTrendTable, 6, 60, text = str.tostring(math.round(thirtyLLcounter / twentynineLLcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(upperLowerCandleTrendTable, 0, 61, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
|
Know Sure Thing + Ribbon | https://www.tradingview.com/script/5hod89KV-Know-Sure-Thing-Ribbon/ | akikostas | https://www.tradingview.com/u/akikostas/ | 72 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© akikostas
//@version=5
indicator(title="Know Sure Thing [Log] + Ribbon", shorttitle="KST-L + Ribbon", format=format.price, precision=4, timeframe="", timeframe_gaps=true)
roclen1 = input.int(10, minval=1, title = "ROC Length #1", group = "KST Settings")
roclen2 = input.int(15, minval=1, title = "ROC Length #2", group = "KST Settings")
roclen3 = input.int(20, minval=1, title = "ROC Length #3", group = "KST Settings")
roclen4 = input.int(30, minval=1, title = "ROC Length #4", group = "KST Settings")
smalen1 = input.int(10, minval=1, title = "SMA Length #1", group = "KST Settings")
smalen2 = input.int(10, minval=1, title = "SMA Length #2", group = "KST Settings")
smalen3 = input.int(10, minval=1, title = "SMA Length #3", group = "KST Settings")
smalen4 = input.int(15, minval=1, title = "SMA Length #4", group = "KST Settings")
siglen = input.int(9, minval=1, title = "Signal Line Length", group = "KST Settings")
source = input(close, title = "Source", group = "KST Settings")
exotic = input.bool(false, title = "Exotic Calculations", group = "KST Settings")
length1 = input.int(9, title="EMA-1 period", minval=1, group = "Ribbon Settings")
length2 = input.int(18, title="EMA-2 period", minval=1, group = "Ribbon Settings")
length3 = input.int(27, title="EMA-3 period", minval=1, group = "Ribbon Settings")
length4 = input.int(36, title="EMA-4 period", minval=1, group = "Ribbon Settings")
length5 = input.int(45, title="EMA-5 period", minval=1, group = "Ribbon Settings")
length6 = input.int(54, title="EMA-6 period", minval=1, group = "Ribbon Settings")
length7 = input.int(63, title="EMA-7 period", minval=1, group = "Ribbon Settings")
length8 = input.int(72, title="EMA-8 period", minval=1, group = "Ribbon Settings")
logarithmic(src)=> math.sign(src) * math.log(math.abs(src) + 1)
price = source
roc(p, l)=> 100 * (p - p[l]) / p[l]
rocl(p, l)=> 100 * (logarithmic(p) - logarithmic(p[l]))
smaroc(roclen, smalen) => ta.sma(roc(price, roclen), smalen)
smarocl(roclen, smalen) => ta.sma(rocl(price, roclen), smalen)
kst = smaroc(roclen1, smalen1) + 2 * smaroc(roclen2, smalen2) + 3 * smaroc(roclen3, smalen3) + 4 * smaroc(roclen4, smalen4)
if (exotic)
kst := smarocl(roclen1, smalen1) + 2 * smarocl(roclen2, smalen2) + 3 * smarocl(roclen3, smalen3) + 4 * smarocl(roclen4, smalen4)
sig = ta.sma(kst, siglen)
hline(0, title="Zero", color = #787B86DE, display = display.none)
plot(ta.ema(kst, length8), title="EMA-8", color=#aa270740, linewidth=2)
plot(ta.ema(kst, length7), title="EMA-7", color=#f5515140, linewidth=2)
plot(ta.ema(kst, length6), title="EMA-6", color=#f57d5140, linewidth=2)
plot(ta.ema(kst, length5), title="EMA-5", color=#f56d5840, linewidth=2)
plot(ta.ema(kst, length4), title="EMA-4", color=#f57b4e40, linewidth=2)
plot(ta.ema(kst, length3), title="EMA-3", color=#f5b05640, linewidth=2)
plot(ta.ema(kst, length2), title="EMA-2", color=#f5b77140, linewidth=2)
plot(ta.ema(kst, length1), title="EMA-1", color=#f5eb5d40, linewidth=2)
plot(sig, color=#f44336DE, title="Signal", linewidth = 3, display = display.none)
plot(kst, color=#5b9cf6DE, title="KST", linewidth = 3) |
Smart Money Concepts Probability (Expo) | https://www.tradingview.com/script/mBINsJlf-Smart-Money-Concepts-Probability-Expo/ | Zeiierman | https://www.tradingview.com/u/Zeiierman/ | 5,285 | study | 5 | CC-BY-NC-SA-4.0 | // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// Β© Zeiierman
//@version=5
indicator("Smart Money Concepts Probability (Expo)",overlay=true,max_bars_back=5000,max_labels_count=500,max_lines_count=500)
// ~~ Tooltips {
string t1 = "Set the pivot period"
string t2 = "Set the response period. A low value returns a short-term structure and a high value returns a long-term structure. If you disable this option the pivot length above will be used."
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Inputs {
prd = input.int(20,minval=1,title="Structure Period",tooltip=t1)
s1 = input.bool(true,title="Structure Responseββ", inline="resp")
resp = input.int(7,minval=1,title="",inline="resp",tooltip=t2)
bull = input.bool(true,"Bullish Structureβββββ",inline="Bullish"), bull2 = input.color(color.rgb(8, 236, 126),"",inline="Bullish"), bull3 = input.color(color.rgb(8, 236, 126),"",inline="Bullish")
bear = input.bool(true,"Bearish Structureββββ",inline="Bearish"), bear2 = input.color(color.rgb(255, 34, 34),"",inline="Bearish"), bear3 = input.color(color.rgb(255, 34, 34),"",inline="Bearish")
showPD = input.bool(true,"Premium & Discount",inline="pd"), prem = input.color(color.new(color.rgb(255, 34, 34),80),"",inline="pd"), disc = input.color(color.new(color.rgb(8, 236, 126),80),"",inline="pd")
hlloc = input.string("Right","", options=["Left","Right"],inline="pd")
var bool [] alert_bool = array.from(
input.bool(true,title="Ticker ID",group="Any alert() function call"),
input.bool(true,title="Timeframe",group="Any alert() function call"),
input.bool(true,title="Probability Percentage",group="Any alert() function call"))
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Variables {
b = bar_index
var Up = float(na)
var Dn = float(na)
var iUp = int(na)
var iDn = int(na)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Matrix & Array {
var vals = matrix.new<float>(9,4,0.0)
var string [] txt = array.new<string>(2,"")
var tbl = matrix.new<table>(1,1,table.new(position.top_right,2,3,
frame_color =color.new(color.gray,50),frame_width=3,
border_color =chart.bg_color,border_width=-2))
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Functions {
//Labels
CreateLabel(x,y,txt,col,z)=>
label.new(x,y,txt,textcolor=col,style=z?label.style_label_down:label.style_label_up,color=color(na))
//Lines
CreateLine(x1,x2,y,col)=>
line.new(x1,x2,b,y,color=col)
//Current
Current(v)=>
str = ""
val1 = float(na)
val2 = float(na)
if v>=0
if v==1
str := "SMS: "
val1 := matrix.get(vals,0,1)
val2 := matrix.get(vals,0,3)
else if v==2
str := "BMS: "
val1 := matrix.get(vals,1,1)
val2 := matrix.get(vals,1,3)
else if v>2
str := "BMS: "
val1 := matrix.get(vals,2,1)
val2 := matrix.get(vals,2,3)
else if v<=0
if v==-1
str := "SMS: "
val1 := matrix.get(vals,3,1)
val2 := matrix.get(vals,3,3)
else if v==-2
str := "BMS: "
val1 := matrix.get(vals,4,1)
val2 := matrix.get(vals,4,3)
else if v<-2
str := "BMS: "
val1 := matrix.get(vals,5,1)
val2 := matrix.get(vals,5,3)
[str,val1,val2]
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Pivots {
Up := math.max(Up[1],high)
Dn := math.min(Dn[1],low)
pvtHi = ta.pivothigh(high,prd,prd)
pvtLo = ta.pivotlow(low,prd,prd)
if pvtHi
Up := pvtHi
if pvtLo
Dn := pvtLo
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Structure {
var pos = 0
if Up>Up[1]
iUp := b
centerBull = math.round(math.avg(iUp[1],b))
if pos<=0
if bull
CreateLabel(centerBull,Up[1],"CHoCH",bull3,true)
CreateLine(iUp[1],Up[1],Up[1],bull2)
pos := 1
matrix.set(vals,6,0,matrix.get(vals,6,0)+1)
else if pos==1 and Up>Up[1] and Up[1]==Up[s1?resp:prd]
if bull
CreateLabel(centerBull,Up[1],"SMS",bull3,true)
CreateLine(iUp[1],Up[1],Up[1],bull2)
pos := 2
matrix.set(vals,6,1,matrix.get(vals,6,1)+1)
else if pos>1 and Up>Up[1] and Up[1]==Up[s1?resp:prd]
if bull
CreateLabel(centerBull,Up[1],"BMS",bull3,true)
CreateLine(iUp[1],Up[1],Up[1],bull2)
pos := pos + 1
matrix.set(vals,6,2,matrix.get(vals,6,2)+1)
else if Up<Up[1]
iUp := b-prd
if Dn<Dn[1]
iDn := b
centerBear = math.round(math.avg(iDn[1],b))
if pos>=0
if bear
CreateLabel(centerBear,Dn[1],"CHoCH",bear3,false)
CreateLine(iDn[1],Dn[1],Dn[1],bear2)
pos := -1
matrix.set(vals,7,0,matrix.get(vals,7,0)+1)
else if pos==-1 and Dn<Dn[1] and Dn[1]==Dn[s1?resp:prd]
if bear
CreateLabel(centerBear,Dn[1],"SMS",bear3,false)
CreateLine(iDn[1],Dn[1],Dn[1],bear2)
pos := -2
matrix.set(vals,7,1,matrix.get(vals,7,1)+1)
else if pos<-1 and Dn<Dn[1] and Dn[1]==Dn[s1?resp:prd]
if bear
CreateLabel(centerBear,Dn[1],"BMS",bear3,false)
CreateLine(iDn[1],Dn[1],Dn[1],bear2)
pos := pos - 1
matrix.set(vals,7,2,matrix.get(vals,7,2)+1)
else if Dn>Dn[1]
iDn := b-prd
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Probability Calculation {
if ta.change(pos)
//Results
if pos>0 and pos[1]>0 or pos<0 and pos[1]<0
if matrix.get(vals,8,0)<matrix.get(vals,8,1)
matrix.set(vals,8,2,matrix.get(vals,8,2)+1)
else
matrix.set(vals,8,3,matrix.get(vals,8,3)+1)
else
if matrix.get(vals,8,0)>matrix.get(vals,8,1)
matrix.set(vals,8,2,matrix.get(vals,8,2)+1)
else
matrix.set(vals,8,3,matrix.get(vals,8,3)+1)
//Score Calulation
//Variables
buC0 = matrix.get(vals,0,0)
buC1 = matrix.get(vals,0,2)
buS0 = matrix.get(vals,1,0)
buS1 = matrix.get(vals,1,2)
buB0 = matrix.get(vals,2,0)
buB1 = matrix.get(vals,2,2)
beC0 = matrix.get(vals,3,0)
beC1 = matrix.get(vals,3,2)
beS0 = matrix.get(vals,4,0)
beS1 = matrix.get(vals,4,2)
beB0 = matrix.get(vals,5,0)
beB1 = matrix.get(vals,5,2)
tbuC = matrix.get(vals,6,0)
tbuS = matrix.get(vals,6,1)
tbuB = matrix.get(vals,6,2)
tbeC = matrix.get(vals,7,0)
tbeS = matrix.get(vals,7,1)
tbeB = matrix.get(vals,7,2)
//Bull
if (pos[1]==1 or pos[1]==0) and pos<0
matrix.set(vals,0,0,buC0+1)
matrix.set(vals,0,1,math.round(((buC0+1)/tbuC)*100,2))
if (pos[1]==1 or pos[1]==0) and pos==2
matrix.set(vals,0,2,buC1+1)
matrix.set(vals,0,3,math.round(((buC1+1)/tbuC)*100,2))
if pos[1]==2 and pos<0
matrix.set(vals,1,0,buS0+1)
matrix.set(vals,1,1,math.round(((buS0+1)/tbuS)*100,2))
if pos[1]==2 and pos>2
matrix.set(vals,1,2,buS1+1)
matrix.set(vals,1,3,math.round(((buS1+1)/tbuS)*100,2))
if pos[1]>2 and pos<0
matrix.set(vals,2,0,buB0+1)
matrix.set(vals,2,1,math.round(((buB0+1)/tbuB)*100,2))
if pos[1]>2 and pos>pos[1]
matrix.set(vals,2,2,buB1+1)
matrix.set(vals,2,3,math.round(((buB1+1)/tbuB)*100,2))
//Bear
if (pos[1]==-1 or pos[1]==0) and pos>0
matrix.set(vals,3,0,beC0+1)
matrix.set(vals,3,1,math.round(((beC0+1)/tbeC)*100,2))
if (pos[1]==-1 or pos[1]==0) and pos==-2
matrix.set(vals,3,2,beC1+1)
matrix.set(vals,3,3,math.round(((beC1+1)/tbeC)*100,2))
if pos[1]==-2 and pos>0
matrix.set(vals,4,0,beS0+1)
matrix.set(vals,4,1,math.round(((beS0+1)/tbeS)*100,2))
if pos[1]==-2 and pos<-2
matrix.set(vals,4,2,beS1+1)
matrix.set(vals,4,3,math.round(((beS1+1)/tbeS)*100,2))
if pos[1]<-2 and pos>0
matrix.set(vals,5,0,beB0+1)
matrix.set(vals,5,1,math.round(((beB0+1)/tbeB)*100,2))
if pos[1]<-2 and pos<pos[1]
matrix.set(vals,5,2,beB1+1)
matrix.set(vals,5,3,math.round(((beB1+1)/tbeB)*100,2))
[str,val1,val2] = Current(pos)
array.set(txt,0,"CHoCH: "+str.tostring(val1,format.percent))
array.set(txt,1,str+str.tostring(val2,format.percent))
matrix.set(vals,8,0,val1)
matrix.set(vals,8,1,val2)
//Alerts
if array.includes(alert_bool,true)
st1 = syminfo.ticker
st2 = timeframe.period
st3 = str.tostring(array.join(txt,'\n'))
string [] str_vals = array.from(st1,st2,st3)
output = array.new_string()
for x=0 to array.size(alert_bool)-1
if array.get(alert_bool,x)
array.push(output,array.get(str_vals,x))
alert(array.join(output,'\n'),alert.freq_once_per_bar_close)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Premium & Discount {
var hi = line.new(na,na,na,na,color=bear2)
var lo = line.new(na,na,na,na,color=bull2)
var fill = linefill.new(hi,lo,na)
var premium = box.new(na,na,na,na,na,bgcolor=prem)
var discount = box.new(na,na,na,na,na,bgcolor=disc)
var mid = box.new(na,na,na,na,na,bgcolor=color.new(color.gray,80))
PremiumTop = Up-(Up-Dn)*.1
PremiumBot = Up-(Up-Dn)*.25
DiscountTop = Dn+(Up-Dn)*.25
DiscountBot = Dn+(Up-Dn)*.1
MidTop = Up-(Up-Dn)*.45
MidBot = Dn+(Up-Dn)*.45
if barstate.islast and showPD
loc = hlloc=="Left"?math.min(iUp,iDn):math.max(iUp,iDn)
//High & Low
line.set_xy1(hi,loc,Up)
line.set_xy2(hi,b,Up)
line.set_xy1(lo,loc,Dn)
line.set_xy2(lo,b,Dn)
linefill.set_color(fill,color.new(color.gray,90))
//Premium & Mid & Discount
box.set_lefttop(premium,loc,PremiumTop)
box.set_rightbottom(premium,b,PremiumBot)
box.set_lefttop(discount,loc,DiscountTop)
box.set_rightbottom(discount,b,DiscountBot)
box.set_lefttop(mid,loc,MidTop)
box.set_rightbottom(mid,b,MidBot)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Probability {
var prob1 = label.new(na,na,na,color=color(na),textcolor=chart.fg_color,style=label.style_label_left)
var prob2 = label.new(na,na,na,color=color(na),textcolor=chart.fg_color,style=label.style_label_left)
if barstate.islast
str1 = pos<0?array.get(txt,0):array.get(txt,1)
str2 = pos>0?array.get(txt,0):array.get(txt,1)
label.set_xy(prob1,b,Up)
label.set_text(prob1,str1)
label.set_xy(prob2,b,Dn)
label.set_text(prob2,str2)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Table {
if barstate.islast
//Calulate WinRatio
W = matrix.get(vals,8,2)
L = matrix.get(vals,8,3)
WR = math.round(W/(W+L)*100,2)
string [] tbl_vals = array.from("WIN: "+str.tostring(W),
"LOSS: "+str.tostring(L),
"Profitability: "+str.tostring(WR,format.percent))
color [] tbl_col = array.from(color.green,color.red,chart.fg_color)
for i=0 to 2
table.cell(matrix.get(tbl,0,0),0,i,array.get(tbl_vals,i),
text_halign=text.align_center,bgcolor=chart.bg_color,
text_color=array.get(tbl_col,i),text_size=size.auto)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} |
Relative Performance of stock against nifty & bank nifty | https://www.tradingview.com/script/oPOYIzm8-Relative-Performance-of-stock-against-nifty-bank-nifty/ | Tradernawab | https://www.tradingview.com/u/Tradernawab/ | 26 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Tradernawab
//@version=5
indicator("Nifty-Bank Nifty Relative Performance", overlay=false)
// Retrieve data for Nifty and Bank Nifty
nifty =request.security("NSE:NIFTY", timeframe.period, close)
banknifty = request.security("NSE:BANKNIFTY", "D", close)
// Calculate daily returns for Nifty and Bank Nifty
nifty_return = (nifty - nifty[1]) / nifty[1] * 100
banknifty_return = (banknifty - banknifty[1]) / banknifty[1] * 100
// Calculate average returns for Nifty and Bank Nifty
lookback=input.int(55,"lookback")
nifty_avg_return = ta.sma(nifty_return, lookback)
banknifty_avg_return = ta.sma(banknifty_return, lookback)
// Calculate relative performance
relative_performance = (close - ta.sma(close, lookback)) / ta.sma(close, lookback) * 100 - (nifty_avg_return + banknifty_avg_return) / 2
//calculate rsi
rsi=ta.rsi(close,14)
// Plot the relative performance and signal line
plot(relative_performance, "Relative Performance", color=color.green)
hline(0, "Signal Line", color=color.black)
//moving avg
interval=input.int(10,"interval")
moving_avg=ta.sma(relative_performance,interval)
plot(moving_avg)
//rsi calculation
Rsi=ta.rsi(close,14)
barcolor(relative_performance>moving_avg and Rsi>50 ?color.yellow:na)
barcolor(relative_performance<moving_avg and Rsi<50?color.rgb(74, 8, 228):na) |
JZ_Chaikin HTF Volatility Breakout | https://www.tradingview.com/script/Et1G3oVa-JZ-Chaikin-HTF-Volatility-Breakout/ | JazzByrd | https://www.tradingview.com/u/JazzByrd/ | 35 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© JazzByrd
// All Credit to Harry Potter's initial Chaikin Volatility Indicator (Copyright by HPotter v1.0 13/08/2014), of which this is only a slight modification.
// Added Higher Timeframe and HMA for smoother signal and for use as confirmation of the faster signal.
// Added a Volatility Breakout Signal based on HTF signals.
// Breakouts try to capture zero crosses from a swing low to high in volatility.
// Added a Range Highlight options to identify range periods and potential no trade zones. Defval is off.
// The HTF Chaikin breakout levels can both be changed in inputs to set your own parameters for the breakout signals.
//@version=5
indicator(title='JZ_Chaikin HTF Volatility Breakout', shorttitle = "CVB")
// INPUTS:
chk_inp = "Chaikin Volatility Inputs:"
chk_Len = input.int(10, minval=1, title = "Chaikin Volatility Length", group = chk_inp)
ROCLength = input.int(12, minval=1, title = "Rate of Change Length", group = chk_inp)
chk_Br_lvl_h = input.int(defval=15, title = "Breakout Range - High", group = chk_inp, tooltip = "Sets higher threshold for breakout. When HTF Chaikin line above this level will not give Breakout signal")
chk_Br_lvl_l = input.int(defval = -10, title = "Breakout Range - Low", group = chk_inp, tooltip = "Sets lower threshold for breakout. When HTF Chaikin below this level will not give breakout signal")
chk_hma_len = input.int(defval = 21, title = "HMA Length", tooltip = "Sets HMA smoothing line length for both Chart and HTF", group = chk_inp)
chk_htf_inp = "Chaikin Vol HTF Options:"
cv_Htf = input.timeframe(title = "Higher Timeframe:", defval = "D", group = chk_htf_inp)
chk_hl = "Chaikin Highlight Conditions:"
cv_range = input.bool(defval = false, title = "Highlight HTF Range/Chop Zones?", tooltip = "Chaikin HTF Line is < 0 and it's HMA is decreasing", group = chk_hl)
col_ch = input.bool(defval = true, title = "Color Change on HMA?", tooltip = "Chaikin Volatility HMA line changes color with direction changes", group = chk_hl)
chk_bo = input.bool(defval=true, title = "Highlight Volatility Breakouts?", group = chk_hl, tooltip = "HTF line rising up close to zero, while Htf HMA also increasing from below zero")
// CALCULATIONS:
// Chaikin Volatility:
xPrice1 = high
xPrice2 = low
xPrice = xPrice1 - xPrice2
cv1 = ta.roc(ta.ema(xPrice, chk_Len), ROCLength)
// HMA/MA on Chaikin Vol:
cv1_Hma = ta.hma(cv1, chk_hma_len)
// Higher Timeframe:
// DECLARE CUSTOM SECURITY FUNCTION:
f_sec(_market, _res, _exp) => request.security(_market, _res, _exp[barstate.isconfirmed ? 0 : 1])
// GET Chaikin Vol & HMA on Higher Timeframes:
cv2_Htf = f_sec(syminfo.tickerid, cv_Htf, cv1)
cv2_Hma = f_sec(syminfo.tickerid, cv_Htf, cv1_Hma)
// CHAIKIN COLOR CHANGE:
ch1_col = cv1_Hma > cv1_Hma[1] ? color.new(color.green, 75) : cv1_Hma < cv1_Hma[1] ? color.new(color.red, 50) : color.new(color.yellow, 50)
ch2_col = cv2_Hma > cv2_Hma[1] ? color.new(color.aqua, 75) : cv2_Hma < cv2_Hma[1] ? color.new(color.orange, 50) : color.new(color.white, 50)
// HIGHLIGHT CONDITIONS:
// HTF Chaikin Line is coming up from low (below zero) and getting close to 0 line range (between breakout levels of input).
// Confirmation is HMA changing to positive momentum (increasing) and coming from a swing low (< -15).
// basically capturing the breakout moment just before or after zero line cross -- a swing low to high in volatility.
ch_htf_BO = (cv2_Htf < chk_Br_lvl_h and cv2_Htf > chk_Br_lvl_l) and (cv2_Hma < 0 and cv2_Hma > cv2_Hma[1] and cv2_Hma < -15) and chk_bo and (cv2_Htf > cv2_Htf[1])
plotshape(ch_htf_BO, title = "Volatility Breakout", style = shape.diamond, color = color.aqua, text = "B", location = location.bottom, textcolor = color.white)
// RANGE:
// NO TRADE ZONE:
NoTrade = (cv2_Hma < 0 and cv2_Hma < cv2_Hma[1]) and cv2_Htf < 0
bgcolor(color = cv_range and NoTrade ? color.new(color.white, 50) : na, title = "HTF No Trade / Low Volatility Zone")
//PLOT:
plot(cv1, color=color.new(color.white, 0), title='Chaikin Volatility')
plot(cv1_Hma, title="HMA of C.V.", color = col_ch ? ch1_col : color.new(color.white, 50), style=plot.style_area)
// Plot HTF:
plot(cv2_Htf, color=color.blue, title = "HTF C.V.", linewidth = 2)
plot(cv2_Hma, color = col_ch ? ch2_col : color.new(color.orange, 50), title = "HTF HMA", style = plot.style_histogram, linewidth = 3)
hline(0, color=color.white, linestyle=hline.style_dotted)
|
ADD 2 | https://www.tradingview.com/script/skuNhTjf-ADD-2/ | buyoption | https://www.tradingview.com/u/buyoption/ | 22 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Tom1trader
// This is the NYSE Advancers - decliners which the SPX pretty much has to follow. The level gives an idea of days move
// but I follow the direction as when more advance (green) or decline (red) the index tends to track it pretty closely.
// On SPX and correlateds - very useful for intr-day trading (Scalping or 0DTE option trades) but not for higher time fromes at all.
// I left it at 5 minutes timeframe which displays well on any intraday chart. You can change it by changing the "5" in the security
// function on line 13 to what you want or change it to timeframe.period (no quotes). 5 min displays better on higher i.e. 15min.
//@version=5
indicator('ADD 2', overlay=false)
f_ma(source, length, type) =>
value_ = 0.0
if type == 'SMA'
value_ := ta.sma(source, length)
if type == 'EMA'
value_ := ta.ema(source, length)
if type == 'WMA'
value_ := ta.wma(source, length)
if type == 'HMA'
value_ := ta.hma(source, length)
value_
grp_add = 'ADD'
i_mtf = input.timeframe('5', title="Time Frame", group = grp_add)
i_length = input(10, 'MA length', group = grp_add, inline = '101')
ma_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA', 'HMA'], inline = '101', group=grp_add)
a = request.security('USI:ADD', i_mtf, hlc3)
green = #00DD00
red = #DD0000
dircol = a > a[1] ? green : red
ma = f_ma(a, i_length, ma_type)
plot(a, title='ADD', color=dircol, linewidth=3)
plot(ma, color=color.new(color.white, 0), linewidth=3)
|
Triple RSI Indicator with Toggle | https://www.tradingview.com/script/XA8e6eEP-Triple-RSI-Indicator-with-Toggle/ | Rginah1974 | https://www.tradingview.com/u/Rginah1974/ | 22 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Rginah1974
//@version=4
study("Triple RSI Indicator with Toggle", shorttitle="TRSI-T", overlay=false)
// Input parameters
rsi1Length = input(5, title="RSI1 Length", minval=1, group="short RSI")
rsi2Length = input(14, title="RSI2 Length", minval=1, group="main RSI")
rsi3Length = input(28, title="RSI3 Length", minval=1, group="long RSI")
overbought1 = input(80, title="RSI1 Overbought Level", group="short RSI")
overbought2 = input(70, title="RSI2 Overbought Level", group="main RSI")
overbought3 = input(70, title="RSI3 Overbought Level", group="long RSI")
oversold1 = input(20, title="RSI1 Oversold Level", group="short RSI")
oversold2 = input(30, title="RSI2 Oversold Level", group="main RSI")
oversold3 = input(30, title="RSI3 Oversold Level", group="long RSI")
use_rsi1 = input(true, title="Use RSI1 for OB/OS signals")
use_rsi2 = input(true, title="Use RSI2 for OB/OS signals")
use_rsi3 = input(true, title="Use RSI3 for OB/OS signals")
// Calculate RSI values
rsi1 = rsi(close, rsi1Length)
rsi2 = rsi(close, rsi2Length)
rsi3 = rsi(close, rsi3Length)
// Plot RSI values
plot(rsi1, title="RSI1", color=color.aqua, linewidth=1)
plot(rsi2, title="RSI2", color=color.white, linewidth=1)
plot(rsi3, title="RSI3", color=color.fuchsia, linewidth=1)
// Calculate bar color based on the enabled RSI values
overboughtCondition = ((use_rsi1 ? rsi1 > overbought1 : true) and (use_rsi2 ? rsi2 > overbought2 : true) and (use_rsi3 ? rsi3 > overbought3 : true))
oversoldCondition = ((use_rsi1 ? rsi1 < oversold1 : true) and (use_rsi2 ? rsi2 < oversold2 : true) and (use_rsi3 ? rsi3 < oversold3 : true))
barColor = overboughtCondition ? color.fuchsia : oversoldCondition ? color.aqua : na
// Plot continuous horizontal bar
bgcolor(barColor, transp=70)
/////////
// RSI
col_black = color.new(color.black, 100)
//Input
src = input(close, title="Source")
rsi_fast_len = input(5, minval=1, title="Fast RSI Length")
rsi_ema_len = input(14, minval=1, title="EMA Length")
//rsi2 = rsi(src, rsi2Length)
rsi_fast = rsi(src, rsi_fast_len)
rsi_ema = ema(rsi2, rsi_ema_len)
//View
color_short = #ff00ea
color_long = #00eeff
color_neutral = #dbd4b3
p_rsi_fast = plot(rsi_fast, title = "Fast RSI", style=plot.style_line, linewidth=1, transp=100, color=color_neutral)
p_rsi_ema = plot(rsi_ema, title = "RSI EMA", style=plot.style_line, linewidth=1, transp=20, color=color.orange)
fill (p_rsi_ema, p_rsi_fast, color = rsi_fast > rsi_ema ? color_long : color_short, transp=75, title = "RSI Cloud Fill")
//Grid
Ex_os = hline(100, linestyle=plot.style_line, linewidth=1, color=color.fuchsia)
Ex_ob = hline(0, linestyle=plot.style_line, linewidth=1, color=color.aqua)
blue = color.new(#00f2ff, transp=80)
fuchsia = color.new(#e100ff,transp=80)
white = color.new(#FFFFFF,transp=95)
Grid_10 = hline(10, linestyle=plot.style_line, linewidth=2, color=blue)
Grid_20 = hline(20, linestyle=plot.style_line, linewidth=1, color=blue)
Grid_40 = hline(40, linestyle=plot.style_line, linewidth=1, color=white)
Grid_50 = hline(50, linestyle=plot.style_line, linewidth=1, color=white)
Grid_60 = hline(60, linestyle=plot.style_line, linewidth=1, color=white)
Grid_80 = hline(80, linestyle=plot.style_line, linewidth=1, color=fuchsia)
Grid_90 = hline(90, linestyle=plot.style_line, linewidth=2, color=fuchsia)
///// |
WillyCycle Oscillator&DoubleMa/ErkOzi/version 2 | https://www.tradingview.com/script/KbJujNsb/ | ErkOzi | https://www.tradingview.com/u/ErkOzi/ | 107 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© ErkOzi
//@version=5
indicator(title='WillyCycle Oscillator&DoubleMa/ErkOzi/version 2x', shorttitle='WCODMA')
// Willy period
length = input.int(240, title='LTF Period')
upper = ta.highest(length)
lower = ta.lowest(length)
// Willy period HTF
length2 = input.int(480, title='HTF Period')
upper2 = ta.highest(length2)
lower2 = ta.lowest(length2)
// Calculate willy
out = 100 * (close - lower) / (upper - lower)
src = out
len = input.int(55, title='LTF EMA Period')
// Compute the EMA of Willy
out2 = ta.ema(out, len)
// Add the top and bottom ranges for Willy to be considered
band1 = hline(78.6, 'Upper Band', color=#2F4F4F)
band0 = hline(23.6, 'Lower Band', color=#2F4F4F)
// Add Slow Stochastic Oscillator
lengthK = input(14, title="K Length")
lengthD = input(3, title="D Length")
smoothD = input(3, title="D Smooth")
k = ta.stoch(out2, out2, out2, lengthK)
d = ta.sma(k, lengthD)
slowK = ta.sma(k, smoothD)
// Plot the Slow Stochastic Oscillator
plot(slowK, title="Slow %K", color=color.blue, linewidth=1)
plot(d, title="Slow %D", color= color.orange, linewidth=1)
// Calculate willy HTF
out22 = 100 * (close - lower2) / (upper2 - lower2) // Change the formula for HTF Willy
src22 = out22
len22 = input.int(618, title='HTF EMA Period')
// Compute the EMA of Willy HTF
out222 = ta.ema(out22, len22)
// Color the background where Willy
fill(hline(100, 'Upper Limit', color.red), band1, out2 > 80 ? color.red : color.black, 'overbought1', transp=70)
fill(band0, hline(0, 'Lower Limit', color.green), out2 < 20 ? color.lime : color.black, 'oversold1', transp=70)
// Color the background where Willy HTF
fill(hline(100, 'Upper Limit', color.black), band1, out222 > 80 ? color.teal : color.black, 'overbought2-HTF', transp=90)
fill(band0, hline(0, 'Lower Limit', color.black), out222 < 20 ? color.fuchsia : color.black, 'oversold2-HTF', transp=90)
// Draw the mid point
midpoint1 = hline(61.8, title='Midpoint61.8', color=color.yellow, linestyle=hline.style_dotted, linewidth=1)
midpoint = hline(50, title='Midpoint', color= color.red, linestyle=hline.style_dotted, linewidth=2)
midpoint2 = hline(38.2, title='Midpoint38.2', color= color.yellow, linestyle=hline.style_dotted, linewidth=1)
// Smoothed WillyCycle Line settings
smoothed = input(false, title='Smoothed WillyCycle Line?')
smooth_len = input.int(5, minval=1, maxval=20, title='Smooth Length')
// Calculate the smoothed WillyCycle Line
smoothed_willy = smoothed ? ta.ema(out, smooth_len) : out
// Draw the Willy and EMA
plot(smoothed ? ta.ema(out, 10) : out, title='WillyCycle', color=color.new(color.aqua,10), linewidth=2)
plot(out2, title='WillyCycle EMA', color=color.new(color.green, 5), linewidth=3)
plot(out22, title='WillyCycle HTF', color=color.new(color.gray, 1), linewidth=1)
plot(out222, title='WillyCycle EMA HTF', color=color.new(color.maroon, 5), linewidth=3)
// ADX calculation
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
sig = adx(dilen, adxlen)
plot(sig, color= color.red, title="ADX")
|
VWAP Bollinger Band Crossover Breakout with Resistance | https://www.tradingview.com/script/TJq6nTJ9-VWAP-Bollinger-Band-Crossover-Breakout-with-Resistance/ | beststockalert | https://www.tradingview.com/u/beststockalert/ | 83 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© RickVBlack
// credit to // Β© Jesus_Salvatierra for VWAP script
//@version=4
study(title = "VWAP Bollinger Band Crossover", shorttitle = "VWAP BB Cross", overlay = true)
// Inputs
price = input(close, title='Price')
bb_length = input(20, title='Bollinger length')
bb_multiplier = input(2, title='Bollinger Multiplier')
// BB
bb_basis = sma(price, bb_length)
bb_dev = bb_multiplier * stdev(price, bb_length)
bb_upper = bb_basis + bb_dev
bb_lower = bb_basis - bb_dev
// Plots
bbc = crossover(price, bb_upper)
plotshape(bbc, title = "BB Cross", location = location.belowbar, style = shape.triangleup, color = #ff2f00, size = size.small)
bbu = crossunder(bb_upper, bb_basis)
plotshape(bbu, title = "BB Under", location = location.belowbar, style = shape.triangledown, color = #160b2f, size = size.small)
computeVWAP(src, isNewPeriod, stDevMultiplier) =>
var float sumSrcVol = na
var float sumVol = na
var float sumSrcSrcVol = na
sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1]
sumVol := isNewPeriod ? volume : volume + sumVol[1]
// sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation
sumSrcSrcVol := isNewPeriod ? volume * pow(src, 2) : volume * pow(src, 2) + sumSrcSrcVol[1]
_vwap = sumSrcVol / sumVol
variance = sumSrcSrcVol / sumVol - pow(_vwap, 2)
variance := variance < 0 ? 0 : variance
stDev = sqrt(variance)
lowerBand = _vwap - stDev * stDevMultiplier
upperBand = _vwap + stDev * stDevMultiplier
[_vwap, lowerBand, upperBand]
hideonDWM = input(false, title="Hide VWAP on 1D or Above", group="VWAP Settings")
var anchor = input(defval = "Session", title="Anchor Period", type=input.string,
options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings")
src = input(title = "Source", type = input.source, defval = hlc3, group="VWAP Settings")
offset = input(0, title="Offset", group="VWAP Settings")
showBands = input(true, title="Calculate Bands", group="Standard Deviation Bands Settings")
stdevMult = input(2.0, title="Bands Multiplier", group="Standard Deviation Bands Settings")
timeChange(period) =>
change(time(period))
new_earnings = earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on)
new_dividends = dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on)
new_split = splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on)
isNewPeriod = anchor == "Earnings" ? new_earnings :
anchor == "Dividends" ? new_dividends :
anchor == "Splits" ? new_split :
na(src[1]) ? true :
anchor == "Session" ? timeChange("D") :
anchor == "Week" ? timeChange("W") :
anchor == "Month" ? timeChange("M") :
anchor == "Quarter" ? timeChange("3M") :
anchor == "Year" ? timeChange("12M") :
anchor == "Decade" ? timeChange("12M") and year % 10 == 0 :
anchor == "Century" ? timeChange("12M") and year % 100 == 0 :
false
float vwapValue = na
float std = na
float upperBandValue = na
float lowerBandValue = na
if not (hideonDWM and timeframe.isdwm)
[_vwap, bottom, top] = computeVWAP(src, isNewPeriod, stdevMult)
vwapValue := _vwap
upperBandValue := showBands ? top : na
lowerBandValue := showBands ? bottom : na
plot(vwapValue, title="VWAP", color=#a229ff, offset=offset)
upperBand = plot(upperBandValue, title="Upper Band", color=color.green, offset=offset)
lowerBand = plot(lowerBandValue, title="Lower Band", color=color.green, offset=offset)
fill(upperBand, lowerBand, title="Bands Fill", color= showBands ? color.new(#c2dac3, 95) : na)
//SAR
start = input(title = "Start", defval = 0.02, step = 0.001)
increment = input(title = "Increment", defval = 0.02, step = 0.001)
maximum = input(title = "Max Value", defval = 0.2, step = 0.01)
putlabel = input(title = "Sell", defval = true)
colup = input(title = "Colors", defval = color.rgb(230, 138, 0), inline = "col")
coldn = input(title = "", defval = color.rgb(19, 16, 21), inline = "col")
int trend = 0
float sar = 0.0
float ep = 0.0
float af = 0.0
trend := nz(trend[1])
ep := nz(ep[1])
af :=nz(af[1])
sar := sar[1]
if trend == 0 and not na(high[1])
trend := high >= high[1] or low >= low[1] ? 1 : -1
sar := trend > 0 ? low[1] : high[1]
ep := trend > 0 ? high[1] : low[1]
af := start
else
nextsar = sar
if trend > 0
if high[1] > ep
ep := high[1]
af := min(maximum, af + increment)
nextsar := sar + af * (ep - sar)
nextsar := min(min(low[1], low[2]), nextsar)
//Reversal
if nextsar > low
trend := -1
nextsar := ep
ep := low
af := start
else
if low[1] < ep
ep := low[1]
af := min(maximum, af + increment)
nextsar := sar + af * (ep - sar)
nextsar := max(max(high[1], high[2]), nextsar)
//Reversal
if nextsar < high
trend := 1
nextsar := ep
ep := high
af := start
sar := nextsar
//plot(sar, title = "Parabolic SAR", color = trend > 0 ? colup : coldn, linewidth = 2, style = plot.style_circles)
alertcondition(change(trend) > 0, title='PSAR Trend UP', message='PSAR Trend UP')
alertcondition(change(trend) < 0, title='PSAR Trend DOWN', message='PSAR Trend DOWN')
if change(trend) < 0 and putlabel
label.new(bar_index, sar, text = "", color = coldn, style=label.style_labeldown, size = size.tiny) |
Fed Projected Interest Rates | https://www.tradingview.com/script/YVMSLzBP-Fed-Projected-Interest-Rates/ | triccomane | https://www.tradingview.com/u/triccomane/ | 14 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© triccomane
//@version=5
indicator("Fed Projected Interest Rates", overlay = true)
cur_input =input('CBOT:ZQJ2023',title = 'current zq')
cur_zq = 100-request.security(cur_input, timeframe.period, close)
cur_name = input("current interest",title = 'current zq')
jun_input =input('CBOT:ZQM2023',title = 'June zq')
next1_zq = 100-request.security(jun_input, timeframe.period, close)
next1_name = input("June interest",title = 'next1 zq')
sep_input =input('CBOT:ZQU2023',title = 'September zq')
next2_zq = 100-request.security(sep_input, timeframe.period, close)
next2_name = input("September interest",title = 'next2 zq')
dec_input =input('CBOT:ZQZ2023',title = 'December zq')
next3_zq = 100-request.security(dec_input, timeframe.period, close)
next3_name = input("December interest",title = 'next3 zq')
pos = input.string(title="Position", options=["Top Left", "Top Right", "Bottom Left", "Bottom Right"], defval="Top Right")
position = pos=="Top Left" ? position.top_left : pos=="Top Right" ? position.top_right : pos=="Bottom Left" ? position.bottom_left : position.bottom_right
//Table
var t = table.new(position, 5, 5, color.black)
if barstate.islast
table.cell(t, 0, 1, cur_name, text_color=color.white)
table.cell(t, 1, 1, str.tostring(cur_zq), text_color=color.white, bgcolor = #f2ff009b)
table.cell(t, 0, 2, next1_name, text_color=color.white)
table.cell(t, 1, 2, str.tostring(next1_zq), text_color=color.white, bgcolor = #f2ff009b)
table.cell(t, 0, 3, next2_name, text_color=color.white)
table.cell(t, 1, 3, str.tostring(next2_zq), text_color=color.white, bgcolor = #f2ff009b)
table.cell(t, 0, 4, next3_name, text_color=color.white)
table.cell(t, 1, 4, str.tostring(next3_zq), text_color=color.white, bgcolor = #f2ff009b)
|
Correlation Crypto Matrix | https://www.tradingview.com/script/j9R6AY6t-Correlation-Crypto-Matrix/ | VanHe1sing | https://www.tradingview.com/u/VanHe1sing/ | 74 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© [VanHelsing 2023]
//@version=5
indicator("Correlation Crypto Matrix", 'CCM', overlay = false)
int cc_len = input.int(30, 'Correlation Length')
string sym1= input("BTCUSD")
string sym2= input("BNBUSD")
string sym3= input("ETHUSD")
string sym4= input("BCHUSD")
string sym5= input("XRPUSD")
string sym6= input("EOSUSD")
string sym7= input("LTCUSD")
string sym8= input("TRXUSD")
string sym9= input("ETCUSD")
string sym10= input("LINKUSD")
symbol1= request.security( sym1 ,"" ,close)
symbol2= request.security( sym2 ,"" ,close)
symbol3= request.security( sym3 ,"" ,close)
symbol4= request.security( sym4 ,"" ,close)
symbol5= request.security( sym5 ,"" ,close)
symbol6= request.security( sym6 ,"" ,close)
symbol7= request.security( sym7 ,"" ,close)
symbol8= request.security( sym8 ,"" ,close)
symbol9= request.security( sym9 ,"" ,close)
symbol10= request.security( sym10 ,"" ,close)
// β οΉ οΉ
corelation_col(sym, sym2, cc_len)=>
cc = math.round(ta.correlation(sym, sym2, cc_len),2)
color = color.from_gradient(cc, -1, 1,color.red,color.green)
[cc, color]
[cc1, color1] = corelation_col(symbol1, symbol2, cc_len)
[cc2, color2] = corelation_col(symbol1, symbol3, cc_len)
[cc3, color3] = corelation_col(symbol1, symbol4, cc_len)
[cc4, color4] = corelation_col(symbol1, symbol5, cc_len)
[cc5, color5] = corelation_col(symbol1, symbol6, cc_len)
[cc6, color6] = corelation_col(symbol1, symbol7, cc_len)
[cc7, color7] = corelation_col(symbol1, symbol8, cc_len)
[cc8, color8] = corelation_col(symbol1, symbol9, cc_len)
[cc9, color9] = corelation_col(symbol1, symbol10, cc_len)
[cc10, color10] = corelation_col(symbol2, symbol3, cc_len)
[cc11, color11] = corelation_col(symbol2, symbol4, cc_len)
[cc12, color12] = corelation_col(symbol2, symbol5, cc_len)
[cc13, color13] = corelation_col(symbol2, symbol6, cc_len)
[cc14, color14] = corelation_col(symbol2, symbol7, cc_len)
[cc15, color15] = corelation_col(symbol2, symbol8, cc_len)
[cc16, color16] = corelation_col(symbol2, symbol9, cc_len)
[cc17, color17] = corelation_col(symbol2, symbol10, cc_len)
[cc18, color18] = corelation_col(symbol3, symbol4, cc_len)
[cc19, color19] = corelation_col(symbol3, symbol5, cc_len)
[cc20, color20] = corelation_col(symbol3, symbol6, cc_len)
[cc21, color21] = corelation_col(symbol3, symbol7, cc_len)
[cc22, color22] = corelation_col(symbol3, symbol8, cc_len)
[cc23, color23] = corelation_col(symbol3, symbol9, cc_len)
[cc24, color24] = corelation_col(symbol3, symbol10, cc_len)
[cc25, color25] = corelation_col(symbol4, symbol5, cc_len)
[cc26, color26] = corelation_col(symbol4, symbol6, cc_len)
[cc27, color27] = corelation_col(symbol4, symbol7, cc_len)
[cc28, color28] = corelation_col(symbol4, symbol8, cc_len)
[cc29, color29] = corelation_col(symbol4, symbol9, cc_len)
[cc30, color30] = corelation_col(symbol4, symbol10, cc_len)
[cc31, color31] = corelation_col(symbol5, symbol6, cc_len)
[cc32, color32] = corelation_col(symbol5, symbol7, cc_len)
[cc33, color33] = corelation_col(symbol5, symbol8, cc_len)
[cc34, color34] = corelation_col(symbol5, symbol9, cc_len)
[cc35, color35] = corelation_col(symbol5, symbol10, cc_len)
[cc36, color36] = corelation_col(symbol6, symbol7, cc_len)
[cc37, color37] = corelation_col(symbol6, symbol8, cc_len)
[cc38, color38] = corelation_col(symbol6, symbol9, cc_len)
[cc39, color39] = corelation_col(symbol6, symbol10, cc_len)
[cc40, color40] = corelation_col(symbol7, symbol8, cc_len)
[cc41, color41] = corelation_col(symbol7, symbol9, cc_len)
[cc42, color42] = corelation_col(symbol7, symbol10, cc_len)
[cc43, color43] = corelation_col(symbol8, symbol9, cc_len)
[cc44, color44] = corelation_col(symbol8, symbol10, cc_len)
[cc45, color45] = corelation_col(symbol9, symbol10, cc_len)
var table = table.new(position.top_center, 40, 40, border_color = color.rgb(61, 62, 68), border_width = 2)
cell(sym, a, c, color, text_size = size.normal)=>
table.cell(table, a, c, text = str.tostring(sym), text_color = color, text_size = text_size)
cell1(cc, a, c, color)=>
table.cell(table, a, c, text = cc<0.2 and cc>-0.2?"β":cc>0.2? "οΉ":cc<-0.2 ? 'οΉ':na, text_color = color1, text_size = size.large)
cell(sym1, 0, 1, color.white)
cell(sym2, 0, 2, color.white)
cell(sym3, 0, 3, color.white)
cell(sym4, 0, 4, color.white)
cell(sym5, 0, 5, color.white)
cell(sym6, 0, 6, color.white)
cell(sym7, 0, 7, color.white)
cell(sym8, 0, 8, color.white)
cell(sym9, 0, 9, color.white)
cell(sym10, 0, 10, color.white)
cell(sym1, 1, 0, color.white)
cell(sym2, 2, 0, color.white)
cell(sym3, 3, 0, color.white)
cell(sym4, 4, 0, color.white)
cell(sym5, 5, 0, color.white)
cell(sym6, 6, 0, color.white)
cell(sym7, 7, 0, color.white)
cell(sym8, 8, 0, color.white)
cell(sym9, 9, 0, color.white)
cell(sym10, 10, 0, color.white)
cell("βΏ", 1, 1, color.gray)
cell(sym2, 2, 2, color.gray)
cell(sym3, 3, 3, color.gray)
cell(sym4, 4, 4, color.gray)
cell(sym5, 5, 5, color.gray)
cell(sym6, 6, 6, color.gray)
cell(sym7, 7, 7, color.gray)
cell(sym8, 8, 8, color.gray)
cell(sym9, 9, 9, color.gray)
cell(sym10, 10, 10, color.gray)
cell(str.tostring(cc1), 1, 2, color1)
cell1(cc1, 2, 1, color1)
cell(str.tostring(cc2), 1, 3, color2)
cell1(cc2, 3, 1, color2)
cell(str.tostring(cc3), 1, 4, color3)
cell1(cc3, 4, 1, color3)
cell(str.tostring(cc4), 1, 5, color4)
cell1(cc4, 5, 1, color4)
cell(str.tostring(cc5), 1, 6, color5)
cell1(cc5, 6, 1, color5)
cell(str.tostring(cc6), 1, 7, color6)
cell1(cc6, 7, 1, color6)
cell(str.tostring(cc7), 1, 8, color7)
cell1(cc7, 8, 1, color7)
cell(str.tostring(cc8), 1, 9, color8)
cell1(cc8, 9, 1, color8)
cell(str.tostring(cc9), 1, 10, color9)
cell1(cc9, 10, 1, color9)
cell(str.tostring(cc10), 2, 3, color10)
cell1(cc10, 3, 2, color10)
cell(str.tostring(cc11), 2, 4, color11)
cell1(cc11, 4, 2, color11)
cell(str.tostring(cc12), 2, 5, color12)
cell1(cc12, 5, 2, color12)
cell(str.tostring(cc13), 2, 6, color13)
cell1(cc13, 6, 2, color13)
cell(str.tostring(cc14), 2, 7, color14)
cell1(cc14, 7, 2, color14)
cell(str.tostring(cc15), 2, 8, color15)
cell1(cc15, 8, 2, color15)
cell(str.tostring(cc16), 2, 9, color16)
cell1(cc16, 9, 2, color16)
cell(str.tostring(cc17), 2, 10, color17)
cell1(cc17, 10, 2, color17)
cell(str.tostring(cc18), 3, 4, color18)
cell1(cc18, 4, 3, color18)
cell(str.tostring(cc19), 3, 5, color19)
cell1(cc19, 5, 3, color19)
cell(str.tostring(cc20), 3, 6, color20)
cell1(cc20, 6, 3, color20)
cell(str.tostring(cc21), 3, 7, color21)
cell1(cc21, 7, 3, color21)
cell(str.tostring(cc22), 3, 8, color22)
cell1(cc22, 8, 3, color22)
cell(str.tostring(cc23), 3, 9, color23)
cell1(cc23, 9, 3, color23)
cell(str.tostring(cc24), 3, 10, color24)
cell1(cc24, 10, 3, color24)
cell(str.tostring(cc25), 4, 5, color25)
cell1(cc25, 5, 4, color25)
cell(str.tostring(cc26), 4, 6, color26)
cell1(cc26, 6, 4, color26)
cell(str.tostring(cc27), 4, 7, color27)
cell1(cc27, 7, 4, color27)
cell(str.tostring(cc28), 4, 8, color28)
cell1(cc28, 8, 4, color28)
cell(str.tostring(cc29), 4, 9, color29)
cell1(cc29, 9, 4, color29)
cell(str.tostring(cc30), 4, 10, color30)
cell1(cc30, 10, 4, color30)
cell(str.tostring(cc31), 5, 6, color31)
cell1(cc31, 6, 5, color31)
cell(str.tostring(cc32), 5, 7, color32)
cell1(cc32, 7, 5, color32)
cell(str.tostring(cc33), 5, 8, color33)
cell1(cc33, 8, 5, color33)
cell(str.tostring(cc34), 5, 9, color34)
cell1(cc34, 9, 5, color34)
cell(str.tostring(cc35), 5, 10, color35)
cell1(cc35, 10, 5, color35)
cell(str.tostring(cc36), 6, 7, color36)
cell1(cc36, 7, 6, color36)
cell(str.tostring(cc37), 6, 8, color37)
cell1(cc37, 8, 6, color37)
cell(str.tostring(cc38), 6, 9, color38)
cell1(cc38, 9, 6, color38)
cell(str.tostring(cc39), 6, 10, color39)
cell1(cc39, 10, 6, color39)
cell(str.tostring(cc40), 7, 8, color40)
cell1(cc40, 8, 7, color40)
cell(str.tostring(cc41), 7, 9, color41)
cell1(cc41, 9, 7, color41)
cell(str.tostring(cc42), 7, 10, color42)
cell1(cc42, 10, 7, color42)
cell(str.tostring(cc43), 8, 9, color43)
cell1(cc43, 9, 8, color43)
cell(str.tostring(cc44), 8, 10, color44)
cell1(cc44, 10, 8, color44)
cell(str.tostring(cc45), 9, 10, color45)
cell1(cc45, 10, 9, color45)
alert('- ' + str.tostring(sym1) +" "+ str.tostring(sym2) +" "+ str.tostring(sym3) +" "+ str.tostring(sym4) +" "+ str.tostring(sym5) +" "+ str.tostring(sym6) +" "+ str.tostring(sym7)
+" "+ str.tostring(sym8) +" "+ str.tostring(sym9)
+","+str.tostring(sym1)+","+
str.tostring(sym2) +" "+str.tostring(cc1)+","+
str.tostring(sym3) +" "+str.tostring(cc2)+" "+str.tostring(cc10)+","+
str.tostring(sym4) +" "+str.tostring(cc3)+" "+str.tostring(cc11)+" "+str.tostring(cc18)+","+
str.tostring(sym5) +" "+str.tostring(cc4)+" "+str.tostring(cc12)+" "+str.tostring(cc19)+" "+str.tostring(cc25)+","+
str.tostring(sym6) +" "+str.tostring(cc5)+" "+str.tostring(cc13)+" "+str.tostring(cc20)+" "+str.tostring(cc26)+" "+str.tostring(cc31)+","+
str.tostring(sym7) +" "+str.tostring(cc6)+" "+str.tostring(cc14)+" "+str.tostring(cc21)+" "+str.tostring(cc27)+" "+str.tostring(cc32)+" "+str.tostring(cc36)+","+
str.tostring(sym8) +" "+str.tostring(cc7)+" "+str.tostring(cc15)+" "+str.tostring(cc22)+" "+str.tostring(cc28)+" "+str.tostring(cc33)+" "+str.tostring(cc37)+" "+str.tostring(cc40)+","+
str.tostring(sym9) +" "+str.tostring(cc8)+" "+str.tostring(cc16)+" "+str.tostring(cc23)+" "+str.tostring(cc29)+" "+str.tostring(cc34)+" "+str.tostring(cc38)+" "+str.tostring(cc41)+" "+str.tostring(cc43)+","+
str.tostring(sym10)+" "+str.tostring(cc9)+" "+str.tostring(cc17)+" "+str.tostring(cc24)+" "+str.tostring(cc30)+" "+str.tostring(cc35)+" "+str.tostring(cc39)+" "+str.tostring(cc41)+" "+str.tostring(cc44)+" "+str.tostring(cc45)
) |
Trendlines [theEccentricTrader] | https://www.tradingview.com/script/pt2xPg6g-Trendlines-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 45 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Trendlines [theEccentricTrader]', overlay = true)
//////////// shsl ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
shPriceBarIndex = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? bar_index :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? bar_index - 1 : na
shPriceOne = ta.valuewhen(shPrice, shPrice, 1)
shPriceBarIndexOne = ta.valuewhen(shPriceBarIndex, shPriceBarIndex, 1)
shPriceTwo = ta.valuewhen(shPrice, shPrice, 2)
shPriceBarIndexTwo = ta.valuewhen(shPriceBarIndex, shPriceBarIndex, 2)
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
slPriceBarIndex = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? bar_index :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? bar_index - 1 : na
slPriceOne = ta.valuewhen(slPrice, slPrice, 1)
slPriceBarIndexOne = ta.valuewhen(slPriceBarIndex, slPriceBarIndex, 1)
slPriceTwo = ta.valuewhen(slPrice, slPrice, 2)
slPriceBarIndexTwo = ta.valuewhen(slPriceBarIndex, slPriceBarIndex, 2)
//////////// lines ////////////
resistanceLineColor = input(defval = color.blue, title = 'Resistance Line Color', group = "Line Coloring")
supportLineColor = input(defval = color.blue, title = 'Support Line Color', group = "Line Coloring")
previousLines = input(defval = false, title = 'Previous Lines', group = "Lines")
var resistanceLine = line.new(na, na, na, na, color = resistanceLineColor, extend = extend.right)
var supportLine = line.new(na, na, na, na, color = supportLineColor, extend = extend.right)
var resistanceLineOne = line.new(na, na, na, na, color = resistanceLineColor, extend = extend.right)
var supportLineOne = line.new(na, na, na, na, color = supportLineColor, extend = extend.right)
if shPrice
line.set_xy1(resistanceLine, shPriceBarIndexOne, shPriceOne)
line.set_xy2(resistanceLine, shPriceBarIndex, shPrice)
if slPrice
line.set_xy1(supportLine, slPriceBarIndexOne, slPriceOne)
line.set_xy2(supportLine, slPriceBarIndex, slPrice)
|
Return Line Downtrends [theEccentricTrader] | https://www.tradingview.com/script/3NWHQtHB-Return-Line-Downtrends-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 23 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Return Line Downtrends [theEccentricTrader]', overlay = true)
//////////// return line downtrends ////////////
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
onePartReturnLineDowntrend = slPrice < ta.valuewhen(slPrice, slPrice, 1)
twoPartReturnLineDowntrend = onePartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 1) < ta.valuewhen(slPrice, slPrice, 2)
threePartReturnLineDowntrend = twoPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 2) < ta.valuewhen(slPrice, slPrice, 3)
fourPartReturnLineDowntrend = threePartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 3) < ta.valuewhen(slPrice, slPrice, 4)
fivePartReturnLineDowntrend = fourPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 4) < ta.valuewhen(slPrice, slPrice, 5)
sixPartReturnLineDowntrend = fivePartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 5) < ta.valuewhen(slPrice, slPrice, 6)
sevenPartReturnLineDowntrend = sixPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 6) < ta.valuewhen(slPrice, slPrice, 7)
eightPartReturnLineDowntrend = sevenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 7) < ta.valuewhen(slPrice, slPrice, 8)
ninePartReturnLineDowntrend = eightPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 8) < ta.valuewhen(slPrice, slPrice, 9)
tenPartReturnLineDowntrend = ninePartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 9) < ta.valuewhen(slPrice, slPrice, 10)
elevenPartReturnLineDowntrend = tenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 10) < ta.valuewhen(slPrice, slPrice, 11)
twelvePartReturnLineDowntrend = elevenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 11) < ta.valuewhen(slPrice, slPrice, 12)
thirteenPartReturnLineDowntrend = twelvePartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 12) < ta.valuewhen(slPrice, slPrice, 13)
fourteenPartReturnLineDowntrend = thirteenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 13) < ta.valuewhen(slPrice, slPrice, 14)
fifteenPartReturnLineDowntrend = fourteenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 14) < ta.valuewhen(slPrice, slPrice, 15)
sixteenPartReturnLineDowntrend = fifteenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 15) < ta.valuewhen(slPrice, slPrice, 16)
seventeenPartReturnLineDowntrend = sixteenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 16) < ta.valuewhen(slPrice, slPrice, 17)
eighteenPartReturnLineDowntrend = seventeenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 17) < ta.valuewhen(slPrice, slPrice, 18)
nineteenPartReturnLineDowntrend = eighteenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 18) < ta.valuewhen(slPrice, slPrice, 19)
twentyPartReturnLineDowntrend = nineteenPartReturnLineDowntrend and ta.valuewhen(slPrice, slPrice, 19) < ta.valuewhen(slPrice, slPrice, 20)
//////////// plots ////////////
plotshape(slPrice and onePartReturnLineDowntrend and not twoPartReturnLineDowntrend and low <= low[1] ? onePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '1', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and twoPartReturnLineDowntrend and not threePartReturnLineDowntrend and low <= low[1] ? twoPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '2', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and threePartReturnLineDowntrend and not fourPartReturnLineDowntrend and low <= low[1] ? threePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '3', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and fourPartReturnLineDowntrend and not fivePartReturnLineDowntrend and low <= low[1] ? fourPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '4', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and fivePartReturnLineDowntrend and not sixPartReturnLineDowntrend and low <= low[1] ? fivePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '5', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and sixPartReturnLineDowntrend and not sevenPartReturnLineDowntrend and low <= low[1] ? sixPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '6', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and sevenPartReturnLineDowntrend and not eightPartReturnLineDowntrend and low <= low[1] ? sevenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '7', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and eightPartReturnLineDowntrend and not ninePartReturnLineDowntrend and low <= low[1] ? eightPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '8', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and ninePartReturnLineDowntrend and not tenPartReturnLineDowntrend and low <= low[1] ? ninePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '9', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and tenPartReturnLineDowntrend and not elevenPartReturnLineDowntrend and low <= low[1] ? tenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '10', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and elevenPartReturnLineDowntrend and not twelvePartReturnLineDowntrend and low <= low[1] ? elevenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '11', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and twelvePartReturnLineDowntrend and not thirteenPartReturnLineDowntrend and low <= low[1] ? twelvePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '12', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and thirteenPartReturnLineDowntrend and not fourteenPartReturnLineDowntrend and low <= low[1] ? thirteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '13', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and fourteenPartReturnLineDowntrend and not fifteenPartReturnLineDowntrend and low <= low[1] ? fourteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '14', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and fifteenPartReturnLineDowntrend and not sixteenPartReturnLineDowntrend and low <= low[1] ? fifteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '15', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and sixteenPartReturnLineDowntrend and not seventeenPartReturnLineDowntrend and low <= low[1] ? sixteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '16', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and seventeenPartReturnLineDowntrend and not eighteenPartReturnLineDowntrend and low <= low[1] ? seventeenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '17', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and eighteenPartReturnLineDowntrend and not nineteenPartReturnLineDowntrend and low <= low[1] ? eighteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '18', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and nineteenPartReturnLineDowntrend and not twentyPartReturnLineDowntrend and low <= low[1] ? nineteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '19', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and twentyPartReturnLineDowntrend and low <= low[1] ? twentyPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '20', textcolor = color.red, location = location.belowbar)
plotshape(slPrice and onePartReturnLineDowntrend and not twoPartReturnLineDowntrend and low > low[1] ? onePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '1', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and twoPartReturnLineDowntrend and not threePartReturnLineDowntrend and low > low[1] ? twoPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '2', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and threePartReturnLineDowntrend and not fourPartReturnLineDowntrend and low > low[1] ? threePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '3', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and fourPartReturnLineDowntrend and not fivePartReturnLineDowntrend and low > low[1] ? fourPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '4', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and fivePartReturnLineDowntrend and not sixPartReturnLineDowntrend and low > low[1] ? fivePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '5', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and sixPartReturnLineDowntrend and not sevenPartReturnLineDowntrend and low > low[1] ? sixPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '6', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and sevenPartReturnLineDowntrend and not eightPartReturnLineDowntrend and low > low[1] ? sevenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '7', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and eightPartReturnLineDowntrend and not ninePartReturnLineDowntrend and low > low[1] ? eightPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '8', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and ninePartReturnLineDowntrend and not tenPartReturnLineDowntrend and low > low[1] ? ninePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '9', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and tenPartReturnLineDowntrend and not elevenPartReturnLineDowntrend and low > low[1] ? tenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '10', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and elevenPartReturnLineDowntrend and not twelvePartReturnLineDowntrend and low > low[1] ? elevenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '11', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and twelvePartReturnLineDowntrend and not thirteenPartReturnLineDowntrend and low > low[1] ? twelvePartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '12', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and thirteenPartReturnLineDowntrend and not fourteenPartReturnLineDowntrend and low > low[1] ? thirteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '13', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and fourteenPartReturnLineDowntrend and not fifteenPartReturnLineDowntrend and low > low[1] ? fourteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '14', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and fifteenPartReturnLineDowntrend and not sixteenPartReturnLineDowntrend and low > low[1] ? fifteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '15', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and sixteenPartReturnLineDowntrend and not seventeenPartReturnLineDowntrend and low > low[1] ? sixteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '16', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and seventeenPartReturnLineDowntrend and not eighteenPartReturnLineDowntrend and low > low[1] ? seventeenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '17', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and eighteenPartReturnLineDowntrend and not nineteenPartReturnLineDowntrend and low > low[1] ? eighteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '18', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and nineteenPartReturnLineDowntrend and not twentyPartReturnLineDowntrend and low > low[1] ? nineteenPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '19', textcolor = color.red, location = location.belowbar, offset = -1)
plotshape(slPrice and twentyPartReturnLineDowntrend and low > low[1] ? twentyPartReturnLineDowntrend : na,
style = shape.triangledown, color = color.red, text = '20', textcolor = color.red, location = location.belowbar, offset = -1)
|
Trendlines HTF [theEccentricTrader] | https://www.tradingview.com/script/SsiX8yk4-Trendlines-HTF-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 175 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Trendlines HTF [theEccentricTrader]', overlay = true)
//////////// shsl ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] ? high :
close[1] >= open[1] and close < open and high <= high[1] ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] ? low :
close[1] < open[1] and close >= open and low >= low[1] ? low[1] : na
htf = input.timeframe(title = 'HTF Resolution', defval = '1D')
[shPriceHTF, slPriceHTF, closeHTF] = request.security(syminfo.tickerid, htf, [shPrice[1], slPrice[1], close[1]], lookahead = barmerge.lookahead_on)
shPriceOneHTF = ta.valuewhen(shPriceHTF, shPriceHTF, 1)
shOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
shCloseBarIndexHTF = ta.valuewhen(shPriceHTF and not shPriceHTF[1], bar_index, 0)
var shOpenBarIndexOneHTF = 0
shCloseBarIndexOneHTF = ta.valuewhen(shPriceHTF and not shPriceHTF[1], bar_index, 1)
slPriceOneHTF = ta.valuewhen(slPriceHTF, slPriceHTF, 1)
slOpenBarIndexHTF = ta.valuewhen(ta.change(closeHTF), bar_index, 2)
slCloseBarIndexHTF = ta.valuewhen(slPriceHTF and not slPriceHTF[1], bar_index, 0)
var slOpenBarIndexOneHTF = 0
slCloseBarIndexOneHTF = ta.valuewhen(slPriceHTF and not slPriceHTF[1], bar_index, 1)
//////////// lines ////////////
resistanceLineColor = input(defval = color.blue, title = 'Resistance Line Color', group = "Line Coloring")
supportLineColor = input(defval = color.blue, title = 'Support Line Color', group = "Line Coloring")
var htfPeakTrendline = line.new(na, na, na, na, extend = extend.right, color = resistanceLineColor)
var htfTroughTrendline = line.new(na, na, na, na, extend = extend.right, color = supportLineColor)
if shPriceHTF and not shPriceHTF[1]
lowerTimeFrameLookbackHighestHighBars = (bar_index - shOpenBarIndexHTF)
highestHighPassThrough = high[1]
lowerTimeFrameLookbackHighestHighBars1 = (shCloseBarIndexOneHTF - shOpenBarIndexOneHTF)
highestHighPassThrough1 = high[bar_index - shCloseBarIndexOneHTF]
for i = 2 to lowerTimeFrameLookbackHighestHighBars by 1
if high[i] == shPriceHTF
highestHighPassThrough := high[i]
lowerTimeFrameLookbackHighestHighBars := i
for j = (bar_index - shCloseBarIndexOneHTF) to (bar_index - shOpenBarIndexOneHTF) by 1
if high[j] == shPriceOneHTF
highestHighPassThrough1 := high[j]
lowerTimeFrameLookbackHighestHighBars1 := j
line.set_xy1(htfPeakTrendline, bar_index - lowerTimeFrameLookbackHighestHighBars1, shPriceOneHTF)
line.set_xy2(htfPeakTrendline, bar_index - lowerTimeFrameLookbackHighestHighBars, shPriceHTF)
shOpenBarIndexOneHTF := shOpenBarIndexHTF
if slPriceHTF and not slPriceHTF[1]
lowerTimeFrameLookbackLowestLowBars = (bar_index - slOpenBarIndexHTF)
lowestLowPassThrough = low[1]
lowerTimeFrameLookbackLowestLowBars1 = (slCloseBarIndexOneHTF - slOpenBarIndexOneHTF)
lowestLowPassThrough1 = low[(bar_index - slCloseBarIndexOneHTF)]
for e = 2 to lowerTimeFrameLookbackLowestLowBars by 1
if low[e] == slPriceHTF
lowestLowPassThrough := low[e]
lowerTimeFrameLookbackLowestLowBars := e
for f = (bar_index - slCloseBarIndexOneHTF) to (bar_index - slOpenBarIndexOneHTF) by 1
if low[f] == slPriceOneHTF
lowestLowPassThrough1 := low[f]
lowerTimeFrameLookbackLowestLowBars1 := f
line.set_xy1(htfTroughTrendline, bar_index - lowerTimeFrameLookbackLowestLowBars1, slPriceOneHTF)
line.set_xy2(htfTroughTrendline, bar_index - lowerTimeFrameLookbackLowestLowBars, slPriceHTF)
slOpenBarIndexOneHTF := slOpenBarIndexHTF
|
Three-Day Rolling Pivot | https://www.tradingview.com/script/94rwUtQr-Three-Day-Rolling-Pivot/ | weak_hand | https://www.tradingview.com/u/weak_hand/ | 106 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© weak_hand
//@version=5
indicator("Three-Day Rolling Pivot", "Rolling Pivot", overlay = true, max_lines_count = 500)
// ----------------------------------------------}
// PREDEFINED ROLLING TYPE
// ----------------------------------------------{
string type_grp = "--- Rolling Type"
string interval = input.string("D", "Calculation Interval", ["D", "W", "M"], "When changing to 'W' this will result in a weekly rolling pivot. Same goes for 'M' which will result in a monthly rolling pivot.\n\nDefault is 'D' for daily.\nMark Fisher used the default seetings back in the days.", group = type_grp)
int calc_amount = input.int(3, "Length", [2, 3, 4, 5, 6], "This is where you can select the amount of intervals which should take into account.\nFor example, default is 3 and this means a three days/week/month rolling pivot.\n\nThere is no 1 nor 7, cause this would result in daily and weekly Pivot Range.", group = type_grp)
bool speculations = input.bool(false, "Speculations", "When enabled this will calculated unpredictable results and should be avoided. It seems this will offset the lines by one day/week/month to the right.\nI dont know why this option exsist. But I use this sometimes to get less trading signals.", group = type_grp)
// ----------------------------------------------}
// FETCHING HISTORICAL DATA
// ----------------------------------------------{
[yesterday_open, yesterday_high, yesterday_low, yesterday_close, yesterday_bar_index] = request.security(syminfo.tickerid, interval, [open[1], high[1], low[1], close[1], bar_index[1]], lookahead = speculations ? barmerge.lookahead_off : barmerge.lookahead_on)
// ----------------------------------------------}
// FILL 1st UDT
// ----------------------------------------------{
type candle
float open
float high
float low
float close
int bar_index
new_candle = candle.new(yesterday_open, yesterday_high, yesterday_low, yesterday_close, yesterday_bar_index)
var candles = array.new<candle>()
if timeframe.change(interval)
candles.unshift(new_candle)
// ----------------------------------------------}
// FILL 2nd UDT
// ----------------------------------------------{
string col_grp = "--- Color and Shape"
color col_upper = input.color(color.lime, "Upper Line", group = col_grp)
color col_lower = input.color(color.maroon, "Lower Line", group = col_grp)
color col_bg = input.color(color.new(color.black, 80), "Background", group = col_grp)
string line_style = input.string(line.style_dashed, "Style of Lines", [line.style_dashed, line.style_dotted, line.style_solid], display = display.none, group = col_grp)
type rolling_pivot
float y_upper
float y_lower
int x_start
int x_stop
string xloc
line line_upper
line line_lower
linefill line_bg
var rolling_pivots = array.new<rolling_pivot>()
int time_session_open = time(interval)
int time_session_close = time_close(interval)
if timeframe.change(interval) and candles.size() >= calc_amount and ((interval == "D" and timeframe.isintraday) or interval != "D")
high_low = array.new<float>()
for counter = 0 to calc_amount - 1
high_low.unshift(candles.get(counter).high)
high_low.unshift(candles.get(counter).low)
float new_high = high_low.max()
float new_low = high_low.min()
float pivot = (new_high + new_low + candles.get(0).close) / 3
float hl2_3day = (new_high + new_low) / 2
float diff = math.max(pivot, hl2_3day) - math.min(pivot, hl2_3day)
float upper = math.round_to_mintick(pivot + diff)
float lower = math.round_to_mintick(pivot - diff)
line line_upper = line.new(time_session_open, upper, time_session_close, upper, xloc.bar_time, extend.none, col_upper, line_style, 2)
line line_lower = line.new(time_session_open, lower, time_session_close, lower, xloc.bar_time, extend.none, col_lower, line_style, 2)
linefill line_bg = linefill.new(line_upper, line_lower, col_bg)
rolling_pivots.unshift(rolling_pivot.new(upper, lower, time_session_open, time_session_close, xloc.bar_time, line_upper, line_lower, line_bg))
// ----------------------------------------------}
// OUTPUT
// ----------------------------------------------{
float latest_upper = rolling_pivots.size() > 0 ? rolling_pivots.get(0).y_upper : na
float latest_lower = rolling_pivots.size() > 0 ? rolling_pivots.get(0).y_lower : na
plot_upper = plot(latest_upper, " High", col_upper, display = display.all - display.pane, editable = false)
plot_lower = plot(latest_lower, " Low", col_lower, display = display.all - display.pane, editable = false)
// ----------------------------------------------}
// TRIM ARRAYS
// ----------------------------------------------{
int max_rolling_pivots_back = input.int(15, "Max Rolling Pivots Back", 1, 250, group = type_grp)
if rolling_pivots.size() > max_rolling_pivots_back
old_rolling_pivot = rolling_pivots.pop()
old_rolling_pivot.line_upper.delete()
old_rolling_pivot.line_lower.delete()
old_rolling_pivot.line_bg.delete()
if candles.size() > max_rolling_pivots_back + 2
candles.pop()
// ----------------------------------------------}
// ALERTS
// ----------------------------------------------{
string alarm_grp = "--- Alarm"
string alarm_text = input.text_area("Price touched Three-Day Rolling Pivot", "Display Text", group = alarm_grp)
string alarm_freq = input.string(alert.freq_once_per_bar_close, "Frequency", [alert.freq_all, alert.freq_once_per_bar, alert.freq_once_per_bar_close], display = display.none, group = alarm_grp)
if ta.crossunder(close, latest_upper) or ta.crossover(close, latest_lower)
alert(alarm_text, alert.freq_once_per_bar)
// ----------------------------------------------}
// DEBUG
// ----------------------------------------------{
//import weak_hand/Debug/2 as debug
//if candles.size() > 0
//ebug.label_on_last_bar(str.tostring(candles.get(0).bar_index) + "\n" + str.tostring(bar_index), high)
|
RedK DIY ZLMA: Customizable Zero-Lag MA (Educational / Utility) | https://www.tradingview.com/script/Gj3CgIso-RedK-DIY-ZLMA-Customizable-Zero-Lag-MA-Educational-Utility/ | RedKTrader | https://www.tradingview.com/u/RedKTrader/ | 186 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© RedKTrader
//@version=5
// customize your own ZLMA using 3-pass MAs and get the 1-line formula to use in other scripts
// Some common MA's use this technique to decreae the lagging effect (for example, Hull MA)
// Though HMA uses 2 MA's of different lengths of the same source data series
// Also TEMA (triple EMA) works slightly differently
// So you can't get this ZLMA to become exaclt equivalent to an HMA or a TEMA
// To-do List for next updates:
// add offest
// add 2 colors
// add alerts
// can't use timeframe = "" here to support MTF due to the existance of a table - unless we commented the table section below
indicator("Customizable ZLMA v1.0", shorttitle="DIY_ZLMA v1.0", overlay = true) //, timeframe = "", timeframe_gaps = false)
//======================================================================================================================
// Prep Section
//======================================================================================================================
// ***********************************************************************************************************
// This function (method) calcualtes a user-defined moving average type
method GetAverage(float _data, string MAOption, int _len) =>
float value = 0.0
SMA = ta.sma(_data, _len)
EMA = ta.ema(_data, _len)
HMA = ta.hma(_data, _len)
RMA = ta.rma(_data, _len)
WMA = ta.wma(_data, _len)
value := switch MAOption
'SMA' => SMA
'EMA' => EMA
'HMA' => HMA
'RMA' => RMA
=> WMA
// ***********************************************************************************************************
// This is a generic MovingAverage UDT - used as a template for the 3 MA's the user will customize
// and we will use later in the My_ZLMA calculation
type MovingAverage
float Source
string Type
float Value
//======================================================================================================================
// Input Section
//======================================================================================================================
// first moving average is the Base MA
BaseMA = MovingAverage.new()
grp_1 = "1. Base MA"
line_1 = "Base MA"
BaseMA.Source := input.source(close, "Source", inline = line_1, group = grp_1)
var int Length1 = input.int(10, 'Length', minval = 1, inline = line_1, group = grp_1)
BaseMA.Type := input.string( 'WMA', title = 'MA type',
options = ['WMA', 'EMA', 'SMA', 'HMA', 'RMA'], inline = line_1, group = grp_1)
// second moving average calulcates an MA of the BaseMA, the displacement between the 2 MAs (delta) is then used to create a "de-lag" effect
// we will call this the "de-lagging MA"
// we can additionally manipulate delta with a magnification factor (1 = no magnification) to increase/decrease the de-lagging effect
// too much de-lagging (usually > 2.0) will cause an overshoot of the MA - so we'll restrict it to 2.0 - acts more like "fine-tuning"
// magnification of 0 means that we're not using any de-lagging .. so it's like completely skipping this MA and only using smoothing
MA2 = MovingAverage.new()
grp_2 = "2. De-lagging"
line_2 = "De-lagging MA"
var int Length2 = input.int(5, 'Length', minval = 1, inline = line_2, group = grp_2)
MA2.Type := input.string( 'SMA', title = 'MA type',
options = ['WMA', 'EMA', 'SMA', 'HMA', 'RMA'], inline = line_2, group = grp_2)
delta_mag = input.float(1.40, "Magnification", minval = 0.0, maxval = 2.0, step = 0.05, group = grp_2)
// the third MA is used for smoothing the final ZLMA - it's simply an MA of the resulting MA from prior phase
MA3 = MovingAverage.new()
grp_3 = "3. Smoothing"
line_3 = "Smoothing"
UseSmoothing = input.bool(true, "Use Smoothing ?", inline = line_3, group = grp_3)
var int Length3 = input.int(3, 'Length', minval = 1, inline = line_3, group = grp_3)
MA3.Type := input.string( 'WMA', title = 'MA type',
options = ['WMA', 'EMA', 'SMA', 'HMA', 'RMA'], inline = line_3, group = grp_3)
grp_4 = "4. Other Settings"
line_4 = "ZMLA Formula"
DualColor = input.bool(true, "Dual Color ZLMA ?", group = grp_4)
ShowMAString = input.bool(false, 'Show My_ZLMA Formula ?', inline = line_4, group = grp_4)
c_ZLMA_String = input.color(color.yellow, "Color", inline = line_4, group = grp_4)
var int offset = input.int(0, "Offset", group = grp_4)
//======================================================================================================================
// Calculations
//======================================================================================================================
// we use the GetAverage() method to calculate 1st (base) MA, using the source selected by user
BaseMA.Value := BaseMA.Source.GetAverage(BaseMA.Type, Length1)
// we use the GetAverage() method again to calculate 2nd MA, using the value of the BaseMA as a source
MA2.Value := BaseMA.Value.GetAverage(MA2.Type, Length2)
// Calculate the intermediate ZLMA by using the "magnified" displacement to "de-lag" the BaseMA
ZLMA_2 = BaseMA.Value + delta_mag * (BaseMA.Value - MA2.Value)
// we use the GetAverage() method to calculate the final MA using the value of the intermediate ZLMA
MyZLMA = UseSmoothing ?
ZLMA_2.GetAverage(MA3.Type, Length3)
: ZLMA_2
//======================================================================================================================
// Colors & Plots
//======================================================================================================================
up = ta.change(MyZLMA) > 0
c_ZLMA = DualColor ? up ? #2196f3 : #f57f17 : color.blue
plot(MyZLMA, "My ZLMA", color = c_ZLMA, linewidth =3, offset = offset )
//======================================================================================================================
// Compile and show the 1-line MyZLMA Formula
//======================================================================================================================
//for example: this is the 1-line My_ZLMA formula, assuming all MA's are WMA's
//string = ta.wma(ta.wma(src, length_1) + delta * (ta.wma(src, length_1) - ta.wma(ta.wma(src, length_1), length_2)), length_3)
//plot(string, 'string', color.blue)
//************************************************************************
// here we compile the 1-line MyZLMA formula based on the customizations selected by user
// first MA pass, the BaseMA
_MA_str1 = 'ta.' + BaseMA.Type + '(src, ' + str.tostring(Length1) + ')'
// adding the 2nd pass which includes the delta magnification part
_MA_str2 = _MA_str1 + ' + ' + str.tostring(delta_mag) + ' * (' + _MA_str1 + ' - ' +
'ta.' + MA2.Type + '(' + _MA_str1 + ', ' + str.tostring(Length2) + '))'
// if no smoothing is applied, the 3rd MA pass is excluded from the MyZLMA formula line
_MA_str3 = UseSmoothing ?
'ta.' + MA3.Type + '(' + _MA_str2 + ', ' + str.tostring(Length3) + ')'
: _MA_str2
// convert all functions to lower case and compile final 1-line format
_MyZLMA_string = 'My_ZLMA = ' + str.lower(_MA_str3)
//************************************************************************
// show the 1-line MyZLMA formula using a quick table cell.
// Comment this part if MTF support is needed - then uncomment the timeframe = "" in script declaration
var table ShowMAFormula = table.new(position.top_right, 1, 1)
if barstate.islast and ShowMAString
table.cell(ShowMAFormula, 0, 0, _MyZLMA_string, text_color =c_ZLMA_String,
text_size = size.large, text_font_family = font.family_monospace) |
Leveraged Share Conversion Indicator | https://www.tradingview.com/script/TIXs33JM-Leveraged-Share-Conversion-Indicator/ | Steversteves | https://www.tradingview.com/u/Steversteves/ | 16 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Steversteves
// Update Details: Last update: March 21st, 2023
// Next Update: June 1st, 2023
//@version=5
indicator("Leveraged Share Conversion Indicator")
// Select Leveraged Share
//UPRO
uprotospy = input.bool(false, title="UPRO to SPY", group="SPY")
spytoupro = input.bool(false, title="SPY to UPRO", group="SPY")
//SPXS
spxstospy = input.bool(false, title="SPXS to SPY", group="SPY")
spytospxs = input.bool(false, title="SPY to SPXS", group="SPY")
//SPXU
spxutospy = input.bool(false, title="SPXU to SPY", group="SPY")
spytospxu = input.bool(false, title="SPY to SPXU", group="SPY")
// QQQ
qqqtotqqq = input.bool(false, title="QQQ to TQQQ", group="QQQ")
tqqqtoqqq = input.bool(false, title="TQQQ to QQQ", group="QQQ")
//BTC
btctobito = input.bool(false, title="BTC to BITO", group="BTC")
bitotobtc = input.bool(false, title="BITO to BTC", group="BTC")
btctobiti = input.bool(false, title="BTC to BITI", group="BTC")
// IWM
iwmtotza = input.bool(false, title="IWM to TZA", group="IWM")
tzatoiwm = input.bool(false, title="TZA to IWM", group="IWM")
iwmtotna = input.bool(false, title="IWM to TNA", group="IWM")
tnatoiwm = input.bool(false, title="TNA to IWM", group="IWM")
// Alternative Ticker
usealtticker = input.bool(false, title="Use Alternative Ticker", group="Manual Conversion")
altnerativeticker = input.symbol("", title="Alternative Ticker", group="Manual Conversion")
// Manual Conversion
manualconversion = input.bool(false, title="Enable Manual Converison?", group="Manual Conversion")
manualclose = input.float(1, title="Manual Close Price", group="Manual Conversion")
manuallookback = input.int(10, title="Manual Conversion Lookback", group="Manual Conversion", tooltip="This is used for the correlation function")
// Ticker Inputs
btcclose = request.security("COINBASE:BTCUSD", "60", close, lookahead=barmerge.lookahead_on)
uproclose = request.security("BATS:UPRO", "60", close, lookahead=barmerge.lookahead_on)
spxuclose = request.security("BATS:SPXU", "60", close, lookahead=barmerge.lookahead_on)
spxsclose = request.security("BATS:SPXS", "60", close, lookahead=barmerge.lookahead_on)
spyclose = request.security("BATS:SPY", "60", close, lookahead=barmerge.lookahead_on)
bitoclose = request.security("BATS:BITO", "60", close, lookahead=barmerge.lookahead_on)
biticlose = request.security("BATS:BITI", "60", close, lookahead=barmerge.lookahead_on)
qqqclose = request.security("BATS:QQQ", "60", close, lookahead=barmerge.lookahead_on)
tqqclose = request.security("BATS:TQQQ", "60", close, lookahead=barmerge.lookahead_on)
tnaclose = request.security("BATS:TNA", "60", close, lookahead=barmerge.lookahead_on)
iwmclose = request.security("BATS:IWM", "60", close, lookahead=barmerge.lookahead_on)
tzaclose = request.security("BATS:TZA", "60", close, lookahead=barmerge.lookahead_on)
tickerclose = request.security(altnerativeticker, "60", close, lookahead=barmerge.lookahead_on)
curclose = request.security(syminfo.ticker, "60", close, lookahead=barmerge.lookahead_on)
// Colours
color red = color.new(color.red, 0)
color green = color.new(color.green,0)
color white = color.new(color.white, 0)
color blue = color.new(color.blue, 0)
color black = color.new(color.black, 0)
// Variables
var tickerucl = 0.0
var ticker = 0.0
var tickerlcl = 0.0
string tickerid = na
var se = 0.0
var conversionresult = ticker
var currentclose = 0.0
var currentcorrelation = 0.0
// UPRO calculcations
uprotospyconv = (uproclose * 2.144) + 312.098 // 5.65
spytouproconv = (spyclose * 0.451) - 139.301 // 2.59
if uprotospy
ticker := uprotospyconv
tickerucl := uprotospyconv + 5.65
tickerlcl := uprotospyconv - 5.65
tickerid := "Upro to SPY"
se := 5.65
currentclose := spyclose
currentcorrelation := ta.correlation(uproclose, spyclose, 10)
if uprotospy and manualconversion
ticker := (manualclose * 2.144) + 312.098
tickerucl := ticker + 5.65
tickerlcl := ticker - 5.65
if spytoupro
ticker := spytouproconv
tickerucl := spytouproconv + 2.59
tickerlcl := spytouproconv - 2.59
tickerid := "SPY to UPRO"
se := 2.59
currentclose := uproclose
currentcorrelation := ta.correlation(uproclose, spyclose, 10)
if spytoupro and manualconversion
ticker := (manualclose * 0.451) - 139.301
tickerucl := ticker + 2.59
tickerlcl := ticker - 2.59
// SPXS
spytospxscon = (spyclose * -0.198) + 99.287 // SE 0.81
spxstospycon = (spxsclose * -4.633) + 491.451 // 3.94
if spytospxs
ticker := spytospxscon
tickerucl := spytospxscon + 0.81
tickerlcl := spytospxscon - 0.81
tickerid := "SPY to SPXS"
se := 0.81
currentclose := spxsclose
currentcorrelation := ta.correlation(spyclose, spxsclose, 10)
if spytospxs and manualconversion
ticker := (manualclose * -0.198) + 99.287
tickerucl := ticker + 0.81
tickerlcl := ticker - 0.81
if spxstospy
ticker := spxstospycon
tickerucl := spxstospycon + 3.94
tickerlcl := spxstospycon - 3.94
tickerid := "SPXS to SPY"
se := 3.94
currentclose := spyclose
currentcorrelation := ta.correlation(spxsclose, spyclose, 10)
if spxstospy and manualconversion
ticker := (manualclose * -4.633) + 491.451
tickerucl := ticker + 3.94
tickerlcl := ticker - 3.94
// SPXU
spytospxucon = (spyclose * -0.134) + 69.466 // 1
spxutospycon = (spxuclose * -6.054) + 493.793 // 6.70
if spytospxu
ticker := spytospxucon
tickerucl := spytospxucon + 1
tickerlcl := spytospxucon - 1
tickerid := "SPY to SPXU"
se := 1
currentclose := spxuclose
currentcorrelation := ta.correlation(spyclose, spxuclose, 10)
if spytospxu and manualconversion
ticker := (manualclose * -0.134) + 69.466
tickerucl := ticker + 1
tickerlcl := ticker - 1
if spxutospy
ticker := spxutospycon
tickerucl := spxutospycon + 6.70
tickerlcl := spxutospycon - 6.70
tickerid := "SPXU to SPY"
se := 6.70
currentclose := spyclose
currentcorrelation := ta.correlation(spyclose, spxsclose, 10)
if spxutospy and manualconversion
ticker := (manualclose * -6.054) + 493.793
tickerucl := ticker + 6.70
tickerlcl := ticker - 6.70
// BTC to BITO
btctobitocon = (btcclose * -0.002) + 69.983 // se 2.82
bitotobtccon = (bitoclose * -420.074) + 35408.272 // 1407.78
if btctobito
ticker := btctobitocon
tickerucl := btctobitocon + 2.82
tickerlcl := btctobitocon - 2.82
tickerid := "BTC to BITO"
se := 2.82
currentclose := bitoclose
currentcorrelation := ta.correlation(btcclose, bitoclose, 10)
if btctobito and manualconversion
ticker := (manualclose * -0.002) + 69.983
tickerucl := ticker + se
tickerlcl := ticker - se
if bitotobtc
ticker := bitotobtccon
tickerucl := bitotobtccon + 1407.78
tickerlcl := bitotobtccon - 1407.78
tickerid := "BITO to BTC"
//conversionresult := ticker
se := 1407.78
currentclose := btcclose
currentcorrelation := ta.correlation(btcclose, bitoclose, 10)
// BTC to BITI
if btctobiti
se := 2.76
ticker := (btcclose * -0.00166236589174558) + 69.6339750232392
tickerucl := ticker + se
tickerlcl := ticker - se
tickerid := "BTC to BITI"
currentclose := biticlose
currentcorrelation := ta.correlation(btcclose, bitoclose, 10)
if btctobiti and manualconversion
ticker := (manualclose * -0.00166236589174558) + 69.6339750232392
tickerucl := ticker + se
tickerlcl := ticker - se
// QQQ to TQQQ
var qqqtotqqqbase = 0.527562726082778
var qqqtotqqqint = -128.128467285399 //se 3.51
var tqqqtoqqqbase = 1.84883620557836
var tqqqtoqqqint = 244.976170444663
if qqqtotqqq
se := 3.51
ticker := (qqqclose * qqqtotqqqbase) + qqqtotqqqint
tickerucl := ticker + se
tickerlcl := ticker - se
currentclose := tqqclose
tickerid := "QQQ to TQQQ"
currentcorrelation := ta.correlation(qqqclose, tqqclose, 10)
if qqqtotqqq and manualconversion
ticker := (manualclose * qqqtotqqqbase) + qqqtotqqqint
tickerucl := ticker + se
tickerlcl := ticker - se
if tqqqtoqqq
se := 6.58
ticker := (tqqclose * tqqqtoqqqbase) + tqqqtoqqqint
tickerucl := ticker + se
tickerlcl := ticker - se
tickerid := "TQQQ to QQQ"
currentclose := qqqclose
currentcorrelation := ta.correlation(qqqclose, tqqclose, 10)
if tqqqtoqqq and manualconversion
ticker := (manualclose * tqqqtoqqqbase) + tqqqtoqqqint
tickerucl := ticker + se
tickerlcl := ticker - se
// IWM
tnatoiwmbase = 1.0173534935394
tnatoiwmint = 142.159147225345 // se 3.89
iwmtotnabase = 0.860707288878205
iwmtotnaint = -117.118398640605 //se 3.58
if tnatoiwm
se := 3.89
ticker := (tnaclose * tnatoiwmbase) + tnatoiwmint
tickerucl := ticker + se
tickerlcl := ticker - se
tickerid := "TNA to IWM"
currentclose := iwmclose
currentcorrelation := ta.correlation(tnaclose, iwmclose, 10)
if tnatoiwm and manualconversion
ticker := (manualclose * tnatoiwmbase) + tnatoiwmint
tickerucl := ticker + se
tickerlcl := ticker - se
if iwmtotna
se := 3.58
ticker := (iwmclose * iwmtotnabase) + iwmtotnaint
tickerucl := ticker + se
tickerlcl := ticker - se
tickerid := "IWM to TNA"
currentclose := tnaclose
currentcorrelation := ta.correlation(iwmclose, tnaclose, 10)
if iwmtotna and manualconversion
ticker := (manualclose * iwmtotnabase) + iwmtotnaint
tickerucl := ticker + se
tickerlcl := ticker - se
// TZA
tzatoiwmbase = -2.61817049480552
tzatoiwmint = 286.538707884321 // se 14.79
iwmtotzabase = -0.190938510381163
iwmtotzaint = 71.2387218412078 // se 3.99
if tzatoiwm
se := 14.79
ticker := (tzaclose * tzatoiwmbase) + tzatoiwmint
tickerucl := ticker + se
tickerlcl := ticker - se
tickerid := "TZA to IWM"
currentclose := iwmclose
currentcorrelation := ta.correlation(tzaclose, iwmclose, 10)
if tzatoiwm and manualconversion
ticker := (manualclose * tzatoiwmbase) + tzatoiwmint
tickerucl := ticker + se
tickerlcl := ticker - se
if iwmtotza
se := 3.99
ticker := (iwmclose * iwmtotzabase) + iwmtotzaint
tickerucl := ticker + se
tickerlcl := ticker - se
tickerid := "IWM to TZA"
currentclose := tzaclose
currentcorrelation := ta.correlation(iwmclose, tzaclose, 10)
if iwmtotza and manualconversion
ticker := (manualclose * iwmtotzabase) + iwmtotzaint
tickerucl := ticker + se
tickerlcl := ticker - se
// Manual Conversion with undefined ticker, manual calculcation of linreg to avoid linreg function limitations
//y Variable
a = tickerclose[1]
b = tickerclose[2]
c = tickerclose[3]
d = tickerclose[4]
e = tickerclose[5]
f = tickerclose[6]
g = tickerclose[7]
h = tickerclose[8]
i = tickerclose[9]
j = tickerclose[10]
a2 = math.pow(a, 2)
b2 = math.pow(b, 2)
c2 = math.pow(c, 2)
d2 = math.pow(d, 2)
e2 = math.pow(e, 2)
f2 = math.pow(f, 2)
g2 = math.pow(g, 2)
h2 = math.pow(h, 2)
i2 = math.pow(i, 2)
j2 = math.pow(j, 2)
y = (a + b + c + d + e + f + g + h + i + j)
y2 = (a2 + b2 + c2 + d2 + e2 + f2 + g2 + h2 + i2 + j2)
// X Variable
aa = curclose[1]
bb = curclose[2]
cc = curclose[3]
dd = curclose[4]
ee = curclose[5]
ff = curclose[6]
gg = curclose[7]
hh = curclose[8]
ii = curclose[9]
jj = curclose[10]
aa2 = math.pow(aa, 2)
bb2 = math.pow(bb, 2)
cc2 = math.pow(cc, 2)
dd2 = math.pow(dd, 2)
ee2 = math.pow(ee, 2)
ff2 = math.pow(ff, 2)
gg2 = math.pow(gg, 2)
hh2 = math.pow(hh, 2)
ii2 = math.pow(ii, 2)
jj2 = math.pow(jj, 2)
x = (aa + bb + cc + dd + ee + ff + gg + hh + ii + jj)
x2 = (aa2 + bb2 + cc2 + dd2 + ee2 + ff2 + gg2 + hh2 + ii2 + jj2)
//xy
xy = (a * aa) + (b * bb) + (c * cc) + (d * dd) + (e * ee) + (f * ff) + (g * gg) + (h * hh) + (i * ii) + (j * jj)
b1 = xy - (x * y) / 10
bbb2 = x2 - (math.pow(x, 2) / 10)
slope = (b1 / bbb2)
abc = y - (slope * x)
abc1 = abc / 10
// Manual Correlation
mancor = ta.correlation(tickerclose, curclose, manuallookback)
manualconversionresult = (curclose * slope) + abc1
// Manual Standard Error
se10 = manualconversionresult[10] - tickerclose[10]
se9 = manualconversionresult[9] - tickerclose[9]
se8 = manualconversionresult[8] - tickerclose[8]
se7 = manualconversionresult[7] - tickerclose[7]
se6 = manualconversionresult[6] - tickerclose[6]
se5 = manualconversionresult[5] - tickerclose[5]
se4 = manualconversionresult[4] - tickerclose[4]
se3 = manualconversionresult[3] - tickerclose[3]
se2 = manualconversionresult[2] - tickerclose[2]
se1 = manualconversionresult[1] - tickerclose[1]
se10rt = math.pow(se10, 2)
se9rt = math.pow(se9, 2)
se8rt = math.pow(se8, 2)
se7rt = math.pow(se7, 2)
se6rt = math.pow(se6, 2)
se5rt = math.pow(se5, 2)
se4rt = math.pow(se4, 2)
se3rt = math.pow(se3, 2)
se2rt = math.pow(se2, 2)
se1rt = math.pow(se1, 2)
rtadd = (se10rt + se9rt + se7rt + se6rt + se5rt + se4rt + se3rt + se2rt + se1rt)
r1 = rtadd / (10 - 2)
r2 = math.sqrt(r1)
if usealtticker
ticker := manualconversionresult
currentcorrelation := mancor
currentclose := tickerclose
se := r2
tickerucl := ticker + r2
tickerlcl := ticker - r2
tickerid := str.tostring(altnerativeticker)
if usealtticker and manualconversion
ticker := (manualclose * slope) + abc1
tickerucl := ticker + se
tickerlcl := ticker - se
// Plot functions
plot(tickerucl, color=green)
plot(ticker, color=white)
plot(tickerlcl, color=red)
showTable = input.bool(true, "Show Table")
tablePosInput = input.string(title="Position", defval="Top Right", options=["Bottom Left", "Bottom Right", "Top Left", "Top Right"], tooltip="Select where you want the table to draw.")
var tablePos = tablePosInput == "Bottom Left" ? position.bottom_left : tablePosInput == "Bottom Right" ? position.bottom_right : tablePosInput == "Top Left" ? position.top_left : tablePosInput == "Top Right" ? position.top_right : na
var dataTable = table.new(tablePos, columns = 9, rows = 8, border_color = color.black, border_width = 2)
if showTable
table.cell(dataTable, 1, 1, text = "Ticker:", bgcolor = black, text_color = white)
table.cell(dataTable, 2, 1, text = str.tostring(tickerid), bgcolor = blue, text_color = white)
table.cell(dataTable, 1, 2, text = "Conversion Result:", bgcolor = black, text_color = white)
table.cell(dataTable, 2, 2, text = str.tostring(math.round(ticker, 2)), bgcolor = blue, text_color=white)
table.cell(dataTable, 1, 3, text = "Standard Error:", bgcolor = black, text_color=white)
table.cell(dataTable, 2, 3, text = str.tostring(math.round(se,2)), bgcolor=blue, text_color=white)
table.cell(dataTable, 1, 4, text = "+ Standard Error", bgcolor = black, text_color=white)
table.cell(dataTable, 2, 4, text = str.tostring(math.round(tickerucl, 2)), bgcolor = blue, text_color=white)
table.cell(dataTable, 1, 5, text = "- Standard Error", bgcolor = black, text_color=white)
table.cell(dataTable, 2, 5, text = str.tostring(math.round(tickerlcl, 2)), bgcolor = blue, text_color=white)
table.cell(dataTable, 1, 6, text = "Current Close", bgcolor = black, text_color = white)
table.cell(dataTable, 2, 6, str.tostring(math.round(currentclose)), bgcolor = blue, text_color = white)
table.cell(dataTable, 1, 7, text = "Current Correlation", bgcolor = black, text_color = white)
table.cell(dataTable, 2, 7, text = str.tostring(math.round(currentcorrelation,2)), bgcolor = blue, text_color = white) |
Balance Zone Extension | https://www.tradingview.com/script/RQlRPxVP-Balance-Zone-Extension/ | mcthatsme | https://www.tradingview.com/u/mcthatsme/ | 114 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© mcthatsme
//@version=5
indicator("Balance Zone Extension", overlay=true, max_lines_count=500)
//Inputs
balance_High = input.float (defval=3900, title="Top of Balance Zone")
balance_Low = input.float (defval=3790, title="Bottom of Balance Zone")
numLines = input.string(defval="8" , title="Number of Sections per Balance Zone", options=["2", "4", "8", "16", "32"], tooltip="How many times the box is halved. Warning: Max line limit is 500")
num_Boxes_Above = input.int (defval=2 , title="Number of Boxes Above Balance Zone")
num_Boxes_Below = input.int (defval=2 , title="Number of Boxes Below Balance Zone")
//Balance Zone Colors
balance_zone_color = input.color(defval=color.new(color.gray, 90) , title="Balance Zone Background Color", group="Balance Zone Colors")
even_zone_color = input.color(defval=color.new(color.blue, 90) , title="Even Zone Color" , group="Balance Zone Colors")
odd_zone_color = input.color(defval=color.new(color.yellow, 90), title="Odd Zone Color" , group="Balance Zone Colors")
HL_lineColor = input.color (defval=color.new(color.white, 50), title="Balance High/Low Line Color" , group="Line Colors")
HL_linewidth = input.int (defval=2 , title="Balance High/Low Line Thickness", group="Line Colors")
HL_styleOption = input.string( defval="solid (β)" , title='Balance High/Low Line Style' , group="Line Colors", options=["solid (β)", "dashed (β)", "dotted (β)"])
HL_lineStyle = (HL_styleOption == "dotted (β)") ? line.style_dotted :
(HL_styleOption == "dashed (β)") ? line.style_dashed :
line.style_solid
Half_lineColor = input.color (defval=color.new(color.yellow, 50), title="50% Line Color" , group="Line Colors")
Half_linewidth = input.int (defval=1 , title="50% Line Thickness", group="Line Colors")
Half_styleOption = input.string(defval="dashed (β)" , title='50% Line Style' , group="Line Colors", options=["solid (β)", "dashed (β)", "dotted (β)"])
Half_lineStyle = (Half_styleOption == "dotted (β)") ? line.style_dotted :
(Half_styleOption == "dashed (β)") ? line.style_dashed :
line.style_solid
Bal_lineColor = input.color (defval=color.new(color.blue, 50), title="Other Balance Line Color" , group="Line Colors")
Bal_linewidth = input.int (defval=1 , title="Other Balance Line Thickness", group="Line Colors")
Bal_styleOption = input.string(defval="dotted (β)" , title='Other Balance Line Style' , group="Line Colors", options=["solid (β)", "dashed (β)", "dotted (β)"])
Bal_lineStyle = (Bal_styleOption == "dotted (β)") ? line.style_dotted :
(Bal_styleOption == "dashed (β)") ? line.style_dashed :
line.style_solid
lines_Per_Box = str.tonumber(numLines)
sectionSize = 1/lines_Per_Box
balance_Vals = array.new_float(0)
var BALANCE_HIGH_LINES = array.new_line(0)
var BALANCE_LOW_LINES = array.new_line(0)
var BALANCE_50_LINES = array.new_line(0)
var BALANCE_LINES = array.new_line(0)
var LINE_FILLS = array.new_linefill(0)
//Value Calculations
balance_Range = balance_High - balance_Low
balance_50 = balance_Range / 2
if lines_Per_Box > 1
for i = 1 to lines_Per_Box - 1
if sectionSize * i != 0.5
array.push(balance_Vals, balance_Low + balance_Range * (i * 1/lines_Per_Box))
//Delete Lines before creating new ones
if array.size(BALANCE_HIGH_LINES) > 0
sizeArrHigh = array.size(BALANCE_HIGH_LINES) - 1
for i = sizeArrHigh to 0
line.delete(array.get(BALANCE_HIGH_LINES, i))
array.remove(BALANCE_HIGH_LINES, i)
if array.size(BALANCE_LOW_LINES) > 0
sizeArrLow = array.size(BALANCE_LOW_LINES) - 1
for i = sizeArrLow to 0
line.delete(array.get(BALANCE_LOW_LINES, i))
array.remove(BALANCE_LOW_LINES, i)
if array.size(BALANCE_LINES) > 0
sizeArrBal = array.size(BALANCE_LINES) - 1
for i = sizeArrBal to 0
line.delete(array.get(BALANCE_LINES, i))
array.remove(BALANCE_LINES, i)
if array.size(BALANCE_50_LINES) > 0
sizeArr50 = array.size(BALANCE_50_LINES) - 1
for i = sizeArr50 to 0
line.delete(array.get(BALANCE_50_LINES, i))
array.remove(BALANCE_50_LINES, i)
if array.size(LINE_FILLS) > 0
sizeArrLineFill = array.size(LINE_FILLS) - 1
for i = sizeArrLineFill to 0
linefill.delete(array.get(LINE_FILLS, i))
array.remove(LINE_FILLS, i)
//Add lines to chart based on user inputs
//Original Balance Zone lines
array.push(BALANCE_HIGH_LINES, line.new(bar_index, balance_High, bar_index[1], balance_High, color=HL_lineColor, style=HL_lineStyle,width=HL_linewidth, extend=extend.both))
array.push(BALANCE_LOW_LINES, line.new(bar_index, balance_Low , bar_index[1], balance_Low, color=HL_lineColor, style=HL_lineStyle,width=HL_linewidth, extend=extend.both))
array.push(BALANCE_50_LINES, line.new(bar_index, balance_Low + balance_50, bar_index[1], balance_Low + balance_50, color=Half_lineColor, style=Half_lineStyle, width=Half_linewidth, extend=extend.both))
if lines_Per_Box > 2
for j = 0 to array.size(balance_Vals) - 1
array.push(BALANCE_LINES , line.new(bar_index, array.get(balance_Vals, j), bar_index[1], array.get(balance_Vals, j), color=Bal_lineColor, style=Bal_lineStyle,width=Bal_linewidth, extend=extend.both))
//Balance zone color fill
array.push(LINE_FILLS, linefill.new(array.get(BALANCE_HIGH_LINES, 0), array.get(BALANCE_LOW_LINES, 0), balance_zone_color))
//For loops to cycle through balance zone extensions
if num_Boxes_Above > 0
for i = 1 to num_Boxes_Above
array.push(BALANCE_HIGH_LINES, line.new(bar_index, balance_High + balance_Range * i, bar_index[1], balance_High + balance_Range * i, color=HL_lineColor, style=HL_lineStyle,width=HL_linewidth, extend=extend.both))
array.push(BALANCE_50_LINES, line.new(bar_index, balance_Low + (balance_Range * i + balance_50), bar_index[1], balance_Low + (balance_Range * i + balance_50), color=Half_lineColor, style=Half_lineStyle, width=Half_linewidth, extend=extend.both))
if lines_Per_Box > 2
for j = 0 to array.size(balance_Vals) - 1
array.push(BALANCE_LINES, line.new(bar_index, array.get(balance_Vals, j) + balance_Range * i, bar_index[1], array.get(balance_Vals, j) + balance_Range * i, color=Bal_lineColor, style=Bal_lineStyle,width=Bal_linewidth, extend=extend.both))
if i % 2 == 1
array.push(LINE_FILLS, linefill.new(array.get(BALANCE_HIGH_LINES, i - 1), array.get(BALANCE_HIGH_LINES, i), odd_zone_color))
else
array.push(LINE_FILLS, linefill.new(array.get(BALANCE_HIGH_LINES, i - 1), array.get(BALANCE_HIGH_LINES, i), even_zone_color))
if num_Boxes_Below > 0
for i = 1 to num_Boxes_Below
array.push(BALANCE_LOW_LINES, line.new(bar_index, balance_Low - balance_Range * i, bar_index[1], balance_Low - balance_Range * i, color=HL_lineColor, style=HL_lineStyle,width=HL_linewidth, extend=extend.both))
array.push(BALANCE_50_LINES, line.new(bar_index, balance_Low - (balance_Range * i - balance_50), bar_index[1], balance_Low - (balance_Range * i - balance_50), color=Half_lineColor, style=Half_lineStyle, width=Half_linewidth, extend=extend.both))
if lines_Per_Box > 2
for j = 0 to array.size(balance_Vals) - 1
array.push(BALANCE_LINES, line.new(bar_index, array.get(balance_Vals, j) - balance_Range * i, bar_index[1], array.get(balance_Vals, j) - balance_Range * i, color=Bal_lineColor, style=Bal_lineStyle,width=Bal_linewidth, extend=extend.both))
if i % 2 == 1
array.push(LINE_FILLS, linefill.new(array.get(BALANCE_LOW_LINES, i - 1), array.get(BALANCE_LOW_LINES, i), odd_zone_color))
else
array.push(LINE_FILLS, linefill.new(array.get(BALANCE_LOW_LINES, i - 1), array.get(BALANCE_LOW_LINES, i), even_zone_color))
|
IOFin F-Score by zdmre | https://www.tradingview.com/script/da0KJmys-IOFin-F-Score-by-zdmre/ | zdmre | https://www.tradingview.com/u/zdmre/ | 34 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© zdmre
//@version=5
indicator('IOFin F-Score by zdmre', overlay = false, precision=0)
period = input.string('FY', 'Financial Period', options=['FQ', 'FY'], tooltip='FQ: Financial Quarter\nFY: Financial Year')
pb = request.financial(syminfo.tickerid,"BOOK_VALUE_PER_SHARE", period)
de = request.financial(syminfo.tickerid,"DEBT_TO_EQUITY", period)
pfcf= close/request.financial(syminfo.tickerid,"FREE_CASH_FLOW", period)
sgr = request.financial(syminfo.tickerid,'SUSTAINABLE_GROWTH_RATE', period)
peg = request.financial(syminfo.tickerid,'PEG_RATIO', period)
evtoebitda = request.financial(syminfo.tickerid,'ENTERPRISE_VALUE_EBITDA', period)
roe = request.financial(syminfo.tickerid,'RETURN_ON_EQUITY', period)
roic = request.financial(syminfo.tickerid,'RETURN_ON_INVESTED_CAPITAL', period)
qr = request.financial(syminfo.tickerid,'QUICK_RATIO', period)
opmar = request.financial(syminfo.tickerid,'OPERATING_MARGIN', period)
pb_ = na(pb) ? na : pb < 3 ? 1 : 0
de_ = na(de) ? na : de < 0.5 ? 1 : 0
pfcf_ = na(pfcf) ? na : (pfcf > 0) and (pfcf <= 20) ? 1 : 0
sgr_ = na(sgr) ? na : sgr > 0.3 ? 1 : 0
peg_ = na(peg) ? na : (peg > 0) and (peg < 1) ? 1 : 0
evtoebitda_ = na(evtoebitda) ? na : evtoebitda < 10 ? 1 : 0,
roe_ = na(roe) ? na : roe > 0.3 ? 1 : 0
roic_ = na(roic) ? na : roic > 0.07 ? 1 : 0
qr_ = na(qr) ? na : qr >= 1 ? 1 : 0
opmar_ = na(opmar) ? na : opmar > 0.15 ? 1 : 0
iofinf = pb_ + de_ + pfcf_ + sgr_ + peg_ + evtoebitda_ + roe_ + roic_ + qr_ + opmar_
io_c = color.from_gradient(iofinf, 2, 9 , color.new(#f64343, 0), color.new(#41fc47, 0))
if barstate.islast
label.new(bar_index, iofinf, text="IOFin F-Score: " + str.tostring(iofinf), size = size.normal, textcolor=color.rgb(0, 0, 0), style=label.style_label_left, color = io_c)
plot(iofinf,style=plot.style_stepline_diamond, linewidth=4, join=true, color = io_c) |
CPR Weekly Variable Weekday Seller | https://www.tradingview.com/script/gBoRFvpx-CPR-Weekly-Variable-Weekday-Seller/ | DeuceDavis | https://www.tradingview.com/u/DeuceDavis/ | 133 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© DeuceDavis
//@version=5
indicator("CPR Weekly Variable Weekday Seller", overlay=true)
tradeSource = input.source(close, title='Source For Trigger')
weekdayExpiry = input.string(defval = "Friday", title="Expiry Day", options=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"])
nearStrikeMethod = input.string('Traditional Pivot S1/R1',
title="Near Strike Calculation Source",
options=['Traditional Pivot S1/R1',
'Camarilla Pivot R1/S1',
'Camarilla Pivot R2/S2',
'Manual Offset From Central Pivot Point'],
group="Near Strike Calculation Method")
nearStrikeManualOffset = input.float(0, "Manual Offset Value", group="Near Strike Calculation Method")
spreadMethod = input.string('Auto', title='Determine Spread', options=['Auto', 'Manual'], group='Spread Method')
manSpreadValue = input.float(5.0, title="Spread Width, if Manual", group='Spread Method')
showPriorDayHiLo = input.bool(false, title='Show Prior Day High and Low', group='Visual')
showCurrentWeekHiLo= input.bool(false, title='Show Current Week Highs and Lows', group='Visual')
priorDayHigh = request.security(syminfo.tickerid, 'D', high[1], lookahead=barmerge.lookahead_on)
priorDayLow = request.security(syminfo.tickerid, 'D', low[1], lookahead=barmerge.lookahead_on)
currentWeekHigh = request.security(syminfo.tickerid, 'W', high, lookahead=barmerge.lookahead_on)
currentWeekLow = request.security(syminfo.tickerid, 'W', low, lookahead=barmerge.lookahead_on)
pdHigh = plot(showPriorDayHiLo ? priorDayHigh : na, title="Prior Day High", color=color.new(color.red, 0))
pdLow = plot(showPriorDayHiLo ? priorDayLow : na, title="Prior Day Low", color=color.new(color.green, 0))
cwHigh = plot(showCurrentWeekHiLo ? currentWeekHigh : na, title="Current Week High", color=color.new(color.red, 0))
cwLow = plot(showCurrentWeekHiLo ? currentWeekLow : na, title="Current Week Low", color=color.new(color.green, 0))
//pivotPeriodShift =input.int(defval=1, title='Lookback Period for Pivot', group='Primary Settings')
pivotPeriodShift = 1
sendStandardAlert = input.bool(false, title='Enable Standard Alert', group='Alerts')
sendDiscordWebhookAlert = input.bool(false, title='Enable Discord Webhook Alert', group='Alerts')
sendPremiumZoneChangeAlert = input.bool(false, title='Enable Price Movement Into Different Zone', group='Alerts')
plotTS1R1 = input.bool(false, title='Plot Traditional Pivot R1/S1', group='Traditional Pivot Plots')
plotTS2R2 = input.bool(false, title='Plot Traditional Pivot R2/S2', group='Traditional Pivot Plots')
plotTS3R3 = input.bool(false, title='Plot Traditional Pivot R3/S3', group='Traditional Pivot Plots')
plotCS1R1 = input.bool(false, title='Plot Camarilla Pivot R1/S1', group='Camarilla Pivot Plots')
plotCS2R2 = input.bool(false, title='Plot Camarilla Pivot R2/S2', group='Camarilla Pivot Plots')
plotCS3R3 = input.bool(false, title='Plot Camarilla Pivot R3/S3', group='Camarilla Pivot Plots')
plotCS4R4 = input.bool(false, title='Plot Camarilla Pivot R4/S4', group='Camarilla Pivot Plots')
plotCS5R5 = input.bool(false, title='Plot Camarilla Pivot R5/S5', group='Camarilla Pivot Plots')
tradeOnMon = input.bool(true, title='Mondays', group='Trade Days (Good for Dailies)')
tradeOnTue = input.bool(true, title='Tuesdays', group='Trade Days (Good for Dailies)')
tradeOnWed = input.bool(true, title='Wednesdays', group='Trade Days (Good for Dailies)')
tradeOnThu = input.bool(true, title='Thursdays', group='Trade Days (Good for Dailies)')
tradeOnFri = input.bool(true, title='Fridays', group='Trade Days (Good for Dailies)')
showHistoricalTradeLabel = input.bool(false, title='Show Historical Strike Value Labels', group='Visual')
showFuture = input.bool(false, title='Extend Developing Levels Into Future', group='Visual')
showHistoricalResults = input.bool(true, title='Show Historical Win/Loss Percentages', group='Visual')
backtestStartDate = input.time(timestamp("1 Jan 2020"),
title="Start Date", group="Backtest Time Period",
tooltip="This start date is in the time zone of the exchange " +
"where the chart's instrument trades. It doesn't use the time " +
"zone of the chart or of your computer.")
backtestEndDate = input.time(timestamp("1 Jan 2099"),
title="End Date", group="Backtest Time Period",
tooltip="This end date is in the time zone of the exchange " +
"where the chart's instrument trades. It doesn't use the time " +
"zone of the chart or of your computer.")
pivotTF = 'W'
//New Pivot Bar
is_newbar() =>
switch
dayofweek == dayofweek.monday and weekdayExpiry == "Monday" => true
dayofweek == dayofweek.tuesday and weekdayExpiry == "Tuesday" => true
dayofweek == dayofweek.wednesday and weekdayExpiry == "Wednesday" => true
dayofweek == dayofweek.thursday and weekdayExpiry == "Thursday" => true
dayofweek == dayofweek.friday and weekdayExpiry == "Friday" => true
=> false
var pivotTFHigh = 0.00
var pivotTFLow = 0.00
var pivotTFClose = 0.00
var curHigh = 0.00
var curLow = 0.00
var curClose = 0.00
curHigh := high > curHigh ? high : curHigh
curLow := low < curLow ? low : curLow
curClose := close
if is_newbar()[1] and not is_newbar()
pivotTFHigh := curHigh[1]
pivotTFLow := curLow[1]
pivotTFClose := curClose[1]
curHigh := high
curLow := low
curClose := close
priorPivotTFHigh = request.security(syminfo.tickerid, pivotTF, high[pivotPeriodShift + 1], lookahead=barmerge.lookahead_on)
priorPivotTFLow = request.security(syminfo.tickerid, pivotTF, low[pivotPeriodShift + 1], lookahead=barmerge.lookahead_on)
priorPivotTFClose = request.security(syminfo.tickerid, pivotTF, close[pivotPeriodShift + 1], lookahead=barmerge.lookahead_on)
RANGE = pivotTFHigh- pivotTFLow
//CPR Calculations
centralPivot = (pivotTFHigh + pivotTFLow + pivotTFClose) / 3
tempBottomPivot = (pivotTFHigh + pivotTFLow) / 2
tempTopPivot = (centralPivot - tempBottomPivot) + centralPivot
bottomPivot = (tempBottomPivot > tempTopPivot) ? tempTopPivot : tempBottomPivot
topPivot = bottomPivot == tempBottomPivot ? tempTopPivot : tempBottomPivot
cprRange = topPivot - bottomPivot
//Traditional Pivot Point Calculations
tS1 = 2 * centralPivot - pivotTFHigh
tS2 = centralPivot - (pivotTFHigh - pivotTFLow)
tS3 = tS1 - (pivotTFHigh - pivotTFLow)
tR1 = 2 * centralPivot - pivotTFLow
tR2 = centralPivot + (pivotTFHigh - pivotTFLow)
tR3 = tR1 + (pivotTFHigh - pivotTFLow)
//Camarilla Pivot Point Calculations
camR5 = pivotTFHigh / pivotTFLow * pivotTFClose
camR4 = pivotTFClose + RANGE * 1.1 / 2
camR3 = pivotTFClose + RANGE * 1.1 / 4
camR2 = pivotTFClose + RANGE * 1.1 / 6
camR1 = pivotTFClose + RANGE * 1.1 / 12
camS1 = pivotTFClose - RANGE * 1.1 / 12
camS2 = pivotTFClose - RANGE * 1.1 / 6
camS3 = pivotTFClose - RANGE * 1.1 / 4
camS4 = pivotTFClose - RANGE * 1.1 / 2
camS5 = pivotTFClose - (camR5 - pivotTFClose)
//spreadValue Floor & Ceiling
spreadValueCalc(calcValue, spreadValue, callOrPutSide) =>
var retValue = 0.00
switch
callOrPutSide == 'Call' => retValue := (math.ceil(calcValue/spreadValue)) * spreadValue
callOrPutSide == 'Put' => retValue := (math.floor(calcValue/spreadValue)) * spreadValue
//Strike Values
spreadValue = spreadMethod == "Auto" ? close >= 1000 ? 50.0 :
close >= 500 ? 10.0 :
close >= 100 ? 5.0 :
close >= 50 ? 2.5 :
close >= 20 ? 1 :
close < 20 ? 0.5 : 0
:
manSpreadValue
callTriggerValue = nearStrikeMethod == 'Traditional Pivot S1/R1' ? tS1 :
nearStrikeMethod == 'Camarilla Pivot R1/S1' ? camS1 :
nearStrikeMethod == 'Camarilla Pivot R2/S2' ? camS2 :
centralPivot
putTriggerValue = nearStrikeMethod == 'Traditional Pivot S1/R1' ? tR1 :
nearStrikeMethod == 'Camarilla Pivot R1/S1' ? camR1 :
nearStrikeMethod == 'Camarilla Pivot R2/S2' ? camR2 :
centralPivot
callNearStrikeSource = nearStrikeMethod == 'Traditional Pivot S1/R1' ? math.max(pivotTFHigh, tR1) :
nearStrikeMethod == 'Camarilla Pivot R1/S1' ? math.max(pivotTFHigh, camR1) :
nearStrikeMethod == 'Camarilla Pivot R2/S2' ? math.max(pivotTFHigh, camR2) :
centralPivot + nearStrikeManualOffset
putNearStrikeSource = nearStrikeMethod == 'Traditional Pivot S1/R1' ? math.min(pivotTFLow, tS1) :
nearStrikeMethod == 'Camarilla Pivot R1/S1' ? math.min(pivotTFLow, camS1) :
nearStrikeMethod == 'Camarilla Pivot R2/S2' ? math.min(pivotTFLow, camS2) :
centralPivot - nearStrikeManualOffset
calcCallValue = close < callTriggerValue ? topPivot : math.avg(centralPivot, callNearStrikeSource)
callStrikeValue = spreadValueCalc(calcCallValue, spreadValue, 'Call')
callStrikeValue2 = callStrikeValue + spreadValue
calcPutValue = close > putTriggerValue ? bottomPivot : math.avg(centralPivot, putNearStrikeSource)
putStrikeValue = spreadValueCalc(calcPutValue, spreadValue, 'Put')
putStrikeValue2 = putStrikeValue - spreadValue
icCallStrikeValue = spreadValueCalc(tR1,spreadValue, 'Call')
icCallStrikeValue2 = icCallStrikeValue + spreadValue
icPutStrikeValue = spreadValueCalc(tS1, spreadValue, 'Put')
icPutStrikeValue2 = icPutStrikeValue - spreadValue
plot(callStrikeValue, "Current Call", style=plot.style_line, color=color.new(color.orange, 75))
plot(putStrikeValue, "Current Put", style=plot.style_line, color=color.new(color.orange, 75))
//Plots
//Central Pivot Range
plot(topPivot, "CP Top", style=plot.style_circles)
plot(centralPivot, "Central Pivot", style=plot.style_cross, linewidth=2, color=color.orange)
plot(bottomPivot, "CP Bottom", style=plot.style_circles)
//Traditional Pivots
plot(plotTS1R1 ? tR1 : na, "tR1", style=plot.style_circles, color=color.red)
plot(plotTS1R1 ? tS1 : na, "tS1", style=plot.style_circles, color=color.green)
plot(plotTS2R2 ? tR2 : na, "tR2", style=plot.style_circles, color=color.new(color.red, 30))
plot(plotTS2R2 ? tS2 : na, "tS2", style=plot.style_circles, color=color.new(color.green, 30))
plot(plotTS3R3 ? tR3 : na, "tR3", style=plot.style_circles, color=color.new(color.red, 60))
plot(plotTS3R3 ? tS3 : na, "tS3", style=plot.style_circles, color=color.new(color.green, 60))
//
plot(plotCS3R3 ? camR3 : na, "cR3",style=plot.style_line, color=color.red)
plot(plotCS3R3 ? camS3 : na, "cS3", style=plot.style_line, color=color.green)
plot(plotCS1R1 ? camR1 : na, "cR1",style=plot.style_line, color=color.new(color.red, 75))
plot(plotCS1R1 ? camS1 : na, "cS1", style=plot.style_line, color=color.new(color.green, 75))
plot(plotCS2R2 ? camR2 : na, "cR2",style=plot.style_line, color=color.new(color.red, 90))
plot(plotCS2R2 ? camS2 : na, "cS2", style=plot.style_line, color=color.new(color.green, 90))
plot(plotCS4R4 ? camR4 : na, "cR4",style=plot.style_line, color=color.new(color.red, 25))
plot(plotCS4R4 ? camS4 : na, "cS4", style=plot.style_line, color=color.new(color.green, 25))
plot(plotCS5R5 ? camR5 : na, "cR5",style=plot.style_line, color=color.new(color.red, 90))
plot(plotCS5R5 ? camS5 : na, "cS5", style=plot.style_line, color=color.new(color.green, 90))
openingBarClosed = is_newbar()[1] and not is_newbar()
openingBarOpen = is_newbar() and not is_newbar()[1]
//Trade Calculations {{LEGACY}}
string tradeType = switch
tradeSource > centralPivot => "Sell Put"
tradeSource < centralPivot => "Sell Call"
(tradeSource < topPivot and tradeSource > bottomPivot) => "Sell IC"
var tradeDecision = "No Trade"
var strikeValue = 0.00
var strikeValue2 = 0.00
var yPlacement = 0.00
var labelStyle = label.style_label_lower_right
var tradeLabelText = "None"
var alertText ="None"
inBacktestRange = time >= backtestStartDate and
time <= backtestEndDate
if openingBarClosed[1] and not openingBarClosed and inBacktestRange
tradeDecision := tradeType[1]
strikeValue :=
tradeDecision == "Sell Put" ? putStrikeValue[1] :
tradeDecision == "Sell Call" ? callStrikeValue[1] :
tradeDecision == "Sell IC" ? icCallStrikeValue[1] : na
strikeValue2 :=
tradeDecision == "Sell Put" ? putStrikeValue2[1] :
tradeDecision == "Sell Call" ? callStrikeValue2[1] :
tradeDecision == "Sell IC" ? icPutStrikeValue[1] : na
tradeLabelText := tradeDecision + ' for ' + str.tostring(strikeValue, '#.##')
yPlacement :=
tradeDecision == "Sell Put" ? putStrikeValue[1] :
tradeDecision == "Sell Call" ? callStrikeValue[1] :
tradeDecision == "Sell IC" ? icCallStrikeValue[1] : na
labelStyle :=
tradeDecision == "Sell Put" ? label.style_label_upper_left:
tradeDecision == "Sell Call" ? label.style_label_lower_left:
tradeDecision == "Sell IC" ? label.style_label_lower_left: label.style_label_lower_left
alertText :=
tradeDecision == "Sell Put" ?
"Sell Put Strike " + str.tostring(strikeValue, '#.##') + " | " +
"Buy Put Strike " + str.tostring(strikeValue2, '#.##') :
tradeDecision == "Sell Call" ?
"Sell Call Strike " + str.tostring(strikeValue, '#.##') + " | " +
"Buy Call Strike " + str.tostring(strikeValue2, '#.##') :
tradeDecision == "Sell IC" ?
"IC | Sell Call Strike " + str.tostring(icCallStrikeValue, '#.##') + " | " +
"Buy Call Strike " + str.tostring(icCallStrikeValue2, '#.##') + " | " +
"Sell Put Strike " + str.tostring(icPutStrikeValue, '#.##') + " | " +
"Buy Put Strike " + str.tostring(icPutStrikeValue2, '#.##') : na
if showHistoricalTradeLabel or (openingBarClosed[1])
label.new(x=bar_index, y=yPlacement, color=color.new(color.blue,50),
textcolor=color.white, size=size.small,
style=labelStyle,
text=alertText)
alertText := "Ticker: " + syminfo.ticker + " - " + alertText
plot(( not openingBarOpen and inBacktestRange) ? strikeValue : na, "Strike Value", color=color.white, style=plot.style_circles)
//Prior Day Trade Result
var wins = 0
var losses = 0
var callWins = 0
var callLosses = 0
var icWins = 0
var icLosses = 0
var putWins = 0
var putLosses = 0
var callCount = 0
var icCount = 0
var putCount = 0
var tradeResult = "No Trade"
if openingBarClosed and inBacktestRange[1]
if tradeDecision[1] == "Sell Put"
wins := close[1] > strikeValue ? wins + 1 : wins
losses := close[1] < strikeValue ? losses + 1 : losses
tradeResult := close[1] > strikeValue ? "Win" : "Loss"
putWins := close[1] > strikeValue ? putWins + 1 : putWins
putLosses := close[1] < strikeValue ? putLosses + 1 : putLosses
putCount := putCount + 1
if tradeDecision[1] == "Sell Call"
wins := close[1] < strikeValue ? wins + 1 : wins
losses := close[1] > strikeValue ? losses + 1 : losses
tradeResult := close[1] < strikeValue ? "Win" : "Loss"
callWins := close[1] < strikeValue ? callWins + 1 : callWins
callLosses := close[1] > strikeValue ? callLosses + 1 : callLosses
callCount := callCount + 1
label.new(x=bar_index -1, y=yPlacement[1], color=color.new(tradeResult == "Win" ? color.green : color.red,50),
textcolor=color.white, size=size.small,
style=labelStyle,
text=tradeResult)
// Results & Current Trade
string premiumValue = switch
(strikeValue < bottomPivot and close < bottomPivot) or
(strikeValue > topPivot and close > topPivot) => "Optimal (Hedge)"
(strikeValue < bottomPivot and close < centralPivot) or
(strikeValue > topPivot and close > centralPivot) => "Good"
(strikeValue < bottomPivot and close < topPivot) or
(strikeValue > topPivot and close > bottomPivot) => "Decent"
=> "Standard"
var table resultsDisplay = table.new(position.bottom_right, 4, 4)
var table currentSetup = table.new(position.top_right, 2, 3)
if barstate.islast
var tfLabelText ="nothing"
tfLabelText := '----Current Setup----\n\n'
tfLabelText := tfLabelText + 'Pivot Timeframe: ' + pivotTF
tfLabelText := tfLabelText + '\n' + tradeLabelText
table.cell(currentSetup, 0, 0, 'Pivot TF', text_color=color.white)
table.cell(currentSetup, 1, 0, pivotTF, text_color=color.white)
table.cell(currentSetup, 0, 1, tradeDecision, text_color=color.white)
table.cell(currentSetup, 1, 1, str.tostring(strikeValue, '#.##'), text_color=color.white)
table.cell(currentSetup, 0, 2, 'Timing', text_color=color.white)
table.cell(currentSetup, 1, 2, premiumValue, text_color=color.white)
//Plot Future Values
// We only populate the table on the last bar.
if showHistoricalResults
table.cell(resultsDisplay, 1, 0, 'Trades', text_color=color.white)
table.cell(resultsDisplay, 2, 0, 'Wins', text_color=color.white)
table.cell(resultsDisplay, 3, 0, 'Win %', text_color=color.white)
table.cell(resultsDisplay, 0, 1, 'All', text_color=color.white)
table.cell(resultsDisplay, 1, 1, str.tostring(wins+losses, '#'), text_color=color.white)
table.cell(resultsDisplay, 2, 1, str.tostring(wins, '#'), text_color=color.white)
table.cell(resultsDisplay, 3, 1, str.tostring(wins/(wins+losses)*100, '#.#') , text_color=color.white)
table.cell(resultsDisplay, 0, 2, 'Calls', text_color=color.white)
table.cell(resultsDisplay, 1, 2, str.tostring(callWins + callLosses, '#'), text_color=color.white)
table.cell(resultsDisplay, 2, 2, str.tostring(callWins, '#') , text_color=color.white)
table.cell(resultsDisplay, 3, 2, str.tostring(callWins/(callWins+callLosses)*100, '#.#') , text_color=color.white)
table.cell(resultsDisplay, 0, 3, 'Puts', text_color=color.white)
table.cell(resultsDisplay, 1, 3, str.tostring(putWins + putLosses, '#'), text_color=color.white)
table.cell(resultsDisplay, 2, 3, str.tostring(putWins, '#') , text_color=color.white)
table.cell(resultsDisplay, 3, 3, str.tostring(putWins/(putWins + putLosses)*100, '#.#') , text_color=color.white)
// table.cell(resultsDisplay, 0, 4, 'ICs', text_color=color.white)
// table.cell(resultsDisplay, 1, 4, str.tostring(icWins + icLosses, '#'), text_color=color.white)
// table.cell(resultsDisplay, 2, 4, str.tostring(icWins, '#') , text_color=color.white)
// table.cell(resultsDisplay, 3, 4, str.tostring(icWins/(icWins + icLosses)*100, '#.#') , text_color=color.white)
//Alerts
sendAlert = close < 6000
webHookAlertMessage = '{\"content\":\"' + alertText + '\"}'
//{"content":"{{ticker}} Long Entry Triggered | Open: {{open}} | Close: {{close}} | Low: {{low}} |High: {{high}}"}
if (sendStandardAlert and openingBarClosed)
alert(alertText, alert.freq_once_per_bar)
if (sendDiscordWebhookAlert and openingBarClosed)
alert(webHookAlertMessage, alert.freq_once_per_bar)
|
Trading Checklist - Sonarlab | https://www.tradingview.com/script/1wm71JZK-Trading-Checklist-Sonarlab/ | Sonarlab | https://www.tradingview.com/u/Sonarlab/ | 696 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Sonarlab
//@version=5
indicator("Trading Checklist - Sonarlab", shorttitle="Trading Checklist - Sonarlab", overlay=true)
//------------------------------------------------------------------------------------
// Trading Checklist
//------------------------------------------------------------------------------------
_titleGrp = "Title"
_TitleTxt = input.string("Trading Checklist", "Title", inline="1", group=_titleGrp)
title_text_color = input.color(#14a9e4b0, "", inline="1", group=_titleGrp)
_titleTextSize = input.string('Large', 'Text Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group=_titleGrp)
titleTextSize = _titleTextSize == 'Auto' ? size.auto : _titleTextSize == 'Tiny' ? size.tiny : _titleTextSize == 'Small' ? size.small : _titleTextSize == 'Normal' ? size.normal : _titleTextSize == 'Large' ? size.large : size.huge
_title_alignment = input.string('Center', 'Text Alignmentβ', group=_titleGrp, options=['Left', 'Center', 'Right'])
title_alignment = _title_alignment == "Left" ? text.align_left : _title_alignment == "Center" ? text.align_center : text.align_right
_bodyGrp = "Body"
_midTxt = input.text_area("TRADING PLAN\nβ
Trend Direction\nβ
Support & Resistance\n\nRISK MANAGEMENT\nβ
Risk 1%\n\nPSYCHOLOGY\nβ
Don't Chase!", "Body", group=_bodyGrp)
body_text_color = input.color(#d6d6d6b0, "Text Color", group=_bodyGrp)
bg_color = input.color(#00000000, "Background Color", group=_bodyGrp)
_bodyTextSize = input.string('Normal', 'Text Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group=_bodyGrp)
bodyTextSize = _bodyTextSize == 'Auto' ? size.auto : _bodyTextSize == 'Tiny' ? size.tiny : _bodyTextSize == 'Small' ? size.small : _bodyTextSize == 'Normal' ? size.normal : _bodyTextSize == 'Large' ? size.large : size.huge
_txt_alignment = input.string('Left', 'Text Alignmentβ', group=_bodyGrp, options=['Left', 'Center', 'Right'])
txt_alignment = _txt_alignment == "Left" ? text.align_left : _txt_alignment == "Center" ? text.align_center : text.align_right
_tableGrp = "Position"
_tableYpos = input.string('Top', 'ββ', inline='01', group=_tableGrp, options=['Top', 'Middle', 'Bottom'])
tableYpos = _tableYpos == "Top" ? "top" : _tableYpos == "Bottom" ? "bottom" : "middle"
_tableXpos = input.string('Right', 'ββββ', inline='01', group=_tableGrp, options=['Left', 'Center', 'Right'], tooltip='Position on the chart.')
tableXpos = _tableXpos == "Right" ? "right" : _tableXpos == "Center" ? "center" : "left"
// Draw Table
var tradingPanel = table.new(position= tableYpos + '_' + tableXpos , columns=1, rows=3, bgcolor=bg_color, border_width = 0)
if barstate.islast
// Title
table.cell(table_id=tradingPanel, column=0, row=0, text=_TitleTxt, text_size=titleTextSize, text_color=title_text_color, text_halign = title_alignment)
// Body
table.cell(table_id=tradingPanel, column=0, row=1, text=_midTxt, text_size=bodyTextSize, text_color=body_text_color, text_halign = txt_alignment)
|
Weis Wave Volume - Simple labels and comparison | https://www.tradingview.com/script/hcsDqW4W-Weis-Wave-Volume-Simple-labels-and-comparison/ | TonioVolcano | https://www.tradingview.com/u/TonioVolcano/ | 145 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Original version of this script from @the_MarketWhisperer and some other pieces of the script from @LucF. This version makes changes to the way the waves are calculated as well as changes to how it is displayed for a cleaner chart.
// Modifications by @TonioVolcano
//@version=5
indicator('Weis Wave Volume - Simple labels and comparisson', 'Weis-W', overlay=true)
// Inputs
trendReversalLength = input.int(2, 'Trend reversal length', minval=2, group='Wave Calc')
priceSource = input(close, 'Price source for trend detection', group='Wave Calc')
lastshown = input.int(defval=50, title='Labels for X last bars', group='Display')
isShowMarkers = input.bool(false, 'Show Pivot Markers', group='Display')
colorUpWaveVol = input.color(color.new(#29b13b, 0), 'Up Volume', group='Display')
colorDnWaveVol = input.color(color.new(#ff4800, 0), 'Down Volume', group='Display')
// Detect Price Waves
var trend = 0
var wave = 0
upOrDn = priceSource > priceSource[1] ? 1 : priceSource < priceSource[1] ? -1 : 0
trend := upOrDn != 0 and upOrDn != upOrDn[1] ? upOrDn : trend
reversalTrend = ta.rising(priceSource, trendReversalLength) or ta.falling(priceSource, trendReversalLength)
wave := trend != wave and reversalTrend ? trend : wave
bullWave = wave == 1
bearWave = wave == -1
sameWave = wave == wave[1]
poschange = wave[1] == -1 and wave == 1
negchange = wave[1] == 1 and wave == -1
// Wave calculations
var cumVolume = 0.0
cumVolume := sameWave ? cumVolume + volume : volume
var waveBars = 0
var lastWaveBars = 0
waveBars := sameWave ? waveBars + 1 : 1
averageWaveVolume = cumVolume / waveBars
var increasingBars = 0
increasingBars := sameWave ? averageWaveVolume > nz(averageWaveVolume[1]) ? increasingBars + 1 : 0 : 0
var wavesTot = 0
var wavesTotVol = 0.0
var wavesTotAvg = 0.0
var lastWaveHi = 0.0
// Update numbers when changing waves
if not sameWave
lastWaveBars := nz(waveBars[1])
lastWaveHi := cumVolume[1]
wavesTot += 1
wavesTotVol += nz(cumVolume[1])
wavesTotAvg := wavesTotVol / wavesTot
wavesTotAvg
// Label variables
C_DEFAULT = color.silver
wavestren = lastWaveHi > lastWaveHi[1] ? "o" : "u"
wavestren2 = cumVolume > lastWaveHi ? "[o]" : "[u]"
var label currentWaveLabel = na
var color labelColor = C_DEFAULT
var color textColor = C_DEFAULT
var string labelText = ''
var string labelTool = ''
labelStyle = label.style_none
xloc = bar_index
yloc = yloc.abovebar
label.delete(currentWaveLabel[lastshown])
if poschange
labelText := str.tostring(wavestren)
labelTool := str.tostring(int(lastWaveHi))
labelStyle := isShowMarkers ? label.style_arrowup : label.style_none
labelColor := colorDnWaveVol
textColor := colorDnWaveVol
xloc := bar_index - 1
yloc := yloc.belowbar
currentWaveLabel := label.new(xloc, close, yloc=yloc, color=labelColor, textcolor=textColor, style=labelStyle, text=labelText, tooltip=labelTool)
currentWaveLabel
else if negchange
labelText := str.tostring(wavestren)
labelTool := str.tostring(int(lastWaveHi))
labelStyle := isShowMarkers ? label.style_arrowdown : label.style_none
labelColor := colorUpWaveVol
textColor := colorUpWaveVol
xloc := bar_index - 1
yloc := yloc.abovebar
currentWaveLabel := label.new(xloc, close, yloc=yloc, color=labelColor, textcolor=textColor, style=labelStyle, text=labelText, tooltip=labelTool)
currentWaveLabel
// Label for current wave cumulative vol
colorWaveVol = bullWave ? colorUpWaveVol : bearWave ? colorDnWaveVol : na
var label currentWaveLabel2 = na
var color labelColor2 = C_DEFAULT
var color textColor2 = C_DEFAULT
var string labelText2 = ''
labelStyle2 = label.style_none
xloc2 = bar_index
yloc2 = yloc.price
label.delete(currentWaveLabel2)
if cumVolume > 0
labelText2 := str.tostring(wavestren2) + str.tostring(int(cumVolume))
labelStyle2 := label.style_none
labelColor2 := colorWaveVol
textColor2 := colorWaveVol
xloc2 := bar_index+3
yloc2 := yloc.price
currentWaveLabel2 := label.new(xloc2, close, yloc=yloc2, color=labelColor2, textcolor=textColor2, style=labelStyle2, text=labelText2)
currentWaveLabel2
|
RSI Divergence Method | https://www.tradingview.com/script/HvgoSImF-RSI-Divergence-Method/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 219 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© RozaniGhani-RG
//@version=5
indicator('RSI Divergence Method', 'RDM')
// 0. Inputs
// 1. Custom Functions
// 2. Variables
// 3. Plots
//#region ββββββββββββββββββββ 0. Inputs
src = input.source(close, 'Source / Length', inline = '0', group = 'RSI')
len = input.int( 14, '', inline = '0', group = 'RSI', minval = 1)
left = input.int( 5, 'Left / Right', inline = '1', group = 'Pivot Lookback')
right = input.int( 5, '', inline = '1', group = 'Pivot Lookback')
min = input.int( 5, 'Min / Max', inline = '2', group = 'Lookback Range')
max = input.int( 60, '', inline = '2', group = 'Lookback Range')
boolBigBull = input.bool(true, 'Big | Small', inline = '3', group = 'Bull')
boolKidBull = input.bool(true, '', inline = '3', group = 'Bull')
boolBigBear = input.bool(true, 'Big | Small', inline = '4', group = 'Bear')
boolKidBear = input.bool(true, '', inline = '4', group = 'Bear')
//#endregion
//#region ββββββββββββββββββββ 1. Custom Functions
// @type Used for divergence setup
// @field osc oscillator used such as rsi
// @field src source such as high or low
// @field right offset value for pivot
// @field min minimum bars for barssince
// @field max maximum bars for barssince
type setup
float osc = na
float right = na
int min = na
int max = na
// @function range between bars
// @param condition bars since
// @param min minimum bars
// @param max maximum bars
method rangeBetween(setup startUp = na, bool condition = true) =>
bars = ta.barssince(condition)
startUp.min <= bars and bars <= startUp.max
// @function divergence
// @param higher higher or lower condition
// @param rsi rsi
// @param src source close
// @param condition bars since
// @param right nbars since
// @param min minimum bars
// @param max maximum bars
// @param enable bool condition
// @returns osc rsiHL / rsiLL / rsiLH / rsiHH
// @returns price priceLL / priceHL / priceHH / priceLH
// @returns output bigBull / kidBull / bigBear / kidBear
method divergence(setup startUp = na, bool higher = true, float src = na,bool condition = true, bool enable = true) =>
vw0 = ta.valuewhen(condition, startUp.osc[startUp.right], 1)
vw1 = ta.valuewhen(condition, src[startUp.right], 1)
rng = startUp.rangeBetween(condition[1])
ref = startUp.osc[startUp.right]
osc = switch higher
true => ref > vw0 and rng
false => ref < vw0 and rng
price = switch higher
true => src[right] < vw1
false => src[right] > vw1
output = enable and price and osc and condition
[osc, price, output]
// @function validate
// @param this refer to formula or float
// @returns true / false
method validate(float this = na) => na(this) ? false : true
//#endregion
//#region ββββββββββββββββββββ 2. Variables
rsi = ta.rsi(src, len)
PL = ta.pivotlow( rsi, left, right).validate()
PH = ta.pivothigh(rsi, left, right).validate()
startUp = setup.new(rsi, right, min, max)
// // RSI Price Bul / Bear
[rsiHL, priceLL, bigBull] = startUp.divergence(true, low, PL, boolBigBull) // HL LL Big Bull
[rsiLL, priceHL, kidBull] = startUp.divergence(false, low, PL, boolKidBull) // LL HL Kid Bull
[rsiLH, priceHH, bigBear] = startUp.divergence(false, high, PH, boolBigBear) // LH HH Big Bear
[rsiHH, priceLH, kidBear] = startUp.divergence(true, high, PH, boolKidBear) // HH LH Kid Bear
//#endregion
//#region ββββββββββββββββββββ 3. Plots
plot(rsi, 'RSI', chart.fg_color, 2)
hline(50, "Middle Line", color.silver, hline.style_dashed, 2, false)
OB100 = hline(100, 'OVERBOUGHT', color.red, hline.style_solid, 1, false, display.none)
OB070 = hline( 70, 'OVERBOUGHT', color.red, hline.style_solid, 1, false, display.none)
OS030 = hline( 30, 'OVERSOLD', color.red, hline.style_solid, 1, false, display.none)
OS000 = hline( 0, 'OVERSOLD', color.red, hline.style_solid, 1, false, display.none)
fill(OB070, OB100, color.new(color.red, 90), 'OVERBOUGHT')
fill(OS000, OS030, color.new(color.lime, 90), 'OVERSOLD')
plot(PL ? rsi[right] : na, 'BIG BULL', bigBull ? color.lime : color.new(color.lime, 100), 2, offset = -right, editable = false)
plot(PL ? rsi[right] : na, 'SMALL BULL', kidBull ? color.lime : color.new(color.lime, 100), 2, offset = -right, editable = false)
plot(PH ? rsi[right] : na, 'BIG BEAR', bigBear ? color.red : color.new(color.red, 100), 2, offset = -right, editable = false)
plot(PH ? rsi[right] : na, 'SMALL BEAR', kidBear ? color.red : color.new(color.red, 100), 2, offset = -right, editable = false)
plotshape(bigBull ? rsi[right] : na, 'BIG BULL LABEL', shape.labelup, location.bottom, color.new(color.lime, 100), -right, 'BIG\nBULL', color.lime, display = display.pane, editable = false)
plotshape(kidBull ? rsi[right] : na, 'SMALL BULL LABEL', shape.labelup, location.absolute, color.new(color.lime, 100), -right, 'SMALL\nBULL', chart.fg_color, display = display.pane, editable = false)
plotshape(bigBear ? rsi[right] : na, 'BIG BEAR LABEL', shape.labeldown, location.top, color.new(color.red, 100), -right, 'BIG\nBEAR', color.red, display = display.pane, editable = false)
plotshape(kidBear ? rsi[right] : na, 'SMALL BEAR LABEL', shape.labeldown, location.absolute, color.new(color.red, 100), -right, 'SMALL\nBEAR', chart.fg_color, display = display.pane, editable = false)
//#endregion |
Multi-Timeframe High Low (@JP7FX) | https://www.tradingview.com/script/UuM0gYyG-Multi-Timeframe-High-Low-JP7FX/ | jp7fx | https://www.tradingview.com/u/jp7fx/ | 360 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© jp7fx
//@version=5
indicator('Multi-Timeframe High Low (@JP7FX)', overlay=true)
S1 = '----Inputs----'
S2 = '----Line and Label Settings----'
/////Inputs - Shown in Menu
TF = input.timeframe(title='High/Low Timeframe', defval='D', group=S1)
showHigh = input.bool(title='Show High Levels', defval=true, group=S1)
showLow = input.bool(title='Show Low Levels', defval=true, group=S1)
showLabel = input.bool(title='Show Levels Label', defval=true, group=S1)
lineWidth = input.int(title='Line Width', defval=1, minval=1, group=S2)
highColor = input.color(title='High Level Color', defval=color.red, group=S2)
lowColor = input.color(title='Low Level Color', defval=color.green, group=S2)
labelTextColor = input.color(title='Label Text Color', defval=color.rgb(0, 0, 0), group=S2)
////Request High / Low Data
Prev_high = request.security(syminfo.tickerid, TF, high[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
Prev_low = request.security(syminfo.tickerid, TF, low[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
///// Plot the breakout levels
plot(showHigh ? Prev_high: na, color=color.new(highColor, 0), style=plot.style_stepline, linewidth=lineWidth)
plot(showLow ? Prev_low: na, color=color.new(lowColor, 0), style=plot.style_stepline, linewidth=lineWidth)
var label highLabel = na
var label lowLabel = na
// Add labels for high and low levels
if showHigh and showLabel and barstate.islast
label.delete(highLabel) // Remove previous high label
highLabel := label.new(x=bar_index, y=Prev_high, text="High (" + str.tostring(TF) + ")", textcolor=labelTextColor, color=highColor, style=label.style_label_left, yloc=yloc.price)
if showLow and showLabel and barstate.islast
label.delete(lowLabel) // Remove previous low label
lowLabel := label.new(x=bar_index, y=Prev_low, text="Low (" + str.tostring(TF) + ")", textcolor=labelTextColor, color=lowColor, style=label.style_label_left, yloc=yloc.price)
// Alert conditions
highTaken = ta.crossover(high, Prev_high)
lowTaken = ta.crossunder(low, Prev_low)
alertcondition(highTaken, title='High Level Alert', message='Price has taken the high level')
alertcondition(lowTaken, title='Low Level Alert', message='Price has taken the low level')
alertcondition(highTaken or lowTaken, title='Level Alert', message='Price has taken a level')
//// End Of Script
|
Multi-Timeframe Trend Indicator | https://www.tradingview.com/script/xQSGzY4E-Multi-Timeframe-Trend-Indicator/ | Ox_kali | https://www.tradingview.com/u/Ox_kali/ | 662 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Ox_kali
// ________________________________________________________________________________________________________________________________
// βββββββ βββ βββ βββ βββ ββββββ βββ βββ ββββββ βββ βββββββ βββββββ βββββββ βββββββββββββββ βββββββ ββββ
// βββββββββββββββββ βββ βββββββββββββββ βββ βββββββββββ ββββββββ ββββββββββββββββββββββββββββββββ ββββββββ βββββ
// βββ βββ ββββββ βββββββ βββββββββββ βββ βββββββββββ βββ βββββββ ββββββββββββββ βββ βββββββββββββββββββ
// βββ βββ ββββββ βββββββ βββββββββββ βββ βββββββββββ βββ ββββββ ββββββββββββββ βββ βββββββββββββββββββ
// βββββββββββββ ββββββββββββββ ββββββ ββββββββββββββ βββ ββββββββββββββββββββββββββββββββ ββββββ βββ βββ ββββββ βββ βββ
// βββββββ βββ ββββββββββββββ ββββββ ββββββββββββββ βββ βββββββββββ βββββββ βββββββ βββ ββββββ βββ βββ ββββββ βββ
// ________________________________________________________________________________________________________________________________
//@version=5
// Indicator title and short title
// ________________________________________________________________________________________________________________________________
indicator("Multi-Timeframe Trend Indicator", shorttitle="MTFTI", overlay=true)
// Table position input
// ________________________________________________________________________________________________________________________________
tablePosition = input.string(title="Table Position", defval="bottom_right", options=["top_left", "top_right", "middle_left", "middle_right", "bottom_left", "bottom_right"])
showTf1 = input(true, title="Show 5min")
showTf2 = input(true, title="Show 15min")
showTf3 = input(true, title="Show 30min")
showTf4 = input(true, title="Show 1H")
showTf5 = input(true, title="Show 2H")
showTf6 = input(true, title="Show 4H")
showTf7 = input(true, title="Show 6H")
showTf8 = input(true, title="Show 12H")
showTf9 = input(true, title="Show 1 Day")
showTf10 = input(true, title="Show 1 week")
showTf11 = input(true, title="Show AVG")
// Function to convert user input to position type
// ________________________________________________________________________________________________________________________________
get_position(value) =>
pos = position.middle_right
if value == "top_left"
pos := position.top_left
else if value == "top_right"
pos := position.top_right
else if value == "middle_left"
pos := position.middle_left
else if value == "middle_right"
pos := position.middle_right
else if value == "bottom_left"
pos := position.bottom_left
else if value == "bottom_right"
pos := position.bottom_right
pos
// Input for timeframes
// ________________________________________________________________________________________________________________________________
tf1 = "5"
tf2 = "15"
tf3 = "30"
tf4 = "60"
tf5 = "120"
tf6 = "240"
tf7 = "360"
tf8 = "720"
tf9 = "1440"
tf10 = "1W"
// Input for EMA lengths
// ________________________________________________________________________________________________________________________________
shortTerm = input(50, title="Short Term EMA Length")
longTerm = input(200, title="Long Term EMA Length")
showShortTerm = input(true, title="Show Short Term EMA")
showLongTerm = input(true, title="Show Long Term EMA")
emaShort = ta.ema(close, shortTerm)
emaLong = ta.ema(close, longTerm)
// Trend calculation function
// ________________________________________________________________________________________________________________________________
trendCalc(timeframe) =>
emaShort = request.security(syminfo.tickerid, timeframe, ta.ema(close, shortTerm))
emaLong = request.security(syminfo.tickerid, timeframe, ta.ema(close, longTerm))
trend = emaShort > emaLong ? 1 : -1
trend
// Calculate trends for each timeframe
// ________________________________________________________________________________________________________________________________
trend1 = trendCalc(tf1)
trend2 = trendCalc(tf2)
trend3 = trendCalc(tf3)
trend4 = trendCalc(tf4)
trend5 = trendCalc(tf5)
trend6 = trendCalc(tf6)
trend7 = trendCalc(tf7)
trend8 = trendCalc(tf8)
trend9 = trendCalc(tf9)
trend10 = trendCalc(tf10)
// Initialize trendSum and activeTfs
// ________________________________________________________________________________________________________________________________
trendSum = 0.0
activeTfs = 0
if showTf1
trendSum := trendSum + trend1
activeTfs := activeTfs + 1
if showTf2
trendSum := trendSum + trend2
activeTfs := activeTfs + 1
if showTf3
trendSum := trendSum + trend3
activeTfs := activeTfs + 1
if showTf4
trendSum := trendSum + trend4
activeTfs := activeTfs + 1
if showTf5
trendSum := trendSum + trend5
activeTfs := activeTfs + 1
if showTf6
trendSum := trendSum + trend6
activeTfs := activeTfs + 1
if showTf7
trendSum := trendSum + trend7
activeTfs := activeTfs + 1
if showTf8
trendSum := trendSum + trend8
activeTfs := activeTfs + 1
if showTf9
trendSum := trendSum + trend9
activeTfs := activeTfs + 1
if showTf10
trendSum := trendSum + trend10
activeTfs := activeTfs + 1
// Calculate average trend if activeTfs is not zero to avoid division by zero
// ________________________________________________________________________________________________________________________________
trendAvg = activeTfs != 0 ? trendSum / activeTfs : na
trendAvgText = ""
trendAvgBgcolor = color.silver
if trendAvg <= -0.8
trendAvgText := "Strong Down"
trendAvgBgcolor := color.rgb(172, 1, 1)
else if trendAvg <= -0.2
trendAvgText := "Down"
trendAvgBgcolor := color.red
else if trendAvg >= 0.8
trendAvgText := "Strong Up"
trendAvgBgcolor := color.rgb(1, 128, 5)
else if trendAvg >= 0.2
trendAvgText := "Up"
trendAvgBgcolor := color.green
else
trendAvgText := "Neutral"
trendAvgBgcolor := color.rgb(170, 169, 169)
trendTable = table.new(position=get_position(tablePosition), columns=2, rows=12, frame_color=color.white, bgcolor=color.black)
// Add header cell with left alignment
// ________________________________________________________________________________________________________________________________
table.cell(trendTable, column=0, row=0, text="Trend", bgcolor=color.black, text_color=color.white)
table.cell(trendTable, column=1, row=0, text="TF", bgcolor=color.black, text_color=color.white)
// Fill table cells
// ________________________________________________________________________________________________________________________________
if showTf1
table.cell(trendTable, column=1, row=1, text="5", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=1, text=(trend1 > 0 ? "Up" : "Down"), bgcolor=trend1 > 0 ? color.green : color.red)
if showTf2
table.cell(trendTable, column=1, row=2, text="15", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=2, text=(trend2 > 0 ? "Up" : "Down"), bgcolor=trend2 > 0 ? color.green : color.red)
if showTf3
table.cell(trendTable, column=1, row=3, text="30", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=3, text=(trend3 > 0 ? "Up" : "Down"), bgcolor=trend3 > 0 ? color.green : color.red)
if showTf4
table.cell(trendTable, column=1, row=4, text="1H", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=4, text=(trend4 > 0 ? "Up" : "Down"), bgcolor=trend4 > 0 ? color.green : color.red)
if showTf5
table.cell(trendTable, column=1, row=5, text="2H", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=5, text=(trend5 > 0 ? "Up" : "Down"), bgcolor=trend5 > 0 ? color.green : color.red)
if showTf6
table.cell(trendTable, column=1, row=6, text="4H", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=6, text=(trend6 > 0 ? "Up" : "Down"), bgcolor=trend6 > 0 ? color.green : color.red)
if showTf7
table.cell(trendTable, column=1, row=7, text="6H", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=7, text=(trend7 > 0 ? "Up" : "Down"), bgcolor=trend7 > 0 ? color.green : color.red)
if showTf8
table.cell(trendTable, column=1, row=8, text="12H", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=8, text=(trend8 > 0 ? "Up" : "Down"), bgcolor=trend8 > 0 ? color.green : color.red)
if showTf9
table.cell(trendTable, column=1, row=9, text="1D", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=9, text=(trend9 > 0 ? "Up" : "Down"), bgcolor=trend9 > 0 ? color.green : color.red)
if showTf10
table.cell(trendTable, column=1, row=10, text="1W", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=10, text=(trend10 > 0 ? "Up" : "Down"), bgcolor=trend10 > 0 ? color.green : color.red)
if showTf11
table.cell(trendTable, column=1, row=11, text="AVG", bgcolor=color.rgb(0, 0, 0, 70), text_color=color.white)
table.cell(trendTable, column=0, row=11, text=(trendAvgText), bgcolor=trendAvgBgcolor)
// Plot table and ema
// ________________________________________________________________________________________________________________________________
plot(showShortTerm ? emaShort : na, title="Short Term EMA", color=color.blue, linewidth=2)
plot(showLongTerm ? emaLong : na, title="Long Term EMA", color=color.orange, linewidth=2)
|
Weekly Options Expiry Candle V.2 | https://www.tradingview.com/script/D4PvJWUe-Weekly-Options-Expiry-Candle-V-2/ | tanayroy | https://www.tradingview.com/u/tanayroy/ | 254 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© tanayroy
//@version=5
indicator("Weekly Options Expiry Candle V.2", shorttitle = 'Expiry Candale V.2',overlay = true,max_boxes_count = 500,
max_labels_count = 500)
var string GP1 = 'Option Expiry Candle'
sess = input.session("0915-0920", title="Session Time",group = GP1,tooltip = 'Opening Session Time')
t = time(timeframe.period, sess + ":23456")
expiary_day=input.string("Thursday",title = "Weekly Expiary Day",options = ['Monday', 'Tuesday', 'Wednesday', 'Thursday'
, 'Friday'],group = GP1)
show_expiry_candle = input(title='Show Candle', defval=true,group = GP1)
show_expiry_OHLC = input(title='Show Expiry OHLC', defval=true,group = GP1)
var string GP2 = 'Option Expiry Pivot'
display_pivot = input(title='Display Pivot', defval=true,group = GP2,tooltip = 'Pivot Calculated on Expiry OHLC')
type_of_pivot = input.string('Fibonacci','Pivot Type',options = ['Fibonacci','Floor'],group = GP2)
show_pivot = input(title='Show Pivot', defval=true,group = GP2)
show_tc = input(title='Show TC', defval=true,group = GP2)
show_bc = input(title='Show BC', defval=true,group = GP2)
show_r1 = input(title='Show R1', defval=true,group = GP2)
show_r2 = input(title='Show R2', defval=false,group = GP2)
show_r3 = input(title='Show R3', defval=false,group = GP2)
show_r4 = input(title='Show R4', defval=false,group = GP2)
show_s1 = input(title='Show S1', defval=true,group = GP2)
show_s2 = input(title='Show S2', defval=false,group = GP2)
show_s3 = input(title='Show S3', defval=false,group = GP2)
show_s4 = input(title='Show S4', defval=false,group = GP2)
var string GP3 = "Display Range Table"
show_table = input.bool(true,title = 'Show Range Table', group = GP3)
tableYpos = input.string("top", "Panel position", inline = "31", options = ["top", "middle", "bottom"], group = GP3)
tableXpos = input.string("right", "", inline = "31", options = ["left", "center", "right"], group = GP3)
in_session = not na(t)
is_first = in_session and not in_session[1]
var int dayofweek_d=na
var int barpos=na
var int expiry_bar_start=na
var int pre_expiry_bar_end=na
if is_first
dayofweek_d:=dayofweek(time )
barpos:=bar_index
var float expiry_open=0
var float expiry_high=0
var float expiry_low=0
var float pre_expiry_close=0
var position_array=array.from(0,0,0)
var range_array=array.new_float(100)
var body_array=array.new_float(100)
var float pivot=na
var float tc=na
var float bc=na
var float r1=na
var float r2=na
var float r3=na
var float r4=na
var float s1=na
var float s2=na
var float s3=na
var float s4=na
var float ar1=na
var float ar2=na
var float ar3=na
var float ar4=na
var float as1=na
var float as2=na
var float as3=na
var float as4=na
var float last_week_range=na
var float three_weeks_range=na
var float five_weeks_range=na
var float seven_weeks_range=na
var float ten_weeks_range=na
var float fifteen_weeks_range=na
var float twenty_weeks_range=na
var float last_week_body=na
var float three_weeks_body=na
var float five_weeks_body=na
var float seven_weeks_body=na
var float ten_weeks_body=na
var float fifteen_weeks_body=na
var float twenty_weeks_body=na
var day_array = switch expiary_day
"Monday" => array.from(3,4,5)
"Tuesday" => array.from(4,5,6)
"Wednesday" => array.from(5,6,2)
"Thursday" => array.from(6,2,3)
"Friday" => array.from(2,3,4)
// Default used when the three first cases do not match.
=> array.from(6,2,3)
if dayofweek_d==array.get(day_array,0) //Friday, so we can take open
if is_first and timeframe.isintraday
expiry_open:=open
pre_expiry_close:=close[1]
expiry_high:=high
expiry_low:=low
array.set(position_array,0,array.get(position_array,1))
array.set(position_array,1,bar_index)
array.set(position_array,2,bar_index[1])
mid_val=int((array.get(position_array,2)-array.get(position_array,0))/2)
if show_expiry_candle
box.new(array.get(position_array,0),expiry_open[1],array.get(position_array,2),pre_expiry_close,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=expiry_open[1]>pre_expiry_close?color.new(color.red,70):color.new(color.green,70))
box.new(array.get(position_array,0)+mid_val-1, expiry_high[1], array.get(position_array,0)+mid_val+1,
expiry_open[1]>pre_expiry_close?expiry_open[1]:pre_expiry_close, xloc=xloc.bar_index,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=color.new(color.red,100))
box.new(array.get(position_array,0)+mid_val-1, expiry_open[1]>pre_expiry_close?pre_expiry_close:
expiry_open[1], array.get(position_array,0)+mid_val+1, expiry_low[1], xloc=xloc.bar_index,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=color.new(color.red,100))
if show_expiry_OHLC
label.new(array.get(position_array,2),expiry_high[1],text = 'O: '+str.tostring(expiry_open[1])+'\nH: '+
str.tostring(expiry_high[1])+'\nL: '+str.tostring(expiry_low[1])+'\nC: '+str.tostring(pre_expiry_close),
color = color.rgb(0,0,0,50),textcolor = color.white)
pivot := (expiry_high[1] + expiry_low[1] + pre_expiry_close) / 3
abc = (expiry_high[1] + expiry_low[1]) / 2
atc = pivot - abc + pivot
tc := abc >= atc ? abc : atc
bc := abc >= atc ? atc : abc
if type_of_pivot=='Floor'
r1 := 2 * pivot - expiry_low[1]
r2 := pivot + expiry_high[1] - expiry_low[1]
r3 := r1 + expiry_high[1] - expiry_low[1]
r4 := r3 + r2 - r1
s1 := 2 * pivot - expiry_high[1]
s2 := pivot - (expiry_high[1] - expiry_low[1])
s3 := s1 - (expiry_high[1] - expiry_low[1])
s4 := s3 - (s1 - s2)
else
r1 := pivot + ((expiry_high[1] - expiry_low[1]) * 0.382)
r2 := pivot + ((expiry_high[1] - expiry_low[1]) * 0.618)
r3 := pivot + ((expiry_high[1] - expiry_low[1]) * 1.0)
r4 := pivot + ((expiry_high[1] - expiry_low[1]) * 1.382)
s1 := pivot - ((expiry_high[1] - expiry_low[1]) * 0.382)
s2 := pivot - ((expiry_high[1] - expiry_low[1]) * 0.618)
s3 := pivot - ((expiry_high[1] - expiry_low[1]) * 1.0)
s4 := pivot - ((expiry_high[1] - expiry_low[1]) * 1.382)
expiry_range=expiry_high[1]-expiry_low[1]
expiry_body=math.abs(pre_expiry_close-expiry_open[1])
if array.size(range_array)>100
array.pop(range_array)
array.pop(body_array)
array.unshift(range_array,expiry_range)
array.unshift(body_array,expiry_body)
else
array.unshift(range_array,expiry_range)
array.unshift(body_array,expiry_body)
//Friday is holiday and expiry open is not available, take Monday open
if dayofweek_d == array.get(day_array,1) and dayofweek_d[(bar_index-barpos)+1]!=array.get(day_array,0)
if is_first and timeframe.isintraday
expiry_open:=open
pre_expiry_close:=close[1]
expiry_high:=high
expiry_low:=low
array.set(position_array,0,array.get(position_array,1))
array.set(position_array,1,bar_index)
array.set(position_array,2,bar_index[1])
mid_val=int((array.get(position_array,2)-array.get(position_array,0))/2)
if show_expiry_candle
box.new(array.get(position_array,0),expiry_open[1],array.get(position_array,2),pre_expiry_close,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=expiry_open[1]>pre_expiry_close?color.new(color.red,70):color.new(color.green,70))
box.new(array.get(position_array,0)+mid_val-1, expiry_high[1], array.get(position_array,0)+mid_val+1,
expiry_open[1]>pre_expiry_close?expiry_open[1]:pre_expiry_close, xloc=xloc.bar_index,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=color.new(color.red,100))
box.new(array.get(position_array,0)+mid_val-1, expiry_open[1]>pre_expiry_close?pre_expiry_close:
expiry_open[1], array.get(position_array,0)+mid_val+1, expiry_low[1], xloc=xloc.bar_index,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=color.new(color.red,100))
if show_expiry_OHLC
label.new(array.get(position_array,2),expiry_high[1],text = 'O: '+str.tostring(expiry_open[1])+'\nH: '+
str.tostring(expiry_high[1])+'\nL: '+str.tostring(expiry_low[1])+'\nC: '+str.tostring(pre_expiry_close),
color = color.rgb(0,0,0,50),textcolor = color.white)
pivot := (expiry_high[1] + expiry_low[1] + pre_expiry_close) / 3
abc = (expiry_high[1] + expiry_low[1]) / 2
atc = pivot - abc + pivot
tc := abc >= atc ? abc : atc
bc := abc >= atc ? atc : abc
if type_of_pivot=='Floor'
r1 := 2 * pivot - expiry_low[1]
r2 := pivot + expiry_high[1] - expiry_low[1]
r3 := r1 + expiry_high[1] - expiry_low[1]
r4 := r3 + r2 - r1
s1 := 2 * pivot - expiry_high[1]
s2 := pivot - (expiry_high[1] - expiry_low[1])
s3 := s1 - (expiry_high[1] - expiry_low[1])
s4 := s3 - (s1 - s2)
else
r1 := pivot + ((expiry_high[1] - expiry_low[1]) * 0.382)
r2 := pivot + ((expiry_high[1] - expiry_low[1]) * 0.618)
r3 := pivot + ((expiry_high[1] - expiry_low[1]) * 1.0)
r4 := pivot + ((expiry_high[1] - expiry_low[1]) * 1.382)
s1 := pivot - ((expiry_high[1] - expiry_low[1]) * 0.382)
s2 := pivot - ((expiry_high[1] - expiry_low[1]) * 0.618)
s3 := pivot - ((expiry_high[1] - expiry_low[1]) * 1.0)
s4 := pivot - ((expiry_high[1] - expiry_low[1]) * 1.382)
expiry_range=expiry_high[1]-expiry_low[1]
expiry_body=math.abs(pre_expiry_close-expiry_open[1])
if array.size(range_array)>100
array.pop(range_array)
array.pop(body_array)
array.unshift(range_array,expiry_range)
array.unshift(body_array,expiry_body)
else
array.unshift(range_array,expiry_range)
array.unshift(body_array,expiry_body)
//Friday and Monday is holiday and expiry open is not available, take Tuesday open
if dayofweek_d==array.get(day_array,2) and dayofweek_d[(bar_index-barpos)+1]!=array.get(day_array,1) and
dayofweek_d[(bar_index-barpos[(bar_index-barpos)+1])]!=array.get(day_array,0)
if is_first and timeframe.isintraday
expiry_open:=open
pre_expiry_close:=close[1]
expiry_high:=high
expiry_low:=low
array.set(position_array,0,array.get(position_array,1))
array.set(position_array,1,bar_index)
array.set(position_array,2,bar_index[1])
mid_val=int((array.get(position_array,2)-array.get(position_array,0))/2)
if show_expiry_candle
box.new(array.get(position_array,0),expiry_open[1],array.get(position_array,2),pre_expiry_close,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=expiry_open[1]>pre_expiry_close?color.new(color.red,70):color.new(color.green,70))
box.new(array.get(position_array,0)+mid_val-1, expiry_high[1], array.get(position_array,0)+mid_val+1,
expiry_open[1]>pre_expiry_close?expiry_open[1]:pre_expiry_close, xloc=xloc.bar_index,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=color.new(color.red,100))
box.new(array.get(position_array,0)+mid_val-1, expiry_open[1]>pre_expiry_close?pre_expiry_close:
expiry_open[1], array.get(position_array,0)+mid_val+1, expiry_low[1], xloc=xloc.bar_index,
border_color=expiry_open[1]>pre_expiry_close?color.red:color.green, border_style=line.style_solid,
bgcolor=color.new(color.red,100))
if show_expiry_OHLC
label.new(array.get(position_array,2),expiry_high[1],text = 'O: '+str.tostring(expiry_open[1])+'\nH: '+
str.tostring(expiry_high[1])+'\nL: '+str.tostring(expiry_low[1])+'\nC: '+str.tostring(pre_expiry_close),
color = color.rgb(0,0,0,50),textcolor = color.white)
pivot := (expiry_high[1] + expiry_low[1] + pre_expiry_close) / 3
abc = (expiry_high[1] + expiry_low[1]) / 2
atc = pivot - abc + pivot
tc := abc >= atc ? abc : atc
bc := abc >= atc ? atc : abc
if type_of_pivot=='Floor'
r1 := 2 * pivot - expiry_low[1]
r2 := pivot + expiry_high[1] - expiry_low[1]
r3 := r1 + expiry_high[1] - expiry_low[1]
r4 := r3 + r2 - r1
s1 := 2 * pivot - expiry_high[1]
s2 := pivot - (expiry_high[1] - expiry_low[1])
s3 := s1 - (expiry_high[1] - expiry_low[1])
s4 := s3 - (s1 - s2)
else
r1 := pivot + ((expiry_high[1] - expiry_low[1]) * 0.382)
r2 := pivot + ((expiry_high[1] - expiry_low[1]) * 0.618)
r3 := pivot + ((expiry_high[1] - expiry_low[1]) * 1.0)
r4 := pivot + ((expiry_high[1] - expiry_low[1]) * 1.382)
s1 := pivot - ((expiry_high[1] - expiry_low[1]) * 0.382)
s2 := pivot - ((expiry_high[1] - expiry_low[1]) * 0.618)
s3 := pivot - ((expiry_high[1] - expiry_low[1]) * 1.0)
s4 := pivot - ((expiry_high[1] - expiry_low[1]) * 1.382)
expiry_range=expiry_high[1]-expiry_low[1]
expiry_body=math.abs(pre_expiry_close-expiry_open[1])
if array.size(range_array)>100
array.pop(range_array)
array.pop(body_array)
array.unshift(range_array,expiry_range)
array.unshift(body_array,expiry_body)
else
array.unshift(range_array,expiry_range)
array.unshift(body_array,expiry_body)
if high>expiry_high
expiry_high:=high
if low<expiry_low
expiry_low:=low
if timeframe.isintraday
if show_expiry_candle
dev_box=box.new(array.get(position_array,1),expiry_open,bar_index,close,border_color=expiry_open>
close?color.red:color.green, border_style=line.style_solid,bgcolor=expiry_open>close?
color.new(color.red,70):color.new(color.green,70))
high_box=box.new(array.get(position_array,1)+1, expiry_high, bar_index-1, expiry_open>close?
expiry_open:close, xloc=xloc.bar_index,border_color=expiry_open>close?color.red:color.green,
border_style=line.style_solid,bgcolor=color.new(color.red,100))
low_box=box.new(array.get(position_array,1)+1, expiry_open>close?close:expiry_open, bar_index-1,
expiry_low, xloc=xloc.bar_index,border_color=expiry_open>close?color.red:color.green,
border_style=line.style_solid,bgcolor=color.new(color.red,100))
box.delete(dev_box[1])
box.delete(high_box[1])
box.delete(low_box[1])
if show_expiry_OHLC
dev_label=label.new(bar_index,expiry_high,text = 'O: '+str.tostring(expiry_open)+'\nH: '+
str.tostring(expiry_high)+'\nL: '+str.tostring(expiry_low)+'\nC: '+str.tostring(close),
color = color.rgb(0,0,0,50),textcolor = color.white)
label.delete(dev_label[1])
plot(show_pivot and display_pivot ? pivot : na, title='Pivot', style=plot.style_cross,
color=color.new(color.blue, 0), linewidth=1)
plot(show_tc and display_pivot? tc : na, style=plot.style_cross, title='TC', color=color.new(color.blue, 0),
linewidth=1)
plot(show_bc and display_pivot? bc : na, style=plot.style_cross, title='BC', color=color.new(color.blue, 0),
linewidth=1)
plot(show_r1 and display_pivot? r1 : na, style=plot.style_cross, title='R1', color=color.new(#a81b41, 0), linewidth=1)
plot(show_r2 and display_pivot? r2 : na, style=plot.style_cross, title='R2', color=color.new(#a81b41, 0), linewidth=1)
plot(show_r3 and display_pivot? r3 : na, style=plot.style_cross, title='R3', color=color.new(#a81b41, 0), linewidth=1)
plot(show_r4 and display_pivot? r4 : na, style=plot.style_cross, title='R4', color=color.new(#a81b41, 0), linewidth=1)
plot(show_s1 and display_pivot? s1 : na, style=plot.style_cross, title='S1', color=color.new(#02796f, 0), linewidth=1)
plot(show_s2 and display_pivot? s2 : na, style=plot.style_cross, title='S2', color=color.new(#02796f, 0), linewidth=1)
plot(show_s3 and display_pivot? s3 : na, style=plot.style_cross, title='S3', color=color.new(#02796f, 0), linewidth=1)
plot(show_s4 and display_pivot? s4 : na, style=plot.style_cross, title='S4', color=color.new(#02796f, 0), linewidth=1)
apivot = (expiry_high + expiry_low + close) / 3
aabc = (expiry_high + expiry_low) / 2
aatc = apivot - aabc + apivot
atc = aabc >= aatc ? aabc : aatc
abc = aabc >= aatc ? aatc : aabc
if type_of_pivot=='Floor'
ar1 := 2 * apivot - expiry_low
ar2 := apivot + expiry_high - expiry_low
ar3 := ar1 + expiry_high - expiry_low
ar4 := ar3 + ar2 - ar1
as1 := 2 * apivot - expiry_high
as2 := apivot - (expiry_high - expiry_low)
as3 := as1 - (expiry_high - expiry_low)
as4 := as3 - (as1 - as2)
else
ar1 := apivot + ((expiry_high[1] - expiry_low[1]) * 0.382)
ar2 := apivot + ((expiry_high[1] - expiry_low[1]) * 0.618)
ar3 := apivot + ((expiry_high[1] - expiry_low[1]) * 1.0)
ar4 := apivot + ((expiry_high[1] - expiry_low[1]) * 1.382)
as1 := apivot - ((expiry_high[1] - expiry_low[1]) * 0.382)
as2 := apivot - ((expiry_high[1] - expiry_low[1]) * 0.618)
as3 := apivot - ((expiry_high[1] - expiry_low[1]) * 1.0)
as4 := apivot - ((expiry_high[1] - expiry_low[1]) * 1.382)
var line pl = na
var line tcl = na
var line bcl = na
var line r1l = na
var line r2l = na
var line r3l = na
var line r4l = na
var line s1l = na
var line s2l = na
var line s3l = na
var line s4l = na
if not na(pl[1])
line.delete(pl[1])
if not na(tcl[1])
line.delete(tcl[1])
if not na(bcl[1])
line.delete(bcl[1])
if not na(r1l[1])
line.delete(r1l[1])
if not na(r2l[1])
line.delete(r2l[1])
if not na(r3l[1])
line.delete(r3l[1])
if not na(r4l[1])
line.delete(r4l[1])
if not na(s1l[1])
line.delete(s1l[1])
if not na(s2l[1])
line.delete(s2l[1])
if not na(s3l[1])
line.delete(s3l[1])
if not na(s4l[1])
line.delete(s4l[1])
this_week_range=expiry_high-expiry_low
this_week_body=math.abs(expiry_open-close)
var float average_range=na
var float average_body=na
if array.size(range_array)>20
last_week_range:=array.get(range_array,0)
three_weeks_range:=(array.get(range_array,0)+array.get(range_array,1)+array.get(range_array,2))/3
five_weeks_range:=(array.get(range_array,0)+array.get(range_array,1)+array.get(range_array,2)+array.get(range_array,3)+
array.get(range_array,4))/5
seven_weeks_range:=(array.get(range_array,0)+array.get(range_array,1)+array.get(range_array,2)+array.get(range_array,3)+
array.get(range_array,4)+array.get(range_array,5)+array.get(range_array,6))/7
ten_weeks_range:=(array.get(range_array,0)+array.get(range_array,1)+array.get(range_array,2)+array.get(range_array,3)+
array.get(range_array,4)+array.get(range_array,5)+array.get(range_array,6)+array.get(range_array,7)+
array.get(range_array,8)+array.get(range_array,9))/10
fifteen_weeks_range:=(array.get(range_array,0)+array.get(range_array,1)+array.get(range_array,2)+array.get(range_array,3)+
array.get(range_array,4)+array.get(range_array,5)+array.get(range_array,6)+array.get(range_array,7)+
array.get(range_array,8)+array.get(range_array,9)+array.get(range_array,11)+array.get(range_array,12)+array.get(range_array,13)
+array.get(range_array,14))/15
twenty_weeks_range:=(array.get(range_array,0)+array.get(range_array,1)+array.get(range_array,2)+array.get(range_array,3)+
array.get(range_array,4)+array.get(range_array,5)+array.get(range_array,6)+array.get(range_array,7)+
array.get(range_array,8)+array.get(range_array,9)+array.get(range_array,11)+array.get(range_array,12)+array.get(range_array,13)
+array.get(range_array,14)+array.get(range_array,15)+array.get(range_array,16)+array.get(range_array,17)
+array.get(range_array,18)+array.get(range_array,19))/20
average_range:=((last_week_range*6)+(three_weeks_range*5)+(seven_weeks_range*4)+(ten_weeks_range*3)+
(fifteen_weeks_range*2)+(twenty_weeks_range*1))/21
last_week_body:=array.get(body_array,0)
three_weeks_body:=(array.get(body_array,0)+array.get(body_array,1)+array.get(body_array,2))/3
five_weeks_body:=(array.get(body_array,0)+array.get(body_array,1)+array.get(body_array,2)+array.get(body_array,3)+
array.get(body_array,4))/5
seven_weeks_body:=(array.get(body_array,0)+array.get(body_array,1)+array.get(body_array,2)+array.get(body_array,3)+
array.get(body_array,4)+array.get(body_array,5)+array.get(body_array,6))/7
ten_weeks_body:=(array.get(body_array,0)+array.get(body_array,1)+array.get(body_array,2)+array.get(body_array,3)+
array.get(body_array,4)+array.get(body_array,5)+array.get(body_array,6)+array.get(body_array,7)+
array.get(body_array,8)+array.get(body_array,9))/10
fifteen_weeks_body:=(array.get(body_array,0)+array.get(body_array,1)+array.get(body_array,2)+array.get(body_array,3)+
array.get(body_array,4)+array.get(body_array,5)+array.get(body_array,6)+array.get(body_array,7)+
array.get(body_array,8)+array.get(body_array,9)+array.get(body_array,11)+array.get(body_array,12)+array.get(body_array,13)
+array.get(body_array,14))/15
twenty_weeks_body:=(array.get(body_array,0)+array.get(body_array,1)+array.get(body_array,2)+array.get(body_array,3)+
array.get(body_array,4)+array.get(body_array,5)+array.get(body_array,6)+array.get(body_array,7)+
array.get(body_array,8)+array.get(body_array,9)+array.get(body_array,11)+array.get(body_array,12)+array.get(body_array,13)
+array.get(body_array,14)+array.get(body_array,15)+array.get(body_array,16)+array.get(body_array,17)
+array.get(body_array,18)+array.get(body_array,19))/20
average_body:=((last_week_body*6)+(three_weeks_body*5)+(seven_weeks_body*4)+(ten_weeks_body*3)+
(fifteen_weeks_body*2)+(twenty_weeks_body*1))/21
var table range_table = table.new(tableYpos + "_" + tableXpos, columns=3, rows=21,bgcolor=color.yellow,border_width=1,
border_color=color.white)
if barstate.islast and show_table and timeframe.isintraday
table.cell(range_table,0,0,"Head")
table.cell(range_table,1,0,"Average")
table.cell(range_table,2,0,"Percent")
table.cell(range_table,0,1,'Option Expiry Range')
table.merge_cells(range_table,0,1,2,1)
table.cell(range_table,0,2,'Last Week Range')
table.cell(range_table,1,2,str.tostring(last_week_range,format.mintick))
table.cell(range_table,2,2,str.tostring((this_week_range/last_week_range)*100,format.mintick))
table.cell(range_table,0,3,'Three Weeks Range')
table.cell(range_table,1,3,str.tostring(three_weeks_range,format.mintick))
table.cell(range_table,2,3,str.tostring((this_week_range/three_weeks_range)*100,format.mintick))
table.cell(range_table,0,4,'Five Weeks Range')
table.cell(range_table,1,4,str.tostring(five_weeks_range,format.mintick))
table.cell(range_table,2,4,str.tostring((this_week_range/five_weeks_range)*100,format.mintick))
table.cell(range_table,0,5,'Seven Weeks Range')
table.cell(range_table,1,5,str.tostring(seven_weeks_range,format.mintick))
table.cell(range_table,2,5,str.tostring((this_week_range/seven_weeks_range)*100,format.mintick))
table.cell(range_table,0,6,'Ten Weeks Range')
table.cell(range_table,1,6,str.tostring(ten_weeks_range,format.mintick))
table.cell(range_table,2,6,str.tostring((this_week_range/ten_weeks_range)*100,format.mintick))
table.cell(range_table,0,7,'Fifteen Weeks Range')
table.cell(range_table,1,7,str.tostring(fifteen_weeks_range,format.mintick))
table.cell(range_table,2,7,str.tostring((this_week_range/fifteen_weeks_range)*100,format.mintick))
table.cell(range_table,0,8,'Twenty Weeks Range')
table.cell(range_table,1,8,str.tostring(twenty_weeks_range,format.mintick))
table.cell(range_table,2,8,str.tostring((this_week_range/twenty_weeks_range)*100,format.mintick))
table.cell(range_table,0,9,'This Weeks Range')
table.cell(range_table,1,9,str.tostring(this_week_range,format.mintick))
table.cell(range_table,2,9,str.tostring((this_week_range/this_week_range)*100,format.mintick))
table.cell(range_table,0,10,'Average Week Range')
table.cell(range_table,1,10,str.tostring(average_range,format.mintick))
table.cell(range_table,2,10,str.tostring((this_week_range/average_range)*100,format.mintick))
table.cell(range_table,0,11,'Option Expiry Body')
table.merge_cells(range_table,0,11,2,11)
table.cell(range_table,0,12,'Last Week Body')
table.cell(range_table,1,12,str.tostring(last_week_body,format.mintick))
table.cell(range_table,2,12,str.tostring((this_week_body/last_week_body)*100,format.mintick))
table.cell(range_table,0,13,'Three Weeks Body')
table.cell(range_table,1,13,str.tostring(three_weeks_body,format.mintick))
table.cell(range_table,2,13,str.tostring((this_week_body/three_weeks_body)*100,format.mintick))
table.cell(range_table,0,14,'Five Weeks Body')
table.cell(range_table,1,14,str.tostring(five_weeks_body,format.mintick))
table.cell(range_table,2,14,str.tostring((this_week_body/five_weeks_body)*100,format.mintick))
table.cell(range_table,0,15,'Seven Weeks Body')
table.cell(range_table,1,15,str.tostring(seven_weeks_body,format.mintick))
table.cell(range_table,2,15,str.tostring((this_week_body/seven_weeks_body)*100,format.mintick))
table.cell(range_table,0,16,'Ten Weeks Body')
table.cell(range_table,1,16,str.tostring(ten_weeks_body,format.mintick))
table.cell(range_table,2,16,str.tostring((this_week_body/ten_weeks_body)*100,format.mintick))
table.cell(range_table,0,17,'Fifteen Weeks Body')
table.cell(range_table,1,17,str.tostring(fifteen_weeks_body,format.mintick))
table.cell(range_table,2,17,str.tostring((this_week_body/fifteen_weeks_body)*100,format.mintick))
table.cell(range_table,0,18,'Twenty Weeks Body')
table.cell(range_table,1,18,str.tostring(twenty_weeks_body,format.mintick))
table.cell(range_table,2,18,str.tostring((this_week_body/twenty_weeks_body)*100,format.mintick))
table.cell(range_table,0,19,'This Weeks Body')
table.cell(range_table,1,19,str.tostring(this_week_body,format.mintick))
table.cell(range_table,2,19,str.tostring((this_week_body/this_week_body)*100,format.mintick))
table.cell(range_table,0,20,'Average Week Body')
table.cell(range_table,1,20,str.tostring(average_body,format.mintick))
table.cell(range_table,2,20,str.tostring((this_week_body/average_body)*100,format.mintick))
if barstate.islast and timeframe.isintraday
if show_pivot and display_pivot
pl := line.new(bar_index, apivot, bar_index + 20 , apivot, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=color.lime, width=2)
if show_tc and display_pivot
tcl := line.new(bar_index, atc, bar_index + 20 , atc, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=color.blue, width=2)
if show_bc and display_pivot
bcl := line.new(bar_index, abc, bar_index + 20 , abc, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=color.blue, width=2)
if show_r1 and display_pivot
r1l := line.new(bar_index, ar1, bar_index + 20 , ar1, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#a81b41, width=1)
if show_r2 and display_pivot
r2l := line.new(bar_index, ar2, bar_index + 20 , ar2, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#a81b41, width=1)
if show_r3 and display_pivot
r3l := line.new(bar_index, ar3, bar_index + 20 , ar3, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#a81b41, width=1)
if show_r4 and display_pivot
r4l := line.new(bar_index, ar4, bar_index + 20 , ar4, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#a81b41, width=1)
if show_s1 and display_pivot
s1l := line.new(bar_index, as1, bar_index + 20 , as1, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#02796f, width=1)
if show_s2 and display_pivot
s2l := line.new(bar_index, as2, bar_index + 20 , as2, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#02796f, width=1)
if show_s3 and display_pivot
s3l := line.new(bar_index, as3, bar_index + 20 , as3, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#02796f, width=1)
if show_s4 and display_pivot
s4l := line.new(bar_index, as4, bar_index + 20 , as4, xloc=xloc.bar_index, extend=extend.right,
style=line.style_dotted, color=#02796f, width=1)
|
Optimized Logarithmic Curve for Bitcoin (BTC/USD) by FICAS | https://www.tradingview.com/script/oaS3QRn4-Optimized-Logarithmic-Curve-for-Bitcoin-BTC-USD-by-FICAS/ | alimizanioskui | https://www.tradingview.com/u/alimizanioskui/ | 61 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//Β© anon2414691 Optimized by alimizanioskui(FICAS) originally created by @quantadelic
// @version=5
indicator('Optimized Logarithmic Curve for Bitcoin (BTC/USD) by FICAS', overlay=true)
// Group String //
var group_text0="Curve Settings"
var group_text1="Curve Color Setting"
var group_text2='Extend Input'
var group_text3="Plot width Setting"
A = input.float(defval=0.01, title='A=', step=0.001,group=group_text0)
beta = input.float(defval=0.511798, title='beta=', step=0.0001,group=group_text0)
lambda = input.float(defval=0.42665, title='lambda=', step=0.0001,group=group_text0)
c = input.float(defval=-4.3, title='c=', step=0.01,group=group_text0)
m = input.float(defval=-0.000667, title='m=', step=0.0001,group=group_text0)
b = input.float(defval=-0.01, title='b=', step=0.1,group=group_text0)
//Band=input(defval=true,title="Band?", type=input.bool)
B1 = input.float(defval=1.77, title='Band 1 Multiple', step=0.1,group=group_text0)
B2 = input.float(defval=3.13, title='Band 2 Multiple', step=0.1,group=group_text0)
B3 = input.float(defval=5.55, title='Band 3 Multiple', step=0.1,group=group_text0)
B4 = input.float(defval=9.82, title='Band 4 Multiple', step=0.1,group=group_text0)
B5 = input.float(defval=17.37, title='Band 5 Multiple', step=0.1,group=group_text0)
B6 = input.float(defval=30.75, title='Band 6 Multiple', step=0.1,group=group_text0)
CB = input(defval=true, title='Show Crisis Band',group=group_text0)
B7 = input.float(defval=0.55, title='Crisis multiple', step=0.1,group=group_text0)
CB2 = input(defval=true, title='Show Crisis Band2',group=group_text0)
B8 = input.float(defval=0.3192, title='Crisis multiple 2', step=0.1,group=group_text0)
CB3 = input(defval=true, title='Hide Mid lines',group=group_text0)
i_extend = input.int(0, title=' Extend', group=group_text2)
line_width=input.int(0,title = "Plot Width",group = group_text3)
// color input ///////////////
var p0_col=input.color(#ff0000,title = "P Color",group = group_text1,inline = "El")
var p1_col=input.color( #ffa500,title = "P1 Color",group = group_text1,inline = "El")
var p2_col=input.color(#ffff00,title = "P2 Color",group = group_text1,inline = "El")
var p3_col=input.color(#008000,title = "P3 Color",group = group_text1,inline = "EX")
var p4_col=input.color(#0000ff,title = "P4 Color",group = group_text1,inline = "EX")
var p5_col=input.color(#4b0082,title = "P5 Color",group = group_text1,inline = "EX")
var p6_col=input.color(#ee82ee,title = "P6 Color",group = group_text1,inline = "EZ")
var p7_col=input.color(#aaff00,title = "P7 Color",group = group_text1,inline = "EZ")
var p8_col=input.color(#0033ff,title = "P8 Color",group = group_text1,inline = "EZ")
t = time
genesis = timestamp(2009, 1, 3, 0, 0, 0)
x = (t - genesis) / 86400000
p = A * math.exp(beta * math.pow(x, lambda) + c) + m * x + b
P = plot(p, linewidth=1, color=p0_col, offset=i_extend)
p1 = p * B1
p2 = p * B2
p3 = p * B3
p4 = p * B4
p5 = p * B5
p6 = p * B6
p7 = p * B7
p8 = p*B8
// median line calculation
fun_medi(J1,k1)=>math.sqrt(J1*k1)
p_8median=math.sqrt(p8*p7)
P1 = plot(p1, linewidth=line_width, color=p1_col, offset=i_extend)
P2 = plot(p2, linewidth=line_width, color=p2_col, offset=i_extend)
P3 = plot(p3, linewidth=line_width, color=p3_col, offset=i_extend)
P4 = plot(p4, linewidth=line_width, color=p4_col, offset=i_extend)
P5 = plot(p5, linewidth=line_width, color=p5_col, offset=i_extend)
P6 = plot(p6, linewidth=line_width, color=p6_col, offset=i_extend)
P7 = plot(CB ? p7 : p, linewidth=line_width, color=p7_col, offset=i_extend)
P8=plot(CB2 ? p8 : p, linewidth=line_width, color=p8_col, offset=i_extend)
// plot meidan
plot(CB3 ? p :fun_medi(p7,p),title = "P7-P Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
plot(CB3 ? p :fun_medi(p,p1),title = "P-P1 Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
plot(CB3 ? p :fun_medi(p1,p2),title = "P1-P2 Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
plot(CB3 ? p :fun_medi(p2,p3),title = "P2-P3 Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
plot(CB3 ? p :fun_medi(p3,p4),title = "P3-P4 Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
plot(CB3 ? p :fun_medi(p4,p5),title = "P4-P5 Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
plot(CB3 ? p :fun_medi(p5,p6),title = "P6-P7 Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
plot(CB3 ? p :fun_medi(p8,p7),title = "P7-P8 Median" ,linewidth=line_width, color=color.gray, offset=i_extend,style = plot.style_circles)
// table information about curve
var string GP2 = "Table"
bool en_table=input.bool(true,title = "Enable/Disable Table",group = GP2)
string tableYposInput = input.string("top", "Y position", inline = "11", options = ["top", "middle", "bottom"], group = GP2)
string tableXposInput = input.string("right", "X position", inline = "11", options = ["left", "center", "right"], group = GP2)
int tb_size=input.int(5,title = "Input table border width ",group = GP2)
var tbl = table.new(tableYposInput + "_" + tableXposInput, 6, 41, frame_color=#151715, frame_width=3, border_width=tb_size, border_color=color.new(color.white, 100))
if barstate.islast and en_table
table.cell(tbl, 0, 0, 'Data', text_halign = text.align_center, bgcolor =color.silver, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 1, 'P', text_halign = text.align_center, bgcolor =p0_col,text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 2, 'P1', text_halign = text.align_center, bgcolor =p1_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 3, 'P2', text_halign = text.align_center, bgcolor =p2_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 4, 'P3', text_halign = text.align_center, bgcolor =p3_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 5, 'P4', text_halign = text.align_center, bgcolor =p4_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 6, 'P5', text_halign = text.align_center, bgcolor =p5_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 7, 'P6', text_halign = text.align_center, bgcolor =p6_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 8, 'P7', text_halign = text.align_center, bgcolor =p7_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 9, 'P8', text_halign = text.align_center, bgcolor =p8_col, text_color = color.white, text_size = size.small)
table.cell(tbl, 1, 0, 'value', text_halign = text.align_center, bgcolor = color.silver, text_color = color.white, text_size = size.small)
table.cell(tbl, 1, 1, str.tostring(p,'#.###'), text_halign = text.align_center, bgcolor = close>p ? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 2, str.tostring(p1,'#.###'), text_halign = text.align_center, bgcolor = close>p1? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 3, str.tostring(p2,'#.###'), text_halign = text.align_center, bgcolor = close>p2? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 4, str.tostring(p3,'#.###'), text_halign = text.align_center, bgcolor = close>p3? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 5, str.tostring(p4,'#.###'), text_halign = text.align_center, bgcolor = close>p4? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 6, str.tostring(p5,'#.###'), text_halign = text.align_center, bgcolor = close>p5? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 7, str.tostring(p6,'#.###'), text_halign = text.align_center, bgcolor = close>p6? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 8, str.tostring(p7,'#.###'), text_halign = text.align_center, bgcolor = close>p7? color.green:color.red, text_color =color.white, text_size = size.small)
table.cell(tbl, 1, 9, str.tostring(p8,'#.###'), text_halign = text.align_center, bgcolor = close>p8? color.green:color.red, text_color =color.white, text_size = size.small)
// label
var string gp3="Label Set"
en_label=input.bool(false,title = "Enable Label",group = gp3)
f_lineLabel(_label, _line, _barsBack, _color, _text) =>
label.delete(_label)
if en_label
label.new(time - _barsBack * (time - time[1]), _line[_barsBack], xloc=xloc.bar_time, yloc=yloc.price, text=_text + '\n', color=_color, textcolor=color.new(color.white, 0), size=size.small)
var plabel =label(na)
var p1Label = label(na)
var p2Labe2 = label(na)
var p3Label = label(na)
var p4Labe2 = label(na)
var p5Label = label(na)
var p6Labe2 = label(na)
var p7Label = label(na)
plabel :=f_lineLabel(plabel , p, 0, close>p ? color.green:color.red, str.tostring(p,'#.###'))
p1Label :=f_lineLabel(p1Label, p1, 0, close>p1? color.green:color.red, str.tostring(p1,'#.###'))
p2Labe2 :=f_lineLabel(p2Labe2, p2, 0, close>p2? color.green:color.red, str.tostring(p2,'#.###'))
p3Label :=f_lineLabel(p3Label, p3, 0, close>p3? color.green:color.red, str.tostring(p3,'#.###'))
p4Labe2 :=f_lineLabel(p4Labe2, p4, 0, close>p4? color.green:color.red, str.tostring(p4,'#.###'))
p5Label :=f_lineLabel(p5Label, p5, 0, close>p5? color.green:color.red, str.tostring(p5,'#.###'))
p6Labe2 :=f_lineLabel(p6Labe2, p6, 0, close>p6? color.green:color.red, str.tostring(p6,'#.###'))
p7Label :=f_lineLabel(p7Label, p7, 0, close>p7? color.green:color.red, str.tostring(p7,'#.###')) |
Ectopic Bar by Moti Rakam | https://www.tradingview.com/script/uaha7LZ0-Ectopic-Bar-by-Moti-Rakam/ | MotiRakam | https://www.tradingview.com/u/MotiRakam/ | 78 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© MotiRakam
//@version=5
indicator("Ectopic Bar by Moti Rakam", "Ectopic Bar", overlay=true)
var bool highClose = false
var bool lowClose = false
var bool bullishPinBar = false
var bool bearishPinBar = false
var bool ectopicPinBar = false
useCustomTimeframeInput = input.bool(false, "Use custom timeframe")
lowerTimeframeInput = input.timeframe("1", "Volume Timeframe")
closeRange = input.float(0.35, title="Close Range", minval=0.05, maxval=0.75, step=0.05)
//Find Ectopic candle
upAndDownVolume() =>
posVol = 0.0
negVol = 0.0
switch
close > open => posVol += volume
close < open => negVol -= volume
close >= close[1] => posVol += volume
close < close[1] => negVol -= volume
[posVol, negVol]
lowerTimeframe = switch
useCustomTimeframeInput => lowerTimeframeInput
timeframe.isintraday => "1"
timeframe.isdaily => "5"
=> "60"
[upVolumeArray, downVolumeArray] = request.security_lower_tf(syminfo.tickerid, lowerTimeframe, upAndDownVolume())
upVolume = array.sum(upVolumeArray)
downVolume = array.sum(downVolumeArray)
delta = upVolume + downVolume
//Close Above or Below Mid-Point
barRange = math.abs(high - low)
if close > (high - (barRange / 2))
highClose := true
else
lowClose := true
//Check if Close is closer to High
if highClose and (close >= high - (barRange * closeRange)) and (open >= high - (barRange * closeRange))
bullishPinBar := true
else
bullishPinBar := false
//Check if Close is closer to Low
if lowClose and (close <= low + (barRange * closeRange)) and (open <= low + (barRange * closeRange))
bearishPinBar := true
else
bearishPinBar := false
//Ectopic Pin Bar
ectopicPinBar := (bullishPinBar and (math.abs(downVolume) > upVolume)) or (bearishPinBar and (upVolume > math.abs(downVolume)))
ectopicPinBarColor = ectopicPinBar ? color.yellow : na
barcolor(ectopicPinBarColor, title="Ectopic Pin Bar")
//reset the variables
highClose := false
lowClose := false
bullishPinBar := false
bearishPinBar := false
ectopicPinBar := false |
Oliver Velez Indicator | https://www.tradingview.com/script/kBUTQ1e4-Oliver-Velez-Indicator/ | Rginah1974 | https://www.tradingview.com/u/Rginah1974/ | 93 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Rginah1974
//@version=4
study("Oliver Velez Indicator", shorttitle="OVI", overlay=true)
//use_HA = input.bool(false, title='Use HeikinAshi data?', group='HeikinAshi')
// Input parameters for Elephant Bars
lookback = input(5, title="Lookback Period", minval=1, group='Elephantbars')
multiplier = input(1.5, title="Size Multiplier", type=input.float, minval=0.1, group='Elephantbars')
//input parameters Tailbars
input_tail_ratio = input(2.0, title="Tail Ratio", type=input.float, group= "tailbars")
input_opposite_wick_ratio = input(0.2, title="Opposite Wick Ratio", type=input.float, group= "tailbars")
// Input parameters for Moving Averages
shortLength = input(20, title="Short MA Length", minval=1, group='MAs')
longLength = input(200, title="Long MA Length", minval=1, group='MAs')
maType = input(title="MA Type", defval="SMA", options=["SMA", "EMA", "WMA", "VWMA", "SMMA", "HullMA", "TEMA"], group='MAs')
// Moving Average function
ma(src, length, ma_type) =>
if ma_type == "SMA"
sma(src, length)
else if ma_type == "EMA"
ema(src, length)
else if ma_type == "WMA"
wma(src, length)
else if ma_type == "VWMA"
vwma(src, length)
else if ma_type == "HullMA"
wma(2 * wma(src, length / 2) - wma(src, length), round(sqrt(length)))
else if ma_type == "TEMA"
3 * ema(src, length) - 3 * ema(ema(src, length), length) + ema(ema(ema(src, length), length), length)
else
na
// Calculate average candle size and volume
avg_candle_size = sum(abs(close - open), lookback) / lookback
avg_volume = sum(volume, lookback) / lookback
// Calculate body size, and tailsize proportions
body_size = abs(close - open)
tail_size = close > open ? open - low : close - low
upper_wick_size = close > open ? high - close : high - open
opposite_wick_size = close > open ? high - open : high - close
// Calculate Moving Averages
shortMA = ma(close, shortLength, maType)
longMA = ma(close, longLength, maType)
// Define the touch_shortMA function
touch_shortMA(i) => (low[i] <= shortMA[i] and high[i] >= shortMA[i])
// Identify Elephant Bars with additional conditions
is_bullish = (close - open) > (multiplier * avg_candle_size) and volume > avg_volume and (touch_shortMA(0) or touch_shortMA(1) or touch_shortMA(2) or touch_shortMA(3) or touch_shortMA(4))
is_bearish = (open - close) > (multiplier * avg_candle_size) and volume > avg_volume and (touch_shortMA(0) or touch_shortMA(1) or touch_shortMA(2) or touch_shortMA(3) or touch_shortMA(4))
//Identify Tailbars with conditions
is_bullish_tailbar1 = (tail_size > body_size * input_tail_ratio) and close > open and (upper_wick_size <= tail_size * input_opposite_wick_ratio)
is_bullish_tailbar2 = (tail_size > body_size * input_tail_ratio) and close < open and (upper_wick_size <= tail_size * input_opposite_wick_ratio)
is_bearish_tailbar1 = (upper_wick_size > body_size * input_tail_ratio) and close < open and (tail_size <= upper_wick_size * input_opposite_wick_ratio)
is_bearish_tailbar2 = (upper_wick_size > body_size * input_tail_ratio) and close > open and (tail_size <= upper_wick_size * input_opposite_wick_ratio)
// Plot elephantbar signals
//plotshape(is_bullish, style=shape.circle, location=location.abovebar, color=color.aqua, size=size.tiny)
//plotshape(is_bearish, style=shape.circle, location=location.belowbar, color=color.fuchsia, size=size.tiny)
//candle color:
barcolor(is_bullish ? color.aqua : is_bearish ? color.fuchsia : na)
//plot tailbar signals
barcolor(is_bullish_tailbar1 ? color.aqua : na)
barcolor(is_bullish_tailbar2 ? color.blue : na)
barcolor(is_bearish_tailbar1 ? color.fuchsia : na)
barcolor(is_bearish_tailbar2 ? color.orange : na)
//plotshape(is_bullish_tailbar1 or is_bullish_tailbar2, title="Bullish Tail Bar", location=location.belowbar, color=color.green, style=shape.arrowup, size=size.small)
//plotshape(is_bearish_tailbar1 or is_bearish_tailbar2, title="Bearish Tail Bar", location=location.abovebar, color=color.red, style=shape.arrowdown, size=size.small)
plot(is_bullish_tailbar1 or is_bullish_tailbar2 ? low : na, color=color.aqua, linewidth=1, style=plot.style_circles)
plot(is_bearish_tailbar1 or is_bearish_tailbar2 ? high : na, color=color.fuchsia, linewidth=1, style=plot.style_circles)
plot(is_bullish_tailbar2 ? low : na, color=color.blue, linewidth=1, style=plot.style_circles)
plot(is_bearish_tailbar2 ? high : na, color=color.orange, linewidth=1, style=plot.style_circles)
// Plot Moving Averages
plot(shortMA, title="Short MA", color=color.aqua, linewidth=2)
plot(longMA, title="Long MA", color=color.fuchsia, linewidth=2)
// Add Keltner Channel1
mult = input(3.0, "Multiplier",group='KeltnerChannel1')
keltnerSource = input(title="Keltner Channel Source", defval="Short MA", options=["Short MA", "Long MA"],group='KeltnerChannel1')
BandsStyle = input("Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style",group='KeltnerChannel1')
atrlength = input(14, "ATR Length",group='KeltnerChannel1')
keltnerMA = keltnerSource == "Short MA" ? shortMA : longMA
keltnerLength = keltnerSource == "Short MA" ? shortLength : longLength
rangema = BandsStyle == "True Range" ? tr : BandsStyle == "Average True Range" ? atr(atrlength) : rma(high - low, keltnerLength)
keltnerUpper = keltnerMA + rangema * mult
keltnerLower = keltnerMA - rangema * mult
// Plot the Keltner Channel on the chart
u = plot(keltnerUpper, color=color.rgb(255, 82, 82, 100), title="Keltner Channel Upper1", linewidth=1)
//plot(keltnerMA, color=color.blue, title="Keltner Channel Basis", linewidth=1)
l = plot(keltnerLower, color=color.rgb(255, 82, 82, 100), title="Keltner Channel Lower1", linewidth=1)
// Fill the Keltner Channel with white color and 20% transparency
fill(u, l, color=color.white, transp=90)
// Add Keltner Channel2
mult1 = input(3.0, "Multiplier",group='KeltnerChannel2')
keltnerSource1 = input(title="Keltner Channel Source", defval="Short MA", options=["Short MA", "Long MA"],group='KeltnerChannel2')
BandsStyle1 = input("Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style",group='KeltnerChannel2')
atrlength1= input(14, "ATR Length",group='KeltnerChannel2')
keltnerMA1 = keltnerSource1 == "Short MA" ? shortMA : longMA
keltnerLength1 = keltnerSource1 == "Short MA" ? shortLength : longLength
rangema1 = BandsStyle1 == "True Range" ? tr : BandsStyle == "Average True Range" ? atr(atrlength1) : rma(high - low, keltnerLength1)
keltnerUpper1 = keltnerMA1 + rangema1 * mult1
keltnerLower1 = keltnerMA1 - rangema1 * mult1
// Plot the Keltner Channel on the chart
u1 = plot(keltnerUpper1, color=color.rgb(255, 82, 82, 100), title="Keltner Channel Upper2", linewidth=1)
//plot(keltnerMA1, color=color.rgb(33, 149, 243, 100), title="Keltner Channel Basis", linewidth=1)
l1 = plot(keltnerLower1, color=color.rgb(255, 82, 82, 100), title="Keltner Channel Lower2", linewidth=1)
// Fill the Keltner Channel with white color and 20% transparency
fill(u1, l1, color=color.white, transp=90) |
Momentum Reversal [AngelAlgo] | https://www.tradingview.com/script/1UCzmRD4-Momentum-Reversal-AngelAlgo/ | AngelAlgo | https://www.tradingview.com/u/AngelAlgo/ | 56 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator("Momentum Reversal [AngelAlgo]", overlay = false)
// Inputs
momentumLength = input(14,"Period")
trendLength = input(50,"Trend length")
signalsType = input.string("Contrarian",options=["Contrarian","Trend"], title="Signals type")
signalsSmoothed = input(true,"Smothed signals")
// Internal variables
momentum = ta.change(close, momentumLength)
trend = ta.sma(momentum, trendLength)
hist = momentum - trend
threshold = ta.sma(math.abs(hist),500)
// Calculating conditional colors
colorHist = hist > 0 ? color.new(color.green,50) : color.new(color.red,50)
colorHistSmoothed = hist > 0 ? color.new(color.green,0) : color.new(color.red,0)
// Plotting the indicator histogram
plot(hist, "Momentum Reversal", color = colorHist, style = plot.style_columns)
// Adjusting max and min threshold levels
min = -1.3*threshold
max = 1.3*threshold
// Calculating the smoothed indicator line
histSmoothed = ta.hma(hist,10)
// Chossing the input data for signals calculation
histType = signalsSmoothed ? histSmoothed : hist
// Determining the choosen signal type
TrendSignals = signalsType == "Trend" ? true : false
ContrarianSignals = signalsType == "Contrarian" ? true : false
//Trading sginals conditions
ContrarianBuy = ta.crossunder(histType, min) and ContrarianSignals and barstate.isconfirmed
ContrarianSell = ta.crossover(histType, max) and ContrarianSignals and barstate.isconfirmed
TrendBuy = ta.crossover(histType, max) and TrendSignals and barstate.isconfirmed
TrendSell = ta.crossunder(histType, min) and TrendSignals and barstate.isconfirmed
// Plotting the signal arrows
//Contrarian signals
plotshape(ContrarianSell ? histType: na, style=shape.triangledown, color = color.red, size = size.small, location = location.absolute)
plotshape(ContrarianBuy ? histType: na, style=shape.triangleup, color = color.green, size = size.small, location = location.absolute)
// Trend signals
plotshape(TrendBuy ? histType: na, style=shape.triangleup, color = color.green, size = size.small, location = location.absolute)
plotshape(TrendSell ? histType: na, style=shape.triangledown, color = color.red, size = size.small, location = location.absolute)
// Plotting the smoothed indicator line
plot(histSmoothed ,color=colorHistSmoothed)
// Plotting the dynamic threshold levels
plot(min, style = plot.style_circles)
plot(max, style = plot.style_circles) |
Rainbow Collection - Blue | https://www.tradingview.com/script/eulaoHZT-Rainbow-Collection-Blue/ | Sofien-Kaabar | https://www.tradingview.com/u/Sofien-Kaabar/ | 227 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Sofien-Kaabar
//@version=5
indicator("Rainbow Collection - Blue", overlay = true)
lookback = input(defval = 21, title = 'Lookback')
lookback_rsi = input(defval = 21, title = 'RSI Lookback')
slope = (close - close[lookback]) / lookback
indicator = ta.rsi(slope, lookback_rsi)
buy = indicator > 30 and indicator[1] < 30 and indicator < 35
sell = indicator < 70 and indicator[1] > 70 and indicator > 65
plotshape(buy, style = shape.triangleup, color = color.blue, location = location.belowbar, size = size.small)
plotshape(sell, style = shape.triangledown, color = color.blue, location = location.abovebar, size = size.small)
|
Candle Counter [theEccentricTrader] | https://www.tradingview.com/script/XsgxvZjB-Candle-Counter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 50 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Candle Counter [theEccentricTrader]', overlay = true)
//////////// sample period filter ////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input.time(timestamp('2 Jan 1800 00:00'), title = 'Start Date', group = 'Sample Period')
end = input.time(timestamp('1 Jan 3000 00:00'), title = 'End Date', group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
str.tostring(dayofmonth(_t), '00') + '.' + str.tostring(month(_t), '00') + '.' + str.tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
//////////// candle counters ////////////
candle = close and samplePeriodFilter and barstate.isconfirmed
higherHigh = high > high[1] and samplePeriodFilter and barstate.isconfirmed
higherLow = low > low[1] and samplePeriodFilter and barstate.isconfirmed
lowerHigh = high < high[1] and samplePeriodFilter and barstate.isconfirmed
lowerLow = low < low[1] and samplePeriodFilter and barstate.isconfirmed
doubleTop = high == high[1] and samplePeriodFilter and barstate.isconfirmed
doubleBottom = low == low[1] and samplePeriodFilter and barstate.isconfirmed
greenCandle = close >= open and samplePeriodFilter and barstate.isconfirmed
higherHighGreen = high > high[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
higherLowGreen = low > low[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
lowerHighGreen = high < high[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
lowerLowGreen = low < low[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
doubleTopGreen = high == high[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
doubleBottomGreen = low == low[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
redCandle = close < open and samplePeriodFilter and barstate.isconfirmed
higherHighRed = high > high[1] and close < open and samplePeriodFilter and barstate.isconfirmed
higherLowRed = low > low[1] and close < open and samplePeriodFilter and barstate.isconfirmed
lowerHighRed = high < high[1] and close < open and samplePeriodFilter and barstate.isconfirmed
lowerLowRed = low < low[1] and close < open and samplePeriodFilter and barstate.isconfirmed
doubleTopRed = high == high[1] and close < open and samplePeriodFilter and barstate.isconfirmed
doubleBottomRed = low == low[1] and close < open and samplePeriodFilter and barstate.isconfirmed
var candleCounter = 0
var higherHighCounter = 0
var higherLowCounter = 0
var lowerHighCounter = 0
var lowerLowCounter = 0
var doubleTopCounter = 0
var doubleBottomCounter = 0
var greenCounter = 0
var higherHighGreenCounter = 0
var higherLowGreenCounter = 0
var lowerHighGreenCounter = 0
var lowerLowGreenCounter = 0
var doubleTopGreenCounter = 0
var doubleBottomGreenCounter = 0
var redCounter = 0
var higherHighRedCounter = 0
var higherLowRedCounter = 0
var lowerHighRedCounter = 0
var lowerLowRedCounter = 0
var doubleTopRedCounter = 0
var doubleBottomRedCounter = 0
if candle
candleCounter += 1
if higherHigh
higherHighCounter += 1
if higherLow
higherLowCounter += 1
if lowerHigh
lowerHighCounter += 1
if lowerLow
lowerLowCounter += 1
if doubleTop
doubleTopCounter += 1
if doubleBottom
doubleBottomCounter += 1
if greenCandle
greenCounter += 1
if higherHighGreen
higherHighGreenCounter += 1
if higherLowGreen
higherLowGreenCounter += 1
if lowerHighGreen
lowerHighGreenCounter += 1
if lowerLowGreen
lowerLowGreenCounter += 1
if doubleTopGreen
doubleTopGreenCounter += 1
if doubleBottomGreen
doubleBottomGreenCounter += 1
if redCandle
redCounter += 1
if higherHighRed
higherHighRedCounter += 1
if higherLowRed
higherLowRedCounter += 1
if lowerHighRed
lowerHighRedCounter += 1
if lowerLowRed
lowerLowRedCounter += 1
if doubleTopRed
doubleTopRedCounter += 1
if doubleBottomRed
doubleBottomRedCounter += 1
//////////// table ////////////
candleTablePositionInput = input.string(title = 'Position', defval = 'Top Right', options = ['Top Right', 'Top Center', 'Top Left', 'Bottom Right', 'Bottom Center', 'Bottom Left',
'Middle Right', 'Middle Center', 'Middle Left'], group = 'Table Positioning')
candleTablePosition = candleTablePositionInput == 'Top Right' ? position.top_right : candleTablePositionInput == 'Top Center' ? position.top_center :
candleTablePositionInput == 'Top Left' ? position.top_left : candleTablePositionInput == 'Bottom Right' ? position.bottom_right :
candleTablePositionInput == 'Bottom Center' ? position.bottom_center : candleTablePositionInput == 'Bottom Left' ? position.bottom_left :
candleTablePositionInput == 'Middle Right' ? position.middle_right : candleTablePositionInput == 'Middle Center' ? position.middle_center :
candleTablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
var candleTable = table.new(candleTablePosition, 100, 100, border_width = 1)
table.cell(candleTable, 0, 1, text = 'Candles', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 2, text = 'Green Candles', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 3, text = 'Red Candles', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 4, text = 'Higher High Candles', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 5, text = 'Higher Low Candles', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 6, text = 'Lower High Candles', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 7, text = 'Lower Low Candles', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 8, text = 'Double Top Candles', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 9, text = 'Double Bottom Candles', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 10, text = 'Higher High Green Candles', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 11, text = 'Higher Low Green Candles', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 12, text = 'Lower High Green Candles', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 13, text = 'Lower Low Green Candles', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 14, text = 'Double Top Green Candles', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 15, text = 'Double Bottom Green Candles', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 16, text = 'Higher High Red Candles', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 17, text = 'Higher Low Red Candles', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 18, text = 'Lower High Red Candles', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 19, text = 'Lower Low Red Candles', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 20, text = 'Double Top Red Candles', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 0, 21, text = 'Double Bottom Red Candles', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 1, text = str.tostring(candleCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 2, text = str.tostring(greenCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 3, text = str.tostring(redCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 4, text = str.tostring(higherHighCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 5, text = str.tostring(higherLowCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 6, text = str.tostring(lowerHighCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 7, text = str.tostring(lowerLowCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 8, text = str.tostring(doubleTopCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 9, text = str.tostring(doubleBottomCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 10, text = str.tostring(higherHighGreenCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 11, text = str.tostring(higherLowGreenCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 12, text = str.tostring(lowerHighGreenCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 13, text = str.tostring(lowerLowGreenCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 14, text = str.tostring(doubleTopGreenCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 15, text = str.tostring(doubleBottomGreenCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 16, text = str.tostring(higherHighRedCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 17, text = str.tostring(higherLowRedCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 18, text = str.tostring(lowerHighRedCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 19, text = str.tostring(lowerLowRedCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 20, text = str.tostring(doubleTopRedCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 1, 21, text = str.tostring(doubleBottomRedCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 1, text = '%', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 2, text = str.tostring(math.round(greenCounter / candleCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 3, text = str.tostring(math.round(redCounter / candleCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 4, text = str.tostring(math.round(higherHighCounter / candleCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 5, text = str.tostring(math.round(higherLowCounter / candleCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 6, text = str.tostring(math.round(lowerHighCounter / candleCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 7, text = str.tostring(math.round(lowerLowCounter / candleCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 8, text = str.tostring(math.round(doubleTopCounter / candleCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 9, text = str.tostring(math.round(doubleBottomCounter / candleCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 10, text = str.tostring(math.round(higherHighGreenCounter / greenCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 11, text = str.tostring(math.round(higherLowGreenCounter / greenCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 12, text = str.tostring(math.round(lowerHighGreenCounter / greenCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 13, text = str.tostring(math.round(lowerLowGreenCounter / greenCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 14, text = str.tostring(math.round(doubleTopGreenCounter / greenCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 15, text = str.tostring(math.round(doubleBottomGreenCounter / greenCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 16, text = str.tostring(math.round(higherHighRedCounter / redCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 17, text = str.tostring(math.round(higherLowRedCounter / redCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 18, text = str.tostring(math.round(lowerHighRedCounter / redCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 19, text = str.tostring(math.round(lowerLowRedCounter / redCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 20, text = str.tostring(math.round(doubleTopRedCounter / redCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTable, 2, 21, text = str.tostring(math.round(doubleBottomRedCounter / redCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(candleTable, 0, 22, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
//////////// plots ////////////
showPlots = input(defval = true, title = "Show Plots", group = 'Plots')
plotshape(high > high[1] and close >= open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangleup, color = color.green)
plotshape(low > low[1] and close >= open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangleup, color = color.green, location = location.belowbar)
plotshape(high < high[1] and close >= open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangledown, color = color.red)
plotshape(low < low[1] and close >= open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangledown, color = color.red, location = location.belowbar)
plotshape(high == high[1] and close >= open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.diamond, color = color.blue, textcolor = color.blue)
plotshape(low == low[1] and close >= open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.diamond, color = color.blue, textcolor = color.blue, location = location.belowbar)
plotshape(high > high[1] and close < open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangleup, color = color.green)
plotshape(low > low[1] and close < open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangleup, color = color.green, location = location.belowbar)
plotshape(high < high[1] and close < open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangledown, color = color.red)
plotshape(low < low[1] and close < open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.triangledown, color = color.red, location = location.belowbar)
plotshape(high == high[1] and close < open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.diamond, color = color.blue)
plotshape(low == low[1] and close < open and samplePeriodFilter and barstate.isconfirmed and showPlots, style = shape.diamond, color = color.blue, location = location.belowbar)
|
Advanced RSI with Volatility Bands [RedWhite] | https://www.tradingview.com/script/QfiDfM8u/ | mrojas-mx | https://www.tradingview.com/u/mrojas-mx/ | 85 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© mrojas-mx
//@version=5
// # ========================================================================= #
// # | Indicator |
// # ========================================================================= #
indicator(
title = "Advanced RSI with Volatility Bands (VB)" ,
shorttitle = "Advanced RSI" ,
overlay = false ,
precision = 2 ,
scale = scale.right ,
timeframe = "" ,
timeframe_gaps = true ,
explicit_plot_zorder = false ,
max_lines_count = 500 ,
max_labels_count = 500 ,
max_boxes_count = 500
)
// # ========================================================================= #
// # | Indicator |
// # ========================================================================= #
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
// # ======================================================================================================================== #
//
// β¬ C O N S T A N T V A L U E S
//
// # ======================================================================================================================== #
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
//*-[ Parameters: titles ]-*
string Txt_Hdg_1 = "Moving Average: Tom Tillson (T3)"
string Txt_Hdg_2 = "Moving Average: Arnaud Legoux (ALMA)"
string Txt_Hdg_3 = "Relative Strength Index (RSI)"
string Txt_Hdg_5 = "Moving Average Bands"
string Txt_Hdg_6 = "Band crossing (maximum and minimum)"
string Txt_Hdg_4 = "Moving Average Indicator"
// *-[ ******** ]-*
//*-[ Parameters: colors ]-*
color Clr_RSI = color.new(color = #9F47E1 , transp = 0 )
color Clr_MA_RSI = color.new(color = #FFF538 , transp = 0 )
color Clr_Up_1 = color.new(color = #00cc99 , transp = 0 )
color Clr_Dn_1 = color.new(color = #d90368 , transp = 0 )
// < --------------------------------------------------------------------------------------------------------- >
color Clr_Band = color.new(color = #568CCE , transp = 50 )
color Clr_Ln_1 = color.new(color = #adb5bd , transp = 40 )
color Clr_Ln_2 = color.new(color = #adb5bd , transp = 60 )
color Clr_Ln_3 = color.new(color = #B573E8 , transp = 90 )
// *-[ ******** ]-*
//*-[ Parameters: descriptions ]-*
string Ttip_Grp_1 = "The T3 moving average was developed by Tom Tillson.\nThis moving average is designed to be smoother and more responsive than traditional moving averages, but it can overshoot the price or indicator to which it is applied.\nThe volume factor is usually 0.7 or 0.618."
string Ttip_Grp_2 = "The ALMA moving average was developed by Arnaud Legoux.\nThe ALMA moving average is more sensitive to recent price movements than conventional moving averages, allowing for faster identification of emerging trends."
// *-[ ******** ]-*
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
// # ======================================================================================================================== #
//
// π¦ I N P U T D A T A : G E N E R A L
//
// # ======================================================================================================================== #
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
//*-[ Input values: Parameters for Tom Tillson's MA ]-*
aa_T3_Val = input.float (defval = 0.70 , title = "Alpha" , tooltip = Ttip_Grp_1 , group = Txt_Hdg_1 )
// *-[ ******** ]-*
//*-[ Input values: Parameters for Arnaud Legoux's MA ]-*
ba_ALMA_Ofst = input.float (defval = 0.85 , title = "Offset" , tooltip = Ttip_Grp_2 , group = Txt_Hdg_2 )
ba_ALMA_Sgm = input.float (defval = 6 , title = "Sigma" , group = Txt_Hdg_2 )
// *-[ ******** ]-*
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
// # ======================================================================================================================== #
//
// π¦ I N P U T D A T A : A D V A N C E D R S I
//
// # ======================================================================================================================== #
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
//*-[ Input values : Relative Strength Index (RSI) ]-*
ca_RSI_Lgth = input.int (defval = 14 , title = "" , minval = 1 , inline = "01" , group = Txt_Hdg_3 )
ca_RSI_Src = input.source (defval = close , title = "" , inline = "01" , group = Txt_Hdg_3 )
ca_Clr_RSI = input.color (defval = Clr_RSI , title = "Line color" , group = Txt_Hdg_3 )
// *-[ ******** ]-*
//*-[ Input values : Moving Average ]-*
da_MA_Lgth = input.int (defval = 14 , title = "" , minval = 1 , inline = "01" , group = Txt_Hdg_4 )
da_MA_Mtd = input.string (defval = "SMA" , title = "" , options = ["SMA", "EMA", "WMA", "HMA", "SMMA/RMA", "SWMA", "ALMA", "VWMA", "VWAP", "DEMA", "TEMA", "T3"], inline = "01" , group = Txt_Hdg_4 )
da_Clr_MA = input.color (defval = Clr_MA_RSI , title = "Line color" , group = Txt_Hdg_4 )
// *-[ ******** ]-*
//*-[ Input values : Moving Average Bands ]-*
ea_MA_Lgth = input.int (defval = 70 , title = "Length" , minval = 1 , group = Txt_Hdg_5 )
ea_MA_Stdev = input.float (defval = 1.0 , title = "Standard deviation" , minval = 0.0 , group = Txt_Hdg_5 )
ea_MA_Mtd = input.string (defval = "EMA" , title = "Method" , options = ["SMA", "EMA", "WMA", "HMA", "SMMA/RMA", "SWMA", "ALMA", "VWMA", "VWAP", "DEMA", "TEMA", "T3"] , group = Txt_Hdg_5 )
ea_Clr_Bnd = input.color (defval = Clr_Band , title = "Band color" , group = Txt_Hdg_5 )
// *-[ ******** ]-*
//*-[ Input values : Lower, middle and upper band ]-*
fa_RSI_Shw = input.bool (defval = true , title = "Show fill color RSI" , group = Txt_Hdg_6 )
// < --------------------------------------------------------------------------------------------------------- >
fa_RSI_Up = input.int (defval = 70 , title = "" , minval = 0, maxval = 100 , inline = "01" , group = Txt_Hdg_6 )
fa_Clr_Up = input.color (defval = Clr_Up_1 , title = "" , inline = "01" , group = Txt_Hdg_6 )
// < --------------------------------------------------------------------------------------------------------- >
fb_RSI_Dn = input.int (defval = 30 , title = "" , minval = 0, maxval = 100 , inline = "02" , group = Txt_Hdg_6 )
fb_Clr_Dn = input.color (defval = Clr_Dn_1 , title = "" , inline = "02" , group = Txt_Hdg_6 )
// < --------------------------------------------------------------------------------------------------------- >
fc_RSI_Shw = input.bool (defval = true , title = "Show background color" , group = Txt_Hdg_6 )
fc_Clr_Bgd = input.color (defval = Clr_Ln_3 , title = "Background color" , group = Txt_Hdg_6 )
// *-[ ******** ]-*
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
// # ======================================================================================================================== #
//
// π₯ C U S T O M F U N C T I O N S
//
// # ======================================================================================================================== #
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
//*-[ DEMA: Doble Exponencial Movil Average ]-*
z_Typ_DEMA (xb_MA_Src, xb_MA_Lgth) =>
float xb_DEMA_01 = ta.ema(source = xb_MA_Src , length = xb_MA_Lgth )
float xb_DEMA_02 = ta.ema(source = xb_DEMA_01 , length = xb_MA_Lgth )
float xb_DEMA_Rslt = 2 * (xb_DEMA_01 - xb_DEMA_02 )
// *-[ ******** ]-*
//*-[ TEMA: Triple Exponential Moving Average ]-*
z_Typ_TEMA (xc_MA_Src, xc_MA_Lgth) =>
float xc_TEMA_01 = ta.ema(source = xc_MA_Src , length = xc_MA_Lgth )
float xc_TEMA_02 = ta.ema(source = xc_TEMA_01 , length = xc_MA_Lgth )
float xc_TEMA_03 = ta.ema(source = xc_TEMA_02 , length = xc_MA_Lgth )
float xc_TEMA_Rslt = 3 * (xc_TEMA_01 - xc_TEMA_02) + xc_TEMA_03
// *-[ ******** ]-*
//*-[ T3: Tillson Moving Average ]-*
z_Typ_TILLSON (xd_MA_Src, xd_MA_Lgth, xd_TT_Alpha) =>
float xd_T3_01 = ta.ema(source = xd_MA_Src , length = xd_MA_Lgth )
float xd_T3_02 = xd_T3_01 * ( 1 + aa_T3_Val ) - ta.ema(source = xd_T3_01 , length = xd_MA_Lgth ) * aa_T3_Val
// < --------------------------------------------------------------------------------------------------------- >
z_Typ_T3 (xe_MA_Src, xe_MA_Lgth, xe_TT_Alpha = 0.7) =>
float xd_T3_Rslt = z_Typ_TILLSON(z_Typ_TILLSON(z_Typ_TILLSON(xe_MA_Src, xe_MA_Lgth, xe_TT_Alpha),xe_MA_Lgth, xe_TT_Alpha),xe_MA_Lgth, xe_TT_Alpha)
// *-[ ******** ]-*
//*-[ Type of Moving Averages ]-*
z_Slct_MA (z_Selct_Typ_MA, z_MA_Src, z_MA_Lgth) =>
float xy_Typ_MA = switch str.upper(z_Selct_Typ_MA)
"SMA" => ta.sma (source = z_MA_Src , length = z_MA_Lgth ) // Simple Moving Average
"EMA" => ta.ema (source = z_MA_Src , length = z_MA_Lgth ) // Exponential Moving Average
"WMA" => ta.wma (source = z_MA_Src , length = z_MA_Lgth ) // Weighted Moving Average
"HMA" => ta.hma (source = z_MA_Src , length = z_MA_Lgth ) // Hull Moving Average
"SMMA/RMA" => ta.rma (source = z_MA_Src , length = z_MA_Lgth ) // Relative Moving Average or Smoothed Moving Average
"SWMA" => ta.swma (source = z_MA_Src ) // Symmetrically-Weighted Moving Average
"ALMA" => ta.alma (series = z_MA_Src , length = z_MA_Lgth , offset = ba_ALMA_Ofst , sigma = ba_ALMA_Sgm ) // Arnaud Legoux Moving Average
"VWMA" => ta.vwma (source = z_MA_Src , length = z_MA_Lgth ) // Volume-Weighted Moving Average
"VWAP" => ta.vwap (z_MA_Src ) // Volume-Weighted Average Price
"DEMA" => z_Typ_DEMA (z_MA_Src , z_MA_Lgth ) // Doble Exponencial Movil Average
"TEMA" => z_Typ_TEMA (z_MA_Src , z_MA_Lgth ) // Triple Exponential Moving Average
"T3" => z_Typ_T3 (z_MA_Src , z_MA_Lgth , aa_T3_Val ) // Tillson Moving Average
// *-[ ******** ]-*
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
// # ======================================================================================================================== #
//
// π© A R I T H M E T I C C A L C U L A T I O N S
//
// # ======================================================================================================================== #
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
//*-[ Arithmetic result: Relative Strength Index (RSI) ]-*
cr_RSI_Rslt = ta.rsi (source = ca_RSI_Src , length = ca_RSI_Lgth )
// *-[ ******** ]-*
//*-[ Arithmetic result: Moving Average ]-*
dr_MAB_Rslt = z_Slct_MA (da_MA_Mtd , cr_RSI_Rslt , da_MA_Lgth )
// *-[ ******** ]-*
//*-[ Arithmetic result: Moving Average Band ]-*
er_MA_Rslt = z_Slct_MA (ea_MA_Mtd , cr_RSI_Rslt , ea_MA_Lgth )
er_Stdev_Rslt = ta.stdev (source = cr_RSI_Rslt , length = ea_MA_Lgth )
// *-[ ******** ]-*
//*-[ Arithmetic result: Upper and lower bands ]-*
fr_MAB_Up = er_MA_Rslt + ea_MA_Stdev * er_Stdev_Rslt
fr_MAB_Dn = er_MA_Rslt - ea_MA_Stdev * er_Stdev_Rslt
// *-[ ******** ]-*
//*-[ Color gradient: Moving Average Band ]-*
Clr_Grdt_1 = color.from_gradient(
value = cr_RSI_Rslt
, bottom_value = fb_RSI_Dn
, top_value = fa_RSI_Up
, bottom_color = fb_Clr_Dn
, top_color = fa_Clr_Up
)
// *-[ ******** ]-*
//*-[ Arithmetic result: Trend patterns ]-*
color fr_Ptrn_Up = color ( cr_RSI_Rslt > fr_MAB_Up ? Clr_Grdt_1 : na )
color fr_Ptrn_Dn = color ( cr_RSI_Rslt < fr_MAB_Dn ? Clr_Grdt_1 : na )
color fr_Clr_Bgd = color ( fc_RSI_Shw ? fc_Clr_Bgd : na )
// *-[ ******** ]-*
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
// # ======================================================================================================================== #
//
// πͺ G R A P H I C R E P R E S E N T A T I O N
//
// # ======================================================================================================================== #
//******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ******** ********
f_Plot_RSI = plot(series = cr_RSI_Rslt , title = "RSI" , color = ca_Clr_RSI , linewidth = 1 , style = plot.style_line , trackprice = false, editable = true , display = display.all )
f_Plot_MA = plot(series = dr_MAB_Rslt , title = "RSI moving average" , color = da_Clr_MA , linewidth = 1 , style = plot.style_line , trackprice = false, editable = true , display = display.all )
f_Plot_Up = plot(series = fr_MAB_Up , title = "Upper moving average" , color = ea_Clr_Bnd , linewidth = 1 , style = plot.style_line , trackprice = false, editable = true , display = display.all )
f_Plot_Dn = plot(series = fr_MAB_Dn , title = "Lower moving average" , color = ea_Clr_Bnd , linewidth = 1 , style = plot.style_line , trackprice = false, editable = true , display = display.all )
// < --------------------------------------------------------------------------------------------------------- >
h_Line_Up = hline(price = 70 , title = "Upper band" , color = Clr_Ln_1, linestyle = hline.style_dashed , linewidth = 1, editable = true )
h_Line_Md = hline(price = 50 , title = "Middle band" , color = Clr_Ln_2, linestyle = hline.style_dashed , linewidth = 1, editable = true )
h_Line_Dn = hline(price = 30 , title = "Lower band" , color = Clr_Ln_1, linestyle = hline.style_dashed , linewidth = 1, editable = true )
// < --------------------------------------------------------------------------------------------------------- >
fill(plot1 = f_Plot_Up , plot2 = f_Plot_RSI , color = fa_RSI_Shw ? fr_Ptrn_Up : na , title = "Background upper", editable = true )
fill(plot1 = f_Plot_Dn , plot2 = f_Plot_RSI , color = fa_RSI_Shw ? fr_Ptrn_Dn : na , title = "Background lower", editable = true )
// < --------------------------------------------------------------------------------------------------------- >
fill(hline1 = h_Line_Up , hline2 = h_Line_Dn , color = fr_Clr_Bgd , title = "Background fill" , editable = true ) |
Swing Counter [theEccentricTrader] | https://www.tradingview.com/script/VnhEhVA1-Swing-Counter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 21 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Swing Counter [theEccentricTrader]', overlay = true, max_lines_count = 500)
//////////// sample period filter ////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input.time(timestamp('2 Jan 1800 00:00'), title = 'Start Date', group = 'Sample Period')
end = input.time(timestamp('1 Jan 3000 00:00'), title = 'End Date', group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
str.tostring(dayofmonth(_t), '00') + '.' + str.tostring(month(_t), '00') + '.' + str.tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
//////////// swing counters ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
shBarIndex = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? bar_index :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? bar_index - 1 : na
shPriceOne = ta.valuewhen(shPrice, shPrice, 1)
shBarIndexOne = ta.valuewhen(shBarIndex, shBarIndex, 1)
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
slBarIndex = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? bar_index :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? bar_index - 1 : na
slPriceOne = ta.valuewhen(slPrice, slPrice, 1)
slBarIndexOne = ta.valuewhen(slBarIndex, slBarIndex, 1)
returnLineUptrend = ta.valuewhen(shPrice, shPrice, 0) > ta.valuewhen(shPrice, shPrice, 1)
uptrend = ta.valuewhen(slPrice, slPrice, 0) > ta.valuewhen(slPrice, slPrice, 1)
downtrend = ta.valuewhen(shPrice, shPrice, 0) < ta.valuewhen(shPrice, shPrice, 1)
returnLineDowntrend = ta.valuewhen(slPrice, slPrice, 0) < ta.valuewhen(slPrice, slPrice, 1)
doubleTop = ta.valuewhen(shPrice, shPrice, 0) == ta.valuewhen(shPrice, shPrice, 1)
doubleBottom = ta.valuewhen(slPrice, slPrice, 0) == ta.valuewhen(slPrice, slPrice, 1)
var shCounter = 0
var slCounter = 0
var returnLineUptrendCounter = 0
var uptrendCounter = 0
var downtrendCounter = 0
var returnLineDowntrendCounter = 0
var doubleTopCounter = 0
var doubleBottomCounter = 0
if shPrice and samplePeriodFilter
shCounter += 1
if slPrice and samplePeriodFilter
slCounter += 1
if shPrice and returnLineUptrend and samplePeriodFilter
returnLineUptrendCounter += 1
if slPrice and uptrend and samplePeriodFilter
uptrendCounter += 1
if shPrice and downtrend and samplePeriodFilter
downtrendCounter += 1
if slPrice and returnLineDowntrend and samplePeriodFilter
returnLineDowntrendCounter += 1
if shPrice and doubleTop and samplePeriodFilter
doubleTopCounter += 1
if slPrice and doubleBottom and samplePeriodFilter
doubleBottomCounter += 1
//////////// table ////////////
swingTablePositionInput = input.string(title = 'Position', defval = 'Top Right', options = ['Top Right', 'Top Center', 'Top Left', 'Bottom Right', 'Bottom Center', 'Bottom Left',
'Middle Right', 'Middle Center', 'Middle Left'], group = 'Table Positioning')
swingTablePosition = swingTablePositionInput == 'Top Right' ? position.top_right : swingTablePositionInput == 'Top Center' ? position.top_center :
swingTablePositionInput == 'Top Left' ? position.top_left : swingTablePositionInput == 'Bottom Right' ? position.bottom_right : swingTablePositionInput == 'Bottom Center' ? position.bottom_center :
swingTablePositionInput == 'Bottom Left' ? position.bottom_left : swingTablePositionInput == 'Middle Right' ? position.middle_right : swingTablePositionInput == 'Middle Center' ? position.middle_center :
swingTablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval='Normal', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
var swingTable = table.new(swingTablePosition, 100, 100, border_width = 1)
table.cell(swingTable, 0, 0, text = 'Peaks', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 0, 1, text = 'Troughs', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 0, 2, text = 'Higher Peaks', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(swingTable, 0, 3, text = 'Higher Troughs', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(swingTable, 0, 4, text = 'Lower Peaks', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(swingTable, 0, 5, text = 'Lower Troughs', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(swingTable, 0, 6, text = 'Double-Top Peaks', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 0, 7, text = 'Double-Bottom Troughs', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 0, text = str.tostring(shCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 1, text = str.tostring(slCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 2, text = str.tostring(returnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 3, text = str.tostring(uptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 4, text = str.tostring(downtrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 5, text = str.tostring(returnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 6, text = str.tostring(doubleTopCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 1, 7, text = str.tostring(doubleBottomCounter), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 2, 1, text = '%', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 2, 2, text = str.tostring(math.round(returnLineUptrendCounter / shCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(swingTable, 2, 3, text = str.tostring(math.round(uptrendCounter / slCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(swingTable, 2, 4, text = str.tostring(math.round(downtrendCounter / shCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(swingTable, 2, 5, text = str.tostring(math.round(returnLineDowntrendCounter / slCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(swingTable, 2, 6, text = str.tostring(math.round(doubleTopCounter / shCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(swingTable, 2, 7, text = str.tostring(math.round(doubleBottomCounter / slCounter * 100, 2)), bgcolor = color.blue, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(swingTable, 0, 8, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
//////////// plots ////////////
showPlots = input(defval = true, title = "Show Plots", group = 'Plots')
plotshape(shPrice and returnLineUptrend and samplePeriodFilter and showPlots and high >= high[1] and barstate.isconfirmed,
style = shape.triangleup, color = color.green, text = "HP", textcolor = color.green)
plotshape(slPrice and uptrend and samplePeriodFilter and showPlots and low <= low[1] and barstate.isconfirmed,
style = shape.triangleup, color = color.green, text = "HT", textcolor = color.green, location = location.belowbar)
plotshape(shPrice and downtrend and samplePeriodFilter and showPlots and high >= high[1] and barstate.isconfirmed,
style = shape.triangledown, color = color.red, text = "LP", textcolor = color.red)
plotshape(slPrice and returnLineDowntrend and samplePeriodFilter and showPlots and low <= low[1] and barstate.isconfirmed,
style = shape.triangledown, color = color.red, text = "LT", textcolor = color.red, location = location.belowbar)
plotshape(shPrice and doubleTop and samplePeriodFilter and showPlots,
style = shape.diamond, color = color.blue, text = "DP", textcolor = color.blue)
plotshape(slPrice and doubleBottom and samplePeriodFilter and showPlots,
style = shape.diamond, color = color.blue, text = "DT", textcolor = color.blue, location = location.belowbar)
plotshape(shPrice and returnLineUptrend and samplePeriodFilter and showPlots and high < high[1] and barstate.isconfirmed,
style = shape.triangleup, color = color.green, text = "HP", textcolor = color.green, offset = -1)
plotshape(slPrice and uptrend and samplePeriodFilter and showPlots and low > low[1] and barstate.isconfirmed,
style = shape.triangleup, color = color.green, text = "HT", textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(shPrice and downtrend and samplePeriodFilter and showPlots and high < high[1] and barstate.isconfirmed,
style = shape.triangledown, color = color.red, text = "LP", textcolor = color.red, offset = -1)
plotshape(slPrice and returnLineDowntrend and samplePeriodFilter and showPlots and low > low[1] and barstate.isconfirmed,
style = shape.triangledown, color = color.red, text = "LT", textcolor = color.red, location = location.belowbar, offset = -1)
//////////// lines ////////////
showLines = input(defval = true, title = "Show Lines", group = 'Lines')
if shPrice and showLines
line.new(shBarIndexOne, shPriceOne, shBarIndex, shPrice, color = shPrice > shPriceOne ? color.green : color.red)
if slPrice and showLines
line.new(slBarIndexOne, slPriceOne, slBarIndex, slPrice, color = slPrice > slPriceOne ? color.green : color.red)
|
Candle Trend Counter [theEccentricTrader] | https://www.tradingview.com/script/hIlTukJJ-Candle-Trend-Counter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 29 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Candle Trend Counter [theEccentricTrader]', overlay = true)
///////////////////////////
// SAMPLE PERIOD FILTER //
///////////////////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input.time(timestamp('2 Jan 1800 00:00'), title = 'Start Date', group = 'Sample Period')
end = input.time(timestamp('1 Jan 3000 00:00'), title = 'End Date', group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
str.tostring(dayofmonth(_t), '00') + '.' + str.tostring(month(_t), '00') + '.' + str.tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
///////////////////////////
// CANDLE TREND COUNTERS //
///////////////////////////
oneGC = close[1] < open[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twoGC = oneGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
threeGC = twoGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
fourGC = threeGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
fiveGC = fourGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
sixGC = fiveGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
sevenGC = sixGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
eightGC = sevenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
nineGC = eightGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
tenGC = nineGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
elevenGC = tenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twelveGC = elevenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
thirteenGC = twelveGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
fourteenGC = thirteenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
fifteenGC = fourteenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
sixteenGC = fifteenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
seventeenGC = sixteenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
eighteenGC = seventeenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
nineteenGC = eighteenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentyGC = nineteenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentyoneGC = twentyGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentytwoGC = twentyoneGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentythreeGC = twentytwoGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentyfourGC = twentythreeGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentyfiveGC = twentyfourGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentysixGC = twentyfiveGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentysevenGC = twentysixGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentyeightGC = twentysevenGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
twentynineGC = twentyeightGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
thirtyGC = twentynineGC[1] and close >= open and samplePeriodFilter and barstate.isconfirmed
oneRC = close[1] >= open[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twoRC = oneRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
threeRC = twoRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
fourRC = threeRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
fiveRC = fourRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
sixRC = fiveRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
sevenRC = sixRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
eightRC = sevenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
nineRC = eightRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
tenRC = nineRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
elevenRC = tenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twelveRC = elevenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
thirteenRC = twelveRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
fourteenRC = thirteenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
fifteenRC = fourteenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
sixteenRC = fifteenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
seventeenRC = sixteenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
eighteenRC = seventeenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
nineteenRC = eighteenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentyRC = nineteenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentyoneRC = twentyRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentytwoRC = twentyoneRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentythreeRC = twentytwoRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentyfourRC = twentythreeRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentyfiveRC = twentyfourRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentysixRC = twentyfiveRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentysevenRC = twentysixRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentyeightRC = twentysevenRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
twentynineRC = twentyeightRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
thirtyRC = twentynineRC[1] and close < open and samplePeriodFilter and barstate.isconfirmed
var oneGCcounter = 0
var twoGCcounter = 0
var threeGCcounter = 0
var fourGCcounter = 0
var fiveGCcounter = 0
var sixGCcounter = 0
var sevenGCcounter = 0
var eightGCcounter = 0
var nineGCcounter = 0
var tenGCcounter = 0
var elevenGCcounter = 0
var twelveGCcounter = 0
var thirteenGCcounter = 0
var fourteenGCcounter = 0
var fifteenGCcounter = 0
var sixteenGCcounter = 0
var seventeenGCcounter = 0
var eighteenGCcounter = 0
var nineteenGCcounter = 0
var twentyGCcounter = 0
var twentyoneGCcounter = 0
var twentytwoGCcounter = 0
var twentythreeGCcounter = 0
var twentyfourGCcounter = 0
var twentyfiveGCcounter = 0
var twentysixGCcounter = 0
var twentysevenGCcounter = 0
var twentyeightGCcounter = 0
var twentynineGCcounter = 0
var thirtyGCcounter = 0
var oneRCcounter = 0
var twoRCcounter = 0
var threeRCcounter = 0
var fourRCcounter = 0
var fiveRCcounter = 0
var sixRCcounter = 0
var sevenRCcounter = 0
var eightRCcounter = 0
var nineRCcounter = 0
var tenRCcounter = 0
var elevenRCcounter = 0
var twelveRCcounter = 0
var thirteenRCcounter = 0
var fourteenRCcounter = 0
var fifteenRCcounter = 0
var sixteenRCcounter = 0
var seventeenRCcounter = 0
var eighteenRCcounter = 0
var nineteenRCcounter = 0
var twentyRCcounter = 0
var twentyoneRCcounter = 0
var twentytwoRCcounter = 0
var twentythreeRCcounter = 0
var twentyfourRCcounter = 0
var twentyfiveRCcounter = 0
var twentysixRCcounter = 0
var twentysevenRCcounter = 0
var twentyeightRCcounter = 0
var twentynineRCcounter = 0
var thirtyRCcounter = 0
if oneGC
oneGCcounter += 1
if twoGC
twoGCcounter += 1
if threeGC
threeGCcounter += 1
if fourGC
fourGCcounter += 1
if fiveGC
fiveGCcounter += 1
if sixGC
sixGCcounter += 1
if sevenGC
sevenGCcounter += 1
if eightGC
eightGCcounter += 1
if nineGC
nineGCcounter += 1
if tenGC
tenGCcounter += 1
if elevenGC
elevenGCcounter += 1
if twelveGC
twelveGCcounter += 1
if thirteenGC
thirteenGCcounter += 1
if fourteenGC
fourteenGCcounter += 1
if fifteenGC
fifteenGCcounter += 1
if sixteenGC
sixteenGCcounter += 1
if seventeenGC
seventeenGCcounter += 1
if eighteenGC
eighteenGCcounter += 1
if nineteenGC
nineteenGCcounter += 1
if twentyGC
twentyGCcounter += 1
if twentyoneGC
twentyoneGCcounter += 1
if twentytwoGC
twentytwoGCcounter += 1
if twentythreeGC
twentythreeGCcounter += 1
if twentyfourGC
twentyfourGCcounter += 1
if twentyfiveGC
twentyfiveGCcounter += 1
if twentysixGC
twentysixGCcounter += 1
if twentysevenGC
twentysevenGCcounter += 1
if twentyeightGC
twentyeightGCcounter += 1
if twentynineGC
twentynineGCcounter += 1
if thirtyGC
thirtyGCcounter += 1
if oneRC
oneRCcounter += 1
if twoRC
twoRCcounter += 1
if threeRC
threeRCcounter += 1
if fourRC
fourRCcounter += 1
if fiveRC
fiveRCcounter += 1
if sixRC
sixRCcounter += 1
if sevenRC
sevenRCcounter += 1
if eightRC
eightRCcounter += 1
if nineRC
nineRCcounter += 1
if tenRC
tenRCcounter += 1
if elevenRC
elevenRCcounter += 1
if twelveRC
twelveRCcounter += 1
if thirteenRC
thirteenRCcounter += 1
if fourteenRC
fourteenRCcounter += 1
if fifteenRC
fifteenRCcounter += 1
if sixteenRC
sixteenRCcounter += 1
if seventeenRC
seventeenRCcounter += 1
if eighteenRC
eighteenRCcounter += 1
if nineteenRC
nineteenRCcounter += 1
if twentyRC
twentyRCcounter += 1
if twentyoneRC
twentyoneRCcounter += 1
if twentytwoRC
twentytwoRCcounter += 1
if twentythreeRC
twentythreeRCcounter += 1
if twentyfourRC
twentyfourRCcounter += 1
if twentyfiveRC
twentyfiveRCcounter += 1
if twentysixRC
twentysixRCcounter += 1
if twentysevenRC
twentysevenRCcounter += 1
if twentyeightRC
twentyeightRCcounter += 1
if twentynineRC
twentynineRCcounter += 1
if thirtyRC
thirtyRCcounter += 1
///////////
// TABLE //
///////////
candleTrendTablePositionInput = input.string(title = 'Position', defval = 'Top Right', options = ['Top Right', 'Top Center', 'Top Left', 'Bottom Right', 'Bottom Center', 'Bottom Left',
'Middle Right', 'Middle Center', 'Middle Left'], group = 'Table Positioning')
candleTrendTablePosition = candleTrendTablePositionInput == 'Top Right' ? position.top_right : candleTrendTablePositionInput == 'Top Center' ? position.top_center :
candleTrendTablePositionInput == 'Top Left' ? position.top_left : candleTrendTablePositionInput == 'Bottom Right' ? position.bottom_right :
candleTrendTablePositionInput == 'Bottom Center' ? position.bottom_center : candleTrendTablePositionInput == 'Bottom Left' ? position.bottom_left :
candleTrendTablePositionInput == 'Middle Right' ? position.middle_right : candleTrendTablePositionInput == 'Middle Center' ? position.middle_center :
candleTrendTablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input.string(title = 'Text Size', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
var candleTrendTable = table.new(candleTrendTablePosition, 100, 100, border_width = 1)
table.cell(candleTrendTable, 1, 0, text = 'Green Swings', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 0, text = '% Total', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 0, text = '% Last', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 0, 1, text = '1-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 1, text = str.tostring(oneGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 1, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 0, text = 'Red Swings', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 0, text = '% Total', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 0, text = '% Last', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 1, text = str.tostring(oneRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 1, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twoGCcounter >= 1 or twoRCcounter >= 1)
table.cell(candleTrendTable, 0, 2, text = '2-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 2, text = str.tostring(twoGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 2, text = str.tostring(math.round(twoGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 2, text = '-', bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 2, text = str.tostring(twoRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 2, text = str.tostring(math.round(twoRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 2, text = '-', bgcolor = color.red, text_color = color.white, text_size = textSize)
if (threeGCcounter >= 1 or threeRCcounter >= 1)
table.cell(candleTrendTable, 0, 3, text = '3-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 3, text = str.tostring(threeGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 3, text = str.tostring(math.round(threeGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 3, text = str.tostring(math.round(threeGCcounter / twoGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 3, text = str.tostring(threeRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 3, text = str.tostring(math.round(threeRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 3, text = str.tostring(math.round(threeRCcounter / twoRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourGCcounter >= 1 or fourRCcounter >= 1)
table.cell(candleTrendTable, 0, 4, text = '4-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 4, text = str.tostring(fourGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 4, text = str.tostring(math.round(fourGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 4, text = str.tostring(math.round(fourGCcounter / threeGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 4, text = str.tostring(fourRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 4, text = str.tostring(math.round(fourRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 4, text = str.tostring(math.round(fourRCcounter / threeRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fiveGCcounter >= 1 or fiveRCcounter >= 1)
table.cell(candleTrendTable, 0, 5, text = '5-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 5, text = str.tostring(fiveGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 5, text = str.tostring(math.round(fiveGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 5, text = str.tostring(math.round(fiveGCcounter / fourGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 5, text = str.tostring(fiveRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 5, text = str.tostring(math.round(fiveRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 5, text = str.tostring(math.round(fiveRCcounter / fourRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixGCcounter >= 1 or sixRCcounter >= 1)
table.cell(candleTrendTable, 0, 6, text = '6-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 6, text = str.tostring(sixGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 6, text = str.tostring(math.round(sixGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 6, text = str.tostring(math.round(sixGCcounter / fiveGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 6, text = str.tostring(sixRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 6, text = str.tostring(math.round(sixRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 6, text = str.tostring(math.round(sixRCcounter / fiveRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sevenGCcounter >= 1 or sevenRCcounter >= 1)
table.cell(candleTrendTable, 0, 7, text = '7-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 7, text = str.tostring(sevenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 7, text = str.tostring(math.round(sevenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 7, text = str.tostring(math.round(sevenGCcounter / sixGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 7, text = str.tostring(sevenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 7, text = str.tostring(math.round(sevenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 7, text = str.tostring(math.round(sevenRCcounter / sixRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eightGCcounter >= 1 or eightRCcounter >= 1)
table.cell(candleTrendTable, 0, 8, text = '8-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 8, text = str.tostring(eightGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 8, text = str.tostring(math.round(eightGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 8, text = str.tostring(math.round(eightGCcounter / sevenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 8, text = str.tostring(eightRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 8, text = str.tostring(math.round(eightRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 8, text = str.tostring(math.round(eightRCcounter / sevenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineGCcounter >= 1 or nineRCcounter >= 1)
table.cell(candleTrendTable, 0, 9, text = '9-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 9, text = str.tostring(nineGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 9, text = str.tostring(math.round(nineGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 9, text = str.tostring(math.round(nineGCcounter / eightGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 9, text = str.tostring(nineRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 9, text = str.tostring(math.round(nineRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 9, text = str.tostring(math.round(nineRCcounter / eightRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (tenGCcounter >= 1 or tenRCcounter >= 1)
table.cell(candleTrendTable, 0, 10, text = '10-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 10, text = str.tostring(tenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 10, text = str.tostring(math.round(tenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 10, text = str.tostring(math.round(tenGCcounter / nineGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 10, text = str.tostring(tenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 10, text = str.tostring(math.round(tenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 10, text = str.tostring(math.round(tenRCcounter / nineRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (elevenGCcounter >= 1 or elevenRCcounter >= 1)
table.cell(candleTrendTable, 0, 11, text = '11-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 11, text = str.tostring(elevenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 11, text = str.tostring(math.round(elevenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 11, text = str.tostring(math.round(elevenGCcounter / tenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 11, text = str.tostring(elevenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 11, text = str.tostring(math.round(elevenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 11, text = str.tostring(math.round(elevenRCcounter / tenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twelveGCcounter >= 1 or twelveRCcounter >= 1)
table.cell(candleTrendTable, 0, 12, text = '12-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 12, text = str.tostring(twelveGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 12, text = str.tostring(math.round(twelveGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 12, text = str.tostring(math.round(twelveGCcounter / elevenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 12, text = str.tostring(twelveRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 12, text = str.tostring(math.round(twelveRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 12, text = str.tostring(math.round(twelveRCcounter / elevenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirteenGCcounter >= 1 or thirteenRCcounter >= 1)
table.cell(candleTrendTable, 0, 13, text = '13-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 13, text = str.tostring(thirteenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 13, text = str.tostring(math.round(thirteenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 13, text = str.tostring(math.round(thirteenGCcounter / twelveGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 13, text = str.tostring(thirteenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 13, text = str.tostring(math.round(thirteenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 13, text = str.tostring(math.round(thirteenRCcounter / twelveRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourteenGCcounter >= 1 or fourteenRCcounter >= 1)
table.cell(candleTrendTable, 0, 14, text = '14-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 14, text = str.tostring(fourteenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 14, text = str.tostring(math.round(fourteenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 14, text = str.tostring(math.round(fourteenGCcounter / thirteenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 14, text = str.tostring(fourteenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 14, text = str.tostring(math.round(fourteenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 14, text = str.tostring(math.round(fourteenRCcounter / thirteenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fifteenGCcounter >= 1 or fifteenRCcounter >= 1)
table.cell(candleTrendTable, 0, 15, text = '15-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 15, text = str.tostring(fifteenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 15, text = str.tostring(math.round(fifteenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 15, text = str.tostring(math.round(fifteenGCcounter / fourteenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 15, text = str.tostring(fifteenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 15, text = str.tostring(math.round(fifteenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 15, text = str.tostring(math.round(fifteenRCcounter / fourteenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixteenGCcounter >= 1 or sixteenRCcounter >= 1)
table.cell(candleTrendTable, 0, 16, text = '16-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 16, text = str.tostring(sixteenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 16, text = str.tostring(math.round(sixteenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 16, text = str.tostring(math.round(sixteenGCcounter / fifteenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 16, text = str.tostring(sixteenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 16, text = str.tostring(math.round(sixteenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 16, text = str.tostring(math.round(sixteenRCcounter / fifteenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (seventeenGCcounter >= 1 or seventeenRCcounter >= 1)
table.cell(candleTrendTable, 0, 17, text = '17-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 17, text = str.tostring(seventeenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 17, text = str.tostring(math.round(seventeenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 17, text = str.tostring(math.round(seventeenGCcounter / sixteenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 17, text = str.tostring(seventeenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 17, text = str.tostring(math.round(seventeenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 17, text = str.tostring(math.round(seventeenRCcounter / sixteenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eighteenGCcounter >= 1 or eighteenRCcounter >= 1)
table.cell(candleTrendTable, 0, 18, text = '18-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 18, text = str.tostring(eighteenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 18, text = str.tostring(math.round(eighteenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 18, text = str.tostring(math.round(eighteenGCcounter / seventeenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 18, text = str.tostring(eighteenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 18, text = str.tostring(math.round(eighteenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 18, text = str.tostring(math.round(eighteenRCcounter / seventeenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineteenGCcounter >= 1 or nineteenRCcounter >= 1)
table.cell(candleTrendTable, 0, 19, text = '19-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 19, text = str.tostring(nineteenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 19, text = str.tostring(math.round(nineteenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 19, text = str.tostring(math.round(nineteenGCcounter / eighteenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 19, text = str.tostring(nineteenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 19, text = str.tostring(math.round(nineteenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 19, text = str.tostring(math.round(nineteenRCcounter / eighteenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyGCcounter >= 1 or twentyRCcounter >= 1)
table.cell(candleTrendTable, 0, 20, text = '20-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 20, text = str.tostring(twentyGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 20, text = str.tostring(math.round(twentyGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 20, text = str.tostring(math.round(twentyGCcounter / nineteenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 20, text = str.tostring(twentyRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 20, text = str.tostring(math.round(twentyRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 20, text = str.tostring(math.round(twentyRCcounter / nineteenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyoneGCcounter >= 1 or twentyoneRCcounter >= 1)
table.cell(candleTrendTable, 0, 21, text = '21-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 21, text = str.tostring(twentyoneGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 21, text = str.tostring(math.round(twentyoneGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 21, text = str.tostring(math.round(twentyoneGCcounter / twentyGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 21, text = str.tostring(twentyoneRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 21, text = str.tostring(math.round(twentyoneRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 21, text = str.tostring(math.round(twentyoneRCcounter / twentyRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentytwoGCcounter >= 1 or twentytwoRCcounter >= 1)
table.cell(candleTrendTable, 0, 22, text = '22-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 22, text = str.tostring(twentytwoGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 22, text = str.tostring(math.round(twentytwoGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 22, text = str.tostring(math.round(twentytwoGCcounter / twentyoneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 22, text = str.tostring(twentytwoRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 22, text = str.tostring(math.round(twentytwoRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 22, text = str.tostring(math.round(twentytwoRCcounter / twentyoneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentythreeGCcounter >= 1 or twentythreeRCcounter >= 1)
table.cell(candleTrendTable, 0, 23, text = '23-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 23, text = str.tostring(twentythreeGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 23, text = str.tostring(math.round(twentythreeGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 23, text = str.tostring(math.round(twentythreeGCcounter / twentytwoGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 23, text = str.tostring(twentythreeRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 23, text = str.tostring(math.round(twentythreeRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 23, text = str.tostring(math.round(twentythreeRCcounter / twentytwoRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfourGCcounter >= 1 or twentyfourRCcounter >= 1)
table.cell(candleTrendTable, 0, 24, text = '24-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 24, text = str.tostring(twentyfourGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 24, text = str.tostring(math.round(twentyfourGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 24, text = str.tostring(math.round(twentyfourGCcounter / twentythreeGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 24, text = str.tostring(twentyfourRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 24, text = str.tostring(math.round(twentyfourRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 24, text = str.tostring(math.round(twentyfourRCcounter / twentythreeRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyfiveGCcounter >= 1 or twentyfiveRCcounter >= 1)
table.cell(candleTrendTable, 0, 25, text = '25-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 25, text = str.tostring(twentyfiveGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 25, text = str.tostring(math.round(twentyfiveGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 25, text = str.tostring(math.round(twentyfiveGCcounter / twentyfourGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 25, text = str.tostring(twentyfiveRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 25, text = str.tostring(math.round(twentyfiveRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 25, text = str.tostring(math.round(twentyfiveRCcounter / twentyfourRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysixGCcounter >= 1 or twentysixRCcounter >= 1)
table.cell(candleTrendTable, 0, 26, text = '26-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 26, text = str.tostring(twentysixGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 26, text = str.tostring(math.round(twentysixGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 26, text = str.tostring(math.round(twentysixGCcounter / twentyfiveGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 26, text = str.tostring(twentysixRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 26, text = str.tostring(math.round(twentysixRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 26, text = str.tostring(math.round(twentysixRCcounter / twentyfiveRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentysevenGCcounter >= 1 or twentysevenRCcounter >= 1)
table.cell(candleTrendTable, 0, 27, text = '27-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 27, text = str.tostring(twentysevenGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 27, text = str.tostring(math.round(twentysevenGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 27, text = str.tostring(math.round(twentysevenGCcounter / twentysixGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 27, text = str.tostring(twentysevenRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 27, text = str.tostring(math.round(twentysevenRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 27, text = str.tostring(math.round(twentysevenRCcounter / twentysixRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyeightGCcounter >= 1 or twentyeightRCcounter >= 1)
table.cell(candleTrendTable, 0, 28, text = '28-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 28, text = str.tostring(twentyeightGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 28, text = str.tostring(math.round(twentyeightGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 28, text = str.tostring(math.round(twentyeightGCcounter / twentysevenGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 28, text = str.tostring(twentyeightRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 28, text = str.tostring(math.round(twentyeightRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 28, text = str.tostring(math.round(twentyeightRCcounter / twentysevenRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentynineGCcounter >= 1 or twentynineRCcounter >= 1)
table.cell(candleTrendTable, 0, 29, text = '29-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 29, text = str.tostring(twentynineGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 29, text = str.tostring(math.round(twentynineGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 29, text = str.tostring(math.round(twentynineGCcounter / twentyeightGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 29, text = str.tostring(twentynineRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 29, text = str.tostring(math.round(twentynineRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 29, text = str.tostring(math.round(twentynineRCcounter / twentyeightRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirtyGCcounter >= 1 or thirtyRCcounter >= 1)
table.cell(candleTrendTable, 0, 30, text = '30-Candle', bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 1, 30, text = str.tostring(thirtyGCcounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 2, 30, text = str.tostring(math.round(thirtyGCcounter / oneGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 3, 30, text = str.tostring(math.round(thirtyGCcounter / twentynineGCcounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 4, 30, text = str.tostring(thirtyRCcounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 5, 30, text = str.tostring(math.round(thirtyRCcounter / oneRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(candleTrendTable, 6, 30, text = str.tostring(math.round(thirtyRCcounter / twentynineRCcounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(candleTrendTable, 0, 31, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
///////////
// PLOTS //
///////////
showPlots = input(defval = true, title = "Show Plots", group = 'Plots')
plotshape(oneGC and showPlots, style = shape.triangleup, color = color.green, text = '1', textcolor = color.green, location = location.belowbar)
plotshape(twoGC and showPlots, style = shape.triangleup, color = color.green, text = '2', textcolor = color.green, location = location.belowbar)
plotshape(threeGC and showPlots, style = shape.triangleup, color = color.green, text = '3', textcolor = color.green, location = location.belowbar)
plotshape(fourGC and showPlots, style = shape.triangleup, color = color.green, text = '4', textcolor = color.green, location = location.belowbar)
plotshape(fiveGC and showPlots, style = shape.triangleup, color = color.green, text = '5', textcolor = color.green, location = location.belowbar)
plotshape(sixGC and showPlots, style = shape.triangleup, color = color.green, text = '6', textcolor = color.green, location = location.belowbar)
plotshape(sevenGC and showPlots, style = shape.triangleup, color = color.green, text = '7', textcolor = color.green, location = location.belowbar)
plotshape(eightGC and showPlots, style = shape.triangleup, color = color.green, text = '8', textcolor = color.green, location = location.belowbar)
plotshape(nineGC and showPlots, style = shape.triangleup, color = color.green, text = '9', textcolor = color.green, location = location.belowbar)
plotshape(tenGC and showPlots, style = shape.triangleup, color = color.green, text = '10', textcolor = color.green, location = location.belowbar)
plotshape(elevenGC and showPlots, style = shape.triangleup, color = color.green, text = '11', textcolor = color.green, location = location.belowbar)
plotshape(twelveGC and showPlots, style = shape.triangleup, color = color.green, text = '12', textcolor = color.green, location = location.belowbar)
plotshape(thirteenGC and showPlots, style = shape.triangleup, color = color.green, text = '13', textcolor = color.green, location = location.belowbar)
plotshape(fourteenGC and showPlots, style = shape.triangleup, color = color.green, text = '14', textcolor = color.green, location = location.belowbar)
plotshape(fifteenGC and showPlots, style = shape.triangleup, color = color.green, text = '15', textcolor = color.green, location = location.belowbar)
plotshape(sixteenGC and showPlots, style = shape.triangleup, color = color.green, text = '16', textcolor = color.green, location = location.belowbar)
plotshape(seventeenGC and showPlots, style = shape.triangleup, color = color.green, text = '17', textcolor = color.green, location = location.belowbar)
plotshape(eighteenGC and showPlots, style = shape.triangleup, color = color.green, text = '18', textcolor = color.green, location = location.belowbar)
plotshape(nineteenGC and showPlots, style = shape.triangleup, color = color.green, text = '19', textcolor = color.green, location = location.belowbar)
plotshape(twentyGC and showPlots, style = shape.triangleup, color = color.green, text = '20', textcolor = color.green, location = location.belowbar)
plotshape(twentyoneGC and showPlots, style = shape.triangleup, color = color.green, text = '21', textcolor = color.green, location = location.belowbar)
plotshape(twentytwoGC and showPlots, style = shape.triangleup, color = color.green, text = '22', textcolor = color.green, location = location.belowbar)
plotshape(twentythreeGC and showPlots, style = shape.triangleup, color = color.green, text = '23', textcolor = color.green, location = location.belowbar)
plotshape(twentyfourGC and showPlots, style = shape.triangleup, color = color.green, text = '24', textcolor = color.green, location = location.belowbar)
plotshape(twentyfiveGC and showPlots, style = shape.triangleup, color = color.green, text = '25', textcolor = color.green, location = location.belowbar)
plotshape(twentysixGC and showPlots, style = shape.triangleup, color = color.green, text = '26', textcolor = color.green, location = location.belowbar)
plotshape(twentysevenGC and showPlots, style = shape.triangleup, color = color.green, text = '27', textcolor = color.green, location = location.belowbar)
plotshape(twentyeightGC and showPlots, style = shape.triangleup, color = color.green, text = '28', textcolor = color.green, location = location.belowbar)
plotshape(twentynineGC and showPlots, style = shape.triangleup, color = color.green, text = '29', textcolor = color.green, location = location.belowbar)
plotshape(thirtyGC and showPlots, style = shape.triangleup, color = color.green, text = '30', textcolor = color.green, location = location.belowbar)
plotshape(oneRC and showPlots, style = shape.triangledown, color = color.red, text = '1', textcolor = color.red)
plotshape(twoRC and showPlots, style = shape.triangledown, color = color.red, text = '2', textcolor = color.red)
plotshape(threeRC and showPlots, style = shape.triangledown, color = color.red, text = '3', textcolor = color.red)
plotshape(fourRC and showPlots, style = shape.triangledown, color = color.red, text = '4', textcolor = color.red)
plotshape(fiveRC and showPlots, style = shape.triangledown, color = color.red, text = '5', textcolor = color.red)
plotshape(sixRC and showPlots, style = shape.triangledown, color = color.red, text = '6', textcolor = color.red)
plotshape(sevenRC and showPlots, style = shape.triangledown, color = color.red, text = '7', textcolor = color.red)
plotshape(eightRC and showPlots, style = shape.triangledown, color = color.red, text = '8', textcolor = color.red)
plotshape(nineRC and showPlots, style = shape.triangledown, color = color.red, text = '9', textcolor = color.red)
plotshape(tenRC and showPlots, style = shape.triangledown, color = color.red, text = '10', textcolor = color.red)
plotshape(elevenRC and showPlots, style = shape.triangledown, color = color.red, text = '11', textcolor = color.red)
plotshape(twelveRC and showPlots, style = shape.triangledown, color = color.red, text = '12', textcolor = color.red)
plotshape(thirteenRC and showPlots, style = shape.triangledown, color = color.red, text = '13', textcolor = color.red)
plotshape(fourteenRC and showPlots, style = shape.triangledown, color = color.red, text = '14', textcolor = color.red)
plotshape(fifteenRC and showPlots, style = shape.triangledown, color = color.red, text = '15', textcolor = color.red)
plotshape(sixteenRC and showPlots, style = shape.triangledown, color = color.red, text = '16', textcolor = color.red)
plotshape(seventeenRC and showPlots, style = shape.triangledown, color = color.red, text = '17', textcolor = color.red)
plotshape(eighteenRC and showPlots, style = shape.triangledown, color = color.red, text = '18', textcolor = color.red)
plotshape(nineteenRC and showPlots, style = shape.triangledown, color = color.red, text = '19', textcolor = color.red)
plotshape(twentyRC and showPlots, style = shape.triangledown, color = color.red, text = '20', textcolor = color.red)
plotshape(twentyoneRC and showPlots, style = shape.triangledown, color = color.red, text = '21', textcolor = color.red)
plotshape(twentytwoRC and showPlots, style = shape.triangledown, color = color.red, text = '22', textcolor = color.red)
plotshape(twentythreeRC and showPlots, style = shape.triangledown, color = color.red, text = '23', textcolor = color.red)
plotshape(twentyfourRC and showPlots, style = shape.triangledown, color = color.red, text = '24', textcolor = color.red)
plotshape(twentyfiveRC and showPlots, style = shape.triangledown, color = color.red, text = '25', textcolor = color.red)
plotshape(twentysixRC and showPlots, style = shape.triangledown, color = color.red, text = '26', textcolor = color.red)
plotshape(twentysevenRC and showPlots, style = shape.triangledown, color = color.red, text = '27', textcolor = color.red)
plotshape(twentyeightRC and showPlots, style = shape.triangledown, color = color.red, text = '28', textcolor = color.red)
plotshape(twentynineRC and showPlots, style = shape.triangledown, color = color.red, text = '29', textcolor = color.red)
plotshape(thirtyRC and showPlots, style = shape.triangledown, color = color.red, text = '30', textcolor = color.red)
////////////
// ALERTS //
////////////
addOneGreenAlert = input(defval = true, title = 'One Green Alert', group = 'Green Candle Trend Alerts')
addTwoGreenAlert = input(defval = false, title = 'Two Green Alert', group = 'Green Candle Trend Alerts')
addThreeGreenAlert = input(defval = false, title = 'Three Green Alert', group = 'Green Candle Trend Alerts')
addFourGreenAlert = input(defval = false, title = 'Four Green Alert', group = 'Green Candle Trend Alerts')
addFiveGreenAlert = input(defval = false, title = 'Five Green Alert', group = 'Green Candle Trend Alerts')
addSixGreenAlert = input(defval = false, title = 'Six Green Alert', group = 'Green Candle Trend Alerts')
addSevenGreenAlert = input(defval = false, title = 'Seven Green Alert', group = 'Green Candle Trend Alerts')
addEightGreenAlert = input(defval = false, title = 'Eight Green Alert', group = 'Green Candle Trend Alerts')
addNineGreenAlert = input(defval = false, title = 'Nine Green Alert', group = 'Green Candle Trend Alerts')
addTenGreenAlert = input(defval = false, title = 'Ten Green Alert', group = 'Green Candle Trend Alerts')
addElevenGreenAlert = input(defval = false, title = 'Eleven Green Alert', group = 'Green Candle Trend Alerts')
addTwelveGreenAlert = input(defval = false, title = 'Twelve Green Alert', group = 'Green Candle Trend Alerts')
addThirteenGreenAlert = input(defval = false, title = 'Thirteen Green Alert', group = 'Green Candle Trend Alerts')
addFourteenGreenAlert = input(defval = false, title = 'Fourteen Green Alert', group = 'Green Candle Trend Alerts')
addFifteenGreenAlert = input(defval = false, title = 'Fifteen Green Alert', group = 'Green Candle Trend Alerts')
addSixteenGreenAlert = input(defval = false, title = 'Sixteen Green Alert', group = 'Green Candle Trend Alerts')
addSeventeenGreenAlert = input(defval = false, title = 'Seventeen Green Alert', group = 'Green Candle Trend Alerts')
addEighteenGreenAlert = input(defval = false, title = 'Eighteen Green Alert', group = 'Green Candle Trend Alerts')
addNineteenGreenAlert = input(defval = false, title = 'Nineteen Green Alert', group = 'Green Candle Trend Alerts')
addTwentyGreenAlert = input(defval = false, title = 'Twenty Green Alert', group = 'Green Candle Trend Alerts')
addTwentyOneGreenAlert = input(defval = false, title = 'Twenty-One Green Alert', group = 'Green Candle Trend Alerts')
addTwentyTwoGreenAlert = input(defval = false, title = 'Twenty-Two Green Alert', group = 'Green Candle Trend Alerts')
addTwentyThreeGreenAlert = input(defval = false, title = 'Twenty-Three Green Alert', group = 'Green Candle Trend Alerts')
addTwentyFourGreenAlert = input(defval = false, title = 'Twenty-Four Green Alert', group = 'Green Candle Trend Alerts')
addTwentyFiveGreenAlert = input(defval = false, title = 'Twenty-Five Green Alert', group = 'Green Candle Trend Alerts')
addTwentySixGreenAlert = input(defval = false, title = 'Twenty-Six Green Alert', group = 'Green Candle Trend Alerts')
addTwentySevenGreenAlert = input(defval = false, title = 'Twenty-Seven Green Alert', group = 'Green Candle Trend Alerts')
addTwentyEightGreenAlert = input(defval = false, title = 'Twenty-Eight Green Alert', group = 'Green Candle Trend Alerts')
addTwentyNineGreenAlert = input(defval = false, title = 'Twenty-Nine Green Alert', group = 'Green Candle Trend Alerts')
addThirtyGreenAlert = input(defval = false, title = 'Thirty Green Alert', group = 'Green Candle Trend Alerts')
addOneRedAlert = input(defval = true, title = 'One Red Alert', group = 'Red Candle Trend Alerts')
addTwoRedAlert = input(defval = false, title = 'Two Red Alert', group = 'Red Candle Trend Alerts')
addThreeRedAlert = input(defval = false, title = 'Three Red Alert', group = 'Red Candle Trend Alerts')
addFourRedAlert = input(defval = false, title = 'Four Red Alert', group = 'Red Candle Trend Alerts')
addFiveRedAlert = input(defval = false, title = 'Five Red Alert', group = 'Red Candle Trend Alerts')
addSixRedAlert = input(defval = false, title = 'Six Red Alert', group = 'Red Candle Trend Alerts')
addSevenRedAlert = input(defval = false, title = 'Seven Red Alert', group = 'Red Candle Trend Alerts')
addEightRedAlert = input(defval = false, title = 'Eight Red Alert', group = 'Red Candle Trend Alerts')
addNineRedAlert = input(defval = false, title = 'Nine Red Alert', group = 'Red Candle Trend Alerts')
addTenRedAlert = input(defval = false, title = 'Ten Red Alert', group = 'Red Candle Trend Alerts')
addElevenRedAlert = input(defval = false, title = 'Eleven Red Alert', group = 'Red Candle Trend Alerts')
addTwelveRedAlert = input(defval = false, title = 'Twelve Red Alert', group = 'Red Candle Trend Alerts')
addThirteenRedAlert = input(defval = false, title = 'Thirteen Red Alert', group = 'Red Candle Trend Alerts')
addFourteenRedAlert = input(defval = false, title = 'Fourteen Red Alert', group = 'Red Candle Trend Alerts')
addFifteenRedAlert = input(defval = false, title = 'Fifteen Red Alert', group = 'Red Candle Trend Alerts')
addSixteenRedAlert = input(defval = false, title = 'Sixteen Red Alert', group = 'Red Candle Trend Alerts')
addSeventeenRedAlert = input(defval = false, title = 'Seventeen Red Alert', group = 'Red Candle Trend Alerts')
addEighteenRedAlert = input(defval = false, title = 'Eighteen Red Alert', group = 'Red Candle Trend Alerts')
addNineteenRedAlert = input(defval = false, title = 'Nineteen Red Alert', group = 'Red Candle Trend Alerts')
addTwentyRedAlert = input(defval = false, title = 'Twenty Red Alert', group = 'Red Candle Trend Alerts')
addTwentyOneRedAlert = input(defval = false, title = 'Twenty-One Red Alert', group = 'Red Candle Trend Alerts')
addTwentyTwoRedAlert = input(defval = false, title = 'Twenty-Two Red Alert', group = 'Red Candle Trend Alerts')
addTwentyThreeRedAlert = input(defval = false, title = 'Twenty-Three Red Alert', group = 'Red Candle Trend Alerts')
addTwentyFourRedAlert = input(defval = false, title = 'Twenty-Four Red Alert', group = 'Red Candle Trend Alerts')
addTwentyFiveRedAlert = input(defval = false, title = 'Twenty-Five Red Alert', group = 'Red Candle Trend Alerts')
addTwentySixRedAlert = input(defval = false, title = 'Twenty-Six Red Alert', group = 'Red Candle Trend Alerts')
addTwentySevenRedAlert = input(defval = false, title = 'Twenty-Seven Red Alert', group = 'Red Candle Trend Alerts')
addTwentyEightRedAlert = input(defval = false, title = 'Twenty-Eight Red Alert', group = 'Red Candle Trend Alerts')
addTwentyNineRedAlert = input(defval = false, title = 'Twenty-Nine Red Alert', group = 'Red Candle Trend Alerts')
addThirtyRedAlert = input(defval = false, title = 'Thirty Red Alert', group = 'Red Candle Trend Alerts')
if oneGC and addOneGreenAlert
alert('One Green')
if twoGC and addTwoGreenAlert
alert('Two Green')
if threeGC and addThreeGreenAlert
alert('Three Green')
if fourGC and addFourGreenAlert
alert('Four Green')
if fiveGC and addFiveGreenAlert
alert('Five Green')
if sixGC and addSixGreenAlert
alert('Six Green')
if sevenGC and addSevenGreenAlert
alert('Seven Green')
if eightGC and addEightGreenAlert
alert('Eight Green')
if nineGC and addNineGreenAlert
alert('Nine Green')
if tenGC and addTenGreenAlert
alert('Ten Green')
if elevenGC and addElevenGreenAlert
alert('Eleven Green')
if twelveGC and addTwelveGreenAlert
alert('Twleve Green')
if thirteenGC and addThirteenGreenAlert
alert('Thirteen Green')
if fourteenGC and addFourteenGreenAlert
alert('Fourteen Green')
if fifteenGC and addFifteenGreenAlert
alert('Fifteen Green')
if sixteenGC and addSixteenGreenAlert
alert('Sixteen Green')
if seventeenGC and addSeventeenGreenAlert
alert('Seventeen Green')
if eighteenGC and addEighteenGreenAlert
alert('Eighteen Green')
if nineteenGC and addNineteenGreenAlert
alert('Nineteen Green')
if twentyGC and addTwentyGreenAlert
alert('Twenty Green')
if twentyoneGC and addTwentyOneGreenAlert
alert('Twenty-One Green')
if twentytwoGC and addTwentyTwoGreenAlert
alert('Twenty-Two Green')
if twentythreeGC and addTwentyThreeGreenAlert
alert('Twenty-Three Green')
if twentyfourGC and addTwentyFourGreenAlert
alert('Twenty-Four Green')
if twentyfiveGC and addTwentyFiveGreenAlert
alert('Twenty-Five Green')
if twentysixGC and addTwentySixGreenAlert
alert('Twenty-Six Green')
if twentysevenGC and addTwentySevenGreenAlert
alert('Twenty-Seven Green')
if twentyeightGC and addTwentyEightGreenAlert
alert('Twenty-Eight Green')
if twentynineGC and addTwentyNineGreenAlert
alert('Twenty-Nine Green')
if thirtyGC and addThirtyGreenAlert
alert('Thirty Green')
if oneRC and addOneRedAlert
alert('One Red')
if twoRC and addTwoRedAlert
alert('Two Red')
if threeRC and addThreeRedAlert
alert('Three Red')
if fourRC and addFourRedAlert
alert('Four Red')
if fiveRC and addFiveRedAlert
alert('Five Red')
if sixRC and addSixRedAlert
alert('Six Red')
if sevenRC and addSevenRedAlert
alert('Seven Red')
if eightRC and addEightRedAlert
alert('Eight Red')
if nineRC and addNineRedAlert
alert('Nine Red')
if tenRC and addTenRedAlert
alert('Ten Red')
if elevenRC and addElevenRedAlert
alert('Eleven Red')
if twelveRC and addTwelveRedAlert
alert('Twleve Red')
if thirteenRC and addThirteenRedAlert
alert('Thirteen Red')
if fourteenRC and addFourteenRedAlert
alert('Fourteen Red')
if fifteenRC and addFifteenRedAlert
alert('Fifteen Red')
if sixteenRC and addSixteenRedAlert
alert('Sixteen Red')
if seventeenRC and addSeventeenRedAlert
alert('Seventeen Red')
if eighteenRC and addEighteenRedAlert
alert('Eighteen Red')
if nineteenRC and addNineteenRedAlert
alert('Nineteen Red')
if twentyRC and addTwentyRedAlert
alert('Twenty Red')
if twentyoneRC and addTwentyOneRedAlert
alert('Twenty-One Red')
if twentytwoRC and addTwentyTwoRedAlert
alert('Twenty-Two Red')
if twentythreeRC and addTwentyThreeRedAlert
alert('Twenty-Three Red')
if twentyfourRC and addTwentyFourRedAlert
alert('Twenty-Four Red')
if twentyfiveRC and addTwentyFiveRedAlert
alert('Twenty-Five Red')
if twentysixRC and addTwentySixRedAlert
alert('Twenty-Six Red')
if twentysevenRC and addTwentySevenRedAlert
alert('Twenty-Seven Red')
if twentyeightRC and addTwentyEightRedAlert
alert('Twenty-Eight Red')
if twentynineRC and addTwentyNineRedAlert
alert('Twenty-Nine Red')
if thirtyRC and addThirtyRedAlert
alert('Thirty Red') |
Uptrends [theEccentricTrader] | https://www.tradingview.com/script/pzOrfxND-Uptrends-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 23 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Uptrends [theEccentricTrader]', overlay = true)
//////////// uptrends ////////////
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
onePartUptrend = slPrice > ta.valuewhen(slPrice, slPrice, 1)
twoPartUptrend = onePartUptrend and ta.valuewhen(slPrice, slPrice, 1) > ta.valuewhen(slPrice, slPrice, 2)
threePartUptrend = twoPartUptrend and ta.valuewhen(slPrice, slPrice, 2) > ta.valuewhen(slPrice, slPrice, 3)
fourPartUptrend = threePartUptrend and ta.valuewhen(slPrice, slPrice, 3) > ta.valuewhen(slPrice, slPrice, 4)
fivePartUptrend = fourPartUptrend and ta.valuewhen(slPrice, slPrice, 4) > ta.valuewhen(slPrice, slPrice, 5)
sixPartUptrend = fivePartUptrend and ta.valuewhen(slPrice, slPrice, 5) > ta.valuewhen(slPrice, slPrice, 6)
sevenPartUptrend = sixPartUptrend and ta.valuewhen(slPrice, slPrice, 6) > ta.valuewhen(slPrice, slPrice, 7)
eightPartUptrend = sevenPartUptrend and ta.valuewhen(slPrice, slPrice, 7) > ta.valuewhen(slPrice, slPrice, 8)
ninePartUptrend = eightPartUptrend and ta.valuewhen(slPrice, slPrice, 8) > ta.valuewhen(slPrice, slPrice, 9)
tenPartUptrend = ninePartUptrend and ta.valuewhen(slPrice, slPrice, 9) > ta.valuewhen(slPrice, slPrice, 10)
elevenPartUptrend = tenPartUptrend and ta.valuewhen(slPrice, slPrice, 10) > ta.valuewhen(slPrice, slPrice, 11)
twelvePartUptrend = elevenPartUptrend and ta.valuewhen(slPrice, slPrice, 11) > ta.valuewhen(slPrice, slPrice, 12)
thirteenPartUptrend = twelvePartUptrend and ta.valuewhen(slPrice, slPrice, 12) > ta.valuewhen(slPrice, slPrice, 13)
fourteenPartUptrend = thirteenPartUptrend and ta.valuewhen(slPrice, slPrice, 13) > ta.valuewhen(slPrice, slPrice, 14)
fifteenPartUptrend = fourteenPartUptrend and ta.valuewhen(slPrice, slPrice, 14) > ta.valuewhen(slPrice, slPrice, 15)
sixteenPartUptrend = fifteenPartUptrend and ta.valuewhen(slPrice, slPrice, 15) > ta.valuewhen(slPrice, slPrice, 16)
seventeenPartUptrend = sixteenPartUptrend and ta.valuewhen(slPrice, slPrice, 16) > ta.valuewhen(slPrice, slPrice, 17)
eighteenPartUptrend = seventeenPartUptrend and ta.valuewhen(slPrice, slPrice, 17) > ta.valuewhen(slPrice, slPrice, 18)
nineteenPartUptrend = eighteenPartUptrend and ta.valuewhen(slPrice, slPrice, 18) > ta.valuewhen(slPrice, slPrice, 19)
twentyPartUptrend = nineteenPartUptrend and ta.valuewhen(slPrice, slPrice, 19) > ta.valuewhen(slPrice, slPrice, 20)
//////////// plots ////////////
plotshape(slPrice and onePartUptrend and not twoPartUptrend and low <= low[1] ? onePartUptrend : na,
style = shape.triangleup, color = color.green, text = '1', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and twoPartUptrend and not threePartUptrend and low <= low[1] ? twoPartUptrend : na,
style = shape.triangleup, color = color.green, text = '2', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and threePartUptrend and not fourPartUptrend and low <= low[1] ? threePartUptrend : na,
style = shape.triangleup, color = color.green, text = '3', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and fourPartUptrend and not fivePartUptrend and low <= low[1] ? fourPartUptrend : na,
style = shape.triangleup, color = color.green, text = '4', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and fivePartUptrend and not sixPartUptrend and low <= low[1] ? fivePartUptrend : na,
style = shape.triangleup, color = color.green, text = '5', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and sixPartUptrend and not sevenPartUptrend and low <= low[1] ? sixPartUptrend : na,
style = shape.triangleup, color = color.green, text = '6', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and sevenPartUptrend and not eightPartUptrend and low <= low[1] ? sevenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '7', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and eightPartUptrend and not ninePartUptrend and low <= low[1] ? eightPartUptrend : na,
style = shape.triangleup, color = color.green, text = '8', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and ninePartUptrend and not tenPartUptrend and low <= low[1] ? ninePartUptrend : na,
style = shape.triangleup, color = color.green, text = '9', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and tenPartUptrend and not elevenPartUptrend and low <= low[1] ? tenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '10', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and elevenPartUptrend and not twelvePartUptrend and low <= low[1] ? elevenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '11', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and twelvePartUptrend and not thirteenPartUptrend and low <= low[1] ? twelvePartUptrend : na,
style = shape.triangleup, color = color.green, text = '12', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and thirteenPartUptrend and not fourteenPartUptrend and low <= low[1] ? thirteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '13', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and fourteenPartUptrend and not fifteenPartUptrend and low <= low[1] ? fourteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '14', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and fifteenPartUptrend and not sixteenPartUptrend and low <= low[1] ? fifteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '15', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and sixteenPartUptrend and not seventeenPartUptrend and low <= low[1] ? sixteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '16', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and seventeenPartUptrend and not eighteenPartUptrend and low <= low[1] ? seventeenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '17', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and eighteenPartUptrend and not nineteenPartUptrend and low <= low[1] ? eighteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '18', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and nineteenPartUptrend and not twentyPartUptrend and low <= low[1] ? nineteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '19', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and twentyPartUptrend and low <= low[1] ? twentyPartUptrend : na,
style = shape.triangleup, color = color.green, text = '20', textcolor = color.green, location = location.belowbar)
plotshape(slPrice and onePartUptrend and not twoPartUptrend and low > low[1] ? onePartUptrend : na,
style = shape.triangleup, color = color.green, text = '1', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and twoPartUptrend and not threePartUptrend and low > low[1] ? twoPartUptrend : na,
style = shape.triangleup, color = color.green, text = '2', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and threePartUptrend and not fourPartUptrend and low > low[1] ? threePartUptrend : na,
style = shape.triangleup, color = color.green, text = '3', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and fourPartUptrend and not fivePartUptrend and low > low[1] ? fourPartUptrend : na,
style = shape.triangleup, color = color.green, text = '4', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and fivePartUptrend and not sixPartUptrend and low > low[1] ? fivePartUptrend : na,
style = shape.triangleup, color = color.green, text = '5', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and sixPartUptrend and not sevenPartUptrend and low > low[1] ? sixPartUptrend : na,
style = shape.triangleup, color = color.green, text = '6', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and sevenPartUptrend and not eightPartUptrend and low > low[1] ? sevenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '7', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and eightPartUptrend and not ninePartUptrend and low > low[1] ? eightPartUptrend : na,
style = shape.triangleup, color = color.green, text = '8', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and ninePartUptrend and not tenPartUptrend and low > low[1] ? ninePartUptrend : na,
style = shape.triangleup, color = color.green, text = '9', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and tenPartUptrend and not elevenPartUptrend and low > low[1] ? tenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '10', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and elevenPartUptrend and not twelvePartUptrend and low > low[1] ? elevenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '11', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and twelvePartUptrend and not thirteenPartUptrend and low > low[1] ? twelvePartUptrend : na,
style = shape.triangleup, color = color.green, text = '12', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and thirteenPartUptrend and not fourteenPartUptrend and low > low[1] ? thirteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '13', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and fourteenPartUptrend and not fifteenPartUptrend and low > low[1] ? fourteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '14', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and fifteenPartUptrend and not sixteenPartUptrend and low > low[1] ? fifteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '15', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and sixteenPartUptrend and not seventeenPartUptrend and low > low[1] ? sixteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '16', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and seventeenPartUptrend and not eighteenPartUptrend and low > low[1] ? seventeenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '17', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and eighteenPartUptrend and not nineteenPartUptrend and low > low[1] ? eighteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '18', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and nineteenPartUptrend and not twentyPartUptrend and low > low[1] ? nineteenPartUptrend : na,
style = shape.triangleup, color = color.green, text = '19', textcolor = color.green, location = location.belowbar, offset = -1)
plotshape(slPrice and twentyPartUptrend and low > low[1] ? twentyPartUptrend : na,
style = shape.triangleup, color = color.green, text = '20', textcolor = color.green, location = location.belowbar, offset = -1)
|
Downtrends [theEccentricTrader] | https://www.tradingview.com/script/9hDHiVBw-Downtrends-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 19 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Downtrends [theEccentricTrader]', overlay = true)
//////////// downtrends ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
onePartDowntrend = shPrice < ta.valuewhen(shPrice, shPrice, 1)
twoPartDowntrend = onePartDowntrend and ta.valuewhen(shPrice, shPrice, 1) < ta.valuewhen(shPrice, shPrice, 2)
threePartDowntrend = twoPartDowntrend and ta.valuewhen(shPrice, shPrice, 2) < ta.valuewhen(shPrice, shPrice, 3)
fourPartDowntrend = threePartDowntrend and ta.valuewhen(shPrice, shPrice, 3) < ta.valuewhen(shPrice, shPrice, 4)
fivePartDowntrend = fourPartDowntrend and ta.valuewhen(shPrice, shPrice, 4) < ta.valuewhen(shPrice, shPrice, 5)
sixPartDowntrend = fivePartDowntrend and ta.valuewhen(shPrice, shPrice, 5) < ta.valuewhen(shPrice, shPrice, 6)
sevenPartDowntrend = sixPartDowntrend and ta.valuewhen(shPrice, shPrice, 6) < ta.valuewhen(shPrice, shPrice, 7)
eightPartDowntrend = sevenPartDowntrend and ta.valuewhen(shPrice, shPrice, 7) < ta.valuewhen(shPrice, shPrice, 8)
ninePartDowntrend = eightPartDowntrend and ta.valuewhen(shPrice, shPrice, 8) < ta.valuewhen(shPrice, shPrice, 9)
tenPartDowntrend = ninePartDowntrend and ta.valuewhen(shPrice, shPrice, 9) < ta.valuewhen(shPrice, shPrice, 10)
elevenPartDowntrend = tenPartDowntrend and ta.valuewhen(shPrice, shPrice, 10) < ta.valuewhen(shPrice, shPrice, 11)
twelvePartDowntrend = elevenPartDowntrend and ta.valuewhen(shPrice, shPrice, 11) < ta.valuewhen(shPrice, shPrice, 12)
thirteenPartDowntrend = twelvePartDowntrend and ta.valuewhen(shPrice, shPrice, 12) < ta.valuewhen(shPrice, shPrice, 13)
fourteenPartDowntrend = thirteenPartDowntrend and ta.valuewhen(shPrice, shPrice, 13) < ta.valuewhen(shPrice, shPrice, 14)
fifteenPartDowntrend = fourteenPartDowntrend and ta.valuewhen(shPrice, shPrice, 14) < ta.valuewhen(shPrice, shPrice, 15)
sixteenPartDowntrend = fifteenPartDowntrend and ta.valuewhen(shPrice, shPrice, 15) < ta.valuewhen(shPrice, shPrice, 16)
seventeenPartDowntrend = sixteenPartDowntrend and ta.valuewhen(shPrice, shPrice, 16) < ta.valuewhen(shPrice, shPrice, 17)
eighteenPartDowntrend = seventeenPartDowntrend and ta.valuewhen(shPrice, shPrice, 17) < ta.valuewhen(shPrice, shPrice, 18)
nineteenPartDowntrend = eighteenPartDowntrend and ta.valuewhen(shPrice, shPrice, 18) < ta.valuewhen(shPrice, shPrice, 19)
twentyPartDowntrend = nineteenPartDowntrend and ta.valuewhen(shPrice, shPrice, 19) < ta.valuewhen(shPrice, shPrice, 20)
//////////// plots ////////////
plotshape(shPrice and onePartDowntrend and not twoPartDowntrend and high >= high[1] ? onePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '1', textcolor = color.red)
plotshape(shPrice and twoPartDowntrend and not threePartDowntrend and high >= high[1] ? twoPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '2', textcolor = color.red)
plotshape(shPrice and threePartDowntrend and not fourPartDowntrend and high >= high[1] ? threePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '3', textcolor = color.red)
plotshape(shPrice and fourPartDowntrend and not fivePartDowntrend and high >= high[1] ? fourPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '4', textcolor = color.red)
plotshape(shPrice and fivePartDowntrend and not sixPartDowntrend and high >= high[1] ? fivePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '5', textcolor = color.red)
plotshape(shPrice and sixPartDowntrend and not sevenPartDowntrend and high >= high[1] ? sixPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '6', textcolor = color.red)
plotshape(shPrice and sevenPartDowntrend and not eightPartDowntrend and high >= high[1] ? sevenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '7', textcolor = color.red)
plotshape(shPrice and eightPartDowntrend and not ninePartDowntrend and high >= high[1] ? eightPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '8', textcolor = color.red)
plotshape(shPrice and ninePartDowntrend and not tenPartDowntrend and high >= high[1] ? ninePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '9', textcolor = color.red)
plotshape(shPrice and tenPartDowntrend and not elevenPartDowntrend and high >= high[1] ? tenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '10', textcolor = color.red)
plotshape(shPrice and elevenPartDowntrend and not twelvePartDowntrend and high >= high[1] ? elevenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '11', textcolor = color.red)
plotshape(shPrice and twelvePartDowntrend and not thirteenPartDowntrend and high >= high[1] ? twelvePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '12', textcolor = color.red)
plotshape(shPrice and thirteenPartDowntrend and not fourteenPartDowntrend and high >= high[1] ? thirteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '13', textcolor = color.red)
plotshape(shPrice and fourteenPartDowntrend and not fifteenPartDowntrend and high >= high[1] ? fourteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '14', textcolor = color.red)
plotshape(shPrice and fifteenPartDowntrend and not sixteenPartDowntrend and high >= high[1] ? fifteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '15', textcolor = color.red)
plotshape(shPrice and sixteenPartDowntrend and not seventeenPartDowntrend and high >= high[1] ? sixteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '16', textcolor = color.red)
plotshape(shPrice and seventeenPartDowntrend and not eighteenPartDowntrend and high >= high[1] ? seventeenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '17', textcolor = color.red)
plotshape(shPrice and eighteenPartDowntrend and not nineteenPartDowntrend and high >= high[1] ? eighteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '18', textcolor = color.red)
plotshape(shPrice and nineteenPartDowntrend and not twentyPartDowntrend and high >= high[1] ? nineteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '19', textcolor = color.red)
plotshape(shPrice and twentyPartDowntrend and high >= high[1] ? twentyPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '20', textcolor = color.red)
plotshape(shPrice and onePartDowntrend and not twoPartDowntrend and high < high[1] ? onePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '1', textcolor = color.red, offset = -1)
plotshape(shPrice and twoPartDowntrend and not threePartDowntrend and high < high[1] ? twoPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '2', textcolor = color.red, offset = -1)
plotshape(shPrice and threePartDowntrend and not fourPartDowntrend and high < high[1] ? threePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '3', textcolor = color.red, offset = -1)
plotshape(shPrice and fourPartDowntrend and not fivePartDowntrend and high < high[1] ? fourPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '4', textcolor = color.red, offset = -1)
plotshape(shPrice and fivePartDowntrend and not sixPartDowntrend and high < high[1] ? fivePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '5', textcolor = color.red, offset = -1)
plotshape(shPrice and sixPartDowntrend and not sevenPartDowntrend and high < high[1] ? sixPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '6', textcolor = color.red, offset = -1)
plotshape(shPrice and sevenPartDowntrend and not eightPartDowntrend and high < high[1] ? sevenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '7', textcolor = color.red, offset = -1)
plotshape(shPrice and eightPartDowntrend and not ninePartDowntrend and high < high[1] ? eightPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '8', textcolor = color.red, offset = -1)
plotshape(shPrice and ninePartDowntrend and not tenPartDowntrend and high < high[1] ? ninePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '9', textcolor = color.red, offset = -1)
plotshape(shPrice and tenPartDowntrend and not elevenPartDowntrend and high < high[1] ? tenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '10', textcolor = color.red, offset = -1)
plotshape(shPrice and elevenPartDowntrend and not twelvePartDowntrend and high < high[1] ? elevenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '11', textcolor = color.red, offset = -1)
plotshape(shPrice and twelvePartDowntrend and not thirteenPartDowntrend and high < high[1] ? twelvePartDowntrend : na,
style = shape.triangledown, color = color.red, text = '12', textcolor = color.red, offset = -1)
plotshape(shPrice and thirteenPartDowntrend and not fourteenPartDowntrend and high < high[1] ? thirteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '13', textcolor = color.red, offset = -1)
plotshape(shPrice and fourteenPartDowntrend and not fifteenPartDowntrend and high < high[1] ? fourteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '14', textcolor = color.red, offset = -1)
plotshape(shPrice and fifteenPartDowntrend and not sixteenPartDowntrend and high < high[1] ? fifteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '15', textcolor = color.red, offset = -1)
plotshape(shPrice and sixteenPartDowntrend and not seventeenPartDowntrend and high < high[1] ? sixteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '16', textcolor = color.red, offset = -1)
plotshape(shPrice and seventeenPartDowntrend and not eighteenPartDowntrend and high < high[1] ? seventeenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '17', textcolor = color.red, offset = -1)
plotshape(shPrice and eighteenPartDowntrend and not nineteenPartDowntrend and high < high[1] ? eighteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '18', textcolor = color.red, offset = -1)
plotshape(shPrice and nineteenPartDowntrend and not twentyPartDowntrend and high < high[1] ? nineteenPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '19', textcolor = color.red, offset = -1)
plotshape(shPrice and twentyPartDowntrend and high < high[1] ? twentyPartDowntrend : na,
style = shape.triangledown, color = color.red, text = '20', textcolor = color.red, offset = -1)
|
Trend Counter [theEccentricTrader] | https://www.tradingview.com/script/ue2aOkn8-Trend-Counter-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 18 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=4
study("Trend Counter [theEccentricTrader]", overlay = true)
//////////// sample period filter ////////////
showSamplePeriod = input(defval = true, title = 'Show Sample Period', group = 'Sample Period')
start = input(defval = timestamp('2 Jan 1800 00:00'), title = 'Start Date', type = input.time, group = 'Sample Period')
end = input(defval = timestamp('1 Jan 3000 00:00'), title = 'End Date', type = input.time, group = 'Sample Period')
samplePeriodFilter = time >= start and time <= end
var barOneDate = time
f_timeToString(_t) =>
tostring(dayofmonth(_t), '00') + '.' + tostring(month(_t), '00') + '.' + tostring(year(_t), '0000')
startDateText = barOneDate > start ? f_timeToString(barOneDate) : f_timeToString(start)
endDateText = time >= end ? '-' + f_timeToString(end) : '-' + f_timeToString(time)
//////////// trend counters ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
slPrice = close[1] < open[1] and close >= open and low <= low[1] and barstate.isconfirmed ? low :
close[1] < open[1] and close >= open and low >= low[1] and barstate.isconfirmed ? low[1] : na
onePartReturnLineUptrend = shPrice > valuewhen(shPrice, shPrice, 1) and samplePeriodFilter
twoPartReturnLineUptrend = onePartReturnLineUptrend and valuewhen(shPrice, shPrice, 1) > valuewhen(shPrice, shPrice, 2) and samplePeriodFilter
threePartReturnLineUptrend = twoPartReturnLineUptrend and valuewhen(shPrice, shPrice, 2) > valuewhen(shPrice, shPrice, 3) and samplePeriodFilter
fourPartReturnLineUptrend = threePartReturnLineUptrend and valuewhen(shPrice, shPrice, 3) > valuewhen(shPrice, shPrice, 4) and samplePeriodFilter
fivePartReturnLineUptrend = fourPartReturnLineUptrend and valuewhen(shPrice, shPrice, 4) > valuewhen(shPrice, shPrice, 5) and samplePeriodFilter
sixPartReturnLineUptrend = fivePartReturnLineUptrend and valuewhen(shPrice, shPrice, 5) > valuewhen(shPrice, shPrice, 6) and samplePeriodFilter
sevenPartReturnLineUptrend = sixPartReturnLineUptrend and valuewhen(shPrice, shPrice, 6) > valuewhen(shPrice, shPrice, 7) and samplePeriodFilter
eightPartReturnLineUptrend = sevenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 7) > valuewhen(shPrice, shPrice, 8) and samplePeriodFilter
ninePartReturnLineUptrend = eightPartReturnLineUptrend and valuewhen(shPrice, shPrice, 8) > valuewhen(shPrice, shPrice, 9) and samplePeriodFilter
tenPartReturnLineUptrend = ninePartReturnLineUptrend and valuewhen(shPrice, shPrice, 9) > valuewhen(shPrice, shPrice, 10) and samplePeriodFilter
elevenPartReturnLineUptrend = tenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 10) > valuewhen(shPrice, shPrice, 11) and samplePeriodFilter
twelvePartReturnLineUptrend = elevenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 11) > valuewhen(shPrice, shPrice, 12) and samplePeriodFilter
thirteenPartReturnLineUptrend = twelvePartReturnLineUptrend and valuewhen(shPrice, shPrice, 12) > valuewhen(shPrice, shPrice, 13) and samplePeriodFilter
fourteenPartReturnLineUptrend = thirteenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 13) > valuewhen(shPrice, shPrice, 14) and samplePeriodFilter
fifteenPartReturnLineUptrend = fourteenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 14) > valuewhen(shPrice, shPrice, 15) and samplePeriodFilter
sixteenPartReturnLineUptrend = fifteenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 15) > valuewhen(shPrice, shPrice, 16) and samplePeriodFilter
seventeenPartReturnLineUptrend = sixteenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 16) > valuewhen(shPrice, shPrice, 17) and samplePeriodFilter
eighteenPartReturnLineUptrend = seventeenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 17) > valuewhen(shPrice, shPrice, 18) and samplePeriodFilter
nineteenPartReturnLineUptrend = eighteenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 18) > valuewhen(shPrice, shPrice, 19) and samplePeriodFilter
twentyPartReturnLineUptrend = nineteenPartReturnLineUptrend and valuewhen(shPrice, shPrice, 19) > valuewhen(shPrice, shPrice, 20) and samplePeriodFilter
onePartDowntrend = shPrice < valuewhen(shPrice, shPrice, 1) and samplePeriodFilter
twoPartDowntrend = onePartDowntrend and valuewhen(shPrice, shPrice, 1) < valuewhen(shPrice, shPrice, 2) and samplePeriodFilter
threePartDowntrend = twoPartDowntrend and valuewhen(shPrice, shPrice, 2) < valuewhen(shPrice, shPrice, 3) and samplePeriodFilter
fourPartDowntrend = threePartDowntrend and valuewhen(shPrice, shPrice, 3) < valuewhen(shPrice, shPrice, 4) and samplePeriodFilter
fivePartDowntrend = fourPartDowntrend and valuewhen(shPrice, shPrice, 4) < valuewhen(shPrice, shPrice, 5) and samplePeriodFilter
sixPartDowntrend = fivePartDowntrend and valuewhen(shPrice, shPrice, 5) < valuewhen(shPrice, shPrice, 6) and samplePeriodFilter
sevenPartDowntrend = sixPartDowntrend and valuewhen(shPrice, shPrice, 6) < valuewhen(shPrice, shPrice, 7) and samplePeriodFilter
eightPartDowntrend = sevenPartDowntrend and valuewhen(shPrice, shPrice, 7) < valuewhen(shPrice, shPrice, 8) and samplePeriodFilter
ninePartDowntrend = eightPartDowntrend and valuewhen(shPrice, shPrice, 8) < valuewhen(shPrice, shPrice, 9) and samplePeriodFilter
tenPartDowntrend = ninePartDowntrend and valuewhen(shPrice, shPrice, 9) < valuewhen(shPrice, shPrice, 10) and samplePeriodFilter
elevenPartDowntrend = tenPartDowntrend and valuewhen(shPrice, shPrice, 10) < valuewhen(shPrice, shPrice, 11) and samplePeriodFilter
twelvePartDowntrend = elevenPartDowntrend and valuewhen(shPrice, shPrice, 11) < valuewhen(shPrice, shPrice, 12) and samplePeriodFilter
thirteenPartDowntrend = twelvePartDowntrend and valuewhen(shPrice, shPrice, 12) < valuewhen(shPrice, shPrice, 13) and samplePeriodFilter
fourteenPartDowntrend = thirteenPartDowntrend and valuewhen(shPrice, shPrice, 13) < valuewhen(shPrice, shPrice, 14) and samplePeriodFilter
fifteenPartDowntrend = fourteenPartDowntrend and valuewhen(shPrice, shPrice, 14) < valuewhen(shPrice, shPrice, 15) and samplePeriodFilter
sixteenPartDowntrend = fifteenPartDowntrend and valuewhen(shPrice, shPrice, 15) < valuewhen(shPrice, shPrice, 16) and samplePeriodFilter
seventeenPartDowntrend = sixteenPartDowntrend and valuewhen(shPrice, shPrice, 16) < valuewhen(shPrice, shPrice, 17) and samplePeriodFilter
eighteenPartDowntrend = seventeenPartDowntrend and valuewhen(shPrice, shPrice, 17) < valuewhen(shPrice, shPrice, 18) and samplePeriodFilter
nineteenPartDowntrend = eighteenPartDowntrend and valuewhen(shPrice, shPrice, 18) < valuewhen(shPrice, shPrice, 19) and samplePeriodFilter
twentyPartDowntrend = nineteenPartDowntrend and valuewhen(shPrice, shPrice, 19) < valuewhen(shPrice, shPrice, 20) and samplePeriodFilter
onePartUptrend = slPrice > valuewhen(slPrice, slPrice, 1) and samplePeriodFilter
twoPartUptrend = onePartUptrend and valuewhen(slPrice, slPrice, 1) > valuewhen(slPrice, slPrice, 2) and samplePeriodFilter
threePartUptrend = twoPartUptrend and valuewhen(slPrice, slPrice, 2) > valuewhen(slPrice, slPrice, 3) and samplePeriodFilter
fourPartUptrend = threePartUptrend and valuewhen(slPrice, slPrice, 3) > valuewhen(slPrice, slPrice, 4) and samplePeriodFilter
fivePartUptrend = fourPartUptrend and valuewhen(slPrice, slPrice, 4) > valuewhen(slPrice, slPrice, 5) and samplePeriodFilter
sixPartUptrend = fivePartUptrend and valuewhen(slPrice, slPrice, 5) > valuewhen(slPrice, slPrice, 6) and samplePeriodFilter
sevenPartUptrend = sixPartUptrend and valuewhen(slPrice, slPrice, 6) > valuewhen(slPrice, slPrice, 7) and samplePeriodFilter
eightPartUptrend = sevenPartUptrend and valuewhen(slPrice, slPrice, 7) > valuewhen(slPrice, slPrice, 8) and samplePeriodFilter
ninePartUptrend = eightPartUptrend and valuewhen(slPrice, slPrice, 8) > valuewhen(slPrice, slPrice, 9) and samplePeriodFilter
tenPartUptrend = ninePartUptrend and valuewhen(slPrice, slPrice, 9) > valuewhen(slPrice, slPrice, 10) and samplePeriodFilter
elevenPartUptrend = tenPartUptrend and valuewhen(slPrice, slPrice, 10) > valuewhen(slPrice, slPrice, 11) and samplePeriodFilter
twelvePartUptrend = elevenPartUptrend and valuewhen(slPrice, slPrice, 11) > valuewhen(slPrice, slPrice, 12) and samplePeriodFilter
thirteenPartUptrend = twelvePartUptrend and valuewhen(slPrice, slPrice, 12) > valuewhen(slPrice, slPrice, 13) and samplePeriodFilter
fourteenPartUptrend = thirteenPartUptrend and valuewhen(slPrice, slPrice, 13) > valuewhen(slPrice, slPrice, 14) and samplePeriodFilter
fifteenPartUptrend = fourteenPartUptrend and valuewhen(slPrice, slPrice, 14) > valuewhen(slPrice, slPrice, 15) and samplePeriodFilter
sixteenPartUptrend = fifteenPartUptrend and valuewhen(slPrice, slPrice, 15) > valuewhen(slPrice, slPrice, 16) and samplePeriodFilter
seventeenPartUptrend = sixteenPartUptrend and valuewhen(slPrice, slPrice, 16) > valuewhen(slPrice, slPrice, 17) and samplePeriodFilter
eighteenPartUptrend = seventeenPartUptrend and valuewhen(slPrice, slPrice, 17) > valuewhen(slPrice, slPrice, 18) and samplePeriodFilter
nineteenPartUptrend = eighteenPartUptrend and valuewhen(slPrice, slPrice, 18) > valuewhen(slPrice, slPrice, 19) and samplePeriodFilter
twentyPartUptrend = nineteenPartUptrend and valuewhen(slPrice, slPrice, 19) > valuewhen(slPrice, slPrice, 20) and samplePeriodFilter
onePartReturnLineDowntrend = slPrice < valuewhen(slPrice, slPrice, 1) and samplePeriodFilter
twoPartReturnLineDowntrend = onePartReturnLineDowntrend and valuewhen(slPrice, slPrice, 1) < valuewhen(slPrice, slPrice, 2) and samplePeriodFilter
threePartReturnLineDowntrend = twoPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 2) < valuewhen(slPrice, slPrice, 3) and samplePeriodFilter
fourPartReturnLineDowntrend = threePartReturnLineDowntrend and valuewhen(slPrice, slPrice, 3) < valuewhen(slPrice, slPrice, 4) and samplePeriodFilter
fivePartReturnLineDowntrend = fourPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 4) < valuewhen(slPrice, slPrice, 5) and samplePeriodFilter
sixPartReturnLineDowntrend = fivePartReturnLineDowntrend and valuewhen(slPrice, slPrice, 5) < valuewhen(slPrice, slPrice, 6) and samplePeriodFilter
sevenPartReturnLineDowntrend = sixPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 6) < valuewhen(slPrice, slPrice, 7) and samplePeriodFilter
eightPartReturnLineDowntrend = sevenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 7) < valuewhen(slPrice, slPrice, 8) and samplePeriodFilter
ninePartReturnLineDowntrend = eightPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 8) < valuewhen(slPrice, slPrice, 9) and samplePeriodFilter
tenPartReturnLineDowntrend = ninePartReturnLineDowntrend and valuewhen(slPrice, slPrice, 9) < valuewhen(slPrice, slPrice, 10) and samplePeriodFilter
elevenPartReturnLineDowntrend = tenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 10) < valuewhen(slPrice, slPrice, 11) and samplePeriodFilter
twelvePartReturnLineDowntrend = elevenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 11) < valuewhen(slPrice, slPrice, 12) and samplePeriodFilter
thirteenPartReturnLineDowntrend = twelvePartReturnLineDowntrend and valuewhen(slPrice, slPrice, 12) < valuewhen(slPrice, slPrice, 13) and samplePeriodFilter
fourteenPartReturnLineDowntrend = thirteenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 13) < valuewhen(slPrice, slPrice, 14) and samplePeriodFilter
fifteenPartReturnLineDowntrend = fourteenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 14) < valuewhen(slPrice, slPrice, 15) and samplePeriodFilter
sixteenPartReturnLineDowntrend = fifteenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 15) < valuewhen(slPrice, slPrice, 16) and samplePeriodFilter
seventeenPartReturnLineDowntrend = sixteenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 16) < valuewhen(slPrice, slPrice, 17) and samplePeriodFilter
eighteenPartReturnLineDowntrend = seventeenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 17) < valuewhen(slPrice, slPrice, 18) and samplePeriodFilter
nineteenPartReturnLineDowntrend = eighteenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 18) < valuewhen(slPrice, slPrice, 19) and samplePeriodFilter
twentyPartReturnLineDowntrend = nineteenPartReturnLineDowntrend and valuewhen(slPrice, slPrice, 19) < valuewhen(slPrice, slPrice, 20) and samplePeriodFilter
var onePartReturnLineUptrendCounter = 0
var twoPartReturnLineUptrendCounter = 0
var threePartReturnLineUptrendCounter = 0
var fourPartReturnLineUptrendCounter = 0
var fivePartReturnLineUptrendCounter = 0
var sixPartReturnLineUptrendCounter = 0
var sevenPartReturnLineUptrendCounter = 0
var eightPartReturnLineUptrendCounter = 0
var ninePartReturnLineUptrendCounter = 0
var tenPartReturnLineUptrendCounter = 0
var elevenPartReturnLineUptrendCounter = 0
var twelvePartReturnLineUptrendCounter = 0
var thirteenPartReturnLineUptrendCounter = 0
var fourteenPartReturnLineUptrendCounter = 0
var fifteenPartReturnLineUptrendCounter = 0
var sixteenPartReturnLineUptrendCounter = 0
var seventeenPartReturnLineUptrendCounter = 0
var eighteenPartReturnLineUptrendCounter = 0
var nineteenPartReturnLineUptrendCounter = 0
var twentyPartReturnLineUptrendCounter = 0
var onePartDowntrendCounter = 0
var twoPartDowntrendCounter = 0
var threePartDowntrendCounter = 0
var fourPartDowntrendCounter = 0
var fivePartDowntrendCounter = 0
var sixPartDowntrendCounter = 0
var sevenPartDowntrendCounter = 0
var eightPartDowntrendCounter = 0
var ninePartDowntrendCounter = 0
var tenPartDowntrendCounter = 0
var elevenPartDowntrendCounter = 0
var twelvePartDowntrendCounter = 0
var thirteenPartDowntrendCounter = 0
var fourteenPartDowntrendCounter = 0
var fifteenPartDowntrendCounter = 0
var sixteenPartDowntrendCounter = 0
var seventeenPartDowntrendCounter = 0
var eighteenPartDowntrendCounter = 0
var nineteenPartDowntrendCounter = 0
var twentyPartDowntrendCounter = 0
var onePartUptrendCounter = 0
var twoPartUptrendCounter = 0
var threePartUptrendCounter = 0
var fourPartUptrendCounter = 0
var fivePartUptrendCounter = 0
var sixPartUptrendCounter = 0
var sevenPartUptrendCounter = 0
var eightPartUptrendCounter = 0
var ninePartUptrendCounter = 0
var tenPartUptrendCounter = 0
var elevenPartUptrendCounter = 0
var twelvePartUptrendCounter = 0
var thirteenPartUptrendCounter = 0
var fourteenPartUptrendCounter = 0
var fifteenPartUptrendCounter = 0
var sixteenPartUptrendCounter = 0
var seventeenPartUptrendCounter = 0
var eighteenPartUptrendCounter = 0
var nineteenPartUptrendCounter = 0
var twentyPartUptrendCounter = 0
var onePartReturnLineDowntrendCounter = 0
var twoPartReturnLineDowntrendCounter = 0
var threePartReturnLineDowntrendCounter = 0
var fourPartReturnLineDowntrendCounter = 0
var fivePartReturnLineDowntrendCounter = 0
var sixPartReturnLineDowntrendCounter = 0
var sevenPartReturnLineDowntrendCounter = 0
var eightPartReturnLineDowntrendCounter = 0
var ninePartReturnLineDowntrendCounter = 0
var tenPartReturnLineDowntrendCounter = 0
var elevenPartReturnLineDowntrendCounter = 0
var twelvePartReturnLineDowntrendCounter = 0
var thirteenPartReturnLineDowntrendCounter = 0
var fourteenPartReturnLineDowntrendCounter = 0
var fifteenPartReturnLineDowntrendCounter = 0
var sixteenPartReturnLineDowntrendCounter = 0
var seventeenPartReturnLineDowntrendCounter = 0
var eighteenPartReturnLineDowntrendCounter = 0
var nineteenPartReturnLineDowntrendCounter = 0
var twentyPartReturnLineDowntrendCounter = 0
if onePartReturnLineUptrend and not twoPartReturnLineUptrend
onePartReturnLineUptrendCounter += 1
if twoPartReturnLineUptrend and not threePartReturnLineUptrend
twoPartReturnLineUptrendCounter += 1
if threePartReturnLineUptrend and not fourPartReturnLineUptrend
threePartReturnLineUptrendCounter += 1
if fourPartReturnLineUptrend and not fivePartReturnLineUptrend
fourPartReturnLineUptrendCounter += 1
if fivePartReturnLineUptrend and not sixPartReturnLineUptrend
fivePartReturnLineUptrendCounter += 1
if sixPartReturnLineUptrend and not sevenPartReturnLineUptrend
sixPartReturnLineUptrendCounter += 1
if sevenPartReturnLineUptrend and not eightPartReturnLineUptrend
sevenPartReturnLineUptrendCounter += 1
if eightPartReturnLineUptrend and not ninePartReturnLineUptrend
eightPartReturnLineUptrendCounter += 1
if ninePartReturnLineUptrend and not tenPartReturnLineUptrend
ninePartReturnLineUptrendCounter += 1
if tenPartReturnLineUptrend and not elevenPartReturnLineUptrend
tenPartReturnLineUptrendCounter += 1
if elevenPartReturnLineUptrend and not twelvePartReturnLineUptrend
elevenPartReturnLineUptrendCounter += 1
if twelvePartReturnLineUptrend and not thirteenPartReturnLineUptrend
twelvePartReturnLineUptrendCounter += 1
if thirteenPartReturnLineUptrend and not fourteenPartReturnLineUptrend
thirteenPartReturnLineUptrendCounter += 1
if fourteenPartReturnLineUptrend and not fifteenPartReturnLineUptrend
fourteenPartReturnLineUptrendCounter += 1
if fifteenPartReturnLineUptrend and not sixteenPartReturnLineUptrend
fifteenPartReturnLineUptrendCounter += 1
if sixteenPartReturnLineUptrend and not seventeenPartReturnLineUptrend
sixteenPartReturnLineUptrendCounter += 1
if seventeenPartReturnLineUptrend and not eighteenPartReturnLineUptrend
seventeenPartReturnLineUptrendCounter += 1
if eighteenPartReturnLineUptrend and not nineteenPartReturnLineUptrend
eighteenPartReturnLineUptrendCounter += 1
if nineteenPartReturnLineUptrend and not twentyPartReturnLineUptrend
nineteenPartReturnLineUptrendCounter += 1
if twentyPartReturnLineUptrend
twentyPartReturnLineUptrendCounter += 1
if onePartDowntrend and not twoPartDowntrend
onePartDowntrendCounter += 1
if twoPartDowntrend and not threePartDowntrend
twoPartDowntrendCounter += 1
if threePartDowntrend and not fourPartDowntrend
threePartDowntrendCounter += 1
if fourPartDowntrend and not fivePartDowntrend
fourPartDowntrendCounter += 1
if fivePartDowntrend and not sixPartDowntrend
fivePartDowntrendCounter += 1
if sixPartDowntrend and not sevenPartDowntrend
sixPartDowntrendCounter += 1
if sevenPartDowntrend and not eightPartDowntrend
sevenPartDowntrendCounter += 1
if eightPartDowntrend and not ninePartDowntrend
eightPartDowntrendCounter += 1
if ninePartDowntrend and not tenPartDowntrend
ninePartDowntrendCounter += 1
if tenPartDowntrend and not elevenPartDowntrend
tenPartDowntrendCounter += 1
if elevenPartDowntrend and not twelvePartDowntrend
elevenPartDowntrendCounter += 1
if twelvePartDowntrend and not thirteenPartDowntrend
twelvePartDowntrendCounter += 1
if thirteenPartDowntrend and not fourteenPartDowntrend
thirteenPartDowntrendCounter += 1
if fourteenPartDowntrend and not fifteenPartDowntrend
fourteenPartDowntrendCounter += 1
if fifteenPartDowntrend and not sixteenPartDowntrend
fifteenPartDowntrendCounter += 1
if sixteenPartDowntrend and not seventeenPartDowntrend
sixteenPartDowntrendCounter += 1
if seventeenPartDowntrend and not eighteenPartDowntrend
seventeenPartDowntrendCounter += 1
if eighteenPartDowntrend and not nineteenPartDowntrend
eighteenPartDowntrendCounter += 1
if nineteenPartDowntrend and not twentyPartDowntrend
nineteenPartDowntrendCounter += 1
if twentyPartDowntrend
twentyPartDowntrendCounter += 1
if onePartUptrend and not twoPartUptrend
onePartUptrendCounter += 1
if twoPartUptrend and not threePartUptrend
twoPartUptrendCounter += 1
if threePartUptrend and not fourPartUptrend
threePartUptrendCounter += 1
if fourPartUptrend and not fivePartUptrend
fourPartUptrendCounter += 1
if fivePartUptrend and not sixPartUptrend
fivePartUptrendCounter += 1
if sixPartUptrend and not sevenPartUptrend
sixPartUptrendCounter += 1
if sevenPartUptrend and not eightPartUptrend
sevenPartUptrendCounter += 1
if eightPartUptrend and not ninePartUptrend
eightPartUptrendCounter += 1
if ninePartUptrend and not tenPartUptrend
ninePartUptrendCounter += 1
if tenPartUptrend and not elevenPartUptrend
tenPartUptrendCounter += 1
if elevenPartUptrend and not twelvePartUptrend
elevenPartUptrendCounter += 1
if twelvePartUptrend and not thirteenPartUptrend
twelvePartUptrendCounter += 1
if thirteenPartUptrend and not fourteenPartUptrend
thirteenPartUptrendCounter += 1
if fourteenPartUptrend and not fifteenPartUptrend
fourteenPartUptrendCounter += 1
if fifteenPartUptrend and not sixteenPartUptrend
fifteenPartUptrendCounter += 1
if sixteenPartUptrend and not seventeenPartUptrend
sixteenPartUptrendCounter += 1
if seventeenPartUptrend and not eighteenPartUptrend
seventeenPartUptrendCounter += 1
if eighteenPartUptrend and not nineteenPartUptrend
eighteenPartUptrendCounter += 1
if nineteenPartUptrend and not twentyPartUptrend
nineteenPartUptrendCounter += 1
if twentyPartUptrend
twentyPartUptrendCounter += 1
if onePartReturnLineDowntrend and not twoPartReturnLineDowntrend
onePartReturnLineDowntrendCounter += 1
if twoPartReturnLineDowntrend and not threePartReturnLineDowntrend
twoPartReturnLineDowntrendCounter += 1
if threePartReturnLineDowntrend and not fourPartReturnLineDowntrend
threePartReturnLineDowntrendCounter += 1
if fourPartReturnLineDowntrend and not fivePartReturnLineDowntrend
fourPartReturnLineDowntrendCounter += 1
if fivePartReturnLineDowntrend and not sixPartReturnLineDowntrend
fivePartReturnLineDowntrendCounter += 1
if sixPartReturnLineDowntrend and not sevenPartReturnLineDowntrend
sixPartReturnLineDowntrendCounter += 1
if sevenPartReturnLineDowntrend and not eightPartReturnLineDowntrend
sevenPartReturnLineDowntrendCounter += 1
if eightPartReturnLineDowntrend and not ninePartReturnLineDowntrend
eightPartReturnLineDowntrendCounter += 1
if ninePartReturnLineDowntrend and not tenPartReturnLineDowntrend
ninePartReturnLineDowntrendCounter += 1
if tenPartReturnLineDowntrend and not elevenPartReturnLineDowntrend
tenPartReturnLineDowntrendCounter += 1
if elevenPartReturnLineDowntrend and not twelvePartReturnLineDowntrend
elevenPartReturnLineDowntrendCounter += 1
if twelvePartReturnLineDowntrend and not thirteenPartReturnLineDowntrend
twelvePartReturnLineDowntrendCounter += 1
if thirteenPartReturnLineDowntrend and not fourteenPartReturnLineDowntrend
thirteenPartReturnLineDowntrendCounter += 1
if fourteenPartReturnLineDowntrend and not fifteenPartReturnLineDowntrend
fourteenPartReturnLineDowntrendCounter += 1
if fifteenPartReturnLineDowntrend and not sixteenPartReturnLineDowntrend
fifteenPartReturnLineDowntrendCounter += 1
if sixteenPartReturnLineDowntrend and not seventeenPartReturnLineDowntrend
sixteenPartReturnLineDowntrendCounter += 1
if seventeenPartReturnLineDowntrend and not eighteenPartReturnLineDowntrend
seventeenPartReturnLineDowntrendCounter += 1
if eighteenPartReturnLineDowntrend and not nineteenPartReturnLineDowntrend
eighteenPartReturnLineDowntrendCounter += 1
if nineteenPartReturnLineDowntrend and not twentyPartReturnLineDowntrend
eighteenPartReturnLineDowntrendCounter += 1
if twentyPartReturnLineDowntrend
twentyPartReturnLineDowntrendCounter += 1
//////////// table ////////////
trendTablePositionInput = input(title = 'Position', defval = 'Top Right', options = ['Top Right', 'Top Center', 'Top Left', 'Bottom Right', 'Bottom Center', 'Bottom Left',
'Middle Right', 'Middle Center', 'Middle Left'], group = 'Table Positioning')
trendTablePosition = trendTablePositionInput == 'Top Right' ? position.top_right : trendTablePositionInput == 'Top Center' ? position.top_center :
trendTablePositionInput == 'Top Left' ? position.top_left : trendTablePositionInput == 'Bottom Right' ? position.bottom_right :
trendTablePositionInput == 'Bottom Center' ? position.bottom_center : trendTablePositionInput == 'Bottom Left' ? position.bottom_left :
trendTablePositionInput == 'Middle Right' ? position.middle_right : trendTablePositionInput == 'Middle Center' ? position.middle_center :
trendTablePositionInput == 'Middle Left' ? position.middle_left : na
textSizeInput = input(title = 'Text Size', defval = 'Normal', options = ['Tiny', 'Small', 'Normal', 'Large'], group = 'Table Text Sizing')
textSize = textSizeInput == 'Tiny' ? size.tiny : textSizeInput == 'Small' ? size.small : textSizeInput == 'Normal' ? size.normal : textSizeInput == 'Large' ? size.large : na
var trendTable = table.new(trendTablePosition, 100, 100, border_width = 1)
table.cell(trendTable, 2, 0, text = "Return Line Uptrends", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 0, text = "% Total", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 0, text = "% Last", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 0, text = "Downtrends", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 0, text = "% Total", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 0, text = "% Last", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 1, 1, text = "1-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 1, text = tostring(onePartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 1, text = "-", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 1, text = "-", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 1, text = tostring(onePartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 1, text = "-", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 1, text = "-", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 21, text = "Uptrends", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 21, text = "% Total", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 21, text = "% Last", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 21, text = "Return Line Downtrends", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 21, text = "% Total", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 21, text = "% Last", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 1, 22, text = "1-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 22, text = tostring(onePartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 22, text = "-", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 22, text = "-", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 22, text = tostring(onePartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 22, text = "-", bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 22, text = "-", bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twoPartReturnLineUptrendCounter >= 1 or twoPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 2, text = "2-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 2, text = tostring(twoPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 2, text = tostring(round(twoPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 2, text = "-", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 2, text = tostring(twoPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 2, text = tostring(round(twoPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 2, text = "-", bgcolor = color.red, text_color = color.white, text_size = textSize)
if (threePartReturnLineUptrendCounter >= 1 or threePartDowntrendCounter >= 1)
table.cell(trendTable, 1, 3, text = "3-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 3, text = tostring(threePartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 3, text = tostring(round(threePartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 3, text = tostring(round(threePartReturnLineUptrendCounter / twoPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 3, text = tostring(threePartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 3, text = tostring(round(threePartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 3, text = tostring(round(threePartDowntrendCounter / twoPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourPartReturnLineUptrendCounter >= 1 or fourPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 4, text = "4-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 4, text = tostring(fourPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 4, text = tostring(round(fourPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 4, text = tostring(round(fourPartReturnLineUptrendCounter / threePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 4, text = tostring(fourPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 4, text = tostring(round(fourPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 4, text = tostring(round(fourPartDowntrendCounter / threePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fivePartReturnLineUptrendCounter >= 1 or fivePartDowntrendCounter >= 1)
table.cell(trendTable, 1, 5, text = "5-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 5, text = tostring(fivePartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 5, text = tostring(round(fivePartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 5, text = tostring(round(fivePartReturnLineUptrendCounter / fourPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 5, text = tostring(fivePartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 5, text = tostring(round(fivePartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 5, text = tostring(round(fivePartDowntrendCounter / fourPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixPartReturnLineUptrendCounter >= 1 or sixPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 6, text = "6-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 6, text = tostring(sixPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 6, text = tostring(round(sixPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 6, text = tostring(round(sixPartReturnLineUptrendCounter / fivePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 6, text = tostring(sixPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 6, text = tostring(round(sixPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 6, text = tostring(round(sixPartDowntrendCounter / fivePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sevenPartReturnLineUptrendCounter >= 1 or sevenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 7, text = "7-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 7, text = tostring(sevenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 7, text = tostring(round(sevenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 7, text = tostring(round(sevenPartReturnLineUptrendCounter / sixPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 7, text = tostring(sevenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 7, text = tostring(round(sevenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 7, text = tostring(round(sevenPartDowntrendCounter / sixPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eightPartReturnLineUptrendCounter >= 1 or eightPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 8, text = "8-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 8, text = tostring(eightPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 8, text = tostring(round(eightPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 8, text = tostring(round(eightPartReturnLineUptrendCounter / sevenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 8, text = tostring(eightPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 8, text = tostring(round(eightPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 8, text = tostring(round(eightPartDowntrendCounter / sevenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (ninePartReturnLineUptrendCounter >= 1 or ninePartDowntrendCounter >= 1)
table.cell(trendTable, 1, 9, text = "9-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 9, text = tostring(ninePartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 9, text = tostring(round(ninePartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 9, text = tostring(round(ninePartReturnLineUptrendCounter / eightPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 9, text = tostring(ninePartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 9, text = tostring(round(ninePartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 9, text = tostring(round(ninePartDowntrendCounter / eightPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (tenPartReturnLineUptrendCounter >= 1 or tenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 10, text = "10-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 10, text = tostring(tenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 10, text = tostring(round(tenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 10, text = tostring(round(tenPartReturnLineUptrendCounter / ninePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 10, text = tostring(tenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 10, text = tostring(round(tenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 10, text = tostring(round(tenPartDowntrendCounter / ninePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (elevenPartReturnLineUptrendCounter >= 1 or elevenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 11, text = "11-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 11, text = tostring(elevenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 11, text = tostring(round(elevenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 11, text = tostring(round(elevenPartReturnLineUptrendCounter / tenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 11, text = tostring(elevenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 11, text = tostring(round(elevenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 11, text = tostring(round(elevenPartDowntrendCounter / tenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twelvePartReturnLineUptrendCounter >= 1 or twelvePartDowntrendCounter >= 1)
table.cell(trendTable, 1, 12, text = "12-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 12, text = tostring(twelvePartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 12, text = tostring(round(twelvePartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 12, text = tostring(round(twelvePartReturnLineUptrendCounter / elevenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 12, text = tostring(twelvePartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 12, text = tostring(round(twelvePartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 12, text = tostring(round(twelvePartDowntrendCounter / elevenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirteenPartReturnLineUptrendCounter >= 1 or thirteenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 13, text = "13-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 13, text = tostring(thirteenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 13, text = tostring(round(thirteenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 13, text = tostring(round(thirteenPartReturnLineUptrendCounter / twelvePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 13, text = tostring(thirteenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 13, text = tostring(round(thirteenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 13, text = tostring(round(thirteenPartDowntrendCounter / twelvePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourteenPartReturnLineUptrendCounter >= 1 or fourteenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 14, text = "14-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 14, text = tostring(fourteenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 14, text = tostring(round(fourteenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 14, text = tostring(round(fourteenPartReturnLineUptrendCounter / thirteenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 14, text = tostring(fourteenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 14, text = tostring(round(fourteenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 14, text = tostring(round(fourteenPartDowntrendCounter / thirteenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fifteenPartReturnLineUptrendCounter >= 1 or fifteenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 15, text = "15-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 15, text = tostring(fifteenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 15, text = tostring(round(fifteenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 15, text = tostring(round(fifteenPartReturnLineUptrendCounter / fourteenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 15, text = tostring(fifteenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 15, text = tostring(round(fifteenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 15, text = tostring(round(fifteenPartDowntrendCounter / fourteenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixteenPartReturnLineUptrendCounter >= 1 or sixteenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 16, text = "16-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 16, text = tostring(sixteenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 16, text = tostring(round(sixteenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)) , bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 16, text = tostring(round(sixteenPartReturnLineUptrendCounter / fifteenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 16, text = tostring(sixteenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 16, text = tostring(round(sixteenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)) , bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 16, text = tostring(round(sixteenPartDowntrendCounter / fifteenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (seventeenPartReturnLineUptrendCounter >= 1 or seventeenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 17, text = "17-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 17, text = tostring(seventeenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 17, text = tostring(round(seventeenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 17, text = tostring(round(seventeenPartReturnLineUptrendCounter / sixteenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 17, text = tostring(seventeenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 17, text = tostring(round(seventeenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 17, text = tostring(round(seventeenPartDowntrendCounter / sixteenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eighteenPartReturnLineUptrendCounter >= 1 or eighteenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 18, text = "18-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 18, text = tostring(eighteenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 18, text = tostring(round(eighteenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 18, text = tostring(round(eighteenPartReturnLineUptrendCounter / seventeenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 18, text = tostring(eighteenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 18, text = tostring(round(eighteenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 18, text = tostring(round(eighteenPartDowntrendCounter / seventeenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineteenPartReturnLineUptrendCounter >= 1 or nineteenPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 19, text = "19-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 19, text = tostring(nineteenPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 19, text = tostring(round(nineteenPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 19, text = tostring(round(nineteenPartReturnLineUptrendCounter / eighteenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 19, text = tostring(nineteenPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 19, text = tostring(round(nineteenPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 19, text = tostring(round(nineteenPartDowntrendCounter / eighteenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyPartReturnLineUptrendCounter >= 1 or twentyPartDowntrendCounter >= 1)
table.cell(trendTable, 1, 20, text = "20-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 20, text = tostring(twentyPartReturnLineUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 20, text = tostring(round(twentyPartReturnLineUptrendCounter / onePartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 20, text = tostring(round(twentyPartReturnLineUptrendCounter / nineteenPartReturnLineUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 20, text = tostring(twentyPartDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 20, text = tostring(round(twentyPartDowntrendCounter / onePartDowntrendCounter * 100, 2)), bgcolor = color.red,text_color = color.white, text_size=textSize)
table.cell(trendTable, 7, 20, text = tostring(round(twentyPartDowntrendCounter / nineteenPartDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twoPartUptrendCounter >= 1 or twoPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 23, text = "2-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 23, text = tostring(twoPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 23, text = tostring(round(twoPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 23, text = "-", bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 23, text = tostring(twoPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 23, text = tostring(round(twoPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 23, text = "-", bgcolor = color.red, text_color = color.white, text_size = textSize)
if (threePartUptrendCounter >= 1 or threePartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 24, text = "3-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 24, text = tostring(threePartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 24, text = tostring(round(threePartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 24, text = tostring(round(threePartUptrendCounter / twoPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 24, text = tostring(threePartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 24, text = tostring(round(threePartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 24, text = tostring(round(threePartReturnLineDowntrendCounter / twoPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourPartUptrendCounter >= 1 or fourPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 25, text = "4-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 25, text = tostring(fourPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 25, text = tostring(round(fourPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 25, text = tostring(round(fourPartUptrendCounter / threePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 25, text = tostring(fourPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 25, text = tostring(round(fourPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 25, text = tostring(round(fourPartReturnLineDowntrendCounter / threePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fivePartUptrendCounter >= 1 or fivePartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 26, text = "5-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 26, text = tostring(fivePartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 26, text = tostring(round(fivePartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 26, text = tostring(round(fivePartUptrendCounter / fourPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 26, text = tostring(fivePartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 26, text = tostring(round(fivePartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 26, text = tostring(round(fivePartReturnLineDowntrendCounter / fourPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixPartUptrendCounter >= 1 or sixPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 27, text = "6-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 27, text = tostring(sixPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 27, text = tostring(round(sixPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 27, text = tostring(round(sixPartUptrendCounter / fivePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 27, text = tostring(sixPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 27, text = tostring(round(sixPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 27, text = tostring(round(sixPartReturnLineDowntrendCounter / fivePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sevenPartUptrendCounter >= 1 or sevenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 28, text = "7-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 28, text = tostring(sevenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 28, text = tostring(round(sevenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 28, text = tostring(round(sevenPartUptrendCounter / sixPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 28, text = tostring(sevenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 28, text = tostring(round(sevenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 28, text = tostring(round(sevenPartReturnLineDowntrendCounter / sixPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eightPartUptrendCounter >= 1 or eightPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 29, text = "8-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 29, text = tostring(eightPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 29, text = tostring(round(eightPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 29, text = tostring(round(eightPartUptrendCounter / sevenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 29, text = tostring(eightPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 29, text = tostring(round(eightPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 29, text = tostring(round(eightPartReturnLineDowntrendCounter / sevenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (ninePartUptrendCounter >= 1 or ninePartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 30, text = "9-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 30, text = tostring(ninePartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 30, text = tostring(round(ninePartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 30, text = tostring(round(ninePartUptrendCounter / eightPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 30, text = tostring(ninePartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 30, text = tostring(round(ninePartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 30, text = tostring(round(ninePartReturnLineDowntrendCounter / eightPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (tenPartUptrendCounter >= 1 or tenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 31, text = "10-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 31, text = tostring(tenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 31, text = tostring(round(tenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 31, text = tostring(round(tenPartUptrendCounter / ninePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 31, text = tostring(tenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 31, text = tostring(round(tenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 31, text = tostring(round(tenPartReturnLineDowntrendCounter / ninePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (elevenPartUptrendCounter >= 1 or elevenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 32, text = "11-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 32, text = tostring(elevenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 32, text = tostring(round(elevenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 32, text = tostring(round(elevenPartUptrendCounter / tenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 32, text = tostring(elevenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 32, text = tostring(round(elevenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 32, text = tostring(round(elevenPartReturnLineDowntrendCounter / tenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twelvePartUptrendCounter >= 1 or twelvePartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 33, text = "12-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 33, text = tostring(twelvePartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 33, text = tostring(round(twelvePartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 33, text = tostring(round(twelvePartUptrendCounter / elevenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 33, text = tostring(twelvePartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 33, text = tostring(round(twelvePartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 33, text = tostring(round(twelvePartReturnLineDowntrendCounter / elevenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (thirteenPartUptrendCounter >= 1 or thirteenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 34, text = "13-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 34, text = tostring(thirteenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 34, text = tostring(round(thirteenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 34, text = tostring(round(thirteenPartUptrendCounter / twelvePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 34, text = tostring(thirteenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 34, text = tostring(round(thirteenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 34, text = tostring(round(thirteenPartReturnLineDowntrendCounter / twelvePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fourteenPartUptrendCounter >= 1 or fourteenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 35, text = "14-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 35, text = tostring(fourteenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 35, text = tostring(round(fourteenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 35, text = tostring(round(fourteenPartUptrendCounter / thirteenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 35, text = tostring(fourteenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 35, text = tostring(round(fourteenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 35, text = tostring(round(fourteenPartReturnLineDowntrendCounter / thirteenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (fifteenPartUptrendCounter >= 1 or fifteenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 36, text = "15-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 36, text = tostring(fifteenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 36, text = tostring(round(fifteenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 36, text = tostring(round(fifteenPartUptrendCounter / fourteenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 36, text = tostring(fifteenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 36, text = tostring(round(fifteenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 36, text = tostring(round(fifteenPartReturnLineDowntrendCounter / fourteenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (sixteenPartUptrendCounter >= 1 or sixteenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 37, text = "16-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 37, text = tostring(sixteenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 37, text = tostring(round(sixteenPartUptrendCounter / onePartUptrendCounter * 100, 2)) , bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 37, text = tostring(round(sixteenPartUptrendCounter / fifteenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 37, text = tostring(sixteenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 37, text = tostring(round(sixteenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)) , bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 37, text = tostring(round(sixteenPartReturnLineDowntrendCounter / fifteenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (seventeenPartUptrendCounter >= 1 or seventeenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 38, text = "17-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 38, text = tostring(seventeenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 38, text = tostring(round(seventeenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 38, text = tostring(round(seventeenPartUptrendCounter / sixteenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 38, text = tostring(seventeenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 38, text = tostring(round(seventeenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 38, text = tostring(round(seventeenPartReturnLineDowntrendCounter / sixteenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (eighteenPartUptrendCounter >= 1 or eighteenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 39, text = "18-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 39, text = tostring(eighteenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 39, text = tostring(round(eighteenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 39, text = tostring(round(eighteenPartUptrendCounter / seventeenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 39, text = tostring(eighteenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 39, text = tostring(round(eighteenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 39, text = tostring(round(eighteenPartReturnLineDowntrendCounter / seventeenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (nineteenPartUptrendCounter >= 1 or nineteenPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 40, text = "19-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 40, text = tostring(nineteenPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 40, text = tostring(round(nineteenPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 40, text = tostring(round(nineteenPartUptrendCounter / eighteenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 40, text = tostring(nineteenPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 40, text = tostring(round(nineteenPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 7, 40, text = tostring(round(nineteenPartReturnLineDowntrendCounter / eighteenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if (twentyPartUptrendCounter >= 1 or twentyPartReturnLineDowntrendCounter >= 1)
table.cell(trendTable, 1, 41, text = "20-Part", bgcolor = color.blue, text_color = color.white, text_size = textSize)
table.cell(trendTable, 2, 41, text = tostring(twentyPartUptrendCounter), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 3, 41, text = tostring(round(twentyPartUptrendCounter / onePartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 4, 41, text = tostring(round(twentyPartUptrendCounter / nineteenPartUptrendCounter * 100, 2)), bgcolor = color.green, text_color = color.white, text_size = textSize)
table.cell(trendTable, 5, 41, text = tostring(twentyPartReturnLineDowntrendCounter), bgcolor = color.red, text_color = color.white, text_size = textSize)
table.cell(trendTable, 6, 41, text = tostring(round(twentyPartReturnLineDowntrendCounter / onePartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red,text_color = color.white, text_size=textSize)
table.cell(trendTable, 7, 41, text = tostring(round(twentyPartReturnLineDowntrendCounter / nineteenPartReturnLineDowntrendCounter * 100, 2)), bgcolor = color.red, text_color = color.white, text_size = textSize)
if showSamplePeriod
table.cell(trendTable, 1, 42, text = startDateText + endDateText, bgcolor = color.black, text_color = color.white, text_size = textSize)
|
Return Line Uptrends [theEccentricTrader] | https://www.tradingview.com/script/C2NDkKj7-Return-Line-Uptrends-theEccentricTrader/ | theEccentricTrader | https://www.tradingview.com/u/theEccentricTrader/ | 16 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theEccentricTrader
//@version=5
indicator('Return Line Uptrends [theEccentricTrader]', overlay = true)
//////////// return line uptrends ////////////
shPrice = close[1] >= open[1] and close < open and high >= high[1] and barstate.isconfirmed ? high :
close[1] >= open[1] and close < open and high <= high[1] and barstate.isconfirmed ? high[1] : na
onePartReturnLineUptrend = shPrice > ta.valuewhen(shPrice, shPrice, 1)
twoPartReturnLineUptrend = onePartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 1) > ta.valuewhen(shPrice, shPrice, 2)
threePartReturnLineUptrend = twoPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 2) > ta.valuewhen(shPrice, shPrice, 3)
fourPartReturnLineUptrend = threePartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 3) > ta.valuewhen(shPrice, shPrice, 4)
fivePartReturnLineUptrend = fourPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 4) > ta.valuewhen(shPrice, shPrice, 5)
sixPartReturnLineUptrend = fivePartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 5) > ta.valuewhen(shPrice, shPrice, 6)
sevenPartReturnLineUptrend = sixPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 6) > ta.valuewhen(shPrice, shPrice, 7)
eightPartReturnLineUptrend = sevenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 7) > ta.valuewhen(shPrice, shPrice, 8)
ninePartReturnLineUptrend = eightPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 8) > ta.valuewhen(shPrice, shPrice, 9)
tenPartReturnLineUptrend = ninePartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 9) > ta.valuewhen(shPrice, shPrice, 10)
elevenPartReturnLineUptrend = tenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 10) > ta.valuewhen(shPrice, shPrice, 11)
twelvePartReturnLineUptrend = elevenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 11) > ta.valuewhen(shPrice, shPrice, 12)
thirteenPartReturnLineUptrend = twelvePartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 12) > ta.valuewhen(shPrice, shPrice, 13)
fourteenPartReturnLineUptrend = thirteenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 13) > ta.valuewhen(shPrice, shPrice, 14)
fifteenPartReturnLineUptrend = fourteenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 14) > ta.valuewhen(shPrice, shPrice, 15)
sixteenPartReturnLineUptrend = fifteenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 15) > ta.valuewhen(shPrice, shPrice, 16)
seventeenPartReturnLineUptrend = sixteenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 16) > ta.valuewhen(shPrice, shPrice, 17)
eighteenPartReturnLineUptrend = seventeenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 17) > ta.valuewhen(shPrice, shPrice, 18)
nineteenPartReturnLineUptrend = eighteenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 18) > ta.valuewhen(shPrice, shPrice, 19)
twentyPartReturnLineUptrend = nineteenPartReturnLineUptrend and ta.valuewhen(shPrice, shPrice, 19) > ta.valuewhen(shPrice, shPrice, 20)
//////////// plots ////////////
plotshape(shPrice and onePartReturnLineUptrend and not twoPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? onePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '1', textcolor = color.green)
plotshape(shPrice and twoPartReturnLineUptrend and not threePartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? twoPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '2', textcolor = color.green)
plotshape(shPrice and threePartReturnLineUptrend and not fourPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? threePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '3', textcolor = color.green)
plotshape(shPrice and fourPartReturnLineUptrend and not fivePartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? fourPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '4', textcolor = color.green)
plotshape(shPrice and fivePartReturnLineUptrend and not sixPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? fivePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '5', textcolor = color.green)
plotshape(shPrice and sixPartReturnLineUptrend and not sevenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? sixPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '6', textcolor = color.green)
plotshape(shPrice and sevenPartReturnLineUptrend and not eightPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? sevenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '7', textcolor = color.green)
plotshape(shPrice and eightPartReturnLineUptrend and not ninePartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? eightPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '8', textcolor = color.green)
plotshape(shPrice and ninePartReturnLineUptrend and not tenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? ninePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '9', textcolor = color.green)
plotshape(shPrice and tenPartReturnLineUptrend and not elevenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? tenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '10', textcolor = color.green)
plotshape(shPrice and elevenPartReturnLineUptrend and not twelvePartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? elevenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '11', textcolor = color.green)
plotshape(shPrice and twelvePartReturnLineUptrend and not thirteenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? twelvePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '12', textcolor = color.green)
plotshape(shPrice and thirteenPartReturnLineUptrend and not fourteenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? thirteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '13', textcolor = color.green)
plotshape(shPrice and fourteenPartReturnLineUptrend and not fifteenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? fourteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '14', textcolor = color.green)
plotshape(shPrice and fifteenPartReturnLineUptrend and not sixteenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? fifteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '15', textcolor = color.green)
plotshape(shPrice and sixteenPartReturnLineUptrend and not seventeenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? sixteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '16', textcolor = color.green)
plotshape(shPrice and seventeenPartReturnLineUptrend and not eighteenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? seventeenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '17', textcolor = color.green)
plotshape(shPrice and eighteenPartReturnLineUptrend and not nineteenPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? eighteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '18', textcolor = color.green)
plotshape(shPrice and nineteenPartReturnLineUptrend and not twentyPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? nineteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '19', textcolor = color.green)
plotshape(shPrice and twentyPartReturnLineUptrend and high >= high[1] and barstate.isconfirmed ? twentyPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '20', textcolor = color.green)
plotshape(shPrice and onePartReturnLineUptrend and not twoPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? onePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '1', textcolor = color.green, offset = -1)
plotshape(shPrice and twoPartReturnLineUptrend and not threePartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? twoPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '2', textcolor = color.green, offset = -1)
plotshape(shPrice and threePartReturnLineUptrend and not fourPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? threePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '3', textcolor = color.green, offset = -1)
plotshape(shPrice and fourPartReturnLineUptrend and not fivePartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? fourPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '4', textcolor = color.green, offset = -1)
plotshape(shPrice and fivePartReturnLineUptrend and not sixPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? fivePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '5', textcolor = color.green, offset = -1)
plotshape(shPrice and sixPartReturnLineUptrend and not sevenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? sixPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '6', textcolor = color.green, offset = -1)
plotshape(shPrice and sevenPartReturnLineUptrend and not eightPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? sevenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '7', textcolor = color.green, offset = -1)
plotshape(shPrice and eightPartReturnLineUptrend and not ninePartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? eightPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '8', textcolor = color.green, offset = -1)
plotshape(shPrice and ninePartReturnLineUptrend and not tenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? ninePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '9', textcolor = color.green, offset = -1)
plotshape(shPrice and tenPartReturnLineUptrend and not elevenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? tenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '10', textcolor = color.green, offset = -1)
plotshape(shPrice and elevenPartReturnLineUptrend and not twelvePartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? elevenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '11', textcolor = color.green, offset = -1)
plotshape(shPrice and twelvePartReturnLineUptrend and not thirteenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? twelvePartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '12', textcolor = color.green, offset = -1)
plotshape(shPrice and thirteenPartReturnLineUptrend and not fourteenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? thirteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '13', textcolor = color.green, offset = -1)
plotshape(shPrice and fourteenPartReturnLineUptrend and not fifteenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? fourteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '14', textcolor = color.green, offset = -1)
plotshape(shPrice and fifteenPartReturnLineUptrend and not sixteenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? fifteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '15', textcolor = color.green, offset = -1)
plotshape(shPrice and sixteenPartReturnLineUptrend and not seventeenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? sixteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '16', textcolor = color.green, offset = -1)
plotshape(shPrice and seventeenPartReturnLineUptrend and not eighteenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? seventeenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '17', textcolor = color.green, offset = -1)
plotshape(shPrice and eighteenPartReturnLineUptrend and not nineteenPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? eighteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '18', textcolor = color.green, offset = -1)
plotshape(shPrice and nineteenPartReturnLineUptrend and not twentyPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? nineteenPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '19', textcolor = color.green, offset = -1)
plotshape(shPrice and twentyPartReturnLineUptrend and high < high[1] and barstate.isconfirmed ? twentyPartReturnLineUptrend : na,
style = shape.triangleup, color = color.green, text = '20', textcolor = color.green, offset = -1)
|
Kimchi Premium watch | https://www.tradingview.com/script/JNYTNY7t/ | Quu | https://www.tradingview.com/u/Quu/ | 49 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Quu
//@version=5
indicator('Kimchi Premium watch', scale=scale.none, overlay = true)
dollar = input.symbol(title='Dollar/KRW', defval='USDKRW')
dollar_value = request.security(dollar, timeframe.period, close)
btcusdt = input.symbol(title='BTCUSDT', defval='BINANCE:BTCUSDT')
btcusdt_value = request.security(btcusdt, timeframe.period, close)
usdtusd = input.symbol(title='USDTUSD', defval='BITSTAMP:USDTUSD')
usdt_usd_value = request.security(usdtusd, timeframe.period, close)
btckrw = input.symbol(title='BTCKRW', defval='UPBIT:BTCKRW')
btckrw_value = request.security(btckrw, timeframe.period, close)
converted = btcusdt_value * usdt_usd_value * dollar_value
premium_btc = (btckrw_value - converted) / converted * 100
symbol = syminfo.ticker
cleaned_symbol = symbol
ends_with_perp = str.endswith(symbol, ".P")
if ends_with_perp
cleaned_symbol := str.replace(symbol, ".P", "")
ends_with_busd = str.endswith(cleaned_symbol, "BUSD")
ends_with_usd = str.endswith(cleaned_symbol, "USD")
ends_with_usdt = str.endswith(cleaned_symbol, "USDT")
ends_with_krw = str.endswith(cleaned_symbol, "KRW")
tic = "unknown"
tic_text = "Not supported"
tic_size = size.large
if ends_with_busd
tic := str.replace(cleaned_symbol, "BUSD", "")
else if ends_with_usd
tic := str.replace(cleaned_symbol, "USD", "")
else if ends_with_usdt
tic := str.replace(cleaned_symbol, "USDT", "")
else if ends_with_krw
tic := str.replace(cleaned_symbol, "KRW", "")
binance_busd = request.security("BINANCE:"+tic+"BUSD", timeframe.period, close, ignore_invalid_symbol = true)
binance_usdt = request.security("BINANCE:"+tic+"USDT", timeframe.period, close, ignore_invalid_symbol = true)
coinbase_usd = request.security("COINBASE:"+tic+"USD", timeframe.period, close, ignore_invalid_symbol = true)
upbit_krw = request.security("UPBIT:"+tic+"KRW", timeframe.period, close, ignore_invalid_symbol = true)
curr_krw_data = request.security(tic+"KRW", timeframe.period, close, ignore_invalid_symbol = true)
curr_usd_data = request.security(tic+"USD", timeframe.period, close, ignore_invalid_symbol = true)
curr_usdt_data = request.security(tic+"USDT", timeframe.period, close, ignore_invalid_symbol = true)
curr_busd_data = request.security(tic+"BUSD", timeframe.period, close, ignore_invalid_symbol = true)
premium_curr = 0.1
not_supported = false
if ends_with_busd
busd_data = close
if not na(upbit_krw)
curr_converted = busd_data * dollar_value
premium_curr := (upbit_krw - curr_converted) / curr_converted * 100
else if not na(curr_krw_data)
curr_converted = busd_data * dollar_value
premium_curr := (curr_krw_data - curr_converted) / curr_converted * 100
else
not_supported := true
else if ends_with_usd
usd_data = close
if not na(upbit_krw)
curr_converted = usd_data * dollar_value
premium_curr := (upbit_krw - curr_converted) / curr_converted * 100
else if not na(curr_krw_data)
curr_converted = usd_data * dollar_value
premium_curr := (curr_krw_data - curr_converted) / curr_converted * 100
else
not_supported := true
else if ends_with_usdt
usdt_data = close
if not na(upbit_krw)
curr_converted = usdt_data * usdt_usd_value * dollar_value
premium_curr := (upbit_krw - curr_converted) / curr_converted * 100
else if not na(curr_krw_data)
curr_converted = usdt_data * usdt_usd_value * dollar_value
premium_curr := (curr_krw_data - curr_converted) / curr_converted * 100
else
not_supported := true
else if ends_with_krw
krw_data = close
if not na(binance_usdt)
curr_converted = binance_usdt * usdt_usd_value * dollar_value
premium_curr := (krw_data - curr_converted) / curr_converted * 100
else if not na(curr_usdt_data)
curr_converted = curr_usdt_data * usdt_usd_value * dollar_value
premium_curr := (krw_data - curr_converted) / curr_converted * 100
else
not_supported := true
else
not_supported := true
if not_supported
tic_text := "Not supported"
tic_size := size.normal
else
tic_text := str.tostring(math.round(premium_curr * 100) / 100) + " %"
tic_size := size.large
var premium_table = table.new(position = position.top_right, columns = 2, rows = 4, bgcolor = color.rgb(95,95,95), border_width = 1, frame_color = color.yellow, border_color = color.yellow, frame_width = 1)
table.merge_cells(premium_table, 0, 0, 1, 0)
if tic == 'BTC'
table.merge_cells(premium_table, 0, 1, 0, 2)
table.merge_cells(premium_table, 1, 1, 1, 2)
table.cell(table_id = premium_table, column = 0, row = 0, text = "Kimchi premium", text_color = color.white, bgcolor = color.black)
table.cell(table_id = premium_table, column = 0, row = 1, text = "BTC", text_color = color.white)
table.cell(table_id = premium_table, column = 0, row = 2, text = tic, text_color = color.white)
table.cell(table_id = premium_table, column = 1, row = 1, text = str.tostring(math.round(premium_btc * 100) / 100) + " %", text_color = color.white, text_size = size.large, text_halign = text.align_right)
table.cell(table_id = premium_table, column = 1, row = 2, text = str.tostring(tic_text), text_color = color.white, text_size = tic_size, text_halign = text.align_right) |
Remove Hodler [5ema] | https://www.tradingview.com/script/EWyQX2Qk-Remove-Hodler-5ema/ | vn5ema | https://www.tradingview.com/u/vn5ema/ | 45 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Reused some functions from (I believe made by Β©paaax, @QuantNomad)
// Β©paaax: The table position function (https://www.tradingview.com/script/Jp37jHwT-PX-MTF-Overview/).
// @QuantNomad: The function calculated value and array screener for 40+ instruments (https://www.tradingview.com/script/zN8rwPFF-Screener-for-40-instruments/).
// Β© vn-5ema
//@version=5
indicator('Remove Hodler [5ema]', overlay = true)
// Timeframe
itimeframe = input.timeframe(defval = "D", title = "Time frame", tooltip = "By defaul, flowing the current chart. Can select another to only flowing.")
// Look back day
ilookback = input.int(defval = 30, title = "Number of bars", minval = 1, tooltip = "By befaul, choose 30 days.")
// Input changingpercent
iRange = input.float(defval = 50, title = "Change percentage (%)", minval = 10, tooltip = "The maximum Price changed.")
// Input number of shooting bar
iShooting = input.int(defval = 9, title = "Number of Shooting bars", minval = 1, tooltip = "Should follow minimum 9 shootting bars.")
ipercent = input.int(defval = 25, title = "Percent of Shooting", minval = 1, tooltip = "By defaut, price of (close + open) = 0.25*(high + low).")
// Set up table
pTable = input.string("Bottom Left", title="Show tables at", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], group="Set up table")
// Set up table
/////// This function reused from Β©paaax /////
getPosition(pTable) =>
ret = position.top_left
if pTable == "Top Center"
ret := position.top_center
if pTable == "Top Right"
ret := position.top_right
if pTable == "Middle Left"
ret := position.middle_left
if pTable == "Middle Center"
ret := position.middle_center
if pTable == "Middle Right"
ret := position.middle_right
if pTable == "Bottom Left"
ret := position.bottom_left
if pTable == "Bottom Center"
ret := position.bottom_center
if pTable == "Bottom Right"
ret := position.bottom_right
ret
/////////
// Set up color of table
table_boder = input(color.new(color.white, 100), group = "Set up table", title = "Boder Color ")
table_frame = input(#151715, group = "Set up table", title ="Frame Color ")
table_bg = input(color.black, group = "Set up table", title ="Back Color ")
table_text = input(color.white, group = "Set up table", title ="Text Color ")
boolTbale = input.bool(defval = true, title = "Show tables", group = "Set up table")
boolalltable = input.bool(defval = false, title = "Show all symbols on table", group = "Set up table")
boolshooting = input.bool(defval = true, title = "Show shooting bars", group = "Set up table")
boolrange = input.bool(defval = true, title = "Show checking ranges", group = "Set up table")
// Bool Symbols
/////// This bool symbool refer from @QuantNomad /////
u01 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's01')
u02 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's02')
u03 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's03')
u04 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's04')
u05 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's05')
u06 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's06')
u07 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's07')
u08 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's08')
u09 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's09')
u10 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's10')
u11 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's11')
u12 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's12')
u13 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's13')
u14 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's14')
u15 = input.bool(true, title = "", group = 'Symbols following (maximum 40)', inline = 's15')
u16 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's16')
u17 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's17')
u18 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's18')
u19 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's19')
u20 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's20')
u21 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's21')
u22 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's22')
u23 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's23')
u24 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's24')
u25 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's25')
u26 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's26')
u27 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's27')
u28 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's28')
u29 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's29')
u30 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's30')
u31 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's31')
u32 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's32')
u33 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's33')
u34 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's34')
u35 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's35')
u36 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's36')
u37 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's37')
u38 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's38')
u39 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's39')
//u40 = input.bool(false, title = "", group = 'Symbols following (maximum 40)', inline = 's40')
// Input Symbols
s01 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's01')
s02 = input.symbol('ETHUSDT', group = 'Symbols following (maximum 40)', inline = 's02')
s03 = input.symbol('BNBUSDT', group = 'Symbols following (maximum 40)', inline = 's03')
s04 = input.symbol('SOLUSDT', group = 'Symbols following (maximum 40)', inline = 's04')
s05 = input.symbol('ADAUSDT', group = 'Symbols following (maximum 40)', inline = 's05')
s06 = input.symbol('NEARUSDT', group = 'Symbols following (maximum 40)', inline = 's06')
s07 = input.symbol('DOTUSDT', group = 'Symbols following (maximum 40)', inline = 's07')
s08 = input.symbol('LINKUSDT', group = 'Symbols following (maximum 40)', inline = 's08')
s09 = input.symbol('TRXUSDT', group = 'Symbols following (maximum 40)', inline = 's09')
s10 = input.symbol('AVAXUSDT', group = 'Symbols following (maximum 40)', inline = 's10')
s11 = input.symbol('FTMUSDT', group = 'Symbols following (maximum 40)', inline = 's11')
s12 = input.symbol('CELOUSDT', group = 'Symbols following (maximum 40)', inline = 's12')
s13 = input.symbol('ATOMUSDT', group = 'Symbols following (maximum 40)', inline = 's13')
s14 = input.symbol('MATICUSDT', group = 'Symbols following (maximum 40)', inline = 's14')
s15 = input.symbol('LTCUSDT', group = 'Symbols following (maximum 40)', inline = 's15')
s16 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's16')
s17 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's17')
s18 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's18')
s19 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's19')
s20 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's20')
s21 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's21')
s22 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's22')
s23 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's23')
s24 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's24')
s25 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's25')
s26 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's26')
s27 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's27')
s28 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's28')
s29 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's29')
s30 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's30')
s31 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's31')
s32 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's32')
s33 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's33')
s34 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's34')
s35 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's35')
s36 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's36')
s37 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's37')
s38 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's38')
s39 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's39')
//s40 = input.symbol('BTCUSDT', group = 'Symbols following (maximum 40)', inline = 's40')
/////////
// Get only symbol
only_symbol(s) =>
array.get(str.split(s, ":"), 1)
// Calculate min max Price
rangePrice_func()=>
hPrice = ta.highest(high, ilookback)
lPrice = ta.lowest(low, ilookback)
rangePrice = ((hPrice - lPrice) / lPrice) * 100
// Calculate shooting bar
nshooting_func()=>
// Count shooting bar
shooting = low + ipercent/100 * math.abs(high - low) > math.max(open, close)
nshooting = math.sum(shooting ? 1 : 0, ilookback)
// Screener
screener_func() =>
rangePrice = rangePrice_func()
nshooting = nshooting_func()
// Alert Condition
signalBUY = rangePrice < iRange and nshooting >= iShooting
[rangePrice, nshooting, signalBUY]
// Display checking range
range_check() =>
top_range = ta.highest(high, ilookback)
bottom_range = ta.lowest(low, ilookback)
[top_range,bottom_range]
[top_range,bottom_range] = request.security(syminfo.tickerid, itimeframe, range_check())
timeframe_request = timeframe.in_seconds(itimeframe)
timeframe_current = timeframe.in_seconds(timeframe.period)
comvert_timeframe = timeframe_request / timeframe_current
rangecheck = boolrange ? box.new(left = bar_index[ilookback * comvert_timeframe] , top = top_range, right = bar_index, bottom = bottom_range, border_color = color.new(#d1d4dc, 75), bgcolor = color.new(#d1d4dc, 95)) : na
box.delete(rangecheck[1])
// Security call
/////// This bool symbool refer from @QuantNomad /////
[rangePrice01, nshooting01, signalBUY01] = request.security(s01, itimeframe, screener_func())
[rangePrice02, nshooting02, signalBUY02] = request.security(s02, itimeframe, screener_func())
[rangePrice03, nshooting03, signalBUY03] = request.security(s03, itimeframe, screener_func())
[rangePrice04, nshooting04, signalBUY04] = request.security(s04, itimeframe, screener_func())
[rangePrice05, nshooting05, signalBUY05] = request.security(s05, itimeframe, screener_func())
[rangePrice06, nshooting06, signalBUY06] = request.security(s06, itimeframe, screener_func())
[rangePrice07, nshooting07, signalBUY07] = request.security(s07, itimeframe, screener_func())
[rangePrice08, nshooting08, signalBUY08] = request.security(s08, itimeframe, screener_func())
[rangePrice09, nshooting09, signalBUY09] = request.security(s09, itimeframe, screener_func())
[rangePrice10, nshooting10, signalBUY10] = request.security(s10, itimeframe, screener_func())
[rangePrice11, nshooting11, signalBUY11] = request.security(s11, itimeframe, screener_func())
[rangePrice12, nshooting12, signalBUY12] = request.security(s12, itimeframe, screener_func())
[rangePrice13, nshooting13, signalBUY13] = request.security(s13, itimeframe, screener_func())
[rangePrice14, nshooting14, signalBUY14] = request.security(s14, itimeframe, screener_func())
[rangePrice15, nshooting15, signalBUY15] = request.security(s15, itimeframe, screener_func())
[rangePrice16, nshooting16, signalBUY16] = request.security(s16, itimeframe, screener_func())
[rangePrice17, nshooting17, signalBUY17] = request.security(s17, itimeframe, screener_func())
[rangePrice18, nshooting18, signalBUY18] = request.security(s18, itimeframe, screener_func())
[rangePrice19, nshooting19, signalBUY19] = request.security(s19, itimeframe, screener_func())
[rangePrice20, nshooting20, signalBUY20] = request.security(s20, itimeframe, screener_func())
[rangePrice21, nshooting21, signalBUY21] = request.security(s21, itimeframe, screener_func())
[rangePrice22, nshooting22, signalBUY22] = request.security(s22, itimeframe, screener_func())
[rangePrice23, nshooting23, signalBUY23] = request.security(s23, itimeframe, screener_func())
[rangePrice24, nshooting24, signalBUY24] = request.security(s24, itimeframe, screener_func())
[rangePrice25, nshooting25, signalBUY25] = request.security(s25, itimeframe, screener_func())
[rangePrice26, nshooting26, signalBUY26] = request.security(s26, itimeframe, screener_func())
[rangePrice27, nshooting27, signalBUY27] = request.security(s27, itimeframe, screener_func())
[rangePrice28, nshooting28, signalBUY28] = request.security(s28, itimeframe, screener_func())
[rangePrice29, nshooting29, signalBUY29] = request.security(s29, itimeframe, screener_func())
[rangePrice30, nshooting30, signalBUY30] = request.security(s30, itimeframe, screener_func())
[rangePrice31, nshooting31, signalBUY31] = request.security(s31, itimeframe, screener_func())
[rangePrice32, nshooting32, signalBUY32] = request.security(s32, itimeframe, screener_func())
[rangePrice33, nshooting33, signalBUY33] = request.security(s33, itimeframe, screener_func())
[rangePrice34, nshooting34, signalBUY34] = request.security(s34, itimeframe, screener_func())
[rangePrice35, nshooting35, signalBUY35] = request.security(s35, itimeframe, screener_func())
[rangePrice36, nshooting36, signalBUY36] = request.security(s36, itimeframe, screener_func())
[rangePrice37, nshooting37, signalBUY37] = request.security(s37, itimeframe, screener_func())
[rangePrice38, nshooting38, signalBUY38] = request.security(s38, itimeframe, screener_func())
[rangePrice39, nshooting39, signalBUY39] = request.security(s39, itimeframe, screener_func())
//[rangePrice40, nshooting40, signalBUY40] = request.security(s40, itimeframe, screener_func())
// For table
// Arrays //
s_arr = array.new_string(0)
u_arr = array.new_bool(0)
rangePrice_arr = array.new_float(0)
nshooting_arr = array.new_float(0)
// Add Symbols
array.push(s_arr, only_symbol(s01))
array.push(s_arr, only_symbol(s02))
array.push(s_arr, only_symbol(s03))
array.push(s_arr, only_symbol(s04))
array.push(s_arr, only_symbol(s05))
array.push(s_arr, only_symbol(s06))
array.push(s_arr, only_symbol(s07))
array.push(s_arr, only_symbol(s08))
array.push(s_arr, only_symbol(s09))
array.push(s_arr, only_symbol(s10))
array.push(s_arr, only_symbol(s11))
array.push(s_arr, only_symbol(s12))
array.push(s_arr, only_symbol(s13))
array.push(s_arr, only_symbol(s14))
array.push(s_arr, only_symbol(s15))
array.push(s_arr, only_symbol(s16))
array.push(s_arr, only_symbol(s17))
array.push(s_arr, only_symbol(s18))
array.push(s_arr, only_symbol(s19))
array.push(s_arr, only_symbol(s20))
array.push(s_arr, only_symbol(s21))
array.push(s_arr, only_symbol(s22))
array.push(s_arr, only_symbol(s23))
array.push(s_arr, only_symbol(s24))
array.push(s_arr, only_symbol(s25))
array.push(s_arr, only_symbol(s26))
array.push(s_arr, only_symbol(s27))
array.push(s_arr, only_symbol(s28))
array.push(s_arr, only_symbol(s29))
array.push(s_arr, only_symbol(s30))
array.push(s_arr, only_symbol(s31))
array.push(s_arr, only_symbol(s32))
array.push(s_arr, only_symbol(s33))
array.push(s_arr, only_symbol(s34))
array.push(s_arr, only_symbol(s35))
array.push(s_arr, only_symbol(s36))
array.push(s_arr, only_symbol(s37))
array.push(s_arr, only_symbol(s38))
array.push(s_arr, only_symbol(s39))
//array.push(s_arr, only_symbol(s40))
// Flags //
array.push(u_arr, u01)
array.push(u_arr, u02)
array.push(u_arr, u03)
array.push(u_arr, u04)
array.push(u_arr, u05)
array.push(u_arr, u06)
array.push(u_arr, u07)
array.push(u_arr, u08)
array.push(u_arr, u09)
array.push(u_arr, u10)
array.push(u_arr, u11)
array.push(u_arr, u12)
array.push(u_arr, u13)
array.push(u_arr, u14)
array.push(u_arr, u15)
array.push(u_arr, u16)
array.push(u_arr, u17)
array.push(u_arr, u18)
array.push(u_arr, u19)
array.push(u_arr, u20)
array.push(u_arr, u21)
array.push(u_arr, u22)
array.push(u_arr, u23)
array.push(u_arr, u24)
array.push(u_arr, u25)
array.push(u_arr, u26)
array.push(u_arr, u27)
array.push(u_arr, u28)
array.push(u_arr, u29)
array.push(u_arr, u30)
array.push(u_arr, u31)
array.push(u_arr, u32)
array.push(u_arr, u33)
array.push(u_arr, u34)
array.push(u_arr, u35)
array.push(u_arr, u36)
array.push(u_arr, u37)
array.push(u_arr, u38)
array.push(u_arr, u39)
//array.push(u_arr, u40)
array.push(rangePrice_arr, rangePrice01)
array.push(rangePrice_arr, rangePrice02)
array.push(rangePrice_arr, rangePrice03)
array.push(rangePrice_arr, rangePrice04)
array.push(rangePrice_arr, rangePrice05)
array.push(rangePrice_arr, rangePrice06)
array.push(rangePrice_arr, rangePrice07)
array.push(rangePrice_arr, rangePrice08)
array.push(rangePrice_arr, rangePrice09)
array.push(rangePrice_arr, rangePrice10)
array.push(rangePrice_arr, rangePrice11)
array.push(rangePrice_arr, rangePrice12)
array.push(rangePrice_arr, rangePrice13)
array.push(rangePrice_arr, rangePrice14)
array.push(rangePrice_arr, rangePrice15)
array.push(rangePrice_arr, rangePrice16)
array.push(rangePrice_arr, rangePrice17)
array.push(rangePrice_arr, rangePrice18)
array.push(rangePrice_arr, rangePrice19)
array.push(rangePrice_arr, rangePrice20)
array.push(rangePrice_arr, rangePrice21)
array.push(rangePrice_arr, rangePrice22)
array.push(rangePrice_arr, rangePrice23)
array.push(rangePrice_arr, rangePrice24)
array.push(rangePrice_arr, rangePrice25)
array.push(rangePrice_arr, rangePrice26)
array.push(rangePrice_arr, rangePrice27)
array.push(rangePrice_arr, rangePrice28)
array.push(rangePrice_arr, rangePrice29)
array.push(rangePrice_arr, rangePrice30)
array.push(rangePrice_arr, rangePrice31)
array.push(rangePrice_arr, rangePrice32)
array.push(rangePrice_arr, rangePrice33)
array.push(rangePrice_arr, rangePrice34)
array.push(rangePrice_arr, rangePrice35)
array.push(rangePrice_arr, rangePrice36)
array.push(rangePrice_arr, rangePrice37)
array.push(rangePrice_arr, rangePrice38)
array.push(rangePrice_arr, rangePrice39)
//array.push(rangePrice_arr, rangePrice40)
array.push(nshooting_arr, nshooting01)
array.push(nshooting_arr, nshooting02)
array.push(nshooting_arr, nshooting03)
array.push(nshooting_arr, nshooting04)
array.push(nshooting_arr, nshooting05)
array.push(nshooting_arr, nshooting06)
array.push(nshooting_arr, nshooting07)
array.push(nshooting_arr, nshooting08)
array.push(nshooting_arr, nshooting09)
array.push(nshooting_arr, nshooting10)
array.push(nshooting_arr, nshooting11)
array.push(nshooting_arr, nshooting12)
array.push(nshooting_arr, nshooting13)
array.push(nshooting_arr, nshooting14)
array.push(nshooting_arr, nshooting15)
array.push(nshooting_arr, nshooting16)
array.push(nshooting_arr, nshooting17)
array.push(nshooting_arr, nshooting18)
array.push(nshooting_arr, nshooting19)
array.push(nshooting_arr, nshooting20)
array.push(nshooting_arr, nshooting21)
array.push(nshooting_arr, nshooting22)
array.push(nshooting_arr, nshooting23)
array.push(nshooting_arr, nshooting24)
array.push(nshooting_arr, nshooting25)
array.push(nshooting_arr, nshooting26)
array.push(nshooting_arr, nshooting27)
array.push(nshooting_arr, nshooting28)
array.push(nshooting_arr, nshooting29)
array.push(nshooting_arr, nshooting30)
array.push(nshooting_arr, nshooting31)
array.push(nshooting_arr, nshooting32)
array.push(nshooting_arr, nshooting33)
array.push(nshooting_arr, nshooting34)
array.push(nshooting_arr, nshooting35)
array.push(nshooting_arr, nshooting36)
array.push(nshooting_arr, nshooting37)
array.push(nshooting_arr, nshooting38)
array.push(nshooting_arr, nshooting39)
//array.push(nshooting_arr, nshooting40)
//////////
// Plot Shooting
if barstate.islast
for i = 0 to ilookback
if low[i] + ipercent/100 * math.abs(high[i] - low[i]) > math.max(open[i], close[i])
lbl = boolshooting == false ? na : label.new(bar_index[i], high[i] + 2, "Shooting", yloc = yloc.abovebar, color = color.black, textcolor = color.white)
// Calculate for current symbol
rangePrice_current = ((ta.highest(high, ilookback) - ta.lowest(low, ilookback)) / ta.lowest(low, ilookback)) * 100
nshooting_current = math.sum(low + ipercent/100 * math.abs(high - low) > math.max(open, close) ? 1 : 0, ilookback)
rangePrice_col_current = rangePrice_current < iRange ? #04D204 : color.white
nshooting_col_current = nshooting_current >= iShooting ? #04D204 : color.white
signal_text_current = rangePrice_current < iRange and nshooting_current >= iShooting ? "β¦Ώ" : ""
signal_color_current = rangePrice_current < iRange and nshooting_current >= iShooting ? #04D204 : color.white
// Plot table//
/////// This bool symbool refer from @QuantNomad /////
var tbl = table.new(getPosition(pTable), 5, 41, frame_color=table_frame, frame_width=1, border_width=2, border_color= table_boder)
if barstate.islast and boolTbale
table.cell(tbl, 0, 0, "TFr", text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 1, 0, 'Symbol', text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 2, 0, 'Range', text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 3, 0, 'Shooting', text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 4, 0, 'Signal', text_halign = text.align_center, bgcolor = #fd7600, text_color = table_text, text_size = size.small)
table.cell(tbl, 0, 1, itimeframe, text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 1, 1, syminfo.ticker, text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 2, 1, str.tostring(rangePrice_current, "#.##")+"%", text_halign = text.align_center, bgcolor = table_bg, text_color = rangePrice_col_current, text_size = size.small)
table.cell(tbl, 3, 1, str.tostring(nshooting_current), text_halign = text.align_center, bgcolor = table_bg, text_color =nshooting_col_current, text_size = size.small)
table.cell(tbl, 4, 1, signal_text_current, text_halign = text.align_center, bgcolor = table_bg, text_size = size.small, text_color = signal_color_current)
if boolalltable
for i = 0 to 38
if array.get(u_arr, i)
rangePrice_col = array.get(rangePrice_arr, i) < iRange ? #04D204 : color.white
nshooting_col = array.get(nshooting_arr, i) >= iShooting ? #04D204 : color.white
signal_text = array.get(rangePrice_arr, i) < iRange and array.get(nshooting_arr, i) >= iShooting ? "β¦Ώ" : ""
signal_color = array.get(rangePrice_arr, i) < iRange and array.get(nshooting_arr, i) >= iShooting ? #04D204 : color.white
table.cell(tbl, 0, i + 2, itimeframe, text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 1, i + 2, array.get(s_arr, i), text_halign = text.align_center, bgcolor = table_bg, text_color = table_text, text_size = size.small)
table.cell(tbl, 2, i + 2, str.tostring(array.get(rangePrice_arr, i), "#.##")+"%", text_halign = text.align_center, bgcolor = table_bg, text_color =rangePrice_col, text_size = size.small)
table.cell(tbl, 3, i + 2, str.tostring(array.get(nshooting_arr, i)), text_halign = text.align_center, bgcolor = table_bg, text_color = nshooting_col, text_size = size.small)
table.cell(tbl, 4, i + 2, signal_text, text_halign = text.align_center, bgcolor = table_bg, text_size = size.small, text_color = signal_color)
//////////
// For Alert
crh_alert = ''
//Signal BUY
crh_alert := u01 != false and signalBUY01 ? crh_alert + s01 + ' - BUY' + '\n' : crh_alert
crh_alert := u02 != false and signalBUY02 ? crh_alert + s02 + ' - BUY' + '\n' : crh_alert
crh_alert := u03 != false and signalBUY03 ? crh_alert + s03 + ' - BUY' + '\n' : crh_alert
crh_alert := u04 != false and signalBUY04 ? crh_alert + s04 + ' - BUY' + '\n' : crh_alert
crh_alert := u05 != false and signalBUY05 ? crh_alert + s05 + ' - BUY' + '\n' : crh_alert
crh_alert := u06 != false and signalBUY06 ? crh_alert + s06 + ' - BUY' + '\n' : crh_alert
crh_alert := u07 != false and signalBUY07 ? crh_alert + s07 + ' - BUY' + '\n' : crh_alert
crh_alert := u08 != false and signalBUY08 ? crh_alert + s08 + ' - BUY' + '\n' : crh_alert
crh_alert := u09 != false and signalBUY09 ? crh_alert + s09 + ' - BUY' + '\n' : crh_alert
crh_alert := u10 != false and signalBUY10 ? crh_alert + s10 + ' - BUY' + '\n' : crh_alert
crh_alert := u11 != false and signalBUY11 ? crh_alert + s11 + ' - BUY' + '\n' : crh_alert
crh_alert := u12 != false and signalBUY12 ? crh_alert + s12 + ' - BUY' + '\n' : crh_alert
crh_alert := u13 != false and signalBUY13 ? crh_alert + s13 + ' - BUY' + '\n' : crh_alert
crh_alert := u14 != false and signalBUY14 ? crh_alert + s14 + ' - BUY' + '\n' : crh_alert
crh_alert := u15 != false and signalBUY15 ? crh_alert + s15 + ' - BUY' + '\n' : crh_alert
crh_alert := u16 != false and signalBUY16 ? crh_alert + s16 + ' - BUY' + '\n' : crh_alert
crh_alert := u17 != false and signalBUY17 ? crh_alert + s17 + ' - BUY' + '\n' : crh_alert
crh_alert := u18 != false and signalBUY18 ? crh_alert + s18 + ' - BUY' + '\n' : crh_alert
crh_alert := u19 != false and signalBUY19 ? crh_alert + s19 + ' - BUY' + '\n' : crh_alert
crh_alert := u20 != false and signalBUY20 ? crh_alert + s20 + ' - BUY' + '\n' : crh_alert
crh_alert := u21 != false and signalBUY21 ? crh_alert + s21 + ' - BUY' + '\n' : crh_alert
crh_alert := u22 != false and signalBUY22 ? crh_alert + s22 + ' - BUY' + '\n' : crh_alert
crh_alert := u23 != false and signalBUY23 ? crh_alert + s23 + ' - BUY' + '\n' : crh_alert
crh_alert := u24 != false and signalBUY24 ? crh_alert + s24 + ' - BUY' + '\n' : crh_alert
crh_alert := u25 != false and signalBUY25 ? crh_alert + s25 + ' - BUY' + '\n' : crh_alert
crh_alert := u26 != false and signalBUY26 ? crh_alert + s26 + ' - BUY' + '\n' : crh_alert
crh_alert := u27 != false and signalBUY27 ? crh_alert + s27 + ' - BUY' + '\n' : crh_alert
crh_alert := u28 != false and signalBUY28 ? crh_alert + s28 + ' - BUY' + '\n' : crh_alert
crh_alert := u29 != false and signalBUY29 ? crh_alert + s29 + ' - BUY' + '\n' : crh_alert
crh_alert := u30 != false and signalBUY30 ? crh_alert + s30 + ' - BUY' + '\n' : crh_alert
crh_alert := u31 != false and signalBUY31 ? crh_alert + s31 + ' - BUY' + '\n' : crh_alert
crh_alert := u32 != false and signalBUY32 ? crh_alert + s32 + ' - BUY' + '\n' : crh_alert
crh_alert := u33 != false and signalBUY33 ? crh_alert + s33 + ' - BUY' + '\n' : crh_alert
crh_alert := u34 != false and signalBUY34 ? crh_alert + s34 + ' - BUY' + '\n' : crh_alert
crh_alert := u35 != false and signalBUY35 ? crh_alert + s35 + ' - BUY' + '\n' : crh_alert
crh_alert := u36 != false and signalBUY36 ? crh_alert + s36 + ' - BUY' + '\n' : crh_alert
crh_alert := u37 != false and signalBUY37 ? crh_alert + s37 + ' - BUY' + '\n' : crh_alert
crh_alert := u38 != false and signalBUY38 ? crh_alert + s38 + ' - BUY' + '\n' : crh_alert
crh_alert := u39 != false and signalBUY39 ? crh_alert + s39 + ' - BUY' + '\n' : crh_alert
//crh_alert := u40 != false and signalBUY40 ? crh_alert + s40 + ' - BUY' + '\n' : crh_alert
// Send alert only if screener is not empty
if (crh_alert != '')
alert(crh_alert + '\n(Remove Holder [5ema.vn])', freq = alert.freq_once_per_bar_close)
|
FVGs & CEs + Alerts: simple & efficient method | https://www.tradingview.com/script/5MXFwNal-FVGs-CEs-Alerts-simple-efficient-method/ | twingall | https://www.tradingview.com/u/twingall/ | 513 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//FVG indicator: Paints FVGs and their midlines (CEs). Stops painting when CE is hit, or when fully filled; user choice of threshold. This threshold is also used in the Alert conditions.
//Big thank you to @Bjorgum for his fantastic extendAndRemove method. Modified here for use with boxes and to integrate Alerts
//29th June'23 added IOFED alerts (price merely enters FVG above or below)
//5th Nov'23 added simple 'FVG confirmed' alerts
// Β© twingall
//@version=5
indicator("FVGs & CEs + Alerts: simple method", overlay = true, max_boxes_count = 500, max_lines_count = 500)
numDays = input.int(7, "number of days lookback")
showUP = input.bool(true, "'UP' FVGs:", inline ='1')
colUp = input.color(color.new(color.blue, 86), "", inline ='1')
showDN = input.bool(true, "'DOWN' FVGs:", inline ='2')
colDn = input.color(color.new(color.orange, 86), "", inline ='2')
showCE = input.bool(true, "show CE", inline ='3')
ceCol = input.color(color.new(color.black, 1), "| color:", inline ='3')
ceStyle = input.string(line.style_dotted, "| style:", options=[line.style_dotted,line.style_solid, line.style_dashed], inline ='3')
deleteFilledBoxes = input.bool(false, "delete filled boxes & lines")
CEcond = input.bool (true, "Use CE (as opposed to Full Fill)", group = 'conditions/alerts', tooltip = "If toggled OFF, FVGs and CEs will paint until FVG has been completely filled.\n\nThis threshold is used for Above/Below threshold Alert conditions too (but does not effect the IOFED alerts):\ni.e. this will determine if your 'ABOVE threshold' alert fires when price hits latest active FVG CE ABOVE or latest active FVG Full Fill ABOVE\n\nAlerts are set by clicking the three dots on the indicator display line.")
colorNone = color.new(color.white, 100)
_day = 24*3600*1000
var box bxUp = na, var box bxDn = na, var line lnUp = na, var line lnDn = na
var array<box> bxUpArr = array.new<box>(0), var array<line> lnUpArr = array.new<line>(0)
var array<box> bxDnArr = array.new<box>(0), var array<line> lnDnArr = array.new<line>(0)
dnCE = high[1] + (low[3]-high[1])/2
upCE = low[1] - (low[1]-high[3])/2
if low[3] > high[1] and time> timenow- numDays*_day and showDN
bxDnArr.push(box.new(bar_index-3, low[3], bar_index, high[1], bgcolor = colDn, border_color = colorNone))
lnDnArr.push(line.new(bar_index-3, dnCE, bar_index, dnCE, color = showCE?ceCol:colorNone, style =ceStyle))
if high[3] < low[1] and time> timenow- numDays*_day and showUP
bxUpArr.push(box.new(bar_index-3, low[1], bar_index, high[3], bgcolor = colUp, border_color = colorNone))
lnUpArr.push(line.new(bar_index-3, upCE, bar_index, upCE, color = showCE?ceCol:colorNone, style =ceStyle))
var array<int> _countArr =array.new<int>(0)
var array<int> _countArrIOFED =array.new<int>(0)
//modified form of @Bjorgum's looping function. This stops boxes/lines painting when price passes to or through them
extendAndRemoveBx(array<box> boxArray, array<line> lineArray, array<int> countArr1, array<int> countArr2, simple bool isBull, int maxSize) =>
if boxArray.size() > 0
for i = boxArray.size() -1 to 0
line ln = lineArray.get(i)
box bx = boxArray.get(i)
bx.set_right(bar_index)
ln.set_x2(bar_index)
float price = CEcond?ln.get_price(bar_index):(isBull?bx.get_top():bx.get_bottom())
float price_IOFED = isBull?bx.get_bottom():bx.get_top()
int m = isBull ? 1 : -1
float hiLo = isBull ? high : low
if hiLo * m > price * m
boxArray.remove(i)
lineArray.remove(i)
countArr1.push(isBull?1:-1) //for 'above/below threshold alerts; counter sum will decrement 1 on lower threshold hit, increment 1 on upper threshold hit
if deleteFilledBoxes
bx.set_bgcolor(colorNone)
ln.set_color(colorNone)
if hiLo*m>price_IOFED*m
countArr2.push(isBull?1:-1)
if boxArray.size() > maxSize
box.delete(boxArray.shift())
line.delete(lineArray.shift())
extendAndRemoveBx(bxDnArr,lnDnArr,_countArr,_countArrIOFED, true, 12) //12 should be good for around 2200 bars of history
extendAndRemoveBx(bxUpArr, lnUpArr,_countArr,_countArrIOFED, false, 12)
upThresholdLst = array.sum(_countArr)>array.sum(_countArr)[1]
dnThresholdLst = array.sum(_countArr)<array.sum(_countArr)[1]
upIOFEDlast= array.sum(_countArrIOFED)>array.sum(_countArrIOFED)[1]
dnIOFEDlast= array.sum(_countArrIOFED)<array.sum(_countArrIOFED)[1]
alertcondition(upThresholdLst, "ABOVE threshold of latest active Up FVG (CE or fvg High)", "price has crossed threshold of latest active Up FVG")
alertcondition(dnThresholdLst, "BELOW threshold of latest active Down FVG (CE or fvg low)", "price has crossed threshold of latest active Down FVG")
alertcondition(upIOFEDlast, "IOFED into latest active Up FVG", "price has entered latest active UP FVG")
alertcondition(dnIOFEDlast, "IOFED into latest active Down FVG", "price has entered latest active Down FVG")
alertcondition(low[3] > high[1], "Simple alert: Down FVG confirmed", "Down FVG has formed")
alertcondition(high[3] < low[1], "Simple alert: Up FVG confirmed", "Up FVG has formed") |
Technical Dashboard with High and Low Price Prediction | https://www.tradingview.com/script/ugr4EWvo-Technical-Dashboard-with-High-and-Low-Price-Prediction/ | Steversteves | https://www.tradingview.com/u/Steversteves/ | 147 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// /$$$$$$ /$$ /$$
// /$$__ $$ | $$ | $$
//| $$ \__//$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$
//| $$$$$$|_ $$_/ /$$__ $$| $$ /$$//$$__ $$ /$$__ $$ /$$_____/|_ $$_/ /$$__ $$| $$ /$$//$$__ $$ /$$_____/
// \____ $$ | $$ | $$$$$$$$ \ $$/$$/| $$$$$$$$| $$ \__/| $$$$$$ | $$ | $$$$$$$$ \ $$/$$/| $$$$$$$$| $$$$$$
// /$$ \ $$ | $$ /$$| $$_____/ \ $$$/ | $$_____/| $$ \____ $$ | $$ /$$| $$_____/ \ $$$/ | $$_____/ \____ $$
//| $$$$$$/ | $$$$/| $$$$$$$ \ $/ | $$$$$$$| $$ /$$$$$$$/ | $$$$/| $$$$$$$ \ $/ | $$$$$$$ /$$$$$$$/
// \______/ \___/ \_______/ \_/ \_______/|__/ |_______/ \___/ \_______/ \_/ \_______/|_______/
// ___________________
// / \
// / _____ _____ \
// / / \ / \ \
// __/__/ \____/ \__\_____
//| ___________ ____|
// \_________/ \_________/
// \ /////// /
// \/////////
// Β© Steversteves
//@version=5
indicator("Technical Dashboard", overlay=true)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// User Inputs ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Stochastic inputs
showsto = input.bool(true, title="Show Stochastics", group="Stochastics")
stolength = input.int(14, title="Stochastic Length (K)", group = "Stochastics")
stosmad = input.int(3, title="Stochastic SMA (D)", group="Stochastics")
storeversal = input.bool(false, title="Display Reversals based on SMA", group="Stochastics")
// RSI Inputs
showrsi = input.bool(true, title="Show RSI", group="RSI")
rsilength = input.int(14, title="RSI Length", group="RSI")
rsisource = input.source(close, title="RSI Source", group="RSI")
rsismalength = input.int(14, title="RSI SMA Length", group="RSI")
rsireversal = input.bool(false, title="Display Reversals based on SMA", group="RSI")
// Z-Score Inputs
showz = input.bool(true, title="Show Z-Score", group="Z-Score")
zsource = input.source(close, title="Z-Score Source", group="Z-Score")
zlength = input.int(14, title="Z-Score Length", group="Z-Score")
zsmalength = input.int(3, title="Z-Score SMA Length", group="Z-Score")
zreversal = input.bool(false, title="Display reversals based on SMA", group="Z-Score")
//MFI Inputs
showmfi = input.bool(true, title="Show MFI", group="MFI")
mfisource = input.source(close, title="MFI Source", group="MFI")
mfilength = input.int(14, title="MFI Length", group="MFI")
mfismalength = input.int(14, title="MFI SMA Length", group="MFI")
mfireversal = input.bool(false, title="Display reversals based on SMA")
lookback = input.int(14, title="Lookback Period", tooltip="Technical lookback period, applies to all technical indicators.")
// Price Prediction Inputs
len = input(defval = 15, title = 'Price Prediction Lookback', group="Price Prediction", tooltip="This determines the amount of time the indicator will analyze to predict prospective price targets. This will also apply to the Highest High and Lowest Low values.")
smalen = input.int(15, title="High and Low SMA Length", group="Price Prediction", tooltip="The lookback length for the High and Low SMA")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Stochastics ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Stochastics
sto = ta.stoch(close, high, low, stolength)
stosma = ta.sma(sto, stosmad)
stohighest = ta.highest(sto, lookback)
stolowest = ta.lowest(sto, lookback)
stosmahighest = ta.highest(stosma, lookback)
stosmalowest = ta.lowest(stosma, lookback)
bool stobearishreversal = sto >= stohighest
bool stobullishreversal = sto <= stolowest
bool stobearishreversalsma = stosma >= stosmahighest
bool stobullishreversalsma = stosma <= stosmalowest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// RSI ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rsi = ta.rsi(rsisource, rsilength)
rsisma = ta.sma(rsi, rsismalength)
rsihighest = ta.highest(rsi, lookback)
rsilowest = ta.lowest(rsi, lookback)
rsismahighest = ta.highest(rsisma, lookback)
rsismalowest = ta.lowest(rsisma, lookback)
bool rsibearishreversal = rsi >= rsihighest
bool rsibullishreversal = rsi <= rsilowest
bool rsibearishreversalsma = rsisma >= rsismahighest
bool rsibullishreversalsma = rsisma <= rsismalowest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Z-Score ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
zavg = ta.sma(zsource, zlength)
zsd = ta.stdev(zsource, zlength)
z = (zsource - zavg) / zsd
zsma = ta.sma(z, zsmalength)
zhighest = ta.highest(z, lookback)
zlowest = ta.lowest(z, lookback)
zsmahighest = ta.highest(zsma, lookback)
zsmalowest = ta.lowest(zsma, lookback)
bool zbearishreversal = z >= zhighest
bool zbullishreversal = z <= zlowest
bool zbearishreversalsma = zsma >= zsmahighest
bool zbullishreversalsma = zsma <= zsmalowest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// MFI ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
mfi = ta.mfi(mfisource, mfilength)
mfisma = ta.sma(mfi, mfismalength)
mfihighest = ta.highest(mfi, lookback)
mfilowest = ta.lowest(mfi, lookback)
mfismahighest = ta.highest(mfisma, lookback)
mfismalowest = ta.lowest(mfisma, lookback)
bool mfibearishreversal = mfi >= mfihighest
bool mfibullishreversal = mfi <= mfilowest
bool mfibearishreversalsma = mfisma >= mfismahighest
bool mfibullishreversalsma = mfisma <= mfismalowest
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Price Prediction ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
linregs(y, x, len) =>
ybar = math.sum(y, len)/len
xbar = math.sum(x, len)/len
b = math.sum((x - xbar)*(y - ybar),len)/math.sum((x - xbar)*(x - xbar),len)
a = ybar - b*xbar
[a, b]
// Historical stock price data
h = high
o = open
l = low
// Calculate linear regression for stock price based on open price
[a, b] = linregs(h, o, len)
[c, d] = linregs(l, o, len)
predicted_high = a + b*o
predicted_low = c + d * o
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Highs and Lows ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
maxhi = ta.highest(high, len)
minhi = ta.lowest(high, len)
maxlo = ta.highest(low, len)
minlo = ta.lowest(low, len)
// Hi and Lo SMA
hisma = ta.sma(high, smalen)
losma = ta.sma(low, smalen)
// Predicted High / low result
bool highachieved = high >= predicted_high
bool lowachieved = low <= predicted_low
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Plots ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
phplots = input.bool(false, title="Plot Predicted Highs", group="Price Prediction")
plplots = input.bool(false, title="Plot Predicted Lows", group="Price Prediction")
hismaplots = input.bool(false, title="SMA of High", group="Price Prediction")
losmaplots = input.bool(false, title="SMA of Low", group="Price Prediction")
var loplots = 0.0
var hiplots = 0.0
var hismaplot = 0.0
var losmaplot = 0.0
if phplots
hiplots := predicted_high
if plplots
loplots := predicted_low
if hismaplots
hismaplot := hisma
if losmaplots
losmaplot := losma
plot(hismaplot, "High SMA Plot", color=color.green)
plot(losmaplot, "Low SMA Plots", color=color.red)
plot(loplots, "Predicted Low", color=color.red)
plot(hiplots, "Predicted High", color=color.green)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Colours ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
color black = color.new(color.black, 75)
color blue = color.new(color.blue, 75)
color aqua = color.new(color.aqua, 65)
color white = color.new(color.white, 0)
color green = color.new(color.green, 0)
color red = color.new(color.red, 0)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Strings for Assessment Results ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
string bull = "In Lowest Range"
string bear = "In Max Range"
string nothing = "In Neutral Range"
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Data Tables ///
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
tablePosInput = input.string(title="Position", defval="Top Right", options=["Bottom Left", "Bottom Right", "Top Left", "Top Right"], tooltip="Select where you want the table to draw.")
reversaltable = input.bool(true, title="Show Reversal Table")
var tablePos = tablePosInput == "Bottom Left" ? position.bottom_left : tablePosInput == "Bottom Right" ? position.bottom_right : tablePosInput == "Top Left" ? position.top_left : tablePosInput == "Top Right" ? position.top_right : na
var techtable = table.new(tablePos, columns = 9, rows = 8, border_color = color.black, border_width = 2)
// Columns
table.cell(techtable, 1, 1, text = "Tech Dashboard", bgcolor = black, text_color = white)
table.cell(techtable, 2, 1, text = "Highest", bgcolor = black, text_color = white)
table.cell(techtable, 3, 1, text = "Lowest", bgcolor = black, text_color = white)
table.cell(techtable, 4, 1, text = "Current SMA", bgcolor = black, text_color = white)
table.cell(techtable, 5, 1, text = "Current Value", bgcolor = black, text_color = white)
// Rows
table.cell(techtable, 1, 6, text = "Highs", bgcolor = blue, text_color = white)
table.cell(techtable, 1, 7, text = "Lows", bgcolor = blue, text_color = white)
// RSI
if showrsi
table.cell(techtable, 1, 2, text = "RSI", bgcolor = blue, text_color = white)
table.cell(techtable, 2, 2, text = rsireversal ? str.tostring(math.round(rsismahighest, 2)) : str.tostring(math.round(rsihighest, 2)), bgcolor = aqua, text_color = white)
table.cell(techtable, 3, 2, text = storeversal ? str.tostring(math.round(rsismalowest, 2)) : str.tostring(math.round(rsilowest, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 4, 2, text = str.tostring(math.round(rsisma, 2)), bgcolor=aqua, text_color=white)
table.cell(techtable, 5, 2, text = str.tostring(math.round(rsi, 2)), bgcolor = aqua, text_color = white)
// Stochastics
if showsto
table.cell(techtable, 1, 3, text = "Stochastics", bgcolor = blue, text_color = white)
table.cell(techtable, 2, 3, text = storeversal ? str.tostring(math.round(stosmahighest, 2)) : str.tostring(math.round(stohighest, 2)), bgcolor = aqua, text_color = white)
table.cell(techtable, 3, 3, text = storeversal ? str.tostring(math.round(stosmalowest, 2)) : str.tostring(math.round(stolowest, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 4, 3, text = str.tostring(math.round(stosma, 2)), bgcolor=aqua, text_color=white)
table.cell(techtable, 5, 3, text = str.tostring(math.round(sto, 2)), bgcolor = aqua, text_color = white)
// Z-Score
if showz
table.cell(techtable, 1, 4, text = "Z-Score", bgcolor = blue, text_color = white)
table.cell(techtable, 2, 4, text = zreversal ? str.tostring(math.round(zsmahighest, 2)) : str.tostring(math.round(zhighest, 2)), bgcolor = aqua, text_color = white)
table.cell(techtable, 3, 4, text = zreversal ? str.tostring(math.round(zsmalowest, 2)) : str.tostring(math.round(zlowest, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 4, 4, text = str.tostring(math.round(zsma, 2)), bgcolor=aqua, text_color=white)
table.cell(techtable, 5, 4, text = str.tostring(math.round(z, 2)), bgcolor = aqua, text_color = white)
// MFI
if showmfi
table.cell(techtable, 1, 5, text = "MFI", bgcolor = blue, text_color = white)
table.cell(techtable, 2, 5, text = mfireversal ? str.tostring(math.round(mfismahighest, 2)) : str.tostring(math.round(mfihighest, 2)), bgcolor = aqua, text_color = white)
table.cell(techtable, 3, 5, text = mfireversal ? str.tostring(math.round(mfismalowest, 2)) : str.tostring(math.round(mfilowest, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 4, 5, text = str.tostring(math.round(mfisma, 2)), bgcolor=aqua, text_color=white)
table.cell(techtable, 5, 5, text = str.tostring(math.round(mfi, 2)), bgcolor = aqua, text_color = white)
// Highs
table.cell(techtable, 2, 6, text = str.tostring(math.round(maxhi, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 3, 6, text = str.tostring(math.round(minhi, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 4, 6, text = str.tostring(math.round(hisma, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 5, 6, text = str.tostring(math.round(predicted_high, 2)), bgcolor = aqua, text_color=white)
// Lows
table.cell(techtable, 2, 7, text = str.tostring(math.round(maxlo, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 3, 7, text = str.tostring(math.round(minlo, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 4, 7, text = str.tostring(math.round(losma, 2)), bgcolor = aqua, text_color=white)
table.cell(techtable, 5, 7, text = str.tostring(math.round(predicted_low, 2)), bgcolor = aqua, text_color=white)
//Range Table
if reversaltable
table.cell(techtable, 6,1, text = "Current Range", bgcolor = black, text_color = white)
if showrsi
table.cell(techtable, 6, 2, text = rsireversal and rsibearishreversalsma ? str.tostring(bear) : rsireversal and rsibullishreversalsma ? str.tostring(bull) : rsibearishreversal ? str.tostring(bear) : rsibullishreversal ? str.tostring(bull) : str.tostring(nothing), bgcolor = rsireversal and rsibearishreversalsma ? red : rsireversal and rsibullishreversalsma ? green : rsibearishreversal ? red : rsibullishreversal ? green : black, text_color = white)
if showsto
table.cell(techtable, 6, 3, text = storeversal and stobearishreversalsma ? str.tostring(bear) : storeversal and stobullishreversalsma ? str.tostring(bull) : stobearishreversal ? str.tostring(bear) : stobullishreversal ? str.tostring(bull) : str.tostring(nothing), bgcolor = storeversal and stobearishreversalsma ? red : storeversal and stobullishreversalsma ? green : stobearishreversal ? red : stobullishreversal ? green : black, text_color = white)
if showz
table.cell(techtable, 6, 4, text = zreversal and zbearishreversalsma ? str.tostring(bear) : zreversal and zbullishreversalsma ? str.tostring(bull) : zbearishreversal ? str.tostring(bear) : zbullishreversal ? str.tostring(bull) : str.tostring(nothing), bgcolor = zreversal and zbearishreversalsma ? red : zreversal and zbullishreversalsma ? green : zbearishreversal ? red : zbullishreversal ? green : black, text_color = white)
if showmfi
table.cell(techtable, 6, 5, text = mfireversal and mfibearishreversalsma ? str.tostring(bear) : mfireversal and mfibullishreversalsma ? str.tostring(bull) : mfibearishreversal ? str.tostring(bear) : mfibullishreversal ? str.tostring(bull) : str.tostring(nothing), bgcolor = mfireversal and mfibearishreversalsma ? red : mfireversal and mfibullishreversalsma ? green : mfibearishreversal ? red : mfibullishreversal ? green : black, text_color = white)
table.cell(techtable, 6, 6, text = highachieved ? "Predicted High Obtained" : "Predicted High Unrealized", bgcolor = highachieved ? green : black, text_color=white)
table.cell(techtable, 6, 7, text = lowachieved ? "Predicted Low Obtained" : "Predicted Low Unrealized", bgcolor = lowachieved ? green : black, text_color=white)
|
Masonβs Line Indicator | https://www.tradingview.com/script/mNcGcDvI-Mason-s-Line-Indicator/ | Ox_kali | https://www.tradingview.com/u/Ox_kali/ | 89 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Ox_kali
// ________________________________________________________________________________________________________________________________
// βββββββ βββ βββ βββ βββ ββββββ βββ βββ ββββββ βββ βββββββ βββββββ βββββββ βββββββββββββββ βββββββ ββββ
// βββββββββββββββββ βββ βββββββββββββββ βββ βββββββββββ ββββββββ ββββββββββββββββββββββββββββββββ ββββββββ βββββ
// βββ βββ ββββββ βββββββ βββββββββββ βββ βββββββββββ βββ βββββββ ββββββββββββββ βββ βββββββββββββββββββ
// βββ βββ ββββββ βββββββ βββββββββββ βββ βββββββββββ βββ ββββββ ββββββββββββββ βββ βββββββββββββββββββ
// βββββββββββββ ββββββββββββββ ββββββ ββββββββββββββ βββ ββββββββββββββββββββββββββββββββ ββββββ βββ βββ ββββββ βββ βββ
// βββββββ βββ ββββββββββββββ ββββββ ββββββββββββββ βββ βββββββββββ βββββββ βββββββ βββ ββββββ βββ βββ ββββββ βββ
// ________________________________________________________________________________________________________________________________
//@version=5
// Indicator title and short title
// ________________________________________________________________________________________________________________________________
indicator(title="Masonβs Line Indicator", shorttitle="Masonβs Line Indicator", format=format.price, precision=4)
// Parameters - user input settings
// ________________________________________________________________________________________________________________________________
min_max_period = input.int(365, title="Period for min and max (days)", minval=1, maxval=365, step=20)
satisfaction_period = input.int(365, title="Period for average satisfaction (days)", minval=1, maxval=365, step=20)
sma_period = input.int(365, title="Period for SMA", minval=1, maxval=1000, step=10)
bubble_value = input.float(0.5, "bubble_value", minval=0, maxval=1, step=0.025)
user_choice = input.bool(true, "Normalized average satisfaction")
smooth_normalized = input.int(2, title="Smooth normalized value by periode mutlipicator", minval=1, maxval=10, step=1)
// Calculate the highest high and lowest low over a given period
// ________________________________________________________________________________________________________________________________
lowest_low = ta.lowest(low, min_max_period)
highest_high = ta.highest(high, min_max_period)
// Calculate the air bubble position in the tube
// ________________________________________________________________________________________________________________________________
air_bubble = (close - lowest_low) / (highest_high - lowest_low)
// Calculate the average satisfaction of masons who invested in the last 365 days
// ________________________________________________________________________________________________________________________________
average_satisfaction = 0.0
for i = 0 to math.min(bar_index, satisfaction_period - 1)
average_satisfaction := average_satisfaction + ((close - close[i]) / (highest_high - lowest_low))
average_satisfaction := average_satisfaction / math.min(bar_index + 1, satisfaction_period)
// Calculate the average satisfaction over the entire period
// ________________________________________________________________________________________________________________________________
satisfaction_moyenne_ensemble = ta.sma(average_satisfaction, bar_index + 1)
// Calculate the closing price for a 0.5 air bubble
// ________________________________________________________________________________________________________________________________
price_bubble_05 = bubble_value * (highest_high - lowest_low) + lowest_low
// Create a variable to store the normalized average satisfaction
// ________________________________________________________________________________________________________________________________
normalized_satisfaction = 0.0
// Calculate the minimum and maximum satisfaction over the selected period
// ________________________________________________________________________________________________________________________________
min_satisfaction = ta.lowest(average_satisfaction, satisfaction_period*smooth_normalized)
max_satisfaction = ta.highest(average_satisfaction, satisfaction_period*smooth_normalized)
// Normalize the average satisfaction between 0 and 1
// ________________________________________________________________________________________________________________________________
normalized_satisfaction := (average_satisfaction - min_satisfaction) / (max_satisfaction - min_satisfaction)
// Plot the normalized average satisfaction between 0 and 1 or the average satisfaction
// ________________________________________________________________________________________________________________________________
hline(bubble_value, linestyle=hline.style_dashed, linewidth=2, color=color.new(#F7931A, 40), title='buble value')
// Plot the selected satisfaction plot (normalized or not) and the corresponding SMA
// ________________________________________________________________________________________________________________________________
plot(user_choice ? normalized_satisfaction : average_satisfaction, color=color.new(#008000, 0), title='Masons Satisfaction')
plot(user_choice ? ta.sma(normalized_satisfaction, sma_period) : ta.sma(average_satisfaction, sma_period))
|
Cloud Bunching [5ema] | https://www.tradingview.com/script/hpfiKBMT-Cloud-Bunching-5ema/ | vn5ema | https://www.tradingview.com/u/vn5ema/ | 61 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Reused some functions from (I believe made by Β©paaax, @QuantNomad)
// Β©paaax: The table position function (https://www.tradingview.com/script/Jp37jHwT-PX-MTF-Overview/).
// @QuantNomad: The function calculated value and array screener for 40+ instruments (https://www.tradingview.com/script/zN8rwPFF-Screener-for-40-instruments/).
// Β© vn-5ema
//@version=5
indicator("Cloud Bunching [5ema]", overlay = true)
// Input condition
iBunch = input.float(defval = 1, minval=0, title="Bunching (%)", group = "Condition of Signal", tooltip = "The bunching ratio between Upper and Lower of Cloud. Change the value for each symbol to get the highest win rate.")
// Input the ratio to over of Close
iCross = input.float(defval = 2, minval=0, title="Crossing (%)", group = "Condition of Signal", tooltip = "The crossing ratio of close Close over Cloud. Change the value for each symbol to get the highest win rate.")
// Volume condition
opVolume = input.string(title="High Volume", defval = "Yes", options = ["Yes", "No"], group = "Condition of Signal", tooltip = "By default, only buy and sell if volume > MA20 Volume.")
// Table position
boolTable = input.bool(defval = false, title = "Table Β Β Β Β Β Β Β ", group="Show on chart", inline = "table")
pos = input.string("Bottom Left", title="", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], group="Show on chart", inline = "table")
// Table position
/////// This function reused from Β©paaax /////
TablePosition(pos) =>
ret = position.top_left
if pos == "Top Center"
ret := position.top_center
if pos == "Top Right"
ret := position.top_right
if pos == "Middle Left"
ret := position.middle_left
if pos == "Middle Center"
ret := position.middle_center
if pos == "Middle Right"
ret := position.middle_right
if pos == "Bottom Left"
ret := position.bottom_left
if pos == "Bottom Center"
ret := position.bottom_center
if pos == "Bottom Right"
ret := position.bottom_right
ret
//////////
boolCloud = input.bool(defval = true, title = "The Cloud", group="Show on chart")
// Cloud Color
bunchColor = input.color(color.new(#ffa726, 75), title = "Bunching color", group = "Set up Cloud color")
upperColor = input.color(color.new(#388e3c, 75),title = "Upper color", group = "Set up Cloud color")
lowerColor = input.color(color.new(#b22833, 75),title = "Lower color", group = "Set up Cloud color")
// Set up Alert
boolSignalAlert = input.string(title="Select signal", defval = "BUY and SELL", options = ["BUY", "SELL", "BUY and SELL"], group = "Set up Alert")
// Timeframe
timeframe = input.timeframe(defval = "", title = "Time frame", group = "Set up Alert", tooltip = "By default, following the current chart. Can select another time frame to follow the symbol for showing on table and making the arlert.")
// Symbol bool
/////// This bool symbool refer from @QuantNomad /////
u01 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's01')
u02 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's02')
u03 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's03')
u04 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's04')
u05 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's05')
u06 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's06')
u07 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's07')
u08 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's08')
u09 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's09')
u10 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's10')
u11 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's11')
u12 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's12')
u13 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's13')
u14 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's14')
u15 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's15')
u16 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's16')
u17 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's17')
u18 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's18')
u19 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's19')
u20 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's20')
u21 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's21')
u22 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's22')
u23 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's23')
u24 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's24')
u25 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's25')
u26 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's26')
u27 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's27')
u28 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's28')
u29 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's29')
u30 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's30')
u31 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's31')
u32 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's32')
u33 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's33')
u34 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's34')
u35 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's35')
u36 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's36')
u37 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's37')
u38 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's38')
u39 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's39')
//u40 = input.bool(false, title = "", group = 'Symbols following and alert', inline = 's40')
//Symbol choose
s01 = input.symbol('BTCUSDT', group = 'Symbols following and alert', inline = 's01')
s02 = input.symbol('ETHUSDT', group = 'Symbols following and alert', inline = 's02')
s03 = input.symbol('BNBUSDT', group = 'Symbols following and alert', inline = 's03')
s04 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's04')
s05 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's05')
s06 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's06')
s07 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's07')
s08 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's08')
s09 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's09')
s10 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's10')
s11 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's11')
s12 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's12')
s13 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's13')
s14 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's14')
s15 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's15')
s16 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's16')
s17 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's17')
s18 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's18')
s19 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's19')
s20 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's20')
s21 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's21')
s22 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's22')
s23 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's23')
s24 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's24')
s25 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's25')
s26 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's26')
s27 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's27')
s28 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's28')
s29 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's29')
s30 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's30')
s31 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's31')
s32 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's32')
s33 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's33')
s34 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's34')
s35 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's35')
s36 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's36')
s37 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's37')
s38 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's38')
s39 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's39')
//s40 = input.symbol('USDT', group = 'Symbols following and alert', inline = 's40')
//////////
// CALCULATIONS //
// Get only symbol
only_symbol(s) =>
array.get(str.split(s, ":"), 1)
// Calculate
oEMA1 = ta.ema(close, 20)
oEMA2 = ta.ema(close, 50)
oEMA3 = ta.ema(close, 200)
oEMA4 = ta.ema(close, 460)
oEMA5 = ta.ema(close, 610)
avgEMA = math.avg(oEMA1, oEMA2, oEMA3, oEMA4, oEMA5)
maxEMA = math.max(oEMA1, oEMA2, oEMA3, oEMA4, oEMA5)
minEMA = math.min(oEMA1, oEMA2, oEMA3, oEMA4, oEMA5)
//Calculate Bunching
cPriceBUY = ((close - maxEMA) / maxEMA) * 100
cPriceSELL = ((close - minEMA) / minEMA) * 100
//Bar Coditions
greenbar = close > open
redbar = close < open
bodybar = math.abs(close - open)
fullbar = high - low
topwick = high - math.max(close, open)
bottomwick = math.abs (math.min(close, open) - low)
Hammer = bodybar < bottomwick *0.786 and topwick < 0.236 * bottomwick
InvertedHammer = bodybar < topwick *786 and bottomwick < 0.236 * topwick
redlongbody = redbar[1] ? (redbar and bodybar > 0.786 * fullbar and fullbar > fullbar[1]) : (redbar and bodybar > 0.786 * fullbar and (fullbar >= 1.5* fullbar[1] or InvertedHammer[1]))
greenlongbody = greenbar[1] ? (greenbar and bodybar > 0.786 * fullbar and fullbar > fullbar[1]) : (greenbar and bodybar > 0.786 * fullbar and (fullbar >= 1.5* fullbar[1] or Hammer[1]))
BullishEngulfing = redbar[1] and not InvertedHammer[1] and low[1] > low and close[1] <= open and close > high[1] and greenlongbody
BearishEngulfing = greenbar[1] and not Hammer[1] and low[1] > low and close[1] < open and redlongbody
//Signal condition
barBUY = (BullishEngulfing or greenlongbody) and close[1] > avgEMA and close > close[1] and (close + open) / 2 >= maxEMA
barSELL = (BearishEngulfing or redlongbody) and close[1] < avgEMA and close < close[1] and (open + close) / 2 <= minEMA
// Volume condition
oVolume = opVolume == "No" ? (volume > ta.sma(volume, 20) * 0) : (volume > ta.sma(volume, 20) * 1)
//Bunch
cBunch_func () =>
cBunch = (math.abs(maxEMA - minEMA) / minEMA) * 100
//Cross
cPrice_func () =>
cPrice = (cPriceBUY < 0 and cPriceSELL > 0) ? 0 : (cPriceSELL < 0) ? cPriceSELL : cPriceBUY
// Screener
screener_func() =>
//Bunch
cBunch = cBunch_func()
//Cross
cPrice = cPrice_func()
//signal condition
signalBUY = cBunch <= iBunch and cBunch > 0 and cPrice <= iCross and cPrice > 0 and barBUY and oVolume
signalSELL = cBunch <= iBunch and cBunch > 0 and math.abs(cPrice) <= iCross and cPrice < 0 and barSELL and oVolume
//Security func
[cBunch, cPrice, signalSELL, signalBUY]
// Security call
/////// This bool symbool refer from @QuantNomad /////
[cBunch, cPrice, signalSELL, signalBUY] = request.security(symbol = syminfo.tickerid, timeframe = timeframe.period, expression = screener_func())
[cBunch01, cPrice01, signalSELL01, signalBUY01] = request.security(s01, timeframe, screener_func())
[cBunch02, cPrice02, signalSELL02, signalBUY02] = request.security(s02, timeframe, screener_func())
[cBunch03, cPrice03, signalSELL03, signalBUY03] = request.security(s03, timeframe, screener_func())
[cBunch04, cPrice04, signalSELL04, signalBUY04] = request.security(s04, timeframe, screener_func())
[cBunch05, cPrice05, signalSELL05, signalBUY05] = request.security(s05, timeframe, screener_func())
[cBunch06, cPrice06, signalSELL06, signalBUY06] = request.security(s06, timeframe, screener_func())
[cBunch07, cPrice07, signalSELL07, signalBUY07] = request.security(s07, timeframe, screener_func())
[cBunch08, cPrice08, signalSELL08, signalBUY08] = request.security(s08, timeframe, screener_func())
[cBunch09, cPrice09, signalSELL09, signalBUY09] = request.security(s09, timeframe, screener_func())
[cBunch10, cPrice10, signalSELL10, signalBUY10] = request.security(s10, timeframe, screener_func())
[cBunch11, cPrice11, signalSELL11, signalBUY11] = request.security(s11, timeframe, screener_func())
[cBunch12, cPrice12, signalSELL12, signalBUY12] = request.security(s12, timeframe, screener_func())
[cBunch13, cPrice13, signalSELL13, signalBUY13] = request.security(s13, timeframe, screener_func())
[cBunch14, cPrice14, signalSELL14, signalBUY14] = request.security(s14, timeframe, screener_func())
[cBunch15, cPrice15, signalSELL15, signalBUY15] = request.security(s15, timeframe, screener_func())
[cBunch16, cPrice16, signalSELL16, signalBUY16] = request.security(s16, timeframe, screener_func())
[cBunch17, cPrice17, signalSELL17, signalBUY17] = request.security(s17, timeframe, screener_func())
[cBunch18, cPrice18, signalSELL18, signalBUY18] = request.security(s18, timeframe, screener_func())
[cBunch19, cPrice19, signalSELL19, signalBUY19] = request.security(s19, timeframe, screener_func())
[cBunch20, cPrice20, signalSELL20, signalBUY20] = request.security(s20, timeframe, screener_func())
[cBunch21, cPrice21, signalSELL21, signalBUY21] = request.security(s21, timeframe, screener_func())
[cBunch22, cPrice22, signalSELL22, signalBUY22] = request.security(s22, timeframe, screener_func())
[cBunch23, cPrice23, signalSELL23, signalBUY23] = request.security(s23, timeframe, screener_func())
[cBunch24, cPrice24, signalSELL24, signalBUY24] = request.security(s24, timeframe, screener_func())
[cBunch25, cPrice25, signalSELL25, signalBUY25] = request.security(s25, timeframe, screener_func())
[cBunch26, cPrice26, signalSELL26, signalBUY26] = request.security(s26, timeframe, screener_func())
[cBunch27, cPrice27, signalSELL27, signalBUY27] = request.security(s27, timeframe, screener_func())
[cBunch28, cPrice28, signalSELL28, signalBUY28] = request.security(s28, timeframe, screener_func())
[cBunch29, cPrice29, signalSELL29, signalBUY29] = request.security(s29, timeframe, screener_func())
[cBunch30, cPrice30, signalSELL30, signalBUY30] = request.security(s30, timeframe, screener_func())
[cBunch31, cPrice31, signalSELL31, signalBUY31] = request.security(s31, timeframe, screener_func())
[cBunch32, cPrice32, signalSELL32, signalBUY32] = request.security(s32, timeframe, screener_func())
[cBunch33, cPrice33, signalSELL33, signalBUY33] = request.security(s33, timeframe, screener_func())
[cBunch34, cPrice34, signalSELL34, signalBUY34] = request.security(s34, timeframe, screener_func())
[cBunch35, cPrice35, signalSELL35, signalBUY35] = request.security(s35, timeframe, screener_func())
[cBunch36, cPrice36, signalSELL36, signalBUY36] = request.security(s36, timeframe, screener_func())
[cBunch37, cPrice37, signalSELL37, signalBUY37] = request.security(s37, timeframe, screener_func())
[cBunch38, cPrice38, signalSELL38, signalBUY38] = request.security(s38, timeframe, screener_func())
[cBunch39, cPrice39, signalSELL39, signalBUY39] = request.security(s39, timeframe, screener_func())
//[cBunch40, cPrice40, signalSELL40, signalBUY40] = request.security(s40, timeframe, screener_func())
//Screener table
scr_table = ''
//Signal BUY
scr_table := u01 != false and signalBUY01 ? scr_table + s01 + ' β¦Ώ' + '\n' : scr_table
scr_table := u02 != false and signalBUY02 ? scr_table + s02 + ' β¦Ώ' + '\n' : scr_table
scr_table := u03 != false and signalBUY03 ? scr_table + s03 + ' β¦Ώ' + '\n' : scr_table
scr_table := u04 != false and signalBUY04 ? scr_table + s04 + ' β¦Ώ' + '\n' : scr_table
scr_table := u05 != false and signalBUY05 ? scr_table + s05 + ' β¦Ώ' + '\n' : scr_table
scr_table := u06 != false and signalBUY06 ? scr_table + s06 + ' β¦Ώ' + '\n' : scr_table
scr_table := u07 != false and signalBUY07 ? scr_table + s07 + ' β¦Ώ' + '\n' : scr_table
scr_table := u08 != false and signalBUY08 ? scr_table + s08 + ' β¦Ώ' + '\n' : scr_table
scr_table := u09 != false and signalBUY09 ? scr_table + s09 + ' β¦Ώ' + '\n' : scr_table
scr_table := u10 != false and signalBUY10 ? scr_table + s10 + ' β¦Ώ' + '\n' : scr_table
scr_table := u11 != false and signalBUY11 ? scr_table + s11 + ' β¦Ώ' + '\n' : scr_table
scr_table := u12 != false and signalBUY12 ? scr_table + s12 + ' β¦Ώ' + '\n' : scr_table
scr_table := u13 != false and signalBUY13 ? scr_table + s13 + ' β¦Ώ' + '\n' : scr_table
scr_table := u14 != false and signalBUY14 ? scr_table + s14 + ' β¦Ώ' + '\n' : scr_table
scr_table := u15 != false and signalBUY15 ? scr_table + s15 + ' β¦Ώ' + '\n' : scr_table
scr_table := u16 != false and signalBUY16 ? scr_table + s16 + ' β¦Ώ' + '\n' : scr_table
scr_table := u17 != false and signalBUY17 ? scr_table + s17 + ' β¦Ώ' + '\n' : scr_table
scr_table := u18 != false and signalBUY18 ? scr_table + s18 + ' β¦Ώ' + '\n' : scr_table
scr_table := u19 != false and signalBUY19 ? scr_table + s19 + ' β¦Ώ' + '\n' : scr_table
scr_table := u20 != false and signalBUY20 ? scr_table + s20 + ' β¦Ώ' + '\n' : scr_table
scr_table := u21 != false and signalBUY21 ? scr_table + s21 + ' β¦Ώ' + '\n' : scr_table
scr_table := u22 != false and signalBUY22 ? scr_table + s22 + ' β¦Ώ' + '\n' : scr_table
scr_table := u23 != false and signalBUY23 ? scr_table + s23 + ' β¦Ώ' + '\n' : scr_table
scr_table := u24 != false and signalBUY24 ? scr_table + s24 + ' β¦Ώ' + '\n' : scr_table
scr_table := u25 != false and signalBUY25 ? scr_table + s25 + ' β¦Ώ' + '\n' : scr_table
scr_table := u26 != false and signalBUY26 ? scr_table + s26 + ' β¦Ώ' + '\n' : scr_table
scr_table := u27 != false and signalBUY27 ? scr_table + s27 + ' β¦Ώ' + '\n' : scr_table
scr_table := u28 != false and signalBUY28 ? scr_table + s28 + ' β¦Ώ' + '\n' : scr_table
scr_table := u29 != false and signalBUY29 ? scr_table + s29 + ' β¦Ώ' + '\n' : scr_table
scr_table := u30 != false and signalBUY30 ? scr_table + s30 + ' β¦Ώ' + '\n' : scr_table
scr_table := u31 != false and signalBUY31 ? scr_table + s31 + ' β¦Ώ' + '\n' : scr_table
scr_table := u32 != false and signalBUY32 ? scr_table + s32 + ' β¦Ώ' + '\n' : scr_table
scr_table := u33 != false and signalBUY33 ? scr_table + s33 + ' β¦Ώ' + '\n' : scr_table
scr_table := u34 != false and signalBUY34 ? scr_table + s34 + ' β¦Ώ' + '\n' : scr_table
scr_table := u35 != false and signalBUY35 ? scr_table + s35 + ' β¦Ώ' + '\n' : scr_table
scr_table := u36 != false and signalBUY36 ? scr_table + s36 + ' β¦Ώ' + '\n' : scr_table
scr_table := u37 != false and signalBUY37 ? scr_table + s37 + ' β¦Ώ' + '\n' : scr_table
scr_table := u38 != false and signalBUY38 ? scr_table + s38 + ' β¦Ώ' + '\n' : scr_table
scr_table := u39 != false and signalBUY39 ? scr_table + s39 + ' β¦Ώ' + '\n' : scr_table
//scr_table := u40 != false and signalBUY40 ? scr_table + s40 + ' β¦Ώ' + '\n' : scr_table
//Signal SELL
scr_table := u01 != false and signalSELL01 ? scr_table + s01 + ' β¦Ώ' + '\n' : scr_table
scr_table := u02 != false and signalSELL02 ? scr_table + s02 + ' β¦Ώ' + '\n' : scr_table
scr_table := u03 != false and signalSELL03 ? scr_table + s03 + ' β¦Ώ' + '\n' : scr_table
scr_table := u04 != false and signalSELL04 ? scr_table + s04 + ' β¦Ώ' + '\n' : scr_table
scr_table := u05 != false and signalSELL05 ? scr_table + s05 + ' β¦Ώ' + '\n' : scr_table
scr_table := u06 != false and signalSELL06 ? scr_table + s06 + ' β¦Ώ' + '\n' : scr_table
scr_table := u07 != false and signalSELL07 ? scr_table + s07 + ' β¦Ώ' + '\n' : scr_table
scr_table := u08 != false and signalSELL08 ? scr_table + s08 + ' β¦Ώ' + '\n' : scr_table
scr_table := u09 != false and signalSELL09 ? scr_table + s09 + ' β¦Ώ' + '\n' : scr_table
scr_table := u10 != false and signalSELL10 ? scr_table + s10 + ' β¦Ώ' + '\n' : scr_table
scr_table := u11 != false and signalSELL11 ? scr_table + s11 + ' β¦Ώ' + '\n' : scr_table
scr_table := u12 != false and signalSELL12 ? scr_table + s12 + ' β¦Ώ' + '\n' : scr_table
scr_table := u13 != false and signalSELL13 ? scr_table + s13 + ' β¦Ώ' + '\n' : scr_table
scr_table := u14 != false and signalSELL14 ? scr_table + s14 + ' β¦Ώ' + '\n' : scr_table
scr_table := u15 != false and signalSELL15 ? scr_table + s15 + ' β¦Ώ' + '\n' : scr_table
scr_table := u16 != false and signalSELL16 ? scr_table + s16 + ' β¦Ώ' + '\n' : scr_table
scr_table := u17 != false and signalSELL17 ? scr_table + s17 + ' β¦Ώ' + '\n' : scr_table
scr_table := u18 != false and signalSELL18 ? scr_table + s18 + ' β¦Ώ' + '\n' : scr_table
scr_table := u19 != false and signalSELL19 ? scr_table + s19 + ' β¦Ώ' + '\n' : scr_table
scr_table := u20 != false and signalSELL20 ? scr_table + s20 + ' β¦Ώ' + '\n' : scr_table
scr_table := u21 != false and signalSELL21 ? scr_table + s21 + ' β¦Ώ' + '\n' : scr_table
scr_table := u22 != false and signalSELL22 ? scr_table + s22 + ' β¦Ώ' + '\n' : scr_table
scr_table := u23 != false and signalSELL23 ? scr_table + s23 + ' β¦Ώ' + '\n' : scr_table
scr_table := u24 != false and signalSELL24 ? scr_table + s24 + ' β¦Ώ' + '\n' : scr_table
scr_table := u25 != false and signalSELL25 ? scr_table + s25 + ' β¦Ώ' + '\n' : scr_table
scr_table := u26 != false and signalSELL26 ? scr_table + s26 + ' β¦Ώ' + '\n' : scr_table
scr_table := u27 != false and signalSELL27 ? scr_table + s27 + ' β¦Ώ' + '\n' : scr_table
scr_table := u28 != false and signalSELL28 ? scr_table + s28 + ' β¦Ώ' + '\n' : scr_table
scr_table := u29 != false and signalSELL29 ? scr_table + s29 + ' β¦Ώ' + '\n' : scr_table
scr_table := u30 != false and signalSELL30 ? scr_table + s30 + ' β¦Ώ' + '\n' : scr_table
scr_table := u31 != false and signalSELL31 ? scr_table + s31 + ' β¦Ώ' + '\n' : scr_table
scr_table := u32 != false and signalSELL32 ? scr_table + s32 + ' β¦Ώ' + '\n' : scr_table
scr_table := u33 != false and signalSELL33 ? scr_table + s33 + ' β¦Ώ' + '\n' : scr_table
scr_table := u34 != false and signalSELL34 ? scr_table + s34 + ' β¦Ώ' + '\n' : scr_table
scr_table := u35 != false and signalSELL35 ? scr_table + s35 + ' β¦Ώ' + '\n' : scr_table
scr_table := u36 != false and signalSELL36 ? scr_table + s36 + ' β¦Ώ' + '\n' : scr_table
scr_table := u37 != false and signalSELL37 ? scr_table + s37 + ' β¦Ώ' + '\n' : scr_table
scr_table := u38 != false and signalSELL38 ? scr_table + s38 + ' β¦Ώ' + '\n' : scr_table
scr_table := u39 != false and signalSELL39 ? scr_table + s39 + ' β¦Ώ' + '\n' : scr_table
//scr_table := u40 != false and signalSELL40 ? scr_table + s40 + ' β¦Ώ' + '\n' : scr_table
//////////
// Plot Cloud of current symbol
// Cloud
colortrend = color.from_gradient(oEMA5, minEMA, maxEMA, upperColor, lowerColor)
colorCloud = color.from_gradient(cBunch, 0, iBunch, bunchColor, colortrend)
upperCloud = plot(boolCloud == true ? maxEMA : na, "Upper Cloud", color.new(#d1d4dc, 100), offset = 1)
lowerCloud = plot(boolCloud == true ? minEMA : na, "Lower Cloud", color.new(#d1d4dc, 100), offset = 1)
fill(upperCloud, lowerCloud, color = boolCloud == false ? na : colorCloud , title="Fill Cloud")
// Plot Signal
currentBUY = signalBUY and not signalBUY[1] and not signalBUY[2]
currentSELL = signalSELL and not signalSELL[1] and not signalSELL[2]
plotshape(currentBUY, title = "Shape Buy", style=shape.triangleup, location=location.belowbar, color = #4caf50, text = "", textcolor = color.white, size = size.tiny)
plotshape(currentSELL, title = "Shape Sell", style=shape.triangledown, location=location.abovebar, color = #f23645, text = "", textcolor = color.white, size = size.tiny)
// Plot table //
if boolTable
var tbl = table.new(TablePosition(pos), 1, 2, frame_color=#151715, frame_width=1, border_width=1, border_color=color.new(color.white, 100))
table.cell(tbl, 0, 0, 'Signal on Timeframe: ' + timeframe, text_halign = text.align_center, bgcolor = color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 0, 1, scr_table, text_halign = text.align_right, bgcolor = color.black, text_color = signalBUY ? color.green : signalSELL ? color.red : color.white, text_size = size.small)
//Screener Alert
scr_alertBUY = ''
//Signal BUY
scr_alertBUY := u01 != false and signalBUY01 ? scr_alertBUY + s01 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u02 != false and signalBUY02 ? scr_alertBUY + s02 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u03 != false and signalBUY03 ? scr_alertBUY + s03 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u04 != false and signalBUY04 ? scr_alertBUY + s04 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u05 != false and signalBUY05 ? scr_alertBUY + s05 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u06 != false and signalBUY06 ? scr_alertBUY + s06 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u07 != false and signalBUY07 ? scr_alertBUY + s07 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u08 != false and signalBUY08 ? scr_alertBUY + s08 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u09 != false and signalBUY09 ? scr_alertBUY + s09 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u10 != false and signalBUY10 ? scr_alertBUY + s10 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u11 != false and signalBUY11 ? scr_alertBUY + s11 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u12 != false and signalBUY12 ? scr_alertBUY + s12 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u13 != false and signalBUY13 ? scr_alertBUY + s13 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u14 != false and signalBUY14 ? scr_alertBUY + s14 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u15 != false and signalBUY15 ? scr_alertBUY + s15 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u16 != false and signalBUY16 ? scr_alertBUY + s16 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u17 != false and signalBUY17 ? scr_alertBUY + s17 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u18 != false and signalBUY18 ? scr_alertBUY + s18 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u19 != false and signalBUY19 ? scr_alertBUY + s19 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u20 != false and signalBUY20 ? scr_alertBUY + s20 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u21 != false and signalBUY21 ? scr_alertBUY + s21 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u22 != false and signalBUY22 ? scr_alertBUY + s22 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u23 != false and signalBUY23 ? scr_alertBUY + s23 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u24 != false and signalBUY24 ? scr_alertBUY + s24 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u25 != false and signalBUY25 ? scr_alertBUY + s25 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u26 != false and signalBUY26 ? scr_alertBUY + s26 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u27 != false and signalBUY27 ? scr_alertBUY + s27 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u28 != false and signalBUY28 ? scr_alertBUY + s28 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u29 != false and signalBUY29 ? scr_alertBUY + s29 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u30 != false and signalBUY30 ? scr_alertBUY + s30 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u31 != false and signalBUY31 ? scr_alertBUY + s31 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u32 != false and signalBUY32 ? scr_alertBUY + s32 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u33 != false and signalBUY33 ? scr_alertBUY + s33 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u34 != false and signalBUY34 ? scr_alertBUY + s34 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u35 != false and signalBUY35 ? scr_alertBUY + s35 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u36 != false and signalBUY36 ? scr_alertBUY + s36 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u37 != false and signalBUY37 ? scr_alertBUY + s37 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u38 != false and signalBUY38 ? scr_alertBUY + s38 + ' - BUY' + '\n' : scr_alertBUY
scr_alertBUY := u39 != false and signalBUY39 ? scr_alertBUY + s39 + ' - BUY' + '\n' : scr_alertBUY
//scr_alertBUY := u40 != false and signalBUY40 ? scr_alertBUY + s40 + ' - BUY' + '\n' : scr_alertBUY
//Signal SELL
scr_alertSELL = ''
scr_alertSELL := u01 != false and signalSELL01 ? scr_alertSELL + s01 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u02 != false and signalSELL02 ? scr_alertSELL + s02 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u03 != false and signalSELL03 ? scr_alertSELL + s03 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u04 != false and signalSELL04 ? scr_alertSELL + s04 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u05 != false and signalSELL05 ? scr_alertSELL + s05 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u06 != false and signalSELL06 ? scr_alertSELL + s06 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u07 != false and signalSELL07 ? scr_alertSELL + s07 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u08 != false and signalSELL08 ? scr_alertSELL + s08 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u09 != false and signalSELL09 ? scr_alertSELL + s09 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u10 != false and signalSELL10 ? scr_alertSELL + s10 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u11 != false and signalSELL11 ? scr_alertSELL + s11 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u12 != false and signalSELL12 ? scr_alertSELL + s12 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u13 != false and signalSELL13 ? scr_alertSELL + s13 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u14 != false and signalSELL14 ? scr_alertSELL + s14 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u15 != false and signalSELL15 ? scr_alertSELL + s15 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u16 != false and signalSELL16 ? scr_alertSELL + s16 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u17 != false and signalSELL17 ? scr_alertSELL + s17 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u18 != false and signalSELL18 ? scr_alertSELL + s18 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u19 != false and signalSELL19 ? scr_alertSELL + s19 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u20 != false and signalSELL20 ? scr_alertSELL + s20 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u21 != false and signalSELL21 ? scr_alertSELL + s21 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u22 != false and signalSELL22 ? scr_alertSELL + s22 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u23 != false and signalSELL23 ? scr_alertSELL + s23 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u24 != false and signalSELL24 ? scr_alertSELL + s24 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u25 != false and signalSELL25 ? scr_alertSELL + s25 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u26 != false and signalSELL26 ? scr_alertSELL + s26 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u27 != false and signalSELL27 ? scr_alertSELL + s27 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u28 != false and signalSELL28 ? scr_alertSELL + s28 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u29 != false and signalSELL29 ? scr_alertSELL + s29 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u30 != false and signalSELL30 ? scr_alertSELL + s30 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u31 != false and signalSELL31 ? scr_alertSELL + s31 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u32 != false and signalSELL32 ? scr_alertSELL + s32 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u33 != false and signalSELL33 ? scr_alertSELL + s33 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u34 != false and signalSELL34 ? scr_alertSELL + s34 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u35 != false and signalSELL35 ? scr_alertSELL + s35 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u36 != false and signalSELL36 ? scr_alertSELL + s36 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u37 != false and signalSELL37 ? scr_alertSELL + s37 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u38 != false and signalSELL38 ? scr_alertSELL + s38 + ' - SELL' + '\n' : scr_alertSELL
scr_alertSELL := u39 != false and signalSELL39 ? scr_alertSELL + s39 + ' - SELL' + '\n' : scr_alertSELL
//scr_alertSELL := u40 != false and signalSELL40 ? scr_alertSELL + s40 + ' - SELL' + '\n' : scr_alertSELL
// Send alert only if screener is not empty
if (scr_alertBUY != '') and boolSignalAlert != "SELL"
alert(scr_alertBUY + '\n([5ema.vn] - Timeframe: ' + timeframe + ')', freq = alert.freq_once_per_bar_close)
if (scr_alertSELL != '') and boolSignalAlert != "BUY"
alert(scr_alertSELL + '\n([5ema.vn] - Timeframe: ' + timeframe + ')', freq = alert.freq_once_per_bar_close)
|
Colorful Moving Averages | https://www.tradingview.com/script/Qc7GykOv-Colorful-Moving-Averages/ | faytterro | https://www.tradingview.com/u/faytterro/ | 468 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© faytterro
//@version=5
indicator("Colorful Moving Averages", overlay = true)
////////////
a1 = input(0.7, "T3 Volume Factor", group = "Tillson T3 Settings ")
T3(source,length)=>
e1 = ta.ema((high + low + 2 * close) / 4, length)
e2 = ta.ema(e1, length)
e3 = ta.ema(e2, length)
e4 = ta.ema(e3, length)
e5 = ta.ema(e4, length)
e6 = ta.ema(e5, length)
c1 = -a1 * a1 * a1
c2 = 3 * a1 * a1 + 3 * a1 * a1 * a1
c3 = -6 * a1 * a1 - 3 * a1 - 3 * a1 * a1 * a1
c4 = 1 + 3 * a1 + a1 * a1 * a1 + 3 * a1 * a1
T3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3
/////////////////
ma(source, length, type) =>
switch type
"T3" => T3(source, length)
"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)
"LSMA" => ta.linreg(source,length,0)
"HLM" => ta.hma(source, length)
maTypeInput = input.string("T3", title="Moving Average Type", options=["T3","SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA","LSMA", "HLM"], group = "general settings for all indicators.")
LengthInput = input.int(8, minval=1, title="Length", group = "general settings for all indicators.")
SourceInput = input.source(close, "Source", group = "general settings for all indicators.")
w = input.int(2, "width", group = "general settings for all indicators.")
MA = ma(SourceInput, LengthInput, maTypeInput)
d = ta.change(MA)
g = ta.change(d)
ad = ta.cum(math.abs(d))/bar_index
ag = ta.cum(math.abs(g))/bar_index
while ad<1
ad:= ad*10
d:= d*10
while ag<1
ag:= ag*10
g:= g*10
ck = 1//input.float(1,"Contrast", minval = 1, step = 0.5)
fd(x,y) =>
100-200/(math.pow(1+ck/y,x)+1)
delta = fd(d,ad)
gamma = fd(g,ag)
//plot(delta)
//plot(gamma, color = color.white)
f = 2.55*delta/2+50*2.55
plot(MA, "CMA", color=color.rgb(math.min(510-2*f,255),math.min(2*f,255),0), linewidth = w)
var tbl = table.new(position.top_right, 2, 2, color.rgb(120, 123, 134, 100), color.rgb(0,0,0,100), 1, color.rgb(255, 255, 255,100), 5)
if barstate.islast
table.cell(tbl, 1, 0, str.tostring(math.round(delta*100)/100), height = 6, width = 9,
text_color = d<0? color.rgb(255, 255, 255,0) : color.rgb(0,0,0,0), bgcolor = d>0? color.rgb(50, 255, 50,50) : color.rgb(255, 0, 0,50), text_size = size.large) //table_id = testTable, column = 0, row = 0, text = "Open is " + str.tostring(open))
table.cell(tbl, 1, 1, str.tostring(math.round(gamma*100)/100), height = 6, width = 9,
text_color = g<0? color.rgb(255, 255, 255,0) : color.rgb(0,0,0,0), bgcolor = g>0? color.rgb(50, 255, 50,50) : color.rgb(255, 0, 0,50), text_size = size.large)
table.cell(tbl, 0, 0, "Ξ", height = 6,
text_color = d<0? color.rgb(255, 255, 255,0) : color.rgb(0,0,0,0), bgcolor = d>0? color.rgb(50, 255, 50,50) : color.rgb(255, 0, 0,50), text_size = size.huge) //table_id = testTable, column = 0, row = 0, text = "Open is " + str.tostring(open))
table.cell(tbl, 0, 1,"Ξ", height = 6,
text_color = g<0? color.rgb(255, 255, 255,0) : color.rgb(0,0,0,0), bgcolor = g>0? color.rgb(50, 255, 50,50) : color.rgb(255, 0, 0,50), text_size = size.huge)
buy = ta.crossover(d,0)
sell = ta.crossunder(d,0)
plotshape(buy, "local minimum", shape.diamond, location.belowbar, color.green, 0, "local minimum", color.gray, true, size = size.small)
plotshape(sell, "local maximum", shape.diamond, location.abovebar, color.red, 0, "local maximum", color.gray, true, size = size.small)
alertcondition(buy, "local minimum")
alertcondition(sell, "local maximum") |
RS - Relative Strength Score | https://www.tradingview.com/script/EEL0qc2z-RS-Relative-Strength-Score/ | Lantzwat | https://www.tradingview.com/u/Lantzwat/ | 132 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β©Lantzwat
//@version=5
indicator("RS - Relative Strength Score", "RS")
src = input(title='Source', defval=close)
RefTickerId = input.symbol("SP:SPX+NASDAQ_DLY:NDX+DJ:DWCPF", title="Reference index", tooltip = "e.g. SPX/NDX/RUT/DWCPF or combinations of it, or TOTAL for Crypto")
bRSI = input.bool(true, "Show Relative Strength - annual based (IBD Style)")
bRSIQuarterly = input.bool(true, "Show Relative Strength - quarterly based")
// default lines
p0 = plot(0, color = color.new(color.white,100))
hline(0, "0" , linestyle = hline.style_dotted, color = color.new(color.white,90) )
hline(30, "30", linestyle = hline.style_dotted, color = color.new(color.white,70) )
hline(60, "60", linestyle = hline.style_dotted, color = color.new(color.white,70) )
var table infoTable = table.new(position.top_right, 1, 1, border_width = 0)
f_fillCell(_table, _column, _row, _value) =>
_cellText = str.tostring(_value, "#.##")
table.cell(_table, _column, _row, _cellText, text_size = size.tiny, text_color = color.white)
f_fillCelltext(_table, _column, _row, _value) =>
_cellText = _value
table.cell(_table, _column, _row, _cellText, text_size = size.tiny, text_color = color.white)
// Calculate relative strength
RS(tf, baseSymbol,comparativeSymbol, q) =>
// RS Score (Additional Momentum Parameter IBD Style)
// checking if traded 5 days a week (stock) or 7 days a week (crypto, forex)
lb_day = dayofweek(time('D')) == dayofweek(time('D')[7]) ? 365 : 251
lb_week = 52
// calculate default values
m3 = 0
m6 = 0
m9 = 0
m12 = 0
if tf == "W"
m3 := int(lb_week / 4)
m6 := int(lb_week / 2)
m9 := int((lb_week * 3) / 4)
m12 := lb_week
else if tf == "D" // default
m3 := int(lb_day / 4)
m6 := int(lb_day / 2)
m9 := int((lb_day * 3 )/ 4)
m12 := lb_day
rs_score = 0.
if m3 != 0
rs_score_3m = (baseSymbol / baseSymbol[m3] / (comparativeSymbol / comparativeSymbol[m3]) - 1)
rs_score_6m = (baseSymbol / baseSymbol[m6] / (comparativeSymbol / comparativeSymbol[m6]) - 1)
rs_score_9m = (baseSymbol / baseSymbol[m9] / (comparativeSymbol / comparativeSymbol[m9]) - 1)
rs_score_12m = (baseSymbol / baseSymbol[m12] / (comparativeSymbol / comparativeSymbol[m12]) - 1)
if q == 4
rs_score := (0.4 * rs_score_3m + 0.2 * rs_score_6m + 0.2 * rs_score_9m + 0.2 * rs_score_12m) * 100
if q == 1
rs_score := (rs_score_3m) * 100
else
f_fillCelltext(infoTable, 0, 0, "Only valid in daily and weekly timeframe")
rs_score
reference_close = request.security(RefTickerId, timeframe.period, src)
// plot RS quarterly
relative_strength_quarter = RS(timeframe.period, src,reference_close,1)
RSQcolor = relative_strength_quarter <= 0 ? color.red : relative_strength_quarter < 10 ? color.from_gradient(relative_strength_quarter, 0, 10, color.yellow, color.yellow ) : relative_strength_quarter < 60 ? color.from_gradient(relative_strength_quarter, 10, 60, color.green , color.blue) : color.from_gradient(relative_strength_quarter, 60, 100, color.blue , color.navy)
pRSq = plot(bRSIQuarterly ? relative_strength_quarter : na, color = RSQcolor, linewidth = 1)
fill(p0,pRSq,color = color.new(RSQcolor,70))
// plot RS annual (IBD style)
relative_strength = RS(timeframe.period, src,reference_close,4)
RScolor = relative_strength <= 0 ? color.red : relative_strength < 10 ? color.from_gradient(relative_strength, 0, 10, color.yellow, color.yellow ) : relative_strength < 60 ? color.from_gradient(relative_strength, 10, 60, color.green , color.blue) : color.from_gradient(relative_strength, 60, 100, color.blue , color.navy)
pRS = plot(bRSI ? relative_strength : na, color = RScolor, linewidth = 3)
fill(p0,pRS,color = color.new(RScolor,70))
f_fillCell(infoTable, 0, 0, relative_strength)
|
Import Forex Volume from 5 biggest FX Brokers (single/combined) | https://www.tradingview.com/script/1lVcjlrz-Import-Forex-Volume-from-5-biggest-FX-Brokers-single-combined/ | twingall | https://www.tradingview.com/u/twingall/ | 85 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// I typically use Forex.com for FX, which doesn't show volume. This indicator allows user to import Volume from a range of FX brokers that DO show volume
// Either pick a broker to draw from, or combine the reported volumes from all four brokers: "FXCM", "Currency.com", "OANDA", "GLOBALPRIME"
// Thank you @theEccentricTrader for the idea of pulling volume feed from other brokers
// Β© twingall
//@version=5
indicator("Import Total FX Volume from Other Brokers", shorttitle = "Import FX Volume")
showAll = input.bool(true, "Show Volume from Multiple Brokers", group = "multiple brokers")
show3 = input.bool(false, "//(Only FXCM, Pepperstone & Oanda)", group = "multiple brokers", tooltip = "Only applies if the top checkbox is toggled ON\n\nLonger volume history for these three brokers=> start date for plotting is June 2012 as opposed to Oct 2019")
brokerPrefix = input.string("FXCM", "broker to import from", group="show only one broker's volume", options = ["FXCM","EIGHTCAP","PEPPERSTONE" , "Currency.com", "OANDA"], tooltip = "Only applies if the top checkbox is toggled OFF\n\nIn descending order of volume size")
showFutVol = input.bool(true, "show only Futures Mkts Volume", group = "Futures markets Volume", tooltip = "OVERRIDES ALL OF THE ABOVE\n\nShow volume from Futures market: i.e. if Eur/Usd chart, shows volume from 6E1! continuous futures contract (CME)\n\nWorking for EurUsd, GbpUsd, AudUsd, NzdUsd, UsdChf, UsdJpy\n\nIf USD is the first part of the currency pair, volume from inverse of the futures chart will be shown (i.e. Usd/Cad =>> volume from 1/6C1!)")
volBullCol = input.color(color.green, "Bull bar color:", group = "formatting", inline ='1')
volBearCol = input.color(color.red, "Bear bar color:", group = "formatting", inline ='1')
showTable = input.bool(true, "show Table", group = "formatting", inline ='2')
titleCellCol = input.color( color.orange, "|| Title cell:", group = "formatting", inline ='2')
valCellCol = input.color( color.yellow, "value cell:", group = "formatting", inline ='2')
txtSize = input.string(size.normal, "\\Table Text Size", group = "formatting", inline ='3', options = [ size.auto, size.tiny, size.small, size.normal, size.large, size.huge])
tablePos = input.string(position.top_right, "| Table Pos:" , group = "formatting", inline ='3', options =[position.top_right,position.middle_right, position.bottom_right,position.top_left, position.top_center, position.middle_left, position.middle_center, position.bottom_left, position.bottom_center])
string prefix = switch brokerPrefix
"FXCM" => "FX"
"EIGHTCAP" => "EIGHTCAP"
"PEPPERSTONE" => "PEPPERSTONE"
"Currency.com" => "CURRENCYCOM"
"OANDA" => "OANDA"
///// ~~ FUTURES VOLUME ~~ //
modFutTicker = syminfo.ticker =="EURUSD"? "6E1!":
syminfo.ticker =="GBPUSD"? "6B1!":
syminfo.ticker =="AUDUSD"? "6A1!":
syminfo.ticker =="NZDUSD"? "6N1!":
syminfo.ticker =="USDJPY"? "1/6J1!": //inverted because USD is the numerator in Usd/Jpy
syminfo.ticker =="USDCHF"? "1/6S1!": //inverted because USD is the numerator
syminfo.ticker =="USDCAD"? "1/6C1!": //inverted because USD is the numerator
//~~ crosses ~~
//Aud
syminfo.ticker =="AUDCAD"?"6A1!/6C1!":
syminfo.ticker =="AUDCHF"?"6A1!/6S1!":
syminfo.ticker =="AUDJPY"?"6A1!/6J1!":
syminfo.ticker =="AUDNZD"?"6A1!/6N1!":
syminfo.ticker =="EURAUD"?"6E1!/6A1!":
syminfo.ticker =="GBPAUD"?"6B1!/6A1!":
//+Cad
syminfo.ticker =="CADCHF"?"6C1!/6S1!":
syminfo.ticker =="CADJPY"?"6C1!/6J1!":
syminfo.ticker =="EURCAD"?"6E1!/6C1!":
syminfo.ticker =="GBPCAD"?"6B1!/6C1!":
syminfo.ticker =="NZDCAD"?"6N1!/6C1!":
//+Chf
syminfo.ticker =="CHFJPY"?"6S1!/6J1!":
syminfo.ticker =="EURCHF"?"6E1!/6S1!":
syminfo.ticker =="GBPCHF"?"6B1!/6S1!":
syminfo.ticker =="NZDCHF"?"6N1!/6S1!":
//+Eur
syminfo.ticker =="EURGBP"?"6E1!/6B1!":
syminfo.ticker =="EURJPY"?"6E1!/6J1!":
syminfo.ticker =="EURNZD"?"6E1!/6N1!":
//+Gbp
syminfo.ticker =="GBPJPY"?"6B1!/6J1!":
syminfo.ticker =="GBPNZD"?"6B1!/6N1!":
//+Nzd
syminfo.ticker =="NZDJPY"?"6N1!/6J1!":
//(Jpy: see above)
"Input_Futures_Paired_Mkt_into_Script!"
//////
ModifiedTicker =showFutVol?modFutTicker: prefix + ":" +syminfo.ticker
importedVolume = request.security(ModifiedTicker, timeframe.period, volume)
var cumVol = 0.
cumVol += nz(importedVolume)
if barstate.islast and cumVol == 0
runtime.error("No volume is provided by the data vendor.")
_chg = ta.change(close)
_sign = _chg ==0?+1:_chg
nv = math.sign(_sign) * importedVolume
isBull = math.sign(nv)>=1?true:false
vol =isBull?nv:-nv
MA_single = ta.sma(vol,100)
plot(not showAll or (showAll and showFutVol)?vol:na, color=isBull?volBullCol:volBearCol, title="NV", style =plot.style_columns)
//combined total volume from several brokers:
st5 = time > timestamp("30 Sept 2019")
st3 = time >timestamp("04 Jun 2012")
st_cond = showAll?(show3?st3:st5):false
impVol1 =request.security("FX" + ":" +syminfo.ticker , timeframe.period, volume)
impVol2 =request.security("EIGHTCAP" + ":" +syminfo.ticker , timeframe.period, volume)
impVol3 =request.security("PEPPERSTONE" + ":" +syminfo.ticker , timeframe.period, volume)
impVol4 =request.security("CURRENCYCOM" + ":" +syminfo.ticker , timeframe.period, volume)
impVol5=request.security("OANDA" + ":" +syminfo.ticker , timeframe.period, volume)
inpVolTot = show3? impVol1+impVol3+impVol5: impVol1+impVol2+impVol3+impVol4+impVol5
var cumVolTot = 0.
cumVolTot += nz(inpVolTot )
if barstate.islast and cumVolTot == 0
runtime.error("No volume is provided by the data vendor.")
_chgTot = ta.change(close)
_signTot = _chgTot ==0?+1:_chgTot
nvTot = math.sign(_signTot) * (inpVolTot )
isBullTot = math.sign(nvTot)>=1?true:false
volTot =isBullTot?nvTot:-nvTot
MA_multi = ta.sma(volTot, 104)
plot(st_cond and not showFutVol?volTot:na, color=isBullTot?volBullCol:volBearCol, title="VolTot", style =plot.style_columns)
//display Table
string brokerStr = showFutVol?modFutTicker: (showAll?(show3?"FX & Pepp & Oanda":"All Five"):prefix)
MA_broker = math.round((showAll?MA_multi:MA_single)/1000)
string Title = showFutVol?"Futures Volume":"Brokers"
var Table = table.new(tablePos, columns = 5, rows = 5, bgcolor = titleCellCol, border_width = 1)
if barstate.islast and showTable
table.cell(Table, 0, 0, Title, bgcolor = titleCellCol, text_size =txtSize)
table.cell(Table, 0, 1, str.tostring(brokerStr),bgcolor = valCellCol, text_size =txtSize)
if barstate.islast and showTable and not showFutVol
table.cell(Table, 1, 0, "SMA 100", text_size =txtSize)
table.cell(Table, 1, 1, str.tostring(MA_broker) + " K",bgcolor = valCellCol, text_size =txtSize) |
Orion:Sagitta | https://www.tradingview.com/script/vSP6B13i-Orion-Sagitta/ | priceprophet | https://www.tradingview.com/u/priceprophet/ | 30 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© priceprophet
//@version=5
indicator("Orion:Sagitta")
s = ta.stoch(close,high,low,2)
s1 = ta.stoch(close,high,low,1)
x = s >= 80 ? color.green :
s >= 60 and s < 80 ? color.blue :
s >= 40 and s < 60 ? color.yellow :
s >= 20 and s < 50 ? color.orange :
s < 20 ? color.red : color.red
y = s > 80 ? 100 :
s >= 60 and s < 80 ? 80 :
s >= 40 and s < 60 ? 60 :
s >= 20 and s < 40 ? 40 :
s < 20 ? 20 : 0
bullishBear = (high[1] > high[0] and low[1] > low[0] and close > low[1]) and (s1>=60)
x := bullishBear ? color.silver : x
h0 = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
h1 = hline(20, "Lower Band", color=#787B86)
HH = ta.highest(high,1)
LL = ta.lowest(low,1)
var cHigh = high
var cLow = low
consol = cHigh > close and close > cLow
cHigh := consol and high > cHigh ? high : cHigh
cLow := consol and cLow > low ? low : cLow
cHigh := consol == false ? high : cHigh
cLow := consol == false ? low : cLow
consolFlag = consol ? y : 0
alertValueHigher = y[0] > y[1]
alertValueLower = y[0] < y[1]
if alertValueHigher
alert("Potential Entry Establish",alert.freq_once_per_bar_close)
else if alertValueLower
alert("Adjust Stop Loss if in trade",alert.freq_once_per_bar_close)
plot(y,style=plot.style_histogram,linewidth = 8, color=x,title="Stochastic C%")
plot(consolFlag,style=plot.style_histogram,linewidth = 3,color=color.maroon,title="Consolidation Flag")
//plot(s,color=color.white,title="Stochastic")
|
kama | https://www.tradingview.com/script/1O7gafpR-kama/ | palitoj_endthen | https://www.tradingview.com/u/palitoj_endthen/ | 78 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© palitoj_endthen
//@version=5
indicator(title = 'Perry J. Kaufman - Adaptive Moving Average - Modified', shorttitle = 'kama', overlay = true)
// input
length = input.int(defval = 14, title = 'Length', group = 'Value', tooltip = 'Determines the length of input data')
fast_length = input.int(defval = 2,title = 'Fast Length', group = 'Value', minval = 2, maxval = 30, tooltip = 'Determines the length of fast input')
slow_length = input.int(defval = 30, title = 'Slow Length', group = 'Value', minval = 2, maxval = 30, tooltip = 'Determines the length of slow input')
hp_period = input.int(defval = 48, title = 'High-Pass Period', group = 'Value', tooltip = 'Determines the length of High-Pass period')
src = input.source(defval = ohlc4, title = 'Source', group = 'Source', tooltip = 'Determines the source of input data, default to ohlc4')
hysteresis = input.bool(defval = true, title = 'Hysteresis', group = 'Options', tooltip = 'Determines whether to display hysteresis band')
bar_color = input.bool(defval = false, title = 'Bar Color', group = 'Options', tooltip = 'Determines whether to apply bar color')
// determine applied lendth with dominant cycle (Ehlers)
// variable
avg_length = 0
m = 0.00
n = 0.00
x = 0.00
y = 0.09
alpha1 = 0.00
hp = 0.00
a1 = 0.00
b1 = 0.00
c1 = 0.00
c2 = 0.00
c3 = 0.00
filt = 0.00
sx = 0.00
sy = 0.00
sxx = 0.00
syy = 0.00
sxy = 0.00
max_pwr = 0.00
dominant_cycle = 0.00
// array
var corr = array.new_float(length)
var cosine_part = array.new_float(length)
var sine_part = array.new_float(length)
var sq_sum = array.new_float(length)
var r1 = array.new_float(length)
var r2 = array.new_float(length)
var pwr = array.new_float(length)
// high-pass filter cyclic components whose periods are shorter than 48 bars
pi = 2*math.asin(1)
alpha1 := (math.cos(.707*2*pi/hp_period) + math.sin(.707*2*pi/hp_period)-1) / math.cos(.707*2*pi/hp_period)
hp := (1-alpha1/2)*(1-alpha1/2)*(src-2*src[1]+src[2])+2*(1-alpha1)*nz(hp[1])-(1-alpha1)*(1-alpha1)*nz(hp[2])
// smooth with super smoother filter
a1 := math.exp(-1.414*pi/10)
b1 := 2*a1*math.cos(1.414*180/10)
c2 := b1
c3 := -a1*a1
c1 := 1-c2-c3
filt := c1*(hp+hp[1])/2+c2*nz(filt[1])+c3*nz(filt[2])
// pearson correlation for each value of lag
for lag = 0 to length-1
// set the averaging length as m
m := avg_length
if avg_length == 0
m := lag
// initialize correlation sums
sx := 0.00
sy := 0.00
sxx := 0.00
syy := 0.00
sxy := 0.00
// advance samples of both data streams and sum pearson components
for count = 0 to m
x := filt[count]
y := filt[lag+count]
sx := sx+x
sy := sy+y
sxx := sxx+x*x
sxy := sxy+x*y
syy := syy+y*y
// compute correlation for each value of lag
if (m*sxx-sx*sx)*(m*syy-sy*sy) > 0
array.set(corr, lag, ((m*sxy-sx*sy)/math.sqrt((m*sxx-sx*sx)*(m*syy-sy*sy))))
for period = 8 to length-1
array.set(cosine_part, period, 0)
array.set(sine_part, period, 0)
for n2 = 8 to length-1
array.set(cosine_part, period, nz(array.get(cosine_part, period))+nz(array.get(corr, n2))*math.cos(360*n2/period))
array.set(sine_part, period, nz(array.get(sine_part, period))+nz(array.get(corr, n2))*math.sin(360*n2/period))
array.set(sq_sum, period, nz(array.get(cosine_part, period))*nz(array.get(cosine_part, period))+nz(array.get(sine_part, period))*nz(array.get(sine_part, period)))
for period2 = 8 to length-1
array.set(r2, period2, nz(array.get(r1, period2)))
array.set(r1, period2, .2*nz(array.get(sq_sum, period2))*nz(array.get(sq_sum, period2))+.8*nz(array.get(r2, period2)))
// find maximum power level for normalization
max_pwr := .991*max_pwr
for period3 = 8 to length-1
if nz(array.get(r1, period3)) > max_pwr
max_pwr := nz(array.get(r1, period3))
for period4 = 8 to length-1
array.set(pwr, period4, nz(array.get(r1, period4))/max_pwr)
// compute the dominant cycle using the cg of the spectrum
spx = 0.00
sp = 0.00
for period5 = 8 to length-1
if nz(array.get(pwr, period5)) >= .5
spx := spx+period5*nz(array.get(pwr, period5))
sp := sp+nz(array.get(pwr, period5))
if sp != 0
dominant_cycle := spx/sp
if dominant_cycle < 8
dominant_cycle := 8
if dominant_cycle > 14
dominant_cycle := 14
// kaufman adaptive moving average
fastest = 2/(fast_length+1)
slowest = 2/(slow_length+1)
// eficiency ratio
num = src - src[int(dominant_cycle)]
num := num > 0 ? num : num*-1
denom = math.sum(math.abs(src-src[1]), int(dominant_cycle))
er = num/denom
// smoothing constant
sc = math.pow(er*(fastest-slowest)+slowest, 2)
kama = 0.00
kama := nz(kama[1]) + sc*(src-nz(kama[1]))
// visualize
// color condition
color_con = kama > kama[1] and kama[1] > kama[2] ? color.green : color.red
color_con_ = kama > kama[1] and kama[1] > kama[2]
plot(kama, color = color_con, linewidth = 3)
plot(hysteresis ? kama*(1+(.5/100)) : na, color = color.new(color.yellow, 50), linewidth = 1)
plot(hysteresis ? kama*(1-(.5/100)) : na, color = color.new(color.yellow, 50), linewidth = 1)
barcolor(bar_color ? color_con : na)
// alert condition
alertcondition((not color_con_[1] and color_con_ and barstate.isconfirmed), title = 'Kama Entry', message = 'Buy/Long entry detected')
alertcondition((color_con_[1] and not color_con_ and barstate.isconfirmed), title = 'Kama Close', message = 'Sell/Short entry detected ')
// strategy test
// long_condition = not (color_con_[1] and color_con_)
// if long_condition
// strategy.entry('long', strategy.long)
// short_condition = color_con_[1] and not color_con_
// if short_condition
// strategy.exit('exit', 'long', profit = 10, loss = 1)
|
SumInd | https://www.tradingview.com/script/G5reYYAI/ | fpucci | https://www.tradingview.com/u/fpucci/ | 98 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© fpucci
// V1.00 - March 21, 2023
//@version=5
indicator("SumInd", overlay=false)
wha = input.int(100, "Heiking Ashi Weight (0-200%)", 0, 200)
wpsar = input.int(100, "Parabolic SAR Weight (0-200%)", 0, 200)
wkon = input.int(60, "Koncord Weight (0-200%)", 0, 200)
wrsi = input.int(100, "RSI Weight (0-200%)", 0, 200)
wdmi = input.int(100, "DMI Weight (0-200%)", 0, 200)
wbb = input.int(0, "Bollinger Bands Weight (0-200%)", 0, 200)
wmacd = input.int(100, "MACD Weight (0-200%)", 0, 200)
triggerb = input.int(30, "Buy level (0-100%)", 0, 100)
triggers = input.int(-45, "Sell level (0-100%)", -100, 0)
hold = input.bool(false, "Distinguish wait/hold state")
trans=90
count=7
scorep = 0
scoren = 0
var bgc=0
psar = ta.sar(0.02, 0.02, 0.2)
[macdf, macds, macdh] = ta.macd(close, 12, 26, 9)
[bbm, bbh, bbl] = ta.bb(close, 26, 2)
[dip, dim, adx] = ta.dmi(14, 14)
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
hamax = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
hamin = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
rsi = ta.rsi(close, 14)
emarsi = ta.ema(rsi, 14)
basis_boll = ta.ema(close, 21)
dev_boll = ta.stdev(close, 21)
BollOsc = ((close - basis_boll ) / (dev_boll * 4) ) * 100 + 50
stoc = ta.sma(ta.stoch(close, high, low, 14), 3)
mont = (rsi + BollOsc + stoc)/3
konc = ta.ema(mont, 15)
scorep += (haopen == hamin) ? (wha/2) : 0 // OK + 1 green candle HA
scoren -= (haopen == hamax) ? (wha/2) : 0 // OK - 1 red candle HA
scorep += ((haopen == hamin) and (haopen[1] == hamin[1])) ? (wha/2) : 0 // 2 green candles
scoren -= (haopen == hamax) and (haopen[1] == hamax[1]) ? (wha/2) : 0 // 2 red candles
scorep += (emarsi<rsi) ? wrsi : 0 // OK +
scoren -= (emarsi>rsi) ? wrsi : 0 // OK +
scorep += ((psar[0]<low[0]) and (psar[1]>low[1])) ? wpsar/2 : 0 // Psar goes into grow
scoren -= ((psar[0]>high[0]) and (psar[1]<high[1])) ? wpsar/2 : 0 // Psar goes into decline
scorep += (psar < (0.97*low)) ? wpsar/2 : 0 // Psar rising steadily
scoren -= (psar > (1.03*high)) ? wpsar/2 : 0 // Psar in constant decline
scorep += ((konc>konc[4]) and konc[4]<35) ? wkon : 0 // rising from 35-
scoren -= ((konc<konc[4]) and konc[4]>65) ? wkon : 0 // dropping from 65+
scorep += math.min(((dip>(1.15*dim)) ? int(wdmi*adx/25) : 0), wdmi)
scoren -= math.min(((dim>(1.15*dip)) ? int(wdmi*adx/25) : 0), wdmi)
scorep += ((hlc3[2] <= bbl[2]) and (hlc3>bbl) and ((bbh-bbm)>0.15*bbm)) ? wbb : 0 // touched the lower band but is already going up
scoren -= ((hlc3[2] >= bbh[2]) and (hlc3<bbh) and ((bbh-bbm)>0.15*bbm)) ? wbb : 0 // touched the upper band but is already down
scorep += ((macdh[2]<macdh[1]) and (macdh[1]<macdh)) ? (wmacd/3) : 0
scoren -= ((macdh[2]>macdh[1]) and (macdh[1]>macdh)) ? (wmacd/3) : 0
scorep += (macdf>macds) ? (wmacd/3) : 0
scoren -= (macdf<macds) ? (wmacd/3) : 0
scorep += ((macdf<0) and (macdf>macds)) ? (wmacd/3) : 0
scoren -= ((macdf>0) and (macdf<macds)) ? (wmacd/3) : 0
scorep/=count
scoren/=count
score = scorep+scoren
buy = score >= triggerb
shell = score <= triggers
if (buy)
bgc:=1
if (shell)
bgc:=-1
if (hold and not buy and not shell)
bgc := 0
colorbg = (bgc==1) ? color.new(color.green,trans) : ((bgc==-1) ? color.new(color.red,trans) : na)
bgcolor(colorbg)
plotshape(shell, title="Sell signal", style=shape.arrowdown, location=location.top, color=(not hold) ? color.white : na, size=size.tiny) // location.abovebar
plotshape(buy, title= "Buy signal", style=shape.arrowup, location=location.bottom, color=(not hold) ? color.white : na, size=size.tiny) // location.abovebar
// Advanced, change overlay true by false false and select all lines
hline(triggerb, title='Buy', color=color.gray, linewidth=1)
hline(triggers, title='Sell', color=color.gray, linewidth=1)
plot (scorep, title="Buy line", color=color.teal)
plot (scoren, title="Sell line", color=color.maroon)
plot (score, title="Total line", color=color.yellow)
|
Spot vs Derivative Premium | https://www.tradingview.com/script/TGu0M96P-Spot-vs-Derivative-Premium/ | ShisuiCrypto | https://www.tradingview.com/u/ShisuiCrypto/ | 5 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© ShisuiCrypto
//@version=4
study("Spot vs Derivative Premium")
src1 = security("COINBASE:BTCUSD", timeframe.period, close)
src2 = security("BYBIT:BTCUSD.P", timeframe.period, close)
src3 = security("BINANCE:BTCUSDT", timeframe.period, close)
src4 = security("BINANCE:BTCUSDTPERP", timeframe.period, close)
plot(0, color=color.black)
plot(src1 - src2, title="Coinbase vs Bybit", display=display.none)
plot(src3 - src4, title="Binance", color=color.green, display=display.none)
plot(avg(src1 - src2, src3 - src4), title="average premium", color=color.red)
plot(close)
|
SB Multiple Moving Averages (Simple) | https://www.tradingview.com/script/gXSI92jx-SB-Multiple-Moving-Averages-Simple/ | SeyfettinBal | https://www.tradingview.com/u/SeyfettinBal/ | 22 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© SeyfettinBal
//@version=5
indicator("SB Moving Averages", overlay = true)
i = input.source(close,"Source")
l1 = input.int(3, "1. MA Days")
l2 = input.int(5, "2. MA Days")
l3 = input.int(8, "3. MA Days")
l4 = input.int(13, "4. MA Days")
l5 = input.int(21, "5. MA Days")
l6 = input.int(34, "6. MA Days")
l7 = input.int(55, "7. MA Days")
m1 = ta.sma(i, l1)
m2 = ta.sma(i, l2)
m3 = ta.sma(i, l3)
m4 = ta.sma(i, l4)
m5 = ta.sma(i, l5)
m6 = ta.sma(i, l6)
m7 = ta.sma(i, l7)
c1 = close > m1 ? "+" : "-"
c2 = close > m2 ? "+" : "-"
c3 = close > m3 ? "+" : "-"
c4 = close > m4 ? "+" : "-"
c5 = close > m5 ? "+" : "-"
c6 = close > m6 ? "+" : "-"
c7 = close > m7 ? "+" : "-"
color1 = (c1 == "+" ? color.lime : color.red)
color2 = (c2 == "+" ? color.lime : color.red)
color3 = (c3 == "+" ? color.lime : color.red)
color4 = (c4 == "+" ? color.lime : color.red)
color5 = (c5 == "+" ? color.lime : color.red)
color6 = (c6 == "+" ? color.lime : color.red)
color7 = (c7 == "+" ? color.lime : color.red)
li = input.int(2, "Linewidth")
plot(m1, "MA 1", color = color.yellow, linewidth = li)
plot(m2, "MA 2", color = color.orange, linewidth = li)
plot(m3, "MA 3", color = color.aqua, linewidth = li)
plot(m4, "MA 4", color = color.blue, linewidth = li)
plot(m5, "MA 5", color = color.red, linewidth = li)
plot(m6, "MA 6", color = color.purple, linewidth = li)
plot(m7, "MA 7", color = color.black, linewidth = li)
var myTable = table.new(position = position.top_right, columns = 2, rows = 9, bgcolor = color.rgb(207, 255, 255), frame_color = #313131, frame_width = 2, border_color = #818181, border_width = 1)
table.cell(table_id = myTable, column = 0, row = 0, text = str.tostring(syminfo.ticker), text_color = color.white, bgcolor = color.rgb(0, 79, 144), width = 7.5)
table.cell(table_id = myTable, column = 0, row = 1, text = "MA 1", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 2, text = "MA 2", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 3, text = "MA 3", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 4, text = "MA 4", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 5, text = "MA 5", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 6, text = "MA 6", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 7, text = "MA 7", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column=1, row=0, text = "Position", text_color = color.white, bgcolor = color.rgb(0, 79, 144), width = 7.5)
table.cell(table_id = myTable, column = 1, row = 1, text = str.tostring(c1), text_color = #313131, bgcolor = color1)
table.cell(table_id = myTable, column = 1, row = 2, text = str.tostring(c2), text_color = #313131, bgcolor = color2)
table.cell(table_id = myTable, column = 1, row = 3, text = str.tostring(c3), text_color = #313131, bgcolor = color3)
table.cell(table_id = myTable, column = 1, row = 4, text = str.tostring(c4), text_color = #313131, bgcolor = color4)
table.cell(table_id = myTable, column = 1, row = 5, text = str.tostring(c5), text_color = #313131, bgcolor = color5)
table.cell(table_id = myTable, column = 1, row = 6, text = str.tostring(c6), text_color = #313131, bgcolor = color6)
table.cell(table_id = myTable, column = 1, row = 7, text = str.tostring(c7), text_color = #313131, bgcolor = color7) |
Trade Ideas to Discord Webhook | https://www.tradingview.com/script/7GwmQNeB-Trade-Ideas-to-Discord-Webhook/ | godzcopilot | https://www.tradingview.com/u/godzcopilot/ | 28 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© godzcopilot
//@version=5
indicator('Trade Ideas to Discord Webhook', shorttitle='π‘', overlay=true)
// Input fields
alert_type = input.string('Combined',title='Alert Type',options = ['Combined', 'Entry', 'Exit'],tooltip='Select Alert Type' )
direction = input.string('LONG',title='Long/Short',options = ['LONG', 'SHORT'],tooltip='Select Long / Short' )
entry1 = input.float(0.0, title='Entry 1', group='Entry', inline='1')
entry2 = input.float(0.0, title='Entry 2', group='Entry', inline='1')
entry3 = input.float(0.0, title='Entry 3', group='Entry', inline='2')
entry4 = input.float(0.0, title='Entry 4', group='Entry', inline='2')
tp1 = input.float(0.0, title='TP 1', group='Exits', inline='3')
tp2 = input.float(0.0, title='TP 2', group='Exits', inline='3')
tp3 = input.float(0.0, title='TP 3', group='Exits', inline='4')
tp4 = input.float(0.0, title='TP 4', group='Exits', inline='4')
stopLoss = input.float(0.0, title='Stop Loss', group='Safe Trading', inline='5')
maxLeverage = input.int(0, title='Max Leverage', group='Safe Trading', inline='5')
otherNotes = input.string('', title='Other Notes', group='Trade Notes', inline='6')
sentAlert = false
// Indicator logic
alertCondition = (alert_type == 'Combined' and (entry1 != 0 or entry2 != 0 or entry3 != 0 or entry4 != 0)) or (alert_type == 'Entry' and (entry1 != 0 or entry2 != 0 or entry3 != 0 or entry4 != 0)) or (alert_type == 'Exit' and (tp1 != 0 or tp2 != 0 or tp3 != 0 or tp4 != 0))
msg_Color = direction == 'LONG' ? 60227 : 15730953
// JSON formatted alert message with ticker and excluding default values
jsonMessage = '{"embeds": [{ "title": "' + direction + ' trade idea for: ' + syminfo.ticker + '", "color": ' + str.tostring(msg_Color) + ', "description": "' + ((alert_type == "Combined" or alert_type == "Entry") ? '**__ENTRY__**' + '\\n' + (entry1 != 0 ? '**1:**σ γ
€' + str.tostring(entry1) + '\\n' : '') + (entry2 != 0 ? '**2:**γ
€' + str.tostring(entry2) + '\\n' : '') + (entry3 != 0 ? '**3:**γ
€' + str.tostring(entry3) + '\\n' : '') + (entry4 != 0 ? '**4:**γ
€' + str.tostring(entry4) + '\\n' + '\\n' : '') : "" ) + ((alert_type == "Combined" or alert_type == "Exit") ? '**__TAKE PROFIT__**' + '\\n' + (tp1 != 0 ? '**1:**γ
€' + str.tostring(tp1) + '\\n' : '') + (tp2 != 0 ? '**2:**γ
€' + str.tostring(tp2) + '\\n' : '') + (tp3 != 0 ? '**3:**γ
€' + str.tostring(tp3) + '\\n' : '') + (tp4 != 0 ? '**4:**γ
€' + str.tostring(tp4) + '\\n' + '\\n' : ''):"") + (stopLoss != 0 ? '**STOP LOSS:**γ
€' + str.tostring(stopLoss) + '\\n' : '') + (maxLeverage != 0 ? '**MAX LEVERAGE:**γ
€' + str.tostring(maxLeverage) + '\\n' + '\\n' : '') + (otherNotes != '' ? '**__CONSIDERATIONS:__** ' + '\\n' + otherNotes : '') + '"}] }'
// Generate alerts
if alertCondition and not sentAlert
alert(jsonMessage, alert.freq_once_per_bar)
sentAlert := true
sentAlert
|
HT Momentum Indicator [ ZCrypto ] | https://www.tradingview.com/script/aVXYkicb-HT-Momentum-Indicator-ZCrypto/ | TZack88 | https://www.tradingview.com/u/TZack88/ | 65 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© TZack88
//@version=5
indicator("HT Momentum Indicator [ ZCrypto ]")
string ht_group = "HT Core"
string ht2_group = "HT Settings"
string sma_group = "SMA Settings"
string vwap_group = "VWAP Settings"
float src = input(hlc3, title="Source",group = ht_group,inline = "01")
int period = input(14, title="Period",group = ht_group,inline = "01")
color bull = input(color.green,group = ht_group,inline = "01")
color bear = input(color.red,group = ht_group,inline = "01")
bool showfast = input(false,"Show Fastβ",group = ht2_group,inline = "01")
int fastLength = input(9, title="Length",group = ht2_group,inline = "01")
color fast_color = input(color.rgb(216, 180, 64),title="",group = ht2_group,inline = "01")
bool showslow = input(false,"Show Slowβ",group = ht2_group,inline = "02")
int slowLength = input(26, title="Length",group = ht2_group,inline = "02")
color slow_color = input(color.rgb(0, 19, 230),title="",group = ht2_group,inline = "02")
bool showvwap = input(true,"Show VWAPβ",group = vwap_group,inline = "01")
int vwapLength = input(9, title="VWAP Length",group = vwap_group,inline = "01")
color vwap_cl = input(color.rgb(194, 61, 183),title="",group = vwap_group,inline = "01")
// Hyperbolic tangent Calculations-----------{
HT() =>
_mom = ta.change(src, period)
cal = (math.exp(2 * _mom) - 1) / (math.exp(2 * _mom) + 1)
// momfilter = ta.sma(cal, Length)
//---------------}
momentum = HT()
fastema = ta.ema(momentum, fastLength)
slowema = ta.ema(momentum, slowLength)
vwap = ta.vwap(momentum, vwapLength) / 1.2
hist = fastema - slowema
//plotting-----------{
plot(hist, title="HT Momentum", linewidth=2,style=plot.style_histogram,color= hist > 0 ? bull : bear,editable = false,histbase = 0)
plot(showvwap ? vwap: na ,title = "VWAP",color=vwap_cl,editable = false)
plot(showfast ? fastema : na ,color=fast_color,editable = false)
plot(showslow ? slowema : na ,color=slow_color,editable = false)
hline(0,"Zero Line",color = color.rgb(214, 201, 17))
//-----------}
// Alerts -----------{
alertcondition(ta.crossover(fastema,slowema),"Fast Cross up Slow")
alertcondition(ta.crossover(vwap,0),"VWAP Momentum")
alertcondition( hist > 0 and hist[1] < 0,"Bull Momentum")
alertcondition( vwap > 0 and hist > 0 and hist[1] < 0,"Vwap/Bull Momentum")
//------------} |
Entry Alert Bot | https://www.tradingview.com/script/M1wov6cq-Entry-Alert-Bot/ | drother | https://www.tradingview.com/u/drother/ | 119 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© drother
//@version=5
indicator("Entry Alert Bot", overlay = true)
f_tp = input.float(2, title = "Take Profit")
f_entry = input.float(1.0, minval = 0, title = "Entry Price")
f_sl_perc = input.float(2.0, minval = 0, title = "Total Stoploss %")
f_leverage = input.float(10.0, minval = 1, title ="Leverage")
b_re_entry = input.bool(true, title = "Automatic re-entry after Stopped out?")
s_margin_mode = input.string("% of Portfolio", title = "Margin Type", options=["% of Portfolio", "Static Amount"])
f_orig_size = input.float(1, title = "Margin size")
start_day_time = input.time(timestamp('20 Mar 2023 00:20'), "Entry Begin Date/Time")
s_alert_freq = input.string("Once per Bar", title = "Alert Frequency", options=["Once per Bar", "Once per Bar Close", "All"])
s_long_entry_text = input.text_area(defval = "Long Entry \n #leverage# \n #symbol# \n #tpfull# \n #stoplossprice# \n #stoplosspercent# \n #margin# \n #margintype#", title = "Long Entry")
s_short_entry_text = input.text_area(defval = "Short Entry \n #leverage# \n #symbol# \n #tpfull# \n #stoplossprice# \n #stoplosspercent# \n #margin# \n #margintype#", title = "Short Entry")
b_enable_dashboard = input.bool(true, title = "Enable Dashboard?")
i_line_bars = input.int(15, title = "Future Positions box width")
bool b_long_trade = if f_tp > f_entry
true
else
false
// Create Arrays and initialize vars
var int i_entry_num = 0
var float f_sl = if b_long_trade
math.round_to_mintick(f_entry * ((100 - f_sl_perc) * .01))
else
math.round_to_mintick(f_entry * ((100 + f_sl_perc) * .01))
var box box_prof = na
var box box_loss = na
box.set_top(box_prof, b_long_trade? f_tp: f_entry)
box.set_top(box_loss, b_long_trade? f_entry : f_sl)
box.set_bottom(box_prof, b_long_trade? f_entry : f_tp)
box.set_bottom(box_loss, b_long_trade? f_sl : f_entry)
varip bool b_trade_entered = false
varip bool b_cross_up_entry = false
varip bool b_cross_dn_entry = false
varip bool b_cross_sl = false
varip bool b_cross_tp = false
varip bool b_trade_finished = false
varip bool b_stopped_out = false
time_to_trade = time > start_day_time
trade_time_index = bar_index + (-1 * (time - start_day_time) / (1000 * timeframe.in_seconds(timeframe.period)))
var int trade_fin_time = 0
var int trade_beg_time = 0
//replace text in alerts
s_long_entry_text := str.replace_all(s_long_entry_text, "#symbol#", str.replace_all(syminfo.ticker, ".P", ""))
s_long_entry_text := str.replace_all(s_long_entry_text, "#leverage#", str.tostring(f_leverage))
s_long_entry_text := str.replace_all(s_long_entry_text, "#tpfull#", str.tostring(f_tp))
s_long_entry_text := str.replace_all(s_long_entry_text, "#stoplossprice#", str.tostring(f_sl))
s_long_entry_text := str.replace_all(s_long_entry_text, "#stoplosspercent#", str.tostring(f_sl_perc))
s_long_entry_text := str.replace_all(s_long_entry_text, "#margin#", str.tostring(f_orig_size))
s_long_entry_text := str.replace_all(s_long_entry_text, "#margintype#", str.tostring(s_margin_mode =="Static Amount"? 2: 1))
s_short_entry_text := str.replace_all(s_short_entry_text, "#symbol#", str.replace_all(syminfo.ticker, ".P", ""))
s_short_entry_text := str.replace_all(s_short_entry_text, "#leverage#", str.tostring(f_leverage))
s_short_entry_text := str.replace_all(s_short_entry_text, "#tpfull#", str.tostring(f_tp))
s_short_entry_text := str.replace_all(s_short_entry_text, "#stoplossprice#", str.tostring(f_sl))
s_short_entry_text := str.replace_all(s_short_entry_text, "#stoplosspercent#", str.tostring(f_sl_perc))
s_short_entry_text := str.replace_all(s_short_entry_text, "#margin#", str.tostring(f_orig_size))
s_short_entry_text := str.replace_all(s_short_entry_text, "#margintype#", str.tostring(s_margin_mode =="Static Amount"? 2: 1))
if bar_index == 0
if b_long_trade
box_prof := box.new(na, f_tp, na, f_entry, border_color = color.gray, border_width = 1, bgcolor = color.new(color.green, 80))
box_loss := box.new(na, f_entry, na, f_sl, border_color = color.gray, border_width = 1, bgcolor = color.new(color.red, 80))
else
box_prof := box.new(na, f_entry, na, f_tp, border_color = color.gray, border_width = 1, bgcolor = color.new(color.green, 80))
box_loss := box.new(na, f_sl, na, f_entry, border_color = color.gray, border_width = 1, bgcolor = color.new(color.red, 80))
b_cross_up_entry := if (ta.crossover(high, f_entry) and time_to_trade) or (ta.crossover(close, f_entry) and time_to_trade)
true
else
false
b_cross_dn_entry := if (ta.crossunder(low, f_entry) and time_to_trade) or ta.crossunder(close, f_entry) and time_to_trade
true
else
false
b_cross_sl := if low <= f_sl and high >= f_sl and time_to_trade
true
else
false
b_cross_tp := if high >= f_tp and low <= f_tp and time_to_trade
true
else
false
if time_to_trade and not b_trade_finished and b_trade_entered
if not b_trade_finished
if b_cross_sl
b_stopped_out := true
trade_fin_time := bar_index
if b_cross_tp
b_trade_finished := true
trade_fin_time := bar_index
// Alerts and drawings
if b_cross_tp and b_trade_finished and not b_trade_finished[1]
box.set_right(box_prof, bar_index)
box.set_right(box_loss, bar_index)
if b_cross_sl and b_trade_finished and not b_trade_finished[1]
box.set_right(box_prof, bar_index)
box.set_right(box_loss, bar_index)
if b_long_trade and b_cross_up_entry and time_to_trade and not b_trade_finished
if s_alert_freq == "Once per Bar"
alert(s_long_entry_text, freq=alert.freq_once_per_bar)
if s_alert_freq == "Once per Bar Close"
alert(s_long_entry_text, freq=alert.freq_once_per_bar_close)
if s_alert_freq == "All"
alert(s_long_entry_text, freq=alert.freq_all)
b_trade_entered := true
trade_beg_time := bar_index
if not b_long_trade and b_cross_dn_entry and time_to_trade
if s_alert_freq == "Once per Bar"
alert(s_short_entry_text, freq=alert.freq_once_per_bar)
if s_alert_freq == "Once per Bar Close"
alert(s_short_entry_text, freq=alert.freq_once_per_bar_close)
if s_alert_freq == "All"
alert(s_short_entry_text, freq=alert.freq_all)
b_trade_entered := true
trade_beg_time := bar_index
//do stuff
if b_stopped_out and not b_stopped_out[1]
box.set_right(box_prof, bar_index)
box.set_right(box_loss, bar_index)
if b_long_trade
box.new(box.get_left(box_prof), box.get_top(box_prof), box.get_right(box_prof), box.get_bottom(box_prof), border_color = color.gray, border_width = 1, bgcolor = color.new(color.green, 80))
box.new(box.get_left(box_loss), box.get_top(box_loss), box.get_right(box_loss), box.get_bottom(box_loss), border_color = color.gray, border_width = 1, bgcolor = color.new(color.red, 80))
else
box.new(box.get_left(box_prof), box.get_top(box_prof), box.get_right(box_prof), box.get_bottom(box_prof), border_color = color.gray, border_width = 1, bgcolor = color.new(color.green, 80))
box.new(box.get_left(box_loss), box.get_top(box_loss), box.get_right(box_loss), box.get_bottom(box_loss), border_color = color.gray, border_width = 1, bgcolor = color.new(color.red, 80))
if b_re_entry
b_trade_entered := false
b_stopped_out := false
box.set_left(box_prof, bar_index)
box.set_left(box_loss, bar_index)
i_entry_num += 1
else
b_stopped_out := true
b_trade_entered := true
b_trade_finished := true
box.delete(box_prof)
box.delete(box_loss)
if time_to_trade and not b_trade_finished
if not b_trade_entered
box.set_left(box_prof, bar_index)
box.set_left(box_loss, bar_index)
box.set_right(box_prof, bar_index + i_line_bars)
box.set_right(box_loss, bar_index + i_line_bars)
if not time_to_trade
if trade_time_index - bar_index > i_line_bars
box.set_left(box_prof, bar_index + i_line_bars)
box.set_left(box_loss, bar_index + i_line_bars)
box.set_right(box_prof, bar_index + 2 * i_line_bars)
box.set_right(box_loss, bar_index + 2 * i_line_bars)
else
box.set_left(box_prof, trade_time_index)
box.set_left(box_loss, trade_time_index)
box.set_right(box_prof, trade_time_index + i_line_bars)
box.set_right(box_loss, trade_time_index + i_line_bars)
info_table_color = color.gray
var table debug_table = table.new(position.top_right, 1, 20, bgcolor = info_table_color, frame_width = 2, frame_color = color.black)
deb_txt_size = size.small
if barstate.islast and b_enable_dashboard
s_trade_type = b_long_trade? "Long" : "Short"
table.cell(debug_table, 0, 0, text=" Trade Direction? " + str.tostring(s_trade_type), text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 1, text=" Current Take Profit " + str.tostring(f_tp), text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 2, text=" Current Entry " + str.tostring(f_entry), text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 3, text=" Current Stoploss " + str.tostring(f_sl), text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 4, text=" Current Stoploss " + str.tostring(math.round(f_sl_perc, 3)) + "% ", text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 5, text=" Current Entry Attmept " + str.tostring(i_entry_num + 1), text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 6, text=" Is Trade Entered? " + str.tostring(b_trade_entered), text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 7, text=" Is it time to trade? " + str.tostring(time_to_trade), text_color = color.white, text_size = deb_txt_size)
table.cell(debug_table, 0, 8, text=" Is trade finished? " + str.tostring(b_trade_finished), text_color = color.white, text_size = deb_txt_size)
|
ADX trend reversal/continuation spotter | https://www.tradingview.com/script/W1qI60Ob-ADX-trend-reversal-continuation-spotter/ | Bonny99 | https://www.tradingview.com/u/Bonny99/ | 84 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Bonny99
//@version=5
indicator("ADX trend reversal/continuation spotter" , overlay = false)
[dp , dm , adx] = ta.dmi(14,14)
decrement = input.int(60 , "decrement/increment value")
lookback = input.int(20, "lookback")
pivotHAdx = ta.pivothigh(adx , lookback , 0)
adxDec = (pivotHAdx - ((pivotHAdx/100)*decrement))
pivotLAdx = ta.pivotlow(adx , lookback , 0)
adxIncL = (pivotLAdx + ((pivotLAdx/100)*decrement))
plot(adx, "adx" , color.rgb(0, 30, 255) , 2)
plot(pivotHAdx , "pivot high" , color.rgb(0, 255, 8) , 1)
plot(adxDec , "decreased adx" , color.blue , 1 , display = display.none)
plot(pivotLAdx , "pivot low" , color.rgb(255, 0, 0) , 1)
plot(adxIncL , "increased adx" , color.blue , 1, display = display.none)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//indicator 2
lengthAvgAdx= input.int(50,"sma adx" , 3 , 999)
adxAvg = ta.sma(adx , lengthAvgAdx)
plot(adxAvg , "adx avg" , color.white , 1 , plot.style_line, display = display.none)
hline(40 , "line 40" , color.white , hline.style_dotted , 1 , editable = true )
hline(15 , "line 15" , color.white , hline.style_dotted , 1 , editable = true )
|
Multi-Symbol Cross Indicator Template - Unleash Your Potential! | https://www.tradingview.com/script/D6YG33n7-Multi-Symbol-Cross-Indicator-Template-Unleash-Your-Potential/ | Autoview_ext | https://www.tradingview.com/u/Autoview_ext/ | 48 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Autoview_ext
// Your mind is your edge. When you believe that money comes easily and frequently, it does. Say it loud!
//@version=5
indicator("Multi-Symbol Golden Cross Alert", overlay=true, shorttitle="MS GC Alert")
// Input for short-term and long-term moving averages
shortTermMA = input.int(50, title="Short-term Moving Average", minval=1)
longTermMA = input.int(200, title="Long-term Moving Average", minval=1)
ma1 = ta.sma(close, shortTermMA)
ma2 = ta.sma(close, longTermMA)
plot(ma1, color=color.orange)
plot(ma2, color=color.white)
// Function to securely and simply call `security()` so that it never repaints and never looks ahead.
f_secureSecurity(_symbol, _res, _src) => request.security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)
resolution = input.timeframe('D', "Resolution")
// Calculate the moving averages and detect golden crosses for each symbol
calcGoldenCross(symbol) =>
closePrice = f_secureSecurity(symbol, resolution, close)
shortMA = ta.sma(closePrice, shortTermMA)
longMA = ta.sma(closePrice, longTermMA)
gc_cross = ta.crossover(shortMA, longMA)
[shortMA, longMA, gc_cross]
calcDeathCross(symbol) =>
closePrice = f_secureSecurity(symbol, resolution, close)
shortMA = ta.sma(closePrice, shortTermMA)
longMA = ta.sma(closePrice, longTermMA)
d_cross = ta.crossunder(shortMA, longMA)
[shortMA, longMA, d_cross]
exchange = input.string("BINANCE", title="Exchange")
symbol1 = input.string("APEBUSD", title="Symbol")
symbol2 = input.string("BTCBUSD", title="Symbol")
symbol3 = input.string("ETHBUSD", title="Symbol")
symbol4 = input.string("BNBBUSD", title="Symbol")
symbol5 = input.string("BCHBUSD", title="Symbol")
symbol6 = input.string("XRPBUSD", title="Symbol")
symbol7 = input.string("EOSBUSD", title="Symbol")
symbol8 = input.string("LTCBUSD", title="Symbol")
symbol9 = input.string("TRXBUSD", title="Symbol")
symbol10 = input.string("ETCBUSD", title="Symbol")
symbol11 = input.string("LINKBUSD", title="Symbol")
symbol12 = input.string("ADABUSD", title="Symbol")
symbol13 = input.string("XMRBUSD", title="Symbol")
symbol14 = input.string("DASHBUSD", title="Symbol")
symbol15 = input.string("ZECBUSD", title="Symbol")
symbol16 = input.string("XTZBUSD", title="Symbol")
// Declare the moving averages and golden crosses for each symbol
[APE_shortMA, APE_longMA, APE_gc_cross] = calcGoldenCross(exchange + ":" + symbol1)
[BTC_shortMA, BTC_longMA, BTC_gc_cross] = calcGoldenCross(exchange + ":" + symbol2)
[ETH_shortMA, ETH_longMA, ETH_gc_cross] = calcGoldenCross(exchange + ":" + symbol3)
[BNB_shortMA, BNB_longMA, BNB_gc_cross] = calcGoldenCross(exchange + ":" + symbol4)
[BCH_shortMA, BCH_longMA, BCH_gc_cross] = calcGoldenCross(exchange + ":" + symbol5)
[XRP_shortMA, XRP_longMA, XRP_gc_cross] = calcGoldenCross(exchange + ":" + symbol6)
[EOS_shortMA, EOS_longMA, EOS_gc_cross] = calcGoldenCross(exchange + ":" + symbol7)
[LTC_shortMA, LTC_longMA, LTC_gc_cross] = calcGoldenCross(exchange + ":" + symbol8)
[TRX_shortMA, TRX_longMA, TRX_gc_cross] = calcGoldenCross(exchange + ":" + symbol9)
[ETC_shortMA, ETC_longMA, ETC_gc_cross] = calcGoldenCross(exchange + ":" + symbol10)
[LINK_shortMA, LINK_longMA, LINK_gc_cross] = calcGoldenCross(exchange + ":" + symbol11)
[ADA_shortMA, ADA_longMA, ADA_gc_cross] = calcGoldenCross(exchange + ":" + symbol12)
[XMR_shortMA, XMR_longMA, XMR_gc_cross] = calcGoldenCross(exchange + ":" + symbol13)
[DASH_shortMA, DASH_longMA, DASH_gc_cross] = calcGoldenCross(exchange + ":" + symbol14)
[ZEC_shortMA, ZEC_longMA, ZEC_gc_cross] = calcGoldenCross(exchange + ":" + symbol15)
[XTZ_shortMA, XTZ_longMA, XTZ_gc_cross] = calcGoldenCross(exchange + ":" + symbol16)
// Declare the moving averages and golden crosses for each symbol
[APE_shortMAd, APE_longMAd, APE_d_cross] = calcDeathCross(exchange + ":" + symbol1)
[BTC_shortMAd, BTC_longMAd, BTC_d_cross] = calcDeathCross(exchange + ":" + symbol2)
[ETH_shortMAd, ETH_longMAd, ETH_d_cross] = calcDeathCross(exchange + ":" + symbol3)
[BNB_shortMAd, BNB_longMAd, BNB_d_cross] = calcDeathCross(exchange + ":" + symbol4)
[BCH_shortMAd, BCH_longMAd, BCH_d_cross] = calcDeathCross(exchange + ":" + symbol5)
[XRP_shortMAd, XRP_longMAd, XRP_d_cross] = calcDeathCross(exchange + ":" + symbol6)
[EOS_shortMAd, EOS_longMAd, EOS_d_cross] = calcDeathCross(exchange + ":" + symbol7)
[LTC_shortMAd, LTC_longMAd, LTC_d_cross] = calcDeathCross(exchange + ":" + symbol8)
[TRX_shortMAd, TRX_longMAd, TRX_d_cross] = calcDeathCross(exchange + ":" + symbol9)
[ETC_shortMAd, ETC_longMAd, ETC_d_cross] = calcDeathCross(exchange + ":" + symbol10)
[LINK_shortMAd, LINK_longMAd, LINK_d_cross] = calcDeathCross(exchange + ":" + symbol11)
[ADA_shortMAd, ADA_longMAd, ADA_d_cross] = calcDeathCross(exchange + ":" + symbol12)
[XMR_shortMAd, XMR_longMAd, XMR_d_cross] = calcDeathCross(exchange + ":" + symbol13)
[DASH_shortMAd, DASH_longMAd, DASH_d_cross] = calcDeathCross(exchange + ":" + symbol14)
[ZEC_shortMAd, ZEC_longMAd, ZEC_d_cross] = calcDeathCross(exchange + ":" + symbol15)
[XTZ_shortMAd, XTZ_longMAd, XTZ_d_cross] = calcDeathCross(exchange + ":" + symbol16)
useAutoview = input.bool(true, "Using Autoview to place the trades live on the exchange?")
qty = input.float(50.50, "Amount to buy with")
// Alert if a golden cross occurs for each symbol
if APE_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol1 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("APE Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="APE Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if BTC_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol2 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("BTC Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="BTC Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if ETH_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol3 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("ETH Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="ETH Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if BNB_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol4 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("BNB Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="BNB Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if BCH_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol5 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("BCH Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="BCH Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if XRP_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol6 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("XRP Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="XRP Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if EOS_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol7 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("EOS Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="EOS Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if LTC_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol8 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("LTC Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="LTC Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if TRX_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol9 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("TRX Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="TRX Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if ETC_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol10 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("ETC Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="ETC Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if LINK_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol11 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("LINK Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="LINK Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if ADA_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol12 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("ADA Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="ADA Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if XMR_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol13 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("XMR Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="XMR Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if DASH_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol14 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("DASH Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="DASH Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if ZEC_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol15 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("ZEC Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="ZEC Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if XTZ_gc_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol6 + "b=buy q=" + str.tostring(qty) + " u=currency t=market", alert.freq_once_per_bar)
else
alert("XTZ Golden Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=high, text="XTZ Golden Cross", color=color.green, textcolor=color.white, style=label.style_label_down)
if APE_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol1 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("APE Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="APE Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if BTC_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol2 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("BTC Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="BTC Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if ETH_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol3 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("ETH Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="ETH Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if BNB_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol4 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("BNB Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="BNB Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if BCH_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol5 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("BCH Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="BCH Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if XRP_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol6 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("XRP Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="XRP Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if EOS_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol7 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("EOS Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="EOS Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if LTC_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol8 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("LTC Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="LTC Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if TRX_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol9 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("TRX Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="TRX Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if ETC_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol10 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("ETC Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="ETC Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if LINK_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol11 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("LINK Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="LINK Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if ADA_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol12 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("ADA Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="ADA Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if XMR_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol13 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("XMR Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="XMR Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if DASH_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol14 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("DASH Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="DASH Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if ZEC_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol15 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("ZEC Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="ZEC Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
if XTZ_d_cross
if useAutoview
alert("e=" + exchange + " s=" + symbol16 + "b=sell t=market", alert.freq_once_per_bar)
else
alert("XTZ Death Cross", alert.freq_once_per_bar)
label.new(x=bar_index, y=low, text="XTZ Death Cross", color=color.red, textcolor=color.white, style=label.style_label_up)
// Plot the moving averages and golden crosses for each symbol
// plot(APE_shortMA, title="APE Short-term MA", color=color.blue, linewidth=1)
// plot(APE_longMA, title="APE Long-term MA", color=color.red, linewidth=1)
// plotshape(APE_gc_cross, title="APE Golden Cross", style=shape.labeldown, location=location.abovebar,
|
ICT Market Structure and OTE Zone | https://www.tradingview.com/script/hTOhzi4J-ICT-Market-Structure-and-OTE-Zone/ | xflorex | https://www.tradingview.com/u/xflorex/ | 248 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© xflorex
//@version=4
study("ICT Market Structure and OTE Zone", shorttitle="ICT MS & OTE", overlay=true)
// Parameters
fib_lower = input(0.618, title="Fibonacci Lower Level", type=input.float)
fib_upper = input(0.786, title="Fibonacci Upper Level", type=input.float)
// Calculate Daily Highs and Lows
daily_high = security(syminfo.tickerid, "D", high[1])
daily_low = security(syminfo.tickerid, "D", low[1])
// Define OTE Zone
ote_upper = daily_high - (daily_high - daily_low) * fib_lower
ote_lower = daily_high - (daily_high - daily_low) * fib_upper
// Plot Daily Highs, Lows, and OTE Zone
line.new(x1=bar_index[1], y1=daily_high, x2=bar_index, y2=daily_high, color=color.red, width=1, extend=extend.right)
line.new(x1=bar_index[1], y1=daily_low, x2=bar_index, y2=daily_low, color=color.green, width=1, extend=extend.right)
ote_upper_plot = plot(ote_upper, color=color.gray, linewidth=2, title="OTE Upper", trackprice=false)
ote_lower_plot = plot(ote_lower, color=color.gray, linewidth=2, title="OTE Lower", trackprice=false)
fill(ote_upper_plot, ote_lower_plot, color=color.silver, transp=80)
// Notes
// The red line represents the daily high, while the green line represents the daily low.
// The gray area represents the optimal trade entry (OTE) zone based on Fibonacci retracement levels.
|
Candle % locator | https://www.tradingview.com/script/BZol7nrX-Candle-locator/ | jonarod | https://www.tradingview.com/u/jonarod/ | 10 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© jonarod
//@version=5
indicator("Candle % locator", overlay = true)
min_perc_move = input.float(20.0, "Minium %")/100
bar_range = (math.abs(open[0] - close[0]) / open[0])
// plot(bar_range)
plotshape(bar_range >= min_perc_move, "plot move", style=shape.triangleup, color=color.blue, location=location.belowbar, size=size.small)
|
graham's formula | https://www.tradingview.com/script/BNvOLW8x/ | crovisgrind | https://www.tradingview.com/u/crovisgrind/ | 16 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© crovisgrind
//@version=5
indicator(title="graham's formula", overlay=true)
symbol = syminfo.tickerid
EPS = request.financial(symbol, "EARNINGS_PER_SHARE_BASIC", "TTM")
BVPS = request.financial(symbol, "BOOK_VALUE_PER_SHARE", "FQ")
formula = math.sqrt(22.5 * EPS * BVPS)
plot(formula)
p= plot(close)
p2 = plot(formula)
fill(p,p2, color=color.lime)
var tabela = table.new(position = position.middle_left, columns = 2, rows = 2, bgcolor = color.rgb(211, 154, 47), border_width = 1, border_color= color.black, frame_color=color.black)
table.set_frame_color(tabela, frame_color= color.black)
EPSA=EPS
BVPSA=BVPS
if barstate.islast
table.cell(table_id = tabela, column = 0, row = 0, text = "EPS",bgcolor=color.rgb(89, 218, 205))
table.cell(table_id = tabela, column = 0, row = 1, text = "BVPS " , bgcolor=color.rgb(89, 218, 205))
table.cell(table_id = tabela, column = 1, row = 0, text=str.tostring(EPSA))
table.cell(table_id = tabela, column = 1, row = 1, text=str.tostring(BVPSA))
|
Linear Regress on Price And Volume | https://www.tradingview.com/script/y7HBegCO-Linear-Regress-on-Price-And-Volume/ | stocktechbot | https://www.tradingview.com/u/stocktechbot/ | 36 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© stocktechbot
//@version=5
indicator("Linear Regress on Price And Volume",shorttitle = "Linear Predict", overlay=true)
// Input variable
vol = volume
// Function to calculate linear regression
linregs(y, x, len) =>
ybar = math.sum(y, len)/len
xbar = math.sum(x, len)/len
b = math.sum((x - xbar)*(y - ybar),len)/math.sum((x - xbar)*(x - xbar),len)
a = ybar - b*xbar
[a, b]
// Historical stock price data
price = close
// Length of linear regression
len = input(defval = 21, title = 'Lookback')
// Calculate linear regression for stock price based on volume
[a, b] = linregs(price, vol, len)
// Predicted stock price based on volume
predicted_price = a + b*vol
// Plot predicted stock price
plot(predicted_price, color=color.rgb(223, 84, 200), linewidth=2, title="Predicted Stock Price") |
Futures/Spot Ratio | https://www.tradingview.com/script/IwU2bWON-Futures-Spot-Ratio/ | faytterro | https://www.tradingview.com/u/faytterro/ | 109 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© faytterro
//@version=5
indicator("Futures/Spot Ratio", max_lines_count = 500)
len=input.int(10, step = 1, minval = 1, maxval = 200, title = "Colorful Regression Length")
perp = input.symbol("BTCUSDTPERP", title = "futures")
spt = input.symbol("BTCUSDT", title = "spot")
float futures = request.security(perp, timeframe = "", expression = close)
float spot = request.security(spt, timeframe = "", expression = close)
r = futures/spot-1
a = ta.cum(math.abs(r))/bar_index
while a<1
a:= a*10
r:= r*10
src = r
fd(x,y) =>
100-100/(math.pow(1+1/y,x)+1)
src := fd(src,a)
//plot(a)//, display = display.none)
plot(src, color = color.white, style = plot.style_circles)
line1=hline(50)
hline(100)
hline(0)
p2= plot(50, color=color.rgb(1,1,1,100), display = display.none)
cr(x, y) =>
z = 0.0
weight = 0.0
for i = 0 to y-1
z:=z + x[i]*((y-1)/2+1-math.abs(i-(y-1)/2))
z/(((y+1)/2)*(y+1)/2)
cr= cr(src,2*len-1)
width=input.int(1, title="linewidth", minval=1)
crm=ta.change(cr)
///////////
dx(x) =>
x-x[1]
pm = dx(cr)
/////////////////////////
y = math.abs(pm)
n = bar_index
m = math.min(math.max(n-2*len+2,1),500)
t = ta.wma(y,m)//ta.cum(y)/n
f = fd(pm,t/2)
f:= f*2.5
p1=plot(cr, color= color.rgb(math.min(510-2*f,255),math.min(2*f,255),0), linewidth=width,offset=-len+1, display = display.pane)
fill(p1,p2, color= cr>50? color.rgb(0, 255, 8, 80) : color.rgb(255, 82, 82, 80))
/////////////////////////
// extrapolation
diz = array.new_float(501)
var lin=array.new_line()
var lin2=array.new_line()
if barstate.islast
for k=0 to len-1
sum=0.0
for i=0 to 2*len-2-k
sum +=(len-math.abs(len-1-k-i))*src[i]/(len*len-k*(k+1)/2)
array.set(diz,k, sum )
for i=0 to (len-1)
array.push(lin, line.new(na, na, na, na))
fp= 2.5*fd(array.get(diz,i+1)-array.get(diz,i),t/2)
line.set_color(array.get(lin,i),color.blue)//array.get(diz,i+1)>=array.get(diz,i)? #35cf02 : #cf0202)
line.set_xy1(array.get(lin,i), bar_index[len]+i+1, array.get(diz,i))
line.set_xy2(array.get(lin,i), bar_index[len]+i+2,array.get(diz,i+1))
line.set_color(array.get(lin,i), color.rgb(math.min(510-2*fp,255),math.min(2*fp,255),0))
line.set_width(array.get(lin,i),width)
array.push(lin2, line.new(na, na, na, na))
line.set_xy1(array.get(lin2,i), bar_index[len]+i+1, 50)
line.set_xy2(array.get(lin2,i), bar_index[len]+i+2,50)
line.set_color(array.get(lin2,i), color.rgb(0,0,0,100))
linefill.new(array.get(lin2,i),array.get(lin,i), array.get(diz,i)>50? color.rgb(0, 255, 8,80) : color.rgb(255, 82, 82, 80))
fp= 2.5*fd(array.get(diz,1)-array.get(diz,0),t/2)
plot(ta.wma(src,len), color = color.rgb(math.min(510-2*fp,255),math.min(2*fp,255),0,100)) |
Liquidity Candles with Prev Day High/Low and Midnight Open | https://www.tradingview.com/script/TUBMfh09-Liquidity-Candles-with-Prev-Day-High-Low-and-Midnight-Open/ | theDOGEguy1 | https://www.tradingview.com/u/theDOGEguy1/ | 111 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© theDOGEguy1
//@version=4
study(title="Liquidity Candles with Prev Day High/Low and Midnight Open", overlay=true)
// Inputs
lookback = input(20, title="Lookback Period")
// Calculate LH and HL
lh = high >= highest(high[1], lookback) and high > high[lookback]
hl = low <= lowest(low[1], lookback) and low < low[lookback]
// Calculate Bullish and Bearish Engulfing Candles
eng_bull = (close[1] > open[1]) and (close < open) and ((open - close[1]) / (close - open) > 0.6)
eng_bear = (close[1] < open[1]) and (close > open) and ((close - open[1]) / (open - close) > 0.6)
// Calculate Previous Day's High, Low, and Midnight Open
prev_high = security(syminfo.tickerid, 'D', high[1], lookahead=true)
prev_low = security(syminfo.tickerid, 'D', low[1], lookahead=true)
midnight_open = security(syminfo.tickerid, 'D', open, lookahead=true)
// Color the Candles
candle_color = lh or hl ? color.yellow : na
candle_color := eng_bull ? color.green : candle_color
candle_color := eng_bear ? color.red : candle_color
plotcandle(open, high, low, close, color=candle_color)
// Plot Previous Day's High, Low, and Midnight Open
plot(prev_high, title="Prev Day High", style=plot.style_linebr, color=color.white)
plot(prev_low, title="Prev Day Low", style=plot.style_linebr, color=color.white)
plot(midnight_open, title="Midnight Open", style=plot.style_linebr, color=color.purple)
|
Stock Intrinsic Value & MOS Indicator | https://www.tradingview.com/script/PinBA9PY-Stock-Intrinsic-Value-MOS-Indicator/ | ChrisTradeOfficial | https://www.tradingview.com/u/ChrisTradeOfficial/ | 36 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© ChrisTradeOfficial
//@version=5
indicator("Stock Intrinsic Value & MOS Indicator", overlay=true)
// Define the inputs
pe_ratio = input(15, title="P/E Ratio")
eps = input(3, title="Earnings per Share")
div_yield = input(2, title="Dividend Yield")
margin_of_safety = input(30, title="Margin of Safety (%)")
// Calculate the intrinsic value
intrinsic_value = eps * (pe_ratio + (2 * (div_yield / 100)))
margin_of_safety_value = intrinsic_value * (1 - (margin_of_safety / 100))
// Plot the intrinsic value and margin of safety value
plot(intrinsic_value, color=color.blue, linewidth=2, title="Intrinsic Value")
plot(margin_of_safety_value, color=color.green, linewidth=2, title="Margin of Safety") |
ValueView | https://www.tradingview.com/script/LQJ693Dm-ValueView/ | fetthelm | https://www.tradingview.com/u/fetthelm/ | 24 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© fetthelm
// =======================================================================
// This indicator shows a summary of financial data of the selected stock,
// over a selectable period of fiscal years
// =======================================================================
//@version=5
indicator("ValueView",overlay=true)
// -----------------------------------------
// inputs for indicator
//
var metricGrp = " === Select Metric to display === "
var fontSizeGrp = " === Select Font size for table === "
period = input.int(defval=5, title="Fiscal Years") // number of fiscal periods to evaluate
showPE = input.bool(true,"P/E","Price to earnings ratio","r1",metricGrp)
showPS = input.bool(true,"P/S","Price to sales ratio","r1",metricGrp)
showPFCF = input.bool(true,"P/FCF","price to FreeCashFlow ratio","r1",metricGrp)
showEY = input.bool(true,"Earnigs Yield","","r2",metricGrp)
showSALES = input.bool(true,"Sales","","r2",metricGrp)
showNI = input.bool(true,"Net income","","r3",metricGrp)
showNI2Sales = input.bool(true,"Net income / Sales","","r3",metricGrp)
showLTD = input.bool(true,"Long term debt","","r4",metricGrp)
showLTD2FCF = input.bool(true,"LTD / FCF","Long term debt / Free cash flow","r4",metricGrp)
showShares = input.bool(true,"Shares outstanding","Number of shares outstanding. Decreasing number is a positive sign for investors","r5",metricGrp)
showFCF = input.bool(true,"Free Cash Flow","","r5",metricGrp)
fs = input.string(size.auto,"Table Font Size",[size.auto,size.tiny,size.small,size.normal,size.large,size.huge ],"",fontSizeGrp)
// ===========================================
// Display array cells in table columns
//
// Parameters:
// T : reference to the table
// ar : array containing the data to display
// N : number of columns to display
// R : Number of rows in table
// C : Start column for display
// TS : Text size
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
arr2col(T,ar,N,R,C,TS) =>
var string s =""
for i = 1 to N
val = array.get(ar,array.size(ar)-i)
s := str.tostring( val,"####.##")
var cc = color.yellow
if val < 0
cc := color.orange
else
cc := color.yellow
table.cell(table_id=T, column=C-1+i, row=R, text=s, bgcolor=cc,text_halign=text.align_right,text_size=TS )
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// =======================================================================================================================
// the table containing the data to visualize
//
var T_VV = table.new(position.top_right,period+2,14,bgcolor = color.yellow, border_width = 1,border_color=color.gray)
var float marker = 0
// -------------------------------------------------------------
// arrays containing data to evaluate, one entry per fiscal year
//
var float[] p2e = array.new_float(0)
var float[] p2s = array.new_float(0)
var float[] p2fcf = array.new_float(0)
var float[] fcf = array.new_float(0)
var float[] tso = array.new_float(0)
var float[] n2s = array.new_float(0)
var float[] tr = array.new_float(0)
var float[] p = array.new_float(0)
var float[] y = array.new_float(0)
var float[] ey = array.new_float(0)
var float[] ni = array.new_float(0)
var float[] ltd = array.new_float(0)
var float[] ltd2fcf = array.new_float(0)
P = 0.5 * (open + close) // evaluate mean value of close,open price
LTD = request.financial(syminfo.tickerid, "LONG_TERM_DEBT", "FY")
FCF = request.financial(syminfo.tickerid, "FREE_CASH_FLOW", "FY")
FCFttm = request.financial(syminfo.tickerid, "FREE_CASH_FLOW", "TTM")
TSO = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FY")
TR = request.financial(syminfo.tickerid, "TOTAL_REVENUE", "FY")
TRttm = request.financial(syminfo.tickerid, "TOTAL_REVENUE", "TTM")
ROIC = request.financial(syminfo.tickerid, "RETURN_ON_INVESTED_CAPITAL", "FY")
NetIncome = request.financial(syminfo.tickerid, "NET_INCOME", "FY")
NetIncomeTTM = request.financial(syminfo.tickerid, "NET_INCOME", "TTM")
EPS = request.financial(syminfo.tickerid, "EARNINGS_PER_SHARE", "FY")
EPSttm = request.financial(syminfo.tickerid, "EARNINGS_PER_SHARE", "TTM")
EarningsYield = (EPS / P) * 100
EarningsYieldTTM = (EPSttm / P) * 100
PriceEarningsRatio = P / EPS
PriceEarningsRatioTTM = P / EPSttm
PriceSalesRatio = P / ( TR / TSO)
// ------------------------------------
// memorize data if fiscal year changes
//
if(marker != EPS)
marker := EPS
array.push(p2e,PriceEarningsRatio)
array.push(p2s,PriceSalesRatio)
array.push(p2fcf,P/FCF*TSO)
array.push(fcf,FCF*0.000001)
array.push(tso,TSO*0.000001)
array.push(n2s,NetIncome/TR)
array.push(tr,TR * 0.000001)
array.push(p,P)
array.push(y,year)
array.push(ey,EarningsYield)
array.push(ni,NetIncome*1.0e-6)
array.push(ltd2fcf,LTD/FCF)
array.push(ltd,LTD*1.0e-6)
// --------------------------------------------
// render Table only when last bar is evaluated
// and time frame is greater or equal "DAY"
//
if timeframe.in_seconds() < timeframe.in_seconds("D")
table.cell(table_id = T_VV, column = 0, row = 0, text = "ValueView: Timeframe must be greater or equal DAY", text_color=color.white, bgcolor = color.red, text_halign=text.align_left, text_size=size.large )
else if barstate.islast
var numY = array.size(y)
var numCols = period + 1
var k = 0
array.push(p2e,PriceEarningsRatioTTM)
array.push(p2s,PriceEarningsRatio)
array.push(p2fcf,P/FCF*TSO)
array.push(fcf,FCFttm*0.000001)
array.push(tso,TSO*0.000001)
array.push(n2s,NetIncomeTTM/TRttm)
array.push(tr,TRttm * 0.000001)
array.push(p,P)
array.push(y,year)
array.push(ey,EarningsYieldTTM)
array.push(ni,NetIncomeTTM*1.0e-6)
array.push(ltd2fcf,LTD/FCFttm)
array.push(ltd,LTD*1.0e-6)
if numY <= period
numCols := numY
table.cell(table_id = T_VV, column = 0, row = k, text = "Metric", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,y,numCols,k,1,TS=fs)
table.cell(table_id = T_VV, column = 1, row = k, text = "TTM", text_halign=text.align_center, text_size=fs )
k := k+1
table.cell(table_id = T_VV, column = 0, row = k, text = "Price (FY end)", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,p,numCols,k,1,TS=fs)
k := k+1
if showPE
table.cell(table_id = T_VV, column = 0, row = k, text = "P / E", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,p2e,numCols,k,1,TS=fs)
k := k+1
if showPS
table.cell(table_id = T_VV, column = 0, row = k, text = "P / S", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,p2s,numCols,k,1,TS=fs)
k := k+1
if showPFCF
table.cell(table_id = T_VV, column = 0, row = k, text = "P / FCF", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,p2fcf,numCols,k,1,TS=fs)
k := k+1
if showEY
table.cell(table_id = T_VV, column = 0, row = k, text = "Earnings yield (%)", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,ey,numCols,k,1,TS=fs)
k := k+1
if showSALES
table.cell(table_id = T_VV, column = 0, row = k, text = "Sales (M)", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,tr,numCols,k,1,TS=fs)
k := k+1
if showNI
table.cell(table_id = T_VV, column = 0, row = k, text = "Net Income (M)", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,ni,numCols,k,1,TS=fs)
k := k+1
if showNI2Sales
table.cell(table_id = T_VV, column = 0, row = k, text = "Net Income/Sales", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,n2s,numCols,k,1,TS=fs)
k := k+1
if showLTD2FCF
table.cell(table_id = T_VV, column = 0, row = k, text = "Debt / FCF", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,ltd2fcf,numCols,k,1,TS=fs)
k := k+1
if showLTD
table.cell(table_id = T_VV, column = 0, row = k, text = "Long Term Debt (M)", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,ltd,numCols,k,1,TS=fs)
k := k+1
if showFCF
table.cell(table_id = T_VV, column = 0, row = k, text = "Free Cash Flow (M)", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,fcf,numCols,k,1,TS=fs)
k := k+1
if showShares
table.cell(table_id = T_VV, column = 0, row = k, text = "Shares out (M)", text_halign=text.align_left, text_size=fs )
arr2col(T_VV,tso,numCols,k,1,TS=fs)
k := k+1
|
Rainbow Collection - Violet | https://www.tradingview.com/script/1WjQ50St-Rainbow-Collection-Violet/ | Sofien-Kaabar | https://www.tradingview.com/u/Sofien-Kaabar/ | 88 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Sofien-Kaabar
//@version=5
indicator("Rainbow Collection - Violet", overlay = true)
psar = ta.sar(0.01, 0.02, 0.2)
buy = close > ta.hma(close, 20) and close[1] < ta.hma(close, 20)[1] and close[2] < ta.hma(close, 20)[2] and close[3] < ta.hma(close, 20)[3] and close[5] < ta.hma(close, 20)[5] and close[8] < ta.hma(close, 20)[8] and close[13] < ta.hma(close, 20)[13] and close[21] < ta.hma(close, 20)[21]
sell = close < ta.hma(close, 20) and close[1] > ta.hma(close, 20)[1] and close[2] > ta.hma(close, 20)[2] and close[3] > ta.hma(close, 20)[3] and close[5] > ta.hma(close, 20)[5] and close[8] > ta.hma(close, 20)[8] and close[13] > ta.hma(close, 20)[13] and close[21] > ta.hma(close, 20)[21]
plotshape(buy and buy[1] == 0, style = shape.triangleup, color = color.rgb(127, 0, 255), location = location.belowbar, size = size.small)
plotshape(sell and sell[1] == 0, style = shape.triangledown, color = color.rgb(127, 0, 255), location = location.abovebar, size = size.small)
|
Volatility Percentile (H-LINES) | https://www.tradingview.com/script/LVj1PgGP-Volatility-Percentile-H-LINES/ | D_dot_ZK | https://www.tradingview.com/u/D_dot_ZK/ | 18 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© HeWhoMustNotBeNamed (THE OG)
// __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
// / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
// $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
// $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
// $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
// $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
// $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
// $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
// $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
//
// ^ THANKS FOR THE SCRIPT MATE
// ALL CREDIT GOES TO HeWhoMustNotBeNamed
// VISUAL CHANGES DONE BY @D_dot_ZK (H-LINES RELEASE)
//@version=5
indicator("Volatility Percentile (H-LINES)", overlay=false)
import HeWhoMustNotBeNamed/enhanced_ta/10 as eta
amatype = input.string("linreg", title="Type", group="ATR", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"])
amalength = input.int(20, title="Length", group="ATR")
roundingType = input.string("round", title="Rounding Type", group="ATR", options=["round", "floor", "ceil"])
precision = input.int(2, group="ATR", minval=0, maxval=2)
displayLowerPercentile = input.bool(false, "Inverse", group="Display", inline="b")
displayStatsTable = input.bool(true, "Stats", group="Display", inline="b")
displayDetailedStats = input.bool(false, 'Detailed Stats', group="Display", inline="b")
textSize = input.string(size.small, title='Text Size', options=[size.tiny, size.small, size.normal, size.large, size.huge], group='Table', inline='text')
headerColor = input.color(color.maroon, title='Header', group='Table', inline='GC')
neutralColor = input.color(#FFEEBB, title='Cell', group='Table', inline='GC')
presentColor = input.color(color.aqua, title='Present', group='Table', inline='GC')
useStartTime = input.bool(true, title='Start Time', group='Window', inline="start")
startTime = input.time(defval=timestamp('01 Jan 2023 00:00 +0000'), title='', group='Window', inline='start')
useEndTime = input.bool(false, title='End Timeβ', group='Window', inline="end")
endTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), title='', group='Window', inline='end')
inDateRange = (not useStartTime or time >= startTime) and (not useEndTime or time <= endTime)
precisionMultiplier = int(math.pow(10, precision))
var pArray = array.new_int(100*precisionMultiplier, 0)
float percentile = na
color cellColor = color.blue
if(inDateRange)
var dateStart = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth)
dateEnd = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth)
atrpercent = eta.atrpercent(amatype, amalength)
index = roundingType == "round"? math.round(atrpercent*precisionMultiplier) :
roundingType == "floor"? math.floor(atrpercent*precisionMultiplier) : math.ceil(atrpercent*precisionMultiplier)
if(index > 0)
array.set(pArray, index, array.get(pArray, index)+1)
upperPortion = array.slice(pArray, index+1, array.size(pArray))
lowerPortion = array.slice(pArray, 0, index)
total = array.sum(pArray)
upper = array.sum(upperPortion)
lower = array.sum(lowerPortion)
same = array.get(pArray, index)
upperPercentile = (total-upper)*100/total
lowerPercentile = (total-lower)*100/total
cumulativeCount = 0
medianIndex = 0
maxIndex = 0
for i=0 to array.size(pArray)-1
cumulativeCount += array.get(pArray, i)
if(cumulativeCount < total/2)
medianIndex := i+1
if(cumulativeCount == total)
maxIndex := i
break
medianAtrPercent = medianIndex/precisionMultiplier
maxAtrPercent = maxIndex/precisionMultiplier
medianAndMax = array.join(array.from(str.tostring(medianAtrPercent, format.percent), str.tostring(maxAtrPercent, format.percent)), ' / ')
displayTable = table.new(position=position.bottom_right, columns=2, rows=3, border_width=1)
cellColor := color.from_gradient(upperPercentile, 0, 100, displayLowerPercentile? color.red : color.green, displayLowerPercentile ? color.green : color.red)
percentile := displayLowerPercentile? lowerPercentile : upperPercentile
table.cell(table_id=displayTable, column=0, row=0, text='ATR Percent', bgcolor=color.teal, text_color=color.white, text_size=textSize)
table.cell(table_id=displayTable, column=1, row=0, text=str.tostring(atrpercent, format.percent), bgcolor=cellColor, text_color=color.white, text_size=textSize)
table.cell(table_id=displayTable, column=0, row=1, text='Median/Max', bgcolor=color.teal, text_color=color.white, text_size=textSize)
table.cell(table_id=displayTable, column=1, row=1, text=medianAndMax, bgcolor=cellColor, text_color=color.white, text_size=textSize)
table.cell(table_id=displayTable, column=0, row=2, text='Percentile', bgcolor=color.teal, text_color=color.white, text_size=textSize)
table.cell(table_id=displayTable, column=1, row=2, text=str.tostring(percentile, format.percent), bgcolor=cellColor, text_color=color.white, text_size=textSize)
if(displayDetailedStats and total!=0)
detailedTable = table.new(position=position.middle_center, columns=21, rows=10, border_width=1)
table.cell(table_id=detailedTable, column=0, row=0, text=dateStart + ' to ' + dateEnd, bgcolor=color.teal, text_color=color.white, text_size=textSize)
table.cell(table_id=detailedTable, column=0, row=1, text=syminfo.tickerid, bgcolor=color.teal, text_color=color.white, text_size=textSize)
headerArray = array.new_string()
valueArray = array.new_string()
cellColorArray = array.new_color()
for i=0 to 99
end = math.min((i+1)*precisionMultiplier, array.size(pArray))
slice = array.slice(pArray, 0, end)
count = array.sum(slice)
row = math.floor(i/10)
col = (i%10) * 2 + 1
if (count != 0)
percent = count*100/total
headerText = '0 - ' + str.tostring(end/precisionMultiplier)
cColor = math.floor(index/precisionMultiplier) == i ? presentColor : neutralColor
array.push(headerArray, headerText)
array.push(valueArray, str.tostring(percent, format.percent))
array.push(cellColorArray, cColor)
if(count == total)
break
rowCol = math.ceil(math.sqrt(array.size(headerArray)))
counter = 0
for i=0 to rowCol-1
for j=0 to rowCol-1
row = i
col = j*2 + 1
if(counter >= array.size(headerArray))
break
table.cell(table_id=detailedTable, column=col, row=row, text=array.get(headerArray, counter), bgcolor=headerColor, text_color=color.white, text_size=textSize)
table.cell(table_id=detailedTable, column=col + 1, row=row, text=array.get(valueArray, counter), bgcolor=array.get(cellColorArray, counter), text_color=color.black, text_size=textSize)
counter += 1
plot(displayDetailedStats? na : percentile, title="Historical Volatility Percentile", color=cellColor)
// CRUSADE FUNK RIGHT HERE BABY
hline(70, 'upperSwingline', color=#000000, linestyle=hline.style_solid, linewidth=1)
hline(30, 'lowerSwingline', color=#000000, linestyle=hline.style_solid, linewidth=1)
|
RS Stage Analysis | https://www.tradingview.com/script/EoRtw6uz-RS-Stage-Analysis/ | jadeja_rajdeep | https://www.tradingview.com/u/jadeja_rajdeep/ | 102 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© jadeja_rajdeep
//@version=5
indicator("RS Stage Analysis",precision = 5,overlay = true,max_bars_back = 1260)
autodraw_lookback_period=input.int(defval = 504,title = "No of days look back for auto draw resistance & support",minval = 63,maxval = 1260,step = 21)
gap_between_2_lines=input.int(defval = 15,title = "Days gap between 2 same stage lines",minval = 5,maxval =63,step = 1)
display_stage_3_support_line = input.bool(defval = true,title = "Stage 3 Support Line",group = "lines")
display_stage_1_resistance_line = input.bool(defval = false,title = "Stage 1 Resistance Line",group = "lines")
display_stage_1_proper_resistance_line = input.bool(defval = true,title = "Proper Stage 1 Resistance Line",group = "lines")
display_stage_2_resistance_line = input.bool(defval = true,title = "Stage 2 Resistance Line",group = "lines")
display_stage_2_proper_resistance_line = input.bool(defval = true,title = "Proper Stage 2 Resistance Line",group = "lines")
color_stage_3_support_line=input.color(defval = color.green,title = "Stage 3 Support Line Color",group = "colors")
color_stage_1_resistance_line=input.color(defval = color.aqua,title = "Stage 1 Resistance Line Color",group = "colors")
color_stage_1_proper_resistance_line=input.color(defval = color.navy,title = "Proper Stage 1 Resistance Line Color",group = "colors")
color_stage_2_resistance_line=input.color(defval = color.orange,title = "Stage 1 Resistance Line Color",group = "colors")
color_stage_2_proper_resistance_line=input.color(defval = color.red,title = "Proper Stage 2 Resistance Line Color",group = "colors")
i_nifty50 = input.symbol("NSE:CNX500", "Symbol")
NIFTY50 = request.security(i_nifty50, timeframe.period, close)
var stages = array.new_float()
sma200=ta.ema(close,200)
//plot(ema189,title = 'EMA189',color=color.gray)
sma150=ta.vwma(close,150)
//plot(vwmah189,title = 'VWMAH189',color=color.rgb(146, 194, 233))
sma100=ta.vwma(close,100)
//plot(vwma189,title = 'VWMA189',color=color.rgb(126, 199, 132))
rs=(close/NIFTY50)
rs21=ta.ema(rs,21)
rs42=ta.ema(rs,42)
rs63=ta.ema(rs,63)
rs72=ta.ema(rs,72)
rs84=ta.ema(rs,84)
rs126=ta.ema(rs,126)
rs147=ta.ema(rs,147)
rs168=ta.ema(rs,168)
rs252=ta.ema(rs,252)
hh7=ta.highest(high,7)
hh15=ta.highest(high,15)
var stage1_line_bar_index = 0
var stage1_proper_line_bar_index = 0
var stage3_line_bar_index = 0
var stage2_line_bar_index = 0
var stage2_proper_line_bar_index = 0
color ccolor = na
if(rs>=rs84 and rs < rs126)
//stage 1
array.push(stages,1)
ccolor:=color.new(color.aqua,90)
else if(rs < rs42 and rs >= rs72 and rs >= rs84 and rs >= rs126 and rs >= rs147 and rs >= rs168 and rs >= rs252 and (rs42 > rs63 or rs < rs63) and rs63 > rs126 and close >= math.max(sma200,sma150,sma100))
//stage 3
array.push(stages,3)
ccolor:=color.new(color.yellow,90)
else if(rs >= rs168 and rs >= rs147 and rs>=rs126 and rs >= rs252 and close>=math.max(sma200,sma150,sma100) and (rs21 >= rs42 or rs42 >= rs63))
//stage 2
array.push(stages,2.1)
ccolor:=color.new(color.green,70)
else if(rs>=rs126 and rs >= rs147 and (close>=sma200 or close>=math.max(sma100,sma150)) and (rs21 >= rs42 or rs42 >= rs63))
//stage 2
array.push(stages,2)
ccolor:=color.new(color.green,90)
else if((rs<rs63 and rs < rs126) or (rs63 < rs126 and rs < rs126))
//stage 4
array.push(stages,4)
ccolor:=color.new(color.red,90)
else if((math.max(close,open)>=math.max(sma200,sma150) or math.max(close,open)>=math.max(sma100,sma150)) and rs >= rs72 and rs < rs126)
//stage 1
array.push(stages,1)
ccolor:=color.new(color.aqua,90)
else if(rs >= rs84 and rs >= rs72 and (math.max(close,open)>=math.max(sma200,sma150) or math.max(close,open)>=math.max(sma100,sma150)))
//stage 1
array.push(stages,1)
ccolor:=color.new(color.aqua,90)
else
array.push(stages,0)
bgcolor(ccolor)
// if(bar_index == 0)
// label.new(x=bar_index,y = high,text= str.tostring(array.size(stages)) + " = " + str.tostring(bar_index), xloc=xloc.bar_index, yloc=yloc.price)
// if(bar_index == last_bar_index)
// label.new(x=bar_index,y = high,text= str.tostring(array.size(stages)) + " = " + str.tostring(bar_index), xloc=xloc.bar_index, yloc=yloc.price)
if((bar_index >= (last_bar_index - autodraw_lookback_period) or ((last_bar_index - autodraw_lookback_period) < 0 and bar_index >= 130)) and bar_index >=6) //only start auto draw for last 2 years
//stage 3 support line code start
if(display_stage_3_support_line==true)
if(array.get(stages,bar_index)==3 and array.get(stages,(bar_index - 1))==3 and array.get(stages,(bar_index - 2))==2.1 and array.get(stages,(bar_index - 3))==2.1 and array.get(stages,(bar_index - 4))==2.1 and array.get(stages,(bar_index - 5))==2.1 and array.get(stages,(bar_index - 6))==2.1)
if(bar_index >= (stage3_line_bar_index + gap_between_2_lines))
line.new(x1=bar_index - 1,y1=hh15,x2=bar_index,y2=hh15,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=color_stage_3_support_line)
stage3_line_bar_index := bar_index
if(array.get(stages,bar_index)==2.1 and array.get(stages,(bar_index - 1))==3 and array.get(stages,(bar_index - 2))==2.1 and array.get(stages,(bar_index - 3))==2.1 and array.get(stages,(bar_index - 4))==2.1 and array.get(stages,(bar_index - 5))==2.1 and array.get(stages,(bar_index - 6))==2.1)
if(bar_index >= (stage3_line_bar_index + gap_between_2_lines))
line.new(x1=bar_index - 1,y1=hh15,x2=bar_index,y2=hh15,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=color_stage_3_support_line)
stage3_line_bar_index := bar_index
//stage 3 support line code end
//stage 2 resistance line code start
if(display_stage_2_resistance_line==true)
if((array.get(stages,bar_index)==1 or array.get(stages,bar_index)==0) and array.get(stages,(bar_index - 1))==2 and array.get(stages,(bar_index - 2))==2)
if(bar_index >= (stage2_line_bar_index + gap_between_2_lines))
line.new(x1=bar_index - 1,y1=hh15,x2=bar_index,y2=hh15,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=color_stage_2_resistance_line)
stage2_line_bar_index := bar_index
//stage 2 resistance line code end
//proper stage 2 resistance line code start
if(display_stage_2_proper_resistance_line ==true)
check_stage_2=0
check_stage_2_1=0
if(array.get(stages,bar_index) == 2 or array.get(stages,bar_index) == 2.1)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 1) == 2 or array.get(stages,bar_index - 1) == 2.1)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 2) == 2 or array.get(stages,bar_index - 2) == 2.1)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 3) == 2 or array.get(stages,bar_index - 3) == 2.1)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 4) == 2 or array.get(stages,bar_index - 4) == 2.1)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 5) == 2 or array.get(stages,bar_index - 5) == 2.1)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 6) == 2 or array.get(stages,bar_index - 6) == 2.1)
check_stage_2 := check_stage_2 + 1
//state 2.1 checking
if(array.get(stages,bar_index - 1) == 2.1)
check_stage_2_1 := check_stage_2_1 + 1
if(array.get(stages,bar_index - 2) == 2.1)
check_stage_2_1 := check_stage_2_1 + 1
if(array.get(stages,bar_index - 3) == 2.1)
check_stage_2_1 := check_stage_2_1 + 1
if(array.get(stages,bar_index - 4) == 2.1)
check_stage_2_1 := check_stage_2_1 + 1
if(array.get(stages,bar_index - 5) == 2.1)
check_stage_2_1 := check_stage_2_1 + 1
if(array.get(stages,bar_index - 6) == 2.1)
check_stage_2_1 := check_stage_2_1 + 1
if(check_stage_2 >= 5 and check_stage_2_1 >= 2 and (array.get(stages,bar_index) == 2 or array.get(stages,bar_index) == 0 or array.get(stages,bar_index) == 1 or array.get(stages,bar_index) == 4))
if(bar_index >= (stage2_proper_line_bar_index + gap_between_2_lines))
line.new(x1=bar_index - 6,y1=hh15,x2=bar_index,y2=hh15,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=color_stage_2_proper_resistance_line)
stage2_proper_line_bar_index := bar_index
//proper stage 2 resistance line code end
//stage 1 resistance line code start - 1 - stage 1 and stage 0 count >= 2 in last 5 days. minimum 1 stage 1 days required. no stage 2 in last 5 days and no stage 1 in previouse 6th days.
if(display_stage_1_resistance_line==true)
check_pass_count=0
check_stage_1=0
check_stage_2=0
//day 1
if(array.get(stages,bar_index) == 1 or array.get(stages,bar_index) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index) == 1)
check_stage_1 := check_stage_1 + 1
if(array.get(stages,bar_index) == 2)
check_stage_2 := check_stage_2 + 1
//day 2
if(array.get(stages,bar_index - 1) == 1 or array.get(stages,bar_index - 1) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 1) == 1)
check_stage_1 := check_stage_1 + 1
if(array.get(stages,bar_index - 1) == 2)
check_stage_2 := check_stage_2 + 1
//day 3
if(array.get(stages,bar_index - 2) == 1 or array.get(stages,bar_index - 2) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 2) == 1)
check_stage_1 := check_stage_1 + 1
if(array.get(stages,bar_index - 2) == 2)
check_stage_2 := check_stage_2 + 1
//day 4
if(array.get(stages,bar_index - 3) == 1 or array.get(stages,bar_index - 3) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 3) == 1)
check_stage_1 := check_stage_1 + 1
if(array.get(stages,bar_index - 3) == 2)
check_stage_2 := check_stage_2 + 1
//day 5
if(array.get(stages,bar_index - 4) == 1 or array.get(stages,bar_index - 4) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 4) == 1)
check_stage_1 := check_stage_1 + 1
if(array.get(stages,bar_index - 4) == 2)
check_stage_2 := check_stage_2 + 1
if(check_pass_count >= 2 and check_stage_1 >= 1 and check_stage_2==0 and array.get(stages,bar_index - 5) != 1)
if(bar_index >= (stage1_line_bar_index + gap_between_2_lines))
line.new(x1=bar_index - 4,y1=hh15,x2=bar_index - 3,y2=hh15,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=color_stage_1_resistance_line)
stage1_line_bar_index := bar_index
//stage 1 resistance line code start - 1 - stage 1 and stage 0 count >= 2 in last 5 days. minimum 1 stage 1 days required. no stage 2 in last 5 days and no stage 1 in previouse 6th days.
//stage 1 proper resistance line code start - in last 7 days total 5 days in stage 1/0 and no stage 2 in last 7 days.
if(display_stage_1_proper_resistance_line==true and bar_index >= 132)
check_pass_count=0
check_stage_2=0
check_stage_1=0
//day 1
if(array.get(stages,bar_index) == 1 or array.get(stages,bar_index) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index) == 2)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index) == 1)
check_stage_1 := check_stage_1 + 1
//day 2
if(array.get(stages,bar_index - 1) == 1 or array.get(stages,bar_index - 1) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 1) == 2)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 1) == 1)
check_stage_1 := check_stage_1 + 1
//day 3
if(array.get(stages,bar_index - 2) == 1 or array.get(stages,bar_index - 2) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 2) == 2)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 2) == 1)
check_stage_1 := check_stage_1 + 1
//day 4
if(array.get(stages,bar_index - 3) == 1 or array.get(stages,bar_index - 3) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 3) == 2)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 3) == 1)
check_stage_1 := check_stage_1 + 1
//day 5
if(array.get(stages,bar_index - 4) == 1 or array.get(stages,bar_index - 4) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 4) == 2)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 4) == 1)
check_stage_1 := check_stage_1 + 1
//day 6
if(array.get(stages,bar_index - 5) == 1 or array.get(stages,bar_index - 5) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 5) == 2)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 5) == 1)
check_stage_1 := check_stage_1 + 1
//day 7
if(array.get(stages,bar_index - 6) == 1 or array.get(stages,bar_index - 6) == 0)
check_pass_count := check_pass_count + 1
if(array.get(stages,bar_index - 6) == 2)
check_stage_2 := check_stage_2 + 1
if(array.get(stages,bar_index - 6) == 1)
check_stage_1 := check_stage_1 + 1
if(check_pass_count >= 5 and check_stage_1 >= 1)
if(bar_index >= (stage1_proper_line_bar_index + gap_between_2_lines))
line.new(x1=bar_index - 6,y1=hh15,x2=bar_index - 5,y2=hh15,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=color_stage_1_proper_resistance_line)
stage1_proper_line_bar_index := bar_index
//stage 1 proper resistance line code start - in last 7 days total 5 days in stage 1/0 and no stage 2 in last 7 days. |
RESISTANCE & SUPPORT | https://www.tradingview.com/script/n06TN8XI-RESISTANCE-SUPPORT/ | jadeja_rajdeep | https://www.tradingview.com/u/jadeja_rajdeep/ | 37 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© jadeja_rajdeep
//@version=5
indicator("RESISTANCE & SUPPORT",overlay=true,max_lines_count=20,max_bars_back=254)
ema10 = ta.ema(close,10)
ema21 = ta.ema(close,21)
sma50 = ta.sma(close,50)
sma100 = ta.sma(close,100)
downcolor=input.color(color.red,"Pullback Line","","Line Color")
upcolor=input.color(color.green,"Rising Line","","Line Color")
vcolor=input.color(color.blue,"Vshape Line","","Line Color")
bar2color=input.color(#ff9800,"2 Bar Fail","","Line Color")
bar2_reversal_color=input.color(#00865a,"2 Bar Reversal","","Line Color")
insidebar_reversal_color=input.color(color.rgb(255, 0, 221),"Inside Bar Reversal","","Line Color")
showlable=input.bool(true,"Show Line Counter")
downvisible=input.bool(true,"Pullback Line")
upvisible=input.bool(true,"Rising Line")
vvisible=input.bool(true,"Vshape Line")
bar2visible=input.bool(true,"2 Bar Fail Line")
bar2_reversal_visible=input.bool(true,"2 Bar Reversal")
insidebar_reversal_visible=input.bool(true,"Inside Bar Reversal")
var linecounter = 0
get_line_counter(linecounter) =>
linecounter+1
if (high >= sma50 or (close>=sma100 and ema21>=sma100 and sma50>=sma100))
if(bar2_reversal_visible==true)
if(close[1]<close[2] and close[2]<close[3] and close>=high[1])
line.new(x1=bar_index-1,y1=high[1],x2=bar_index,y2=high[1],xloc=xloc.bar_index,extend=extend.right,style=line.style_dashed,color=bar2_reversal_color)
if(showlable==true)
linecounter := get_line_counter(linecounter)
label.new(x=bar_index-1,y = high[1],text= str.tostring(linecounter)+" - BUY @ "+str.tostring(math.round(high[1],2)), xloc=xloc.bar_index, yloc=yloc.price,color=bar2_reversal_color, style=label.style_label_down , textcolor=#ffffff,size = size.small)
if(insidebar_reversal_visible==true)
inside_bar=0
mainbar_high=high[10]
mainbar_low=low[10]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),10) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),10))
inside_bar := 1
if(inside_bar==0)
mainbar_high :=high[9]
mainbar_low :=low[9]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),9) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),9))
inside_bar := 1
if(inside_bar==0)
mainbar_high :=high[8]
mainbar_low :=low[8]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),8) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),8))
inside_bar := 1
if(inside_bar==0)
mainbar_high :=high[7]
mainbar_low :=low[7]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),7) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),7))
inside_bar := 1
if(inside_bar==0)
mainbar_high :=high[6]
mainbar_low :=low[6]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),6) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),6))
inside_bar := 1
if(inside_bar==0)
mainbar_high :=high[5]
mainbar_low :=low[5]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),5) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),5))
inside_bar := 1
if(inside_bar==0)
mainbar_high :=high[4]
mainbar_low :=low[4]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),4) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),4))
inside_bar := 1
if(inside_bar==0)
mainbar_high :=high[3]
mainbar_low :=low[3]
if(close>=high[1] and close[1] < high[2] and mainbar_high>= ta.highest(math.max(open[1],close[1]),3) and mainbar_low <= ta.lowest(math.min(open[1],close[1]),3))
inside_bar := 1
if(inside_bar==1)
line.new(x1=bar_index-1,y1=high[1],x2=bar_index,y2=high[1],xloc=xloc.bar_index,extend=extend.right,style=line.style_dashed,color=insidebar_reversal_color)
if(showlable==true)
linecounter := get_line_counter(linecounter)
label.new(x=bar_index-1,y = high[1],text= str.tostring(linecounter)+" - BUY @ "+str.tostring(math.round(high[1],2)), xloc=xloc.bar_index, yloc=yloc.price,color=insidebar_reversal_color, style=label.style_label_down , textcolor=#ffffff,size = size.small)
if (ema10 >= ema21 and ema21 >= sma50)
if(bar2visible==true)
if(volume <= volume[1])
if(close < open and close[1] >= open[1] and open >= close[1] and close < close[1])
line.new(x1=bar_index-1,y1=high,x2=bar_index,y2=high,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=bar2color)
if(showlable==true)
linecounter := get_line_counter(linecounter)
label.new(x=bar_index,y = high,text= str.tostring(linecounter), xloc=xloc.bar_index, yloc=yloc.price,color=bar2color, style=label.style_label_down , textcolor=#ffffff,size = size.small)
if(volume[2] >= volume[1] and volume[1] >= volume)
if(downvisible==true)
if(close[2] >= close[1] and close[1] >= close)
line.new(x1=bar_index-1,y1=high,x2=bar_index,y2=high,xloc=xloc.bar_index,extend=extend.right,style=line.style_dashed,color=downcolor)
if(showlable==true)
linecounter := get_line_counter(linecounter)
label.new(x=bar_index,y = high,text= str.tostring(linecounter), xloc=xloc.bar_index, yloc=yloc.price,color=downcolor, style=label.style_label_down , textcolor=#ffffff,size = size.small)
if(upvisible==true)
if(close > close[1] and close[1] > close[2])
line.new(x1=bar_index-1,y1=high,x2=bar_index,y2=high,xloc=xloc.bar_index,extend=extend.right,style=line.style_solid,color=upcolor)
if(showlable==true)
linecounter := get_line_counter(linecounter)
label.new(x=bar_index,y = high,text= str.tostring(linecounter), xloc=xloc.bar_index, yloc=yloc.price,color=upcolor, style=label.style_label_down , textcolor=#ffffff,size = size.small)
if(vvisible==true)
if(close > close[1] and close[1] < close[2])
line.new(x1=bar_index-1,y1=high,x2=bar_index,y2=high,xloc=xloc.bar_index,extend=extend.right,style=line.style_dotted,color=vcolor)
if(showlable==true)
linecounter := get_line_counter(linecounter)
label.new(x=bar_index,y = high,text= str.tostring(linecounter), xloc=xloc.bar_index, yloc=yloc.price,color=vcolor, style=label.style_label_down , textcolor=#ffffff,size = size.small)
|
interest rate gap for forex | https://www.tradingview.com/script/HCSqKkml-interest-rate-gap-for-forex/ | kmassociates | https://www.tradingview.com/u/kmassociates/ | 6 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© kmassociates
//@version=5
indicator("interest rate gap")
duration = input.int(2, title="yield duration", minval = 1, inline="yield duration")
duration_unit = input.string("Year", title="", options=["Year", "Month"], inline="yield duration")
_duration_unit = duration_unit == "Year"? "": "M"
suffix = duration >= 10? str.tostring(duration) + _duration_unit + "Y": "0" + str.tostring(duration) + _duration_unit + "Y"
ticker01 = str.startswith(syminfo.ticker, 'USD')? 'US':
str.startswith(syminfo.ticker, 'EUR')? 'EU':
str.startswith(syminfo.ticker, 'JPY')? 'JP':
str.startswith(syminfo.ticker, 'AUD')? 'AU':
str.startswith(syminfo.ticker, 'CAD')? 'CA':
str.startswith(syminfo.ticker, 'NZD')? 'NZ':
str.startswith(syminfo.ticker, 'GBP')? 'GB':
str.startswith(syminfo.ticker, 'CHF')? 'CH':
str.startswith(syminfo.ticker, 'CNH')? 'CN':
str.startswith(syminfo.ticker, 'DKK')? 'DK':
str.startswith(syminfo.ticker, 'HKD')? 'HK':
str.startswith(syminfo.ticker, 'HUF')? 'HU':
str.startswith(syminfo.ticker, 'MXN')? 'MX':
str.startswith(syminfo.ticker, 'NOK')? 'NO':
str.startswith(syminfo.ticker, 'PLN')? 'PL':
str.startswith(syminfo.ticker, 'SEK')? 'SE':
str.startswith(syminfo.ticker, 'SGD')? 'SG':
str.startswith(syminfo.ticker, 'TRY')? 'TR':
str.startswith(syminfo.ticker, 'ZAR')? 'ZA':
str.startswith(syminfo.ticker, 'AED')? 'AE':
str.startswith(syminfo.ticker, 'AFN')? 'AF':
str.startswith(syminfo.ticker, 'ALL')? 'AL':
str.startswith(syminfo.ticker, 'AMD')? 'AM':
str.startswith(syminfo.ticker, 'AOA')? 'AO':
str.startswith(syminfo.ticker, 'ARS')? 'AR':
str.startswith(syminfo.ticker, 'AWG')? 'AW':
str.startswith(syminfo.ticker, 'AZN')? 'AZ':
str.startswith(syminfo.ticker, 'BAM')? 'BA':
str.startswith(syminfo.ticker, 'BBD')? 'BB':
str.startswith(syminfo.ticker, 'BDT')? 'BD':
str.startswith(syminfo.ticker, 'BGN')? 'BG':
str.startswith(syminfo.ticker, 'BHD')? 'BH':
str.startswith(syminfo.ticker, 'BIF')? 'BI':
str.startswith(syminfo.ticker, 'BMD')? 'BM':
str.startswith(syminfo.ticker, 'BND')? 'BN':
str.startswith(syminfo.ticker, 'BOB')? 'BO':
str.startswith(syminfo.ticker, 'BRL')? 'BR':
str.startswith(syminfo.ticker, 'BSD')? 'BS':
str.startswith(syminfo.ticker, 'BTN')? 'BT':
str.startswith(syminfo.ticker, 'BWP')? 'BW':
str.startswith(syminfo.ticker, 'BYN')? 'BY':
str.startswith(syminfo.ticker, 'BZD')? 'BZ':
str.startswith(syminfo.ticker, 'CDF')? 'CD':
str.startswith(syminfo.ticker, 'CHE')? 'CH':
str.startswith(syminfo.ticker, 'CHW')? 'CH':
str.startswith(syminfo.ticker, 'CLF')? 'CL':
str.startswith(syminfo.ticker, 'CLP')? 'CL':
str.startswith(syminfo.ticker, 'CNY')? 'CN':
str.startswith(syminfo.ticker, 'COP')? 'CO':
str.startswith(syminfo.ticker, 'COU')? 'CO':
str.startswith(syminfo.ticker, 'CRC')? 'CR':
str.startswith(syminfo.ticker, 'CUC')? 'CU':
str.startswith(syminfo.ticker, 'CUP')? 'CU':
str.startswith(syminfo.ticker, 'CVE')? 'CV':
str.startswith(syminfo.ticker, 'CZK')? 'CZ':
str.startswith(syminfo.ticker, 'DJF')? 'DJ':
str.startswith(syminfo.ticker, 'DOP')? 'DO':
str.startswith(syminfo.ticker, 'DZD')? 'DZ':
str.startswith(syminfo.ticker, 'EGP')? 'EG':
str.startswith(syminfo.ticker, 'ERN')? 'ER':
str.startswith(syminfo.ticker, 'ETB')? 'ET':
str.startswith(syminfo.ticker, 'FJD')? 'FJ':
str.startswith(syminfo.ticker, 'FKP')? 'FK':
str.startswith(syminfo.ticker, 'GEL')? 'GE':
str.startswith(syminfo.ticker, 'GHS')? 'GH':
str.startswith(syminfo.ticker, 'GIP')? 'GI':
str.startswith(syminfo.ticker, 'GMD')? 'GM':
str.startswith(syminfo.ticker, 'GNF')? 'GN':
str.startswith(syminfo.ticker, 'GTQ')? 'GT':
str.startswith(syminfo.ticker, 'GYD')? 'GY':
str.startswith(syminfo.ticker, 'HNL')? 'HN':
str.startswith(syminfo.ticker, 'HRK')? 'HR':
str.startswith(syminfo.ticker, 'HTG')? 'HT':
str.startswith(syminfo.ticker, 'IDR')? 'ID':
str.startswith(syminfo.ticker, 'ILS')? 'IL':
str.startswith(syminfo.ticker, 'INR')? 'IN':
str.startswith(syminfo.ticker, 'IQD')? 'IQ':
str.startswith(syminfo.ticker, 'IRR')? 'IR':
str.startswith(syminfo.ticker, 'ISK')? 'IS':
str.startswith(syminfo.ticker, 'JMD')? 'JM':
str.startswith(syminfo.ticker, 'JOD')? 'JO':
str.startswith(syminfo.ticker, 'KES')? 'KE':
str.startswith(syminfo.ticker, 'KGS')? 'KG':
str.startswith(syminfo.ticker, 'KHR')? 'KH':
str.startswith(syminfo.ticker, 'KMF')? 'KM':
str.startswith(syminfo.ticker, 'KPW')? 'KP':
str.startswith(syminfo.ticker, 'KRW')? 'KR':
str.startswith(syminfo.ticker, 'KWD')? 'KW':
str.startswith(syminfo.ticker, 'KYD')? 'KY':
str.startswith(syminfo.ticker, 'KZT')? 'KZ':
str.startswith(syminfo.ticker, 'LAK')? 'LA':
str.startswith(syminfo.ticker, 'LBP')? 'LB':
str.startswith(syminfo.ticker, 'LKR')? 'LK':
str.startswith(syminfo.ticker, 'LRD')? 'LR':
str.startswith(syminfo.ticker, 'LSL')? 'LS':
str.startswith(syminfo.ticker, 'LYD')? 'LY':
str.startswith(syminfo.ticker, 'MAD')? 'MA':
str.startswith(syminfo.ticker, 'MDL')? 'MD':
str.startswith(syminfo.ticker, 'MGA')? 'MG':
str.startswith(syminfo.ticker, 'MKD')? 'MK':
str.startswith(syminfo.ticker, 'MMK')? 'MM':
str.startswith(syminfo.ticker, 'MNT')? 'MN':
str.startswith(syminfo.ticker, 'MOP')? 'MO':
str.startswith(syminfo.ticker, 'MRU')? 'MR':
str.startswith(syminfo.ticker, 'MUR')? 'MU':
str.startswith(syminfo.ticker, 'MVR')? 'MV':
str.startswith(syminfo.ticker, 'MWK')? 'MW':
str.startswith(syminfo.ticker, 'MXV')? 'MX':
str.startswith(syminfo.ticker, 'MYR')? 'MY':
str.startswith(syminfo.ticker, 'MZN')? 'MZ':
str.startswith(syminfo.ticker, 'NAD')? 'NA':
str.startswith(syminfo.ticker, 'NGN')? 'NG':
str.startswith(syminfo.ticker, 'NIO')? 'NI':
str.startswith(syminfo.ticker, 'NPR')? 'NP':
str.startswith(syminfo.ticker, 'OMR')? 'OM':
str.startswith(syminfo.ticker, 'PAB')? 'PA':
str.startswith(syminfo.ticker, 'PEN')? 'PE':
str.startswith(syminfo.ticker, 'PGK')? 'PG':
str.startswith(syminfo.ticker, 'PHP')? 'PH':
str.startswith(syminfo.ticker, 'PKR')? 'PK':
str.startswith(syminfo.ticker, 'PYG')? 'PY':
str.startswith(syminfo.ticker, 'QAR')? 'QA':
str.startswith(syminfo.ticker, 'RON')? 'RO':
str.startswith(syminfo.ticker, 'RSD')? 'RS':
str.startswith(syminfo.ticker, 'RUB')? 'RU':
str.startswith(syminfo.ticker, 'RWF')? 'RW':
str.startswith(syminfo.ticker, 'SAR')? 'SA':
str.startswith(syminfo.ticker, 'SBD')? 'SB':
str.startswith(syminfo.ticker, 'SCR')? 'SC':
str.startswith(syminfo.ticker, 'SDG')? 'SD':
str.startswith(syminfo.ticker, 'SHP')? 'SH':
str.startswith(syminfo.ticker, 'SLL')? 'SL':
str.startswith(syminfo.ticker, 'SOS')? 'SO':
str.startswith(syminfo.ticker, 'SRD')? 'SR':
str.startswith(syminfo.ticker, 'SSP')? 'SS':
str.startswith(syminfo.ticker, 'STN')? 'ST':
str.startswith(syminfo.ticker, 'SVC')? 'SV':
str.startswith(syminfo.ticker, 'SYP')? 'SY':
str.startswith(syminfo.ticker, 'SZL')? 'SZ':
str.startswith(syminfo.ticker, 'THB')? 'TH':
str.startswith(syminfo.ticker, 'TJS')? 'TJ':
str.startswith(syminfo.ticker, 'TMT')? 'TM':
str.startswith(syminfo.ticker, 'TND')? 'TN':
str.startswith(syminfo.ticker, 'TOP')? 'TO':
str.startswith(syminfo.ticker, 'TTD')? 'TT':
str.startswith(syminfo.ticker, 'TZS')? 'TZ':
str.startswith(syminfo.ticker, 'UAH')? 'UA':
str.startswith(syminfo.ticker, 'UGX')? 'UG':
str.startswith(syminfo.ticker, 'UYI')? 'UY':
str.startswith(syminfo.ticker, 'UYU')? 'UY':
str.startswith(syminfo.ticker, 'UYW')? 'UY':
str.startswith(syminfo.ticker, 'UZS')? 'UZ':
str.startswith(syminfo.ticker, 'VND')? 'VN':
str.startswith(syminfo.ticker, 'VUV')? 'VU':
str.startswith(syminfo.ticker, 'WST')? 'WS':
str.startswith(syminfo.ticker, 'YER')? 'YE':
str.startswith(syminfo.ticker, 'ZMW')? 'ZM':
str.startswith(syminfo.ticker, 'ZWL')? 'ZW':""
ticker01 += ticker01 == ""? "": suffix
ticker02 = str.endswith(syminfo.ticker, 'USD')? 'US':
str.endswith(syminfo.ticker, 'EUR')? 'EU':
str.endswith(syminfo.ticker, 'JPY')? 'JP':
str.endswith(syminfo.ticker, 'AUD')? 'AU':
str.endswith(syminfo.ticker, 'CAD')? 'CA':
str.endswith(syminfo.ticker, 'NZD')? 'NZ':
str.endswith(syminfo.ticker, 'GBP')? 'GB':
str.endswith(syminfo.ticker, 'CHF')? 'CH':
str.endswith(syminfo.ticker, 'CNH')? 'CN':
str.endswith(syminfo.ticker, 'DKK')? 'DK':
str.endswith(syminfo.ticker, 'HKD')? 'HK':
str.endswith(syminfo.ticker, 'HUF')? 'HU':
str.endswith(syminfo.ticker, 'MXN')? 'MX':
str.endswith(syminfo.ticker, 'NOK')? 'NO':
str.endswith(syminfo.ticker, 'PLN')? 'PL':
str.endswith(syminfo.ticker, 'SEK')? 'SE':
str.endswith(syminfo.ticker, 'SGD')? 'SG':
str.endswith(syminfo.ticker, 'TRY')? 'TR':
str.endswith(syminfo.ticker, 'ZAR')? 'ZA':
str.endswith(syminfo.ticker, 'AED')? 'AE':
str.endswith(syminfo.ticker, 'AFN')? 'AF':
str.endswith(syminfo.ticker, 'ALL')? 'AL':
str.endswith(syminfo.ticker, 'AMD')? 'AM':
str.endswith(syminfo.ticker, 'AOA')? 'AO':
str.endswith(syminfo.ticker, 'ARS')? 'AR':
str.endswith(syminfo.ticker, 'AWG')? 'AW':
str.endswith(syminfo.ticker, 'AZN')? 'AZ':
str.endswith(syminfo.ticker, 'BAM')? 'BA':
str.endswith(syminfo.ticker, 'BBD')? 'BB':
str.endswith(syminfo.ticker, 'BDT')? 'BD':
str.endswith(syminfo.ticker, 'BGN')? 'BG':
str.endswith(syminfo.ticker, 'BHD')? 'BH':
str.endswith(syminfo.ticker, 'BIF')? 'BI':
str.endswith(syminfo.ticker, 'BMD')? 'BM':
str.endswith(syminfo.ticker, 'BND')? 'BN':
str.endswith(syminfo.ticker, 'BOB')? 'BO':
str.endswith(syminfo.ticker, 'BRL')? 'BR':
str.endswith(syminfo.ticker, 'BSD')? 'BS':
str.endswith(syminfo.ticker, 'BTN')? 'BT':
str.endswith(syminfo.ticker, 'BWP')? 'BW':
str.endswith(syminfo.ticker, 'BYN')? 'BY':
str.endswith(syminfo.ticker, 'BZD')? 'BZ':
str.endswith(syminfo.ticker, 'CDF')? 'CD':
str.endswith(syminfo.ticker, 'CHE')? 'CH':
str.endswith(syminfo.ticker, 'CHW')? 'CH':
str.endswith(syminfo.ticker, 'CLF')? 'CL':
str.endswith(syminfo.ticker, 'CLP')? 'CL':
str.endswith(syminfo.ticker, 'CNY')? 'CN':
str.endswith(syminfo.ticker, 'COP')? 'CO':
str.endswith(syminfo.ticker, 'COU')? 'CO':
str.endswith(syminfo.ticker, 'CRC')? 'CR':
str.endswith(syminfo.ticker, 'CUC')? 'CU':
str.endswith(syminfo.ticker, 'CUP')? 'CU':
str.endswith(syminfo.ticker, 'CVE')? 'CV':
str.endswith(syminfo.ticker, 'CZK')? 'CZ':
str.endswith(syminfo.ticker, 'DJF')? 'DJ':
str.endswith(syminfo.ticker, 'DOP')? 'DO':
str.endswith(syminfo.ticker, 'DZD')? 'DZ':
str.endswith(syminfo.ticker, 'EGP')? 'EG':
str.endswith(syminfo.ticker, 'ERN')? 'ER':
str.endswith(syminfo.ticker, 'ETB')? 'ET':
str.endswith(syminfo.ticker, 'FJD')? 'FJ':
str.endswith(syminfo.ticker, 'FKP')? 'FK':
str.endswith(syminfo.ticker, 'GEL')? 'GE':
str.endswith(syminfo.ticker, 'GHS')? 'GH':
str.endswith(syminfo.ticker, 'GIP')? 'GI':
str.endswith(syminfo.ticker, 'GMD')? 'GM':
str.endswith(syminfo.ticker, 'GNF')? 'GN':
str.endswith(syminfo.ticker, 'GTQ')? 'GT':
str.endswith(syminfo.ticker, 'GYD')? 'GY':
str.endswith(syminfo.ticker, 'HNL')? 'HN':
str.endswith(syminfo.ticker, 'HRK')? 'HR':
str.endswith(syminfo.ticker, 'HTG')? 'HT':
str.endswith(syminfo.ticker, 'IDR')? 'ID':
str.endswith(syminfo.ticker, 'ILS')? 'IL':
str.endswith(syminfo.ticker, 'INR')? 'IN':
str.endswith(syminfo.ticker, 'IQD')? 'IQ':
str.endswith(syminfo.ticker, 'IRR')? 'IR':
str.endswith(syminfo.ticker, 'ISK')? 'IS':
str.endswith(syminfo.ticker, 'JMD')? 'JM':
str.endswith(syminfo.ticker, 'JOD')? 'JO':
str.endswith(syminfo.ticker, 'KES')? 'KE':
str.endswith(syminfo.ticker, 'KGS')? 'KG':
str.endswith(syminfo.ticker, 'KHR')? 'KH':
str.endswith(syminfo.ticker, 'KMF')? 'KM':
str.endswith(syminfo.ticker, 'KPW')? 'KP':
str.endswith(syminfo.ticker, 'KRW')? 'KR':
str.endswith(syminfo.ticker, 'KWD')? 'KW':
str.endswith(syminfo.ticker, 'KYD')? 'KY':
str.endswith(syminfo.ticker, 'KZT')? 'KZ':
str.endswith(syminfo.ticker, 'LAK')? 'LA':
str.endswith(syminfo.ticker, 'LBP')? 'LB':
str.endswith(syminfo.ticker, 'LKR')? 'LK':
str.endswith(syminfo.ticker, 'LRD')? 'LR':
str.endswith(syminfo.ticker, 'LSL')? 'LS':
str.endswith(syminfo.ticker, 'LYD')? 'LY':
str.endswith(syminfo.ticker, 'MAD')? 'MA':
str.endswith(syminfo.ticker, 'MDL')? 'MD':
str.endswith(syminfo.ticker, 'MGA')? 'MG':
str.endswith(syminfo.ticker, 'MKD')? 'MK':
str.endswith(syminfo.ticker, 'MMK')? 'MM':
str.endswith(syminfo.ticker, 'MNT')? 'MN':
str.endswith(syminfo.ticker, 'MOP')? 'MO':
str.endswith(syminfo.ticker, 'MRU')? 'MR':
str.endswith(syminfo.ticker, 'MUR')? 'MU':
str.endswith(syminfo.ticker, 'MVR')? 'MV':
str.endswith(syminfo.ticker, 'MWK')? 'MW':
str.endswith(syminfo.ticker, 'MXV')? 'MX':
str.endswith(syminfo.ticker, 'MYR')? 'MY':
str.endswith(syminfo.ticker, 'MZN')? 'MZ':
str.endswith(syminfo.ticker, 'NAD')? 'NA':
str.endswith(syminfo.ticker, 'NGN')? 'NG':
str.endswith(syminfo.ticker, 'NIO')? 'NI':
str.endswith(syminfo.ticker, 'NPR')? 'NP':
str.endswith(syminfo.ticker, 'OMR')? 'OM':
str.endswith(syminfo.ticker, 'PAB')? 'PA':
str.endswith(syminfo.ticker, 'PEN')? 'PE':
str.endswith(syminfo.ticker, 'PGK')? 'PG':
str.endswith(syminfo.ticker, 'PHP')? 'PH':
str.endswith(syminfo.ticker, 'PKR')? 'PK':
str.endswith(syminfo.ticker, 'PYG')? 'PY':
str.endswith(syminfo.ticker, 'QAR')? 'QA':
str.endswith(syminfo.ticker, 'RON')? 'RO':
str.endswith(syminfo.ticker, 'RSD')? 'RS':
str.endswith(syminfo.ticker, 'RUB')? 'RU':
str.endswith(syminfo.ticker, 'RWF')? 'RW':
str.endswith(syminfo.ticker, 'SAR')? 'SA':
str.endswith(syminfo.ticker, 'SBD')? 'SB':
str.endswith(syminfo.ticker, 'SCR')? 'SC':
str.endswith(syminfo.ticker, 'SDG')? 'SD':
str.endswith(syminfo.ticker, 'SHP')? 'SH':
str.endswith(syminfo.ticker, 'SLL')? 'SL':
str.endswith(syminfo.ticker, 'SOS')? 'SO':
str.endswith(syminfo.ticker, 'SRD')? 'SR':
str.endswith(syminfo.ticker, 'SSP')? 'SS':
str.endswith(syminfo.ticker, 'STN')? 'ST':
str.endswith(syminfo.ticker, 'SVC')? 'SV':
str.endswith(syminfo.ticker, 'SYP')? 'SY':
str.endswith(syminfo.ticker, 'SZL')? 'SZ':
str.endswith(syminfo.ticker, 'THB')? 'TH':
str.endswith(syminfo.ticker, 'TJS')? 'TJ':
str.endswith(syminfo.ticker, 'TMT')? 'TM':
str.endswith(syminfo.ticker, 'TND')? 'TN':
str.endswith(syminfo.ticker, 'TOP')? 'TO':
str.endswith(syminfo.ticker, 'TTD')? 'TT':
str.endswith(syminfo.ticker, 'TZS')? 'TZ':
str.endswith(syminfo.ticker, 'UAH')? 'UA':
str.endswith(syminfo.ticker, 'UGX')? 'UG':
str.endswith(syminfo.ticker, 'UYI')? 'UY':
str.endswith(syminfo.ticker, 'UYU')? 'UY':
str.endswith(syminfo.ticker, 'UYW')? 'UY':
str.endswith(syminfo.ticker, 'UZS')? 'UZ':
str.endswith(syminfo.ticker, 'VND')? 'VN':
str.endswith(syminfo.ticker, 'VUV')? 'VU':
str.endswith(syminfo.ticker, 'WST')? 'WS':
str.endswith(syminfo.ticker, 'YER')? 'YE':
str.endswith(syminfo.ticker, 'ZMW')? 'ZM':
str.endswith(syminfo.ticker, 'ZWL')? 'ZW':""
ticker02 += ticker02 == ""? "": suffix
sym01 = request.security(ticker01, timeframe.period, close)
sym02 = request.security(ticker02, timeframe.period, close)
irg = sym01 - sym02
plot(syminfo.type == "forex"? irg: na, title="interest rate gap")
bool_ma = input.bool(true, title="SMA", inline="MA")
len_ma = input.int(20, title="length", inline="MA")
plot(syminfo.type == "forex" and bool_ma? ta.sma(irg, len_ma): na, title="SMA", color=color.olive)
bool_zero = input.bool(true, title="Zero line", inline="zero")
hline(bool_zero? 0.0: na, title="zero line", color=color.gray, linestyle=hline.style_dotted)
show_notes = input.bool(true, title="show_notes")
var tbl = table.new(position = position.top_right, columns = 1, rows = 2, bgcolor = color.new(color.gray, 80), border_width = 1)
if barstate.islast and show_notes
if syminfo.type == "forex"
table.cell(tbl, column = 0, row = 0, text = ticker01 + " - " + ticker02, text_color = color.white, text_size=size.small)
tbl_duration_unit = duration_unit == "Year"? "year": "month"
table.cell(tbl, column = 0, row = 1, text = syminfo.description + "\n" + str.tostring(duration) + " " + tbl_duration_unit + " gov bonds yield gap", text_color = color.white, text_size=size.small)
if syminfo.type != "forex"
table.cell(tbl, column = 0, row = 0, text = "symbol is not forex", text_color = color.white, text_size=size.small)
table.set_position(tbl, position.middle_center)
|
Ladder StDev | https://www.tradingview.com/script/HQwUjdqu-Ladder-StDev/ | jason5480 | https://www.tradingview.com/u/jason5480/ | 45 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© jason5480
//@version=5
indicator(title = 'Ladder StDev',
shorttitle = 'LStDev',
timeframe = '',
timeframe_gaps = true)
import HeWhoMustNotBeNamed/arraymethods/1
// INPUT ============================================================================================================
stdevMode = input.string(defval = 'PRICE', title = 'StDev Mode', options = ['PRICE', 'RETURN'], tooltip = 'Use the "PRICE" as source for the standard deviation calculations. Or use "RETURN" to use the log returns of the price as source for the standard deviation.')
priceSrc = input.source(defval = close, title = 'ββPrice Src', tooltip = 'The source to be used for the standard deviation calculation when PRICE mode is selected or for the log returns when RETURN mode is selected.')
stdevLength = input.int(defval = 20, title = 'StDev Len', minval = 1, tooltip = 'The length to be used for the standard deviation calculation.')
// LOGIC ============================================================================================================
var positiveStDevs = array.new<float>()
var negativeStDevs = array.new<float>()
float stdevSrc = stdevMode == 'PRICE' ? priceSrc : math.log(priceSrc/priceSrc[1])
if(close > open)
positiveStDevs.push(stdevSrc, stdevLength)
else
negativeStDevs.push(stdevSrc, stdevLength)
float possitiveStDev = array.stdev(positiveStDevs, false)
float negativeStDev = array.stdev(negativeStDevs, false)
float ladderPositiveStDev = stdevMode == 'PRICE' ? possitiveStDev : priceSrc * (math.exp(possitiveStDev) - 1.0)
float ladderNegativeStDev = stdevMode == 'PRICE' ? negativeStDev : priceSrc * (math.exp(negativeStDev) - 1.0)
// PLOT =============================================================================================================
var positiveColor = color.new(#26A69A, 0)
plot(series = ladderPositiveStDev, title = 'Positive StDev', color = positiveColor, linewidth = 1, style = plot.style_line, trackprice = true)
var negativeColor = color.new(#EF5350, 0)
plot(series = ladderNegativeStDev, title = 'Negative StDev', color = negativeColor, linewidth = 1, style = plot.style_line, trackprice = true) |
Ultimate P&L Indicator | https://www.tradingview.com/script/ETuTl880-Ultimate-P-L-Indicator/ | Steversteves | https://www.tradingview.com/u/Steversteves/ | 68 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© Steversteves
//@version=5
indicator("Ultimate P&L Indicator")
// Input Ticker Data
ticker = input.symbol("", title="Ticker 1", group = "Position Demographics")
dateandtime = input.time(timestamp("Feb 2023 12:00"), title="Position Date & Time", group = "Position Demographics", tooltip = "This is optional; however, input of the time and date will omit irrelevant data and give you more accurate assessments of your high and low P&L history")
tickerclose = request.security(ticker, "", close, lookahead=barmerge.lookahead_on)
// Position Type
futurestrading = input.bool(false, title="Futures Trading", group = "Position Type", tooltip = "If you are trading futures, be sure to adjust the tick size and index point variables below to account for the futures contract you are trading")
shareposition = input.bool(true, "Share Position", group = "Position Type")
longposition = input.bool(true, "Long Position", group = "Position Type")
shortposition = input.bool(false, "Short Position", group = "Position Type")
// Input Position Data
avgcost = input.float(20, title="Ticker Avgerage Cost Basis", group = "Position Variables")
possize = input.int(100, title="Ticker Position Size", group = "Position Variables")
lookback = input.int(5000, title="Lookback Period", group = "Position Variables")
// DCA Adjustments
autodca = input.bool(false, "Automatically Estimate DCA", group = "Additions to Position")
manualdca = input.bool(true, "Manually Calculcate DCA", group = "Additions to Position")
dcaadd = input.float(1, title="Added Share Cost", group = "Additions to Position")
shareadd = input.float(1, title="Number of Added Shares", group = "Additions to Position")
// Long Position
var tickerpl = 0.0
tickerdca = avgcost * possize
tickervalue = tickerclose * possize
if time>= dateandtime
tickerpl := tickervalue - tickerdca
// Short Position
var shorttickerpl = 0.0
if time>= dateandtime
shorttickerpl := tickerdca - tickervalue
// Futures specific P&L
ticksize = input.float(0.25, title="Tick Size", group = "Futures Adjustments", tooltip = "Tick size on ES1! Mini is 0.25, on WTI Oil it is 1 cent and on MNQ is 2")
indexpoint = input.float(50, title="Index Point", group = "Futures Adjustments", tooltip = "Tick size on ES1! Mini is 50, on WTI Oil it is 1,000 and on MNQ it is 0.5")
tickmovement = ticksize * indexpoint
futureslongpl = (tickerpl / ticksize) * tickmovement
futuresshortpl = (shorttickerpl / ticksize) * tickmovement
// Max and Min
var maxreturnlong = 0.0
var minreturnlong = 0.0
var maxreturnshort = 0.0
var minreturnshort = 0.0
var maxreturnlongfutures = 0.0
var maxreturnshortfutures = 0.0
var minreturnlongfutures = 0.0
var minreturnshortfutures = 0.0
if time >= dateandtime
maxreturnlong := ta.highest(tickerpl, lookback)
minreturnlong := ta.lowest(tickerpl, lookback)
maxreturnshort := ta.highest(shorttickerpl, lookback)
minreturnshort := ta.lowest(shorttickerpl, lookback)
maxreturnlongfutures := ta.highest(futureslongpl, lookback)
maxreturnshortfutures := ta.highest(futuresshortpl, lookback)
minreturnlongfutures := ta.lowest(futureslongpl, lookback)
minreturnshortfutures := ta.lowest(futuresshortpl, lookback)
// % Return
longreturn = (tickervalue - tickerdca) / tickerdca * 100
shortreturn = (tickerdca - tickervalue) / tickervalue * 100
longreturnfutures = (futureslongpl / tickerdca) * 100
shortreturnfutures = (futuresshortpl / tickerdca) * 100
// Colours
color bull = color.new(color.lime, 0)
color bear = color.new(color.red, 0)
weakGreen = color.rgb(76, 175, 80, 25)
blue = color.rgb(20, 123, 134, 25)
red = color.new(color.red, 80)
green = color.new(color.lime, 80)
white = color.new(color.white, 0)
aqua = color.new(color.aqua, 85)
// Plots
plot(longposition and shareposition ? tickerpl : na, "Long Position Plot", style=plot.style_area, color = tickerpl > 0 ? bull : bear, linewidth=3)
plot(shortposition and shareposition ? shorttickerpl : na, "Short Position Plot", style=plot.style_area, color = shorttickerpl > 0 ? bull : bear, linewidth=3)
plot(longposition and futurestrading ? futureslongpl : na, "Long Position Plot", style=plot.style_area, color = futureslongpl > 0 ? bull : bear, linewidth=3)
plot(shortposition and futurestrading ? futuresshortpl : na, "Short Position Plot", style=plot.style_area, color = futuresshortpl > 0 ? bull : bear, linewidth=3)
// DCA Assessments
dcaautocalc = (shareadd * tickerclose)
dcaautoadjust = (dcaautocalc + tickerdca) / (possize + shareadd)
dcamanualcalc = (shareadd * dcaadd)
dcamanualadjust = (dcamanualcalc + tickerdca) / (possize + shareadd)
dcalongdifauto = (avgcost - dcaautoadjust) / dcaautoadjust * 100
dcashortdifauto = (dcaautoadjust - avgcost) / avgcost * 100
dcalongdifman = (avgcost - dcamanualadjust) / dcamanualadjust * 100
dcashortdifman = (dcamanualadjust - avgcost) / avgcost * 100
// Alerts
percentdown = input.float(1, title="Percentage Down Alert", group = "Condition Alerts", tooltip = "Minimum % you want to maintain for your position, falling below this level will trigger your alert")
percentup = input.float(1, title="Percentage Up Alert", group = "Condition Alerts", tooltip = "Max desired % you want your position to realize, crossing this % will trigger this alert")
bool longpercentdown = longreturn <= percentdown
bool shortpercentdown = shortreturn <= percentdown
bool longpercentup = longreturn >= percentup
bool shortpercentup = shortreturn >= percentup
bool dcabelowcurrent = dcaautoadjust < avgcost
bool dcaabovecurrent = dcaautoadjust > avgcost
alertcondition(longposition ? dcabelowcurrent : shortposition ? dcaabovecurrent : na, title="Auto DCA Improved", message = "Estimated DCA is improved from current DCA")
alertcondition(longposition ? longpercentdown : shortposition ? shortpercentdown : na, title="Drop Below Desired %", message="Ticker has dropped below desired percent")
alertcondition(longposition ? longpercentup : shortposition ? shortpercentup : na, title="Rise Above Desired %", message="Ticker has risen above desired percent")
// P&L table
showTable = input.bool(true, "Show Table")
tablePosInput = input.string(title="Position", defval="Top Right", options=["Bottom Left", "Bottom Right", "Top Left", "Top Right"], tooltip="Select where you want the table to draw.")
var tablePos = tablePosInput == "Bottom Left" ? position.bottom_left : tablePosInput == "Bottom Right" ? position.bottom_right : tablePosInput == "Top Left" ? position.top_left : tablePosInput == "Top Right" ? position.top_right : na
var dataTable = table.new(tablePos, columns = 4, rows = 10, border_color = color.black, border_width = 2)
if showTable
// Labels
table.cell(dataTable, 1, 1, text = str.tostring(ticker), bgcolor = weakGreen, text_color = color.white)
table.cell(dataTable, 2, 1, text = shortposition ? "Short" : longposition ? "Long" : na, bgcolor = weakGreen, text_color = color.white)
table.cell(dataTable, 1, 2, text = "Open P&L", bgcolor = aqua, text_color = color.white)
table.cell(dataTable, 1, 3, text = "% Return", bgcolor = aqua, text_color = white)
table.cell(dataTable, 1, 4, text = "Position Size", bgcolor = aqua, text_color = white)
table.cell(dataTable, 1, 5, text = "DCA", bgcolor = aqua, text_color = white)
table.cell(dataTable, 1, 6, text = "Highest", bgcolor = aqua, text_color = white)
table.cell(dataTable, 1, 7, text = "Lowest", bgcolor = aqua, text_color = white)
table.cell(dataTable, 1, 8, text = autodca ? "Auto Adjusted DCA" : manualdca ? "Manual DCA" : na, bgcolor = aqua, text_color = white)
table.cell(dataTable, 1, 9, text = "DCA % Dif", bgcolor = aqua, text_color = white)
// Position
table.cell(dataTable, 2, 2, text = longposition and shareposition ? str.tostring(math.round(tickerpl, 2)) : shortposition and shareposition ? str.tostring(math.round(shorttickerpl, 2)) : longposition and futurestrading ? str.tostring(math.round(futureslongpl, 2)) : shortposition and futurestrading ? str.tostring(math.round(futuresshortpl, 2)) : na, bgcolor = longposition and tickerpl > 0 ? green : shortposition and shorttickerpl > 0 ? green : red, text_color = white)
table.cell(dataTable, 2, 3, text = longposition and shareposition ? str.tostring(math.round(longreturn, 2)) : shortposition and shareposition ? str.tostring(math.round(shortreturn, 2)) : longposition and futurestrading ? str.tostring(math.round(longreturnfutures, 2)) : shortposition and futurestrading ? str.tostring(math.round(shortreturnfutures,2)) : na, bgcolor = longposition and tickerpl > 0 ? green : shortposition and shorttickerpl > 0 ? green : red, text_color = white)
table.cell(dataTable, 2, 4, text = str.tostring(possize), bgcolor = blue, text_color = white)
table.cell(dataTable, 2, 5, text = str.tostring(avgcost), bgcolor = blue, text_color = white)
table.cell(dataTable, 2, 6, text = longposition and shareposition ? str.tostring(math.round(maxreturnlong, 2)) : shortposition and shareposition ? str.tostring(math.round(maxreturnshort, 2)) : longposition and futurestrading ? str.tostring(math.round(maxreturnlongfutures, 2)) : shortposition and futurestrading ? str.tostring(math.round(maxreturnshortfutures, 2)) : na, bgcolor = blue, text_color = white)
table.cell(dataTable, 2, 7, text = longposition and shareposition ? str.tostring(math.round(minreturnlong, 2)) : shortposition and shareposition ? str.tostring(math.round(minreturnshort, 2)) : longposition and futurestrading ? str.tostring(math.round(minreturnlongfutures, 2)) : shortposition and futurestrading ? str.tostring(math.round(minreturnshortfutures, 2)) : na, bgcolor = longposition and minreturnlong < 0 ? red : longposition and minreturnlong > 0 ? green : shortposition and minreturnshort < 0 ? red : shortposition and minreturnshort > 0 ? green : blue, text_color = white)
table.cell(dataTable, 2, 8, text = autodca ? str.tostring(math.round(dcaautoadjust, 2)) : manualdca ? str.tostring(math.round(dcamanualadjust, 2)) : na, bgcolor = aqua, text_color = white)
table.cell(dataTable, 2, 9, text = longposition and autodca ? str.tostring(math.round(dcalongdifauto, 2)) : shortposition and autodca ? str.tostring(math.round(dcashortdifauto , 2)) : longposition and manualdca ? str.tostring(math.round(dcalongdifman, 2)) : shortposition and manualdca ? str.tostring(math.round(dcashortdifman, 2)) : na, bgcolor = blue, text_color = white)
// Price Table
var pricetable = table.new(position.bottom_left, columns = 3, rows = 3, border_color = color.black, border_width = 2)
// Labels
table.cell(pricetable, 1, 2, text = "Current Price", bgcolor = blue, text_color = white)
// Price
table.cell(pricetable, 2, 2, text = str.tostring(tickerclose), bgcolor = green, text_color = white) |
Hikkake Hunter 2.0 | https://www.tradingview.com/script/9faMfzbg-Hikkake-Hunter-2-0/ | SolCollector | https://www.tradingview.com/u/SolCollector/ | 110 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© SolCollector
// BS Computer Science
// Spencer G.
//
// This is a script that will identify both variants of the Hikkake patterns on
// a candlestick chart. This reworked version focuses on efficiency and flexibility
// to give the user a better experience when hunting for this specific candlestick
// pattern. It also serves as an educational tool to show the potential value
// User-Defined-Types (UDTs) may provide when creating complex scripts within the
// framework of a scripting language. Statistics will be conducted in real time
// on all patterns identified using this script, and these statistics will be
// displayed to the user when scrolling over the label of confirmed patterns.
//@version=5
indicator("Hikkake Hunter 2.0", overlay=true, max_labels_count = 100)
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// β __ ______ ______ β
// β / / / / __ \/_ __/____ β
// β / / / / / / / / / / ___/ β
// β / /_/ / /_/ / / / (__ ) β
// β \____/_____/ /_/ /____/ β
// β β
// β This script employs 4 different user-defined-types which keep track of β
// β relevant information that help this script process patterns. The four β
// β UDTs are: β
//#region β
// β returnArray - An object that contains information related to the returns β
// β of patterns (represented in % form). Each returnArray holds: β
// β β’ An array that holds all returns that a pattern has seen β
// β β’ The size of that array β
// β β’ The average of the returns β
// β β’ The median of the returns β
// β β’ The standard deviation of the returns β
// β β’ An array that contains the polarities of all returns* β
// β β
// β * Two inputs are related to this: i_NegativeRetTol and i_PositiveRetTol. β
// β This array holds 3 values: each corresponding to the negative, neutral, β
// β and positive returns a pattern may yield. If a pattern returns a % below β
// β i_NegativeRetTol, the value tracking negative returns will be incremented.β
// β If a pattern returns a % above i_PositiveRetTol, the value tracking β
// β positive returns will be incremented. Anything in between will be tracked β
// β as neutral. β
// β β
// β patternObj - An object that on creation will represent a Hikkake pattern β
// β to be processed for confirmation. This object holds: β
// β β’ An ID that declares which pattern this is (for this β
// β script 1 - Bullish, 2 - Bearish) β
// β β’ The number of candles that remain for a confirmation to β
// β be found β
// β β’ The number of candles needed to confirm the pattern β
// β β’ A target value that will need to be conditionally met β
// β to confirm the pattern β
// β β’ A boolean corresponding to the confirmation status of β
// β pattern (na if still processing) β
// β β’ The partition* that the pattern had been found in β
// β β’ The label created for this pattern β
// β β’ The tooltip for this label** β
// β β
// β * This partition value represents where in historical price action the β
// β pattern had been found in. All patterns will have their returns broken up β
// β into three different partitions and separated by the number of candles β
// β that were required to confirm them. Example: 2 bullish patterns that had β
// β required 1 candle to confirm would have their returns placed in different β
// β groups if one of these patterns had occurred near the top of a yearly β
// β trading range, and one occurred near the bottom of a yearly trading range.β
// β β
// β ** PineScrypt has a label.set_tooltip function but not a label.get_tooltipβ
// β function. This variable allows the creation of dynamic labels that adds β
// β information onto the tooltip of the label. This will be used to display β
// β the relevant statistics for all patterns when the user scrolls over the β
// β label (which includes displaying the return for that specific pattern). β
// β β
// β patConfirm - A simple object that corresponds to a linked-list reduction β
// β of the patternObj. It only contains the relevant information β
// β needed to retrieve elements from the matrix that holds all β
// β returns. The reason a linked-list data structure is used here β
// β is to allow multiple patterns to confirm on the same candle β
// β and still be able to back test for % change analysis. (Using β
// β the built-in array data structure proved tedious when trying β
// β to use historical reference). This UDT holds: β
// β β’ The type (ID) of the pattern β
// β β’ The number of candles needed to confirm β
// β β’ The partition this pattern was found in β
// β β’ A link to the next pattern that was confirmed β
// β β
// β point - A simple object that contains X,Y coordinates which β
// β correspond to initialized points in the matrix. This is mainlyβ
// β for efficiency, by cutting down on loops that analyze a matrixβ
// β of returnArrays to search for extremes (highest or lowest β
// β average or median returns of the matrix). These extremes will β
// β then be used for creating the gradient used in the adaptive β
// β coloring setting. β
// β β
// β Note: This script breaks PineCoders' script formatting guide on several β
// β occasions. Functions relevant to initializing/simple processing of values β
// β related to these UDTs will be placed by the UDTs themselves. Other times β
// β this convention is broken by the placement of certain inputs that some β
// β constants depend on, plot/fill calls, and alerts. β
//#endregion β
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Return Array is a user defined type to be used in the matrix that contains
// all returns of all types of patterns to be found by this hunter. The variables
// it utilizes are:
//
// @field returns Contains % representations of all returns for a pattern in an array.
// @field size The size of the returns array.
// @field stdDev The Standard Deviation of the values in the returns array.
// @field median The Median of the values in the returns array.
// @field avg The Average of the values in the returns array.
// @field polarities An array of size 3 that contains the respective polarities of the returns for that pattern (negative, neutral, positive).
type returnArray
float[] returns = na
int size = 0
float avg = 0
float median = 0
float stdDev = 0
int[] polarities = na
// Initializes the ReturnArray object to be placed into the matrix that keeps track
// of the returns for all patterns.
f_InitializeReturnArray() =>
returnArray initial =
returnArray.new(returns = array.new_float(), polarities = array.new_int(3, 0))
initial
// Pattern Obj(ect) is a UDT that will be initialized for a pattern to be processed
// by the confirmation logic in this script. It will contain:
//
// @field ID The identifier for this pattern.
// @field candlesLeft The number of candles that remain to confirm this pattern.
// @field ccandles The number of candles that were necessary to confirm this pattern.
// @field targetVal The target value to be tested against closes succeeding the pattern for finding confirmations.
// @field confirmed A boolean value that indicates if this pattern has been confirmed or not ('na' for patterns still processing).
// @field partition The partition of price action that this pattern was detected in.
// @field patLbl The label that is generated for this pattern.
// @field lblTooltip A string that contains the tooltip for the pattern label so it may be modified/updated at later points in this script's execution.
type patternObj
int ID = 0
int candlesLeft = -1
int ccandles = -1
float targetVal = -1.0
bool confirmed = na
int partition = -1
label patLbl = na
string lblTooltip = ""
// Append Return To Tip will display what a pattern has returned directly onto the
// tooltip of the pattern following the stats/'stats unavailable' section.
f_AppendReturnToTip(patternObj _pat, float _retVal) =>
formatStr = "\nThis Pattern Returned: " + str.tostring(_retVal, "#.####") + "%"
updateTooltip = _pat.lblTooltip + formatStr
label.set_tooltip(_pat.patLbl, updateTooltip)
_pat.lblTooltip := updateTooltip
// Pat(tern) Confirm is a UDT that acts as reductive linked list created only
// when a pattern has been confirmed. The reason a linked list is used is to
// ensure multiple patterns confirmed on the same candle will all be displayed
// properly. It was also necessary as I found historically referencing the built
// in array type was nearly impossible to implement properly. It contains:
//
// @field patType The type of pattern this confirmation corresponds to.
// @field ccandles The number of candles necessary to confirm this pattern.
// @field part The partition this pattern has appeared in.
// @field link The link to the next patConfirm object.
type patConfirm
int patType = 0
int ccandles = -1
int part = -1
patConfirm link = na
// Derive Confirmation Object returns the simplified object of the patternObj in
// a Linked-List form.
//
// @param:
// patternObj _pat - The current object that has been confirmed.
//
// @return:
// patConfirm - An object that contains the pattern ID, number of candles
// needed to confirm the pattern, the pattern's partition, and a 'na' link.
//
f_DeriveConfirmObj(patternObj _pat) =>
patConfirm pc = patConfirm.new(patType = _pat.ID, ccandles = _pat.ccandles,
part = _pat.partition)
pc
// Link Next Confirmed is an out-of-place feature function specific to the
// linked-list UDT to link the next patConfirm object in the chain of links
// supplied to it at the end. It will iterate through each link until the link
// is 'na' then place the new link at this point in the chain.
//
// @params:
// _head - (patConfirm) The head of the linked list.
// _link - (patConfirm) The link to be added to the supplied _head at the end.
//
// @returns:
// void
//
f_LinkNextConfirmed(patConfirm _head, patConfirm _link) =>
if na(_head)
_link
else
currHead = _head
tmp = _head.link
while not na(tmp)
tmp := tmp.link
tmp := _link
currHead
// Point is a simple container that will be used to keep track of which elements
// in a matrix have been initialized to cut down on excessive loops when
// generating a color gradient used for the patterns when they appear.
//
// @field x The row of the matrix to access for information.
// @field y The column of the matrix to access for information.
type point
int x = -1
int y = -1
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// β ____ __ __ __ β
// β / _/___ ____/ /__ ____ ___ ____ ____/ /__ ____ / /_ β
// β / // __ \/ __ / _ \/ __ \/ _ \/ __ \/ __ / _ \/ __ \/ __/ β
// β _/ // / / / /_/ / __/ /_/ / __/ / / / /_/ / __/ / / / /_ β
// β /___/_/ /_/\__,_/\___/ .___/\___/_/ /_/\__,_/\___/_/ /_/\__/ β
// β /_/ β
// β ______ __ __ β
// β / ____/___ ____ _____/ /_____ _____ / /______ β
// β / / / __ \/ __ \/ ___/ __/ __ `/ __ \/ __/ ___/ β
// β / /___/ /_/ / / / (__ ) /_/ /_/ / / / / /_(__ ) β
// β \____/\____/_/ /_/____/\__/\__,_/_/ /_/\__/____/ β
// β β
// β The constants in this section are independent of any inputs that may be β
// β used in part of their creation. These include an invisible color used for β
// β partition background coloring, group names for inputs, and a Ticker Stringβ
// β used in alerts. β
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
var color COLOR_INVIS = #00000000
var PARTG = "PARTITION SETTINGS"
var STATG = "STATISTICS SETTINGS"
var ALRTG = "ALERT SETTINGS"
var VISIG = "VISIBILITY SETTINGS"
var TICKERSTRING =
"Ticker: " + syminfo.tickerid + "\nResolution: " + timeframe.period + "\n"
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// β ____ __ β
// β / _/___ ____ __ __/ /______ β
// β / // __ \/ __ \/ / / / __/ ___/ β
// β _/ // / / / /_/ / /_/ / /_(__ ) β
// β /___/_/ /_/ .___/\__,_/\__/____/ β
// β /_/ β
// β β
// β This section comprises all inputs that will be available to the user to β
// β modify the behavior of this script. All inputs are denoted with an i_ β
// β before the name of the input; with input colors denoted with ic_. Each β
// β group of inputs affect a different portion of this script's behavior, β
// β broken up in such a way that makes sense when viewing these in the β
// β 'Settings' tab of the indicator. β
//#region β
// β MaxToConfirm - Sets the maximum number of candles allowed for β
// β confirming patterns. β
// β range: 2 - 5 (candles) β
// β defval: 3 β
// β dependencies: PERCENTRETURNS β
// β f_InitCustomLabel β
// β f_MatchConfig β
// β f_ConfirmPattern β
// β f_RunPatternConfirmation β
// β matrixRow (variable - main call block) β
// β β
// β AlertOn Booleans (+ functions): β
// β Find - Triggers an alert when a Hikkake pattern has been β
// β found. β
// β defval: false β
// β β
// β Confirm - Triggers an alert when a Hikkake pattern is confirmed. β
// β defval: false β
// β β
// β NonConfirm - Triggers an alert when a Hikkake pattern has not been β
// β confirmed within i_MaxToConfirm candles. β
// β defval: false β
// β β
// β WithReturn - Triggers an alert that displays the % return a pattern β
// β has yielded after it was found. β
// β defval: false β
// β β
// β Partition Settings: β
// β Resolution - Sets the resolution that OHLC values will be grabbed β
// β from for partitioning the graph into separate sections β
// β for grouping returns of patterns. β
// β defval: 'W' (weekly) β
// β β
// β RefLength - Sets the length at the Partition Resolution to find β
// β the highest high and lowest low from. β
// β defval: 52 (@ 'W' - grabs yearly high/low) β
// β β
// β UpperLimit - Sets the upper partition's lower limit to a specified β
// β progression through the range β
// β defval: 80* β
// β β
// β LowerLimit - Sets the lower partition's upper limit to a specified β
// β progression through the range. β
// β defval: 33* β
// β β
// β * The default values for these 4 inputs will designate the high of the β
// β yearly range to 80% of the range as the 'upper' section, 80% - 33% of the β
// β range as the 'middle' section, and below 33% - the yearly low as the β
// β 'lower' section. β
// β β
// β EnableBGColor - Shows the three bands that make up the upper, middle, β
// β and lower partitions. β
// β defval: false β
// β β
// β Color - (Upper/Middle/Lower) Sets the colors for the three β
// β partitions. β
// β defvals: green/yellow/red β
// β β
// β ColorOpacity - Opacity setting to change the transparency of the β
// β partition background coloring. β
// β defval: 75 (% opaque) β
// β β
// β Stats/Visual Settings: β
// β PnLSampleLength - Sets the number of candles ahead of the pattern to β
// β calculate the price difference. β
// β defval: 10 (candles ahead) β
// β β
// β PnLType - Determines which starting point to use in PnL β
// β calculations. β
// β defval: 'FROM CONFIRMATION' β
// β options: β
// β 'FROM CONFIRMATION': PnL Calculations will be done β
// β from the open immediately following the confirmation of β
// β a pattern. β
// β 'FROM APPEARANCE': PnL Calculations will be done by β
// β offsetting the calculation start and end points by the β
// β number of candles needed to confirm. β
// β β
// β MinReturnsNeeded - Sets the number of required patterns in each group β
// β before statistics are displayed onto the pattern label's β
// β tooltip (Also affects Adaptive Coloring Mode). β
// β defval: 5 β
// β β
// β Stats/Visual Settings: β
// β EnableAdaptCol - Enables Adaptive Coloring; Patterns will be assessed β
// β on bullish/bearishness and be colored based on prior β
// β performance. β
// β defval: false β
// β β
// β GradientRef - Sets which returnArray values from the matrix will be β
// β used for scaling bullish/bearish coloring by. β
// β defval: 'AVG' β
// β options: β
// β 'AVG': The average return of the patterns that qualify β
// β will be what is compared against the range of the β
// β minimum/maximum average of all returns in the matrix. β
// β 'MEDIAN': The median return of the patterns that qualify β
// β will be what is compared against the range of the β
// β minimum/maximum median of all returns in the matrix. β
// β β
// β GradColor - (Bullish/Neutral/Bearish) Sets the gradient colors to β
// β be used in Adaptive Coloring. β
// β defvals: Green/Yellow/Red β
// β β
// β NEIColor - Not Enough Info color. This color will be used when a β
// β pattern has fewer than MinReturnsNeeded occurrences in β
// β Adaptive Coloring mode. β
// β defval: #888B8D (aluminum gray) β
// β β
// β HardLimit - Alters color scheme to color patterns that exceed the β
// β Return Tolerances the fully bullish or bearish gradient β
// β colors. β
// β defval: false β
// β β
// βPositiveReturnTol - Sets the value patterns must return above after the β
// β specified number of candles for that return to be β
// β considered 'Positive'. β
// β defval: 3.0 (3%) β
// β step: 0.01 (0.01%) β
// β β
// βNegativeReturnTol - Sets the value patterns must return below after the β
// β specified number of candles for that return to be β
// β considered 'Negative'. β
// β defval: -3.0 (-3%) β
// β step: 0.01 (0.01%) β
// β β
// β LabelNudge - Bumps the label's Y-position further upward or β
// β downward based on a percentage of the candle's range β
// β it's been placed at. β
// β defval: 0.125 (12.5%) β
// β β
// β Standard Colors: β
// β 'ish'Color(s) - Sets the bullish and bearish colors for the labels and β
// β patterns that have been confirmed. β
// β defval: Green/Red β
// β β
// β Unconfirmed - Sets the color for the labels and patterns that have β
// β yet to be confirmed. β
// β defval: Yellow β
// β β
// β NonConfirmed - Sets the color for Non-confirmed patterns if the user β
// β has them enabled. β
// β defval: Black β
// β β
// β ShowNonConfirmed - Displays patterns that have not been confirmed. β
// β defval: false β
//#endregion β
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
i_MaxToConfirm = input.int(defval = 3, title = "Max Confirmation Candles",
minval = 2, maxval = 5, tooltip = "Changes how many candles may be allowed "
+ "until a confirmation is found.", group = "CONFIRMATION SETTING", confirm = true)
i_AlertOnFind = input.bool(defval = false, title = "On Find",
inline = "ALERTS", group = ALRTG)
i_AlertOnConfirm = input.bool(defval = false, title = "On Confirm",
inline = "ALERTS", group = ALRTG)
i_AlertOnNonConfirm = input.bool(defval = false, title = "On Non-Confirm",
inline = "ALERTS", group = ALRTG)
i_AlertWithReturn = input.bool(defval = false, title = "On Return",
tooltip = "Sets which alerts will be triggered during execution:\n\nFind "
+ "- Alert will trigger when a Hikkake pattern has been found.\nConfirm - "
+ "Alert will trigger when a Hikkake pattern has been confirmed.\n"
+ "Non-Confirmed - Alert will trigger when a Hikkake pattern has not been "
+ "confirmed.\nReturn - Alert will be triggered stating the % return that "
+ "Hikkake pattern had yielded.\n\nNote: This script uses the 'alert' "
+ "function and not 'alertcondition', These booleans must be set *before* "
+ "'all alert() calls' is enabled in TradingView's settings for your chart.",
inline = "ALERTS", group = ALRTG)
// Alert Functions: On Find - Will trigger an alert if a Hikkake pattern has been
// found/the alert has been enabled.
f_AlertOnFound(patternObj _pat) =>
if i_AlertOnFind
patString = str.substring(label.get_text(_pat.patLbl), 0, 16) + "Found"
alert(TICKERSTRING + patString)
// On Confirm - Will trigger an alert if a Hikkake pattern has been confirmed. This
// will also display the statistics associated with that pattern (viewable from the
// app by expanding the push notification).
f_AlertOnConfirm(patternObj _pat) =>
if i_AlertOnConfirm and _pat.confirmed
patString = str.substring(label.get_text(_pat.patLbl), 0, 16) + "Confirmed"
statString = _pat.lblTooltip
alert(TICKERSTRING + patString + "\n" + statString)
// On Non-Confirm - Will trigger an alert if the Hikkake pattern identified earlier
// had not been confirmed during its lifespan.
f_AlertOnNonConfirm(patternObj _pat) =>
if i_AlertOnNonConfirm and not (na(_pat.confirmed) or _pat.confirmed)
patternString = (_pat.ID == 1 ? "Bullish" : "Bearish") + " Hikkake"
unconfString = patternString + " Non-Confirmed"
alert(TICKERSTRING + unconfString)
// With Return - Will trigger an alert that displays the name of the confirmed Hikkake
// pattern and the percentage that pattern had returned over the number of candles
// specified by the i_PnLSampleLength input.
f_AlertWithReturn(patternObj _pat, float _val) =>
if i_AlertWithReturn
patString = str.substring(label.get_text(_pat.patLbl), 0, 16) + "returned: "
formatValStr = str.tostring(_val, "#.####") + "%"
fullStr = patString + formatValStr
alert(TICKERSTRING + fullStr)
i_PartitionResolution = input.timeframe(defval = "W", title = "Partition Resolution",
tooltip = "Defines which timeframe a price range will be grabbed from.", group = PARTG)
i_PartitionRefLength = input.int(defval = 52, title = "Partition Reference Length",
minval = 3, tooltip = "Sets how many candles back at the 'Partition Resolution' "
+ "to grab the price range from that separates the chart into three partitions."
+ "\n\nThe default values for 'Partition Resolution' and 'Partition Reference "
+ "Length' will have this script grab the 52-week 'high' and 52 week 'low' for "
+ "the range that breaks up the chart into these three separate sections.",
group = PARTG)
i_UpperPartitionLim = input.float(defval = 80, title = "Partition Limits: Upper",
minval = 50, maxval = 100, step = 0.01, group = PARTG, inline = "PARTITION BOUNDS")
i_LowerPartitionLim = input.float(defval = 33, title = "Lower",
minval = 0, maxval = 50, step = 0.01, tooltip = "Defines the upper and lower "
+ "bounds of the high-low range from the Reference Resolution/Length that will "
+ "break the range up into three sections.\n\nEx:\nResolution: 'W'\nReference "
+ "Length: 52\nUpper Limit: 80\nLower Limit: 33\n\nYearly High: 100\nYearly "
+ "Low: 50\nUpper Band will be 100 -> 90.\nMiddle Band will be 90 -> 66.66\n"
+ "Lower Band will be 66.66 -> 50", group = PARTG, inline = "PARTITION BOUNDS")
i_PartitionEnableBGColor = input.bool(false,
title = "Enable Partition Background Coloring",
tooltip = "Enabling this will show the three different partitions of the "
+ "chart's price action over the given Resolution and Length.", group = PARTG)
ic_PartitionUpperColor = input.color(defval = color.green ,
title = "Band Colors: Upper", inline = "BAND COLORS", group = PARTG)
ic_PartitionMiddleColor = input.color(defval = color.yellow ,
title = "Middle", inline = "BAND COLORS", group = PARTG)
ic_PartitionLowerColor = input.color(defval = color.red ,
title = "Lower", inline = "BAND COLORS", group = PARTG)
i_PartitionColorOpacity = input.int(75, title = "Partition Background Opacity",
minval = 0, maxval = 100, tooltip = "Determines how transparent the background "
+ "coloring of the partition shading will be (if enabled).", group = PARTG)
i_PnLSampleLength = input.int(defval = 10, title = "P/L Sample Length",
minval = 2, maxval = 20, tooltip = "Sets the number of candles from the "
+ "appearance of a pattern (or from confirmation) to calculate % Profit/Loss:"
+ "\n\nCalculation:\n(close[0 {+ # to confirm}] - open[P/L Sample{+ # to "
+ "confirm}]) / open[P/L Sample {+ # to confirm}]*\n\n* {} indicates additional "
+ "roll back if \"FROM APPEARANCE\" is selected.", group = STATG)
i_PnLType = input.string(defval = "FROM CONFIRMATION", title = "P/L Starting Point",
options = ["FROM CONFIRMATION", "FROM APPEARANCE"], tooltip = "Changes how "
+ "Profit/Loss calculations are conducted.\n\nFROM CONFIRMATION - P/L "
+ "Calculation will be done from the first open after the confirmation of a "
+ "pattern to the close \"P/L Sample Length\" candles later.\nFROM APPEARANCE "
+ "- P/L Calculation will be done from the first open after the appearance of "
+ "a pattern to the close \"P/L Sample Length\" candles later.", group = STATG)
i_MinReturnsNeeded = input.int(defval = 5, title = "Minimum Returns Needed",
minval = 3, maxval = 10, tooltip = "Defines the number of occurrences a pattern "
+ "must have in order for % PnL Stats to be displayed on the label's tooltip for "
+ "that pattern.", group = STATG)
i_EnableAdaptCol = input.bool(defval = false, title = "Enable Adaptive Coloring",
tooltip = "Changes the coloring of patterns based on statistics derived from "
+ "the prior occurrences of each pattern. The gradient colors below will be "
+ "substituted for the pattern coloration, however the default 'Bullish/Bearish "
+ "Hikkake Color(s)' further along will be used for the coloration of the labels."
+ " The color gradient will be created based on the 'Negative/Positive Return "
+ "Tolerance' values. These values will be changed if the 'Gradient Reference' "
+ "value chosen of any patterns that meet the minimum number of returns needed "
+ "exceed these values in either direction. The closer the pattern's 'Gradient "
+ "Reference' value is to the Tolerance values (or substituted values from the "
+ "set of returns), the stronger the coloration to their respective 'Gradient "
+ "Color' will be starting from the 'Neutral Color'.\n\nIf the pattern appeared "
+ "has not met the minimum number of prior instances, 'NEI Color' will be used "
+ "instead for that pattern's color.", group = STATG)
i_GradientRef = input.string(defval = "AVG", title = "Gradient Reference",
options = ["AVG", "MEDIAN"], tooltip = "AVG - The average return of the patterns "
+ "will be used for gradient generation.\nMEDIAN - The median return of the "
+ "patterns will be used for gradient generation.", group = STATG)
ic_BullishGradColor = input.color(defval = color.green , title = "Gradient Color: Bullish",
inline = "GRADCOLORS", group = STATG)
ic_NeutralGradColor = input.color(defval = color.yellow , title = "Neutral",
inline = "GRADCOLORS", group = STATG)
ic_BearishGradColor = input.color(defval = color.red, title = "Bearish",
tooltip = "Sets the colors used for generating the gradient in adaptive pattern "
+ "coloration.", inline = "GRADCOLORS", group = STATG)
// Not Enough information color (aluminum/light gray)
ic_NEIColor = input.color(defval = #888B8D, title = "NEI Color",
tooltip = "\'Not Enough Information\' Color. Color used for when there hasn't "
+ "been enough of that pattern detected to generate a color for.", group = STATG)
i_HardLimit = input.bool(defval = false, title = "Hard Limit", tooltip = "If enabled, "
+ "color gradient rules are changed so that any pattern which exceeds either "
+ "'Return Tolerance' values will be colored the full Bullish or Bearish gradient "
+ "colors.\n\nNote: This also affects the perceived 'strength' of less bullish/bearish "
+ "patterns. I recommended increasing the related Tolerances with this setting.",
group = STATG)
i_NegativeRetTol = input.float(defval = -3.0, title = "Negative Return Tolerance",
minval = -100, maxval = 0, step = 0.01, tooltip = "Defines the maximum % return "
+ "a pattern must be below after the specified number of candles to be considered"
+ " \"negative\".", group = STATG)
i_PositiveRetTol = input.float(defval = 3.0, title = "Positive Return Tolerance",
minval = 0, maxval = 100, step = 0.01, tooltip = "Defines the minimum % return "
+ "a pattern must be above after the specified number of candles to be considered"
+ " \"Positive\".\n\nNote: Returns that are between this tolerance and the "
+ "\"Negative Return Tolerance\" will be declared \"Neutral\".", group = STATG)
i_LabelNudge = input.float(title = "Label Nudge", defval = 0.125, step = 0.001,
maxval = 2.0, minval = 0, tooltip = "This floating point value will determine how "
+ "close/far away from the price points around identified patterns that the "
+ "labels will be placed.", group = VISIG)
ic_BullColor = input.color(title = "Bullish Hikkake Color", defval = color.green,
group = VISIG, inline ="Hikkake Colors")
ic_BearColor = input.color(title = "Bearish Hikkake Color", defval = color.red,
group = VISIG, inline ="Hikkake Colors")
ic_Unconfirmed = input.color(title = "Unconfirmed Hikkake Color",
defval = color.yellow, group = VISIG, inline = "Hikkake Colors")
ic_NonConfirmed = input.color(title = "Non Confirmed Hikkake Color",
defval = color.black, group = VISIG, inline = "Hikkake Colors")
i_ShowNonConfirmed = input.bool(title = "Show Non-Confirmed patterns",
defval = false, group = VISIG)
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// β ____ __ __ β
// β / __ \___ ____ ___ ____ ____/ /__ ____ / /_ β
// β / / / / _ \/ __ \/ _ \/ __ \/ __ / _ \/ __ \/ __/ β
// β / /_/ / __/ /_/ / __/ / / / /_/ / __/ / / / /_ β
// β /_____/\___/ .___/\___/_/ /_/\__,_/\___/_/ /_/\__/ β
// β /_/ β
// β ______ __ __ β
// β / ____/___ ____ _____/ /_____ _____ / /______ β
// β / / / __ \/ __ \/ ___/ __/ __ `/ __ \/ __/ ___/ β
// β / /___/ /_/ / / / (__ ) /_/ /_/ / / / / /_(__ ) β
// β \____/\____/_/ /_/____/\__/\__,_/_/ /_/\__/____/ β
// β β
// β This section contains all constants that will be used in the process of β
// β identifying, placing, and processing all patterns identified by this β
// β script. The majority of constants in this section depend values given to β
// β them by the inputs above. β
// β β
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Modify the opacity of the colors for partition coloring
var color UPPER_COLOR_MOD = color.new(ic_PartitionUpperColor, i_PartitionColorOpacity)
var color MIDDLE_COLOR_MOD = color.new(ic_PartitionMiddleColor, i_PartitionColorOpacity)
var color LOWER_COLOR_MOD = color.new(ic_PartitionLowerColor, i_PartitionColorOpacity)
// MATRIX SET UP FOR % RETURNS COLLECTION
// P1 P2 P3
// BULL1 x x x
// BULL2 x x x
// ...
// BULLN x x x
// BEAR1 x x x
// BEAR2 x x x
// ...
// BEARN x x x
//
// BxxxN -> N indicates the number of candles needed to confirm (specified by the user)
// P(1-3) -> Indicates the partition of established price history
//
// ctrl-f "MatrixSetup"
//
var PERCENTRETURNS = matrix.new<returnArray>((i_MaxToConfirm * 2), 3, na)
var UNCONFIRMEDHIKKAKES = array.new<patternObj>()
var RETURNLOCATIONS = array.new<point>()
// For color gradient generation.
float MINRETURNVAL = i_NegativeRetTol
float MAXRETURNVAL = i_PositiveRetTol
// Grab candle values of the previous three for pattern set-up detection
C1HIGH = high[3]
C1LOW = low[3]
C2HIGH = high[2]
C2LOW = low[2]
C2RANGE = C2HIGH - C2LOW
C3HIGH = high[1]
C3LOW = low[1]
// Used in label-positioning
HIGHEST3 = math.max(C1HIGH, C2HIGH, C3HIGH)
LOWEST3 = math.min(C1LOW, C2LOW, C3LOW)
HIGHLOW3RANGE = HIGHEST3 - LOWEST3
// Reusable values
CURRCLOSE = close
CURRBARSTATE = barstate.isconfirmed
// Initialize Linked-List
patConfirm confirmedPatternsLL = na
// Used in 'barcolor' calls, these arrays grant this script the
// ability to confirm and display multiple patterns simultaneously.
COLOROFFSET = array.new_int(6)
CANDLECOLOR = array.new_color(6)
// REQUEST.SECURITY CALLS -> This code creates the partitions that will be used
// to determine where along the specified resolution and sample length of price action
// patterns have occurred in.
// These variables and their respective plot() and fill() calls are kept together here to avoid
// confusion down the line (PineCoders' Style guide recommends these kinds of calls are moved
// closer to the end of this script).
BARINDREF = request.security(syminfo.tickerid, i_PartitionResolution, bar_index)
BARINDTERN = BARINDREF > i_PartitionRefLength ? i_PartitionRefLength : BARINDREF + 1
HIGHREF = request.security(syminfo.tickerid, i_PartitionResolution,
ta.highest(high, BARINDTERN))
LOWREF = request.security(syminfo.tickerid, i_PartitionResolution,
ta.lowest(low, BARINDTERN))
UPPERSECTION = ((HIGHREF - LOWREF) * (i_UpperPartitionLim / 100)) + LOWREF
LOWERSECTION = ((HIGHREF - LOWREF) * (i_LowerPartitionLim / 100)) + LOWREF
// Generate bands related to the above variables and display them
// (if the user wishes to)
REFLINE = plot(series = i_PartitionEnableBGColor ? HIGHREF : na,
title = "High Ref Line", color = COLOR_INVIS, editable = false)
UPPERLINE = plot(series = i_PartitionEnableBGColor ? UPPERSECTION : na,
title = "Upper Limit Line", color = COLOR_INVIS, editable = false)
LOWERLINE = plot(series = i_PartitionEnableBGColor ? LOWERSECTION : na,
title = "Lower Limit Line", color = COLOR_INVIS, editable = false)
PSEUDOZEROLINE = plot(series = i_PartitionEnableBGColor ? LOWREF : na,
title = "Zero Line", color = COLOR_INVIS, editable = false)
fill(plot1 = REFLINE, plot2 = UPPERLINE, color = UPPER_COLOR_MOD, editable = false)
fill(plot1 = UPPERLINE, plot2 = LOWERLINE, color = MIDDLE_COLOR_MOD, editable = false)
fill(plot1 = LOWERLINE, plot2 = PSEUDOZEROLINE, color = LOWER_COLOR_MOD, editable = false)
// Grabs the partition at the candle close directly before the appearance of a
// pattern. This value will be used to determine which returnArray returns for
// patterns will be added to, effectively dividing up the returns for each
// pattern based on which point in the yearly (default) price range that pattern
// had occurred in.
PARTITIONPOS = CURRCLOSE[4] >= UPPERSECTION ? 0 : CURRCLOSE[4] < UPPERSECTION
and CURRCLOSE[4] > LOWERSECTION ? 1 : 2
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// β ______ __ _ β
// β / ____/_ ______ _____/ /_(_)___ ____ _____ β
// β / /_ / / / / __ \/ ___/ __/ / __ \/ __ \/ ___/ β
// β / __/ / /_/ / / / / /__/ /_/ / /_/ / / / (__ ) β
// β /_/ \__,_/_/ /_/\___/\__/_/\____/_/ /_/____/ β
// β β
// β This section of code contains all functions that tear down analyzing the β
// β three previous candles and determine if a Hikkake pattern has been found. β
// β They are placed in order that they are called in the 'main' call block. β
// β β
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Init Custom label is a helper function that will initially create the label to
// identify an unconfirmed Hikkake pattern.
// This function will:
// 1. Identify which pattern it is intended for.
// 2. Place the label at the lows for bullish patterns, and highs for bearish.
// 3. Nudge the y-position of the label by a proportion of the middle candle's
// high-low range.
// 4. Place the label at the pattern's middle candle.
// 5. Colors the label initially by ic_Unconfirmed.
//
// @param
// _type - The type of pattern to initialize the label for. Corresponding
// values are 1 for the Bullish Hikkake Pattern. 2 for the Bearish
// Hikkake Pattern.
//
// @returns
// label - a newly generated label that indicates which type of pattern has
// occurred and how many candles (based on i_MaxToConfirm) are left to
// confirm that pattern.
//
f_InitCustomLabel(int _type) =>
nudgeRange = i_LabelNudge * HIGHLOW3RANGE
labelPos = _type == 1 ? LOWEST3 : HIGHEST3
labelNudgeVal = _type == 1 ? -nudgeRange : nudgeRange
labelStyle = _type == 1 ? label.style_label_up : label.style_label_down
builtLabelString =
(_type == 1 ? "Bullish " : "Bearish ") + "Hikkake Unconfirmed\n\n("
+ str.tostring(i_MaxToConfirm) + " candles remain)"
label.new(bar_index - 2, labelPos + labelNudgeVal, builtLabelString,
color = ic_Unconfirmed, style = labelStyle, textcolor = color.black)
// Match Config(uration) is a helper function which determines if a valid Hikkake
// setup pattern has been detected. This function will either yield 'na' or
// initialize a new patternObj for the corresponding Hikkake pattern that has been
// detected. If a pattern has been detected, this function will set the ID, number
// of candles to confirm the pattern (based on i_MaxToConfirm provided by the user),
// the target value depending on which pattern was detected, the current partition of
// the pattern when it was detected, and initializes the label for the pattern that
// will be updated throughout its lifespan.
//
// @returns:
// patternObj - A pattern object representing a found Hikkake pattern (both
// variants). It contains the number of candles left to confirm the
// pattern, the targetVal to confirm the pattern, the partition
// of price action the pattern was found in, and the label +
// tooltip associated with the pattern. 'na' otherwise.
//
f_MatchConfig() =>
// Both patterns need to have a nested second candle
secondCandleInside = C2HIGH < C1HIGH and C2LOW > C1LOW
// Test bullish and bearish cases
thirdCandleValidBear = C3HIGH > C2HIGH and C3LOW > C2LOW
thirdCandleValidBull = C3HIGH < C2HIGH and C3LOW < C2LOW
bearish = secondCandleInside and thirdCandleValidBear
bullish = secondCandleInside and thirdCandleValidBull
// Generate new Pattern Object for detected patterns, return
patternObj retObj = na
if bullish
retObj := patternObj.new(ID = 1, candlesLeft = i_MaxToConfirm,
targetVal = C2HIGH, partition = PARTITIONPOS, patLbl = f_InitCustomLabel(1))
if bearish
retObj := patternObj.new(ID = 2, candlesLeft = i_MaxToConfirm,
targetVal = C2LOW, partition = PARTITIONPOS, patLbl = f_InitCustomLabel(2))
retObj
// Matrix Min/Max is a helper function which will reference all initialized
// returnArray objects in the matrix and return the minimum and maximum
// values of the user-specified value (average or median return) of the matrix.
// These values will then be used to determine a color gradient to be used for
// patterns.
//
// @inputs:
// i_MinReturnsNeeded - Defines the minimum number of occurred patterns
// necessary to include the user-specified value of that
// pattern's return array as a part of the determination
// process.
// i_GradientRef - The specified statistics value to be used in comparing
// all returns in the matrix.
//
// @returns:
// minVal - The minimum value for the matrix.
// maxVal - The maximum value for the matrix.
f_MatrixMinMax() =>
pointListSize = array.size(RETURNLOCATIONS)
float minVal = na
float maxVal = na
if pointListSize != 0
for i = 0 to pointListSize - 1
pointV = array.get(RETURNLOCATIONS, i)
retRow = pointV.x
retCol = pointV.y
returnArr = matrix.get(PERCENTRETURNS, retRow, retCol)
if returnArr.size >= i_MinReturnsNeeded
valToAssign = i_GradientRef == "AVG" ? returnArr.avg : returnArr.median
minVal := na(minVal) or valToAssign < minVal ? valToAssign : minVal
maxVal := na(maxVal) or valToAssign > maxVal ? valToAssign : maxVal
[minVal, maxVal]
// Confirm Pattern is a helper function which takes in a pattern object and
// determines if the pattern is confirmed at the current candle in the
// confirmation process.
//
// @param:
// patternObj pat - Pattern Object which contains the pattern type,
// number of candles remaining, and the target value to
// be used in confirming the pattern.
//
// @return:
// bool - true/false if the pattern at its current point during the
// lifespan to confirm meets the requirements to confirm the
// pattern.
//
f_ConfirmPattern(patternObj _pat) =>
patType = _pat.ID
currCandle = i_MaxToConfirm - _pat.candlesLeft
confirmationTest = false
if patType == 1
confirmationTest := CURRCLOSE > _pat.targetVal[currCandle]
if patType == 2
confirmationTest := CURRCLOSE < _pat.targetVal[currCandle]
confirmationTest
// Update Label is a helper function which will update labels for both confirmed
// and unconfirmed patterns accordingly. For confirmed patterns, this function
// will:
// Display if the pattern is in the process of being confirmed.
// Display the number of candles required to confirm the pattern.
// Change the color of the label accordingly.
//
// For unconfirmed patterns, this will update the number of candles that remain
// for the pattern to be confirmed.
//
// @params:
// int _updateType - Tells this function which type of update will occur. 1
// for unconfirmed patterns, 2 for confirmed patterns.
// patternObj _pat - UDT that contains the label to be modified.
// color _confColor - Color to be set for the label (confirmed only).
//
// @returns:
// void
//
f_UpdateLabel(int _updateType, patternObj _pat, color _confColor = na) =>
textToMod = label.get_text(_pat.patLbl)
if _updateType == 1
currCandle = _pat.candlesLeft
// "Bxxxish Hikkake Unconfirmed\n\n(X {candle}s remain{s}"
// _______________________________ -> string length = 30 (\n = 1 character)
updateText = str.substring(textToMod, 0, 30)
plural = currCandle != 1
updateText := updateText + str.tostring(currCandle) + " candle"
+ (plural ? "s" : "") + " remain" + (plural ? "" : "s") + ")"
label.set_text(_pat.patLbl, updateText)
if _updateType == 2
// "Bxxxish Hikkake Unconfirmed\n\n(X {candle}s remain{s}"
// ________________ -> string length = 16
updateText = str.substring(textToMod, 0, 16)
updateText := updateText + "Confirm" + (CURRBARSTATE ? "ed" : "ing") + "\n\n("
updateText := updateText + str.tostring(_pat.ccandles) + " candle"
+ (_pat.ccandles == 1 ? "" : "s") + " needed)"
label.set_text(_pat.patLbl, updateText)
label.set_color(_pat.patLbl, _confColor)
// Grab Color From Gradient takes a returnArray object and determines the color
// needed for this object based on the statistics it contains compared to the
// upper and lower limits of the returns contained by the matrix. It will return
// the NEI color if the returnArray object's size does not contain enough data
// specified with i_MinReturnsNeeded.
//
// @inputs:
// i_MinReturnsNeeded - The minimum required returns for determining a
// color generated for that pattern.
// i_GradientRef - The specified returnArray stats value to be used
// in the gradient generation process.
// ic_BullishGradColor - The color that corresponds to patterns yielding above
// 0.
// ic_BearishGradColor - The color that corresponds to patterns yielding below
// 0.
// ic_NeutralGradColor - The color that will serve as an intermediary between
// bullish and bearish patterns.
// ic_NEIColor - The color to be used when the pattern does not meet
// i_MinReturnsNeeded.
//
// @param:
// returnArray _retArr - The array that contains the necessary information to
// generate a color out of the gradient for that pattern.
//
// @returns:
// color - Either NEIColor OR a color along the gradient corresponding to
// the (bull/bear)ishness of that pattern compared to others in the matrix
// dataset.
//
f_GrabColorFromGrad(returnArray _retArr) =>
if _retArr.size < i_MinReturnsNeeded
ic_NEIColor
else
gradientVal = i_GradientRef == "AVG" ? _retArr.avg : _retArr.median
if gradientVal > 0
if i_HardLimit and gradientVal > MAXRETURNVAL
ic_BullishGradColor
else
color.from_gradient(gradientVal, 0, MAXRETURNVAL, ic_NeutralGradColor,
ic_BullishGradColor)
else
if i_HardLimit and gradientVal < MINRETURNVAL
ic_BearishGradColor
else
color.from_gradient(gradientVal, MINRETURNVAL, 0, ic_BearishGradColor,
ic_NeutralGradColor)
// Display Stats on Label will take all of the relevant statistics from a
// returnArray matrix entry for a specific pattern, and display them onto the
// tooltip of the pattern's label. When the user scrolls over the pattern label,
// it will display:
//
// - The partition of the chart the pattern has been found in.
// - The number of previous instances.
// - The median return for that pattern.
// - The average return for that pattern.
// - The standard deviation of returns for that pattern.
// - A 95% confidence interval of the expected return for this pattern.
// - The current number of negative, neutral, and positive returns this pattern
// has experienced.
//
// If the pattern has not occurred at least i_MinReturnsNeeded times, it will
// instead specify an 'return stats unavailable' message with the number of
// patterns needed.
//
// @input:
// i_MinReturnsNeeded - The number of patterns that need to occur before the
// statistics of the pattern is displayed on the tooltip.
//
// @params:
// patternObj _p - The pattern to assess data from (partition) and the
// label/tooltip to be modified.
// returnArray _r - The returnArray that contains all stats on the pattern
// that has occurred.
//
// @returns:
// void
//
f_DisplayStatsOnLabel(patternObj _p, returnArray _r) =>
updateTooltip = ""
sizeStr = str.tostring(_r.size)
partString = switch _p.partition
0 => "Upper"
1 => "Middle"
2 => "Lower"
partString := partString + " Section"
if _r.size >= i_MinReturnsNeeded
stdDevStr = str.tostring(_r.stdDev, "#.####")
medianStr = str.tostring(_r.median, "#.####")
averageStr = str.tostring(_r.avg, "#.####")
// CONFIDENCE INTERVAL CALC (ASSUMES NORMAL DISTRIBUTION):
// CI = avg Β± (Z * (Ο / βn))
// Z -> Z-score for 95% intervals (~1.96)
// Ο -> standard deviation of the set
// n -> number of elements in the set
CILower = str.tostring(_r.avg -
(1.96 * (_r.stdDev / math.sqrt(_r.size))), "#.####") + "%"
CIUpper = str.tostring(_r.avg +
(1.96 * (_r.stdDev / math.sqrt(_r.size))), "#.####") + "%"
negReturns = array.get(_r.polarities, 0)
neuReturns = array.get(_r.polarities, 1)
posReturns = array.get(_r.polarities, 2)
totReturns = negReturns + neuReturns + posReturns
negRetStr = str.tostring(negReturns) + " (" +
str.tostring((negReturns / totReturns) * 100, "#.####") + "%)"
neuRetStr = str.tostring(neuReturns) + " (" +
str.tostring((neuReturns / totReturns) * 100, "#.####") + "%)"
posRetStr = str.tostring(posReturns) + " (" +
str.tostring((posReturns / totReturns) * 100, "#.####") + "%)"
combinedString = "Return Stats:\n\nPartition: "+ partString
+ "\nPrevious Instances: " + sizeStr
+ "\nMedian Return: " + medianStr + "%"
+ "\nAverage Return: " + averageStr + "%"
+ "\nStandard Deviation: Β±" + stdDevStr + "%"
+ "\n95% Confidence Interval: [" + CILower + ", " + CIUpper + "]"
+ "\nNegative Returns: " + negRetStr
+ "\nNeutral Returns: " + neuRetStr
+ "\nPositive Returns: " + posRetStr
updateTooltip := combinedString
else
updateTooltip := "Return Stats (Unavailable):\n\nPartition: " + partString
+ "\nPrevious Instances: " + sizeStr + "\n\n"
+ str.tostring(i_MinReturnsNeeded - _r.size) + " more patterns needed."
label.set_tooltip(_p.patLbl, updateTooltip)
_p.lblTooltip := updateTooltip
// Run Pattern Confirmation is the overarching logic function that determines if
// a pattern meets the requirements to be confirmed and subsequently sets the
// values in the object associated with that pattern to reflect this confirmation.
// This function heavily relies on the use of the CURRBARSTATE variable, thus
// repainting patterns/their labels during the currently-closing candle.
//
// @inputs:
// i_MaxToConfirm - Used here to determine confirmation candles, matrix
// positions, and which candles to color.
// i_EnableAdaptCol - Determines the altered color scheme for patterns.
//
// @param:
// patternObj _patObj - The current pattern being evaluated for confirmation.
// The values of this object are to be changed when it has
// been confirmed, and the label properly updated throughout
// the lifespan of the pattern.
//
// @return:
// bool - true if a pattern has been confirmed or has reached the end of its
// lifespan.
// false if the pattern is still unconfirmed after a bar-close.
//
f_RunPatternConfirmation(patternObj _patObj) =>
patConfirmed = f_ConfirmPattern(_patObj)
barstateOffset = CURRBARSTATE ? 0 : 1
if patConfirmed
// Only decrement candlesLeft/set confirmed boolean after bar-close
_patObj.candlesLeft :=
CURRBARSTATE ? _patObj.candlesLeft - 1 : _patObj.candlesLeft
_patObj.ccandles := i_MaxToConfirm - _patObj.candlesLeft + barstateOffset
_patObj.confirmed := CURRBARSTATE ? true : na
confColor = _patObj.ID == 1 ? ic_BullColor : ic_BearColor
f_UpdateLabel(2, _patObj, confColor)
// MatrixSetup
// Bullish Confirmed Patterns will be rows 0 -> i_MaxToConfirm - 1
// Bearish Confirmed Patterns will be rows i_MaxToConfirm -> 2 * i_MaxToConfirm - 1
// Columns will be the partitions in which the patterns have appeared.
returnMatrixRow = (_patObj.ID == 1 ? 0 : i_MaxToConfirm) + (_patObj.ccandles - 1)
returnMatrixCol = _patObj.partition
returnArrObj = matrix.get(PERCENTRETURNS, returnMatrixRow, returnMatrixCol)
// Initialize the returnArray if it hasn't been yet, reassign (necessary).
if na(returnArrObj)
matrix.set(PERCENTRETURNS, returnMatrixRow, returnMatrixCol, f_InitializeReturnArray())
returnArrObj := matrix.get(PERCENTRETURNS, returnMatrixRow, returnMatrixCol)
// Only add new points when these returns are initialized.
array.push(RETURNLOCATIONS, point.new(x = returnMatrixRow, y = returnMatrixCol))
// This will keep the label color the same, while changing the color of the
// bars at the pattern.
if i_EnableAdaptCol
confColor := f_GrabColorFromGrad(returnArrObj)
// Display stats on label,
f_DisplayStatsOnLabel(_patObj, returnArrObj)
array.push(COLOROFFSET, _patObj.ccandles)
array.set(CANDLECOLOR, _patObj.ccandles - 1, confColor)
true
else
// RetVal used here to force code past if...else block to execute.
bool retVal = na
// Decrement on non-confirms
_patObj.candlesLeft := CURRBARSTATE ? _patObj.candlesLeft - 1 : _patObj.candlesLeft
if _patObj.candlesLeft == 0
_patObj.confirmed := false
label.delete(_patObj.patLbl)
retVal := true
// Unconfirmed patterns update
else
f_UpdateLabel(1, _patObj)
retVal := false
// Add the color to the correct indices for candle coloring
candleColorIndex = (i_MaxToConfirm - _patObj.candlesLeft)
array.push(COLOROFFSET, candleColorIndex + barstateOffset)
array.set(CANDLECOLOR, candleColorIndex, candleColorIndex == i_MaxToConfirm ? na : ic_Unconfirmed)
// handle non-confirmed coloration
if retVal and i_ShowNonConfirmed
array.push(COLOROFFSET, i_MaxToConfirm)
array.set(CANDLECOLOR, i_MaxToConfirm - 1, ic_NonConfirmed)
retVal
// Calculate Percent Return will calculate from open->close the percent change
// in price for a specified length (at an offset if specified).
//
// @params:
// _length - How far back to grab the open from previous price data.
// _offset - The number of candles to offset this open value with
// (mainly for "FROM APPEARANCE" setting, this offset is
// typically the number of candles required for confirmation).
//
// @return:
// float - The percent change (ratio multiplied by 100) of the close[_offset]
// compared to the open[_length + _offset] candles ago.
//
f_CalculatePercentReturn(int _length, int _offset) =>
openAt = open[_length + _offset]
closeAfter = close[_offset]
percentRet = ((closeAfter - openAt) / openAt) * 100
percentRet
// This function will append the given return array with a new return. It will
// also update all relevant statistics for that return array:
// The array's size
// Array's average
// Array's median
// Array's standard deviation
// Which polarity of returns this pattern has impacted
//
// @inputs:
// i_(Nega/Posi)tiveRetTol - These two inputs specify which polarities to
// change dependent upon the _returnVal to be added.
//
// If the _returnVal is:
// <= i_NegativeRetTol -> increment negative val
// > i_NegativeRetTol & < i_PositiveRetTol ->
// increment neutral val
// >= i_PositiveRetTol -> increment positive val
//
// @params:
// returnArray _r - The return array that corresponds to this pattern.
// float _returnVal - The value to add to the returnArray's collection and
// generate statistics from.
//
// @returns:
// void
//
f_AddReturnAndUpdate(returnArray _r, float _returnVal) =>
array.push(_r.returns, _returnVal)
polarityToInc = _returnVal <= i_NegativeRetTol ? 0 : _returnVal >
i_NegativeRetTol and _returnVal < i_PositiveRetTol ? 1 : 2
currPolVal = array.get(_r.polarities, polarityToInc)
array.set(_r.polarities, polarityToInc, currPolVal + 1)
_r.size := _r.size + 1
_r.stdDev := array.stdev(_r.returns)
_r.median := array.median(_r.returns)
_r.avg := array.avg(_r.returns)
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// β __ ___ _ ______ ____ ____ __ __ β
// β / |/ /___ _(_)___ / ____/___ _/ / / / __ )/ /___ _____/ /__ β
// β / /|_/ / __ `/ / __ \ / / / __ `/ / / / __ / / __ \/ ___/ //_/ β
// β / / / / /_/ / / / / / / /___/ /_/ / / / / /_/ / / /_/ / /__/ ,< β
// β /_/ /_/\__,_/_/_/ /_/ \____/\__,_/_/_/ /_____/_/\____/\___/_/|_| β
// β β
// β This section will utilize all the defined functions above to identify β
// β Hikkake patterns and process them through their lifespan. It creates the β
// β alerts, places labels, processes confirmations, performs the % return β
// β analysis, and colors bars to user specification. β
// β β
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
if bar_index > 3
hikkakeTestVal = f_MatchConfig()
if not na(hikkakeTestVal)
array.push(UNCONFIRMEDHIKKAKES, hikkakeTestVal)
f_AlertOnFound(hikkakeTestVal)
unconfSize = array.size(UNCONFIRMEDHIKKAKES)
updateNecessary = unconfSize != 0
// Only run testing logic when there was a recently found or confirmed hikkake.
if updateNecessary
// Stack -> FILO enforced
indicesToRemove = array.new<int>()
for i = 0 to unconfSize - 1
patToTest = array.get(UNCONFIRMEDHIKKAKES, i)
// This must be done first because f_GrabColorFromGrad references the
// global variables MIN/MAXRETURNVAL (function variables cannot be mutable).
if i_EnableAdaptCol
if not i_HardLimit
[min, max] = f_MatrixMinMax()
MINRETURNVAL := na(min) or min > MINRETURNVAL ? MINRETURNVAL : min
MAXRETURNVAL := na(max) or max < MAXRETURNVAL ? MAXRETURNVAL : max
confirmed = f_RunPatternConfirmation(patToTest)
if confirmed
array.push(indicesToRemove, i)
f_AlertOnConfirm(patToTest)
f_AlertOnNonConfirm(patToTest)
// Pop all items from the stack and remove them from the UNCONFIRMEDHIKKAKES
// array in reverse order to avoid corrupting that array (reverse order
// prevents index-out-of-bounds errors/removing unconfirmed patterns as
// though they had been confirmed).
indicesRemovedSize = array.size(indicesToRemove)
// The loop will attempt to execute even if the size of the array is 0
// and even if the step specified is 'by +1'
if indicesRemovedSize != 0
for j = 0 to indicesRemovedSize - 1
currInd = array.pop(indicesToRemove)
patternRem = array.remove(UNCONFIRMEDHIKKAKES, currInd)
if patternRem.confirmed
confirmedPatternsLL :=
f_LinkNextConfirmed(confirmedPatternsLL, f_DeriveConfirmObj(patternRem))
// +1 used here to properly offset % return calculations since confirmation objects are
// created on the candle that had confirmed the pattern; not the candle where price
// difference measurements are initiated.
confPatLLBacktest = confirmedPatternsLL[i_PnLSampleLength + 1]
if not na(confPatLLBacktest) and CURRBARSTATE
tmp = confPatLLBacktest
while not na(tmp)
patType = confPatLLBacktest.patType
confCandles = confPatLLBacktest.ccandles
matrixRow = (patType == 1 ? 0 : i_MaxToConfirm) + (confCandles - 1)
matrixCol = confPatLLBacktest.part
returnArrToAppend = matrix.get(PERCENTRETURNS, matrixRow, matrixCol)
PnLOffset = i_PnLType == "FROM CONFIRMATION" ? 0 : confCandles
percentReturned = f_CalculatePercentReturn(i_PnLSampleLength, PnLOffset)
hikkakeBackTest = hikkakeTestVal[i_PnLSampleLength + confCandles]
f_AddReturnAndUpdate(returnArrToAppend, percentReturned)
// Add return to the label created for this pattern.
f_AppendReturnToTip(hikkakeBackTest, percentReturned)
f_AlertWithReturn(hikkakeBackTest, percentReturned)
tmp := tmp.link
// barcolor() does not like variables for the offset, no idea why.
barcolor(color=array.includes(COLOROFFSET, 6) ? array.get(CANDLECOLOR, 5) : na, offset=-8)
barcolor(color=array.includes(COLOROFFSET, 6) ? array.get(CANDLECOLOR, 5) : na, offset=-7)
barcolor(color=array.includes(COLOROFFSET, 6) ? array.get(CANDLECOLOR, 5) : na, offset=-6)
barcolor(color=array.includes(COLOROFFSET, 5) ? array.get(CANDLECOLOR, 4) : na, offset=-7)
barcolor(color=array.includes(COLOROFFSET, 5) ? array.get(CANDLECOLOR, 4) : na, offset=-6)
barcolor(color=array.includes(COLOROFFSET, 5) ? array.get(CANDLECOLOR, 4) : na, offset=-5)
barcolor(color=array.includes(COLOROFFSET, 4) ? array.get(CANDLECOLOR, 3) : na, offset=-6)
barcolor(color=array.includes(COLOROFFSET, 4) ? array.get(CANDLECOLOR, 3) : na, offset=-5)
barcolor(color=array.includes(COLOROFFSET, 4) ? array.get(CANDLECOLOR, 3) : na, offset=-4)
barcolor(color=array.includes(COLOROFFSET, 3) ? array.get(CANDLECOLOR, 2) : na, offset=-5)
barcolor(color=array.includes(COLOROFFSET, 3) ? array.get(CANDLECOLOR, 2) : na, offset=-4)
barcolor(color=array.includes(COLOROFFSET, 3) ? array.get(CANDLECOLOR, 2) : na, offset=-3)
barcolor(color=array.includes(COLOROFFSET, 2) ? array.get(CANDLECOLOR, 1) : na, offset=-4)
barcolor(color=array.includes(COLOROFFSET, 2) ? array.get(CANDLECOLOR, 1) : na, offset=-3)
barcolor(color=array.includes(COLOROFFSET, 2) ? array.get(CANDLECOLOR, 1) : na, offset=-2)
barcolor(color=array.includes(COLOROFFSET, 1) ? array.get(CANDLECOLOR, 0) : na, offset=-3)
barcolor(color=array.includes(COLOROFFSET, 1) ? array.get(CANDLECOLOR, 0) : na, offset=-2)
barcolor(color=array.includes(COLOROFFSET, 1) ? array.get(CANDLECOLOR, 0) : na, offset=-1) |
Correlation prix [SP500, TESLA, BTC | https://www.tradingview.com/script/bFJsDGVL/ | AmosTradingSystem | https://www.tradingview.com/u/AmosTradingSystem/ | 14 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Β© AmosTradingSystem
//I multiplied the tesla price 116x to see it on the BTC chart. in fact if we multiply the closing price of tesla by 116 times we will get the price of btc...
//...Same mathematical operation for SP500 which is on average 5.6 times lower than the price of BTC. By multiplying the closing price of Sp500 we will obtain a
//...line that we can superimpose on the price of BTC.
//@version=5
indicator("Correlation prix [SP500, TESLA, BTC", shorttitle = "SP_TE_BTC", overlay = true)
SP500 = request.security("SPX", "60", close* 5.6)
Tesla = request.security("TSLA", "60", close* 114)
//The closing price of BTC
Btc = close
Btc1 = open
// This is the average of the price between SP500 and TESLA
SP_TE = (SP500 + Tesla) / 2
//The average of the price between BTC and the previously calculated average between SP500 and Tesla
BTC_SP_TE= (Btc + SP_TE) /2
//plot(SP500, "SP500", color=color.new(color.blue,5), linewidth = 4)
//plot(Tesla, "tesla", color=color.rgb(204, 145, 35), linewidth = 4)
//plot(Btc,"BTC", color=color.white, linewidth = 2)
//This is the average drawing
//plot(SP_TE, "SP_TE", color =color.fuchsia, linewidth = 4)
//plot(BTC_SP_TE,"BTC_SP_TE", color=color.green, linewidth = 4)
color1 = BTC_SP_TE < Btc ? color.new(color.green,70) : color.new(color.fuchsia,70)
plot1=plot(Btc, color= color1, linewidth = 2)
plot2=plot(BTC_SP_TE, color= color1, linewidth = 2)
fill(plot1, plot2, color1)
plotchar(BTC_SP_TE < Btc and Btc > Btc1[10] and Btc1 > Btc[1], "Moyen BTC_SP_Te", "β²", location.belowbar, size = size.small)
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.