0% found this document useful (0 votes)
91 views18 pages

SCRIPT Koncorde

The document is a Pine Script code for a trading indicator named 'Koncorde Plus', which includes various functionalities such as price value retrieval, pattern display options, and multiple technical analysis tools like MACD, RSI, and Stochastic. It allows users to customize settings for different indicators, including moving averages and volume analysis, and provides options for alerting based on certain conditions. The script also defines functions for calculating the PVI and NVI, as well as a volume-adjusted moving average.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views18 pages

SCRIPT Koncorde

The document is a Pine Script code for a trading indicator named 'Koncorde Plus', which includes various functionalities such as price value retrieval, pattern display options, and multiple technical analysis tools like MACD, RSI, and Stochastic. It allows users to customize settings for different indicators, including moving averages and volume analysis, and provides options for alerting based on certain conditions. The script also defines functions for calculating the PVI and NVI, as well as a volume-adjusted moving average.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

//@version=5

indicator("Koncorde Plus", "Koncorde [+]")

f_getPriceValue(_htf) =>
var value = 0.
if ta.change(time(_htf))
value := close[1]
value

f_crossingLevel(_curret, _level) =>


_level > _curret and _level < _curret[1] or _level < _curret and _level > _curret[1]

alarm(_cond, _message, _htfUser, _oncePerBarClose) =>


if _cond
alert(_message + '\n' + syminfo.ticker + ' Price (' + str.tostring(close,
format.mintick) + '), Timeframe ' + _htfUser + '\n')
if _oncePerBarClose
alert(_message + '\n' + syminfo.ticker + ' Price (' + str.tostring(close,
format.mintick) + '), Timeframe ' + _htfUser + '\n', alert.freq_once_per_bar_close)

g_pattern = "Koncorde : Pattern � � �"


show_K = input.bool(true, "⏩ Show Koncorde", inline="p0", group=g_pattern)
show_cero = input.bool(true, "Zero Pattern", inline="p0", group=g_pattern)
char_up_cero = input.string("▲", "", inline="p0", group=g_pattern)
show_espejo = input.bool(true, "Mirror Pattern", inline="p1", group=g_pattern)
col_espejo = input.color(color.new(color.aqua, 85), "", inline="p1", group=g_pattern)
show_oso = input.bool(false, "Bear Hug Pattern", inline="p2", group=g_pattern)
col_oso = input.color(color.new(color.red, 85), "", inline="p2", group=g_pattern)
show_arpon = input.bool(true, "Harpoon Pattern", inline="p3", group=g_pattern)
char_up_arp = input.string("⇗", "", inline="p3", group=g_pattern)
char_dn_arp = input.string("⇗", "", inline="p3", group=g_pattern)
show_primavera = input.bool(false, "Spring Pattern", inline="p4", group=g_pattern)
char_up_primavera = input.string("▲", "", inline="p4", group=g_pattern)
show_cruces = input.bool(false, "Crossing Pattern", inline="p5", group=g_pattern)
char_up_cruce = input.string("▲", "", inline="p5", group=g_pattern)
char_dn_cruce = input.string("▼", "", inline="p5", group=g_pattern)

show_macd = input.bool(true, "⏩ Show MACD Dots", inline = "0_macd")


show_macd3 = input.bool(false, "⏩ MACD Plot", inline = "0_macd")
show_macdv = input.bool(false, "Use Volatility", inline = "0_macd")
show_rsi = input.bool(false, "⏩ Show RSI & MFI", inline = "0_rsi")
option_rsi = input.string("RSI", " ⇗ Option", options=["RSI", "MFI", "AVG(RSI, MFI)",
"Ultimate RSI"], inline = "0_rsi")
show_rsi_sig = input.bool(false, "Use Signal Line", inline = "0_rsi")
show_stoc = input.bool(false, "⏩ Show Stochastic")
show_DVDI = input.bool(false, "⏩ Dual Volume Divergence Index", inline="0_dv")
mode = input.string("Oscillator Mode", " ⇗ Mode", inline="0_dv", options=["Cloud
Mode", "Oscillator Mode", "Bar Counter Mode"])
show_delta = input.bool(false, "⏩ Show Volume Delta Arrows")
show_tsv = input.bool(false, "⏩ Show Enhanced Time Segmented Volume [TSV]")

group_stat = "Statistic Panel"


chgStat = input.bool(false, "⇗ Performance || Distance to MA ⇗", inline="PD",
group=group_stat, tooltip="Performance , displays values from the beginning of the month,
week, year, etc\n\nDistance from/to MA - Multi TimeFrame Price Distance from/to MA")
pmaStat = input.bool(true, "", inline="PD", group=group_stat)
statSize = input.string("Small", "Statistic Panel Text Size", options=['Tiny', 'Small',
'Normal'], group=group_stat)
textSize = statSize == "Small" ? size.small : statSize == "Normal" ? size.normal :
size.tiny
maAlarm = input.bool(true, "Enable Moving Average Alerts", group=group_stat, tooltip =
"MA alerts : price crossing ma levels detection")

type_ma1 = input.string("EMA", "MA 1", options=["T3", "SMA", "EMA", "Wilder", "ALMA",


"WMA", "VWMA", "D_SMA", "D_EMA", "D_WMA", "VAMA"], inline="ma1", group=group_stat)
length_ma1 = input.int(9, "Length", minval = 1, inline="ma1", group=group_stat)
source_ma1 = input.source(hlcc4, "Source", inline="ma1", group=group_stat)

type_ma2 = input.string("EMA", "MA 2", options=["T3", "SMA", "EMA", "Wilder", "ALMA",


"WMA", "VWMA", "D_SMA", "D_EMA", "D_WMA", "VAMA"], inline="ma2", group=group_stat)
length_ma2 = input.int(50, "Length", minval = 1, inline="ma2", group=group_stat)
source_ma2 = input.source(close, "Source", inline="ma2", group=group_stat)

type_ma3 = input.string("SMA", "MA 3", options=["T3", "SMA", "EMA", "Wilder", "ALMA",


"WMA", "VWMA", "D_SMA", "D_EMA", "D_WMA", "VAMA"], inline="ma3", group=group_stat)
length_ma3 = input.int(200, "Length", minval = 1, inline="ma3", group=group_stat)
source_ma3 = input.source(close, "Source", inline="ma3", group=group_stat)

g_trend = "Koncorde Trend"


tprice = input.source(ohlc4, "RSI, BB & Stoch Source", group = g_trend)
srcMfi = input.source(hlc3, "MFI Source", group = g_trend)
len_mfi_rsi = input.int(9, "MFI & RSI Length", 1, group = g_trend)
length_bb = input.int(18, "BB Length", 1, inline="bb", group = g_trend)
mult_bb = input.float(2.0, "BB Multiplier", 1, inline="bb", group = g_trend)
length_ma01 = input.int(18, "MA Length", 1, inline="ma1", group = g_trend)
type_ma01 = input.string("EMA", "Type", inline="ma1", group = g_trend, options=["T3",
"SMA", "EMA", "Wilder", "WMA", "VWMA", "ALMA", "LSMA", "HMA", "VAMA", "JMA", "RSS_WMA"])
// VAMA factor
factor = input.float(0.67, "Factor (if VAMA)", minval = 0.01, step = 0.1, inline = "v_l",
group = g_trend)
// LSMA Offset
loff = input.int(0, "Offset (if LSMA)", minval=0, inline = "v_l", group = g_trend)
// ALMA Offset and Sigma
offs = input.float(0.85, "Offset (if ALMA)", step=0.01, minval=0, inline = "alma", group
= g_trend)
sigma = input.int(6, "Sigma (if ALMA)", minval=0, inline = "alma", group = g_trend)
// JMA
phaseJ = input.int(50, "Phase (if JMA)", inline = "jma", group = g_trend)
powerJ = input.int(2, "Power (if JMA)", inline = "jma", group = g_trend)

m_pvi_nvi = input.int(9, "PVI & NVI Length", 1, group="Koncorde Volume")


longitudPVI = input.int(90, "Min-Max Period [PVI]", 2, group="Koncorde Volume")
longitudNVI = input.int(90, "Min-Max Period [NVI]", 2, group="Koncorde Volume")

group_macd = "Moving Average Convergence Divergence [MACD]"


tool_atr = "Used to gauge volatility to standardize MACD. Keep at the same value as the
MACD Slow Length parameter for best results."
macd_src = input.source(close, "Source", inline="macd1", group = group_macd)
show_macd2 = input.bool(false, "Show Bars Color", inline="macd1", group = group_macd)
macd_fast = input.int(9, "Length: Fast", 1, inline = "macd2", group = group_macd)
macd_slow = input.int(18, "Slow", 2, inline = "macd2", group = group_macd)
macd_sig = input.int(4, "Signal", 1, inline = "macd2", group = group_macd)
atr_length = input.int(18, "ATR Length", 2, inline = "macdv", group = group_macd,
tooltip = tool_atr)

group_rsi = "Relative Strength Index & Money Flow Index"


rsiLengthInput = input.int(9, "Length", minval=1, inline = "rsi0", group =
group_rsi)
rsiSourceInput = input.source(close, "Source", inline = "rsi0", group = group_rsi)
show_rsi2 = input.bool(false, "Show Bars Color", inline = "rsi0", group =
group_rsi)
maTypeInput = input.string("EMA", "MA Type", options=["T3", "SMA", "D_SMA", "Wilder",
"EMA", "D_EMA", "ALMA", "WMA", "D_WMA", "VWMA", "VAMA"], inline = "rsi1", group =
group_rsi)
maLengthInput = input.int(9, "MA Length", inline = "rsi1", group = group_rsi)
obValue = input.float(80, "Overbought", inline = 'rsi_o', group = group_rsi)
osValue = input.float(20, "Oversold", inline = 'rsi_o', group = group_rsi)

group_stoc = "Stochastic"
periodK = input.int(9, "%K Length", 1, group = group_stoc)
smoothK = input.int(7, "%K Smoothing", 1, group = group_stoc)
periodD = input.int(4, "%D Smoothing", 1, group = group_stoc)
ob_stoc = input.float(80, "Overbought", inline = "stoc_o", group = group_stoc)
os_stoc = input.float(20, "Oversold", inline = 'stoc_o', group = group_stoc)

group_DVDI = "Dual Volume Divergence Index"


show_bar_dvdi = input.bool(false, "Show Bars Color", inline="extra2", group = group_DVDI)
src = input.source(close, "Source", group = group_DVDI) // Source
// Sampling Period
per = input.int(50, "Sampling Period", 1, group = group_DVDI)
smper = input.int(1, "Smoothing Period", 1, group = group_DVDI)

group_delta = "Volume Delta Arrows"


v_type = input.string("Cumulative Volume Delta", "Volume Type", inline="delta0",
group = group_delta, options = ["Cumulative Volume Delta", "Delta+AccDist", "Delta+OBV",
"Delta+PVT", "OBV+PVT+AccDist", "OBV+PVT"])
show_delta2 = input.bool(false, "Show Bars Color", inline="delta0", group = group_delta)
fast_len = input.int(9, "Fast MA", 1, inline="delta1", group = group_delta)
type_fast = input.string("Wilder", "Type", inline="delta1", group = group_delta,
options=["T3", "SMA", "EMA", "Wilder", "WMA", "ALMA", "LSMA", "HMA", "JMA", "RSS_WMA"])
slow_len = input.int(18, "Slow MA", 1, inline="delta2", group = group_delta)
type_slow = input.string("EMA", "Type", inline="delta2", group = group_delta,
options=["T3", "SMA", "EMA", "Wilder", "WMA", "ALMA", "LSMA", "HMA", "JMA", "RSS_WMA"])

group_tsv = "Enhanced Time Segmented Volume [TSV]"


len_tsv = input.int(9, "Length", 3, inline = "tsv2", group = group_tsv)
show_tsv2 = input.bool(false, "Show Bars Color", inline = "tsv2", group = group_tsv)
len_ma = input.int(9, "MA Length", 1, inline = "ma_tsv", group = group_tsv)
type_ma = input.string("EMA", "Type", inline = "ma_tsv", group = group_tsv,
options=["T3", "SMA", "EMA", "Wilder", "WMA", "ALMA", "LSMA", "HMA", "JMA", "RSS_WMA"])

//__________________________________________________________
//_______________Definitions of Koncorde Plus_______________
pvi_media = ta.ema(ta.pvi, m_pvi_nvi)
pvi_max = ta.highest(pvi_media, longitudPVI)
pvi_min = ta.lowest(pvi_media, longitudPVI)
osc_pos = (ta.pvi - pvi_media)*100 / (pvi_max - pvi_min)

nvi_media = ta.ema(ta.nvi, m_pvi_nvi)


nvi_max = ta.highest(nvi_media, longitudNVI)
nvi_min = ta.lowest(nvi_media, longitudNVI)
osc_neg = (ta.nvi - nvi_media)*100 / (nvi_max - nvi_min)

// VAMA - Volume Adjusted Moving Average of @allanster


vama(_src,_len,_fct,_rul,_nvb) => //
vama(source,length,factor,rule,sample)
tvb = 0, tvb := _nvb == 0 ? nz(tvb[1]) + 1 : _nvb // total volume bars used in
sample
tvs = _nvb == 0 ? ta.cum(volume) : math.sum(volume, _nvb) // total volume in sample
v2i = volume / ((tvs / tvb) * _fct) // ratio of volume to
increments of volume
wtd = _src*v2i // weighted prices
nmb = 1 // initialize number of bars
summed back
wtdSumB = 0.0 // initialize weighted prices
summed back
v2iSumB = 0.0 // initialize ratio of volume
to increments of volume summed back
for i = 1 to _len * 10 // set artificial cap for
strict to VAMA length * 10 to help reduce edge case timeout errors
strict = _rul ? false : i == _len // strict rule N bars' v2i
ratios >= vama length, else <= vama length
wtdSumB := wtdSumB + nz(wtd[i-1]) // increment number of bars'
weighted prices summed back
v2iSumB := v2iSumB + nz(v2i[i-1]) // increment number of bars'
v2i's summed back
if v2iSumB >= _len or strict // if chosen rule met
break // break (exit loop)
nmb := nmb + 1 // increment number of bars
summed back counter
nmb // number of bars summed back
to fulfill volume requirements or vama length
wtdSumB // number of bars' weighted
prices summed back
v2iSumB // number of bars' v2i's
summed back
vama = (wtdSumB - (v2iSumB - _len) * _src[nmb]) / _len // volume adjusted moving
average

// JMA - Jurik Moving Average of @everget


jma(src, length, power, phase) =>
phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5
beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)
alpha = math.pow(beta, power)
Jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 = 0.0
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(Jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2)
* nz(e2[1])
Jma := e2 + nz(Jma[1])

// ALMA - Arnaud Legoux Moving Average of @kurtsmock


enhanced_alma(_series, _length, _offset, _sigma) =>
length = int(_length) // Floating point protection
numerator = 0.0
denominator = 0.0
m = _offset * (length - 1)
s = length / _sigma
for i=0 to length-1
weight = math.exp(-((i-m)*(i-m)) / (2 * s * s))
numerator := numerator + weight * _series[length - 1 - i]
denominator := denominator + weight
numerator / denominator

// Tick Volume
tick = syminfo.mintick
rng = close - open
tickrng = tick
tickrng := math.abs(rng) < tick ? nz(tickrng[1]) : rng
tickvol = math.abs(tickrng)/tick
volumen = nz(volume) == 0 ? tickvol : volume

enhanced_vwma(_series, _length) =>


vol = volumen
vmp = _series * vol
VWMA = math.sum(vmp, _length) / math.sum(vol, _length)

// RSS_WMA of @RedKTrader
f_LazyLine(_data, _length) =>
w1 = 0, w2 = 0, w3 = 0
L1 = 0.0, L2 = 0.0, L3 = 0.0
w = _length / 3

if _length > 2
w2 := math.round(w)
w1 := math.round((_length - w2) / 2)
w3 := int((_length - w2) / 2)

L1 := ta.wma(_data, w1)
L2 := ta.wma(L1, w2)
L3 := ta.wma(L2, w3)
else
L3 := _data

L3

//T3 Moving Average based on the article 'Smoothing Techniques For More Accurate Signals'
by Tim Tillson
f_t3(src, len) =>
x1 = ta.ema(src, len) //(hlcc, 8)
x2 = ta.ema(x1, len)
x3 = ta.ema(x2, len)
x4 = ta.ema(x3, len)
x5 = ta.ema(x4, len)
x6 = ta.ema(x5, len)
b = 0.7 //Volume Factor
c1 = - math.pow(b, 3)
c2 = 3 * math.pow(b, 2) + 3 * math.pow(b, 3)
c3 = -6 * math.pow(b, 2) - 3 * b - 3 * math.pow(b, 3)
c4 = 1 + 3 * b + math.pow(b, 3) + 3 * math.pow(b, 2)
c1 * x6 + c2 * x5 + c3 * x4 + c4 * x3

ma(_type, _source, _length) =>


switch _type
"SMA" => ta.sma (_source, _length)
"EMA" => ta.ema (_source, _length)
"WMA" => ta.wma (_source, _length)
"VWMA" => enhanced_vwma(_source, _length)
"LSMA" => ta.linreg(_source, _length, loff) // Least Squares
"ALMA" => enhanced_alma(_source, _length, offs, sigma)
"HMA" => ta.hma(_source, _length)
"VAMA" => vama(_source, _length, factor, true, 0)
"JMA" => jma(_source, _length, powerJ, phaseJ)
"Wilder" => wild = _source, wild := nz(wild[1]) + (_source - nz(wild[1])) / _length
// Wilder's moving average
"RSS_WMA" => f_LazyLine(_source, _length)
"D_SMA" => ta.sma(ta.sma(_source, _length), _length)
"D_EMA" => ta.ema(ta.ema(_source, _length), _length)
"D_WMA" => ta.wma(ta.wma(_source, _length), _length)
"T3" => f_t3(_source, _length)

f_bb(source, length) =>


basis = ta.sma(source, length)
dev = mult_bb * ta.stdev(source, length)
upper = basis + dev // Upper Band
lower = basis - dev // Lower Band
avg_up_low = math.avg(upper, lower)
diff_up_low = upper - lower
(source - avg_up_low) / diff_up_low * 100

f_stoch(src, length, smoothFastD) =>


ll = ta.lowest(low, length)
hh = ta.highest(high, length)
k = 100 * (src - ll) / (hh - ll)
ta.sma(k, smoothFastD) // enhanced_alma(k, smoothFastD, 0.85, 6)

rsi_valor = ta.rsi(tprice, len_mfi_rsi)


mfi_valor = ta.mfi(srcMfi, len_mfi_rsi)
osc_bb = f_bb(tprice, length_bb)
stoc = f_stoch(tprice, 21, 3)

tendencia = (rsi_valor + mfi_valor + osc_bb + stoc/3) / 2 //math.avg(rsi_valor,


mfi_valor, osc_bb, stoc)
tiburones = ta.sma(osc_neg, 1)
pececillos = tendencia + osc_pos

ma_trend = ma(type_ma01, tendencia, length_ma01) //ta.ema(tendencia, length_ma01)

patron_espejo = (pececillos < 0 and tiburones > 0)


patron_oso = (pececillos > 0 and tiburones < 0) and pececillos >= tendencia
patron_cero = ta.crossover(tendencia, 0)

cross_up_trend = ta.crossover(tendencia, ma_trend)


cross_dn_trend = ta.crossunder(tendencia, ma_trend)

patron_primavera = (ta.crossover(tendencia, ma_trend) and pececillos > tendencia) //or


(ta.crossover(pececillos, tendencia) and pececillos >0)

cross_up_shark = ta.crossover(tiburones, ma_trend) and (pececillos < 0 and tiburones >


0)
cross_dn_shark = ta.crossunder(tiburones, 0) and pececillos > tendencia and pececillos >
ma_trend
cross_up_shark2 = not cross_up_shark and ta.crossover(tiburones, ma_trend) and tendencia
< ma_trend

plot(show_K ? pececillos : na, "Minnows", pececillos > 0 ? #05FF68 : #009929, 1,


plot.style_columns)
plot(show_K ? tiburones : na, "Shark", tiburones > 0 ? #0E55FF : #003785, 1,
plot.style_columns) //#00B0F6
plot(show_K ? ma_trend : na, "MA of Trend", #FF0000, 2, plot.style_line)
//hline(show_K ? 0 : na, "Center Line", #FAF5A5, hline.style_dotted)
plot(show_K ? tendencia : na, "Trend", tendencia > tendencia[1] ? #8D4925 : #320000, 2,
plot.style_line)
plot(show_K ? tendencia : na, "Trend", tendencia > tendencia[1] ? color.new(#8D4925, 70)
: color.new(#320000, 45), 1, plot.style_columns)

//______________________________________________________________________________
// Dual Volume Divergence Index - DVDI of @DonovanWall
// https://www.tradingview.com/script/p2tfpKK3-Dual-Volume-Divergence-Index-DW/
//---------------------------------------------------------------------------------------
--------------------------------------------------------------------------
// Definitions
//---------------------------------------------------------------------------------------
--------------------------------------------------------------------------
// Dual Volume Divergence Index
roc_x = ta.roc(src, 1)
dvdi(x, t1, t2, v)=>
pvi = x
pvi := v > v[1] ? nz(pvi[1]) + roc_x : nz(pvi[1])
psig = ta.ema(pvi, t1)
PDIV = ta.ema(pvi - psig, t2)
nvi = x
nvi := v < v[1] ? nz(nvi[1]) - roc_x : nz(nvi[1])
nsig = ta.ema(nvi, t1)
NDIV = ta.ema(nvi - nsig, t2)
DVDIO = PDIV - NDIV
[PDIV, NDIV, DVDIO]

vol = volumen
[pdiv, ndiv, dvdio] = dvdi(src, per, smper, vol)

// DVDI Bar Counter


cross_up = ta.barssince(ta.crossover(dvdio, 0))
cross_dn = ta.barssince(ta.crossunder(dvdio, 0))
pdbars = dvdio > 0 ? cross_up + 1 : 0
ndbars = dvdio < 0 ? cross_dn + 1 : 0

// Divergence Color
color1 = (pdiv > ndiv) and (pdiv > 0) ? #05ffa6 : (pdiv > ndiv) and (pdiv <= 0) ?
#00945f :
(ndiv > pdiv) and (ndiv > 0) ? #ff0a70 : (ndiv > pdiv) and (ndiv <= 0) ? #990040 :
#cccccc
color2 = (dvdio > 0) and (dvdio > dvdio[1]) ? #05ffa6 : (dvdio > 0) and (dvdio <=
dvdio[1]) ? #00945f :
(dvdio < 0) and (dvdio < dvdio[1]) ? #ff0a70 : (dvdio < 0) and (dvdio >= dvdio[1])
? #990040 : #cccccc
color3 = (pdbars > 0) and (src > src[1]) ? #05ffa6 : (pdbars > 0) and (src <= src[1]) ?
#00945f :
(ndbars > 0) and (src < src[1]) ? #ff0a70 : (ndbars > 0) and (src >= src[1]) ?
#990040 : #cccccc
barcolor = mode=="Cloud Mode" ? color1 : mode=="Oscillator Mode" ? color2 : color3

color1_60 = (pdiv > ndiv) and (pdiv > 0) ? color.new(#05ffa6, 60) : (pdiv > ndiv) and
(pdiv <= 0) ? color.new(#00945f, 60) :
(ndiv > pdiv) and (ndiv > 0) ? color.new(#ff0a70, 60) : (ndiv > pdiv) and (ndiv <=
0) ? color.new(#990040, 60) : color.new(#cccccc, 60)
color2_60 = (dvdio > 0) and (dvdio > dvdio[1]) ? color.new(#05ffa6, 60) : (dvdio > 0)
and (dvdio <= dvdio[1]) ? color.new(#00945f, 60) :
(dvdio < 0) and (dvdio < dvdio[1]) ? color.new(#ff0a70, 60) : (dvdio < 0) and
(dvdio >= dvdio[1]) ? color.new(#990040, 60) : color.new(#cccccc, 60)
//---------------------------------------------------------------------------------------
-------------------------------------------------------------------------
// Plots
//---------------------------------------------------------------------------------------
-------------------------------------------------------------------------
// Dual Index Plots
pplot = plot(show_DVDI and mode=="Cloud Mode" ? pdiv : na, "PVI Divergence", #05FFA6)
nplot = plot(show_DVDI and mode=="Cloud Mode" ? ndiv : na, "NVI Divergence", #FF0A70)
// Dual Index Fill
fill(pplot, nplot, color1_60, "Cloud Fill")

//Oscillator Plot
oplot = plot(show_DVDI and mode=="Oscillator Mode" ? dvdio : na, "DVDI Oscillator",
color2)

// Oscillator Fill
centplot = plot(0, "Index Center", display = display.none, editable = false) // Index
Center
fill(oplot, centplot, color2_60, "Oscillator Fill")

// Bar Counter Plot


pdbarsplot = plot(show_DVDI and mode=="Bar Counter Mode" ? pdbars : na, "Positive
Dominant Bar Count", #05FFA6)
ndbarsplot = plot(show_DVDI and mode=="Bar Counter Mode" ? ndbars : na, "Negative
Dominant Bar Count", #FF0A70)

// Bar Counter Fill


fill(pdbarsplot, centplot, color.new(#05FFA6, 60), "Positive Dominant Bar Count Fill")
fill(ndbarsplot, centplot, color.new(#FF0A70, 60), "Negative Dominant Bar Count Fill")

// Bar Colors
barcolor(show_bar_dvdi ? barcolor : na, title="DVDI Bars Color")

//____________________________________________________________________________
// Enhanced Time Segmented Volume of @StephXAGs

// https://www.tradingview.com/script/672uPH9q-Enhanced-Time-Segmented-Volume/
t = math.sum(close > close[1] ? volume * (close - close[1]) : close < close[1] ? volume *
(close - close[1]) : 0, len_tsv)
m = ma(type_ma, t, len_ma)

PAL = t > m and t > 0


PAL_fail = t < m and t > 0
PAS = t < m and t < 0
PAS_fail = t > m and t < 0

plotshape(show_tsv ? PAL : na, "Price Action Long", shape.square, location.bottom,


color.new(#04E604, 40), size=size.auto)
plotshape(show_tsv ? PAS : na, "Price Action Short", shape.square, location.bottom,
color.new(#E60404, 40), size=size.auto)
plotshape(show_tsv ? PAL_fail : na, "Price Action Long - FAILURE", shape.xcross,
location.bottom, color.new(#027302, 60), size=size.auto)
plotshape(show_tsv ? PAS_fail : na, "Price Action Short - FAILURE", shape.xcross,
location.bottom, color.new(#730202, 60), size=size.auto)
color_tsv = PAL ? color.new(#04E604, 10) : PAS ? color.new(#E60404, 10) : PAL_fail ?
color.new(#027302, 10) : PAS_fail ? color.new(#730202, 10) : color.gray
barcolor(show_tsv2 ? color_tsv : na, title="TSV Bars Color")

//____________________________________________Delta
Arrows____________________________________________
tw = high - math.max(open, close)
bw = math.min(open, close) - low
body = math.abs(close - open)

f_rate(cond) =>
ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body)
ret := nz(ret) == 0 ? 0.5 : ret

delta_up = volume * f_rate(open <= close)


delta_down = volume * f_rate(open > close)
delta = close >= open ? delta_up : -delta_down
cum_delta = switch v_type
"Cumulative Volume Delta" => ta.cum(delta)
"OBV+PVT" => math.avg(ta.obv, ta.pvt)
"OBV+PVT+AccDist" => math.avg(ta.obv, ta.pvt, ta.accdist)
"Delta+AccDist" => math.avg(delta, ta.accdist)
"Delta+OBV" => math.avg(delta, ta.obv)
"Delta+PVT" => math.avg(delta, ta.pvt)

ma_fast = ma(type_fast, cum_delta, fast_len)


ma_slow = ma(type_slow, cum_delta, slow_len)
delta_osc = ma_fast - ma_slow

sc1 = delta_osc >= 0


sc2 = delta_osc < 0
sc3 = delta_osc >= delta_osc[1]
sc4 = delta_osc < delta_osc[1]
col_delta_up = sc1 and sc3 ? #8080FF : sc1 and sc4 ? #40407F : color.silver
col_delta_dn = sc2 and sc4 ? #FF8080 : sc2 and sc3 ? #7F4040 : color.silver
color_delta = delta_osc >= 0 ? col_delta_up : col_delta_dn

plotshape(show_delta and delta_osc >= 0, "Up Delta", shape.triangleup,


location.bottom, col_delta_up)
plotshape(show_delta and delta_osc < 0, "Down Delta", shape.triangledown,
location.bottom, col_delta_dn)
barcolor(show_delta2 ? color_delta : na, title="Delta Bars Color")

//
____________________________________________MACD_________________________________________
___
[macd_line, macd_signal, _] = ta.macd(macd_src, macd_fast, macd_slow, macd_sig)

// MACD-V: Volatility Normalised Momentum of @Mik3Christ3ns3n


// https://www.tradingview.com/script/CE4EqZ1A-MACD-V-Volatility-Normalized-Momentum/
// https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4099617
macdv_line = ((ta.ema(macd_src, macd_fast) - ta.ema(macd_src, macd_slow)) /
ta.atr(atr_length)) * 100
macdv_signal = ta.ema(macdv_line, macd_sig)

cian = color.new(#38F5E9, 0)
cian_oscuro = color.new(#1C7A74, 0)
pink = color.new(#F7709D, 0)
pink_oscuro = color.new(#7B384E, 0)
char_dot = "◍"
char_dot_red = ""�"
char_dot_blue = ""�"

color_up = macd_line >= macd_signal ? cian : cian_oscuro


color_dn = macd_line <= macd_signal ? pink : pink_oscuro
color_macd = macd_line >= 0 ? color_up : color_dn

color_up_v = macdv_line >= 150 ? color.blue : (macdv_line >= macdv_signal ? cian :


cian_oscuro)
color_dn_v = macdv_line <= -150 ? color.red : (macdv_line <= macdv_signal ? pink :
pink_oscuro)
color_macdv = macdv_line >= 0 ? color_up_v : color_dn_v

color_m = show_macdv ? color_macdv : color_macd


area_macd = show_macdv ? macdv_line : macd_line

plot(show_macd3 ? area_macd : na, "MACD Area", color_m, 2, plot.style_histogram)


plot(show_macd3 and not show_macdv ? macd_signal : na, "MACD Siganal", color.new(#DBDB78,
45), 2)
plotchar(show_macd ? macd_line : na, "MACD", char_dot, location.top, color_m)
plotchar(show_macdv and macdv_line >= 150 ? macdv_line : na, "MACD-V OverBought",
char_dot_blue, location.top, color.blue)
hline(show_macd3 and show_macdv ? 150 : na, "MACD-V - Upper Band", color =
color.new(#EFEFBF, 50), linestyle = hline.style_dotted)
plotchar(show_macdv and macdv_line <= -150 ? macdv_line : na, "MACD-V OverSold",
char_dot_red, location.top, color.red)
hline(show_macd3 and show_macdv ? -150 : na, "MACD-V - Lower Band", color =
color.new(#EFEFBF, 50), linestyle = hline.style_dotted)
barcolor(show_macd2 ? color_m : na, title="MACD Bars Color")

//
____________________________________________Stochastic___________________________________
_________
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)

plot(show_stoc ? k : na, "%K", #00BCD4, 2) // #2962FF


plot(show_stoc ? d : na, "%D", #FF9800) // #FF6D00
h0 = hline(show_stoc ? ob_stoc : na, "Upper Band", color=color.new(#EFEFBF, 50),
linestyle = hline.style_dotted)
hline(show_stoc ? 50 : na, "Middle Band", color=color.new(#EFEFBF, 50), linestyle =
hline.style_dotted)
h1 = hline(show_stoc ? os_stoc : na, "Lower Band", color=color.new(#EFEFBF, 50),
linestyle = hline.style_dotted)
//fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")

//____________________________________________Relative Strength
Index___________________________________________
// Ultimate RSI of @LuxAlgo
// https://www.tradingview.com/script/17Jj7Vcg-Ultimate-RSI-LuxAlgo/
upper = ta.highest(rsiSourceInput, rsiLengthInput)
lower = ta.lowest(rsiSourceInput, rsiLengthInput)
r = upper - lower
diff = upper > upper[1] ? r
: lower < lower[1] ? -r
: rsiSourceInput - rsiSourceInput[1]
num = ta.rma(diff, rsiLengthInput)
den = ta.rma(math.abs(diff), rsiLengthInput)
u_rsi = num / den * 50 + 50

rsi = switch option_rsi


"RSI" => ta.rsi(rsiSourceInput, rsiLengthInput)
"MFI" => ta.mfi(rsiSourceInput, rsiLengthInput)
"AVG(RSI, MFI)" => math.avg(ta.rsi(close, rsiLengthInput), ta.mfi(hlc3,
rsiLengthInput))
"Ultimate RSI" => u_rsi

rsiMA = ma(maTypeInput, rsi, maLengthInput)

color color_rsi =
rsi > 50 ?
(rsi > obValue ?
color.new(#03A36A, 0) :
color.new(#05FFA6, 0)) :
(rsi < osValue ?
color.new(#A3033B, 0) :
color.new(#FF055D, 0))
//color_rsi = rsi > 50 ? #05FFA6 : #FF055D
rsiPlot = plot(show_rsi ? rsi : na, "RSI", color_rsi, 1)
plot(show_rsi and show_rsi_sig ? rsiMA : na, "RSI-based MA", #DBDB78)
//rsiUpperBand = hline(show_rsi ? 70 : na, "RSI Upper Band", color = #FF055D, linestyle =
hline.style_dotted)
rsiUpperBand = plot(show_rsi ? obValue : na, "RSI Upper Band", color.new(#FF055D, 25))
midline = hline(show_rsi ? 50 : na, "RSI Middle Band", color = color.silver, linestyle =
hline.style_dotted)
//rsiLowerBand = hline(show_rsi ? 30 : na, "RSI Lower Band", color = #05FFA6, linestyle =
hline.style_dotted)
rsiLowerBand = plot(show_rsi ? osValue : na, "RSI Lower Band", color.new(#05FFA6, 25))
//fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI
Background Fill")

midLinePlot = plot(50, color = na, editable = false, display = display.none)


fill(rsiPlot, midLinePlot, 100, 50, top_color = color.new(#05FFA6, 0), bottom_color =
color.new(#05FFA6, 100), title = "Overbought Gradient Fill")
fill(rsiPlot, midLinePlot, 50, 0, top_color = color.new(#FF055D, 100), bottom_color =
color.new(#FF055D, 0), title = "Oversold Gradient Fill")
barcolor(show_rsi2 ? color_rsi : na, title="RSI Bars Color")

// Divergence
------------------------------------------------------------------------------
lookbackRight = 5
lookbackLeft = 5
rangeUpper = 60
rangeLower = 5
bearColor = color.red
bullColor = color.green
textColor = color.white
noneColor = color.new(color.white, 100)
indicador = show_rsi ? rsi : show_stoc ? k : show_macd3 ? area_macd : show_DVDI and
mode=="Oscillator Mode" ? dvdio : na
showDivergence = na(indicador) ? false : true

plFound = na(ta.pivotlow(indicador, lookbackLeft, lookbackRight)) ? false : true


phFound = na(ta.pivothigh(indicador, lookbackLeft, lookbackRight)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper

//------------------------------------------------------------------------------
// Regular Bullish
// Higher Low
indiHL = indicador[lookbackRight] > ta.valuewhen(plFound, indicador[lookbackRight], 1)
and _inRange(plFound[1])

// Price: Lower Low


priceLL = low[lookbackRight] < ta.valuewhen(plFound, low[lookbackRight], 1)
bullCondAlert = priceLL and indiHL and plFound
bullCond = showDivergence and bullCondAlert

plot(
plFound ? indicador[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor)
)

plotshape(
bullCond ? indicador[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bullish Label",
text=" R ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)

//------------------------------------------------------------------------------
// Regular Bearish
// Lower High
indiLH = indicador[lookbackRight] < ta.valuewhen(phFound, indicador[lookbackRight], 1)
and _inRange(phFound[1])

// Price: Higher High


priceHH = high[lookbackRight] > ta.valuewhen(phFound, high[lookbackRight], 1)

bearCondAlert = priceHH and indiLH and phFound


bearCond = showDivergence and bearCondAlert

plot(
phFound ? indicador[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor)
)

plotshape(
bearCond ? indicador[lookbackRight] : na,
offset=-lookbackRight,
title="Regular Bearish Label",
text=" R ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)

alertcondition(bullCondAlert, title='Regular Bullish Divergence', message="Found a new


Regular Bullish Divergence, `Pivot Lookback Right` number of bars to the left of the
current bar.")
alertcondition(bearCondAlert, title='Regular Bearish Divergence', message='Found a new
Regular Bearish Divergence, `Pivot Lookback Right` number of bars to the left of the
current bar.')

//
____________________________________________Pattern______________________________________
______
plotchar(show_cruces ? cross_up_trend : na, "Crossover", char_up_cruce, location.bottom,
color.new(color.teal, 55), size=size.tiny)
plotchar(show_cruces ? cross_dn_trend : na, "Crossunder", char_dn_cruce, location.top,
color.new(color.red, 55), size=size.tiny)

plotchar(show_cero ? patron_cero : na, "Zero Pattern", char_up_cero, location.bottom,


color.new(#FFCC99, 20), size=size.tiny)
plotchar(show_primavera ? patron_primavera : na, "Spring Pattern", char_up_primavera,
location.bottom, color.new(color.lime, 35), size=size.tiny)

plotchar(show_arpon ? cross_up_shark : na, "Harpoon Pattern", char_up_arp,


location.bottom, color.new(#00FFFF, 15), size=size.small)
plotchar(show_arpon ? cross_dn_shark : na, "Exit Harpoon Pattern", char_dn_arp,
location.top, color.new(#FF4500, 10), size=size.tiny)
plotchar(show_arpon ? cross_up_shark2 : na, "Weak Harpoon Pattern", char_up_arp,
location.bottom, color.new(#0475E6, 0), size=size.tiny)

bgcolor(show_espejo and patron_espejo ? col_espejo : na, title="Mirror Pattern")


bgcolor(show_oso and patron_oso ? col_oso : na, title="Bear Hug Pattern")

//______________________________________________________________________________
// Performance Table by @dgtrd
//______________________________________________________________________________
sma20 = ma(type_ma1, source_ma1, length_ma1)
sma50 = ma(type_ma2, source_ma2, length_ma2)
sma200 = ma(type_ma3, source_ma2, length_ma3)

txt_ma1 = type_ma1 + str.tostring(length_ma1)


txt_ma2 = type_ma2 + str.tostring(length_ma2)
txt_ma3 = type_ma3 + str.tostring(length_ma3)
if maAlarm
alarm(f_crossingLevel(close, sma20) , 'Price crossing current tf ' + txt_ma1 + '(' +
str.tostring(sma20 , format.mintick) + ')', timeframe.period, true)
alarm(f_crossingLevel(close, sma50) , 'Price crossing current tf ' + txt_ma2 + '(' +
str.tostring(sma50 , format.mintick) + ')', timeframe.period, true)
alarm(f_crossingLevel(close, sma200), 'Price crossing current tf ' + txt_ma3 + '(' +
str.tostring(sma200, format.mintick) + ')', timeframe.period, true)

upColor = #26A69A
dnColor = #EF5350
naColor = color.blue
upColor2 = #00FF98
dnColor2 = #FF9800
//var float firstC = na
//if barstate.isfirst
// firstC := close

dROR = (close / f_getPriceValue('D') - 1) * 100


wROR = (close / f_getPriceValue('W') - 1) * 100
mROR = (close / f_getPriceValue('M') - 1) * 100
qROR = (close / f_getPriceValue('3M') - 1) * 100
yROR = (close / f_getPriceValue('12M') - 1) * 100

//if na(yROR)
// yROR := (close / firstC - 1) * 100

var float q1 = na, var float q2 = na, var float q3 = na, var float q4 = na

if month < 4
q1 := qROR, q2 := na, q3 := na, q4 := na
else if month > 3 and month < 7
q2 := qROR
else if month > 6 and month < 10
q3 := qROR
else if month > 9
q4 := qROR

var float yROR1 = na, var float yROR2 = na, var float yROR3 = na
var int yr1 = na, var int yr2 = na, var int yr3= na

if ta.change(time('12M'))
yROR3 := yROR2 , yr3 := yr2
yROR2 := yROR1 , yr2 := yr1
yROR1 := yROR[1], yr1 := year[1]
var table change = table.new(position.top_right, 4, 10, border_width=3)
if barstate.islast and chgStat and chart.is_standard
table.cell(change, 0, 0, 'PERF', text_color=naColor, bgcolor=color.new(naColor, 80),
text_halign=text.align_left, text_size=textSize)

if not timeframe.isweekly and not timeframe.ismonthly


table.cell(change, 1, 0, str.tostring( dROR, '#.##') + '%\nDTD' , text_color=dROR >
0 ? upColor2 : dnColor2, bgcolor=dROR > 0 ? color.new(upColor, 80) : color.new(dnColor,
80), text_size=textSize, tooltip='Day to Date')
if not timeframe.ismonthly
table.cell(change, 2, 0, na(wROR) ? '-\nWTD' : str.tostring( wROR, '#.##') + '%\
nWTD' , text_color=na(wROR) ? naColor : wROR > 0 ? upColor2 : dnColor2, bgcolor=na(wROR)
? color.new(naColor, 80) : wROR > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize, tooltip='Week to Date' )
table.cell (change, 3, 0, na(mROR) ? '-\nMTD' : str.tostring( mROR, '#.##') + '%\
nMTD' , text_color=na(mROR) ? naColor : mROR > 0 ? upColor2 : dnColor2, bgcolor=na(mROR)
? color.new(naColor, 80) : mROR > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize, tooltip='Month to Date')

if not na(q1) and not na(q2) and not na(q3) and not na(q4)
table.cell(change, 0, 1, na(q1) ? '-\nQ1' : str.tostring( q1, '#.##') + '%\nQ1',
text_color=na(q1) ? naColor : q1 > 0 ? upColor2 : dnColor2, bgcolor=na(q1) ?
color.new(naColor, 80) : q1 > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize, tooltip='1st Quarter of ' + str.tostring(year))
table.cell(change, 1, 1, na(q2) ? '-\nQ2' : str.tostring( q2, '#.##') + '%\nQ2',
text_color=na(q2) ? naColor : q2 > 0 ? upColor2 : dnColor2, bgcolor=na(q2) ?
color.new(naColor, 80) : q2 > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize, tooltip='2nd Quarter of ' + str.tostring(year))
table.cell(change, 2, 1, na(q3) ? '-\nQ3' : str.tostring( q3, '#.##') + '%\nQ3',
text_color=na(q3) ? naColor : q3 > 0 ? upColor2 : dnColor2, bgcolor=na(q3) ?
color.new(naColor, 80) : q3 > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize, tooltip='3rd Quarter of ' + str.tostring(year))
table.cell(change, 3, 1, na(q4) ? '-\nQ4' : str.tostring( q4, '#.##') + '%\nQ4',
text_color=na(q4) ? naColor : q4 > 0 ? upColor2 : dnColor2, bgcolor=na(q4) ?
color.new(naColor, 80) : q4 > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize, tooltip='4th Quarter of ' + str.tostring(year))

if not na(yROR)
table.cell(change, 3, 2, str.tostring(yROR , '#.##') + '%\n' + str.tostring(year),
text_color=yROR > 0 ? upColor2 : dnColor2, bgcolor=yROR > 0 ? color.new(upColor, 80) :
color.new(dnColor, 80), text_size=textSize, tooltip= str.tostring(year) + ' Year to
Date')
table.cell(change, 2, 2, na(yROR1) ? '-\n-' : str.tostring(yROR1, '#.##') + '%\n' +
str.tostring(yr1) , text_color=na(yROR1) ? naColor : yROR1 > 0 ? upColor2 : dnColor2,
bgcolor=na(yROR1) ? color.new(naColor, 80) : yROR1 > 0 ? color.new(upColor, 80) :
color.new(dnColor, 80), text_size=textSize, tooltip=na(yROR1) and na(yr1) ? '' :
str.tostring(yr1) + ' Rate of Return')
table.cell(change, 1, 2, na(yROR2) ? '-\n-' : str.tostring(yROR2, '#.##') + '%\n' +
str.tostring(yr2) , text_color=na(yROR2) ? naColor : yROR2 > 0 ? upColor2 : dnColor2,
bgcolor=na(yROR2) ? color.new(naColor, 80) : yROR2 > 0 ? color.new(upColor, 80) :
color.new(dnColor, 80), text_size=textSize, tooltip=na(yROR2) and na(yr2) ? '' :
str.tostring(yr2) + ' Rate of Return')
table.cell(change, 0, 2, na(yROR3) ? '-\n-' : str.tostring(yROR3, '#.##') + '%\n' +
str.tostring(yr3) , text_color=na(yROR3) ? naColor : yROR3 > 0 ? upColor2 : dnColor2,
bgcolor=na(yROR3) ? color.new(naColor, 80) : yROR3 > 0 ? color.new(upColor, 80) :
color.new(dnColor, 80), text_size=textSize, tooltip=na(yROR3) and na(yr3) ? '' :
str.tostring(yr3) + ' Rate of Return')

pma20 = (source_ma1 / sma20 - 1) * 100


pma50 = (source_ma2 / sma50 - 1) * 100
pma200 = (source_ma3 / sma200 - 1) * 100

[pma201h, pma501h, pma2001h] = request.security(syminfo.tickerid, '60', [pma20, pma50,


pma200])
[pma20d, pma50d, pma200d] = request.security(syminfo.tickerid, 'D' , [pma20, pma50,
pma200])
[pma20w, pma50w, pma200w] = request.security(syminfo.tickerid, 'W' , [pma20, pma50,
pma200])

if barstate.islast and pmaStat and chart.is_standard


table.cell(change, 1, 3, '1H' , text_color=naColor, bgcolor=color.new(naColor, 80),
text_size=textSize)
table.cell(change, 2, 3, 'Day' , text_color=naColor, bgcolor=color.new(naColor, 80),
text_size=textSize)
table.cell(change, 3, 3, 'Week', text_color=naColor, bgcolor=color.new(naColor, 80),
text_size=textSize)

table.cell(change, 0, 4, type_ma1+" "+str.tostring(length_ma1), text_color=naColor,


bgcolor=color.new(naColor, 80), text_halign=text.align_left, text_size=textSize)
table.cell(change, 1, 4, na(pma201h) ? '-' : str.tostring(pma201h, '#.##') + '%',
text_color=na(pma201h) ? naColor : pma201h > 0 ? upColor2 : dnColor2, bgcolor=na(pma201h)
? color.new(naColor, 80) : pma201h > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize)
table.cell(change, 2, 4, na(pma20d) ? '-' : str.tostring(pma20d, '#.##') + '%',
text_color=na(pma20d) ? naColor : pma20d > 0 ? upColor2 : dnColor2, bgcolor=na(pma20d)
? color.new(naColor, 80) : pma20d > 0 ? color.new(upColor, 80) : color.new(dnColor,
80), text_size=textSize)
table.cell(change, 3, 4, na(pma20w) ? '-' : str.tostring(pma20w, '#.##') + '%',
text_color=na(pma20w) ? naColor : pma20w > 0 ? upColor2 : dnColor2, bgcolor=na(pma20w)
? color.new(naColor, 80) : pma20w > 0 ? color.new(upColor, 80) : color.new(dnColor,
80), text_size=textSize)

table.cell(change, 0, 5, type_ma2+" "+str.tostring(length_ma2), text_color=naColor,


bgcolor=color.new(naColor, 80), text_halign=text.align_left, text_size=textSize)
table.cell(change, 1, 5, na(pma501h) ? '-' : str.tostring(pma501h, '#.##') + '%',
text_color=na(pma501h) ? naColor : pma501h > 0 ? upColor2 : dnColor2, bgcolor=na(pma501h)
? color.new(naColor, 80) : pma501h > 0 ? color.new(upColor, 80) : color.new(dnColor, 80),
text_size=textSize)
table.cell(change, 2, 5, na(pma50d) ? '-' : str.tostring(pma50d, '#.##') + '%',
text_color=na(pma50d) ? naColor : pma50d > 0 ? upColor2 : dnColor2, bgcolor=na(pma50d)
? color.new(naColor, 80) : pma50d > 0 ? color.new(upColor, 80) : color.new(dnColor,
80), text_size=textSize)
table.cell(change, 3, 5, na(pma50w) ? '-' : str.tostring(pma50w, '#.##') + '%',
text_color=na(pma50w) ? naColor : pma50w > 0 ? upColor2 : dnColor2, bgcolor=na(pma50w)
? color.new(naColor, 80) : pma50w > 0 ? color.new(upColor, 80) : color.new(dnColor,
80), text_size=textSize)

table.cell(change, 0, 6, type_ma3+" "+str.tostring(length_ma3), text_color=naColor,


bgcolor=color.new(naColor, 80), text_halign=text.align_left, text_size=textSize)
table.cell(change, 1, 6, na(pma2001h) ? '-' : str.tostring(pma2001h, '#.##') + '%',
text_color=na(pma2001h) ? naColor : pma2001h > 0 ? upColor2 : dnColor2,
bgcolor=na(pma2001h) ? color.new(naColor, 80) : pma2001h > 0 ? color.new(upColor, 80) :
color.new(dnColor, 80), text_size=textSize)
table.cell(change, 2, 6, na(pma200d) ? '-' : str.tostring(pma200d, '#.##') + '%',
text_color=na(pma200d) ? naColor : pma200d > 0 ? upColor2 : dnColor2,
bgcolor=na(pma200d) ? color.new(naColor, 80) : pma200d > 0 ? color.new(upColor, 80) :
color.new(dnColor, 80), text_size=textSize)
table.cell(change, 3, 6, na(pma200w) ? '-' : str.tostring(pma200w, '#.##') + '%',
text_color=na(pma200w) ? naColor : pma200w > 0 ? upColor2 : dnColor2,
bgcolor=na(pma200w) ? color.new(naColor, 80) : pma200w > 0 ? color.new(upColor, 80) :
color.new(dnColor, 80), text_size=textSize)
//////////

hline(30)
hline(65)
hline(100)

You might also like