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
|
---|---|---|---|---|---|---|---|---|
PWV - Price Weighted Volume | https://www.tradingview.com/script/K5iGcZKm-PWV-Price-Weighted-Volume/ | Gokubro | https://www.tradingview.com/u/Gokubro/ | 38 | 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/
// © Gokubro
//@version=5
indicator("price weighted volume")
pwv = close * volume
plot(pwv, "PWV", color=#7E57C2)
hline(50, "Baseline", color=color.new(#787B86, 0))
shortest = ta.ema(pwv, 20)
short = ta.ema(pwv, 50)
longer = ta.ema(pwv, 100)
longest = ta.ema(pwv, 200)
plot(shortest, "shortest", color = color.red, display=display.none)
plot(short, "short", color = color.orange, display=display.none)
plot(longer, "longer", color = color.aqua, display=display.none)
plot(longest, "longest", color = color.blue, display=display.none) |
Support Resistance Channels/Zones Multi Time Frame | https://www.tradingview.com/script/DrcEUv8C-Support-Resistance-Channels-Zones-Multi-Time-Frame/ | LonesomeTheBlue | https://www.tradingview.com/u/LonesomeTheBlue/ | 7,033 | 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/
// © LonesomeTheBlue
//@version=5
indicator("Support Resistance Channels/Zones Multi Time Frame", "SRMTF", overlay = true)
TF = input.timeframe(defval = 'D', title = "Higher Time Frame")
prd = input.int(defval = 5, title="Pivot Period", minval = 1, maxval = 30, tooltip="Used while calculating Pivot Points, checks left&right bars")
loopback = input.int(defval = 250, title = "Loopback Period", minval = 50, maxval = 400, tooltip="While calculating S/R levels it checks Pivots in Loopback Period")
ChannelW = input.float(defval = 6, title = "Maximum Channel Width %", minval = 1, maxval = 15, tooltip="Calculated using Highest/Lowest levels in 300 bars")
minstrength = input.int(defval = 2, title = "Minimum Strength", minval = 1, tooltip = "Channel must contain at least X Pivot Points")
maxnumsr = input.int(defval = 6, title = "Maximum Number of S/R", minval = 1, maxval = 10, tooltip = "Maximum number of Support/Resistance Channels to Show") - 1
showsrfit = input.bool(defval = true, title = "Show S/Rs that fits the Chart")
showtable = input.bool(defval = true, title = "Show S/R channels in a table")
tableposy = input.string(defval='bottom', title='Chart Location', options=['bottom', 'middle', 'top'], inline='chartpos')
tableposx = input.string(defval='left', title='', options=['left', 'center', 'right'], inline='chartpos')
res_col = input(defval = color.new(color.red, 75), title = "Resistance Color")
sup_col = input(defval = color.new(color.lime, 75), title = "Support Color")
inch_col = input(defval = color.new(color.gray, 75), title = "Color When Price in Channel")
get_highlow()=>
var hlmatrix = matrix.new<float>(loopback, 2, 0.)
if barstate.islast // use less memory
for x = 0 to loopback - 1
matrix.set(hlmatrix, x, 0, high[x])
matrix.set(hlmatrix, x, 1, low[x])
hlmatrix
hlmatrix = request.security(syminfo.tickerid, TF, get_highlow(), lookahead = barmerge.lookahead_on)
if na(hlmatrix)
runtime.error('You should choose Time Frame wisely')
if matrix.rows(hlmatrix) < prd * 10
runtime.error('There is not enough candles on Time Frame you choose. You better choose Time Frame wisely')
get_pivotvals(hlmatrix)=>
highs = matrix.col(hlmatrix, 0)
lows = matrix.col(hlmatrix, 1)
pivotvals = array.new_float(0)
for x = prd to array.size(highs) - prd - 1
if array.get(highs, x) >= array.max(array.slice(highs, x - prd, x + prd + 1))
array.push(pivotvals, array.get(highs, x))
if array.get(lows, x) <= array.min(array.slice(lows, x - prd, x + prd + 1))
array.push(pivotvals, array.get(lows, x))
pivotvals
//find/calculate SR channel/strength by using pivot points
get_sr_vals(pivotvals, cwidth, ind)=>
float lo = array.get(pivotvals, ind)
float hi = lo
int numpp = 0
for y = 0 to array.size(pivotvals) - 1
float cpp = array.get(pivotvals, y)
float wdth = cpp <= hi ? hi - cpp : cpp - lo
if wdth <= cwidth // fits the max channel width?
if cpp <= hi
lo := math.min(lo, cpp)
else
hi := math.max(hi, cpp)
numpp := numpp + 20 // each pivot point added as 20
[hi, lo, numpp]
var suportresistance = array.new_float(20, 0) // min & max levels * 10
// Change the location of the array elements
changeit(suportresistance, x, y)=>
tmp = array.get(suportresistance, y * 2)
array.set(suportresistance, y * 2, array.get(suportresistance, x * 2))
array.set(suportresistance, x * 2, tmp)
tmp := array.get(suportresistance, y * 2 + 1)
array.set(suportresistance, y * 2 + 1, array.get(suportresistance, x * 2 + 1))
array.set(suportresistance, x * 2 + 1, tmp)
// get related S/R level
get_level(suportresistance, ind)=>
float ret = na
if ind < array.size(suportresistance)
if array.get(suportresistance, ind) != 0
ret := array.get(suportresistance, ind)
ret
// get the color of elated S/R level
get_color(suportresistance, ind)=>
color ret = na
if ind < array.size(suportresistance)
if array.get(suportresistance, ind) != 0
ret := array.get(suportresistance, ind) > close and array.get(suportresistance, ind + 1) > close ? res_col :
array.get(suportresistance, ind) < close and array.get(suportresistance, ind + 1) < close ? sup_col :
inch_col
ret
// find and use highest/lowest on current chart if "Show S/Rs that fits the Chart" enabled
var times = array.new_float(0)
array.unshift(times, time)
visibleBars = 1
if time == chart.right_visible_bar_time
visibleBars := array.indexof(times, chart.left_visible_bar_time) + 1
chart_highest = ta.highest(visibleBars)
chart_lowest = ta.lowest(visibleBars)
// use 5% more
chart_highest += (chart_highest - chart_lowest) * 0.05
chart_lowest -= (chart_highest - chart_lowest) * 0.05
// alerts
resistancebroken = false
supportbroken = false
// calculate S/R on last bar
if barstate.islast
pivotvals = get_pivotvals(hlmatrix)
//calculate maximum S/R channel width
prdhighest = array.max(pivotvals)
prdlowest = array.min(pivotvals)
cwidth = (prdhighest - prdlowest) * ChannelW / 100
supres = array.new_float(0) // number of pivot, strength, min/max levels
stren = array.new_float(10, 0)
// get levels and strengs
for x = 0 to array.size(pivotvals) - 1
[hi, lo, strength] = get_sr_vals(pivotvals, cwidth, x)
array.push(supres, strength)
array.push(supres, hi)
array.push(supres, lo)
// chech last 500 bars on curent time frame and add each OHLC to strengh
for x = 0 to array.size(pivotvals) - 1
h = array.get(supres, x * 3 + 1)
l = array.get(supres, x * 3 + 2)
s = 0
for y = 0 to 499
if (high[y] <= h and high[y] >= l) or
(low[y] <= h and low[y] >= l) or
(open[y] <= h and open[y] >= l) or
(close[y] <= h and close[y] >= l)
s := s + 1
array.set(supres, x * 3, array.get(supres, x * 3) + s)
//reset SR levels
array.fill(suportresistance, 0)
// get strongest SRs
src = 0
for x = 0 to array.size(pivotvals) - 1
stv = -1. // value
stl = -1 // location
for y = 0 to array.size(pivotvals) - 1
if array.get(supres, y * 3) > stv and array.get(supres, y * 3) >= minstrength * 20
stv := array.get(supres, y * 3)
stl := y
if stl >= 0
//get sr level
hh = array.get(supres, stl * 3 + 1)
ll = array.get(supres, stl * 3 + 2)
array.set(suportresistance, src * 2, hh)
array.set(suportresistance, src * 2 + 1, ll)
array.set(stren, src, array.get(supres, stl * 3))
// make included pivot points' strength zero
for y = 0 to array.size(pivotvals) - 1
if (array.get(supres, y * 3 + 1) <= hh and array.get(supres, y * 3 + 1) >= ll) or
(array.get(supres, y * 3 + 2) <= hh and array.get(supres, y * 3 + 2) >= ll)
array.set(supres, y * 3, -1)
src += 1
if src >= 10
break
// sort S/R according to their strengths
for x = 0 to 8
for y = x + 1 to 9
if array.get(stren, y) > array.get(stren, x)
tmp = array.get(stren, y)
array.set(stren, y, array.get(stren, x))
changeit(suportresistance, x, y)
var srtable = table.new(position = tableposy + '_' + tableposx, columns = 5, rows= 11, frame_width = 1, frame_color = color.gray, border_width = 1, border_color = color.gray)
if showtable
table.cell(srtable, 0, 0, text = "TF:" + str.tostring(TF) + " Sorted by the Strength", text_color = color.rgb(0, 0, 250), bgcolor = color.yellow)
table.merge_cells(srtable, 0, 0, 3, 0)
// show S/R channels and tables if enabled
var srchannels = array.new_box(10)
rowindex = 1
for x = 0 to math.min(9, maxnumsr)
box.delete(array.get(srchannels, x))
srcol = get_color(suportresistance, x * 2)
if not na(srcol)
if not showsrfit or (get_level(suportresistance,x * 2 + 1) <= chart_highest and get_level(suportresistance,x * 2) >= chart_lowest)
array.set(srchannels, x,
box.new(left = bar_index - 300, top = get_level(suportresistance,x * 2), right = bar_index + 1, bottom = get_level(suportresistance,x * 2 + 1),
border_color = srcol,
border_width = 1,
extend = extend.both,
bgcolor = srcol))
if showtable
srtext = srcol == res_col ? "Resistance" : "Support"
bgcol = srcol == res_col ? color.rgb(200, 0, 0) : color.rgb(0, 200, 0)
txtcol = srcol == res_col ? color.white: color.black
table.cell(table_id = srtable, column = 0, row = rowindex, text = str.tostring(rowindex), text_color = txtcol, bgcolor = bgcol)
table.cell(table_id = srtable, column = 1, row = rowindex, text = srtext, text_color = txtcol, bgcolor = bgcol)
table.cell(table_id = srtable, column = 2, row = rowindex, text = str.tostring(math.round_to_mintick(get_level(suportresistance,x * 2 + 1))), text_color = txtcol, bgcolor = bgcol)
table.cell(table_id = srtable, column = 3, row = rowindex, text = str.tostring(math.round_to_mintick(get_level(suportresistance,x * 2))), text_color = txtcol, bgcolor = bgcol)
rowindex += 1
// alerts
// check if the price is not in a channel
not_in_a_channel = true
for x = 0 to math.min(9, maxnumsr)
if close <= array.get(suportresistance, x * 2) and close >= array.get(suportresistance, x * 2 + 1)
not_in_a_channel := false
// if price is not in a channel then check if S/R was broken
if not_in_a_channel
for x = 0 to math.min(9, maxnumsr)
if close[1] <= array.get(suportresistance, x * 2) and close > array.get(suportresistance, x * 2)
resistancebroken := true
if close[1] >= array.get(suportresistance, x * 2 + 1) and close < array.get(suportresistance, x * 2 + 1)
supportbroken := true
alertcondition(resistancebroken, title = "Resistance Broken", message = "Resistance Broken")
alertcondition(supportbroken, title = "Support Broken", message = "Support Broken") |
MA COLORED | https://www.tradingview.com/script/6G0qLjDq-MA-COLORED/ | yashchotrani | https://www.tradingview.com/u/yashchotrani/ | 12 | 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/
// © yashchotrani
//@version=5
indicator("MA COLOR CODED")
ma(source, length, type) =>
type == "SMA" ? ta.sma(source, length) :
type == "EMA" ? ta.ema(source, length) :
type == "SMMA (RMA)" ? ta.rma(source, length) :
type == "WMA" ? ta.wma(source, length) :
type == "VWMA" ? ta.vwma(source, length) :
na
ma_type = input.string(defval="VWMA", title="1-MA Type: ", options=["SMA", "EMA", "WMA", "VWMA", "SMMA(RMA)"])
mas = input(close, "MA Source")
ma1l = input(13, "MA 1 Length")
ma2l = input(21, "MA 2 Length")
ma1 = ma(mas, ma1l, ma_type)
ma2 = ma(mas, ma2l, ma_type)
ma1p = ma1 > ma1[1]
ma1n = ma1 < ma1[1]
ma2p = ma2 > ma2[1]
ma2n = ma2 < ma2[1]
colorMA = ma1p and ma2p ? color.green : ma1n and ma2n ? color.red : color.black
plot(ma1, color = colorMA, linewidth = 2)
plot(ma2, color = colorMA, linewidth = 2)
|
NSE Paper Stocks Index | https://www.tradingview.com/script/3yWYVt0y-NSE-Paper-Stocks-Index/ | davenderb | https://www.tradingview.com/u/davenderb/ | 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/
// © davenderb
// Made by Stef @Scheplick
// Modified by DB for having NSE paper stocks
// Release Sep 9 2022
//@version=5
indicator(title = "NSE Paper Stocks Index", shorttitle = "NSE Paper Index", overlay = false)
// Inputs
weightType = input.string("Custom Weighted", "Index Type", options=["Custom Weighted"])
symbol_1 = input.bool(title='Andhra Papers', defval=true, inline='1')
ticker_1 = input.symbol(title='', defval='ANDHRAPAP', inline='1')
weighting_1 = input.float(title='Weight', defval=10, inline='1') / 100.0
symbol_2 = input.bool(title='Seshayee Paper', defval=true, inline='2')
ticker_2 = input.symbol(title='', defval='SESHAPAPER', inline='2')
weighting_2 = input.float(title='Weight', defval=10, inline='2') / 100.0
symbol_3 = input.bool(title='Pudumjee Paper', defval=true, inline='3')
ticker_3 = input.symbol(title='', defval='PDMJEPAPER', inline='3')
weighting_3 = input.float(title='Weight', defval=10, inline='3') / 100.0
symbol_4 = input.bool(title='JK PAPER', defval=true, inline='4')
ticker_4 = input.symbol(title='', defval='JKPAPER', inline='4')
weighting_4 = input.float(title='Weight', defval=10, inline='4') / 100.0
symbol_5 = input.bool(title='WEST COAST PAPERS', defval=true, inline='5')
ticker_5 = input.symbol(title='', defval='WSTCSTPAPR', inline='5')
weighting_5 = input.float(title='Weight', defval=10, inline='5') / 100.0
symbol_6 = input.bool(title='ORIENT PAPER', defval=true, inline='6')
ticker_6 = input.symbol(title='', defval='ORIENTPPR', inline='6')
weighting_6 = input.float(title='Weight', defval=10, inline='6') / 100.0
symbol_7 = input.bool(title='RUCHIRA PAPERS', defval=true, inline='7')
ticker_7 = input.symbol(title='', defval='RUCHIRA', inline='7')
weighting_7 = input.float(title='Weight', defval=10, inline='7') / 100.0
symbol_8 = input.bool(title='GENUS PAPER AND BOARD', defval=true, inline='8')
ticker_8 = input.symbol(title='', defval='GENUSPAPER', inline='8')
weighting_8 = input.float(title='Weight', defval=5, inline='8') / 100.0
symbol_9 = input.bool(title='YASH PAPERS', defval=true, inline='9')
ticker_9 = input.symbol(title='', defval='YASHPAKKA', inline='9')
weighting_9 = input.float(title='Weight', defval=5, inline='9') / 100.0
symbol_10 = input.bool(title='BALLARPUR', defval=true, inline='10')
ticker_10 = input.symbol(title='', defval='BALLARPUR', inline='10')
weighting_10 = input.float(title='Weight', defval=10, inline='10') / 100.0
symbol_11 = input.bool(title='STAR PAPER', defval=true, inline='10')
ticker_11 = input.symbol(title='', defval='STARPAPER', inline='10')
weighting_11 = input.float(title='Weight', defval=10, inline='10') / 100.0
// Security
symcalc01 = symbol_1 ? request.security(ticker_2, timeframe.period, close) : 0
symcalc02 = symbol_2 ? request.security(ticker_2, timeframe.period, close) : 0
symcalc03 = symbol_3 ? request.security(ticker_3, timeframe.period, close) : 0
symcalc04 = symbol_4 ? request.security(ticker_4, timeframe.period, close) : 0
symcalc05 = symbol_5 ? request.security(ticker_5, timeframe.period, close) : 0
symcalc06 = symbol_6 ? request.security(ticker_6, timeframe.period, close) : 0
symcalc07 = symbol_7 ? request.security(ticker_7, timeframe.period, close) : 0
symcalc08 = symbol_8 ? request.security(ticker_8, timeframe.period, close) : 0
symcalc09 = symbol_9 ? request.security(ticker_9, timeframe.period, close) : 0
symcalc10 = symbol_10 ? request.security(ticker_10, timeframe.period, close) : 0
symcalc11 = symbol_11 ? request.security(ticker_11, timeframe.period, close) : 0
// Plot
plot(symcalc01*weighting_1+symcalc02*weighting_2+symcalc03*weighting_3+symcalc04*weighting_4+symcalc05*weighting_5+symcalc06*weighting_6+symcalc07*weighting_7+symcalc08*weighting_8+symcalc09*weighting_9+symcalc10*weighting_10+symcalc11*weighting_11)
|
MESA Stochastic Multi Length | https://www.tradingview.com/script/pioqjQXv-MESA-Stochastic-Multi-Length/ | jojogoop | https://www.tradingview.com/u/jojogoop/ | 96 | 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/
// © veryfid
// Uses MESA Stochastic code published by @blackcat1402 as open source under the terms of the Mozilla Public License 2.0
//####################
// optimized by jojogoop
// - converted to v5
// - modified smoothing, now indicator reacting faster to price change
// - rewrote code and functions, now just 1 function handles all lengths, and is called only once
//@version=5
indicator(title='MESA Stochastic Multi Length', shorttitle='MESAStochML', overlay=false)
PI = float(3.14)
//=============== MESA Function
_mesa(len,src, PI) =>
a1 = 0.00
b1 = 0.00
c1 = 0.00
c2 = 0.00
c3 = 0.00
alpha1 = 0.00
HP = 0.00
Filt = 0.00
HighestC = 0.00
LowestC = 0.00
Stoc = 0.00
MESAStochastic = 0.00
Trigger = 0.00
pi = PI
alpha1 := (math.cos(0.707 * 2 * pi / 48) + math.sin(0.707 * 2 * pi / 48) - 1) / math.cos(0.707 * 2 * pi / 48)
HP := (1 - alpha1 / 2) * (1 - alpha1 / 2) * (src - 2 * nz(src[1]) + nz(src[2])) + 2 * (1 - alpha1) * nz(HP[1]) - (1 - alpha1) * (1 - alpha1) * nz(HP[2])
a1 := math.exp(-1.414 * pi / 10)
b1 := 2 * a1 * math.cos(1.414 * pi / 10)
c2 := b1
c3 := -a1 * a1
c1 := 1 - c2 - c3
Filt := c1 * (HP + nz(HP)) / 2 + c2 * nz(Filt[1]) + c3 * nz(Filt[2])
HighestC := Filt
LowestC := Filt
for count = 0 to len - 1 by 1
if nz(Filt[count]) > HighestC
HighestC := nz(Filt[count])
HighestC
if nz(Filt[count]) < LowestC
LowestC := nz(Filt[count])
LowestC
Stoc := (Filt - LowestC) / (HighestC - LowestC)
//MESAStochastic := c1 * (Stoc + nz(Stoc[1])) / 2 + c2 * nz(MESAStochastic[1]) + c3 * nz(MESAStochastic[2])
MESAStochastic := c1 * (Stoc + nz(Stoc)) / 2 + c2 * nz(MESAStochastic[1]) + c3 * nz(MESAStochastic[2])
MESAStochastic
//==================Inputs
Price = input.source(close, title='Source')
Length1 = input.int(48, title='Length #1', group='MESA Stochastic')
Length2 = input.int(21, title='Length #2', group='MESA Stochastic')
Length3 = input.int(9, title='Length #3', group='MESA Stochastic')
Length4 = input.int(6, title='Length #4', group='MESA Stochastic')
show_trigger = input(false, title='Show Trigger', group='Trigger')
trig = input.int(2, title='Trigger Length', group='Trigger')
poscol = input.color(color.blue, title='Positive Color', group='Colors')
negcol = input.color(color.red, title='Negative Color', group='Colors')
ncol = input.color(color.red, title='Neutral Color', group='Colors')
//================ Calculations
ms1 = _mesa(Length1, Price, PI)
ms2 = _mesa(Length2, Price, PI)
ms3 = _mesa(Length3, Price, PI)
ms4 = _mesa(Length4, Price, PI)
trigger1 = ta.sma(ms1, trig)
trigger2 = ta.sma(ms2, trig)
trigger3 = ta.sma(ms3, trig)
trigger4 = ta.sma(ms4, trig)
col1 = ta.change(ms1) > 0 ? poscol : ta.change(ms1) < 0 ? negcol : ncol
col2 = ta.change(ms2) > 0 ? poscol : ta.change(ms2) < 0 ? negcol : ncol
col3 = ta.change(ms3) > 0 ? poscol : ta.change(ms3) < 0 ? negcol : ncol
col4 = ta.change(ms4) > 0 ? poscol : ta.change(ms4) < 0 ? negcol : ncol
//===============Plotting
plot1 = plot(ms1, 'MESAStochastic 1', color=col1, linewidth=1)
plot2 = plot(show_trigger ? trigger1 : na, 'Trigger 1', color=color.new(#2962ff, 0), linewidth=1)
plot3 = plot(ms2, 'MESAStochastic 2', color=col2, linewidth=1)
plot4 = plot(show_trigger ? trigger2 : na, 'Trigger 2', color=color.new(#2962ff, 0), linewidth=1)
plot5 = plot(ms3, 'MESAStochastic 3', color=col3, linewidth=1)
plot6 = plot(show_trigger ? trigger3 : na, 'Trigger 3', color=color.new(#2962ff, 0), linewidth=1)
plot7 = plot(ms4, 'MESAStochastic 4', color=col4, linewidth=1)
plot8 = plot(show_trigger ? trigger4 : na, 'Trigger 4', color=color.new(#2962ff, 0), linewidth=1)
|
HPK Crash Indicator | https://www.tradingview.com/script/trvIDe0U-HPK-Crash-Indicator/ | JoeCA9772 | https://www.tradingview.com/u/JoeCA9772/ | 31 | 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/
// © JoeCA9772
//@version=5
indicator("HPK Crash Indicator", overlay=true)
//
return_period = input(252, title="Period for Return")
volatility_period = input(21, title="Period for Volatility")
// thresholds
return_bound = input.float(2, title="Z-Score Bound for Return")
volatility_bound = input.float(2, title="Z-Score Bound for Volatility")
// regime length
window = input(1260, title="Trailing Window")
// additional feature
include_surges = input.bool(true, "Include Surge Warnings")
//
return_ = math.log(close / close[return_period])
volatility = ta.stdev(close / close[1], volatility_period)
// regime z-scores
return_z = (return_ - ta.sma(return_, window)) / ta.stdev(return_, window)
volatility_z = (volatility - ta.sma(volatility, window)) / ta.stdev(volatility, window)
// thresholds met?
warning = (return_z > return_bound) and (volatility_z > volatility_bound) ? true : false
surge_warning = include_surges and (return_z < (-1 * return_bound)) and (volatility_z > volatility_bound) ? true : false
// plot(s)
bgcolor(warning ? color.new(color.red, 85) : na)
bgcolor(surge_warning ? color.new(color.green, 85) : na)
|
Mansfield Relative Strength (Original Version) by stageanalysis | https://www.tradingview.com/script/NzUBDDtb-Mansfield-Relative-Strength-Original-Version-by-stageanalysis/ | Stage_Analysis | https://www.tradingview.com/u/Stage_Analysis/ | 616 | 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/
// © stageanalysis
//@version=5
indicator('Mansfield Relative Strength (Original Version) by stageanalysis', shorttitle='Mansfield RS', overlay=false)
// Global Variables
resolution = '1W'
sym = input.symbol(title='Symbol', defval='SPCFD:SPX')
maLength = input.int(52, minval = 1, title='MA Length')
mansfieldRSInput = input(defval=true, title="Original Style")
// Retrieve the other symbol's data
spx = request.security(sym, resolution, close)
stock = close
stockDividedBySpx = stock / spx * 100
zeroLineMA = ta.sma(stockDividedBySpx, maLength)
mansfieldRS = ((( stockDividedBySpx / zeroLineMA ) - 1 ) * 100)
v = if mansfieldRSInput
mansfieldRS
else
stockDividedBySpx
x = if not mansfieldRSInput
zeroLineMA
plot(v, title='Mansfield RS Line', color=color.new(color.black, 0))
hline(0, title="Zero Line", color=color.blue, linestyle=hline.style_solid, linewidth=1)
plot(x, title='MA', color=color.blue)
// Create inputs to configure the background colour signals
positiveColor = color.new(#53b987, 85)
neutralColorRisingMA = color.new(color.blue, 85)
neutralColorFallingMA = color.new(color.gray, 95)
negativeColor = color.new(color.red, 85)
zeroLineMaisRising = ta.rising(zeroLineMA, 1)
zeroLineMaisFalling = ta.falling(zeroLineMA, 1)
// Compare price and averages to determine background colour
backgroundColour = if stockDividedBySpx > zeroLineMA and zeroLineMaisRising
positiveColor
else if stockDividedBySpx < zeroLineMA and zeroLineMaisRising
neutralColorRisingMA
else if stockDividedBySpx > zeroLineMA and zeroLineMaisFalling
neutralColorFallingMA
else
negativeColor
// Apply chosen background to the chart
bgcolor(backgroundColour, title="Background Colors") |
Candle Fill % Meter | https://www.tradingview.com/script/Vg488Hot-Candle-Fill-Meter/ | EsIstTurnt | https://www.tradingview.com/u/EsIstTurnt/ | 66 | 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("Candle Fill % Meter",overlay=true)
//Make sure the chart is set to Hollow Candles!
//Inputs
label = input.bool (true,'Show Measurment Value by Candle',group='Candle ')
cop = input.bool (false,'Fill Using Cooppock Curve isntead of RSI ',group='Candle Source (Optional:Select Only 1)')
vol = input.bool (false,'Fill Using Volume isntead of RSI ',group='Candle Source (Optional:Select Only 1)')
flip = input.bool (false,'Fill from candle Open rather than from the bottom up ',group='Candle ')
zoom = input.bool (true ,'Increase Fill Sensitivity ',group='Candle ')
arrow = input.bool (true ,'Show Value-Dircection Characters ',group='Measurement ')
levels = input.bool (true ,'Show Level Dividers ',group='Measurement ')
measurecolor = input.bool (false,'Measurement Line Color Switch ',group='Measurement ')
offsetvalue = input.int (1 ,'Dot Offset ',group='Measurement ')
layers = input.int (5 ,'Dividing Levels ',maxval=5,minval=0,group='Measurement ')
transparency = input.int (50 ,'Fill Transparency 1 ',group='Transparency ')
transparency2 = input.int (30 ,'Fill Transparency 2 ',group='Transparency ')
transparency3 = input.int (80 ,'Fill Transparency 2 ',group='Transparency ')
border = input.int (0 ,'Border Transparency ',group='Transparency ')
//Candle Colors
overbought = input.color(#acfb00 ,'overbought (70 +) ',group='Colors ')
buy = input.color(color.olive ,'buy (50-70) ',group='Colors ')
sell = input.color(color.orange ,'sell (30-50) ',group='Colors ')
oversold = input.color(#ff0000 ,'oversold (- 30) ',group='Colors ')
//Calculations
float1 = 1/layers
float2 = float1>2? float1-1:float1
oc2 = math.avg(open,close)
rs = zoom?ta.rsi(ohlc4,8):ta.rsi(ohlc4,16)
coppock = zoom?(ta.wma(ta.roc(hl2,6)+ta.roc(hl2,7),5)/4)+50:(ta.wma(ta.roc(hl2,11)+ta.roc(hl2,14),10)/4)+50
rsi = rs/100
highest1 = ta.highest(high,128)
highest2 = ta.highest(high,64 )
lowest1 = ta.lowest (low ,128)
lowest2 = ta.lowest (low ,64 )
center = ta.linreg(math.avg(highest1,highest2,lowest1,lowest2),16,0)
h_l = highest1-lowest1
rsihl = ta.wma((rsi*h_l)+lowest1,32)
ocbase = flip?open:math.min(open,close)
gap = open<close?close-open:open-close
base = flip?open:(open<close?open:close)
rsifill = (rsi)
volfill = zoom?(volume/ta.highest(volume,32)):(volume/ta.highest(volume,128))
measure = cop?(coppock/100):vol?volfill:rsifill
value = flip?open>close?ocbase-(measure*gap):ocbase+(measure*gap):ocbase+(measure*gap)
linex = flip?open>close?value:base:base
liney = flip?open>close?base:value:value
linez = open>open[1]?liney:linex
mid = math.avg(open,close)
candle_level1 = math.min(open,close) + ((math.max(open,close)-math.min(open,close))*float1 )
candle_level2a = math.min(open,close) + ((math.max(open,close)-math.min(open,close))*float1 )
candle_level2b = math.max(open,close) - ((math.max(open,close)-math.min(open,close))*float1 )
candle_level3a = math.min(open,close) + ((math.max(open,close)-math.min(open,close))*(float1*2) )
candle_level3b = math.max(open,close) - ((math.max(open,close)-math.min(open,close))*(float1*2))
//Colors
color_a = rs>=70?color.new(overbought,transparency):rs>=50?color.new(buy,transparency):rs>=30?color.new(sell,transparency):color.new(oversold,transparency)
color_b = rs>=70?color.new(overbought,transparency2):rs>=50?color.new(buy,transparency2):rs>=30?color.new(sell,transparency2):color.new(oversold,transparency2)
levelcolor=measurecolor?color.new(input.color(color.white,'Alternative Measure Line Color'),transparency):color.new(color_a,transparency2)
//Draw
//plot (candle_level1 ,'50',linewidth=1,style=plot.style_stepline,color=levelcolor)
plot (candle_level2a,'Level #1',linewidth=1,style=plot.style_stepline,color=float2<0.5?levelcolor:na)
plot (candle_level2b,'Level #4',linewidth=1,style=plot.style_stepline,color=float2<0.5?levelcolor:na)
plot (candle_level3a,'Level #2',linewidth=1,style=plot.style_stepline,color=float2<0.5?levelcolor:na)
plot (candle_level3b,'Level #3',linewidth=1,style=plot.style_stepline,color=float2<0.5?levelcolor:na)
plot (oc2,'50',linewidth=1,style=plot.style_stepline,color= layers == 2?levelcolor:na)
plotcandle(base,high,low,value,color=cop?color_a:color_a,bordercolor=cop?color_a:color_a,wickcolor=na)
plotchar (arrow?open<hl2[3]and value< value[2]?low :na:na,color=color.new(color_b,transparency2),char='ₓ',offset=0,location=location.absolute,size=size.tiny)//︾
plotchar (arrow?open>hl2[3]and value> value[2]?high :na:na,color=color.new(color_b,transparency2),char='ₓ',offset=0,location=location.absolute,size=size.tiny)//︽
plotchar (arrow?low <hl2[2] or value<=value[4]?liney:na:na,color=color.new(color.white,transparency2),char='-',offset=0,location=location.absolute,size=size.tiny)
var label1 = label?label.new(bar_index, liney, "", style=label.style_none):na
label.set_xloc(label1, time, xloc.bar_time)
label.set_text(label1, text= input.string('Val=','Value=')+ (cop?str.tostring(math.round(coppock)):vol?str.tostring(math.round(volfill*100)):str.tostring(math.round(rs))))
label.set_y(label1, high)
label.set_textcolor(label1,color_b)
|
Gaussian Filter MACD [Loxx] | https://www.tradingview.com/script/UzSweE49-Gaussian-Filter-MACD-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 142 | 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("Gaussian Filter MACD [Loxx]",
shorttitle="GFMACD [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
SM01 = 'Zero Cross'
SM02 = 'Signal Cross'
_alpha(int period, int poles)=>
w = 2.0 * math.pi / period
float b = (1.0 - math.cos(w)) / (math.pow(1.414, 2.0 / poles) - 1.0)
float a = - b + math.sqrt(b * b + 2.0 * b)
a
_gsmth(float src, int poles, float alpha)=>
float out = 0.
out := switch poles
1 => alpha * src + (1 - alpha) *
nz(out[1])
2 => math.pow(alpha, 2) *
src + 2 *
(1 - alpha) *
nz(out[1]) - math.pow(1 - alpha, 2) *
nz(out[2])
3 => math.pow(alpha, 3) *
src + 3 * (1 - alpha) *
nz(out[1]) - 3 *
math.pow(1 - alpha, 2) *
nz(out[2]) + math.pow(1 - alpha, 3) *
nz(out[3])
4 => math.pow(alpha, 4) *
src + 4 * (1 - alpha) *
nz(out[1]) - 6 *
math.pow(1 - alpha, 2) *
nz(out[2]) + 4 *
math.pow(1 - alpha, 3) *
nz(out[3]) - math.pow(1 - alpha, 4) *
nz(out[4])
out
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = 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)"])
fper = input.int(12,'Fast Period', group = "Basic Settings")
sper = input.int(26,'Slow Period', group = "Basic Settings")
sigper = input.int(9,'Signal Period', group = "Basic Settings")
fpoles = input.int(4,'Fast Poles', group = "Basic Settings", minval = 1, maxval = 4)
spoles = input.int(4,'Slow Poles', group = "Basic Settings", minval = 1, maxval = 4)
sigpoles = input.int(4,'Signal Poles', group = "Basic Settings", minval = 1, maxval = 4)
sigtype = input.string(SM01, "Signal type", options = [SM01, SM02], group = "Signal 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
float src = switch srcoption
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
Fast_alfa = _alpha(fper, fpoles)
Slow_alfa = _alpha(sper, spoles)
Signal_alfa = _alpha(sigper, sigpoles)
fout = _gsmth(src, fpoles, Fast_alfa)
sout = _gsmth(src, spoles, Slow_alfa)
macd = fout - sout
sigout = _gsmth(macd, sigpoles, Signal_alfa)
state = 0., mid = 0
if sigtype == SM01
if (macd < mid)
state :=-1
if (macd > mid)
state := 1
else if sigtype == SM02
if (macd < sigout)
state :=-1
if (macd > sigout)
state := 1
colorout = state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(macd, "MACD", color = colorout, linewidth = 2)
plot(sigout, "Signal", color = color.white, linewidth = 1)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM01 ? ta.crossover(macd, mid) : ta.crossover(macd, sigout)
goShort = sigtype == SM01 ? ta.crossunder(macd, mid) : ta.crossunder(macd, sigout)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Gaussian Filter MACD [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Gaussian Filter MACD [Loxx]]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
STD-Filtered, N-Pole Gaussian Filter [Loxx] | https://www.tradingview.com/script/i4xZNAoy-STD-Filtered-N-Pole-Gaussian-Filter-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 4,433 | 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("STD-Filtered, N-Pole Gaussian Filter [Loxx]",
shorttitle="STDFNPGF [Loxx]",
overlay = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
//factorial calc
fact(int n)=>
float a = 1
for i = 1 to n
a *= i
a
//alpha calc
_alpha(int period, int poles)=>
w = 2.0 * math.pi / period
float b = (1.0 - math.cos(w)) / (math.pow(1.414, 2.0 / poles) - 1.0)
float a = - b + math.sqrt(b * b + 2.0 * b)
a
//n-pole calc
_makeCoeffs(simple int period, simple int order)=>
coeffs = matrix.new<float>(order + 1, 3, 0.)
float a = _alpha(period, order)
for r = 0 to order
out = nz(fact(order) / (fact(order - r) * fact(r)), 1)
matrix.set(coeffs, r, 0, out)
matrix.set(coeffs, r, 1, math.pow(a, r))
matrix.set(coeffs, r, 2, math.pow(1.0 - a, r))
coeffs
//n-pole calc
_npolegf(float src, simple int period, simple int order)=>
var coeffs = _makeCoeffs(period, order)
float filt = src * matrix.get(coeffs, order, 1)
int sign = 1
for r = 1 to order
filt += sign * matrix.get(coeffs, r, 0) * matrix.get(coeffs, r, 2) * nz(filt[r])
sign *= -1
filt
//std filter
_filt(float src, int len, float filter)=>
float price = src
float filtdev = filter * ta.stdev(src, len)
price := math.abs(price - nz(price[1])) < filtdev ? nz(price[1]) : price
price
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = 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)"])
period = input.int(25,'Period', group = "Basic Settings")
order = input.int(5,'Order', group = "Basic Settings", minval = 1)
filterop = input.string("Gaussian Filter", "Filter Options", options = ["Price", "Gaussian Filter", "Both", "None"], group= "Filter Settings")
filter = input.float(1, "Filter Devaitions", minval = 0, group= "Filter Settings")
filterperiod = input.int(10, "Filter Period", minval = 0, group= "Filter 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")
[haclose, haopen, hahigh, halow, hamedian, hatypical, haweighted, haaverage] = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, [close, open, high, low, hl2, hlc3, hlcc4, ohlc4])
float src = switch srcoption
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
src := filterop == "Both" or filterop == "Price" and filter > 0 ? _filt(src, filterperiod, filter) : src
out = _npolegf(src, period, order)
out := filterop == "Both" or filterop == "Gaussian Filter" and filter > 0 ? _filt(out, filterperiod, filter) : out
sig = nz(out[1])
state = 0
if (out > sig)
state := 1
if (out < sig)
state := -1
pregoLong = out > sig and (nz(out[1]) < nz(sig[1]) or nz(out[1]) == nz(sig[1]))
pregoShort = out < sig and (nz(out[1]) > nz(sig[1]) or nz(out[1]) == nz(sig[1]))
contsw = 0
contsw := nz(contsw[1])
contsw := pregoLong ? 1 : pregoShort ? -1 : nz(contsw[1])
goLong = pregoLong and nz(contsw[1]) == -1
goShort = pregoShort and nz(contsw[1]) == 1
var color colorout = na
colorout := state == -1 ? redcolor : state == 1 ? greencolor : nz(colorout[1])
plot(out, "N-Pole GF", color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
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 = "STD-Filtered, N-Pole Gaussian Filter [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "STD-Filtered, N-Pole Gaussian Filter [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Crypto Map Dashboard v1.0 | https://www.tradingview.com/script/mo3TjzyS-Crypto-Map-Dashboard-v1-0/ | PRO_SMART_Trader | https://www.tradingview.com/u/PRO_SMART_Trader/ | 62 | 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/
// © PRO_SMART_Trader
//@version=5
indicator("Crypto Map Dashboard ⭕📊", overlay=true,max_lines_count=500,scale=scale.none)
// INPUT--------------------------------------------------------------------------------------------------------------------
show_capS =input.bool (false, "💡Show/Hide Coins MarketCap$", tooltip="Monitor Crypto MarketCap$ (Table1) ",group="️⚙️⚙️⚙️⚙️⚙️⚙️🈁TABLES SSETTING🈁⚙️⚙️⚙️⚙️⚙️⚙️")
show_FLOWS=input.bool (false, "💡Show/Hide Liquidity Flow$", tooltip="Monitor InFlow$ and OutFlow$ (Table1) ")
Trnsp1 =input.int (20,"Transparency" ,0,100,10 )
tablesize =input.string (size.normal, "Tables Size:",[ size.auto, size.tiny, size.small, size.normal, size.large, size.huge])
interval =input.string ('Weekly', "Period", options=['4Hour','Daily', 'Weekly', 'Monthly','3Month','6Month','Yearly'], inline='1')
OPTIONAL =input.string ("XRP.D","| Dominance For :" ,["ADA.D","SOL.D","XRP.D","DOGE.D","DOT.D","AVAX.D","LTC.D","ETC.D","ATOM.D","FTT.D","NEAR.D","XMR.D","XLM.D","BCH.D","ALGO.D"], tooltip=("Other Major coins \n position>>top_right_corner") , inline='1')
i_res=interval== "4Hour"?"240": interval== "Daily" ? "1D" : interval== "Weekly"?"1W" : interval== "Monthly"?"1M" :interval== "3Month"?"3M" :interval== "6Month"?"6M":interval== "Yearly"?"12M":interval
// MAJOR DOMINANCES REQUEST-------------------------------------------------------------------------------------------------
BTCD = math.round(request.security ("BTC.D" , i_res, close),2)
ETHD = math.round(request.security ("ETH.D" , i_res, close),2)
OTHERSD = math.round(request.security ("OTHERS.D", i_res, close),2)
USDTD = math.round( request.security ("USDT.D" , i_res, close),2)
BNBD = math.round(request.security ("BNB.D" , i_res, close),2)
USDCD = math.round(request.security ("USDC.D" , i_res, close),2)
// MINOR DOMINANCES REQUEST
XRPD = math.round(request.security ("XRP.D" , i_res, close),2)
ADAD = math.round(request.security ("ADA.D" , i_res, close),2)
SOLD = math.round(request.security ("SOL.D" , i_res, close),2)
TRXD = math.round(request.security ("TRX.D" , i_res, close),2)
DOTD = math.round(request.security ("DOT.D" , i_res, close),2)
DOGED = math.round(request.security ("DOGE.D", i_res, close),2)
OPTD = math.round(request.security (OPTIONAL, i_res, close),2)
// ----------------------------------------------------------------
OTHERSD2= 100-(BTCD+ETHD+OTHERSD+USDTD+BNBD+USDCD)
// ----------------------------------------------------------------
TOTAL = int (request.security("TOTAL" , i_res, close))
TOTAL2 = int (request.security("TOTAL2" , i_res, close))
TOTAL3 = int (request.security("TOTAL3" , i_res, close))
TOTALDEFI = int (request.security("TOTALDEFI", i_res, close))
BTCCAP=(BTCD*TOTAL/100)
ETHCAP=(ETHD*TOTAL/100)
OTHERSCAP=(OTHERSD*TOTAL/100)
USDTCAP=(USDTD*TOTAL/100)
USDCCAP=(USDCD*TOTAL/100)
BNBCAP=(BNBD*TOTAL/100)
OPTCAP=(OPTD*TOTAL/100)
// =====================================================================
//funtions (Calculate changes)-------------------------------------------------------------
chng(x,x1) =>
math.round((x-x1)/x1*100, 2)
// ======================================================================================================🈁TABLE🈁=========================================================================================
var Table = table.new(position = position.top_right, columns = 8, rows =8, border_width = 0,bgcolor=color.new(color.white, Trnsp1))
if barstate.islast
table.cell(table_id = Table, column = 0, row = 0, text = "👁️️ CRYPTO👁️🗨️ \n DOMINANCEs" , text_size=tablesize, tooltip="DominanceS Screener " )
table.cell(table_id = Table, column = 1, row = 0, text = " BTC.D % \n " + str.tostring(BTCD) , text_size=tablesize, bgcolor=color.new(color.orange, Trnsp1), tooltip="Bitcoin " )
table.cell(table_id = Table, column = 2, row = 0, text = " ETH.D % \n " + str.tostring(ETHD) , text_size=tablesize, bgcolor=color.new(color.blue , Trnsp1), tooltip="Ethereum " )
table.cell(table_id = Table, column = 3, row = 0, text = " OTHERS.D% \n" + str.tostring(OTHERSD) , text_size=tablesize, bgcolor=color.new(color.teal , Trnsp1), tooltip="Others(Altcoins)" )
table.cell(table_id = Table, column = 4, row = 0, text = " USDT.D % \n " + str.tostring(USDTD) , text_size=tablesize, bgcolor=color.new(color.green , Trnsp1), tooltip="Tether " )
table.cell(table_id = Table, column = 5, row = 0, text = " USDC.D % \n " + str.tostring(USDCD) , text_size=tablesize, bgcolor=color.new(color.lime , Trnsp1), tooltip="USD Coin " )
table.cell(table_id = Table, column = 6, row = 0, text = " BNB.D % \n " + str.tostring(BNBD) , text_size=tablesize, bgcolor=color.new(color.yellow, Trnsp1), tooltip="Binance Coin " )
table.cell(table_id = Table, column = 7, row = 0, text = OPTIONAL +"% \n" + str.tostring(OPTD) , text_size=tablesize,text_color=color.white,bgcolor=color.new(color.black, Trnsp1),tooltip="Other Major Coin" )
// // ------------------------------------------
// // ------------------------------------------
table.cell(table_id = Table, column = 0, row =1, text = "🔺Change ("+interval+")\n\n 🔻Change (" +interval +")%" , bgcolor=color.new(color.red, Trnsp1) ,text_size=tablesize )
table.cell(table_id = Table, column = 1, row =1, text = str.tostring(math.round(chng(BTCD,BTCD[1])*BTCD[1]/100 ,2 )) +" \n -------- \n " +str.tostring(chng(BTCD,BTCD[1] ))+ " %" ,text_size=tablesize, text_size=tablesize, text_color=chng(BTCD,BTCD[1])>=0? color.green:color.red )
table.cell(table_id = Table, column = 2, row =1, text = str.tostring(math.round(chng(ETHD,ETHD[1])*ETHD[1]/100,2 )) +" \n -------- \n " +str.tostring(chng(ETHD,ETHD[1] ))+ " %" ,text_size=tablesize, text_size=tablesize, text_color=chng(ETHD,ETHD[1])>=0? color.green:color.red )
table.cell(table_id = Table, column = 3, row =1, text = str.tostring(math.round(chng(OTHERSD,OTHERSD[1])*OTHERSD[1]/100 ,2)) +" \n -------- \n " +str.tostring(chng(OTHERSD,OTHERSD[1]))+ " %" ,text_size=tablesize, text_size=tablesize, text_color=chng(OTHERSD,OTHERSD[1])>=0?color.green:color.red )
table.cell(table_id = Table, column = 4, row =1, text = str.tostring(math.round(chng(USDTD,USDTD[1])*USDTD[1]/100,2 )) +" \n -------- \n " +str.tostring(chng(USDTD,USDTD[1] ))+ " %" ,text_size=tablesize, text_size=tablesize, text_color=chng(USDTD,USDTD[1])>=0? color.green:color.red )
table.cell(table_id = Table, column = 5, row =1, text = str.tostring(math.round(chng(USDCD,USDCD[1])*USDCD[1]/100,2 )) +" \n -------- \n " +str.tostring(chng(USDCD,USDCD[1] ))+ " %" ,text_size=tablesize, text_size=tablesize, text_color=chng(USDCD,USDCD[1])>=0? color.green:color.red )
table.cell(table_id = Table, column = 6, row =1, text = str.tostring(math.round(chng(BNBD,BNBD[1])*BNBD[1]/100,2 )) +" \n -------- \n " +str.tostring(chng(BNBD,BNBD[1] ))+ " %" ,text_size=tablesize, text_size=tablesize, text_color=chng(BNBD,BNBD[1])>=0? color.green:color.red )
table.cell(table_id = Table, column = 7, row =1, text = str.tostring(math.round(chng(OPTD,OPTD[1])*OPTD[1]/100,2 )) +" \n -------- \n " +str.tostring(chng(OPTD,OPTD[1] ))+ " %" ,text_size=tablesize, text_size=tablesize, text_color=chng(OPTD,OPTD[1])>=0? color.green:color.red )
// -------------------------------------------------------------------------------------------------------------------------------------
if show_capS
table.cell(table_id = Table, column = 0, row = 2, text = " 💹Market Cap$💵 " ,width=9,tooltip="MarketCap$ Screener " ,text_size=tablesize)
table.cell(table_id = Table, column = 1, row = 2, text ="$"+ str.tostring(math.round((BTCCAP)/1000000000 ,3)) +" B" , bgcolor=color.new(color.orange, Trnsp1),text_size=tablesize)
table.cell(table_id = Table, column = 2, row = 2, text ="$"+ str.tostring(math.round((ETHCAP)/1000000000 ,3)) +" B" , bgcolor=color.new(color.blue , Trnsp1),text_size=tablesize)
table.cell(table_id = Table, column = 3, row = 2, text ="$"+ str.tostring(math.round((OTHERSCAP)/1000000000 ,3)) +" B" , bgcolor=color.new(color.teal , Trnsp1),text_size=tablesize)
table.cell(table_id = Table, column = 4, row = 2, text ="$"+ str.tostring(math.round((USDTCAP)/1000000000 ,3)) +" B" , bgcolor=color.new(color.green , Trnsp1),text_size=tablesize)
table.cell(table_id = Table, column = 5, row = 2, text ="$"+ str.tostring(math.round((USDCCAP)/1000000000 ,3)) +" B" , bgcolor=color.new(color.lime , Trnsp1),text_size=tablesize)
table.cell(table_id = Table, column = 6, row = 2, text ="$"+ str.tostring(math.round((BNBCAP)/1000000000 ,3)) +" B" , bgcolor=color.new(color.yellow, Trnsp1),text_size=tablesize)
table.cell(table_id = Table, column = 7, row = 2, text ="$"+ str.tostring(math.round((OPTCAP)/1000000000 ,3)) +" B" , text_color=color.white,bgcolor=color.new(color.black, Trnsp1),text_size=tablesize)
if show_FLOWS
table.cell(table_id = Table, column = 0, row = 3, text = "🔄Market Flow$💸\n("+(interval)+")" , bgcolor=color.new(color.rgb(208, 129, 117) , Trnsp1),tooltip="InFlow$ and OutFlow$ Screener " ,text_size=tablesize )
table.cell(table_id = Table, column = 1, row = 3, text ="$"+ str.tostring(int(chng(BTCCAP,BTCCAP[1])*BTCCAP[1]/100000) /1000 ) +" M" +" \n -------- \n " +str.tostring(chng(BTCCAP,BTCCAP[1] ))+ " %" ,text_size=tablesize,text_color=chng(BTCCAP,BTCCAP[1])>=0? color.green:color.red)
table.cell(table_id = Table, column = 2, row = 3, text ="$"+ str.tostring(int(chng(ETHCAP,ETHCAP[1])*ETHCAP[1]/100000) /1000 ) +" M" +" \n -------- \n " +str.tostring(chng(ETHCAP,ETHCAP[1] ))+ " %" ,text_size=tablesize,text_color=chng(ETHCAP,ETHCAP[1])>=0? color.green:color.red)
table.cell(table_id = Table, column = 3, row = 3, text ="$"+ str.tostring(int(chng(OTHERSCAP,OTHERSCAP[1])*OTHERSCAP[1]/100000) /1000 ) +" M" +" \n -------- \n " +str.tostring(chng(OTHERSCAP,OTHERSCAP[1]))+ " %" ,text_size=tablesize,text_color=chng(OTHERSCAP,OTHERSCAP[1])>=0?color.green:color.red)
table.cell(table_id = Table, column = 4, row = 3, text ="$"+ str.tostring(int(chng(USDTCAP,USDTCAP[1])*USDTCAP[1]/100000 ) /1000 ) +" M" +" \n -------- \n " +str.tostring(chng(USDTCAP,USDTCAP[1] ))+ " %" ,text_size=tablesize,text_color=chng(USDTCAP,USDTCAP[1])>=0? color.green:color.red)
table.cell(table_id = Table, column = 5, row = 3, text ="$"+ str.tostring(int(chng(USDCCAP,USDCCAP[1])*USDCCAP[1]/100000 ) /1000 ) +" M" +" \n -------- \n " +str.tostring(chng(USDCCAP,USDCCAP[1] ))+ " %" ,text_size=tablesize,text_color=chng(USDCCAP,USDCCAP[1])>=0? color.green:color.red)
table.cell(table_id = Table, column = 6, row = 3, text ="$"+ str.tostring(int(chng(BNBCAP,BNBCAP[1])*BNBCAP[1]/100000 ) /1000 ) +" M" +" \n -------- \n " +str.tostring(chng(BNBCAP,BNBCAP[1] ))+ " %" ,text_size=tablesize,text_color=chng(BNBCAP,BNBCAP[1])>=0? color.green:color.red)
table.cell(table_id = Table, column = 7, row = 3, text ="$"+ str.tostring(int(chng(OPTCAP,OPTCAP[1])*OPTCAP[1]/100000 ) /1000 ) +" M" +" \n -------- \n " +str.tostring(chng(OPTCAP,OPTCAP[1] ))+ " %" ,text_size=tablesize,text_color=chng(OPTCAP,OPTCAP[1])>=0? color.green:color.red)
// // // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// // // ---------------------------------------------------bottom right Table---------------------------------------------------------------------------------------------------
// // // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var Table1 = table.new(position = position.bottom_right, columns =5, rows =3, border_width = 0,bgcolor=color.new(color.black, Trnsp1))
if barstate.islast
table.cell(table_id = Table1, column = 0, row = 0, text = " 👁️ CRYPTO👁️🗨️ \n TOTALs CAP$" , bgcolor=color.new(color.rgb(88, 88, 88), Trnsp1) ,text_size=tablesize ,text_color=color.white ,tooltip="Crypto Total MarketCap$ Screener " )
table.cell(table_id = Table1, column = 1, row = 0, text = " TOTAL:\n $ " + str.tostring (math.round((TOTAL/1000000000 ),3)) +" B" ,text_size=tablesize ,text_color=color.white,bgcolor=color.new(#000080, Trnsp1),tooltip=" Total MarkcetCap" )
table.cell(table_id = Table1, column = 2, row = 0, text = " TOTAL2:\n $ " + str.tostring(math.round((TOTAL2/1000000000 ),3)) +" B" ,text_size=tablesize ,text_color=color.white,bgcolor=color.new(#0000CD, Trnsp1),tooltip=" Total MarkcetCap Exclude BTC" )
table.cell(table_id = Table1, column = 3, row = 0, text = " TOTAL3:\n $ " + str.tostring(math.round((TOTAL3/1000000000 ),3)) +" B" ,text_size=tablesize ,text_color=color.white,bgcolor=color.new(#4169E1, Trnsp1),tooltip=" Total MarkcetCap Exclude BTC & ETH " )
table.cell(table_id = Table1, column = 4, row = 0, text = " TOTALDEFI:\n $ " + str.tostring(math.round((TOTALDEFI/1000000000),3)) +" B" ,text_size=tablesize ,text_color=color.white,bgcolor=color.new(#6495ED, Trnsp1),tooltip=" Total DeFi MarkcetCap" )
table.cell(table_id = Table1, column = 0, row =1, text = "🔺Change ("+interval+")\n\n 🔻Change (" +interval +")%" , bgcolor=color.new(color.red, Trnsp1),text_color=color.white ,text_size=tablesize)
table.cell(table_id = Table1, column = 1, row =1, text ="$ " + str.tostring(math.round((chng(TOTAL,TOTAL[1])*TOTAL[1]/100 /1000000000 ),3)) +" B\n -------- \n " +str.tostring(chng(TOTAL,TOTAL[1] )) +" %" ,text_color=chng(TOTAL,TOTAL[1]) >=0?color.green:color.red,text_size=tablesize)
table.cell(table_id = Table1, column = 2, row =1, text ="$ " + str.tostring(math.round((chng(TOTAL2,TOTAL2[1])*TOTAL2[1]/100 /1000000000 ),3)) +" B\n -------- \n " +str.tostring(chng(TOTAL2,TOTAL2[1] )) +" %" ,text_color=chng(TOTAL2,TOTAL2[1]) >=0?color.green:color.red,text_size=tablesize)
table.cell(table_id = Table1, column = 3, row =1, text ="$ " + str.tostring(math.round((chng(TOTAL3,TOTAL3[1])*TOTAL3[1]/100 /1000000000 ),3)) +" B\n -------- \n " +str.tostring(chng(TOTAL3,TOTAL3[1] )) +" %" ,text_color=chng(TOTAL3,TOTAL3[1]) >=0?color.green:color.red,text_size=tablesize)
table.cell(table_id = Table1, column = 4, row =1, text ="$ " + str.tostring(math.round((chng(TOTALDEFI,TOTALDEFI[1])*TOTALDEFI[1]/100/1000000000),3)) +" B\n -------- \n " +str.tostring(chng(TOTALDEFI,TOTALDEFI[1]))+" %" ,text_color=chng(TOTALDEFI,TOTALDEFI[1])>=0?color.green:color.red,text_size=tablesize)
// // // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// // // --------------------------------------------------------------⭕PIE CHART______DONUT CHART⭕----------------------------------------------------------------------------------------------
// // // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Pie_Donut_chart =input.bool(false, "💡(PIE_DONUT) CHART", group="️⚙️⚙️️⚙️️️️️⚙️⚙️⭕️️pie & Donut Chart setting⭕️️⚙️⚙️⚙️⚙️️⚙️️️")
Show1 = input.bool(false, "💡Show/Hide labels and details " ,tooltip="Monitor dominances on Pie chart 🔰\nif you also want to see a Donut Chart form just increace the insider Radius " ,inline="2")
r = input.int (0 ,"*Inside radius* ",minval=0,maxval=50,step=10 ,inline="3")
R = input.int (120 ,"*Outside radius*",minval=80,maxval=200,step=10 ,tooltip="🔘 Radius of insider and outer circle \nNOTE🔰\n*If this larger radius exceeds the allowed limit,\nthe chart may disappear So, to solve this problem, shift the graph to the leftside *👇" ,inline="3")
w = input.int (10 ,"|Overlap|",minval=0,maxval=10,step=2 ,inline="4")
p_x = input.int (-50 ,"<<==Shift==>> " ,step=50 ,tooltip="Overlap:Lines Thickness \n shift: (-)shift to leftside _OR_ rightside(+) " ,inline="4")
//color partition on circle
C1=int(BTCD*360/100 )
C2=int( C1+(ETHD*360/100) )
C3=int(C2+(OTHERSD*360/100))
C4=int (C3+(USDTD*360/100) )
C5=int(C4+(USDCD*360/100) )
C6=int(C5+(BNBD*360/100) )
C7=int(C6+(OPTD*360/100) )
// Pie_chart ======================================================================================================================================================================
color CLR= na
for i = 0 to 360 by 1
x0 =int( r*math.sin(math.toradians(i)))
y0 =int( r*math.cos(math.toradians(i)))
x =int( R*math.sin(math.toradians(i)))
y =int( R*math.cos(math.toradians(i)))
CLR:=( i<C1 ? color.orange : i<C2 ? color.blue: i< C3? color.teal:i<C4 ? color.green:i<C5?color.lime:i<C6?color.yellow: color.fuchsia)
if barstate.islast and Pie_Donut_chart
line = line.new(bar_index+p_x+R+x0 , close+y0 , bar_index+p_x+ x+R, close + y , color= CLR ,style= w==0? line.style_arrow_right:line.style_solid, extend = extend.none, width=w )
L1 =label.new(bar_index+p_x+R ,close ,"Crypto Dominance \n🔎Distribution🔍" , color=color.black ,style=label.style_label_center,textcolor=color.yellow,textalign=text.align_center,size=size.small,tooltip="🔴Pie chart or \n⭕Dounat chart \n 👆👆⚙️✅")
// Pie_chart
//------------------------------ showing lables and details on Pie_chart-----------------------------------------------
if Show1 and Pie_Donut_chart
L2=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians(C1/2))) ,close+ int( (r+R)/2*math.cos(math.toradians(C1/2))) ,"BTC.D = "+ str.tostring(BTCD) + " %" ,style= label.style_none,textcolor=color.white ,textalign=text.align_center ,size=size.large ,tooltip="👑Bitcoin Dominance")
label.delete(L2[1])
L3=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians((C1+C2)/2))),close+ int( (r+R)/2*math.cos(math.toradians((C1+C2)/2))) ,"ETH.D = "+ str.tostring(ETHD) + " %" ,style= label.style_none,textcolor=color.white ,textalign=text.align_center ,size=size.normal,tooltip="💎Ethereum Dominance")
label.delete(L3[1])
L4=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians((C2+C3)/2))),close+ int( (r+R)/2*math.cos(math.toradians((C2+C3)/2))) ,"OTHERS.D = "+ str.tostring(OTHERSD) + " %" ,style= label.style_none,textcolor=color.white ,textalign=text.align_center ,size=size.normal,tooltip="Others Dominance \n(🚀Minor Altcoins)" )
label.delete(L4[1])
L5=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians((C3+C4)/2))),close+ int( (r+R)/2*math.cos(math.toradians((C3+C4)/2))) ," USDT.D = "+ str.tostring(USDTD) + " %" ,style= label.style_label_right,color=color.navy ,textcolor=color.white,textalign=text.align_center ,size=size.small ,tooltip="Tether Dominance")
label.delete(L5[1])
L6=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians((C4+C5)/2))),close+ int( (r+R)/2*math.cos(math.toradians((C4+C5)/2))) ,"USDC.D = "+ str.tostring(USDCD) + " %" ,style= label.style_label_right,color=color.navy ,textcolor=color.white,textalign=text.align_center ,size=size.small ,tooltip="USD Coin Dominance")
label.delete(L6[1])
L7=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians((C5+C6)/2))),close+ int( (r+R)/2*math.cos(math.toradians((C5+C6)/2))) ,"BNB.D = "+ str.tostring(BNBD) + " %" ,style= label.style_label_lower_right,color=color.gray ,textcolor=color.white,textalign=text.align_center ,size=size.small ,tooltip="Binance Coin Dominance")
label.delete(L7[1])
// L8=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians((C6+C7)/2))),close+ int( (r+R)/2*math.cos(math.toradians((C6+C7)/2))) ,OPTIONAL+" = " + str.tostring(OPTD) + " %" ,style= label.style_label_lower_right,color=color.black,textcolor=color.white,textalign=text.align_center ,size=size.small)
// label.delete(L8[1])
L8=label.new(bar_index+p_x+R+ int( (r+R)/2*math.sin(math.toradians((C6+360)/2))),close+ int( (r+R)/2*math.cos(math.toradians((C6+360)/2))),"📍The rest: "+ str.tostring(OTHERSD2) + " %" ,style= label.style_label_down,color=color.maroon ,textcolor=color.white,textalign=text.align_center ,size=size.normal ,tooltip=("🔅Other Major coins:🔰\n ADA.D ="+ str.tostring(ADAD)
+ "%\n SOL.D ="+ str.tostring(SOLD) + " % " + "\n XRP.D ="+ str.tostring(XRPD) + " % \n "+ "DOGE.D =" + str.tostring(DOGED) + " % \n"+ " TRX.D ="+ str.tostring(TRXD) + " %\n "+ "DOT.D ="+ str.tostring(DOTD) + " % \n +... "))
label.delete(L8[1])
// ===========================================📊Column chart📊==========================================================================================================================================
// variables and inputs----------------------------------------------------------------------------------------------------
Column_chart = input.bool(false, "💡 Column chart",group="️⚙️⚙️️⚙️⚙️⚙️⚙️️📊Column chart setting📊⚙️️⚙️⚙️⚙️⚙️️⚙️" )
Show2 = input.bool(false, "💡Show/Hide labels and details ", tooltip="Monitor TOTALs details on Column chart")
var ATHT=3009000000000
ATHT := TOTAL> ATHT ? TOTAL:ATHT
var ATHT2=1707000000000
ATHT2 := TOTAL2> ATHT2 ? TOTAL2:ATHT2
var ATHT3=1131000000000
ATHT3 := TOTAL3> ATHT3 ? TOTAL3:ATHT3
var ATHTDEFI=199481000000
ATHTDEFI:= TOTALDEFI> ATHTDEFI ? TOTALDEFI:ATHTDEFI
TOP =close+R/2
BOTTOM=close-R/1.5
H =7/6*R
H3T = H- ( H*9/3009)
// ===================================================================================================================
if barstate.islast and Column_chart
// ==================================================lines============================================================
ll =line.new(bar_index+p_x+20+ 2*R , BOTTOM, bar_index+20 + p_x+2*R, TOP+R/6 , color=color.black,style=line.style_arrow_right, width=3)
lll=line.new(bar_index+p_x+20+ 2*R , BOTTOM, bar_index+300+ p_x+2*R, BOTTOM , color=color.black,style=line.style_arrow_right, width=3)
// ------------------------------------------
l_05T=line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/6 , bar_index+270+ p_x+2*R, BOTTOM+ H3T/6 ,color=color.white,style= line.style_dashed, width=1)
l_1T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3 , bar_index+270+ p_x+2*R, BOTTOM+ H3T/3 ,color=color.white,style= line.style_dashed, width=1)
l_2T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*2, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*2 ,color=color.white,style= line.style_dashed, width=1)
l_3T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T , bar_index+270+ p_x+2*R, BOTTOM+ H3T ,color=color.white,style= line.style_dashed, width=1)
// l_4T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*4, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*4 ,color=color.white,style= line.style_dashed, width=1 )
// l_5T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*5, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*5 ,color=color.white,style= line.style_dashed, width=1 )
// l_6T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*6, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*6 ,color=color.white,style= line.style_dashed, width=1 )
// l_7T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*7, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*7 ,color=color.white,style= line.style_dashed, width=1 )
// l_8T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*8, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*8 ,color=color.white,style= line.style_dashed, width=1 )
// l_9T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*9, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*9 ,color=color.white,style= line.style_dashed, width=1 )
// l_10T =line.new(bar_index+p_x+10+ 2*R , BOTTOM+ H3T/3*10, bar_index+270+ p_x+2*R, BOTTOM+ H3T/3*10 ,color=color.white,style= line.style_dashed, width=1)
// ==================================================BOXES============================================================
BOX_total =box.new(bar_index+p_x+30+ 2*R , BOTTOM+H*(TOTAL/ATHT) , bar_index+p_x+70+ 2*R ,BOTTOM, border_color=color.white,border_width=2, border_style=line.style_dotted, bgcolor=color.new(#000080, 0),text= Show2 ? (str.tostring(math.round((TOTAL/ATHT *100),2))+"%\n of ATH"):"📊?" ,text_size=size.normal, text_color=color.white, text_valign=text.align_top)
BOX_total2 =box.new(bar_index+p_x+90+ 2*R , BOTTOM+H*(TOTAL2/ATHT) , bar_index+p_x+130+ 2*R,BOTTOM, border_color=color.white,border_width=2, border_style=line.style_dotted, bgcolor=color.new(#0000CD, 0),text=Show2 ?(str.tostring(math.round((TOTAL2/ATHT2 *100),2))+"%\n of ATH"):"📊?" ,text_size=size.normal, text_color=color.white, text_valign=text.align_top)
BOX_total3 =box.new(bar_index+p_x+150+ 2*R, BOTTOM+H*(TOTAL3/ATHT) , bar_index+p_x+190+ 2*R,BOTTOM, border_color=color.white,border_width=2, border_style=line.style_dotted, bgcolor=color.new(#4169E1, 0),text=Show2 ?(str.tostring(math.round((TOTAL3/ATHT3 *100),2))+"%\n of ATH"):"📊?" ,text_size=size.normal, text_color=color.white, text_valign=text.align_top)
BOX_totaldefi=box.new(bar_index+p_x+210+ 2*R, BOTTOM+H*(TOTALDEFI/ATHT), bar_index+p_x+250+ 2*R,BOTTOM, border_color=color.white,border_width=2, border_style=line.style_dotted, bgcolor=color.new(#6495ED,0) ,text=Show2 ?(str.tostring(math.round((TOTALDEFI/ATHTDEFI *100),2))+"%\n of ATH"):"📊?" ,text_size=size.small , text_color=color.white, text_valign=text.align_top)
// ==================================================Labels and details============================================================
L10=label.new(bar_index+p_x+20+ 2*R , BOTTOM-R/10,"TOTALs CAP$\n🔎 Comparison 🔍" , color=color.new(color.white, 30),style=label.style_label_center,textcolor=color.black,textalign=text.align_center,size=size.small,tooltip="📊Column chart\n 👆👆⚙️✅")
if Show2
L11=label.new( bar_index+p_x+50 + 2*R, TOP ,"ATH ",style= label.style_label_down,color=color.new(color.red, 50),textcolor=color.black,textalign=text.align_center,size=size.normal,tooltip="TOTAL \n All Time High = $ " + str.tostring(ATHT/1000000000000) +" T" )
L12=label.new( bar_index+p_x+110+ 2*R, BOTTOM+H*(ATHT2/ATHT) ,"ATH ",style= label.style_label_down,color=color.new(color.red, 50),textcolor=color.black,textalign=text.align_center,size=size.small ,tooltip="TOTAL2 \nAll Time High = $ " + str.tostring(ATHT2/1000000000000) +" T" )
L13=label.new( bar_index+p_x+170+ 2*R, BOTTOM+H*(ATHT3/ATHT) ,"ATH ",style= label.style_label_down,color=color.new(color.red, 50),textcolor=color.black,textalign=text.align_center,size=size.small ,tooltip="TOTAL3 \nAll Time High = $ " + str.tostring(ATHT3/1000000000000) + " T" )
L14=label.new( bar_index+p_x+230+ 2*R, BOTTOM+H*(ATHTDEFI/ATHT) ,"ATH ",style= label.style_label_down,color=color.new(color.red, 50),textcolor=color.black,textalign=text.align_center,size=size.small ,tooltip="TOTALDEFI \nAll Time High = $ " + str.tostring(ATHTDEFI/1000000000)+" B" )
// --------------------------------------------------------------------------
//
lABLE_05T=label.new(bar_index+270+ p_x+2*R , BOTTOM+ H3T/6 ,style= label.style_diamond,color=color.new(color.red,0),textcolor=color.yellow,textalign=text.align_center,size=size.tiny ,tooltip="$500 B " )
lABLE_1T=label.new (bar_index+270+ p_x+2*R , BOTTOM+ H3T/3 ,style= label.style_diamond,color=color.new(color.red,0),textcolor=color.yellow,textalign=text.align_center,size=size.small ,tooltip="$1 T " )
lABLE_2T=label.new (bar_index+270+ p_x+2*R , BOTTOM+ H3T/3*2 ,style= label.style_diamond,color=color.new(color.red,0),textcolor=color.yellow,textalign=text.align_center,size=size.normal ,tooltip="$2 T " )
lABLE_3T=label.new (bar_index+270+ p_x+2*R , BOTTOM+ H3T ,"$3 T" ,style= label.style_flag ,color=color.new(color.red,0),textcolor=color.yellow,textalign=text.align_center,size=size.normal,tooltip="3 Trillion Dollar" )
// --------------------------------------------------------------------------------------_END_----------------------------------------------------------------------------------------------------------------
// ============================================================================================================================================================================================================= |
Multi Timeframe Support & Resistance | https://www.tradingview.com/script/UkTTsmOV-Multi-Timeframe-Support-Resistance/ | jordanfray | https://www.tradingview.com/u/jordanfray/ | 710 | 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/
// © jordanfray
//@version=5
indicator(title="Multi-Timeframe Support & Resistance", overlay=true, max_bars_back=5000)
import jordanfray/threengine_global_automation_library/74 as bot
// Colors - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
green = color.new(#2DBD85,0)
lightGreen = color.new(#2DBD85,80)
red = color.new(#E02A4A,0)
lightRed = color.new(#E02A4A,80)
white = color.new(#ffffff,0)
transparent = color.new(#ffffff,100)
// Strategy Settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
supportLookBack = input.int(defval=22, title = "Support Look Back", group="Support & Resistance Settings")
supportLookAhead = input.int(defval=26, title = "Support Look Ahead", group="Support & Resistance Settings")
resistanceLookBack = input.int(defval=30, title = "Reistance Look Back", group="Support & Resistance Settings")
resistanceLookAhead = input.int(defval=27, title = "Reistance Look Ahead", group="Support & Resistance Settings")
timeframe1 = input.timeframe(defval="60", title="Timeframe 1", group="Support & Resistance 1")
enableSrRanges1 = input.bool(defval=true, title="Enable Support & Resistance Ranges", group="Support & Resistance 1")
supportRange1 = input.float(defval=.25, title=" Support Range (%) ", inline="support1", group="Support & Resistance 1")
supportRange1Color = input.color(defval=green, title="", inline="support1", group="Support & Resistance 1")
resistanceRange1 = input.float(defval=.25, title=" Resistance Range (%) ", inline="resistance1", group="Support & Resistance 1")
resistanceRange1Color = input.color(defval=red, title="", inline="resistance1", group="Support & Resistance 1")
timeframe2 = input.timeframe(defval="120", title="Timeframe 2", group="Support & Resistance 2")
enableSrRanges2 = input.bool(defval=true, title="Enable Support & Resistance Ranges", group="Support & Resistance 2")
supportRange2 = input.float(defval=.25, title=" Support Range (%) ", inline="support2", group="Support & Resistance 2")
supportRange2Color = input.color(defval=green, title="", inline="support2", group="Support & Resistance 2")
resistanceRange2 = input.float(defval=.25, title=" Resistance Range (%) ", inline="resistance2", group="Support & Resistance 2")
resistanceRange2Color = input.color(defval=red, title="", inline="resistance2", group="Support & Resistance 2")
// Support and Resistance Functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getSupport(lookback, lookahead) =>
support = fixnan(ta.pivotlow(lookback, lookahead)[1])
support
getResistance(lookback, lookahead) =>
resistance = fixnan(ta.pivothigh(lookback, lookahead)[1])
resistance
// Support and Resistance 1
support1 = request.security(syminfo.ticker, timeframe1, getSupport(supportLookBack, supportLookAhead))
resistance1 = request.security(syminfo.ticker, timeframe1, getResistance(resistanceLookBack, resistanceLookAhead))
var float mostRecentResistance1 = na
var float mostRecentSupport1 = na
mostRecentResistance1 := ta.change(resistance1) ? resistance1 : mostRecentResistance1
mostRecentSupport1 := ta.change(support1) ? support1 : mostRecentSupport1
var line resistance1Line = na
var line support1Line = na
line.delete(resistance1Line)
line.delete(support1Line)
resistance1Line := line.new(x1=bar_index[10], y1=mostRecentResistance1, x2=bar_index, y2=mostRecentResistance1, color=resistanceRange1Color, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
support1Line := line.new(x1=bar_index[10], y1=mostRecentSupport1, x2=bar_index, y2=mostRecentSupport1, color=supportRange1Color, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
resistance1Price = plot(series=mostRecentResistance1, title="Resistance Price", color=red, editable=false, display=display.price_scale)
support1Price = plot(series=mostRecentSupport1, title="Support Price", color=green, editable=false, display=display.price_scale)
var label support1label = na
var label resistance1label = na
label.delete(support1label)
label.delete(resistance1label)
support1label := label.new(x=bar_index+30, y=mostRecentSupport1, text=bot.convertTimeframeToString(timeframe1), color=supportRange1Color, textcolor=white, style=label.style_label_down)
resistance1label := label.new(x=bar_index+30, y=mostRecentResistance1, text=bot.convertTimeframeToString(timeframe1), color=resistanceRange1Color, textcolor=white, style=label.style_label_down)
// Support and Resistance 2
support2 = request.security(syminfo.ticker, timeframe2, getSupport(supportLookBack, supportLookAhead))
resistance2 = request.security(syminfo.ticker, timeframe2, getResistance(resistanceLookBack, resistanceLookAhead))
var float mostRecentResistance2 = na
var float mostRecentSupport2 = na
mostRecentResistance2 := ta.change(resistance2) ? resistance2 : mostRecentResistance2
mostRecentSupport2 := ta.change(support2) ? support2 : mostRecentSupport2
var line resistance2Line = na
var line support2Line = na
line.delete(resistance2Line)
line.delete(support2Line)
resistance2Line := line.new(x1=bar_index[10], y1=mostRecentResistance2, x2=bar_index, y2=mostRecentResistance2, color=resistanceRange2Color, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
support2Line := line.new(x1=bar_index[10], y1=mostRecentSupport2, x2=bar_index, y2=mostRecentSupport2, color=supportRange2Color, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
resistance2Price = plot(series=mostRecentResistance2, title="Resistance Price", color=red, editable=false, display=display.price_scale)
support2Price = plot(series=mostRecentSupport2, title="Support Price", color=green, editable=false, display=display.price_scale)
var label support2label = na
var label resistance2label = na
label.delete(support2label)
label.delete(resistance2label)
support2label := label.new(x=bar_index+30, y=mostRecentSupport2, text=bot.convertTimeframeToString(timeframe2), color=supportRange2Color, textcolor=white, style=label.style_label_down)
resistance2label := label.new(x=bar_index+30, y=mostRecentResistance2, text=bot.convertTimeframeToString(timeframe2), color=resistanceRange2Color, textcolor=white, style=label.style_label_down)
if enableSrRanges1
support1RangeTop = support1 + (support1 * (supportRange1/100))
support1RangeBottom = support1 - (support1 * (supportRange1/100))
resistance1RangeTop = resistance1 + (resistance1 * (resistanceRange1/100))
resistance1RangeBottom = resistance1 - (resistance1 * (resistanceRange1/100))
var line support1RangeTopLine = na
var line support1RangeBottomLine = na
var line resistance1RangeTopLine = na
var line resistance1RangeBottomLine = na
line.delete(support1RangeTopLine)
line.delete(support1RangeBottomLine)
line.delete(resistance1RangeTopLine)
line.delete(resistance1RangeBottomLine)
support1RangeTopLine := line.new(x1=bar_index[10], y1=support1RangeTop, x2=bar_index, y2=support1RangeTop, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
support1RangeBottomLine := line.new(x1=bar_index[10], y1=support1RangeBottom, x2=bar_index, y2=support1RangeBottom, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
linefill.new(line1=support1RangeTopLine, line2=support1RangeBottomLine, color=lightGreen)
resistance1RangeTopLine := line.new(x1=bar_index[10], y1=resistance1RangeTop, x2=bar_index, y2=resistance1RangeTop, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
resistance1RangeBottomLine := line.new(x1=bar_index[10], y1=resistance1RangeBottom, x2=bar_index, y2=resistance1RangeBottom, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
linefill.new(line1=resistance1RangeTopLine, line2=resistance1RangeBottomLine, color=lightRed)
if enableSrRanges2
support2RangeTop = support2 + (support2 * (supportRange2/100))
support2RangeBottom = support2 - (support2 * (supportRange2/100))
resistance2RangeTop = resistance2 + (resistance2 * (resistanceRange2/100))
resistance2RangeBottom = resistance2 - (resistance2 * (resistanceRange2/100))
var line support2RangeTopLine = na
var line support2RangeBottomLine = na
var line resistance2RangeTopLine = na
var line resistance2RangeBottomLine = na
line.delete(support2RangeTopLine)
line.delete(support2RangeBottomLine)
line.delete(resistance2RangeTopLine)
line.delete(resistance2RangeBottomLine)
support2RangeTopLine := line.new(x1=bar_index[10], y1=support2RangeTop, x2=bar_index, y2=support2RangeTop, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
support2RangeBottomLine := line.new(x1=bar_index[10], y1=support2RangeBottom, x2=bar_index, y2=support2RangeBottom, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
linefill.new(line1=support2RangeTopLine, line2=support2RangeBottomLine, color=lightGreen)
resistance2RangeTopLine := line.new(x1=bar_index[10], y1=resistance2RangeTop, x2=bar_index, y2=resistance2RangeTop, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
resistance2RangeBottomLine := line.new(x1=bar_index[10], y1=resistance2RangeBottom, x2=bar_index, y2=resistance2RangeBottom, color=transparent, width=1, xloc=xloc.bar_index, style=line.style_solid, extend=extend.both)
linefill.new(line1=resistance2RangeTopLine, line2=resistance2RangeBottomLine, color=lightRed)
|
Koncorde Plus | https://www.tradingview.com/script/mAEzn9Im-Koncorde-Plus/ | OskarGallard | https://www.tradingview.com/u/OskarGallard/ | 379 | 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/
// © OskarGallard
//@version=5
indicator("Koncorde Plus", "Koncorde [+]")
f_htf_ohlc(_htf) =>
var htf_o = 0.
var htf_h = 0.
var htf_l = 0.
htf_c = close
var htf_ox = 0.
var htf_hx = 0.
var htf_lx = 0.
var htf_cx = 0.
if ta.change(time(_htf))
htf_ox := htf_o
htf_o := open
htf_hx := htf_h
htf_h := high
htf_lx := htf_l
htf_l := low
htf_cx := htf_c[1]
htf_cx
else
htf_h := math.max(high, htf_h)
htf_l := math.min(low, htf_l)
htf_l
[htf_ox, htf_hx, htf_lx, htf_cx, htf_o, htf_h, htf_l, htf_c]
show_K = input.bool(true, "═══════ Show Koncorde ═══════")
g_pattern = "Pattern 🐳 🆚 🐟"
show_espejo = input.bool(true, "Mirror Pattern", inline="p1", group=g_pattern)
show_oso = input.bool(false, "Bear Hug Pattern", inline="p1", group=g_pattern)
show_cruces = input.bool(false, "Crossing Pattern", inline="p2", group=g_pattern)
show_primavera = input.bool(false, "Spring Pattern", inline="p2", group=g_pattern)
show_cero = input.bool(true, "Zero Pattern", inline="p3", group=g_pattern)
show_arpon = input.bool(true, "Harpoon Pattern", inline="p3", group=g_pattern)
tip_chg = 'Performance (Change), displays values from the beginning of the month, week, year etc (So = Start of)\n\nDistance from/to MA - Multi TimeFrame Price Distance from/to MA'
i_chg = input.bool(true, "Statistic Panel of Performance (Change)", inline='oth', group=g_pattern, tooltip=tip_chg)
i_textSize = input.string('Small', 'Text Size', options=['Tiny', 'Small', 'Normal'], inline='oth', group=g_pattern)
textSize = i_textSize == 'Small' ? size.small : i_textSize == 'Normal' ? size.normal : size.tiny
tprice = input.source(ohlc4, "RSI, BB & Stoch Source", group="Trend")
srcMfi = input.source(hlc3, "MFI Source", group="Trend")
len_mfi_rsi = input.int(14, "MFI & RSI Length", 1, group="Trend")
length_bb = input.int(25, "BB Length", 1, inline="bb", group="Trend")
mult_bb = input.float(2.0, "BB Multiplier", 1, inline="bb", group="Trend")
length_ma1 = input.int(15, "MA Length", 1, inline="ma1", group="Trend")
type_ma1 = input.string("EMA", "Type", inline="ma1", group="Trend", options=["SMA", "EMA", "Wilder", "WMA", "VWMA", "ALMA", "LSMA", "HMA", "VAMA", "JMA", "RSS_WMA"])
// Volume Type
voltype = input.string("Default", "Volume Type (if VWMA)", options=["Default", "Tick"], group = "Trend")
// VAMA factor
factor = input.float(0.67, "Factor (if VAMA)", minval = 0.01, step = 0.1, group = "Trend")
// ALMA Offset and Sigma
offs = input.float(0.85, "Offset (if ALMA)", step=0.01, minval=0, group = "Trend")
sigma = input.int(6, "Sigma (if ALMA)", minval=0, group = "Trend")
// JMA
phaseJ = input.int(50, "Phase (if JMA)", group = "Trend")
powerJ = input.int(2, "Power (if JMA)", group = "Trend")
// LSMA Offset
loff = input.int(0, "Offset (if LSMA)", minval=0, group = "Trend")
m_pvi_nvi = input.int(15, "PVI & NVI Length", 1, group="Volume")
longitudPVI = input.int(90, "Min-Max Period [PVI]", 2, group="Volume")
longitudNVI = input.int(90, "Min-Max Period [NVI]", 2, group="Volume")
show_DVDI = input.bool(false, "═════ Show Dual Volume Divergence Index ═════")
// Mode Selection
mode = input.string("Oscillator Mode", "Mode Selection", inline="extra2", options=["Cloud Mode", "Oscillator Mode", "Bar Counter Mode"])
// Tick Volume Toggle
usetick = input.bool(false, "Use Tick Volume", inline="extra2")
show_bar_dvdi = input.bool(false, "Show Bars Color", inline="extra2")
src = input.source(close, "Source") // Source
// Sampling Period
per = input.int(55, "Sampling Period", 1)
smper = input.int(1, "Smoothing Period", 1)
group_macd = "Moving Average Convergence Divergence"
show_macd = input.bool(true, "═════ Show MACD ═════", group = group_macd)
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(12, "Length: Fast", 1, inline = "macd2", group = group_macd)
macd_slow = input.int(26, "Slow", 2, inline = "macd2", group = group_macd)
macd_sig = input.int(9, "Signal", 1, inline = "macd2", group = group_macd)
show_delta = input.bool(false, "═══════ Show Volume Delta Arrows ═══════", group="Volume Delta Arrows")
v_type = input.string("Cumulative Volume Delta", "Volume Type", group="Volume Delta Arrows", options = ["Cumulative Volume Delta", "Delta+AccDist", "Delta+OBV", "Delta+PVT", "OBV+PVT+AccDist", "OBV+PVT"])
fast_len = input.int(5, "Fast MA", 1, inline="delta1", group="Volume Delta Arrows")
type_fast = input.string("Wilder", "Type", inline="delta1", group="Volume Delta Arrows", options=["SMA", "EMA", "Wilder", "WMA", "ALMA", "LSMA", "HMA", "JMA", "RSS_WMA"])
slow_len = input.int(21, "Slow MA", 1, inline="delta2", group="Volume Delta Arrows")
type_slow = input.string("EMA", "Type", inline="delta2", group="Volume Delta Arrows", options=["SMA", "EMA", "Wilder", "WMA", "ALMA", "LSMA", "HMA", "JMA", "RSS_WMA"])
group_tsv = "Enhanced Time Segmented Volume"
show_tsv = input.bool(false, "Show Time Segmented Volume [TSV]", inline = "s1", group = group_tsv)
len_tsv = input.int(13, "Length", 3, inline = "s1", group = group_tsv)
len_ma = input.int(7, "MA Length", 1, inline = "ma_tsv", group = group_tsv)
type_ma = input.string("SMA", "Type", inline = "ma_tsv", group = group_tsv, options=["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])
Jma
// 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 = voltype == "Default" ? volumen : tickvol
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
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)
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_ma1, tendencia, length_ma1) //ta.ema(tendencia, length_ma1)
char_up = "▲", char_dn = "▼", char_arp = "⇗", char_sur = "⇘"
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
cross_up_shark2 = 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 ? #00B0F6 : #003785, 1, plot.style_columns)
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)
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)
plotchar(show_cruces ? cross_up_trend : na, "Crossover", char_up, location.bottom, color.new(color.teal, 60), size=size.tiny)
plotchar(show_cruces ? cross_dn_trend : na, "Crossunder", char_dn, location.top, color.new(color.red, 60), size=size.tiny)
plotchar(show_cero ? patron_cero : na, "Zero Pattern", char_up, location.bottom, color.new(#FFCC99, 25), size=size.tiny)
plotchar(show_primavera ? patron_primavera : na, "Spring Pattern", char_up, location.bottom, color.new(color.lime, 35), size=size.tiny)
plotchar(show_arpon ? cross_up_shark : na, "Harpoon Pattern", char_arp, location.bottom, color.new(color.aqua, 10), size=size.tiny)
plotchar(show_arpon ? cross_dn_shark : na, "Exit Harpoon Pattern", char_sur, location.top, color.new(#FF0062, 10), size=size.tiny)
plotchar(show_arpon ? cross_up_shark2 : na, "Weak Harpoon Pattern", char_arp, location.bottom, color.new(color.blue, 50), size=size.tiny)
bgcolor(show_espejo and patron_espejo ? color.new(color.aqua, 85) : na, title="Mirror Pattern")
bgcolor(show_oso and patron_oso ? color.new(color.red, 85) : na, title="Bear Hug Pattern")
//______________________________________________________________________________
// 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 = usetick ? tickvol : volume
[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
//----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Index Center
centplot = plot(0, "Index Center", display=display.none, editable=false)
// 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
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)
//____________________________________________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
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
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)
//____________________________________________MACD____________________________________________
[macd_line, macd_signal, _] = ta.macd(macd_src, macd_fast, macd_slow, macd_sig)
cian = color.new(#38F5E9, 0)
cian_oscuro = color.new(#1C7A74, 0)
pink = color.new(#F7709D, 0)
pink_oscuro = color.new(#7B384E, 0)
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
char_dot = "◍"
plotchar(show_macd ? macd_line : na, "MACD", char_dot, location.top, color_macd)
barcolor(show_macd2 ? color_macd : na, title="MACD Bars Color")
//______________________________________________________________________________
// Performance Table
//______________________________________________________________________________
[_, _, _, Cd , _, _, _, _] = f_htf_ohlc('D')
[_, _, _, Cw , _, _, _, _] = f_htf_ohlc('W')
[_, _, _, Cm , _, _, _, _] = f_htf_ohlc('M')
[_, _, _, C3m, _, _, _, _] = f_htf_ohlc('3M')
[_, _, _, C6m, _, _, _, _] = f_htf_ohlc('6M')
[_, _, _, Cy , _, _, _, _] = f_htf_ohlc('12M')
var table change = table.new(position.top_right, 4, 2, border_width=3)
if barstate.islast and i_chg
table.cell(change, 0, 0, 'CHG %', text_color=color.blue, bgcolor=color.new(color.blue, 80), text_halign=text.align_left, text_size=textSize)
table.cell(change, 0, 1, ' ', text_color=color.blue, bgcolor=color.new(color.blue, 80), text_halign=text.align_left, text_size=textSize)
table.cell(change, 1, 0, str.tostring((close / Cd - 1) * 100, '#.##') + '%\nSoD ', text_color=close / Cd - 1 > 0 ? #00FF98 : #FF9800, bgcolor=close / Cd - 1 > 0 ? color.new(color.green, 80) : color.new(color.red, 80), text_size=textSize, tooltip='SoD : Start of the Day')
table.cell(change, 2, 0, str.tostring((close / Cw - 1) * 100, '#.##') + '%\nSoW' , text_color=close / Cw - 1 > 0 ? #00FF98 : #FF9800, bgcolor=close / Cw - 1 > 0 ? color.new(color.green, 80) : color.new(color.red, 80), text_size=textSize, tooltip='SoW : Start of the Week')
table.cell(change, 3, 0, str.tostring((close / Cm - 1) * 100, '#.##') + '%\nSoM' , text_color=close / Cm - 1 > 0 ? #00FF98 : #FF9800, bgcolor=close / Cm - 1 > 0 ? color.new(color.green, 80) : color.new(color.red, 80), text_size=textSize, tooltip='SoM : Start of the Month')
table.cell(change, 1, 1, str.tostring((close / C3m - 1) * 100, '#.##') + '%\nSo3M', text_color=close / C3m - 1 > 0 ? #00FF98 : #FF9800, bgcolor=close / C3m - 1 > 0 ? color.new(color.green, 80) : color.new(color.red, 80), text_size=textSize, tooltip='So3M : Start of the Quarter')
table.cell(change, 2, 1, str.tostring((close / C6m - 1) * 100, '#.##') + '%\nSo6M', text_color=close / C6m - 1 > 0 ? #00FF98 : #FF9800, bgcolor=close / C6m - 1 > 0 ? color.new(color.green, 80) : color.new(color.red, 80), text_size=textSize, tooltip='So6M : Start of the HalfYear')
table.cell(change, 3, 1, str.tostring((close / Cy - 1) * 100, '#.##') + '%\nSoY' , text_color=close / Cy - 1 > 0 ? #00FF98 : #FF9800, bgcolor=close / Cy - 1 > 0 ? color.new(color.green, 80) : color.new(color.red, 80), text_size=textSize, tooltip='SoY : Start of the Year')
|
Market Monitor | https://www.tradingview.com/script/HFGmR9ST-market-monitor/ | beskrovnykh | https://www.tradingview.com/u/beskrovnykh/ | 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/
// © beskrovnykh
//@version=5
indicator(title = "Market Monitor", shorttitle="MM", overlay=false)
_pullData(src, res, rep) =>
out = request.security(syminfo.tickerid, res, src[rep ? 0 : barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)[rep ? 0 : barstate.isrealtime ? 0 : 1]
out
tf = input.timeframe('D', title="Monitoring frequency")
_metricToJson(name, value) =>
"{" + '"name": ' + '"' + str.tostring(name) + '"' + ', "value": ' + str.tostring(value) + "}"
_marketConditionsToJson(timestamp, ticker, timeframe, metrics) =>
messageContent = array.new_string()
array.push(messageContent, '"timestamp": ' + str.tostring(timestamp))
array.push(messageContent, '"ticker": ' + '"' + str.tostring(ticker) + '"')
array.push(messageContent, '"timeframe": ' + '"' + str.tostring(timeframe) + '"')
array.push(messageContent, '"metrics": ' + str.tostring(metrics))
messageJson = "{" + array.join(messageContent, ', ') + "}"
barTime = time(tf)
barTimeChanged = ta.change(barTime)
spread = _pullData(high-low, tf, false)
change = _pullData(close-close[1], tf, false)
volumeChange = _pullData(volume-volume[1], tf, false)
plot(spread, title="Spread", color=color.green, linewidth=2)
plot(change, title="Change", color=color.yellow, linewidth=2)
if barTimeChanged
metrics = array.new_string()
array.push(metrics, _metricToJson("spread", spread))
array.push(metrics, _metricToJson("change", change))
array.push(metrics, _metricToJson("volume_change", volumeChange))
metricsJson = "[" + array.join(metrics,', ') + "]"
msg = _marketConditionsToJson(timenow, syminfo.ticker, tf, metricsJson)
alert(msg, alert.freq_once_per_bar)
bgcolor(barTimeChanged ? color.new(color.green, 80) : na)
|
Line Chart with circles on sub chart / LineChart no Candles | https://www.tradingview.com/script/wJjZc2Kc/ | kryptocollector | https://www.tradingview.com/u/kryptocollector/ | 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/
// © kryptocollector
// version 1 - 05 Sep 2022
//@version=5
indicator("LineSubChart with circles", shorttitle='LineChart', timeframe="", overlay=false)
source = input(title="Source", defval=close)
colLine = barstate.isconfirmed ? color.new(color.gray, 0) : color.new(#f7525f, 40)
colPlot = barstate.isconfirmed ? color.new(color.orange, 40) : na
plot(source, color=colLine, linewidth=2, title="Linie")
plot(source, style=plot.style_circles, color=colPlot, linewidth=2, title="Circles")
//end |
BankNifty Scripts | https://www.tradingview.com/script/8P9lraRx-BankNifty-Scripts/ | nanujogi | https://www.tradingview.com/u/nanujogi/ | 177 | 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/
// © nanujogi
// More info on cRSI visit below URL
// cRSI code thanks flies to RozaniGhani-RG
// https://in.tradingview.com/script/2zKoLmRP-Cyclic-RSI-High-Low-With-Noise-Filter/
// In this script cRSI > 70 Focus Sell & < 30 Focus Buy.
//@version=5
indicator("BankNifty Scripts", overlay=true)
len = input.int( 50, minval=1, title="Length", tooltip = "Change as per your choice" )
var value_cRSI = array.new_float(10)
var _myRows = 0
var _myCols = 0
// User Table Position is now flexible
string tableYposInput = input.string("top", "Table position", inline = "11", options = ["top", "middle", "bottom"])
string tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"])
///// COLORS
SCRIPT_NAME = color.rgb(8,196,236, 30)
HEMA_COLOR = color.rgb(227,255,20)
NEON_GREEN = color.rgb(57,255,20)
HEX_RED = #FF1818
////// EMA calculation for 1 Hour 1 Day and 1 Week
var _DEMA = 0
var _HEMA = 1
var _WEMA = 2
var IDX_CLOSE = 3
// Initialize an empty array to store variables
var global = array.new_float(52)
var previous_close = array.new_float(10)
var table emaTable = table.new(tableYposInput + "_" + tableXposInput, columns=7, rows=15, border_color = color.white, frame_color = color.white, frame_width = 1, border_width = 1)
var script_name = " "
f_display_table_cell(_txt, _col0, _col1, _col2, _col3, _row, ix_dema, ix_hema, ix_wema, ix_close) =>
if barstate.islast
// We only populate the table on the last bar.
table.cell(emaTable, 0, 0, " Script Name ", text_color = color.rgb(210,219,35), text_halign = text.align_center, text_size = size.normal, bgcolor = color.black, tooltip="Daily EMA")
table.cell(emaTable, 1, 0, " DEMA " + "(" + str.format("{0, number}", len)+")", text_color = color.rgb(210,219,35), text_halign = text.align_center, text_size = size.normal, bgcolor = color.black, tooltip="Daily EMA")
table.cell(emaTable, 2, 0, " HEMA " + "(" + str.format("{0, number}", len)+")", text_color = color.rgb(210,219,35), text_halign = text.align_center, text_size = size.normal, bgcolor = color.black, tooltip="Hourly EMA")
table.cell(emaTable, 3, 0, " WEMA " + "(" + str.format("{0, number}", len)+")", text_color = color.rgb(210,219,35), text_halign = text.align_center, text_size = size.normal, bgcolor = color.black, tooltip="Weekly EMA")
table.cell(emaTable, 4, 0, " CMP ", text_color = color.rgb(210,219,35), text_halign = text.align_center, text_size = size.normal, bgcolor = color.black, tooltip="Weekly EMA")
table.cell(emaTable, 5, 0, " Chg ", text_color = color.rgb(210,219,35), text_halign = text.align_center, text_size = size.normal, bgcolor = color.black, tooltip="Weekly EMA")
table.cell(emaTable, 6, 0, " cRSI ", text_color = color.rgb(210,219,35), text_halign = text.align_center, text_size = size.normal, bgcolor = color.black, tooltip="")
// #00A2ED
table.cell(emaTable, _col0, _row, _txt, text_color = color.white, text_halign = text.align_left, text_size = size.normal)
// table.cell(emaTable, _col1, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_dema))) + _display, text_color = #00A2ED, text_halign = text.align_center, text_size = size.normal)
if array.get(global, ix_close) > array.get(global, ix_dema)
_display = " ▲"
table.cell(emaTable, _col1, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_dema))) + _display, text_color = #00A2ED, text_halign = text.align_right, text_size = size.normal)
else
_display = " ▼"
table.cell(emaTable, _col1, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_dema))) + _display, text_color = #00A2ED, text_halign = text.align_right, text_size = size.normal)
if array.get(global, ix_close) > array.get(global, ix_hema)
_display = " ▲"
table.cell(emaTable, _col2, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_hema))) + _display, text_color = HEMA_COLOR, text_halign = text.align_right, text_size = size.normal)
else
_display = " ▼"
table.cell(emaTable, _col2, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_hema))) + _display, text_color = HEMA_COLOR, text_halign = text.align_right, text_size = size.normal)
// table.cell(emaTable, _col2, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_hema))), text_color = color.lime, text_halign = text.align_center, text_size = size.normal)
if array.get(global, ix_close) > array.get(global, ix_wema)
_display = " ▲"
table.cell(emaTable, _col3, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_wema))) + _display, text_color = color.orange, text_halign = text.align_right, text_size = size.normal)
else
_display = " ▼"
table.cell(emaTable, _col3, _row, str.format("{0, number, #.##}", math.round(array.get(global, ix_wema))) + _display, text_color = color.orange, text_halign = text.align_right, text_size = size.normal)
table.cell(emaTable, 4, _row, str.format("{0, number, #.##}", array.get(global, ix_close)), text_color = array.get(global, ix_close) > array.get(previous_close, 0) ? NEON_GREEN: HEX_RED, text_halign = text.align_right, text_size = size.normal)
var percentage_calculation = ( array.get(global, ix_close) * 100 / array.get(previous_close, 0) ) - 100
table.cell(emaTable, 5, _row, str.format("{0, number, #.##}", math.round(percentage_calculation, 2)) + "%", text_color = array.get(global, ix_close) > array.get(previous_close, 0) ? NEON_GREEN : HEX_RED, text_halign = text.align_right, text_size = size.normal)
if array.get(value_cRSI, 0) > 70
table.cell(emaTable, 6, _row, str.format("{0, number, #.##}", array.get(value_cRSI, 0) ) + " Focus Sell", text_color = HEMA_COLOR, text_halign = text.align_right, text_size = size.normal)
else if array.get(value_cRSI, 0) < 30
table.cell(emaTable, 6, _row, str.format("{0, number, #.##}", array.get(value_cRSI, 0) ) + " Focus Buy", text_color = HEMA_COLOR, text_halign = text.align_right, text_size = size.normal)
else
table.cell(emaTable, 6, _row, str.format("{0, number, #.##}", array.get(value_cRSI, 0) ), text_color = color.fuchsia, text_halign = text.align_right, text_size = size.normal)
f_get_EMA(_ticker, idx_dema, idx_hema, idx_wema, idx_close)=>
/// cRSI
src = close
domcycle = input.int(20, minval=10, title="Dominant Cycle Length")
crsi = 0.0
cyclelen = domcycle / 2
vibration = 10
leveling = 10.0
torque = 2.0 / (vibration + 1)
phasingLag = (vibration - 1) / 2.0
cyclicmemory = domcycle * 2
//// cRSI ENDS
[_close, p_close, _dema, up, down] = request.security(_ticker, "D", [close, close[1], ta.ema(close, len), ta.rma(math.max(ta.change(src), 0), cyclelen),ta.rma(-math.min(ta.change(src), 0), cyclelen) ])
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
crsi := torque * (2 * rsi - rsi[phasingLag]) + (1 - torque) * nz(crsi[1])
_hema = request.security(_ticker, "60", ta.ema(close, len))
_wema = request.security(_ticker, "W", ta.ema(close, len))
array.set(global, idx_dema, math.round(_dema))
array.set(global, idx_hema, math.round(_hema))
array.set(global, idx_wema, math.round(_wema))
array.set(global, idx_close, _close)
// previous_close array just sotres the previous close so that we can display CMP in green or red.
// is the current price above previous day close then green else red.
array.set(previous_close, 0, p_close)
array.set(value_cRSI, 0, crsi)
// f_get_EMA(_ticker, idx_dema, idx_hema, idx_wema, idx_close)
//f_display_table_cell(_txt, _col0, _col1, _col2, _col3, _row, ix_dema, ix_hema, ix_wema, ix_close) =>
//f_display_table_cell("HDFCBANK",
// 0, 1, 2, 3, 3, 0+4*2, 1+4*2, 2+4*2, 3+4*2)
// 0 = DEMA 1 = HEMA 2 = WEMA 3 = CMP, 3 = Rows,
// 0+4*2 = index of dema in array for display in table cell
// 1+4*2 = index of hema in array for display in table cell
// 2+4*2 = index of wema in array for display in table cell
// 3+4*2 = index of CMP current market price for display in table cell
// we keepng multiplying with DEMA
// 0
f_get_EMA("NSE:HDFCBANK", _DEMA, _HEMA, _WEMA, IDX_CLOSE)
f_display_table_cell(syminfo.ticker("NSE:HDFCBANK"), 0, 1, 2, 3, 1, 0, 1, 2, 3)
_myCols := 1
_myRows := 1
//1
f_get_EMA("NSE:ICICIBANK", _DEMA+4, _HEMA+4, _WEMA+4, IDX_CLOSE+4)
f_display_table_cell("ICICI Bank", 0, 1, 2, 3, 2, 0+4, 1+4, 2+4, 3+4)
//2
f_get_EMA("NSE:SBIN", _DEMA+4*2, _HEMA+4*2, _WEMA+4*2, IDX_CLOSE+4*2)
f_display_table_cell("SBIN", 0, 1, 2, 3, 3, 0+4*2, 1+4*2, 2+4*2, 3+4*2)
// // 3
f_get_EMA("NSE:AXISBANK", _DEMA+4*3, _HEMA+4*3, _WEMA+4*3, IDX_CLOSE+4*3)
f_display_table_cell("AXISBANK", 0, 1, 2, 3, 4, 0+4*3, 1+4*3, 2+4*3, 3+4*3)
// 4
f_get_EMA("NSE:KOTAKBANK", _DEMA+4*4, _HEMA+4*4, _WEMA+4*4, IDX_CLOSE+4*4)
f_display_table_cell("KOTAKBANK", 0, 1, 2, 3, 5, 0+4*4, 1+4*4, 2+4*4, 3+4*4)
// 5
f_get_EMA("NSE:INDUSINDBK", _DEMA+4*5, _HEMA+4*5, _WEMA+4*5, IDX_CLOSE+4*5)
f_display_table_cell("INDUSINDBK", 0, 1, 2, 3, 6, 0+4*5, 1+4*5, 2+4*5, 3+4*5)
// 6
f_get_EMA("NSE:BANKBARODA", _DEMA+4*6, _HEMA+4*6, _WEMA+4*6, IDX_CLOSE+4*6)
f_display_table_cell("Bank of Baroda", 0, 1, 2, 3, 7, 0+4*6, 1+4*6, 2+4*6, 3+4*6)
// 7
f_get_EMA("NSE:BANDHANBNK", _DEMA+4*7, _HEMA+4*7, _WEMA+4*7, IDX_CLOSE+4*7)
f_display_table_cell("Bandhan Bank", 0, 1, 2, 3, 8, 0+4*7, 1+4*7, 2+4*7, 3+4*7)
// 8
f_get_EMA("NSE:IDFCFIRSTB", _DEMA+4*8, _HEMA+4*8, _WEMA+4*8, IDX_CLOSE+4*8)
f_display_table_cell("IDFC First Bank", 0, 1, 2, 3, 9, 0+4*8, 1+4*8, 2+4*8, 3+4*8)
//9
f_get_EMA("NSE:AUBANK", _DEMA+4*9, _HEMA+4*9, _WEMA+4*9, IDX_CLOSE+4*9)
f_display_table_cell("AU Bank", 0, 1, 2, 3, 10, 0+4*9, 1+4*9, 2+4*9, 3+4*9)
// 10
f_get_EMA("NSE:FEDERALBNK", _DEMA+4*10, _HEMA+4*10, _WEMA+4*10, IDX_CLOSE+4*10)
f_display_table_cell("Federal Bank", 0, 1, 2, 3, 11, 0+4*10, 1+4*10, 2+4*10, 3+4*10)
// 11
f_get_EMA("NSE:PNB", _DEMA+4*11, _HEMA+4*11, _WEMA+4*11, IDX_CLOSE+4*11)
f_display_table_cell("PNB Bank", 0, 1, 2, 3, 12, 0+4*11, 1+4*11, 2+4*11, 3+4*11)
// 12
f_get_EMA("NSE:BANKNIFTY", _DEMA+4*12, _HEMA+4*12, _WEMA+4*12, IDX_CLOSE+4*12)
f_display_table_cell("Bank Nifty", 0, 1, 2, 3, 13, 0+4*12, 1+4*12, 2+4*12, 3+4*12)
|
Pivot Breaks | https://www.tradingview.com/script/CRpX6VqD-Pivot-Breaks/ | sosso_bott | https://www.tradingview.com/u/sosso_bott/ | 184 | 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/
// © sosso_bott
//@version=5
indicator(title="Pivot Breaks", overlay=true)
import sosso_bott/SAT_LIB/13 as tm
// ——————————————————————————— \\
// ▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ \\
// ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ \\
// ——————————————————————————— \\
no_rep(_symbol, _res, _src) =>
request.security(_symbol, _res, _src[barstate.isrealtime ? 1:0], barmerge.gaps_off, barmerge.lookahead_off)
resy = input.timeframe(defval="", title="timeFrame", group="PIVOT H/L")
len = input.int(defval=20, minval=1, title="Length", group="PIVOT H/L")
showOnlyFirstSignal = input.bool(defval=true, title="Use First Break only?", group="PIVOT H/L")
color_breakout = input.bool(defval=true, title="Color BreakOut BG ?", group="PIVOT H/L")
color_state = input.bool(defval=true, title="Color Breaking State", group="PIVOT H/L")
bullish_break = input.color(defval=color.new(color.green, 50), title="Bull BreakOut", group="Colors")
bearish_break = input.color(defval=color.new(color.red, 50), title="Bear BreakOut", group="Colors")
bullish = input.color(defval=color.new(color.blue, 90), title="Bull State", group="Colors")
bearish = input.color(defval=color.new(color.orange,90), title="Bear State", group="Colors")
use_alerts = input.bool(defval=true, title="Use Alerts", group="ALERTS")
bullish_msg = input.string(defval="{{exchange}} BUY {{ticker}}", title="Bull BreakOut Message", group="ALERTS")
bearish_msg = input.string(defval="{{exchange}} SELL {{ticker}}", title="Bear BreakOut Message", group="ALERTS")
ha_t = syminfo.tickerid
ha_h = no_rep(ha_t, resy, ta.highest(len))
ha_l = no_rep(ha_t, resy, ta.lowest(len))
h1 = ta.dev(ha_h, len) ? na : ha_h
hpivot = fixnan(h1)
l1 = ta.dev(ha_l, len) ? na : ha_l
lpivot = fixnan(l1)
// ############ QUICK MAGIC ############# \\\
b_p = ta.crossover(close, hpivot)
s_p = ta.crossunder(close, lpivot)
int pivot_state = 0
if b_p
pivot_state := 1
if s_p
pivot_state := -1
buy_pivot = b_p and pivot_state[1] != pivot_state
sell_pivot = s_p and pivot_state[1] != pivot_state
[b_breakout, s_breakout] = tm.showOnlyFirstOccurence(showOnlyFirstSignal, buy_pivot, sell_pivot)
var int break_state = 0
if b_breakout
break_state := 1
if s_breakout
break_state := -1
// ############ QUICK MAGIC ############# \\\
// ############ PLOT ############# \\\
plot(hpivot, color=color.blue, linewidth=2, offset= -len+1)
plot(lpivot, color=color.purple, linewidth=2, offset= -len+1)
plotshape(b_breakout, title="buy", location=location.belowbar, color=bullish_break, style=shape.triangleup)
plotshape(s_breakout, title="sell", location=location.abovebar, color=bearish_break, style=shape.triangledown)
bgcolor(not color_breakout ? na: b_breakout ? bullish_break : s_breakout ? bearish_break : na)
bgcolor(not color_state ? na: break_state == 1 ? bullish : break_state == -1 ? bearish : na)
// ############ PLOT ############# \\\
// ############ ALERTS ############# \\\
if use_alerts
if b_breakout
alert(bullish_msg, alert.freq_once_per_bar_close)
if s_breakout
alert(bearish_msg, alert.freq_once_per_bar_close)
// ############ ALERTS ############# \\\
|
TARVIS Labs - Alts Macro Bottom/Top Signals | https://www.tradingview.com/script/L3Tj6R5g-TARVIS-Labs-Alts-Macro-Bottom-Top-Signals/ | arrash0x | https://www.tradingview.com/u/arrash0x/ | 131 | 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/
// © TARVIS Labs LLC
//@version=5
// a script to determine macro ALTS bottoms to accumulate and tops to sell
// with warnings provided of local tops
//@version=5
indicator(title="TARVIS Labs - Alts Macro Bottom/Top Signals", shorttitle="TARVIS Labs alts macro bottom/top signals", overlay=true, timeframe="1D", timeframe_gaps=true)
src = input(close, title="Source")
len1a = int(200)
len1b = int(300)
len1c = int(700)
len3 = int(36)
len4 = int(18)
len5 = int(63)
// long term EMA for overall run
ema1a = ta.ema(src, len1a)
ema1b = ta.ema(src, len1b)
ema1c = ta.ema(src, len1c)
// major cross pairing
ema3 = ta.ema(src, len3)
// major cross pairing to rebuy in
ema4 = ta.ema(src, len4)
ema5 = ta.ema(src, len5)
// bottom MACD
fast_length = int(168)
slow_length = int(364)
signal_length = int(6)
fast_ma = ta.ema(src, fast_length)
slow_ma = ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = ta.ema(macd, signal_length)
// Top MACD
fast_length2 = int(108)
slow_length2 = int(234)
signal_length2 = int(9)
fast_ma2 = ta.ema(src, fast_length2)
slow_ma2 = ta.ema(src, slow_length2)
macd2 = fast_ma2 - slow_ma2
signal2 = ta.ema(macd2, signal_length2)
// local top warning MACD
fast_length3 = int(9)
slow_length3 = int(36)
signal_length3 = int(9)
fast_ma3 = ta.ema(src, fast_length3)
slow_ma3 = ta.ema(src, slow_length3)
macd3 = fast_ma3 - slow_ma3
signal3 = ta.ema(macd3, signal_length3)
val = ta.crossunder(macd2, signal2)
val2 = ta.crossunder(ema4, ema5)
// bottom
plot(ema1a < ema1b ? src < ema1a * .60 ? src : na : na, title='Accumulation Zone Indicator', color=#DAF7A6, style = plot.style_areabr, linewidth = 2)
plot(ema1a < ema1b ? ema1a[7] * .95 > ema1a ? src : na : na, title='Accumulation Zone Indicator', color=#DAF7A6, style = plot.style_areabr, linewidth = 2)
plot(ema3[1] * .98 > ema3 ? ema1a < ema1b ? ema1a[7] * .97 > ema1a ? src : na : na : na, color=#006400, title='Strong Buy in Accumulation Zone Indicator', style = plot.style_areabr, linewidth = 2)
// warnings
plot(ema1c[7] * 1.04 < ema1c ? signal3[1] > signal3 ? src : na : na, color=#FF5733, title='Local Top Near Bull Run Top Indicator', style = plot.style_areabr, linewidth = 2)
// top
plot(ema1c[7] * 1.03 < ema1c ? signal2[1] > signal2 ? ema4 > ema5 ? src : na : na : na, title='Potential End of Bull Run Top Indicator', color=#C70039, style = plot.style_areabr, linewidth = 2)
|
Fibo SR | https://www.tradingview.com/script/Fcijzh6t-Fibo-SR/ | hamidreza1366 | https://www.tradingview.com/u/hamidreza1366/ | 3 | 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/
// © Duyck
//@version=4
study("Fibo SR", overlay = true, resolution = "")
//{
//
//}
// inputs //
//{
trailType = input("modified", "Trailtype", options = ["modified", "unmodified"])
ATRPeriod = input(28, "ATR Period")
ATRFactor = input(5, "ATR Factor")
show_fib_entries = input(true, "Show Fib Entries?")
norm_o = security(tickerid(syminfo.prefix,syminfo.ticker), timeframe.period, open)
norm_h = security(tickerid(syminfo.prefix,syminfo.ticker), timeframe.period, high)
norm_l = security(tickerid(syminfo.prefix,syminfo.ticker), timeframe.period, low)
norm_c = security(tickerid(syminfo.prefix,syminfo.ticker), timeframe.period, close)
//}
//////// FUNCTIONS //////////////
//{
// Wilders ma //
Wild_ma(_src, _malength) =>
_wild = 0.0
_wild := nz(_wild[1]) + (_src - nz(_wild[1])) / _malength
/////////// TRUE RANGE CALCULATIONS /////////////////
HiLo = min(norm_h - norm_l, 1.5 * nz(sma((norm_h - norm_l), ATRPeriod)))
HRef = norm_l<= norm_h[1] ?
norm_h - norm_c[1] :
(norm_h - norm_c[1]) - 0.5 * (norm_l- norm_h[1])
LRef = norm_h >= norm_l[1] ?
norm_c[1] - norm_l:
(norm_c[1] - norm_l) - 0.5 * (norm_l[1] - norm_h)
trueRange =
trailType == "modified" ? max(HiLo, HRef, LRef) :
max(norm_h - norm_l, abs(norm_h - norm_c[1]), abs(norm_l - norm_c[1]))
//}
/////////// TRADE LOGIC ////////////////////////
//{
loss = ATRFactor * Wild_ma(trueRange, ATRPeriod)
Up = norm_c - loss
Dn = norm_c + loss
TrendUp = Up
TrendDown = Dn
Trend = 1
TrendUp := norm_c[1] > TrendUp[1] ? max(Up, TrendUp[1]) : Up
TrendDown := norm_c[1] < TrendDown[1] ? min(Dn, TrendDown[1]) : Dn
Trend := norm_c > TrendDown[1] ? 1 : norm_c < TrendUp[1]? -1 : nz(Trend[1],1)
trail = Trend == 1? TrendUp : TrendDown
ex = 0.0
ex :=
crossover(Trend, 0) ? norm_h :
crossunder(Trend, 0) ? norm_l :
Trend == 1 ? max(ex[1], norm_h) :
Trend == -1 ? min(ex[1], norm_l) : ex[1]
//}
// //////// PLOT TP and SL /////////////
////// FIBONACCI LEVELS ///////////
//{
state = Trend == 1 ? "long" : "short"
fib1Level = 38.2
fib2Level = 50.0
fib3Level = 61.8
f1 = ex + (trail - ex) * fib1Level / 100
f2 = ex + (trail - ex) * fib2Level / 100
f3 = ex + (trail - ex) * fib3Level / 100
l100 = trail + 0
Fib1 = plot(f1, "Fib 1", style = plot.style_line, color = color.black)
Fib2 = plot(f2, "Fib 2", style = plot.style_line, color = color.black)
Fib3 = plot(f3, "Fib 3", style = plot.style_line, color = color.black)
L100 = plot(l100, "l100", style = plot.style_line, color = color.black)
fill(Fib1, Fib2, color = state == "long"? color.green : state == "short"? color.red : na)
fill(Fib2, Fib3, color = state == "long"? color.new(color.green, 70) : state == "short"? color.new(color.red, 70) : na)
fill(Fib3, L100, color = state == "long"? color.new(color.green, 60) : state == "short"? color.new(color.red, 60) : na)
l1 = state[1] == "long" and crossunder(norm_c, f1[1])
l2 = state[1] == "long" and crossunder(norm_c, f2[1])
l3 = state[1] == "long" and crossunder(norm_c, f3[1])
s1 = state[1] == "short" and crossover(norm_c, f1[1])
s2 = state[1] == "short" and crossover(norm_c, f2[1])
s3 = state[1] == "short" and crossover(norm_c, f3[1])
atr = sma(trueRange, 14)
/////////// FIB PLOTS /////////////////.
//}
//////////// FIB ALERTS /////////////////////
//{
//} |
Gann Square | https://www.tradingview.com/script/kxaEl2i9-Gann-Square/ | AlphaNodal | https://www.tradingview.com/u/AlphaNodal/ | 443 | 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/
// © Mr_Amiiin_n
//@version=5
indicator('Gann Square', overlay=true)
//set background color
bg = input.color(#7ca5ff, "square diagonals color")
bgDefault = input.color(#9e9e9e, "cells color")
txtColor = input.color(#212121, "numbers color")
//gann square 19*19
var table t = table.new(position.top_right, 19, 19, frame_color=color.rgb(255, 230, 204), frame_width=1, border_color=color.rgb(255, 230, 204), border_width=1)
//c0
table.cell(t, 0, 0, str.tostring(307), text_color=txtColor, bgcolor=bg)
table.cell(t, 1, 0, str.tostring(308), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 0, str.tostring(309), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 0, str.tostring(310), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 0, str.tostring(311), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 0, str.tostring(312), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 0, str.tostring(313), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 0, str.tostring(314), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 0, str.tostring(315), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 0, str.tostring(316), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 0, str.tostring(317), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 0, str.tostring(318), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 0, str.tostring(319), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 0, str.tostring(320), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 0, str.tostring(321), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 0, str.tostring(322), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 0, str.tostring(323), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 0, str.tostring(324), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 0, str.tostring(325), text_color=txtColor, bgcolor=bg)
//c1
table.cell(t, 0, 1, str.tostring(306), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 1, str.tostring(241), text_color=txtColor, bgcolor=bg)
table.cell(t, 2, 1, str.tostring(242), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 1, str.tostring(243), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 1, str.tostring(244), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 1, str.tostring(245), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 1, str.tostring(246), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 1, str.tostring(247), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 1, str.tostring(248), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 1, str.tostring(249), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 1, str.tostring(250), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 1, str.tostring(251), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 1, str.tostring(252), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 1, str.tostring(253), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 1, str.tostring(254), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 1, str.tostring(255), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 1, str.tostring(256), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 1, str.tostring(257), text_color=txtColor, bgcolor=bg)
table.cell(t, 18, 1, str.tostring(326), text_color=txtColor, bgcolor = bgDefault)
//c2
table.cell(t, 0, 2, str.tostring(305), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 2, str.tostring(240), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 2, str.tostring(183), text_color=txtColor, bgcolor=bg)
table.cell(t, 3, 2, str.tostring(184), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 2, str.tostring(185), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 2, str.tostring(186), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 2, str.tostring(187), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 2, str.tostring(188), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 2, str.tostring(189), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 2, str.tostring(190), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 2, str.tostring(191), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 2, str.tostring(192), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 2, str.tostring(193), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 2, str.tostring(194), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 2, str.tostring(195), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 2, str.tostring(196), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 2, str.tostring(197), text_color=txtColor, bgcolor=bg)
table.cell(t, 17, 2, str.tostring(258), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 2, str.tostring(327), text_color=txtColor, bgcolor = bgDefault)
//c3
table.cell(t, 0, 3, str.tostring(304), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 3, str.tostring(239), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 3, str.tostring(182), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 3, str.tostring(133), text_color=txtColor, bgcolor=bg)
table.cell(t, 4, 3, str.tostring(134), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 3, str.tostring(135), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 3, str.tostring(136), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 3, str.tostring(137), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 3, str.tostring(138), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 3, str.tostring(139), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 3, str.tostring(140), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 3, str.tostring(141), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 3, str.tostring(142), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 3, str.tostring(143), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 3, str.tostring(144), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 3, str.tostring(145), text_color=txtColor, bgcolor=bg)
table.cell(t, 16, 3, str.tostring(198), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 3, str.tostring(259), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 3, str.tostring(328), text_color=txtColor, bgcolor = bgDefault)
//c4
table.cell(t, 0, 4, str.tostring(303), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 4, str.tostring(238), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 4, str.tostring(181), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 4, str.tostring(132), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 4, str.tostring(91), text_color=txtColor, bgcolor=bg)
table.cell(t, 5, 4, str.tostring(92), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 4, str.tostring(93), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 4, str.tostring(94), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 4, str.tostring(95), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 4, str.tostring(96), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 4, str.tostring(97), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 4, str.tostring(98), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 4, str.tostring(99), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 4, str.tostring(100), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 4, str.tostring(101), text_color=txtColor, bgcolor=bg)
table.cell(t, 15, 4, str.tostring(146), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 4, str.tostring(199), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 4, str.tostring(260), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 4, str.tostring(329), text_color=txtColor, bgcolor = bgDefault)
//c5
table.cell(t, 0, 5, str.tostring(302), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 5, str.tostring(237), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 5, str.tostring(180), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 5, str.tostring(131), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 5, str.tostring(90), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 5, str.tostring(57), text_color=txtColor, bgcolor=bg)
table.cell(t, 6, 5, str.tostring(58), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 5, str.tostring(59), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 5, str.tostring(60), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 5, str.tostring(61), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 5, str.tostring(62), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 5, str.tostring(63), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 5, str.tostring(64), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 5, str.tostring(65), text_color=txtColor, bgcolor=bg)
table.cell(t, 14, 5, str.tostring(102), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 5, str.tostring(147), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 5, str.tostring(200), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 5, str.tostring(261), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 5, str.tostring(330), text_color=txtColor, bgcolor = bgDefault)
//c6
table.cell(t, 0, 6, str.tostring(301), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 6, str.tostring(236), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 6, str.tostring(179), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 6, str.tostring(130), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 6, str.tostring(89), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 6, str.tostring(56), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 6, str.tostring(31), text_color=txtColor, bgcolor=bg)
table.cell(t, 7, 6, str.tostring(32), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 6, str.tostring(33), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 6, str.tostring(34), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 6, str.tostring(35), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 6, str.tostring(36), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 6, str.tostring(37), text_color=txtColor, bgcolor=bg)
table.cell(t, 13, 6, str.tostring(66), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 6, str.tostring(103), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 6, str.tostring(148), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 6, str.tostring(201), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 6, str.tostring(262), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 6, str.tostring(331), text_color=txtColor, bgcolor = bgDefault)
//c7
table.cell(t, 0, 7, str.tostring(300), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 7, str.tostring(235), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 7, str.tostring(178), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 7, str.tostring(129), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 7, str.tostring(88), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 7, str.tostring(55), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 7, str.tostring(30), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 7, str.tostring(13), text_color=txtColor, bgcolor=bg)
table.cell(t, 8, 7, str.tostring(14), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 7, str.tostring(15), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 7, str.tostring(16), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 7, str.tostring(17), text_color=txtColor, bgcolor=bg)
table.cell(t, 12, 7, str.tostring(38), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 7, str.tostring(67), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 7, str.tostring(104), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 7, str.tostring(149), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 7, str.tostring(202), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 7, str.tostring(263), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 7, str.tostring(332), text_color=txtColor, bgcolor = bgDefault)
//c8
table.cell(t, 0, 8, str.tostring(299), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 8, str.tostring(234), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 8, str.tostring(177), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 8, str.tostring(128), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 8, str.tostring(87), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 8, str.tostring(54), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 8, str.tostring(29), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 8, str.tostring(12), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 8, str.tostring(3), text_color=txtColor, bgcolor=bg)
table.cell(t, 9, 8, str.tostring(4), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 8, str.tostring(5), text_color=txtColor, bgcolor=bg)
table.cell(t, 11, 8, str.tostring(18), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 8, str.tostring(39), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 8, str.tostring(68), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 8, str.tostring(105), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 8, str.tostring(150), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 8, str.tostring(203), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 8, str.tostring(264), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 8, str.tostring(333), text_color=txtColor, bgcolor = bgDefault)
//c9
table.cell(t, 0, 9, str.tostring(298), text_color=txtColor, bgcolor=bg)
table.cell(t, 1, 9, str.tostring(233), text_color=txtColor, bgcolor=bg)
table.cell(t, 2, 9, str.tostring(176), text_color=txtColor, bgcolor=bg)
table.cell(t, 3, 9, str.tostring(127), text_color=txtColor, bgcolor=bg)
table.cell(t, 4, 9, str.tostring(86), text_color=txtColor, bgcolor=bg)
table.cell(t, 5, 9, str.tostring(53), text_color=txtColor, bgcolor=bg)
table.cell(t, 6, 9, str.tostring(28), text_color=txtColor, bgcolor=bg)
table.cell(t, 7, 9, str.tostring(11), text_color=txtColor, bgcolor=bg)
table.cell(t, 8, 9, str.tostring(2), text_color=txtColor, bgcolor=bg)
table.cell(t, 9, 9, str.tostring(1), text_color=txtColor, bgcolor=bgDefault) //core of sqaure=1
table.cell(t, 10, 9, str.tostring(6), text_color=txtColor, bgcolor=bg)
table.cell(t, 11, 9, str.tostring(19), text_color=txtColor, bgcolor=bg)
table.cell(t, 12, 9, str.tostring(40), text_color=txtColor, bgcolor=bg)
table.cell(t, 13, 9, str.tostring(69), text_color=txtColor, bgcolor=bg)
table.cell(t, 14, 9, str.tostring(106), text_color=txtColor, bgcolor=bg)
table.cell(t, 15, 9, str.tostring(151), text_color=txtColor, bgcolor=bg)
table.cell(t, 16, 9, str.tostring(204), text_color=txtColor, bgcolor=bg)
table.cell(t, 17, 9, str.tostring(265), text_color=txtColor, bgcolor=bg)
table.cell(t, 18, 9, str.tostring(334), text_color=txtColor, bgcolor=bg)
//c10
table.cell(t, 0, 10, str.tostring(297), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 10, str.tostring(232), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 10, str.tostring(175), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 10, str.tostring(126), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 10, str.tostring(85), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 10, str.tostring(52), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 10, str.tostring(27), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 10, str.tostring(10), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 10, str.tostring(9), text_color=txtColor, bgcolor=bg)
table.cell(t, 9, 10, str.tostring(8), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 10, str.tostring(7), text_color=txtColor, bgcolor=bg)
table.cell(t, 11, 10, str.tostring(20), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 10, str.tostring(41), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 10, str.tostring(70), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 10, str.tostring(107), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 10, str.tostring(152), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 10, str.tostring(205), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 10, str.tostring(266), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 10, str.tostring(335), text_color=txtColor, bgcolor = bgDefault)
//c11
table.cell(t, 0, 11, str.tostring(296), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 11, str.tostring(231), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 11, str.tostring(174), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 11, str.tostring(125), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 11, str.tostring(84), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 11, str.tostring(51), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 11, str.tostring(26), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 11, str.tostring(25), text_color=txtColor, bgcolor=bg)
table.cell(t, 8, 11, str.tostring(24), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 11, str.tostring(23), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 11, str.tostring(22), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 11, str.tostring(21), text_color=txtColor, bgcolor=bg)
table.cell(t, 12, 11, str.tostring(42), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 11, str.tostring(71), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 11, str.tostring(108), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 11, str.tostring(153), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 11, str.tostring(206), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 11, str.tostring(267), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 11, str.tostring(336), text_color=txtColor, bgcolor = bgDefault)
//c12
table.cell(t, 0, 12, str.tostring(295), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 12, str.tostring(230), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 12, str.tostring(173), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 12, str.tostring(124), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 12, str.tostring(83), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 12, str.tostring(50), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 12, str.tostring(49), text_color=txtColor, bgcolor=bg)
table.cell(t, 7, 12, str.tostring(48), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 12, str.tostring(47), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 12, str.tostring(46), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 12, str.tostring(45), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 12, str.tostring(44), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 12, str.tostring(43), text_color=txtColor, bgcolor=bg)
table.cell(t, 13, 12, str.tostring(72), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 12, str.tostring(109), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 12, str.tostring(154), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 12, str.tostring(207), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 12, str.tostring(268), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 12, str.tostring(337), text_color=txtColor, bgcolor = bgDefault)
//c13
table.cell(t, 0, 13, str.tostring(294), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 13, str.tostring(229), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 13, str.tostring(172), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 13, str.tostring(123), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 13, str.tostring(82), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 13, str.tostring(81), text_color=txtColor, bgcolor=bg)
table.cell(t, 6, 13, str.tostring(80), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 13, str.tostring(79), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 13, str.tostring(78), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 13, str.tostring(77), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 13, str.tostring(76), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 13, str.tostring(75), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 13, str.tostring(74), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 13, str.tostring(73), text_color=txtColor, bgcolor=bg)
table.cell(t, 14, 13, str.tostring(110), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 13, str.tostring(155), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 13, str.tostring(208), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 13, str.tostring(269), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 13, str.tostring(338), text_color=txtColor, bgcolor = bgDefault)
//c14
table.cell(t, 0, 14, str.tostring(293), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 14, str.tostring(228), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 14, str.tostring(171), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 14, str.tostring(122), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 14, str.tostring(121), text_color=txtColor, bgcolor=bg)
table.cell(t, 5, 14, str.tostring(120), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 14, str.tostring(119), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 14, str.tostring(118), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 14, str.tostring(117), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 14, str.tostring(116), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 14, str.tostring(115), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 14, str.tostring(114), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 14, str.tostring(113), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 14, str.tostring(112), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 14, str.tostring(111), text_color=txtColor, bgcolor=bg)
table.cell(t, 15, 14, str.tostring(156), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 14, str.tostring(209), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 14, str.tostring(270), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 14, str.tostring(339), text_color=txtColor, bgcolor = bgDefault)
//c15
table.cell(t, 0, 15, str.tostring(292), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 15, str.tostring(227), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 15, str.tostring(170), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 15, str.tostring(169), text_color=txtColor, bgcolor=bg)
table.cell(t, 4, 15, str.tostring(168), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 15, str.tostring(167), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 15, str.tostring(166), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 15, str.tostring(165), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 15, str.tostring(164), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 15, str.tostring(163), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 15, str.tostring(162), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 15, str.tostring(161), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 15, str.tostring(160), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 15, str.tostring(159), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 15, str.tostring(158), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 15, str.tostring(157), text_color=txtColor, bgcolor=bg)
table.cell(t, 16, 15, str.tostring(210), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 15, str.tostring(271), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 15, str.tostring(340), text_color=txtColor, bgcolor = bgDefault)
//c16
table.cell(t, 0, 16, str.tostring(291), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 16, str.tostring(226), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 16, str.tostring(225), text_color=txtColor, bgcolor=bg)
table.cell(t, 3, 16, str.tostring(224), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 16, str.tostring(223), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 16, str.tostring(222), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 16, str.tostring(221), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 16, str.tostring(220), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 16, str.tostring(219), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 16, str.tostring(218), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 16, str.tostring(217), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 16, str.tostring(216), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 16, str.tostring(215), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 16, str.tostring(214), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 16, str.tostring(213), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 16, str.tostring(212), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 16, str.tostring(211), text_color=txtColor, bgcolor=bg)
table.cell(t, 17, 16, str.tostring(272), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 16, str.tostring(341), text_color=txtColor, bgcolor = bgDefault)
//c17
table.cell(t, 0, 17, str.tostring(290), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 1, 17, str.tostring(289), text_color=txtColor, bgcolor=bg)
table.cell(t, 2, 17, str.tostring(288), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 17, str.tostring(287), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 17, str.tostring(286), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 17, str.tostring(285), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 17, str.tostring(284), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 17, str.tostring(283), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 17, str.tostring(282), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 17, str.tostring(281), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 17, str.tostring(280), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 17, str.tostring(279), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 17, str.tostring(278), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 17, str.tostring(277), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 17, str.tostring(276), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 17, str.tostring(275), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 17, str.tostring(274), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 17, str.tostring(273), text_color=txtColor, bgcolor=bg)
table.cell(t, 18, 17, str.tostring(342), text_color=txtColor, bgcolor = bgDefault)
//c18
table.cell(t, 0, 18, str.tostring(361), text_color=txtColor, bgcolor=bg)
table.cell(t, 1, 18, str.tostring(360), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 2, 18, str.tostring(359), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 3, 18, str.tostring(358), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 4, 18, str.tostring(357), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 5, 18, str.tostring(356), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 6, 18, str.tostring(355), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 7, 18, str.tostring(354), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 8, 18, str.tostring(353), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 9, 18, str.tostring(352), text_color=txtColor, bgcolor=bg)
table.cell(t, 10, 18, str.tostring(351), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 11, 18, str.tostring(350), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 12, 18, str.tostring(349), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 13, 18, str.tostring(348), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 14, 18, str.tostring(347), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 15, 18, str.tostring(346), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 16, 18, str.tostring(345), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 17, 18, str.tostring(344), text_color=txtColor, bgcolor = bgDefault)
table.cell(t, 18, 18, str.tostring(343), text_color=txtColor, bgcolor=bg)
//get date info
lastDate = input.time(title='Date : ', defval=timestamp('1 sep 2022'), tooltip='Last HH or LL Date ')
//get numbers
firstPivot = input.int(title='Num 1 : ', defval=0, tooltip='First number to show future pivot', group="Numbers")
SecondPivot = input.int(title='Num 2 : ', defval=0, tooltip='Second number to show future pivot', group="Numbers")
ThirdPivot = input.int(title='Num 3 : ', defval=0, tooltip='Third number to show future pivot', group="Numbers")
fourthPivot = input.int(title='Num 4 : ', defval=0, tooltip='Fourth number to show future pivot', group="Numbers")
fifthPivot = input.int(title='Num 5 : ', defval=0, tooltip='Fifth number to show future pivot', group="Numbers")
sixthPivot = input.int(title='Num 6 : ', defval=0, tooltip='sixth number to show future pivot', group="Numbers")
seventhPivot = input.int(title='Num 7 : ', defval=0, tooltip='seventh number to show future pivot', group="Numbers")
//get labels color
firstColor = input.color(title='Num 1 Color: ', defval=color.blue, tooltip='First number color label', group="Colors")
secondColor = input.color(title='Num 2 Color: ', defval=color.blue, tooltip='Second number color label', group="Colors")
thirdColor = input.color(title='Num 3 Color: ', defval=color.blue, tooltip='Third number color label', group="Colors")
fourthColor = input.color(title='Num 4 Color: ', defval=color.blue, tooltip='Fourth number color label', group="Colors")
fifthColor = input.color(title='Num 5 Color: ', defval=color.blue, tooltip='Fifth number color label', group="Colors")
sixthColor = input.color(title='Num 6 Color: ', defval=color.blue, tooltip='sixth number color label', group="Colors")
seventhColor = input.color(title='Num 7 Color: ', defval=color.blue, tooltip='seventh number color label', group="Colors")
if firstPivot != 0
d1 = line.new(lastDate + firstPivot * 86400000, high, lastDate + firstPivot * 86400000, high - 1, xloc=xloc.bar_time, extend=extend.both, color=color.orange, style=line.style_dashed)
l1 = label.new(lastDate + firstPivot * 86400000, low, str.tostring(firstPivot), xloc=xloc.bar_time, color=firstColor)
label.delete(l1[1])
line.delete(d1[1])
if SecondPivot != 0
d2 = line.new(lastDate + SecondPivot * 86400000, high, lastDate + SecondPivot * 86400000, high - 1, xloc=xloc.bar_time, extend=extend.both, color=color.orange, style=line.style_dashed)
l2 = label.new(lastDate + SecondPivot * 86400000, low, str.tostring(SecondPivot), xloc=xloc.bar_time, color=secondColor)
label.delete(l2[1])
line.delete(d2[1])
if ThirdPivot != 0
d3 = line.new(lastDate + ThirdPivot * 86400000, high, lastDate + ThirdPivot * 86400000, high - 1, xloc=xloc.bar_time, extend=extend.both, color=color.orange, style=line.style_dashed)
l3 = label.new(lastDate + ThirdPivot * 86400000, low, str.tostring(ThirdPivot), xloc=xloc.bar_time, color=thirdColor)
label.delete(l3[1])
line.delete(d3[1])
if fourthPivot != 0
d4 = line.new(lastDate + fourthPivot * 86400000, high, lastDate + fourthPivot * 86400000, high - 1, xloc=xloc.bar_time, extend=extend.both, color=color.orange, style=line.style_dashed)
l4 = label.new(lastDate + fourthPivot * 86400000, low, str.tostring(fourthPivot), xloc=xloc.bar_time, color=fourthColor)
label.delete(l4[1])
line.delete(d4[1])
if fifthPivot != 0
d5 = line.new(lastDate + fifthPivot * 86400000, high, lastDate + fifthPivot * 86400000, high - 1, xloc=xloc.bar_time, extend=extend.both, color=color.orange, style=line.style_dashed)
l5 = label.new(lastDate + fifthPivot * 86400000, low, str.tostring(fifthPivot), xloc=xloc.bar_time, color=fifthColor)
label.delete(l5[1])
line.delete(d5[1])
if sixthPivot != 0
d6 = line.new(lastDate + sixthPivot * 86400000, high, lastDate + sixthPivot * 86400000, high - 1, xloc=xloc.bar_time, extend=extend.both, color=color.orange, style=line.style_dashed)
l6 = label.new(lastDate + sixthPivot * 86400000, low, str.tostring(sixthPivot), xloc=xloc.bar_time, color=sixthColor)
label.delete(l6[1])
line.delete(d6[1])
if seventhPivot != 0
d7 = line.new(lastDate + seventhPivot * 86400000, high, lastDate + seventhPivot * 86400000, high - 1, xloc=xloc.bar_time, extend=extend.both, color=color.orange, style=line.style_dashed)
l7 = label.new(lastDate + seventhPivot * 86400000, low, str.tostring(seventhPivot), xloc=xloc.bar_time, color=seventhColor)
label.delete(l7[1])
line.delete(d7[1])
|
Chervolinos Ultrafast RMTA MACD | https://www.tradingview.com/script/n2Q3aUcH/ | chervolino | https://www.tradingview.com/u/chervolino/ | 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/
// © chervolino
//@version=5
indicator(title='Chervolinos Ultrafast RMTA MACD')
// Getting inputs
src = input(title='Source', defval=close)
i_switch = input.bool(true, "Switch MACD / RMTA")
length_RMTA_1 = input.int(21, title="Fast Length RMTA", minval=1, group='Getting Length Inputs')
length_RMTA_2 = input.int(27, title="Slow Length RMTA", minval=1, group='Getting Length Inputs')
signal_length = input.int(9, title='Signal Smoothing', minval=1, maxval=50, group='Getting Length Inputs')
col_grow_above = input.color(#26a643, "Grow Above Color", group='Color Settings')
col_grow_below = input.color(#f9938f, "Grow Below Color", group='Color Settings')
col_fall_above = input.color(#aaccb2, "Fall Above Color", group='Color Settings')
col_fall_below = input.color(#f42922, "Fall Below Color", group='Color Settings')
col_macd = input.color(#0094ff, "MACD Color", group='Color Settings')
col_signal = input.color(#ff6a00, "Signal Color", group='Color Settings')
// RMTA 1
alpha_RMTA_1 = 2 / (length_RMTA_1 + 1)
b_RMTA_1 = 0.0
b_RMTA_1 := (1 - alpha_RMTA_1) * nz(b_RMTA_1[1], src) + src
rmta_RMTA_1 = 0.0
rmta_RMTA_1 := (1 - alpha_RMTA_1) * nz(rmta_RMTA_1[1], src) + alpha_RMTA_1 * (src + b_RMTA_1 - nz(b_RMTA_1[1]))
rmtaColor_RMTA_1 = color.white
// RMTA 2
alpha_RMTA_2 = 2 / (length_RMTA_2 + 1)
b_RMTA_2 = 0.0
b_RMTA_2 := (1 - alpha_RMTA_2) * nz(b_RMTA_2[1], src) + src
rmta_RMTA_2 = 0.0
rmta_RMTA_2 := (1 - alpha_RMTA_2) * nz(rmta_RMTA_2[1], src) + alpha_RMTA_2 * (src + b_RMTA_2 - nz(b_RMTA_2[1]))
rmtaColor_RMTA_2 = color.yellow
// plot
plot(i_switch==false? rmta_RMTA_1:na, title='RMTA', linewidth=2, color=rmtaColor_RMTA_1)
plot(i_switch==false? rmta_RMTA_2:na, title='RMTA', linewidth=2, color=rmtaColor_RMTA_2)
macd = rmta_RMTA_1 - rmta_RMTA_2
msignal = ta.ema(macd, signal_length)
macdas = macd - msignal
signal = ta.ema(macdas, signal_length)
plot(i_switch? macdas: na, title='MACD-AS', style=plot.style_columns, color=macdas >= 0 ? macdas[1] < macdas ? col_grow_above : col_fall_above : macdas[1] < macdas ? col_grow_below : col_fall_below)
plot(i_switch? signal: na, title='Signal', color=color.new(color.blue, 0), linewidth=2)
|
BTCSPXRATIO | https://www.tradingview.com/script/Xy8D9dRz-BTCSPXRATIO/ | In_Finito_ | https://www.tradingview.com/u/In_Finito_/ | 13 | 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/
// © In_Finito_
//@version=5
indicator("BTCSPXRATIO", overlay=false)
float btcprice=request.security("INDEX:BTCUSD", timeframe.period, close)
float spxprice=request.security("CME_MINI:ES1!", timeframe.period, close)
plot(btcprice/spxprice, style=plot.style_line)
|
SubCandles-V2 | https://www.tradingview.com/script/kMr9d0s0-SubCandles-V2/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 192 | 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
// __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
// / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
// $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
// $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
// $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
// $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
// $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
// $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
// $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
//
//
//
//@version=5
indicator("SubCandles-V2", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=500)
numberOfBacktestBars = 100
import PineCoders/Time/3 as t
[lo, lh, ll, lc] = request.security_lower_tf(syminfo.tickerid, '1', [open, high, low, close], true)
low_indices_sorted = array.sort_indices(ll, order.ascending)
high_indices_sorted = array.sort_indices(lh, order.descending)
ll_index = array.size(lh)>0? array.get(low_indices_sorted, 0) : 0
hh_index = array.size(ll)>0? array.get(high_indices_sorted, 0) : 0
high_after_low = array.size(lh)>0? array.max(array.slice(lh, ll_index, array.size(lh))) : na
low_after_high = array.size(ll)>0? array.min(array.slice(ll, hh_index, array.size(ll))) : na
high_before_low = array.size(lh)>0? array.max(array.slice(lh, 0, ll_index+1)) : na
low_before_high = array.size(ll)>0? array.min(array.slice(ll, 0, hh_index+1)) : na
fSize = math.min(ll_index, hh_index)
sSize = math.max(ll_index, hh_index) - math.min(ll_index, hh_index)
tSize = array.size(lh) - math.max(ll_index, hh_index)
sizeArray = array.from(fSize, sSize, tSize)
sizeArraySortOrder = array.sort_indices(sizeArray, order.ascending)
_first_open = open
_first_high = ll_index < hh_index? high_before_low : high
_first_low = ll_index < hh_index? low : low_before_high
_first_close = ll_index < hh_index? low : high
_first_size = array.get(sizeArraySortOrder, 0)+1
_second_open = _first_close
_second_high = high
_second_low = low
_second_close = ll_index < hh_index? high : low
_second_size = array.get(sizeArraySortOrder, 1)+1
_third_open = _second_close
_third_high = ll_index < hh_index ? high : high_after_low
_third_low = ll_index < hh_index ? low_after_high : low
_third_close = close
_third_size = array.get(sizeArraySortOrder, 2)+1
draw_envelope(candleStart, candleEnd)=>
var box envelope = na
box.delete(envelope)
borderColor = (open > close and close[1] > close) ? color.red : ((open < close and close[1] < close) ? color.green : color.silver)
envelopeColor = color.new(borderColor, 90)
diff = 0.2*(high - low)
envelope := box.new(candleStart, high+diff, candleEnd, low-diff, bgcolor = envelopeColor, border_color=borderColor)
draw_candle(_open, _high, _low, _close, _size, _offset)=>
var box body = na
var line upperWick = na
var line lowerWick = na
box.delete(body)
line.delete(upperWick)
line.delete(lowerWick)
candleStart = _offset
candleEnd = _offset+_size*2
candleColor = _open > _close? color.red : color.green
body := box.new(candleStart, _open, candleEnd, _close, bgcolor = candleColor, border_color = candleColor)
upperWick := line.new((candleStart+candleEnd)/2, math.max(_open, _close), (candleStart+candleEnd)/2, _high, color=candleColor)
lowerWick := line.new((candleStart+candleEnd)/2, math.min(_open, _close), (candleStart+candleEnd)/2, _low, color=candleColor)
candleEnd+1
initialDistance = bar_index + 10
offset = initialDistance+1
offset := draw_candle(_first_open, _first_high, _first_low, _first_close, _first_size, offset)
offset := draw_candle(_second_open, _second_high, _second_low, _second_close, _second_size, offset)
offset := draw_candle(_third_open, _third_high, _third_low, _third_close, _third_size, offset)
draw_envelope(initialDistance, offset) |
RSI+ by Wilson (alt) | https://www.tradingview.com/script/yoGhkCsV-RSI-by-Wilson-alt/ | tartigradia | https://www.tradingview.com/u/tartigradia/ | 97 | 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/
// © wilsonlibero
// extended by tartigradia
//@version=5
indicator(title='RSI+ by Wilson (alt)', shorttitle='RSI+ (Wilson alt)', format=format.price, precision=2, timeframe="", timeframe_gaps=true)
//
// Inputs
var grp1 = 'Core parameters'
src1 = input.source(close, title='RSI Source', inline='11', group=grp1)
length1 = input.int(defval=14, minval=1, title='RSI Length', inline='11', group=grp1)
var grp2 = 'Thresholds and highlights'
overbthr = input.int(defval=70, minval=1, maxval=100, title='Overbought threshold', group=grp2)
oversthr = input.int(defval=30, minval=1, maxval=100, title='Oversold threshold', group=grp2)
overbthr2 = input.int(defval=75, minval=1, maxval=100, title='Extended overbought threshold', group=grp2)
oversthr2 = input.int(defval=25, minval=1, maxval=100, title='Extended oversold threshold', group=grp2)
overbthr3 = input.int(defval=85, minval=1, maxval=100, title='Maximally extended overbought threshold', group=grp2)
oversthr3 = input.int(defval=15, minval=1, maxval=100, title='Maximally extended oversold threshold', group=grp2)
plotoverli = input.bool(true, title='Plot Overbought & Oversold Margin Lines', group=grp2)
plotoverli2 = input.bool(false, title='Plot Extended Overbought & Oversold Margin Lines', group=grp2)
highlight = input.bool(true, title='Highlight Overbought & Oversold Areas', group=grp2, tooltip='Highlight the background when price is beyond overbought or oversold thresholds, with different colors for extended and maximally extended thresholds. This does not require the display of the thresholds.')
highlightmid = input.bool(true, title='Highlight Bullish & Bearish Areas Above & Below Midline', group=grp2, tooltip='Highlight the background when price is consistently above or below the midle (RSI 50%), which is usually considered a sign of bullish or bearish trend respectively.')
midlinemargin = input.int(5, minval=0, maxval=50, title='Midline Margin To Exclude Bullish & Bearish Areas Highlight', group=grp2, tooltip='When price will be plus or minus this margin around 50%, there will be no background highlighting, as a way to signal that the trend remains uncertain. Default is 5, which means that RSI 45%-55% will remain without highlighting = uncertain trend area.')
// RSI Shadow
// Copied over from the indicator of the same name by Tartigradia, but with the RSI Shadow Sentiment adapted to display as a bar instead of a background highlighting, for better ergonomy.
// How to use: compare the colors of both RSI Status and RSI Shadow Sentiment bars, when they are in agreement, especially for longer strings, the sentiment is stronger than if sentiment is only indicated by either bar alone.
// RSI Shadow Sentiment bar can also sometimes show a trend reversal earlier, although it is unreliable (it is highly sensitive to market participants emotions), hence using it as a reversal tool should always be combined with other indicators/readings from RSI (e.g. , RSI MA cloud, RSI midline sentiment with background highlight, etc...).
var grpshadow = 'RSI Shadow'
rsishadow = input.bool(true, title='Show RSI Shadow', tooltip='Shows the area of high/low RSI values attained during open sessions (ie, wicks).', group=grpshadow)
rsishadowtype = input.string('New', title='RSI Shadow calculation method', options=['Old', 'New'], tooltip='New: accurate shadow, showing the exact RSI values attained at high and low during the open session. Old: area between max(rsi of open or high or low or close) vs min of all the same possible inputs.', group=grpshadow)
src_high_str = input.string('high', title='RSI Shadow Source 1', options=['close', 'open', 'high', 'low', 'hl2', 'hlc3', 'hlcc4'], group=grpshadow) // workaround: we use an input.string combined with a select, to avoid using multiple input.source, because when there is only one single input.source, then TradingView allows to select external inputs such as other indicators' outputs, instead of just price values.
src_low_str = input.string('low', title='RSI Shadow Source 2', options=['close', 'open', 'high', 'low', 'hl2', 'hlc3', 'hlcc4'], group=grpshadow)
shadow_sentiment = input.bool(true, "Display RSI Shadow Sentiment Bar?", tooltip="Display a bar at the bottom codifying bullish or bearish sentiment depending on RSI being closer to the high or low shadow bounds respectively.", group=grpshadow)
shadow_sentiment_congruent = input.bool(true, "RSI Shadow Sentiment Congruency", tooltip="If true, then will highlight background only if both 1) RSI is close to a bound, 2) RSI goes in the same direction as the bound it is closest. Eg, if RSI is close to high shadow bound, but is going down, then it is incongruent and there will be no highlight.", group=grpshadow)
shadow_sentiment_margin = input.int(2, "RSI Shadow Sentiment Margin", minval=0, step=1, tooltip="Margin to consider that RSI is significantly closer to the high or low bounds", group=grpshadow)
// Workaround to use only one source: we manually input each possible price source from an input.string()
src_high = switch src_high_str
'close' => close
'open' => open
'high' => high
'low' => low
'hl2' => hl2
'hlc3' => hlc3
'hlcc4' => hlcc4
src_low = switch src_low_str
'close' => close
'open' => open
'high' => high
'low' => low
'hl2' => hl2
'hlc3' => hlc3
'hlcc4' => hlcc4
var grp3 = 'Moving Averages'
plotma1 = input.bool(true, title='Plot First MA', group=grp3)
length2 = input.int(defval=20, minval=2, title='First MA Length', group=grp3)
type = input.string(defval='EMA', options=['SMA', 'EMA', 'WMA', 'VWMA', 'HullMA', 'ALMA'], title=' First MA Type', group=grp3)
plotma2 = input.bool(false, title='Plot Second MA', group=grp3)
length3 = input.int(defval=5, minval=2, title='Second MA Length', group=grp3)
type2 = input.string(defval='ALMA', options=['SMA', 'EMA', 'WMA', 'VWMA', 'HullMA', 'ALMA'], title=' Second MA Type', group=grp3)
almaOffset = input.float(0.85, minval=0, title='ALMA Offset', group=grp3)
almaSigma = input.int(6, minval=0, title='ALMA Sigma', group=grp3)
plothist1 = input.bool(true, title='Plot Histogram of RSI & First MA', group=grp3)
plothist2 = input.bool(false, title='Plot Histogram of RSI & Second MA', group=grp3)
colorfill1 = input.bool(true, title='Fill colour between RSI & First MA (RSI Cloud 1)', group=grp3)
colorfill2 = input.bool(false, title='Fill colour between RSI & Second MA (RSI Cloud 2)', group=grp3)
signalplot1 = input.bool(true, title='Show Cross Signals of First MA', group=grp3)
signalplot2 = input.bool(false, title='Show Cross Signals of Second MA', group=grp3)
status = input.bool(true, title='Show RSI Positional Status Bar', group=grp3, tooltip='RSI Positional Status codifies the current trend as a colored bar depending on the crossings of the two MAs. Note that the RSI Status will use the configuration for each MAs even if they are not displayed (ie, if you change one MA type, it will change the RSI Status bar).')
var grp4 = 'Alerts'
alert1 = input(false, title='Alert for Crosses of First MA', group=grp4)
alert2 = input(false, title='Alert for Crosses of Second MA', group=grp4)
//
// Aux functions
// The following shadow functions perform the usual calculations except for the current bar, for which a value based on another source is returned.
// For example, this allows to calculate what the SMA would be if we used the close value for all past bars, but use the high or low value for the current bar. Repeat this for all bars, and you get the higher/lower bound of SMA values that happened during open sessions.
// Hence, the "shadow" functions allow to plot the high/low values that were attained during open sessions, and hence allow to visually represent the variability that historically happened, which may be of importance for the future.
// From pinescript doc
shadow_sma(src, src_cur, len) =>
sum = 0.0
sum := nz(sum[1]) - nz(src[len]) + src // compute the updated rolling sum
(nz(sum[1]) - nz(src) + src_cur)/len // but don't return the normal sum using the src, instead remove the last src value and replace it with src_cur (the second source) and return the sma of it!
// Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.
// from pinescript v5 doc
shadow_rma(src, src_cur, length) =>
alpha = 1/length
sum = 0.0
sum_cur = na(sum[1]) ? shadow_sma(src, src_cur, length) : alpha * src_cur + (1 - alpha) * nz(sum[1]) // calculate the EMA using the second source (src_cur) before modifying the sum, because it would be more complicated to reverse the calculation afterwards (as we do in SMA)
sum := na(sum[1]) ? shadow_sma(src, src_cur, length) : alpha * src + (1 - alpha) * nz(sum[1]) // update the sum so that on next bar we can reuse the typical EMA value derived from the first source (src).
sum_cur // return the shadow EMA value, using src for all past bars, except current bar which uses the second source src_cur.
// from pinescript v5 doc
shadow_rsi(src1, src2, length) =>
// normal RSI values
u = math.max(src1 - src1[1], 0) // upward ta.change
d = math.max(src1[1] - src1, 0) // downward ta.change
// shadow RSI values (using second source for last bar vs first source for past bars)
u_cur = math.max(src2 - src1[1], 0) // upward ta.change
d_cur = math.max(src1[1] - src2, 0) // downward ta.change
// use shadow functions to force using the second source for the last bar
rs = shadow_rma(u, u_cur, length) / shadow_rma(d, d_cur, length)
// calculate RSI as usual
res = 100 - 100 / (1 + rs)
res
//
// Calculations
rsi = ta.rsi(src1, length1)
maplot = type == 'SMA' ? ta.sma(rsi, length2) : type == 'EMA' ? ta.ema(rsi, length2) : type == 'WMA' ? ta.wma(rsi, length2) : type == 'VWMA' ? ta.vwma(rsi, length2) : type == 'HullMA' ? ta.wma(2 * ta.wma(rsi, length2 / 2) - ta.wma(rsi, length2), math.round(math.sqrt(length2))) : type == 'ALMA' ? ta.alma(rsi, length2, almaOffset, almaSigma) : na
maplot2 = type == 'SMA' ? ta.sma(rsi, length3) : type == 'EMA' ? ta.ema(rsi, length3) : type == 'WMA' ? ta.wma(rsi, length3) : type == 'VWMA' ? ta.vwma(rsi, length3) : type == 'HullMA' ? ta.wma(2 * ta.wma(rsi, length3 / 2) - ta.wma(rsi, length3), math.round(math.sqrt(length3))) : type == 'ALMA' ? ta.alma(rsi, length3, almaOffset, almaSigma) : na
diffp = (rsi - maplot) / maplot * 100
diffn = (maplot - rsi) / maplot * 100
absdiff = math.abs(rsi - maplot)
diffp2 = (rsi - maplot2) / maplot2 * 100
diffn2 = (maplot2 - rsi) / maplot2 * 100
absdiff2 = math.abs(rsi - maplot2)
rsi_h = ta.rsi(high, length1)
rsi_o = ta.rsi(open, length1)
rsi_l = ta.rsi(low, length1)
rsi_c = ta.rsi(close, length1)
// Old RSI Shadow
rsimax = rsishadow and (rsishadowtype == 'Old') ? math.max(rsi_h, rsi_o, rsi_l, rsi_c) : 0.0
rsimin = rsishadow and (rsishadowtype == 'Old') ? math.min(rsi_h, rsi_o, rsi_l, rsi_c) : 0.0
// New RSI Shadow: Calculate values of RSI, RSI high and RSI low
//vrsi = shadow_rsi(src, src, rsi_length)
vrsi_high = (rsishadow and (rsishadowtype == 'New')) or shadow_sentiment ? shadow_rsi(src1, src_high, length1) : 0.0
vrsi_low = (rsishadow and (rsishadowtype == 'New')) or shadow_sentiment ? shadow_rsi(src1, src_low, length1) : 0.0
// Preconfigure some colors
cgr = #64ffda // color.green
cre = color.red
cwh = color.white
cye = color.yellow
cbl = #90bff9
//
// Plotting
p2 = plot(rsi, title='RSI', color=rsi > rsi[1] ? color.new(cgr, 20) : color.new(cwh, 20), linewidth=3)
p1 = plot(plotma1 ? maplot : na, title='First MA', color=color.new(color.yellow, 0))
p3 = plot(plotma2 ? maplot2 : na, title='Second MA', color=color.new(color.blue, 0)) // TODO: remove ternary conditional plotma2 and plotma1 and similar, and replace with display=display.none or display.all, this will hide/display graph by default and it can be changed in style, instead of having an input option that counts for 2 objects on graph instead of 1
p4 = plot(plothist1 ? absdiff : na, title='Histogram MA1', color=rsi > maplot ? cgr : cre, style=plot.style_histogram)
p5 = plot(plothist2 ? absdiff2 : na, title='Histogram MA2', color=rsi > maplot2 ? cgr : cre, style=plot.style_histogram)
p6 = hline(status ? -3 : na, color=color.new(cwh, 100), title='Status Line Bottom', linestyle=hline.style_dotted)
p7 = hline(status ? 0 : na, color=color.new(cwh, 100), title='Status Line Top', linestyle=hline.style_dotted)
p8 = hline(50, color=color.new(cwh, 50), title='Midline', linewidth=1, linestyle=hline.style_solid)
p9 = hline(plotoverli ? overbthr : na, color=color.new(cwh, 100), title='Overbought line', linestyle=hline.style_dotted)
p10 = hline(plotoverli ? oversthr : na, color=color.new(cwh, 100), title='Oversold line', linestyle=hline.style_dotted)
p11 = hline(plotoverli or plotoverli2 ? overbthr2 : na, color=color.new(cwh, 100), title='Extended overbought line', linestyle=hline.style_dotted)
p12 = hline(plotoverli or plotoverli2 ? oversthr2 : na, color=color.new(cwh, 100), title='Extended oversold line', linestyle=hline.style_dotted)
p13 = hline(plotoverli2 ? overbthr3 : na, color=color.new(cwh, 100), title='Maximally extended overbought line', linestyle=hline.style_dotted)
p14 = hline(plotoverli2 ? oversthr3 : na, color=color.new(cwh, 100), title='Maximally extended oversold line', linestyle=hline.style_dotted)
prsih = plot(rsishadow and (rsishadowtype == 'New') ? vrsi_high : rsishadow ? rsimax : na, title='RSI Shadow high line', color=color.new(color.white, 50), linewidth=1, display=display.none)
prsil = plot(rsishadow and (rsishadowtype == 'New') ? vrsi_low : rsishadow ? rsimin : na, title='RSI Shadow low min line', color=color.new(color.white, 50), linewidth=1, display=display.none)
pshadowsentiment = hline(shadow_sentiment ? -6 : na, color=color.new(cwh, 100), title='RSI Shadow Sentiment Bar Line Bottom', linestyle=hline.style_dotted) // use invisible color lines instead of display.none to ensure chart is scaled to include bar, otherwise with display.none the fill will still be displayed but the chart won't necessarily get scaled to display it
plotshape(signalplot1 and ta.crossover(rsi, maplot) ? rsi : na, 'First MA Crossover', size=size.tiny, style=shape.circle, location=location.absolute, color=color.new(cgr, 0))
plotshape(signalplot1 and ta.crossunder(rsi, maplot) ? rsi : na, 'First MA Crossunder', size=size.tiny, style=shape.circle, location=location.absolute, color=color.new(cre, 0))
plotshape(signalplot2 and ta.crossover(rsi, maplot2) ? rsi : na, 'Second MA Crossover', size=size.tiny, style=shape.diamond, location=location.absolute, color=color.new(cgr, 0))
plotshape(signalplot2 and ta.crossunder(rsi, maplot2) ? rsi : na, 'Second MA Crossunder', size=size.tiny, style=shape.diamond, location=location.absolute, color=color.new(cre, 0))
fill(p6, p7, rsi > maplot and rsi > maplot2 and status ? color.new(cgr, 10) : na, title="RSI Status Bullish")
fill(p6, p7, rsi < maplot and rsi < maplot2 and status ? color.new(cre, 10) : na, title="RSI Status Bearish")
fill(p6, p7, rsi > maplot and rsi < maplot2 and status ? color.new(cye, 10) : na, title="RSI Status Undecided")
fill(p6, p7, rsi < maplot and rsi > maplot2 and status ? color.new(cye, 10) : na, title="RSI Status Undecided")
fill(prsih, prsil, color=rsishadow ? color.new(color.white, 50) : na, title='RSI Shadow') // Fill between RSI high and RSI low to get the RSI Shadow!
// RSI Shadow Sentiment Bar coloring
// To save on the PineScript limit of maximum drawn objects under 64, we plot all this under one call:
// First we check if shadow_sentiment display is enabled
// Secondly, we check if RSI is closer to the higher shadow bound than the lower bound, including the margin.
// If yes, then if congruency check is enabled, we check if bar is congruent (ie, RSI of current bar is higher than RSI of previous bar, hence, RSI is both closer to higher shadow bound AND it is rising higher), then we fill in green
// Otherwise, bar is incongruent, we fill in gray.
// If no (RSI is not closer to the higher shadow bound), then Thirdly, we check if RSI is closer to the lower shadow bound than the higher bound, including the margin.
// If yes, then if congruency check is enabled, check if bar is congruent. If yes, fill in red. Otherwise, bar is incongruent, fill in gray.
// If no again (RSI is neither closer to the higher shadow bound nor lower bound including margin, it's kind of in the middle), then fill in yellow, to signal current bar has an undecided sentiment.
//
fill(pshadowsentiment, p6, color=
not shadow_sentiment ?
na :
(vrsi_high - rsi + shadow_sentiment_margin) < (rsi - vrsi_low) ?
(shadow_sentiment_congruent ? rsi > rsi[1] : true) ?
color.new(cgr, 10) :
color.new(color.gray, 10)
:
(vrsi_high - rsi) > (rsi - vrsi_low + shadow_sentiment_margin) ?
(shadow_sentiment_congruent ? rsi < rsi[1] : true) ?
color.new(cre, 10) :
color.new(color.gray, 10)
:
color.new(cye, 10),
title="RSI Shadow Sentiment Status Bar (is RSI closer to the higher or lower bound?)")
fill(p9, p11, plotoverli ? color.new(cwh, 90) : na, title='Overbought Margin')
fill(p11, p13, plotoverli2 ? color.new(cwh, 85) : na, title='Oversold Margin')
fill(p10, p12, plotoverli ? color.new(cwh, 90) : na, title='Extended Overbought Margin')
fill(p12, p14, plotoverli2 ? color.new(cwh, 85) : na, title='Extended OverSold Margin')
//
// Fill diff
// TODO: to save on number of outputs and still keep a filling gradient, try to use the new overload filling? https://www.tradingview.com/script/Tj38mR1q-RSI-colour-fill/
fill(p1, p2, color=colorfill1 and rsi > maplot and diffp > 90 ? color.new(cgr, 5) : na, title='Fill Diff Positive MA1 >90%')
fill(p1, p2, color=colorfill1 and rsi > maplot and diffp > 80 and diffp <= 90 ? color.new(cgr, 10) : na, title='Fill Diff Positive MA1 >80%')
fill(p1, p2, color=colorfill1 and rsi > maplot and diffp > 60 and diffp <= 80 ? color.new(cgr, 20) : na, title='Fill Diff Positive MA1 >60%')
fill(p1, p2, color=colorfill1 and rsi > maplot and diffp > 40 and diffp <= 60 ? color.new(cgr, 30) : na, title='Fill Diff Positive MA1 >40%')
fill(p1, p2, color=colorfill1 and rsi > maplot and diffp > 20 and diffp <= 40 ? color.new(cgr, 40) : na, title='Fill Diff Positive MA1 >20%')
fill(p1, p2, color=colorfill1 and rsi > maplot and diffp > 10 and diffp <= 20 ? color.new(cgr, 60) : na, title='Fill Diff Positive MA1 >10%')
fill(p1, p2, color=colorfill1 and rsi > maplot and diffp <= 10 ? color.new(cgr, 80) : na, title='Fill Diff MA1 <=10%')
fill(p1, p2, color=colorfill1 and rsi < maplot and diffn > 90 ? color.new(cre, 5) : na, title='Fill Diff Negative MA1 >90%')
fill(p1, p2, color=colorfill1 and rsi < maplot and diffn > 80 and diffn <= 90 ? color.new(cre, 10) : na, title='Fill Diff Negative MA1 >80%')
fill(p1, p2, color=colorfill1 and rsi < maplot and diffn > 60 and diffn <= 80 ? color.new(cre, 20) : na, title='Fill Diff Negative MA1 >60%')
fill(p1, p2, color=colorfill1 and rsi < maplot and diffn > 40 and diffn <= 60 ? color.new(cre, 30) : na, title='Fill Diff Negative MA1 >40%')
fill(p1, p2, color=colorfill1 and rsi < maplot and diffn > 20 and diffn <= 40 ? color.new(cre, 40) : na, title='Fill Diff Negative MA1 >20%')
fill(p1, p2, color=colorfill1 and rsi < maplot and diffn > 10 and diffn <= 20 ? color.new(cre, 60) : na, title='Fill Diff Negative MA1 >10%')
fill(p1, p2, color=colorfill1 and rsi < maplot and diffn <= 10 ? color.new(cre, 80) : na, title='Fill Diff Negative MA1 <=10%')
fill(p3, p2, color=colorfill2 and rsi > maplot2 and diffp2 > 90 ? color.new(cgr, 5) : na, title='Fill Diff Positive MA2 >90%')
fill(p3, p2, color=colorfill2 and rsi > maplot2 and diffp2 > 80 and diffp2 <= 90 ? color.new(cgr, 10) : na, title='Fill Diff Positive MA2 >80%')
fill(p3, p2, color=colorfill2 and rsi > maplot2 and diffp2 > 60 and diffp2 <= 80 ? color.new(cgr, 20) : na, title='Fill Diff Positive MA2 >60%')
fill(p3, p2, color=colorfill2 and rsi > maplot2 and diffp2 > 40 and diffp2 <= 60 ? color.new(cgr, 30) : na, title='Fill Diff Positive MA2 >40%')
fill(p3, p2, color=colorfill2 and rsi > maplot2 and diffp2 > 20 and diffp2 <= 40 ? color.new(cgr, 40) : na, title='Fill Diff Positive MA2 >20%')
fill(p3, p2, color=colorfill2 and rsi > maplot2 and diffp2 > 10 and diffp2 <= 20 ? color.new(cgr, 60) : na, title='Fill Diff Positive MA2 >10%')
fill(p3, p2, color=colorfill2 and rsi > maplot2 and diffp2 <= 10 ? color.new(cgr, 80) : na, title='Fill Diff Positive MA2 <=10%')
fill(p3, p2, color=colorfill2 and rsi < maplot2 and diffn2 > 90 ? color.new(cre, 5) : na, title='Fill Diff Negative MA2 >90%')
fill(p3, p2, color=colorfill2 and rsi < maplot2 and diffn2 > 80 and diffn2 <= 90 ? color.new(cre, 10) : na, title='Fill Diff Negative MA2 >80%')
fill(p3, p2, color=colorfill2 and rsi < maplot2 and diffn2 > 60 and diffn2 <= 80 ? color.new(cre, 20) : na, title='Fill Diff Negative MA2 >60%')
fill(p3, p2, color=colorfill2 and rsi < maplot2 and diffn2 > 40 and diffn2 <= 60 ? color.new(cre, 30) : na, title='Fill Diff Negative MA2 >40%')
fill(p3, p2, color=colorfill2 and rsi < maplot2 and diffn2 > 20 and diffn2 <= 40 ? color.new(cre, 40) : na, title='Fill Diff Negative MA2 >20%')
fill(p3, p2, color=colorfill2 and rsi < maplot2 and diffn2 > 10 and diffn2 <= 20 ? color.new(cre, 60) : na, title='Fill Diff Negative MA2 >10%')
fill(p3, p2, color=colorfill2 and rsi < maplot2 and diffn2 <= 10 ? color.new(cre, 80) : na, title='Fill Diff Negative MA2 <=10%')
//
// Overbought highlight
bgcolor(highlight and rsi >= overbthr and rsi < overbthr2 ? color.new(cgr, 50) : na, title='Overbought Highlight')
bgcolor(highlight and rsi >= overbthr2 and rsi < overbthr3 ? color.new(cgr, 20) : na, title='Extended Overbought Highlight')
bgcolor(highlight and rsi >= overbthr3 ? color.new(cgr, 5) : na, title='Maximally Extended Overbought Highlight')
//
// Oversold highlight
bgcolor(highlight and rsi <= oversthr and rsi > oversthr2 ? color.new(cre, 50) : na, title='Oversold Highlight')
bgcolor(highlight and rsi <= oversthr2 and rsi > oversthr3 ? color.new(cre, 20) : na, title='Extended Oversold Highlight')
bgcolor(highlight and rsi <= oversthr3 ? color.new(cre, 10) : na, title='Maximally Extended Oversold Highlight')
//
// RSI trend compared to midline
bgcolor(highlightmid and rsi < 50 - midlinemargin ? color.new(cye, 75) : na, title='Bearish Trend (Below Midline) Bg Highlight')
bgcolor(highlightmid and rsi > 50 + midlinemargin ? color.new(cbl, 70) : na, title='Bullish Trend (Above Midline) Bg Highlight')
//
// Alerts
alertcondition(alert1 and ta.crossover(rsi, maplot) or ta.crossunder(rsi, maplot), title='RSI Crossing First MA')
alertcondition(alert2 and ta.crossover(rsi, maplot2) or ta.crossunder(rsi, maplot2), title='RSI Crossing Second MA')
//
// Stochastic RSI (from TradingView native library)
cstoch1 = #2962FF
cstoch2 = #FF6D00
var grp5 = 'Stochastic RSI'
plotstoch = input(true, title='Plot Stochastic RSI', inline='S1', group=grp5)
lengthStoch = input.int(14, "Stochastic Length", minval=1, inline='S1', group=grp5)
smoothK = input.int(3, "Stochastic smoothing K", minval=1, inline='S2', group=grp5)
smoothD = input.int(3, "Stochastic smoothing D", minval=1, inline='S2', group=grp5)
stochrescale = input(true, title='Rescale Stochastic RSI between RSI overbought/oversold thresholds?', group=grp5, tooltip='Rescale stochastic RSI to be under overbought/oversold thresholds instead of 0-100%, to minimize space used by stochastic RSI and hence less cluttered visuals.')
k = ta.sma(ta.stoch(rsi, rsi, rsi, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
k_rescale = oversthr + ((k - ta.min(k)) * (overbthr - oversthr) / ta.max(k) - ta.min(k))
d_rescale = oversthr + ((d - ta.min(d)) * (overbthr - oversthr) / ta.max(d) - ta.min(d))
plot(plotstoch ? (stochrescale ? k_rescale : k) : na, "StochRSI K", color=color.new(cstoch1, 30))
plot(plotstoch ? (stochrescale ? d_rescale : d) : na, "StochRSI D", color=color.new(cstoch2, 30))
//h0 = hline(80, "Upper Band", color=#787B86)
//hline(50, "Middle Band", color=color.new(#787B86, 50))
//h1 = hline(20, "Lower Band", color=#787B86)
//fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")
|
Higher Time Frame EMAs and 1% volatility indicator | https://www.tradingview.com/script/9VubExWG/ | ft74 | https://www.tradingview.com/u/ft74/ | 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/
// © ft74
//@version=5
indicator(title="Higher Time Frame EMA", shorttitle="HTFEMA", overlay=true)
HTF = input('30', title="Higher Timeframe for EMA")
len1 = input(5, title="EMA1 Length")
col1 = input(color.new(color.red,65), title="EMA1 Color")
smooth1 = input(defval=true, title="EMA1 Smooth")
len2 = input(10, title="EMA2 Length")
col2 = input(color.new(color.yellow,80), title="EMA2 Color")
smooth2 = input(defval=true, title="EMA2 Smooth")
len3 = input(60, title="EMA3 Length")
col3 = input(color.rgb(0,255,255,80), title="EMA3 Color")
smooth3 = input(defval=true, title="EMA3 Smooth")
len4 = input(223, title="EMA4 Length")
col4 = input(color.new(color.purple,60), title="EMA4 Color")
smooth4 = input(defval=true, title="EMA4 Smooth")
ema1 = ta.ema(close, len1)
emaSmooth1 = request.security(syminfo.tickerid, HTF, ema1, barmerge.gaps_on, barmerge.lookahead_on)
emaStep1 = request.security(syminfo.tickerid, HTF, ema1, barmerge.gaps_off, barmerge.lookahead_on)
ema2 = ta.ema(close, len2)
emaSmooth2 = request.security(syminfo.tickerid, HTF, ema2, barmerge.gaps_on, barmerge.lookahead_on)
emaStep2 = request.security(syminfo.tickerid, HTF, ema2, barmerge.gaps_off, barmerge.lookahead_on)
ema3 = ta.ema(close, len3)
emaSmooth3 = request.security(syminfo.tickerid, HTF, ema3, barmerge.gaps_on, barmerge.lookahead_on)
emaStep3 = request.security(syminfo.tickerid, HTF, ema3, barmerge.gaps_off, barmerge.lookahead_on)
ema4 = ta.ema(close, len4)
emaSmooth4 = request.security(syminfo.tickerid, HTF, ema4, barmerge.gaps_on, barmerge.lookahead_on)
emaStep4 = request.security(syminfo.tickerid, HTF, ema4, barmerge.gaps_off, barmerge.lookahead_on)
plot(series = smooth1 ? emaSmooth1 : emaStep1,
title = "HTF EMA1",
color = col1,
linewidth = 10,
style = plot.style_line
)
plot(series = smooth2 ? emaSmooth2 : emaStep2,
title = "HTF EMA2",
color = col2,
linewidth = 10,
style = plot.style_line
)
plot(series = smooth3 ? emaSmooth3 : emaStep3,
title = "HTF EMA3",
color = col3,
linewidth = 10,
style = plot.style_line
)
plot(series = smooth4 ? emaSmooth4 : emaStep4,
title = "HTF EMA4",
color = col4,
linewidth = 10,
style = plot.style_line
)
line100 = line.new(bar_index[1]+2, close, bar_index+2, close, extend=extend.right, color=color.white)
line.delete(line100[1])
label100 = label.new(bar_index+2, close, "0%", textalign=text.align_left, style=label.style_none, textcolor=color.white)
label.delete(label100[1])
line101=line.new(bar_index[1]+2,close*1.01,bar_index+2, close*1.01,extend=extend.right, color=color.white)
line.delete(line101[1])
label101 = label.new(bar_index+2, close*1.01, "+1%", textalign=text.align_left, style=label.style_none, textcolor=color.white)
label.delete(label101[1])
line99=line.new(bar_index[1]+2,close*0.99,bar_index+2, close*0.99,extend=extend.right, color=color.white)
line.delete(line99[1])
label99 = label.new(bar_index+2, close*0.99, "-1%", textalign=text.align_left, style=label.style_none, textcolor=color.white)
label.delete(label99[1])
|
Improved Lowry Up-Down Volume + Stocks Indicator | https://www.tradingview.com/script/uQFVad9F-Improved-Lowry-Up-Down-Volume-Stocks-Indicator/ | jlb05013 | https://www.tradingview.com/u/jlb05013/ | 250 | 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/
// © jlb05013
//@version=5
indicator("Improved Lowry Up-Down Volume + Stocks Indicator")
nyse_upvol = request.security('UPVOL.NY', timeframe.period, close)
nyse_dnvol = request.security('DNVOL.NY', timeframe.period, close)
nq_upvol = request.security('UPVOL.NQ', timeframe.period, close)
nq_dnvol = request.security('DNVOL.NQ', timeframe.period, close)
dj_upvol = request.security('UPVOL.DJ', timeframe.period, close)
dj_dnvol = request.security('DNVOL.DJ', timeframe.period, close)
nyse_upstocks = request.security('ADVN', timeframe.period, close)
nyse_dnstocks = request.security('DECN', timeframe.period, close)
nq_upstocks = request.security('ADVN.NQ', timeframe.period, close)
nq_dnstocks = request.security('DECL.NQ', timeframe.period, close)
dj_upstocks = request.security('ADVN.DJ', timeframe.period, close)
dj_dnstocks = request.security('DECL.DJ', timeframe.period, close)
// get input from the user on whether they would like to plot volume or stocks, and give a choice on which exchange to pick from
input_exchanges = input.string(defval='NYSE', title='Which Exchanges?', options=['NYSE', 'NASDAQ', 'NYSE + NASDAQ', 'DJ', 'NYSE + NASDAQ + DJ'], tooltip='Default is NYSE')
input_unit = input.string(defval='Volume', title='Volume or Stocks?', options=['Volume', 'Stocks'], tooltip="Default is Volume")
// return the values to use, either volume or stocks, based on user inputs
nyse_up_unit = input_unit == 'Volume' ? nyse_upvol : nyse_upstocks
nyse_dn_unit = input_unit == 'Volume' ? nyse_dnvol : nyse_dnstocks
nq_up_unit = input_unit == 'Volume' ? nq_upvol : nq_upstocks
nq_dn_unit = input_unit == 'Volume' ? nq_dnvol : nq_dnstocks
dj_up_unit = input_unit == 'Volume' ? dj_upvol : dj_upstocks
dj_dn_unit = input_unit == 'Volume' ? dj_dnvol : dj_dnstocks
// perform the calculations based on user input
hist_up = input_exchanges == 'NYSE' ? nyse_up_unit / (nyse_up_unit + nyse_dn_unit) :
input_exchanges == 'NASDAQ' ? nq_up_unit / (nq_up_unit + nq_dn_unit) :
input_exchanges == 'DJ' ? dj_up_unit / (dj_up_unit + dj_dn_unit) :
input_exchanges == 'NYSE + NASDAQ' ? (nyse_up_unit + nq_up_unit) / (nyse_up_unit + nyse_dn_unit + nq_up_unit + nq_dn_unit) :
(nyse_up_unit + nq_up_unit + dj_up_unit) / (nyse_up_unit + nyse_dn_unit + nq_up_unit + nq_dn_unit + dj_up_unit + dj_dn_unit)
hist_dn = input_exchanges == 'NYSE' ?
-nyse_dn_unit / (nyse_up_unit + nyse_dn_unit) :
input_exchanges == 'NASDAQ' ?
-nq_dn_unit / (nq_up_unit + nq_dn_unit) :
input_exchanges == 'DJ' ?
-dj_dn_unit / (dj_up_unit + dj_dn_unit) :
input_exchanges == 'NYSE + NASDAQ' ?
-(nyse_dn_unit + nq_dn_unit) / (nyse_up_unit + nyse_dn_unit + nq_up_unit + nq_dn_unit) :
-(nyse_dn_unit + nq_dn_unit + dj_dn_unit) / (nyse_up_unit + nyse_dn_unit + nq_up_unit + nq_dn_unit + dj_up_unit + dj_dn_unit)
// create logic that will present a down arrow when there are 90% down days, and an up arrow when there is either a 90% up day or two back-to-back 80% up days
dn_arrow = hist_dn <= -0.9
up_arrow = hist_up >= 0.9 or (hist_up[0] >= 0.8 and hist_up[1] >= 0.8)
// create plots
plot(hist_up, title='Up %', color=color.new(color.green, 40), style=plot.style_histogram, linewidth=3)
plot(hist_dn, title='Down %', color=color.new(color.red, 40), style=plot.style_histogram, linewidth=3)
// add horizontal reference lines for positive and negative 90%
hline(0.9, linestyle=hline.style_solid)
hline(-0.9, linestyle=hline.style_solid)
// create logic that will present a down arrow when there are 90% down days, and an up arrow when there is either a 90% up day or two back-to-back 80% up days
plotshape(up_arrow, title='Up Trigger', style=shape.triangleup, location=location.top, color=color.new(color.green, 0), size=size.small)
plotshape(dn_arrow, title='Down Trigger', style=shape.triangledown, location=location.bottom, color=color.new(color.red, 0), size=size.small)
|
STD-Filtered, Gaussian Moving Average (GMA) [Loxx] | https://www.tradingview.com/script/MgakXHcV-STD-Filtered-Gaussian-Moving-Average-GMA-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 406 | 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("STD-Filtered, Gaussian Moving Average (GMA) [Loxx]",
shorttitle="STDFGMA [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_alpha(int period, int poles)=>
w = 2.0 * math.pi / period
float b = (1.0 - math.cos(w)) / (math.pow(1.414, 2.0 / poles) - 1.0)
float a = - b + math.sqrt(b * b + 2.0 * b)
a
_gsmth(float src, int poles, float alpha)=>
float out = 0.
out := switch poles
1 => alpha * src +
(1 - alpha) * nz(out[1])
2 => math.pow(alpha, 2) * src +
2 * (1 - alpha) * nz(out[1]) -
math.pow(1 - alpha, 2) * nz(out[2])
3 => math.pow(alpha, 3) * src +
3 * (1 - alpha) * nz(out[1]) -
3 * math.pow(1 - alpha, 2) * nz(out[2]) +
math.pow(1 - alpha, 3) * nz(out[3])
4 => math.pow(alpha, 4) * src +
4 * (1 - alpha) * nz(out[1]) -
6 * math.pow(1 - alpha, 2) * nz(out[2]) +
4 * math.pow(1 - alpha, 3) * nz(out[3]) -
math.pow(1 - alpha, 4) * nz(out[4])
out
_filt(float src, int len, float filter)=>
float price = src
float filtdev = filter * ta.stdev(src, len)
price := math.abs(price - price[1]) < filtdev ? price[1] : price
price
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = 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)"])
per = input.int(25,'Period', group = "Basic Settings")
poles = input.int(4,'Poles', group = "Basic Settings", minval = 1, maxval = 4)
filterop = input.string("GMA", "Filter Options", options = ["Price", "GMA", "Both", "None"], group= "Filter Settings")
filter = input.float(1, "Filter Devaitions", minval = 0, group= "Filter Settings")
filterperiod = input.int(10, "Filter Period", minval = 0, group= "Filter 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
float src = switch srcoption
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
src := filterop == "Both" or filterop == "Price" and filter > 0 ? _filt(src, filterperiod, filter) : src
alpha = _alpha(per, poles)
out = _gsmth(src, poles, alpha)
out := filterop == "Both" or filterop == "GMA" and filter > 0 ? _filt(out, filterperiod, filter) : out
sig = nz(out[1])
state = 0
if (out > sig)
state := 1
if (out < sig)
state := -1
pregoLong = out > sig and (nz(out[1]) < nz(sig[1]) or nz(out[1]) == nz(sig[1]))
pregoShort = out < sig and (nz(out[1]) > nz(sig[1]) or nz(out[1]) == nz(sig[1]))
contsw = 0
contsw := nz(contsw[1])
contsw := pregoLong ? 1 : pregoShort ? -1 : nz(contsw[1])
goLong = pregoLong and nz(contsw[1]) == -1
goShort = pregoShort and nz(contsw[1]) == 1
var color colorout = na
colorout := state == -1 ? redcolor : state == 1 ? greencolor : nz(colorout[1])
plot(out, "GMA", color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
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 = "STD-Filtered, Gaussian Moving Average (GMA) [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "STD-Filtered, Gaussian Moving Average (GMA) [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Volume Buy/Sell (by iammaximov) | https://www.tradingview.com/script/o2yXLrfI-volume-buy-sell-by-iammaximov/ | iammaximov | https://www.tradingview.com/u/iammaximov/ | 330 | 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/
// © iammaximov
//@version=5
indicator("Volume Buy/Sell (by iammaximov)", shorttitle="Volume B/S (by iammaximov)", format=format.volume)
maView = input(false, "MA", inline="ma")
maType = input.string("EMA", title="Type", inline="ma", options=["SMA", "HMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
maLen = input.int(14, "Length", inline="ma")
totalVol = input(true, "View total Volume?")
_vol24 = input(false, "View 24H Volume?", inline="vol24")
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Ma Volume
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)
"HMA" => ta.hma(source, length)
pMa = plot(maView ? ma(volume, maLen, maType) : na, title="MA", color=color.new(#ffeb3b, 0), linewidth=1, style=plot.style_stepline)
p0 = plot(0, editable=false, display=display.none)
fill(p0, pMa, color=color.new(#ffeb3b, 80))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//24H Volume
volumetype = input.string("Volume", title="Type", options=["Volume", "Volume * Price"], inline="vol24")
msIn24h = 24 * 60 * 60 * 1000
maxBufferSize = switch
timeframe.isminutes or timeframe.isseconds => 24 * 60
timeframe.isdaily => 24 * 60 / 5
=> 24
cumVolTF = switch
timeframe.isminutes or timeframe.isseconds => "1"
timeframe.isdaily => "5"
=> "60"
cum24hVol(s) =>
src = s
if bar_index == 0
// Creating a buffer of 'maxBufferSize+1' for 'src' and 'time' to avoid the 'max_bars_back' error
src := src[maxBufferSize+1] * time[maxBufferSize+1] * 0
var cumSum = 0.
var int firstBarTimeIndex = na
if na(firstBarTimeIndex) // 24H have not elapsed yet
sum = 0.
for i = 0 to maxBufferSize
if (time - time[i]) >= msIn24h
firstBarTimeIndex := bar_index - i + 1
break
sum += src[i]
cumSum := sum
else
cumSum += nz(src)
for i = firstBarTimeIndex to bar_index
if (time - time[bar_index - i]) < msIn24h
firstBarTimeIndex := i
break
cumSum -= nz(src[bar_index - i])
cumSum
noVolumeError = "The data vendor doesn't provide volume data for this symbol."
//if syminfo.volumetype == "tick" and syminfo.type == "crypto"
//runtime.error(noVolumeError)
var cumVol = 0.
cumVol += nz(volume)
if barstate.islast and cumVol == 0
runtime.error(noVolumeError)
expr = volumetype == "Volume" ? volume : close * volume
vol24h = request.security(syminfo.tickerid, cumVolTF, cum24hVol(expr))
p_volume24 = plot(_vol24 ? vol24h : na, title="24H Volume", style=plot.style_columns, color=close > open ? color.new(#0ecb81, 75) : color.new(#f6465d, 75))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Buy/Sell volume
totalamp = (high-low)/low*100
a = close > open ? ((open-low)/low*100)+((high-close)/close*100) : ((close-low)/low*100)+((high-open)/open*100)
b = a*1/totalamp/2
volBuy = close > open ? volume*b + (volume-(volume*b*2)) : volume*b
volSell = close < open ? volume*b + (volume-(volume*b*2)) : volume*b
ptotal = plot(totalVol ? volBuy + volSell : na, title="Total Volume", style=plot.style_columns, color=close > open ? color.new(#0ecb81, 50) : color.new(#f6465d, 50))
pbuy = plot(volBuy, title="Buy Volume", style=plot.style_columns, color=color.new(#0ecb81, 0))
psell = plot(volSell * -1, title="Sell Volume", style=plot.style_columns, color=color.new(#f6465d, 0))
hline(0, linestyle=hline.style_dotted, color=color.new(#ffeb3b, 0), editable=false)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Amplitude volume
amVol = input(false, "View %Bar/24H Volume?")
d = input.float(5, title="% Bar volume", step=0.01)
aVol = volume*100/vol24h
aVolPlot = plot(amVol and aVol > d and close > open ? volume : amVol and aVol > d and close < open ? -volume : na, title="% Volume", style=plot.style_columns, color=close > open ? color.new(#ff4cf3, 75) : color.new(#ffb74d, 75))
|
Volatility Percentage Indicator | https://www.tradingview.com/script/0YkuBMFT/ | ft74 | https://www.tradingview.com/u/ft74/ | 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/
// © ft74
//@version=5
indicator(title="Volatility Percentage Indicator", shorttitle="VPI", overlay=true)
// Plotting lines -5%, -4%, -3%, -2%, -1%, 0%, +1%, +2%, +3%, +4%, +5%
line95=line.new(bar_index[1]+2,close*0.95,bar_index+3, close*0.95,extend=extend.none, color=color.silver, width=2)
line.delete(line95[1])
label95 = label.new(bar_index+3, close*0.95, "-5%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label95[1])
line96=line.new(bar_index[1]+2,close*0.96,bar_index+3, close*0.96,extend=extend.none, color=color.silver, width=1)
line.delete(line96[1])
label96 = label.new(bar_index+3, close*0.96, "-4%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label96[1])
line97=line.new(bar_index[1]+2,close*0.97,bar_index+3, close*0.97,extend=extend.none, color=color.silver, width=1)
line.delete(line97[1])
label97 = label.new(bar_index+3, close*0.97, "-3%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label97[1])
line98=line.new(bar_index[1]+2,close*0.98,bar_index+3, close*0.98,extend=extend.none, color=color.silver)
line.delete(line98[1])
label98 = label.new(bar_index+3, close*0.98, "-2%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label98[1])
line99=line.new(bar_index[1]+2,close*0.99,bar_index+3, close*0.99,extend=extend.none, color=color.silver)
line.delete(line99[1])
label99 = label.new(bar_index+3, close*0.99, "-1%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label99[1])
line100 = line.new(bar_index[1]+2, close, bar_index+3, close, extend=extend.none, color=color.silver, width=2)
line.delete(line100[1])
label100 = label.new(bar_index+3, close, "0%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label100[1])
line101=line.new(bar_index[1]+2,close*1.01,bar_index+3, close*1.01,extend=extend.none, color=color.silver)
line.delete(line101[1])
label101 = label.new(bar_index+3, close*1.01, "+1%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label101[1])
line102=line.new(bar_index[1]+2,close*1.02,bar_index+3, close*1.02,extend=extend.none, color=color.silver)
line.delete(line102[1])
label102 = label.new(bar_index+3, close*1.02, "+2%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label102[1])
line103=line.new(bar_index[1]+2,close*1.03,bar_index+3, close*1.03,extend=extend.none, color=color.silver, width=1)
line.delete(line103[1])
label103 = label.new(bar_index+3, close*1.03, "+3%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label103[1])
line104=line.new(bar_index[1]+2,close*1.04,bar_index+3, close*1.04,extend=extend.none, color=color.silver, width=1)
line.delete(line104[1])
label104 = label.new(bar_index+3, close*1.04, "+4%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label104[1])
line105=line.new(bar_index[1]+2,close*1.05,bar_index+3, close*1.05,extend=extend.none, color=color.silver, width=2)
line.delete(line105[1])
label105 = label.new(bar_index+3, close*1.05, "+5%", textalign=text.align_left, style=label.style_none, textcolor=color.silver)
label.delete(label105[1]) |
Heiken Ashi Lower Pane | https://www.tradingview.com/script/FKnMVyVz-Heiken-Ashi-Lower-Pane/ | PapaAlan | https://www.tradingview.com/u/PapaAlan/ | 40 | 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/
// © PapaAlan
// Not one of my more challenging scripts, never the less I was requested to publish this open source indicator.
// Heiken Ashi (HA) candles indicate strength usually when the candles have wicks in the direction of the movement, ie. top wicks on green candles w/NO wicks on bottom and vice versa for bearish behavior (bottom wicks on red candles). Weakness in the movement CAN be spotted by watching for wicks opposite the movement appearing.
// This indicator can be used in a lower pane to show heiken ashi candles concurrently with above main chart regular candles.
// Nothing special about it other than displaying bull/bear ha candles with a twist of third color candle (orange default) which is shown when HA candle gets a wick in opposite direction of movement which usually indicates potential directional weakness.
// I also provides various moving average line types based upon the HA high, low, close, open values (HLC4) that can used.
// Note: You can also display this over the main chart as an overlay just by selecting the three dots on the indicator and "Move to" option. Be advised doing so will probably cause too much overlapping onto the regular candles.
//@version=5
indicator("Heiken Ashi Lower Pane",shorttitle="HA Lower Pane")
ma_type_descrip = "EMA - Exponential MA, RMA - Running MA (Smoothed), WMA - Weighted MA, VWMA - Volume Weighted MA, HMA - Hull MA"
show_custom_ma = input.bool(defval=true,title='Show Custom MA')
ma_type = input.string(defval="HMA" ,title='Custom MA Type', options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "HMA"],tooltip= ma_type_descrip)
ma_len = input.int(20, minval=1, title='Custom MA Length')
tf = input.string(defval='5',title='Timeframe')
habull_color = input.color(defval=color.yellow,title='Bull Candle Color')
habear_color = input.color(defval=color.fuchsia,title='Bear Candle Color')
habull_wcolor = input.color(defval=color.yellow,title='Bull Wick Color')
habear_wcolor = input.color(defval=color.fuchsia,title='Bear Wick Color')
haneutral_color = input.color(defval=color.white,title='Neutral Candle Color')
timeframe = tf//timeframe.period
hkopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe, open)
hkhigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe, high)
hklow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe, low)
hkclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe, close)
// var testTable = table.new(position = position.bottom_right, columns = 1, rows = 1, bgcolor = color.yellow, border_width = 1)
// table.cell(table_id = testTable, column = 0, row = 0, text = str.tostring(hkopen) + " " + str.tostring(hkclose) + " " + str.tostring(hkhigh) + " " + str.tostring(hklow))
IsSessionStart(sessionTime, sessionTimeZone=syminfo.timezone) =>
inSess = not na(time(timeframe.period, sessionTime, sessionTimeZone))
inSess and not inSess[1]
isFirstBarOfMarket = IsSessionStart("0930-1600")
float o = na
int openbarindex = na
openbarindex := isFirstBarOfMarket ? bar_index : openbarindex[1]
o := isFirstBarOfMarket ? open : o[1]
// save code for future possible usage with lower tf request.security in obtaining the expected multiple values stored by that function
// _get_values(_array,_len) =>
// val1 = 0.0
// for i=0 to array.size(_array) -1
// val1 := val1 + array.get(_array, i)
// tval = val1 / 2
val1 = 0.0
direction = hkopen < hkclose ? 1 : hkopen > hkclose ? -1 : 0
//up_downwick = direction and hkopen > hklow ? true : false
//dn_upwick = (not direction) and hkhigh > hkopen ? true : false
//c_type = up_downwick or dn_upwick ? color.new(color.orange,0) : hkopen < hkclose ? color.new(#4caf50,0) : color.new(#801922,0)
c_type = direction == 1 ? habull_color : direction == -1 ? habear_color : haneutral_color//h hkopen < hkclose ? color.new(#4caf50,0) : color.new(#f23645,0)
wickcolor = direction == 1 ? habull_wcolor : direction == -1 ? habear_wcolor : haneutral_color//color.new(#4caf50,0) : color.new(#f23645,0)
plotcandle(open=hkopen,high=hkhigh,low=hklow,close=hkclose,title='PlotCandle',color=c_type,wickcolor=wickcolor)
//plotcandle(open=hkopen-o,high=hkhigh-o,low=hklow-o,close=hkclose-o,title='PlotCandle',color=c_type,wickcolor=wickcolor)
ma(source, length, type) =>
type == "SMA" ? ta.sma(source, length) :
type == "EMA" ? ta.ema(source, length) :
type == "SMMA (RMA)" ? ta.rma(source, length) :
type == "WMA" ? ta.wma(source, length) :
type == "VWMA" ? ta.vwma(source, length) :
type == "HMA" ? ta.hma(source, length) :
na
tot = (hkclose + hkopen + hkhigh + hklow) / 4
combhmaclose = ma(tot,ma_len,ma_type)
plot(show_custom_ma ? combhmaclose : na,color=color.white)
arrow_up = hkclose > combhmaclose and hkclose[1] <= combhmaclose
arrow_down = hkclose < combhmaclose and hkclose[1] >= combhmaclose
|
Stochastic Guppy | https://www.tradingview.com/script/LhbqMVY0-Stochastic-Guppy/ | jdotcee | https://www.tradingview.com/u/jdotcee/ | 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/
//Derived from TradingView's built-in Stochastic indicator. Switched from SMA to EMA and applied Guppy (GMMA) indicator short and long term periods.
// © jacasanare
//@version=5
indicator(title="Stochastic Guppy EMA", shorttitle="StochGuppy EMA", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
periodK = input.int(14, title="%K Length", minval=1)
smoothK = input.int(1, title="%K Smoothing", minval=1)
k = ta.ema(ta.stoch(close, high, low, periodK), smoothK)
d1 = ta.ema(k, 3)
d2 = ta.ema(k, 5)
d3 = ta.ema(k, 8)
d4 = ta.ema(k, 10)
d5 = ta.ema(k, 12)
d6 = ta.ema(k, 15)
d7 = ta.ema(k, 30)
d8 = ta.ema(k, 35)
d9 = ta.ema(k, 40)
d10 = ta.ema(k, 45)
d11 = ta.ema(k, 50)
d12 = ta.ema(k, 60)
plot(k, title="%K", color=#FF6D00)
plot(d1, title="%D1", color=#FF6D00)
plot(d2, title="%D2", color=#FF6D00)
plot(d3, title="%D3", color=#FF6D00)
plot(d4, title="%D4", color=#FF6D00)
plot(d5, title="%D5", color=#FF6D00)
plot(d6, title="%D6", color=#FF6D00)
plot(d7, title="%D7", color=#2962FF)
plot(d8, title="%D8", color=#2962FF)
plot(d9, title="%D9", color=#2962FF)
plot(d10, title="%D10", color=#2962FF)
plot(d11, title="%D11", color=#2962FF)
plot(d12, title="%D12", color=#2962FF)
h0 = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
h1 = hline(20, "Lower Band", color=#787B86)
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background") |
MA 3:1 & CZs | https://www.tradingview.com/script/QhoLkbcK/ | ej-camilotto | https://www.tradingview.com/u/ej-camilotto/ | 41 | 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/
// © EJC1453
//
// MA 3:1 & Consolidation Zones
// Tres Medias Móviles y Zonas de Consolidación en un único Indicador.
// By Dev. Camilotto Ezequiel J.
//
//@version=4
//================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//=============================| MEDIAS MÓVILES 3:1 |=============================
study(shorttitle="MA 3:1 & Consolidation Zones", title="MA 3:1 & CZs", overlay=true)
m1 = input(20, minval=1)
m2 = input(50, minval=1)
m3 = input(200, minval=1)
src = input(close, title="Source")
media_1 = sma(src, m1)
media_2 = sma(src, m2)
media_3 = sma(src, m3)
plot(media_1, color=#A5D6A7)
plot(media_2, color=#F48FB1)
plot(media_3, color=#FFEE58)
//================================================================================
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//============================| CONSOLIDATION ZONES |=============================
prd = input(defval = 10, title="Loopback Period", minval = 2, maxval = 50)
conslen = input(defval = 5, title="Min Consolidation Length", minval = 2, maxval = 20)
paintcons = input(defval = true, title = "Paint Consolidation Area ")
zonecol = input(defval = color.new(color.blue, 70), title = "Zone Color")
float hb_ = highestbars(prd) == 0 ? high : na
float lb_ = lowestbars(prd) == 0 ? low : na
var int dir = 0
float zz = na
float pp = na
dir := iff(hb_ and na(lb_), 1, iff(lb_ and na(hb_), -1, dir))
if hb_ and lb_
if dir == 1
zz := hb_
else
zz := lb_
else
zz := iff(hb_, hb_, iff(lb_, lb_, na))
for x = 0 to 1000
if na(close) or dir != dir[x]
break
if zz[x]
if na(pp)
pp := zz[x]
else
if dir[x] == 1 and zz[x] > pp
pp := zz[x]
if dir[x] == -1 and zz[x] < pp
pp := zz[x]
var int conscnt = 0
var float condhigh = na
var float condlow = na
float H_ = highest(conslen)
float L_ = lowest(conslen)
var line upline = na
var line dnline = na
bool breakoutup = false
bool breakoutdown = false
if change(pp)
if conscnt > conslen
if pp > condhigh
breakoutup := true
if pp < condlow
breakoutdown := true
if conscnt > 0 and pp <= condhigh and pp >= condlow
conscnt := conscnt + 1
else
conscnt := 0
else
conscnt := conscnt + 1
if conscnt >= conslen
if conscnt == conslen
condhigh := H_
condlow := L_
else
line.delete(upline)
line.delete(dnline)
condhigh := max(condhigh, high)
condlow := min(condlow, low)
upline := line.new(bar_index, condhigh, bar_index - conscnt, condhigh, color = color.lime, style = line.style_dashed)
dnline := line.new(bar_index, condlow, bar_index - conscnt, condlow, color = color.red, style = line.style_dashed)
fill(plot(condhigh, color = na, style = plot.style_stepline),
plot(condlow, color = na, style = plot.style_stepline),
color = paintcons and conscnt > conslen ? zonecol : color.new(color.white, 100))
alertcondition(breakoutup, title='Breakout Up', message='Breakout Up')
alertcondition(breakoutdown, title='Breakout Down', message='Breakout Down')
//================================================================================
////////////////////////////////////////////////////////////////////////////////////////////////////
|
Faytterro Estimator | https://www.tradingview.com/script/dxeE7GZi/ | faytterro | https://www.tradingview.com/u/faytterro/ | 453 | 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("Faytterro Estimator", overlay=true, max_lines_count=500)
src=input(hlc3,title="source")
len=input.int(10,title="lenght", maxval=499)
c1 = input.color(#35cf02 , "positive momentum color")
c2 = input.color(#cf0202, "negative momentum color")
t1 = input.color(color.white, "text color")
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(3, title="linewidth", minval=1)
plot(cr, color=(cr>=cr[1])? c1 : c2 , linewidth=width,offset=-len+1)
dizi = array.new_float(1000)
var line=array.new_line()
if barstate.islast
for i=0 to len*2
array.set(dizi,i,(i*(i-1)*(cr-2*cr[1]+cr[2])/2+i*(cr[1]-cr[2])+cr[2]))
for i=0 to (len/2+5)
// array.push(line, line.new(bar_index[len]+i*2-1, array.get(dizi,i*2), bar_index[len]+i*2,array.get(dizi,i*2+1),
// color=array.get(dizi,i*2+1)>=array.get(dizi,i*2)? #35cf02 : #cf0202, width=width))
array.push(line, line.new(na, na, na, na))
line.set_xy1(array.get(line,i), bar_index[len]+i*2-1, array.get(dizi,i*2))
line.set_xy2(array.get(line,i), bar_index[len]+i*2, array.get(dizi,i*2+1))
line.set_color(array.get(line,i),array.get(dizi,i*2+1)>=array.get(dizi,i*2)? c1 : c2)
line.set_width(array.get(line,i),width)
dizii = array.new_float(1000)
for i=0 to len*2
array.set(dizii,i,(i*(i-1)*(cr-2*cr[1]+cr[2])/2+i*(cr[1]-cr[2])+cr[2]))
r=ta.stdev(close,len*10)
mid=cr(src,10*len-1)
bot=cr(src,5*len-1)-r
top=cr(src,5*len-1)+r
buy=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0
sell=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0
ttk=buy? 1 : sell?-1 : 0
sbuy=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0 and ta.highest(ttk,len)[1]!=1 and ta.lowest(ttk,math.round(len/2))[1]!=-1 and close<bot
ssell=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0 and ta.lowest(ttk,len)[1]!=-1 and ta.highest(ttk,math.round(len/2))[1]!=1 and close>top
plotshape(sbuy, title = "buy", text = "strong buy", style = shape.labelup, location = location.belowbar, color = c1, textcolor = t1, size = size.small)
plotshape(ssell, title = "sell", text ="strong sell", style = shape.labeldown, location = location.abovebar, color = c2, textcolor = t1, size = size.small)
buy:=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0 and ta.highest(ttk,len)[1]!=1 and ta.lowest(ttk,math.round(len/2))[1]!=-1 and close>bot and close<top
sell:=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0 and ta.lowest(ttk,len)[1]!=-1 and ta.highest(ttk,math.round(len/2))[1]!=1 and close<top and close>bot
plotshape(buy, title = "buy", text = "buy", style = shape.labelup, location = location.belowbar, color = c1, textcolor = t1, size = size.small)
plotshape(sell, title = "sell", text ="sell", style = shape.labeldown, location = location.abovebar, color = c2, textcolor = t1, size = size.small)
alertbuy=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0 and ta.highest(ttk,len)[1]!=1 and ta.lowest(ttk,math.round(len/2))[1]!=-1 and close<top
alertsell=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0 and ta.lowest(ttk,len)[1]!=-1 and ta.highest(ttk,math.round(len/2))[1]!=1 and close>bot
alertcondition(alertbuy or alertsell)
int botsignal= (buy or sbuy)? 1 : (ssell or sell)? -1 : na
plot(botsignal, display=display.none) |
ABGALGO | https://www.tradingview.com/script/H6Pcd4xM-ABGALGO/ | abggamer | https://www.tradingview.com/u/abggamer/ | 13 | 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/
// © abggamer
//@version=5
indicator("oke", overlay=true, precision=0, explicit_plot_zorder=true, max_labels_count=500)
yah = input.bool(false, "yes", group='yes')
plot(close)
|
Intraday Accumulator [close-open] | https://www.tradingview.com/script/3452eEam-Intraday-Accumulator-close-open/ | barnabygraham | https://www.tradingview.com/u/barnabygraham/ | 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/
// © barnabygraham
//@version=5
indicator("Intraday Accumulator [close-open]",overlay=true,scale=scale.none)
var x = 0.
if barstate.isfirst
x := close
x := x + (close-open)
plot(x,'Out',color=color.orange) |
Samurai Beta | https://www.tradingview.com/script/7pPtERo6-Samurai-Beta/ | leo07lee | https://www.tradingview.com/u/leo07lee/ | 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/
// © leo07lee
//@version=5
indicator("Samurai",overlay=true)
//CrossOver
fast = 50
slow = 200
fastMA = ta.ema(close, fast)
slowMA = ta.ema(close, slow)
plot(fastMA, color = color.green)
plot(slowMA, color = color.red)
plotshape(ta.crossover(fastMA, slowMA) ? slowMA : na, style=shape.triangleup,size=size.small,color=color.green,textcolor=color.green, text="LONG",location=location.absolute )
plotshape(ta.crossover(slowMA,fastMA) ? fastMA : na, style=shape.triangledown,size=size.small,color=color.red, textcolor=color.red,text="SHORT",location=location.absolute)
|
Round Numbers | https://www.tradingview.com/script/9VnMC30a-Round-Numbers/ | jdotcee | https://www.tradingview.com/u/jdotcee/ | 55 | 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/
// © jacasanare
// This is a variation of "Round numbers above and below" indicator by BitcoinJesus-Not-Roger-Ver
//@version=4
study("Round Numbers", overlay=true)
//1st set of lines
var number_of_lines_1 = input(5, title="Number of Lines 1", type=input.integer)
var range_size_1 = input(100, title="Range Size 1", type=input.integer)
var step1 = syminfo.mintick*range_size_1
if barstate.islast
//label.new(bar_index, low, text=syminfo.type, yloc=yloc.abovebar)
for counter1 = 0 to number_of_lines_1 - 1
stepUp1 = ceil(close / step1) * step1 + (counter1 * step1)
line.new(bar_index, stepUp1, bar_index - 1, stepUp1, xloc=xloc.bar_index, extend=extend.both, color=color.purple, width=1, style=line.style_dashed)
stepDown1 = floor(close / step1) * step1 - (counter1 * step1)
line.new(bar_index, stepDown1, bar_index - 1, stepDown1, xloc=xloc.bar_index, extend=extend.both, color=color.purple, width=1, style=line.style_dashed)
//2nd set of lines
var number_of_lines_2 = input(2, title="Number of Lines 2", type=input.integer)
var range_size_2 = input(500, title="Range Size 2", type=input.integer)
var step2 = syminfo.mintick*range_size_2
if barstate.islast
//label.new(bar_index, low, text=syminfo.type, yloc=yloc.abovebar)
for counter2 = 0 to number_of_lines_2 - 1
stepUp2 = ceil(close / step2) * step2 + (counter2 * step2)
line.new(bar_index, stepUp2, bar_index - 1, stepUp2, xloc=xloc.bar_index, extend=extend.both, color=color.green, width=1, style=line.style_solid)
stepDown2 = floor(close / step2) * step2 - (counter2 * step2)
line.new(bar_index, stepDown2, bar_index - 1, stepDown2, xloc=xloc.bar_index, extend=extend.both, color=color.green, width=1, style=line.style_solid)
|
Trend Change | https://www.tradingview.com/script/zsKAGPlT-Trend-Change/ | ajayvarma00047 | https://www.tradingview.com/u/ajayvarma00047/ | 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/
// © ajayvarma00047
//@version=5
indicator("Trend Change", overlay=true)
body = close[0] - open[0]
bodyPrev = close[1] - open[1]
bodyAbs = body < 0 ? body *-1 : body
bodyPrevAbs = bodyPrev < 0 ? bodyPrev *-1 : bodyPrev
avgVolumeLast5 = ta.sma(volume, 5)
longSignal = (volume[0] > avgVolumeLast5 * 2) and ta.falling(open,3)
//or (body > 0 and body < 10 and volume[0] > volume[1] * 3)
shortSignal = (volume[0] > avgVolumeLast5 * 2) and ta.rising(close,3)
plotshape(longSignal, "Long", shape.triangleup, location.abovebar, color=color.green, size=size.tiny)
plotshape(shortSignal, "Short", shape.triangledown, location.belowbar, color=color.red, size=size.tiny)
LineLengthMult = close / 20000
LineLength = 50 * LineLengthMult
drawVerticalLine(offset, lineColor) =>
line.new(bar_index[offset], low-LineLength, bar_index[offset], high+LineLength, color=color.new(lineColor, 50), width=3)
if shortSignal
drawVerticalLine(0, color.red)
else if longSignal
drawVerticalLine(0, color.green)
//plot(longSignal, color=color.green)
//plot(shortSignal, color=color.red)
//plot(avgVolumeLast5)
//hlcVwap = ta.vwap(hlc3)
//plot(hlcVwap,"vwap")
//plotarrow(body, colorup = color.teal, colordown = color.orange, minheight=7, maxheight=7)
|
HTC_Bollinger_Band_Strategy_By_Corbacho | https://www.tradingview.com/script/MWIiIhyp/ | mrcorbacho | https://www.tradingview.com/u/mrcorbacho/ | 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/
// © mrcorbachofit
//@version=4
study("HTC_Bollinger_Band_Strategy_By_Corbacho", overlay=true)
//prueba de switch
//b = input(title="On/Off", type=input.bool, defval=true)
//plot(b ? open : na)
//Definición colores
green = #33FF33, blue = #33FFF3, red = #FF3333, purple = #B233FF
///////////////////////////////
// ENTRADAS DE DATOS //
///////////////////////////////
//Entradas de datos
//SMAs
sma_1 = input(200, title= "SMA_1", type=input.integer)
//sma_2 = input(100, title= "SMA_2", type=input.integer)
//sma_3 = input(50, title= "SMA_3", type=input.integer)
//Bollinger
longitud = input(20, title="Longitud BB", type=input.integer)
mult = input(3.0, title="Multiplicador BB", type=input.float, step=0.2)
fuente = input(close, title="Fuente BB", type=input.source)
pintar_sma = input (true, title="Pintar SMA")
pintar_bb = input (true, title="Pintar BB")
///////////////////////////////
// CALCULOS //
///////////////////////////////
//Calculo EMAs
sma_1_calc = sma(close, sma_1)
//sma_2_calc = sma(close, sma_2)
//sma_3_calc = sma(close, sma_3)
//Calculo BB
[mm, banda_superior, banda_inferior] = bb(fuente, longitud, mult)
///////////////////////////////
// REPRESENTACIONES GRAFICAS //
///////////////////////////////
//Dibujo en gráfico de las 3 SMA
plot(pintar_sma ? sma_1_calc : na, color=green, linewidth=4, title='SMA 200')
//plot(pintar_sma ? mid : na, color=blue, linewidth=3, title='EMA Media')
//plot(pintar_sma ? long : na, color=red, linewidth=3, title='EMA Larga')
//plot(pintar_sma ? weighted : na, color=purple, linewidth=3, title='WMA Larga')
//Dibujo en gráfico de Bollinger
plot(pintar_bb ? banda_superior : na, color=color.blue, title='Bollinger superior')
plot(pintar_bb ? mm : na, color=color.white, title='Bollinger media')
plot(pintar_bb ? banda_inferior : na, color=color.blue, title='Bollinger inferior')
//ps = plot(banda_superior, color=color.yellow, title='Bollinger superior')
//plot(mm, color=color.white, title='Bollinger media')
//pi = plot(banda_inferior, color=color.yellow, title='Bollinger inferior')
//fill(ps,pi, color=color.yellow, transp=90)
|
MyBalance | https://www.tradingview.com/script/rCfg0fYp-MyBalance/ | csmottola71 | https://www.tradingview.com/u/csmottola71/ | 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/
// © csmottola71
//@version=4
study("MyBalance", overlay=false)
period=input(title="Period", type=input.integer, defval=10)
vbd = input(title="Show Volume Bars Back", type=input.integer, defval=3, tooltip="Plot volume histograms back 0=all")
totVol = sum(volume,period)
upVol = close>open ? sum(volume,period) : na
dnVol = close<open ? sum(volume,period) : na
difVol = upVol-dnVol
pVol = (difVol/totVol)*100
plot(upVol/period)
plot(dnVol/period,color=color.red)
plot(volume, show_last=vbd, color=color.yellow, style=plot.style_histogram)
//plot(difVol) |
Yearly Monthly Vertical Lines [MsF] | https://www.tradingview.com/script/t0NM4QnZ/ | Trader_Morry | https://www.tradingview.com/u/Trader_Morry/ | 128 | 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/
// © Trader_Morry
//@version=5
////////
// Title
indicator(title='Vertical & Open Lines - Yearly Monthly Weekly Daily [MsF]', shorttitle='YMWD V&O Lines', overlay=true, max_lines_count=500, max_labels_count=500)
////////
// Input values
// [
iBaseTime = input.time(defval=timestamp('01 Jan 2018 0:00 +0000'), title='Base Time')
yearlyColor = input.color(defval=color.red, title='', inline='year')
iYearly = input.bool(true, title='Show Yearly', inline='year')
hyearlyColor = input.color(defval=color.red, title='', inline='year')
ihYearly = input.bool(false, title='Open Line', inline='year')
monthlyColor = input.color(defval=color.orange, title='', inline='month')
iMonthly = input.bool(true, title='Show Monthly', inline='month')
hmonthlyColor = input.color(defval=color.orange, title='', inline='month')
ihMonthly = input.bool(false, title='Open Line', inline='month')
dailyColor = input.color(defval=color.yellow, title='', inline='day')
iDaily = input.bool(false, title='Show Daily', inline='day')
hdailyColor = input.color(defval=color.yellow, title='', inline='day')
ihDaily = input.bool(false, title='Open Line', inline='day')
weeklyColor = input.color(defval=color.lime, title='', inline='week')
iWeekly = input.bool(false, title='Show Weekly', inline='week')
hweeklyColor = input.color(defval=color.lime, title='', inline='week')
ihWeekly = input.bool(false, title='Open Line', inline='week')
iSelectWeek = input.string(title="Select Week", defval="MON", options=["MON","TUE","WED","THU","FRI","SAT","SUN"])
lineStyle = input.string(title='Vertical Line Style', defval=line.style_dashed, options=[line.style_dotted, line.style_dashed, line.style_solid])
hLineStyle = input.string(title='Horizontal Line Style', defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid])
// ]
////////
// Preparing
// [
[yearlyTime, yearlyOpen] = request.security(syminfo.tickerid, '12M', [time, open], lookahead=barmerge.lookahead_on)
[monthlyTime, monthlyOpen] = request.security(syminfo.tickerid, 'M', [time, open], lookahead=barmerge.lookahead_on)
[dailyTime, dailyOpen] = request.security(syminfo.tickerid, 'D', [time, open], lookahead=barmerge.lookahead_on)
[weeklyTime, weeklyOpen] = request.security(syminfo.tickerid, 'W', [time, open], lookahead=barmerge.lookahead_on)
// ]
////////
// Making
// [
var line hLine_yearly = na
var label hlabel_yearly = na
if iYearly
var iDrawTimeY_= 0
yy = year
mm = month(iBaseTime)
dd = dayofmonth(iBaseTime)
hh = hour(iBaseTime)
m2 = minute(iBaseTime)
iDrawTime = timestamp(yy, mm, dd, hh, m2)
// double drawing prevention
if iDrawTime != iDrawTimeY_ and iDrawTime < timenow
// Horizontal
if ihYearly
line.new(iDrawTimeY_, yearlyOpen, iDrawTime, yearlyOpen, xloc=xloc.bar_time, style=hLineStyle, extend=extend.none, color=hyearlyColor, width=1)
// Vertical
line.new(iDrawTime, yearlyOpen, iDrawTime, yearlyOpen + syminfo.mintick, xloc=xloc.bar_time, style=lineStyle, extend=extend.both, color=yearlyColor, width=1)
iDrawTimeY_ := iDrawTime
if ihYearly
line.delete(hLine_yearly)
label.delete(hlabel_yearly)
hLine_yearly := line.new(iDrawTimeY_, yearlyOpen, last_bar_time, yearlyOpen, xloc=xloc.bar_time, style=hLineStyle, extend=extend.right, color=hyearlyColor, width=1)
hlabel_yearly := label.new(last_bar_index+50, yearlyOpen, "Yearly Open", xloc=xloc.bar_index, color=color.rgb(255,255,255,100), style=label.style_label_down, textcolor=hyearlyColor, size=size.normal)
var line hLine_monthly = na
var label hlabel_monthly = na
if iMonthly
var iDrawTimeM_= 0
yy = year
mm = month
dd = dayofmonth(iBaseTime)
hh = hour(iBaseTime)
m2 = minute(iBaseTime)
iDrawTime = timestamp(yy, mm, dd, hh, m2)
// double drawing prevention
if iDrawTime != iDrawTimeM_ and iDrawTime < timenow
// Horizontal
if ihMonthly
line.new(iDrawTimeM_, monthlyOpen, iDrawTime, monthlyOpen, xloc=xloc.bar_time, style=hLineStyle, extend=extend.none, color=hmonthlyColor, width=1)
// Vertical
line.new(iDrawTime, monthlyOpen, iDrawTime, monthlyOpen + syminfo.mintick, xloc=xloc.bar_time, style=lineStyle, extend=extend.both, color=monthlyColor, width=1)
iDrawTimeM_ := iDrawTime
if ihMonthly
line.delete(hLine_monthly)
label.delete(hlabel_monthly)
hLine_monthly := line.new(iDrawTimeM_, monthlyOpen, last_bar_time, monthlyOpen, xloc=xloc.bar_time, style=hLineStyle, extend=extend.right, color=hmonthlyColor, width=1)
hlabel_monthly := label.new(last_bar_index+50, monthlyOpen, "Monthly Open", xloc=xloc.bar_index, color=color.rgb(255,255,255,100), style=label.style_label_down, textcolor=hmonthlyColor, size=size.normal)
var line hLine_daily = na
var label hlabel_daily = na
// flag for plotshape()
iDspWeekOnDaily=false
if iDaily
// H4を超える時間足は出力しない
if timeframe.in_seconds(timeframe.period) <= 14400
var iDrawTimeD_= 0
var iOpenD_ = 0.0
yy = year
mm = month
dd = dayofmonth
hh = hour(iBaseTime)
m2 = minute(iBaseTime)
iDrawTime = timestamp(yy, mm, dd, hh, m2)
hour_j = hour(iDrawTime, "GMT+9")
dayofweek_j = dayofweek(iDrawTime, "GMT+9")
iDsp = true
if dayofweek_j == dayofweek.saturday and hour_j >= 6
iDsp := false
else if dayofweek_j == dayofweek.sunday
iDsp := false
else if dayofweek_j == dayofweek.monday and hour_j < 7
iDsp := false
if syminfo.type == "crypto"
iDsp := true
// double drawing prevention
if iDrawTime != iDrawTimeD_ and iDsp and iDrawTime < timenow
// Horizontal
if ihDaily
line.new(iDrawTimeD_, iOpenD_, iDrawTime, iOpenD_, xloc=xloc.bar_time, style=hLineStyle, extend=extend.none, color=hdailyColor, width=1)
// Vertical
line.new(iDrawTime, dailyOpen, iDrawTime, dailyOpen + syminfo.mintick, xloc=xloc.bar_time, style=lineStyle, extend=extend.both, color=dailyColor, width=1)
iDspWeekOnDaily:=true
iDrawTimeD_ := iDrawTime
iOpenD_ := dailyOpen
if ihDaily
line.delete(hLine_daily)
label.delete(hlabel_daily)
hLine_daily := line.new(iDrawTimeD_, dailyOpen, last_bar_time, dailyOpen, xloc=xloc.bar_time, style=hLineStyle, extend=extend.right, color=hdailyColor, width=1)
hlabel_daily := label.new(last_bar_index+50, dailyOpen, "Daily Open", xloc=xloc.bar_index, color=color.rgb(255,255,255,100), style=label.style_label_down, textcolor=hdailyColor, size=size.normal)
// Draw a vertical line to display the day of the week below the chart
plotshape(iDspWeekOnDaily and dayofweek==dayofweek.monday, offset=0, style=shape.diamond, text="MON" , color=color.lime , location = location.bottom, textcolor=color.lime )
plotshape(iDspWeekOnDaily and dayofweek==dayofweek.tuesday, offset=0, style=shape.diamond, text="TUE" , color=color.red , location = location.bottom, textcolor=color.red )
plotshape(iDspWeekOnDaily and dayofweek==dayofweek.wednesday, offset=0, style=shape.diamond, text="WED" , color=color.aqua , location = location.bottom, textcolor=color.aqua )
plotshape(iDspWeekOnDaily and dayofweek==dayofweek.thursday, offset=0, style=shape.diamond, text="THU" , color=color.yellow, location = location.bottom, textcolor=color.yellow)
plotshape(iDspWeekOnDaily and dayofweek==dayofweek.friday, offset=0, style=shape.diamond, text="FRI" , color=color.orange, location = location.bottom, textcolor=color.orange)
plotshape(iDspWeekOnDaily and dayofweek==dayofweek.saturday, offset=0, style=shape.diamond, text="SAT" , color=color.gray , location = location.bottom, textcolor=color.gray )
plotshape(iDspWeekOnDaily and dayofweek==dayofweek.sunday, offset=0, style=shape.diamond, text="SUN" , color=color.gray , location = location.bottom, textcolor=color.gray )
var line hLine_weekly = na
var label hlabel_weekly = na
if iWeekly
// Convert day of week to number
iDayofweek=iSelectWeek=="SUN"?0:iSelectWeek=="MON"?1:iSelectWeek=="TUE"?2:iSelectWeek=="WED"?3:iSelectWeek=="THU"?4:iSelectWeek=="FRI"?5:iSelectWeek=="SAT"?6:1
// Selected day of week?
if dayofweek==iDayofweek and ta.change(dayofweek)
var iDrawTimeW_ = 0
yy = year
mm = month
dd = dayofmonth
hh = hour(iBaseTime)
m2 = minute(iBaseTime)
iDrawTime = timestamp(yy, mm, dd, hh, m2)
if iDrawTime != iDrawTimeW_ and iDrawTime < timenow
// Horizontal
if ihWeekly
line.new(iDrawTimeW_, weeklyOpen[1], iDrawTime, weeklyOpen[1], xloc=xloc.bar_time, style=hLineStyle, extend=extend.none, color=hweeklyColor, width=1)
// Vertical
line.new(iDrawTime, weeklyOpen, iDrawTime, weeklyOpen + syminfo.mintick, xloc=xloc.bar_time, style=lineStyle, extend=extend.both, color=weeklyColor, width=1)
iDrawTimeW_ := iDrawTime
if ihWeekly
line.delete(hLine_weekly)
label.delete(hlabel_weekly)
// hLine_weekly := line.new(iDrawTimeW_, weeklyOpen, last_bar_time, weeklyOpen, xloc=xloc.bar_time, style=hLineStyle, extend=extend.right, color=hweeklyColor, width=1)
if ta.change(weekofyear)
hLine_weekly := line.new(na, na, na, na, style=hLineStyle, extend=extend.right, color=hweeklyColor, width=1)
line.set_xy1(hLine_weekly, bar_index[1], open)
line.set_xy2(hLine_weekly, bar_index, open)
hlabel_weekly := label.new(last_bar_index+50, weeklyOpen, "Weekly Open", xloc=xloc.bar_index, color=color.rgb(255,255,255,100), style=label.style_label_down, textcolor=hweeklyColor, size=size.normal)
// ]
|
Price based ATR% | https://www.tradingview.com/script/XPNoznnc-Price-based-ATR/ | carlpwilliams2 | https://www.tradingview.com/u/carlpwilliams2/ | 9 | 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/
// © carlpwilliams2
//@version=5
indicator("Price based ATR%", overlay=true)
priceAdditionModifier = input.float(1.5, title="Modifier", tooltip="Price Addition Modifier i.e 1.5 * ATR", minval=-0.01, group="Upper ATR Line (Added line)")
priceSubtractModifier = input.float(1, title="Modifier", tooltip="Price Subtraction Modifier i.e 1 * ATR", minval=-0.01, group="Lower ATR Line (Subtracted line)")
additionSource = input.source(close,title="Source for addition atr", group="Upper ATR Line (Added line)")
subtractSource = input.source(close,title="Source for subtract atr", group="Lower ATR Line (Subtracted line)")
upperATRLength = input.int(14,title="Length", group="Upper ATR Line (Added line)")
LowerATRLength = input.int(14,title="Length", group="Lower ATR Line (Subtracted line)")
upperATR = ta.atr(upperATRLength)
lowerATR = ta.atr(upperATRLength)
pricePlusATR = additionSource + ( (additionSource/100) * (upperATR * priceAdditionModifier))
priceSubtractATR = subtractSource - ( (subtractSource/100) * (lowerATR * priceSubtractModifier))
plot(pricePlusATR, color=color.white)
plot(priceSubtractATR, color=color.white)
|
Currency Strength by Bollinger Bands | https://www.tradingview.com/script/PAS39uYu/ | dairin | https://www.tradingview.com/u/dairin/ | 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/
// © dairin(V1.00)
//@version=5
indicator(shorttitle = "BB_POWERS", title = "Currency Strength by Bollinger Bands", overlay = true)
//--------------------------------------------------------------------------
// Input parameter
//--------------------------------------------------------------------------
// 表示通貨
var GRP_SYM = "表示通貨"
bo_USD = input.bool(title="USD", defval = true, inline = '01', group = GRP_SYM)
bo_EUR = input.bool(title="EUR", defval = true, inline = '01', group = GRP_SYM)
bo_JPY = input.bool(title="JPY", defval = true, inline = '01', group = GRP_SYM)
bo_GBP = input.bool(title="GBP", defval = true, inline = '01', group = GRP_SYM)
bo_AUD = input.bool(title="AUD", defval = true, inline = '01', group = GRP_SYM)
bo_NZD = input.bool(title="NZD", defval = true, inline = '01', group = GRP_SYM)
bo_CAD = input.bool(title="CAD", defval = true, inline = '02', group = GRP_SYM)
bo_CHF = input.bool(title="CHF", defval = true, inline = '02', group = GRP_SYM)
bo_XAU = input.bool(title="XAU", defval = true, inline = '02', group = GRP_SYM)
var GRP_BB = 'ボリンジャーバンドの設定'
length = input.int(defval = 20, minval = 1, group = GRP_BB)
var GRP_WIN_COND = '勝敗の基準'
win_cond = input.string(title='基準', options = ['MAより上で勝利(下で敗退)', '+1σより上で勝利(下で敗退)', '+2σより上で勝利(下で敗退)'],defval = '+1σより上で勝利(下で敗退)', group = GRP_WIN_COND)
// 表示通貨
var GRP_BAR = "対象バーの設定"
bb_power_index = input.int(title="インデックス", defval = 0, group = GRP_BAR)
bo_line = input.bool(title="対象バーに垂直線を表示", defval = false, group = GRP_BAR)
bb_power_line_color = input.color(title="色", defval = color.red, inline = '11', group = GRP_BAR)
bb_power_line_style = input.string(title="線種", options = ['solid', 'dotted', 'dashed'],defval = 'dotted',inline = '11', group = GRP_BAR)
bb_power_line_width = input.int(title="太さ", defval = 2, inline = '11', group = GRP_BAR)
//=== 表の設定 ===
var GRP_LIST = "表の設定"
// 表示位置
list_pos = input.string(title="表示位置", options = ['top_left','top_center','top_right', 'middle_left', 'middle_center','middle_right', 'bottom_left','bottom_center','bottom_right'], defval = "bottom_left", group = GRP_LIST)
// 表のセルの境界線(外枠以外)の色
border_color = input.color(title="境界線の色", defval = color.black, inline = '21',group = GRP_LIST)
// 表のセルの境界線(外枠以外)の幅
border_width = input.int(title="太さ", defval = 1, inline = '21', group = GRP_LIST)
// 表の外枠の色
frame_color = input.color(title="外枠の色 ", defval = color.black, inline = '22', group = GRP_LIST)
// 表の外枠の幅
frame_width = input.int(title="太さ", defval = 1, inline = '22', group = GRP_LIST)
//=== セルのヘッダー設定 ===
var GRP_CEL = 'セルの設定'
// 文字色
head_text_color = input.color(title="ヘッダ 色", defval = color.white, inline = '33', group = GRP_CEL)
// 背景色
head_background_color = input.color(title="背景色", defval = color.gray, inline = '33', group = GRP_CEL)
// 文字のサイズ
head_text_size = input.string(title="文字サイズ", options = ['auto', 'tiny', 'small', 'normal', 'large', 'huge'],defval = 'auto', inline = '33', group = GRP_CEL)
//=== セルのヘッダー以外の設定 ===
// 文字色
text_color = input.color(title="データ 色", defval = color.black, inline = '34', group = GRP_CEL)
// 背景色
background_color = input.color(title="背景色", defval = color.white, inline = '34', group = GRP_CEL)
// 文字のサイズ
text_size = input.string(title="文字サイズ", options = ['auto', 'tiny', 'small', 'normal', 'large', 'huge'],defval = 'auto', inline = '34', group = GRP_CEL)
//--------------------------------------------------------------------------
// Global parameter
//--------------------------------------------------------------------------
var string win_mark = '○'
var string loss_mark = '●'
var int cel_width = 0
var int cel_height = 0
var color invalid_sym = color.gray
var int BB_EURUSD_IDX = 0
var int BB_USDJPY_IDX = 1
var int BB_GBPUSD_IDX = 2
var int BB_AUDUSD_IDX = 3
var int BB_NZDUSD_IDX = 4
var int BB_USDCAD_IDX = 5
var int BB_USDCHF_IDX = 6
var int BB_EURJPY_IDX = 7
var int BB_EURGBP_IDX = 8
var int BB_EURAUD_IDX = 9
var int BB_EURNZD_IDX = 10
var int BB_EURCAD_IDX = 11
var int BB_EURCHF_IDX = 12
var int BB_GBPJPY_IDX = 13
var int BB_AUDJPY_IDX = 14
var int BB_NZDJPY_IDX = 15
var int BB_CADJPY_IDX = 16
var int BB_CHFJPY_IDX = 17
var int BB_GBPAUD_IDX = 18
var int BB_GBPNZD_IDX = 19
var int BB_GBPCAD_IDX = 20
var int BB_GBPCHF_IDX = 21
var int BB_AUDNZD_IDX = 22
var int BB_AUDCAD_IDX = 23
var int BB_AUDCHF_IDX = 24
var int BB_NZDCAD_IDX = 25
var int BB_NZDCHF_IDX = 26
var int BB_CADCHF_IDX = 27
var int BB_XAUUSD_IDX = 28
var int BB_XAUEUR_IDX = 29
var int BB_XAUJPY_IDX = 30
var int BB_XAUGBP_IDX = 31
var int BB_XAUAUD_IDX = 32
var int BB_XAUNZD_IDX = 33
var int BB_XAUCAD_IDX = 34
var int BB_XAUCHF_IDX = 35
var int BB_IDX_MAX = BB_XAUCHF_IDX + 1
//--------------------------------------------------------------------------
// 指定レートがボリバンのどの位置にあるかを取得する
// price 指定レート
// ma_price MAの値
// dev_price 標準偏差値
// 復帰値(int)
// 0 = +3σより上
// 1 = +3a ~ +2σの間
// 2 = +2a ~ +1σの間
// 3 = +1σ ~ middleの間
// 4 = middleb ~ -1aの間
// 5 = -1σ ~ -2aの間
// 6 = -2σ ~ -3aの間
// 7 = -3σより下
//--------------------------------------------------------------------------
get_bb_rate(price, ma_price, dev_price) =>
ret = 0
plus3a = ma_price + dev_price * 3
plus2a = ma_price + dev_price * 2
plus1a = ma_price + dev_price * 1
middle = ma_price
minus1a = ma_price - dev_price * 1
minus2a = ma_price - dev_price * 2
minus3a = ma_price - dev_price * 3
if (price > plus3a)
ret := 0
else if price <= plus3a and price >= plus2a
ret := 1
else if price <= plus2a and price >= plus1a
ret := 2
else if price <= plus1a and price >= middle
ret := 3
else if price <= middle and price >= minus1a
ret := 4
else if price <= minus1a and price >= minus2a
ret := 5
else if price <= minus2a and price >= minus3a
ret := 6
else
ret := 7
//--------------------------------------------------------------------------
// 指定した時間足は現在チャートの時間足よりしたかどうかをチェックする
//--------------------------------------------------------------------------
is_lower_time_frame(time_frame) =>
cur_time = timeframe.in_seconds(timeframe.period)
target_time = timeframe.in_seconds(time_frame)
if (target_time < cur_time)
true
else
false
//--------------------------------------------------------------------------
// ボリバン位置を取得
//--------------------------------------------------------------------------
get_bb_rate_sym(sym) =>
ma = ta.sma(close[bb_power_index], 20)
dev = ta.stdev(close[bb_power_index] ,20)
[ma_price, dev_price, price] = request.security(sym, timeframe.period, [ma, dev, close[bb_power_index]], barmerge.gaps_off, barmerge.lookahead_on)
ret_val = get_bb_rate(price, ma_price, dev_price)
//--------------------------------------------------------------------------
// 表のポジションを取得
//--------------------------------------------------------------------------
get_list_pos(pos) =>
switch pos
'top_left' => position.top_left
'top_center' => position.top_center
'top_right' => position.top_right
'middle_left' => position.middle_left
'middle_center' => position.middle_center
'middle_right' => position.middle_right
'bottom_left' => position.bottom_left
'bottom_center' => position.bottom_center
'bottom_right' => position.bottom_right
=> position.bottom_left
//--------------------------------------------------------------------------
// 表のポジションを取得
//--------------------------------------------------------------------------
get_text_size(text_sizepos) =>
switch text_sizepos
'auto' => size.auto
'tiny' => size.tiny
'small' => size.small
'normal' => size.normal
'large' => size.large
'huge' => size.huge
=> size.auto
//--------------------------------------------------------------------------
// 表のポジションを取得
//--------------------------------------------------------------------------
get_line_style(line_style) =>
switch line_style
"solid" => line.style_solid
"dotted" => line.style_dotted
"dashed" => line.style_dashed
=> line.style_solid
//--------------------------------------------------------------------------
// 勝利条件の取得
//--------------------------------------------------------------------------
get_victory_condition_type(vic_cond) =>
switch vic_cond
'MAより上で勝利(下で敗退)' => 1
'+1σより上で勝利(下で敗退)' => 2
'+2σより上で勝利(下で敗退)' => 3
=> 2
//--------------------------------------------------------------------------
// シンボル数取得
//--------------------------------------------------------------------------
get_sym_count() =>
sym_count = 0
sym_count := sym_count + ((bo_USD) ? 1 : 0)
sym_count := sym_count + ((bo_EUR) ? 1 : 0)
sym_count := sym_count + ((bo_JPY) ? 1 : 0)
sym_count := sym_count + ((bo_GBP) ? 1 : 0)
sym_count := sym_count + ((bo_AUD) ? 1 : 0)
sym_count := sym_count + ((bo_NZD) ? 1 : 0)
sym_count := sym_count + ((bo_CAD) ? 1 : 0)
sym_count := sym_count + ((bo_CHF) ? 1 : 0)
sym_count := sym_count + ((bo_XAU) ? 1 : 0)
var string BB_WIN_MARK = '○'
//--------------------------------------------------------------------------
// 勝敗取得
//--------------------------------------------------------------------------
get_bb_power(bb_rate, bo_front) =>
string ret_mark = ''
win_cond_type = get_victory_condition_type(win_cond)
// draw = 0, win = 1, loss = 2
ret = switch win_cond_type
1 => ( bb_rate <= 3 ? 1 : (bb_rate >= 4 ? 2 : 0) )
2 => ( bb_rate <= 2 ? 1 : (bb_rate >= 5 ? 2 : 0) )
3 => ( bb_rate <= 1 ? 1 : (bb_rate >= 6 ? 2 : 0) )
=> 0
if (bo_front)
ret_mark := ( ret == 1 ? win_mark : (ret == 2 ? loss_mark : '') )
else
ret_mark := ( ret == 1 ? loss_mark : (ret == 2 ? win_mark : '') )
//--------------------------------------------------------------------------
// ヘッダー領域に項目追加
//--------------------------------------------------------------------------
set_bb_power_head(table_id, col, row, cel_text) =>
table.cell(table_id, column = col, row = row, text = cel_text, width = cel_width, height = cel_height, text_color = head_text_color, bgcolor = head_background_color, text_size = get_text_size(head_text_size))
//--------------------------------------------------------------------------
// データ領域に項目追加
//--------------------------------------------------------------------------
set_bb_power_item(table_id, col, row, cel_text) =>
if (cel_text == '-')
table.cell(table_id, column = col, row = row, text = cel_text, width = cel_width, height = cel_height, text_color = text_color, bgcolor = invalid_sym, text_size = get_text_size(text_size))
else
table.cell(table_id, column = col, row = row, text = cel_text, width = cel_width, height = cel_height, text_color = text_color, bgcolor = background_color, text_size = get_text_size(text_size))
//--------------------------------------------------------------------------
// メイン処理
//--------------------------------------------------------------------------
main() =>
// ボリンジャーバンド位置を取得
var bb_rate_list = array.new_int(BB_IDX_MAX, -1)
array.set(bb_rate_list, BB_EURUSD_IDX, get_bb_rate_sym('EURUSD'))
array.set(bb_rate_list, BB_USDJPY_IDX, get_bb_rate_sym('USDJPY'))
array.set(bb_rate_list, BB_GBPUSD_IDX, get_bb_rate_sym('GBPUSD'))
array.set(bb_rate_list, BB_AUDUSD_IDX, get_bb_rate_sym('AUDUSD'))
array.set(bb_rate_list, BB_NZDUSD_IDX, get_bb_rate_sym('NZDUSD'))
array.set(bb_rate_list, BB_USDCAD_IDX, get_bb_rate_sym('USDCAD'))
array.set(bb_rate_list, BB_USDCHF_IDX, get_bb_rate_sym('USDCHF'))
array.set(bb_rate_list, BB_EURJPY_IDX, get_bb_rate_sym('EURJPY'))
array.set(bb_rate_list, BB_EURGBP_IDX, get_bb_rate_sym('EURGBP'))
array.set(bb_rate_list, BB_EURAUD_IDX, get_bb_rate_sym('EURAUD'))
array.set(bb_rate_list, BB_EURNZD_IDX, get_bb_rate_sym('EURNZD'))
array.set(bb_rate_list, BB_EURCAD_IDX, get_bb_rate_sym('EURCAD'))
array.set(bb_rate_list, BB_EURCHF_IDX, get_bb_rate_sym('EURCHF'))
array.set(bb_rate_list, BB_GBPJPY_IDX, get_bb_rate_sym('GBPJPY'))
array.set(bb_rate_list, BB_AUDJPY_IDX, get_bb_rate_sym('AUDJPY'))
array.set(bb_rate_list, BB_NZDJPY_IDX, get_bb_rate_sym('NZDJPY'))
array.set(bb_rate_list, BB_CADJPY_IDX, get_bb_rate_sym('CADJPY'))
array.set(bb_rate_list, BB_CHFJPY_IDX, get_bb_rate_sym('CHFJPY'))
array.set(bb_rate_list, BB_GBPAUD_IDX, get_bb_rate_sym('GBPAUD'))
array.set(bb_rate_list, BB_GBPNZD_IDX, get_bb_rate_sym('GBPNZD'))
array.set(bb_rate_list, BB_GBPCAD_IDX, get_bb_rate_sym('GBPCAD'))
array.set(bb_rate_list, BB_GBPCHF_IDX, get_bb_rate_sym('GBPCHF'))
array.set(bb_rate_list, BB_AUDNZD_IDX, get_bb_rate_sym('AUDNZD'))
array.set(bb_rate_list, BB_AUDCAD_IDX, get_bb_rate_sym('AUDCAD'))
array.set(bb_rate_list, BB_AUDCHF_IDX, get_bb_rate_sym('AUDCHF'))
array.set(bb_rate_list, BB_NZDCAD_IDX, get_bb_rate_sym('NZDCAD'))
array.set(bb_rate_list, BB_NZDCHF_IDX, get_bb_rate_sym('NZDCHF'))
array.set(bb_rate_list, BB_CADCHF_IDX, get_bb_rate_sym('CADCHF'))
array.set(bb_rate_list, BB_XAUUSD_IDX, get_bb_rate_sym('XAUUSD'))
array.set(bb_rate_list, BB_XAUEUR_IDX, get_bb_rate_sym('XAUEUR'))
array.set(bb_rate_list, BB_XAUJPY_IDX, get_bb_rate_sym('XAUJPY'))
array.set(bb_rate_list, BB_XAUGBP_IDX, get_bb_rate_sym('XAUGBP'))
array.set(bb_rate_list, BB_XAUAUD_IDX, get_bb_rate_sym('XAUAUD'))
array.set(bb_rate_list, BB_XAUNZD_IDX, get_bb_rate_sym('XAUNZD'))
array.set(bb_rate_list, BB_XAUCAD_IDX, get_bb_rate_sym('XAUCAD'))
array.set(bb_rate_list, BB_XAUCHF_IDX, get_bb_rate_sym('XAUCHF'))
// テーブルヘッダ作成
var table_head = array.new_string(9, 'text')
array.set(table_head, 0, 'USD')
array.set(table_head, 1, 'EUR')
array.set(table_head, 2, 'JPY')
array.set(table_head, 3, 'GBP')
array.set(table_head, 4, 'AUD')
array.set(table_head, 5, 'NZD')
array.set(table_head, 6, 'CAD')
array.set(table_head, 7, 'CHF')
array.set(table_head, 8, 'XAU')
var bb_power_table = table.new(position = get_list_pos(list_pos), columns = 10, rows = 1 + get_sym_count(), border_color = border_color, border_width = border_width, frame_color = frame_color, frame_width = frame_width)
// Create header table
set_bb_power_head(bb_power_table, 0, 0, '')
for i = 0 to array.size(table_head) - 1
item = array.get(table_head, i)
set_bb_power_head(bb_power_table, i + 1, 0, item)
cell_row = 0
// === USD ===
if (bo_USD)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 0))
set_bb_power_item(bb_power_table, 1, cell_row, '-')
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURUSD_IDX), false))
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_USDJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPUSD_IDX), false))
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDUSD_IDX), false))
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDUSD_IDX), false))
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_USDCAD_IDX), true))
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_USDCHF_IDX), true))
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUUSD_IDX), false))
// === EUR ===
if (bo_EUR)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 1))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURUSD_IDX), true))
set_bb_power_item(bb_power_table, 2, cell_row, '-')
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURGBP_IDX), true))
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURAUD_IDX), true))
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURNZD_IDX), true))
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURCAD_IDX), true))
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURCHF_IDX), true))
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUEUR_IDX), false))
// === JPY ===
if (bo_JPY)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 2))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_USDJPY_IDX), false))
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURJPY_IDX), false))
set_bb_power_item(bb_power_table, 3, cell_row, '-')
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPJPY_IDX), false))
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDJPY_IDX), false))
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDJPY_IDX), false))
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_CADJPY_IDX), false))
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_CHFJPY_IDX), false))
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUJPY_IDX), false))
// === GBP ===
if (bo_GBP)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 3))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPUSD_IDX), true))
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURGBP_IDX), false))
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, '-')
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPAUD_IDX), true))
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPNZD_IDX), true))
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPCAD_IDX), true))
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPCHF_IDX), true))
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUGBP_IDX), false))
// === AUD ===
if (bo_AUD)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 4))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDUSD_IDX), true))
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURAUD_IDX), false))
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPAUD_IDX), false))
set_bb_power_item(bb_power_table, 5, cell_row, '-')
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDNZD_IDX), true))
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDCAD_IDX), true))
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDCHF_IDX), true))
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUAUD_IDX), false))
// === NZD ===
if (bo_NZD)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 5))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDUSD_IDX), true))
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURNZD_IDX), false))
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPNZD_IDX), false))
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDNZD_IDX), false))
set_bb_power_item(bb_power_table, 6, cell_row, '-')
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDCAD_IDX), true))
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDCHF_IDX), true))
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUNZD_IDX), false))
// === CAD ===
if (bo_CAD)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 6))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_USDCAD_IDX), false))
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURCAD_IDX), false))
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_CADJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPCAD_IDX), false))
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDCAD_IDX), false))
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDCAD_IDX), false))
set_bb_power_item(bb_power_table, 7, cell_row, '-')
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_CADCHF_IDX), true))
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUCAD_IDX), false))
// === CHF ===
if (bo_CHF)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 7))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_USDCHF_IDX), false))
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_EURCHF_IDX), false))
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_CHFJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_GBPCHF_IDX), false))
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_AUDCHF_IDX), false))
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_NZDCHF_IDX), false))
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_CADCHF_IDX), false))
set_bb_power_item(bb_power_table, 8, cell_row, '-')
set_bb_power_item(bb_power_table, 9, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUCHF_IDX), false))
// === XAU ===
if (bo_XAU)
cell_row := cell_row + 1
set_bb_power_head(bb_power_table, 0, cell_row, array.get(table_head, 8))
set_bb_power_item(bb_power_table, 1, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUUSD_IDX), true))
set_bb_power_item(bb_power_table, 2, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUEUR_IDX), true))
set_bb_power_item(bb_power_table, 3, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUJPY_IDX), true))
set_bb_power_item(bb_power_table, 4, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUGBP_IDX), true))
set_bb_power_item(bb_power_table, 5, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUAUD_IDX), true))
set_bb_power_item(bb_power_table, 6, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUNZD_IDX), true))
set_bb_power_item(bb_power_table, 7, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUCAD_IDX), true))
set_bb_power_item(bb_power_table, 8, cell_row, get_bb_power(array.get(bb_rate_list, BB_XAUCHF_IDX), true))
set_bb_power_item(bb_power_table, 9, cell_row, '-')
// 表示高速化のため、最後のバーのみ処理する。
// この対応により警告出るけど気にしない
if (barstate.islast == true) and (get_sym_count() > 0)
main()
// 対象ローソク足に水平線を描画。なぜかここでしか水平線作れなかった。
// 関数化しても駄目。
var line line_id = na
line.delete(line_id)
if (bo_line)
line_id := line.new(bar_index[bb_power_index], low, bar_index[bb_power_index], high, xloc.bar_index, extend.both, bb_power_line_color, get_line_style(bb_power_line_style), bb_power_line_width)
|
Multi TF Trend Indicator | https://www.tradingview.com/script/Bxg0g0ko-multi-tf-trend-indicator/ | beskrovnykh | https://www.tradingview.com/u/beskrovnykh/ | 54 | study | 5 | CC-BY-NC-SA-4.0 | // This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © andrew173139
//@version=5
indicator("Multi TF Trend Indicator", shorttitle="MTFT", overlay=true)
_pullData(src, rs, rep) =>
out = request.security(syminfo.tickerid, rs, src[rep ? 0 : barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)[rep ? 0 : barstate.isrealtime ? 0 : 1]
out
src = input.source(close, "Data source", group = "Multi TF")
tf = input.timeframe("5", "Multi TF resolution", group = "Multi TF")
rep = input.bool(false, "Allow repainting", group = "UI")
showTrendLine = input.bool(true, "Highlight trend line", group = "UI")
showTrendBack = input.bool(true, "Highlight background", group = "UI")
data = _pullData(src, tf, rep)
inc = _pullData(src >= src[1], tf, rep)
plot(data, "Plot Multi TF trend", color = showTrendLine ? inc ? color.green : color.red : na, linewidth = 3)
bgcolor(color = showTrendBack ? inc ? color.new(color.green, 80) : color.new(color.red, 80) : na)
goLong = inc and ta.change(inc)
goShort = not inc and ta.change(inc) |
SSTO for Efin | https://www.tradingview.com/script/tTDtynYE-SSTO-for-Efin/ | Krittapon | https://www.tradingview.com/u/Krittapon/ | 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/
// The author will not responsible for any loss or damage caused by using this script.
//@version=5
indicator(title='Cloud Stoch. with Tongkaw', shorttitle='CloudSto', format=format.price, precision=2, timeframe='')
groupsto = 'Stoch. Settings'
periodK = input.int(9, title='%K Period', minval=1, group = groupsto)
periodD = input.int(3, title='%D Period', minval=1, group = groupsto)
smoothK = input.int(3, title='Smooth Level', minval=1, group = groupsto)
oblevel = input.int(80, title='Overbought Level', minval=1, group = groupsto)
oslevel = input.int(20, title='Oversold Level', minval=1, group = groupsto)
//Stoch calculation
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)
//Fill Cloud Sto
pk = plot(k, title='%K', linewidth=1, color=color.new(color.blue, 20))
pd = plot(d, title='%D', linewidth=1, color=color.new(color.red, 20))
fill(pk, pd, color=k>=d ? color.new(color.blue, 20) : color.new(color.red, 20) , title='Stoch. Fill')
//Fill Band
h0 = hline(oblevel, 'Upper Band', color=#606060)
h1 = hline(oslevel, 'Lower Band', color=#606060)
fill(h0, h1, color=color.rgb(153, 21, 255, 90), title='Band Background')
//Tongkaw is alerts for your enjoyment.
alertcondition(ta.crossover(k, oblevel), title='Stoch Overbought', message='OB {{exchange}}:{{ticker}} TF[{{interval}}] Stoch in overbought')
alertcondition(ta.crossunder(k, oslevel), title='Stoch Oversold', message='OS {{exchange}}:{{ticker}} TF[{{interval}}] Stoch in oversold')
alertcondition(ta.cross(k,d), title="K cross D", message='X {{exchange}}:{{ticker}} TF[{{interval}}] %K crossed %D') |
Normalized Correlation Coefficient | https://www.tradingview.com/script/uN6WJVK8-Normalized-Correlation-Coefficient/ | LeafAlgo | https://www.tradingview.com/u/LeafAlgo/ | 81 | 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/
// © PlantFi
//@version=5
indicator(title='Normalized Correlation Coefficient', shorttitle='Norm. Co. Co.', format=format.price, precision=2, timeframe="", timeframe_gaps=true)
sym = input.symbol('Symbol', confirm=true)
src = input(ohlc4, title='Source')
len = input.int(40, minval=1, title="CoCo Length")
res=timeframe.period
ovr = request.security(sym, res, src)
coco = ta.correlation(src, ovr, len)
coco_h = ta.max(coco)
coco_l = ta.min(coco)
norm_coco = (coco - coco_l) / (coco_h - coco_l)
coco_Color = (norm_coco > 0.80) ? color.green : color.red
coco_plot = plot(norm_coco, color=coco_Color, style=plot.style_line, linewidth=3, title='CorCoef')
coco_th = plot(0.80, "CoCo Threshold", color=color.silver)
fill(coco_plot, coco_th, color=color.white, transp=40)
|
Pivot Average [Misu] | https://www.tradingview.com/script/Sct0ycvJ-Pivot-Average-Misu/ | Fontiramisu | https://www.tradingview.com/u/Fontiramisu/ | 264 | 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/
// Author : @Fontiramisu
// Indicator based pivot points to determine "Pivot Average".
// @version=5
indicator("Pivot Average [Misu]", shorttitle="AP [Misu]", overlay=true)
// import Fontiramisu/fontLib/80 as fontilab
import Fontiramisu/fontilab/8 as fontilab
// -------- Find dev pivots ---------- [
// -- Var user input --
var devTooltip = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot."
var depthTooltip = "The minimum number of bars that will be taken into account when analyzing pivots."
thresholdMultiplier = input.float(title="Deviation", defval=3, step=0.1, minval=0, tooltip=devTooltip, group="Pivot")
depth = input.int(title="Depth", defval=8, minval=1, tooltip=depthTooltip, group="Pivot")
// Prepare pivot variables
var line lineLast = na
var int iLast = 0 // Index last
var int iPrev = 0 // Index previous
var float pLast = 0 // Price last
var float pLastHigh = 0 // Price last
var float pLastLow = 0 // Price last
var isHighLast = false // If false then the last pivot was a pivot low
isPivotUpdate = false
// Get pivot information from dev pivot finding function
[dupLineLast, dupIsHighLast, dupIPrev, dupILast, dupPLast, dupPLastHigh, dupPLastLow] =
fontilab.getDeviationPivots(thresholdMultiplier, depth, lineLast, isHighLast, iLast, pLast, true, close, high, low)
if not na(dupIsHighLast)
lineLast := dupLineLast
isHighLast := dupIsHighLast
iPrev := dupIPrev
iLast := dupILast
pLast := dupPLast
pLastHigh := dupPLastHigh
pLastLow := dupPLastLow
isPivotUpdate := true
// Plot.
// Get last Pivots.
var highP = 0.0
var lowP = 0.0
var midP = 0.0
highP := isHighLast ? pLast : highP
lowP := not isHighLast ? pLast : lowP
midP := (highP + lowP)/2
// ] -------- Resistance Script -------- [
// Inputs
int maxResis = input.int(title="Length", defval=6, minval=1, tooltip="History Lenght used to determine Pivot Average", group="Pivot Average")
int smoothLength = input.int(title="Smoothing MA Lenght", defval=10, minval=1, group="Pivot Average")
float rangePercentResis = input.float(title="Close Range %", defval=1.5, step=0.1, tooltip="Define price percentage change required to determine close pivots", group="Pivot Average")
color apColor = input.color(color.yellow, title="Color", group="Pivot Average")
// Vars
var float[] resPrices = array.new_float(1, 0)
var int[] resWeights = array.new_int(1, 0)
var int[] resBarIndexes = array.new_int(1, 0)
var int[] resNbLows = array.new_int(1, 0)
var int[] resNbHighs = array.new_int(1, 0)
if isPivotUpdate
[dupResPrices, dupResWeights, dupResBarIndexes, dupResNbLows, dupResNbHighs] = fontilab.getResistances(resPrices, resBarIndexes, resWeights, resNbLows, resNbHighs, maxResis, rangePercentResis/100, pLast, iLast, isHighLast)
if not na(dupResPrices)
resPrices := dupResPrices
resWeights := dupResWeights
resBarIndexes := dupResBarIndexes
resNbHighs := dupResNbHighs
resNbLows := dupResNbLows
// -- Show Resis --
var float[] topResPrices = array.new_float(1, 0)
var int[] topBarIndexes = array.new_int(1, 0)
var int[] topResWeights = array.new_int(1, 0)
// Update lines every pivot update
if isPivotUpdate
[dupTopResPrices, dupTopResWeights, dupTopBarIndexes] = fontilab.getTopRes(1, 0, resWeights, resPrices, resBarIndexes)
topResPrices := dupTopResPrices
topBarIndexes := dupTopBarIndexes
topResWeights := dupTopResWeights
// Plot.
rawPA = fontilab.getElFloatArrayFromEnd(topResPrices, 0)
smoothingPA = ta.sma(rawPA,smoothLength)
plot(smoothingPA, title="res", color=apColor)
//]
|
SSTO by Saint | https://www.tradingview.com/script/NCvzbl58-SSTO-by-Saint/ | Krittapon | https://www.tradingview.com/u/Krittapon/ | 9 | 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/
// The author will not responsible for any loss or damage caused by using this script.
//@version=5
indicator(title='Cloud Stoch. with Tongkaw', shorttitle='CloudSto', format=format.price, precision=2, timeframe='')
groupsto = 'Stoch. Settings'
periodK = input.int(9, title='%K Period', minval=1, group = groupsto)
periodD = input.int(3, title='%D Period', minval=1, group = groupsto)
smoothK = input.int(3, title='Smooth Level', minval=1, group = groupsto)
oblevel = input.int(80, title='Overbought Level', minval=1, group = groupsto)
oslevel = input.int(20, title='Oversold Level', minval=1, group = groupsto)
//Stoch calculation
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)
//Fill Cloud Sto
pk = plot(k, title='%K', linewidth=1, color=color.new(color.blue, 20))
pd = plot(d, title='%D', linewidth=1, color=color.new(color.red, 20))
fill(pk, pd, color=k>=d ? color.new(color.blue, 20) : color.new(color.red, 20) , title='Stoch. Fill')
//Fill Band
h0 = hline(oblevel, 'Upper Band', color=#606060)
h1 = hline(oslevel, 'Lower Band', color=#606060)
fill(h0, h1, color=color.rgb(153, 21, 255, 90), title='Band Background')
//Tongkaw is alerts for your enjoyment.
alertcondition(ta.crossover(k, oblevel), title='Stoch Overbought', message='OB {{exchange}}:{{ticker}} TF[{{interval}}] Stoch in overbought')
alertcondition(ta.crossunder(k, oslevel), title='Stoch Oversold', message='OS {{exchange}}:{{ticker}} TF[{{interval}}] Stoch in oversold')
alertcondition(ta.cross(k,d), title="K cross D", message='X {{exchange}}:{{ticker}} TF[{{interval}}] %K crossed %D') |
Sector Relative Strength | https://www.tradingview.com/script/fcSCAIv5-Sector-Relative-Strength/ | atlas54000 | https://www.tradingview.com/u/atlas54000/ | 137 | 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/
// © atlas54000
// This script is a remastered version of my previous relative strength scanner
//@version=5
indicator("Sector Relative Strength", shorttitle = "Sector RS", overlay = true)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// INPUTS // ---------------------------------------------------------------
// Parameters names //
var string strength1 = "Relative Strength 1", var string strength2 = "Relative Strength 2", var string strength3 = "Relative Strength 3"
var string change1 = "Price Change", var string volume1 = "Relative Volume", var string des = "Desactivated"
var string l = "Left", var string c = "Center", var string r = "Right"
var string s = "Small", var string m = "Medium"
// Calculation parameters //
ch_1 = input.bool (defval = true, title = "Display the 5M RS", group = "5M RS parameters")
le_1 = input.int (defval = 12, title = "Period of the 5M RS", group = "5M RS parameters")
tf_1 = "5"
ch_2 = input.bool (defval = true, title = "Display a second RS", group = "Second RS parameters")
tf_2 = input.timeframe (defval = "30", title = "Second RS timeframe", group = "Second RS parameters")
le_2 = input.int (defval = 6, title = "Second RS period", group = "Second RS parameters")
ch_3 = input.bool (defval = true, title = "Display a third RS", group = "Third RS parameters")
tf_3 = input.timeframe (defval = "60", title = "Third RS timeframe", group = "Third RS parameters")
le_3 = input.int (defval = 6, title = "Third RS period", group = "Third RS parameters")
ch_c = input.bool (defval = true, title = "Display change", group = "Change parameters")
mu_c = input.int (defval = 3, title = "Number of 5M candles used", group = "Change parameters")
mu_1 = (5 * mu_c)
ch_v = input.bool (defval = true, title = "Display RV", group = "Relative volume parameters")
mu_v = input.int (defval = 3, title = "Number of 5M candles used", group = "Relative volume parameters")
le_v = input.int (defval = 78, title = "Length of volume SMA", group = "Relative volume parameters")
mu_2 = mu_v * 5
sorting = input.string (defval = change1, title = "Activate sorting using", group = "Sorting parameters", options = [des, change1, volume1, strength1, strength2, strength3])
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Graphical parameters //
cl_1 = input.float (defval = 0.75, title = "Upper limit", group = "Heatmap parameters")
cl_2 = input.float (defval = 0.50, title = "Middle limit", group = "Heatmap parameters")
cl_3 = input.float (defval = 0.25, title = "Lower limit", group = "Heatmap parameters")
cl_s = input.bool (defval = true, title = "Dark mode", group = "Color theme")
ta_s = input.string (defval = s, title = "Text size", group = "Table display setting", options = [s, m])
ta_p = input.string (defval = r, title = "Position of table", group = "Table display setting", options = [l, c, r])
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Symbol selection //
s00 = "SPY", s01 = "XLC", s02 = "XLY", s03 = "XLP", s04 = "XLE", s05 = "XLF"
s06 = "XLV", s07 = "XLI", s08 = "XLB", s09 = "XLRE", s10 = "XLK", s11 = "XLU"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// REQUESTS // -------------------------------------------------------------
// Index requests formulas //
request_i1() =>
change_s = math.round((close - close[mu_c]) / close[mu_c] * 100, 2)
volume_s = math.sum(volume,mu_v) / (ta.sma(volume,le_v) * mu_v)
strength_s = ta.change(close,le_1) / ta.atr(le_1)[1]
[change_s, volume_s ,strength_s]
request_i2() =>
strength_s = ta.change(close,le_2) / ta.atr(le_2)[1]
request_i3() =>
strength_s = ta.change(close,le_3) / ta.atr(le_3)[1]
// Make the index requests //
// - - - - Change, relative volume and power index for first timeframe - - - - | - - - - - Power index for second timeframe - - - - - - | - - - - - - Power index for third timeframe - - - - - - //
[change_00, volume_00, strength1_00] = request.security(s00, tf_1, request_i1()), strength2_00 = request.security(s00, tf_2, request_i2()), strength3_00 = request.security(s00, tf_3, request_i3())
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Sector requests formulas //
request_s1() =>
change_s = math.round((close - close[mu_c]) / close[mu_c] * 100, 2)
volume_s = math.sum(volume,mu_v) / (ta.sma(volume,le_v) * mu_v)
change_1 = ta.change(close,le_1)
atr_1 = ta.atr(le_1)[1]
[change_s, volume_s, change_1, atr_1]
request_s2() =>
change_2 = ta.change(close,le_2)
atr_2 = ta.atr(le_2)[1]
[change_2, atr_2]
request_s3() =>
change_3 = ta.change(close,le_3)
atr_3 = ta.atr(le_3)[1]
[change_3, atr_3]
// Make the sector requests //
// - - Change, relative volume and relative strength for first timeframe - - - | - - - - Relative strength for second timeframe - - - - | - - - - Relative strength for third timeframe - - - - //
[change_01, volume_01, change1_01, atr1_01] = request.security(s01, tf_1, request_s1()), [change2_01, atr2_01] = request.security(s01, tf_2, request_s2()), [change3_01, atr3_01] = request.security(s01, tf_3, request_s3())
[change_02, volume_02, change1_02, atr1_02] = request.security(s02, tf_1, request_s1()), [change2_02, atr2_02] = request.security(s02, tf_2, request_s2()), [change3_02, atr3_02] = request.security(s02, tf_3, request_s3())
[change_03, volume_03, change1_03, atr1_03] = request.security(s03, tf_1, request_s1()), [change2_03, atr2_03] = request.security(s03, tf_2, request_s2()), [change3_03, atr3_03] = request.security(s03, tf_3, request_s3())
[change_04, volume_04, change1_04, atr1_04] = request.security(s04, tf_1, request_s1()), [change2_04, atr2_04] = request.security(s04, tf_2, request_s2()), [change3_04, atr3_04] = request.security(s04, tf_3, request_s3())
[change_05, volume_05, change1_05, atr1_05] = request.security(s05, tf_1, request_s1()), [change2_05, atr2_05] = request.security(s05, tf_2, request_s2()), [change3_05, atr3_05] = request.security(s05, tf_3, request_s3())
[change_06, volume_06, change1_06, atr1_06] = request.security(s06, tf_1, request_s1()), [change2_06, atr2_06] = request.security(s06, tf_2, request_s2()), [change3_06, atr3_06] = request.security(s06, tf_3, request_s3())
[change_07, volume_07, change1_07, atr1_07] = request.security(s07, tf_1, request_s1()), [change2_07, atr2_07] = request.security(s07, tf_2, request_s2()), [change3_07, atr3_07] = request.security(s07, tf_3, request_s3())
[change_08, volume_08, change1_08, atr1_08] = request.security(s08, tf_1, request_s1()), [change2_08, atr2_08] = request.security(s08, tf_2, request_s2()), [change3_08, atr3_08] = request.security(s08, tf_3, request_s3())
[change_09, volume_09, change1_09, atr1_09] = request.security(s09, tf_1, request_s1()), [change2_09, atr2_09] = request.security(s09, tf_2, request_s2()), [change3_09, atr3_09] = request.security(s09, tf_3, request_s3())
[change_10, volume_10, change1_10, atr1_10] = request.security(s10, tf_1, request_s1()), [change2_10, atr2_10] = request.security(s10, tf_2, request_s2()), [change3_10, atr3_10] = request.security(s10, tf_3, request_s3())
[change_11, volume_11, change1_11, atr1_11] = request.security(s11, tf_1, request_s1()), [change2_11, atr2_11] = request.security(s11, tf_2, request_s2()), [change3_11, atr3_11] = request.security(s11, tf_3, request_s3())
relative_strength (strength, change, atr) =>
rs = (change - strength * atr) / atr
strength1_01 = relative_strength(strength1_00, change1_01, atr1_01), strength2_01 = relative_strength(strength2_00, change2_01, atr2_01), strength3_01 = relative_strength(strength3_00, change3_01, atr3_01)
strength1_02 = relative_strength(strength1_00, change1_02, atr1_02), strength2_02 = relative_strength(strength2_00, change2_02, atr2_02), strength3_02 = relative_strength(strength3_00, change3_02, atr3_02)
strength1_03 = relative_strength(strength1_00, change1_03, atr1_03), strength2_03 = relative_strength(strength2_00, change2_03, atr2_03), strength3_03 = relative_strength(strength3_00, change3_03, atr3_03)
strength1_04 = relative_strength(strength1_00, change1_04, atr1_04), strength2_04 = relative_strength(strength2_00, change2_04, atr2_04), strength3_04 = relative_strength(strength3_00, change3_04, atr3_04)
strength1_05 = relative_strength(strength1_00, change1_05, atr1_05), strength2_05 = relative_strength(strength2_00, change2_05, atr2_05), strength3_05 = relative_strength(strength3_00, change3_05, atr3_05)
strength1_06 = relative_strength(strength1_00, change1_06, atr1_06), strength2_06 = relative_strength(strength2_00, change2_06, atr2_06), strength3_06 = relative_strength(strength3_00, change3_06, atr3_06)
strength1_07 = relative_strength(strength1_00, change1_07, atr1_07), strength2_07 = relative_strength(strength2_00, change2_07, atr2_07), strength3_07 = relative_strength(strength3_00, change3_07, atr3_07)
strength1_08 = relative_strength(strength1_00, change1_08, atr1_08), strength2_08 = relative_strength(strength2_00, change2_08, atr2_08), strength3_08 = relative_strength(strength3_00, change3_08, atr3_08)
strength1_09 = relative_strength(strength1_00, change1_09, atr1_09), strength2_09 = relative_strength(strength2_00, change2_09, atr2_09), strength3_09 = relative_strength(strength3_00, change3_09, atr3_09)
strength1_10 = relative_strength(strength1_00, change1_10, atr1_10), strength2_10 = relative_strength(strength2_00, change2_10, atr2_10), strength3_10 = relative_strength(strength3_00, change3_10, atr3_10)
strength1_11 = relative_strength(strength1_00, change1_11, atr1_11), strength2_11 = relative_strength(strength2_00, change2_11, atr2_11), strength3_11 = relative_strength(strength3_00, change3_11, atr3_11)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ARRAYS // ---------------------------------------------------------------
// Create arrays for each column //
name_arr = array.new_string (0), change_arr = array.new_float (0), volume_arr = array.new_float (0)
strength1_arr = array.new_float (0), strength2_arr = array.new_float (0), strength3_arr = array.new_float (0)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Filling the arrays //
// - - - - - Name of each sector - - - - - - | - - - - Change of each sector - - - | - Relative volume of each sector - | - - - - - First RS of each sector - - - - | - - - - Second RS of each sector - - - - | - - - - Third RS of each sector - - - - //
array.push(name_arr, "XLC - Communication"), array.push(change_arr, change_01), array.push(volume_arr, volume_01), array.push(strength1_arr, strength1_01), array.push(strength2_arr, strength2_01), array.push(strength3_arr, strength3_01)
array.push(name_arr, "XLY - Cons Disctret"), array.push(change_arr, change_02), array.push(volume_arr, volume_02), array.push(strength1_arr, strength1_02), array.push(strength2_arr, strength2_02), array.push(strength3_arr, strength3_02)
array.push(name_arr, "XLP - Cons Staples"), array.push(change_arr, change_03), array.push(volume_arr, volume_03), array.push(strength1_arr, strength1_03), array.push(strength2_arr, strength2_03), array.push(strength3_arr, strength3_03)
array.push(name_arr, "XLE - Energy"), array.push(change_arr, change_04), array.push(volume_arr, volume_04), array.push(strength1_arr, strength1_04), array.push(strength2_arr, strength2_04), array.push(strength3_arr, strength3_04)
array.push(name_arr, "XLF - Financial"), array.push(change_arr, change_05), array.push(volume_arr, volume_05), array.push(strength1_arr, strength1_05), array.push(strength2_arr, strength2_05), array.push(strength3_arr, strength3_05)
array.push(name_arr, "XLV - Healthcare"), array.push(change_arr, change_06), array.push(volume_arr, volume_06), array.push(strength1_arr, strength1_06), array.push(strength2_arr, strength2_06), array.push(strength3_arr, strength3_06)
array.push(name_arr, "XLI - Industrials"), array.push(change_arr, change_07), array.push(volume_arr, volume_07), array.push(strength1_arr, strength1_07), array.push(strength2_arr, strength2_07), array.push(strength3_arr, strength3_07)
array.push(name_arr, "XLB - Materials"), array.push(change_arr, change_08), array.push(volume_arr, volume_08), array.push(strength1_arr, strength1_08), array.push(strength2_arr, strength2_08), array.push(strength3_arr, strength3_08)
array.push(name_arr, "XLRE - Real Estate"), array.push(change_arr, change_09), array.push(volume_arr, volume_09), array.push(strength1_arr, strength1_09), array.push(strength2_arr, strength2_09), array.push(strength3_arr, strength3_09)
array.push(name_arr, "XLK - Technology"), array.push(change_arr, change_10), array.push(volume_arr, volume_10), array.push(strength1_arr, strength1_10), array.push(strength2_arr, strength2_10), array.push(strength3_arr, strength3_10)
array.push(name_arr, "XLU - Utilities"), array.push(change_arr, change_11), array.push(volume_arr, volume_11), array.push(strength1_arr, strength1_11), array.push(strength2_arr, strength2_11), array.push(strength3_arr, strength3_11)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Sorting the arrays //
// The sorting system was inspired by LuxGecko an his Bubble Sort function
// For more details see : https://www.tradingview.com/script/mMF7fVKO-Pinescript-Bubble-Sort-using-Arrays/
if sorting != des
sorter = sorting == change1 ? change_arr : sorting == volume1 ? volume_arr : sorting == strength1 ? strength1_arr : sorting == strength2 ? strength2_arr : strength3_arr
n = array.size(sorter) - 1
for i = 0 to n - 1
for j = 0 to n - i - 1
if array.get(sorter , j) < array.get(sorter, j+1)
name_temp = array.get(name_arr, j)
array.set(name_arr, j, array.get(name_arr, j + 1))
array.set(name_arr, j + 1, name_temp)
change_temp = array.get(change_arr, j)
array.set(change_arr, j, array.get(change_arr, j + 1))
array.set(change_arr, j + 1, change_temp)
volume_temp = array.get(volume_arr, j)
array.set(volume_arr, j, array.get(volume_arr, j + 1))
array.set(volume_arr, j + 1, volume_temp)
strength1_temp = array.get(strength1_arr, j)
array.set(strength1_arr, j, array.get(strength1_arr, j + 1))
array.set(strength1_arr, j + 1, strength1_temp)
strength2_temp = array.get(strength2_arr, j)
array.set(strength2_arr, j, array.get(strength2_arr, j + 1))
array.set(strength2_arr, j + 1, strength2_temp)
strength3_temp = array.get(strength3_arr, j)
array.set(strength3_arr, j, array.get(strength3_arr, j + 1))
array.set(strength3_arr, j + 1, strength3_temp)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TABLE // ----------------------------------------------------------------
// Graphical variables //
g_1 = color.rgb(016, 158, 119), r_1 = color.rgb(239, 083, 080)
g_2 = cl_s ? color.rgb(017, 124, 098) : color.rgb(076, 182, 153), r_2 = cl_s ? color.rgb(184, 068, 069) : color.rgb(245, 126, 124)
g_3 = cl_s ? color.rgb(017, 090, 077) : color.rgb(135, 206, 187), r_3 = cl_s ? color.rgb(129, 053, 057) : color.rgb(247, 169, 167)
g_4 = cl_s ? color.rgb(018, 057, 055) : color.rgb(195, 231, 221), r_4 = cl_s ? color.rgb(073, 037, 046) : color.rgb(249, 193, 192)
bkg = cl_s ? color.rgb(019, 023, 034) : color.white, txt = cl_s ? color.white : color.black
cl_f1 (val) => val > 0 ? g_1 : val < 0 ? r_1 : txt
cl_f2 (val) => val > cl_1 ? g_1 : val > cl_2 ? g_2 : val > cl_3 ? g_3 : val > 0.0 ? g_4 : val > -cl_3 ? r_4 : val > -cl_2 ? r_3 : val > -cl_1 ? r_2 : r_1
cl_f3 (val) => (val / volume_00) > cl_1 +1 ? g_1 : (val / volume_00) > cl_2 +1 ? g_2 : (val / volume_00) > cl_3 +1 ? g_3 : (val / volume_00) > 1 ? g_4 : (val / volume_00) > -cl_3 +1? r_4 : (val / volume_00) > -cl_2 +1? r_3 : (val / volume_00) > -cl_1 +1? r_2 : r_1
brd_s = ta_s == s ? 2 : 3
txt_s = ta_s == s ? size.small : size.normal
ta_pl = ta_p == r ? position.top_right : ta_p == c ? position.top_center : position.top_left
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Columns calculator //
ch1_pl = (ch_c == true ? 1 : 0)
rs1_pl = (ch_1 == true ? 1 : 0) + ch1_pl
rs2_pl = (ch_2 == true ? 1 : 0) + rs1_pl
rs3_pl = (ch_3 == true ? 1 : 0) + rs2_pl
rv1_pl = (ch_v == true ? 1 : 0) + rs3_pl
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Filling the table //
var tbl = table.new(ta_pl, rv1_pl + 1, 14, border_width = brd_s, border_color = bkg)
if barstate.islast
table.cell(tbl, 0, 0, "Symbol", text_halign = text.align_right, bgcolor = bkg, text_color = txt, text_size = size.normal)
table.cell(tbl, 0, 1, "SPY", text_halign = text.align_right, bgcolor = bkg, text_color = txt, text_size = txt_s)
for i = 0 to 10
table.cell(tbl, 0, i + 2, array.get(name_arr, i), text_halign = text.align_left, bgcolor = bkg, text_color = txt, text_size = txt_s)
if ch_c == true
table.cell(tbl, ch1_pl, 0, "Change " + str.tostring(mu_1), text_halign = text.align_center, bgcolor = bkg, text_color = txt, text_size = size.normal)
table.cell(tbl, ch1_pl, 1, str.tostring(change_00, "#.##") + " %", text_halign = text.align_center, bgcolor = bkg, text_color = cl_f1 (change_00), text_size = txt_s)
for i = 0 to 10
table.cell(tbl, ch1_pl, i + 2, str.tostring(array.get(change_arr, i), "#.##") + " %" , text_halign = text.align_center, bgcolor = bkg, text_color = cl_f1 (array.get(change_arr, i)), text_size = txt_s)
if ch_1 == true
table.cell(tbl, rs1_pl, 0, " RS 5 ", text_halign = text.align_center, bgcolor = bkg, text_color = txt, text_size = size.normal)
table.cell(tbl, rs1_pl, 1, str.tostring(strength1_00, "#.##"), text_halign = text.align_center, bgcolor = cl_f2 (strength1_00), text_color = txt, text_size = txt_s)
for i = 0 to 10
table.cell(tbl, rs1_pl, i + 2, str.tostring(array.get(strength1_arr, i), "#.##"), text_halign = text.align_center, bgcolor = cl_f2 (array.get(strength1_arr, i)), text_color = txt, text_size = txt_s)
if ch_2 == true
table.cell(tbl, rs2_pl, 0, " RS " + tf_2 + " ", text_halign = text.align_center, bgcolor = bkg, text_color = txt, text_size = size.normal)
table.cell(tbl, rs2_pl, 1, str.tostring(strength2_00, "#.##"), text_halign = text.align_center, bgcolor = cl_f2 (strength2_00), text_color = txt, text_size = txt_s)
for i = 0 to 10
table.cell(tbl, rs2_pl, i + 2, str.tostring(array.get(strength2_arr, i), "#.##"), text_halign = text.align_center, bgcolor = cl_f2 (array.get(strength2_arr, i)), text_color = txt, text_size = txt_s)
if ch_3 == true
table.cell(tbl, rs3_pl, 0, " RS " + tf_3 + " ", text_halign = text.align_center, bgcolor = bkg, text_color = txt, text_size = size.normal)
table.cell(tbl, rs3_pl, 1, str.tostring(strength3_00, "#.##"), text_halign = text.align_center, bgcolor = cl_f2 (strength3_00), text_color = txt, text_size = txt_s)
for i = 0 to 10
table.cell(tbl, rs3_pl, i + 2, str.tostring(array.get(strength3_arr, i), "#.##"), text_halign = text.align_center, bgcolor = cl_f2 (array.get(strength3_arr, i)), text_color = txt, text_size = txt_s)
if ch_v == true
table.cell(tbl, rv1_pl, 0, " RV " + str.tostring(mu_2), text_halign = text.align_center, bgcolor = bkg, text_color = txt, text_size = size.normal)
table.cell(tbl, rv1_pl, 1, str.tostring(volume_00, "#.##"), text_halign = text.align_center, bgcolor = cl_f2 (volume_00 - 1), text_color = txt, text_size = txt_s)
for i = 0 to 10
table.cell(tbl, rv1_pl, i + 2, str.tostring(array.get(volume_arr, i), "#.##"), text_halign = text.align_center, bgcolor = cl_f3(array.get(volume_arr, i)), text_color = txt, text_size = txt_s) |
PeakTrough Indicator | https://www.tradingview.com/script/sQprJne8-PeakTrough-Indicator/ | agungkuswanto | https://www.tradingview.com/u/agungkuswanto/ | 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/
// © agungkuswanto
//@version=5
indicator("PETRUK", "", true)
import agungkuswanto/PEAKTROUGHLIB268/1 as showNow
plot (showNow.showThePeak(), color=color.lime)
plot (showNow.showTheTrough(), color=color.orange)
|
TDI w/ Variety RSI, Averages, & Source Types [Loxx] | https://www.tradingview.com/script/DCmku2ZK-TDI-w-Variety-RSI-Averages-Source-Types-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 265 | 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("TDI w/ Variety RSI, Averages, & Source Types [Loxx]",
shorttitle = "TDIVRSIAST [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxvarietyrsi/1
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Signal Crosses'
SM03 = 'Floating Boundary Crosses'
SM04 = 'Horizontal Boundary Crosses'
SM05 = 'Floating Middle Crosses'
SM06 = 'Horizontal Middle Crosses'
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)"])
RsiPeriod = input.int(14, "RSI Period", group = "Basic Settings")
RsiMethod = input.string("RSX", "RSI Type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed", "T3 RSI"], group = "Basic Settings")
RsiPriceLinePeriod = input.int(2, "RSI Price Line Period", group = "Basic Settings")
// Signal line moving average method
RsiPriceLineMAMode = input.string("Simple Moving Average - SMA", "Signal Line MA 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 Filter", "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")
RsiSignalLinePeriod = input.int(14, "RSI Signal Line Period", group = "Basic Settings")
// Signal line moving average method
RsiSignalLineMAMode = input.string("Simple Moving Average - SMA", "RSI Signal Line MA 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 Filter", "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")
VolatilityBandPeriod = input.int(34, "Volatility Band Period", group = "Volatility Band Settings")
VolatilityBandMultiplier = input.float(1.6185, "Volatility Band Multiplier", group = "Volatility Band Settings")
sigtype = input.string(SM02, "Signal Type", options = [SM02, SM03, SM04, SM05, SM06], group = "Signal Settings")
statup = input.int(68, "Upper Horizontal Boundary", group = "Horizontal Boundary Settings")
statmid = input.int(50, "Middle Horizontal Boundary", group = "Horizontal Boundary Settings")
statdn = input.int(32, "Down Horizontal Boundary", group = "Horizontal Boundary 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 Filter (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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
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 Filter"
[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
rsimode = switch RsiMethod
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
prices = src
rsi = loxxvarietyrsi.rsiVariety(rsimode, prices, RsiPeriod)
rsiPL = variant(RsiPriceLineMAMode, rsi, RsiPriceLinePeriod)
rsiSL = variant(RsiSignalLineMAMode, rsi, RsiSignalLinePeriod)
bandMi = 0.
for k = 0 to VolatilityBandPeriod - 1
bandMi += nz(rsi[k])
bandMi /= VolatilityBandPeriod
deviation = ta.stdev(rsi, VolatilityBandPeriod)
bandUp = bandMi + VolatilityBandMultiplier * deviation
bandDn = bandMi - VolatilityBandMultiplier * deviation
trend = 0
trend := (rsiPL > rsiSL) ? 1 : (rsiPL < rsiSL) ? -1 : nz(trend[1])
state = 0.
if sigtype == SM02
if (rsiPL < rsiSL)
state :=-1
if (rsiPL > rsiSL)
state := 1
else if sigtype == SM03
if (rsiPL < bandDn)
state :=-1
if (rsiPL > bandUp)
state := 1
else if sigtype == SM04
if (rsiPL < statdn)
state :=-1
if (rsiPL > statup)
state := 1
else if sigtype == SM05
if (rsiPL < bandMi)
state :=-1
if (rsiPL > bandMi)
state := 1
else if sigtype == SM06
if (rsiPL < statmid)
state :=-1
if (rsiPL > statmid)
state := 1
colorout = state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(rsiPL, "RSI Price Line", color = colorout, linewidth = 2)
plot(rsiSL, "RSI Signal Line", color = color.white, linewidth = 1)
uppl = plot(bandUp, "Upper Band", color = darkGreenColor, linewidth = 1)
dnpl = plot(bandDn, "Lower Band", color = darkRedColor, linewidth = 1)
midpl = plot(bandMi, "Mid Level", color = color.yellow, linewidth = 1)
fill(uppl, midpl, color.new(greencolor, 85))
fill(dnpl, midpl, color.new(redcolor, 85))
plot(statup, "Upper Horizontal Boundary", color = bar_index % 2 ? color.gray : na, linewidth = 1)
plot(statmid, "Middle Horizontal Boundary", color = bar_index % 2 ? color.gray : na, linewidth = 1)
plot(statdn, "Down Horizontal Boundary", color = bar_index % 2 ? color.gray : na, linewidth = 1)
barcolor(colorbars ? colorout : na)
goLong =
sigtype == SM02 ? ta.crossover(rsiPL, rsiSL) :
sigtype == SM03 ? ta.crossover(rsiPL, bandUp) :
sigtype == SM04 ? ta.crossover(rsiPL, statup) :
sigtype == SM05 ? ta.crossover(rsiPL, bandMi) :
ta.crossover(rsiPL, statmid)
goShort = sigtype == SM02 ? ta.crossunder(rsiPL, rsiSL) :
sigtype == SM03 ? ta.crossunder(rsiPL, bandDn) :
sigtype == SM04 ? ta.crossunder(rsiPL, statdn) :
sigtype == SM05 ? ta.crossunder(rsiPL, bandMi) :
ta.crossunder(rsiPL, statmid)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="TDI w/ Variety RSI, Averages, & Source Types [Loxx: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="TDI w/ Variety RSI, Averages, & Source Types [Loxx: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Jurik-Filtered Kase Permission Stochastic [Loxx] | https://www.tradingview.com/script/kIBAXchQ-Jurik-Filtered-Kase-Permission-Stochastic-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("Jurik-Filtered Kase Permission Stochastic [Loxx]",
shorttitle="JFKPS [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxjuriktools/1 as jf
greencolor = #2DD204
redcolor = #D2042D
pstLength = input.int(9, "Period", group = "Basic Settings")
pstX = input.int(5, "Synthetic Multiplier", group = "Basic Settings")
pstSmooth = input.int(3, "Stochasitc Smoothing Period", group = "Basic Settings")
smoothPeriod = input.int(10, "Jurik Smoothing Period", group = "Basic Settings")
jphs = input.float(0., "Jurik Phase", group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group = "UI Options")
lookBackPeriod = pstLength * pstX
alpha = 2.0 / (1.0 + pstSmooth)
TripleK = 0., TripleDF = 0., TripleDS = 0., TripleDSs = 0., TripleDFs = 0.
fmin = ta.lowest(low, lookBackPeriod)
fmax = ta.highest(high, lookBackPeriod) - fmin
if (fmax > 0)
TripleK := 100.0 * (close - fmin) / fmax
else
TripleK := 0.0
TripleDF := nz(TripleDF[pstX]) + alpha * (TripleK - nz(TripleDF[pstX]))
TripleDS := (nz(TripleDS[pstX]) * 2.0 + TripleDF) / 3.0
TripleDSs := ta.sma(TripleDS, 3)
pssBuffer = jf.jurik_filt(TripleDSs, smoothPeriod, jphs)
TripleDFs := ta.sma(TripleDF, 3)
pstBuffer = jf.jurik_filt(TripleDFs, smoothPeriod, jphs)
trend = 0
trend := nz(trend[1])
if (pstBuffer > pssBuffer)
trend := 1
if (pstBuffer < pssBuffer)
trend := -1
colorout = trend == 1 ? greencolor : trend == -1 ? redcolor : color.gray
plot(pssBuffer, color = color.white, linewidth = 1)
plot(pstBuffer, color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(pstBuffer, pssBuffer)
goShort = ta.crossunder(pstBuffer, pssBuffer)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "Jurik-Filtered Kase Permission Stochastic [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "Jurik-Filtered Kase Permission Stochastic [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Simple Levels | https://www.tradingview.com/script/85WbdoJ3-Simple-Levels/ | SamRecio | https://www.tradingview.com/u/SamRecio/ | 122 | 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/
// © SamRecio
//@version=5
indicator("Simple Levels",overlay = true)
//User Inputs///////////////////////////////////////////////////////////////////
lvls = str.replace_all(input.string("", title = "Insert Levels ->", group = "SIMPLE LEVELS", tooltip = "Insert Levels, Separated by commas(,).", inline = "1", confirm = true)," ","")//Replaces all spaces with blanks
line_style = input.string("___", title = "Style", options = ["___","- - -",". . ."], group = "SETTINGS", inline = "2")
thickness = input.int(1, title = "Width", group = "SETTINGS", inline = "2")
low_color = input.color(color.rgb(0,124,150), title = "Support Color", group = "SETTINGS", inline = "3")
high_color = input.color(color.rgb(221,75,50), title = "Resistance Color", group = "SETTINGS", inline = "3")
lab_size = input.string("small", title = "Label Size", options = ["tiny","small","normal","large","huge"], inline = "4", group = "SETTINGS")
lab_offset = input.int(9, title = "Label Offset", inline = "4", group = "SETTINGS")
//Transforms Style input into actual line styles////////////////////////////////
linestyle(_input) =>
_input == "___"?line.style_solid:
_input == "- - -"?line.style_dashed:
_input == ". . ."?line.style_dotted:
line.style_solid
//Splits levels input into an array to read later//////////////////////////////
split = str.split(lvls,",")
//ERROR MESSAGE/////////////////////////////////////////////////////////////////
if array.size(split) == 0 //If the array has no values then the box is empty. Please input values.
runtime.error("Please input Levels.")
//Variable initialization///////////////////////////////////////////////////////
var line lvl_line = na
var label lvl_lab = na
//Delete all lines & Labels
a_allLines = line.all
if array.size(a_allLines) > 0
for i = 0 to array.size(a_allLines) - 1
line.delete(array.get(a_allLines, i))
a_allLabels = label.all
if array.size(a_allLabels) > 0
for i = 0 to array.size(a_allLabels) - 1
label.delete(array.get(a_allLabels, i))
//Loops for every entry in the array above and draws a line with the appropriate color and label.
for i = 0 to array.size(split) - 1
num = str.tonumber(array.get(split,i)) //The array values are 'string'(text) values, this grabs that text value and makes it into a number.
col = (num>close)?high_color:(num<close)?low_color:color.gray //Compairing our number to the current close price to see if its above or below, and assigning a color value.
lvl_line := line.new(bar_index,num,bar_index+1,num, extend = extend.right, color = col, style = linestyle(line_style), width = thickness)
lvl_lab := label.new(bar_index + lab_offset,num,text = str.format("{0,number,currency}",str.tonumber(array.get(split,i))), color = color.new(color.black,100), size = lab_size, textcolor = col, style = label.style_label_lower_left) |
TARVIS Labs - Bitcoin Macro Bottom/Top Signals | https://www.tradingview.com/script/TCTEjpGR-TARVIS-Labs-Bitcoin-Macro-Bottom-Top-Signals/ | arrash0x | https://www.tradingview.com/u/arrash0x/ | 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/
// © TARVIS Labs LLC
//@version=5
// a script to determine macro Bitcoin bottoms to accumulate and tops to sell
// with warnings provided of local tops
//@version=5
indicator(title="TARVIS Labs - Bitcoin Macro Bottom/Top Signals", shorttitle="TARVIS Labs btc macro bottom/top signals", overlay=true, timeframe="1D", timeframe_gaps=true)
src = input(close, title="Source")
len1 = int(700)
len2 = int(18)
len3 = int(63)
len4 = int(12)
len5 = int(52)
len6 = int(12)
// long term EMA for overall run
ema1 = ta.ema(src, len1)
// major cross pairing
ema2 = ta.ema(src, len2)
ema3 = ta.ema(src, len3)
// major cross pairing to rebuy in
ema4 = ta.ema(src, len4)
ema5 = ta.ema(src, len5)
// helper in beginning bull run warnings
ema6 = ta.ema(src, len6)
// bottom MACD
fast_length = int(168)
slow_length = int(364)
signal_length = int(6)
fast_ma = ta.ema(src, fast_length)
slow_ma = ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = ta.ema(macd, signal_length)
// Top MACD
fast_length2 = int(63)
slow_length2 = int(133)
signal_length2 = int(1)
fast_ma2 = ta.ema(src, fast_length2)
slow_ma2 = ta.ema(src, slow_length2)
macd2 = fast_ma2 - slow_ma2
signal2 = ta.ema(macd2, signal_length2)
// local top warning MACD
fast_length3 = int(30)
slow_length3 = int(65)
signal_length3 = int(4)
fast_ma3 = ta.ema(src, fast_length3)
slow_ma3 = ta.ema(src, slow_length3)
macd3 = fast_ma3 - slow_ma3
signal3 = ta.ema(macd3, signal_length3)
// beginning of bull run local top warning MACD
fast_length4 = int(9)
slow_length4 = int(19)
signal_length4 = int(6)
fast_ma4 = ta.ema(src, fast_length4)
slow_ma4 = ta.ema(src, slow_length4)
macd4 = fast_ma4 - slow_ma4
signal4 = ta.ema(macd4, signal_length4)
// bottom
plot(signal[1] < signal ? src < ema1 ? src : na : na, title='Accumulation Zone Indicator', color=#DAF7A6, style = plot.style_areabr, linewidth = 2)
plotchar(ta.crossover(fast_ma4, slow_ma4) ? signal[1] < signal ? src < ema1 ? src : na : na : na, title='Strong Buy in Accumulation Zone Indicator', color=#013220, text = 'strong buy', location='Top')
plot(ta.crossover(fast_ma4, slow_ma4) ? signal[1] < signal ? src < ema1 ? src : na : na : na, color=#013220, title='Strong Buy in Accumulation Zone Indicator', style = plot.style_areabr, linewidth = 2)
// end
plot(ta.crossunder(ema2, ema3) ? ema1[7] * 1.015 < ema1 ? src : na : na, title='End of Bull Run Indicator', color=#581845, style = plot.style_circles, linewidth = 6)
plotchar(ta.crossunder(ema2, ema3) ? ema1[7] * 1.015 < ema1 ? src : na : na, title='End of Bull Run Indicator', color=#581845, text = 'end', location='Top')
// warnings
plot(ema6[1] >= ema6 ? ema2 > ema3 ? ema1[7] * 1.01 < ema1 ? signal4[1] > signal4 ? src : na : na : na : na, title='Bull Run Local Top Indicator', color=#FFA500, style = plot.style_areabr, linewidth = 2)
plot(ema2 > ema3 ? ema1[7] * 1.025 < ema1 ? signal3[1] > signal3 ? src : na : na : na, color=#FF5733, title='Local Top Near Bull Run Top Indicator', style = plot.style_areabr, linewidth = 2)
// rebuy in
plot(ta.crossover(ema4, ema5) ? ema2 > ema3 ? signal3[1] < signal3 ? src : na : na : na, title='Opportunity to Buy Back in Indicator', color=#0000FF, style = plot.style_areabr, linewidth = 2)
plotchar(ta.crossover(ema4, ema5) ? ema2 > ema3 ? signal3[1] < signal3 ? src : na : na : na, title='Opportunity to Buy Back in Indicator', color=#0000FF, text = 'buy', location='Top')
// top
plot(ema3[1] >= ema3 ? ema2 > ema3 ? ema1[7] * 1.03 < ema1 ? signal2[1] > signal2 ? src : na : na : na : na, title='Top is Likely In Indicator', color=#C70039, style = plot.style_areabr, linewidth = 2)
|
Improved Z-Score Overlay | https://www.tradingview.com/script/2o4U5ilG-Improved-Z-Score-Overlay/ | jlb05013 | https://www.tradingview.com/u/jlb05013/ | 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/
// © jlb05013
//@version=5
indicator("Improved Z-Score Overlay", overlay=true)
z_score_type = input.string(defval='Close', title='Ticker Type', options=['Open', 'High', 'Low', 'Close', 'OHLC4'])
z_score_smooth = input.bool(defval=false, title='Ticker Smoothing?', tooltip='Whether or not you would like the ticker raw data to be smoothened or not by a particular period. Sometimes 3 or 5 period smoothing helps filter noise.')
z_score_smooth_period = input.int(defval=3, title='Ticker Smoothing Period', tooltip='This is the smoothing period for the ticker if "Ticker Smoothing?" is set to True. I recommend using 3 or 5 period smoothing to filter noise.')
z_score_ma_type = input.string(defval='SMA', title='Z-Score Type', options=['SMA', 'EMA'])
z_score_ma_period = input.int(defval=21, title='Moving Average Period', tooltip='The length (in bars) for normalizing with a moving average. Standard is 21 (one month of trading days) but is customizable.')
z_score_stdev_period = input.int(defval=252, title='Standard Deviation Period', tooltip='The length of time (in bars) for calculating standard deviation. Standard is 252 for use on Daily chart (1 trading year)')
ticker_raw_data = z_score_type == 'Close' ? close : z_score_type == 'Open' ? open : z_score_type == 'High' ? high : z_score_type == 'Low' ? low : z_score_type == 'OHLC4' ? ohlc4 : na
ticker_smooth = z_score_smooth ? ta.ema(ticker_raw_data, z_score_smooth_period) : ticker_raw_data
ticker_ma = z_score_ma_type == 'SMA' ? ta.sma(ticker_raw_data, z_score_ma_period) : z_score_ma_type == 'EMA' ? ta.ema(ticker_raw_data, z_score_ma_period) : na
ticker_stdev = ta.stdev(ticker_raw_data, z_score_stdev_period)
final_zscore = (ticker_smooth - ticker_ma) / ticker_stdev
ticker_zscore_p3 = ticker_ma + 3*ticker_stdev
ticker_zscore_p2 = ticker_ma + 2*ticker_stdev
ticker_zscore_p1 = ticker_ma + 1*ticker_stdev
ticker_zscore_n3 = ticker_ma - 3*ticker_stdev
ticker_zscore_n2 = ticker_ma - 2*ticker_stdev
ticker_zscore_n1 = ticker_ma - 1*ticker_stdev
ticker_zscore_0 = ticker_ma
plot(final_zscore, title='Z-Score', color=color.new(color.red, 30), style=plot.style_area, display=display.none)
plot(ticker_zscore_p3, color=color.new(color.red, 50), linewidth=3, title='+3S')
plot(ticker_zscore_p2, color=color.new(color.red, 50), linewidth=2, title='+2S')
plot(ticker_zscore_p1, color=color.new(color.red, 50), linewidth=1, title='+1S')
plot(ticker_zscore_n3, color=color.new(color.green, 50), linewidth=3, title='-3S')
plot(ticker_zscore_n2, color=color.new(color.green, 50), linewidth=2, title='-2S')
plot(ticker_zscore_n1, color=color.new(color.green, 50), linewidth=1, title='-1S')
plot(ticker_zscore_0, color=color.new(color.black, 50), linewidth=1, title='CL') |
Dline | https://www.tradingview.com/script/0cbfqb21-Dline/ | B-negative | https://www.tradingview.com/u/B-negative/ | 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/
// © ChatchaiMeena
//@version=5
indicator(title="Double Line", shorttitle="Dline", overlay=true, timeframe="", timeframe_gaps=true)
length = input.int(233, minval=1)
length2 = input.int(89, minval=1)
src = input(close, title="Source")
e1 = ta.ema(src, length)
e2 = ta.ema(e1, length)
e3 = ta.ema(src, length2)
dema = 2 * e1 - e2
dline = (e3 + dema)/2
length3 = input.int(610, minval=1)
ema1 = ta.ema(close, length3)
ema2 = ta.ema(ema1, length3)
ema3 = ta.ema(ema2, length3)
out = 3 * (ema1 - ema2) + ema3
plot(out, "TEMA", color=#2962FF)
plot(dema, "DEMA", color=#43A047)
plot(e3,"EMA", color=#43A044)
plot(dline,"DLINE",color=#A43048)
percent = input(10.0)
k = percent/100.0
upper = out * (1 + k)
lower = out * (1 - k)
u = plot(upper, "Upper", color=#2962FF)
l = plot(lower, "Lower", color=#2962FF)
barcolor(dline < close ? color.green: color.red)
|
Round Numbers and Quarter Levels | https://www.tradingview.com/script/ZN56FUFR/ | bluebeardit | https://www.tradingview.com/u/bluebeardit/ | 706 | 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/
// © bluebeardit
//
// ________ ___ ___ ___ _______ ________ _______ ________ ________ ________ ___ _________
// |\ __ \ |\ \ |\ \|\ \ |\ ___ \ |\ __ \ |\ ___ \ |\ __ \ |\ __ \ |\ ___ \ |\ \ |\___ ___\
// \ \ \|\ /_\ \ \ \ \ \\\ \\ \ __/| \ \ \|\ /_\ \ __/| \ \ \|\ \\ \ \|\ \\ \ \_|\ \\ \ \\|___ \ \_|
// \ \ __ \\ \ \ \ \ \\\ \\ \ \_|/__\ \ __ \\ \ \_|/__\ \ __ \\ \ _ _\\ \ \ \\ \\ \ \ \ \ \
// \ \ \|\ \\ \ \____ \ \ \\\ \\ \ \_|\ \\ \ \|\ \\ \ \_|\ \\ \ \ \ \\ \ \\ \|\ \ \_\\ \\ \ \ \ \ \
// \ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \__\ \__\\ \__\\ _\ \ \_______\\ \__\ \ \__\
// \|_______| \|_______| \|_______| \|_______| \|_______| \|_______| \|__|\|__| \|__|\|__| \|_______| \|__| \|__|
//
//
// V. 1.0
//This script is based on "Round Numbers Above and Below" by BitcoinJesus-Not-Roger-Ver
//@version=5
indicator("Round numbers and quarter levels", shorttitle="Round Num & Q. Lev", overlay=true)
//User input Round 00
var GRP1 = "Round 00 Numbers"
linecolor1 = input(title="Line color", defval = color.blue, group = GRP1)
linestyle1 = input.string(title="Line style", defval = line.style_solid, options=[line.style_solid, line.style_dotted, line.style_dashed], group = GRP1)
linewidth1 = input.int(title="Line width", defval = 2, minval=1, maxval=4, group = GRP1)
//User input Round 50
var GRP2 = "Round 50 Numbers"
linecolor2 = input(title="Line color", defval = color.orange, group = GRP2)
linestyle2 = input.string(title="Line style", defval = line.style_solid, options=[line.style_solid, line.style_dotted, line.style_dashed], group = GRP2)
linewidth2 = input.int(title="Line width", defval = 1, minval=1, maxval=4, group = GRP2)
//User input Quarters
var GRP3 = "Quarter Numbers"
linecolor3 = input(title="Line color", defval = color.green, group = GRP3)
linestyle3 = input.string(title="Line style", defval = line.style_dashed, options=[line.style_solid, line.style_dotted, line.style_dashed], group = GRP3)
linewidth3 = input.int(title="Line width", defval = 1, minval=1, maxval=4, group = GRP3)
var number_of_lines = input.int(4, title="Number of lines above/below")
var step = syminfo.mintick*250
if barstate.islast
for counter = 0 to number_of_lines - 1
stepUp = math.ceil(close / step) * step + (counter * step)
line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=linecolor3, width=linewidth3, style=linestyle3)
stepDown = math.floor(close / step) * step - (counter * step)
line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=linecolor3, width=linewidth3, style=linestyle3)
var step2 = syminfo.mintick*500
if barstate.islast
for counter = 0 to (number_of_lines /2) - 1
stepUp = math.ceil(close / step2) * step2 + (counter * step2)
line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=linecolor2, width=linewidth2, style=linestyle2)
stepDown = math.floor(close / step2) * step2 - (counter * step2)
line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=linecolor2, width=linewidth2, style=linestyle2)
var step3 = syminfo.mintick*1000
if barstate.islast
for counter = 0 to (number_of_lines /4) - 1
stepUp = math.ceil(close / step3) * step3 + (counter * step3)
line.new(bar_index, stepUp, bar_index - 1, stepUp, xloc=xloc.bar_index, extend=extend.both, color=linecolor1, width=linewidth1, style=linestyle1)
stepDown = math.floor(close / step3) * step3 - (counter * step3)
line.new(bar_index, stepDown, bar_index - 1, stepDown, xloc=xloc.bar_index, extend=extend.both, color=linecolor1, width=linewidth1, style=linestyle1) |
Covering Shadow Candle Pattern | https://www.tradingview.com/script/JSIT2Mdv-Covering-Shadow-Candle-Pattern/ | Mahdi_Fatemi1998 | https://www.tradingview.com/u/Mahdi_Fatemi1998/ | 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/
// © Mahdi_Fatemi1998
//@version=5
indicator("Covering Shadow Candle Pattern", overlay=true)
//detecting covering shadows
threeGreenCandles = (close[1] > open[1]) and (close[2] > open[2]) and (close[3] > open[3])
threeRedCandles = (close[1] < open[1]) and (close[2] < open[2]) and (close[3] < open[3])
coveringRedCandle = (low < low[1]) and (low < low[2]) and (low < low[3]) and (close < open) //remove the last term for test
coveringGreenCandle = (high > high[1]) and (high > high[2]) and (high > high[3]) and (close > open) //remove the last term for test
redCover = threeGreenCandles and coveringRedCandle
greenCover = threeRedCandles and coveringGreenCandle
//detecting supply and demand zones
threeGreenCandles2 = (close[6] > open[6]) and (close[5] > open[5]) and (close[4] > open[4])
threeRedCandles2 = (close[6] < open[6]) and (close[5] < open[5]) and (close[4] < open[4])
coveringRedCandle2 = (low[3] < low[6]) and (low[3] < low[5]) and (low[3] < low[4]) and (close[3] < open[3]) //remove the last term for test
coveringGreenCandle2 = (high[3] > high[6]) and (high[3] > high[5]) and (high[3] > high[6]) and (close[3] > open[3]) //remove the last term for test
redFollowing2 = close[2] < open[2]
greenFollowing2 = close[2] > open[2]
failureDoubleGreen2 = (close[1] > open[1]) and (close > open)
failuteDoubleRed2 = (close[1] < open[1]) and (close < open)
demandZone = threeGreenCandles2 and coveringRedCandle2 and redFollowing2 and failureDoubleGreen2
supplyZone = threeRedCandles2 and coveringGreenCandle2 and greenFollowing2 and failuteDoubleRed2
//plot covering shadows
plotshape(redCover, style=shape.triangledown, location=location.abovebar, color=color.red)
plotshape(greenCover, style=shape.triangleup, location=location.belowbar, color=color.green)
//plot zones
if demandZone
box.new(
left=bar_index - 3,
right=bar_index + 10,
top=high[3],
bottom=low[2],
bgcolor=color.new(color.white, 90))
if supplyZone
box.new(
left=bar_index - 3,
right=bar_index + 10,
top=high[2],
bottom=low[3],
bgcolor=color.new(color.white, 90))
|
Nasdaq 100 Screener | https://www.tradingview.com/script/kTrZXrWB-Nasdaq-100-Screener/ | avsr90 | https://www.tradingview.com/u/avsr90/ | 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/
// © avsr90
//@version=5
indicator("Nasdaq100 Input Screener","N100",max_bars_back=5000)
//Input for A to B stocks
Sym0 =input.string(defval="nasdaq:aapl",title="input A to B(Use dropdown symbol ▼ to view and select Input Symbols in Input Box)",options=["nasdaq:atvi","nasdaq:adbe","nasdaq:amd","nasdaq:algn","nasdaq:googl",
"nasdaq:goog","nasdaq:amzn","nasdaq:aep","nasdaq:amgn","nasdaq:adi","nasdaq:anss","nasdaq:aapl","nasdaq:amat","nasdaq:asml",
"nasdaq:team","nasdaq:adsk", "nasdaq:adp","nasdaq:bidu","nasdaq:biib","nasdaq:bkng","nasdaq:avgo"])
//Switch of A to B stocks
Name1=switch Sym0
"nasdaq:atvi" =>"ActivisionBlizzard"
"nasdaq:adbe"=> "AdobeInformation"
"nasdaq:amd"=> "AdvancedMicroDevices"
"nasdaq:algn"=> "AlignTechnology"
"nasdaq:googl"=> "AlphabetClassA"
"nasdaq:goog"=> "AlphabetClassC "
"nasdaq:amzn"=> "Amazoncom"
"nasdaq:aep"=> "AmericanElectricPower"
"nasdaq:amgn"=> "Amgen"
"nasdaq:adi"=> "AnalogDevices"
"nasdaq:anss"=> "Ansys"
"nasdaq:aapl"=> "Apple"
"nasdaq:amat"=> "AppliedMaterials"
"nasdaq:asml"=> "ASMLHolding"
"nasdaq:team"=> "Atlassian"
"nasdaq:adsk"=> "Autodesk"
"nasdaq:adp"=> "AutomaticDataProcessing"
"nasdaq:bidu"=> "Baidu "
"nasdaq:biib"=>"Biogen "
"nasdaq:bkng"=>"BookingHoldings "
"nasdaq:avgo"=>"Broadcom"
//Inputs for C to E stocks
Sym2 =input.string(defval="nasdaq:cdns",title="input C to E(Use dropdown symbol ▼ to view and select Input Symbols in Input Box)",options=["nasdaq:cdns","nasdaq:cdw","nasdaq:chtr","nasdaq:chkp",
"nasdaq:ctas","nasdaq:csco","nasdaq:ctsh","nasdaq:cmcsa","nasdaq:cprt","nasdaq:cost","nasdaq:crwd","nasdaq:csx","nasdaq:dxcm","nasdaq:docu",
"nasdaq:dltr","nasdaq:ebay","nasdaq:ea","nasdaq:exc"])
//Switch of C to E stocks
Name2=switch Sym2
"nasdaq:cdns"=> "CadenceDesignSystems"
"nasdaq:cdw"=>"CDW"
"nasdaq:chtr"=>"Charter Communication"
"nasdaq:chkp"=>"CheckPoint"
"nasdaq:csco"=>"CiscoSystems"
"nasdaq:ctsh"=> "Cognizant"
"nasdaq:cmcsa"=>"Comcast"
"nasdaq:cprt"=>"Copart"
"nasdaq:cost"=> "Costco"
"nasdaq:crwd"=> "CrowdStrike"
"nasdaq:csx"=>"CSXCorporation"
"nasdaq:ctas"=>"Cintas Corporation"
"nasdaq:dxcm"=>"DexCom"
"nasdaq:docu"=> "DocuSign"
"nasdaq:dltr"=> "DollarTree"
"nasdaq:ebay"=>"eBay"
"nasdaq:ea"=>"ElectronicArts"
"nasdaq:exc"=>"Exelon"
//Input for F to L stocks
Sym3 =input.string(defval="nasdaq:fast",title="input F to L(Use dropdown symbol ▼ to view and select Input Symbols in Input Box)",options=["nasdaq:fast","nasdaq:fisv","nasdaq:foxa","nasdaq:fox",
"nasdaq:gild","nasdaq:hon","nasdaq:idxx","nasdaq:ilmn","nasdaq:incy","nasdaq:intc","nasdaq:intu","nasdaq:isrg","nasdaq:jd",
"nasdaq:kdp","nasdaq:klac", "nasdaq:khc","nasdaq:lrcx","nasdaq:lulu"])
//Switch of F to L stocks
Name3=switch Sym3
"nasdaq:meta"=>"Meta"
"nasdaq:fast"=>"Fastenal"
"nasdaq:fisv"=>"Fiserv"
"nasdaq:foxa"=>"FoxCorporationClassA"
"nasdaq:fox"=>"FoxCorporationClassB"
"nasdaq:gild"=>"GileadSciences"
"nasdaq:hon"=>"Honeywell"
"nasdaq:idxx"=>"IdexxLaboratories"
"nasdaq:ilmn"=>"Illumina"
"nasdaq:incy"=>"Incyte"
"nasdaq:intc"=>"Intel"
"nasdaq:intu"=> "Intuit"
"nasdaq:isrg"=> "IntuitiveSurgical"
"nasdaq:jd"=> "JDcom"
"nasdaq:kdp"=>"Keurig Dr Pepper"
"nasdaq:klac"=>"KLACorporation"
"nasdaq:khc"=>"KraftHeinz"
"nasdaq:lrcx"=>"LamResearch"
"nasdaq:lulu"=>"LululemonAthletica"
//Input for M to P stocks
Sym4 =input.string(defval="nasdaq:mar",title="input M to P (Use dropdown symbol ▼ to view and select Input Symbols in Input Box)",options=["nasdaq:mar","nasdaq:mrvl","nasdaq:mtch","nasdaq:meli",
"nasdaq:meta", "nasdaq:mchp","nasdaq:mu","nasdaq:msft", "nasdaq:mrna","nasdaq:mdlz","nasdaq:mnst","nasdaq:ntes","nasdaq:nflx",
"nasdaq:nvda","nasdaq:nxpi","nasdaq:orly","nasdaq:okta", "nasdaq:pcar", "nasdaq:payx","nasdaq:pypl","nasdaq:pton",
"nasdaq:pep","nasdaq:pdd"])
//Switch of M to P stocks
Name4=switch Sym4
"nasdaq:mar"=> "MarriottInternational"
"nasdaq:mrvl"=> "MarvellTechnology"
"nasdaq:mtch"=>"MatchGroup"
"nasdaq:meli"=>"MercadoLibre"
"nasdaq:mchp"=>"MicrochipTechnology"
"nasdaq:mu"=> "MicronTechnology "
"nasdaq:msft"=>"Microsoft"
"nasdaq:mrna"=> "Moderna",
"nasdaq:mdlz"=>"MondelezInternational"
"nasdaq:mnst"=>"MonsterBeverage "
"nasdaq:ntes"=>"NetEase "
"nasdaq:nflx"=>"Netflix "
"nasdaq:nvda"=>"Nvidia"
"nasdaq:nxpi"=> "NXPSemiconductors"
"nasdaq:orly"=>"OReillyAutomotive"
"nasdaq:okta"=>"Okta"
"nasdaq:pcar"=> "Paccar "
"nasdaq:payx"=> "Paychex"
"nasdaq:pypl"=>"PayPal "
"nasdaq:pton"=>"PelotonInteractive"
"nasdaq:pep"=>"PepsiCo",
"nasdaq:pdd"=>"Pinduoduo"
//Input for Q to Z stocks
Sym5 =input.string(defval="nasdaq:sgen",title="input Q toZ(Use dropdown symbol ▼ to view and select Input Symbols in Input Box)",options=["nasdaq:qcom","nasdaq:regn","nasdaq:rost","nasdaq:sgen",
"nasdaq:siri","nasdaq:swks","nasdaq:splk","nasdaq:sbux", "nasdaq:snps","nasdaq:tmus","nasdaq:tsla","nasdaq:txn","nasdaq:tcom",
"nasdaq:vrsn","nasdaq:vrsk", "nasdaq:vrtx","nasdaq:wba","nasdaq:wday","nasdaq:xel","nasdaq:zm"])
//Switch of Q to Z stocks
Name5=switch Sym5
"nasdaq:qcom"=>"Qualcomm"
"nasdaq:regn"=>"RegeneronPharmaceuticals"
"nasdaq:rost"=>"RossStores"
"nasdaq:sgen"=>"Seagen"
"nasdaq:siri"=>"SiriusXM"
"nasdaq:swks"=>"SkyworksSolutions"
"nasdaq:splk"=>"Splunk"
"nasdaq:sbux"=>"Starbucks"
"nasdaq:snps"=>"Synopsys"
"nasdaq:tmus"=>"TMobileUS"
"nasdaq:tsla"=>"Tesla"
"nasdaq:txn"=>"TexasInstruments"
"nasdaq:tcom"=>"TripcomGroup"
"nasdaq:vrsn"=> "Verisign"
"nasdaq:vrsk"=>"VeriskAnalytics"
"nasdaq:vrtx"=>"VertexPharmaceuticals"
"nasdaq:wba"=>"WalgreensBootsAlliance"
"nasdaq:wday"=>"Workday"
"nasdaq:xel"=>"XcelEnergy"
"nasdaq:xlnx"=>"Xilinx "
"nasdaq:zm"=>"ZoomVideoCommunicati"
//Input for A to Z stocks (All stocks)
Syma=input.string(defval="nasdaq:aapl",title="Input A to Z (Use dropdown symbol ▼ to view and select Input Symbols in Input Box)",options=["nasdaq:atvi","nasdaq:adbe","nasdaq:amd","nasdaq:algn","nasdaq:googl",
"nasdaq:goog","nasdaq:amzn","nasdaq:aep","nasdaq:amgn","nasdaq:adi","nasdaq:anss","nasdaq:aapl","nasdaq:amat","nasdaq:asml",
"nasdaq:team","nasdaq:adsk", "nasdaq:adp","nasdaq:bidu","nasdaq:biib","nasdaq:bkng","nasdaq:avgo",
"nasdaq:cdns","nasdaq:cdw","nasdaq:chtr","nasdaq:chkp","nasdaq:ctas","nasdaq:csco","nasdaq:ctsh","nasdaq:cmcsa","nasdaq:cprt",
"nasdaq:cost","nasdaq:crwd","nasdaq:csx","nasdaq:dxcm","nasdaq:docu",
"nasdaq:dltr","nasdaq:ebay","nasdaq:ea","nasdaq:exc","nasdaq:fast","nasdaq:fisv","nasdaq:foxa","nasdaq:fox",
"nasdaq:gild","nasdaq:hon","nasdaq:idxx","nasdaq:ilmn","nasdaq:incy","nasdaq:intc","nasdaq:intu","nasdaq:isrg","nasdaq:jd",
"nasdaq:kdp","nasdaq:klac", "nasdaq:khc","nasdaq:lrcx","nasdaq:lulu","nasdaq:mar","nasdaq:mrvl","nasdaq:mtch","nasdaq:meli",
"nasdaq:meta",
"nasdaq:mchp","nasdaq:mu","nasdaq:msft","nasdaq:mrna","nasdaq:mdlz","nasdaq:mnst","nasdaq:ntes","nasdaq:nflx","nasdaq:nvda",
"nasdaq:nxpi","nasdaq:orly","nasdaq:okta",
"nasdaq:pcar", "nasdaq:payx","nasdaq:pypl","nasdaq:pton","nasdaq:pep","nasdaq:pdd","nasdaq:qcom","nasdaq:regn","nasdaq:rost",
"nasdaq:sgen",
"nasdaq:siri","nasdaq:swks","nasdaq:splk","nasdaq:sbux", "nasdaq:snps","nasdaq:tmus","nasdaq:tsla","nasdaq:txn","nasdaq:tcom",
"nasdaq:vrsn","nasdaq:vrsk", "nasdaq:vrtx","nasdaq:wba","nasdaq:wday","nasdaq:xel","nasdaq:zm"])
//switch of A to Z stocks (All stocks)
Nameall=switch Syma
"nasdaq:atvi" =>"ActivisionBlizzard"
"nasdaq:adbe"=> "AdobeInformation"
"nasdaq:amd"=> "AdvancedMicroDevices"
"nasdaq:algn"=> "AlignTechnology"
"nasdaq:googl"=> "AlphabetClassA"
"nasdaq:goog"=> "AlphabetClassC "
"nasdaq:amzn"=> "Amazoncom"
"nasdaq:aep"=> "AmericanElectricPower"
"nasdaq:amgn"=> "Amgen"
"nasdaq:adi"=> "AnalogDevices"
"nasdaq:anss"=> "Ansys"
"nasdaq:aapl"=> "Apple"
"nasdaq:amat"=> "AppliedMaterials"
"nasdaq:asml"=> "ASMLHolding"
"nasdaq:team"=> "Atlassian"
"nasdaq:adsk"=> "Autodesk"
"nasdaq:adp"=> "AutomaticDataProcessing"
"nasdaq:bidu"=> "Baidu "
"nasdaq:biib"=>"Biogen "
"nasdaq:bkng"=>"BookingHoldings "
"nasdaq:avgo"=>"Broadcom"
"nasdaq:cdns"=> "CadenceDesignSystems"
"nasdaq:cdw"=>"CDW"
"nasdaq:chtr"=>"Charter Communication"
"nasdaq:chkp"=>"CheckPoint"
"nasdaq:csco"=>"CiscoSystems"
"nasdaq:ctsh"=> "Cognizant"
"nasdaq:cmcsa"=>"Comcast"
"nasdaq:cprt"=>"Copart"
"nasdaq:cost"=> "Costco"
"nasdaq:crwd"=> "CrowdStrike"
"nasdaq:csx"=>"CSXCorporation"
"nasdaq:ctas"=>"Cintas Corporation"
"nasdaq:dxcm"=>"DexCom"
"nasdaq:docu"=> "DocuSign"
"nasdaq:dltr"=> "DollarTree"
"nasdaq:ebay"=>"eBay"
"nasdaq:ea"=>"ElectronicArts"
"nasdaq:exc"=>"Exelon"
"nasdaq:meta"=>"Meta"
"nasdaq:fast"=>"Fastenal"
"nasdaq:fisv"=>"Fiserv"
"nasdaq:foxa"=>"FoxCorporationClassA"
"nasdaq:fox"=>"FoxCorporationClassB"
"nasdaq:gild"=>"GileadSciences"
"nasdaq:hon"=>"Honeywell"
"nasdaq:idxx"=>"IdexxLaboratories"
"nasdaq:ilmn"=>"Illumina"
"nasdaq:incy"=>"Incyte"
"nasdaq:intc"=>"Intel"
"nasdaq:intu"=> "Intuit"
"nasdaq:isrg"=> "IntuitiveSurgical"
"nasdaq:jd"=> "JDcom"
"nasdaq:kdp"=>"Keurig Dr Pepper"
"nasdaq:klac"=>"KLACorporation"
"nasdaq:khc"=>"KraftHeinz"
"nasdaq:lrcx"=>"LamResearch"
"nasdaq:lulu"=>"LululemonAthletica"
"nasdaq:mar"=> "MarriottInternational"
"nasdaq:mrvl"=> "MarvellTechnology"
"nasdaq:mtch"=>"MatchGroup"
"nasdaq:meli"=>"MercadoLibre"
"nasdaq:mchp"=>"MicrochipTechnology"
"nasdaq:mu"=> "MicronTechnology "
"nasdaq:msft"=>"Microsoft"
"nasdaq:mrna"=> "Moderna",
"nasdaq:mdlz"=>"MondelezInternational"
"nasdaq:mnst"=>"MonsterBeverage "
"nasdaq:ntes"=>"NetEase "
"nasdaq:nflx"=>"Netflix "
"nasdaq:nvda"=>"Nvidia"
"nasdaq:nxpi"=> "NXPSemiconductors"
"nasdaq:orly"=>"OReillyAutomotive"
"nasdaq:okta"=>"Okta"
"nasdaq:pcar"=> "Paccar "
"nasdaq:payx"=> "Paychex"
"nasdaq:pypl"=>"PayPal "
"nasdaq:pton"=>"PelotonInteractive"
"nasdaq:pep"=>"PepsiCo",
"nasdaq:pdd"=>"Pinduoduo"
"nasdaq:qcom"=>"Qualcomm"
"nasdaq:regn"=>"RegeneronPharmaceuticals"
"nasdaq:rost"=>"RossStores"
"nasdaq:sgen"=>"Seagen"
"nasdaq:siri"=>"SiriusXM"
"nasdaq:swks"=>"SkyworksSolutions"
"nasdaq:splk"=>"Splunk"
"nasdaq:sbux"=>"Starbucks"
"nasdaq:snps"=>"Synopsys"
"nasdaq:tmus"=>"TMobileUS"
"nasdaq:tsla"=>"Tesla"
"nasdaq:txn"=>"TexasInstruments"
"nasdaq:tcom"=>"TripcomGroup"
"nasdaq:vrsn"=> "Verisign"
"nasdaq:vrsk"=>"VeriskAnalytics"
"nasdaq:vrtx"=>"VertexPharmaceuticals"
"nasdaq:wba"=>"WalgreensBootsAlliance"
"nasdaq:wday"=>"Workday"
"nasdaq:xel"=>"XcelEnergy"
"nasdaq:xlnx"=>"Xilinx "
"nasdaq:zm"=>"ZoomVideoCommunicati"
//Resolutions
Resn=input.timeframe(defval="",title="resolution")
Resn1=input.timeframe(defval="D",title="resolution")
//Nasdaq Index input
Sym=input.symbol(defval="nasdaq:ndx",title="Nasdaq")
Nift= request.security(Sym ,Resn1,close[1],barmerge.gaps_off, barmerge.lookahead_on)
//length from Day open
Nifnum= ta.change(Nift)
Lb=int(math.max(1, nz(ta.barssince(Nifnum)) + 1))
//Lengths for various Table parameters
Lfor_Atr=input.int(defval=14,title="LforAtr")
Lfor_Rsi=input.int(defval=14,title="L for Rsi")
Lfor_Cci=input.int(defval=20,title="Lfor CCI")
Lfor_Dmi=input.int(defval=14,title="Lfor Dmi")
Lfor_Dmisig=input.int(defval=14,title="LfordmiSig")
Lfor_Mom=input.int(defval=10,title="lfor Mom")
Lfor_Cmo=input.int(defval=9,title="lfor CMO")
//Chaikin Money Flow parameter
var cumVol = 0.
cumVol += nz(volume)
Lfor_Cmf= input.int(20, minval=1,title="LforCMF")
ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume
cmf = math.sum(ad, Lfor_Cmf) / math.sum(volume,Lfor_Cmf )
//Macd and Signal
[macdline, signalline, _] = ta.macd(close, 12, 26, 9)
[_, _, adx] = ta.dmi(Lfor_Dmi,Lfor_Dmisig)
//SMA calculations
Sma20=math.round_to_mintick(ta.sma(close,20))
Sma50=math.round_to_mintick(ta.sma(close,50))
Sma200=math.round_to_mintick(ta.sma(close,200))
//Table parameters
cle=math.round_to_mintick(close)
oc1=math.round_to_mintick(cle-cle[1])
adin=math.round_to_mintick(ta.roc(cle,Lb))
adi1=math.round_to_mintick(Sma20)
max_bars_back(adi1,500)
adi2=math.round_to_mintick(cle-Sma20)
max_bars_back(adi2,500)
adi3=math.round_to_mintick(Sma50)
max_bars_back(adi3,500)
adi4=math.round_to_mintick(cle-Sma50)
max_bars_back(adi4,500)
adi5=math.round_to_mintick(Sma200)
max_bars_back(adi5,500)
adi6=math.round_to_mintick(cle-Sma200)
max_bars_back(adi6,500)
adi7=math.round_to_mintick(adx)
max_bars_back(adi7,500)
adi8=math.round_to_mintick(ta.rsi(cle,Lfor_Rsi))
max_bars_back(adi8,500)
adi9=math.round_to_mintick(ta.cci(hlc3,Lfor_Cci))
max_bars_back(adi9,500)
adi10=math.round_to_mintick(ta.atr(Lfor_Atr))
max_bars_back(adi10,500)
adi11=math.round_to_mintick(ta.mom(cle,Lfor_Mom))
max_bars_back(adi11,500)
adi12=math.round_to_mintick(ta.cmo(cle,Lfor_Cmo) )
max_bars_back(adi12,500)
adi13=math.round_to_mintick(cmf )
max_bars_back(adi13,500)
adi14=math.round_to_mintick(macdline )
max_bars_back(adi14,500)
adi15=math.round_to_mintick(signalline )
max_bars_back(adi15,500)
//Table parameters retrieval
[nif,cl,dif,avgn]= request.security(Sym ,Resn1,[cle[1],cle,oc1,adin],barmerge.gaps_off, barmerge.lookahead_on)
[a20,a20d,a50,a50d,a200,a200d,dx,r,c,atr,mom,nvv,mf,macd,sig]=request.security(Sym ,Resn,[adi1,adi2,adi3,adi4,adi5,adi6,adi7,adi8,
adi9,adi10,adi11,adi12,adi13,adi14,adi15], barmerge.gaps_off, barmerge.lookahead_on)
[nif1,cl1,dif1,avgn1]=request.security(Sym0 ,Resn1,[cle[1],cle,oc1,adin],barmerge.gaps_off, barmerge.lookahead_on)
[a201,a20d1,a501,a50d1,a2001,a200d1,dx1,r1,c1,atr1,mom1,nvv1,mf1,macd1,sig1]=request.security(Sym0 ,Resn,[adi1,adi2,adi3,adi4,adi5,
adi6,adi7,adi8,adi9,adi10,adi11,adi12,adi13,adi14,adi15],barmerge.gaps_off, barmerge.lookahead_on)
[nif2,cl2,dif2,avgn2]=request.security(Sym2 ,Resn1,[cle[1],cle,oc1,adin],barmerge.gaps_off, barmerge.lookahead_on)
[a202,a20d2,a502,a50d2,a2002,a200d2,dx2,r2,c2,atr2,mom2,nvv2,mf2,macd2,sig2]=request.security(Sym2 ,Resn,[adi1,adi2,adi3,adi4,adi5,
adi6, adi7,adi8,adi9,adi10,adi11,adi12,adi13,adi14,adi15], barmerge.gaps_off, barmerge.lookahead_on)
[nif3,cl3,dif3,avgn3]=request.security(Sym3 ,Resn1,[cle[1],cle,oc1,adin],barmerge.gaps_off, barmerge.lookahead_on)
[a203,a20d3,a503,a50d3,a2003,a200d3,dx3,r3,c3,atr3,mom3,nvv3,mf3,macd3,sig3]=request.security(Sym3 ,Resn,[adi1,adi2,adi3,adi4,adi5,
adi6,adi7,adi8,adi9,adi10,adi11,adi12,adi13,adi14,adi15], barmerge.gaps_off, barmerge.lookahead_on)
[nif4,cl4,dif4,avgn4]=request.security(Sym4 ,Resn1,[cle[1],cle,oc1,adin],barmerge.gaps_off, barmerge.lookahead_on)
[a204,a20d4,a504,a50d4,a2004,a200d4,dx4,r4,c4,atr4,mom4,nvv4,mf4,macd4,sig4]=request.security(Sym4 ,Resn,[adi1,adi2,adi3,adi4,adi5,
adi6,adi7,adi8,adi9,adi10,adi11,adi12,adi13,adi14,adi15], barmerge.gaps_off, barmerge.lookahead_on)
[nif5,cl5,dif5,avgn5]=request.security(Sym5 ,Resn1,[cle[1],cle,oc1,adin],barmerge.gaps_off, barmerge.lookahead_on)
[a205,a20d5,a505,a50d5,a2005,a200d5,dx5,r5,c5,atr5,mom5,nvv5,mf5,macd5,sig5]=request.security(Sym5 ,Resn,[adi1,adi2,adi3,adi4,adi5,
adi6,adi7,adi8,adi9,adi10,adi11,adi12,adi13,adi14,adi15],barmerge.gaps_off, barmerge.lookahead_on)
[nif6,cl6,dif6,avgn6]=request.security(Syma ,Resn1,[cle[1],cle,oc1,adin],barmerge.gaps_off, barmerge.lookahead_on)
[a206,a20d6,a506,a50d6,a2006,a200d6,dx6,r6,c6,atr6,mom6,nvv6,mf6,macd6,sig6]=request.security(Syma ,Resn,[adi1,adi2,adi3,adi4,adi5,
adi6,adi7,adi8,adi9,adi10,adi11,adi12,adi13,adi14,adi15], barmerge.gaps_off, barmerge.lookahead_on)
//Table
BorderThickness = 1
TableWidth = 0
Tableheight=0
TableLocation = input.string("top_left", title='Select Table Position',options=["top_left","top_center","top_right",
"middle_left","middle_center","middle_right","bottom_left","bottom_center","bottom_right"] ,
tooltip="Default location is at top_ left")
TableTextSize = input.string("Auto", title='Select Table Text Size',options=["Auto","Huge","Large","Normal","Small",
"Tiny"] , tooltip="Default Text Size is Auto")
celltextsize = switch TableTextSize
"Auto" => size.auto
"Huge" => size.huge
"Large" => size.large
"Normal" => size.normal
"Small" => size.small
"Tiny" => size.tiny
//colors
TBGcol=input.color(defval=color.new(#ffffff,0),title="BG color")
cellcol=input.color(defval=color.new(#c2e1b4,20),title="column header BG color")
cellcol1=input.color(defval=color.new(#c2e1b4,20),title="column header BG color")
ctexcol=input.color(defval=color.new(#000000,0),title="column header textcolor")
var table t = table.new (position=TableLocation,columns=30,rows= 50, bgcolor=TBGcol,frame_color=color.black,frame_width=2,
border_color=color.gray,border_width=BorderThickness)
if barstate.islast
table.cell(t, 1, 4,"Index" ,text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol,text_halign=text.align_left)
table.cell(t, 2, 4,"Name" ,text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 4,"Op",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 4, 4,"LaP",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 5, 4,"O-L",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 6, 4,"ROC",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 7, 4,"Sma20",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 8,4,"s20d",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 9, 4,"Sma50",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 10, 4,"s50d",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 11, 4,"Sma200", text_size=celltextsize,width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 12,4,"s200d",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 13,4,"ADX(14)",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 14,4,"RSI(14)",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 15,4,"CCI(20)",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 16,4,"ATR(14)",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 17,4,"MOM(10)",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 18,4,"CMO",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 19,4,"CMF(20)",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 20,4,"Macd",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 21,4,"Sig",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol,text_color=ctexcol)
table.cell(t, 2, 5, "Nasdaq",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol1,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 5, str.tostring(nif),text_size=celltextsize, width=TableWidth,height=Tableheight,text_color=color.blue,
text_halign=text.align_right)
table.cell(t, 4, 5, str.tostring(cl),text_size=celltextsize, width=TableWidth,text_color=cl>cl[1]? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 5, 5, str.tostring(dif),text_size=celltextsize, width=TableWidth,text_color=dif>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 6, 5, str.tostring(avgn),text_size=celltextsize, width=TableWidth,text_color=avgn>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 7, 5, str.tostring(a20),text_size=celltextsize, width=TableWidth, text_color= color.blue,height=Tableheight)
table.cell(t, 8, 5, str.tostring(a20d),text_size=celltextsize, width=TableWidth,text_color=a20d>0? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 9, 5, str.tostring(a50),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 10, 5, str.tostring(a50d),text_size=celltextsize, width=TableWidth,text_color=a50d>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 11, 5, str.tostring(a200),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 12, 5, str.tostring(a200d),text_size=celltextsize, width=TableWidth, text_color=a200d>0 ?color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 13, 5, str.tostring(dx),text_size=celltextsize, width=TableWidth, text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 14, 5, str.tostring(r),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 15, 5, str.tostring(c),text_size=celltextsize, width=TableWidth, text_color=c>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 16, 5, str.tostring(atr),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 17, 5, str.tostring(mom),text_size=celltextsize, width=TableWidth, text_color=mom>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 18, 5, str.tostring(nvv),text_size=celltextsize, width=TableWidth, text_color=nvv>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 19, 5, str.tostring(mf),text_size=celltextsize, width=TableWidth, text_color=mf>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 20, 5, str.tostring(macd),text_size=celltextsize, width=TableWidth, text_color=macd>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 21, 5, str.tostring(sig),text_size=celltextsize, width=TableWidth, text_color=sig>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 1, 6, "A to B",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=TBGcol,text_color=color.fuchsia,
text_halign=text.align_left)
table.cell(t, 2, 6, str.tostring(Name1),text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol1,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 6, str.tostring(nif1),text_size=celltextsize, width=TableWidth,height=Tableheight,text_color=color.blue,
text_halign=text.align_right)
table.cell(t, 4, 6, str.tostring(cl1),text_size=celltextsize, width=TableWidth,text_color=cl1>cl1[1]? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 5, 6, str.tostring(dif1),text_size=celltextsize, width=TableWidth,text_color=dif1>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 6, 6, str.tostring(avgn1),text_size=celltextsize, width=TableWidth,text_color=avgn1>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 7, 6, str.tostring(a201),text_size=celltextsize, width=TableWidth, text_color= color.blue,height=Tableheight)
table.cell(t, 8, 6, str.tostring(a20d1),text_size=celltextsize, width=TableWidth,text_color=a20d1>0? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 9, 6, str.tostring(a501),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 10, 6, str.tostring(a50d1),text_size=celltextsize, width=TableWidth,text_color=a50d1>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 11, 6, str.tostring(a2001),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 12, 6, str.tostring(a200d1),text_size=celltextsize, width=TableWidth, text_color=a200d1>0 ?color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 13, 6, str.tostring(dx1),text_size=celltextsize, width=TableWidth, text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 14, 6, str.tostring(r1),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 15, 6, str.tostring(c1),text_size=celltextsize, width=TableWidth, text_color=c1>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 16, 6, str.tostring(atr1),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 17, 6, str.tostring(mom1),text_size=celltextsize, width=TableWidth, text_color=mom1>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 18, 6, str.tostring(nvv1),text_size=celltextsize, width=TableWidth, text_color=nvv1>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 19, 6, str.tostring(mf1),text_size=celltextsize, width=TableWidth, text_color=mf1>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 20, 6, str.tostring(macd1),text_size=celltextsize, width=TableWidth, text_color=macd1>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 21, 6, str.tostring(sig1),text_size=celltextsize, width=TableWidth, text_color=sig1>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 1, 7, "C to E",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=TBGcol,text_color=color.fuchsia,
text_halign=text.align_left)
table.cell(t, 2, 7, str.tostring(Name2),text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol1,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 7, str.tostring(nif2),text_size=celltextsize, width=TableWidth,height=Tableheight,text_color=color.blue,
text_halign=text.align_right)
table.cell(t, 4, 7, str.tostring(cl2),text_size=celltextsize, width=TableWidth,text_color=cl2>cl2[1]? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 5, 7, str.tostring(dif2),text_size=celltextsize, width=TableWidth,text_color=dif2>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 6, 7, str.tostring(avgn2),text_size=celltextsize, width=TableWidth,text_color=avgn2>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 7, 7, str.tostring(a202),text_size=celltextsize, width=TableWidth, text_color= color.blue,height=Tableheight)
table.cell(t, 8, 7, str.tostring(a20d2),text_size=celltextsize, width=TableWidth,text_color=a20d2>0? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 9, 7, str.tostring(a502),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 10, 7, str.tostring(a50d2),text_size=celltextsize, width=TableWidth,text_color=a50d2>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 11, 7, str.tostring(a2002),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 12, 7, str.tostring(a200d2),text_size=celltextsize, width=TableWidth, text_color=a200d2>0 ?color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 13, 7, str.tostring(dx2),text_size=celltextsize, width=TableWidth, text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 14, 7, str.tostring(r2),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 15, 7, str.tostring(c2),text_size=celltextsize, width=TableWidth, text_color=c2>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 16, 7, str.tostring(atr2),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 17, 7, str.tostring(mom2),text_size=celltextsize, width=TableWidth, text_color=mom2>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 18, 7, str.tostring(nvv2),text_size=celltextsize, width=TableWidth, text_color=nvv2>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 19, 7, str.tostring(mf2),text_size=celltextsize, width=TableWidth, text_color=mf2>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 20, 7, str.tostring(macd2),text_size=celltextsize, width=TableWidth, text_color=macd2>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 21, 7, str.tostring(sig2),text_size=celltextsize, width=TableWidth, text_color=sig2>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 1, 8, "F to L",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=TBGcol,text_color=color.fuchsia,
text_halign=text.align_left)
table.cell(t, 2, 8, str.tostring(Name3),text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol1,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 8, str.tostring(nif3),text_size=celltextsize, width=TableWidth,height=Tableheight,text_color=color.blue,
text_halign=text.align_right)
table.cell(t, 4, 8, str.tostring(cl3),text_size=celltextsize, width=TableWidth,text_color=cl3>cl3[1]? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 5, 8, str.tostring(dif3),text_size=celltextsize, width=TableWidth,text_color=dif3>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 6, 8, str.tostring(avgn3),text_size=celltextsize, width=TableWidth,text_color=avgn3>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 7, 8, str.tostring(a203),text_size=celltextsize, width=TableWidth, text_color= color.blue,height=Tableheight)
table.cell(t, 8, 8, str.tostring(a20d3),text_size=celltextsize, width=TableWidth,text_color=a20d3>0? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 9, 8, str.tostring(a503),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 10, 8, str.tostring(a50d3),text_size=celltextsize, width=TableWidth,text_color=a50d3>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 11, 8, str.tostring(a2003),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 12, 8, str.tostring(a200d3),text_size=celltextsize, width=TableWidth, text_color=a200d3>0 ?color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 13, 8, str.tostring(dx3),text_size=celltextsize, width=TableWidth, text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 14, 8, str.tostring(r3),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 15, 8, str.tostring(c3),text_size=celltextsize, width=TableWidth, text_color=c3>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 16, 8, str.tostring(atr3),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 17, 8, str.tostring(mom3),text_size=celltextsize, width=TableWidth, text_color=mom3>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 18, 8, str.tostring(nvv3),text_size=celltextsize, width=TableWidth, text_color=nvv3>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 19, 8, str.tostring(mf3),text_size=celltextsize, width=TableWidth, text_color=mf3>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 20, 8, str.tostring(macd3),text_size=celltextsize, width=TableWidth, text_color=macd3>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 21, 8, str.tostring(sig3),text_size=celltextsize, width=TableWidth, text_color=sig3>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 1, 9, "M to P",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=TBGcol,text_color=color.fuchsia,
text_halign=text.align_left)
table.cell(t, 2, 9, str.tostring(Name4),text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol1,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 9, str.tostring(nif4),text_size=celltextsize, width=TableWidth,height=Tableheight,text_color=color.blue,
text_halign=text.align_right)
table.cell(t, 4, 9, str.tostring(cl4),text_size=celltextsize, width=TableWidth,text_color=cl4>cl4[1]? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 5, 9, str.tostring(dif4),text_size=celltextsize, width=TableWidth,text_color=dif4>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 6, 9, str.tostring(avgn4),text_size=celltextsize, width=TableWidth,text_color=avgn4>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 7, 9, str.tostring(a204),text_size=celltextsize, width=TableWidth, text_color= color.blue,height=Tableheight)
table.cell(t, 8, 9, str.tostring(a20d4),text_size=celltextsize, width=TableWidth,text_color=a20d4>0? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 9, 9, str.tostring(a504),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 10, 9, str.tostring(a50d4),text_size=celltextsize, width=TableWidth,text_color=a50d4>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 11, 9, str.tostring(a2004),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 12, 9, str.tostring(a200d4),text_size=celltextsize, width=TableWidth, text_color=a200d4>0 ?color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 13, 9, str.tostring(dx4),text_size=celltextsize, width=TableWidth, text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 14, 9, str.tostring(r4),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 15, 9, str.tostring(c4),text_size=celltextsize, width=TableWidth, text_color=c4>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 16, 9, str.tostring(atr4),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 17, 9, str.tostring(mom4),text_size=celltextsize, width=TableWidth, text_color=mom4>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 18, 9, str.tostring(nvv4),text_size=celltextsize, width=TableWidth, text_color=nvv4>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 19, 9, str.tostring(mf4),text_size=celltextsize, width=TableWidth, text_color=mf4>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 20, 9, str.tostring(macd4),text_size=celltextsize, width=TableWidth, text_color=macd4>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 21, 9, str.tostring(sig4),text_size=celltextsize, width=TableWidth, text_color=sig4>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 1, 10, "R to Z",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=TBGcol,text_color=color.fuchsia,
text_halign=text.align_left)
table.cell(t, 2, 10, str.tostring(Name5),text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol1,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 10, str.tostring(nif5),text_size=celltextsize, width=TableWidth,height=Tableheight,text_color=color.blue,
text_halign=text.align_right)
table.cell(t, 4, 10, str.tostring(cl5),text_size=celltextsize, width=TableWidth,text_color=cl5>cl5[1]? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 5, 10, str.tostring(dif5),text_size=celltextsize, width=TableWidth,text_color=dif5>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 6, 10, str.tostring(avgn5),text_size=celltextsize, width=TableWidth,text_color=avgn5>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 7, 10, str.tostring(a205),text_size=celltextsize, width=TableWidth, text_color= color.blue,height=Tableheight)
table.cell(t, 8, 10, str.tostring(a20d5),text_size=celltextsize, width=TableWidth,text_color=a20d5>0? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 9, 10, str.tostring(a505),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 10, 10, str.tostring(a50d5),text_size=celltextsize, width=TableWidth,text_color=a50d5>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 11, 10, str.tostring(a2005),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 12, 10, str.tostring(a200d5),text_size=celltextsize, width=TableWidth, text_color=a200d5>0 ?color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 13, 10, str.tostring(dx5),text_size=celltextsize, width=TableWidth, text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 14, 10, str.tostring(r5),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 15, 10, str.tostring(c5),text_size=celltextsize, width=TableWidth, text_color=c5>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 16, 10, str.tostring(atr5),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 17, 10, str.tostring(mom5),text_size=celltextsize, width=TableWidth, text_color=mom5>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 18, 10, str.tostring(nvv5),text_size=celltextsize, width=TableWidth, text_color=nvv5>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 19, 10, str.tostring(mf5),text_size=celltextsize, width=TableWidth, text_color=mf5>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 20, 10, str.tostring(macd5),text_size=celltextsize, width=TableWidth, text_color=macd5>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 21, 10, str.tostring(sig5),text_size=celltextsize, width=TableWidth, text_color=sig5>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 1, 11, "A to Z",text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=TBGcol,text_color=color.blue,
text_halign=text.align_left)
table.cell(t, 2, 11, str.tostring(Nameall),text_size=celltextsize, width=TableWidth,height=Tableheight,bgcolor=cellcol1,text_color=ctexcol,
text_halign=text.align_left)
table.cell(t, 3, 11, str.tostring(nif6),text_size=celltextsize, width=TableWidth,height=Tableheight,text_color=color.blue,
text_halign=text.align_right)
table.cell(t, 4, 11, str.tostring(cl6),text_size=celltextsize, width=TableWidth,text_color=cl6>cl6[1]? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 5, 11, str.tostring(dif6),text_size=celltextsize, width=TableWidth,text_color=dif6>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 6, 11, str.tostring(avgn6),text_size=celltextsize, width=TableWidth,text_color=avgn6>0 ? color.green:
color.red,height=Tableheight,text_halign=text.align_right)
table.cell(t, 7, 11, str.tostring(a206),text_size=celltextsize, width=TableWidth, text_color= color.blue,height=Tableheight)
table.cell(t, 8, 11, str.tostring(a20d6),text_size=celltextsize, width=TableWidth,text_color=a20d6>0? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 9, 11, str.tostring(a506),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 10, 11, str.tostring(a50d6),text_size=celltextsize, width=TableWidth,text_color=a50d6>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 11, 11, str.tostring(a2006),text_size=celltextsize, width=TableWidth,text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 12, 11, str.tostring(a200d6),text_size=celltextsize, width=TableWidth, text_color=a200d6>0 ?color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 13, 11, str.tostring(dx6),text_size=celltextsize, width=TableWidth, text_color=color.blue,height=Tableheight,
text_halign=text.align_right)
table.cell(t, 14, 11, str.tostring(r6),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 15, 11, str.tostring(c6),text_size=celltextsize, width=TableWidth, text_color=c6>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 16, 11, str.tostring(atr6),text_size=celltextsize, width=TableWidth, text_color=color.blue,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 17, 11, str.tostring(mom6),text_size=celltextsize, width=TableWidth, text_color=mom6>0 ? color.green:color.red,
height=Tableheight, text_halign=text.align_right)
table.cell(t, 18, 11, str.tostring(nvv6),text_size=celltextsize, width=TableWidth, text_color=nvv6>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 19, 11, str.tostring(mf6),text_size=celltextsize, width=TableWidth, text_color=mf6>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 20, 11, str.tostring(macd6),text_size=celltextsize, width=TableWidth, text_color=macd6>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
table.cell(t, 21, 11, str.tostring(sig6),text_size=celltextsize, width=TableWidth, text_color=sig6>0 ? color.green:color.red,
height=Tableheight,text_halign=text.align_right)
|
Real-time price distribution in candles | https://www.tradingview.com/script/MXzvxEyu-Real-time-price-distribution-in-candles/ | Dicargo_Beam | https://www.tradingview.com/u/Dicargo_Beam/ | 104 | 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/
// © Dicargo_Beam
//@version=5
indicator("Real-time price distribution in candles", overlay=true)
int sec = math.floor((timenow-time)/1000)
varip p = array.new_float(31)
varip term = math.floor((time_close-time)/1000 /30)
if barstate.isnew
for i = 0 to 30
array.set(p,i,na)
array.set(p,0,open)
for i = 1 to 30
if sec < i * term + 1 and sec > i * term - 1
array.set(p,i,close)
col_op = input.color(color.new(color.yellow,50),"Open color")
col_cl = input.color(color.new(color.aqua,50),"Close color")
col = input.color(color.new(color.gray,50),"Real-time color")
width = input.int(2)
plot(array.get(p,0), color=col_op, style=plot.style_circles, linewidth = width)
plot(array.get(p,1), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,2), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,3), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,4), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,5), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,6), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,7), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,8), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,9), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,10), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,11), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,12), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,13), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,14), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,15), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,16), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,17), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,18), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,19), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,20), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,21), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,22), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,23), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,24), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,25), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,26), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,27), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,28), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,29), color=col, style=plot.style_circles, linewidth = width)
plot(array.get(p,30), color=col_cl, style=plot.style_circles, linewidth = width)
|
Disclaimer | https://www.tradingview.com/script/FW1OhogS-Disclaimer/ | Mr_Nikoru | https://www.tradingview.com/u/Mr_Nikoru/ | 7 | 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/
// © Mr_Nikoru
//@version=5
indicator("Disclaimer", overlay=true)
txt_disclaimer_line1 = input.string("This is not a signal service. It will be used for educational chart mark ups and explanations. Trading is done at your own risk.","Disclaimer text line 1")
txt_disclaimer_line2 = input.string("",title= "Disclaimer text line 2")
txt_disclaimer_line3 = input.string("",title= "Disclaimer text line 3")
pos_disclaimer = input.string(position.top_right, "Disclaimer Position", 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])
box_color = input.color(color.gray,"Box Colour")
txt_color = input.color(color.black,"Text Colour")
var disclaimer = table.new(pos_disclaimer,columns = 1, rows = 4, bgcolor = box_color, border_width = 1)
table.cell(disclaimer,0,0,text = "Disclaimer",text_color = txt_color, text_halign = text.align_center)
table.cell(disclaimer,0,1,text = txt_disclaimer_line1,text_color = txt_color, text_halign = text.align_center)
if txt_disclaimer_line2 != ""
table.cell(disclaimer,0,2,text = txt_disclaimer_line2,text_color = txt_color, text_halign = text.align_center)
if txt_disclaimer_line3 != ""
table.cell(disclaimer,0,3,text = txt_disclaimer_line3,text_color = txt_color, text_halign = text.align_center)
|
Bitcoin Stalemate Indicator | https://www.tradingview.com/script/LcSdRUPg-Bitcoin-Stalemate-Indicator/ | DamonAndTheSea | https://www.tradingview.com/u/DamonAndTheSea/ | 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/
// © DamonAndTheSea
//@version=5
indicator(title="Bitcoin Stalemate Indicator")
//Collect BTC volume from top exchanges
volBinance = request.security('BINANCE:BTCUSDT', timeframe.period, expression=volume)
volCoinbase = request.security('COINBASE:BTCUSD', timeframe.period, expression=volume)
volBitfinex = request.security('BITFINEX:BTCUSD', timeframe.period, expression=volume)
volGemini = request.security('GEMINI:BTCUSD', timeframe.period, expression=volume)
volHuobi = request.security('HUOBI:BTCUSDT', timeframe.period, expression=volume)
volOKX = request.security('OKX:BTCUSDT', timeframe.period, expression=volume)
//Populate array with all exchange volume values
float [] exchangeVol = array.new_float(0)
array.push(exchangeVol, volBinance)
array.push(exchangeVol, volCoinbase)
array.push(exchangeVol, volBitfinex)
array.push(exchangeVol, volGemini)
array.push(exchangeVol, volHuobi)
array.push(exchangeVol, volOKX)
//Create exchange bool checkbox inputs for UI
includesBinanceInput = input.bool(true, "Include Binance")
includesCoinbaseInput = input.bool(true, "Include Coinbase")
includesBitfinexInput = input.bool(true, "Include Bitfinex")
includesGeminiInput = input.bool(true, "Include Gemini")
includesHuobiInput = input.bool(true, "Include Huobi")
includesOKXInput = input.bool(true, "Include OKX")
//Populate array with all the checkbox bool values
bool [] exchangeInputs = array.new_bool(0)
array.push(exchangeInputs, includesBinanceInput)
array.push(exchangeInputs, includesCoinbaseInput)
array.push(exchangeInputs, includesBitfinexInput)
array.push(exchangeInputs, includesGeminiInput)
array.push(exchangeInputs, includesHuobiInput)
array.push(exchangeInputs, includesOKXInput)
//exchange and vol vars
float avgVol = 0.0
int totalNumExchangesIncluded = 0
//loop through input checkbox array to combine volume from each selected exchange
for i = 0 to (array.size(exchangeInputs) - 1)
input = array.get(exchangeInputs, i)
if input == true
totalNumExchangesIncluded := totalNumExchangesIncluded + 1
avgVol := avgVol + array.get(exchangeVol, i)
//Divide by total included exchanges to average
avgVol := avgVol/totalNumExchangesIncluded
//Get candle size as a percentage of close value
candleSizePct = (high - low)/close
//Stalemate amplitude is canlde volume over the candle size percentage. Divided by 100000 to scale down to more readable numbers
stalemateAmplitude = avgVol/candleSizePct/100000
//Create sma period input UI
periodInput = input.int(title="SMA Period", defval=5)
//Smooth stalemateAmplitude with SMA
stalemateSMA = ta.sma(stalemateAmplitude, periodInput)
//Convert timeframe to minutes float
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60. :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 1440. :
timeframe.isweekly ? 10080. :
timeframe.ismonthly ? 43800. : na)
//Chained ternary operator to smooth out heat map for different timeframes
numMin = f_resInMinutes()
targetThresh = (numMin <= 3 ? math.log10(numMin) :
numMin <= 60 ? math.log10(numMin) * 1 :
numMin <= 240 ? math.log10(numMin) * 1.25 :
numMin <= 720 ? math.log10(numMin) * 2 :
numMin <= 1440 ? math.log10(numMin) * 3 :
numMin <= 4320 ? math.log10(numMin) * 4 :
numMin <= 10080 ? math.log10(numMin) * 5 :
numMin <= 43800 ? math.log10(numMin) * 6.5 :
numMin > 43800 ? math.log10(numMin) * 9 : na)
//Create input for heatmap checkbox
showsHeatmap = input.bool(true, "Show Heatmap")
//Check if all exchanges represented. Heatmap is disabled unless all are selected
bool isAllExchanges = totalNumExchangesIncluded == array.size(exchangeInputs)
//Define the target threshold for the heatmap
isTargetThresh = stalemateSMA > targetThresh
//Transparency value is keyed to strength of indicator value for readability
transparency_val = 100 - ((stalemateSMA - targetThresh) * 5)
//Plot UI
bgcolor(isTargetThresh and showsHeatmap and isAllExchanges ? color.new(color.lime, transparency_val) : na)
plot(stalemateSMA, color=color.fuchsia)
|
Kase Peak Oscillator w/ Divergences [Loxx] | https://www.tradingview.com/script/vifAv2En-Kase-Peak-Oscillator-w-Divergences-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 220 | 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("Kase Peak Oscillator w/ Divergences [Loxx]",
shorttitle="KPOD [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
darkGreenColor = #1B7E02
darkRedColor = #93021F
kpoDeviations = input.float(2.0, "Deviations", group= "Basic Settings") // Kase peak oscillator deviations
kpoShortCycle = input.int(8, "Short Cycle Period", group= "Basic Settings") // Kase peak oscillator short cycle
kpoLongCycle = input.int(65, "Long Cycle Period", group= "Basic Settings") // Kase peak oscillator long cycle
kpoSensitivity = input.float(40, "Sensitivity", group= "Basic Settings") // Kase peak oscillator sensitivity
allPeaksMode = input.bool(true, "Show all peaks?", group= "Basic Settings") // Show all peaks?
colorbars = input.bool(false, "Color bars?", group= "UI Options")
mutebars = input.bool(false, "Mute bars?", group= "UI Options")
lbR = input(title="Pivot Lookback Right", defval=5, group = "Divergences Settings")
lbL = input(title="Pivot Lookback Left", defval=5, group = "Divergences Settings")
rangeUpper = input(title="Max of Lookback Range", defval=60, group = "Divergences Settings")
rangeLower = input(title="Min of Lookback Range", defval=5, group = "Divergences Settings")
plotBull = input(title="Plot Bullish", defval=true, group = "Divergences Settings")
plotHiddenBull = input(title="Plot Hidden Bullish", defval=false, group = "Divergences Settings")
plotBear = input(title="Plot Bearish", defval=true, group = "Divergences Settings")
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false, group = "Divergences Settings")
bearColor = darkRedColor
bullColor = darkGreenColor
hiddenBullColor = color.new(darkGreenColor, 80)
hiddenBearColor = color.new(darkRedColor, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
x1 = 0.
xs = 0.
x1 := nz(x1[1])
xs := nz(xs[1])
ccLog = math.log(close / nz(close[1]))
ccDev = ta.stdev(ccLog, 9)
avg = ta.sma(ccDev, 30)
max1 = 0.
maxs = 0.
for k = kpoShortCycle to kpoLongCycle - 1
max1 := math.max(math.log(high / nz(low[k])) / math.sqrt(k), max1)
maxs := math.max(math.log(nz(high[k]) / low) / math.sqrt(k), maxs)
x1 := max1 / avg
xs := maxs / avg
xp = kpoSensitivity * (ta.sma(x1, 3) - ta.sma(xs, 3))
xpAbs = math.abs(xp)
kppBuffer = 0.
kpoBuffer = xp
kphBuffer = xp
tmpVal = ta.sma(xpAbs, 50) + kpoDeviations * (ta.stdev(xpAbs, 50))
maxVal = math.max(90.0, tmpVal)
minVal = math.min(90.0, tmpVal)
kpdBuffer = 0.
kpmBuffer = 0.
if kpoBuffer > 0.
kpdBuffer := maxVal
kpmBuffer := minVal
else
kpdBuffer := -maxVal
kpmBuffer := -minVal
if (not allPeaksMode)
if (nz(kpoBuffer[1]) > 0 and nz(kpoBuffer[1]) > kpoBuffer and nz(kpoBuffer[1]) >= nz(kpoBuffer[2]) and nz(kpoBuffer[1]) >= maxVal)
kppBuffer := kpoBuffer
if (nz(kpoBuffer[1]) < 0 and nz(kpoBuffer[1]) < kpoBuffer and nz(kpoBuffer[1]) <= nz(kpoBuffer[2]) and nz(kpoBuffer[1]) <= -maxVal)
kppBuffer := kpoBuffer
else
if (nz(kpoBuffer[1]) > 0 and nz(kpoBuffer[1]) > kpoBuffer and nz(kpoBuffer[1]) >= nz(kpoBuffer[2]))
kppBuffer := kpoBuffer
if (nz(kpoBuffer[1]) < 0 and nz(kpoBuffer[1]) < kpoBuffer and nz(kpoBuffer[1]) <= nz(kpoBuffer[2]))
kppBuffer := kpoBuffer
plot(kpoBuffer, "Kase Peak Oscillator", color = color.gray)
plot(kphBuffer, "Kase Peak Oscillator Histogram", color = color.gray, style=plot.style_histogram)
plot(kpdBuffer, "Max Peak Value", color = color.yellow, linewidth = 1) //Blue Kpeak-Min line is a maximum of two standard deviations of the PeakOscillator value.
plot(kpmBuffer, "Min Peak Value", color = color.white, linewidth = 1) //Red PeakOut line is a minimum of two standard deviations of the PeakOscillator value
colorout = kppBuffer ? kppBuffer > 0 ? redcolor : greencolor : mutebars ? color.gray : na
plot(kppBuffer, "Market Extreme", color = kppBuffer ? colorout : na, style = plot.style_histogram, linewidth = 3)
barcolor(colorbars ? colorout : na)
osc = kpoBuffer
plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
//------------------------------------------------------------------------------
// Regular Bullish
// Osc: Higher Low
oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
// Price: Lower Low
priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1)
bullCond = plotBull and priceLL and oscHL and plFound
plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor)
)
plotshape(
bullCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text="R",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------------------------------------------------------------------------------
// Hidden Bullish
// Osc: Lower Low
oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
// Price: Higher Low
priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1)
hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound
plot(
plFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullCond ? hiddenBullColor : noneColor)
)
plotshape(
hiddenBullCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text="H",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------------------------------------------------------------------------------
// Regular Bearish
// Osc: Lower High
oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
// Price: Higher High
priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1)
bearCond = plotBear and priceHH and oscLH and phFound
plot(
phFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor)
)
plotshape(
bearCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text="R",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
//------------------------------------------------------------------------------
// Hidden Bearish
// Osc: Higher High
oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
// Price: Lower High
priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1)
hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound
plot(
phFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearCond ? hiddenBearColor : noneColor)
)
plotshape(
hiddenBearCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text="H",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
goLong = kppBuffer < 0
goShort = kppBuffer > 0
alertcondition(goLong, title="Long", message="Kase Peak Oscillator w/ Divergences [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Kase Peak Oscillator w/ Divergences [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBearCond, title="Hidden Bear Divergence", message="Kase Peak Oscillator w/ Divergences [Loxx]: Hidden Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bearCond, title="Regular Bear Divergence", message="Kase Peak Oscillator w/ Divergences [Loxx]: Regular Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBullCond, title="Hidden Bull Divergence", message="Kase Peak Oscillator w/ Divergences [Loxx]: Hidden Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bullCond, title="Regular Bull Divergence", message="Kase Peak Oscillator w/ Divergences [Loxx]: Regular Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
|
MA20 Hi-Lo-Close Magic Band | https://www.tradingview.com/script/5JjCh5CG-MA20-Hi-Lo-Close-Magic-Band/ | phd16ashokp | https://www.tradingview.com/u/phd16ashokp/ | 23 | 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/
// © phd16ashokp AKPHUF-PP
//@version=4
study(title="MA20 HiLoClo", shorttitle="MA20HLC Band", overlay=true)
ln = input(20, minval=1, title="Length20Lo")
sr = input(low, title="Source")
out = sma(sr, ln)
lnn = input(20, minval=1, title="Length20Hi")
srr = input(high, title="Source")
outt = sma(srr, lnn)
lnm = input(20, minval=1, title="Length20Cl")
srt = input(close, title="Source")
outtt = sma(srt, lnm)
plot(out, color=color.red, title="MA20Lo")
plot(outt, color=color.blue, title="MA20Hi")
plot(outtt, color=color.olive, title="MA20Cl") |
Sector Rotation | https://www.tradingview.com/script/8sz9Dow4-Sector-Rotation/ | Vignesh_vish | https://www.tradingview.com/u/Vignesh_vish/ | 787 | 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/
// © Vignesh_vish
//@version=5
indicator("Sector Rotation",max_boxes_count=500)
Highlight=input.string(defval="None",title="Highlite",options=["None","BNF","IT","PRMA","FMCG","AUTO","MTAL","MDIA","RLTY","IFRA","ENGY","PSU-B","PVT-B","F-SRV","CONSM","C-DUBL"],inline="Highlite",group="Sector to Highlight")
highliteColor=input.color(defval=color.orange,title="Highlite Color",inline="Highlite",group="Sector to Highlight")
IT_SorH=input.bool(true,title="IT (IT)",group="Sector to Plot")
BN_SorH=input.bool(true,title="BANKNIFTY (BNF)",group="Sector to Plot")
PHARMA_SorH=input.bool(true,title="CNX-PHARMA (PRMA)",group="Sector to Plot")
FMCG_SorH=input.bool(true,title="CNX-FMCG (FMCG)",group="Sector to Plot")
AUTO_SorH=input.bool(true,title="CNX-AUTO (AUTO)",group="Sector to Plot")
METAL_SorH=input.bool(true,title="CNX-METAL (MTAL)",group="Sector to Plot")
MEDIA_SorH=input.bool(true,title="CNX-MEDIA (MDIA)",group="Sector to Plot")
REALITY_SorH=input.bool(true,title="CNX-REALTY (RLTY)",group="Sector to Plot")
INFRA_SorH=input.bool(true,title="CNX-INFRA (IFRA)",group="Sector to Plot")
ENERGY_SorH=input.bool(true,title="CNX-ENERGY (ENGY)",group="Sector to Plot")
PSUBANK_SorH=input.bool(true,title="CNX-PSUBANK (PSU-B)",group="Sector to Plot")
PVTBANK_SorH=input.bool(true,title="NIFTY-PVTBANK (PVT-B)",group="Sector to Plot")
FINANCE_SorH=input.bool(true,title="CNX-FINANCE (F-SRV)",group="Sector to Plot")
CONSUMPTION_SorH=input.bool(true,title="CNXCONSUMPTION (CONSM)",group="Sector to Plot")
CONSUMERDURBL_SorH=input.bool(true,title="NIFTY_CONSR_DURBL (C-DUBL)",group="Sector to Plot")
ITClose=request.security("CNXIT",timeframe.period,close)
BNClose=request.security("BANKNIFTY",timeframe.period,close)
PHARMAClose=request.security("CNXPHARMA",timeframe.period,close)
FMCGClose=request.security("CNXFMCG",timeframe.period,close)
AUTOClose=request.security("CNXAUTO",timeframe.period,close)
METALClose=request.security("CNXMETAL",timeframe.period,close)
MEDIAClose=request.security("CNXMEDIA",timeframe.period,close)
REALITYClose=request.security("CNXREALTY",timeframe.period,close)
INFRAClose=request.security("CNXINFRA",timeframe.period,close)
ENERGYClose=request.security("CNXENERGY",timeframe.period,close)
PSUBANKClose=request.security("CNXPSUBANK",timeframe.period,close)
PVTBANKClose=request.security("NIFTYPVTBANK",timeframe.period,close)
FINANCEClose=request.security("CNXFINANCE",timeframe.period,close)
CONSUMPTIONClose=request.security("CNXCONSUMPTION",timeframe.period,close)
CONSUMERDURBLClose=request.security("NIFTY_CONSR_DURBL",timeframe.period,close)
bool[] SorH_Arr=array.from(BN_SorH,IT_SorH,PHARMA_SorH,FMCG_SorH,AUTO_SorH,METAL_SorH,MEDIA_SorH,REALITY_SorH,INFRA_SorH,ENERGY_SorH,PSUBANK_SorH,PVTBANK_SorH,FINANCE_SorH,CONSUMPTION_SorH,CONSUMERDURBL_SorH)
float[] secuCloseArr=array.from(BNClose,ITClose,PHARMAClose,FMCGClose,AUTOClose,METALClose,MEDIAClose,REALITYClose,INFRAClose,ENERGYClose,PSUBANKClose,PVTBANKClose,FINANCEClose,CONSUMPTIONClose,CONSUMERDURBLClose)
float[] secuPreCloseArr=array.from(BNClose[1],ITClose[1],PHARMAClose[1],FMCGClose[1],AUTOClose[1],METALClose[1],MEDIAClose[1],REALITYClose[1],INFRAClose[1],ENERGYClose[1],PSUBANKClose[1],PVTBANKClose[1],FINANCEClose[1],CONSUMPTIONClose[1],CONSUMERDURBLClose[1])
string[] inxName=array.from("BNF","IT","PRMA","FMCG","AUTO","MTAL","MDIA","RLTY","IFRA","ENGY","PSU-B","PVT-B","F-SRV","CONSM","C-DUBL")
indexName=array.new_string()
perChArr=array.new_float()
for i=0 to array.size(SorH_Arr)-1
if(array.get(SorH_Arr,i))
cls=math.round(((array.get(secuCloseArr,i)-array.get(secuPreCloseArr,i))/array.get(secuPreCloseArr,i))*100,2)
array.push(perChArr,cls)
array.push(indexName,array.get(inxName,i))
currentSymbolPerCh=math.round(((close-close[1])/close[1])*100,2)
perChArrGTZ_unSorted=array.new_float()
indexNameGTZ_unSorted=array.new_string()
perChArrLTZ_unSorted=array.new_float()
indexNameLTZ_unSorted=array.new_string()
var int LtPos=na
var int GtPos=na
//separating -ve and +ve array
for i=0 to array.size(perChArr)-1
if(array.get(perChArr,i)>=0)
array.push(perChArrGTZ_unSorted,array.get(perChArr,i))
array.push(indexNameGTZ_unSorted,array.get(indexName,i))
else
array.push(perChArrLTZ_unSorted,array.get(perChArr,i))
array.push(indexNameLTZ_unSorted,array.get(indexName,i))
//sorting +ve array
positiveBox=array.new_box()
negativeBox=array.new_box()
boxC(I_id,T_top,B_bottom,T_txt,BG_color,BC_color)=>
array.push(I_id,box.new(bar_index,T_top,bar_index+1,B_bottom,text=T_txt,bgcolor=color.new(BG_color,80),border_color=color.new(BC_color,50),text_halign=text.align_left,text_size=size.small))
float boxSpace=0.0
float boxSpaceCluster=0.0
if (timeframe.period=="D")
boxSpace:=0.07
boxSpaceCluster:=0.06
else if(timeframe.period=="W")
boxSpace:=0.14
boxSpaceCluster:=0.12
else if(timeframe.period=="M")
boxSpace:=0.23
boxSpaceCluster:=0.21
else if(timeframe.isintraday)
boxSpace:=0.05
boxSpaceCluster:=0.04
if(time>=chart.left_visible_bar_time and time<=chart.right_visible_bar_time)
if(array.size(perChArrGTZ_unSorted)>0)
for i=0 to array.size(perChArrGTZ_unSorted)-1
lowinx=i
for j=i to array.size(perChArrGTZ_unSorted)-1
if(array.get(perChArrGTZ_unSorted,j)<array.get(perChArrGTZ_unSorted,lowinx))
lowinx:=j
temp=array.get(perChArrGTZ_unSorted,lowinx)
array.set(perChArrGTZ_unSorted,lowinx,array.get(perChArrGTZ_unSorted,i))
array.set(perChArrGTZ_unSorted,i,temp)
Ntemp=array.get(indexNameGTZ_unSorted,lowinx)
array.set(indexNameGTZ_unSorted,lowinx,array.get(indexNameGTZ_unSorted,i))
array.set(indexNameGTZ_unSorted,i,Ntemp)
currentMaxTopValue=0.0
currentMaxBottomValue=0.0
//positiveBox=array.new_box()
string txt=na
for i=0 to array.size(perChArrGTZ_unSorted)-1
HLC=array.get(indexNameGTZ_unSorted,i)==Highlight?highliteColor:color.green
if(i==0)
boxC(positiveBox,array.get(perChArrGTZ_unSorted,i)+boxSpace,array.get(perChArrGTZ_unSorted,i)," "+str.tostring(array.get(indexNameGTZ_unSorted,i))+" "+str.tostring(array.get(perChArrGTZ_unSorted,i))+"%",color.green,HLC)
currentMaxTopValue:=array.get(perChArrGTZ_unSorted,i)+boxSpace
currentMaxBottomValue:=array.get(perChArrGTZ_unSorted,i)
txt:=str.tostring(array.get(indexNameGTZ_unSorted,i))+" "+str.tostring(array.get(perChArrGTZ_unSorted,i))+"%"
else
if (array.get(perChArrGTZ_unSorted,i)>currentMaxTopValue)
boxC(positiveBox,array.get(perChArrGTZ_unSorted,i)+boxSpace,array.get(perChArrGTZ_unSorted,i)," "+str.tostring(array.get(indexNameGTZ_unSorted,i))+" "+str.tostring(array.get(perChArrGTZ_unSorted,i))+"%",color.green,HLC)
currentMaxTopValue:=array.get(perChArrGTZ_unSorted,i)+boxSpace
currentMaxBottomValue:=array.get(perChArrGTZ_unSorted,i)
txt:=str.tostring(array.get(indexNameGTZ_unSorted,i))+" "+str.tostring(array.get(perChArrGTZ_unSorted,i))+"%"
else
txt:=str.tostring(array.get(indexNameGTZ_unSorted,i))+" "+str.tostring(array.get(perChArrGTZ_unSorted,i))+"%"+"\n"+txt
HLC:=str.contains(txt,Highlight)?highliteColor:color.blue
txtArr=str.split(txt,"\n")
wordCount=0
for s=0 to array.size(txtArr)-1
if str.length(array.get(txtArr,s))>1
wordCount:=wordCount+1
top=array.get(perChArrGTZ_unSorted,i)>(currentMaxBottomValue+(wordCount*boxSpaceCluster))?array.get(perChArrGTZ_unSorted,i):currentMaxBottomValue+(wordCount*boxSpaceCluster)
box.set_text(array.get(positiveBox,array.size(positiveBox)-1), txt)
box.set_top(array.get(positiveBox,array.size(positiveBox)-1),top)
box.set_bottom(array.get(positiveBox,array.size(positiveBox)-1),currentMaxBottomValue)
box.set_border_color(array.get(positiveBox,array.size(positiveBox)-1),HLC)
box.set_bgcolor(array.get(positiveBox,array.size(positiveBox)-1),color.new(color.green,80))
currentMaxTopValue:=top//array.get(perChArrGTZ_unSorted,i)+array.get(perChArrGTZ_unSorted,i)>(currentMaxBottomValue+(wordCount*0.04))?array.get(perChArrGTZ_unSorted,i):currentMaxBottomValue+(wordCount*0.04)
if array.max(perChArr)>=0
line.new(bar_index,currentMaxTopValue,bar_index+1,currentMaxTopValue,color=color.new(color.blue,0),width=2)
if array.min(perChArr)>=0
line.new(bar_index,array.min(perChArr),bar_index+1,array.min(perChArr),color=color.new(color.blue,0),width=2)
if array.size(positiveBox)>0
for i=0 to array.size(positiveBox)-1
array.get(positiveBox,i)
//negative Array
if(array.size(perChArrLTZ_unSorted)>0)
for i=0 to array.size(perChArrLTZ_unSorted)-1
highinx=i
for j=i to array.size(perChArrLTZ_unSorted)-1
if(array.get(perChArrLTZ_unSorted,j)>array.get(perChArrLTZ_unSorted,highinx))
highinx:=j
temp=array.get(perChArrLTZ_unSorted,highinx)
array.set(perChArrLTZ_unSorted,highinx,array.get(perChArrLTZ_unSorted,i))
array.set(perChArrLTZ_unSorted,i,temp)
Ntemp=array.get(indexNameLTZ_unSorted,highinx)
array.set(indexNameLTZ_unSorted,highinx,array.get(indexNameLTZ_unSorted,i))
array.set(indexNameLTZ_unSorted,i,Ntemp)
currentMaxTopValue=0.0
currentMaxBottomValue=0.0
//positiveBox=array.new_box()
string txt=na
for i=0 to array.size(perChArrLTZ_unSorted)-1
HLC=array.get(indexNameLTZ_unSorted,i)==Highlight?highliteColor:color.red
if(i==0)
boxC(negativeBox,array.get(perChArrLTZ_unSorted,i),array.get(perChArrLTZ_unSorted,i)-boxSpace," "+str.tostring(array.get(indexNameLTZ_unSorted,i))+" "+str.tostring(array.get(perChArrLTZ_unSorted,i))+"%",color.red,HLC)
currentMaxTopValue:=array.get(perChArrLTZ_unSorted,i)
currentMaxBottomValue:=array.get(perChArrLTZ_unSorted,i)-boxSpace
txt:=str.tostring(array.get(indexNameLTZ_unSorted,i))+" "+str.tostring(array.get(perChArrLTZ_unSorted,i))+"%"
else
if(array.get(perChArrLTZ_unSorted,i)<currentMaxBottomValue)
boxC(negativeBox,array.get(perChArrLTZ_unSorted,i),array.get(perChArrLTZ_unSorted,i)-boxSpace," "+str.tostring(array.get(indexNameLTZ_unSorted,i))+" "+str.tostring(array.get(perChArrLTZ_unSorted,i))+"%",color.red,HLC)
currentMaxTopValue:=array.get(perChArrLTZ_unSorted,i)
currentMaxBottomValue:=array.get(perChArrLTZ_unSorted,i)-boxSpace
txt:=str.tostring(array.get(indexNameLTZ_unSorted,i))+" "+str.tostring(array.get(perChArrLTZ_unSorted,i))+"%"
else
txt:=txt+"\n"+str.tostring(array.get(indexNameLTZ_unSorted,i))+" "+str.tostring(array.get(perChArrLTZ_unSorted,i))+"%"
HLC:=str.contains(txt,Highlight)?highliteColor:color.blue
txtArr=str.split(txt,"\n")
wordCount=0
for s=0 to array.size(txtArr)-1
if str.length(array.get(txtArr,s))>1
wordCount:=wordCount+1
bottom=array.get(perChArrLTZ_unSorted,i)<(currentMaxTopValue-(wordCount*boxSpaceCluster))?array.get(perChArrLTZ_unSorted,i):currentMaxTopValue-(wordCount*boxSpaceCluster)
box.set_text(array.get(negativeBox,array.size(negativeBox)-1), txt)
box.set_top(array.get(negativeBox,array.size(negativeBox)-1),currentMaxTopValue)
box.set_bottom(array.get(negativeBox,array.size(negativeBox)-1),bottom)
box.set_border_color(array.get(negativeBox,array.size(negativeBox)-1),HLC)
box.set_bgcolor(array.get(negativeBox,array.size(negativeBox)-1),color.new(color.red,80))
currentMaxBottomValue:=bottom
if array.max(perChArr)<0
line.new(bar_index,array.max(perChArr),bar_index+1,array.max(perChArr),color=color.new(color.blue,0),width=2)
if array.min(perChArr)<0
line.new(bar_index,currentMaxBottomValue,bar_index+1,currentMaxBottomValue,color=color.new(color.blue,0),width=2)
if array.size(negativeBox)>0
for i=0 to array.size(negativeBox)-1
array.get(negativeBox,i)
hline(0,title="LineZero",color=color.blue,linewidth=2,linestyle=hline.style_dotted)
colr=currentSymbolPerCh>=0?color.green:color.red
vline= if ta.change(time("M"))and (timeframe.period=="D" or timeframe.period=="W")
line.new(bar_index,-0.02,bar_index,0.02,extend=extend.both,color=color.new(color.gray,0),width=1)
plotshape(currentSymbolPerCh,title="Current Symbol Percentage Change",style=shape.square,location= location.absolute,color=colr,size=size.tiny,display=display.price_scale + display.pane) |
Om RSI | https://www.tradingview.com/script/fPahtAgn-Om-RSI/ | OmPSoni1987 | https://www.tradingview.com/u/OmPSoni1987/ | 9 | 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/
// © OmPSoni1987
//@version=4
study("Om ORB RSI", overlay = false)
// timeframes 5,1hr, 1 day
tf1 = input('5', type=input.resolution)
tf2 = input('60', type=input.resolution)
tf3 = input('375', type=input.resolution)
//RSI
RSI = rsi(close, 14)
//
s0 = security(syminfo.tickerid, timeframe.period, RSI)
s1 = security(syminfo.tickerid, tf1, RSI)
s2 = security(syminfo.tickerid, tf2, RSI)
s3 = security(syminfo.tickerid, tf3, RSI)
WMA = wma (RSI,21)
PEMA = ema (RSI,3)
plot (RSI, "RSI 14", color= color.white)
plot (WMA, "21 WMA RSI", color= color.red)
plot (PEMA, "3 EMA RSI", color= color.green)
plot (50)
plot(s1,title= "5 Min", color=color.gray, linewidth=2)
plot(s2,title= "1 Hour", color=color.yellow, linewidth=2)
plot(s3,title= "1 Day", color=color.blue, linewidth=2) |
T3 Velocity Candles [Loxx] | https://www.tradingview.com/script/yIXq20GM-T3-Velocity-Candles-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 71 | 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("T3 Velocity Candles [Loxx]",
shorttitle='T3VC [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_iT3(src, per, hot, clean)=>
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 + (per - 1.0) / 2.0)
else
alpha := 2.0 / (1.0 + per)
_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
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Source Settings")
srcin = input.string("HAB Trend Biased (Extreme)", "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)"])
per = input.int(32, "Period", group= "Basic Settings")
t3hot = input.float(.7, "T3 Hot", group= "Basic Settings")
t3swt = input.string("T3 New", "T3 Type", options = ["T3 New", "T3 Original"], group = "Basic Settings")
ColorNorm = input.int(20, "Coloring Period", group= "Basic Settings")
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")
clrup = input.color(greencolor, "Up color", group = "UI Options")
clrdn = input.color(redcolor, "Down color", group = "UI Options")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
vel = _iT3(src, per, t3hot, t3swt) - _iT3(src, per, t3hot/2, t3swt)
fmin = ta.lowest(vel, ColorNorm)
fmax = ta.highest(vel, ColorNorm)
sto = 100 * (vel - fmin) / (fmax - fmin)
colorout = color.from_gradient(sto, 0, 100, clrdn, clrup)
barcolor(colorout)
|
Sortino Ratio | https://www.tradingview.com/script/l2CkJikC-Sortino-Ratio/ | JoeCA9772 | https://www.tradingview.com/u/JoeCA9772/ | 27 | 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/
// © JoeCA9772
//@version=5
indicator(title="Sortino Ratio", overlay=false)
// determine annualization factor (not all timeframes are currently supported)
days = input(365, title="Trading Days In A Year")
multiplier = if (timeframe.period == "60") // hourly
days * 24
else if (timeframe.period == "D") // daily
days
else if (timeframe.period == "W") // weekly
days / 52
else if (timeframe.period == "M") // monthly
days / 12
// number of bars to include in the calculation
window = input(1460, title="Lookback Window")
// zero, risk-free rate, etc. (example: for Fed average inflation target of 2%, use 2 and not 0.02)
r = input(0, title="Minimum Acceptable Return Percentage") / 100
// 1-period log-return
ret = math.log(close / close[1])
// piecewise squared difference considering only negative log-returns
sq_diff = if ret < 0
math.pow(ret - r, 2)
else
0
// annualized expected return
mean_ret = ta.sma(ret, window) * multiplier
// annualized downside deviation
dn_dev = math.sqrt(ta.sma(sq_diff, window) * multiplier)
// Sortino Ratio
sortino = (mean_ret - r) / dn_dev
// background
fill(hline(0, linestyle=hline.style_solid, color=color.rgb(255,255,255,90)), hline(1, linestyle=hline.style_dashed), color=color.rgb(255,0,0,95))
plot(sortino, color=color.rgb(255,0,0,50))
|
T3 Striped [Loxx] | https://www.tradingview.com/script/HNzSGutO-T3-Striped-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 871 | 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("T3 Striped [Loxx]",
shorttitle="T3S [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_iT3(src, per, hot, clean)=>
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 + (per - 1.0) / 2.0)
else
alpha := 2.0 / (1.0 + per)
_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
lev0 = _t30
lev1 = _t31
lev2 = _t32
lev3 = _t33
lev4 = _t34
lev5 = _t35
[lev0, lev1, lev2, lev3, lev4, lev5]
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)"])
per = input.int(14, "Period", group= "Basic Settings")
t3hot = input.float(.7, "T3 Hot", group= "Basic Settings")
t3swt = input.string("T3 New", "T3 Type", options = ["T3 New", "T3 Original"], 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
[lev0, lev1, lev2, lev3, lev4, lev5] = _iT3(src, per, t3hot, t3swt)
colorout = lev0 < lev1 and lev0 > lev5 ? color.gray : lev0 > lev5 ? greencolor : redcolor
pl0 = plot(lev0, "level 0", color = colorout, linewidth = 2)
pl1 = plot(lev1, "level 1", color = colorout, linewidth = 2)
pl2 = plot(lev2, "level 2", color = colorout, linewidth = 2)
pl3 = plot(lev3, "level 3", color = colorout, linewidth = 2)
pl4 = plot(lev4, "level 4", color = colorout, linewidth = 2)
pl5 = plot(lev5, "level 5", color = colorout, linewidth = 2)
fill(pl0, pl1, color = color.new(colorout, 25))
fill(pl1, pl2, color = color.new(colorout, 40))
fill(pl2, pl3, color = color.new(colorout, 55))
fill(pl3, pl4, color = color.new(colorout, 70))
fill(pl4, pl5, color = color.new(colorout, 85))
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(lev0, lev5)
goShort = ta.crossunder(lev0, lev5)
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 = "T3 Striped [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "T3 Striped [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
HHV & LLV based Trend | https://www.tradingview.com/script/nZSDgGwU-HHV-LLV-based-Trend/ | NumberGames | https://www.tradingview.com/u/NumberGames/ | 105 | 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/
// © NumberGames
/////////////////////////////////////////////////////////////////////////////////////////
//// UP trend: HHV_fastline = HHV Slowline and LLVfastline crossover LLVSlowline /////
/// DOWN trend: HHV_fastline crossunder HHV Slowline and LLVfastline !=LLVSlowline /////
////////////////////////////////////////////////////////////////////////////////////////
//@version=4
study("HHV & LLV based Trend", overlay=true,resolution="",resolution_gaps=false)
fastline=input(3,title="FastLine")
slowline=input(10,title="SlowLine")
HHV3 = highest(high, fastline)
LLV3 = lowest(low, fastline)
HHV10 = highest(high, slowline)
LLV10 = lowest(low, slowline)
h3=plot(HHV3, color=HHV3==HHV10?na:#ff009b, linewidth=2, title="HHV3")
l3=plot(LLV3, color=LLV3==LLV10?na:#00ffa0, linewidth=2, title="LLV3")
h10=plot(HHV10, color=HHV3==HHV10?na:#ff009b, linewidth=2, title="HHV10")
l10=plot(LLV10, color=LLV3==LLV10?na:#00ffa0, linewidth=2, title="LLV10")
fill(h3,h10,color=color.orange,transp=20)
fill(l3,l10,color=color.green,transp=20)
|
MACD Modified | https://www.tradingview.com/script/c923lS4l-MACD-Modified/ | Ronald_Ryninger | https://www.tradingview.com/u/Ronald_Ryninger/ | 105 | 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/
// © Ron_C
//Code is built upon TradingView MACD Indicator
//@version=5
indicator("MACD Modified", shorttitle = "MACD MOD")
//------------ Inputs {
//MACD Inputs
macdType = input.string(title = "MACD Calculation", defval = "Traditional", options = ["Traditional","Modified"], group = "MACD")
fastLength = input(title="Fast Length", defval=12, group = "MACD")
slowLength = input(title="Slow Length", defval=26, group = "MACD")
src = input(title="Source", defval=close, group = "MACD")
signalLength = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9, group ="MACD")
smaSource = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"], group = "MACD")
smaSignal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"], group = "MACD")
// Plot colors
colMacd = input(#2962FF, "MACD Line ", group="Color Settings", inline="MACD")
colSignal = input(#FF6D00, "Signal Line ", group="Color Settings", inline="Signal")
colGrowAbove = input(#26A69A, "Above Grow", group="Histogram", inline="Above")
colFallAbove = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
colGrowBelow = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
colFallBelow = input(#FF5252, "Fall", group="Histogram", inline="Below")
colBetweenOSOB = input(color.new(color.blue,70), title = "Between OB/OS", group = "Overbought/Oversold", inline = "Above")
//Overbought Oversold Type
obosStyle = input.string("Pivot", options = ["Pivot", "Bollinger Bands", "Previous High/Low"], title = "OB/OS Type", group = "Overbought/Oversold Condition")
//}
//------------ MACD {
fastMA = smaSource == "SMA" ? ta.sma(src, fastLength) : ta.ema(src, fastLength)
slowMA = smaSource == "SMA" ? ta.sma(src, slowLength) : ta.ema(src, slowLength)
macd = macdType == "Traditional" ? fastMA - slowMA : ((fastMA - slowMA) / slowMA)*100
signal = smaSignal == "SMA" ? ta.sma(macd, signalLength) : ta.ema(macd, signalLength)
hist = macd - signal
//Plots
plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? colGrowAbove : colFallAbove) : (hist[1] < hist ? colGrowBelow : colFallBelow)))
plot(macd, title="MACD", color=colMacd)
plot(signal, title="Signal", color=colSignal)
//}
//------------ MACD Overbought and Oversold{
//Pivots Inputs
pivotHighLimit = input(0, title = "Pivots High Lower Limit", group = "Pivots")
pivotLowLimit = input(0, title = "Pivots Low Upper Limit", group = "Pivots")
sizeInput = input.int(10, "Array size", minval = 0, maxval = 100000, group = "Pivots")
pivotStrength = input.int(5, "Pivot Strength", minval = 0, maxval = 100000, group = "Pivots")
//Pivots Variables
var pivotLowPlot = float(na)
var pivotLowCross = color(na)
var pivotHighPlot = float(na)
var pivotHighCross = color(na)
var pivotHighAvgArray = float(na)
var pivotLowAvgArray = float(na)
//Bollinger Band Variables
var middle = float(na)
var upper = float(na)
var lower = float(na)
var dev = float(na)
bbLength = input(200, title = "Length", group = "Bollinger Bands")
bbStdDev = input(2, title = "Number of Standard Deviations", group = "Bollinger Bands")
bbSource = input.string("MACD", title = "Source", options = ["MACD", "Signal"], group = "Bollinger Bands")
bbSrce = bbSource == "MACD" ? macd : signal
//Previous High/Low Variables
var pivotLowPlotHL = float(na)
var pivotHighPlotHL = float(na)
//Pivots Calcs
if obosStyle == "Pivot"
var lowPivots = array.new_float(sizeInput)
var highPivots = array.new_float(sizeInput)
pivotLow = ta.pivotlow(macd, pivotStrength, pivotStrength)
pivotHigh = ta.pivothigh(macd, pivotStrength, pivotStrength)
if pivotLow < pivotLowLimit
pivotLowCross := color.new(color.red,0)
if array.size(lowPivots) == sizeInput
array.shift(lowPivots)
array.push(lowPivots, pivotLow)
pivotLowPlot := pivotLow
else
array.push(lowPivots, pivotLow)
else
pivotLowCross := color(na)
if pivotHigh > pivotHighLimit
pivotHighCross := color.new(color.green,0)
if array.size(highPivots) == sizeInput
array.shift(highPivots)
array.push(highPivots, pivotHigh)
pivotHighPlot := pivotHigh
else
array.push(highPivots, pivotHigh)
else
pivotHighCross := color(na)
pivotLowAvgArray := array.avg(lowPivots)
pivotHighAvgArray := array.avg(highPivots)
//Bollinger Band Calcs
else if obosStyle == "Bollinger Bands"
middle := ta.sma(bbSrce, bbLength)
dev := bbStdDev * ta.stdev(bbSrce, bbLength)
upper := middle + dev
lower := middle - dev
//Previous High/Low
else
pivotLow = ta.pivotlow(macd, pivotStrength, pivotStrength)
pivotHigh = ta.pivothigh(macd, pivotStrength, pivotStrength)
if pivotLow < 0
pivotLowPlotHL := pivotLow
if pivotHigh > 0
pivotHighPlotHL := pivotHigh
//}
//------------ MACD Overbought and Oversold Plots{
//Pivots
//Plot Crosses
plot(pivotLowPlot, title = "Oversold Marker", style = plot.style_cross, color = pivotLowCross, linewidth = 3, offset=-pivotStrength)
plot(pivotHighPlot, title = "Overbought Marker", style = plot.style_cross, color = pivotHighCross, linewidth = 3, offset=-pivotStrength)
//Plot Overbought and Oversold Lines
p1 = plot(pivotHighAvgArray, title = "Overbought Pivot", color=color.purple)
p2 =plot(pivotLowAvgArray, title = "Oversold Pivot", color=color.purple)
hline(0.0, color=color.black, linestyle=hline.style_dotted, linewidth=1)
fill(p1, p2, color = colBetweenOSOB)
//Bollinger Bands
plot(middle, color=color.yellow, title = "BB Middle")
p3 = plot(upper, color=color.blue, title = "BB Upper")
p4 = plot(lower, color=color.blue, title = "BB Lower")
fill(p3, p4, color = colBetweenOSOB)
//Previous High/Low
p5 = plot(pivotLowPlotHL, title = "Previous Low")
p6 = plot(pivotHighPlotHL, title = "Previous High")
fill(p5, p6, color = colBetweenOSOB)
//} |
(Quartile Vol.; Vol. Aggregation; Range US Bars; Gaps) [Kioseff] | https://www.tradingview.com/script/DF63CmXh-Quartile-Vol-Vol-Aggregation-Range-US-Bars-Gaps-Kioseff/ | KioseffTrading | https://www.tradingview.com/u/KioseffTrading/ | 996 | 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/
// © KioseffTrading
//@version=5
indicator("(Quartile Volume; Volume Aggregation; US Range Bars; Gaps) [Kioseff Trading]", overlay = true,
max_labels_count = 500 ,
max_boxes_count = 500 ,
max_lines_count = 500 ,
max_bars_back = 500
)
// ________________________________________________
// | |
// | --------------------------------- |
// | | K̲ i̲ o̲ s̲ e̲ f̲ f̲ T̲ r̲ a̲ d̲ i̲ n̲ g | |
// | | | |
// | | ƃ u ᴉ p ɐ ɹ ꓕ ⅎ ⅎ ǝ s o ᴉ ꓘ | |
// | -------------------------------- |
// | |
// |_______________________________________________|
// _______________________________________________________
//
// Inputs
// _______________________________________________________
// => Range US Params <=
show = input.string(defval = "Quartile Volume", title = "Dataset", options = ["Range US", "Volume Aggregation", "Gaps", "Quartile Volume"] )
fast = input.bool (defval = false , title = "Improve Loading Time?" , tooltip = "Selecting This Box Improves Load Times; However, Data More Than 7,500 Bars Old Will Not be Calculated. This Setting Does Not Improve Initial Compilation Time.")
tra = input.string(defval = "Auto" , title = "Auto Range US Candles? Or User-Defined?" , group = "Range US", options = ["Auto", "Custom"] )
rev = input.float (defval = 22 , title = "Reverse Candle Price Move" , group = "Range US", minval = 0.0000000001 )
tre = input.float (defval = 44 , title = "Trend Candle Price Move" , group = "Range US", minval = 0.0000000001 )
ranShow = input.bool (defval = false , title = "Segment Range US Bars By Date?" , group = "Range US" )
levShow = input.bool (defval = true , title = "Show Trend/Reverse Levels?" , group = "Range US" )
warn1 = input.bool (defval = true , title = "Show Warning?" , group = "Range US" )
sz = input.string(defval = "Tiny" , title = "Box Text Size (Auto Increases Chart Lag)" , group = "Range US", tooltip = "Box Text Size for Range US Candles.'Auto' Size May Cause Chart Lag" ,
options = ["Auto", "Tiny", "Small", "Normal", "Large", "Huge"] )
treShow = input.int(defval= 7 , title = "Number of Congestion Areas to Show (0 = None)" , group = "Range US", minval = 0 )
move = input.bool(defval = true , title = "Move Current Range US Bar to Levels Section?" , group = "Range US")
// => Volume Aggregation Params <=
tra1 = input.string(defval = "Auto" , title = "Auto Volume Aggregation Candles? Or User-Defined?", group = "Volume Aggregation", options = ["Auto", "Custom"] )
volInt = input.int (defval = 1000000 , title = "Required Volume", step = 10000 , group = "Volume Aggregation" )
vShow = input.bool (defval = false , title = "Segment Vol. Aggregation Bars By Date?" , group = "Volume Aggregation" )
sz1 = input.string(defval = "Tiny" , title = "Box Text Size (Auto Increases Chart Lag)" , group = "Volume Aggregation", tooltip = "Box Text Size for Range US Candles.'Auto' Size May Cause Chart Lag",
options = ["Auto", "Tiny", "Small", "Normal", "Large", "Huge"] )
showAl = input.bool (defval = true , title = "Show Largest Increases and Decreases?" , group = "Volume Aggregation" )
showUp = input.int (defval = 15 , title = "Number of Largest Volume Agg. Increases to Show", group = "Volume Aggregation", minval = 1,maxval = 20 )
showDn = input.int (defval = 15 , title = "Number of Largest Volume Agg. Decreases to Show", group = "Volume Aggregation", minval = 1,maxval = 20 )
warn = input.bool (defval = true , title = "Show Warning?" , group = "Volume Aggregation" )
// => Gaps Params <=
perG = input.float (defval = 0 , title = "Percentage Difference For Gap to Appear" , group = "Gaps", step = 0.1, minval = 0 ) /100
old = input.float (defval = -1 , title = "Hide Gaps When Price Deviates by Percentage" , group = "Gaps", minval = -1, tooltip = "Configuring This Setting to “-1” Will Keep All Gaps on the Chart. Configuring This Setting at or Above “0” Will Hide Gap Boxes if Price Moves the Percentage Amount Away From the Box. The “Percentage Amount” Is the Number in Defined for This Setting.") / 100
del = input.bool (defval = false , title = "Delete Filled Gaps?" , group = "Gaps" )
vis = input.bool (defval = false , title = "Visualize Gaps?" , group = "Gaps" )
rec = input.int (defval = 5 , title = "Recent Unfilled Gaps to Show (Table)" , group = "Gaps", minval = 0 )
// => Quartile Volume Params <=
colE = input.color (defval = color.red , title = "Low Volume Quartile Volume Color" ,inline = "1" , group = "Quartile Volume" )
colE1 = input.color (defval = color.lime, title = "High Volume Quartile Volume Color",inline = "1" , group = "Quartile Volume" )
pCalculation = input.int (defval = 10 , title = "% Gain / Loss After 'n' Bars for Exceeded 90th Percentile" , group = "Quartile Volume" , minval = 2 )
log = input.bool (defval = true , title = "Use Log Returns?" , group = "Quartile Volume" )
la = input.bool (defval = false , title = "Show Quartile on Bar?" , group = "Quartile Volume" )
quar = input.bool (defval = false , title = "Color Bars by Volume Quartiles" , group = "Quartile Volume" )
c1 = input.color (defval = #a5d6a7 , title = "First Quartile Color" , group = "Quartile Volume" )
c2 = input.color (defval = #81c784 , title = "Second Quartile Color" , group = "Quartile Volume" )
c3 = input.color (defval = #66bb6a , title = "Third Quartile Color" , group = "Quartile Volume" )
c4 = input.color (defval = #388e3c , title = "90th Percentile" , group = "Quartile Volume" )
c5 = input.color (defval = #1b5e20 , title = "Fourth Quartile Color" , group = "Quartile Volume" )
showIns = input.bool (defval = true , title = "Show Instructions?" , group = "Quartile Volume" )
anch = input.bool (defval = true , title = "Show Anchored VWAP" , group = "Quartile Volume", tooltip = "Adjust Start and End Times Below to Show Anchored VWAP - Drag & Drop the Time Bars On the Chart For Quick Configuration" )
s = input.time (defval = timestamp("20 Jul 1872 00:00 +0300"), title = "Anchored VWAP Start" , group = "Quartile Volume" )
e = input.time (defval = timestamp("20 Jul 2023 00:00 +0300"), title = "Anchored VWAP End" , group = "Quartile Volume" )
// _______________________________________________________
//
// Prerequisite Calculations
// _______________________________________________________
var color colCond = color.yellow
var color finCol = na
var float [] xz = array.new_float()
var float [] vol = array.new_float()
lin() =>
array.push(xz, close)
if array.size(xz) > 50
array.shift(xz)
X = array.sum(xz) / array.size(xz) -
(ta.linreg(close, array.size(xz), 0) -
ta.linreg(close, array.size(xz), 1)) *
math.floor(array.size(xz) / 2) + 0.5 *
(ta.linreg(close, array.size(xz), 0) -
ta.linreg(close, array.size(xz), 1))
Y = (array.sum(xz) / array.size(xz) -
(ta.linreg(close, array.size(xz), 0) -
ta.linreg(close, array.size(xz), 1)) *
math.floor(array.size(xz) / 2)) +
(ta.linreg(close, array.size(xz), 0) -
ta.linreg(close, array.size(xz), 1)) *
(array.size(xz) - 1)
float stDev = ta.stdev(X, array.size(xz) > 0 ? array.size(xz) : 1) * 2
[X, Y, stDev]
[X, Y, stDev] = lin()
atr = ta.atr(14)
tvsVol = request.security(syminfo.ticker + "_SHORT_VOLUME", "D", close, ignore_invalid_symbol = true)
var int loopCount = 0
start() =>
s <= e ? time >= s and time <= e: time <= s and time >= e
var int [] tim = array.new_int(2), var int timFin = 0
if barstate.isfirst
array.set(tim, 0,
math.round(timestamp(year, month, dayofmonth, hour, minute, second)))
if bar_index == 1
array.set(tim, 1,
math.round(timestamp(year, month, dayofmonth, hour, minute, second)))
timFin := array.get(tim, 1) - array.get(tim, 0)
bool loadFast = switch fast
false => bar_index > -1
true => last_bar_index - bar_index <= 7500
// _______________________________________________________
//
// Range US Bars
// _______________________________________________________
[lowClose, lowHigh, lowLow, lowOpen, lowVol, lowATR] = request.security_lower_tf(syminfo.ticker, "1", [close, high, low, open, volume, atr])
if show == "Range US" and loadFast
var float [] trCandle = array.new_float ()
var box [] boxTr = array.new_box()
bool cond = year(time) == year(timenow)
and month(time) == month(timenow)
and dayofmonth(time) == dayofmonth(timenow)
if array.size(lowClose) != 0
var float clo = 0.0
float revFin = switch tra
"Custom" => rev
"Auto" => clo / 150
float treFin = switch tra
"Custom" => tre
"Auto" => clo / 75
var int [] trCount = array.new_int(initial_value = 0)
var color [] col = array.new_color ()
var string [] dNp = array.new_string()
if array.size(trCandle) > 500
for i = 0 to array.size(trCandle) - 500
array.shift(trCandle)
array.shift(trCount)
array.shift(col)
array.shift(dNp)
if na(array.size(lowClose)[1])
array.push(trCandle, array.get(lowHigh, 0))
array.push(col, color(na))
array.push(trCount, 0)
array.push(dNp, "Start")
clo := close
varip dayCount = array.new_float ()
if array.size(trCandle) > 0
string dStri = "\n" +
str.tostring(year, "###") + "/" +
str.tostring(month, "###") + "/" +
str.tostring(dayofmonth, "###")
for i = 0 to array.size(lowClose) - 1
if array.get(trCount, array.size(trCount) - 1) == 0
if array.size(trCandle) == 1
if array.get(lowHigh, i) > array.get(trCandle, array.size(trCandle) - 1) + treFin
array.push(trCandle, array.get(trCandle, array.size(trCandle) - 1) + treFin)
array.push(col, color(na))
array.push(trCount, 0)
array.push(dNp, "+ " + str.tostring(treFin, "###.##") + dStri)
if cond
array.push(dayCount, timFin)
if array.get(lowLow, i) < array.get(trCandle, array.size(trCandle) - 1) - revFin
array.push(trCandle, array.get(trCandle, array.size(trCandle) - 1) - revFin)
array.push(trCount, 1)
array.push(col, color(na))
array.push(dNp, "- " + str.tostring(revFin, "###.##") + dStri)
if cond
array.push(dayCount, timFin)
else if array.size(trCandle) > 1
if array.get(lowHigh, i) >= array.get(trCandle, array.size(trCandle) - 1) + treFin
array.push(trCandle, array.get(trCandle, array.size(trCandle) - 1) + treFin)
array.push(col, color.new(color.lime, 50))
array.push(trCount, 0)
array.push(dNp, "+ " + str.tostring(treFin, "###.##") + dStri)
if cond
array.push(dayCount, timFin)
if array.get(lowLow, i) < array.get(trCandle, array.size(trCandle) - 1) - revFin
array.push(trCandle, array.get(trCandle, array.size(trCandle) - 1) - revFin)
array.push(col, color.new(color.red, 50))
array.push(trCount, 1)
array.push(dNp, "- " + str.tostring(revFin, "###.##") + dStri)
if cond
array.push(dayCount, timFin)
if array.get(trCount, array.size(trCount) - 1) == 1
if array.get(lowLow, i) <= array.get(trCandle, array.size(trCandle) - 1) - treFin
array.push(trCandle, array.get(trCandle, array.size(trCandle) - 1) - treFin)
array.push(col, color.new(color.red, 50))
array.push(trCount, 1)
array.push(dNp, "- " + str.tostring(treFin, "###.##") + dStri)
if cond
array.push(dayCount, timFin)
if array.get(lowHigh, i) > array.get(trCandle, array.size(trCandle) - 1) + revFin
array.push(trCandle, array.get(trCandle, array.size(trCandle) - 1) + revFin)
array.push(col, color.new(color.lime, 50))
array.push(trCount, 0)
array.push(dNp, "+ " + str.tostring(revFin, "###.##") + dStri)
if cond
array.push(dayCount, timFin)
if barstate.islast and array.size(trCandle) > 1
var line [] dayCon = array.new_line ()
color [] colCopy = array.new_color ()
float [] trCandleCopy = array.new_float ()
int [] trCountCopy = array.new_int ()
string [] dNpCopy = array.new_string()
for i = array.size(trCandle) - 1 to 0
array.push(colCopy, array.get(col, i))
array.push(trCandleCopy, array.get(trCandle, i))
array.push(trCountCopy, array.get(trCount, i))
array.push(dNpCopy, array.get(dNp, i))
if array.size(boxTr) > 0
for i = 0 to array.size(boxTr) - 1
box.delete(array.shift(boxTr))
var string [] finReq1 = array.new_string()
array.reverse(finReq1)
string txtSz = switch sz
"Auto" => size.auto
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
for i = 1 to math.min(array.size(trCandleCopy) - 1, 500)
array.push(finReq1, str.substring(array.get(dNpCopy, i - 1), str.pos(array.get(dNpCopy, i - 1), "/") - 4))
array.push(boxTr, box.new(bar_index[i + 1],
array.get(trCandleCopy, i - 1) > array.get(trCandleCopy, i) ? array.get(trCandleCopy, i - 1) : array.get(trCandleCopy, i),
bar_index[i],
array.get(trCandleCopy, i - 1) > array.get(trCandleCopy, i) ? array.get(trCandleCopy, i) : array.get(trCandleCopy, i - 1),
bgcolor = array.get(colCopy, i - 1),
border_color = color.white,
border_width = 1,
xloc = xloc.bar_index,
text = array.get(dNpCopy, i - 1),
text_color = color.white,
text_size = txtSz
))
var float [] cong = array.new_float()
if array.size(boxTr) > 5
for n = 5 to array.size(boxTr) - 1
if math.avg(box.get_top(array.get(boxTr, n)), box.get_bottom(array.get(boxTr, n))) ==
math.avg(box.get_top(array.get(boxTr, n - 5)), box.get_bottom(array.get(boxTr, n - 5)))
and array.includes(cong, math.avg(box.get_top(array.get(boxTr, n)), box.get_bottom(array.get(boxTr, n)))) == false
array.push(cong, math.avg(box.get_top(array.get(boxTr, n)), box.get_bottom(array.get(boxTr, n))))
if ranShow == true
and array.size(finReq1) > 1
var linefill [] dayFill = array.new_linefill()
for n = 1 to array.size(finReq1) - 1
if array.get(finReq1, n - 1) != array.get(finReq1, n)
array.push(dayCon, line.new(box.get_left(array.get(boxTr, n)) + 1,
close[n],
box.get_left(array.get(boxTr, n)) + 1,
close[n] + syminfo.mintick,
extend = extend.both,
xloc = xloc.bar_index,
color = color.new(color.yellow, 50)
))
if array.size(dayCon) > 1
for x = 1 to array.size(dayCon) - 1
array.push(dayFill, linefill.new(array.get(dayCon, x), array.get(dayCon, x - 1), color.new(color.yellow, 90)))
else
z = line.new(box.get_left(array.get(boxTr, array.size(boxTr) - 1)),
close,
box.get_left(array.get(boxTr, array.size(boxTr) - 1)),
close + syminfo.mintick,
color = color.new(color.yellow, 90)
)
z1 = line.new(bar_index,
close,
bar_index,
close + syminfo.mintick,
color = color.new(color.yellow, 90)
)
linefill.new(z, z1, color.new(color.yellow, 90))
var line [] x = array.new_line (2)
var linefill [] xf = array.new_linefill(2)
var label [] xl = array.new_label (1)
if array.size(finReq1) > 0
indexStop = 0
for i = 1 to array.size(finReq1) - 1
if array.get(finReq1, i - 1 ) ==
str.tostring(year(timenow), "###") + "/" +
str.tostring(month(timenow), "###") + "/" +
str.tostring(dayofmonth(timenow), "###")
and array.get(finReq1, i) != array.get(finReq1, i - 1)
indexStop := i + 1
break
if indexStop != 0
array.set(x, 0, line.new(bar_index - indexStop,
close,
bar_index - indexStop,
close + syminfo.mintick, color = color.white, extend = extend.both, xloc = xloc.bar_index
))
array.set(x, 1, line.new(bar_index + 1, close, bar_index + 1, close + syminfo.mintick, color = color.white,
extend = extend.both,
xloc = xloc.bar_index
))
array.set(xf, 0, linefill.new(array.get(x, 0), array.get(x, 1), color.new(color.white, 95)))
array.set(xl, 0, label.new(math.round(math.avg(line.get_x1(array.get(x, 0)),
line.get_x1(array.get(x, 1)))),
close,
text = "Recent Price Action",
xloc = xloc.bar_index,
color = na,
textcolor = color.white,
size = size.huge,
yloc = yloc.abovebar
))
if array.size(dayCon) > 0
array.set(xf, 1, linefill.new(array.get(dayCon, 0), array.get(x, 0), color.new(color.yellow, 90)))
var box [] finBox = array.new_box(0)
var line [] levels = array.new_line()
var label [] levelLabels = array.new_label()
var linefill [] levelsFill = array.new_linefill()
bool cX = array.get(trCountCopy, 0) == 0 and close >= box.get_top(array.get(boxTr, 0))
bool cY = array.get(trCountCopy, 0) == 0 and close < box.get_top(array.get(boxTr, 0))
bool cZ = array.get(trCountCopy, 0) == 1 and close >= box.get_bottom(array.get(boxTr, 0))
if array.size(finBox) == 0
array.push(finBox, box.new(move == false ? bar_index - 1 : bar_index + 4,
cX ? close :
cY ? box.get_top( array.get(boxTr, 0)) :
cZ ? close :
box.get_bottom ( array.get(boxTr, 0)) ,
move == false ? bar_index : bar_index + 5,
cX ? box.get_top( array.get(boxTr, 0)) :
cY ? close :
cZ ? box.get_bottom(array.get(boxTr, 0)) :
close,
border_color = color.white,
text_color = color.white,
bgcolor =
cX ? color.new(color.lime, 50) :
cY ? color.new(color.red, 50) :
cZ ? color.new(color.lime, 50) :
color.new(color.red, 50) ,
text =
cX ? "+ " + str.tostring(close - box.get_top(array.get(boxTr, 0)), format.mintick) :
cY ? str.tostring(close - box.get_top(array.get(boxTr, 0)), format.mintick) :
cZ ? "+ " + str.tostring(close - box.get_bottom(array.get(boxTr, 0)), format.mintick) :
str.tostring(close - box.get_bottom(array.get(boxTr, 0)), format.mintick) ,
xloc = xloc.bar_index
))
else
box.set_left(array.get(finBox, 0) , box.get_right(array.get(finBox , 0)) )
box.set_right(array.get(finBox, 0), box.get_right(array.get(finBox , 0)) + 1)
box.set_top(array.get(finBox, 0),
cX ? close :
cY ? box.get_top( array.get(boxTr, 0)) :
cZ ? close :
box.get_bottom ( array.get(boxTr, 0))
)
box.set_bottom(array.get(finBox, 0),
cX ? box.get_top( array.get(boxTr, 0)) :
cY ? close :
cZ ? box.get_bottom(array.get(boxTr, 0)) :
close
)
box.set_bgcolor(array.get(finBox, 0),
cX ? color.new(color.lime, 50) :
cY ? color.new(color.red, 50) :
cZ ? color.new(color.lime, 50) :
color.new(color.red, 50)
)
box.set_text(array.get(finBox, 0),
cX ? "+ " + str.tostring(close - box.get_top(array.get(boxTr, 0 )), format.mintick) :
cY ? str.tostring(close - box.get_top(array.get(boxTr, 0 )), format.mintick) :
cZ ? "+ " + str.tostring(close - box.get_bottom(array.get(boxTr, 0)), format.mintick) :
str.tostring(close - box.get_bottom(array.get(boxTr, 0)), format.mintick)
)
if array.size(cong) > 0 and treShow > 0
str = ""
for n = 0 to math.min(array.size(cong) - 2, treShow - 1)
str := array.get(cong, n) >= array.get(cong, n + 1) ?
str + str.tostring(array.get(cong, n), format.mintick) + " △\n"
: str + str.tostring(array.get(cong, n), format.mintick) + " ▼\n"
if n == math.min(array.size(cong) - 2, treShow - 1)
str := str + str.tostring(array.get(cong, n + 1), format.mintick)
+ "\n"
var table upRight = table.new(position.top_right, 10, 10, frame_color = color.white, border_color = color.white, frame_width = 1, border_width = 1)
table.cell(upRight, 0, 0, text = "Congestion Areas \n(Reversed Order of Occurrence)", text_color = #00ffff, bgcolor = color.new(#000000, 75))
table.cell(upRight, 0, 1, text = str, text_color = color.red, bgcolor = color.new(#000000, 75))
if tra == "Custom" and warn1 == true
if rev < array.get(lowATR, array.size(lowATR) - 1) * 1.9 or tre < array.get(lowATR, array.size(lowATR) - 1) * 1.9
table.cell(upRight, 1, 1, bgcolor = color.new(#000000, 75), text_color = color.red, text_size = size.small, text = "This Chart Type Is Using 1 Minute OHLC Data; \nNo Tick Data Is Used. \nIf You’re Seeing This Message: \nYour Configurations for a Trend Candle or Reversal Candle Are Likely Too Low. \nFor Instance, if You Set Trend Candles to $1 Then Trend Candles Will \nForm Subsequent a $1 Price Move. This Is Sufficient for Lower Priced Assets; \nHowever, if You Were Trading, for Instance, Bitcoin - \nA $1 Price Move Can Happen Numerous Times in One Minute. \nThis Script Can’t Plot Bars and Record Data Until a 1-Minute \nBar Closes and a New 1-Minute Bar Opens. \nTry Adjusting the Trend Candle and Reversal Candle Settings to Price Level \nThat’s Unlikely to Be Exceeded Numerous Times per Minute. \nThis Message Will Dissapear if \n You Adjust the Price Levels to\n" + str.tostring(array.get(lowATR, array.size(lowATR) - 1) * 2 , format.mintick) + " or Greater")
table.cell(upRight, 1, 0, bgcolor = color.new(#000000, 75), text_color = color.red, text_size = size.normal, text = "Warning")
var table stats = table.new(position.bottom_right, 10, 10, frame_color = color.white, border_color = color.white, frame_width = 1, border_width = 1)
table.cell(stats, 0, 0, "Range US🛈", bgcolor = color.new(#ffffff, 75), text_color = color.white, tooltip = "A Range US Chart Operates Irrespective of Time and Volume - Simply - Bars Move After a User-Defined Price Move Is Achieved/Exceeded in either Direction. A Range US Chart Produces: \n1. “Trend Candles” \n2. “Reversal Candles” \nA Reversal Candle Always Moves Against the Most Immediate Bar; A Trend Candle Always Moves in Favor of the Most Immediate Bar. The User Defines the Dollar Amount Price Must Travel Up/Down for a Trend Candle to Fulfill, and for a Reversal Candle to Fulfill. Note, if a “Down Reversal” Candle (Red) Is Produced, It’s *Impossible* For the Next Candle to Also Be a Down Reversal Candle - For the Downside Move to Continue the Criteria for a Down Trend Candle Must Be Fulfilled. Similarly, if an “Up Reversal” Candle (Green) Is Produced, It’s Impossible for the Next Candle to Also Be an Up Reversal Candle - For the Upside Move to Continue, the Criteria for an Uptrend Trend Candle Must Be Fulfilled. Consequently, Range US Bars Frequently Trade at the Same Level for Extended Periods. This Is Intentional, as This Chart Type Is Theorized to “Filter Noise” - Whether Range US Charts Fulfill This Theory Is to Your Discretion. Lastly, if a Green (Up) Trend Candle Is Produced, the Next Candle Cannot Be up a Reversal Up Candle - Only a Trend Up Candle or Reversal Down Candle Can Produce - Vice Versa for a Trend Down Candle (The Subsequent Candle Cannot Be a Reversal Down Candle). In This Sense, an Uptrend Continues on Successive Trend Up Candles; A Down Trend Continues on Successive Trend Down Candles.")
table.cell(stats, 0, 1, "🛈", bgcolor = color.new(#ffffff, 75), text_color = color.lime, tooltip = "The Dollar Amount Prices Must Increase for a Green Trend Candle to Form - The Precise Price Level Is Included in Parenthesis. Note: If the Current Range Us Bar Is a Trend Down Bar or Down Reverse Bar, an Up Reverse Bar Must First Produce.")
table.cell(stats, 0, 2, "🛈", bgcolor = color.new(#ffffff, 75), text_color = color.lime, tooltip = "The Dollar Amount Prices Must Decrease for a Red Trend Candle to Form - The Precise Price Level Is Included in Parenthesis. Note: If the Current Range Us Bar Is a Trend Up Bar or Up Reverse Bar, a Down Reverse Bar Must First Produce.")
table.cell(stats, 0, 3, "🛈", bgcolor = color.new(#ffffff, 75), text_color = color.lime, tooltip = array.get(trCountCopy, 0) == 0 ? "The Dollar Amount Prices Must Decrease for a Down Reverse Candle to Form - The Precise Price Level Is Included in Parenthesis." : "The Dollar Amount Prices Must Increase for an Up Reverse Candle to Form - The Precise Price Level Is Included in Parenthesis. ")
table.cell(stats, 2, 1, "Trending After $" + str.tostring(treFin, format.mintick) + " Price Move", text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 2, 2, "Reversing After $" + str.tostring(revFin, format.mintick) + " Price Move", text_color = color.lime, bgcolor = color.new(#131722, 75))
table.cell(stats, 1, 1, "$ for Trend Up: " + str.tostring(
(box.get_top(array.get(boxTr, 0)) + treFin) - close, format.mintick) + " Price Move ($"
+ str.tostring((box.get_top(array.get(boxTr, 0)) + treFin), format.mintick) + ")" ,
text_color = color.lime,
bgcolor = color.new(#2a2e39, 75)
)
table.cell(stats, 1, 2, "$ for Trend Down: " + str.tostring(
(box.get_bottom(array.get(boxTr, 0)) - treFin) - close, format.mintick) + " Price Move ($"
+ str.tostring((box.get_bottom(array.get(boxTr, 0)) - treFin), format.mintick) + ")" ,
text_color = color.lime,
bgcolor = color.new(#434651, 75)
)
if array.get(trCountCopy, 0) == 0
table.cell(stats, 1, 3, "$ for Reverse Down: " + str.tostring(
(box.get_top(array.get(boxTr, 0)) - revFin) - close, format.mintick) + " Price Move ($"
+ str.tostring((box.get_top(array.get(boxTr, 0)) - revFin), format.mintick) + ")" ,
text_color = color.lime,
bgcolor = color.new(#5d606b, 75)
)
if levShow == true
array.push(levels, line.new( bar_index + 2,
box.get_top(array.get(boxTr, 0)) - revFin,
bar_index + 8,
box.get_top(array.get(boxTr, 0)) - revFin,
color = color.orange
))
array.push(levels, line.new( bar_index + 2,
math.avg(box.get_top(array.get(boxTr, 0)) - revFin, box.get_bottom(array.get(boxTr, 0)) - treFin),
bar_index + 8,
math.avg(box.get_top(array.get(boxTr, 0)) - revFin, box.get_bottom(array.get(boxTr, 0)) - treFin),
color = na
))
array.push(levelLabels, label.new(bar_index + 8, box.get_top(array.get(boxTr, 0)) - revFin,
"Reverse Down", textcolor = color.orange, color = color.new(color.white, 100),
size = size.small, style = label.style_label_left ))
else
table.cell(stats, 1, 3, "$ for Reverse Up: " + str.tostring(
(box.get_bottom(array.get(boxTr, 0)) + revFin) - close, format.mintick) + " Price Move ($"
+ str.tostring((box.get_bottom(array.get(boxTr, 0)) + revFin), format.mintick) + ")" ,
text_color = color.lime,
bgcolor = color.new(#5d606b, 75) )
if levShow == true
array.push(levels, line.new( bar_index + 2,
box.get_bottom(array.get(boxTr, 0)) + revFin,
bar_index + 8,
box.get_bottom(array.get(boxTr, 0)) + revFin,
color = color.blue
))
array.push(levels, line.new( bar_index + 2,
math.avg(box.get_bottom(array.get(boxTr, 0)) + revFin, box.get_bottom(array.get(boxTr, 0)) - treFin),
bar_index + 8,
math.avg(box.get_bottom(array.get(boxTr, 0)) + revFin, box.get_bottom(array.get(boxTr, 0)) - treFin),
color = na
))
array.push(levelLabels, label.new(bar_index + 8, box.get_bottom(array.get(boxTr, 0)) + revFin,
"Reverse Up", textcolor = color.blue, color = color.new(color.white, 100),
style = label.style_label_left,
size = size.small))
if array.size(cong) > 0
table.cell(stats, 2, 3, "Most Recent Congestion Area: $" + str.tostring(array.get(cong, 0), format.mintick),
text_color = color.lime,
bgcolor = color.new(#5d606b, 75))
table.merge_cells(stats, 0, 0, 2, 0)
if levShow == true
array.push(levels, line.new( bar_index + 2,
box.get_top(array.get(boxTr, 0)) + treFin,
bar_index + 8,
box.get_top(array.get(boxTr, 0)) + treFin,
color = color.lime
))
array.push(levelLabels, label.new(bar_index + 8, box.get_top(array.get(boxTr, 0)) + treFin,
"Trend Up", textcolor = color.lime, color = color.new(color.white, 100),
style = label.style_label_left,
size = size.small))
array.push(levels, line.new( bar_index + 2,
box.get_bottom(array.get(boxTr, 0)) - treFin,
bar_index + 8,
box.get_bottom(array.get(boxTr, 0)) - treFin,
color = color.red
))
array.push(levelLabels, label.new(bar_index + 8, box.get_bottom(array.get(boxTr, 0)) - treFin,
"Trend Down", textcolor = color.red, color = color.new(color.white, 100),
style = label.style_label_left, size = size.small))
array.push(levels, line.new( bar_index + 2,
math.avg(line.get_y1(array.get(levels, 0)), line.get_y1(array.get(levels, 2))),
bar_index + 8,
math.avg(line.get_y1(array.get(levels, 0)), line.get_y1(array.get(levels, 2))),
color = na
))
if array.size(levels) > 5
for i = 0 to 4
line.delete(array.shift(levels))
if array.size(levels) == 5
array.push(levelsFill, linefill.new(array.get(levels, 0), array.get(levels, 2), color.new(color.lime, 90)))
array.push(levelsFill, linefill.new(array.get(levels, 0), array.get(levels, 4), color.new(array.get(trCount, 0) == 0 ? color.orange : color.blue, 90)))
array.push(levelsFill, linefill.new(array.get(levels, 0), array.get(levels, 3), color.new(array.get(trCount, 0) == 0 ? color.orange : color.blue, 90)))
array.push(levelsFill, linefill.new(array.get(levels, 1), array.get(levels, 3), color.new(color.red, 90)))
if array.size(levelsFill) > 4
for i = 0 to 3
linefill.delete(array.shift(levelsFill))
if array.size(levelLabels) > 3
for i = 0 to 2
label.delete(array.shift(levelLabels))
// _______________________________________________________
//
// Volume Aggregation Bars
// _______________________________________________________
if show == "Volume Aggregation" and loadFast
var box finBox = na
var float [] cumVol = array.new_float()
var float [] volC = array.new_float()
var string [] date = array.new_string()
var line [] dayCon = array.new_line()
var float [] volMed = array.new_float()
array.push(volMed, volume)
float volIn = tra1 == "Auto" ? array.percentile_linear_interpolation(volMed, 90) : volInt
string txtSz = switch sz1
"Auto" => size.auto
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
array.push(cumVol, array.size(cumVol) == 0 ? volume : array.get(cumVol, array.size(cumVol) - 1) + volume)
if array.size(cumVol) > 0
if array.get(cumVol, array.size(cumVol) - 1) > volIn
var float calc = 0.0
calc := array.get(cumVol, array.size(cumVol) - 1) - volIn
array.clear(cumVol)
array.push(cumVol, calc)
array.push(volC, close)
array.push(date,
str.tostring(year) + "/"
+ str.tostring(month) + "/"
+ str.tostring(dayofmonth) + "\n$"
+ str.tostring(close, format.mintick))
if array.size(volC) > 0
if array.size(volC) > 502
array.shift(volC)
array.shift(date)
array.shift(volMed)
if barstate.islast
var string [] finReq1 = array.new_string()
var float [] max = array.new_float()
var box [] volBox = array.new_box()
float [] volCopy = array.new_float()
string [] dateCopy = array.new_string()
for i = array.size(volC) - 1 to 0
array.push(volCopy, array.get(volC, i))
array.push(dateCopy, array.get(date, i))
if array.size(volBox) > 0
for i = 0 to array.size(volBox) - 1
box.delete(array.shift(volBox))
if array.size(finReq1) > 0
array.clear(finReq1)
if array.size(max) > 0
array.clear(max)
for i = 0 to math.min(array.size(volC) - 2, 500)
array.push(max, i == 0 ? 0 : array.get(volCopy, i) / array.get(volCopy, i + 1) - 1)
array.push(finReq1, str.substring(array.get(dateCopy, i),0, str.pos(array.get(dateCopy, i), "\n")))
array.push(volBox, box.new(bar_index[i + 1],
array.get(volCopy, i) > array.get(volCopy, i + 1) ? array.get(volCopy, i) : array.get(volCopy, i + 1),
bar_index[i],
array.get(volCopy, i) > array.get(volCopy, i + 1) ? array.get(volCopy, i + 1) : array.get(volCopy, i),
bgcolor = array.get(volCopy, i) > array.get(volCopy, i + 1) ?
color.new(color.green, 50) :
color.new(color.red, 50) ,
border_color = color.white ,
text = array.get(dateCopy, i) + "\nMoves On \n" +
str.tostring(volIn, format.volume) + " Volume" ,
text_color = color.white ,
text_size = txtSz
))
box.delete(finBox)
finBox := box.new(bar_index, array.get(volCopy, 0) > array.get(volCopy, 1) ? array.get(volCopy, 0) : close,
bar_index + 1,
array.get(volCopy, 0) > array.get(volCopy, 1) ? close : array.get(volCopy, 0),
bgcolor = close > array.get(volCopy, 0) ? color.new(color.green, 50) : color.new(color.red, 50),
border_color = color.white,
text = str.tostring(year, "###") + "/" + str.tostring(month, "###") + "/" + str.tostring(dayofmonth, "###") + "\n" +
str.tostring(array.get(cumVol, array.size(cumVol) - 1), format.volume) + " Volume",
text_color = color.white
)
if vShow == true
and array.size(finReq1) > 1
var linefill [] dayFill = array.new_linefill()
for n = 1 to array.size(finReq1) - 1
if array.get(finReq1, n - 1) != array.get(finReq1, n)
array.push(dayCon, line.new(box.get_left(array.get(volBox, n)) + 1,
close[n],
box.get_left(array.get(volBox, n)) + 1,
close[n] + syminfo.mintick,
extend = extend.both,
xloc = xloc.bar_index,
color = color.new(color.yellow, 50)
))
if array.size(dayCon) > 1
for x = 1 to array.size(dayCon) - 1
array.push(dayFill, linefill.new(array.get(dayCon, x), array.get(dayCon, x - 1), color.new(color.yellow, 90)))
var table stats = table.new(position.bottom_right, 10, 10, frame_color = color.white, border_color = color.white, frame_width = 1, border_width = 1)
table.cell(stats, 0, 0, text = "Volume Aggregation🛈", text_color = color.red, text_size = size.normal, bgcolor = color.new(#000000, 50)
, tooltip = "Volume Aggregation Bars Aren’t Bound to a Time-Axis; The Bars Form After a User-Defined, Cumulative Amount of Volume Is Achieved or Exceeded. Consequently, Once the Cumulative Amount of Volume Is Achieved or Exceeded - A Bar Is Produced No Matter the Price. Underlying Theory: The Chat Type Is Conducive to Identifying Price Levels Where Traders Are “Trapped”." )
table.cell(stats, 0, 1, text = "Moving On " + str.tostring(volIn, format.volume) + " Volume", text_color = color.red, text_size = size.normal,
bgcolor = color.new(#000000, 50)
)
table.cell(stats, 0, 2, text = "Largest Upside Move: " + str.tostring(array.max(max)* 100, format.percent), text_color = color.red, text_size = size.normal,
bgcolor = color.new(#000000, 50)
)
table.cell(stats, 0, 3, text = "Largest Downside Move: " + str.tostring(array.min(max)* 100, format.percent), text_color = color.red, text_size = size.normal,
bgcolor = color.new(#000000, 50)
)
if showAl == true
maxStrCop = array.new_string(array.size(finReq1))
maxCop = array.copy(max)
if array.size(max) == array.size(finReq1) and array.size(max) > 1
array.sort(maxCop, order.descending)
for i = 0 to array.size(max) - 1
finCop = array.get(finReq1, array.indexof(max, array.get(maxCop, i)) > 0 ? array.indexof(max, array.get(maxCop, i)) : 0)
array.set(maxStrCop, i, finCop)
string str = ""
string str1 = ""
if array.size(maxCop) > 0
for i = 0 to math.min(array.size(maxCop) - 1, showUp - 1)
str := str + str.tostring(array.get(maxCop, i) * 100, format.percent) + "(" + array.get(maxStrCop, i) + ")\n"
if array.size(maxCop) > showDn
for i = array.size(maxCop) - 1 to array.size(maxCop) - showDn
str1 := str1 + str.tostring(array.get(maxCop, i) * 100, format.percent) + "(" + array.get(maxStrCop, i) + ")\n"
var table upRight = table.new(position.top_right, 10, 10, frame_color = color.white, border_color = color.white, frame_width = 1, border_width = 1 )
table.cell(upRight, 0, 0, "Largest Upside Moves", text_color = color.lime, bgcolor = color.new(color.green, 75))
table.cell(upRight, 0, 1, str, text_color = color.white, bgcolor = color.new(color.green, 75), text_halign = text.align_left)
table.cell(upRight, 0, 2, "Largest Downside Moves", text_color = color.red, bgcolor = color.new(color.red, 75))
table.cell(upRight, 0, 3, str1, text_color = color.white, bgcolor = color.new(color.red, 75), text_halign = text.align_left)
if tra1 == "Custom" and warn == true
if volInt < array.percentile_linear_interpolation(volMed, 90)
table.cell(upRight, 1, 0, bgcolor = color.new(#000000, 75), text_color = color.red, text_size = size.small, text = "This Data Set Uses the OHLC Data \nFrom the Timeframe on Your Chart; \nNo Tick Data Is Used. \nIf You’re Seeing This Message: \nYour Configurations for Required Volume Are Likely Too Low. \nWhile This Script Calculates Cumulative Volume \nand Remainders Are Carried Over When the Volume Limit Is Exceeded, \nSetting the Volume Requirement Too Low May Result in Missed \nPrice Moves - Should the Cumulative Volume Threshold Be \nExceeded Twice in One Bar. \nSetting the Volume Requirement to " + str.tostring(array.percentile_linear_interpolation(volMed, 90)) + " \nor Deselcting the 'Show Warning' Option \nin the Input Settings Will Hide This Message.")
table.merge_cells(upRight, 1, 0, 1, 3)
// _______________________________________________________
//
// Gaps
// _______________________________________________________
if show == "Gaps" and loadFast
bool gDn = high < low[1] and math.abs(low[1] / high - 1) > perG
bool gUp = low > high[1] and math.abs(low / high[1] - 1) > perG
var float [] gArray = array.new_float()
var box [] gBox = array.new_box()
var color [] col = array.new_color()
var string [] dNp = array.new_string()
var float [] sli = array.new_float()
var box [] boxGpD = array.new_box()
var box [] boxGpU = array.new_box()
var int [] boxCountD = array.new_int()
var int [] boxCountU = array.new_int()
var float [] minU = array.new_float()
var float [] maxD = array.new_float()
var int [] avgU = array.new_int()
var int [] avgD = array.new_int()
if array.size(gArray) > 500
for i = 0 to array.size(gArray) - 500
array.shift(gArray)
array.shift(col)
if gUp
array.push(gArray, array.size(gArray) == 0 ? low : array.get(gArray, array.size(gArray) - 1) + low - high[1])
array.push(sli, (low / high[1] - 1) * 100)
array.push(col, color.new(color.green, 50))
array.push(dNp, str.tostring(low - high[1], format.mintick) + "\n" +
str.tostring(year, "###") + "/" +
str.tostring(month, "###") + "/" +
str.tostring(dayofmonth, "###"))
array.push(boxGpU, box.new(math.round(time),low, math.round(time) + timFin,high[1],
text = str.tostring((close / low - 1) * 100, format.percent) + " To Fill", xloc = xloc.bar_time, bgcolor = color.new(color.lime, 50),
border_color = color.lime, text_color = color.white, text_halign = text.align_right))
array.push(boxCountU, 0), array.push(minU, 1e+13), array.push(avgU, bar_index)
if gDn
array.push(gArray, array.size(gArray) == 0 ? high : array.get(gArray, array.size(gArray) - 1) + high - low[1])
array.push(sli, (high / low[1] - 1) * 100)
array.push(col, color.new(color.red, 50))
array.push(dNp, str.tostring(high - low[1], format.mintick) + "\n" +
str.tostring(year, "###") + "/" +
str.tostring(month, "###") + "/" +
str.tostring(dayofmonth, "###"))
array.push(boxGpD, box.new(math.round(time), low[1], math.round(time) + timFin, high, xloc = xloc.bar_time,
text = str.tostring((close / high - 1) * 100, format.percent) + " To Fill", bgcolor = color.new(color.red, 50),
border_color = color.white, text_color = color.white, text_halign = text.align_right))
array.push(boxCountD, 0), array.push(avgD, bar_index), array.push(maxD, 0)
var float [] finAvgU = array.new_float()
if array.size(boxGpU) > 0
for n = 0 to array.size(boxGpU) - 1
if low < box.get_bottom(array.get(boxGpU, n))
if array.get(boxCountU, n) != 1 and array.get(boxCountU, n) != 3
box.set_text(array.get(boxGpU, n), gDn ? "New Gap" : "Filled")
box.set_bgcolor(array.get(boxGpU, n), color.new(color.lime, 90))
box.set_border_color(array.get(boxGpU, n), color.new(color.lime, 90))
array.push(finAvgU, bar_index - array.get(avgU, n))
if del == false
array.set(boxCountU, n, 1)
else
array.set(boxCountU, n, 3)
else if low < box.get_top(array.get(boxGpU, n)) and low > box.get_bottom(array.get(boxGpU, n)) and array.get(boxCountU, n) == 0
array.set(boxCountU, n, 2)
if array.get(boxCountU, n) != 1 and array.get(boxCountU, n) != 3
array.set(minU, n, math.min(low, array.get(minU, n)))
box.set_right(array.get(boxGpU, n), math.round(time + timFin))
box.set_text(array.get(boxGpU, n),array.get(boxCountU, n) == 0 ?
str.tostring((box.get_bottom(array.get(boxGpU, n)) / close - 1) * 100, format.percent) + " Decrease To Fill"
: str.tostring((box.get_bottom(array.get(boxGpU, n)) / close - 1) * 100, format.percent) + " To Fill \n(Partially Filled " +
str.tostring ((( array.get(minU, n)
- box.get_top ( array.get(boxGpU, n))) * 100)
/ (box.get_bottom( array.get(boxGpU, n))
- box.get_top ( array.get(boxGpU, n))),
format.percent) + ")" )
if del == true
for i = 0 to array.size(boxGpU) - 1
if i < array.size(boxGpU)
if array.get(boxCountU, i) == 3
box.delete(array.remove(boxGpU, i))
array.remove(minU, i)
array.remove(boxCountU, i)
else
if array.size(boxGpU) > 250
for i = 0 to array.size(boxGpU) - 1
if array.get(boxCountU, i) == 1
box.delete(array.remove(boxGpU, i))
array.remove(minU, i)
array.remove(boxCountU, i)
break
if old >= 0 and array.size(boxGpU) > 0
for x = 0 to array.size(boxGpU) - 1
if array.get(boxCountU, x) != 1 and array.get(boxCountU, x) != 3
if close >= box.get_top(array.get(boxGpU, x)) * (1 + old)
box.set_bgcolor(array.get(boxGpU, x), na)
box.set_border_color(array.get(boxGpU, x), na)
box.set_right(array.get(boxGpU, x), box.get_left(array.get(boxGpU, x)))
else
box.set_bgcolor(array.get(boxGpU, x), color.new(color.lime, 50))
box.set_border_color(array.get(boxGpU, x), color.new(color.lime, 50))
var float [] finAvgD = array.new_float()
if array.size(boxGpD) > 0
for n = 0 to array.size(boxGpD) - 1
if high > box.get_top(array.get(boxGpD, n))
if array.get(boxCountD, n) != 1 and array.get(boxCountD, n) != 3
array.push(finAvgD, bar_index - array.get(avgD, n))
box.set_text(array.get(boxGpD, n), gUp ? "New Gap" : "Filled")
box.set_bgcolor(array.get(boxGpD, n), color.new(color.red, 90))
box.set_border_color(array.get(boxGpD, n), color.new(color.red, 90))
if del == false
array.set(boxCountD,n, 1)
else
array.set(boxCountD,n, 3)
else if high < box.get_top(array.get(boxGpD, n)) and high > box.get_bottom(array.get(boxGpD, n)) and array.get(boxCountD, n) == 0
array.set(boxCountD, n, 2)
if array.get(boxCountD, n) != 1 and array.get(boxCountD, n) != 3
array.set(maxD, n, math.max(high, array.get(maxD, n)))
box.set_right(array.get(boxGpD, n), math.round(time) + timFin)
box.set_text(array.get(boxGpD, n), array.get(boxCountD, n) == 0 ?
str.tostring((box.get_top(array.get(boxGpD, n)) / close - 1) * 100, format.percent) + " Increase To Fill" :
str.tostring((box.get_top(array.get(boxGpD, n)) / close - 1) * 100, format.percent) + " To Fill \n(Partially Filled " +
str.tostring(((array.get(maxD, n)
- box.get_bottom(array.get(boxGpD, n))) * 100)
/ (box.get_top(array.get(boxGpD, n))
- box.get_bottom(array.get(boxGpD, n))),
format.percent) + ")")
if del == true
for i = 0 to array.size(boxGpD) - 1
if i < array.size(boxGpD)
if array.get(boxCountD, i) == 3
box.delete(array.remove(boxGpD, i))
array.remove(maxD, i)
array.remove(boxCountD, i)
else
if array.size(boxGpD) > 250
for i = 0 to array.size(boxGpD) - 1
if array.get(boxCountD, i) == 1
box.delete(array.remove(boxGpD, i))
array.remove(maxD, i)
array.remove(boxCountD, i)
break
if old >= 0 and array.size(boxGpD) > 0
for x = 0 to array.size(boxGpD) - 1
if array.get(boxCountD, x) != 1 and array.get(boxCountD, x) != 3
if close <= box.get_bottom(array.get(boxGpD, x)) * (1 - old)
box.set_bgcolor(array.get(boxGpD, x), na)
box.set_border_color(array.get(boxGpD, x), na)
box.set_right(array.get(boxGpD, x), box.get_left(array.get(boxGpD, x)))
else
box.set_bgcolor(array.get(boxGpD, x), color.new(color.red, 50))
box.set_border_color(array.get(boxGpD, x), color.new(color.red, 50))
if barstate.islast
var int [] hold = array.new_int(1, 0)
if array.get(hold, 0) == 0
array.reverse(gArray)
array.reverse(col)
array.reverse(dNp)
array.set(hold, 0, 1)
if array.size(gArray) > 0
if vis == true
for i = 0 to math.min(500, array.size(gArray) - 2)
array.push(gBox, box.new(bar_index[i + 1],
array.get(gArray, i) > array.get(gArray, i + 1) ? array.get(gArray, i) : array.get(gArray, i + 1) ,
bar_index[i],
array.get(gArray, i) > array.get(gArray, i + 1) ? array.get(gArray, i + 1) : array.get(gArray, i),
bgcolor = array.get(col, i),
border_color = color.white,
text = array.get(dNp, i),
text_color = color.white
))
array.sort(sli, order.ascending)
var float [] dn = array.new_float()
var float [] up = array.new_float()
for x = 1 to array.size(sli) - 1
if array.get(sli, 0) < 0
if array.get(sli, array.size(sli) - 1) > 0
if array.get(sli, x - 1) < 0 and array.get(sli, x) > 0
for n = 0 to x - 1
array.push(dn, array.get(sli, n))
for n = x to array.size(sli) - 1
array.push(up, array.get(sli, n))
break
else if array.get(sli, 0) > 0
if x != array.size(sli) - 1
array.push(up, array.get(sli, x - 1))
else
if array.size(sli) > 1
array.push(up, array.get(sli, x))
array.push(up, array.get(sli, x - 1))
if array.get(sli, array.size(sli) - 1) < 0
if x != array.size(sli) - 1
array.push(dn, array.get(sli, x - 1))
else
if array.size(sli) > 1
array.push(up, array.get(sli, x))
array.push(up, array.get(sli, x - 1))
var table stats = table.new(position.bottom_right, 10, 10, border_color = color.white, frame_color= color.white, border_width = 1, frame_width = 1)
table.cell(stats, 0, 0, "# of Gaps: " + str.tostring(array.size(sli)) , text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 0, 1, "Gaps Up: " + str.tostring(array.size(up)) , text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 0, 2, "Gaps Down: " + str.tostring(array.size(dn)) , text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 1, 1, "Cumulative Increase: " + str.tostring(array.sum(up), format.percent) , text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 2, 1, "Cumulative Decrease: " + str.tostring(array.sum(dn), format.percent) , text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 1, 2, "Avg. Increase: " + str.tostring(array.avg(up), format.percent) , text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 2, 2, "Avg. Decrease: " + str.tostring(array.avg(dn), format.percent) , text_color = color.lime, bgcolor = color.new(#000000, 75))
strUp = ""
strDn = ""
if array.size(boxGpU) > 0 and rec > 0
upCou = 0
for n = array.size(boxGpU) - 1 to 0
if upCou == rec
break
if array.get(boxCountU, n) != 1 and array.get(boxCountU, n) != 3
strUp := strUp + str.tostring(box.get_bottom(array.get(boxGpU, n)), format.mintick) + " - " + str.tostring(box.get_top(array.get(boxGpU, n)), format.mintick) +
" (Distance: " + str.tostring((close - box.get_bottom(array.get(boxGpU, n))) * -1, format.mintick) + ")" +
"\n"
upCou += 1
if array.size(boxGpD) > 0 and rec > 0
dnCou = 0
for n = array.size(boxGpD) - 1 to 0
if dnCou == rec
break
if array.get(boxCountD, n) != 1 and array.get(boxCountD, n) != 3
strDn := strDn + str.tostring(box.get_bottom(array.get(boxGpD, n)), format.mintick) + " - " + str.tostring(box.get_top(array.get(boxGpD, n)), format.mintick) +
" (Distance: +" + str.tostring((close - box.get_top(array.get(boxGpD, n))) * -1, format.mintick) + ")" +
"\n"
dnCou += 1
var table upRight = table.new(position.top_right, 10, 10, border_color = color.white, frame_color= color.white, border_width = 1, frame_width = 1)
if rec > 0
if strUp != ""
table.cell(upRight, 0, 0, "Unfilled Up Gaps", bgcolor = color.new(#000000, 75), text_color = color.lime)
table.cell(upRight, 0, 1, strUp, bgcolor = color.new(#000000, 75), text_color = color.lime)
if strDn != ""
table.cell(upRight, 0, 2, "Unfilled Down Gaps", bgcolor = color.new(#000000, 75), text_color = color.red)
table.cell(upRight, 0, 3, strDn, bgcolor = color.new(#000000, 75), text_color = color.red)
if del == false
table.cell(stats, 1, 0, "Avg. Bars to Fill Up Gap: " + str.tostring(math.round(array.avg(finAvgU)), "#"), text_color = color.lime, bgcolor = color.new(#000000, 75))
table.cell(stats, 2, 0, "Avg. Bars to Fill Down Gap: " + str.tostring(math.round(array.avg(finAvgD)), "#") , text_color = color.lime, bgcolor = color.new(#000000, 75))
else
table.merge_cells(stats, 0, 0, 2, 0)
else
runtime.error("No Gaps Detected - Change Assets or Plot a Different Dataset")
// _______________________________________________________
//
// Quartile Volume
// _______________________________________________________
if show == "Quartile Volume" and loadFast
var line [] xy = array.new_line (2)
var linefill[] xyfill = array.new_linefill(2)
var label [] miniLab = array.new_label ()
var float [] volSub = array.new_float ()
var int [] hold = array.new_int ()
var float [] rang = array.new_float ()
var float [] sVol = array.new_float ()
var float [] pNl = array.new_float ()
var int [] bar = array.new_int ()
var bool [] binTra = array.new_bool (1, false)
var float [] fin = array.new_float ()
var table tab = na
array.push(vol, volume)
if array.size(vol) > 250
array.shift(vol)
if array.size(vol) >= 2
colCond := color.from_gradient(
volume,
array.percentile_linear_interpolation(vol, 25),
array.percentile_linear_interpolation(vol, 75),
colE, colE1
)
var float Q1 = 0.0, var float Q2 = 0.0
var float Q3 = 0.0
var float p9 = 0.0, var float Q4 = 0.0
if array.size(vol) >= 5 and array.size(hold) == 0
if array.size(xz) > 0
array.clear(xz)
array.clear(volSub)
array.clear(rang)
if array.size(sVol) > 0
array.clear(sVol)
for n = 0 to 4 + loopCount
array.push(xz, close[n])
array.push(volSub, volume[n])
array.push(rang, high[n])
array.push(rang, low[n])
for n = 4 + loopCount to 0
if not na(tvsVol)
array.push(sVol, tvsVol[n])
if array.size(vol) > 25 and array.get(binTra, 0) == false
if array.get(vol, array.size(vol) - 1) >= array.percentile_linear_interpolation(vol, 90)
array.push(pNl, close)
array.push(bar, bar_index)
array.set(binTra, 0, true)
if array.get(binTra, 0) == true
if bar_index == array.get(bar, array.size(bar) - 1) + pCalculation
ret = switch log
true => math.log(close / array.get(pNl, array.size(pNl) - 1))
false => (close / array.get(pNl, array.size(pNl) - 1) - 1)
array.push(fin, ret * 100)
array.set(binTra, 0, false)
for i = array.size(vol) - 1 to array.size(vol) - 5 - loopCount
if array.get(vol, i) >= array.percentile_linear_interpolation(vol, 90)
array.push(hold, 1)
if i == array.size(vol) - 5 - loopCount
if array.sum(hold) == 5 + loopCount
if loopCount == 0
array.push(xy, line.new(bar_index - array.size(xz) + 1, X + stDev, bar_index, Y + stDev, color = #00ffff))
array.push(xy, line.new(bar_index - array.size(xz) + 1, X - stDev, bar_index, Y - stDev, color = #00ffff))
array.push(xy, line.new(bar_index - array.size(xz) + 1, X + stDev, bar_index - array.size(xz) + 1, X - stDev, color = #00ffff))
array.push(xy, line.new(bar_index, Y + stDev, bar_index, Y - stDev, color = #00ffff))
array.push(xyfill, linefill.new(array.get(xy, array.size(xy) - 1), array.get(xy, array.size(xy) - 2), color.new(#00ffff, 75)))
array.push(miniLab, label.new(bar_index[2], math.max(X + stDev, Y + stDev) + atr, text = "Volume: " + str.tostring(array.sum(volSub), format.volume)
+ "\nσ: " + str.tostring(array.stdev(xz, false), format.mintick)
+ "\nHigh: " + str.tostring(array.max (rang), format.mintick)
+ "\nLow: " + str.tostring(array.min (rang), format.mintick)
+"\nRange: " + str.tostring(array.range(rang), format.mintick),
style = label.style_label_center,
color = color.new(#00ffff, 50),
textcolor = color.white,
size = size.small
))
if array.sum(sVol) != 0
label.set_text(array.get(miniLab, array.size(miniLab) - 1), label.get_text(array.get(miniLab, array.size(miniLab) - 1)) +
"\nShort Volume: " + str.tostring(array.sum(sVol), format.volume))
loopCount += 1
else
line.set_xy1(array.get(xy, array.size(xy) - 4), bar_index - array.size(xz) + 1, X + stDev)
line.set_xy2(array.get(xy, array.size(xy) - 4), bar_index, Y + stDev)
line.set_xy1(array.get(xy, array.size(xy) - 3), bar_index - array.size(xz) + 1, X - stDev)
line.set_xy2(array.get(xy, array.size(xy) - 3), bar_index, Y - stDev)
line.set_xy1(array.get(xy, array.size(xy) - 2), bar_index - array.size(xz) + 1, X + stDev)
line.set_xy2(array.get(xy, array.size(xy) - 2), bar_index - array.size(xz) + 1, X - stDev)
line.set_xy1(array.get(xy, array.size(xy) - 1), bar_index, Y + stDev)
line.set_xy2(array.get(xy, array.size(xy) - 1), bar_index, Y - stDev)
label.set_xy(array.get(miniLab, array.size(miniLab) - 1), math.round(math.avg(bar_index - array.size(xz) + 1, bar_index)), math.max(X + stDev, Y + stDev) + atr)
label.set_text(array.get(miniLab, array.size(miniLab) - 1), "Volume: " + str.tostring(array.sum(volSub), format.volume)
+ "\nσ: " + str.tostring(array.stdev(xz, false), format.mintick)
+ "\nHigh: " + str.tostring(array.max(rang), format.mintick)
+ "\nLow: " + str.tostring(array.min(rang), format.mintick)
+"\nRange: " + str.tostring(array.max(rang) - array.min(rang), format.mintick)
)
if array.sum(sVol) != 0
label.set_text(array.get(miniLab, array.size(miniLab) - 1), label.get_text(array.get(miniLab, array.size(miniLab) - 1)) +
"\nShort Volume: " + str.tostring(array.sum(sVol), format.volume))
loopCount += 1
if array.size(hold) > 0
array.clear(hold)
if loopCount == loopCount[5]
loopCount := 0
if array.size(vol) > 1
Q1 := array.percentile_linear_interpolation(vol, 25)
Q2 := array.median(vol)
Q3 := array.percentile_linear_interpolation(vol, 75)
p9 := array.percentile_linear_interpolation(vol, 90)
Q4 := array.max(vol)
bool v1 = volume < Q1
bool v2 = volume >= Q1 and volume < Q2
bool v3 = volume >= Q2 and volume < Q3
bool v4 = volume >= Q3 and volume < p9
var label [] quarLab = array.new_label()
array.push(quarLab, label.new(bar_index, close >= open ? high : low,
v1 ? "1" :
v2 ? "2" :
v3 ? "3" :
v4 ? "p9" :
"4" ,
color = color.new(color.white, 100),
style = close >= open ? label.style_label_down : label.style_label_up,
textcolor =
v1 ? c1 :
v2 ? c2 :
v3 ? c3 :
v4 ? c4 :
c5
))
if la == false
if array.size(quarLab) > 15
label.delete(array.shift(quarLab))
if barstate.islastconfirmedhistory
array.sort(fin, order.ascending)
var float [] dn = array.new_float()
var float [] up = array.new_float()
if array.size(fin) > 0
if array.get(fin, 0) <= 0
for i = 1 to array.size(fin) - 1
if array.get(fin, i - 1) <= 0 and array.get(fin, i) > 0
for x = 0 to i - 1
array.push(dn, array.get(fin, x))
for x = i to array.size(fin) - 1
array.push(up, array.get(fin, x))
break
else if array.get(fin, 0) > 0
for i = 0 to array.size(fin) - 1
array.push(up, array.get(fin, i) )
else if array.get(fin, array.size(fin) - 1) <= 0
for i = 0 to array.size(fin) - 1
array.push(dn, array.get(fin, i) )
if array.size(dn) > 0
for n = 0 to array.size(dn) - 1
if n < array.size(dn) - 1
if array.get(dn, n) == 0
array.remove(dn, n)
var table stats = na
tab := table.new(position.top_right, 1, 1, border_color = color.white, frame_color = color.white, border_width = 1, frame_width = 1)
stats := table.new(position.bottom_right, 50, 50, border_width = 1, frame_width = 1, border_color = color.white, frame_color = color.white)
condQuar = showIns == false
table.cell(stats, 0, 0, text = "Volume Percentiles " , bgcolor = color.new(color.white, 50), text_color = #000000)
table.cell(stats, 0, 1, text = "First Quartile: " + str.tostring(array.percentile_linear_interpolation(vol, 25), format.volume), bgcolor = color.new(c1, 50), text_color = color.white)
table.cell(stats, 0, 2, text = "Second Quartile: " + str.tostring(array.median(vol), format.volume), bgcolor = color.new(c2, 50), text_color = color.white)
table.cell(stats, 0, 3, text = "Third Quartile: " + str.tostring(array.percentile_linear_interpolation(vol, 75), format.volume), bgcolor = color.new(c3, 50), text_color = color.white)
table.cell(stats, 0, 4, text = "90 Percentile : " + str.tostring(array.percentile_linear_interpolation(vol, 90), format.volume), bgcolor = color.new(c4, 50), text_color = color.white)
table.cell(stats, 0, 5, text = "Fourth Quartile : " + str.tostring(math.round(array.max(vol)), format.volume), bgcolor = color.new(c5, 50), text_color = color.white)
table.cell(stats, condQuar ? 0 : 1, condQuar ? 6 : 0, text = "Dispersion" , bgcolor = color.new(color.white, 50), text_color = #000000)
table.cell(stats, condQuar ? 0 : 1, condQuar ? 7 : 1, text = "Q2 - Q1: " + str.tostring(Q2 - Q1, format.volume), bgcolor = color.new(#5d606b, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 1, condQuar ? 8 : 2, text = "Q3 - Q2: " + str.tostring(Q3 - Q2, format.volume), bgcolor = color.new(#434651, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 1, condQuar ? 9 : 3, text = "Q4 - Q3: " + str.tostring(Q4 - Q3, format.volume), bgcolor = color.new(#2a2e39, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 1, condQuar ? 10 : 4, text = "Quartile Deviation: " + str.tostring((Q3 - Q1) / 2, format.volume), bgcolor = color.new(#131722, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 1, condQuar ? 11 : 5, text = "Interquartile Range: " + str.tostring(Q3 - Q1, format.volume), bgcolor = color.new(#000000, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 2, condQuar ? 12 : 0, text = "If Volume Exceeds 90th Percentile \n(Flat Returns Excluded)" , bgcolor = color.new(color.white, 50), text_color = #000000)
table.cell(stats, condQuar ? 0 : 2, condQuar ? 13 : 1, text = "Avg. " + str.tostring(pCalculation, "#") + " Bar PnL: " + str.tostring(array.avg(fin), format.percent) , bgcolor = color.new(#5d606b, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 2, condQuar ? 14 : 2, text = "Avg. " + str.tostring(pCalculation, "#") + " Bar Pos. Return: " + str.tostring(array.avg(up), format.percent) , bgcolor = color.new(#434651, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 2, condQuar ? 15 : 3, text = "Avg. " + str.tostring(pCalculation, "#") + " Bar Neg. Return: " + str.tostring(array.avg(dn), format.percent) , bgcolor = color.new(#2a2e39, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 2, condQuar ? 16 : 4, text = "# of Pos. Returns: " + str.tostring(array.size(up), "#") + " (" + str.tostring(array.size(up) / array.size(fin) * 100, format.percent) + ")", bgcolor = color.new(#131722, 50), text_color = color.white, text_halign = text.align_left)
table.cell(stats, condQuar ? 0 : 2, condQuar ? 17 : 5, text = "# of Neg. Returns: " + str.tostring(array.size(dn), "#") + " (" + str.tostring(array.size(dn) / array.size(fin) * 100, format.percent) + ")", bgcolor = color.new(#000000, 50), text_color = color.white, text_halign = text.align_left)
if showIns == true
if quar == false
var table midRight = table.new(position.middle_right, 10, 10, bgcolor = na)
table.cell(midRight, 0, 0, text = "▮ = Higher Volume" , text_color = color.lime)
table.cell(midRight, 0, 1, text = "▮ = Lower Volume " , text_color = color.red)
table.cell(tab, 0, 0, text = "In Chart Settings, Hide TradingView Plotted Candlesticks ↑", text_size = size.small, bgcolor = color.new(#f06292, 50), text_color = color.white)
if barstate.islast
var label [] y = array.new_label()
var line [] y1 = array.new_line()
color c =
volume < Q1 ? color.new(c1, 75) :
volume >= Q1 and volume < Q2 ? color.new(c2, 75) :
volume >= Q2 and volume < Q3 ? color.new(c3, 75) :
volume >= Q3 and volume < p9 ? color.new(c4, 75) :
color.new(c5, 75)
color cFin = switch quar
false => colCond
true => c
if array.size(y) == 0
array.push(y, label.new(bar_index + 2, close >= open ? high : low, color = color.new(cFin, 75),
text = "This Bar Has Higher Volume Than \n" + str.tostring(array.percentrank(vol, array.size(vol) - 1), format.percent)
+ "\n Of Intervals",
style = label.style_label_left,
textcolor = color.white ,
size = size.small ,
tooltip = str.tostring(100 - array.percentrank(vol, array.size(vol) - 1), format.percent)
+ " Of Intervals Had Greater Volume Than This Bar (:"
))
array.push(y1, line.new(bar_index, label.get_y(array.get(y, array.size(y) - 1)),
bar_index + 2,
label.get_y(array.get(y, array.size(y) - 1)),
style = line.style_dashed,
color = color.new(cFin, 75)
))
else
label.set_xy ( array.get(y, array.size(y) - 1), bar_index + 2, close >= open ? high : low)
label.set_color ( array.get(y, array.size(y) - 1), color.new(cFin, 75))
line.set_xy1 ( array.get(y1,array.size(y1) - 1), bar_index, label.get_y(array.get(y, array.size(y) - 1)))
line.set_xy2 ( array.get(y1,array.size(y1) - 1), bar_index + 2, label.get_y(array.get(y, array.size(y) - 1)))
line.set_color ( array.get(y1,array.size(y1) - 1), color.new(cFin, 75))
label.set_tooltip( array.get(y, array.size(y1) - 1), str.tostring(100 - array.percentrank(vol, array.size(vol) - 1), format.percent)
+ " Of Intervals Had Greater Volume Than This Bar (:")
label.set_text ( array.get(y, array.size(y) - 1), "This Bar Has Higher Volume Than \n" + str.tostring(array.percentrank(vol, array.size(vol) - 1), format.percent)
+ "\n Of Intervals")
var line [] sten = array.new_line()
var linefill [] stenfill = array.new_linefill()
if start()
and anch == true
and s >= array.get(tim, 0)
array.push(sten, line.new(math.round(s), close, math.round(s), close + syminfo.mintick, xloc = xloc.bar_time, color = color.white, width = 2, extend = extend.both))
array.push(sten, line.new(math.round(e), close, math.round(e), close + syminfo.mintick, xloc = xloc.bar_time, color = color.white, width = 2, extend = extend.both))
array.push(stenfill, linefill.new(array.get(sten, array.size(sten) - 1), array.get(sten, array.size(sten) - 2), color.new(color.white, 95)))
if array.size(sten) > 2
line.delete(array.shift(sten))
if array.size(stenfill) > 1
linefill.delete(array.get(stenfill, array.size(stenfill) - 1))
finCol() =>
if array.size(vol) > 1
q1 = array.percentile_linear_interpolation(vol, 25)
q2 = array.median(vol)
q3 = array.percentile_linear_interpolation(vol, 75)
p9 = array.percentile_linear_interpolation(vol, 90)
q4 = array.max(vol)
if volume >= 0 and volume < q1
c1
else if volume >= q1 and volume < q2
c2
else if volume >= q2 and volume < q3
c3
else if volume >= q3 and volume < p9
c4
else if volume >= p9 and volume <= q4
c5
VWAP() =>
var float y = na
var float y1 = na
var float y2 = na
if start()[1] == false
if start() == true
y := hlc3 * volume
y1 := volume
y2 := volume * math.pow(hlc3, 2)
if start()[1] == true
y := hlc3 * volume + y[1]
y1 := volume + y1[1]
y2 := volume * math.pow(hlc3, 2) + y2[1]
float middle = y / y1
float vaR = y2 / y1 - math.pow(middle, 2)
vaR := vaR < 0 ? 0 : vaR
float stDevX = math.sqrt(vaR)
float upper = middle + stDevX * 2
float lower = middle - stDevX * 2
[middle, upper, lower]
[m,u,l] = VWAP()
Z = plot(anch == true ? m : na, title = "Anchored VWAP", color = start() ? color.orange : na)
Z1 = plot(anch == true ? u : na, title = "Upper Band", color = start() ? color.lime : na)
Z2 = plot(anch == true ? l : na, title = "Lower Band", color = start() ? color.lime : na)
fill(Z1, Z2, color = anch == true and start() ? color.new(color.lime, 80) : na)
color colr = switch show
"Quartile Volume" => colCond
=> na
color colF = switch quar
false => colr
true => finCol()
plotcandle (
open,
high,
low,
close,
color = show == "Gaps" and close >= open ? color.lime : show == "Gaps" and close < open ? color.red : colF,
wickcolor = show == "Gaps" and close >= open ? color.lime : show == "Gaps" and close < open ? color.red : colF,
bordercolor = show == "Gaps" and close >= open ? color.lime : show == "Gaps" and close < open ? color.red : colF
)
|
CFB-Adaptive, Jurik DMX Histogram [Loxx] | https://www.tradingview.com/script/rFYtjCR1-CFB-Adaptive-Jurik-DMX-Histogram-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 120 | 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(title="CFB-Adaptive, Jurik DMX Histogram [Loxx]",
shorttitle="CFBAJDMXH [Loxx]",
timeframe="",
timeframe_gaps=true,
overlay = false)
import loxx/loxxjuriktools/1 as jf
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
darkGreenColor = #1B7E02
darkRedColor = #93021F
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = 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)"])
adapt = input.string("CFB Adaptive", "Calculation type", options = ["Fixed", "CFB Adaptive"], group = "Basic Settings")
len = input.int(32, minval=1, title="Length", group = "Basic Settings")
phs = input.int(0, title= "Jurik Phase", group = "Basic Settings")
siglen = input.int(5, minval=1, title="Signal Smoothing Length", group = "Basic Settings")
nlen = input.int(50, "CFB Normal Period", minval = 1, group = "CFB Ingest Settings")
cfb_len = input.int(8, "CFB Depth", maxval = 10, group = "CFB Ingest Settings")
smth = input.int(8, "CFB Smooth Period", minval = 1, group = "CFB Ingest Settings")
slim = input.int(10, "CFB Short Limit", minval = 1, group = "CFB Ingest Settings")
llim = input.int(60, "CFB Long Limit", minval = 1, group = "CFB Ingest Settings")
jcfbsmlen = input.int(10, "CFB Jurik Smooth Period", minval = 1, group = "CFB Ingest Settings")
jcfbsmph = input.float(0, "CFB Jurik Smooth Phase", group = "CFB Ingest Settings")
CfbSmoothDouble = input.bool(true, "CFB Double Juirk Smoothing?", group = "CFB Ingest 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
float src = switch srcoption
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
cfb_draft = jf.jcfb(src, cfb_len, smth)
cfb_pre =
CfbSmoothDouble ? jf.jurik_filt(jf.jurik_filt(cfb_draft, jcfbsmlen, jcfbsmph), jcfbsmlen, jcfbsmph) :
jf.jurik_filt(cfb_draft, jcfbsmlen, jcfbsmph)
max = ta.highest(cfb_pre, nlen)
min = ta.lowest(cfb_pre, nlen)
denom = max - min
ratio = (denom > 0) ? (cfb_pre - min) / denom : 0.5
len_out_cfb = math.ceil(slim + ratio * (llim - slim))
out = adapt == "Fixed" ? len : len_out_cfb
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)
trur = jf.jurik_filt(ta.tr, out, phs)
plus = fixnan(100 * jf.jurik_filt(plusDM, out, phs) / trur)
minus = fixnan(100 * jf.jurik_filt(minusDM, out, phs) / trur)
trigger = plus-minus
signal = jf.jurik_filt(trigger, siglen, phs)
colorout =
trigger >= 0 and trigger >= signal ? greencolor :
trigger >= 0 and trigger < signal ? lightgreencolor :
trigger < 0 and trigger < signal ? redcolor :
lightredcolor
mid = 0
plot(trigger, color=colorout, title = "DMX", style = plot.style_histogram)
plot(trigger, "DMX", color = trigger >= 0 ? darkGreenColor : darkRedColor, linewidth = 1)
plot(signal, color = color.white, title = "Signal", linewidth = 1)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(trigger, mid)
goShort = ta.crossunder(trigger, mid)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "CFB-Adaptive, Jurik DMX Histogram [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "CFB-Adaptive, Jurik DMX Histogram [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
STD-Filtered, Gaussian-Kernel-Weighted Moving Average [Loxx] | https://www.tradingview.com/script/4BKPUoCt-STD-Filtered-Gaussian-Kernel-Weighted-Moving-Average-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 294 | 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("STD-Filtered, Gaussian-Kernel-Weighted Moving Average [Loxx]",
shorttitle='STDSGKWMA [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_gkwma(float src, int per, float bw)=>
float sum = 0.
float sumw = 0.
for j = 0 to per - 1
w = (1 / math.sqrt(2 * math.pi)) * math.exp(-0.5 * math.pow(j / bw, 2))
sum += nz(src[j]) * w
sumw += w
out = sum / sumw
out
_filt(src, len, filter)=>
price = src
filtdev = filter * ta.stdev(src, len)
price := math.abs(price - price[1]) < filtdev ? price[1] : price
price
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = input.string("HAB Trend Biased (Extreme)", "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)"])
bw = input.float(11.,'Bandwidth', group = "Gaussian-Kernel Settings")
filterop = input.string("GKS Filter", "Filter Options", options = ["Price", "GKS Filter", "Both"], group= "Filter Settings")
filter = input.float(3, "Filter Devaitions", minval = 0, group= "Filter Settings")
filterperiod = input.int(15, "Filter Period", minval = 0, group= "Filter 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
float src = switch srcoption
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
src := filterop == "Both" or filterop == "Price" and filter > 0 ? _filt(src, filterperiod, filter) : src
out = _gkwma(src, 100, bw)
out := filterop == "Both" or filterop == "GKS Filter" and filter > 0 ? _filt(out, filterperiod, filter) : out
sig = nz(out[1])
state = 0.
if (out < sig)
state :=-1
if (out > sig)
state := 1
pregoLong = ta.crossover(out, sig)
pregoShort = ta.crossunder(out, sig)
contsw = 0
contsw := nz(contsw[1])
contsw := pregoLong ? 1 : pregoShort ? -1 : nz(contsw[1])
goLong = ta.crossover(out, sig) and nz(contsw[1]) == -1
goShort = ta.crossunder(out, sig) and nz(contsw[1]) == 1
var color colorout = na
colorout := state == -1 ? redcolor : state == 1 ? greencolor : nz(colorout[1])
plot(out, "GKWMA", color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
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 = "STD-Filtered, Gaussian-Kernel-Weighted Moving Average [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "STD-Filtered, Gaussian-Kernel-Weighted Moving Average [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
ICT Killzone [Forex Edition] | https://www.tradingview.com/script/gLHqnxvc/ | SimoneMicucci00 | https://www.tradingview.com/u/SimoneMicucci00/ | 363 | 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/
// © SimoneMicucci00
//@version=5
indicator("ICT Killzone [Forex Edition]", "Killzone", true, max_boxes_count = 500, max_labels_count = 500)
lno_ = input.bool(true, "London Open Killzone", "02:00-05:00 New York timezone", "", "Session")
nyo_ = input.bool(true, "New York Open Killzone", "07:00-09:00 New York timezone", "", "Session")
lnc_ = input.bool(true, "London Close Killzone", "10:00-12:00 New York timezone", "", "Session")
asb_ = input.bool(true, "Asian Range", "18:00-24:00 New York timezone", "", "Session")
lno_b = input.bool(false, "London Open box", "", "", "session in box")
nyo_b = input.bool(false, "New York Open box", "", "", "session in box")
lnc_b = input.bool(false, "London Close box", "", "", "session in box")
asb_b = input.bool(true, "Asian Range box", "", "", "session in box")
info = input.bool(false, "info over box", "this will show the range of the session in pips (make sense only on forex)", "", "session in box")
spec = input.int(90, "Transparency", 0, 100, 1, "from 0 to 100, how much you want the color transparent?", "", "Visual Features")
lno_c = input.color(color.green, "London Open Killzone", "", "", "Visual Features")
nyo_c = input.color(color.blue, "New York Open Killzone", "", "", "Visual Features")
lnc_c = input.color(color.orange, "London Close Killzone", "", "", "Visual Features")
asb_c = input.color(color.yellow, "Asian Range", "", "", "Visual Features")
b_color = color.new(#000000,50)
lno = time('', '0200-0500', 'America/New_York') and lno_ and timeframe.isintraday and timeframe.multiplier <= 60
nyo = time('', '0700-0900', 'America/New_York') and nyo_ and timeframe.isintraday and timeframe.multiplier <= 60
lnc = time('', '1000-1200', 'America/New_York') and lnc_ and timeframe.isintraday and timeframe.multiplier <= 60
asb = time('', '1800-0000', 'America/New_York') and asb_ and timeframe.isintraday and timeframe.multiplier <= 60
bgcolor(lno and not lno_b and lno_? color.new(lno_c, spec) : na)
bgcolor(nyo and not nyo_b and nyo_? color.new(nyo_c, spec) : na)
bgcolor(lnc and not lnc_b and lnc_? color.new(lnc_c, spec) : na)
bgcolor(asb and not asb_b and asb_? color.new(asb_c, spec) : na)
var box lno_box = na
var box nyo_box = na
var box lnc_box = na
var box asb_box = na
var label lno_l = na
var label nyo_l = na
var label lnc_l = na
var label asb_l = na
if lno_ and lno_b and timeframe.multiplier<=60 and timeframe.isintraday
if lno and not lno[1]
lno_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(lno_c,spec))
if info
lno_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
if lno and lno[1]
if high > box.get_top(lno_box)
box.set_top(lno_box,high)
if low < box.get_bottom(lno_box)
box.set_bottom(lno_box,low)
box.set_right(lno_box,bar_index+1)
if info
label.set_text(lno_l,str.tostring((box.get_top(lno_box)-box.get_bottom(lno_box))/10/syminfo.mintick)+" pip")
label.set_x(lno_l,(box.get_left(lno_box)+box.get_right(lno_box))/2)
label.set_y(lno_l,box.get_top(lno_box))
if not lno and lno[1]
box.set_right(lno_box,bar_index-1)
if nyo_ and nyo_b and timeframe.multiplier<=60 and timeframe.isintraday
if nyo and not nyo[1]
nyo_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(nyo_c,spec))
if info
nyo_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
if nyo and nyo[1]
if high > box.get_top(nyo_box)
box.set_top(nyo_box,high)
if low < box.get_bottom(nyo_box)
box.set_bottom(nyo_box,low)
box.set_right(nyo_box,bar_index+1)
if info
label.set_text(nyo_l,str.tostring((box.get_top(nyo_box)-box.get_bottom(nyo_box))/10/syminfo.mintick)+" pip")
label.set_x(nyo_l,(box.get_left(nyo_box)+box.get_right(nyo_box))/2)
label.set_y(nyo_l,box.get_top(nyo_box))
if not nyo and nyo[1]
box.set_right(nyo_box,bar_index-1)
if lnc_ and lnc_b and timeframe.multiplier<=60 and timeframe.isintraday
if lnc and not lnc[1]
lnc_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(lnc_c,spec))
if info
lnc_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
if lnc and lnc[1]
if high > box.get_top(lnc_box)
box.set_top(lnc_box,high)
if low < box.get_bottom(lnc_box)
box.set_bottom(lnc_box,low)
box.set_right(lnc_box,bar_index+1)
if info
label.set_text(lnc_l,str.tostring((box.get_top(lnc_box)-box.get_bottom(lnc_box))/10/syminfo.mintick)+" pip")
label.set_x(lnc_l,(box.get_left(lnc_box)+box.get_right(lnc_box))/2)
label.set_y(lnc_l,box.get_top(lnc_box))
if not lnc and lnc[1]
box.set_right(lnc_box,bar_index-1)
if asb_ and asb_b and timeframe.multiplier<=60 and timeframe.isintraday
if asb and not asb[1]
asb_box := box.new(bar_index,high,bar_index+1,low,b_color,bgcolor = color.new(asb_c,spec))
if info
asb_l := label.new(bar_index,high,str.tostring((high-low)/10/syminfo.mintick)+" pip",textcolor = #000000, size = size.small,style = label.style_none)
if asb and asb[1]
if high > box.get_top(asb_box)
box.set_top(asb_box,high)
if low < box.get_bottom(asb_box)
box.set_bottom(asb_box,low)
box.set_right(asb_box,bar_index+1)
if info
label.set_text(asb_l,str.tostring((box.get_top(asb_box)-box.get_bottom(asb_box))/10/syminfo.mintick)+" pip")
label.set_x(asb_l,(box.get_left(asb_box)+box.get_right(asb_box))/2)
label.set_y(asb_l,box.get_top(asb_box))
if not asb and asb[1]
box.set_right(asb_box,bar_index-1)
|
OMA-Filtered Kase Permission Stochastic [Loxx] | https://www.tradingview.com/script/EFA5FfI4-OMA-Filtered-Kase-Permission-Stochastic-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 115 | 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("OMA-Filtered Kase Permission Stochastic [Loxx]",
shorttitle="OMAFKPS [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
_oma(src, len, sped, adapt) =>
e1 = nz(src[1]), e2 = nz(src[1]), e3 = nz(src[1])
e4 = nz(src[1]), e5 = nz(src[1]), e6 = nz(src[1])
averagePeriod = 0.
noise = 0.00000000001
minPeriod = len/2.0
maxPeriod = minPeriod*5.0
endPeriod = math.ceil(maxPeriod)
signal = math.abs(src - nz(src[endPeriod]))
if adapt
for k = 1 to endPeriod
noise += math.abs(src - nz(src[k]))
averagePeriod := ((signal / noise) * (maxPeriod - minPeriod)) + minPeriod
//calc jurik momentum
alpha = (2.0 + sped) / (1.0 + sped + averagePeriod)
e1 := nz(e1[1] + alpha * (src - e1[1]), src)
e2 := nz(e2[1] + alpha * (e1 - e2[1]), e1)
v1 = 1.5 * e1 - 0.5 * e2
e3 := nz(e3[1] + alpha * (v1 - e3[1]), v1)
e4 := nz(e4[1] + alpha * (e3 - e4[1]), e3)
v2 = 1.5 * e3 - 0.5 * e4
e5 := nz(e5[1] + alpha * (v2 - e5[1]), v2)
e6 := nz(e6[1] + alpha * (e5 - e6[1]), e5)
v3 = 1.5 * e5 - 0.5 * e6
v3
pstLength = input.int(9, "Period", group = "Basic Settings")
pstX = input.int(5, "Synthetic Multiplier", group = "Basic Settings")
pstSmooth = input.int(3, "Stochasitc Smoothing Period", group = "Basic Settings")
smoothPeriod = input.int(10, "OMA Smoothing Period", group = "Basic Settings")
smoothSpeed = input.float(3., "OMA Speed", group = "Basic Settings")
smoothAdaptive = input.bool(true, "Make OMA adaptive?", group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group = "UI Options")
lookBackPeriod = pstLength * pstX
alpha = 2.0 / (1.0 + pstSmooth)
TripleK = 0., TripleDF = 0., TripleDS = 0., TripleDSs = 0., TripleDFs = 0.
fmin = ta.lowest(low, lookBackPeriod)
fmax = ta.highest(high, lookBackPeriod) - fmin
if (fmax > 0)
TripleK := 100.0 * (close - fmin) / fmax
else
TripleK := 0.0
TripleDF := nz(TripleDF[pstX]) + alpha * (TripleK - nz(TripleDF[pstX]))
TripleDS := (nz(TripleDS[pstX]) * 2.0 + TripleDF) / 3.0
TripleDSs := ta.sma(TripleDS, 3)
pssBuffer = _oma(TripleDSs, smoothPeriod, smoothSpeed, smoothAdaptive)
TripleDFs := ta.sma(TripleDF, 3)
pstBuffer = _oma(TripleDFs, smoothPeriod, smoothSpeed, smoothAdaptive)
trend = 0
trend := nz(trend[1])
if (pstBuffer > pssBuffer)
trend := 1
if (pstBuffer < pssBuffer)
trend := -1
colorout = trend == 1 ? greencolor : trend == -1 ? redcolor : color.gray
plot(pssBuffer, color = color.white, linewidth = 1)
plot(pstBuffer, color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(pstBuffer, pssBuffer)
goShort = ta.crossunder(pstBuffer, pssBuffer)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "OMA-Filtered Kase Permission Stochastic [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "OMA-Filtered Kase Permission Stochastic [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
3 or more consecutive candles | https://www.tradingview.com/script/fvp5k1CF-3-or-more-consecutive-candles/ | bap666_ | https://www.tradingview.com/u/bap666_/ | 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/
// © bap666_
//@version=5
indicator("3+ candles", overlay=true)
bull_candle = close - open > 0
bear_candle = close - open < 0
tc = close[2] - open[2] > 0 //thirdcandle
sc = close[1] - open[1] > 0 //second candle
fc = close - open > 0 //first candle
threesame = tc == sc and sc == fc and tc == fc
three_bull = bull_candle and threesame
three_bear = bear_candle and threesame
barcolor(three_bear? #fbc02d: three_bull? #9575cd : na,-2)
barcolor(three_bear? #fbc02d: three_bull? #9575cd: na,-1)
barcolor(three_bear? #fbc02d: three_bull? #9575cd : na) |
Previous Days Ranges | https://www.tradingview.com/script/01K6IG2R-Previous-Days-Ranges/ | syntaxgeek | https://www.tradingview.com/u/syntaxgeek/ | 87 | 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/
// © syntaxgeek
//@version=5
indicator(title="Previous Days Ranges", shorttitle="PDR", overlay=true)
// todo
// * add better breakout and retest detection
// * have mid range price lines draw only when necessary to reduce eye strain
// * alerts for key level breakouts like phod and plod
// <inputs>
i_daySession = input.session(title="Regular Session", defval="0930-1600")
i_ethSession = input.session(title="Extended Session", defval="1600-2000")
i_showPriceTargetLabels = input.bool(title="Show Price Target Labels?", defval=true)
i_showEntries = input.bool(true, "Show potential breakouts.")
// i_alertBreakoutsOnly = input.bool(false, "Alert only on breakouts (not price ticks)")
i_showRangeLevels = input.string("none", "Show Range Levels?", options=["fib", "percentage", "none"])
// </inputs>
// <funcs>
// f_SessionHigh() returns the highest price during the specified
// session, optionally corrected for the given time zone.
// Returns 'na' when the session hasn't started or isn't on the chart.
f_SessionHigh(sessionTime, sessionTimeZone=syminfo.timezone) =>
insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
var float sessionHighPrice = na
if insideSession and not insideSession[1]
sessionHighPrice := high
else if insideSession
sessionHighPrice := math.max(sessionHighPrice, high)
sessionHighPrice
// f_SessionLow() returns the lowest price during the given session,
// optionally corrected for the specified time zone.
// Returns 'na' when the session hasn't started or isn't on the chart.
f_SessionLow(sessionTime, sessionTimeZone=syminfo.timezone) =>
insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
var float sessionLowPrice = na
if insideSession and not insideSession[1]
sessionLowPrice := low
else if insideSession
sessionLowPrice := math.min(sessionLowPrice, low)
sessionLowPrice
// f_DrawPriceTargetLabel() draws new price label flag at right of price data
// requires re-execution to keep label right justified of price data
f_DrawPriceTargetLabel(fromPrice, level, name, col) =>
if i_showPriceTargetLabels
var lbl = label.new(bar_index, fromPrice + level, style=label.style_label_lower_left, text=name, color=col, textcolor=color.white)
label.set_xy(lbl, bar_index + 2, fromPrice + level)
f_RenderBreakoutLabel(yloc, labelStyle) =>
lbl = label.new(bar_index, na)
label.set_color(lbl, color.green)
label.set_textcolor(lbl, color.green)
label.set_text(lbl, "Breakout")//\n Wait for Retest")
label.set_yloc(lbl, yloc)
label.set_style(lbl, labelStyle)
label.set_size(lbl, size.tiny)
f_RenderBreakoutRetestLabel(message, yloc, color, labelStyle) =>
lbl = label.new(bar_index, na)
label.set_color(lbl, color)
label.set_textcolor(lbl, color.white)
label.set_text(lbl, message)
label.set_yloc(lbl, yloc)
label.set_style(lbl, labelStyle)
label.set_size(lbl, size.tiny)
f_OverPrevDayHigh(pdh) => close >= pdh
f_UnderPrevDayLow(pdl) => close <= pdl
f_RenderPercentageHigh(pdh) => f_OverPrevDayHigh(pdh) and i_showRangeLevels == "percentage" and session.ismarket
f_RenderPercentageLow(pdl) => f_UnderPrevDayLow(pdl) and i_showRangeLevels == "percentage" and session.ismarket
f_RenderFibHigh(pdh) => f_OverPrevDayHigh(pdh) and i_showRangeLevels == "fib" and session.ismarket
f_RenderFibLow(pdl) => f_UnderPrevDayLow(pdl) and i_showRangeLevels == "fib" and session.ismarket
f_CalculatePDRPercentage(price, priceRange, multi) =>
price + (priceRange * multi)
// </funcs>
// <vars>
v_ethStockSessHigh = f_SessionHigh(i_ethSession)
v_ethStockSessLow = f_SessionLow(i_ethSession)
v_prevDayHigh = request.security(syminfo.tickerid, 'D', high[1], lookahead = barmerge.lookahead_on)
v_prevDayLow = request.security(syminfo.tickerid, 'D', low[1], lookahead = barmerge.lookahead_on)
v_pdrRange = v_prevDayHigh - v_prevDayLow
v_prevDayMid = v_prevDayHigh - (v_pdrRange / 2)
v_pdrRangeMidToHigh = v_prevDayHigh - v_prevDayMid
v_pdrRangeMidToLow = v_prevDayMid - v_prevDayLow
// fib range based levels
v_levelHighFib1 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 0.236)
v_levelHighFib2 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 0.382)
v_levelHighFib3 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 0.5)
v_levelHighFib4 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 0.618)
v_levelHighFib5 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 0.786)
v_levelLowFib1 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -0.236)
v_levelLowFib2 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -0.382)
v_levelLowFib3 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -0.5)
v_levelLowFib4 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -0.618)
v_levelLowFib5 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -0.786)
// percentage range based levels
v_levelHighPer1 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 0.5)
v_levelHighPer2 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 1)
v_levelHighPer3 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 1.5)
v_levelHighPer4 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 2)
v_levelHighPer5 = f_CalculatePDRPercentage(v_prevDayHigh, v_pdrRange, 2.5)
v_levelLowPer1 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -0.5)
v_levelLowPer2 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -1)
v_levelLowPer3 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -1.5)
v_levelLowPer4 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -2)
v_levelLowPer5 = f_CalculatePDRPercentage(v_prevDayLow, v_pdrRange, -2.5)
// fib mid range based levels
v_levelMidHighFib1 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.236)
v_levelMidHighFib2 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.382)
v_levelMidHighFib3 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.5)
v_levelMidHighFib4 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.618)
v_levelMidHighFib5 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.786)
v_levelMidLowFib1 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.236)
v_levelMidLowFib2 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.382)
v_levelMidLowFib3 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.5)
v_levelMidLowFib4 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.618)
v_levelMidLowFib5 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.786)
// percentage mid range based levels
v_levelMidHighPer1 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.25)
v_levelMidHighPer2 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.5)
v_levelMidHighPer3 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToHigh, 0.75)
v_levelMidLowPer1 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.25)
v_levelMidLowPer2 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.5)
v_levelMidLowPer3 = f_CalculatePDRPercentage(v_prevDayMid, v_pdrRangeMidToLow, -0.75)
var v_inBreakout = false
bool v_prevDayHighBreakOut = (low[2] < v_prevDayHigh and close[2] > v_prevDayHigh and low[1] > v_prevDayHigh and close[1] > v_prevDayHigh and close > low[1] and low > v_prevDayHigh) and session.ismarket
bool v_prevDayLowBreakOut = (high[2] > v_prevDayLow and close[2] < v_prevDayLow and high[1] < v_prevDayLow and close[1] < v_prevDayLow and close < high[1] and high < v_prevDayLow) and session.ismarket
bool v_prevDayHighCross = (ta.cross(close, v_prevDayHigh)) or (v_prevDayHighBreakOut) //not i_alertBreakoutsOnly and ... i_alertBreakoutsOnly and
bool v_prevDayLowCross = (ta.cross(close, v_prevDayLow)) or (v_prevDayLowBreakOut) //not i_alertBreakoutsOnly and ... i_alertBreakoutsOnly and
bool v_isPrevDayHighRetest = close[1] > v_prevDayHigh and low <= v_prevDayHigh and close >= v_prevDayHigh
bool v_isPrevDayLowRetest = close[1] < v_prevDayLow and high >= v_prevDayLow and close <= v_prevDayLow
bool v_isFailedRetest = v_inBreakout and ((close[1] > v_prevDayHigh and close < v_prevDayHigh) or (close[1] < v_prevDayLow and close > v_prevDayLow))
// </vars>
// <plots>
if (i_showEntries and session.ismarket)
if (v_prevDayHighBreakOut)
f_RenderBreakoutLabel(yloc.abovebar, label.style_triangledown)
v_inBreakout := true
if (v_prevDayLowBreakOut)
f_RenderBreakoutLabel(yloc.belowbar, label.style_triangleup)
v_inBreakout := true
// if v_inBreakout and (v_isPrevDayHighRetest or v_isPrevDayLowRetest)
// f_RenderBreakoutRetestLabel("Retest", yloc.abovebar, color.green, label.style_label_down)
// v_inBreakout := false
// if v_inBreakout and v_isFailedRetest
// f_RenderBreakoutRetestLabel("Failed Retest", yloc.abovebar, color.red, label.style_label_down)
// v_inBreakout := false
if (session.ismarket)
f_DrawPriceTargetLabel(v_prevDayHigh, 0, "PDH", color.red)
f_DrawPriceTargetLabel(v_prevDayMid, 0, "PDM", color.gray)
f_DrawPriceTargetLabel(v_prevDayLow, 0, "PDL", color.green)
f_DrawPriceTargetLabel(v_ethStockSessHigh, 0, "EH", color.new(color.purple, 50))
f_DrawPriceTargetLabel(v_ethStockSessLow, 0, "EL", color.new(color.yellow, 50))
if (f_RenderPercentageHigh(v_prevDayHigh))
f_DrawPriceTargetLabel(v_levelHighPer5, 0, 'PDH 250%', color.red)
f_DrawPriceTargetLabel(v_levelHighPer4, 0, 'PDH 200%', color.red)
f_DrawPriceTargetLabel(v_levelHighPer3, 0, 'PDH 150%', color.red)
f_DrawPriceTargetLabel(v_levelHighPer2, 0, 'PDH 100%', color.red)
f_DrawPriceTargetLabel(v_levelHighPer1, 0, 'PDH 50%', color.red)
if (f_RenderPercentageLow(v_prevDayLow))
f_DrawPriceTargetLabel(v_levelLowPer5, 0, 'PDL 250%', color.red)
f_DrawPriceTargetLabel(v_levelLowPer4, 0, 'PDL 200%', color.red)
f_DrawPriceTargetLabel(v_levelLowPer3, 0, 'PDL 150%', color.red)
f_DrawPriceTargetLabel(v_levelLowPer2, 0, 'PDL 100%', color.red)
f_DrawPriceTargetLabel(v_levelLowPer1, 0, 'PDL 50%', color.red)
if (f_RenderFibHigh(v_prevDayHigh))
f_DrawPriceTargetLabel(v_levelHighFib5, 0, 'PDH FIB 78.6%', color.red)
f_DrawPriceTargetLabel(v_levelHighFib4, 0, 'PDH FIB 61.8%', color.red)
f_DrawPriceTargetLabel(v_levelHighFib3, 0, 'PDH FIB 50%', color.red)
f_DrawPriceTargetLabel(v_levelHighFib2, 0, 'PDH FIB 38.2%', color.red)
f_DrawPriceTargetLabel(v_levelHighFib1, 0, 'PDH FIB 23.6%', color.red)
if (f_RenderFibLow(v_prevDayLow))
f_DrawPriceTargetLabel(v_levelLowFib1, 0, 'PDL FIB -23.6%', color.green)
f_DrawPriceTargetLabel(v_levelLowFib2, 0, 'PDL FIB -38.2%', color.green)
f_DrawPriceTargetLabel(v_levelLowFib3, 0, 'PDL FIB -50%', color.green)
f_DrawPriceTargetLabel(v_levelLowFib4, 0, 'PDL FIB -61.8%', color.green)
f_DrawPriceTargetLabel(v_levelLowFib5, 0, 'PDL FIB -78.6%', color.green)
if (i_showRangeLevels == "percentage" and session.ismarket)
f_DrawPriceTargetLabel(v_levelMidHighPer3, 0, "PDMH 75%", color.red)
f_DrawPriceTargetLabel(v_levelMidHighPer2, 0, "PDMH 50%", color.red)
f_DrawPriceTargetLabel(v_levelMidHighPer1, 0, "PDMH 25%", color.red)
f_DrawPriceTargetLabel(v_levelMidLowPer1, 0, "PDMH 25%", color.green)
f_DrawPriceTargetLabel(v_levelMidLowPer2, 0, "PDMH 50%", color.green)
f_DrawPriceTargetLabel(v_levelMidLowPer3, 0, "PDMH 75%", color.green)
if (i_showRangeLevels == "fib" and session.ismarket)
f_DrawPriceTargetLabel(v_levelMidHighFib5, 0, 'PDMH FIB 78.6%', color.red)
f_DrawPriceTargetLabel(v_levelMidHighFib4, 0, 'PDMH FIB 61.8%', color.red)
f_DrawPriceTargetLabel(v_levelMidHighFib3, 0, 'PDMH FIB 50%', color.red)
f_DrawPriceTargetLabel(v_levelMidHighFib2, 0, 'PDMH FIB 38.2%', color.red)
f_DrawPriceTargetLabel(v_levelMidHighFib1, 0, 'PDMH FIB 23.6%', color.red)
f_DrawPriceTargetLabel(v_levelMidLowFib1, 0, 'PDML FIB -23.6%', color.green)
f_DrawPriceTargetLabel(v_levelMidLowFib2, 0, 'PDML FIB -38.2%', color.green)
f_DrawPriceTargetLabel(v_levelMidLowFib3, 0, 'PDML FIB -50%', color.green)
f_DrawPriceTargetLabel(v_levelMidLowFib4, 0, 'PDML FIB -61.8%', color.green)
f_DrawPriceTargetLabel(v_levelMidLowFib5, 0, 'PDML FIB -78.6%', color.green)
// previous days rth levels
plot(session.ismarket ? v_prevDayHigh : na, title='PDH', color=color.red, linewidth=2, style=plot.style_cross)
plot(session.ismarket ? v_prevDayMid : na, title='PDM', color=color.gray, linewidth=2, style=plot.style_cross)
plot(session.ismarket ? v_prevDayLow : na, title='PDL', color=color.green, linewidth=2, style=plot.style_cross)
// previous days eth levels
plot(session.ismarket or session.ispremarket ? v_ethStockSessHigh : na, title='EH', color=color.new(color.purple, 50), style=plot.style_circles)
plot(session.ismarket or session.ispremarket ? v_ethStockSessLow : na, title='EL', color=color.new(color.yellow, 50), style=plot.style_circles)
// percentage levels from previous days high/low range
plot(f_RenderPercentageHigh(v_prevDayHigh) ? v_levelHighPer5 : na, title='PDH 250%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageHigh(v_prevDayHigh) ? v_levelHighPer4 : na, title='PDH 200%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageHigh(v_prevDayHigh) ? v_levelHighPer3 : na, title='PDH 150%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageHigh(v_prevDayHigh) ? v_levelHighPer2 : na, title='PDH 100%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageHigh(v_prevDayHigh) ? v_levelHighPer1 : na, title='PDH 50%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageLow(v_prevDayLow) ? v_levelLowPer1 : na, title='PDL -50%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageLow(v_prevDayLow) ? v_levelLowPer2 : na, title='PDL -100%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageLow(v_prevDayLow) ? v_levelLowPer3 : na, title='PDL -150%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageLow(v_prevDayLow) ? v_levelLowPer4 : na, title='PDL -200%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderPercentageLow(v_prevDayLow) ? v_levelLowPer5 : na, title='PDL -250%', color=color.green, linewidth=1, style=plot.style_cross)
// fib levels from previous days high/low range
plot(f_RenderFibHigh(v_prevDayHigh) ? v_levelHighFib5 : na, title='PDH FIB 78.6%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderFibHigh(v_prevDayHigh) ? v_levelHighFib4 : na, title='PDH FIB 61.8%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderFibHigh(v_prevDayHigh) ? v_levelHighFib3 : na, title='PDH FIB 50%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderFibHigh(v_prevDayHigh) ? v_levelHighFib2 : na, title='PDH FIB 38.2%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderFibHigh(v_prevDayHigh) ? v_levelHighFib1 : na, title='PDH FIB 23.6%', color=color.red, linewidth=1, style=plot.style_cross)
plot(f_RenderFibLow(v_prevDayLow) ? v_levelLowFib1 : na, title='PDL FIB -23.6%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderFibLow(v_prevDayLow) ? v_levelLowFib2 : na, title='PDL FIB -38.2%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderFibLow(v_prevDayLow) ? v_levelLowFib3 : na, title='PDL FIB -50%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderFibLow(v_prevDayLow) ? v_levelLowFib4 : na, title='PDL FIB -61.8%', color=color.green, linewidth=1, style=plot.style_cross)
plot(f_RenderFibLow(v_prevDayLow) ? v_levelLowFib5 : na, title='PDL FIB -78.6%', color=color.green, linewidth=1, style=plot.style_cross)
// percentage levels from previous days high/low mid range
plot(i_showRangeLevels == "percentage" and session.ismarket ? v_levelMidHighPer3 : na, title='PDMH 75%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "percentage" and session.ismarket ? v_levelMidHighPer2 : na, title='PDMH 50%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "percentage" and session.ismarket ? v_levelMidHighPer1 : na, title='PDMH 25%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "percentage" and session.ismarket ? v_levelMidLowPer1 : na, title='PDML -25%', color=color.green, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "percentage" and session.ismarket ? v_levelMidLowPer2 : na, title='PDML -50%', color=color.green, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "percentage" and session.ismarket ? v_levelMidLowPer3 : na, title='PDML -75%', color=color.green, linewidth=1, style=plot.style_cross)
// fib levels from previous days high/low mid range
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidHighFib5 : na, title='PDMH FIB 78.6%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidHighFib4 : na, title='PDMH FIB 61.8%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidHighFib3 : na, title='PDMH FIB 50%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidHighFib2 : na, title='PDMH FIB 38.2%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidHighFib1 : na, title='PDMH FIB 23.6%', color=color.red, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidLowFib1 : na, title='PDML FIB -23.6%', color=color.green, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidLowFib2 : na, title='PDML FIB -38.2%', color=color.green, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidLowFib3 : na, title='PDML FIB -50%', color=color.green, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidLowFib4 : na, title='PDML FIB -61.8%', color=color.green, linewidth=1, style=plot.style_cross)
plot(i_showRangeLevels == "fib" and session.ismarket ? v_levelMidLowFib5 : na, title='PDML FIB -78.6%', color=color.green, linewidth=1, style=plot.style_cross)
// </plots>
// <alerts>
// tbd
// </alerts> |
T3 PPO [Loxx] | https://www.tradingview.com/script/dAGbtZ6z-T3-PPO-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 158 | 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(title = 'T3 PPO [Loxx]',
shorttitle = "T3PPO [Loxx]",
timeframe="",
overlay = false,
timeframe_gaps=true,
max_bars_back = 5000)
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
lightgreencolor = #96E881
lightredcolor = #DF4F6C
_iT3(src, per, hot, clean)=>
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 + (per - 1.0) / 2.0)
else
alpha := 2.0 / (1.0 + per)
_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
src = input.source(title='Source', defval=hl2, group = "Basic Settings")
lookBack = input.int(200, "Period", group = "Basic Settings")
FastT3 = input.int(20, "Fast T3", group = "T3 Settings")
SlowT3 = input.int(50, "Slow T3", group = "T3 Settings")
HotT3 = input.float(.5, "T3 Hot", group = "T3 Settings")
t3swt = input.string("T3 New", "T3 Type", options = ["T3 New", "T3 Original"], group = "T3 Settings")
percent1 = input.float(80, "Percent 1", group = "Levels Settings")
percent2 = input.float(90, "Percent 2", group = "Levels Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
lmas = _iT3(src, FastT3, HotT3, t3swt)
lmal = _iT3(src, SlowT3, HotT3, t3swt)
topvalueMinus = 0
topvaluePlus = 0
bottomvalueMinus = 0
bottomvaluePlus = 0
ppoT = (lmas - lmal) / lmal * 100.0
ppoB = (lmal - lmas) / lmal * 100.0
pctRankT = 0.0
pctRankB = 0.0
stateu = 0
stated = 0
for k = 1 to lookBack by 1
if (ppoT[k] < ppoT)
topvalueMinus := topvalueMinus + 1
else
topvaluePlus := topvaluePlus + 1
if (ppoB[k] < ppoB)
bottomvalueMinus := bottomvalueMinus + 1
else
bottomvaluePlus := bottomvaluePlus + 1
if (topvalueMinus + topvaluePlus != 0)
pctRankT := topvalueMinus / (topvalueMinus + topvaluePlus)
if (bottomvalueMinus + bottomvaluePlus != 0)
pctRankB := (bottomvalueMinus / (bottomvalueMinus + bottomvaluePlus)) * -1
if (pctRankT > math.max(percent1, percent2) / 100)
stateu := 2
if (pctRankT> math.min(percent1, percent2) / 100 and stateu == 0)
stateu := 1
if (pctRankB < -math.max(percent1, percent2) / 100)
stated :=-2
if (pctRankB < -math.min(percent1, percent2) / 100 and stated == 0)
stated :=-1
colorout =
stateu == 1 ? lightredcolor :
stateu == 2 ? redcolor :
stated == -1 ? lightgreencolor :
stated == -2 ? greencolor :
color.gray
plot(pctRankB, "8", color = colorout, style = plot.style_columns)
plot(pctRankT, "7", color = colorout, style = plot.style_columns)
barcolor(colorbars ? colorout : na)
plot(percent1/100, color=color.new(redcolor, 30), linewidth=1, style=plot.style_circles, title = "Overbought level 2")
plot(percent2/100, color=color.new(redcolor, 30), linewidth=1, style=plot.style_circles, title = "Overbought level 1")
plot(-percent1/100, color=color.new(greencolor, 30), linewidth=1, style=plot.style_circles, title = "Oversold level 1")
plot(-percent2/100, color=color.new(greencolor, 30), linewidth=1, style=plot.style_circles, title = "Oversold level 2") |
Zero-line Volatility Quality Index (VQI) [Loxx] | https://www.tradingview.com/script/EK0tbp6M-Zero-line-Volatility-Quality-Index-VQI-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 160 | 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-line Volatility Quality Index (VQI) [Loxx]',
shorttitle = "ZLVQI [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
variant(type, src, len) =>
sig = 0.0
if type == "SMA"
sig := ta.sma(src, len)
else if type == "EMA"
sig := ta.ema(src, len)
else if type == "WMA"
sig := ta.wma(src, len)
else if type == "RMA"
sig := ta.rma(src, len)
sig
inpPriceSmoothing = input.int(10, "Source Smoothing Period", group = "Basic Settings")
inpFilter = input.float(7.5, "ATR Percentage %", group = "Basic Settings")/100
type = input.string("WMA", "Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group = "UI Options")
chigh = variant(type, high, inpPriceSmoothing)
clow = variant(type, low, inpPriceSmoothing)
cclose = variant(type, close, inpPriceSmoothing)
copen = variant(type, open, inpPriceSmoothing)
pclose = variant(type, nz(close[1]), inpPriceSmoothing)
trueRange = (chigh > pclose ? chigh : pclose) - (clow < pclose ? clow : pclose)
rng = chigh - clow
vqi = 0.
vqi := (rng > 0 and trueRange > 0) ? ((cclose - pclose) / trueRange + (cclose - copen) / rng) * 0.5 : (bar_index > 0) ? nz(vqi[1]) : 0
vqi := (bar_index > 0) ? (vqi > 0 ? vqi : -vqi) * (cclose - pclose + cclose - copen) * 0.5 : 0
val = vqi
atr = ta.atr(inpPriceSmoothing)
if inpFilter > 0 and bar_index > 0
if (val > nz(val[1]) ? val - nz(val[1]) : nz(val[1]) - val) < inpFilter * atr
val := nz(val[1])
valc = 0
valc := (val > 0) ? 1 : (val < 0) ? 2 : (bar_index > 0) ? nz(valc[1]) : 0
colorout = valc == 1 ? greencolor : valc == 2 ? redcolor : color.gray
mid = 0.
plot(vqi, "VQI", color = colorout, linewidth = 2)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(val, mid)
goShort = ta.crossunder(val, mid)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="QQE of Parabolic-Weighted Velocity [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="QQE of Parabolic-Weighted Velocity [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Ehlers Two-Pole Predictor [Loxx] | https://www.tradingview.com/script/47QOOYXH-Ehlers-Two-Pole-Predictor-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 112 | 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
// "Two Pole Predictor" (C) 1978-2021 John F. Ehlers
//@version=5
indicator("Ehlers Two-Pole Predictor [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
//+------------------------------------------------------------------+
//| Extrenal library exports
//+------------------------------------------------------------------+
import loxx/loxxexpandedsourcetypes/4
//+------------------------------------------------------------------+
//| Declare constants
//+------------------------------------------------------------------+
SM02 = 'Predict/Filter Crosses'
SM03 = 'Predict Middle Crosses'
SM04 = 'Filter Middle Crosses'
redcolor = #D2042D
greencolor = #2DD204
//+------------------------------------------------------------------+
//| Fucntions
//+------------------------------------------------------------------+
highpass(float src, int period) => // High-Pass Filter
float a1 = math.exp(-1.414 * math.pi / period)
float b1 = 2 * a1 * math.cos(1.414 * math.pi / period)
float c2 = b1
float c3 = -a1 * a1
float c1 = (1 + c2 - c3) / 4
float hp = 0.0
hp := bar_index < 4 ? 0 : c1 * (src - 2 * nz(src[1]) + nz(src[2])) + (c2 * nz(hp[1])) + (c3 * nz(hp[2]))
hp
hann(float src, int period) => // Hann Low-Pass FIR Filter
var PIx2 = 2.0 * math.pi / (period + 1)
float sum4Hann = 0.0, sumCoefs = 0.0
for count = 1 to period
float coef = 1.0 - math.cos(count * PIx2)
sum4Hann += coef * src[count - 1]
sumCoefs += coef
float filt = nz(sum4Hann / sumCoefs)
filt
//+------------------------------------------------------------------+
//| Inputs
//+------------------------------------------------------------------+
srctype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", 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)"])
HPLength = input.int(125, "High-Pass Filter Period", group = "Preliminary Filtering Settings")
LPLength = input.int(12, "Low-Pass Hann Filter Period", group = "Preliminary Filtering Settings")
QQ = input.float(0.5, "Two-Pole IIR Radius", group = "Two-Pole IIR Settings")
P2Period = input.int(11, "Two-Pole IIR Period", group = "Two-Pole IIR Settings")
BarsFwd = input.int(5, "Bars Forward", group = "Output Shaping Settings")
sigtype = input.string(SM02, "Signal Type", options = [SM02, SM03, SM04], group = "Signal Settings")
predictcol = input.color(color.yellow, "Prediction Color", group = "UI Settings")
filtcol = input.color(redcolor, "Filter Color", group = "UI Settings")
upcol = input.color(greencolor, "Uptrend Color", group = "UI Settings")
dncol = input.color(redcolor, "Downtrend Color", group = "UI Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group = "UI Options")
//+------------------------------------------------------------------+
//| Prepare source data
//+------------------------------------------------------------------+
//Inputs for Loxx's Expanded Source Types
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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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(srctype, amafl, amasl, kfl, ksl)
"HAB Open" => loxxexpandedsourcetypes.habopen(srctype, amafl, amasl, kfl, ksl)
"HAB High" => loxxexpandedsourcetypes.habhigh(srctype, amafl, amasl, kfl, ksl)
"HAB Low" => loxxexpandedsourcetypes.hablow(srctype, amafl, amasl, kfl, ksl)
"HAB Median" => loxxexpandedsourcetypes.habmedian(srctype, amafl, amasl, kfl, ksl)
"HAB Typical" => loxxexpandedsourcetypes.habtypical(srctype, amafl, amasl, kfl, ksl)
"HAB Weighted" => loxxexpandedsourcetypes.habweighted(srctype, amafl, amasl, kfl, ksl)
"HAB Average" => loxxexpandedsourcetypes.habaverage(srctype, amafl, amasl, kfl, ksl)
"HAB Average Median Body" => loxxexpandedsourcetypes.habavemedbody(srctype, amafl, amasl, kfl, ksl)
"HAB Trend Biased" => loxxexpandedsourcetypes.habtrendb(srctype, amafl, amasl, kfl, ksl)
"HAB Trend Biased (Extreme)" => loxxexpandedsourcetypes.habtrendbext(srctype, amafl, amasl, kfl, ksl)
=> haclose
//+------------------------------------------------------------------+
//| Private Varible declarations
//+------------------------------------------------------------------+
float HP = 0.
float SumSq = 0.
float Filt = 0.
float coef = 0.
int Length = 10
float Predict = 0.
P2coef= array.new<float>(4, 0.) // Two-pole coefficients array
XX = array.new<float>(21, 0.)
//+------------------------------------------------------------------+
//| Calculations
//+------------------------------------------------------------------+
//High-Pass Filter
HP := highpass(src, HPLength)
//Hann Low-Pass Filter
Filt := hann(HP, LPLength)
//Convert the Filt variable to a data array
for count = 1 to Length
array.set(XX, count, nz(Filt[Length - count]))
//+------------------------------------------------------------------+
//| Calculate Two-Pole IIR coefficients
//+------------------------------------------------------------------+
array.set(P2coef, 1, 1)
array.set(P2coef, 2, -2 * QQ * math.cos(2 * math.pi / P2Period))
array.set(P2coef, 3, math.pow(QQ, 2))
coefsum = array.get(P2coef, 1) + array.get(P2coef, 2) + array.get(P2coef, 3)
array.set(P2coef, 1, array.get(P2coef, 1) / coefsum)
array.set(P2coef, 2, array.get(P2coef, 2) / coefsum)
array.set(P2coef, 3, array.get(P2coef, 3) / coefsum)
//+------------------------------------------------------------------+
//| Convolve 2-Pole filter with data to form prediction array
//+------------------------------------------------------------------+
for count = 0 to 9
array.set(XX, Length + count + 1, 0)
for coefcount = 1 to 3
array.set(
XX,
Length + count + 1,
array.get(XX, Length + count + 1) +
array.get(P2coef, coefcount) *
array.get(XX, Length + count + 1 - coefcount)
)
Predict := array.get(XX, Length + BarsFwd)
//Convert desired forward look in the array to the variable Predict
Predict := array.get(XX, Length + BarsFwd)
//+------------------------------------------------------------------+
//| Plot output
//+------------------------------------------------------------------+
mid = 0.
plot(Filt, "Filter", color = filtcol, linewidth = 2)
plot(mid, "Zero line", color = bar_index % 2 ? color.silver : na)
plot(Predict, "Prediction", color = predictcol, linewidth = 1)
state = 0.
if sigtype == SM02
if (Predict < Filt)
state :=-1
if (Predict > Filt)
state := 1
else if sigtype == SM03
if (Predict < mid)
state :=-1
if (Predict > mid)
state := 1
else if sigtype == SM04
if (Filt < mid)
state :=-1
if (Filt > mid)
state := 1
colorout = state == 1 ? upcol : state == -1 ? dncol : color.gray
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(Predict, Filt) : sigtype == SM03 ? ta.crossover(Predict, mid) : ta.crossover(Filt, mid)
goShort = sigtype == SM02 ? ta.crossunder(Predict, Filt) : sigtype == SM03 ? ta.crossunder(Predict, mid) : ta.crossunder(Filt, mid)
plotshape(showSigs and goLong, title = "Long", color = upcol, textcolor = upcol, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = dncol, textcolor = dncol, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Ehlers Two-Pole Predictor [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Ehlers Two-Pole Predictor [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Pivot Parallel Channel by [livetrend] | https://www.tradingview.com/script/EdVgezSC-Pivot-Parallel-Channel-by-livetrend/ | livetrend | https://www.tradingview.com/u/livetrend/ | 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/
// © livetrend
//@version=5
var MAX_BARS_BACK = 5000
indicator(title='Pivot Parallel Channel by [livetrend]', shorttitle='PPC', overlay=true, max_bars_back=MAX_BARS_BACK, max_labels_count=500,max_lines_count=500,format=format.price,precision=2)
hiddenChannel = input(false,group='Channel',inline='line')
lineWidth = input.int(1,minval=1,title="Width",group='Channel',inline='option')
threshold = input.float(5,title="Threshold(%)",minval=0,tooltip="Channel breakout threshold by percent",group='Channel',inline='option')/100
lineStyle = extend.right
res_line_col = hiddenChannel?na:input.color(color.new(#ff1100, 0), 'Down Trend Line',group='Style', inline='line')
sup_line_col = hiddenChannel?na:input.color(color.new(#0cb51a, 0), 'Up Trend Line',group='Style', inline='line')
res_col = hiddenChannel?na:input.color(color.new(#ff1100, 90), 'Down Trend',group='Style', inline='area')
sup_col = hiddenChannel?na:input.color(color.new(#0cb51a, 90), 'Up Trend',group='Style', inline='area')
baseMtf = input.int(2,title='Multiplier I',minval=1,tooltip="Pivot Length Multiplier")
baseMtf_htf = input.int(4,title='Multiplier II',minval=2,tooltip="Pivot Length Multiplier for Higher Time Frame")
if baseMtf_htf<baseMtf
runtime.error("Multiplier II must be greater or equal than Multiplier I")
source = input.source(close, title='Source')
hl = input.string("High-Low", options=["High-Low","Source"])
gr="Left - Right Length"
leftLenH = input.int(title="Pivot High", defval=1, minval=1, inline="Pivot High",group=gr)
rightLenH = input.int(title="/", defval=1, minval=1, inline="Pivot High",group=gr)
leftLenL = input.int(title="Pivot Low", defval=1, minval=1, inline="Pivot Low", group=gr)
rightLenL = input.int(title="/", defval=1, minval=1, inline="Pivot Low",group=gr)
_high = hl=="High-Low"?high:source
_low = hl=="High-Low"?low:source
ph = ta.pivothigh(_high,leftLenH*baseMtf, rightLenH*baseMtf)
pl = ta.pivotlow(_low,leftLenL*baseMtf, rightLenL*baseMtf)
ph_htf = ta.pivothigh(_high,leftLenH*baseMtf_htf, rightLenH*baseMtf_htf)
pl_htf = ta.pivotlow(_low,leftLenL*baseMtf_htf, rightLenL*baseMtf_htf)
var float sup = na
var float res = na
var float prev_sup = na
var float prev_res = na
var int prev_res_index = 0
var int prev_sup_index = 0
var float sup_htf = na
var float res_htf = na
var float prev_sup_htf = na
var float prev_res_htf = na
var int prev_res_index_htf = 0
var int prev_sup_index_htf = 0
var line resline = na
var line supline = na
var line par_supline = na
var line par_resline = na
var line resline_htf = na
var line supline_htf = na
var line par_supline_htf = na
var line par_resline_htf = na
get_slope(xA, yA, xB, yB) =>
(yB - yA) / math.max((xB - xA),1)
get_line_slope(l) =>
x1 = line.get_x1(l)
x2 = line.get_x2(l)
y1 = line.get_y1(l)
y2 = line.get_y2(l)
get_slope(x1,y1,x2,y2)
var trend1 = 0
var trend2 = 0
var trend3 = 0
var trend4 = 0
var float pru = na
var float prl = na
var float psu = na
var float psl = na
var float pru_htf = na
var float prl_htf = na
var float psu_htf = na
var float psl_htf = na
var trend1_index = 0
var trend2_index = 0
var trend3_index = 0
var trend4_index = 0
if not na(ph_htf)
prev_res_htf:=res_htf
res_htf:=ph_htf
if nz(res_htf[1])!=res_htf
prev_res_index_htf := bar_index[rightLenH*baseMtf_htf]
if not (source<pru_htf and source>prl_htf)
a = math.min(prev_res_index_htf[1],prev_sup_index_htf)
resline_htf := line.new(prev_res_index_htf[1], res_htf[1]*(1+threshold), bar_index[rightLenH*baseMtf_htf], res_htf*(1+threshold), xloc=xloc.bar_index, color=res_line_col, extend=lineStyle, style=line.style_solid, width=2*lineWidth)
line.delete(resline_htf[1])
m = get_line_slope(resline_htf)
trend1:=m>0?1:-1
par_resline_htf := line.new(prev_sup_index_htf, sup_htf*(1-threshold), prev_sup_index_htf+1, get_line_slope(resline_htf) + sup_htf*(1-threshold), xloc=xloc.bar_index, color=res_line_col, extend=lineStyle, style=line.style_solid, width=2*lineWidth)
line.delete(par_resline_htf[1])
trend1_index:=prev_res_index_htf[1]
line.set_x1(resline_htf,a)
line.set_y1(resline_htf,res_htf[1]*(1+threshold)-m*(prev_res_index_htf[1]-a))
line.set_x1(par_resline_htf,a)
line.set_y1(par_resline_htf,sup_htf*(1-threshold)-m*(prev_sup_index_htf-a))
linefill.new(resline_htf,par_resline_htf,m>0?sup_col:res_col)
line.set_color(resline_htf, m>0?sup_line_col:res_line_col)
line.set_color(par_resline_htf, m>0?sup_line_col:res_line_col)
pru_htf := line.get_price(resline_htf,bar_index)
prl_htf := line.get_price(par_resline_htf,bar_index)
if not (source<pru_htf and source>prl_htf)
trend1:=0
line.delete(resline_htf)
line.delete(par_resline_htf)
if not na(pl_htf)
prev_sup_htf:=sup_htf
sup_htf:=pl_htf
if nz(sup_htf[1])!=sup_htf
prev_sup_index_htf := bar_index[rightLenL*baseMtf_htf]
if not (source<psu_htf and source>psl_htf)
a = math.min(prev_sup_index_htf[1],prev_res_index_htf)
supline_htf := line.new(prev_sup_index_htf[1], sup_htf[1]*(1-threshold), bar_index[rightLenL*baseMtf_htf], sup_htf*(1-threshold), xloc=xloc.bar_index, color=sup_line_col, extend=lineStyle, style=line.style_solid, width=2*lineWidth)
line.delete(supline_htf[1])
m = get_line_slope(supline_htf)
trend2:=m>0?1:-1
par_supline_htf := line.new(prev_res_index_htf, res_htf*(1+threshold), prev_res_index_htf+1, get_line_slope(supline_htf) + res_htf*(1+threshold), xloc=xloc.bar_index, color=sup_line_col, extend=lineStyle, style=line.style_solid, width=2*lineWidth)
line.delete(par_supline_htf[1])
trend2_index:=prev_sup_index_htf[1]
line.set_x1(supline_htf,a)
line.set_y1(supline_htf,sup_htf[1]*(1-threshold)-m*(prev_sup_index_htf[1]-a))
line.set_x1(par_supline_htf,a)
line.set_y1(par_supline_htf,res_htf*(1+threshold)-m*(prev_res_index_htf-a))
linefill.new(supline_htf,par_supline_htf,m>0?sup_col:res_col)
line.set_color(supline_htf, m>0?sup_line_col:res_line_col)
line.set_color(par_supline_htf, m>0?sup_line_col:res_line_col)
psu_htf := line.get_price(par_supline_htf,bar_index)
psl_htf := line.get_price(supline_htf,bar_index)
if not (source<psu_htf and source>psl_htf)
trend2:=0
line.delete(supline_htf)
line.delete(par_supline_htf)
if not na(ph)
prev_res:=res
res:=ph
if nz(res[1])!=res
prev_res_index := bar_index[rightLenH*baseMtf]
if not (source<pru and source>prl)
a = math.min(prev_res_index[1],prev_sup_index)
resline := line.new(prev_res_index[1], res[1]*(1+threshold), bar_index[rightLenH*baseMtf], res*(1+threshold), xloc=xloc.bar_index, color=res_line_col, extend=lineStyle, style=line.style_solid, width=lineWidth)
line.delete(resline[1])
m = get_line_slope(resline)
par_resline := line.new(prev_sup_index, sup*(1-threshold), prev_sup_index+1, get_line_slope(resline) + sup*(1-threshold), xloc=xloc.bar_index, color=res_line_col, extend=lineStyle, style=line.style_solid, width=lineWidth)
line.delete(par_resline[1])
trend3_index:=prev_res_index[1]
trend3:=m>0?1:-1
line.set_x1(resline,a)
line.set_y1(resline,res[1]*(1+threshold)-m*(prev_res_index[1]-a))
line.set_x1(par_resline,a)
line.set_y1(par_resline,sup*(1-threshold)-m*(prev_sup_index-a))
linefill.new(resline,par_resline,m>0?sup_col:res_col)
line.set_color(resline, m>0?sup_line_col:res_line_col)
line.set_color(par_resline, m>0?sup_line_col:res_line_col)
pru := line.get_price(resline,bar_index)
prl := line.get_price(par_resline,bar_index)
if not (source<pru and source>prl)
trend3:=0
line.delete(resline)
line.delete(par_resline)
if not na(pl)
prev_sup:=sup
sup:=pl
if nz(sup[1])!=sup
prev_sup_index := bar_index[rightLenL*baseMtf]
if not (source<psu and source>psl)
a = math.min(prev_sup_index[1],prev_res_index)
supline := line.new(prev_sup_index[1], sup[1]*(1-threshold), bar_index[rightLenL*baseMtf], sup*(1-threshold), xloc=xloc.bar_index, color=sup_line_col, extend=lineStyle, style=line.style_solid, width=lineWidth)
line.delete(supline[1])
m = get_line_slope(supline)
par_supline := line.new(prev_res_index, res*(1+threshold), prev_res_index+1, get_line_slope(supline) + res*(1+threshold), xloc=xloc.bar_index, color=sup_line_col, extend=lineStyle, style=line.style_solid, width=lineWidth)
line.delete(par_supline[1])
trend4_index:=prev_sup_index[1]
trend4:=m>0?1:-1
line.set_x1(supline,a)
line.set_y1(supline,sup[1]*(1-threshold)-m*(prev_sup_index[1]-a))
line.set_x1(par_supline,a)
line.set_y1(par_supline,res*(1+threshold)-m*(prev_res_index-a))
linefill.new(supline,par_supline,m>0?sup_col:res_col)
line.set_color(supline, m>0?sup_line_col:res_line_col)
line.set_color(par_supline, m>0?sup_line_col:res_line_col)
psu := line.get_price(par_supline,bar_index)
psl := line.get_price(supline,bar_index)
if not (source<psu and source>psl)
trend4:=0
line.delete(supline)
line.delete(par_supline)
var trend = 0
l1=trend1!=0?bar_index-trend1_index:0
l2=trend2!=0?bar_index-trend2_index:0
l3=trend3!=0?bar_index-trend3_index:0
l4=trend4!=0?bar_index-trend4_index:0
lx = math.max(l1,l2,l3,l4)
if lx!=0
if l1 == lx
trend:=trend1
if l2 == lx
trend:=trend2
if l3 == lx
trend:=trend3
if l4 == lx
trend:=trend4
up = trend!=nz(trend[1]) and trend>0
down = trend!=nz(trend[1]) and trend<0
plotshape(up,style=shape.triangleup,location=location.belowbar,color=color.green,size=size.small)
plotshape(down,style=shape.triangledown,location=location.abovebar,color=color.red,size=size.small)
alertcondition(up,title="Buy Alert!",message="It can be long condition :)")
alertcondition(down,title="Sell Alert!",message="It can be short condition :)")
//bgcolor(trend>0?color.green:trend<0?color.red:na, transp=90) |
T3 Volatility Quality Index (VQI) w/ DSL & Pips Filtering [Loxx] | https://www.tradingview.com/script/56Q61Aff-T3-Volatility-Quality-Index-VQI-w-DSL-Pips-Filtering-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 264 | 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("T3 Volatility Quality Index (VQI) w/ DSL & Pips Filtering [Loxx]",
shorttitle="T3VQIDSLPF [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
_iT3(src, per, hot, clean)=>
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 + (per - 1.0) / 2.0)
else
alpha := 2.0 / (1.0 + per)
_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
_declen()=>
mtckstr = str.tostring(syminfo.mintick)
da = str.split(mtckstr, ".")
temp = array.size(da)
dlen = 0.
if syminfo.mintick < 1
dstr = array.get(da, 1)
dlen := str.length(dstr)
dlen
variant(type, src, len) =>
sig = 0.0
trig = 0.0
special = false
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
trig
PriceSmoothing = input.int(5, "Source Smoothing Period", group= "Basic Settings")
t3hot = input.float(.5, "T3 Hot", group= "Basic Settings")
t3swt = input.string("T3 New", "T3 Type", options = ["T3 New", "T3 Original"], group = "Basic Settings")
FilterInPips = input.float(1.9, "Filter in Pips", group= "Basic Settings")
sigmatype = input.string("Exponential Moving Average - EMA", "Signal/DSL Smoothing", options = ["Exponential Moving Average - EMA", "Fast Exponential Moving Average - FEMA"], group = "Signal/DSL Settings")
Ma1Period = input.int(9, "DSL Period", group= "Signal/DSL Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group = "UI Options")
pipMultiplier = math.pow(10, _declen() % 2)
cHigh = _iT3(high, PriceSmoothing, t3hot, t3swt)
cLow = _iT3(low, PriceSmoothing, t3hot, t3swt)
cOpen = _iT3(open, PriceSmoothing, t3hot, t3swt)
cClose = _iT3(close, PriceSmoothing, t3hot, t3swt)
pClose = _iT3(nz(close[1]), PriceSmoothing, t3hot, t3swt)
val = 0., valc = 0.
truerng = math.max(cHigh, pClose) - math.min(cLow, pClose)
rng = cHigh - cLow
vqi = (rng != 0 and truerng != 0) ? ((cClose - pClose) / truerng + (cClose - cOpen) / rng) * 0.5 : val[1]
val := nz(val[1]) + math.abs(vqi) * (cClose - pClose + cClose - cOpen) * 0.5
if (FilterInPips > 0)
if (math.abs(val - val[1]) < FilterInPips * pipMultiplier * syminfo.mintick)
val := nz(val[1])
sig = nz(val[1])
temp = variant(sigmatype, val, Ma1Period)
levelu = 0., leveld = 0., mid = 0.
levelu := (val > sig) ? temp : nz(levelu[1])
leveld := (val < sig) ? temp : nz(leveld[1])
colorout = val > levelu ? greencolor : val < leveld ? redcolor : color.gray
plot(val, "VQI", color = colorout, linewidth = 3)
plot(levelu, "Level Up", color = darkGreenColor)
plot(leveld, "Level Down", color = darkRedColor)
goLong = ta.crossover(val, levelu)
goShort = ta.crossunder(val, leveld)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "High Volatility", message = "T3 Volatility Quality Index (VQI) w/ DSL & Pips Filtering [Loxx]: Uptrend\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Low Volatility", message = "T3 Volatility Quality Index (VQI) w/ DSL & Pips Filtering [Loxx]: Downtrend\nSymbol: {{ticker}}\nPrice: {{close}}")
barcolor(colorbars ? colorout : na)
|
smoothed_rsi | https://www.tradingview.com/script/eK62pN3J-smoothed-rsi/ | palitoj_endthen | https://www.tradingview.com/u/palitoj_endthen/ | 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/
// © palitoj_endthen
//@version=5
indicator(title = 'smoothed_rsi', shorttitle = 'rsi', overlay = false)
// input
length = input.int(defval = 14, title = 'Length', group = 'Value', tooltip = 'Determines length of RSI lookback period')
left = input.int(defval = 30, title = 'Pivot Left', group = 'Value', tooltip = 'Determines length of left pivot')
right = input.int(defval = 20, title = 'Pivot Right', group = 'Value', tooltip = 'Determines length of right pivot')
src = input.source(defval = ohlc4, title = 'Source', group = 'Options', tooltip = 'Determines input source')
trendline = input.bool(defval = true, title = 'Trendline', group = 'Options', tooltip = 'Determines whether to display rsi trendline')
// variable
a1 = 0.0
b1 = 0.0
c1 = 0.0
c2 = 0.0
c3 = 0.0
smoothed_rsi = 0.0
pivot_high = 0.0
pivot_low = 0.0
// relative strength index (rsi)
rsi = ta.rsi(src, length)
// smoothed with super smoother
pi = 2 * math.asin(1)
a1 := math.exp( -1.414*pi/10)
b1 := 2 * a1 * math.cos( 1.414*2*pi/10)
c2 := b1
c3 := -a1 * a1
c1 := 1 - c2 - c3
smoothed_rsi := c1*(rsi+rsi[1])/2+c2*nz(smoothed_rsi[1])+c3*nz(smoothed_rsi[2])
// Visualize
plot(smoothed_rsi, color = color.blue, linewidth = 2)
hline(70, color = color.new(color.blue, 50))
hline(30, color = color.new(color.blue, 50))
// rsi trendline
pivot_high := ta.pivothigh(smoothed_rsi, left, right)
pivot_low := ta.pivotlow(smoothed_rsi, left, right)
for int i = 0 to 1
// array to store x, y value, and line
var x1 = array.new_int(length)
var x2 = array.new_int(length)
var y1 = array.new_float(length)
var y2 = array.new_float(length)
var xl1 = array.new_int(length)
var xl2 = array.new_int(length)
var yl1 = array.new_float(length)
var yl2 = array.new_float(length)
var line_ = array.new_line(length)
// downtrend
array.set(x1, i, ta.valuewhen(pivot_high, bar_index, 1)-right)
array.set(x2, i, ta.valuewhen(pivot_high, bar_index, 0)-left)
array.set(y1, i, ta.valuewhen(pivot_high, pivot_high, 1))
array.set(y2, i, ta.valuewhen(pivot_high, pivot_high, 0))
// uptrend
array.set(xl1, i, ta.valuewhen(pivot_low, bar_index, 1)-right)
array.set(xl2, i, ta.valuewhen(pivot_low, bar_index, 0)-left)
array.set(yl1, i, ta.valuewhen(pivot_low, pivot_low, 1))
array.set(yl2, i, ta.valuewhen(pivot_low, pivot_low, 0))
// trendline
if nz(array.get(y2, i)) < nz(array.get(y1, i))
array.push(line_, line.new(nz(array.get(x1, i)), nz(array.get(y1, i)), nz(array.get(x2, i)), nz(array.get(y2, i)), color = trendline ? color.red : na))
if nz(array.get(yl2, i)) > nz(array.get(yl1, i))
array.push(line_, line.new( nz(array.get(xl1, i)), nz(array.get(yl1, i)), nz(array.get(xl2, i)), nz(array.get(yl2, i)), color = trendline ? color.green : na))
|
Multi T3 Slopes [Loxx] | https://www.tradingview.com/script/etSu8gDi-Multi-T3-Slopes-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("Multi T3 Slopes [Loxx]",
shorttitle="MT3S [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
_iT3(src, per, hot, clean)=>
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 + (per - 1.0) / 2.0)
else
alpha := 2.0 / (1.0 + per)
_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
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)"])
t3hot = input.float(.7, "T3 Hot", group= "Basic Settings")
t3swt = input.string("T3 New", "T3 Type", options = ["T3 New", "T3 Original"], group = "Basic Settings")
inpPeriod1 = input.int(8, "Period 1", group = "Basic Settings")
inpPeriod2 = input.int(11, "Period 1", group = "Basic Settings")
inpPeriod3 = input.int(14, "Period 1", group = "Basic Settings")
inpPeriod4 = input.int(17, "Period 1", group = "Basic Settings")
inpPeriod5 = input.int(20, "Period 1", group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showLongs = input.bool(true, "Show Longs?", group = "Signal Options")
showShorts = input.bool(true, "Show Shorts?", group = "Signal Options")
showCLongs = input.bool(true, "Show Continuation Longs?", group = "Signal Options")
showCShorts = input.bool(true, "Show Continuation Shorts?", group = "Signal 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
ma1 = _iT3(src, inpPeriod1, t3hot, t3swt)
ma2 = _iT3(src, inpPeriod2, t3hot, t3swt)
ma3 = _iT3(src, inpPeriod3, t3hot, t3swt)
ma4 = _iT3(src, inpPeriod4, t3hot, t3swt)
ma5 = _iT3(src, inpPeriod5, t3hot, t3swt)
histou = 0.
histod = 0.
if ma1 > nz(ma1[1])
histou += 1
if ma1 < nz(ma1[1])
histod -= 1
if ma2 > nz(ma2[1])
histou += 1
if ma2 < nz(ma2[1])
histod -= 1
if ma3 > nz(ma3[1])
histou += 1
if ma3 < nz(ma3[1])
histod -= 1
if ma4 > nz(ma4[1])
histou += 1
if ma4 < nz(ma4[1])
histod -= 1
if ma5 > nz(ma5[1])
histou += 1
if ma5 < nz(ma5[1])
histod -= 1
trend = histou > 0 and histod == 0 ? 1 : histod < 0 and histou == 0 ? -1 : 0
plot(histou, color = greencolor, linewidth = 2, style = plot.style_columns)
plot(histod, color = redcolor, linewidth = 2, style = plot.style_columns)
barcolor(colorbars ? trend == 1 ? greencolor : trend == -1 ? redcolor : color.gray : na)
contLSwitch = 0
contLSwitch := nz(contLSwitch[1])
contLSwitch := trend == 1 ? 1 : trend == -1 ? -1 : contLSwitch
goLong = trend == 1 and trend[1] != 1 and nz(contLSwitch[1]) == -1
goShort = trend == -1 and trend[1] != -1 and nz(contLSwitch[1]) == 1
goContL = trend == 1 and trend[1] != 1 and nz(contLSwitch[1]) == 1
goContS = trend == -1 and trend[1] != -1 and nz(contLSwitch[1]) == -1
plotshape(showLongs and goLong, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showShorts and goShort, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
plotshape(showCLongs and goContL, title = "Continuation Long", color = color.yellow, textcolor = color.yellow, text = "CL", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showCShorts and goContS, title = "Continuation Short", color = color.fuchsia, textcolor = color.fuchsia, text = "CS", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "Multi T3 Slopes [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "Multi T3 Slopes [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goContL, title = "Continuation Long", message = "Multi T3 Slopes [Loxx]: Continuation Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goContS, title = "Continuation Short", message = "Multi T3 Slopes [Loxx]: Continuation Short\nSymbol: {{ticker}}\nPrice: {{close}}")
hline(7, color = color.new(color.white, 100), editable = false)
hline(-7, color = color.new(color.white, 100), editable = false)
|
Cumulative Delta Volume RSI-8 Candles | https://www.tradingview.com/script/cvjDt9A2-Cumulative-Delta-Volume-RSI-8-Candles/ | JustMoTrades | https://www.tradingview.com/u/JustMoTrades/ | 220 | 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/
// © SammySam8977
//@version=4
study("Cumulative Delta Volume RSI", "CDV Mo RSI", overlay=true)
linestyle = input(defval = 'Candle', title = "Style", options = ['Candle', 'Line'])
hacandle = input(defval = true, title = "Heikin Ashi Candles?")
showma1 = input(defval = false, title = "SMA 1", inline = "ma1")
ma1len = input(defval = 50, title = "", minval = 1, inline = "ma1")
ma1col = input(defval = color.lime, title = "", inline = "ma1")
showma2 = input(defval = false, title = "SMA 2", inline = "ma2")
ma2len = input(defval = 200, title = "", minval = 1, inline = "ma2")
ma2col = input(defval = color.red, title = "", inline = "ma2")
showema1 = input(defval = false, title = "EMA 1", inline = "ema1")
ema1len = input(defval = 50, title = "", minval = 1, inline = "ema1")
ema1col = input(defval = color.lime, title = "", inline = "ema1")
showema2 = input(defval = false, title = "EMA 2", inline = "ema2")
ema2len = input(defval = 200, title = "", minval = 1, inline = "ema2")
ema2col = input(defval = color.red, title = "", inline = "ema2")
colorup = input(defval = color.lime, title = "Body", inline = "bcol")
colordown = input(defval = color.red, title = "", inline = "bcol")
bcolup = input(defval = #74e05e, title = "Border", inline = "bocol")
bcoldown = input(defval = #ffad7d, title = "", inline = "bocol")
wcolup = input(defval = #b5b5b8, title = "Wicks", inline = "wcol")
wcoldown = input(defval = #b5b5b8, title = "", inline = "wcol")
//ADDED FROM SSL HYBRID//
maType = input(title="SSL1 / Baseline Type", type=input.string, defval="HMA", options=["SMA","EMA","DEMA","TEMA","LSMA","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])
len = input(title="SSL1 / Baseline Length", defval=88)
SSL2Type = input(title="SSL2 / Continuation Type", type=input.string, defval="JMA", options=["SMA","EMA","DEMA","TEMA","WMA","MF","VAMA","TMA","HMA", "JMA","McGinley"])
len2 = input(title="SSL 2 Length", defval=5)
//
SSL3Type = input(title="EXIT Type", type=input.string, defval="HMA", options=["DEMA","TEMA","LSMA","VAMA","TMA","HMA","JMA", "Kijun v2", "McGinley", "MF"])
len3 = input(title="EXIT Length", defval=15)
src = input(title="Source", type=input.source, defval=close)
show_Baseline = input(title="Show Baseline", type=input.bool, defval=true)
show_SSL1 = input(title="Show SSL1", type=input.bool, defval=false)
show_atr = input(title="Show ATR bands", type=input.bool, defval=true)
//ATR
atrlen = input(14, "ATR Period")
mult = input(0.8, "ATR Multi", step=0.1)
smoothing = input(title="ATR Smoothing", defval="WMA", options=["RMA", "SMA", "EMA", "WMA"])
ma_function(source, atrlen) =>
if smoothing == "RMA"
rma(source, atrlen)
else
if smoothing == "SMA"
sma(source, atrlen)
else
if smoothing == "EMA"
ema(source, atrlen)
else
wma(source, atrlen)
atr_slen = ma_function(tr(true), atrlen)
////ATR Up/Low Bands
upper_band = atr_slen * mult + close
lower_band = close - atr_slen * mult
tema(src, len) =>
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
(3 * ema1) - (3 * ema2) + ema3
kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")
jurik_phase = input(title="* Jurik (JMA) Only - Phase", type=input.integer, defval=3)
jurik_power = input(title="* Jurik (JMA) Only - Power", type=input.integer, defval=1)
volatility_lookback = input(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")
//MF
beta = input(0.8,minval=0,maxval=1,step=0.1, title="Modular Filter, General Filter Only - Beta")
feedback = input(false, title="Modular Filter Only - Feedback")
z = input(0.5,title="Modular Filter Only - Feedback Weighting",step=0.1, minval=0, maxval=1)
//EDSMA
ssfLength = input(title="EDSMA - Super Smoother Filter Length", type=input.integer, minval=1, defval=20)
ssfPoles = input(title="EDSMA - Super Smoother Filter Poles", type=input.integer, defval=2, options=[2, 3])
//----
//EDSMA
get2PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = sqrt(2) * PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(arg)
c2 = b1
c3 = -pow(a1, 2)
c1 = 1 - c2 - c3
ssf = 0.0
ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])
get3PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(1.738 * arg)
c1 = pow(a1, 2)
coef2 = b1 + c1
coef3 = -(c1 + b1 * c1)
coef4 = pow(c1, 2)
coef1 = 1 - coef2 - coef3 - coef4
ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])
ma(type, src, len) =>
float result = 0
if type=="TMA"
result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1)
if type=="MF"
ts=0.,b=0.,c=0.,os=0.
//----
alpha = 2/(len+1)
a = feedback ? z*src + (1-z)*nz(ts[1],src) : src
//----
b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a)
c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a)
os := a == b ? 1 : a == c ? 0 : os[1]
//----
upper = beta*b+(1-beta)*c
lower = beta*c+(1-beta)*b
ts := os*upper+(1-os)*lower
result := ts
if type=="LSMA"
result := linreg(src, len, 0)
if type=="SMA" // Simple
result := sma(src, len)
if type=="EMA" // Exponential
result := ema(src, len)
if type=="DEMA" // Double Exponential
e = ema(src, len)
result := 2 * e - ema(e, len)
if type=="TEMA" // Triple Exponential
e = ema(src, len)
result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)
if type=="WMA" // Weighted
result := wma(src, len)
if type=="VAMA" // Volatility Adjusted
/// Copyright © 2019 to present, Joris Duyck (JD)
mid=ema(src,len)
dev=src-mid
vol_up=highest(dev,volatility_lookback)
vol_down=lowest(dev,volatility_lookback)
result := mid+avg(vol_up,vol_down)
if type=="HMA" // Hull
result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
if type=="JMA" // Jurik
/// Copyright © 2018 Alex Orekhov (everget)
/// Copyright © 2017 Jurik Research and Consulting.
phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
alpha = pow(beta, jurik_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])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
result := jma
if type=="Kijun v2"
kijun = avg(lowest(len), highest(len))//, (open + close)/2)
conversionLine = avg(lowest(len/kidiv), highest(len/kidiv))
delta = (kijun + conversionLine)/2
result :=delta
if type=="McGinley"
mg = 0.0
mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4))
result :=mg
if type=="EDSMA"
zeros = src - nz(src[2])
avgZeros = (zeros + zeros[1]) / 2
// Ehlers Super Smoother Filter
ssf = ssfPoles == 2
? get2PoleSSF(avgZeros, ssfLength)
: get3PoleSSF(avgZeros, ssfLength)
// Rescale filter in terms of Standard Deviations
stdev = stdev(ssf, len)
scaledFilter = stdev != 0
? ssf / stdev
: 0
alpha = 5 * abs(scaledFilter) / len
edsma = 0.0
edsma := alpha * src + (1 - alpha) * nz(edsma[1])
result := edsma
result
//ORIGINAL SCRIPT//
tw = high - max(open, close)
bw = min(open, close) - low
body = abs(close - open)
_rate(cond) =>
ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body)
ret := nz(ret) == 0 ? 0.5 : ret
ret
deltaup = volume * _rate(open <= close)
deltadown = volume * _rate(open > close)
delta = close >= open ? deltaup : -deltadown
cumdelta = cum(delta)
float ctl = na
float o = na
float h = na
float l = na
float c = na
if linestyle == 'Candle'
o := cumdelta[1]
h := max(cumdelta, cumdelta[1])
l := min(cumdelta, cumdelta[1])
c := cumdelta
ctl
else
ctl := cumdelta
plot(ctl, title = "CDV Line", color = color.blue, linewidth = 2)
float haclose = na
float haopen = na
float hahigh = na
float halow = na
haclose := (o + h + l + c) / 4
haopen := na(haopen[1]) ? (o + c) / 2 : (haopen[1] + haclose[1]) / 2
hahigh := max(h, max(haopen, haclose))
halow := min(l, min(haopen, haclose))
c_ = hacandle ? haclose : c
o_ = hacandle ? haopen : o
h_ = hacandle ? hahigh : h
l_ = hacandle ? halow : l
///SSL 1 and SSL2
emaHigh = ma(maType, high, len)
emaLow = ma(maType, low, len)
maHigh = ma(SSL2Type, high, len2)
maLow = ma(SSL2Type, low, len2)
///EXIT
ExitHigh = ma(SSL3Type, high, len3)
ExitLow = ma(SSL3Type, low, len3)
///Keltner Baseline Channel
BBMC = ma(maType, close, len)
useTrueRange = input(true)
multy = input(0.2, step=0.05, title="Base Channel Multiplier")
Keltma = ma(maType, src, len)
range = useTrueRange ? tr : high - low
rangema = ema(range, len)
upperk =Keltma + rangema * multy
lowerk = Keltma - rangema * multy
//COLORS
show_color_bar = input(title="Color Bars", type=input.bool, defval=true)
color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.new(color.gray,80)
//color_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na
//PLOTS
//plotarrow(codiff, colorup=#00c3ff, colordown=#ff0062,title="Exit Arrows", transp=20, maxheight=20, offset=0)
p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=2, title='MA Baseline')
//DownPlot = plot( show_SSL1 ? sslDown : na, title="SSL1", linewidth=3, color=color_ssl1, transp=10)
barcolor(show_color_bar ? color_bar : na)
//up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title="Baseline Upper Channel")
//low_channel = plot(show_Baseline ? lowerk : na, color=color_bar, title="Basiline Lower Channel")
//fill(up_channel, low_channel, color=color_bar, transp=90)
////SSL2 Continiuation from ATR
atr_crit = input(0.9, step=0.1, title="Continuation ATR Criteria")
upper_half = atr_slen * atr_crit + close
lower_half = close - atr_slen * atr_crit
//buy_inatr = lower_half < sslDown2
//sell_inatr = upper_half > sslDown2
//sell_cont = close < BBMC and close < sslDown2
//buy_cont = close > BBMC and close > sslDown2
//sell_atr = sell_inatr and sell_cont
//buy_atr = buy_inatr and buy_cont
//atr_fill = buy_atr ? color.green : sell_atr ? color.purple : color.white
//LongPlot = plot(sslDown2, title="SSL2", linewidth=2, color=atr_fill, style=plot.style_circles, transp=0)
u = plot(show_atr ? upper_band : na, "+ATR", color=color.new(color.white,80))
latr = plot(show_atr ? lower_band : na, "-ATR", color=color.new(color.white,80))
//Bear Bar and Bull Bar Calculations//
bearBar = close < open
bullBar = close > open
//RSI BARS//
src3 = close, len4 = input(8, minval=1, title="Length")
up = rma(max(change(src3), 0), len4)
down = rma(-min(change(src3), 0), len4)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//coloring method below
src1 = close, len1 = input(60, minval=1, title="UpLevel")
src2 = close, len8 = input(40, minval=1, title="DownLevel")
isup() => rsi > len1
isdown() => rsi < len8
//barcolor(isup() ? color.new(color.green,0) : isdown() ? color.new(color.red,0) : color.new(color.yellow,0) )
//CDV Variables//
cdvup = o_ <= c_
cdvdown = o_ >= c_
//Divergent Delta Candles//
divLong = cdvup and bearBar
divShort = cdvdown and bullBar
longDivSignal = divLong[1] or divLong[2]
shortDivSignal = divShort[1] or divShort[2]
//Bar Color Variables//
long = isup() and cdvup and bullBar //and longDivSignal
short = isdown() and cdvdown and bearBar //and shortDivSignal
//plotcandle(o_, h_, l_, c_, title='CDV Candles', color = o_ <= c_ ? colorup : colordown, bordercolor = o_ <= c_ ? bcolup : bcoldown, wickcolor = o_ <= c_ ? bcolup : bcoldown)
//barcolor(title='CDV Candles', color = o_ <= c_ ? colorup : colordown)
barcolor(title='RSICDV Candles', color = long ? colorup : short ? colordown : color.new(color.yellow,0))
//plot(showma1 and linestyle == "Candle" ? sma(c_, ma1len) : na, title = "SMA 1", color = ma1col)
//plot(showma2 and linestyle == "Candle" ? sma(c_, ma2len) : na, title = "SMA 2", color = ma2col)
//plot(showema1 and linestyle == "Candle" ? ema(c_, ema1len) : na, title = "EMA 1", color = ema1col)
//plot(showema2 and linestyle == "Candle" ? ema(c_, ema2len) : na, title = "EMA 2", color = ema2col)
|
Ehlers Linear Extrapolation Predictor [Loxx] | https://www.tradingview.com/script/aBFbzoex-Ehlers-Linear-Extrapolation-Predictor-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 93 | 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
// "Predict Extrapolation" (C) 1978-2021 John F. Ehlers
//@version=5
indicator("Ehlers Linear Extrapolation Predictor [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
//+------------------------------------------------------------------+
//| Extrenal library exports
//+------------------------------------------------------------------+
import loxx/loxxexpandedsourcetypes/4
//+------------------------------------------------------------------+
//| Declare constants
//+------------------------------------------------------------------+
SM02 = 'Predict/Filter Crosses'
SM03 = 'Predict Middle Crosses'
SM04 = 'Filter Middle Crosses'
redcolor = #D2042D
greencolor = #2DD204
//+------------------------------------------------------------------+
//| Fucntions
//+------------------------------------------------------------------+
highpass(float src, int period) => // High-Pass Filter
float a1 = math.exp(-1.414 * math.pi / period)
float b1 = 2 * a1 * math.cos(1.414 * math.pi / period)
float c2 = b1
float c3 = -a1 * a1
float c1 = (1 + c2 - c3) / 4
float hp = 0.0
hp := bar_index < 4 ? 0 : c1 * (src - 2 * nz(src[1]) + nz(src[2])) + (c2 * nz(hp[1])) + (c3 * nz(hp[2]))
hp
hann(float src, int period) => // Hann Low-Pass FIR Filter
var PIx2 = 2.0 * math.pi / (period + 1)
float sum4Hann = 0.0, sumCoefs = 0.0
for count = 1 to period
float coef = 1.0 - math.cos(count * PIx2)
sum4Hann += coef * src[count - 1]
sumCoefs += coef
float filt = nz(sum4Hann / sumCoefs)
filt
//+------------------------------------------------------------------+
//| Inputs
//+------------------------------------------------------------------+
srctype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", 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)"])
HPLength = input.int(125, "High-Pass Filter Period", group = "Preliminary Filtering Settings")
LPLength = input.int(12, "Low-Pass Hann Filter Period", group = "Preliminary Filtering Settings")
Gain = input.float(0.7, "Gain Reduction", group = "Output Shaping Settings")
BarsFwd = input.int(5, "Bars Forward", group = "Output Shaping Settings")
sigtype = input.string(SM02, "Signal Type", options = [SM02, SM03, SM04], group = "Signal Settings")
predictcol = input.color(color.yellow, "Prediction Color", group = "UI Settings")
filtcol = input.color(redcolor, "Filter Color", group = "UI Settings")
upcol = input.color(greencolor, "Uptrend Color", group = "UI Settings")
dncol = input.color(redcolor, "Downtrend Color", group = "UI Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group = "UI Options")
//+------------------------------------------------------------------+
//| Prepare source data
//+------------------------------------------------------------------+
//Inputs for Loxx's Expanded Source Types
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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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(srctype, amafl, amasl, kfl, ksl)
"HAB Open" => loxxexpandedsourcetypes.habopen(srctype, amafl, amasl, kfl, ksl)
"HAB High" => loxxexpandedsourcetypes.habhigh(srctype, amafl, amasl, kfl, ksl)
"HAB Low" => loxxexpandedsourcetypes.hablow(srctype, amafl, amasl, kfl, ksl)
"HAB Median" => loxxexpandedsourcetypes.habmedian(srctype, amafl, amasl, kfl, ksl)
"HAB Typical" => loxxexpandedsourcetypes.habtypical(srctype, amafl, amasl, kfl, ksl)
"HAB Weighted" => loxxexpandedsourcetypes.habweighted(srctype, amafl, amasl, kfl, ksl)
"HAB Average" => loxxexpandedsourcetypes.habaverage(srctype, amafl, amasl, kfl, ksl)
"HAB Average Median Body" => loxxexpandedsourcetypes.habavemedbody(srctype, amafl, amasl, kfl, ksl)
"HAB Trend Biased" => loxxexpandedsourcetypes.habtrendb(srctype, amafl, amasl, kfl, ksl)
"HAB Trend Biased (Extreme)" => loxxexpandedsourcetypes.habtrendbext(srctype, amafl, amasl, kfl, ksl)
=> haclose
//+------------------------------------------------------------------+
//| Private Varible declarations
//+------------------------------------------------------------------+
float HP = 0.
float SumSq = 0.
float Filt = 0.
float coef = 0.
int Length = 10
float Predict = 0.
XX = array.new<float>(21, 0.)
//+------------------------------------------------------------------+
//| Calculations
//+------------------------------------------------------------------+
//High-Pass Filter
HP := highpass(src, HPLength)
//Hann Low-Pass Filter
Filt := hann(HP, LPLength)
//Convert the Filt variable to a data array
for count = 1 to Length
array.set(XX, count, nz(Filt[Length - count]))
//Linear Exptrapolation
for count = 0 to 9
array.set(XX, Length + count + 1, array.get(XX, Length + count) + (array.get(XX, Length + count) - array.get(XX, Length + count - 1)))
//Convert desired forward look in the array to the variable Predict
Predict := array.get(XX, Length + BarsFwd) * Gain
//+------------------------------------------------------------------+
//| Plot output
//+------------------------------------------------------------------+
mid = 0.
plot(Filt, "Filter", color = filtcol, linewidth = 2)
plot(mid, "Zero line", color = bar_index % 2 ? color.silver : na)
plot(Predict, "Prediction", color = predictcol, linewidth = 1)
state = 0.
if sigtype == SM02
if (Predict < Filt)
state :=-1
if (Predict > Filt)
state := 1
else if sigtype == SM03
if (Predict < mid)
state :=-1
if (Predict > mid)
state := 1
else if sigtype == SM04
if (Filt < mid)
state :=-1
if (Filt > mid)
state := 1
colorout = state == 1 ? upcol : state == -1 ? dncol : color.gray
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(Predict, Filt) : sigtype == SM03 ? ta.crossover(Predict, mid) : ta.crossover(Filt, mid)
goShort = sigtype == SM02 ? ta.crossunder(Predict, Filt) : sigtype == SM03 ? ta.crossunder(Predict, mid) : ta.crossunder(Filt, mid)
plotshape(showSigs and goLong, title = "Long", color = upcol, textcolor = upcol, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = dncol, textcolor = dncol, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Ehlers Linear Extrapolation Predictor [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Ehlers Linear Extrapolation Predictor [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
High low volatile | https://www.tradingview.com/script/xgFQ3mkZ-High-low-volatile/ | NutnonZz | https://www.tradingview.com/u/NutnonZz/ | 162 | 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/
// © NutnonZz
//@version=4
study("High low volatility v2.0" , overlay=false)
// Choose system and main timeframe
aaa = input(title="System", type=input.string, defval="Spread Data", options=["Spread Data","Mean reversion"])
CTF = input(true, title="Use Current TimeFrame?")
TF = input("D", type=input.resolution, title="TimeFrame",tooltip='Example you trade in 15min timeframe but you want data of 60min or daychart')
// for setting in multiple timeframe
final_TF = CTF? timeframe.period : TF
close_ = security(syminfo.tickerid, final_TF, close)
low_ = security(syminfo.tickerid, final_TF, low)
high_ = security(syminfo.tickerid, final_TF, high)
//
// Calculate different between High and low
HL = high_-low_
// For setting input EMA
INPUT_EMA1 = input(10,title='EMA_HL_short')
INPUT_EMA2 = input(200,title='EMA_HL_long')
// EMA
EMA1 = ema(HL,INPUT_EMA1)
EMA2 = ema(HL,INPUT_EMA2)
// For plotting
plot(aaa == "Spread Data" ? HL : na , title='HL',color=color.teal ,style=plot.style_histogram ,linewidth=2)
plot(aaa == "Spread Data" ? EMA1 : na , title='EMA_HL_short',color=color.red,linewidth=2)
plot(aaa == "Spread Data" ? EMA2 : na , title='EMA_HL_long',color=color.orange ,linewidth=2)
////// system 2 mean reversion data
// type of different
bbb = input(title="Type of reversion", type=input.string, defval="dif_value", options=["dif_value","dif_value_color"])
// Main EMA reverse
INPUT_EMA_reverse = input(200,title='EMA_reversion')
EMA_reverse = ema(close,INPUT_EMA_reverse)
// Calculation
C = close
diff_ema = C - EMA_reverse
diff_ema2 = abs(C - EMA_reverse)
// Color dif
color_dif = diff_ema > 0 ? color.lime : color.red
// For plotting
plot(aaa == "Mean reversion" and bbb == "dif_value_color" ? diff_ema : na , color=color_dif ,style=plot.style_area ,linewidth=1)
plot(aaa == "Mean reversion" and bbb == "dif_value" ? diff_ema2 : na , color=color.teal ,style=plot.style_area ,linewidth=1)
|
Multi HMA Slopes [Loxx] | https://www.tradingview.com/script/RhhskgjI-Multi-HMA-Slopes-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("Multi HMA Slopes [Loxx]",
shorttitle="MHMAS [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
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)"])
inpPeriod1 = input.int(30, "Period 1", group = "Basic Settings")
inpPeriod2 = input.int(33, "Period 1", group = "Basic Settings")
inpPeriod3 = input.int(36, "Period 1", group = "Basic Settings")
inpPeriod4 = input.int(39, "Period 1", group = "Basic Settings")
inpPeriod5 = input.int(42, "Period 1", group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showLongs = input.bool(true, "Show Longs?", group = "Signal Options")
showShorts = input.bool(true, "Show Shorts?", group = "Signal Options")
showCLongs = input.bool(true, "Show Continuation Longs?", group = "Signal Options")
showCShorts = input.bool(true, "Show Continuation Shorts?", group = "Signal 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
ma1 = ta.hma(src, inpPeriod1)
ma2 = ta.hma(src, inpPeriod2)
ma3 = ta.hma(src, inpPeriod3)
ma4 = ta.hma(src, inpPeriod4)
ma5 = ta.hma(src, inpPeriod5)
histou = 0.
histod = 0.
if ma1 > nz(ma1[1])
histou += 1
if ma1 < nz(ma1[1])
histod -= 1
if ma2 > nz(ma2[1])
histou += 1
if ma2 < nz(ma2[1])
histod -= 1
if ma3 > nz(ma3[1])
histou += 1
if ma3 < nz(ma3[1])
histod -= 1
if ma4 > nz(ma4[1])
histou += 1
if ma4 < nz(ma4[1])
histod -= 1
if ma5 > nz(ma5[1])
histou += 1
if ma5 < nz(ma5[1])
histod -= 1
trend = histou > 0 and histod == 0 ? 1 : histod < 0 and histou == 0 ? -1 : 0
plot(histou, color = greencolor, linewidth = 2, style = plot.style_columns)
plot(histod, color = redcolor, linewidth = 2, style = plot.style_columns)
barcolor(colorbars ? trend == 1 ? greencolor : trend == -1 ? redcolor : color.gray : na)
contLSwitch = 0
contLSwitch := nz(contLSwitch[1])
contLSwitch := trend == 1 ? 1 : trend == -1 ? -1 : contLSwitch
goLong = trend == 1 and trend[1] != 1 and nz(contLSwitch[1]) == -1
goShort = trend == -1 and trend[1] != -1 and nz(contLSwitch[1]) == 1
goContL = trend == 1 and trend[1] != 1 and nz(contLSwitch[1]) == 1
goContS = trend == -1 and trend[1] != -1 and nz(contLSwitch[1]) == -1
plotshape(showLongs and goLong, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showShorts and goShort, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
plotshape(showCLongs and goContL, title = "Continuation Long", color = color.yellow, textcolor = color.yellow, text = "CL", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showCShorts and goContS, title = "Continuation Short", color = color.fuchsia, textcolor = color.fuchsia, text = "CS", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "Multi HMA Slopes [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "Multi HMA Slopes [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goContL, title = "Continuation Long", message = "Multi HMA Slopes [Loxx]: Continuation Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goContS, title = "Continuation Short", message = "Multi HMA Slopes [Loxx]: Continuation Short\nSymbol: {{ticker}}\nPrice: {{close}}")
hline(7, color = color.new(color.white, 100), editable = false)
hline(-7, color = color.new(color.white, 100), editable = false)
|
T3 Slope Variation [Loxx] | https://www.tradingview.com/script/FXAa2tqB-T3-Slope-Variation-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 80 | 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("T3 Slope Variation [Loxx]",
shorttitle="T3SV [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
SM02 = 'Trend'
SM03 = 'Agreement'
_iT3(src, per, hot, clean)=>
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 + (per - 1.0) / 2.0)
else
alpha := 2.0 / (1.0 + per)
_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
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)"])
T3Period = input.int(27, "Period", group= "Basic Settings")
Treshold = input.float(10, "Threshold", group= "Basic Settings")
t3hot = input.float(.7, "T3 Hot", group= "Basic Settings")
t3swt = input.string("T3 New", "T3 Type", options = ["T3 New", "T3 Original"], group = "Basic Settings")
sigtype = input.string(SM02, "Signal type", options = [SM02, SM03], group = "Signal 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
_t3a = _iT3(src, T3Period, t3hot, t3swt)
_t3o = 100.0 * (_t3a - nz(_t3a[1])) / nz(_t3a[1])
_t3s = (4.0 * _t3o + 3.0 * nz(_t3o[1]) + 2.0 * nz(_t3o[2]) + nz(_t3o[3])) / 10.0
t3out = _t3o
minVal = math.min(_t3o, _t3s)
maxVal = math.max(_t3o, _t3s)
diffP = 0.
if (minVal != 0)
diffP := math.abs(100 * (maxVal - minVal) / minVal)
HistoUP = 0.
HistoDN = 0.
HistoNN = 0.
TrendUP = 0.
TrendDN = 0.
TrendUP := TrendUP[1]
TrendDN := TrendDN[1]
if _t3o > _t3s and diffP > Treshold
TrendUP := 0
TrendDN := na
if _t3o < _t3s and diffP > Treshold
TrendDN := 0
TrendUP := na
if _t3o > 0 and TrendUP == 0
if high <= nz(high[1])
HistoUP := _t3o
else
HistoNN := _t3o
if _t3o < 0 and TrendDN == 0
if low >= nz(low[1])
HistoDN := _t3o
else
HistoNN := _t3o
trendcolor = t3out > 0 ? greencolor : t3out < 0 ? redcolor : color.gray
colorout = HistoUP > 0 ? greencolor : HistoDN < 0 ? redcolor : color.gray
mid = 0.
plot(HistoUP, color = greencolor, linewidth = 2, style = plot.style_histogram)
plot(HistoDN, color = redcolor, linewidth = 2, style = plot.style_histogram)
plot(HistoNN, color = color.gray, linewidth = 2, style = plot.style_histogram)
plot(mid, color = trendcolor, linewidth = 3)
plot(t3out, color = color.gray, linewidth = 2)
barcolor(colorbars ? sigtype == SM02 ? trendcolor : colorout : na)
pregoLong = sigtype == SM02 ? trendcolor == greencolor and trendcolor[1] != greencolor : colorout == greencolor and colorout[1] != greencolor
pregoShort = sigtype == SM02 ? trendcolor == redcolor and trendcolor[1] != redcolor : colorout == redcolor and colorout[1] != redcolor
contswitch = 0
contswitch := nz(contswitch[1])
contswitch := pregoLong ? 1 : pregoShort ? -1 : contswitch
goLong = pregoLong and contswitch == 1 and contswitch[1] == -1
goShort = pregoShort and contswitch == -1 and contswitch[1] == 1
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "T3 Slope Variation [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "T3 Slope Variation [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
SATAN Cycle Bitcoin | https://www.tradingview.com/script/S8D60odB/ | FJVL85 | https://www.tradingview.com/u/FJVL85/ | 40 | 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/
// © FJVL85
//@version=4
study("SATAN Cycle Bitcoin", shorttitle="SATAN Cycle Bitcoin", overlay=true)
//Create Inputs for the 4 MAs, and Visual
lowma_long = input(471, minval=1, title="BTC Low - Long SMA")
is_show_lowma1 = input(true, type=input.bool, title="Show Low Long SMA?")
lowema_short = input(195, minval=1, title="BTC Low - Short EMA")
is_show_lowma2 = input(true, type=input.bool, title="Show Low Short EMA?")
hima_long = input(555, minval=1, title="BTC High - Long SMA") //BLANCA
is_show_hima1 = input(true, type=input.bool, title="Show High Long SMA?")
hima_short = input(111, minval=1, title="BTC High - Short SMA") //AMARILLA
is_show_hima2 = input(true, type=input.bool, title="Show High Short SMA?")
//Set resolution to the Daily Chart
resolution = input('D', type=input.string, title="Time interval")
//Run the math for the 4 MAs
ma_long_low = security(syminfo.tickerid, resolution, sma(close, lowma_long)*0.8)
ema_short_low = security(syminfo.tickerid, resolution, ema(close, lowema_short))
ma_long_hi = security(syminfo.tickerid, resolution, sma(close, hima_long)*2.625)
ma_short_hi = security(syminfo.tickerid, resolution, sma(close, hima_short))
//Set SRC
src = security(syminfo.tickerid, resolution, close)
//Plot the 4 MAs
plot(is_show_lowma1?ma_long_low:na, color=color.red, linewidth=2, title="Low Long MA")
var lowma_long_label = label.new(x = bar_index, y = lowma_long, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.red, text = "BTC Low - Long SMA")
label.set_xy(lowma_long_label, x = bar_index, y = ma_long_low)
plot(is_show_lowma2?ema_short_low:na, color=color.green, linewidth=2, title="Low Short EMA")
var lowema_short_label = label.new(x = bar_index, y = lowema_short, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.green, text = "BTC Low - Short EMA")
label.set_xy(lowema_short_label, x = bar_index, y = ema_short_low)
plot(is_show_hima1?ma_long_hi:na, color=color.white, linewidth=2, title="High Long MA")
var hima_long_label = label.new(x = bar_index, y = hima_long, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.white, text = "BTC High - Long MA")
label.set_xy(hima_long_label, x = bar_index, y = ma_long_hi)
plot(is_show_hima2?ma_short_hi:na, color=color.yellow, linewidth=2, title="High Short MA")
var hima_short_label = label.new(x = bar_index, y = hima_short, color = color.rgb(0, 0, 0, 100), style = label.style_label_left, textcolor = color.yellow, text = "BTC High - Short MA")
label.set_xy(hima_short_label, x = bar_index, y = ma_short_hi)
//Find where the MAs cross each other
PiCycleLow = crossunder(ema_short_low, ma_long_low) ? src + (src/100 * 10) : na
PiCycleHi = crossunder(ma_long_hi, ma_short_hi) ? src + (src/100 * 10) : na
//Create Labels
plotshape(PiCycleLow, text="Satan Cycle Low", color=color.navy, textcolor=color.white, style=shape.labelup,size=size.normal, location=location.belowbar, title="Cycle Low")
plotshape(PiCycleHi, text="Satan Cycle High", color=color.teal, textcolor=color.white, style=shape.labeldown,size=size.normal, location=location.abovebar, title="Cycle High")
//Generate vertical lines at the BTC Halving Dates
isDate(y, m, d) =>
val = timestamp(y,m,d)
if val <= time and val > time[1]
true
else
false
// First Halving
if isDate(2012, 11, 28)
line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow)
label.new(bar_index, low, text="1st Halving - Nov 28, 2012", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar)
// Second Halving
if isDate(2016, 7, 9)
line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow)
label.new(bar_index, low, text="2nd Halving - Jul 9, 2016", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar)
// Third Halving
if isDate(2020, 5, 11)
line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow)
label.new(bar_index, low, text="3rd Halving - May 11, 2020", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar)
// Fourth Halving
//if isDate(2024, 3, 26)
// line.new(bar_index, low, bar_index, high, xloc.bar_index, extend.both, style=line.style_dashed, color=color.yellow)
// label.new(bar_index, low, text="4th Halving - March 26, 2024", style=label.style_label_upper_left, textcolor=color.yellow, color=color.black, textalign=text.align_right, yloc=yloc.belowbar)
|
Inspirational Watermark | https://www.tradingview.com/script/wTyYbkaZ-Inspirational-Watermark/ | BarefootJoey | https://www.tradingview.com/u/BarefootJoey/ | 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/
//
// © BarefootJoey
// ██████████████████████████████████████████████████████████████████████
// █▄─▄─▀██▀▄─██▄─▄▄▀█▄─▄▄─█▄─▄▄─█─▄▄─█─▄▄─█─▄─▄─███▄─▄█─▄▄─█▄─▄▄─█▄─█─▄█
// ██─▄─▀██─▀─███─▄─▄██─▄█▀██─▄███─██─█─██─███─███─▄█─██─██─██─▄█▀██▄─▄██
// █▄▄▄▄██▄▄█▄▄█▄▄█▄▄█▄▄▄▄▄█▄▄▄███▄▄▄▄█▄▄▄▄██▄▄▄██▄▄▄███▄▄▄▄█▄▄▄▄▄██▄▄▄██
//
// This is an educational script.
// When the bar changes you get a new inspirational quote.
// Hover for quotes.
//
//@version=5
indicator("Inspirational Watermark", overlay=true)
// Groups
grwm = "Watermark"
grt = "Table"
grl = "Label"
// Input
wmTypeIn = input.string("Table", "Type", options=["Label", "Table"], group=grwm, tooltip="Tables do not move. Labels are hard to crop out.")
position = input.string(position.top_right, "Location", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left], group=grt)
size = input.string(size.huge, "Size", [size.tiny, size.small, size.normal, size.large, size.huge], group=grwm)
watermark = input.string('🦉', "Text", group=grwm)
transp = input.int(20, "Transparency", minval=0, maxval=100, group=grwm)
col = input.color(color.orange, "Text Color", group=grwm)
// List of quotes to display
// If you know the unknown authors, I would welcome the information
q1 = '"For ideal entries, you are required to be sensitive to the subtle movement along the probability continuum." -Chris Lori'
q2 = '"Success in the market is not just about the market; it\'s about how you react to fear & greed." -Chris Lori'
q3 = '"Do not consider any other traders commentary when you are already in a position with a defined exit path." -Chris Lori'
q4 = '"Be absolutely clear in your plan. When engaged in the intensity of a trading scenario, focus on the task at hand." -Chris Lori'
q5 = '"In investing, what is comfortable is rarely profitable." -Robert Arnott'
q6 = '"Amateurs think about how much money they can make. Professionals think about how much money they could lose." -Jack Schwager'
q7 = '"It\'s not always easy to do what\'s not popular, but that\'s where you make your money." -John Neff'
q8 = '"Are you willing to lose money on a trade? If not, then don\'t take it." -Sami Abusad'
q9 = '"I\'m only rich because I know when I\'m wrong. I basically have survived by recognizing my mistakes." -George Soros'
q10 = '"I have two basic rules about winning in trading as well as in life: \n1) If you don\'t bet, you can\'t win. \n2) If you lose all your chips, you can\'t bet." -Larry Hite'
q11 = '"I just wait until there is money lying in the corner, and all I have to do is go over there and pick it up. I do nothing in the meantime." -Jim Rogers'
q12 = '"The purpose of trading is not being right, the purpose is to make money, and I think that\'s my number-one rule. Don\'t get hung up on your current positions." -Dana Allen'
q13 = '"Learn to take losses. The most important thing in making money is not letting your losses get out of hand." -Marty Schwartz'
q14 = '"Only buy something that you\'d be perfectly happy to hold if the market shut down for 10 years." -Warren Buffett'
q15 = '"There is a time to go long, a time to go short, and a time to go fishing." -Jesse Livermore'
q16 = '"If most traders would learn to sit on their hands 50 percent of the time, they would make a lot more money." -Bill Lipschutz'
q17 = '"You never know what kind of setup market will present to you; your objective should be to find an opportunity where risk-reward ratio is best." -Jaymin Shah'
q18 = '"The market can stay irrational longer than you can stay solvent." -John Maynard Keynes'
q19 = '"Trading doesn\'t just reveal your character, it also builds it if you stay in the game long enough." -Yvan Byeajee'
q20 = '"Bull markets are born on pessimism, grow on skepticism, mature on optimism and die of euphoria." -John Templeton'
q21 = '"One of the funny things about the stock market is that every time one person buys, another sells, and both think they are astute." -William Feather'
q22 = '"Only the game can teach you the game." -Jesse Livermore'
q23 = '"An investor without investment objectives is like a traveler without a destination." -Ralph Seger'
q24 = '"If stock market experts were so expert, they would be buying stocks, not selling advice." -Norman R. Augustine'
q25 = '"The stock market is a device for transferring money from the impatient to the patient." -Warren Buffett'
q26 = '"The intelligent investor is a realist who sells to optimists and buys from pessimists." -Benjamin Graham'
q27 = '"The stock market is filled with individuals who know the price of everything, but the value of nothing." -Philip Arthur Fisher'
q28 = '"We want to perceive ourselves as winners, but successful traders are always focusing on their losses." -Peter Borish'
q29 = '"In the short run a market is a voting machine, but in the long run it is a weighing machine." -Benjamin Graham'
q30 = '"The big money is not in the buying or the selling, but in the waiting." -Charlie Munger'
q31 = '"The question should not be: How much I will profit on this trade? The true question is: Will I be fine if I don\'t profit from this trade?" -Yvan Byeajee'
q32 = '"If you don\'t find a way to make money while you sleep, you will work until you die." -Warren Buffett'
q33 = '"Always start at the end before you begin. Professional investors always have an exit strategy before they invest." -Robert Kiyosaki'
q34 = '"Don\'t focus on making money; focus on protecting what you have." -Paul Tudor Jones'
q35 = '"The secret to being successful from a trading perspective is to have an indefatigable and an undying and unquenchable thirst for information and knowledge." -Paul Tudor Jones'
q36 = '"Don\'t ever average losers. Decrease your trading volume when you are trading poorly; increase your volume when you are trading well." -Paul Tudor Jones'
q37 = '"I am always thinking about losing money as opposed to making money." -Paul Tudor Jones'
q38 = '"Don\'t buy water during a drought; just put out a bucket when it\'s raining." -Unknown'
q39 = '"An investment in knowledge pays the best interest." -Benjamin Franklin'
q40 = '"Be fearful when others are greedy. Be greedy when others are fearful." -Warren Buffett'
q41 = '"It\'s not whether you\'re right or wrong that\'s important, but how much money you make when you\'re right and how much you lose when you\'re wrong." — George Soros'
q42 = '"Given a 10% chance of a 100 times payoff, you should take that bet every time." -Jeff Bezos'
q43 = '"I don\'t look to jump over seven-foot bars; I look around for one-foot bars that I can step over." -Warren Buffett'
q44 = '"Letting your emotions override your plan or systems is the biggest cause of failure." -J Welles Wilder'
q45 = '"Some traders are born with an innate discipline. Most have to learn it the hard way." -J Welles Wilder'
q46 = '"If you cant deal with emotions, get out of trading." -J Welles Wilder'
q47 = '"Buy the rumor, sell the news." -Joseph De La Vega'
q48 = '"When in doubt, zoom out" -Reggie Watts'
q49 = '"The trend is your friend, except at the end where it bends." -Martin Zweig & Unknown'
q50 = '"No price is too low for a bear or too high for a bull." -Unknown'
q51 = '"We don\'t have to be smarter than the rest, we have to be more disciplined than the rest." -Warren Buffett'
q52 = '"The key to making money in stocks is not to get scared out of them." -Peter Lynch'
q53 = '"The four most expensive words in the english language are: This time it\'s different." -Sir John Templeton'
q54 = '"Learn everyday, but especially from the experiences of others. It\'s cheaper!" -John Bogle'
q55 = '"Everyone has the power to follow the stock market. If you made it through fifth grade math, you can do it." -Peter Lynch'
q56 = '"Look at market fluctuations as your friend rather than your enemy. Profit from folly rather than participate in it." -Warren Buffett'
q57 = '"At a certain point, money is meaningless. It ceases to be the goal. The game is what counts." -Aristotle Onassis'
q58 = '"Seek advice on risk from the wealthy who still take risks, not friends who dare nothing more than a football bet." – J. Paul Getty'
q59 = '"Risk comes from not knowing what you’re doing." -Warren Buffett'
//q60 =
// Logic
r = math.round(math.random(1, 59))
quoteout =
r == 1 ? q1 : r == 2 ? q2 : r == 3 ? q3 : r == 4 ? q4 : r == 5 ? q5 : r == 6 ? q6 : r == 7 ? q7 : r == 8 ? q8 : r == 9 ? q9 :
r == 10 ? q10 : r == 11 ? q11 : r == 12 ? q12 : r == 13 ? q13 : r == 14 ? q14 : r == 15 ? q15 : r == 16 ? q16 : r == 17 ? q17 : r == 18 ? q18 : r == 19 ? q19 :
r == 20 ? q20 : r == 21 ? q21 : r == 22 ? q22 : r == 23 ? q23 : r == 24 ? q24 : r == 25 ? q25 : r == 26 ? q26 : r == 27 ? q27 : r == 28 ? q28 : r == 29 ? q29 :
r == 30 ? q30 : r == 31 ? q31 : r == 32 ? q32 : r == 33 ? q33 : r == 34 ? q34 : r == 35 ? q35 : r == 36 ? q36 : r == 37 ? q37 : r == 38 ? q38 : r == 39 ? q39 :
r == 40 ? q40 : r == 41 ? q41 : r == 42 ? q42 : r == 43 ? q43 : r == 44 ? q44 : r == 45 ? q45 : r == 46 ? q46 : r == 47 ? q47 : r == 48 ? q48 : r == 49 ? q49 :
r == 50 ? q50 : r == 51 ? q51 : r == 52 ? q52 : r == 53 ? q53 : r == 54 ? q54 : r == 55 ? q55 : r == 56 ? q56 : r == 57 ? q57 : r == 58 ? q58 : r == 59 ? q59 :
//r == 60 ? q60 :
na
// Table Out
var table quote = table.new(position, 1, 1)
if barstate.isconfirmed and wmTypeIn=="Table"
table.cell(quote, 0, 0, watermark, text_size = size, text_color = color.new(col, transp), tooltip=str.tostring(quoteout))
// Label Out
watermarklocation = input.string(yloc.abovebar, options=[yloc.belowbar, yloc.abovebar], title='Location', group=grl)
labelhoffset = input.int(0, "Horizontal Offset", maxval=1)
wmPrice = ta.valuewhen(bar_index, close, 0)
var label quote2 = na
if barstate.isconfirmed and wmTypeIn=="Label"
quote2 := label.new(bar_index + labelhoffset, y=wmPrice, yloc=watermarklocation, size=size, text=watermark, style=label.style_none, textcolor=color.new(col,transp), tooltip=quoteout)
label.delete(quote2[1])
// EoS made w/ ❤ by @BarefootJoey ✌💗📈
|
Constantly Applied Pressure Index (CAP index) | https://www.tradingview.com/script/eddWAQAK-Constantly-Applied-Pressure-Index-CAP-index/ | Mynicknameislion | https://www.tradingview.com/u/Mynicknameislion/ | 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/
// © Mynicknameislion
//@version=5
indicator("Constantly Applied Pressure Index (CAP index)", "CAP index")
lookback = input.int(title="Lookback Period", defval = 8)
inverse = input.bool(title="Inverse indicator", defval=true)
smoothingType = input.string(title="Line Smoothing Mehtod", defval="WMA", options=[ "EMA", "SMA", "RMA", "WMA", "None"])
smoothingPeriod = input.int(title="Line Smoothing Period", defval = 17)
src = input(title="Source", defval=close)
predictions = input.bool(title="Determine trend of indicator", defval=true)
baseLine = input.bool(title="Show Baseline", defval = true)
noFail = input.bool(title="No failing trend indication", defval=false)
strengthCurve = input.float(title="Strength Curve One", defval=0.005)
strengthCurveTwo = input.float(title="Strength Curve Two", defval=0.001)
var temp = 0.0
upsideScore = 100.0
downsideScore = 100.0
baseSide = if src > src[1]
"bull"
else
"bear"
//Step 1
if baseSide == "bull"
upsideScore *= 1.05
downsideScore *- 1.025
else
upsideScore *- 1.025
downsideScore *= 1.05
//Step 2
qtyOfHigherCloses(lookback, src) =>
int result = 0
for i = 1 to lookback
if src[i] > src
result += 1
result
qtyOfLowerCloses(lookback, src) =>
int result = 0
for i = 1 to lookback
if src[i] < src
result += 1
result
bullLookback = qtyOfHigherCloses(lookback, src)
bearLookback = qtyOfLowerCloses(lookback, src)
side = if baseSide == "bull"
bullLookback
else
bearLookback
temp := 0
for i = 1 to math.min(side, 5)
temp += strengthCurve * (1 / i)
if baseSide == "bull"
upsideScore *= (temp + 1)
else
downsideScore *= (temp + 1)
side := baseSide == "bull" ? bearLookback : bullLookback
temp := 0
for i = 1 to math.min(side, 8)
temp += strengthCurveTwo * (i * i)
if baseSide == "bull"
downsideScore *= (temp + 1)
else
upsideScore *= (temp + 1)
//Step 3
bearchange = 0.0
bullchange = 0.0
temp := 0
for i = 1 to lookback
if src[i] > src[i - 1]
temp += 1
bullchange += src[i] - src[i - 1]
else
bearchange += src[i - 1] - src[i]
bullchange /= temp
bearchange /= (lookback - temp)
temp := 0
if bullchange > bearchange
temp := (downsideScore / 100) * 5
downsideScore -= temp
upsideScore += temp
else
temp := (upsideScore / 100) * 5
downsideScore += temp
upsideScore -= temp
//Step 4
bullVolume = 0.0
bearVolume = 0.0
temp := 0
for i = 1 to lookback
if src[i] > src[i - 1]
temp += 1
bullVolume += volume[i]
else
bearVolume += volume[i]
bullVolume /= temp
bearVolume /= (lookback - temp)
if bullVolume > bearVolume and baseSide == "bull"
temp := (downsideScore / 100) * 3
downsideScore -= temp
upsideScore += temp
else if bullVolume > bearVolume and baseSide == "bear"
temp := (downsideScore / 100) * 5
downsideScore -= temp
upsideScore += temp
else if bullVolume < bearVolume and baseSide == "bear"
temp := (upsideScore / 100) * 3
downsideScore += temp
upsideScore -= temp
else if bullVolume < bearVolume and baseSide == "bull"
temp := (upsideScore / 100) * 5
downsideScore += temp
upsideScore -= temp
//Plotting and trend calculation
overall = upsideScore - downsideScore
smoothed = 0.0
if smoothingType == "EMA"
smoothed := ta.ema(overall, smoothingPeriod)
else if smoothingType == "SMA"
smoothed := ta.sma(overall, smoothingPeriod)
else if smoothingType == "RMA"
smoothed := ta.rma(overall, smoothingPeriod)
else if smoothingType == "WMA"
smoothed := ta.wma(overall, smoothingPeriod)
else
smoothed := overall
if inverse
smoothed *= -1
var trend = 0 // 1 is strong up, 2 weak up and 0 is failing, negatives are down
var trendHigh = 0.0
var failed = false
if ta.crossover(smoothed, 0)
trend := 1
trendHigh := -1
failed := false
else if ta.crossover(0, smoothed)
trend := -1
trendHigh := 1
failed := false
if trend == 1
if smoothed <= smoothed[1] and smoothed[1] <= smoothed[2]
trend := 2
if trend == -1
if smoothed >= smoothed[1] and smoothed[1] >= smoothed[2]
trend := -2
if trend == 2 and not noFail
if smoothed > trendHigh
trendHigh := smoothed
if smoothed < (trendHigh - (trendHigh * 0.1))
trend := 0
if trend == -2 and not noFail
if smoothed < trendHigh
trendHigh := smoothed
if smoothed > (trendHigh + (trendHigh * 0.1))
trend := 0
if trend == 0
if not failed and smoothed > 0
if smoothed > (trendHigh - (trendHigh * 0.05))
trend := 2
failed := true
if not failed and smoothed < 0
if smoothed < (trendHigh + (trendHigh * 0.05))
trend := -2
failed := true
plot(0, "Baseline", display = (baseLine ? display.all : display.none), color=color.gray)
plot(smoothed, "", predictions ? na : color.white)
plot(smoothed, "Failing Trend Line", predictions ? (trend == 0 ? color.gray : na ) : na)
plot(smoothed, "Strong Trend Line", predictions ? (trend == 1 ? color.lime : (trend == -1 ? color.red : na)) : na)
plot(smoothed, "Weaktrend Line", predictions ? (trend == 2 ? color.olive : (trend == -2 ? color.maroon : na)) : na) |
R-squared Adaptive T3 Ribbon Filled Simple [Loxx] | https://www.tradingview.com/script/GrMplxz3-R-squared-Adaptive-T3-Ribbon-Filled-Simple-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 419 | 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("R-squared Adaptive T3 Ribbon Filled Simple [Loxx]",
shorttitle="RSQRDT3RFS [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_t3rSqrdAdapt(float src, float period, bool original, bool trendFollow)=>
alpha = original ?
2.0 / (1.0 + period) :
2.0 / (2.0 + (period - 1.0) / 2.0)
len = 0., SumX = 0., SumX2 = 0.
SumY = 0., SumY2 = 0., SumXY = 0.
if (len != period)
len := period, SumX := 0
for k = 0 to period - 1
SumX += k + 1
SumX2 := 0
for k = 0 to period - 1
SumX2 += (k + 1) * (k + 1)
for k = 0 to period - 1
tprice = nz(src[k])
SumY += tprice
SumY2 += math.pow(tprice, 2)
SumXY += (k + 1) * tprice
Q1 = SumXY - SumX * SumY / period
Q2 = SumX2 - SumX * SumX / period
Q3 = SumY2 - SumY * SumY / period
hot = Q2 * Q3 != 0 ?
trendFollow ?
math.max(1.0 - (Q1 * Q1 / (Q2 * Q3)), 0.01) :
math.max((Q1 * Q1 / (Q2 * Q3)), 0.01) : 0.
t31 = src, t32 = src, t33 = src
t34 = src, t35 = src, t36 = src
price = 0.
t31 := nz(t31[1]) + alpha * (src - nz(t31[1]))
t32 := nz(t32[1]) + alpha * (t31 - nz(t32[1]))
price := (1.0 + hot) * t31 - hot * t32
t33 := nz(t33[1]) + alpha * (price - nz(t33[1]))
t34 := nz(t34[1]) + alpha * (t33 - nz(t34[1]))
price := (1.0 + hot) * t33 - hot * t34
t35 := nz(t35[1]) + alpha * (price - nz(t35[1]))
t36 := nz(t36[1]) + alpha * (t35 - nz(t36[1]))
out = ((1.0 + hot) * t35 - hot * t36)
out
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Source Settings")
srcin1 = input.string("HAB Trend Biased (Extreme)", "Fast Source", group= "Fast 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)"])
T3Period1 = input.int(30, "Fast period", group = "Fast Settings")
orig1 = input.bool(false, "Fast Original?", group = "Fast Settings")
fllwtrnd1 = input.bool(true, "Fast Trend follow?", group = "Fast Settings")
srcin2 = input.string("HAB Trend Biased (Extreme)", "Slow Source", group= "Slow 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)"])
T3Period2 = input.int(60, "Slow period", group = "Slow Settings")
orig2 = input.bool(false, "Slow Original?", group = "Slow Settings")
fllwtrnd2 = input.bool(true, "Slow Trend follow?", group = "Slow 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
srcout(srcin, smthtype)=>
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
src
buffer1 =_t3rSqrdAdapt(srcout(srcin1, smthtype), T3Period1, orig1, fllwtrnd1)
buffer2 = _t3rSqrdAdapt(srcout(srcin2, smthtype), T3Period2, orig2, fllwtrnd2)
colorout = buffer1 > buffer2 ? greencolor : redcolor
fast = plot(buffer1, color = colorout)
slow = plot(buffer2, color = colorout)
fill(fast, slow, color = color.new(colorout, 75))
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(buffer1, buffer2)
goShort = ta.crossunder(buffer1, buffer2)
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 = "R-squared Adaptive T3 Ribbon Filled Simple [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "R-squared Adaptive T3 Ribbon Filled Simple [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
HMA Slope Variation [Loxx] | https://www.tradingview.com/script/IVSdmm4U-HMA-Slope-Variation-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 268 | 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("HMA Slope Variation [Loxx]",
shorttitle="HMASV [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
SM02 = 'Trend'
SM03 = 'Agreement'
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "hma", "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)"])
hmaPeriod = input.int(60, "Period", group= "Basic Settings")
Treshold = input.float(10, "Threshold", group= "Basic Settings")
sigtype = input.string(SM02, "Signal type", options = [SM02, SM03], group = "Signal 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")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
src = switch srcin
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"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)
=> haclose
_hmaa = ta.hma(src, hmaPeriod)
_hmao = 100.0 * (_hmaa - nz(_hmaa[1])) / nz(_hmaa[1])
_hmas = (4.0 * _hmao + 3.0 * nz(_hmao[1]) + 2.0 * nz(_hmao[2]) + nz(_hmao[3])) / 10.0
hmaout = _hmao
minVal = math.min(_hmao, _hmas)
maxVal = math.max(_hmao, _hmas)
diffP = 0.
if (minVal != 0)
diffP := math.abs(100 * (maxVal - minVal) / minVal)
HistoUP = 0.
HistoDN = 0.
HistoNN = 0.
TrendUP = 0.
TrendDN = 0.
TrendUP := TrendUP[1]
TrendDN := TrendDN[1]
if _hmao > _hmas and diffP > Treshold
TrendUP := 0
TrendDN := na
if _hmao < _hmas and diffP > Treshold
TrendDN := 0
TrendUP := na
if _hmao > 0 and TrendUP == 0
if high <= nz(high[1])
HistoUP := _hmao
else
HistoNN := _hmao
if _hmao < 0 and TrendDN == 0
if low >= nz(low[1])
HistoDN := _hmao
else
HistoNN := _hmao
trendcolor = hmaout > 0 ? greencolor : hmaout < 0 ? redcolor : color.gray
colorout = HistoUP > 0 ? greencolor : HistoDN < 0 ? redcolor : color.gray
mid = 0.
plot(HistoUP, color = greencolor, linewidth = 2, style = plot.style_histogram)
plot(HistoDN, color = redcolor, linewidth = 2, style = plot.style_histogram)
plot(HistoNN, color = color.gray, linewidth = 2, style = plot.style_histogram)
plot(mid, color = trendcolor, linewidth = 3)
plot(hmaout, color = color.gray, linewidth = 2)
barcolor(colorbars ? sigtype == SM02 ? trendcolor : colorout : na)
pregoLong = sigtype == SM02 ? trendcolor == greencolor and trendcolor[1] != greencolor : colorout == greencolor and colorout[1] != greencolor
pregoShort = sigtype == SM02 ? trendcolor == redcolor and trendcolor[1] != redcolor : colorout == redcolor and colorout[1] != redcolor
contswitch = 0
contswitch := nz(contswitch[1])
contswitch := pregoLong ? 1 : pregoShort ? -1 : contswitch
goLong = pregoLong and contswitch == 1 and contswitch[1] == -1
goShort = pregoShort and contswitch == -1 and contswitch[1] == 1
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "HMA Slope Variation [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "HMA Slope Variation [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Autocorrelative Power Oscillator (APO) [SpiritualHealer117] | https://www.tradingview.com/script/08kQR3R3-Autocorrelative-Power-Oscillator-APO-SpiritualHealer117/ | spiritualhealer117 | https://www.tradingview.com/u/spiritualhealer117/ | 82 | 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/
// © spiritualhealer117
//@version=5
indicator("My script")
co_len = input(300,"Correlation Calculation Length")
len = input(10, "Number of correlation offsets")
src = input(close,"Source")
smo = input(5, "Smoothing Length")
calc_correl (src, lag, len)=>
s1 = 0.
s2 = 0.
s3 = 0.
x_bar = ta.sma(src,len)
y_bar = ta.sma(src[lag],len)
for i = 0 to len - 1
s1+=(src[i]-x_bar)*(src[i+lag]-y_bar)
s2+=math.pow((src[i]-x_bar),2)
s3+=math.pow((src[i+lag]-y_bar),2)
s1/(math.sqrt(s2*s3))
sgn(x)=>x>=0?1:-1
signed_correls = array.new<float>(len,0.0)
for i=1 to len
mult_adjustment = src[i]<=src?1:-1
array.set(signed_correls,i-1,mult_adjustment*sgn(calc_correl(close,i,co_len)))
smo_line = ta.sma(array.sum(signed_correls),smo)
clr = smo_line>=0?color.new(color.green,math.min(30,100-array.avg(signed_correls)*100)):color.new(color.red,math.min(30,100+array.avg(signed_correls)*100))
plot(smo_line, style=plot.style_columns, color=clr)
hline(len)
hline(-len) |
Horizontal Lines Automatic | https://www.tradingview.com/script/s4w5jzo2-Horizontal-Lines-Automatic/ | barnabygraham | https://www.tradingview.com/u/barnabygraham/ | 177 | 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/
// © barnabygraham
//@version=5
indicator('Horizontal Lines Automatic [Technimentals]', overlay=true,max_lines_count=500)
toadd = 0.
incval = 0.
background = 0.
line1 = 0.
line2 = 0.
selectedprice = math.ceil(math.round(close)/10)*10
incval := input.float(title='Increment Value', defval=2.5)
toadd := incval
bool h = close > selectedprice + toadd
bool l = close < selectedprice - toadd
alertcondition(h, title='Cross UP', message='{{ticker}} crossed {{close}}') //alert for when the price crosses the first upper interval
alertcondition(l, title='Cross DOWN', message='{{ticker}} crossed {{close}}') //alert for when the price crosses the first lower interval
alertcondition(h or l, title='Cross UP/DOWN', message='{{ticker}} crossed {{close}}') //alert for when the price crosses the first lower interval
colour=input.color(color.new(color.blue,65),'Line Colour')
n = bar_index
if barstate.islast
base = line.new(n[1],selectedprice + toadd * 0,n,selectedprice + toadd * 0,extend=extend.both,color=colour)
a1 = line.new(n[1],selectedprice + toadd * 1,n,selectedprice + toadd * 1,extend=extend.both,color=colour)
b1 = line.new(n[1],selectedprice - toadd * 1,n,selectedprice - toadd * 1,extend=extend.both,color=colour)
a2 = line.new(n[1],selectedprice + toadd * 2,n,selectedprice + toadd * 2,extend=extend.both,color=colour)
b2 = line.new(n[1],selectedprice - toadd * 2,n,selectedprice - toadd * 2,extend=extend.both,color=colour)
a3 = line.new(n[1],selectedprice + toadd * 3,n,selectedprice + toadd * 3,extend=extend.both,color=colour)
b3 = line.new(n[1],selectedprice - toadd * 3,n,selectedprice - toadd * 3,extend=extend.both,color=colour)
a4 = line.new(n[1],selectedprice + toadd * 4,n,selectedprice + toadd * 4,extend=extend.both,color=colour)
b4 = line.new(n[1],selectedprice - toadd * 4,n,selectedprice - toadd * 4,extend=extend.both,color=colour)
a5 = line.new(n[1],selectedprice + toadd * 5,n,selectedprice + toadd * 5,extend=extend.both,color=colour)
b5 = line.new(n[1],selectedprice - toadd * 5,n,selectedprice - toadd * 5,extend=extend.both,color=colour)
a6 = line.new(n[1],selectedprice + toadd * 6,n,selectedprice + toadd * 6,extend=extend.both,color=colour)
b6 = line.new(n[1],selectedprice - toadd * 6,n,selectedprice - toadd * 6,extend=extend.both,color=colour)
a7 = line.new(n[1],selectedprice + toadd * 7,n,selectedprice + toadd * 7,extend=extend.both,color=colour)
b7 = line.new(n[1],selectedprice - toadd * 7,n,selectedprice - toadd * 7,extend=extend.both,color=colour)
a8 = line.new(n[1],selectedprice + toadd * 8,n,selectedprice + toadd * 8,extend=extend.both,color=colour)
b8 = line.new(n[1],selectedprice - toadd * 8,n,selectedprice - toadd * 8,extend=extend.both,color=colour)
a9 = line.new(n[1],selectedprice + toadd * 9,n,selectedprice + toadd * 9,extend=extend.both,color=colour)
b9 = line.new(n[1],selectedprice - toadd * 9,n,selectedprice - toadd * 9,extend=extend.both,color=colour)
a10 = line.new(n[1],selectedprice + toadd * 10,n,selectedprice + toadd * 10,extend=extend.both,color=colour)
b10 = line.new(n[1],selectedprice - toadd * 10,n,selectedprice - toadd * 10,extend=extend.both,color=colour)
a11 = line.new(n[1],selectedprice + toadd * 11,n,selectedprice + toadd * 11,extend=extend.both,color=colour)
b11 = line.new(n[1],selectedprice - toadd * 11,n,selectedprice - toadd * 11,extend=extend.both,color=colour)
a12 = line.new(n[1],selectedprice + toadd * 12,n,selectedprice + toadd * 12,extend=extend.both,color=colour)
b12 = line.new(n[1],selectedprice - toadd * 12,n,selectedprice - toadd * 12,extend=extend.both,color=colour)
a13 = line.new(n[1],selectedprice + toadd * 13,n,selectedprice + toadd * 13,extend=extend.both,color=colour)
b13 = line.new(n[1],selectedprice - toadd * 13,n,selectedprice - toadd * 13,extend=extend.both,color=colour)
a14 = line.new(n[1],selectedprice + toadd * 14,n,selectedprice + toadd * 14,extend=extend.both,color=colour)
b14 = line.new(n[1],selectedprice - toadd * 14,n,selectedprice - toadd * 14,extend=extend.both,color=colour)
a15 = line.new(n[1],selectedprice + toadd * 15,n,selectedprice + toadd * 15,extend=extend.both,color=colour)
b15 = line.new(n[1],selectedprice - toadd * 15,n,selectedprice - toadd * 15,extend=extend.both,color=colour)
a16 = line.new(n[1],selectedprice + toadd * 16,n,selectedprice + toadd * 16,extend=extend.both,color=colour)
b16 = line.new(n[1],selectedprice - toadd * 16,n,selectedprice - toadd * 16,extend=extend.both,color=colour)
a17 = line.new(n[1],selectedprice + toadd * 17,n,selectedprice + toadd * 17,extend=extend.both,color=colour)
b17 = line.new(n[1],selectedprice - toadd * 17,n,selectedprice - toadd * 17,extend=extend.both,color=colour)
a18 = line.new(n[1],selectedprice + toadd * 18,n,selectedprice + toadd * 18,extend=extend.both,color=colour)
b18 = line.new(n[1],selectedprice - toadd * 18,n,selectedprice - toadd * 18,extend=extend.both,color=colour)
a19 = line.new(n[1],selectedprice + toadd * 19,n,selectedprice + toadd * 19,extend=extend.both,color=colour)
b19 = line.new(n[1],selectedprice - toadd * 19,n,selectedprice - toadd * 19,extend=extend.both,color=colour)
a20 = line.new(n[1],selectedprice + toadd * 20,n,selectedprice + toadd * 20,extend=extend.both,color=colour)
b20 = line.new(n[1],selectedprice - toadd * 20,n,selectedprice - toadd * 20,extend=extend.both,color=colour)
line.delete(base[1])
line.delete(a1[1])
line.delete(b1[1])
line.delete(a2[1])
line.delete(b2[1])
line.delete(a3[1])
line.delete(b3[1])
line.delete(a4[1])
line.delete(b4[1])
line.delete(a5[1])
line.delete(b5[1])
line.delete(a6[1])
line.delete(b6[1])
line.delete(a7[1])
line.delete(b7[1])
line.delete(a8[1])
line.delete(b8[1])
line.delete(a9[1])
line.delete(b9[1])
line.delete(a10[1])
line.delete(b10[1])
line.delete(a11[1])
line.delete(b11[1])
line.delete(a12[1])
line.delete(b12[1])
line.delete(a13[1])
line.delete(b13[1])
line.delete(a14[1])
line.delete(b14[1])
line.delete(a15[1])
line.delete(b15[1])
line.delete(a16[1])
line.delete(b16[1])
line.delete(a17[1])
line.delete(b17[1])
line.delete(a18[1])
line.delete(b18[1])
line.delete(a19[1])
line.delete(b19[1])
line.delete(a20[1])
line.delete(b20[1])
|
Median Absolute Deviation Outlier Fractals | https://www.tradingview.com/script/BkDQwP8O-Median-Absolute-Deviation-Outlier-Fractals/ | CryptoGearBox | https://www.tradingview.com/u/CryptoGearBox/ | 42 | 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/
// © CryptoGearBox
//@version=5
indicator("Median Absolute Deviation Fractals", shorttitle = "MAD Fractals", overlay = true)
// ----------------------------------------------------------------------
// Inputs
// ----------------------------------------------------------------------
i_src = input.source(close, "Source")
i_baseline = input.int(89, "Baseline Length")
i_madLen = input.int(13, "MAD Length")
i_madDeviations = input.float(2.9652, "MAD Deviations Limit")
i_showRegFrac = input.bool(true, "Show Regular Fractals?")
// ----------------------------------------------------------------------
// Functions
// ----------------------------------------------------------------------
// G-Channels as baseline for trend
// Source: https://www.tradingview.com/script/fIvlS64B-G-Channels-Efficient-Calculation-Of-Upper-Lower-Extremities/
f_baseline(_src, _length) =>
float _gTop = 0.
float _gBot = 0.
_gTop := math.max(_src, nz(_gTop[1])) - nz(_gTop[1] - _gBot[1]) / _length
_gBot := math.min(_src, nz(_gBot[1])) + nz(_gTop[1] - _gBot[1]) / _length
float _baseline = math.avg(_gTop, _gBot)
// ----------------------------------------------------------------------
// Main
// ----------------------------------------------------------------------
// Trend
float baseline = f_baseline(i_src, i_baseline)
// Bill William's Fractals
int n = 2
bool upFractal = ((high[n+2] < high[n]) and (high[n+1] < high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ((high[n+3] < high[n]) and (high[n+2] < high[n]) and (high[n+1] == high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ((high[n+4] < high[n]) and (high[n+3] < high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ((high[n+5] < high[n]) and (high[n+4] < high[n]) and (high[n+3] == high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
or ((high[n+6] < high[n]) and (high[n+5] < high[n]) and (high[n+4] == high[n]) and (high[n+3] <= high[n]) and (high[n+2] == high[n]) and (high[n+1] <= high[n]) and (high[n-1] < high[n]) and (high[n-2] < high[n]))
bool dnFractal = ((low[n+2] > low[n]) and (low[n+1] > low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ((low[n+3] > low[n]) and (low[n+2] > low[n]) and (low[n+1] == low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ((low[n+4] > low[n]) and (low[n+3] > low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ((low[n+5] > low[n]) and (low[n+4] > low[n]) and (low[n+3] == low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
or ((low[n+6] > low[n]) and (low[n+5] > low[n]) and (low[n+4] == low[n]) and (low[n+3] >= low[n]) and (low[n+2] == low[n]) and (low[n+1] >= low[n]) and (low[n-1] > low[n]) and (low[n-2] > low[n]))
float upFracLine = 0.
float dnFracLine = 0.
upFracLine := upFractal ? high[2] : upFracLine[1]
dnFracLine := dnFractal ? low[2] : dnFracLine[1]
// MAD Fractals
bool dnStart = close[1] > nz(baseline[1]) and close < baseline
bool upStart = close[1] < nz(baseline[1]) and close > baseline
var int trendDir = 1
var int dirCount = 0
if trendDir == 1 and dnStart
trendDir := -1
dirCount := 0
if trendDir == -1 and upStart
trendDir := 1
dirCount := 0
dirCount := dirCount + 1
float median = ta.percentile_nearest_rank(ta.tr, i_madLen, 50)
float mad = ta.percentile_nearest_rank(math.abs(ta.tr - median), i_madLen, 50)
float threshold = median + mad * i_madDeviations
bool outlier = ta.tr >= threshold
bool upOutlierFrac = outlier[2] and upFractal and trendDir[2] == -1
bool dnOutlierFrac = outlier[2] and dnFractal and trendDir[2] == 1
float upMadFracLine = 0.
float dnMadFracLine = 0.
upMadFracLine := upOutlierFrac ? high[2] : high[2] > upMadFracLine[1] ? na : upMadFracLine[1]
dnMadFracLine := dnOutlierFrac ? low[2] : low[2] < dnMadFracLine[1] ? na : dnMadFracLine[1]
// ----------------------------------------------------------------------
// Plot
// ----------------------------------------------------------------------
plot(i_showRegFrac ? upFracLine : na, title = "Up Fractal Entry", color = color.new(color.lime, 50), linewidth = 1, style = plot.style_circles, offset = -2)
plot(i_showRegFrac ? dnFracLine : na, title = "Dn Fractal Entry", color = color.new(color.red, 50), linewidth = 1, style = plot.style_circles, offset = -2)
plot(upMadFracLine, title = "Up MAD Fractal", color = color.new(color.fuchsia, 50), linewidth = 2, style = plot.style_circles, offset = -2)
plot(dnMadFracLine, title = "Dn MAD Fractal", color = color.new(color.fuchsia, 50), linewidth = 2, style = plot.style_circles, offset = -2) |
Volume Weighted Exponential Moving Average | https://www.tradingview.com/script/lwfvDaTv-Volume-Weighted-Exponential-Moving-Average/ | ProfessorION | https://www.tradingview.com/u/ProfessorION/ | 27 | 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/
// © ProfessorION
// Most VWEMAs dont work on the higher timeframes, this one does. it
//@version=5
indicator("VWEMA with Timeframe", timeframe="", overlay=true)
length = input.int(50, minval=1, title="Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
volumePrice = volume * close
vwema = nz(ta.ema(volumePrice, length)/ ta.ema(volume, length))
plot(vwema)
|
Directional Index Macro Indicator | https://www.tradingview.com/script/S0YelAWa-Directional-Index-Macro-Indicator/ | jordanfray | https://www.tradingview.com/u/jordanfray/ | 103 | 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/
// © jordanfray
//@version=5
// About This Indicator
// The default settings for this indicator are for BTC/USDT and intended to be used on the 3D timeframe to identify market trends.
// This indicator does a great job identifying wether the market is bullish, bearish, or consolidating.
// This can also work well on lower timeframes to help identify when a trend is strong or when it's reversing.
indicator("Directional Index Macro Indicator", shorttitle="Directional Index")
import jordanfray/threengine_global_automation_library/65 as bot
// Colors - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
green = color.new(#2DBD85,0)
lightGreen = color.new(#2DBD85,50)
red = color.new(#E02A4A,0)
lightRed = color.new(#E02A4A,50)
yellow = color.new(#FFED00,0)
lightYellow = color.new(#FFED00,50)
purple = color.new(#5A00FF,0)
blue = color.new(#0C6090,0)
skyBlue = color.new(#00A5FF,0)
lightBlue = color.new(#00A5FF,80)
black = color.new(#000000,0)
// Tooltips
diDistanceRocLengthTip = "Core to this indicator is the rate at which DI+ and DI- are moving away or towards each other. This is called The Rate of Change (ROC)." + "\n \n"
+ "The ROC length dictates how many bars back you want to compare to the current bar to see how much it has changed." + "\n \n"
+ "It is calculated like this:" + "\n"
+ "(source - source[length]/source[length]) * 100" + "\n \n"
+ "This indicator has 4 values in the status line: " + "\n"
+ " 1: DI+" + "\n"
+ " 2: DI-" + "\n"
+ " 3: Distance between DI+ and DI-" + "\n"
+ " 4: DI Rate of Change" + "\n \n"
+ "Default: 1"
diDistanceRocEmaLengthTip = "The rate of change is smoothed using an EMA. A shorter EMA length will cause the ROC to flip back and forth between positive and negative while a larger EMA length will cause the ROC to change less often." + "\n \n"
+ "Since the rate of change is used to indicate periods of 'consolidation', you want to find a setting that doesn't flip back and forth too often." + "\n \n"
+ "Default: 5"
diMidlineChannelWidthTip = "Between the DI+ and DI- is a black centerline. Offset from this centerline is a channel that is used to filter out false crosses of the DI+ and DI-. "
+ "Sometimes, the DI+ and DI- lines will come together in this channel and cross momentarily before resuming the direction prior to the cross. "
+ "When this happens, you don't want to flip your bias too soon. The wider the channel, the later the indicator will signal a DI reversal. A narrower channel will call it sooner but risks being more choppy and indicating a false cross." + "\n \n"
+ "Default: 5"
// Indicator Settings
diLength = input.int(defval=23, minval=1, step=1, title="DI Length", group="Directional Index (DI)")
diDistanceRocLength = input.int(defval=1, title="DI Distance ROC Length", group="Directional Index (DI)", tooltip=diDistanceRocLengthTip)
diDistanceRocEmaLength = input.int(defval=5, title="DI Distance ROC Smoothing", group="Directional Index (DI)", tooltip=diDistanceRocEmaLengthTip)
diMidlineChannelWidth = input.float(defval=12, title="DI Midline Channel Width (%)", group="Directional Index (DI)", tooltip=diMidlineChannelWidthTip)
// Directional Index
TrueRange = math.max(math.max(high-low, math.abs(high-nz(close[1]))), math.abs(low-nz(close[1])))
DMPlus = high-nz(high[1]) > nz(low[1])-low ? math.max(high-nz(high[1]), 0): 0
DMMinus = nz(low[1])-low > high-nz(high[1]) ? math.max(nz(low[1])-low, 0): 0
SmoothedTR = 0.0
SmoothedTR := nz(SmoothedTR[1]) - (nz(SmoothedTR[1])/diLength) + TrueRange
SmoothedDMPlus = 0.0
SmoothedDMPlus := nz(SmoothedDMPlus[1]) - (nz(SmoothedDMPlus[1])/diLength) + DMPlus
SmoothedDMMinus = 0.0
SmoothedDMMinus := nz(SmoothedDMMinus[1]) - (nz(SmoothedDMMinus[1])/diLength) + DMMinus
diPlus = SmoothedDMPlus / SmoothedTR * 100
diMinus = SmoothedDMMinus / SmoothedTR * 100
distanceBetweenDi = (diPlus - diMinus) < 0 ? (diPlus - diMinus)*-1 : (diPlus - diMinus)
distanceBetweenDiRoc = bot.getRateOfChange(distanceBetweenDi, diDistanceRocLength)
distanceBetweenDiRocEma = bot.taGetEma("EMA", distanceBetweenDiRoc, diDistanceRocEmaLength)
diCenterLine = (diPlus + diMinus)/2
diCenterLineChannelTop = diCenterLine + (diCenterLine*(diMidlineChannelWidth/100))
diCenterLineChannelBottom = diCenterLine - (diCenterLine*(diMidlineChannelWidth/100))
bool diDistanceRocEmaTrendingDown = distanceBetweenDiRocEma < 0
bool diPlusAboveDiMinus = diPlus > diMinus
bool diPlusAboveCenterChannel = diPlus > diCenterLineChannelTop
bool diMinusAboveDiPlus = diMinus > diPlus
bool diMinusAboveCenterChannel = diMinus > diCenterLineChannelTop
bool bullMarket = diPlusAboveDiMinus
bool bearMarket = diMinusAboveDiPlus
bool bullishConsolidation = diPlusAboveDiMinus and diPlusAboveCenterChannel and diDistanceRocEmaTrendingDown
bool bearishConsolidation = diMinusAboveDiPlus and diPlusAboveCenterChannel and diDistanceRocEmaTrendingDown
var string macroMarketStatus = na
if diPlusAboveDiMinus and not bullishConsolidation and diPlusAboveCenterChannel
macroMarketStatus := "bullish"
else
if diMinusAboveDiPlus and not bearishConsolidation and diMinusAboveCenterChannel
macroMarketStatus := "bearish"
else
macroMarketStatus := "consolidating"
// Plots
diPlusPlot = plot(series=diPlus, title="DI+", color=green, linewidth=2, editable=false, display=display.pane + display.status_line)
diMinusPlot = plot(series=diMinus, title="DI-", color=red, linewidth=2, editable=false, display=display.pane + display.status_line)
diDistancePlot = plot(series=distanceBetweenDi, title="Distance Between DI", color=purple, editable=false, display=display.status_line)
diDistanceRocPlot = plot(series=distanceBetweenDiRocEma, title="DI Distance Rate of Change", color=purple, editable=false, display=display.status_line)
diCenterLineChannelTopPlot = plot(series=diCenterLineChannelTop, title="DI Center Channel Top", color=skyBlue, editable=false, display=display.pane)
diCenterLinePlot = plot(series=diCenterLine, title="DI Center Line", color=skyBlue, editable=false, linewidth=2, display=display.pane)
diCenterLineChannelBottomPlot = plot(series=diCenterLineChannelBottom, title="DI Center Channel Bottom", color=skyBlue, editable=false, display=display.pane)
plotshape(bullMarket, title="Bull Market Indicator", style=shape.triangleup, location=location.top, color=green, display=display.pane)
plotshape(bearMarket, title="Bear Market Indicator", style=shape.triangledown, location=location.top, color=red, display=display.pane)
bgcolor(macroMarketStatus == "bullish" ? lightGreen : macroMarketStatus == "bearish" ? lightRed : lightYellow, title="Background Colors (Market Status)")
fill(diCenterLineChannelTopPlot, diCenterLineChannelBottomPlot, title="DI Center Channel", color=lightBlue)
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.