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
|
---|---|---|---|---|---|---|---|---|
Adaptive-LB, Jurik-Filtered, Triangular MA w/ Price Zones [Loxx] | https://www.tradingview.com/script/cFUGyGBx-Adaptive-LB-Jurik-Filtered-Triangular-MA-w-Price-Zones-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 76 | 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("Adaptive-LB, Jurik-Filtered, Triangular MA w/ Price Zones [Loxx]",
shorttitle="ALBJFTMAPZ [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxjuriktools/1
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_albper(swingCount, speed)=>
swing = 0.
if bar_index > 3
if (high > nz(high[1]) and
nz(high[1]) > nz(high[2]) and
nz(low[2]) < nz(low[3]) and
nz(low[3]) < nz(low[4]))
swing := -1
if (low < nz(low[1]) and
nz(low[1]) < nz(low[2]) and
nz(high[2]) > nz(high[3]) and
nz(high[3]) > nz(high[4]))
swing := 1
swingBuffer = swing
k = 0, n = 0
while (k < bar_index) and (n < swingCount)
if(swingBuffer[k] != 0)
n += 1
k += 1
albPeriod = math.max(math.round((speed != 0 and swingCount != 0) ? k/swingCount/speed : k/swingCount), 1)
albPeriod
_calcrng(per)=>
lsum = (per + 1) * low
hsum = (per + 1) * high
sumw = (per + 1)
k = per
for j = 1 to per
lsum += k * nz(low[j])
hsum += k * nz(high[j])
sumw += k
k -= 1
out = (hsum / sumw - lsum / sumw)
out
src = input.source(hl2, "Source", group= "Source Settings")
swingCount = input.int(15, "ALB Swing Count", group = "Adaptive Lookback Settings")
speed = input.float(.5, "ALB Speed", minval = 0., step = 0.01, group = "Adaptive Lookback Settings")
smthper = input.int(30, "Jurik Smoothing Period", group = "Jurik Settings")
smthphs = input.float(0., "Jurik Smoothing Phase", group = "Jurik Settings")
rngper = input.int(5, "Range Period", group = "Price Zone Settings")
dev = input.float(1.8, "Deviation", group = "Price Zone Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = input.bool(true, "Show signals?", group = "UI Options")
alb = _albper(swingCount, speed)
sum = (alb + 1) * src
sumw = (alb + 1)
k = alb
for j = 1 to alb
sum += k * nz(src[j])
sumw += k
k -= 1
tma = loxxjuriktools.jurik_filt(sum / sumw, smthper, smthphs)
sig = tma[1]
rng = _calcrng(rngper)
uplvl = tma + dev * rng
dnlvl = tma - dev * rng
colorout = tma > sig ? greencolor : redcolor
plot(tma, "TMA", color = colorout, linewidth = 4)
plot(uplvl, "Upper Channel", color = color.gray, linewidth = 1)
plot(dnlvl, "Lower Channel", color = color.gray, linewidth = 1)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(tma, sig)
goShort = ta.crossunder(tma, sig)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goLong, title="Long", message="Adaptive-LB, Jurik-Filtered, Triangular MA w/ Price Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Adaptive-LB, Jurik-Filtered, Triangular MA w/ Price Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Contraction Levels | https://www.tradingview.com/script/Yie1XfH9-Contraction-Levels/ | efe_akm | https://www.tradingview.com/u/efe_akm/ | 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/
// © xobiccc
//@version=5
indicator("Contraction Levels", overlay = true)
// user inputs
size = input.int(title = "Number of Contractions", defval = 5, step = 1, maxval = 10)
tolerance = input.float(title = "Tolerance for the Contraction Candles", defval = 0.001, step = 0.001, maxval = 0.1)
percent_x = input.int(title = "Contraction Level Percentage", defval = 50, step = 1, maxval = 100, minval = 0)
percent_filter = input.int(title = "Filter Level Percentage", defval = 10, step = 1, maxval = 100, minval = 0)
show_contraction_candles = input.bool(title = "Show Contraction Candles", defval = true)
show_center_line = input.bool(title = "Show Center Lines", defval = true)
show_filter_line = input.bool(title = "Show Filter Lines", defval = true)
contraction_alert = input.bool(title = "Alert on New Contraction Bar", defval = true)
bullish_alert = input.bool(title = "Alert on New Bullish Break", defval = true)
bearish_alert = input.bool(title = "Alert on New Bearish Break", defval = true)
center_line_alert = input.bool(title = "Alert on Crossing a Centerline", defval = true)
up_filter_line_alert = input.bool(title = "Alert on Crossing a Upper Filter Line", defval = true)
dn_filter_line_alert = input.bool(title = "Alert on Crossing a Lower Filter Line", defval = true)
bullish_color = input.color(title = "Bullish Contraction Color", defval = color.green)
neutral_color = input.color(title = "New Contraction Color", defval = color.blue)
bearish_color = input.color(title = "Bearish Contraction Color", defval = color.red)
contraction_candle_color = input.color(title = "Contraction Candle Color", defval = color.blue)
// Variables
var float[] upper_threshold = array.new_float(size, 99999999.0)
var float[] lower_threshold = array.new_float(size, 0.0)
var float[] line_x_loc = array.new_float(size, 0.0)
var float[] upper_filter = array.new_float(size, 0.0)
var float[] lower_filter = array.new_float(size, 0.0)
var int[] bar_indexx = array.new_int(size,0)
var color[] line_colors = array.new_color(size, bullish_color)
//Update line colors
for i = 0 to size -1
if array.get(line_colors,i) == neutral_color
if close > array.get(upper_threshold,i) // bullish breakout
array.set(line_colors, i, bullish_color)
if bullish_alert
alert("New Bullish Breakout")
if close < array.get(lower_threshold,i) // bearish breakout
array.set(line_colors, i, bearish_color)
if bearish_alert
alert("New Bearish Breakout")
// Contraction Bar bullish or bearish
bullish_contr = close[1] > open[1] // bullish contr bar
upp = bullish_contr ? close[1] : open[1]
loww = bullish_contr? open[1] : close[1]
up_wick = bullish_contr ? high[1] - close[1] : high[1] - open[1]
dn_wick = bullish_contr ? open[1] - low[1] : close[1] - low[1]
body_range = math.abs(close[1] - open[1])
// Contraction Bar Conditions
c_1 = close[2] >= loww * (1-tolerance)
c_2 = close[2] <= upp * (1+tolerance)
c_3 = open[2] >= loww * (1-tolerance)
c_4 = open[2] <= upp * (1+tolerance)
c_5 = close >= loww * (1-tolerance)
c_6 = close <= upp * (1+tolerance)
c_7 = open >= loww * (1-tolerance)
c_8 = open <= upp * (1+tolerance)
c_9 = body_range > up_wick
c_10 = body_range > dn_wick
c_all = c_1 and c_2 and c_3 and c_4 and c_5 and c_6 and c_7 and c_8 and c_9 and c_10 and barstate.isconfirmed
color bar_color = na
if show_contraction_candles
bar_color := c_all ? contraction_candle_color : na
// Add new contraction bar to the array and delete the oldest one
if c_all
if contraction_alert
alert("New Contraction Candle")
// Get 3 bars high/low
bars_high = math.max(high[2],high[1],high )
bars_low = math.min(low[2],low[1],low )
line_level = ( body_range * percent_x / 100 ) + math.min(close[1], open[1] )
// Add line properties to arrays
array.unshift(upper_threshold, bars_high)
array.unshift(lower_threshold, bars_low)
array.unshift(line_x_loc, line_level)
array.unshift(upper_filter, line_level + (body_range * percent_filter / 100))
array.unshift(lower_filter, line_level - (body_range * percent_filter / 100))
array.unshift(bar_indexx, bar_index - 1)
array.unshift(line_colors, neutral_color)
array.pop(upper_threshold)
array.pop(lower_threshold)
array.pop(line_x_loc)
array.pop(upper_filter)
array.pop(lower_filter)
array.pop(bar_indexx)
array.pop(line_colors)
barcolor(bar_color, offset = 0)
barcolor(bar_color, offset = -1)
barcolor(bar_color, offset = -2)
if barstate.islast
for i = 0 to size-1
if show_center_line
line.new(array.get(bar_indexx,i) , array.get(line_x_loc,i), last_bar_index, array.get(line_x_loc,i), color = array.get(line_colors,i), width = 2)
if show_filter_line
line.new(array.get(bar_indexx,i) , array.get(upper_filter,i), last_bar_index, array.get(upper_filter,i), color = array.get(line_colors,i), style = line.style_dashed)
line.new(array.get(bar_indexx,i) , array.get(lower_filter,i), last_bar_index, array.get(lower_filter,i), color = array.get(line_colors,i), style = line.style_dashed)
// ALERTS
if center_line_alert and ta.cross(close, array.get(line_x_loc,i))
alert(message = "Center Line Cross at " + str.tostring(array.get(line_x_loc,i)) )
if up_filter_line_alert and ta.cross(close, array.get(upper_filter,i))
alert("Upper Filter Line Cross at " + str.tostring(array.get(upper_filter,i)) )
if dn_filter_line_alert and ta.cross(close, array.get(lower_filter,i))
alert("Lower Filter Line Cross at " + str.tostring(array.get(lower_filter,i)) ) |
TF Segmented Polynomial Regression [LuxAlgo] | https://www.tradingview.com/script/WtgiwXjO-TF-Segmented-Polynomial-Regression-LuxAlgo/ | LuxAlgo | https://www.tradingview.com/u/LuxAlgo/ | 2,145 | 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/
// © LuxAlgo
//@version=5
indicator("TF Segmented Polynomial Regression [LuxAlgo]"
, "Segmented PolyReg [LuxAlgo]"
, overlay = true)
//-----------------------------------------------------------------------------}
//Settings
//-----------------------------------------------------------------------------{
degree = input.int(3, "Polynomial Degree"
, minval = 0
, maxval = 10)
mult = input.float(2., "Width"
, minval = 0)
tf = input.timeframe("1D", "Timeframe")
show = input(false, "Show fit for new bars")
src = input(close)
//-----------------------------------------------------------------------------}
//Define variables
//-----------------------------------------------------------------------------{
var coefficients = matrix.new<float>(degree + 1, 1)
var b = matrix.new<float>(0, 0)
var float out = na
var sse = 0.
var k = 0.
n = bar_index
dt = timeframe.change(tf)
//-----------------------------------------------------------------------------}
//Request future prices
//-----------------------------------------------------------------------------{
y = request.security(syminfo.tickerid
, tf
, request.security_lower_tf(syminfo.tickerid, timeframe.period, src)
, lookahead = barmerge.lookahead_on)
K = array.size(y)
//-----------------------------------------------------------------------------}
//Compute polynomial regression point and intervals
//-----------------------------------------------------------------------------{
//Solve system
if dt and K > 1
design = matrix.new<float>(0, 0)
response = matrix.new<float>(0, 0)
for i = 0 to degree
column = array.new_float(0)
for j = 0 to K - 1
array.push(column, math.pow(j,i))
matrix.add_col(design, i, column)
a = matrix.inv(matrix.mult(matrix.transpose(design), design))
b := matrix.mult(a, matrix.transpose(design))
matrix.add_col(response, 0, y)
coefficients := matrix.mult(b, response)
sse := 0
for i = 0 to K - 1
y_ = 0.
for j = 0 to degree
y_ += math.pow(i, j)*matrix.get(coefficients, j, 0)
sse += math.pow(array.get(y, i) - y_, 2)
sse := math.sqrt(sse / (K - 1)) * mult
k := 0
//Compute best fit and upper/lower intervals
reg = 0.
for i = 0 to degree
reg += math.pow(k, i)*matrix.get(coefficients, i, 0)
if barstate.isrealtime
if show
out := reg
else
out := reg
upper = out + sse
lower = out - sse
k += 1
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------{
css = dt ? na : out > out[1] ? #0cb51a : #ff1100
plot_0 = plot(upper, "Upper"
, color = color.new(#2157f3, 100))
plot(out, "PolyReg"
, color = css)
plot_1 = plot(lower, "Lower"
, color = color.new(#ff1100, 100))
fill(plot_0, plot_1
, dt ? na : color.new(#2157f3, 80)
, "Interval Fill")
//-----------------------------------------------------------------------------} |
Future Risk Calculator | https://www.tradingview.com/script/Knjspmi7-Future-Risk-Calculator/ | irchamaji | https://www.tradingview.com/u/irchamaji/ | 503 | 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/
// © irchamaji
//@version=5
indicator("Future Risk Calculator", "Risk Calc", overlay=true)
balance = input.float(defval=1000.00, title="Balance ($)", group="Your Account")
leverage = input.int(defval=125, title="Leverage (x)", group="Your Account")
// direction = input.string(defval="LONG", options=["LONG","SHORT"], title="Direction", group="Your Trade")
entry_price = math.round_to_mintick(input.price(defval=21000, title="Entry Price ==", group="Your Trade"))
// float _price = switch entry_price
// "Last Bar Close" => close
// "Last Bar High" => low
tp_price = math.round_to_mintick(input.price(defval=22000, title="Target Price ++", group="Your Trade"))
sl_price = math.round_to_mintick(input.price(defval=20500, title="Stop Loss Price --", group="Your Trade"))
direction = tp_price>sl_price? entry_price>tp_price?"SETUP ERROR":entry_price<sl_price?"SETUP ERROR": "LONG" : entry_price<tp_price?"SETUP ERROR":entry_price>sl_price?"SETUP ERROR": "SHORT"
max_loss_percentage = input.float(defval=2, options=[0.25,0.5,0.75, 1, 2, 3, 5], title="Max Loss Risk (%)", group="Risk Management")
/// CALCULATION
max_loss_qty_usd = max_loss_percentage/100 * balance
initial_qty_coin = math.abs(max_loss_qty_usd/(sl_price-entry_price))
initial_qty_usd = initial_qty_coin*entry_price/leverage
margin_percentage = initial_qty_usd/balance*100
tp_price_percent = math.abs((tp_price-entry_price)*100/entry_price)
profit_usd = math.abs((tp_price*initial_qty_coin)-(entry_price*initial_qty_coin))
profit_roe = profit_usd/initial_qty_usd*100
sl_price_percent = math.abs((sl_price-entry_price)*100/entry_price)
loss_usd = math.abs((sl_price*initial_qty_coin)-(entry_price*initial_qty_coin))
loss_roe = loss_usd/initial_qty_usd*100
rr_ratio = profit_usd/loss_usd
rr_ratio_ideal = rr_ratio >= 2 ? direction == "SETUP ERROR" ? "SETUP ERROR": "IDEAL" : "NOT IDEAL"
tp_text = "Target: " + str.tostring(tp_price) +" (" + str.tostring(tp_price_percent, '#.##') +"%), ROE: " + str.tostring(profit_roe,'#.##') + "%"
entry_text = "Entry: " + str.tostring(entry_price)+ ", RR Ratio: " + str.tostring(rr_ratio,'#.##') + " ["+ rr_ratio_ideal+"]"
sl_text = "Stop: " + str.tostring(sl_price) +" (" + str.tostring(sl_price_percent, '#.##') +"%), ROE: " + str.tostring(loss_roe,'#.##') + "%"
if barstate.islastconfirmedhistory
table_detail = table.new(position.top_right,columns=2, rows=15,bgcolor=color.new(color.yellow,20),frame_color=color.blue,frame_width=3)//,border_color=color.blue,border_width=2)
table.merge_cells(table_detail, start_column=0, start_row=0, end_column=1, end_row=0)
table.cell(table_detail, column=0, row=0, text="Risk Calculation")
table.cell(table_detail,text_halign=text.align_left, column=0, row=1, text="Balance:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=1, text="$"+str.tostring(balance))
table.cell(table_detail,text_halign=text.align_left, column=0, row=2, text="Leverage:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=2, text=str.tostring(leverage)+"x")
table.cell(table_detail,text_halign=text.align_left, column=0, row=3, text="Direction:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=3, text=direction)
table.cell(table_detail,text_halign=text.align_left, column=0, row=4, text="Risk:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=4, text=str.tostring(max_loss_percentage)+"%")
table.cell(table_detail,text_halign=text.align_left, column=0, row=5, text="")
table.cell(table_detail,text_halign=text.align_left, column=1, row=5, text="")
table.cell(table_detail,text_halign=text.align_left, column=0, row=6, text="Quantity:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=6, text=str.tostring(initial_qty_coin,'#.###') + " coins")
table.cell(table_detail,text_halign=text.align_left, column=0, row=7, text="Initial Margin:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=7, text=direction == "SETUP ERROR" ? "SETUP ERROR":"$" + str.tostring(initial_qty_usd, '#.##') + " (" + str.tostring(margin_percentage,'#.##') + "%)")
table.cell(table_detail,text_halign=text.align_left, column=0, row=8, text="Potential Profit:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=8, text=direction == "SETUP ERROR" ? "SETUP ERROR":"$"+str.tostring(profit_usd, '#.##') + " ("+ str.tostring(profit_roe,'#.##') +"%)")
table.cell(table_detail,text_halign=text.align_left, column=0, row=9, text="Potential Loss:")
table.cell(table_detail,text_halign=text.align_left, column=1, row=9, text=direction == "SETUP ERROR" ? "SETUP ERROR":"$"+str.tostring(loss_usd, '#.##') + " ("+ str.tostring(loss_roe,'#.##') +"%)")
profit_box = box.new(bar_index[20], tp_price, bar_index + 30, entry_price)
box.set_bgcolor(profit_box, color.new(color.green, 90))
box.set_border_width(profit_box, 0)
loss_box = box.new(bar_index[20], sl_price, bar_index + 30, entry_price)
box.set_bgcolor(loss_box, color.new(color.red, 90))
box.set_border_width(loss_box, 0)
entry_line = line.new(bar_index[20], entry_price, bar_index + 30, entry_price)
line.set_width(entry_line,2)
line.set_color(entry_line,color.blue)
tp_line = line.new(bar_index[20], tp_price, bar_index + 30, tp_price)
line.set_width(tp_line,2)
line.set_color(tp_line,color.green)
sl_line = line.new(bar_index[20], sl_price, bar_index + 30, sl_price)
line.set_width(sl_line,2)
line.set_color(sl_line,color.red)
tp_label = label.new(bar_index+30, tp_price, text=tp_text)
label.set_style(tp_label,label.style_label_left)
label.set_color(tp_label, color.teal)
label.set_textcolor(tp_label, color.white)
entry_label = label.new(bar_index+30, entry_price, text=entry_text)
label.set_style(entry_label,label.style_label_left)
label.set_color(entry_label, rr_ratio >= 2 ? direction == "SETUP ERROR" ? color.red : color.teal : color.red)
label.set_textcolor(entry_label, color.white)
sl_label = label.new(bar_index+30, sl_price, text=sl_text)
label.set_style(sl_label,label.style_label_left)
label.set_color(sl_label, color.teal)
label.set_textcolor(sl_label, color.white)
|
Adaptive-Lookback CCI w/ Double Juirk Smoothing [Loxx] | https://www.tradingview.com/script/cRm4hhw7-Adaptive-Lookback-CCI-w-Double-Juirk-Smoothing-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 55 | 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("Adaptive-Lookback CCI w/ Double Juirk Smoothing [Loxx]",
overlay = false,
shorttitle='ALBCCIDJS [Loxx]',
timeframe="",
timeframe_gaps=true)
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crosses'
SM04 = 'Levels Crosses'
_albper(swingCount, speed)=>
swing = 0.
if bar_index > 3
if (high > nz(high[1]) and
nz(high[1]) > nz(high[2]) and
nz(low[2]) < nz(low[3]) and
nz(low[3]) < nz(low[4]))
swing := -1
if (low < nz(low[1]) and
nz(low[1]) < nz(low[2]) and
nz(high[2]) > nz(high[3]) and
nz(high[3]) > nz(high[4]))
swing := 1
swingBuffer = swing
k = 0, n = 0
while (k < bar_index) and (n < swingCount)
if(swingBuffer[k] != 0)
n += 1
k += 1
albPeriod = math.max(math.round((speed != 0 and swingCount != 0) ? k/swingCount/speed : k/swingCount), 1)
albPeriod
src = input.source(hlc3, "CCI Source", group = "Basic Settings")
jper = input.int(14, "Jurik Smoothing Period", group = "Basic Settings")
jphs = input.float(0., "Jurik Smoothing Phase", group = "Basic Settings")
swingCount = input.int(15, "ALB Swing Count", group = "Adaptive Lookback Settings")
speed = input.float(.5, "ALB Speed", minval = 0., step = 0.01, group = "Adaptive Lookback Settings")
lvlup = input.int(100, "Upper Level", group = "Levels Settings")
lvldn = input.int(-100, "Bottom Level", group = "Levels Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showSigs = input.bool(true, "Show signals?", group= "UI Options")
albper = _albper(swingCount, speed)
avg = 0.
for k = 0 to albper - 1
avg += nz(src[k])
avg /= albper
dev = 0.
for k = 0 to albper
dev += math.abs(nz(src[k]) - avg)
dev /= albper
cci = 0.
if (dev != 0)
cci := (src - avg) / (0.015 * dev)
else
cci := 0.
cci := loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(cci, albper, jphs), albper, jphs)
sigval = cci[1]
mid = 0.
state = 0.
if sigtype == SM02
if (cci < sigval)
state :=-1
if (cci > sigval)
state := 1
else if sigtype == SM03
if (cci < mid)
state :=-1
if (cci > mid)
state := 1
else if sigtype == SM04
if (cci < lvldn)
state := -1
if (cci > lvlup)
state := 1
colorout = state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(cci, "CCI", color = colorout, linewidth = 3)
plot(lvlup, "Overbought", color = bar_index % 2 ? color.gray : na)
plot(lvldn, "Oversold", color = bar_index % 2 ? color.gray : na)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout: na)
goLong = sigtype == SM02 ? ta.crossover(cci, sigval) : sigtype == SM03 ? ta.crossover(cci, mid) : ta.crossover(cci, lvlup)
goShort = sigtype == SM02 ? ta.crossunder(cci, sigval) : sigtype == SM03 ? ta.crossunder(cci, mid) : ta.crossunder(cci, lvldn)
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="Adaptive-Lookback CCI w/ Double Juirk Smoothing [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Adaptive-Lookback CCI w/ Double Juirk Smoothing [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
RedK Chop & Breakout Scout (C&B_Scout) | https://www.tradingview.com/script/jnWK8gZg-RedK-Chop-Breakout-Scout-C-B-Scout/ | RedKTrader | https://www.tradingview.com/u/RedKTrader/ | 753 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader
//@version=5
indicator('RedK Chop & Breakout Scout ', shorttitle='C&B_Scout v2.0', overlay = false, explicit_plot_zorder = true, timeframe='', timeframe_gaps=false)
// plots a centered oscillator based on how many ATR units the source price is from a price baseline (could be a Donchian midline or another slow MA)
// the Chop Zone is detected when the price is within a customizable ATR-based distance above or below the baseline
// a filter is then applied (using EMA - but can be other types of long-term MA) to indicate the preferred trade direction (long vs. short)
// when the CBS line is inside the chop zone, trading is not recommended for the conservative trader
// Breakouts are found when the CBS line exits the Chop zone (in agreement with the filter direction)
// An aggressive swing trader can consider positions when the CBS line crosses the 0 line in the filter direction
// =================================================================================================
// ATR Calclatioin Function
// =================================================================================================
ATR_Calc(_price, _length, _atrcalc) =>
switch _atrcalc
"RMA" => ta.rma(_price, _length)
"SMA" => ta.sma(_price, _length)
"EMA" => ta.ema(_price, _length)
=> ta.wma(_price, _length)
// =================================================================================================
// Inputs
// =================================================================================================
Src = input.source(close, title = 'Price')
Length = input.int(10, title = 'Baseline Length', minval = 1)
AtrLength = input.int(10, title = 'TR Avg Length', minval = 1)
ATRCalc = input.string('RMA', title = 'ATR Calculation', options = ["RMA", "SMA", "EMA", "WMA"])
slevel = input.float(0.5, title = 'Chop Level', step = 0.05)
smooth = input.int(3, title = 'Smooth', minval = 1)
Filter = input.int(20, title = 'EMA Filter', minval = 1)
// =================================================================================================
// Calculations
// =================================================================================================
//calculate baseline price -- for v1.0, we'll use a Donchain midline - can add other slow MA's in future
baseline = (ta.highest(Length) + ta.lowest(Length))/2
// Calculate ATR
ATR = ATR_Calc(ta.tr(true), Length, ATRCalc)
// CBS value is basically how far is current price from the baseline in terms of "ATR units"
cbs = (Src - baseline)/ATR
scbs = ta.wma(cbs, smooth)
// check where is price wrt the filter line to determine recommended trading direction
// in v1, we use an EMA-based filter as it's most popular -- may add other MA types in future.
f_modelong = Src > ta.ema(Src, Filter)
// =================================================================================================
// Plots
// =================================================================================================
hline(0, title = 'Zero Line', color = color.blue, linestyle = hline.style_solid)
h0 = hline(slevel, "Chop Zone - Upper", color=#787B86, display=display.none)
h1 = hline(-slevel, "Chop Zone - Lower", color=#787B86, display=display.none)
c_modelong = color.new(#1b5e20, 50)
c_modeshort = color.new(#981919, 50)
FillColor = f_modelong ? c_modelong : c_modeshort
fill(h0, h1, color = FillColor, title = "Background")
// Dynamic coloring of CBS line
c_cbslong = color.new(#11ff20, 60)
c_cbsshort = color.new(#ff1111, 60)
c_cbs_chop = color.new(#ffee58, 50)
// the coloring condition is based on the "CBS_Raw" value to give earliest signal regarding of smoothing
cbs_color = f_modelong and cbs > slevel ? c_cbslong :
not(f_modelong) and cbs < -slevel ? c_cbsshort :
c_cbs_chop
plot(cbs, title = "CBS Raw", display = display.none)
// avoid dublicating the CBS "cloud" value on the status line - by default the cloud is hidden - not sure how many would visually prefer a cloud vs a line.
showcloud = input.bool(false, "Show CBS Cloud?")
plot(showcloud ? scbs : na, title = "CBS Cloud", color = cbs_color,
style = plot.style_area, display = not(showcloud) ? display.none : (display.all - display.status_line))
plot(scbs, title = "CBS Line", color = cbs_color, linewidth = 3)
// =================================================================================================
// Alerts
// =================================================================================================
// These alerts will only trigger if a breakout to the upside happens in long mode (price above filterline)
// or a breakout to the downside happens in short mode (price below filterline)
// to avoid whipsaws, we can apply smoothing to the price crossing the filter - which will reduce false alerts in volatile conditions
// Thought of adding an alert when price comes back into Chop Zone.. then thought it would be too much distraction.. Feedback ?
alert_up = f_modelong and ta.crossover(cbs, slevel)
alert_dn = not(f_modelong) and ta.crossunder(cbs, -slevel)
alertcondition(alert_up, "CBS Breaking Up", "Break Up in Long Mode Detected!")
alertcondition(alert_dn, "CBS Breaking Down", "Break Down in Short Mode Detected!")
|
CDC ActionZone BF for ETHUSD-1D | https://www.tradingview.com/script/sVJnB2w6-CDC-ActionZone-BF-for-ETHUSD-1D/ | ProskynetExtremeEdition | https://www.tradingview.com/u/ProskynetExtremeEdition/ | 32 | 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/
// @version=4
// © PRoSkYNeT-EE
// Based on improvements from "Kitti-Playbook Action Zone V.4.2.0.3 for Stock Market"
// Based on improvements from "CDC Action Zone V3 2020 by piriya33"
// Based on Triple MACD crossover between 9/15, 21/28, 15/28 for filter error signal (noise) from CDC ActionZone V3
// MACDs generated from the execution of millions of times in the "Brute Force Algorithm" to backtest data from the past 5 years. ( 2017-08-21 to 2022-08-01 )
// Released 2022-08-01
// ***** The indicator is used in the ETHUSD 1 Day period ONLY *****
// Recommended Stop Loss : -4 % (execute stop Loss after candlestick has been closed)
// Backtest Result ( Start $100 )
// Winrate 63 % (Win:12, Loss:7, Total:19)
// Live Days 1,806 days
// B : Buy
// S : Sell
// SL : Stop Loss
// 2022-07-19 07 - 1,542 : B 6.971 ETH
// 2022-04-13 07 - 3,118 : S 8.98 % $10,750 12,7,19 63 %
// 2022-03-20 07 - 2,861 : B 3.448 ETH
// 2021-12-03 07 - 4,216 : SL -8.94 % $9,864 11,7,18 61 %
// 2021-11-30 07 - 4,630 : B 2.340 ETH
// 2021-11-18 07 - 3,997 : S 13.71 % $10,832 11,6,17 65 %
// 2021-10-05 07 - 3,515 : B 2.710 ETH
// 2021-09-20 07 - 2,977 : S 29.38 % $9,526 10,6,16 63 %
// 2021-07-28 07 - 2,301 : B 3.200 ETH
// 2021-05-20 07 - 2,769 : S 50.49 % $7,363 9,6,15 60 %
// 2021-03-30 07 - 1,840 : B 2.659 ETH
// 2021-03-22 07 - 1,681 : SL -8.29 % $4,893 8,6,14 57 %
// 2021-03-08 07 - 1,833 : B 2.911 ETH
// 2021-02-26 07 - 1,445 : S 279.27 % $5,335 8,5,13 62 %
// 2020-10-13 07 - 381 : B 3.692 ETH
// 2020-09-05 07 - 335 : S 38.43 % $1,407 7,5,12 58 %
// 2020-07-06 07 - 242 : B 4.199 ETH
// 2020-06-27 07 - 221 : S 28.49 % $1,016 6,5,11 55 %
// 2020-04-16 07 - 172 : B 4.598 ETH
// 2020-02-29 07 - 217 : S 47.62 % $791 5,5,10 50 %
// 2020-01-12 07 - 147 : B 3.644 ETH
// 2019-11-18 07 - 178 : S -2.73 % $536 4,5,9 44 %
// 2019-11-01 07 - 183 : B 3.010 ETH
// 2019-09-23 07 - 201 : SL -4.29 % $551 4,4,8 50 %
// 2019-09-18 07 - 210 : B 2.740 ETH
// 2019-07-12 07 - 275 : S 63.69 % $575 4,3,7 57 %
// 2019-05-03 07 - 168 : B 2.093 ETH
// 2019-04-28 07 - 158 : S 29.51 % $352 3,3,6 50 %
// 2019-02-15 07 - 122 : B 2.225 ETH
// 2019-01-10 07 - 125 : SL -6.02 % $271 2,3,5 40 %
// 2018-12-29 07 - 133 : B 2.172 ETH
// 2018-05-22 07 - 641 : S 5.95 % $289 2,2,4 50 %
// 2018-04-21 07 - 605 : B 0.451 ETH
// 2018-02-02 07 - 922 : S 197.42 % $273 1,2,3 33 %
// 2017-11-11 07 - 310 : B 0.296 ETH
// 2017-10-09 07 - 297 : SL -4.50 % $92 0,2,2 0 %
// 2017-10-07 07 - 311 : B 0.309 ETH
// 2017-08-22 07 - 310 : SL -4.02 % $96 0,1,1 0 %
// 2017-08-21 07 - 323 : B 0.310 ETH
//****************************************************************************//
study("AGS ActionZone BF for ETHUSD-1D", overlay=true, precision=6)
//****************************************************************************//
// Define User Input Variables
xSource = input(title="Source Data",type=input.source, defval=close)
FMAp1 = input(title="Fast EMA period 1", type=input.integer, defval=9)
FMAp2 = input(title="Slow EMA period 2", type=input.integer, defval=15)
FMAp3 = input(title="Fast EMA period 3", type=input.integer, defval=21)
FMAp4 = input(title="Slow EMA period 4", type=input.integer, defval=15)
FMAp5 = input(title="Fast EMA period 5", type=input.integer, defval=28)
xSmooth = input(title="Smoothing period", type=input.integer, defval=1)
xFixTF = input(title="** Fixed Time Frame", type=input.bool, defval=false)
xTF = input(title="** Fix to time frame)", type=input.resolution, defval="D")
//****************************************************************************//
//Calculate Indicators
xPrice = ema(xSource,xSmooth)
yTF = xTF == "" ? timeframe.period : xTF
FMAi1 = xFixTF ? ema(security(syminfo.tickerid,yTF,ema(xSource,FMAp1)),xSmooth):ema(xPrice,FMAp1)
FMAi2 = xFixTF ? ema(security(syminfo.tickerid,yTF,ema(xSource,FMAp2)),xSmooth):ema(xPrice,FMAp2)
FMAi3 = xFixTF ? ema(security(syminfo.tickerid,yTF,ema(xSource,FMAp3)),xSmooth):ema(xPrice,FMAp3)
FMAi4 = xFixTF ? ema(security(syminfo.tickerid,yTF,ema(xSource,FMAp4)),xSmooth):ema(xPrice,FMAp4)
FMAi5 = xFixTF ? ema(security(syminfo.tickerid,yTF,ema(xSource,FMAp5)),xSmooth):ema(xPrice,FMAp5)
Bull = FMAi1 > FMAi3 and FMAi4 > FMAi5 and FMAi2 > FMAi5
Bear = FMAi1 < FMAi3 and FMAi4 < FMAi5
//****************************************************************************//
// Define Color Zones
Green = Bull // Buy
Blue = Bear and xPrice>FMAi1 and xPrice>FMAi2 //Pre Buy 2
LBlue = Bear and xPrice>FMAi1 and xPrice<FMAi2 //Pre Buy 1
Red = Bear // Sell
Orange = Bull and xPrice < FMAi1 and xPrice < FMAi2 // Pre Sell 2
Yellow = Bull and xPrice < FMAi1 and xPrice > FMAi2 // Pre Sell 1
//****************************************************************************//
// Display color on chart
fillSW = input(title="Fill Bar Colors", type=input.bool, defval=true)
bColor = Green ? color.rgb(103, 204, 58) :
Blue ? color.rgb(255, 209, 66) :
LBlue ? color.rgb(255, 209, 66) :
Red ? color.rgb(247, 75, 75) :
Orange ? color.rgb(255, 209, 66) :
Yellow ? color.rgb(255, 209, 66) :
color.black
barcolor(color=fillSW? bColor : na)
//****************************************************************************//
// Display MA lines
fastSW3 = input(title="1 Fast MA On/Off", type=input.bool, defval=true)
slowSW9 = input(title="2 Slow MA On/Off", type=input.bool, defval=true)
FastL3 = plot(fastSW3 ? FMAi1 : na,"FMAp1",color=color.rgb(247, 75, 75))
SlowL9 = plot(slowSW9 ? FMAi2 : na,"FMAp3",color=color.gray)
fastSW12 = input(title="4 Fast MA On/Off", type=input.bool, defval=true)
slowSW26 = input(title="5 Slow MA On/Off", type=input.bool, defval=true)
FastL12 = plot(fastSW12 ? FMAi4 : na,"FMAp4",color=color.yellow)
SlowL26 = plot(slowSW26 ? FMAi5 : na,"FMAp5",color=color.gray)
fastSW9 = input(title="3 Fast MA On/Off", type=input.bool, defval=true)
FastL9 = plot(fastSW9 ? FMAi2 : na,"FMAp2",color=color.gray)
FillColor = Bull ? color.green : Bear ? color.red : color.black
fill(FastL3,SlowL9,FillColor)
fill(FastL12,SlowL26,FillColor)
fill(FastL9,SlowL26,FillColor)
//****************************************************************************//
// Define Buy and Sell condition
// This is only for the basic usage of CDC Actionzone (EMA Crossover)
// ie. Buy on first green bar and sell on first red bar
BuyCond = Green and Green[1]==0
SellCond = Red and Red[1]==0
Bullish = barssince(BuyCond) < barssince(SellCond)
Bearish = barssince(SellCond) < barssince(BuyCond)
buy= Bearish[1] and BuyCond
sell= Bullish[1] and SellCond
//****************************************************************************//
// Plot Buy and Sell point on chart
plotshape(buy, style=shape.circle,
title = "Buy Signal",
location = location.belowbar,
color = color.rgb(103, 204, 58))
plotshape(sell, style=shape.circle,
title = "Sell Signal",
location=location.abovebar,
color = color.rgb(247, 75, 75))
// Alert conditions
alertcondition(buy,
title="Buy Alert",
message= "Buy {{exchange}}:{{ticker}}")
alertcondition(sell,
title="Sell Alert",
message= "Sell {{exchange}}:{{ticker}}")
//****************************************************************************// |
Digital Kahler MACD [Loxx] | https://www.tradingview.com/script/Nb0MMGqd-Digital-Kahler-MACD-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 50 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Digital Kahler MACD [Loxx]",
shorttitle='DKMACD [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
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)"])
mkperiod = input.int(14, "Kahler Smooothing Period", group = "MACD Settings")
mfperiod = input.int(12, "MACD Fast Period", group = "MACD Settings")
msperiod = input.int(26, "MACD Slow Period", group = "MACD Settings")
type = input.string("Exponential Moving Average - EMA", "Fast 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 = "Signal Settings")
mtperiod = input.int(9, "Signal Period", group = "Signal Settings")
fastr = input.int(8, "Fast Ratio", group = "Signal Settings")
slowr = input.int(2, "Slow Ratio", group = "Signal 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
macd = ta.ema(close, mfperiod) - ta.ema(close, msperiod)
fast_k = macd
slow_k = variant(type, macd, mtperiod)
temp = 0
if ((slowr * slow_k + fastr * fast_k) / (fastr + slowr) > 0.0)
temp := 1
if ((slowr * slow_k + fastr * fast_k) / (fastr + slowr) < 0.0)
temp := -1
kmacd = ta.ema(temp, mkperiod)
colorout = kmacd > 0 ? greencolor : redcolor
plot(0, "Middle", color = bar_index % 2 ? color.gray : na)
plot(kmacd, color = colorout, linewidth = 3)
barcolor(colorbars ? colorout: na)
goLong = ta.crossover(kmacd, 0)
goShort = ta.crossunder(kmacd, 0)
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="Digital Kahler MACD [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Digital Kahler MACD [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
vol_box | https://www.tradingview.com/script/xmcUc75j-vol-box/ | voided | https://www.tradingview.com/u/voided/ | 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/
// © voided
//@version=5
indicator("vol_box", overlay = true)
stdevs = input.float(title = "stdevs", defval = 1.0)
pp = input.int(title = "periods to project", defval = 1)
window = input.int(title = "window", defval = 20)
ppy = input.int(title = "periods per year", defval = 252)
history = input.bool(title = "show history", defval = false)
var rvs = array.new_float()
squared_returns = math.pow(math.log(close / close[1]), 2.0)
smoothed_returns = ta.ema(squared_returns, window)
rv = math.sqrt(smoothed_returns * ppy)
array.push(rvs, rv)
upper = close * (1 + rv * stdevs * math.sqrt(pp / ppy))
lower = close * (1 - rv * stdevs * math.sqrt(pp / ppy))
var fcst = array.new_int()
array.push(fcst, close <= upper[pp] and close >= lower[pp] ? 1 : 0)
hist_transp = history ? 0 : 100
hist_upper = close > upper[pp] ? color.new(color.red, hist_transp) : color.new(color.blue, hist_transp)
hist_lower = close < lower[pp] ? color.new(color.red, hist_transp) : color.new(color.blue, hist_transp)
plot(upper[pp], title = "upper bound", color = hist_upper, style = plot.style_stepline)
plot(lower[pp], title = "upper bound", color = hist_lower, style = plot.style_stepline)
if barstate.islast
bgc = color.new(color.white, 100)
bc = color.new(color.blue, 0)
pct_rnk = array.percentrank(rvs, array.indexof(rvs, rv))
acc = array.avg(fcst) * 100
b_txt = str.format("rv: {0,number,#.#}%\nrnk: {1, number, #.#}%\nacc: {2, number, #.#}%", rv * 100, pct_rnk, acc)
b = box.new(left = bar_index + 1, top = upper, bottom = lower, right = bar_index + pp, xloc = xloc.bar_index, bgcolor = bgc, border_color = bc, text = b_txt, text_color = bc, text_halign = text.align_left, text_valign = text.align_top, text_size = size.tiny)
box.delete(b[1]) |
PA-Adaptive TRIX Log [Loxx] | https://www.tradingview.com/script/rnd8QdKc-PA-Adaptive-TRIX-Log-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 54 | 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("PA-Adaptive TRIX Log [Loxx]",
overlay = false,
shorttitle='PAATL [Loxx]',
timeframe="",
timeframe_gaps=true)
import loxx/loxxpaaspecial/1
SM02 = 'Signal'
SM03 = 'Middle Crosses'
_iLWMA(src, per)=>
lwma = src, workLwma = src
sumw = per, sum = per * src
for k = 1 to per - 1
weight = per - k
sumw += weight
sum += weight * nz(workLwma[k])
lwma := (sum/sumw)
lwma
_iRMA(src, per) =>
rma = src
rma := na(rma[1]) ? src : (src - nz(rma[1])) * (1/per) + nz(rma[1])
rma
_iEMA(src, per) =>
ema = src
ema := na(ema[1]) ? src : (src - nz(ema[1])) * (2 / (per + 1)) + nz(ema[1])
ema
_iSMA(src, per)=>
avg = src, k = 1, workSma = src
while k < per
avg += nz(workSma[k])
k += 1
out = avg/k
out
greencolor = #2DD204
redcolor = #D2042D
srcin = input.source(close, "Source", group = "Basic Settings")
sigper = input.int(9, "Signal Period", group = "Basic Settings")
type = input.string("SMA", "Signal Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "Basic Settings")
fregcycles = input.float(1., title = "PA Cycles", group= "Phase Accumulation Cycle Settings")
fregfilter = input.float(0., title = "PA Filter", group= "Phase Accumulation Cycle Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03], group = "Signal Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = input.bool(true, "Show signals?", group= "UI Options")
variant(type, src, len) =>
sig = 0.0
if type == "SMA"
sig := _iSMA(src, len)
else if type == "EMA"
sig := _iEMA(src, len)
else if type == "WMA"
sig := _iLWMA(src, len)
else if type == "RMA"
sig := _iRMA(src, len)
sig
int flen = math.floor(loxxpaaspecial.paa(srcin, fregcycles, fregfilter))
flen := flen < 1 ? 1 : flen
src = math.log(srcin)
workTrix1 = _iEMA(src, flen)
workTrix2 = _iEMA(workTrix1, flen)
workTrix3 = _iEMA(workTrix2, flen)
val = 10000 * (workTrix3 - nz(workTrix3[1])) / nz(workTrix3[1])
sig = variant(type, val, sigper)
mid = 0.
state = 0.
if sigtype == SM02
if (val < sig)
state :=-1
if (val > sig)
state := 1
else if sigtype == SM03
if (val < mid)
state :=-1
if (val > mid)
state := 1
colorout = state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(val, "TRIX Log", color = colorout, linewidth = 3)
plot(sig, "Signal", color = color.white, linewidth = 1)
plot(mid, color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(val, sig) : ta.crossover(val, mid)
goShort = sigtype == SM02 ? ta.crossunder(val, sig) : ta.crossunder(val, mid)
plotshape(showsignals and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showsignals 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="PA-Adaptive TRIX Log [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="PA-Adaptive TRIX Log [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Investing - Correlation Table | https://www.tradingview.com/script/w1jzC6jh-Investing-Correlation-Table/ | RrBc2 | https://www.tradingview.com/u/RrBc2/ | 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/
// © RrBc2
//@version=5
indicator("Investing - Correlation Table", overlay=true, max_bars_back=500)
correlation_TimeFrame = timeframe.period
correlation_Source = input.source(title="Correlation Source", defval=close)
correlation_Percentage = input.float(title="Correlation Percentage (%)", defval=50, tooltip="How many (%) of correlation is considered not CORRELATED?")
barsToCheck = input.int(title="Amount of Bars to Check", defval=500, minval=0, maxval=500, tooltip="How many bars does it has to check for correlation percentage?")
correlated_Color = input.color(title="Correlated Color", defval=color.rgb(255,204,204), inline="tableColor")
notCorrelated_Color = input.color(title="", defval=color.rgb(204,255,204), inline="tableColor")
g_SymList = "Symbol List"
syminfo_1 = input.symbol(title="", defval="FTX:BTCUSD", group=g_SymList, inline=g_SymList)
syminfo_2 = input.symbol(title="", defval="FTX:ETHUSD", group=g_SymList, inline=g_SymList)
syminfo_3 = input.symbol(title="", defval="FTX:BNBUSD", group=g_SymList, inline=g_SymList)
syminfo_4 = input.symbol(title="", defval="FTX:XRPUSD", group=g_SymList, inline=g_SymList)
syminfo_5 = input.symbol(title="", defval="FTX:LTCUSD", group=g_SymList, inline=g_SymList)
syminfo_6 = input.symbol(title="", defval="FTX:SOLUSD", group=g_SymList, inline=g_SymList)
syminfo_7 = input.symbol(title="", defval="FTX:DOTUSD", group=g_SymList, inline=g_SymList)
syminfo_8 = input.symbol(title="", defval="FTX:DOGEUSD", group=g_SymList, inline=g_SymList)
syminfo_9 = input.symbol(title="", defval="FTX:MATICUSD", group=g_SymList, inline=g_SymList)
syminfo_10 = input.symbol(title="", defval="FTX:LINKUSD", group=g_SymList, inline=g_SymList)
syminfo_11 = input.symbol(title="", defval="FTX:FTMUSD", group=g_SymList, inline=g_SymList)
syminfo_12 = input.symbol(title="", defval="FTX:FTTUSD", group=g_SymList, inline=g_SymList)
security_0 = request.security(syminfo.tickerid, correlation_TimeFrame, correlation_Source)
security_1 = request.security(syminfo_1, correlation_TimeFrame, correlation_Source)
security_2 = request.security(syminfo_2, correlation_TimeFrame, correlation_Source)
security_3 = request.security(syminfo_3, correlation_TimeFrame, correlation_Source)
security_4 = request.security(syminfo_4, correlation_TimeFrame, correlation_Source)
security_5 = request.security(syminfo_5, correlation_TimeFrame, correlation_Source)
security_6 = request.security(syminfo_6, correlation_TimeFrame, correlation_Source)
security_7 = request.security(syminfo_7, correlation_TimeFrame, correlation_Source)
security_8 = request.security(syminfo_8, correlation_TimeFrame, correlation_Source)
security_9 = request.security(syminfo_9, correlation_TimeFrame, correlation_Source)
security_10 = request.security(syminfo_10, correlation_TimeFrame, correlation_Source)
security_11 = request.security(syminfo_11, correlation_TimeFrame, correlation_Source)
security_12 = request.security(syminfo_12, correlation_TimeFrame, correlation_Source)
var table correlation_Table = table.new(position = position.top_right, columns = 2, rows = 15, border_width = 1)
var float[] correlation_Value = array.new_float(20, 0)
array.set(correlation_Value, 0, math.round(ta.correlation(security_0, security_1, barsToCheck), 3) * 100)
array.set(correlation_Value, 1, math.round(ta.correlation(security_0, security_2, barsToCheck), 3)* 100)
array.set(correlation_Value, 2, math.round(ta.correlation(security_0, security_3, barsToCheck), 3)* 100)
array.set(correlation_Value, 3, math.round(ta.correlation(security_0, security_4, barsToCheck), 3)* 100)
array.set(correlation_Value, 4, math.round(ta.correlation(security_0, security_5, barsToCheck), 3)* 100)
array.set(correlation_Value, 5, math.round(ta.correlation(security_0, security_6, barsToCheck), 3)* 100)
array.set(correlation_Value, 6, math.round(ta.correlation(security_0, security_7, barsToCheck), 3)* 100)
array.set(correlation_Value, 7, math.round(ta.correlation(security_0, security_8, barsToCheck), 3)* 100)
array.set(correlation_Value, 8, math.round(ta.correlation(security_0, security_9, barsToCheck), 3)* 100)
array.set(correlation_Value, 9, math.round(ta.correlation(security_0, security_10, barsToCheck), 3)* 100)
array.set(correlation_Value, 10, math.round(ta.correlation(security_0, security_11, barsToCheck), 3)* 100)
array.set(correlation_Value, 11, math.round(ta.correlation(security_0, security_12, barsToCheck), 3)* 100)
var string[] symbol_list = array.new_string(20, "")
array.set(symbol_list, 0, str.substring(syminfo_1, (str.pos(syminfo_1, ":")+1)))
array.set(symbol_list, 1, str.substring(syminfo_2, (str.pos(syminfo_2, ":")+1)))
array.set(symbol_list, 2, str.substring(syminfo_3, (str.pos(syminfo_3, ":")+1)))
array.set(symbol_list, 3, str.substring(syminfo_4, (str.pos(syminfo_4, ":")+1)))
array.set(symbol_list, 4, str.substring(syminfo_5, (str.pos(syminfo_5, ":")+1)))
array.set(symbol_list, 5, str.substring(syminfo_6, (str.pos(syminfo_6, ":")+1)))
array.set(symbol_list, 6, str.substring(syminfo_7, (str.pos(syminfo_7, ":")+1)))
array.set(symbol_list, 7, str.substring(syminfo_8, (str.pos(syminfo_8, ":")+1)))
array.set(symbol_list, 8, str.substring(syminfo_9, (str.pos(syminfo_9, ":")+1)))
array.set(symbol_list, 9, str.substring(syminfo_10, (str.pos(syminfo_10, ":")+1)))
array.set(symbol_list, 10, str.substring(syminfo_11, (str.pos(syminfo_10, ":")+1)))
array.set(symbol_list, 11, str.substring(syminfo_12, (str.pos(syminfo_10, ":")+1)))
table.cell(correlation_Table, 0, 0, bgcolor=color.rgb(175,175,175), width=10, text="Symbol")
table.cell(correlation_Table, 1, 0, bgcolor=color.rgb(175,175,175), text="Correlation")
index = 0
while index != 12
correlation = array.get(correlation_Value, index)
tableBG_Color = correlation < correlation_Percentage ? notCorrelated_Color : correlated_Color
table.cell(correlation_Table, 0, index+1, bgcolor=tableBG_Color, text=str.tostring(array.get(symbol_list, index)))
table.cell(correlation_Table, 1, index+1, bgcolor=tableBG_Color, text=str.tostring(correlation) + "%")
index += 1 |
VHF-Adaptive, Digital Kahler Variety RSI w/ Dynamic Zones [Loxx] | https://www.tradingview.com/script/bM3duuZ1-VHF-Adaptive-Digital-Kahler-Variety-RSI-w-Dynamic-Zones-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 73 | 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("VHF-Adaptive, Digital Kahler Variety RSI w/ Dynamic Zones [Loxx]",
shorttitle='VHFADKVRSIDZ [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxvarietyrsi/1
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Zero Cross'
SM04 = 'Levels Cross'
SM05 = 'Dynamic Middle Cross'
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)"])
rperiod = input.int(25, "Calculation Period", group = "Basic Settings")
rsitype = input.string("RSX", "RSI Type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed"], group = "Basic Settings")
type = input.string("Exponential Moving Average - EMA", "Fast 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 = "Digital Kahler Signal Settings")
mtperiod = input.int(9, "Signal Period", group = "Digital Kahler Signal Settings")
fastr = input.int(8, "Fast Ratio", group = "Digital Kahler Signal Settings")
slowr = input.int(2, "Slow Ratio", group = "Digital Kahler Signal Settings")
dzper = input.int(35, "Dynamic Zone Period", group = "Levels Settings")
dzbuyprob = input.float(0.9 , "Dynamic Zone Buy Probability", group = "Levels Settings", maxval = 1)
dzsellprob = input.float(0.9 , "Dynamic Zone Sell Probability", group = "Levels Settings", maxval = 1)
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04, SM05], group = "Signal 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 rsitype
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
vmax = ta.highest(src, rperiod)
vmin = ta.lowest(src, rperiod)
noise = math.sum(math.abs(ta.change(src)), rperiod)
vhf = (vmax - vmin) / noise
len = nz(int(-math.log(vhf) * rperiod), 1)
len := len < 1 ? 1 : len
rsi = loxxvarietyrsi.rsiVariety(rsimode, src, len)
fast_k = rsi
slow_k = variant(type, rsi, mtperiod)
temp = 0
if ((slowr * slow_k + fastr * fast_k) / (fastr + slowr) > 50.0)
temp := 1
if ((slowr * slow_k + fastr * fast_k) / (fastr + slowr) < 50.0)
temp := -1
krsi = ta.ema(temp, rperiod)
sig = krsi[1]
bl1 = loxxdynamiczone.dZone("buy", krsi, dzbuyprob, dzper)
sl1 = loxxdynamiczone.dZone("sell", krsi, dzsellprob, dzper)
zli = loxxdynamiczone.dZone("sell", krsi, 0.5 , dzper)
mid = 0.
state = 0.
if sigtype == SM02
if (krsi < sig)
state :=-1
if (krsi > sig)
state := 1
else if sigtype == SM03
if (krsi < mid)
state :=-1
if (krsi > mid)
state := 1
else if sigtype == SM04
if (krsi > bl1)
state := 1
if (krsi < sl1)
state := -1
else if sigtype == SM05
if (krsi < zli)
state :=-1
if (krsi > zli)
state := 1
colorout = state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(mid, "Zero", color = bar_index % 2 ? color.white : na)
plot(bl1, "Dynamic Buy Level", color = bar_index % 2 ? greencolor : na)
plot(sl1, "Dynamic Sell Level", color = bar_index % 2 ? redcolor : na)
plot(zli, "Dynamic Middle", color = bar_index % 2 ? color.gray : na)
plot(krsi, "Variety RSI", color = colorout, linewidth = 3)
barcolor(colorbars ? colorout: na)
goLong = sigtype == SM02 ? ta.crossover(krsi, sig) : sigtype == SM03 ? ta.crossover(krsi, mid) : sigtype == SM03 ? ta.crossover(krsi, bl1) : ta.crossover(krsi, zli)
goShort = sigtype == SM02 ? ta.crossunder(krsi, sig) : sigtype == SM03 ? ta.crossunder(krsi, mid) : sigtype == SM03 ? ta.crossunder(krsi, sl1) : ta.crossunder(krsi, zli)
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="VHF-Adaptive, Digital Kahler Variety RSI w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="VHF-Adaptive, Digital Kahler Variety RSI w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Many Moving Averages | https://www.tradingview.com/script/9y0SyQEF-Many-Moving-Averages/ | EsIstTurnt | https://www.tradingview.com/u/EsIstTurnt/ | 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/
// © EsIstTurnt
//@version=5
indicator(title="Many Moving Averages",overlay=true)
length1= input.int (8 ,title= 'Linear Regression Length ')
length2= input.int (128 ,title= 'ALMA Length ')
LRC = input.bool (true ,title= 'Plot Set 1')
lrcv2 = input.bool (false,title= 'Alternative LRC Calculation? ')
Alma = input.bool (true ,title= 'Plot Set 2 ')
almav2 = input.bool (false,title= 'Alternative Alma Calculation? ')
MinMax = input.bool (true ,title= 'Borders? ')
src = input.source(close,title= 'Source ')
varlen = ta.rising (hl2,16)?4:64
e1 = ta.ema (src,length1 )
e2 = ta.ema (e1, length1*2)
e3 = ta.ema (e2, length1*3)
e4 = ta.ema (e3, length1*4)
e5 = ta.ema (e4, length1*5)
e6 = ta.ema (e5, length1*6)
w1 = ta.wma (src,length2 )
w2 = ta.wma (e1, length2*2)
w3 = ta.wma (e2, length2*3)
w4 = ta.wma (e3, length2*4)
w5 = ta.wma (e4, length2*5)
w6 = ta.wma (e5, length2*6)
max1 = math.max(e1,e2,e3,e4,e5,e6,w1,w2,w3,w4,w5,w6)
min1 = math.min(e1,e2,e3,e4,e5,e6,w1,w2,w3,w4,w5,w6)
le1 = lrcv2 ?ta.linreg(e1,length1*2 ,0) : ta.linreg(math.avg(e1,w1,e1[16],w1[16],hl2),length1*2 ,0)
le2 = lrcv2 ?ta.linreg(e2,length1*2*2,0) : ta.linreg(math.avg(e2,w2,e2[16],w2[16],hl2),length1*2*2,0)
le3 = lrcv2 ?ta.linreg(e3,length1*2*3,0) : ta.linreg(math.avg(e3,w3,e3[16],w3[16],hl2),length1*2*3,0)
le4 = lrcv2 ?ta.linreg(e4,length1*2*4,0) : ta.linreg(math.avg(e4,w4,e4[16],w4[16],hl2),length1*2*4,0)
le5 = lrcv2 ?ta.linreg(e5,length1*2*5,0) : ta.linreg(math.avg(e5,w5,e5[16],w5[16],hl2),length1*2*5,0)
le6 = lrcv2 ?ta.linreg(e6,length1*2*6,0) : ta.linreg(math.avg(e6,w6,e6[16],w6[16],hl2),length1*2*6,0)
lw1 = lrcv2 ?ta.linreg(w1,length2*2 ,0) : ta.linreg(math.avg(w1,e1,w1[16],e1[16],hl2),length2*2 ,0)
lw2 = lrcv2 ?ta.linreg(w2,length2*2*2,0) : ta.linreg(math.avg(w2,e2,w2[16],e2[16],hl2),length2*2*2,0)
lw3 = lrcv2 ?ta.linreg(w3,length2*2*3,0) : ta.linreg(math.avg(w3,e3,w3[16],e3[16],hl2),length2*2*3,0)
lw4 = lrcv2 ?ta.linreg(w4,length2*2*4,0) : ta.linreg(math.avg(w4,e4,w4[16],e4[16],hl2),length2*2*4,0)
lw5 = lrcv2 ?ta.linreg(w5,length2*2*5,0) : ta.linreg(math.avg(w5,e5,w5[16],e5[16],hl2),length2*2*5,0)
lw6 = lrcv2 ?ta.linreg(w6,length2*2*6,0) : ta.linreg(math.avg(w6,e6,w6[16],e6[16],hl2),length2*2*6,0)
max2 = math.max(le1,le2,le3,le4,le5,le6,lw1,lw2,lw3,lw4,lw5,lw6)
min2 = math.min(le1,le2,le3,le4,le5,le6,lw1,lw2,lw3,lw4,lw5,lw6)
ae1 = almav2?ta.alma (le1,length1+varlen*2 ,0.87,6):ta.alma(e1,length1+varlen*2 ,0.75,8)
ae2 = almav2?ta.alma (le2,length1+varlen*4 ,0.87,6):ta.alma(e2,length1+varlen*4 ,0.75,8)
ae3 = almav2?ta.alma (le3,length1+varlen*6 ,0.87,6):ta.alma(e3,length1+varlen*6 ,0.75,8)
ae4 = almav2?ta.alma (le4,length1+varlen*8 ,0.87,6):ta.alma(e4,length1+varlen*8 ,0.75,8)
ae5 = almav2?ta.alma (le5,length1+varlen*10,0.87,6):ta.alma(e5,length1+varlen*10,0.75,8)
ae6 = almav2?ta.alma (le6,length1+varlen*12,0.87,6):ta.alma(e6,length1+varlen*12,0.75,8)
aw1 = almav2?ta.alma (lw1,length2+varlen*2 ,0.87,6):ta.alma(w1,length2+varlen*2 ,0.75,8)
aw2 = almav2?ta.alma (lw2,length2+varlen*4 ,0.87,6):ta.alma(w2,length2+varlen*4 ,0.75,8)
aw3 = almav2?ta.alma (lw3,length2+varlen*6 ,0.87,6):ta.alma(w3,length2+varlen*6 ,0.75,8)
aw4 = almav2?ta.alma (lw4,length2+varlen*8 ,0.87,6):ta.alma(w4,length2+varlen*8 ,0.75,8)
aw5 = almav2?ta.alma (lw5,length2+varlen*10,0.87,6):ta.alma(w5,length2+varlen*10,0.75,8)
aw6 = almav2?ta.alma (lw6,length2+varlen*12,0.87,6):ta.alma(w6,length2+varlen*12,0.75,8)
max3 = math.max(ae1,ae2,ae3,ae4,ae5,ae6,aw1,aw2,aw3,aw4,aw5,aw6)
min3 = math.min(ae1,ae2,ae3,ae4,ae5,ae6,aw1,aw2,aw3,aw4,aw5,aw6)
center = ta.sma(math.avg(ta.highest(low,128),ta.lowest(high,128),ta.highest(high,32),ta.lowest(low,32)),512)
center2 = ta.sma(math.avg(center,hl2),256)
dema = 2 * e1 - e2
max4=math.max(max1,max2,max3,dema)
min4=math.min(min1,min2,min3,dema)
max =plot(MinMax?max4:na,color=#000000, linewidth=2)
min =plot(MinMax?min4:na,color=#000000, linewidth=2)
centerplot =plot(center ,title='Center' ,color = center==min4 or center==max4?MinMax?na:Alma?color.blue:color.white :na, linewidth=1, style=plot.style_cross )
le1LRCplot =plot(LRC?le1:na ,title='LRC#1' ,color = le1==min4 or le1==max4?MinMax?na:color.yellow :na, linewidth=1, style=plot.style_linebr)
le2LRCplot =plot(LRC?na:le2 ,title='LRC#2' ,color = le2==min4 or le2==max4?MinMax?na:color.yellow :na, linewidth=2, style=plot.style_linebr)
le3LRCplot =plot(LRC?le3:na ,title='LRC#3' ,color = le3==max4 or le3==min4?MinMax?na:#c3b800 :na, linewidth=2, style=plot.style_linebr)
le4LRCplot =plot(LRC?na:le4 ,title='LRC#4' ,color = le4==min4 or le4==max4?MinMax?na:#c3b800 :na, linewidth=1, style=plot.style_linebr)
le5LRCplot =plot(LRC?le5:na ,title='LRC#5' ,color = le5==min4 or le5==max4?MinMax?na:color.orange :na, linewidth=2, style=plot.style_linebr)
le6LRCplot =plot(LRC?na:le6 ,title='LRC#6' ,color = le6==min4 or le6==max4?MinMax?na:#f57c00 :na, linewidth=1, style=plot.style_linebr)
lw1LRCplot =plot(LRC?na:lw1 ,title='LRC#1' ,color = lw1==min4 or lw1==max4?MinMax?na:color.olive :na, linewidth=1, style=plot.style_linebr)
lw3LRCplot =plot(LRC?lw3:na ,title='LRC#3' ,color = lw3==max4 or lw3==min4?MinMax?na:color.blue :na, linewidth=1, style=plot.style_linebr)
lw5LRCplot =plot(LRC?lw5:na ,title='LRC#5' ,color = lw5==max4 or lw5==min4?MinMax?na:color.maroon :na, linewidth=2, style=plot.style_linebr)
lw6LRCplot =plot(LRC?lw6:na ,title='LRC#6' ,color = lw6==max4 or lw6==min4?MinMax?na:#de0000 :na, linewidth=2, style=plot.style_linebr)
ae1ALMAplot=plot(Alma?ae1:na,title='ALMA#1' ,color = ae1==min4 or ae1==max4?MinMax?na:color.olive :na, linewidth=1, style=plot.style_linebr)
ae2ALMAplot=plot(Alma?na:ae2,title='ALMA#2' ,color = ae2==min4 or ae2==max4?MinMax?na:color.orange :na, linewidth=1, style=plot.style_linebr)
ae3ALMAplot=plot(Alma?ae3:na,title='ALMA#3' ,color = ae3==min4 or ae3==max4?MinMax?na:#acfb00 :na, linewidth=2, style=plot.style_linebr)
ae5ALMAplot=plot(Alma?ae5:na,title='ALMA#5' ,color = ae5==min4 or ae5==max4?MinMax?na:#acfb00 :na, linewidth=2, style=plot.style_linebr)
aw2ALMAplot=plot(Alma?aw2:na,title='ALMA#2' ,color = aw2==min4 or aw2==max4?MinMax?na:#acfb00 :na, linewidth=1, style=plot.style_linebr)
aw3ALMAplot=plot(Alma?aw3:na,title='ALMA#3' ,color = aw3==min4 or aw3==max4?MinMax?na:color.blue :na, linewidth=2, style=plot.style_linebr)
aw5ALMAplot=plot(Alma?aw5:na,title='ALMA#5' ,color = aw5==min4 or aw5==max4?MinMax?na:#de0000 :na, linewidth=2, style=plot.style_linebr)
aw6ALMAplot=plot(Alma?aw6:na,title='ALMA#6' ,color = aw6==min4 or aw6==max4?MinMax?na:#de0000 :na, linewidth=2, style=plot.style_linebr)
//DEMAplot =plot(dema ,title='DEMA' ,color = dema==max4 or dema==min4?MinMax?na:color.black :na,transp=0 , linewidth=1, style=plot.style_line)
lw2LRCplot =plot(LRC?lw2:na ,title='LRC#2' ,color = lw2==max4 or lw2==min4?MinMax?na:Alma?#acfb0000:#ff0000 :na , linewidth=2, style=plot.style_line)
aw4ALMAplot=plot(Alma?na:aw4,title='ALMA#4' ,color = aw4==min4 or aw4==max4?MinMax?na:LRC?color.navy:color.maroon :na , linewidth=1, style=plot.style_line)
ae6ALMAplot=plot(Alma?na:ae6,title='ALMA#6' ,color = ae6==min4 or ae6==max4?MinMax?na:LRC?color.blue:color.orange :na , linewidth=1, style=plot.style_line)
aw1ALMAplot=plot(Alma?na:aw1,title='ALMA#1' ,color = aw1==min4 or aw1==max4?MinMax?na:LRC?#ff0000:color.olive :na , linewidth=2, style=plot.style_line)
ae4ALMAplot=plot(Alma?na:ae4,title='ALMA#4' ,color = ae4==min4 or ae4==max4?MinMax?na:LRC?color.maroon:color.orange :na , linewidth=1, style=plot.style_line)
lw4LRCplot =plot(LRC?na:lw4 ,title='LRC#4' ,color = lw4==min4 or lw4==max4?MinMax?na:LRC?#e91ebb:Alma?color.blue:#b01902:na , linewidth=1, style=plot.style_line)
fill(centerplot ,aw3ALMAplot ,color = color.new(color.blue ,60))
fill(centerplot ,lw3LRCplot ,color = color.new(color.aqua ,85))
fill(aw1ALMAplot,lw2LRCplot ,color = color.new(#de0000 ,85))
fill(aw6ALMAplot,lw3LRCplot ,color = color.new(#005edc ,70))
fill(ae4ALMAplot,lw2LRCplot ,color = color.new(#de0000 ,70))
fill(ae2ALMAplot,le5LRCplot ,color = color.new(color.yellow ,93))
fill(ae3ALMAplot,lw1LRCplot ,color = color.new(color.olive ,93))
fill(ae6ALMAplot,lw3LRCplot ,color = color.new(color.teal ,85))
fill(aw5ALMAplot,aw6ALMAplot ,color = color.new(#730101 ,60))
fill(lw3LRCplot ,centerplot ,color = color.new(color.blue ,85))
fill(lw4LRCplot ,centerplot ,color = color.new(color.blue ,85))
fill(le3LRCplot ,le3LRCplot ,color = color.new(#f57c00 ,85))
fill(lw2LRCplot ,aw2ALMAplot ,color = color.new(#acfb00 ,85))
fill(lw5LRCplot ,aw4ALMAplot ,color = color.new(color.maroon ,85))
fill(lw6LRCplot ,aw5ALMAplot ,color = color.new(#ff0000 ,85))
fill(le1LRCplot ,ae2ALMAplot ,color = color.new(#66a204 ,85))
fill(le4LRCplot ,le2LRCplot ,color = color.new (color.olive ,85))
fill(le4LRCplot ,le6LRCplot ,color = color.new(#66a204 ,85))
fill(le1LRCplot ,ae1ALMAplot ,color = color.new(#f7930d ,85))
fill(le1LRCplot ,ae1ALMAplot ,color = color.new(color.white ,95))
fill(ae5ALMAplot,lw2LRCplot ,color = color.new(color.lime ,85))
fill(aw5ALMAplot,lw4LRCplot ,color = color.new(#ff0000 ,70))
fill(le3LRCplot ,le5LRCplot ,color = color.new(#f57c00 ,85))
fill(ae3ALMAplot,ae5ALMAplot ,color = color.new(#1ea809 ,70))
fill(aw2ALMAplot,ae5ALMAplot ,color = color.new(#acfb00 ,70))
fill(le3LRCplot ,ae1ALMAplot ,color = color.new(#f57c00 ,85))
fill(le2LRCplot ,aw1ALMAplot ,color = color.new(#f57c00 ,95))
fill(ae1ALMAplot,ae4ALMAplot ,color = color.new(#ff0000 ,85))
fill(lw5LRCplot ,lw6LRCplot ,color = color.new(#801922 ,85))
//fill(le2LRCplot ,DEMAplot ,color = color.new(color.white ,95))
//fill(ae1ALMAplot,DEMAplot ,color = color.new(color.white ,95)) |
Ichimoku Cloud with EMA | https://www.tradingview.com/script/a4pqw6nn-Ichimoku-Cloud-with-EMA/ | iconians | https://www.tradingview.com/u/iconians/ | 64 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © iconians
//@version=5
indicator(title="Ichimoku Cloud", shorttitle="Ichimoku EMA", overlay=true)
conversionPeriods = input.int(9, minval=1, title="Conversion Line Length")
basePeriods = input.int(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length")
displacement = input.int(26, minval=1, title="Lagging Span")
donchian(len) => src = close,
out = ta.ema(src, len)
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=#2962FF, title="Conversion Line")
plot(baseLine, color=#B71C1C, title="Base Line")
plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,
title="Leading Span A")
p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,
title="Leading Span B")
fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))
|
Volume Analysis | https://www.tradingview.com/script/UxdlGQl8-Volume-Analysis/ | goofoffgoose | https://www.tradingview.com/u/goofoffgoose/ | 332 | 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/
// © goofoffgoose
//Sourced code from DepthHouse Trading Indicators by oh92 for Bull\Bear volume flow calculations.
// This indicator integrates the Ma-over-MA crossover strategy in oh92's DepthHouse calculation with a volume-over-MA
// calculation to further narrow down "Areas of Interest" levels for a potential re-test zone to the right of the chart.
// Added a Moving Average calculation for a multi-level cloud. Broke down more conditions to highlight both
// volume flow crossover on the High and Extreme High MA and also higher than set average and extreme high volume spikes
// without bull\bear conditions. Candle color changes for volume spikes.
// Session backgrounds set for research purposes.
//@version=5
indicator("Volume Analysis", shorttitle="VAS", format=format.volume)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Session BG Shading
t = timestamp("01 Jan 2022 00:00")
OpenSession = input.session(title="Open", defval="0830-0845", tooltip="US(NYSE) Open", group="Highlight Session Background", inline="open")
CloseSession = input.session(title="Close", defval="1445-1500", tooltip="US(NYSE) Close", group="Highlight Session Background", inline="close")
Show_Open_Session = input.bool(title="Show Open Session?", defval=true, group="Highlight Session Background", inline="show") // show open session ?
Show_Close_Session = input.bool(title="Show Close Session?", defval=false, group="Highlight Session Background", inline="show") // show close session ?
inSession(session, sessionTimeZone=syminfo.timezone) =>
na(time(timeframe.period, session + ":1234567")) == false
// Background plot
OpenColor = input.color(color.rgb(153,153,153,95), title="Open", group="Highlight Session Background", inline="open")
CloseColor = input.color(color.rgb(153,153,153,90), title="Close", group="Highlight Session Background", inline="close" )
bgcolor(inSession(OpenSession) and Show_Open_Session ? OpenColor : na, editable=false) // Open
bgcolor(inSession(CloseSession) and Show_Close_Session ? CloseColor : na, editable=false) // Close
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Volume Flow Colors
// bias bull/bear colors
vf_color_bull = color(color.rgb( 0, 176,151,00))
vf_color_bear = color(color.rgb(102, 56, 150,00))
vf_ext_color_bull = color(color.rgb( 0, 245,245,00))
vf_ext_color_bear = color(color.rgb(182, 56, 231,00))
// non-bias high and extreme volume color
vol_ext_color = color(color.rgb(255,255,255,00))
vol_high_color = color(color.rgb(245,245,245,40))
// Cloud color fill color
fill_color1 = color(color.rgb( 76,204, 171,85))
fill_color2 = color(color.rgb(178,102,255,90))
fill_color3 = color(color.rgb(102, 0,204,90))
// Inputs for Volume Flow
vf_maType = input.string(title='Moving Average Type', options=['Simple', 'Exponential', 'Double Exponential'], defval='Simple', group="Volume Flow Settings")
vf_length = input(14, title='MA Length', group="Volume Flow Settings")
x = input(3.1, title='Factor For Breakout Candle', group="Volume Flow Settings")
// Inputs for Cloud MA's
Avg_Type = input.string("SMA", title="Average Type", options=["SMA", "EMA", "HMA", "None"], tooltip="Selecting None removes cloud and all related High Volume Spikes from indicator", group="Volume MA Cloud Settings")
Avg_Length = input(14, title="Average Length", group="Volume MA Cloud Settings")
ma_mult = input(3,title="Multiplier", tooltip="Multiplier to set Moving Average levels. ", group="Volume MA Cloud Settings")
Display_Volume = input(true,title="Show All Volume")
// Var Settings
vol = volume
bull = close > open ? vol : 0
bear = open > close ? vol : 0
Close = (close)
Open = (open)
// Moving Average Calcs
Avg = (Avg_Type == "SMA" ? ta.sma(volume, Avg_Length) : Avg_Type == "EMA" ? ta.ema(volume, Avg_Length) :
Avg_Type == "HMA" ? ta.hma(volume, Avg_Length) : na)
Ma_mult_high = (Avg*ma_mult) //ma1
Ma_mult_mid = (Ma_mult_high/2) //ma2
Ma_mult_low = (Avg/2) //ma3
// Double EMA Function
dema(src, len) =>
2 * ta.ema(src, len) - ta.ema(ta.ema(src, len), len)
// Bull Moving Average Calculation
bullma = vf_maType == 'Exponential' ? ta.ema(bull, vf_length) : vf_maType == 'Double Exponential' ? dema(bull, vf_length) : ta.sma(bull, vf_length)
// Bear Moving Average Calculation //
bearma = vf_maType == 'Exponential' ? ta.ema(bear, vf_length) : vf_maType == 'Double Exponential' ? dema(bear, vf_length) : ta.sma(bear, vf_length)
// Volume Spikes //
vol_ext = ta.crossover(volume, Ma_mult_high) ? vol : na
vol_high = ta.crossover(volume, Ma_mult_mid) ? vol : na
gsig = ta.crossover(bull, bullma * x) ? vol : na
rsig = ta.crossover(bear, bearma * x) ? vol : na
gsig_high = ta.crossover(bull, bullma * x) and vol_high ? vol : na
rsig_high = ta.crossover(bear, bearma * x) and vol_high ? vol : na
gsig_ext = ta.crossover(bull, bullma * x) and vol_ext ? vol : na
rsig_ext = ta.crossover(bear, bearma * x) and vol_ext ? vol : na
// Color Calcs //
vf_dif = bullma - bearma
vdClr = vf_dif > 0 ? vf_color_bull : vf_color_bear
vClr = close > open ? vf_color_bull : vf_color_bear
//volume up/down color calc
Volume_Color = Close > Open ? color(color.rgb(224,224,224,90)) : Close < Open ? color(color.rgb(96,96,96,90)) : na
// PLOTS //
//volume
plot(Display_Volume ? volume : na, title="Volume", color=Volume_Color, style=plot.style_histogram, linewidth=3)
// Moving average lines
plot_avg = plot(Avg, title="Average", color=color(color.rgb(96,96,96,80)), style=plot.style_line, linewidth=1) //plot ma1
plot_ma_high = plot(Ma_mult_high, title="High", color=color(color.rgb(96,96,96,80)), style=plot.style_line, linewidth=1) //plot ma2
plot_ma_mid = plot(Ma_mult_mid, title="Mid", color=color(color.rgb(96,96,96,80)), style=plot.style_line, linewidth=1) //plot ma4
plot_ma_low = plot(Ma_mult_low, title="Low", color=color(color.rgb(96,96,96,80)), style=plot.style_line, linewidth=1) //plot ma3
// Moving average cloud
fill(plot_ma_mid,plot_ma_high, title="Upper Cloud", color=fill_color1)
fill(plot_avg,plot_ma_mid, title="Middle Cloud", color=fill_color2)
fill(plot_ma_low,plot_avg, title="Lower Cloud", color=fill_color3)
// Volume spike without directional bias
plot(vol_ext, style=plot.style_histogram, linewidth=4, color=(vol_ext_color), title='Extreme Volume Spike', display=display.pane)
plot(vol_high, style=plot.style_histogram, linewidth=4, color=(vol_high_color), title='High Volume Spike', display=display.pane)
// Volume spikes with bull/bear bias
plot(gsig, style=plot.style_histogram, linewidth=4, color=(vf_color_bull), title='Bull Vol Spike', display=display.pane)
plot(rsig, style=plot.style_histogram, linewidth=4, color=(vf_color_bear), title='Bear Vol Spike', display=display.pane)
plot(gsig_high, style=plot.style_histogram, linewidth=4, color=(vf_color_bull), title='High Bull Vol Spike', display=display.pane)
plot(rsig_high, style=plot.style_histogram, linewidth=4, color=(vf_color_bear), title='High Bear Vol Spike', display=display.pane)
plot(gsig_ext, style=plot.style_histogram, linewidth=4, color=(vf_ext_color_bull), title='Extreme Bull Vol Spike', display=display.pane)
plot(rsig_ext, style=plot.style_histogram, linewidth=4, color=(vf_ext_color_bear), title='Extreme Bear Vol Spike', display=display.pane)
// Color candles based on volume conditions
barcolor(gsig ? vf_color_bull: rsig ? vf_color_bear: gsig_high ? vf_color_bull : rsig_high ? vf_color_bear : gsig_ext ? vf_ext_color_bull : rsig_ext ? vf_ext_color_bear : na)
barcolor(vol_high ? vol_high_color : vol_ext ? vol_ext_color : na)
|
ICT Sessions (Kill Zones) | https://www.tradingview.com/script/hIR32Xzp/ | bluebeardit | https://www.tradingview.com/u/bluebeardit/ | 261 | 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 2022
// Version 1.1
// Inspired by @ICT_MHuddleston concepts
//
// ________ ___ ___ ___ _______ ________ _______ ________ ________ ________ ___ _________
// |\ __ \ |\ \ |\ \|\ \ |\ ___ \ |\ __ \ |\ ___ \ |\ __ \ |\ __ \ |\ ___ \ |\ \ |\___ ___\
// \ \ \|\ /_\ \ \ \ \ \\\ \\ \ __/| \ \ \|\ /_\ \ __/| \ \ \|\ \\ \ \|\ \\ \ \_|\ \\ \ \\|___ \ \_|
// \ \ __ \\ \ \ \ \ \\\ \\ \ \_|/__\ \ __ \\ \ \_|/__\ \ __ \\ \ _ _\\ \ \ \\ \\ \ \ \ \ \
// \ \ \|\ \\ \ \____ \ \ \\\ \\ \ \_|\ \\ \ \|\ \\ \ \_|\ \\ \ \ \ \\ \ \\ \|\ \ \_\\ \\ \ \ \ \ \
// \ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \_______\\ \__\ \__\\ \__\\ _\ \ \_______\\ \__\ \ \__\
// \|_______| \|_______| \|_______| \|_______| \|_______| \|_______| \|__|\|__| \|__|\|__| \|_______| \|__| \|__|
//
//
//@version=5
indicator("ICT Sessions (Kill Zones)", shorttitle="ICT Sessions (KZ)", overlay=true)
_as = time(timeframe.period, "1800-0300")
ls = time(timeframe.period, "0300-1200")
ns = time(timeframe.period, "0800-1800")
Asia = na(_as) ? na : color.new(color.blue, 90)
London = na(ls) ? na : color.new(color.green, 90)
NY = na(ns) ? na : color.new(color.red, 90)
bgcolor(Asia, title="Asia")
bgcolor(London, title="London")
bgcolor(NY, title="New York")
//Midnight NewYork
sessNum = 1
sh = input(true, title="Show NY Midnight Open?")
First = input.session('0000-0001', title="NY Midnight Open")
sessToUse = sessNum == 1 ? First : '0000-0000'
bartimeSess = (sessNum == 0 ? time('D') : time('D', sessToUse))
bgPlot = (sessNum == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse))
bgcolor(sh and bgPlot > 0 ? color.new(color.purple, 50): na, title="New York Midnight Open")
//London Kill Zone
sessNum2 = 2
sh2= input(true, title="Show London Kill Zone?")
Second = input.session('0200-0500', title="London Kill Zone")
sessToUse2 = sessNum2 == 2 ? Second : '0000-0000'
bartimeSess2 = (sessNum2 == 0 ? time('D') : time('D', sessToUse2))
bgPlot2 = (sessNum2 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse2))
bgcolor(sh2 and bgPlot2 > 0 ? color.new(color.purple, 80): na, title="London Kill Zone")
//London Kill Zone line
sessNum2b = 2
sh2b= input(true, title="Show London Kill Zone Central Line?")
Secondb = input.session('0330-0331', title="London Kill Zone CL")
sessToUse2b = sessNum2b == 2 ? Secondb : '0000-0000'
bartimeSess2b = (sessNum2b == 0 ? time('D') : time('D', sessToUse2b))
bgPlot2b = (sessNum2b == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse2b))
bgcolor(sh2b and bgPlot2b > 0 ? color.new(color.purple, 80): na, title="London Kill Zone CL")
//New York 8:30
sessNum3 = 3
sh3= input(true, title="Show NY 8:30 Opening?")
Third = input.session('0830-0831', title="NY 8:30 Opening")
sessToUse3 = sessNum3 == 3 ? Third : '0000-0000'
bartimeSess3 = (sessNum3 == 0 ? time('D') : time('D', sessToUse3))
bgPlot3 = (sessNum3 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse3))
bgcolor(sh3 and bgPlot3 > 0 ? color.new(color.purple, 50): na, title="New York 8:30")
//New York 9:30
sessNum4 = 4
sh4= input(true, title="Show NY 9:30 Opening?")
Fourth = input.session('0930-0931', title="NY 9:30 Opening")
sessToUse4 = sessNum4 == 4 ? Fourth : '0000-0000'
bartimeSess4 = (sessNum4 == 0 ? time('D') : time('D', sessToUse4))
bgPlot4 = (sessNum4 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse4))
bgcolor(sh4 and bgPlot4 > 0 ? color.new(color.purple, 50): na, title="New York 9:30")
//New York Lunch Hour
sessNum5 = 5
sh5= input(true, title="Show New York Lunch Hour?")
Fifth = input.session('1200-1300', title="New York Lunch Hour")
sessToUse5 = sessNum5 == 5 ? Fifth : '0000-0000'
bartimeSess5 = (sessNum5 == 0 ? time('D') : time('D', sessToUse5))
bgPlot5 = (sessNum5 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse5))
bgcolor(sh5 and bgPlot5 > 0 ? color.new(color.purple, 80): na, title="New York Lunch Hour")
//New York Lunch Hour line
sessNum5b = 5
sh5b= input(true, title="Show New York Lunch Hour Central Line?")
Fifthb = input.session('1230-1231', title="New York Lunch Hour CL")
sessToUse5b = sessNum5b == 5 ? Fifthb : '0000-0000'
bartimeSess5b = (sessNum5b == 0 ? time('D') : time('D', sessToUse5b))
bgPlot5b = (sessNum5b == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse5b))
bgcolor(sh5b and bgPlot5b > 0 ? color.new(color.purple, 80): na, title="New York Lunch Hour CL")
//New York 13:30
sessNum6 = 6
sh6= input(true, title="Show NY 13:30 Opening?")
sixth = input.session('1330-1331', title="NY 13:30 Opening")
sessToUse6 = sessNum6 == 6 ? sixth : '0000-0000'
bartimeSess6 = (sessNum6 == 0 ? time('D') : time('D', sessToUse6))
bgPlot6 = (sessNum6 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse6))
bgcolor(sh6 and bgPlot6 > 0 ? color.new(color.purple, 50): na, title="New York 13:30")
//New York 7:00
sessNum7 = 7
sh7= input(true, title="Show 07:00 NY KZ Opening?")
seventh = input.session('0700-0701', title="NY 07:00 KZ Opening")
sessToUse7 = sessNum7 == 7 ? seventh : '0000-0000'
bartimeSess7 = (sessNum7 == 0 ? time('D') : time('D', sessToUse7))
bgPlot7 = (sessNum7 == 0 ? time(timeframe.period) : time(timeframe.period, sessToUse7))
bgcolor(sh7 and bgPlot7 > 0 ? color.new(color.purple, 50): na, title="NY 07:00 KZ Opening")
anchorTime = time('D', sessToUse)
anchorBarIndex = (time - anchorTime) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack = bar_index - anchorBarIndex
//plot(anchorBarsBack)
labelNYMidnight= label.new(anchorBarsBack, high,
text="NY Midnight Open",
color=color.new(color.white, 0),
textcolor= color.red,
size=size.large,
style = label.style_label_down,
yloc = yloc.abovebar)
anchorTime2 = time('D', sessToUse2b)
anchorBarIndex2 = (time - anchorTime2) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack2 = bar_index - anchorBarIndex2
labelLondonKZ= label.new(anchorBarsBack2, high,
text="London Kill Zone",
color=color.new(color.white, 0),
textcolor= color.red,
size=size.large,
style = label.style_label_down,
yloc = yloc.abovebar)
anchorTime3 = time('D', sessToUse3)
anchorBarIndex3 = (time - anchorTime3) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack3 = bar_index - anchorBarIndex3
labelNY830= label.new(anchorBarsBack3, high,
text="NY 8:30",
color=color.new(color.white, 0),
textcolor= color.red,
size=size.large,
style = label.style_label_down,
yloc = yloc.abovebar)
anchorTime4 = time('D', sessToUse4)
anchorBarIndex4 = (time - anchorTime4) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack4 = bar_index - anchorBarIndex4
labelNY930= label.new(anchorBarsBack4, high,
text="NY 9:30",
color=color.new(color.white, 0),
textcolor= color.red,
size=size.large,
style = label.style_label_down,
yloc = yloc.abovebar)
anchorTime5 = time('D', sessToUse5b)
anchorBarIndex5 = (time - anchorTime5) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack5 = bar_index - anchorBarIndex5
labelNYLunch= label.new(anchorBarsBack5, high,
text="NY Lunch",
color=color.new(color.white, 0),
textcolor= color.red,
size=size.large,
style = label.style_label_down,
yloc = yloc.abovebar)
anchorTime6 = time('D', sessToUse6)
anchorBarIndex6 = (time - anchorTime6) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack6 = bar_index - anchorBarIndex6
labelNY1330= label.new(anchorBarsBack6, high,
text="NY 13:30",
color=color.new(color.white, 0),
textcolor= color.red,
size=size.large,
style = label.style_label_down,
yloc = yloc.abovebar)
anchorTime7 = time('D', sessToUse7)
anchorBarIndex7 = (time - anchorTime7) / (1000 * timeframe.in_seconds(timeframe.period))
anchorBarsBack7 = bar_index - anchorBarIndex7
labelNY0700= label.new(anchorBarsBack7, high,
text="NY 07:00 KZ Open",
color=color.new(color.white, 0),
textcolor= color.red,
size=size.large,
style = label.style_label_down,
yloc = yloc.abovebar)
|
One-Sided Gaussian Filter w/ Channels [Loxx] | https://www.tradingview.com/script/LIGmsUQa-One-Sided-Gaussian-Filter-w-Channels-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 497 | 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("One-Sided Gaussian Filter w/ Channels [Loxx]",
shorttitle="OSGFC [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
//ehlers 2-pole super smoother
_twopoless(float src, int len)=>
a1 = 0., b1 = 0.
coef1 = 0., coef2 = 0., coef3 = 0.
filt = 0., trig = 0.
a1 := math.exp(-1.414 * math.pi / len)
b1 := 2 * a1 * math.cos(1.414 * math.pi / len)
coef2 := b1
coef3 := -a1 * a1
coef1 := 1 - coef2 - coef3
filt := coef1 * src + coef2 * nz(filt[1]) + coef3 * nz(filt[2])
filt := bar_index < 3 ? src : filt
filt
_gaussian(size, x)=>
out = (math.exp(-x * x * 9 / ((size + 1) * (size + 1))))
out
//calc fibonacci numbers 0, 1, 1, 2, 3, 5, 8, 13, 21 ... etc
_fiblevels(len)=>
arr_levels = array.new_float(len, 0.)
t1 = 0, t2 = 1
nxt = t1 + t2
for i = 0 to len - 1
array.set(arr_levels, i, nxt)
t1 := t2
t2 := nxt
nxt := t1 + t2
arr_levels
//calc weights given fibo numbers and how many fibos chosen
_gaussout(levels)=>
perin = array.size(levels)
arr_gauss = matrix.new<float>(perin, perin, 0.)
for k = 0 to array.size(levels) - 1
sum = 0.
for i = 0 to perin - 1
if (i >= array.get(levels, k))
break
matrix.set(arr_gauss, i, k, _gaussian(array.get(levels, k), i))
sum += matrix.get(arr_gauss, i, k)
for i = 0 to perin - 1
if (i >= array.get(levels, k))
break
temp = matrix.get(arr_gauss, i, k) / sum
matrix.set(arr_gauss, i, k, temp)
arr_gauss
//calc moving average applying fibo numbers
_smthMA(level, src, per)=>
sum = 0.
lvltemp = _fiblevels(per)
gtemp = _gaussout(lvltemp)
for i = 0 to matrix.rows(gtemp) - 1
sum += matrix.get(gtemp, i, level) * nz(src[i])
sum
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)"])
smthper = input.int(10, "Guassian Levels Depth", maxval = 100, group= "Basic Settings")
extrasmthper = input.int(10, "Extra Smoothing (2-Pole Ehlers Super Smoother) Period", group= "Basic Settings")
atrper = input.int(21, "ATR Period", group = "Basic Settings")
mult = input.float(.628, "ATR Multiplier", group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = 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
lmax = smthper + 1
out1 = _smthMA(smthper, src, lmax)
out = _twopoless(out1, extrasmthper)
sig = out[1]
colorout = out > sig ? greencolor : redcolor
atr = ta.atr(atrper)
smax = out + atr * mult
smin = out - atr * mult
plot(smax, color = bar_index % 2 ? color.silver : na, linewidth = 1)
plot(smin, color = bar_index % 2 ? color.silver : na, linewidth = 1)
plot(out, "GMA", color = colorout, linewidth = 4)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(out, sig)
goShort = ta.crossunder(out, sig)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goLong, title="Long", message="One-Sided Gaussian Filter w/ Channels [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="One-Sided Gaussian Filter w/ Channels [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
CFB-Adaptive Velocity Histogram [Loxx] | https://www.tradingview.com/script/hpWb892n-CFB-Adaptive-Velocity-Histogram-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("CFB-Adaptive Velocity Histogram [Loxx]",
overlay = false,
shorttitle='CFBVH [Loxx]',
timeframe="",
timeframe_gaps=true)
import loxx/loxxdynamiczone/3
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Slope'
SM03 = 'Middle Crosses'
SM04 = 'Levels Crosses'
_oma(src, len, const, 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 = len
noise = 0.00000000001
minPeriod = averagePeriod/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 := math.ceil(((signal / noise) * (maxPeriod - minPeriod)) + minPeriod)
//calc jurik momentum
alpha = (2.0 + const) / (1.0 + const + 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
_ivel(src, length)=>
vellength = length
coeff0 = length + 1
coeff1 = coeff0 * (coeff0 + 1.0) / 2.0
coeff2 = coeff1 * (2.0 * coeff0 + 1.0) / 3.0
coeff3 = coeff1 * coeff1 * coeff1 - coeff2 * coeff2
suma = 0., sumb = 0.
for l = 0 to length
suma += nz(src[l]) * (coeff0 - l)
sumb += nz(src[l]) * (coeff0 - l) * (coeff0 - l)
tvel = (sumb * coeff1 - suma * coeff2) / (coeff3 * syminfo.mintick)
tvel
SmoothLength = input.int(5, "Velocity Smoothing Period", group = "Basic Settings")
SmoothPhase = input.float(0, "Velocity Jurik Phase", group = "Basic Settings")
veldouble = input.bool(true, "Velocity Double Juirk Smoothing?", group = "Basic Settings")
omaper = input.int(5, "Average Period", minval = 1, group = "OMA Settings")
speed = input.float(3, "Speed", step = .01, group = "OMA Settings")
adapt = input.bool(true, "Make it adaptive?", group = "OMA Settings")
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "CFB Ingest Settings")
srcin = input.string("Weighted", "Source", group= "CFB Ingest 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)"])
nlen = input.int(50, "CFB Normal Period", minval = 1, group = "CFB Ingest Settings")
cfb_len = input.int(4, "CFB Depth", maxval = 10, group = "CFB Ingest Settings")
smth = input.int(8, "CFB Smooth Period", minval = 1, group = "CFB Ingest Settings")
slim = input.int(5, "CFB Short Limit", minval = 1, group = "CFB Ingest Settings")
llim = input.int(50, "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")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buy1 = input.float(0.1 , "Dynamic Zone Buy Probability Level 1", group = "Levels Settings", maxval = 0.5)
sell1 = input.float(0.1 , "Dynamic Zone Sell Probability Level 1", group = "Levels Settings", maxval = 0.5)
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)
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showsignals = 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
cfb_draft = loxxjuriktools.jcfb(src, cfb_len, smth)
cfb_pre =
CfbSmoothDouble ? loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(cfb_draft, jcfbsmlen, jcfbsmph), jcfbsmlen, jcfbsmph) :
loxxjuriktools.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))
src := _oma(src, omaper, speed, adapt)
vel = veldouble ? loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(_ivel(src, len_out_cfb), SmoothLength, SmoothPhase), SmoothLength, SmoothPhase) :
loxxjuriktools.jurik_filt(_ivel(src, len_out_cfb), SmoothLength, SmoothPhase)
sig = vel[1]
bl1 = loxxdynamiczone.dZone("buy", vel, buy1, dzper)
sl1 = loxxdynamiczone.dZone("sell", vel, sell1, dzper)
zli = loxxdynamiczone.dZone("sell", vel, 0.5 , dzper)
state = 0.
if sigtype == SM02
if (vel<sig)
state :=-1
if (vel>sig)
state := 1
else if sigtype == SM03
if (vel<zli)
state :=-1
if (vel>zli)
state := 1
else if sigtype == SM04
if (vel<bl1)
state :=-1
if (vel>sl1)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(vel, "Velocity", color = colorout, linewidth = 3)
plot(bl1, "Oversold", color = lightgreencolor)
plot(sl1, "Overbought", color = lightredcolor)
plot(zli, "Middle", color = bar_index % 2 ? color.white : na)
barcolor(colorbars ? colorout : na)
osc = vel
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 = sigtype == SM02 ? ta.crossover(vel, sig) : sigtype == SM03 ? ta.crossover(vel, zli) : ta.crossover(vel, sl1)
goShort = sigtype == SM02 ? ta.crossunder(vel, sig) : sigtype == SM03 ? ta.crossunder(vel, zli) : ta.crossunder(vel, bl1)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="CFB-Adaptive Velocity Histogram [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="CFB-Adaptive Velocity Histogram [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBearCond, title="Hidden Bear Divergence", message="CFB-Adaptive Velocity Histogram [Loxx]: Hidden Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bearCond, title="Regular Bear Divergence", message="CFB-Adaptive Velocity Histogram [Loxx]: Regular Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBullCond, title="Hidden Bull Divergence", message="CFB-Adaptive Velocity Histogram [Loxx]: Hidden Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bullCond, title="Regular Bull Divergence", message="CFB-Adaptive Velocity Histogram [Loxx]: Regular Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Relative Andean Scalping | https://www.tradingview.com/script/Pc13q4HI-Relative-Andean-Scalping/ | serkany88 | https://www.tradingview.com/u/serkany88/ | 549 | 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
// This script uses source code of Andean Oscilator by @alexgrover and Relative Bandwith Filter by @HeWhoMustNotBeNamed
// This is an experimental signal indicator and should be used with caution.
// © serkany88
//@version=5
indicator("Relative Andean Scalping", precision=3, overlay=true)
// Functions used later
f_ideal_TimesInLast(_cond, _len) => math.sum(_cond ? 1 : 0, _len)
//------------------------------------------------------------------------------
//Andean Settings and Calculation by @alexgrover
//-----------------------------------------------------------------------------{
and_length = input.int(100, minval=1, title='Andean Length', group='Andean Oscilator Settings')
and_sig_length = input.int(13, title='Andean Signal Length', group='Andean Oscilator Settings')
//Andean Calculation
var alpha = 2/(and_length+1)
var up1 = 0.,var up2 = 0.
var dn1 = 0.,var dn2 = 0.
C = close
O = open
up1 := nz(math.max(C, O, up1[1] - (up1[1] - C) * alpha), C)
up2 := nz(math.max(C * C, O * O, up2[1] - (up2[1] - C * C) * alpha), C * C)
dn1 := nz(math.min(C, O, dn1[1] + (C - dn1[1]) * alpha), C)
dn2 := nz(math.min(C * C, O * O, dn2[1] + (C * C - dn2[1]) * alpha), C * C)
bull = math.sqrt(dn2 - dn1 * dn1)
bear = math.sqrt(up2 - up1 * up1)
signal = ta.ema(math.max(bull, bear), and_sig_length)
//-----------------------------------------------------------------------------}
//------------------------------------------------------------------------------
//Relative Bandwith Filter by @HeWhoMustNotBeNamed
//-----------------------------------------------------------------------------{
import HeWhoMustNotBeNamed/enhanced_ta/14 as eta
bandType = input.string("KC", title="Bands Type", group="Relative Bandwith Filter Bands", options=["BB", "KC", "DC"])
bmasource = input.source(close, title="Bands Source", group="Relative Bandwith Filter Bands")
bmatype = input.string("linreg", title="Bands Type", group="Relative Bandwith Filter Bands", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"])
bmalength = input.int(34, title="Bands Length", group="Relative Bandwith Filter Bands")
multiplier = input.float(2.0, step=0.5, title="Bands Multiplier", group="Relative Bandwith Filter Bands")
useTrueRange = input.bool(true, title="Bands Use True Range (KC)", group="Relative Bandwith Filter Bands")
useAlternateSource = input.bool(false, title="Bands Use Alternate Source (DC)", group="Relative Bandwith Filter Bands")
bsticky = input.bool(true, title="Sticky Lines", group="Relative Bandwith Filter Bands")
atrLength = input.int(34, 'ATR Length', group='Relative Bandwith Filter ATR')
bbmatype = input.string("linreg", title="BBands Type", group="Relative Bandwith Filter BBands", options=["sma", "ema", "hma", "rma", "wma", "vwma", "linreg", "median"])
bbmalength = input.int(100, title="BBands Length", group="Relative Bandwith Filter BBands")
mmultiplier = input.float(1.0, step=0.5, title="BBands Multiplier", group="Relative Bandwith Filter BBands")
desiredCondition = input.string("Higher Bandwidth", "Desired Condition", options=["Higher Bandwidth", "Lower Bandwidth"], group="Relative Bandwith Filter")
referenceBand = input.string("Middle", options=["Upper", "Lower", "Middle"], group="Relative Bandwith Filter")
var cloudTransparency = 90
[bbmiddle, bbupper, bblower] = eta.bb(bmasource, bmatype, bmalength, multiplier, sticky=bsticky)
[kcmiddle, kcupper, kclower] = eta.kc(bmasource, bmatype, bmalength, multiplier, useTrueRange, sticky=bsticky)
[dcmiddle, dcupper, dclower] = eta.dc(bmalength, useAlternateSource, bmasource, sticky=bsticky)
upper = bandType == "BB"? bbupper : bandType == "KC"? kcupper : dcupper
lower = bandType == "BB"? bblower : bandType == "KC"? kclower : dclower
middle = bandType == "BB"? bbmiddle : bandType == "KC"? kcmiddle : dcmiddle
atr = ta.atr(atrLength)
relativeBandwidth = (upper-lower)/atr
[mmiddle, uupper, llower] = eta.bb(relativeBandwidth, bbmatype, bbmalength, mmultiplier, sticky=false)
reference = referenceBand == "Middle"? mmiddle : referenceBand == "Upper"? uupper : llower
bbsignal = relativeBandwidth > reference? 2 : 0
bbsignal := desiredCondition == "Lower Bandwidth"? math.abs(bbsignal-2) : bbsignal
//-----------------------------------------------------------------------------}
//------------------------------------------------------------------------------
//Entry Condition Signals
//-----------------------------------------------------------------------------{
longCond = relativeBandwidth < mmiddle and bull > bear and ta.crossover(bull, signal)
shortCond = relativeBandwidth < mmiddle and bear > bull and ta.crossover(bear, signal)
//Define last signal condition to update later
var bool last_signal = false
plotshape(longCond and not(last_signal), title='Long Signal', style=shape.labelup, location=location.belowbar, color=color.green, text='Long', textcolor=color.white, size=size.small)
plotshape(shortCond and not(last_signal), title='Short Signal', style=shape.labeldown, location=location.abovebar, color=color.red, text='Short', textcolor=color.white, size=size.small)
//Alerts
alertcondition(longCond and not(last_signal), "Long Signal", message='Long Signal at Price: {{close}} @ {{ticker}}')
alertcondition(shortCond and not(last_signal), "Short Signal", message='Short Signal at Price: {{close}} @ {{ticker}}')
alertcondition((longCond and not(last_signal)) or (shortCond and not(last_signal)), "Long or Short Signal", message='Signal at Price: {{close}} @ {{ticker}}')
//We check if there is any signal in last 5 bars and if there is we won't show any signal to avoid confusion and filter out some bad signals
last_signal := f_ideal_TimesInLast(longCond or shortCond, 5) >= 1 |
One-Sided Gaussian Support & Resistance Rate [Loxx] | https://www.tradingview.com/script/iuc6YQS1-One-Sided-Gaussian-Support-Resistance-Rate-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("One-Sided Gaussian Support & Resistance Rate [Loxx]",
shorttitle="OSGSRR [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crosses'
//ehlers 2-pole super smoother
_twopoless(float src, int len)=>
a1 = 0., b1 = 0.
coef1 = 0., coef2 = 0., coef3 = 0.
filt = 0., trig = 0.
a1 := math.exp(-1.414 * math.pi / len)
b1 := 2 * a1 * math.cos(1.414 * math.pi / len)
coef2 := b1
coef3 := -a1 * a1
coef1 := 1 - coef2 - coef3
filt := coef1 * src + coef2 * nz(filt[1]) + coef3 * nz(filt[2])
filt := bar_index < 3 ? src : filt
filt
_gaussian(size, x)=>
out = (math.exp(-x * x * 9 / ((size + 1) * (size + 1))))
out
//calc fibonacci numbers 0, 1, 1, 2, 3, 5, 8, 13, 21 ... etc
_fiblevels(len)=>
arr_levels = array.new_float(len, 0.)
t1 = 0, t2 = 1
nxt = t1 + t2
for i = 0 to len - 1
array.set(arr_levels, i, nxt)
t1 := t2
t2 := nxt
nxt := t1 + t2
arr_levels
//calc weights given fibo numbers and how many fibos chosen
_gaussout(levels)=>
perin = array.size(levels)
arr_gauss = matrix.new<float>(perin, perin, 0.)
for k = 0 to array.size(levels) - 1
sum = 0.
for i = 0 to perin - 1
if (i >= array.get(levels, k))
break
matrix.set(arr_gauss, i, k, _gaussian(array.get(levels, k), i))
sum += matrix.get(arr_gauss, i, k)
for i = 0 to perin - 1
if (i >= array.get(levels, k))
break
temp = matrix.get(arr_gauss, i, k) / sum
matrix.set(arr_gauss, i, k, temp)
arr_gauss
//calc moving average applying fibo numbers
_smthMA(level, src, per)=>
sum = 0.
lvltemp = _fiblevels(per)
gtemp = _gaussout(lvltemp)
for i = 0 to matrix.rows(gtemp) - 1
sum += matrix.get(gtemp, i, level) * nz(src)
sum
smthper = input.int(3, "Guassian Level Depth", maxval = 100, group= "Basic Settings")
extrasmthper = input.int(5, "Extra Smoothing Period", group= "Basic Settings")
SRPeriod = input.int(40, "Support/Resistance Period", group= "Basic Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03], group = "Signal Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = input.bool(true, "Show signals?", group = "UI Options")
lmax = smthper + 1
hsmth = _twopoless(high, extrasmthper)
lsmth = _twopoless(low, extrasmthper)
hl2smth = _twopoless(hl2, extrasmthper)
workh = _smthMA(smthper, hsmth, lmax)
workl = _smthMA(smthper, lsmth, lmax)
smin = ta.lowest(workl, SRPeriod)
smax = ta.highest(workh, SRPeriod)
Rate = 0.
if (smin != smax)
Rate := (_smthMA(smthper, hl2smth, lmax) - smin) / (smax - smin)
sig = Rate[1]
mid = .5
state = 0.
if sigtype == SM02
if (Rate < sig)
state :=-1
if (Rate > sig)
state := 1
else if sigtype == SM03
if (Rate < mid)
state :=-1
if (Rate > mid)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(Rate, "OS Gaussian SR Rate", color = colorout, linewidth = 3)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(Rate, sig) : ta.crossover(Rate, mid)
goShort = sigtype == SM02 ? ta.crossunder(Rate, sig) : ta.crossunder(Rate, mid)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="One-Sided Gaussian Support & Resistance Rate [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="One-Sided Gaussian Support & Resistance Rate [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx] | https://www.tradingview.com/script/hmHHH2cf-CFB-Adaptive-Williams-R-w-Dynamic-Zones-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 39 | 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("CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx]",
shorttitle='CFBAWPRDZ [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxdynamiczone/3
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
WprSmoothPhase = input.float(0., "WPR Jurik Phase", group = "WPR Settings")
WprSmoothDouble = input.bool(true, "WPR Double Juirk Smoothing?", group = "WPR Settings")
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "CFB Ingest Settings")
srcin = input.string("Close", "Source", group= "CFB Ingest 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)"])
nlen = input.int(50, "CFB Normal Period", minval = 1, group = "CFB Ingest Settings")
cfb_len = input.int(4, "CFB Depth", maxval = 10, group = "CFB Ingest Settings")
smth = input.int(8, "CFB Smooth Period", minval = 1, group = "CFB Ingest Settings")
slim = input.int(5, "CFB Short Limit", minval = 1, group = "CFB Ingest Settings")
llim = input.int(50, "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")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buy1 = input.float(0.1 , "Dynamic Zone Buy Probability Level 1", group = "Levels Settings", maxval = 0.5)
sell1 = input.float(0.1 , "Dynamic Zone Sell Probability Level 1", group = "Levels Settings", maxval = 0.5)
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)
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showsignals = 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
wpr = 0.
cfb_draft = loxxjuriktools.jcfb(src, cfb_len, smth)
cfb_pre =
CfbSmoothDouble ? loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(cfb_draft, jcfbsmlen, jcfbsmph), jcfbsmlen, jcfbsmph) :
loxxjuriktools.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))
hi = ta.highest(high, len_out_cfb)
lo = ta.lowest(low, len_out_cfb)
t31 = WprSmoothDouble ? loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(-100*(hi-src)/(hi-lo), len_out_cfb, WprSmoothPhase), len_out_cfb, WprSmoothPhase) :
loxxjuriktools.jurik_filt(-100*(hi-src)/(hi-lo), len_out_cfb, WprSmoothPhase)
t32 = WprSmoothDouble ? loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(0., len_out_cfb, WprSmoothPhase) , len_out_cfb, WprSmoothPhase) :
loxxjuriktools.jurik_filt(0., len_out_cfb, WprSmoothPhase)
wpr := hi!=lo ? t31 : t32
sig = wpr[1]
bl1 = loxxdynamiczone.dZone("buy", wpr, buy1, dzper)
sl1 = loxxdynamiczone.dZone("sell", wpr, sell1, dzper)
zli = loxxdynamiczone.dZone("sell", wpr, 0.5 , dzper)
state = 0.
if sigtype == SM02
if (wpr<sig)
state :=-1
if (wpr>sig)
state := 1
else if sigtype == SM03
if (wpr<zli)
state :=-1
if (wpr>zli)
state := 1
else if sigtype == SM04
if (wpr<bl1)
state :=-1
if (wpr>sl1)
state := 1
colorwpr = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(wpr, color = colorwpr, linewidth = 3)
plot(bl1, color = lightgreencolor)
plot(sl1, color = lightredcolor)
plot(zli, color = bar_index % 2 ? color.white : na)
barcolor(colorbars ? colorwpr : na)
osc = wpr
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 = sigtype == SM02 ? ta.crossover(wpr, sig) : sigtype == SM03 ? ta.crossover(wpr, zli) : ta.crossover(wpr, sl1)
goShort = sigtype == SM02 ? ta.crossunder(wpr, sig) : sigtype == SM03 ? ta.crossunder(wpr, zli) : ta.crossunder(wpr, bl1)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBearCond, title="Hidden Bear Divergence", message="CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx]: Hidden Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bearCond, title="Regular Bear Divergence", message="CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx]: Regular Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBullCond, title="Hidden Bull Divergence", message="CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx]: Hidden Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bullCond, title="Regular Bull Divergence", message="CFB-Adaptive, Williams %R w/ Dynamic Zones [Loxx]: Regular Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
|
SMA VWAP BANDS [qrsq] | https://www.tradingview.com/script/Aphv1j1L-SMA-VWAP-BANDS-qrsq/ | qrsq | https://www.tradingview.com/u/qrsq/ | 77 | 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/
// © qrsq
//@version=5
indicator("SMA VWAP BANDS", overlay=true, timeframe="")
ma(type, source, length, offset, sigma) =>
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)
"VWAP" => ta.vwap(source)
"ALMA" => ta.alma(source, length, offset, sigma)
len = input.int(200, title="Length", group="Options")
bandMultiplier = input.float(2, title="Bands Multiplier", step=0.1, group="Options")
showBands = input.bool(true, title="Show Bands", group="Options")
showHLArea = input.bool(true, title="Show High/Low Area", group="Options")
showClose = input.bool(true, title="Show Close", group="Options")
showCloudArea = input.bool(true, title="Show Cloud Area", group="Options")
typeMA = input.string(title = "Method 1", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "VWAP", "ALMA"], group="Smoothing")
offset = input.float(0.6, title="Offset (ALMA)")
sigma = input.float(2, title="Sigma (ALMA)")
volSma = ma(typeMA,volume, len, offset, sigma)
srcVolSmaClose = ma(typeMA,close*volume, len, offset, sigma)
srcVolSmaHigh = ma(typeMA,high*volume, len, offset, sigma)
srcVolSmaLow = ma(typeMA,low*volume, len, offset, sigma)
vwapHighClose = srcVolSmaClose / volSma
vwapHighHigh = srcVolSmaHigh / volSma
vwapHighLow = srcVolSmaLow / volSma
srcSrcVolSmaClose = ma(typeMA,volume * math.pow(close, 2), len, offset, sigma)
srcSrcVolSmaHigh = ma(typeMA,volume * math.pow(high, 2), len, offset, sigma)
srcSrcVolSmaLow = ma(typeMA,volume * math.pow(low, 2), len, offset, sigma)
stDevHighClose = math.sqrt(srcSrcVolSmaClose / volSma - math.pow(vwapHighClose, 2))
stDevHighHigh = math.sqrt(srcSrcVolSmaHigh / volSma - math.pow(vwapHighHigh, 2))
stDevHighLow = math.sqrt(srcSrcVolSmaLow / volSma - math.pow(vwapHighLow, 2))
edgeCol = color.new(#8aa29e, 0)
closeCol = color.new(#8aa29e, 0)
cloudCol = color.new(#686963, 95)
upperCloseVal = vwapHighClose + stDevHighClose * bandMultiplier
lowerCloseVal = vwapHighClose - stDevHighClose * bandMultiplier
upperClose = plot(showClose ? showBands ? upperCloseVal : na : na, title="Upper Close", color=closeCol)
lowerClose = plot(showClose ? showBands ? lowerCloseVal : na : na, title="Lower Close", color=closeCol)
midClose = plot(showClose ? vwapHighClose : na, title="Mid Close", color=closeCol)
midLow = plot(showHLArea ? vwapHighLow : na, title="MC Lower Edge", color=edgeCol)
midHigh = plot(showHLArea ? vwapHighHigh : na, title="MC Higher Edge", color=edgeCol)
lowLow = plot(showHLArea ? showBands ? vwapHighLow - stDevHighLow * bandMultiplier : na : na, title="LC Lower Edge", color=edgeCol)
lowHigh = plot(showHLArea ? showBands ? vwapHighHigh - stDevHighHigh * bandMultiplier : na : na, title="LC Upper Edge", color=edgeCol)
highLow = plot(showHLArea ? showBands ? vwapHighLow + stDevHighLow * bandMultiplier : na : na, title="HC Lower Edge", color=edgeCol)
highHigh = plot(showHLArea ? showBands ? vwapHighHigh + stDevHighHigh * bandMultiplier : na : na, title="HC Upper Edge", color=edgeCol)
fill(lowLow, lowHigh, color=showCloudArea?cloudCol:color.new(color.white, 100))
fill(midLow, midHigh, color=showCloudArea?cloudCol:color.new(color.white, 100))
fill(highLow, highHigh, color=showCloudArea?cloudCol:color.new(color.white, 100))
|
Multiple Frequency Volatility Correlation | https://www.tradingview.com/script/DHPw18Sb-Multiple-Frequency-Volatility-Correlation/ | RicardoSantos | https://www.tradingview.com/u/RicardoSantos/ | 965 | 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/
// © RicardoSantos
//@version=5
indicator(title='Multiple Frequency Volatility Correlation', shorttitle='MFVC', overlay=false)
// description:
// This is a complex indicator that looks to provide some insight
// into the correlation between volume and price volatility.
// Rising volatility is depicted with the color green while falling
// volatility is depicted with purple.
// Lightness of the color is used to depict the length of the window
// used, darker == shorter in the 0 -> 512 window range.
//
import RicardoSantos/ColorExtension/4 as colExt
// @function determines color and correlation level.
vc (window, smoothing) =>
float _price = ta.stdev(close, window)
float _vol = ta.stdev(volume, window)
float _cor = ta.correlation(_price, _vol, smoothing)
float _vol_filter = ta.rising(_price, 1) ? 100 : 300 // green : purple
float _win_filter = 25 + (window / 512) * 40 // higher value, lighter color
color _col = colExt.hsl(_vol_filter, 60, _win_filter, 20)
[_col, _cor]
//
int smoothing = input.int(10)
[c002, v002] = vc( 2, smoothing)
[c003, v003] = vc( 3, smoothing)
[c004, v004] = vc( 4, smoothing)
[c006, v006] = vc( 6, smoothing)
[c008, v008] = vc( 8, smoothing)
[c012, v012] = vc( 12, smoothing)
[c016, v016] = vc( 16, smoothing)
[c024, v024] = vc( 24, smoothing)
[c032, v032] = vc( 32, smoothing)
[c048, v048] = vc( 48, smoothing)
[c064, v064] = vc( 64, smoothing)
[c096, v096] = vc( 96, smoothing)
[c128, v128] = vc(128, smoothing)
[c192, v192] = vc(192, smoothing)
[c256, v256] = vc(256, smoothing)
[c384, v384] = vc(384, smoothing)
[c512, v512] = vc(512, smoothing)
array<float> data = array.from(
v002, v003, v004, v006, v008, v012, v016, v024, v032,
v048, v064, v096, v128, v192, v256, v384, v512
)
float min = array.min(data)
float max = array.max(data)
float avg = array.avg(data)
plot(series=v002, title='V002', color=c002, style=plot.style_circles)
plot(series=v003, title='V003', color=c003, style=plot.style_circles)
plot(series=v004, title='V004', color=c004, style=plot.style_circles)
plot(series=v006, title='V006', color=c006, style=plot.style_circles)
plot(series=v008, title='V008', color=c008, style=plot.style_circles)
plot(series=v012, title='V012', color=c012, style=plot.style_circles)
plot(series=v016, title='V016', color=c016, style=plot.style_circles)
plot(series=v024, title='V024', color=c024, style=plot.style_circles)
plot(series=v032, title='V032', color=c032, style=plot.style_circles)
plot(series=v048, title='V048', color=c048, style=plot.style_circles)
plot(series=v064, title='V064', color=c064, style=plot.style_circles)
plot(series=v096, title='V096', color=c096, style=plot.style_circles)
plot(series=v128, title='V128', color=c128, style=plot.style_circles)
plot(series=v192, title='V192', color=c192, style=plot.style_circles)
plot(series=v256, title='V256', color=c256, style=plot.style_circles)
plot(series=v384, title='V384', color=c384, style=plot.style_circles)
plot(series=v512, title='V512', color=c512, style=plot.style_circles)
plot(series=min, title='min', color=color.rgb(120, 123, 134, 40))
plot(series=max, title='max', color=color.rgb(120, 123, 134, 40))
plot(series=avg, title='avg', color=color.teal)
//
array<int> hist_values = array.new<int>(20, 0)
var array<box> hist_boxes = array.new<box>(20)
var array<box> hist_boxes1 = array.new<box>(20)
if barstate.isfirst
for _i = 0 to 19
array.set(hist_boxes, _i, box.new(0, 0.0, 0, 0.0))
array.set(hist_boxes1, _i, box.new(0, 0.0, 0, 0.0, bgcolor=color.rgb(243, 159, 33, 53)))
for _e in data
int _lvl = math.round(((1 + _e) / 2.0) * 19)
array.set(hist_values, _lvl, array.get(hist_values, _lvl) + 1)
int __sumlength = input.int(10)
int s00 = int(math.sum(array.get(hist_values, 00), __sumlength))
int s01 = int(math.sum(array.get(hist_values, 01), __sumlength))
int s02 = int(math.sum(array.get(hist_values, 02), __sumlength))
int s03 = int(math.sum(array.get(hist_values, 03), __sumlength))
int s04 = int(math.sum(array.get(hist_values, 04), __sumlength))
int s05 = int(math.sum(array.get(hist_values, 05), __sumlength))
int s06 = int(math.sum(array.get(hist_values, 06), __sumlength))
int s07 = int(math.sum(array.get(hist_values, 07), __sumlength))
int s08 = int(math.sum(array.get(hist_values, 08), __sumlength))
int s09 = int(math.sum(array.get(hist_values, 09), __sumlength))
int s10 = int(math.sum(array.get(hist_values, 10), __sumlength))
int s11 = int(math.sum(array.get(hist_values, 11), __sumlength))
int s12 = int(math.sum(array.get(hist_values, 12), __sumlength))
int s13 = int(math.sum(array.get(hist_values, 13), __sumlength))
int s14 = int(math.sum(array.get(hist_values, 14), __sumlength))
int s15 = int(math.sum(array.get(hist_values, 15), __sumlength))
int s16 = int(math.sum(array.get(hist_values, 16), __sumlength))
int s17 = int(math.sum(array.get(hist_values, 17), __sumlength))
int s18 = int(math.sum(array.get(hist_values, 18), __sumlength))
int s19 = int(math.sum(array.get(hist_values, 19), __sumlength))
int stotal = s00 + s01 + s02 + s03 + s04 + s05 + s06 + s07 + s08 + s09 + s10 + s11 + s12 + s13 + s14 + s15 + s16 + s17 + s18 + s19
get_sum(int idx)=>
int _a = switch idx
00 => s00
01 => s01
02 => s02
03 => s03
04 => s04
05 => s05
06 => s06
07 => s07
08 => s08
09 => s09
10 => s10
11 => s11
12 => s12
13 => s13
14 => s14
15 => s15
16 => s16
17 => s17
18 => s18
19 => s19
_a
//
for _i = 0 to 19
box _box = array.get(hist_boxes, _i)
float _pos = -1.0 + (_i / 10.0)
int _nhits = array.get(hist_values, _i)
int _nhits1 = get_sum(_i)
int _nhits1_perc = 100 * (_nhits1 / stotal)
box.set_lefttop( _box, 1 + bar_index , _pos + 0.1)
box.set_rightbottom(_box, 1 + bar_index + _nhits, _pos )
box.set_text( _box, str.format('{0} ( {1}%)', str.tostring(_nhits, '0'), str.tostring(100*(_nhits / 17),'0')))
box _box1 = array.get(hist_boxes1, _i)
box.set_lefttop( _box1, 1 + bar_index , _pos + 0.1)
box.set_rightbottom(_box1, int(1 + bar_index + _nhits1_perc), _pos )
box.set_text( _box1, str.format('{0} ( {1}%)', str.tostring(_nhits1, '0'), str.tostring(_nhits1_perc,'0')))
var label_top = label.new(x=bar_index, y= 1.0, color=color.silver, style=label.style_label_lower_left, text='high synchronicity', tooltip='there is high connection between price returns and volume change.\ngreen color: rising momentum.\npurple color: falling momentum.', size=size.small)
var label_bot = label.new(x=bar_index, y=-1.0, color=color.silver, style=label.style_label_upper_left, text='low synchronicity' , tooltip='there is low connection between price returns and volume change.\ngreen color: rising momentum.\npurple color: falling momentum.' , size=size.small)
label.set_x(label_top, bar_index)
label.set_x(label_bot, bar_index)
|
Multiple Moving Avg MTF Table | https://www.tradingview.com/script/IKBekTqK-Multiple-Moving-Avg-MTF-Table/ | jbritton001 | https://www.tradingview.com/u/jbritton001/ | 248 | 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/
// © jbritton001
// MA MTF v 1.5
// script will plot the smas on higher time frames
// Added Table
// Colored the MAs to make the plot colors
// fixed some floating issues .. along with corrected some request.security issues
// added XY code to where the table can be moved around
// fixed then broke ... fixed the data sourced in the Weekly coloumn but lost one
// added the wvma .. its plotted but NOT in the table as I have reached the number of security requests
// left in the commented out parts in case TV allows more then 40 security requests in the future
// removed EMA so the table is only SMA now.
// removed vwma
// FIXED FINALLY figured it out .. TUPLES TUPLES
// readded EMA and then add WMA
// ADDED VWMA
//@version=5
indicator(title="Multiple Moving Avg MTF Table", shorttitle="Multi MA MTF", overlay=true)
// BEGIN SCRIPT
choice = input.string(title="Moving Avarages", defval="SMA", options=["SMA", "EMA", "WMA","VWMA", "SMA Mobile"], tooltip="This options can be changes for ref or mobile as the size of the font will changed based on your selection")
s01 = input.int(title="SMA 1", defval=5, group='Simple Moving Avg')
s02 = input.int(title="SMA 2", defval=10, group='Simple Moving Avg')
s03 = input.int(title="SMA 3", defval=20, group='Simple Moving Avg')
s04 = input.int(title="SMA 4", defval=50, group='Simple Moving Avg')
s05 = input.int(title="SMA 5", defval=120, group='Simple Moving Avg')
s06 = input.int(title="SMA 6", defval=200, group='Simple Moving Avg')
// SMAs
sma1 = ta.sma(close, s01)
sma2 = ta.sma(close, s02)
sma3 = ta.sma(close, s03)
sma4 = ta.sma(close, s04)
sma5 = ta.sma(close, s05)
sma6 = ta.sma(close, s06)
// SMA Plots
plot(series=sma1, title='SMA 1', color=color.new(#9C27B0, 0), display = display.none) // Purple
plot(series=sma2, title='SMA 2', color=color.new(#FFEB3B, 0), display = display.none) // Yellow
plot(series=sma3, title='SMA 3', color=color.new(#00E676, 0), display = display.none) // Lime Green
plot(series=sma4, title='SMA 4', color=color.new(#2196F3, 0), display = display.none) // Blue
plot(series=sma5, title='SMA 5', color=color.gray, display = display.none) // White color.new(#FFFFFF, 0)
plot(series=sma6, title='SMA 6', color=color.new(#FF9800, 0), display = display.none) // Orange
// EMA values that can be changed
e01 = input.int(title="EMA 1", defval=5, group='Exponential Moving Avg')
e02 = input.int(title="EMA 2", defval=10,group='Exponential Moving Avg')
e03 = input.int(title="EMA 3", defval=20,group='Exponential Moving Avg')
e04 = input.int(title="EMA 4", defval=50,group='Exponential Moving Avg')
e05 = input.int(title="EMA 5", defval=120,group='Exponential Moving Avg')
e06 = input.int(title="EMA 6", defval=200,group='Exponential Moving Avg')
// EMAs
ema1 = ta.ema(close, e01)
ema2 = ta.ema(close, e02)
ema3 = ta.ema(close, e03)
ema4 = ta.ema(close, e04)
ema5 = ta.ema(close, e05)
ema6 = ta.ema(close, e06)
// EMA Plots
plot(series=ema1, title='EMA 1', color=color.new(#9C27B0, 0), display = display.none) // Purple
plot(series=ema2, title='EMA 2', color=color.new(#FFEB3B, 0), display = display.none) // Yellow
plot(series=ema3, title='EMA 3', color=color.new(#00E676, 0), display = display.none) // Lime Green
plot(series=ema4, title='EMA 4', color=color.new(#2196F3, 0), display = display.none) // Blue
plot(series=ema5, title='EMA 5', color=color.gray, display = display.none) // White
plot(series=ema6, title='EMA 6', color=color.new(#FF9800, 0), display = display.none) // Orange
// WMA
// WMA Inputs
w01 = input.int(title="WMA 1", defval=5, group='Weighted Moving Avg')
w02 = input.int(title="WMA 2", defval=10, group='Weighted Moving Avg')
w03 = input.int(title="WMA 3", defval=20, group='Weighted Moving Avg')
w04 = input.int(title="WMA 4", defval=50, group='Weighted Moving Avg')
w05 = input.int(title="WMA 5", defval=120, group='Weighted Moving Avg')
w06 = input.int(title="WMA 6", defval=200, group='Weighted Moving Avg')
// WMAs
wma1 = ta.wma(close, w01)
wma2 = ta.wma(close, w02)
wma3 = ta.wma(close, w03)
wma4 = ta.wma(close, w04)
wma5 = ta.wma(close, w05)
wma6 = ta.wma(close, w06)
// WMA Plots
plot(series=wma1, title='WMA 1', color=color.new(#9C27B0, 0), display = display.none) // Purple
plot(series=wma2, title='WMA 2', color=color.new(#FFEB3B, 0), display = display.none) // Yellow
plot(series=wma3, title='WMA 3', color=color.new(#00E676, 0), display = display.none) // Lime Green
plot(series=wma4, title='WMA 4', color=color.new(#2196F3, 0), display = display.none) // Blue
plot(series=wma5, title='WMA 5', color=color.gray, display = display.none) // White
plot(series=wma6, title='WMA 6', color=color.new(#FF9800, 0), display = display.none) // Orange
// VWMA
// VWMA Inputs
vw1 = input.int(title="VWMA 1", defval=5, group='Volume Weighted Moving Avg')
vw2 = input.int(title="VWMA 2", defval=10, group='Volume Weighted Moving Avg')
vw3 = input.int(title="VWMA 3", defval=20, group='Volume Weighted Moving Avg')
vw4 = input.int(title="VWMA 4", defval=50, group='Volume Weighted Moving Avg')
vw5 = input.int(title="VWMA 5", defval=120, group='Volume Weighted Moving Avg')
vw6 = input.int(title="VWMA 6", defval=200, group='Volume Weighted Moving Avg')
// VWMAs
vwma1 = ta.vwma(close, vw1)
vwma2 = ta.vwma(close, vw2)
vwma3 = ta.vwma(close, vw3)
vwma4 = ta.vwma(close, vw4)
vwma5 = ta.vwma(close, vw5)
vwma6 = ta.vwma(close, vw6)
// VWMA Plots
plot(series=vwma1, title='VWMA 1', color=color.new(#9C27B0, 0), display = display.none) // Purple
plot(series=vwma2, title='VWMA 2', color=color.new(#FFEB3B, 0), display = display.none) // Yellow
plot(series=vwma3, title='VWMA 3', color=color.new(#00E676, 0), display = display.none) // Lime Green
plot(series=vwma4, title='VWMA 4', color=color.new(#2196F3, 0), display = display.none) // Blue
plot(series=vwma5, title='VWMA 5', color=color.gray, display = display.none) // White
plot(series=vwma6, title='VWMA 6', color=color.new(#FF9800, 0), display = display.none) // Orange
// MTF requests SMA
[S1, S7, S13, S19, S25, S31] = request.security(syminfo.tickerid, "60", [sma1, sma2, sma3, sma4, sma5, sma6], lookahead=barmerge.lookahead_on)
[S2, S8, S14, S20, S26, S32] = request.security(syminfo.tickerid, "D", [sma1, sma2, sma3, sma4, sma5, sma6], lookahead=barmerge.lookahead_on)
[S3, S9, S15, S21, S27, S33] = request.security(syminfo.tickerid, "W", [sma1, sma2, sma3, sma4, sma5, sma6] , lookahead=barmerge.lookahead_on)
[S4, S10, S16, S22, S28, S34] = request.security(syminfo.tickerid, "M", [sma1, sma2, sma3, sma4, sma5, sma6] , lookahead=barmerge.lookahead_on)
[S5, S11, S17, S23, S29, S35] = request.security(syminfo.tickerid, "3M", [sma1, sma2, sma3, sma4, sma5, sma6] , lookahead=barmerge.lookahead_on)
[S6, S12, S18, S24, S30, S36] = request.security(syminfo.tickerid, "12M", [sma1, sma2, sma3, sma4, sma5, sma6] , lookahead=barmerge.lookahead_on)
// MTF EMA
[E1, E7, E13, E19, E25, E31] = request.security(syminfo.tickerid, "60", [ema1, ema2, ema3, ema4, ema5, ema6], lookahead=barmerge.lookahead_on)
[E2, E8, E14, E20, E26, E32] = request.security(syminfo.tickerid, "D", [ema1, ema2, ema3, ema4, ema5, ema6], lookahead=barmerge.lookahead_on)
[E3, E9, E15, E21, E27, E33] = request.security(syminfo.tickerid, "W", [ema1, ema2, ema3, ema4, ema5, ema6], lookahead=barmerge.lookahead_on)
[E4, E10, E16, E22, E28, E34] = request.security(syminfo.tickerid, "M", [ema1, ema2, ema3, ema4, ema5, ema6], lookahead=barmerge.lookahead_on)
[E5, E11, E17, E23, E29, E35] = request.security(syminfo.tickerid, "3M", [ema1, ema2, ema3, ema4, ema5, ema6], lookahead=barmerge.lookahead_on)
[E6, E12, E18, E24, E30, E36] = request.security(syminfo.tickerid, "12M", [ema1, ema2, ema3, ema4, ema5, ema6], lookahead=barmerge.lookahead_on)
// MTF WMA
[W1, W7, W13, W19, W25, W31] = request.security(syminfo.tickerid, "60", [wma1, wma2, wma3, wma4, wma5, wma6], lookahead=barmerge.lookahead_on)
[W2, W8, W14, W20, W26, W32] = request.security(syminfo.tickerid, "D", [wma1, wma2, wma3, wma4, wma5, wma6], lookahead=barmerge.lookahead_on)
[W3, W9, W15, W21, W27, W33] = request.security(syminfo.tickerid, "W", [wma1, wma2, wma3, wma4, wma5, wma6], lookahead=barmerge.lookahead_on)
[W4, W10, W16, W22, W28, W34] = request.security(syminfo.tickerid, "M", [wma1, wma2, wma3, wma4, wma5, wma6], lookahead=barmerge.lookahead_on)
[W5, W11, W17, W23, W29, W35] = request.security(syminfo.tickerid, "3M", [wma1, wma2, wma3, wma4, wma5, wma6], lookahead=barmerge.lookahead_on)
[W6, W12, W18, W24, W30, W36] = request.security(syminfo.tickerid, "12M", [wma1, wma2, wma3, wma4, wma5, wma6], lookahead=barmerge.lookahead_on)
// MTF VWMA
[VW1, VW7, VW13, VW19, VW25, VW31] = request.security(syminfo.tickerid, "60", [vwma1, vwma2, vwma3, vwma4, vwma5, vwma6], lookahead=barmerge.lookahead_on)
[VW2, VW8, VW14, VW20, VW26, VW32] = request.security(syminfo.tickerid, "D", [vwma1, vwma2, vwma3, vwma4, vwma5, vwma6], lookahead=barmerge.lookahead_on)
[VW3, VW9, VW15, VW21, VW27, VW33] = request.security(syminfo.tickerid, "W", [vwma1, vwma2, vwma3, vwma4, vwma5, vwma6], lookahead=barmerge.lookahead_on)
[VW4, VW10, VW16, VW22, VW28, VW34] = request.security(syminfo.tickerid, "M", [vwma1, vwma2, vwma3, vwma4, vwma5, vwma6], lookahead=barmerge.lookahead_on)
[VW5, VW11, VW17, VW23, VW29, VW35] = request.security(syminfo.tickerid, "3M", [vwma1, vwma2, vwma3, vwma4, vwma5, vwma6], lookahead=barmerge.lookahead_on)
[VW6, VW12, VW18, VW24, VW30, VW36] = request.security(syminfo.tickerid, "12M", [vwma1, vwma2, vwma3, vwma4, vwma5, vwma6], lookahead=barmerge.lookahead_on)
// Option Varible
c1 = "SMA"
c2 = "EMA"
c3 = "WMA"
c4 = "VWMA"
c1_m = "SMA Mobile"
// Custom function to truncate (cut) excess decimal places
truncate(_number, _decimalPlaces) =>
_factor = math.pow(10, _decimalPlaces)
int(_number * _factor) / _factor
//Table
TblY = input.string("top", "Table Position", inline = "11", options = ["top", "middle", "bottom"])
TblX = input.string("right", "", inline = "11", options = ["left", "center", "right"])
tTable = table.new(TblY + "_" + TblX, columns = 10, rows = 10, border_width = 1,border_color = color.black,frame_width = 1,frame_color = color.red, bgcolor=color.gray)
if barstate.islastconfirmedhistory or barstate.isrealtime
// SMA table
if choice == c1
t1 = str.tostring(s01)
t2 = str.tostring(s02)
t3 = str.tostring(s03)
t4 = str.tostring(s04)
t5 = str.tostring(s05)
t6 = str.tostring(s06)
table.cell(table_id = tTable, column = 0, row = 0, text = "SMA",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 0, text = "Current",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 1, text = t1 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 1, text = str.tostring(truncate(sma1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 0, row = 2, text = t2 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 2, text = str.tostring(truncate(sma2,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 3, text = t3 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 3, text = str.tostring(truncate(sma2,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 4, text = t4 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 4, text = str.tostring(truncate(sma4,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 5, text = t5,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 5, text = str.tostring(truncate(sma5,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 6, text = t6,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 6, text = str.tostring(truncate(sma6,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 0, text = "Hourly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 1, text = str.tostring(truncate(S1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 2, row = 2, text = str.tostring(truncate(S7,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 3, text = str.tostring(truncate(S13,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 4, text = str.tostring(truncate(S19,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 5, text = str.tostring(truncate(S25,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 6, text = str.tostring(truncate(S31,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 0, text = "Daily",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 1, text = str.tostring(truncate(S2,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 3, row = 2, text = str.tostring(truncate(S8,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 3, text = str.tostring(truncate(S14,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 4, text = str.tostring(truncate(S20,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 5, text = str.tostring(truncate(S26,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 6, text = str.tostring(truncate(S32,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 0, text = "Weekly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 1, text = str.tostring(truncate(S3,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 4, row = 2, text = str.tostring(truncate(S9,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 3, text = str.tostring(truncate(S15,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 4, text = str.tostring(truncate(S21,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 5, text = str.tostring(truncate(S27,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 6, text = str.tostring(truncate(S33,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 0, text = "Montly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 1, text = str.tostring(truncate(S4,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 5, row = 2, text = str.tostring(truncate(S10,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 3, text = str.tostring(truncate(S16,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 4, text = str.tostring(truncate(S22,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 5, text = str.tostring(truncate(S28,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 6, text = str.tostring(truncate(S34,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 0, text = "Quartly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 1, text = str.tostring(truncate(S5,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 6, row = 2, text = str.tostring(truncate(S11,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 3, text = str.tostring(truncate(S17,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 4, text = str.tostring(truncate(S23,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 5, text = str.tostring(truncate(S29,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 6, text = str.tostring(truncate(S35,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 0, text = "Yearly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 1, text = str.tostring(truncate(S6,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 7, row = 2, text = str.tostring(truncate(S12,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 3, text = str.tostring(truncate(S18,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 4, text = str.tostring(truncate(S24,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 5, text = str.tostring(truncate(S30,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 6, text = str.tostring(truncate(S36,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
else if choice == c1_m
t01 = str.tostring(s01)
t02 = str.tostring(s02)
t03 = str.tostring(s03)
t04 = str.tostring(s04)
t05 = str.tostring(s05)
t06 = str.tostring(s06)
table.cell(table_id = tTable, column = 0, row = 0, text = "SMA",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 0, text = "Current",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 1, text = t01 ,text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 1, text = str.tostring(truncate(sma1,2)),text_size = size.small,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 0, row = 2, text = t02 ,text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 2, text = str.tostring(truncate(sma2,2)),text_size = size.small,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 3, text = t03 ,text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 3, text = str.tostring(truncate(sma2,2)),text_size = size.small,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 4, text = t04 ,text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 4, text = str.tostring(truncate(sma4,2)),text_size = size.small,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 5, text = t05,text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 5, text = str.tostring(truncate(sma5,2)),text_size = size.small,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 6, text = t06,text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 6, text = str.tostring(truncate(sma6,2)),text_size = size.small,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 0, text = "Hourly",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 1, text = str.tostring(truncate(S1,2)),text_size = size.small,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 2, row = 2, text = str.tostring(truncate(S7,2)),text_size = size.small,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 3, text = str.tostring(truncate(S13,2)),text_size = size.small,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 4, text = str.tostring(truncate(S19,2)),text_size = size.small,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 5, text = str.tostring(truncate(S25,2)),text_size = size.small,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 6, text = str.tostring(truncate(S31,2)),text_size = size.small,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 0, text = "Daily",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 1, text = str.tostring(truncate(S2,2)),text_size = size.small,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 3, row = 2, text = str.tostring(truncate(S8,2)),text_size = size.small,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 3, text = str.tostring(truncate(S14,2)),text_size = size.small,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 4, text = str.tostring(truncate(S20,2)),text_size = size.small,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 5, text = str.tostring(truncate(S26,2)),text_size = size.small,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 6, text = str.tostring(truncate(S32,2)),text_size = size.small,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 0, text = "Weekly",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 1, text = str.tostring(truncate(S3,2)),text_size = size.small,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 4, row = 2, text = str.tostring(truncate(S9,2)),text_size = size.small,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 3, text = str.tostring(truncate(S15,2)),text_size = size.small,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 4, text = str.tostring(truncate(S21,2)),text_size = size.small,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 5, text = str.tostring(truncate(S27,2)),text_size = size.small,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 6, text = str.tostring(truncate(S33,2)),text_size = size.small,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 0, text = "Montly",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 1, text = str.tostring(truncate(S4,2)),text_size = size.small,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 5, row = 2, text = str.tostring(truncate(S10,2)),text_size = size.small,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 3, text = str.tostring(truncate(S16,2)),text_size = size.small,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 4, text = str.tostring(truncate(S22,2)),text_size = size.small,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 5, text = str.tostring(truncate(S28,2)),text_size = size.small,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 6, text = str.tostring(truncate(S34,2)),text_size = size.small,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 0, text = "Quartly",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 1, text = str.tostring(truncate(S5,2)),text_size = size.small,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 6, row = 2, text = str.tostring(truncate(S11,2)),text_size = size.small,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 3, text = str.tostring(truncate(S17,2)),text_size = size.small,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 4, text = str.tostring(truncate(S23,2)),text_size = size.small,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 5, text = str.tostring(truncate(S29,2)),text_size = size.small,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 6, text = str.tostring(truncate(S35,2)),text_size = size.small,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 0, text = "Yearly",text_size = size.small,text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 1, text = str.tostring(truncate(S6,2)),text_size = size.small,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 7, row = 2, text = str.tostring(truncate(S12,2)),text_size = size.small,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 3, text = str.tostring(truncate(S18,2)),text_size = size.small,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 4, text = str.tostring(truncate(S24,2)),text_size = size.small,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 5, text = str.tostring(truncate(S30,2)),text_size = size.small,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 6, text = str.tostring(truncate(S36,2)),text_size = size.small,bgcolor=color.new(#FF9800, 0),text_color = color.black)
// EMA Table
else if choice == c2
t7 = str.tostring(e01)
t8 = str.tostring(e02)
t9 = str.tostring(e03)
t10 = str.tostring(e04)
t11 = str.tostring(e05)
t12 = str.tostring(e06)
table.cell(table_id = tTable, column = 0, row = 0, text = "EMA",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 0, text = "Current",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 1, text = t7 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 1, text = str.tostring(truncate(ema1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 0, row = 2, text = t8 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 2, text = str.tostring(truncate(ema2,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 3, text = t9 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 3, text = str.tostring(truncate(ema2,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 4, text = t10 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 4, text = str.tostring(truncate(ema4,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 5, text = t11,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 5, text = str.tostring(truncate(ema5,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 6, text = t12,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 6, text = str.tostring(truncate(ema6,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 0, text = "Hourly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 1, text = str.tostring(truncate(E1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 2, row = 2, text = str.tostring(truncate(E7,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 3, text = str.tostring(truncate(E13,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 4, text = str.tostring(truncate(E19,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 5, text = str.tostring(truncate(E25,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 6, text = str.tostring(truncate(E31,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 0, text = "Daily",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 1, text = str.tostring(truncate(E2,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 3, row = 2, text = str.tostring(truncate(E8,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 3, text = str.tostring(truncate(E14,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 4, text = str.tostring(truncate(E20,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 5, text = str.tostring(truncate(E26,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 6, text = str.tostring(truncate(E32,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 0, text = "Weekly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 1, text = str.tostring(truncate(E3,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 4, row = 2, text = str.tostring(truncate(E9,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 3, text = str.tostring(truncate(E15,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 4, text = str.tostring(truncate(E21,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 5, text = str.tostring(truncate(E27,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 6, text = str.tostring(truncate(E33,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 0, text = "Montly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 1, text = str.tostring(truncate(E4,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 5, row = 2, text = str.tostring(truncate(E10,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 3, text = str.tostring(truncate(E16,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 4, text = str.tostring(truncate(E22,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 5, text = str.tostring(truncate(E28,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 6, text = str.tostring(truncate(E34,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 0, text = "Quartly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 1, text = str.tostring(truncate(E5,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 6, row = 2, text = str.tostring(truncate(E11,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 3, text = str.tostring(truncate(E17,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 4, text = str.tostring(truncate(E23,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 5, text = str.tostring(truncate(E29,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 6, text = str.tostring(truncate(E35,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 0, text = "Yearly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 1, text = str.tostring(truncate(E6,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 7, row = 2, text = str.tostring(truncate(E12,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 3, text = str.tostring(truncate(E18,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 4, text = str.tostring(truncate(E24,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 5, text = str.tostring(truncate(E30,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 6, text = str.tostring(truncate(E36,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
// WMA table
else if choice == c3
t13 = str.tostring(w01)
t14 = str.tostring(w02)
t15 = str.tostring(w03)
t16 = str.tostring(w04)
t17 = str.tostring(w05)
t18 = str.tostring(w06)
table.cell(table_id = tTable, column = 0, row = 0, text = "WMA",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 0, text = "Current",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 1, text = t13 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 1, text = str.tostring(truncate(wma1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 0, row = 2, text = t14 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 2, text = str.tostring(truncate(wma2,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 3, text = t15 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 3, text = str.tostring(truncate(wma2,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 4, text = t16 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 4, text = str.tostring(truncate(wma4,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 5, text = t17,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 5, text = str.tostring(truncate(wma5,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 6, text = t18,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 6, text = str.tostring(truncate(wma6,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 0, text = "Hourly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 1, text = str.tostring(truncate(W1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 2, row = 2, text = str.tostring(truncate(W7,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 3, text = str.tostring(truncate(W13,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 4, text = str.tostring(truncate(W19,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 5, text = str.tostring(truncate(W25,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 6, text = str.tostring(truncate(W31,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 0, text = "Daily",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 1, text = str.tostring(truncate(W2,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 3, row = 2, text = str.tostring(truncate(W8,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 3, text = str.tostring(truncate(W14,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 4, text = str.tostring(truncate(W20,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 5, text = str.tostring(truncate(W26,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 6, text = str.tostring(truncate(W32,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 0, text = "Weekly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 1, text = str.tostring(truncate(W3,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 4, row = 2, text = str.tostring(truncate(W9,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 3, text = str.tostring(truncate(W15,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 4, text = str.tostring(truncate(W21,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 5, text = str.tostring(truncate(W27,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 6, text = str.tostring(truncate(W33,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 0, text = "Montly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 1, text = str.tostring(truncate(W4,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 5, row = 2, text = str.tostring(truncate(W10,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 3, text = str.tostring(truncate(W16,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 4, text = str.tostring(truncate(W22,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 5, text = str.tostring(truncate(W28,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 6, text = str.tostring(truncate(W34,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 0, text = "Quartly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 1, text = str.tostring(truncate(W5,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 6, row = 2, text = str.tostring(truncate(W11,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 3, text = str.tostring(truncate(W17,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 4, text = str.tostring(truncate(W23,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 5, text = str.tostring(truncate(W29,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 6, text = str.tostring(truncate(W35,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 0, text = "Yearly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 1, text = str.tostring(truncate(W6,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 7, row = 2, text = str.tostring(truncate(W12,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 3, text = str.tostring(truncate(W18,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 4, text = str.tostring(truncate(W24,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 5, text = str.tostring(truncate(W30,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 6, text = str.tostring(truncate(W36,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
// VWMA table
else if choice == c4
t19 = str.tostring(vw1)
t20 = str.tostring(vw2)
t21 = str.tostring(vw3)
t22 = str.tostring(vw4)
t23 = str.tostring(vw5)
t24 = str.tostring(vw6)
table.cell(table_id = tTable, column = 0, row = 0, text = "VWMA",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 0, text = "Current",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 1, text = t19 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 1, text = str.tostring(truncate(vwma1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 0, row = 2, text = t20 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 2, text = str.tostring(truncate(vwma2,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 3, text = t21 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 3, text = str.tostring(truncate(vwma2,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 4, text = t22 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 4, text = str.tostring(truncate(vwma4,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 5, text = t23,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 5, text = str.tostring(truncate(vwma5,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 0, row = 6, text = t24,text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 1, row = 6, text = str.tostring(truncate(vwma6,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 0, text = "Hourly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 1, text = str.tostring(truncate(VW1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 2, row = 2, text = str.tostring(truncate(VW7,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 3, text = str.tostring(truncate(VW13,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 4, text = str.tostring(truncate(VW19,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 5, text = str.tostring(truncate(VW25,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 2, row = 6, text = str.tostring(truncate(VW31,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 0, text = "Daily",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 1, text = str.tostring(truncate(VW2,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 3, row = 2, text = str.tostring(truncate(VW8,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 3, text = str.tostring(truncate(VW14,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 4, text = str.tostring(truncate(VW20,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 5, text = str.tostring(truncate(VW26,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 3, row = 6, text = str.tostring(truncate(VW32,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 0, text = "Weekly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 1, text = str.tostring(truncate(VW3,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 4, row = 2, text = str.tostring(truncate(VW9,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 3, text = str.tostring(truncate(VW15,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 4, text = str.tostring(truncate(VW21,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 5, text = str.tostring(truncate(VW27,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 4, row = 6, text = str.tostring(truncate(VW33,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 0, text = "Montly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 1, text = str.tostring(truncate(VW4,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 5, row = 2, text = str.tostring(truncate(VW10,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 3, text = str.tostring(truncate(VW16,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 4, text = str.tostring(truncate(VW22,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 5, text = str.tostring(truncate(VW28,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 5, row = 6, text = str.tostring(truncate(VW34,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 0, text = "Quartly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 1, text = str.tostring(truncate(VW5,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 6, row = 2, text = str.tostring(truncate(VW11,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 3, text = str.tostring(truncate(VW17,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 4, text = str.tostring(truncate(VW23,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 5, text = str.tostring(truncate(VW29,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 6, row = 6, text = str.tostring(truncate(VW35,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 0, text = "Yearly",text_size = size.normal,text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 1, text = str.tostring(truncate(VW6,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.white)
table.cell(table_id = tTable, column = 7, row = 2, text = str.tostring(truncate(VW12,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 3, text = str.tostring(truncate(VW18,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 4, text = str.tostring(truncate(VW24,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 5, text = str.tostring(truncate(VW30,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = tTable, column = 7, row = 6, text = str.tostring(truncate(VW36,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
// END OF CODE |
Variety RSI of Adaptive Lookback Averages [Loxx] | https://www.tradingview.com/script/PyUEw7Je-Variety-RSI-of-Adaptive-Lookback-Averages-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("Variety RSI of Adaptive Lookback Averages [Loxx]",
shorttitle="VRSIALBA [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxvarietyrsi/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Slope'
SM03 = 'Middle Crosses'
_iLWMA(src, per)=>
lwma = src, workLwma = src
sumw = per, sum = per * src
for k = 1 to per - 1
weight = per - k
sumw += weight
sum += weight * nz(workLwma[k])
lwma := (sum/sumw)
lwma
_iRMA(src, per) =>
rma = src
rma := na(rma[1]) ? src : (src - nz(rma[1])) * (1/per) + nz(rma[1])
rma
_iEMA(src, per) =>
ema = src
ema := na(ema[1]) ? src : (src - nz(ema[1])) * (2 / (per + 1)) + nz(ema[1])
ema
_iSMA(src, per)=>
avg = src, k = 1, workSma = src
while k < per
avg += nz(workSma[k])
k += 1
out = avg/k
out
_albper(swingCount, speed)=>
swing = 0.
if bar_index > 3
if (high > nz(high[1]) and
nz(high[1]) > nz(high[2]) and
nz(low[2]) < nz(low[3]) and
nz(low[3]) < nz(low[4]))
swing := -1
if (low < nz(low[1]) and
nz(low[1]) < nz(low[2]) and
nz(high[2]) > nz(high[3]) and
nz(high[3]) > nz(high[4]))
swing := 1
swingBuffer = swing
k = 0, n = 0
while (k < bar_index) and (n < swingCount)
if(swingBuffer[k] != 0)
n += 1
k += 1
albPeriod = math.max(math.round((speed != 0 and swingCount != 0) ? k/swingCount/speed : k/swingCount), 1)
albPeriod
src = input.source(close, "Source", group = "Basic Settings")
type = input.string("SMA", "Source Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "Basic Settings")
inpPeriod = input.int(14, "RSI Period", group = "Basic Settings")
rsitype = input.string("Regular", "RSI Type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed"], group = "Basic Settings")
swingCount = input.int(5, "ALB Swing Count", group = "Adaptive Lookback Settings")
speed = input.float(0.5, "ALB Speed", group = "Adaptive Lookback Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03], group = "Signal Settings")
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)
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = input.bool(true, "Show signals?", group = "UI Options")
rsimode = switch rsitype
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
variant(type, src, len) =>
sig = 0.0
if type == "SMA"
sig := _iSMA(src, len)
else if type == "EMA"
sig := _iEMA(src, len)
else if type == "WMA"
sig := _iLWMA(src, len)
else if type == "RMA"
sig := _iRMA(src, len)
sig
albout = _albper(swingCount, speed)
src := variant(type, src, albout)
rsi = loxxvarietyrsi.rsiVariety(rsimode, src, inpPeriod)
sig = nz(rsi[1])
mid = 50
state = 0.
if sigtype == SM02
if (rsi<sig)
state :=-1
if (rsi>sig)
state := 1
else if sigtype == SM03
if (rsi<mid)
state :=-1
if (rsi>mid)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(rsi, "RSI", color = colorout, linewidth = 2)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(rsi, sig) : ta.crossover(rsi, mid)
goShort = sigtype == SM02 ? ta.crossunder(rsi, sig) : ta.crossunder(rsi, mid)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Variety RSI of Adaptive Lookback Averages [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Variety RSI of Adaptive Lookback Averages [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Operating Cash Flow on Total Assets Ratio | https://www.tradingview.com/script/7KlLIyVV-Operating-Cash-Flow-on-Total-Assets-Ratio/ | All_Verklempt | https://www.tradingview.com/u/All_Verklempt/ | 17 | 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/
// © All_Verklempt
//@version=5
indicator("Cash Flow on Total Assets Ratio", shorttitle="CFoTA", format=format.price, precision=2, overlay=false, timeframe="", timeframe_gaps=false)
// Formula
CF = request.financial(syminfo.tickerid, "CASH_F_OPERATING_ACTIVITIES", "TTM")
TA = request.financial(syminfo.tickerid, "TOTAL_ASSETS", "FY")
CFoTA = (CF/TA)
// Plot info
plot(CFoTA, linewidth=2, color=#2d82b7, style=plot.style_linebr)
|
Fed Net Liquidity Indicator | https://www.tradingview.com/script/OBJPsNq1-Fed-Net-Liquidity-Indicator/ | jlb05013 | https://www.tradingview.com/u/jlb05013/ | 1,413 | 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("Fed Net Liquidity Indicator", overlay=true, scale=scale.right)
i_res = input.timeframe('D', "Resolution", options=['D', 'W', 'M'])
unit_input = input.string('Millions', options=['Millions', 'Billions', 'Trillions'])
units = unit_input == 'Billions' ? 1e9 : unit_input == 'Millions' ? 1e6 : unit_input == 'Trillions' ? 1e12 : na
fed_bal = request.security('FRED:WALCL', i_res, close) // millions
tga = request.security('FRED:WTREGEN', i_res, close) // billions
rev_repo = request.security('FRED:RRPONTSYD', i_res, close) // billions
net_liquidity = (fed_bal - (tga + rev_repo)) / units
var net_liquidity_offset = 10 // 2-week offset for use with daily charts
if timeframe.isdaily
net_liquidity_offset := 10
if timeframe.isweekly
net_liquidity_offset := 2
if timeframe.ismonthly
net_liquidity_offset := 0
plot(net_liquidity, title='Net Liquidity', color=color.red, style=plot.style_line, offset=net_liquidity_offset, linewidth = 2)
|
Point of Control V2 | https://www.tradingview.com/script/5a8QKPSH-Point-of-Control-V2/ | JohnBaron | https://www.tradingview.com/u/JohnBaron/ | 1,575 | 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/
// © JohnBaron
//@version=5
indicator("Point of Control",shorttitle="POC",overlay=true,explicit_plot_zorder=true)
//======= Inputs
use_day=input.bool(false,"Daily Reset",group="Reset Trigger",tooltip="Priority Order Daily, Weekly, Candles")
use_week=input.bool(false,"Weekly Reset",group="Reset Trigger")
bars_ = input.int(800,title="# of Candles the reset",group="Reset Trigger",tooltip="Candles are counted from left to right")
//________Inputs for level increment
incr_in = input.float(0.,title="Price increment for levels, 0 will result in auto increment",group="Levels")
see_suggestion=input.bool(false,"Show Auto_Incr",group="Levels")
//________Inputs for display
show_hist=input.bool(false,title="Show historic POCs",group="Display" ,tooltip="Historical POC above/below current price")
show_grands=input.bool(false,"Show Grand POC",group="Display",tooltip="Top POC for the entire data set")
show_rank = input.bool(false,"Show Next 3 Chart POCs",group="Display", tooltip="Rank 2-4 POCs for the entire data set")
show_mnmx=input.bool(false,"Show upper and lower bounds",group="Display")
//======= Functions
Round_to_Level(s_,t_)=>
math.round(s_/t_)*t_
// Use average range across chart to estimate an increment
Auto_Incr()=>
avg_range = math.round_to_mintick(ta.cum(high-low)/(bar_index+1)) //calculate the running average of the range rounded to mintick
wn_ = avg_range/syminfo.mintick // transform and convert to whole number
pow_ = math.pow(10,int(math.log10(wn_))) //use only integer portion of log
target_ = 2*math.ceil(wn_/pow_)*syminfo.mintick*pow_ //transform back to scale
//=============== Main Execution
src_ = high
auto_incr = Auto_Incr() //Get auto_increment
incr_ = incr_in==0? auto_incr: incr_in //If input incr is 0 then use auto_incr
//______________ Set up variables
var bar_count =0
var ub_ = high
var lb_ = low
var max_v =0.
var POC_ = hlc3
var v_ = array.new_float(0,0.)
var p_ = array.new_float(0,0.)
var hp_ = array.new_float(0,0.)
var hv_ = array.new_float(0,0.)
var Grand_poc2 = 0.
var Grand_poc3 = 0.
var Grand_poc4 = 0.
var hist_POC_above=hlc3
var hist_POC_below=hlc3
var error= na(volume) //determine if volume is available for the symbol
if error
runtime.error("Indicator is only valid on symbols with volume data") //generate error message if no volume for symbol
new_day = timeframe.change("D") //bool true/false if new day
new_week= timeframe.change("W") //bool true/false if new week
//______________ reset based on day/week or # of bars
reset_ = switch
use_day => new_day
use_week => new_week
=> bar_count>=bars_
//______________ store last POC_ and reset for new POC development
if reset_ or bar_index==0
POC_idx = array.indexof(hp_,POC_)
if POC_idx == -1
array.push(hp_,POC_)
array.push(hv_,max_v)
else
hv_element=array.get(hv_,POC_idx)
array.set(hv_,POC_idx,max_v+hv_element)
bar_count:=0
ub_ := Round_to_Level(high,incr_)
lb_ := math.min(ub_-incr_,Round_to_Level(low,incr_))
array.clear(v_)
array.clear(p_)
array.push(v_,volume/2)
array.push(v_,volume/2)
array.push(p_, ub_)
array.push(p_, lb_)
bar_count +=1
///______________ if upper or lower bounder expands
break_up = math.max(0.,high - ub_)
breaK_dn = math.max(0.,lb_ - low)
max_incr = int(break_up/incr_)+ (break_up%incr_>0? 1:0)
min_decr = int(breaK_dn/incr_)+ (breaK_dn%incr_>0? 1:0)
//______________ Check for upper boundary change
//______________ If a change exists then place at the beginning of the array the new price levels
if max_incr>0
i=1
while i<= max_incr
vol_incr = volume/max_incr
ub_ += incr_
array.unshift(v_,vol_incr)
array.unshift(p_, ub_)
i+=1
//______________ Check for lower boundary change
//______________ If a change exists then place at the end of the array the new price levels
if min_decr>0
j=1
while j<= min_decr
vol_incr = volume/min_decr
lb_ -= incr_
array.push(v_,vol_incr)
array.push(p_, lb_)
j+=1
//______________ Array will be ordered from high to low for index 0 to array,size-1
//______________ If there is no change in the boundaries then locate current price in the defined categories
if max_incr==0 and min_decr==0
for [idx,element] in p_
if src_ > element and idx>0
v_element = array.get(v_,idx-1)
array.set(v_,idx-1, volume+v_element)
break
//______________ Find point of control
max_v :=array.max(v_)
max_idx = array.indexof(v_,max_v)
POC_ := array.get(p_,max_idx)
//=== Sort dataset POCs
hp_sorted_ =array.sort_indices(hp_,order.descending)
hv_sorted_ =array.sort_indices(hv_,order.descending)
//______________ Get historical POCs around current price
for [idx,element] in hp_sorted_
hp_value = array.get(hp_,element)
hist_POC_above := hp_value
if src_>hp_value
hist_POC_below:= hp_value
if idx>=1
higher_idx = array.get(hp_sorted_,idx-1)
hist_POC_above:= array.get(hp_, higher_idx)
break
//______________ find the POC for entire data set
max_max_idx = array.get(hv_sorted_,0)
Grand_POC = array.get(hp_,max_max_idx)
//______________ get the next 3 high volume levels
if array.size(hv_sorted_)>=4 and show_rank
max2_idx = array.get(hv_sorted_,1)
max3_idx = array.get(hv_sorted_,2)
max4_idx = array.get(hv_sorted_,3)
Grand_poc2 := array.get(hp_, max2_idx)
Grand_poc3 := array.get(hp_, max3_idx)
Grand_poc4 := array.get(hp_, max4_idx)
//=============== Plots and Drawings
plot(show_hist? hist_POC_above:na,color=color.aqua,style=plot.style_circles,linewidth=1,title="hist_POC_above")
plot(show_hist? hist_POC_below:na,color=color.aqua,style=plot.style_circles,linewidth=1,title="hist_POC_below")
plot(show_rank? Grand_poc4:na,color=color.fuchsia,style=plot.style_cross,linewidth=1,title="Grand POC_4")
plot(show_rank? Grand_poc3:na,color=color.fuchsia,style=plot.style_cross,linewidth=1,title="Grand POC_3")
plot(show_rank? Grand_poc2:na,color=color.fuchsia,style=plot.style_cross,linewidth=1,title="Grand POC_2")
plot(show_grands? Grand_POC:na,color=color.orange,style=plot.style_cross,linewidth=2,title="Grand POC_")
plot(show_mnmx? ub_:na,color=color.blue,title= "Upper Bound")
plot(show_mnmx? lb_:na, color=color.blue,title= "Lower Bound")
plot(POC_,color=color.yellow,style=plot.style_linebr,linewidth=1,title="POC_")
//______________ Setup label and line
var lab_1 = label.new(na,na,text=na,color=color.white,textcolor=color.black,size=size.small)
var line_1 = line.new(na,na,na,na,color=color.gray, style= line.style_dashed,extend=extend.both)
//______________ Show the auto increment value
if barstate.islast and see_suggestion
label.set_xy(lab_1,bar_index,high+2*incr_)
label.set_text(lab_1,str.tostring(auto_incr))
//______________ Draw Verticle line Marking the Reset Point
if reset_
line.set_xy1(line_1,bar_index,0.)
line.set_xy2(line_1,bar_index,close)
|
Stepped Moving Average of CCI [Loxx] | https://www.tradingview.com/script/xxKrWa8k-Stepped-Moving-Average-of-CCI-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 79 | 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("Stepped Moving Average of CCI [Loxx]",
overlay = false,
shorttitle='SMACCI [Loxx]',
timeframe="",
timeframe_gaps=true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Step-MA CCI Slope'
SM03 = 'CCI Middle Crosses'
SM04 = 'Step-MA CCI Middle Crosses'
SM05 = 'CCI, Step-MA CCI Crosses'
_stepma(_sense, _size, stepMulti, phigh, plow, pprice)=>
sensitivity = _sense, stepSize = _size, _trend = 0.
if (_sense == 0)
sensitivity := 0.0001
if (_size == 0)
stepSize := 0.0001
out = 0.
size = sensitivity * stepSize
_smax = phigh + 2.0 * size * stepMulti
_smin = plow - 2.0 * size * stepMulti
_trend := nz(_trend[1])
if (pprice > nz(_smax[1]))
_trend := 1
if (pprice < nz(_smin[1]))
_trend := -1
if (_trend == 1)
if (_smin <nz(_smin[1]))
_smin := nz(_smin[1])
out := _smin+size * stepMulti
if (_trend == -1)
if (_smax > nz(_smax[1]))
_smax := nz(_smax[1])
out := _smax - size * stepMulti
[out, _trend]
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "CCI Settings")
srcin = input.string("Typical", "Source", group= "CCI 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(50, "MA Period", group = "CCI Settings")
type = input.string("Smoother", "CCI Smoothing 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 = "CCI Settings")
smthper = input.int(5, "CCI Smoothing Period", group = "CCI Settings")
Sensitivity = input.float(4, "Sensivity Factor", group = "Step MA Settings")
StepSize = input.float(5, "Step Size", group = "Step MA Settings")
StepMultiplier = input.float(5, "Step Multiplier", group = "Step MA Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04, SM05], group = "Signal 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
avg = 0.
for k = 0 to per - 1
avg += nz(src[k])
avg /= per
dev = 0.
for k = 0 to per
dev += math.abs(nz(src[k]) - avg)
dev /= per
cci = 0.
if (dev != 0)
cci := (src - avg) / (0.015 * dev)
else
cci := 0.
cci := variant(type, cci, 5)
[val, trend] = _stepma(Sensitivity, StepSize, StepMultiplier, cci, cci, cci)
sigval = val[1]
mid = 0.
state = 0.
if sigtype == SM02
if (val < sigval)
state :=-1
if (val > sigval)
state := 1
else if sigtype == SM03
if (cci < mid)
state :=-1
if (cci > mid)
state := 1
else if sigtype == SM04
if (val < mid)
state :=-1
if (val > mid)
state := 1
else if sigtype == SM05
if (cci < val)
state :=-1
if (cci > val)
state := 1
colorout = state == 1 ? greencolor : redcolor
plot(val,"Step-MA CCI", color = colorout , linewidth = 3)
plot(cci, "CCI", color = color.white, linewidth = 1)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout: na)
goLong = sigtype == SM02 ? ta.crossover(val, sigval) : sigtype == SM03 ? ta.crossover(cci, mid) : sigtype == SM04 ? ta.crossover(val, mid) : ta.crossover(cci, val)
goShort = sigtype == SM02 ? ta.crossunder(val, sigval) : sigtype == SM03 ? ta.crossunder(cci, mid) : sigtype == SM04 ? ta.crossunder(val, mid) : ta.crossunder(cci, val)
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="Stepped Moving Average of CCI [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Stepped Moving Average of CCI [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Volatility Quality Index w/ Pips Filtering [Loxx] | https://www.tradingview.com/script/XpgWoidY-Volatility-Quality-Index-w-Pips-Filtering-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("Volatility Quality Index (VQI) w/ Pips Filtering [Loxx]",
shorttitle="VQIPF [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
_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
PriceSmoothing = input.int(5, "Source Smoothing Period", group= "Basic Settings")
PriceSmoothingMethod = input.string("Simple Moving Average - SMA", "Source Smoothing 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")
Ma1Period = input.int(9, "Fast Signal Period", group= "Basic Settings")
Ma1Method = input.string("Simple Moving Average - SMA", "Fast Signal Smoothing 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")
Ma2Period = input.int(200, "Slow Signal Preiod", group= "Basic Settings")
Ma2Method = input.string("Simple Moving Average - SMA", "Slow Signal Smoothing 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")
FilterInPips = input.float(1.9, "Filter in Pips", group= "Basic Settings")
rocfilt = input.int(10, "Rate of Change Period", group= "Basic Settings", tooltip = "Stridsman suggested to buy when VQI has increased in the previous 10 bars (use the SMAs ) and sell when it has decreased in the previous 10 bars. IMO, use this with your other indicators as a confirmation signal.")
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")
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
pipMultiplier = math.pow(10, _declen() % 2)
cHigh = variant(PriceSmoothingMethod, high, PriceSmoothing)
cLow = variant(PriceSmoothingMethod, low, PriceSmoothing)
cOpen = variant(PriceSmoothingMethod, open, PriceSmoothing)
cClose = variant(PriceSmoothingMethod, close, PriceSmoothing)
pClose = variant(PriceSmoothingMethod, nz(close[1]), PriceSmoothing)
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])
avg1 = variant(Ma1Method, val, Ma1Period)
avg2 = variant(Ma2Method, val, Ma2Period)
fill2in = (val > avg1) ? avg1 : (val < avg1) ? avg1 : val
colorout = fill2in > val ? redcolor : greencolor
fill1 = plot(val, "VQI", color = colorout)
fill2 = plot(fill2in, "Fast Signal", color = colorout)
outer = plot(avg2, "Slow Signal", color = color.white, linewidth = 2)
fill(fill1, fill2, colorout)
golongpre = ta.roc(val, rocfilt) > 0
goshortpre = ta.roc(val, rocfilt) < 0
goLong = golongpre and not golongpre[1]
goShort = goshortpre and not goshortpre[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 = "High Volatility", message = "Volatility Quality Index (VQI) w/ Pips Filtering [Loxx]: Uptrend\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Low Volatility", message = "Volatility Quality Index (VQI) w/ Pips Filtering [Loxx]: Downtrend\nSymbol: {{ticker}}\nPrice: {{close}}")
barcolor(colorbars ? colorout : na)
|
STD-Adaptive T3 Channel w/ Ehlers Swiss Army Knife Mod. [Loxx] | https://www.tradingview.com/script/Pzkuyy7y-STD-Adaptive-T3-Channel-w-Ehlers-Swiss-Army-Knife-Mod-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 201 | 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-Adaptive T3 Channel w/ Ehlers Swiss Army Knife Mod. [Loxx]",
shorttitle="STDAT3CESAKM [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
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 if (clean == "T3 Swiss Army Knife Mod")
alpha := (math.cos(2 * math.pi / per) + math.sin(2 * math.pi / per) - 1) / math.cos(2 * math.pi / per)
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", "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(35, "Period", group = "Basic Settings")
T3Hot = input.float(0.7, "T3 Factor", group = "Basic Settings")
T3Clean = input.string("T3 Swiss Army Knife Mod", "Swiss Army it?", options = ["T3 New", "T3 Swiss Army Knife Mod", "T3 Original"], group = "Basic Settings")
AdaptPeriod = input.int(24, "Adaptive Period", group = "Basic Settings")
atrper = input.int(72, "ATR Period", group = "Basic Settings")
mult = input.float(3., "ATR Multiplier", group = "Basic Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = 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
dev = ta.stdev(src, AdaptPeriod)
avg = ta.sma(dev, AdaptPeriod)
period = 0.
if (dev != 0)
period := per * avg / dev
else
period := per
if (period < 3)
period := 3
out = _iT3(src, period, T3Hot, T3Clean)
sig = out[1]
slope = 0.
if (out > sig)
slope := 1
if (out < sig)
slope := -1
atr = ta.atr(atrper)
smax = out + atr * mult
smin = out - atr * mult
colorout = slope == 1 ? greencolor : redcolor
plot(out, color = colorout, linewidth = 4)
plot(smax, color = bar_index % 2 ? color.gray : na, linewidth = 1)
plot(smin, color = bar_index % 2 ? color.gray : na, linewidth = 1)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(out, sig)
goShort = ta.crossunder(out, sig)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(goShort and showsignals, 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-Adaptive T3 Channel w/ Ehlers Swiss Army Knife Mod. [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="STD-Adaptive T3 Channel w/ Ehlers Swiss Army Knife Mod. [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
VHF-Adaptive T3 iTrend [Loxx] | https://www.tradingview.com/script/GVaN5ZdT-VHF-Adaptive-T3-iTrend-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator(title='VHF-Adaptive T3 iTrend [Loxx]',
overlay = false,
shorttitle='VHFAT3IT [Loxx]',
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", "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(34, "VHF Period Injest", group = "VHF Adaptive Settings")
t3hot = input.float(1, "T3 Factor", step = 0.01, maxval = 1, minval = 0, group = "T3 Settings")
t3swt = input.string("T3 New", "T3 Type", options = ["T3 New", "T3 Original"], group = "T3 Settings")
LevelBars = input.int(300, "Level Period", group = "Level Settings")
LevelFactor = input.float(0.283, "Level Factor", step = 0.001, group = "Level Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = 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
vmax = ta.highest(src, per)
vmin = ta.lowest(src, per)
noise = math.sum(math.abs(ta.change(src)), per)
vhf = (vmax - vmin) / noise
len = nz(int(-math.log(vhf) * per), 1)
len := len < 1 ? 1 : len
mv = _iT3(src, len, t3hot, t3swt)
fillu = (src - mv)
lup = fillu
filluz = 0
filld = (-(low + high - 2 * mv))
ldn = filld
filldz = 0
hi = math.max(fillu, filld)
for k = 1 to LevelBars
hi := math.max(hi, math.max(nz(fillu[k]), nz(filld[k])))
itrendc = 0.
itrend = hi * LevelFactor
itrendc := (fillu > itrend) ? 1 : (filld > itrend) ? 2 : 0
colorout = itrendc == 1 ? greencolor : itrendc == 2 ? redcolor : color.gray
flupl = plot(fillu, "Up", color = greencolor)
fldnl = plot(filld, "Down", color = redcolor)
plot(itrend, "itrend", color = colorout, linewidth = 2)
barcolor(colorbars ? colorout : na)
fillc = color.new(fillu > filld ? greencolor : redcolor, 80)
fill(flupl, fldnl, color =fillc)
goLong = ta.crossover(fillu, itrend)
goShort = ta.crossover(filld, itrend)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="VHF-Adaptive T3 iTrend [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="VHF-Adaptive T3 iTrend [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
2 EMA Pullback | https://www.tradingview.com/script/PkaTDC3Q-2-EMA-Pullback/ | Germangroa | https://www.tradingview.com/u/Germangroa/ | 65 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Germangroa
//@version=5
indicator(title='2 EMA Pullback', overlay=true)
//======= User input ========
//EMA 1
res1 = input.timeframe(title='EMA 1 Time Frame', defval='60', group="Long EMA")
len1 = input(title='EMA 1 Length', defval=26, group="Long EMA")
//col = input(title='Color', defval=true, group="Long EMA")
smooth1 = input(title='Smooth ?', defval=true, group="Long EMA")
//EMA 2
res2 = input.timeframe(title='EMA 2 Time Frame', defval='60', group="Short EMA")
len2 = input(title='EMA 2 Length', defval=12, group="Short EMA")
//col = input(title='Color', defval=true, group="Short EMA")
smooth2 = input(title='Smooth ?', defval=true, group="Short EMA")
//======= Calculate EMAs ========
//EMA 1
ema1 = ta.ema(close, len1)
emaSmooth1 = request.security(syminfo.tickerid, res1, ema1, barmerge.gaps_on, barmerge.lookahead_off)
emaStep1 = request.security(syminfo.tickerid, res1, ema1, barmerge.gaps_off, barmerge.lookahead_off)
//EMA 2
ema2 = ta.ema(close, len2)
emaSmooth2 = request.security(syminfo.tickerid, res2, ema2, barmerge.gaps_on, barmerge.lookahead_off)
emaStep2 = request.security(syminfo.tickerid, res2, ema2, barmerge.gaps_off, barmerge.lookahead_off)
UPtrend = ema2 > ema1
DOWNtrend = ema2 < ema1
//Draw EMA
plot(smooth1 ? emaSmooth1 : emaStep1, color=color.new(color.red, 40), linewidth=4, title='EMA 1', offset=15)
plot(smooth2 ? emaSmooth2 : emaStep2, color=color.new(color.blue, 40), linewidth=2, title='EMA 2', offset=15)
//================ Stoch RSI ==================
smoothK = input.int(3, "K", minval=1)
smoothD = input.int(3, "D", minval=1)
lengthRSI = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
LongStrength = k > d
ShortStrength = k < d
//=========== RSI =====================
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"Bollinger Bands" => 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)
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
maLengthInput = input.int(14, title="MA Length", group="MA Settings")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"
Xover = ta.crossover(rsi, 30) and rsi[1] < rsi
Xunder = ta.crossunder(rsi, 70) and rsi[1] > rsi
//========== Plots & Entrys =========
lo = LongStrength and Xover
sh = ShortStrength and Xunder
Long = lo and UPtrend
Short = sh and DOWNtrend
plotshape(lo ? 1 : na, style=shape.triangleup, color=color.new(color.green, 0),
location=location.belowbar, title='Bullish Signal', text="L", textcolor=color.new(color.white, 0))
plotshape(sh ? 1 : na, style=shape.triangledown, color=color.new(color.purple, 0),
location=location.abovebar, title='Bearish Signal', text='S', textcolor=color.new(color.white, 0))
|
ADXVMA iTrend [Loxx] | https://www.tradingview.com/script/ElulPGxT-ADXVMA-iTrend-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 117 | 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='ADXVMA iTrend [Loxx]',
overlay = false,
shorttitle='ADXVMAIT [Loxx]',
timeframe="",
timeframe_gaps=true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
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", "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(14, "Period", group = "iTrend Settings")
LevelBars = input.int(300, "Level Period", group = "Level Settings")
LevelFactor = input.float(0.283, "Level Factor", step = 0.001, group = "Level Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = 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
[mv, _, _] = loxxmas.adxvma(src, per)
fillu = (src - mv)
lup = fillu
filluz = 0
filld = (-(low + high - 2 * mv))
ldn = filld
filldz = 0
hi = math.max(fillu, filld)
for k = 1 to LevelBars
hi := math.max(hi, math.max(nz(fillu[k]), nz(filld[k])))
itrendc = 0.
itrend = hi * LevelFactor
itrendc := (fillu > itrend) ? 1 : (filld > itrend) ? 2 : 0
colorout = itrendc == 1 ? greencolor : itrendc == 2 ? redcolor : color.gray
flupl = plot(fillu, "Up", color = greencolor)
fldnl = plot(filld, "Down", color = redcolor)
plot(itrend, "itrend", color = colorout, linewidth = 2)
barcolor(colorbars ? colorout : na)
fillc = color.new(fillu > filld ? greencolor : redcolor, 80)
fill(flupl, fldnl, color =fillc)
goLong = ta.crossover(fillu, itrend)
goShort = ta.crossover(filld, itrend)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="ADXVMA iTrend [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="ADXVMA iTrend [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
ER-Adaptive ATR [Loxx] | https://www.tradingview.com/script/7ywmpaOY-ER-Adaptive-ATR-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 18 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("ER-Adaptive ATR [Loxx]",
shorttitle="ERAATR [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
src = input.source(hl2, "Source")
period = input.int(14, "ATR Period")
mper = (period > 1) ? period : 1
mfast = math.max(mper / 2.0, 1)
mslow = mper * 5
mperDiff = mslow - mfast
noise = 0., aatr = 0.
diff = math.abs(src - nz(src[1]))
signal = math.abs(src - nz(src[mper]))
noise := nz(noise[1]) + diff - nz(diff[mper])
avgper = (noise != 0) ? (signal / noise) * mperDiff + mfast : mper
aatr := nz(aatr[1]) + (2.0 / (1.0 + avgper)) * ((high - low) - nz(aatr[1]))
ratr = ta.atr(period)
plot(aatr, "ER-Adaptive ATR", color = greencolor, linewidth = 2)
plot(ratr, "Regular ATR", color = color.white, linewidth = 1)
|
Relative Bandwidth Filter | https://www.tradingview.com/script/5egLveLn-Relative-Bandwidth-Filter/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 1,130 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
// __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
// / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
// $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
// $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
// $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
// $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
// $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
// $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
// $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
//
//
//
//@version=5
indicator("Relative Bandwidth Filter")
import HeWhoMustNotBeNamed/enhanced_ta/14 as eta
bandType = input.string("KC", title="Type", group="Bands", options=["BB", "KC", "DC"])
bmasource = input.source(close, title="Source", group="Bands")
bmatype = input.string("sma", title="Type", group="Bands", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"])
bmalength = input.int(100, title="Length", group="Bands")
multiplier = input.float(2.0, step=0.5, title="Multiplier", group="Bands")
useTrueRange = input.bool(true, title="Use True Range (KC)", group="Bands")
useAlternateSource = input.bool(false, title="Use Alternate Source (DC)", group="Bands")
bsticky = input.bool(true, title="Sticky", group="Bands/Bandwidth/BandPercent")
atrLength = input.int(20, 'Length', group='ATR')
bbmatype = input.string("sma", title="Type", group="BBands", options=["sma", "ema", "hma", "rma", "wma", "vwma", "linreg", "median"])
bbmalength = input.int(100, title="Length", group="BBands")
mmultiplier = input.float(1.0, step=0.5, title="Multiplier", group="BBands")
desiredCondition = input.string("Higher Bandwidth", "Desired Condition", options=["Higher Bandwidth", "Lower Bandwidth"])
referenceBand = input.string("Middle", options=["Upper", "Lower", "Middle"])
var cloudTransparency = 90
[bbmiddle, bbupper, bblower] = eta.bb(bmasource, bmatype, bmalength, multiplier, sticky=bsticky)
[kcmiddle, kcupper, kclower] = eta.kc(bmasource, bmatype, bmalength, multiplier, useTrueRange, sticky=bsticky)
[dcmiddle, dcupper, dclower] = eta.dc(bmalength, useAlternateSource, bmasource, sticky=bsticky)
upper = bandType == "BB"? bbupper : bandType == "KC"? kcupper : dcupper
lower = bandType == "BB"? bblower : bandType == "KC"? kclower : dclower
middle = bandType == "BB"? bbmiddle : bandType == "KC"? kcmiddle : dcmiddle
atr = ta.atr(atrLength)
relativeBandwidth = (upper-lower)/atr
plot(relativeBandwidth, "Relative Bandwidth", color=color.purple)
[mmiddle, uupper, llower] = eta.bb(relativeBandwidth, bbmatype, bbmalength, mmultiplier, sticky=false)
plot(mmiddle, 'Middle', color=color.blue)
plot(uupper, 'Upper', color=color.green)
plot(llower, 'Lower', color=color.red)
reference = referenceBand == "Middle"? mmiddle : referenceBand == "Upper"? uupper : llower
signal = relativeBandwidth > reference? 2 : 0
signal := desiredCondition == "Lower Bandwidth"? math.abs(signal-2) : signal
plot(signal, "Signal", display=display.data_window)
|
Timed Alert | https://www.tradingview.com/script/WrG9bybW-Timed-Alert/ | PropTradingShop | https://www.tradingview.com/u/PropTradingShop/ | 145 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PropTradingShop
//@version=5
indicator("Timed Alert",overlay=true)
i_message=input.string("The closing price is {{close}}","Message",tooltip="Can use certain variables in the message. ex. {{close}} will replace with close price. https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/")
i_hour = input.int(9, "Hour",minval=0,maxval=24,step=1,inline="time",tooltip="Set to exchanges time, alert should be created on a timeframe that corresponds to alert time.")
i_minute = input.int(25, "Minute",minval=0,maxval=59,step=1,inline="time",tooltip="Set to exchanges time, alert should be created on a timeframe that corresponds to alert time.")
i_seconds = input.int(0, "Seconds",minval=0,maxval=59,step=1,inline="time",tooltip="Set to exchanges time, alert should be created on a timeframe that corresponds to alert time.")
is_time = i_hour == hour and i_minute == minute and i_seconds == second
plotchar(is_time,"⏰")
i_message := str.replace_all(i_message, "{{ticker}}", str.tostring(syminfo.ticker))
i_message := str.replace_all(i_message, "{{open}}", str.tostring(open))
i_message := str.replace_all(i_message, "{{high}}", str.tostring(high))
i_message := str.replace_all(i_message, "{{low}}", str.tostring(low))
i_message := str.replace_all(i_message, "{{close}}", str.tostring(close))
i_message := str.replace_all(i_message, "{{volume}}", str.tostring(volume))
if is_time
alert(str.tostring(i_message), alert.freq_once_per_bar)
|
BINANCE_Minimum_qty_for_trading | https://www.tradingview.com/script/VxllCmJC/ | potatoshop | https://www.tradingview.com/u/potatoshop/ | 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/
// © potatoshop
//@version=5
indicator("BINANCE_Minimum_qty_for_trading",precision=5)
ceil_truncate(float number, float min_unit = 1.0) =>
getDecimals = math.abs(math.log(min_unit) / math.log(10))
factor = math.pow(10, getDecimals)
math.ceil(number * factor) / factor
truncate(float number, float min_unit = 1.0) =>
getDecimals = math.abs(math.log(min_unit) / math.log(10))
factor = math.pow(10, getDecimals)
int(number * factor) / factor
////////////////////////////////////////////////////////////////////////////////
var min_unit_str=""
var m = matrix.new<string>(158,2)
matrix.set(m, 0, 0,"0.001"),matrix.set(m, 0, 1,"BCH")
matrix.set(m, 1, 0,"0.001"),matrix.set(m, 1, 1,"BTC")
matrix.set(m, 2, 0,"0.001"),matrix.set(m, 2, 1,"BTCDOM")
matrix.set(m, 3, 0,"0.001"),matrix.set(m, 3, 1,"COMP")
matrix.set(m, 4, 0,"0.001"),matrix.set(m, 4, 1,"DASH")
matrix.set(m, 5, 0,"0.001"),matrix.set(m, 5, 1,"DEFI")
matrix.set(m, 6, 0,"0.001"),matrix.set(m, 6, 1,"ETH")
matrix.set(m, 7, 0,"0.001"),matrix.set(m, 7, 1,"LTC")
matrix.set(m, 8, 0,"0.001"),matrix.set(m, 8, 1,"MKR")
matrix.set(m, 9, 0,"0.001"),matrix.set(m, 9, 1,"XMR")
matrix.set(m, 10, 0,"0.001"),matrix.set(m, 10,1,"YFI")
matrix.set(m, 11, 0,"0.001"),matrix.set(m, 11,1,"ZEC")
matrix.set(m, 12, 0,"0.01"),matrix.set(m, 12, 1,"ATOM")
matrix.set(m, 13, 0,"0.01"),matrix.set(m, 13, 1,"BNB")
matrix.set(m, 14, 0,"0.01"),matrix.set(m, 14, 1,"ETC")
matrix.set(m, 15, 0,"0.01"),matrix.set(m, 15, 1,"LINK")
matrix.set(m, 16, 0,"0.01"),matrix.set(m, 16, 1,"LTC")
matrix.set(m, 17, 0,"0.01"),matrix.set(m, 17, 1,"NEO")
matrix.set(m, 18, 0,"0.1"),matrix.set(m, 18, 1,"AAVE")
matrix.set(m, 19, 0,"0.1"),matrix.set(m, 19, 1,"ALGO")
matrix.set(m, 20, 0,"0.1"),matrix.set(m, 20, 1,"ALICE")
matrix.set(m, 21, 0,"0.1"),matrix.set(m, 21, 1,"ANT")
matrix.set(m, 22, 0,"0.1"),matrix.set(m, 22, 1,"APE")
matrix.set(m, 23, 0,"0.1"),matrix.set(m, 23, 1,"API3")
matrix.set(m, 24, 0,"0.1"),matrix.set(m, 24, 1,"AR")
matrix.set(m, 25, 0,"0.1"),matrix.set(m, 25, 1,"AUCTION")
matrix.set(m, 26, 0,"0.1"),matrix.set(m, 26, 1,"AVAX")
matrix.set(m, 27, 0,"0.1"),matrix.set(m, 27, 1,"BAL")
matrix.set(m, 28, 0,"0.1"),matrix.set(m, 28, 1,"BAND")
matrix.set(m, 29, 0,"0.1"),matrix.set(m, 29, 1,"BAT")
matrix.set(m, 30, 0,"0.1"),matrix.set(m, 30, 1,"BNX")
matrix.set(m, 31, 0,"0.1"),matrix.set(m, 31, 1,"CELO")
matrix.set(m, 32, 0,"0.1"),matrix.set(m, 32, 1,"CRV")
matrix.set(m, 33, 0,"0.1"),matrix.set(m, 33, 1,"CVX")
matrix.set(m, 34, 0,"0.1"),matrix.set(m, 34, 1,"DAR")
matrix.set(m, 35, 0,"0.1"),matrix.set(m, 35, 1,"DOT")
matrix.set(m, 36, 0,"0.1"),matrix.set(m, 36, 1,"DYDX")
matrix.set(m, 37, 0,"0.1"),matrix.set(m, 37, 1,"EGLD")
matrix.set(m, 38, 0,"0.1"),matrix.set(m, 38, 1,"ENS")
matrix.set(m, 39, 0,"0.1"),matrix.set(m, 39, 1,"EOS")
matrix.set(m, 40, 0,"0.1"),matrix.set(m, 40, 1,"ETC")
matrix.set(m, 41, 0,"0.1"),matrix.set(m, 41, 1,"FIL")
matrix.set(m, 42, 0,"0.1"),matrix.set(m, 42, 1,"FLOW")
matrix.set(m, 43, 0,"0.1"),matrix.set(m, 43, 1,"FTT")
matrix.set(m, 44, 0,"0.1"),matrix.set(m, 44, 1,"GMT")
matrix.set(m, 45, 0,"0.1"),matrix.set(m, 45, 1,"GTC")
matrix.set(m, 46, 0,"0.1"),matrix.set(m, 46, 1,"ICP")
matrix.set(m, 47, 0,"0.1"),matrix.set(m, 47, 1,"IOTA")
matrix.set(m, 48, 0,"0.1"),matrix.set(m, 48, 1,"KAVA")
matrix.set(m, 49, 0,"0.1"),matrix.set(m, 49, 1,"KLAY")
matrix.set(m, 50, 0,"0.1"),matrix.set(m, 50, 1,"KSM")
matrix.set(m, 51, 0,"0.1"),matrix.set(m, 51, 1,"LDO")
matrix.set(m, 52, 0,"0.1"),matrix.set(m, 52, 1,"LINK")
matrix.set(m, 53, 0,"0.1"),matrix.set(m, 53, 1,"LIT")
matrix.set(m, 54, 0,"0.1"),matrix.set(m, 54, 1,"LPT")
matrix.set(m, 55, 0,"0.1"),matrix.set(m, 55, 1,"NEAR")
matrix.set(m, 56, 0,"0.1"),matrix.set(m, 56, 1,"OMG")
matrix.set(m, 57, 0,"0.1"),matrix.set(m, 57, 1,"ONT")
matrix.set(m, 58, 0,"0.1"),matrix.set(m, 58, 1,"OP")
matrix.set(m, 59, 0,"0.1"),matrix.set(m, 59, 1,"QTUM")
matrix.set(m, 60, 0,"0.1"),matrix.set(m, 60, 1,"RAY")
matrix.set(m, 61, 0,"0.1"),matrix.set(m, 61, 1,"RLC")
matrix.set(m, 62, 0,"0.1"),matrix.set(m, 62, 1,"SAND")
matrix.set(m, 63, 0,"0.1"),matrix.set(m, 63, 1,"SNX")
matrix.set(m, 64, 0,"0.1"),matrix.set(m, 64, 1,"SXP")
matrix.set(m, 65, 0,"0.1"),matrix.set(m, 65, 1,"THETA")
matrix.set(m, 66, 0,"0.1"),matrix.set(m, 66, 1,"TRB")
matrix.set(m, 67, 0,"0.1"),matrix.set(m, 67, 1,"UNFI")
matrix.set(m, 68, 0,"0.1"),matrix.set(m, 68, 1,"UNI")
matrix.set(m, 69, 0,"0.1"),matrix.set(m, 69, 1,"WAVES")
matrix.set(m, 70, 0,"0.1"),matrix.set(m, 70, 1,"XRP")
matrix.set(m, 71, 0,"0.1"),matrix.set(m, 71, 1,"XTZ")
matrix.set(m, 72, 0,"0.1"),matrix.set(m, 72, 1,"ZEN")
matrix.set(m, 73, 0,"0.1"),matrix.set(m, 73, 1,"ZRX")
matrix.set(m, 74, 0,"1"),matrix.set(m, 74,1,"000LUNC")
matrix.set(m, 75, 0,"1"),matrix.set(m, 75,1,"000SHIB")
matrix.set(m, 76, 0,"1"),matrix.set(m, 76,1,"000XEC")
matrix.set(m, 77, 0,"1"),matrix.set(m, 77,1,"INCH")
matrix.set(m, 78, 0,"1"),matrix.set(m, 78,1,"DA")
matrix.set(m, 79, 0,"1"),matrix.set(m, 79,1,"LPHA")
matrix.set(m, 80, 0,"1"),matrix.set(m, 80,1,"NC")
matrix.set(m, 81, 0,"1"),matrix.set(m, 81,1,"NKR")
matrix.set(m, 82, 0,"1"),matrix.set(m, 82,1,"PE")
matrix.set(m, 83, 0,"1"),matrix.set(m, 83,1,"RPA")
matrix.set(m, 84, 0,"1"),matrix.set(m, 84,1,"TA")
matrix.set(m, 85, 0,"1"),matrix.set(m, 85,1,"UDIO")
matrix.set(m, 86, 0,"1"),matrix.set(m, 86,1,"VAX")
matrix.set(m, 87, 0,"1"),matrix.set(m, 87,1,"XS")
matrix.set(m, 88, 0,"1"),matrix.set(m, 88,1,"AKE")
matrix.set(m, 89, 0,"1"),matrix.set(m, 89,1,"EL")
matrix.set(m, 90, 0,"1"),matrix.set(m, 90,1,"LZ")
matrix.set(m, 91, 0,"1"),matrix.set(m, 91,1,"TS")
matrix.set(m, 92, 0,"1"),matrix.set(m, 92,1,"98")
matrix.set(m, 93, 0,"1"),matrix.set(m, 93,1,"ELR")
matrix.set(m, 94, 0,"1"),matrix.set(m, 94,1,"HR")
matrix.set(m, 95, 0,"1"),matrix.set(m, 95,1,"HZ")
matrix.set(m, 96, 0,"1"),matrix.set(m, 96,1,"OTI")
matrix.set(m, 97, 0,"1"),matrix.set(m, 97,1,"TK")
matrix.set(m, 98, 0,"1"),matrix.set(m, 98,1,"TSI")
matrix.set(m, 99, 0,"1"),matrix.set(m, 99,1,"VC")
matrix.set(m, 100, 0,"1"),matrix.set(m, 100,1,"DENT")
matrix.set(m, 101, 0,"1"),matrix.set(m, 101,1,"DGB")
matrix.set(m, 102, 0,"1"),matrix.set(m, 102,1,"DODO")
matrix.set(m, 103, 0,"1"),matrix.set(m, 103,1,"DOGE")
matrix.set(m, 104, 0,"1"),matrix.set(m, 104,1,"DUSK")
matrix.set(m, 105, 0,"1"),matrix.set(m, 105,1,"ENJ")
matrix.set(m, 106, 0,"1"),matrix.set(m, 106,1,"FLM")
matrix.set(m, 107, 0,"1"),matrix.set(m, 107,1,"FTM")
matrix.set(m, 108, 0,"1"),matrix.set(m, 108,1,"GAL")
matrix.set(m, 109, 0,"1"),matrix.set(m, 109,1,"GALA")
matrix.set(m, 110, 0,"1"),matrix.set(m, 110,1,"GMT")
matrix.set(m, 111, 0,"1"),matrix.set(m, 111,1,"GRT")
matrix.set(m, 112, 0,"1"),matrix.set(m, 112,1,"HBAR")
matrix.set(m, 113, 0,"1"),matrix.set(m, 113,1,"HNT")
matrix.set(m, 114, 0,"1"),matrix.set(m, 114,1,"HOT")
matrix.set(m, 115, 0,"1"),matrix.set(m, 115,1,"ICX")
matrix.set(m, 116, 0,"1"),matrix.set(m, 116,1,"IMX")
matrix.set(m, 117, 0,"1"),matrix.set(m, 117,1,"IOST")
matrix.set(m, 118, 0,"1"),matrix.set(m, 118,1,"IOTX")
matrix.set(m, 119, 0,"1"),matrix.set(m, 119,1,"JASMY")
matrix.set(m, 120, 0,"1"),matrix.set(m, 120,1,"KNC")
matrix.set(m, 121, 0,"1"),matrix.set(m, 121,1,"LEVER")
matrix.set(m, 122, 0,"1"),matrix.set(m, 122,1,"LINA")
matrix.set(m, 123, 0,"1"),matrix.set(m, 123,1,"LRC")
matrix.set(m, 124, 0,"1"),matrix.set(m, 124,1,"LUNA2")
matrix.set(m, 125, 0,"1"),matrix.set(m, 125,1,"MANA")
matrix.set(m, 126, 0,"1"),matrix.set(m, 126,1,"MASK")
matrix.set(m, 127, 0,"1"),matrix.set(m, 127,1,"MATIC")
matrix.set(m, 128, 0,"1"),matrix.set(m, 128,1,"MTL")
matrix.set(m, 129, 0,"1"),matrix.set(m, 129,1,"NEAR")
matrix.set(m, 130, 0,"1"),matrix.set(m, 130,1,"NKN")
matrix.set(m, 131, 0,"1"),matrix.set(m, 131,1,"OCEAN")
matrix.set(m, 132, 0,"1"),matrix.set(m, 132,1,"OGN")
matrix.set(m, 133, 0,"1"),matrix.set(m, 133,1,"ONE")
matrix.set(m, 134, 0,"1"),matrix.set(m, 134,1,"PEOPLE")
matrix.set(m, 135, 0,"1"),matrix.set(m, 135,1,"REEF")
matrix.set(m, 136, 0,"1"),matrix.set(m, 136,1,"REN")
matrix.set(m, 137, 0,"1"),matrix.set(m, 137,1,"ROSE")
matrix.set(m, 138, 0,"1"),matrix.set(m, 138,1,"RSR")
matrix.set(m, 139, 0,"1"),matrix.set(m, 139,1,"RUNE")
matrix.set(m, 140, 0,"1"),matrix.set(m, 140,1,"RVN")
matrix.set(m, 141, 0,"1"),matrix.set(m, 141,1,"SAND")
matrix.set(m, 142, 0,"1"),matrix.set(m, 142,1,"SFP")
matrix.set(m, 143, 0,"1"),matrix.set(m, 143,1,"SKL")
matrix.set(m, 144, 0,"1"),matrix.set(m, 144,1,"SOL")
matrix.set(m, 145, 0,"1"),matrix.set(m, 145,1,"SRM")
matrix.set(m, 146, 0,"1"),matrix.set(m, 146,1,"STMX")
matrix.set(m, 147, 0,"1"),matrix.set(m, 147,1,"STORJ")
matrix.set(m, 148, 0,"1"),matrix.set(m, 148,1,"SUSHI")
matrix.set(m, 149, 0,"1"),matrix.set(m, 149,1,"TLM")
matrix.set(m, 150, 0,"1"),matrix.set(m, 150,1,"TOMO")
matrix.set(m, 151, 0,"1"),matrix.set(m, 151,1,"TRX")
matrix.set(m, 152, 0,"1"),matrix.set(m, 152,1,"UNI")
matrix.set(m, 153, 0,"1"),matrix.set(m, 153,1,"VET")
matrix.set(m, 154, 0,"1"),matrix.set(m, 154,1,"WOO")
matrix.set(m, 155, 0,"1"),matrix.set(m, 155,1,"XEM")
matrix.set(m, 156, 0,"1"),matrix.set(m, 156,1,"XLM")
matrix.set(m, 157, 0,"1"),matrix.set(m, 157,1,"ZIL")
var bool is_right = false
for i=0 to 157
if syminfo.basecurrency == matrix.get(m,i,1) and syminfo.prefix == "BINANCE"
min_unit_str := matrix.get(m,i,0)
is_right := true
if is_right == false
runtime.error("hey~~!! it,s not Binance, check the exchange" )
min_notional_value = input.float(5,"min_notional_value") // Binance have chaged their Minimum notion value from 10 USD to 5 USD.
min_unit = str.tonumber(min_unit_str) // The minimum Limit Order amount for the contract.
maker_fee = input.float(0.02, "maker_fee %") // %
taker_fee = input.float(0.04, "taker_fee %") // %
cost = input.float(100.0,"your investing money") // dollar
maker_taker = input.string("M",title="maker_taker",options=["M","T"])
fee = maker_taker == "M"? maker_fee : taker_fee
min_qty = ceil_truncate(min_notional_value*(1+fee/100)/close,min_unit) // base coin
min_cost = (min_qty*close)*(1+fee/100)
posible_qty = truncate(cost/close,min_unit) >= min_qty? truncate(cost/close,min_unit) : 0 // Amount
how_many_unit = posible_qty/min_unit
how_much_cost = posible_qty*close
how_much_costwithfee = (posible_qty*close)*(1+fee/100)
plot(min_qty,"min_Q",color.blue)
plot(min_cost,"min_C",color.yellow)
plot(posible_qty,"posible_qty",color.white)
plot(how_many_unit,"how_many_min_unit",color.lime)
plot(how_much_cost,"just Q x C",color.gray)
plot(how_much_costwithfee,"real invest cost with fee",color.white)
|
MACDV DASHBOARD | https://www.tradingview.com/script/2Tke9ZF5-MACDV-DASHBOARD/ | WR_RT | https://www.tradingview.com/u/WR_RT/ | 951 | 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/
// © KP_House
//@version=5
indicator("MACDV DASHBOARD", overlay=true)
//Start dashboard
// ---- Table Settings Start ----//
max = 160 //Maximum Length
min = 10 //Minimum Length
// Input setting page start
dash_loc = input.session("Top Right","Dashboard Location" ,options=["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"] ,group='Style Settings')
text_size = input.session('Small',"Dashboard Size" ,options=["Tiny","Small","Normal","Large"] ,group='Style Settings')
cell_up = input.color(color.green,'Up Cell Color' ,group='Style Settings')
cell_dn = input.color(color.red,'Down Cell Color' ,group='Style Settings')
cell_Neut = input.color(color.gray,'Nochange Cell Color' ,group='Style Settings')
row_col = color.blue
col_col = color.white
txt_col = color.white
cell_transp = input.int(60,'Cell Transparency' ,minval=0 ,maxval=100 ,group='Style Settings')
Header_col = color.new(#a49627,50)
//MACDV color
cell_MACDV1 = input.color(color.teal,'Buy Risk' ,inline='indicator1',group='Style Settings')
cell_MACDV2 = input.color(color.green,'Rallying' ,inline='indicator1', group='Style Settings')
cell_MACDV3 = input.color(color.red,'Retracing' ,inline='indicator2', group='Style Settings')
cell_MACDV4 = input.color(color.yellow,'Ranging' ,inline='indicator2', group='Style Settings')
cell_MACDV5 = input.color(color.green,'Rebounding',inline='indicator3', group='Style Settings')
cell_MACDV6 = input.color(color.red,'Reverting' ,inline='indicator3', group='Style Settings')
cell_MACDV7 = input.color(color.maroon,'Sell Risk',inline='indicator4', group='Style Settings')
//Momentum color
cell_phase1 = input.color(color.green,'Phase1:Accumulation' ,inline='indicator6', group='Style Settings')
cell_phase2 = input.color(color.teal,'Phase2:Bullish' ,inline='indicator6', group='Style Settings')
cell_phase3 = input.color(color.red,'Phase3:Warning' ,inline='indicator7', group='Style Settings')
cell_phase4 = input.color(color.red,'Phase4:Distribution' ,inline='indicator7', group='Style Settings')
cell_phase5 = input.color(color.orange,'Phase5:Bearish' ,inline='indicator8', group='Style Settings')
cell_phase6 = input.color(color.green,'Phase6:Recovery' ,inline='indicator8', group='Style Settings')
// ---- Table Settings End ----}//
// ---- Indicators Show/Hide Settings Start ----//
showCls = input.bool(defval=true, title="Show Price Close", inline='indicator1', group="Columns Settings")
showMA01 = input.bool(defval=true, title="Show MA01", inline='indicator1', group="Columns Settings")
showMA02 = input.bool(defval=true, title="Show MA02", inline='indicator1', group="Columns Settings")
showRSI = input.bool(defval=true, title="Show RSI :", inline='indicator2', group="Columns Settings")
showADX = input.bool(defval=true, title="Show ADX", inline='indicator2', group="Columns Settings")
showMACDV = input.bool(defval=true, title="Show MACDV", inline='indicator2', group="Columns Settings")
showSignalV = input.bool(defval=true, title="Show SignalV", inline='indicator3', group="Columns Settings")
showMACDV_Status = input.bool(defval=true, title="Show MACDV_Status", inline='indicator3', group="Columns Settings")
showmomentum = input.bool(defval=true, title="Show Momentum", inline='indicator3', group="Columns Settings")
// ---- Indicators Show/Hide Settings end ----}//
// ---- Timeframe Row Show/Hide Settings Start ----//
showTF1 = input.bool(defval=true, title="Show TF MN", inline='indicator1',group="Rows Settings")
//---- Indicators code Start ----//
CLS= close[1]
//---- RSI code start ----//
rsiPeriod = 14
RSI = ta.rsi(close, rsiPeriod)
//---- RSI code end ----//
//---- EMA 1 code start----//
length_MA1 = input.int(title="MA1",defval=50, minval=1)
MA1 = ta.ema(close, length_MA1)
//plot(MA01, color=color.red, title="MA1")
//---- EMA 1 code end ----//
//---- EMA 2 code start---//
length_MA2 = input.int(title="MA2",defval=200, minval=1)
MA2 = ta.ema(close, length_MA2)
//plot(MA02, color=color.blue, title="MA2")
//---- EMA 2 code end ----//
//---- MACD-V code start ----//
MACD_fast_length = input(title="MACD Fast", defval=12)
MACD_slow_length = input(title="MACD Slow", defval=26)
MACD_signal_length = input.int(title="MACD Signal ", minval = 1, maxval = 50, defval = 9)
MACD_atr_length = input(title="ATR ", defval=26)
// Input seeting page end
// Calculating
fast_ma = ta.ema(close, MACD_fast_length)
slow_ma = ta.ema(close, MACD_slow_length)
atr = ta.atr(MACD_atr_length)
MACDV = (((fast_ma - slow_ma)/atr)*100)//[( 12 bar EMA - 26 bar EMA) / ATR(26) ] * 100
SignalV = ta.ema(MACDV, MACD_signal_length)
//---- MACD-V code end ----//
//---- Indicators code end ----//
//-----Condition start
stringmacdv =(MACDV>150) ? "Buy Risk" :(MACDV>50 and MACDV<150 and MACDV>SignalV ) ? "Rallying" :(MACDV>50 and MACDV<150 and MACDV<SignalV ) ? "Retracing":(MACDV<50) and (MACDV>-50) ? "Ranging" :(MACDV<-50 and MACDV>-150 and MACDV>SignalV ) ? "Rebounding":(MACDV<-50 and MACDV>-150 and MACDV<SignalV ) ? "Reversing":(MACDV<150) ? "Sell Risk" :na
//momentum
stringmomentum =(CLS>MA1 and CLS>MA2 and MA1<MA2) ? "Phase I Accumulation: Buy#2" :(CLS>MA1 and CLS>MA2 and MA1>MA2) ? "Phase II Bullish: Buy#Exit":(CLS<MA1 and CLS>MA2 and MA1>MA2) ? "Phase III Warning: Sell#1":(CLS<MA1 and CLS<MA2 and MA1>MA2) ? "Phase IV Distribution: Sell#2":(CLS<MA1 and CLS<MA2 and MA1<MA2) ? "Phase V Bearish: Sell#Exit":(CLS>MA1 and CLS<MA2 and MA1<MA2) ? "Phase IV Recovery: Entry#1":na
//-----Condition end
//-------------- Table code Start -------------------//
//---- Table Position & Size code start {----//
var table_position = dash_loc == 'Top Left' ? position.top_left :
dash_loc == 'Bottom Left' ? position.bottom_left :
dash_loc == 'Middle Right' ? position.middle_right :
dash_loc == 'Bottom Center' ? position.bottom_center :
dash_loc == 'Top Right' ? position.top_right : position.bottom_right
var table_text_size = text_size == 'Tiny' ? size.tiny :
text_size == 'Small' ? size.small :
text_size == 'Normal' ? size.normal : size.large
var t = table.new(table_position,15,math.abs(max-min)+2,
frame_color =color.new(#000000,0),
frame_width =1,
border_color =color.new(#000000,0),
border_width =1)
//---- Table Position & Size code end ----//
//---- Table Column & Rows code start ----//
if (barstate.islast)
//---- Table Main Column Headers code start ----//
if showCls
table.cell(t,1,1,'Close-1',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if showMA01
table.cell(t,2,1,'MA01',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if showMA02
table.cell(t,3,1,'MA02',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if showRSI
table.cell(t,4,1,'RSI 14',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if showMACDV
table.cell(t,5,1,'MACDV',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if SignalV
table.cell(t,6,1,'SignalV',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if showMACDV_Status
table.cell(t,7,1,'MACDV_Status',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if showmomentum
table.cell(t,8,1,'Momentum',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
//---- Table Main Column Headers code end ----//
//---- Display data code start ----//
//Month data strt
//atrD=request.security(syminfo.tickerid,"D",a)
// if showTF1
// table.cell(t,0,2, "M",text_color=col_col,text_size=table_text_size,bgcolor=Header_col)
if showCls
table.cell(t,1,2, str.tostring(CLS, '#.###'),text_color=color.new(CLS >CLS[2] ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(CLS >CLS[2] ? cell_up : cell_dn ,cell_transp))
if showMA01
table.cell(t,2,2, str.tostring(MA1, '#.###'),text_color=color.new(MA1 >MA1[1] ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(MA1 >MA1[1] ? cell_up : cell_dn ,cell_transp))
if showMA02
table.cell(t,3,2, str.tostring(MA2, '#.###'),text_color=color.new(MA2 >MA2[1] ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(MA2 >MA2[1] ? cell_up : cell_dn ,cell_transp))
if showRSI
table.cell(t,4,2, str.tostring(RSI, '#.###'),text_color=color.new(RSI > 50 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(RSI > 50 ? cell_up : cell_dn ,cell_transp))
if showMACDV
table.cell(t,5,2,str.tostring(MACDV, '#.###'),text_color=color.new(MACDV > MACDV[1] ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(MACDV > MACDV[1] ? cell_up : cell_dn ,cell_transp))
if showSignalV
table.cell(t,6,2,str.tostring(SignalV, '#.###'),text_color=color.new(SignalV > SignalV[1] ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(SignalV> SignalV[1] ? cell_up : cell_dn ,cell_transp))
if showMACDV_Status
table.cell(t,7,2,stringmacdv,text_color=color.white,text_size=table_text_size, bgcolor=color.new(MACDV>50 ? cell_up :MACDV<-50 ? cell_dn:cell_MACDV4 ,cell_transp))
if showmomentum
table.cell(t,8,2,stringmomentum,text_color=color.white,text_size=table_text_size, bgcolor=color.new(CLS>MA1 and CLS>MA2 and MA1<MA2 ? cell_phase1 : (CLS>MA1 and CLS>MA2 and MA1>MA2) ? cell_phase2 : (CLS<MA1 and CLS>MA2 and MA1>MA2) ?cell_phase3 :(CLS<MA1 and CLS<MA2 and MA1>MA2) ? cell_phase4:(CLS<MA1 and CLS<MA2 and MA1<MA2) ? cell_phase5:(CLS>MA1 and CLS<MA2 and MA1<MA2) ? cell_phase6:col_col,cell_transp))
//---- Display data code end ----//
//End dahs board
|
HDT Clouds | https://www.tradingview.com/script/gcoax69D-HDT-Clouds/ | Brettcorr64 | https://www.tradingview.com/u/Brettcorr64/ | 46 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
// Created by Brett. Credit goes to Ripster for the original creation of the clouds.
indicator("HDT Clouds","HDT Clouds", true)
matype = input.string(title="MA Type", defval="EMA", options=["EMA", "SMA"])
ma_len1 = input(title="Short EMA1 Length", defval=8)
ma_len2 = input(title="Long EMA1 Length", defval=9)
ma_len3 = input(title="Short EMA2 Length", defval=5)
ma_len4 = input(title="Long EMA2 Length", defval=13)
ma_len5 = input(title="Short EMA3 Length", defval=34)
ma_len6 = input(title="Long EMA3 Length", defval=50)
ma_len7 = input(title="Short EMA4 Length", defval=72)
ma_len8 = input(title="Long EMA4 Length", defval=89)
ma_len9 = input(title="Short EMA5 Length", defval=180)
ma_len10 = input(title="Long EMA5 Length", defval=200)
src = input(title="Source", defval=hl2)
ma_offset = input(title="Offset", defval=0)
//res = input(title="Resolution", type=resolution, defval="240")
f_ma(malen) =>
float result = 0
if (matype == "EMA")
result := ta.ema(src, malen)
if (matype == "SMA")
result := ta.sma(src, malen)
result
htf_ma1 = f_ma(ma_len1)
htf_ma2 = f_ma(ma_len2)
htf_ma3 = f_ma(ma_len3)
htf_ma4 = f_ma(ma_len4)
htf_ma5 = f_ma(ma_len5)
htf_ma6 = f_ma(ma_len6)
htf_ma7 = f_ma(ma_len7)
htf_ma8 = f_ma(ma_len8)
htf_ma9 = f_ma(ma_len9)
htf_ma10 = f_ma(ma_len10)
//plot(out1, color=green, offset=ma_offset)
//plot(out2, color=red, offset=ma_offset)
//lengthshort = input(8, minval = 1, title = "Short EMA Length")
//lengthlong = input(200, minval = 2, title = "Long EMA Length")
//emacloudleading = input(50, minval = 0, title = "Leading Period For EMA Cloud")
//src = input(hl2, title = "Source")
showlong = input(false, title="Show Long Alerts")
showshort = input(false, title="Show Short Alerts")
showLine = input(false, title="Display EMA Line")
ema1 = input(true, title="Show EMA Cloud-1")
ema2 = input(true, title="Show EMA Cloud-2")
ema3 = input(true, title="Show EMA Cloud-3")
ema4 = input(true, title="Show EMA Cloud-4")
ema5 = input(true, title="Show EMA Cloud-5")
emacloudleading = input.int(0, minval=0, title="Leading Period For EMA Cloud")
mashort1 = htf_ma1
malong1 = htf_ma2
mashort2 = htf_ma3
malong2 = htf_ma4
mashort3 = htf_ma5
malong3 = htf_ma6
mashort4 = htf_ma7
malong4 = htf_ma8
mashort5 = htf_ma9
malong5 = htf_ma10
cloudcolour1 = mashort1 >= malong1 ? #036103 : #880e4f
cloudcolour2 = mashort2 >= malong2 ? #4caf50 : #f44336
cloudcolour3 = mashort3 >= malong3 ? #2196f3 : #ffb74d
cloudcolour4 = mashort4 >= malong4 ? #009688 : #f06292
cloudcolour5 = mashort5 >= malong5 ? #05bed5 : #e65100
//03abc1
mashortcolor1 = mashort1 >= mashort1[1] ? color.olive : color.maroon
mashortcolor2 = mashort2 >= mashort2[1] ? color.olive : color.maroon
mashortcolor3 = mashort3 >= mashort3[1] ? color.olive : color.maroon
mashortcolor4 = mashort4 >= mashort4[1] ? color.olive : color.maroon
mashortcolor5 = mashort5 >= mashort5[1] ? color.olive : color.maroon
mashortline1 = plot(ema1 ? mashort1 : na, color=showLine ? mashortcolor1 : na, linewidth=1, offset=emacloudleading, title="Short Leading EMA1")
mashortline2 = plot(ema2 ? mashort2 : na, color=showLine ? mashortcolor2 : na, linewidth=1, offset=emacloudleading, title="Short Leading EMA2")
mashortline3 = plot(ema3 ?mashort3 : na, color=showLine ? mashortcolor3 : na, linewidth=1, offset=emacloudleading, title="Short Leading EMA3")
mashortline4 = plot(ema4 ? mashort4 :na , color=showLine ? mashortcolor4 : na, linewidth=1, offset=emacloudleading, title="Short Leading EMA4")
mashortline5 = plot(ema5 ? mashort5 : na, color=showLine ? mashortcolor5 : na, linewidth=1, offset=emacloudleading, title="Short Leading EMA5")
malongcolor1 = malong1 >= malong1[1] ? color.green : color.red
malongcolor2 = malong2 >= malong2[1] ? color.green : color.red
malongcolor3 = malong3 >= malong3[1] ? color.green : color.red
malongcolor4 = malong4 >= malong4[1] ? color.green : color.red
malongcolor5 = malong5 >= malong5[1] ? color.green : color.red
malongline1 = plot(ema1 ? malong1 : na, color=showLine ? malongcolor1 : na, linewidth=3, offset=emacloudleading, title="Long Leading EMA1")
malongline2 = plot(ema2 ? malong2 : na, color=showLine ? malongcolor2 : na, linewidth=3, offset=emacloudleading, title="Long Leading EMA2")
malongline3 = plot(ema3 ? malong3 : na, color=showLine ? malongcolor3 : na, linewidth=3, offset=emacloudleading, title="Long Leading EMA3")
malongline4 = plot(ema4 ? malong4 : na, color=showLine ? malongcolor4 : na, linewidth=3, offset=emacloudleading, title="Long Leading EMA4")
malongline5 = plot(ema5 ? malong5 : na, color=showLine ? malongcolor5 : na, linewidth=3, offset=emacloudleading, title="Long Leading EMA5")
emaBand = input.int(200, title="EMA cloud band")
smaBand = input.int(200, title="SMA cloud band")
showSmaAndEmaCloud = input(false, title="Show EMA/MA cloud with above values")
emaBandColor = #EE0000
smaBandColor = #00EE00
emaAndSmaCloudColor = #b5b5f5
emaBandPlot = plot(showSmaAndEmaCloud ? ta.ema(src, emaBand) : na, color=emaBandColor, offset=emacloudleading, title="EMA cloud band length")
smaBandPlot = plot(showSmaAndEmaCloud ? ta.sma(src, smaBand) : na, color=smaBandColor, offset=emacloudleading, title="SMA cloud band length")
fill(emaBandPlot, smaBandPlot, color=emaAndSmaCloudColor, transp=23, title="EMA and SMA Cloud")
fill(mashortline1, malongline1, color=cloudcolour1, transp=45, title="MA Cloud1")
fill(mashortline2, malongline2, color=cloudcolour2, transp=65, title="MA Cloud2")
fill(mashortline3, malongline3, color=cloudcolour3, transp=70, title="MA Cloud3")
fill(mashortline4, malongline4, color=cloudcolour4, transp=65, title="MA Cloud4")
fill(mashortline5, malongline5, color=cloudcolour5, transp=65, title="MA Cloud5")
var cumVol = 0.
cumVol += nz(volume)
if barstate.islast and cumVol == 0
runtime.error("No volume is provided by the data vendor.")
computeVWAP(src, isNewPeriod) =>
var float sumSrcVol = na
var float sumVol = na
var float sumSrcSrcVol = na
sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1]
sumVol := isNewPeriod ? volume : volume + sumVol[1]
// sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation
sumSrcSrcVol := isNewPeriod ? volume * math.pow(src, 2) : volume * math.pow(src, 2) + sumSrcSrcVol[1]
_vwap = sumSrcVol / sumVol
variance = sumSrcSrcVol / sumVol - math.pow(_vwap, 2)
variance := variance < 0 ? 0 : variance
stDev = math.sqrt(variance)
[_vwap, stDev]
computeStdevBands(value, stdev, bandMult) =>
float upperBand = value + stdev * bandMult
float lowerBand = value - stdev * bandMult
[upperBand, lowerBand]
hideonDWM = input(false, title="Hide VWAP on 1D or Above", group="VWAP Settings")
var anchor = input.string(defval = "Session", title="Anchor Period",
options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings")
srcVmap = input(title = "Source", defval = hlc3, group="VWAP Settings")
offset = input(0, title="Offset", group="VWAP Settings")
showBand_1 = input(true, title="", group="Standard Deviation Bands Settings", inline="band_1")
stdevMult_1 = input(1.0, title="Bands Multiplier #1", group="Standard Deviation Bands Settings", inline="band_1")
showBand_2 = input(false, title="", group="Standard Deviation Bands Settings", inline="band_2")
stdevMult_2 = input(2.0, title="Bands Multiplier #2", group="Standard Deviation Bands Settings", inline="band_2")
showBand_3 = input(false, title="", group="Standard Deviation Bands Settings", inline="band_3")
stdevMult_3 = input(3.0, title="Bands Multiplier #3", group="Standard Deviation Bands Settings", inline="band_3")
timeChange(period) =>
ta.change(time(period))
new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
isNewPeriod = switch anchor
"Earnings" => not na(new_earnings)
"Dividends" => not na(new_dividends)
"Splits" => not na(new_split)
"Session" => timeChange("D")
"Week" => timeChange("W")
"Month" => timeChange("M")
"Quarter" => timeChange("3M")
"Year" => timeChange("12M")
"Decade" => timeChange("12M") and year % 10 == 0
"Century" => timeChange("12M") and year % 100 == 0
=> false
isEsdAnchor = anchor == "Earnings" or anchor == "Dividends" or anchor == "Splits"
if na(srcVmap[1]) and not isEsdAnchor
isNewPeriod := true
float vwapValue = na
float stdev = na
float upperBandValue1 = na
float lowerBandValue1 = na
float upperBandValue2 = na
float lowerBandValue2 = na
float upperBandValue3 = na
float lowerBandValue3 = na
if not (hideonDWM and timeframe.isdwm)
[_vwap, _stdev] = computeVWAP(srcVmap, isNewPeriod)
vwapValue := _vwap
stdev := _stdev
[upBV1, loBV1] = computeStdevBands(vwapValue, stdev, stdevMult_1)
upperBandValue1 := showBand_1 ? upBV1 : na
lowerBandValue1 := showBand_1 ? loBV1 : na
[upBV2, loBV2] = computeStdevBands(vwapValue, stdev, stdevMult_2)
upperBandValue2 := showBand_2 ? upBV2 : na
lowerBandValue2 := showBand_2 ? loBV2 : na
[upBV3, loBV3] = computeStdevBands(vwapValue, stdev, stdevMult_3)
upperBandValue3 := showBand_3 ? upBV3 : na
lowerBandValue3 := showBand_3 ? loBV3 : na
plot(vwapValue, title="VWAP", color=#2962FF, offset=offset)
ma200Show = input(false, title="Show the 200MA line")
ma100Show = input(false, title="Show the 100MA line")
plot(ma200Show ? ta.sma(src, 200) : na, color=color.red, linewidth=1, title="MA 200")
plot(ma100Show ? ta.sma(src, 100) : na, color=color.green, linewidth=1, title="MA 100") |
Buy/Sell Signal Template/Boilerplate [JacobMagleby] | https://www.tradingview.com/script/FnhzVVQF-Buy-Sell-Signal-Template-Boilerplate-JacobMagleby/ | JacobMagleby | https://www.tradingview.com/u/JacobMagleby/ | 84 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ExoMaven
//@version=5
indicator(title = "Buy/Sell Signal Template/Boilerplate[ExoMaven]", shorttitle = "Buy/Sell Signal Template[V1]", overlay = true)
source = input.source(title = "Source", defval = ohlc4, group = "Source Settings")
buy_type = input.string(title = "Buy Type", defval = "Greater Than", options = ["Greater Than", "Less Than"], group = "Signal Settings")
buy_value = input.float(title = "Buy Value", defval = 50, group = "Signal Settings")
sell_type = input.string(title = "Sell Type", defval = "Less Than", options = ["Less Than", "Greater Than"], group = "Signal Settings")
sell_value = input.float(title = "Sell Value", defval = 50, group = "Signal Settings")
buy_above_or_below = buy_type == "Greater Than" ? source > buy_value and source[1] < buy_value : source < buy_value and source[1] > buy_value
sell_above_or_below = sell_type == "Less Than" ? source < sell_value and source[1] > sell_value : source > sell_value and source[1] < sell_value
buy = buy_above_or_below and barstate.isconfirmed
sell = sell_above_or_below and barstate.isconfirmed
if buy
label.new(x = bar_index, y = low, xloc = xloc.bar_index, text = "Buy", style = label.style_label_up, color = color.green, size = size.small, textcolor = color.white, textalign = text.align_center)
if sell
label.new(x = bar_index, y = high, xloc = xloc.bar_index, text = "Sell", style = label.style_label_down, color = color.red, size = size.small, textcolor = color.white, textalign = text.align_center)
|
Customizable Pivot Support/Resistance Zones [JacobMagleby] | https://www.tradingview.com/script/h9lmUIU2-Customizable-Pivot-Support-Resistance-Zones-JacobMagleby/ | JacobMagleby | https://www.tradingview.com/u/JacobMagleby/ | 1,540 | 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/
// © ExoMaven
//@version=5
indicator(title = "Customizable Pivot Support/Resistance Zones + Custom Filter Compatibility[ExoMaven]", shorttitle = "Customizable Pivot Support/Resistance Zones [V1]", overlay = true, max_lines_count = 500)
//PIVOT HIGH/LOW
left_bars = input.int(title = "Left Bars", defval = 25, group = "Pivot Settings", tooltip = "Amount of consecutive closing prices to the left of the point that must be above/below the point for a valid zone | DOES NOT AFFECT DELAY OF ZONE")
right_bars = input.int(title = "Right Bars", defval = 25, group = "Pivot Settings", tooltip = "Amount of consecutive closing prices to the right of the point that must be above/below the point for a valid zone | THE AMOUNT OF BARS IT TAKES FOR THE ZONE TO APPEAR OFF OF THE POINT IS DEPENDENT ON THIS SETTING. (i.e. if the right bars is set to 5, it will take 5 candles into the future before it will print in real-time)")
pivot_high = fixnan(ta.pivothigh(high, left_bars, right_bars))
pivot_low = fixnan(ta.pivotlow(low, left_bars, right_bars))
pivot_high_change = pivot_high != pivot_high[1] and barstate.isconfirmed
pivot_low_change = pivot_low != pivot_low[1] and barstate.isconfirmed
//CUSTOM SOURCES/CONDITIONS
use_custom_source1 = input.bool(title = "Enable Custom Source #1", defval = false, group = "Custom Indicator Filter", tooltip = "Check the box to enable this filter. If the box is unchecked, the filter will not apply and the indicator will calculate based only on the pivot points")
custom_source1 = input.source(title = "Custom Indicator Source #1", defval = ohlc4, group = "Custom Indicator Filter", tooltip = "You can select one of these built-in sources, or you can put any 1 indicator of your choice onto the chart alongside this indicator and will have the ability to select one of the external indicators values/outputs as the source, therefore allowing you to create your own custom filter")
binary_long1 = input.string(title = "Value Must Be (Above/Below/Equal) For Support", defval = "Above", options = ["Above", "Below", "Equal"], group = "Custom Indicator Filter", tooltip = "Choose if the Custom Indicator Value above must be above, below, or equal to the required value below for a 'Support Zone'")
required_long1 = input.float(title = "Value Requirement For Support", defval = 100, group = "Custom Indicator Filter", tooltip = "This is the value that the Custom Source above must be above or below for a zone to be valid for the creation of a 'Support Zone'")
use_close_for_required_long = input.bool(title = "Use Closing Price For Requirement For Support", defval = false, group = "Custom Indicator Filter", tooltip = "This will override the 'Value Requirement For Support' input in the above setting, allowing you to use indicators like 'Moving Average' for example. You can attach the 'Moving Average' indicator onto the indicator rather than something like an rsi and make a filter that requires the closing price to be above/below the 'Moving Average' for the zone")
binary_short1 = input.string(title = "Value Must Be (Above/Below/Equal) For Resistance", defval = "Below", options = ["Above", "Below", "Equal"], group = "Custom Indicator Filter", tooltip = "Choose if the Custom Indicator Value above must be above, below, or equal to the required value below for a 'Resistance Zone'")
required_short1 = input.float(title = "Value Requirement For Resistance", defval = 100, group = "Custom Indicator Filter", tooltip = "This is the value that the Custom Source above must be above or below for a zone to be valid for the creation of a 'Resistance Zone'")
use_close_for_required_short = input.bool(title = "Use Closing Price For Requirement For Resistance", defval = false, group = "Custom Indicator Filter", tooltip = "This will override the 'Value Requirement For Resistance' input in the above setting, allowing you to use indicators like 'Moving Average' for example. You can attach the 'Moving Average' indicator onto the indicator rather than something like an rsi and make a filter that requires the closing price to be above/below the 'Moving Average' for the zone")
final_required_long1 = use_close_for_required_long ? close[right_bars] : required_long1[right_bars]
final_required_short1 = use_close_for_required_short ? close[right_bars] : required_short1[right_bars]
custom1_long_is_true = use_custom_source1 ? (binary_long1 == "Above" ? custom_source1[right_bars] > final_required_long1 : binary_long1 == "Below" ? custom_source1[right_bars] < final_required_long1 : custom_source1[right_bars] == final_required_long1) : true
custom1_short_is_true = use_custom_source1 ? (binary_short1 == "Above" ? custom_source1[right_bars] > final_required_short1 : binary_short1 == "Below" ? custom_source1[right_bars] < final_required_short1 : custom_source1[right_bars] == final_required_short1) : true
//COLOR SETTINGS
support_line_color = input.color(title = "Support Edge Color", defval = color.green, group = "Color Settings")
support_linefill_color = input.color(title = "Support Background Color", defval = color.new(color.green, 50), group = "Color Settings")
resistance_line_color = input.color(title = "Resistance Edge Color", defval = color.red, group = "Color Settings")
resistance_linefill_color = input.color(title = "Resistance Background Color", defval = color.new(color.red, 50), group = "Color Settings")
change_colors_based_on_price = input.bool(title = "Change Colors According To Price", defval = true, group = "Color Settings", tooltip = "If enabled, when price is above a zone, the color will change to a support color, vise versa for when the price is below a zone.")
//NEW ZONE CONDITIONS
var line support_top_line = na
var line support_bot_line = na
var linefill support_line_fill = na
var line resistance_top_line = na
var line resistance_bot_line = na
var linefill resistance_line_fill = na
new_support = pivot_low_change and custom1_long_is_true
new_resistance = pivot_high_change and custom1_short_is_true
//MAIN-OP
support_top_value = close[right_bars] < open[right_bars] ? close[right_bars] : open[right_bars]
resistance_bot_value = close[right_bars] > open[right_bars] ? close[right_bars] : open[right_bars]
if new_support
support_top_line := line.new(x1 = bar_index[right_bars], y1 = support_top_value, x2 = bar_index, y2 = support_top_value, xloc = xloc.bar_index, color = support_line_color, extend = extend.none, style = line.style_solid, width = 2)
support_bot_line := line.new(x1 = bar_index[right_bars], y1 = low[right_bars], x2 = bar_index, y2 = low[right_bars], xloc = xloc.bar_index, color = support_line_color, extend = extend.none, style = line.style_solid, width = 2)
support_line_fill := linefill.new(line1 = support_top_line, line2 = support_bot_line, color = support_linefill_color)
if new_resistance
resistance_top_line := line.new(x1 = bar_index[right_bars], y1 = resistance_bot_value, x2 = bar_index, y2 = resistance_bot_value, xloc = xloc.bar_index, color = resistance_line_color, extend = extend.none, style = line.style_solid, width = 2)
resistance_bot_line := line.new(x1 = bar_index[right_bars], y1 = high[right_bars], x2 = bar_index, y2 = high[right_bars], xloc = xloc.bar_index, color = resistance_line_color, extend = extend.none, style = line.style_solid, width = 2)
resistance_line_fill := linefill.new(line1 = resistance_top_line, line2 = resistance_bot_line, color = resistance_linefill_color)
if barstate.isconfirmed
line.set_x2(support_top_line, bar_index)
line.set_x2(support_bot_line, bar_index)
line.set_x2(resistance_top_line, bar_index)
line.set_x2(resistance_bot_line, bar_index)
if change_colors_based_on_price
if close > line.get_y1(support_top_line)
line.set_color(support_top_line, support_line_color)
line.set_color(support_bot_line, support_line_color)
linefill.set_color(support_line_fill, support_linefill_color)
if close < line.get_y1(support_bot_line)
line.set_color(support_top_line, resistance_line_color)
line.set_color(support_bot_line, resistance_line_color)
linefill.set_color(support_line_fill, resistance_linefill_color)
if close > line.get_y1(resistance_top_line)
line.set_color(resistance_top_line, support_line_color)
line.set_color(resistance_bot_line, support_line_color)
linefill.set_color(resistance_line_fill, support_linefill_color)
if close < line.get_y1(resistance_bot_line)
line.set_color(resistance_top_line, resistance_line_color)
line.set_color(resistance_bot_line, resistance_line_color)
linefill.set_color(resistance_line_fill, resistance_linefill_color)
//ALERT CONDITIONS
new_support_created = new_support
new_resistance_created = new_resistance
support_top_line_value = line.get_y1(support_top_line)
support_bot_line_value = line.get_y1(support_bot_line)
resistance_top_line_value = line.get_y1(resistance_top_line)
resistance_bot_line_value = line.get_y1(resistance_bot_line)
close_crosses_below_top_zone = close < support_top_line_value and close[1] >= support_top_line_value and barstate.isconfirmed or close < resistance_top_line_value and close[1] >= resistance_top_line_value and barstate.isconfirmed
close_crosses_above_bot_zone = close > support_bot_line_value and close[1] <= support_bot_line_value and barstate.isconfirmed or close > resistance_bot_line_value and close[1] <= resistance_bot_line_value and barstate.isconfirmed
low_crosses_below_top_zone = low < support_top_line_value and low[1] >= support_top_line_value and barstate.isconfirmed or low < resistance_top_line_value and low[1] >= resistance_top_line_value and barstate.isconfirmed
high_crosses_above_bot_zone = high > support_bot_line_value and high[1] <= support_bot_line_value and barstate.isconfirmed or high > resistance_bot_line_value and high[1] <= resistance_bot_line_value and barstate.isconfirmed
close_is_inside_zone = close < support_top_line_value and close > support_bot_line_value and barstate.isconfirmed or close < resistance_top_line_value and close > resistance_bot_line_value and barstate.isconfirmed
close_is_touching_zone = close <= support_top_line_value and close >= support_bot_line_value and barstate.isconfirmed or close <= resistance_top_line_value and close >= resistance_bot_line_value and barstate.isconfirmed
breakout_to_upside = close > support_top_line_value and close[1] < support_top_line_value and barstate.isconfirmed or close > resistance_top_line_value and close[1] < resistance_top_line_value and barstate.isconfirmed
breakout_to_downside = close < support_bot_line_value and close[1] > support_bot_line_value and barstate.isconfirmed or close < resistance_bot_line_value and close[1] > resistance_bot_line_value and barstate.isconfirmed
alertcondition(condition = new_support_created, title = "New Support Created")
alertcondition(condition = new_resistance_created, title = "New Resistance Created")
alertcondition(condition = close_crosses_below_top_zone, title = "Close Crosses Below Top Of Zone")
alertcondition(condition = close_crosses_above_bot_zone, title = "Close Crosses Above Bottom Of Zone")
alertcondition(condition = low_crosses_below_top_zone, title = "Low Crosses Below Top Of Zone")
alertcondition(condition = high_crosses_above_bot_zone, title = "High Crosses Above Bottom Of Zone")
alertcondition(condition = close_is_inside_zone, title = "Close Is Inside Of Zone")
alertcondition(condition = close_is_touching_zone, title = "Close Is Touching Any Part Of The Zone")
alertcondition(condition = breakout_to_upside, title = "Close Breakout To The Upside")
alertcondition(condition = breakout_to_downside, title = "Close Breakout To The Downside")
|
CFB-Adaptive CCI w/ T3 Smoothing [Loxx] | https://www.tradingview.com/script/Ay9ot6VV-CFB-Adaptive-CCI-w-T3-Smoothing-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 59 | 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("CFB-Adaptive CCI w/ T3 Smoothing [Loxx]",
overlay = false,
shorttitle='CFBACCIT3 [Loxx]',
timeframe="",
timeframe_gaps=true)
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
_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(hlc3, "Source", group = "Basic Settings")
T3Hot = input.float(1.0, "T3 Factor", group = "Basic Settings")
T3Clean = input.string("T3 New", "Swiss Army it?", options = ["T3 New", "T3 Original"], group = "Basic Settings")
nlen = input.int(50, "CFB Normal Period", minval = 1, group = "CFB Ingest Settings")
cfb_len = input.int(4, "CFB Depth", maxval = 10, group = "CFB Ingest Settings")
smth = input.int(8, "CFB Smooth Period", minval = 1, group = "CFB Ingest Settings")
slim = input.int(5, "CFB Short Limit", minval = 1, group = "CFB Ingest Settings")
llim = input.int(50, "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")
sigtype = input.string(SM03, "Signal type", options = [SM03, SM04], group = "Signal Settings")
levelOs = input.int(-100, "Oversold Level", group = "Levels Settings")
levelOb = input.int(100, "Oversold Level", group = "Levels Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = input.bool(true, "Show signals?", group = "UI Options")
cfb_draft = loxxjuriktools.jcfb(src, cfb_len, smth)
cfb_pre = loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(cfb_draft, jcfbsmlen, jcfbsmph), 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))
avg = 0., dev = 0.
avg := math.sum(src, len_out_cfb) / len_out_cfb
for k = 0 to len_out_cfb - 1
dev += math.abs(nz(src[k]) - avg)
dev /= len_out_cfb
tempcci = _iT3((src - avg) / (0.015 * dev), len_out_cfb, T3Hot, T3Clean)
cci = dev != 0 ? tempcci : 0.
sig = nz(cci[1])
mid = 0.
state = 0.
if sigtype == SM03
if (cci < mid)
state :=-1
if (cci > mid)
state := 1
else if sigtype == SM04
if (cci > levelOb)
state := 1
if (cci < levelOs)
state := -1
if (cci > levelOs and cci < levelOb)
state := 0
colorout = state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(cci, "CFB-Adaptive T3 CCI", color = colorout, linewidth = 3, style = plot.style_histogram)
plot(levelOs, "Oversold", color = bar_index % 2 ? color.gray : na)
plot(levelOb, "Overbought", color = bar_index % 2 ? color.gray : na)
plot(mid, "Middle", color = bar_index % 2 ? color.white : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM03 ? ta.crossover(cci, mid) : ta.crossover(cci, levelOb)
goShort = sigtype == SM03 ? ta.crossunder(cci, mid) : ta.crossunder(cci, levelOs)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, 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 CCI w/ T3 Smoothing [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="CFB-Adaptive CCI w/ T3 Smoothing [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Day Week Month High & Low | https://www.tradingview.com/script/tIruAR17-Day-Week-Month-High-Low/ | sxiong1111 | https://www.tradingview.com/u/sxiong1111/ | 49 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sxiong1111
// Script Created On: 7/28/2022
// Script Updated On: 8/9/2022
// Script Version: 1.2
// Description:
//@version=5
indicator(title = "Day Week Month High & Low", shorttitle = "DWM High & Low", overlay = true)
// Variables and Inputs
userTimeFrame2D = input.bool(false, "Show 2-Day High & Low Instead of current Day, Week or Month?", tooltip = "Enabling this, overrides/ignores the timeframe setting directly below.\n\nThis setting shows the 2-Day high and low. It compares the latest trading day with the previous trading day and shows the highest of the two & shows the lowest of the two.", group = "Settings")
userTimeFrame = input.timeframe(title = "Timeframe", defval = "D", options = ['60', 'D', 'W', 'M'], tooltip = "You can choose from HOUR (60), DAY (D), WEEK (W) or MONTH (M).\n\nThis indicator was specifically designed for showing the high & low for the DAY, WEEK or MONTH timeframe, but for those who are day trading and like to keep tight entries & stops, can use the 1 hour timeframe setting. Please note that each time an hour has passed (when the market is currently open), the 1 hour timeframe setting resets to use the current 1 hour bar. This can be useful for those who scalp trades.", group = "Settings")
lineColorH = input.color(title = "Day, Week or Month High Line Color", defval = color.new(#F19CBB, 60), tooltip = "Color for the high line.", group = "Settings")
lineColorL = input.color(title = "Day, Week or Month Low Line Color", defval = color.new(#F19CBB, 60), tooltip = "Color for the low line.", group = "Settings")
lineStyle = input.string(defval = "Dashed", title = "Line Style", options = ["Dashed", "Dotted", "Solid"], tooltip = "You can choose the line style as DASHED, DOTTED or SOLID.", group = "Settings")
lineAlt = input.bool(false, "Change the Line Color If the Day High/Low Matches Week High/Low?", tooltip = "This setting only works if the chosen timeframe is set to the DAY timeframe (and also works if you enable the 2-Day high & low). This setting could potentially benefit swing traders who opens & closes trades on a weekly basis.\n\nAllows you to use an alternate color (that you can define directly below) when the Day's High or Low matches the Week's High or Low.\n\nThis could potentially signify a resistance or support level for the week. Normally, this wouldn't be valid or make sense on the first trading day of the week, since the day's high & low is always the same as the week's high & low (on the first trading day of the week).", group = "Settings")
lineColorAltH = input.color(title = "Day High Line Color (if the Day's High Matches the Week's High)", defval = color.new(#FFBF00, 40), tooltip = "Color for the high line (if the timeframe setting is set to DAY and the day's high matches the week's high).", group = "Settings")
lineColorAltL = input.color(title = "Day Low Line Color (if the Day's Low Matches the Week's Low)", defval = color.new(#FFBF00, 40), tooltip = "Color for the low line (if the timeframe setting is set to DAY and the day's low matches the week's low).", group = "Settings")
var price2D_High = 0.0
var price2D_Low = 0.0
priceH_High = request.security(syminfo.tickerid, "60", high)
priceH_Low = request.security(syminfo.tickerid, "60", low)
pricePD_High = request.security(syminfo.tickerid, "D", high[1])
pricePD_Low = request.security(syminfo.tickerid, "D", low[1])
priceD_High = request.security(syminfo.tickerid, "D", high)
priceD_Low = request.security(syminfo.tickerid, "D", low)
priceW_High = request.security(syminfo.tickerid, "W", high)
priceW_Low = request.security(syminfo.tickerid, "W", low)
priceM_High = request.security(syminfo.tickerid, "M", high)
priceM_Low = request.security(syminfo.tickerid, "M", low)
tmp_priceHigh = 0.0
tmp_priceLow = 0.0
var userLineStyle = "line.style_dashed"
var ln_max = line.new(na, na, na, na, extend = extend.left, style = line.style_dashed, width = 1, color = lineColorH) // Upper Line
var ln_min = line.new(na, na, na, na, extend = extend.left, style = line.style_dashed, width = 1, color = lineColorL) // Lower Line
// Configure User-Preferred Line Style
if (lineStyle == "Dashed")
userLineStyle := line.style_dashed
else if (lineStyle == "Dotted")
userLineStyle := line.style_dotted
else
userLineStyle := line.style_solid
// Calculations
price2D_High := pricePD_High > priceD_High ? pricePD_High : priceD_High
price2D_Low := pricePD_Low < priceD_Low ? pricePD_Low : priceD_Low
// Draws the horizontal lines
if bar_index > 1
if (userTimeFrame2D)
line.set_xy1(ln_max, bar_index - 1, price2D_High)
line.set_xy2(ln_max, bar_index, price2D_High)
line.set_xy1(ln_min, bar_index - 1, price2D_Low)
line.set_xy2(ln_min, bar_index, price2D_Low)
else
if (userTimeFrame == "60")
tmp_priceHigh := priceH_High
tmp_priceLow := priceH_Low
else if (userTimeFrame == "D")
tmp_priceHigh := priceD_High
tmp_priceLow := priceD_Low
else if (userTimeFrame == "W")
tmp_priceHigh := priceW_High
tmp_priceLow := priceW_Low
else
tmp_priceHigh := priceM_High
tmp_priceLow := priceM_Low
line.set_xy1(ln_max, bar_index - 1, tmp_priceHigh)
line.set_xy2(ln_max, bar_index, tmp_priceHigh)
line.set_xy1(ln_min, bar_index - 1, tmp_priceLow)
line.set_xy2(ln_min, bar_index, tmp_priceLow)
line.set_style(ln_max, userLineStyle)
line.set_style(ln_min, userLineStyle)
if ((lineAlt == true) and (userTimeFrame == "D" or userTimeFrame2D == true))
if (priceD_High >= priceW_High)
line.set_color(ln_max, lineColorAltH)
else
line.set_color(ln_max, lineColorH)
if (priceD_Low <= priceW_Low)
line.set_color(ln_min, lineColorAltL)
else
line.set_color(ln_min, lineColorL)
else
line.set_color(ln_max, lineColorH)
line.set_color(ln_min, lineColorL)
|
Breakout Probability (Expo) | https://www.tradingview.com/script/Qt7fqntR-Breakout-Probability-Expo/ | Zeiierman | https://www.tradingview.com/u/Zeiierman/ | 10,807 | study | 5 | CC-BY-NC-SA-4.0 | // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © Zeiierman
//@version=5
indicator("Breakout Probability (Expo)",overlay=true,max_bars_back=5000)
// ~~ Tooltips {
t1 = "The space between the levels can be adjusted with a percentage step. 1% means that each level is located 1% above/under the previous one."
t2 = "Set the number of levels you want to display."
t3 = "If a level got 0 % likelihood of being hit, the level is not displayed as default. Enable the option if you want to see all levels regardless of their values."
t4 = "Enable this option if you want to display the backtest statistics for that a new high or low is made."
string [] tbl_tips = array.from("Number of times price has reached the first highest percentage level",
"Number of times price failed to reach the first highest percentage level",
"Win/Loss ratio")
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Inputs {
perc = input.float(1.0,title="Percentage Step",step=.1,minval=0,group="Settings",tooltip=t1)
nbr = input.int(5, title="Number of Lines",maxval=5,minval=1,group="Settings",tooltip=t2)
upCol = input.color(color.new(color.green,0),title="",inline="col"),dnCol=input.color(color.new(color.red,0),title="",inline="col"),fill=input.bool(true,title="BG Color",inline="col")
var bool [] bools = array.from(input.bool(true,title="Disable 0.00%",group="Settings",tooltip=t3),input.bool(true, title="Show Statistic Panel",group="Settings",tooltip=t4))
var bool [] alert_bool = array.from(
input.bool(true,title="Ticker ID",group="Any alert() function call"),
input.bool(true,title="High/Low Price",group="Any alert() function call"),
input.bool(true,title="Bullish/Bearish Bias",group="Any alert() function call"),
input.bool(true,title="Bullish/Bearish Percentage",group="Any alert() function call"))
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Variables {
b = bar_index
o = open
h = high
l = low
c = close
step = c*(perc/100)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Save Values In Matrix {
var total = matrix.new<int>(7,4,0)
var vals = matrix.new<float>(5,4,0.0)
var lines = matrix.new<line>(1,10,line(na))
var labels = matrix.new<label>(1,10,label(na))
var tbl = matrix.new<table>(1,1,table.new(position.top_right,2,3,
frame_color=color.new(color.gray,50),frame_width=3,
border_color=chart.bg_color,border_width=-2))
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Save Number Of Green & Red Candles {
green = c[1]>o[1]
red = c[1]<o[1]
if green
prev = matrix.get(total,5,0)
matrix.set(total,5,0,prev+1)
if red
prev = matrix.get(total,5,1)
matrix.set(total,5,1,prev+1)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Functions {
//Lines
CreateLine(p,i,c)=>
prevLine = matrix.get(lines,0,i)
line.delete(prevLine)
li = line.new(b[1],p,b,p,color=c,width=2)
matrix.set(lines,0,i,li)
//Labels
CreateLabel(p,i,c,r,v)=>
prevLabel = matrix.get(labels,0,i)
label.delete(prevLabel)
la = label.new(b+1,p,text=str.tostring(matrix.get(vals,r,v),format.percent),
style=label.style_label_left,color=color.new(color.black,100),textcolor=c)
matrix.set(labels,0,i,la)
//Score Calculation
Score(x,i)=>
ghh = matrix.get(total,i,0)
gll = matrix.get(total,i,1)
rhh = matrix.get(total,i,2)
rll = matrix.get(total,i,3)
gtotal = matrix.get(total,5,0)
rtotal = matrix.get(total,5,1)
hh = h>=h[1] + x
ll = l<=l[1] - x
if green and hh
matrix.set(total,i,0,ghh+1)
matrix.set(vals,i,0,math.round(((ghh+1)/gtotal)*100,2))
if green and ll
matrix.set(total,i,1,gll+1)
matrix.set(vals,i,1,math.round(((gll+1)/gtotal)*100,2))
if red and hh
matrix.set(total,i,2,rhh+1)
matrix.set(vals,i,2,math.round(((rhh+1)/rtotal)*100,2))
if red and ll
matrix.set(total,i,3,rll+1)
matrix.set(vals,i,3,math.round(((rll+1)/rtotal)*100,2))
//Backtest
Backtest(v)=>
p1 = matrix.get(total,6,0)
p2 = matrix.get(total,6,1)
if v==h[1]
if h>=v
matrix.set(total,6,0,p1+1)
else
matrix.set(total,6,1,p2+1)
else
if l<=v
matrix.set(total,6,0,p1+1)
else
matrix.set(total,6,1,p2+1)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Code {
//Run Score Function
Score(0,0)
Score(step,1)
Score(step*2,2)
Score(step*3,3)
Score(step*4,4)
//Fetch Score Values
a1 = matrix.get(vals,0,0)
b1 = matrix.get(vals,0,1)
a2 = matrix.get(vals,0,2)
b2 = matrix.get(vals,0,3)
//Lines & Labels & Alerts
for i=0 to nbr-1
hide = array.get(bools,0)
if not hide or (hide and (green?math.min(matrix.get(vals,i,0),
matrix.get(vals,i,1))>0:
math.min(matrix.get(vals,i,2),
matrix.get(vals,i,3))>0))
hi = h[1]+(step*i)
lo = l[1]-(step*i)
//Plot Lines
CreateLine(hi,i,upCol)
CreateLine(lo,5+i,dnCol)
//Plot Labels
if green
CreateLabel(hi,i,upCol,i,0)
CreateLabel(lo,5+i,dnCol,i,1)
else
CreateLabel(hi,i,upCol,i,2)
CreateLabel(lo,5+i,dnCol,i,3)
//Create Alert
if array.includes(alert_bool, true)
s1 = str.tostring(syminfo.ticker)
s2 = "High Price: "+str.tostring(math.round_to_mintick(h[1]))+
" | Low Price: "+str.tostring(math.round_to_mintick(l[1]))
s3 = green?(math.max(a1,b1)==a1?"BULLISH":"BEARISH"):
(math.max(a2,b2)==a2?"BULLISH":"BEARISH")
s4 = green?(math.max(a1,b1)==a1?a1:b1):(math.min(a2,b2)==a2?a2:b2)
s5 = red ?(math.max(a2,b2)==a2?a2:b2):(math.min(a1,b1)==a1?a1:b1)
string [] str_vals = array.from(s1,s2,"BIAS: "+s3,
"Percentage: High: "+str.tostring(s4,format.percent)
+" | Low: "+str.tostring(s5,format.percent))
output = array.new_string()
for x=0 to array.size(alert_bool)-1
if array.get(alert_bool,x)
array.push(output,array.get(str_vals,x))
//Alert Is Triggered On Every Bar Open With Bias And Percentage Ratio
alert(array.join(output,'\n'),alert.freq_once_per_bar)
else
//Delete Old Lines & Labels
line.delete(matrix.get(lines,0,i))
line.delete(matrix.get(lines,0,5+i))
label.delete(matrix.get(labels,0,i))
label.delete(matrix.get(labels,0,5+i))
//Run Backtest Function
Backtest(green?(math.max(a1,b1)==a1?h[1]:l[1]):(math.max(a2,b2)==a2?h[1]:l[1]))
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Linefill {
if fill
var filler = linefill(na)
for i=0 to 8
get = matrix.get(lines,0,i)
get1= matrix.get(lines,0,i+1)
col = i>4?color.new(dnCol,80) : i==4?color.new(color.gray,100) : color.new(upCol,80)
filler := linefill.new(get,get1,color=col)
linefill.delete(filler[1])
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Table {
if barstate.islast and array.get(bools,1)
//Calulate WinRatio
W = matrix.get(total,6,0)
L = matrix.get(total,6,1)
WR = math.round(W/(W+L)*100,2)
string [] tbl_vals = array.from("WIN: "+str.tostring(W),
"LOSS: "+str.tostring(L),
"Profitability: "+str.tostring(WR,format.percent))
color [] tbl_col = array.from(color.green,color.red,chart.fg_color)
for i=0 to 2
table.cell(matrix.get(tbl,0,0),0,i,array.get(tbl_vals,i),
text_halign=text.align_center,bgcolor=chart.bg_color,
text_color=array.get(tbl_col,i),text_size=size.auto,
tooltip=array.get(tbl_tips,i))
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} |
R-squared Adaptive T3 w/ DSL [Loxx] | https://www.tradingview.com/script/f4lkBmKH-R-squared-Adaptive-T3-w-DSL-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 162 | 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 w/ DSL [Loxx]",
shorttitle='RSAT3DSL [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Slope'
SM04 = 'Levels Crosses'
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
_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 = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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")
orig = input.bool(false, "Original?", group = "Basic Settings")
fllwtrnd = input.bool(true, "Trend follow?", group = "Basic Settings")
signal_length = input.int(9, "Signal Period", group = "Signal/DSL 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")
sigtype = input.string(SM04, "Signal type", options = [SM02, SM04], group = "Signal/DSL 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
out = _t3rSqrdAdapt(src, per, orig, fllwtrnd)
sig = nz(out[1])
levelu = 0., leveld = 0., mid = 0.
levelu := (out > sig) ? variant(sigmatype, out, signal_length) : nz(levelu[1])
leveld := (out < sig) ? variant(sigmatype, out, signal_length) : nz(leveld[1])
state = 0.
if sigtype == SM02
if (out < sig)
state :=-1
if (out > sig)
state := 1
else if sigtype == SM04
if (out < leveld)
state :=-1
if (out > levelu)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(out, "R-Squared Adaptive T3 ", color = colorout, linewidth = 3)
plot(levelu, "Level Up", color = darkGreenColor)
plot(leveld, "Level Down", color = darkRedColor)
barcolor(colorbars ? colorout: na)
goLong = colorout == greencolor and colorout[1] != greencolor
goShort = colorout == redcolor and colorout[1] != redcolor
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 w/ DSL [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="R-squared Adaptive T3 w/ DSL [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
PPO w/ Discontinued Signal Lines [Loxx] | https://www.tradingview.com/script/CZTb852a-PPO-w-Discontinued-Signal-Lines-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("PPO w/ Discontinued Signal Lines [Loxx]",
shorttitle='PPODSL [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Signal'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
smthtype = input.string("Kaufman", "Fast Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcin = input.string("Close", "Fast 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)"])
fast_length = input.int(12, title='Fast Length', group = "Basic Settings")
slow_length = input.int(26, title='Slow Length', group = "Basic Settings")
fstype = input.string("Exponential Moving Average - EMA", "Fast/Slow 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")
signal_length = input.int(9, "Signal Period", group = "Signal/DSL 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")
sigtype = input.string(SM04, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
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)
showsignals = input.bool(true, "Show signals?", group = "UI Options")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignline = input.bool(true, "Show signal line?", 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
fast_ma = variant(fstype, src, fast_length)
slow_ma = variant(fstype, src, slow_length)
ppo = (fast_ma - slow_ma) / slow_ma * 100
levelu = 0., leveld = 0., mid = 0.
levelu := (ppo > 0) ? variant(sigmatype, ppo, signal_length) : nz(levelu[1])
leveld := (ppo < 0) ? variant(sigmatype, ppo, signal_length) : nz(leveld[1])
sig = variant(sigmatype, ppo, signal_length)
osc = ppo
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
)
state = 0.
if sigtype == SM02
if (ppo < sig)
state :=-1
if (ppo > sig)
state := 1
else if sigtype == SM03
if (ppo < mid)
state :=-1
if (ppo > mid)
state := 1
else if sigtype == SM04
if (ppo < leveld)
state :=-1
if (ppo > levelu)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(ppo, "PPO", color = colorout, linewidth = 3)
plot(showsignline ? sig : na, "Signal", color = color.white, linewidth = 1)
plot(levelu, "Level Up", color = bar_index % 2 ? color.gray : na)
plot(leveld, "Level Down", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(ppo, sig) : sigtype == SM03 ? ta.crossover(ppo, mid) : ta.crossover(ppo, levelu)
goShort = sigtype == SM02 ? ta.crossunder(ppo, sig) : sigtype == SM03 ? ta.crossunder(ppo, mid) : ta.crossunder(ppo, leveld)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="PPO w/ Discontinued Signal Lines [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="PPO w/ Discontinued Signal Lines [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBearCond, title="Hidden Bear Divergence", message="PPO w/ Discontinued Signal Lines [Loxx]: Hidden Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bearCond, title="Regular Bear Divergence", message="PPO w/ Discontinued Signal Lines [Loxx]: Regular Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBullCond, title="Hidden Bull Divergence", message="PPO w/ Discontinued Signal Lines [Loxx]: Hidden Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bullCond, title="Regular Bull Divergence", message="PPO w/ Discontinued Signal Lines [Loxx]: Regular Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Pips-Stepped, Adaptive-ER DSEMA w/ DSL [Loxx] | https://www.tradingview.com/script/GLYRq9ed-Pips-Stepped-Adaptive-ER-DSEMA-w-DSL-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 86 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Pips-Stepped, Adaptive-ER DSEMA w/ DSL [Loxx]",
shorttitle = "PSAERDSEMADSL [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Slope'
SM04 = 'Levels Crosses'
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
_erdesem(src, per)=>
m_fastEnd = math.max(per / 2.0, 1)
m_slowEnd = per * 5
signal = 0.
noise = 0.
difference = src - nz(src[1])
if (bar_index > per)
signal := math.abs(src - nz(src[per]))
noise := nz(noise[1]) + difference - nz(difference[per])
else
noise := difference
for k = 1 to per - 1
noise += nz(difference[k])
efratio = signal / noise
averagePeriod = noise > 0 ? (efratio * (m_slowEnd - m_fastEnd)) + m_fastEnd : per
val = 0., val2 = 0.
alpha = 2.0 / (1.0 + math.sqrt(averagePeriod))
val := nz(val[1]) + alpha * (src - nz(val[1]))
val2 := nz(val2[1]) + alpha* (val - nz(val2[1]))
val2
_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
_stepTransformer(src, steps)=>
val = 0.
_stepSize = (steps > 0 ? steps : 0) * syminfo.mintick * math.pow(10, _declen() % 2)
if (_stepSize > 0)
_diff = src - nz(val[1])
val := nz(val[1]) + ((_diff < _stepSize and _diff > -_stepSize) ? 0 : int(_diff / _stepSize) * _stepSize)
else
val := (_stepSize > 0) ? math.round(src / _stepSize) * _stepSize : src
val
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Source Settings")
srcin = input.string("HAB 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(35, "Period", group = "Basic Settings")
steps = input.float(5.0, "Steps in Pips", group = "Basic Settings")
signal_length = input.int(9, "Signal Period", group = "Signal/DSL 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")
sigtype = input.string(SM04, "Signal type", options = [SM02, SM04], group = "Signal/DSL 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
outin = _erdesem(src, per)
out = _stepTransformer(outin, steps)
sig = out[1]
levelu = 0., leveld = 0., mid = 0.
levelu := (out > sig) ? variant(sigmatype, out, signal_length) : nz(levelu[1])
leveld := (out < sig) ? variant(sigmatype, out, signal_length) : nz(leveld[1])
state = 0.
if sigtype == SM02
if (out < sig)
state :=-1
if (out > sig)
state := 1
else if sigtype == SM04
if (out < leveld)
state :=-1
if (out > levelu)
state := 1
goLong_pre = sigtype == SM02 ? ta.crossover(out, sig) : ta.crossover(out, levelu)
goShort_pre = sigtype == SM02 ? ta.crossunder(out, sig) : ta.crossunder(out, leveld)
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch
colorout = sigtype == SM02 ? contSwitch == -1 ? redcolor : greencolor :
state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(out,"Pips-Stepped, Adaptive-ER DSEMA", color = colorout, linewidth = 3)
plot(levelu, "Level Up", color = darkGreenColor)
plot(leveld, "Level Down", color = darkRedColor)
barcolor(colorbars ? colorout : na)
goLong = goLong_pre and ta.change(contSwitch)
goShort = goShort_pre and ta.change(contSwitch)
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="Pips-Stepped, Adaptive-ER DSEMA w/ DSL [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Pips-Stepped, Adaptive-ER DSEMA w/ DSL [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
ATR-Adaptive JMA [Loxx] | https://www.tradingview.com/script/8AqKpmj5-ATR-Adaptive-JMA-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 130 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("ATR-Adaptive JMA [Loxx]",
shorttitle='ATRAJMA [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
_corMa(src, work, per)=>
out = 0.
v1 = math.pow(ta.stdev(src, per), 2)
v2 = math.pow(nz(out[1]) - work, 2)
c = (v2 < v1 or v2 == 0) ? 0 : 1 - v1 / v2
out := nz(out[1]) + c * (work - nz(out[1]))
out
src = input.source(close, "Source", group = "Basic Settings")
per = input.int(14, "Period", group = "Basic Settings")
phs = 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")
atr = ta.atr(per)
_max = ta.highest(atr, per)
_min = ta.lowest(atr, per)
_coeff = (_min != _max) ? 1-(atr-_min)/(_max-_min) : 0.5
perout = int(per * (_coeff+1.0)/2.0)
out = loxxjuriktools.jurik_filt(src, perout, phs)
sig = out[1]
goLong_pre = ta.crossover(out, sig)
goShort_pre = ta.crossunder(out, sig)
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch
colorout = out > sig ? greencolor : out < sig ? redcolor : color.gray
plot(out, "ATR-Adaptive JMA", color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
|
Stock Strength Index by zdmre | https://www.tradingview.com/script/Zphqfvej-Stock-Strength-Index-by-zdmre/ | zdmre | https://www.tradingview.com/u/zdmre/ | 48 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zdmre
//@version=5
indicator("Stock Strength Index by zdmre")
// INPUTs
sym1 = input.symbol("NASDAQ:AAPL",title = "1")
sym2 = input.symbol("NASDAQ:AMD",title = "2")
sym3 = input.symbol("NASDAQ:AMZN",title = "3")
sym4 = input.symbol("NASDAQ:TSLA",title = "4")
sym5 = input.symbol("NASDAQ:NFLX",title = "5")
sym6 = input.symbol("NASDAQ:META",title = "6")
sym7 = input.symbol("NASDAQ:INTC",title = "7")
sym8 = input.symbol("NYSE:BABA",title = "8")
opt_textsize = input.string(size.small, 'Text Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge])
Show1 = input(true, "Symbol 1", group= "SHOW")
Show2 = input(true, "Symbol 2", group= "SHOW")
Show3 = input(true, "Symbol 3", group= "SHOW")
Show4 = input(true, "Symbol 4", group= "SHOW")
Show5 = input(true, "Symbol 5", group= "SHOW")
Show6 = input(true, "Symbol 6", group= "SHOW")
Show7 = input(true, "Symbol 7", group= "SHOW")
Show8 = input(true, "Symbol 8", group= "SHOW")
// CALC
rma = ta.rma(close, 200)
rq_sym1 = request.security(sym1, "240", close , barmerge.gaps_off, barmerge.lookahead_off)
sym1_rma = request.security(sym1, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym2 = request.security(sym2, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym2_rma = request.security(sym2, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym3 = request.security(sym3, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym3_rma = request.security(sym3, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym4 = request.security(sym4, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym4_rma = request.security(sym4, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym5 = request.security(sym5, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym5_rma = request.security(sym5, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym6 = request.security(sym6, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym6_rma = request.security(sym6, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym7 = request.security(sym7, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym7_rma = request.security(sym7, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym8 = request.security(sym8, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym8_rma = request.security(sym8, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
str_sym1 = (rq_sym1 - sym1_rma)/rq_sym1 * 100
str_sym2 = (rq_sym2 - sym2_rma)/rq_sym2 * 100
str_sym3 = (rq_sym3 - sym3_rma)/rq_sym3 * 100
str_sym4 = (rq_sym4 - sym4_rma)/rq_sym4 * 100
str_sym5 = (rq_sym5 - sym5_rma)/rq_sym5 * 100
str_sym6 = (rq_sym6 - sym6_rma)/rq_sym6 * 100
str_sym7 = (rq_sym7 - sym7_rma)/rq_sym7 * 100
str_sym8 = (rq_sym8 - sym8_rma)/rq_sym8 * 100
// LABELs
ShowLabels = input(true, "Show Labels")
if (ShowLabels)
style = label.style_label_left
size = opt_textsize
if (Show1)
label lbl1 = label.new(bar_index+1, str_sym1, syminfo.ticker(sym1), color=color.yellow, style=style, textcolor=color.black, size=size), label.delete(lbl1[1])
if (Show2)
label lbl2 = label.new(bar_index+1, str_sym2, syminfo.ticker(sym2), color=color.green, style=style, textcolor=color.black, size=size), label.delete(lbl2[1])
if (Show3)
label lbl3 = label.new(bar_index+1, str_sym3, syminfo.ticker(sym3), color=color.purple, style=style, textcolor=color.black, size=size), label.delete(lbl3[1])
if (Show4)
label lbl4 = label.new(bar_index+1, str_sym4, syminfo.ticker(sym4), color=color.blue, style=style, textcolor=color.white, size=size), label.delete(lbl4[1])
if (Show5)
label lbl5 = label.new(bar_index+1, str_sym5, syminfo.ticker(sym5), color=color.red, style=style, textcolor=color.black, size=size), label.delete(lbl5[1])
if (Show6)
label lbl6 = label.new(bar_index+1, str_sym6, syminfo.ticker(sym6), color=color.orange, style=style, textcolor=color.black, size=size), label.delete(lbl6[1])
if (Show7)
label lbl7 = label.new(bar_index+1, str_sym7, syminfo.ticker(sym7), color=color.teal,style=style, textcolor=color.black, size=size), label.delete(lbl7[1])
if (Show8)
label lbl8 = label.new(bar_index+1, str_sym8, syminfo.ticker(sym8), color=color.aqua, style=style, textcolor=color.black, size=size), label.delete(lbl8[1])
// TABLE
var tbis = table.new(position.middle_right, 3, 9, frame_color=color.black, frame_width=0, border_width=1, border_color=color.black)
table.cell(tbis, 0, 0, 'STOCK', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 1, 0, 'INDEX', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 2, 0, 'DAY', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
if Show1
table.cell(tbis, 0, 1, syminfo.ticker(sym1), bgcolor = color.yellow, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 1, str.tostring(str_sym1[0], '#,##0.00'), text_color=str_sym1[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym1[0] < 0 ? color.red : str_sym1[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 1, str.tostring((str_sym1[0]-str_sym1[1]), '#,##0.00'), text_color=(str_sym1[0]-str_sym1[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym1[0]-str_sym1[1]) < 0 ? color.red : (str_sym1[0]-str_sym1[1]) > 0 ? color.lime : color.black)
if Show2
table.cell(tbis, 0, 2, syminfo.ticker(sym2), bgcolor = color.green, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 2, str.tostring(str_sym2[0], '#,##0.00'), text_color=str_sym2[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym2[0] < 0 ? color.red : str_sym2[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 2, str.tostring((str_sym2[0]-str_sym2[1]), '#,##0.00'), text_color=(str_sym2[0]-str_sym2[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym2[0]-str_sym2[1]) < 0 ? color.red : (str_sym2[0]-str_sym2[1]) > 0 ? color.lime : color.black)
if Show3
table.cell(tbis, 0, 3, syminfo.ticker(sym3), bgcolor = color.purple, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 3, str.tostring(str_sym3[0], '#,##0.00'), text_color=str_sym3[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym3[0] < 0 ? color.red : str_sym3[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 3, str.tostring((str_sym3[0]-str_sym3[1]), '#,##0.00'), text_color=(str_sym3[0]-str_sym3[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym3[0]-str_sym3[1]) < 0 ? color.red : (str_sym3[0]-str_sym3[1]) > 0 ? color.lime : color.black)
if Show4
table.cell(tbis, 0, 4, syminfo.ticker(sym4), bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 1, 4, str.tostring(str_sym4[0], '#,##0.00'), text_color=str_sym4[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym4[0] < 0 ? color.red : str_sym4[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 4, str.tostring((str_sym4[0]-str_sym4[1]), '#,##0.00'), text_color=(str_sym4[0]-str_sym4[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym4[0]-str_sym4[1]) < 0 ? color.red : (str_sym4[0]-str_sym4[1]) > 0 ? color.lime : color.black)
if Show5
table.cell(tbis, 0, 5, syminfo.ticker(sym5), bgcolor = color.red, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 5, str.tostring(str_sym5[0], '#,##0.00'), text_color=str_sym5[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym5[0] < 0 ? color.red : str_sym5[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 5, str.tostring((str_sym5[0]-str_sym5[1]), '#,##0.00'), text_color=(str_sym5[0]-str_sym5[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym5[0]-str_sym5[1]) < 0 ? color.red : (str_sym5[0]-str_sym5[1]) > 0 ? color.lime : color.black)
if Show6
table.cell(tbis, 0, 6, syminfo.ticker(sym6), bgcolor = color.orange, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 6, str.tostring(str_sym6[0], '#,##0.00'), text_color=str_sym6[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym6[0] < 0 ? color.red : str_sym6[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 6, str.tostring((str_sym6[0]-str_sym6[1]), '#,##0.00'), text_color=(str_sym6[0]-str_sym6[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym6[0]-str_sym6[1]) < 0 ? color.red : (str_sym6[0]-str_sym6[1]) > 0 ? color.lime : color.black)
if Show7
table.cell(tbis, 0, 7, syminfo.ticker(sym7), bgcolor = color.teal, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 7, str.tostring(str_sym7[0], '#,##0.00'), text_color=str_sym7[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym7[0] < 0 ? color.red : str_sym7[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 7, str.tostring((str_sym7[0]-str_sym7[1]), '#,##0.00'), text_color=(str_sym7[0]-str_sym7[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym7[0]-str_sym7[1]) < 0 ? color.red : (str_sym7[0]-str_sym7[1]) > 0 ? color.lime : color.black)
if Show8
table.cell(tbis, 0, 8, syminfo.ticker(sym8), bgcolor = color.aqua, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 8, str.tostring(str_sym8[0], '#,##0.00'), text_color=str_sym8[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym8[0] < 0 ? color.red : str_sym8[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 8, str.tostring((str_sym8[0]-str_sym8[1]), '#,##0.00'), text_color=(str_sym8[0]-str_sym8[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym8[0]-str_sym8[1]) < 0 ? color.red : (str_sym8[0]-str_sym8[1]) > 0 ? color.lime : color.black)
// LINEs
plot(Show1 ? str_sym1 : na, "1", color=color.yellow)
plot(Show2 ? str_sym2 : na, "2", color=color.green)
plot(Show3 ? str_sym3 : na, "3", color=color.purple)
plot(Show4 ? str_sym4 : na, "4", color=color.blue)
plot(Show5 ? str_sym5 : na, "5", color=color.red)
plot(Show6 ? str_sym6 : na, "6", color=color.orange)
plot(Show7 ? str_sym7 : na, "7", color=color.teal)
plot(Show8 ? str_sym8 : na, "8", color=color.aqua)
bandh = hline(50, title= "Upper Band", color=color.new(#787B86, 50), display=display.none)
band0 = hline(0, title= "USD", color=color.new(#787B86, 0), linewidth=2)
bandl = hline(-50, title= "Lower Band", color=color.new(#787B86, 50), display=display.none) |
Volume | https://www.tradingview.com/script/DzZl5Vfb-Volume/ | rvtradesetup | https://www.tradingview.com/u/rvtradesetup/ | 33 | 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/
// © rvtradesetup
//@version=5
indicator("Volume", format = format.volume)
len = input(20, "Length", group = "MA")
tf = timeframe.period
ticker = syminfo.tickerid
s = ticker == "NSE:NIFTY" ? "NSE:NIFTY1!" : ticker == "NSE:BANKNIFTY" ? "NSE:BANKNIFTY1!" : ticker == "NSE:CNXFINANCE" ? "NSE:FINNIFTY1!" : ticker
vol = request.security(s, tf, volume)
colr = (close > open) ? color.new(#22ab94, 40) : color.new(#f7525f, 40)
ma = ta.sma(vol, len)
plot(vol, title = "Volume" , color = colr, style = plot.style_columns)
plot(ma, title = "MA", color = color.orange) |
T3 Velocity [Loxx] | https://www.tradingview.com/script/oCqwVqCi-T3-Velocity-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 133 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("T3 Velocity [Loxx]",
shorttitle="T3V [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
_iT3(src, per, hot, org)=>
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 (org)
alpha := 2.0 / (1.0 + per)
else
alpha := 2.0 / (2.0 + (per - 1.0) / 2.0)
_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 = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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(1, "T3 Factor", step = 0.01, maxval = 1, minval = 0, group = "T3 Settings")
t3swt = input.bool(false, "T3 Original?", group = "T3 Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
ColorNorm = input.int(20, "Colors normalization period", group = "UI Options")
showsignals = input.bool(false, "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
out = _iT3(src, per, t3hot, t3swt) - _iT3(src, per, t3hot/2. , t3swt)
smax = ta.highest(out, ColorNorm)
smin = ta.lowest(out, ColorNorm)
sto = 100 * (out - smin)/(smax - smin)
color2 = color.from_gradient(sto, 0, 100, redcolor, greencolor)
mid = 0.
plot(mid, "Middle", color = bar_index % 2 ? color.white : na)
plot(out, "T3 Velocity", color = color2, linewidth = 3, style = plot.style_histogram)
barcolor(colorbars ? color2 : na)
goLong = ta.crossover(out, mid)
goShort = ta.crossunder(out, mid)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="T3 Velocity [Loxx]: Long\nSymbol: {{ticker}}\nsrc: {{close}}")
alertcondition(goShort, title="Short", message="T3 Velocity [Loxx]: Short\nSymbol: {{ticker}}\nsrc: {{close}}")
|
STD-Filtered Variety RSI of Double Averages w/ DSL [Loxx] | https://www.tradingview.com/script/MdPIZyMm-STD-Filtered-Variety-RSI-of-Double-Averages-w-DSL-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 102 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("STD-Filtered Variety RSI of Double Averages w/ DSL [Loxx] ",
shorttitle='STDFVRSIDADSL [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxvarietyrsi/1
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Slope'
SM04 = 'Levels Crosses'
_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
_t3rsi(src, per, t3hot, t3org)=>
chng = src - nz(src[1])
changn = _iT3(chng, per, t3hot, t3org)
changa = _iT3(math.abs(chng), per, t3hot, t3org)
out = 50.
if (changn != 0)
out := (math.min(math.max(50.0 * (changn / math.max(changa, 0.0000001) + 1.0), 0), 100))
out
period = input.int(14, "Caculation Period", group = "Basic Settings")
filt = input.float(1., "Standard Deviation Multiplier", group = "Basic Settings")
src = input.source(close, "Source", group = "RSI Settings")
rsitype = input.string("Regular", "RSI Type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed", "T3 RSI"], group = "RSI Settings")
rsiper = input.int(14, "RSI Period", group = "RSI Settings")
divis = input.float(3., "Divisor Period for Double Smoothing", group = "RSI Settings")
type = input.string("Exponential Moving Average - EMA", "Double Smoothing 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 filt", "Leader Exponential Moving Average", "Linear Regression Value - LSMA (Least Squares Moving Average)"
, "Linear Weighted Moving Average - LWMA", "McGinley Dynamic", "McNicholl EMA", "Non-Lag Moving Average", "Parabolic Weighted Moving Average"
, "Recursive Moving Trendline", "Simple Moving Average - SMA", "Sine Weighted Moving Average", "Smoothed Moving Average - SMMA"
, "Smoother", "Super Smoother", "Three-pole Ehlers Butterworth", "Three-pole Ehlers Smoother"
, "Triangular Moving Average - TMA", "Triple Exponential Moving Average - TEMA", "Two-pole Ehlers Butterworth", "Two-pole Ehlers smoother"
, "Volume Weighted EMA - VEMA", "Zero-Lag DEMA - Zero Lag Double Exponential Moving Average", "Zero-Lag Moving Average"
, "Zero Lag TEMA - Zero Lag Triple Exponential Moving Average"],
group = "Basic Settings")
t3hot = input.float(0.8, "T3 Factor", group = "T3 Settings")
t3org = input.string("T3 New", "T3 Type", options = ["T3 New", "Original"], group = "T3 Settings")
signal_length = input.int(9, "Signal Period", group = "Signal/DSL 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")
precision = input.int(5, "Slope Precision", group = "Signal/DSL Settings")
sigtype = input.string(SM04, "Signal type", options = [SM02, SM04], group = "Signal/DSL Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group = "UI Options")
frama_FC = input.int(defval=1, title="* Fractal Adjusted (FRAMA) Only - FC", group = "Moving Average Inputs")
frama_SC = input.int(defval=200, title="* Fractal Adjusted (FRAMA) Only - SC", group = "Moving Average Inputs")
instantaneous_alpha = input.float(defval=0.07, minval = 0, title="* Instantaneous Trendline (INSTANT) Only - Alpha", group = "Moving Average Inputs")
_laguerre_alpha = input.float(title="* Laguerre filt (LF) Only - Alpha", minval=0, maxval=1, step=0.1, defval=0.7, group = "Moving Average Inputs")
lsma_offset = input.int(defval=0, title="* Least Squares Moving Average (LSMA) Only - Offset", group = "Moving Average Inputs")
_pwma_pwr = input.int(2, "* Parabolic Weighted Moving Average (PWMA) Only - Power", minval=0, group = "Moving Average Inputs")
kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")
variant(type, src, len) =>
sig = 0.0
trig = 0.0
special = false
if type == "ADXvma - Average Directional Volatility Moving Average"
[t, s, b] = loxxmas.adxvma(src, len)
sig := s
trig := t
special := b
else if type == "Ahrens Moving Average"
[t, s, b] = loxxmas.ahrma(src, len)
sig := s
trig := t
special := b
else if type == "Alexander Moving Average - ALXMA"
[t, s, b] = loxxmas.alxma(src, len)
sig := s
trig := t
special := b
else if type == "Double Exponential Moving Average - DEMA"
[t, s, b] = loxxmas.dema(src, len)
sig := s
trig := t
special := b
else if type == "Double Smoothed Exponential Moving Average - DSEMA"
[t, s, b] = loxxmas.dsema(src, len)
sig := s
trig := t
special := b
else if type == "Exponential Moving Average - EMA"
[t, s, b] = loxxmas.ema(src, len)
sig := s
trig := t
special := b
else if type == "Fast Exponential Moving Average - FEMA"
[t, s, b] = loxxmas.fema(src, len)
sig := s
trig := t
special := b
else if type == "Fractal Adaptive Moving Average - FRAMA"
[t, s, b] = loxxmas.frama(src, len, frama_FC, frama_SC)
sig := s
trig := t
special := b
else if type == "Hull Moving Average - HMA"
[t, s, b] = loxxmas.hma(src, len)
sig := s
trig := t
special := b
else if type == "IE/2 - Early T3 by Tim Tilson"
[t, s, b] = loxxmas.ie2(src, len)
sig := s
trig := t
special := b
else if type == "Integral of Linear Regression Slope - ILRS"
[t, s, b] = loxxmas.ilrs(src, len)
sig := s
trig := t
special := b
else if type == "Instantaneous Trendline"
[t, s, b] = loxxmas.instant(src, instantaneous_alpha)
sig := s
trig := t
special := b
else if type == "Laguerre filt"
[t, s, b] = loxxmas.laguerre(src, _laguerre_alpha)
sig := s
trig := t
special := b
else if type == "Leader Exponential Moving Average"
[t, s, b] = loxxmas.leader(src, len)
sig := s
trig := t
special := b
else if type == "Linear Regression Value - LSMA (Least Squares Moving Average)"
[t, s, b] = loxxmas.lsma(src, len, lsma_offset)
sig := s
trig := t
special := b
else if type == "Linear Weighted Moving Average - LWMA"
[t, s, b] = loxxmas.lwma(src, len)
sig := s
trig := t
special := b
else if type == "McGinley Dynamic"
[t, s, b] = loxxmas.mcginley(src, len)
sig := s
trig := t
special := b
else if type == "McNicholl EMA"
[t, s, b] = loxxmas.mcNicholl(src, len)
sig := s
trig := t
special := b
else if type == "Non-Lag Moving Average"
[t, s, b] = loxxmas.nonlagma(src, len)
sig := s
trig := t
special := b
else if type == "Parabolic Weighted Moving Average"
[t, s, b] = loxxmas.pwma(src, len, _pwma_pwr)
sig := s
trig := t
special := b
else if type == "Recursive Moving Trendline"
[t, s, b] = loxxmas.rmta(src, len)
sig := s
trig := t
special := b
else if type == "Simple Moving Average - SMA"
[t, s, b] = loxxmas.sma(src, len)
sig := s
trig := t
special := b
else if type == "Sine Weighted Moving Average"
[t, s, b] = loxxmas.swma(src, len)
sig := s
trig := t
special := b
else if type == "Smoothed Moving Average - SMMA"
[t, s, b] = loxxmas.smma(src, len)
sig := s
trig := t
special := b
else if type == "Smoother"
[t, s, b] = loxxmas.smoother(src, len)
sig := s
trig := t
special := b
else if type == "Super Smoother"
[t, s, b] = loxxmas.super(src, len)
sig := s
trig := t
special := b
else if type == "Three-pole Ehlers Butterworth"
[t, s, b] = loxxmas.threepolebuttfilt(src, len)
sig := s
trig := t
special := b
else if type == "Three-pole Ehlers Smoother"
[t, s, b] = loxxmas.threepolesss(src, len)
sig := s
trig := t
special := b
else if type == "Triangular Moving Average - TMA"
[t, s, b] = loxxmas.tma(src, len)
sig := s
trig := t
special := b
else if type == "Triple Exponential Moving Average - TEMA"
[t, s, b] = loxxmas.tema(src, len)
sig := s
trig := t
special := b
else if type == "Two-pole Ehlers Butterworth"
[t, s, b] = loxxmas.twopolebutter(src, len)
sig := s
trig := t
special := b
else if type == "Two-pole Ehlers smoother"
[t, s, b] = loxxmas.twopoless(src, len)
sig := s
trig := t
special := b
else if type == "Volume Weighted EMA - VEMA"
[t, s, b] = loxxmas.vwema(src, len)
sig := s
trig := t
special := b
else if type == "Zero-Lag DEMA - Zero Lag Double Exponential Moving Average"
[t, s, b] = loxxmas.zlagdema(src, len)
sig := s
trig := t
special := b
else if type == "Zero-Lag Moving Average"
[t, s, b] = loxxmas.zlagma(src, len)
sig := s
trig := t
special := b
else if type == "Zero Lag TEMA - Zero Lag Triple Exponential Moving Average"
[t, s, b] = loxxmas.zlagtema(src, len)
sig := s
trig := t
special := b
trig
rsimode = switch rsitype
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
morph = math.round(period/divis)
srcmorph = variant(type, variant(type, src, morph), morph)
if (filt > 0)
_change = math.abs(srcmorph - nz(srcmorph[1]))
_achang = _change
for k = 1 to period - 1
_achang += nz(_change[k])
_achang /= period
stddev = 0.
for k = 0 to period - 1
stddev += math.pow(nz(_change[k]) - nz(_achang[k]), 2)
stddev := math.sqrt(stddev / period)
filt := filt * stddev
if (math.abs(srcmorph - nz(srcmorph[1])) < filt)
srcmorph := nz(srcmorph[1])
out = rsitype == "T3 RSI" ? _t3rsi(src, rsiper, t3hot, t3org) : loxxvarietyrsi.rsiVariety(rsimode, srcmorph, rsiper)
sig = out[1]
levelu = 0., leveld = 0., mid = 50
levelu := (out > sig) ? variant(sigmatype, out, signal_length) : nz(levelu[1])
leveld := (out < sig) ? variant(sigmatype, out, signal_length) : nz(leveld[1])
state = 0.
if sigtype == SM02
if (math.round(out, precision) < math.round(sig, precision))
state :=-1
if (math.round(out, precision) > math.round(sig, precision))
state := 1
else if sigtype == SM04
if (out < leveld)
state :=-1
if (out > levelu)
state := 1
colorout = state == 1 ? greencolor : state == -1 ? redcolor : color.gray
plot(out,"Variety RSI", color = colorout, linewidth = 3)
plot(levelu, "Level Up", color = darkGreenColor)
plot(leveld, "Level Down", color = darkRedColor)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(out, sig) : ta.crossover(out, levelu)
goShort = sigtype == SM02 ? ta.crossunder(out, sig) : ta.crossunder(out, 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="Long", message="STD-Filtered Variety RSI of Double Averages w/ DSL [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="STD-Filtered Variety RSI of Double Averages w/ DSL [Loxx] : Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Midpoint - MG | https://www.tradingview.com/script/1te5nxTW/ | trademasterf | https://www.tradingview.com/u/trademasterf/ | 33 | 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/
// © MGULHANN
//@version=5
indicator('Midpoint - MG', overlay=true)
BPeriod = input(89, 'Başlangıç Period')
midpoint1 = ta.highest(high, BPeriod) + ta.lowest(low, BPeriod)
midpoint2 = midpoint1 / 2
plot(midpoint2, linewidth=2, color=color.blue)
|
2 Ema Pullback Strategy | https://www.tradingview.com/script/STbPpWPr-2-Ema-Pullback-Strategy/ | Germangroa | https://www.tradingview.com/u/Germangroa/ | 51 | 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/
// © Germangroa
//@version=5
indicator("2 Ema Pullback Strategy", overlay=true)
//============= Time Frame============
//startDate = input.time(title="Start Date", defval=timestamp("01 Jan 2010 13:30 +0000"), group="Tme Frame", tooltip="Date & time to begin analysis")
//endDate = input.time(title="End Date", defval=timestamp("1 Jan 2099 19:30 +0000"), group="Tme Frame", tooltip="Date & time to stop analysis")
//timeSession = input.session(title="Time Session To Analyze", defval="0600-0915", group="Tme Frame", tooltip="Time session to analyze volatility")
//colorBG = input.bool(title="Color Background?", defval=true, group="Tme Frame", tooltip="Change the background color based on whether the current bar falls within the given session?")
// This function returns true if the current bar falls within the given time session (:1234567 is to include all weekdays)
//inSession(sess) => na(time(timeframe.period, sess + ":1234567")) == false and time >= startDate and time <= endDate
//bgcolor(inSession(timeSession) and colorBG ? color.rgb(158, 230, 245, 90) : na)
//=== Check if a new session has begun
//var withinSession = false
//if inSession(timeSession) and not inSession(timeSession)[1]
// withinSession := true
//======= User input ========
//EMA 1
res1 = input.timeframe(title='EMA 1 Time Frame', defval='60', group="Long EMA")
len1 = input(title='EMA 1 Length', defval=26, group="Long EMA")
//col = input(title='Color', defval=true, group="Long EMA")
smooth1 = input(title='Smooth ?', defval=true, group="Long EMA")
//EMA 2
res2 = input.timeframe(title='EMA 2 Time Frame', defval='60', group="Short EMA")
len2 = input(title='EMA 2 Length', defval=12, group="Short EMA")
//col = input(title='Color', defval=true, group="Short EMA")
smooth2 = input(title='Smooth ?', defval=true, group="Short EMA")
//======= Calculate EMAs ========
//EMA 1
ema1 = ta.ema(close, len1)
emaSmooth1 = request.security(syminfo.tickerid, res1, ema1, barmerge.gaps_on, barmerge.lookahead_off)
emaStep1 = request.security(syminfo.tickerid, res1, ema1, barmerge.gaps_off, barmerge.lookahead_off)
//EMA 2
ema2 = ta.ema(close, len2)
emaSmooth2 = request.security(syminfo.tickerid, res2, ema2, barmerge.gaps_on, barmerge.lookahead_off)
emaStep2 = request.security(syminfo.tickerid, res2, ema2, barmerge.gaps_off, barmerge.lookahead_off)
ematest1 = emaSmooth1
ematest2 = emaSmooth2
ematest1 := not na(emaSmooth1) ? emaSmooth1 : ematest1[1]
ematest2 := not na(emaSmooth2) ? emaSmooth2 : ematest2[1]
UPtrend = ematest2 > ematest1
DOWNtrend = ematest2 < ematest1
//Draw EMA
plot(smooth1 ? ematest1 : emaStep1, color=color.new(color.red, 40), linewidth=4, title='EMA 1', offset=15)
plot(smooth2 ? ematest2 : emaStep2, color=color.new(color.blue, 40), linewidth=2, title='EMA 2', offset=15)
//================ Stoch RSI ==================
smoothK = input.int(3, "K", minval=1)
smoothD = input.int(3, "D", minval=1)
lengthRSI = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
LongStrength = k > d
ShortStrength = k < d
//=========== RSI =====================
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"Bollinger Bands" => 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)
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
maLengthInput = input.int(14, title="MA Length", group="MA Settings")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"
//==Fist Opction
//Xover = (ta.crossover(rsi, 30) and rsi[1] < rsi) or (ta.crossover(rsi, rsiMA) and rsi[1] < rsi)
//Xunder = (ta.crossunder(rsi, 70) and rsi[1] > rsi) or (ta.crossunder(rsi, rsiMA) and rsi[1] > rsi)
//==2nd Option <-------- Evaluate
Xover = rsi < 50 and rsi[1] < rsi
Xunder = rsi > 50 and rsi[1] > rsi
//====== 'Directional Movement Index + ADX =======
adxlen = input(14, title='ADX Smoothing')
dilen = input(14, title='DI Length')
keyLevel = input(23, title='key level for ADX')
dirmov(len) =>
Uppp = ta.change(high)
Downnnn = -ta.change(low)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(Uppp > Downnnn and Uppp > 0 ? Uppp : 0, len) / truerange)
minus = fixnan(100 * ta.rma(Downnnn > Uppp and Downnnn > 0 ? Downnnn : 0, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
[adx, plus, minus]
[sig, Uppp, Downnnn] = adx(dilen, adxlen)
BuyerStrength = Uppp > Uppp[1] and Downnnn < Downnnn[1]
SellersStrength = Uppp < Uppp[1] and Downnnn > Downnnn[1]
//========== Volume from Waddah Attar Explosion V2 =======
sensitivity = 150
fastLength = 28
slowLength = 40
channelLength =20
mult = 2.0
DEAD_ZONE = nz(ta.rma(ta.tr(true), 100)) * 3.7
calc_macd(source, fastLength, slowLength) =>
fastMA = ta.ema(source, fastLength)
slowMA = ta.ema(source, slowLength)
fastMA - slowMA
calc_BBUpper(source, length, mult) =>
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
basis + dev
calc_BBLower(source, length, mult) =>
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
basis - dev
t1 = (calc_macd(close, fastLength, slowLength) - calc_macd(close[1], fastLength, slowLength)) * sensitivity
e1 = calc_BBUpper(close, channelLength, mult) - calc_BBLower(close, channelLength, mult)
trendUp = t1 >= 0 ? t1 : 0
trendDown = t1 < 0 ? -1 * t1 : 0
HighVolume = trendUp > DEAD_ZONE or trendDown > DEAD_ZONE
HighVolume123 = HighVolume or HighVolume[1] or HighVolume[2] or HighVolume[3]
//======== Price above 2nd EMA =======
CandleUp = ta.highest(5) > emaSmooth2
CandleUp12345 = CandleUp or CandleUp[1] or CandleUp[2] or CandleUp[3] or CandleUp[4] or CandleUp[5]
//========== Plots & Entrys =========
lo = LongStrength and Xover and BuyerStrength and HighVolume123
sh = ShortStrength and Xunder and SellersStrength and HighVolume123 //and CandleUp
Long = lo and UPtrend and (low < ematest2 or low < ematest2[1] or low < ematest2[2] or low < ematest2[3] or low < ematest2[4])
Short = sh and DOWNtrend and (high > ematest2 or high > ematest2[1] or high > ematest2[2] or high > ematest2[3] or high > ematest2[4])
plotshape(Long ? close : na, style=shape.triangleup, color=color.new(color.green, 0),
location=location.belowbar, title='Bullish Signal', text="L", textcolor=color.new(color.white, 0))
plotshape(Short ? close : na, style=shape.triangledown, color=color.new(color.purple, 0),
location=location.abovebar, title='Bearish Signal', text='S', textcolor=color.new(color.white, 0))
|
[Any Timeframe]-Homerun | https://www.tradingview.com/script/ZoeNf9F3-Any-Timeframe-Homerun/ | Nightweevil2477 | https://www.tradingview.com/u/Nightweevil2477/ | 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/
// © Nightweevil2477-Version 3-Initially Published On 20220727
//
// FYI
// This script is intended to be used as a 'indicator/visual aid'. End users will be able to see 'WHY' plot was shown and if wanted a dynamic alert can be set/triggered in tradingview.com for it
//
// New Version Release Schedule; Every Wednesday evening UTC+10 -only if their is a script update
// For each script version the author releases the end user is not forced to use the newer version, only if they want to
// End users are encouraged to migrate from old versions to new versions (Educates end user on what settings they use and their are always benefits/features when using the new script).
//
// Available script main functions
// 1. Identify 'Strike' patterns on the selected chart/timeframe
// 2. Plot 3 EMA lines on the on the selected chart/timeframe
// 3. Plot when the EMA lines cross on the on the selected chart/timeframe
// 4. Plot when strike patterns appear for a certain EMA
// 5. Plot 3 SMA lines on the on the selected chart/timeframe
// 6. Plot when the SMA lines cross on the on the selected chart/timeframe
// 7. Plot when strike patterns appear for a certain SMA
// 8. Display a table of details end user can see immediately
//
// Available script end user customization options
// Settings Area
// -=Root setting=- (all settings are disabled by default-end user can decide if they want on or off)
// Enable/Disable 'Strike' bearish pattern from being shown
// Enable/Disable 'Strike' bullish pattern from being shown
// Enable/Disable 3 EMA lines from being shown
// Enable/Disable when the EMA line cross's
// Enable/Disable 3 SMA lines from being shown
// Enable/Disable when the SMA line cross's
// Enable/Disable if want BB to be shown
// Enable/Disable when BB bars go outside the cloud
// Enable/Disable if you want table to be shown
// Enable/Disable if want Psar to be shown
// The 2 below are not required to be adjusted
// Symbol = current chart trading pair
// Time Period = current chart period (By default this is ALL)
//
// -=Granularity=-
// Added ability to enable/disable each EMA line
// 3x Set each EMA line length
// Added ability to enable/disable each EMA line
// 3x Set each SMA line length
// Added more EMA crossover labels on the chart
// Set BB scope
// Set Psar settings
// Added ability for end users to have their own customised table heading names
// Table: General oscillator stats added to table of details-RSI, ATR, Stochastic, W%R, CCI, AO, MACD, Aroon, ADX, Dem, Chande, ROC, DMI, VI
//
// Available dynamic alerts – can be used as triggers on tradingview.com
// Related to ‘Strike’ pattern identification
// Strike Bullish – Reason; pattern found
// Strike Bearish – Reason; pattern found
// Related to EMA plotted lines (crossing)
// EMA X Up-Reason; EMA line 1 goes up/over EMA line 2
// EMA X Down-Reason; EMA line 2 goes down/below EMA line 1
// Related to SMA plotted lines (crossing)
// SMA X Up-Reason; SMA line 1 goes up/over SMA line 2
// SMA X Down-Reason; SMA line 2 goes down/below SMA line 1
// BB Bullish-Reason; Bar sticking out upper cloud
// BB Bearish-Reason; Bar sticking out lower cloud
//
// Script modularity
// Each section of code is broken up into easily specific/editable areas
// For example; you can home in onto a specific code related area or you can make new area just
// specifically what you are trying to accomplish and just slot it into the existing code without
// breaking the format (their might be minimal conflict, normally this might be pre-used variables – if
// so; its easy to fix)
//
// For example; Work on individual/separate scripts and when its working, just slot it in to this 'Mega Script' + add script module description
// Normal conditions apply; is it an indicator or strategy. is it coded in the right pine script version 3/4/5
// (if not v5 then can convert old code to new code on tradingview.com)
//
// Table Explanation (more green the better)-Green = lower risk , Orange = medium risk, Red = higher risk
// Using default values supplied via script
// Ande Open
// -Real-Time chart info of the current pair price
// Last Close
// -Real-Time chart info of the current pair price
// Volume
// -Real-Time chart info of the current pair volume
// if over 0 then go green
// if under -0 then go red
// RSI - Relative Strength Index
// if over 70 then go red
// if between 69 through to 31 then go orange
// if under 30 then go green
// ATR - Average True Range
// if over 40 then go green
// if between 49 through to 27 then go orange
// if under 28 then go red
// Stoch Line 1 - Stochastic Oscillator
// if over 80 then go green
// if between 21 through to 79 then go orange
// if under 20 then go red
// Stoch Line 2 - Stochastic Oscillator
// if over 50 then go green
// if under 49 then go red
// W%R - William Percent Range
// if under -20 then go green
// if between -21 through to -79 then go orange
// if under -80 then go red
// CCI - Commodity Channel Index
// if over 100 then go green
// if between 99 through to -99 then go orange
// if under -100 then go red
// AO - Awesome Oscillator
// if over 0 then go green
// if under -0 then go red
// MACD Line 1 - Moving Average Convergence Divergence
// if over 0 then go green
// if under -0 then go red
// MACD Line 2 - Moving Average Convergence Divergence
// if over 0 then go green
// if under -0 then go red
// MACD Hist - Moving Average Convergence Divergence
// if over 0 then go green
// if under -0 then go red
// Aroon - Aroon Oscillator
// if over 50 then go green
// if under -0 then go red
// ADX - Average Directional Index
// if over 50 then go green
// if under -50 then go red
// DeM -DeMarker Indicator
// if over 0.7 then go red
// if under 0.3 then go green
// Chande - Chande Momentum Oscillator
// if over 50 then go red
// if under -50 then go green
// ROC - Rate of change
// if under 0 then go green
// if under 0 then go red
// DMI+ - Directional Movement Index
// if above DMI- then go green
// if under DMI- then go red
// DMI- - Directional Movement Index
// if below DMI+ then go red
// if above DMI+ then go green
// VI - Vorteex Indicator
// if above VI- then go green
// if under VI- then go red
// VI - Vorteex Indicator
// if below VI+ then go red
// if above VI+ then go green
//
// V1 Change log – 27/7/22
// Published initial ‘Strike Pattern Identification’ script
// Included chart plots if detected pattern was ‘Bullish or Bearish’
// Included chart dynamic alerts (depends on the real-time market data and when new pattern is plotted Chart)
//
// V2 Change log – 11/8/22
// Made each coded feature to be either Enabled/Disabled by the end user (all is default OFF as end user can decide if they want to enable else to many plots Chart, this can confuse end users)
// Added EMA lines (x3)
// Added chart plots when the EMA lines cross
// Added SMA lines (x3)
// Added chart plots when the SMA lines cross
// Added granularity – ability for end users to alter few defined parametersAC
// Added table of useful details the end user might want to see at a glance
// For each plotted item added it to the dynamic alert option end user can use as trigger on tradingview.com
// Encapsulated each feature into their own sperate easy to modify/switch out for other modules
// Added all this same info + more in the actual script beginning/blurb as end user not always see tradingview.com or profile site, they just see the item from the site ‘indicator’ area prior to adding it to the ‘Chart or Favorites’
//
// V3 Change log – 31/7/22
// Added missing module descriptions from the previous release
// Fixed some spelling/grammar mistakes
// Decided timeline for future script releases (Every Wednesday evening UTC+10 -only if their is a script update)
// Added Bollinger Bands (In the script it’s called ‘BB’)
// Added Parabolic Sar (In the script it’s called ‘Psar’)
// Added chart plots when the BB exits the cloud
// Add ability to change table orientation
// Improved table colors (more green the better) -Green = lower risk , Orange = medium risk, Red = higher risk
// General oscillator stats added to table of details-RSI, ATR, Stochastic, W%R, CCI, AO, MACD, Aroon, ADX
// Added script Disclaimer to the Settings area
//
// V4 Change log – 5/10/22
// Added ability for end users to have their own customised table heading names
// Cleaned up Settings-->Inputs screen slightly
// Converted code for end user table to be a reuseable functions
// Tweaked table colors
// Added MACD (Histogram) stats to the table
// Added ability to enable/disable each EMA line
// Added more EMA crossover labels on the chart
// Added ability to enable/disable each SMA line
// Added more SMA crossover labels on the chart
// Added DeM stats to the table
// Added Chande stats to the table
// Added ROC stats to the table
// Added VI stats to the table
// Added a tooltip for every table stat to allow end users to be reminded what stat means (i.e; why does the color keep changing)
// Added new module based on Strike patterns and if above or below the EMA line specified
// Added new module based on Strike patterns and if above or below the SMA line specified
// Updated Psar module to have some alerts to use via tradingview.com
//
//@version=5
indicator(title='[Any Timeframe]-Homerun', overlay=true)
//End user notice of script intention
ScriptEula = "This script is intended to be used as a 'indicator/visual aid'. End users will be able to see 'WHY' plot was shown and if wanted a dynamic alert can be set/triggered in tradingview.com for it"
SettingsInputPage = input.bool(true, ScriptEula, group="-=Disclaimer=-")
plotshape(false, color=color.white, title="-=Disclaimer=- " + ScriptEula)
//Strike Pattern Module--------------------------------------------------------------------------
//Give end user the option if they want strike section enabled or not
showBullishStrikepattern = input.bool(false,"Show Bullish Strike Pattern", group="Pattern")
showBearishStrikepattern = input.bool(false,"Show Bearish Strike Pattern", group="Pattern")
//identify bullish pattern; green green green red
StrikeBullcandleCheck1st = barstate.isconfirmed and close[3] > open[3]
StrikeBullcandleCheck2nd = barstate.isconfirmed and close[2] > open[2]
StrikeBullcandleCheck3rd = barstate.isconfirmed and close[1] > open[1]
StrikeBullcandleCheck4th = barstate.isconfirmed and close[0] < open[0]
StrikeBullpatternCheck = StrikeBullcandleCheck1st and StrikeBullcandleCheck2nd and StrikeBullcandleCheck3rd and StrikeBullcandleCheck4th
//identify bearish pattern; red red red green
StrikeBearcandleCheck1st = barstate.isconfirmed and close[3] < open[3]
StrikeBearcandleCheck2nd = barstate.isconfirmed and close[2] < open[2]
StrikeBearcandleCheck3rd = barstate.isconfirmed and close[1] < open[1]
StrikeBearcandleCheck4th = barstate.isconfirmed and close[0] > open[0]
StrikeBearpatternCheck = StrikeBearcandleCheck1st and StrikeBearcandleCheck2nd and StrikeBearcandleCheck3rd and StrikeBearcandleCheck4th
//Plot it Chart
//For every strike pattern found
plotshape(showBullishStrikepattern ? StrikeBullpatternCheck: na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Pattern-Strike-Bullish", title="Chart-Pattern-Strike-Bullish")
plotshape(showBearishStrikepattern ? StrikeBearpatternCheck: na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Pattern-Strike-Bearish", title="Chart-Pattern-Strike-Bearish")
//Trigger Alert (only works if trigger set on tradingview.com site)
//For every strike pattern found
alertcondition(showBullishStrikepattern ? StrikeBullpatternCheck: na, title='Chart-Pattern-Strike-Bullish')
alertcondition(showBearishStrikepattern ? StrikeBearpatternCheck: na, title='Chart-Pattern-Strike-Bearish')
//EMA Module----------------------------------------------------------------------------------------
//Give end user the option if they want EMA line 1 enabled or not
showEmaLine1 = input.bool(false,"Show EMA Line 1", group="EMA")
ema1=input.int(defval=20, title="Chart-EMA-Line 1", group="EMA")
setEma1 = ta.ema(close, ema1)
//Give end user the option if they want EMA line 2 enabled or not
showEmaLine2 = input.bool(false,"Show EMA Line 2", group="EMA")
ema2=input.int(defval=50, title="Chart-EMA-Line 2", group="EMA")
setEma2 = ta.ema(close, ema2)
//Give end user the option if they want EMA line 3 enabled or not
showEmaLine3 = input.bool(false,"Show EMA Line 3", group="EMA")
ema3=input.int(defval=200, title="Chart-EMA-Line 3", group="EMA")
setEma3 = ta.ema(close, ema3)
//Plot it Chart
//Plot EMA lines Chart only if item is enabled in the settings area
plot(showEmaLine1 ? setEma1 : na, color=color.red, linewidth=2, title="Chart-EMA-Line 1")
plot(showEmaLine2 ? setEma2 : na, color=color.green, linewidth=2, title="Chart-EMA-Line 2")
plot(showEmaLine3 ? setEma3 : na, color=color.black, linewidth=2, title="Chart-EMA-Line 3")
//Plot Ema line crosses
//Give end user the option if they want shox x's section enabled or not
showEmaLineCrosses = input.bool(false,"Show EMA X's", group="EMA")
//Detect line cross
ema_crossing_up = ta.crossover(setEma1, setEma2) //red above green
ema_crossing_down = ta.crossunder(setEma1, setEma2) //red under green
ema_crossing_up2 = ta.crossover(setEma2, setEma1) //green above red
ema_crossing_down2 = ta.crossunder(setEma2, setEma1) //green under red
//Plot it Chart if setting is enabled
plotshape(showEmaLineCrosses ? ema_crossing_up : na, style=shape.cross, location=location.abovebar, color=color.new(color.red, 0), text='Chart-EMA-Line 1 X Above Line 2', title='Chart-EMA-Line 1 X Above Line 2')
plotshape(showEmaLineCrosses ? ema_crossing_down : na, style=shape.cross, location=location.abovebar, color=color.new(color.red, 0), text='Chart-EMA-Line 1 X Under Line 2', title='Chart-EMA-Line 1 X Under Line 2')
plotshape(showEmaLineCrosses ? ema_crossing_up2 : na, style=shape.cross, location=location.belowbar, color=color.new(color.red, 0), text='Chart-EMA-Line 2 X Above Line 1', title='Chart-EMA-Line 2 X Above Line 1')
plotshape(showEmaLineCrosses ? ema_crossing_down2 : na, style=shape.cross, location=location.belowbar, color=color.new(color.red, 0), text='Chart-EMA-Line 2 X Under Line 1', title='Chart-EMA-Line 2 X Under Line 1')
//Trigger Alert (only works if trigger set on tradingview.com site)
//When EMA line crosses
alertcondition(showEmaLineCrosses ? ema_crossing_up: na, title='Chart-EMA-Line 1 X Above Line 2')
alertcondition(showEmaLineCrosses ? ema_crossing_down: na, title='Chart-EMA-Line 1 X Under Line 2')
alertcondition(showEmaLineCrosses ? ema_crossing_up2: na, title='Chart-EMA-Line 2 X Above Line 1')
alertcondition(showEmaLineCrosses ? ema_crossing_down2: na, title='Chart-EMA-Line 2 X Under Line 1')
//EMA Strike Module--------------------------------------------------------------------------------------------------------
//Show pattern were filter condition is true
showBullishStrikepatternEMALine1 = input.bool(false,"Show Bullish Strike Pattern Above The EMA Line 1", group="Pattern/EMA")
showBullishStrikepatternEMALine2 = input.bool(false,"Show Bullish Strike Pattern Above The EMA Line 2", group="Pattern/EMA")
showBullishStrikepatternEMALine3 = input.bool(false,"Show Bullish Strike Pattern Above The EMA Line 3", group="Pattern/EMA")
showBearishStrikepatternEMALine1 = input.bool(false,"Show Bearish Strike Pattern Below The EMA Line 1", group="Pattern/EMA")
showBearishStrikepatternEMALine2 = input.bool(false,"Show Bearish Strike Pattern Below The EMA Line 2", group="Pattern/EMA")
showBearishStrikepatternEMALine3 = input.bool(false,"Show Bearish Strike Pattern Below The EMA Line 3", group="Pattern/EMA")
//Filter found patterns to be only above or below the EMA Line
strikebullpatternEMALine1filter = StrikeBullpatternCheck == true and close > setEma1
strikebearpatternEMALine1filter = StrikeBearpatternCheck == true and close < setEma1
strikebullpatternEMALine2filter = StrikeBullpatternCheck == true and close > setEma2
strikebearpatternEMALine2filter = StrikeBearpatternCheck == true and close < setEma2
strikebullpatternEMALine3filter = StrikeBullpatternCheck == true and close > setEma3
strikebearpatternEMALine3filter = StrikeBearpatternCheck == true and close < setEma3
//Plot it on the chart
plotshape(showBullishStrikepatternEMALine1 ? strikebullpatternEMALine1filter : na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Pattern-Above EMA Line 1-Strike-Bullish", title="Chart-Pattern-Above EMA Line 1-Strike-Bullish")
plotshape(showBearishStrikepatternEMALine1 ? strikebearpatternEMALine1filter : na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Pattern-Below EMA Line 1-Strike-Bearish", title="Chart-Pattern-Below EMA Line 1-Strike-Bearish")
plotshape(showBullishStrikepatternEMALine2 ? strikebullpatternEMALine2filter : na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Pattern-Above EMA Line 1-2-Strike-Bullish", title="Chart-Pattern-Above EMA Line 2-Strike-Bullish")
plotshape(showBearishStrikepatternEMALine2 ? strikebearpatternEMALine2filter : na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Pattern-Below EMA Line 2-Strike-Bearish", title="Chart-Pattern-Below EMA Line 2-Strike-Bearish")
plotshape(showBullishStrikepatternEMALine3 ? strikebullpatternEMALine3filter : na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Pattern-Above EMA Line 3-Strike-Bullish", title="Chart-Pattern-Above EMA Line 3-Strike-Bullish")
plotshape(showBearishStrikepatternEMALine3 ? strikebearpatternEMALine3filter : na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Pattern-Below EMA Line 3-Strike-Bearish", title="Chart-Pattern-Below EMA Line 3-Strike-Bearish")
//Trigger Alert (only works if trigger set on tradingview.com site)
//For every strike pattern found
alertcondition(strikebullpatternEMALine1filter, title='Pattern-Above EMA Line 1-Strike-Bullish')
alertcondition(strikebearpatternEMALine1filter, title='Pattern-Below EMA Line 1-Strike-Bearish')
alertcondition(strikebullpatternEMALine2filter, title='Pattern-Above EMA Line 2-Strike-Bullish')
alertcondition(strikebearpatternEMALine2filter, title='Pattern-Below EMA Line 2-Strike-Bearish')
alertcondition(strikebullpatternEMALine3filter, title='Pattern-Above EMA Line 3-Strike-Bullish')
alertcondition(strikebearpatternEMALine3filter, title='Pattern-Below EMA Line 3-Strike-Bearish')
//SMA Module----------------------------------------------------------------------------------------
//Give end user the option if they want SMA line 1 enabled or not
showSmaLine1 = input.bool(false,"Show SMA Line 1", group="SMA")
sma1=input.int(defval=20, title="Chart-SMA-Line 1", group="SMA")
setSma1 = ta.sma(close, sma1)
//Give end user the option if they want SMA line 2 enabled or not
showSmaLine2 = input.bool(false,"Shows SMA Line 2", group="SMA")
sma2=input.int(defval=50, title="Chart-SMA-Line 2", group="SMA")
setSma2 = ta.sma(close, sma2)
//Give end user the option if they want SMA line 3 enabled or not
showSmaLine3 = input.bool(false,"Show SMA Line 3", group="SMA")
sma3=input.int(defval=100, title="Chart-SMA-Line 3", group="SMA")
setSma3 = ta.sma(close, sma3)
//Plot SMA lines Chart only if item is enabled in the settings area
plot(showSmaLine1 ? setSma1 : na, color=color.purple, linewidth=2, title="Chart-SMA-Line 1")
plot(showSmaLine2 ? setSma2 : na, color=color.orange, linewidth=2, title="Chart-SMA-Line 2")
plot(showSmaLine3 ? setSma3 : na, color=color.aqua, linewidth=2, title="Chart-SMA-Line 3")
//Plot Sma line crosses
//Give end user the option if they want table of details enabled or not
showSmaLineCrosses = input.bool(false,"Show SMA X's", group="SMA")
//Detect line cross
sma_crossing_up = ta.crossover(setSma1, setSma2) //purple above orange
sma_crossing_down = ta.crossunder(setSma1, setSma2) //purple under orange
sma_crossing_up2= ta.crossover(setSma2, setSma1) //orange above purple
sma_crossing_down2 = ta.crossunder(setSma2, setSma1) //orange under purple
//Plot it Chart if setting is enabled
plotshape(showSmaLineCrosses ? sma_crossing_up : na, style=shape.cross, location=location.abovebar, color=color.new(color.red, 0), text='Chart-SMA-Line 1 X Above Line 2', title='Chart-SMA-Line 1 X Above Line 2')
plotshape(showSmaLineCrosses ? sma_crossing_down : na, style=shape.cross, location=location.abovebar, color=color.new(color.red, 0), text='Chart-SMA-Line 1 X Under Line 2', title='Chart-SMA-Line 1 X Under Line 2')
plotshape(showSmaLineCrosses ? sma_crossing_up2 : na, style=shape.cross, location=location.belowbar, color=color.new(color.red, 0), text='Chart-SMA-Line 2 X Above Line 1', title='Chart-SMA-Line 2 X Above Line 1')
plotshape(showSmaLineCrosses ? sma_crossing_down2 : na, style=shape.cross, location=location.belowbar, color=color.new(color.red, 0), text='Chart-SMA-Line 2 X Under Line 1', title='Chart-SMA-Line 2 X Under Line 1')
//Trigger Alert (only works if trigger set on tradingview.com site)
//When SMA line crosses
alertcondition(showSmaLineCrosses ? sma_crossing_up: na, title='Chart-SMA-Line 1 X Above Line 2')
alertcondition(showSmaLineCrosses ? sma_crossing_down : na, title='Chart-SMA-Line 1 X Under Line 2')
alertcondition(showSmaLineCrosses ? sma_crossing_up2 : na, title='Chart-SMA-Line 2 X Above Line 1')
alertcondition(showSmaLineCrosses ? sma_crossing_down2 : na, title='Chart-SMA-Line 2 X Under Line 1')
//SMA Strike Module--------------------------------------------------------------------------------------------------------
//Show pattern were filter condition is true
showBullishStrikepatternSMALine1 = input.bool(false,"Show Bullish Strike Pattern Above The SMA Line 1", group="Pattern/SMA")
showBullishStrikepatternSMALine2 = input.bool(false,"Show Bullish Strike Pattern Above The SMA Line 2", group="Pattern/SMA")
showBullishStrikepatternSMALine3 = input.bool(false,"Show Bullish Strike Pattern Above The SMA Line 3", group="Pattern/SMA")
showBearishStrikepatternSMALine1 = input.bool(false,"Show Bearish Strike Pattern Below The SMA Line 1", group="Pattern/SMA")
showBearishStrikepatternSMALine2 = input.bool(false,"Show Bearish Strike Pattern Below The SMA Line 2", group="Pattern/SMA")
showBearishStrikepatternSMALine3 = input.bool(false,"Show Bearish Strike Pattern Below The SMA Line 3", group="Pattern/SMA")
//Filter found patterns to be only above or below the SMA Line
strikebullpatternSMALine1filter = StrikeBullpatternCheck == true and close > setSma1
strikebearpatternSMALine1filter = StrikeBearpatternCheck == true and close < setSma1
strikebullpatternSMALine2filter = StrikeBullpatternCheck == true and close > setSma2
strikebearpatternSMALine2filter = StrikeBearpatternCheck == true and close < setSma2
strikebullpatternSMALine3filter = StrikeBullpatternCheck == true and close > setSma3
strikebearpatternSMALine3filter = StrikeBearpatternCheck == true and close < setSma3
//Plot it on the chart
plotshape(showBullishStrikepatternSMALine1 ? strikebullpatternSMALine1filter : na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Pattern-Above SMA Line 1-Strike-Bullish", title="Chart-Pattern-Above SMA Line 1-Strike-Bullish")
plotshape(showBearishStrikepatternSMALine1 ? strikebearpatternSMALine1filter : na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Pattern-Below SMA Line 1-Strike-Bearish", title="Chart-Pattern-Below SMA Line 1-Strike-Bearish")
plotshape(showBullishStrikepatternSMALine2 ? strikebullpatternSMALine2filter : na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Pattern-Above SMA Line 1-2-Strike-Bullish", title="Chart-Pattern-Above SMA Line 2-Strike-Bullish")
plotshape(showBearishStrikepatternSMALine2 ? strikebearpatternSMALine2filter : na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Pattern-Below SMA Line 2-Strike-Bearish", title="Chart-Pattern-Below SMA Line 2-Strike-Bearish")
plotshape(showBullishStrikepatternSMALine3 ? strikebullpatternSMALine3filter : na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Pattern-Above SMA Line 3-Strike-Bullish", title="Chart-Pattern-Above SMA Line 3-Strike-Bullish")
plotshape(showBearishStrikepatternSMALine3 ? strikebearpatternSMALine3filter : na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Pattern-Below SMA Line 3-Strike-Bearish", title="Chart-Pattern-Below SMA Line 3-Strike-Bearish")
//Trigger Alert (only works if trigger set on tradingview.com site)
//For every strike pattern found
alertcondition(strikebullpatternSMALine1filter, title='Pattern-Above SMA Line 1-Strike-Bullish')
alertcondition(strikebearpatternSMALine1filter, title='Pattern-Below SMA Line 1-Strike-Bearish')
alertcondition(strikebullpatternSMALine2filter, title='Pattern-Above SMA Line 2-Strike-Bullish')
alertcondition(strikebearpatternSMALine2filter, title='Pattern-Below SMA Line 2-Strike-Bearish')
alertcondition(strikebullpatternSMALine3filter, title='Pattern-Above SMA Line 3-Strike-Bullish')
alertcondition(strikebearpatternSMALine3filter, title='Pattern-Below SMA Line 3-Strike-Bearish')
//Psar Module--------------------------------------------------------------------------------------
//Give end user the option if they want to show Psar
showPsar= input.bool(false,"Show Psar Bands",group="Psar")
//Get Psar values to use from the end user
Psarstart = input.float(title='Chart-Psar-Start', step=0.00005, defval=0.00252,group="Psar")
Psarincrement = input.float(title='Chart-Psar-Increment', step=0.00005, defval=0.00133,group="Psar")
Psarmaximum = input.float(title='Chart-Psar-Maximum', step=0.01, defval=0.220,group="Psar")
//Caclculate
psar = ta.sar(Psarstart, Psarincrement, Psarmaximum)
dir = psar < close ? 1 : -1
//Plot it Chart
//Boarder
plot(showPsar ? psar : na, style=plot.style_circles, color=color.blue, title="Chart-Psar-Boarder")
//Give end user the option if they want table of details enabled or not
showPsarLabels = input.bool(false,"Show Psar Bullish & Bearish labels on the Chart", group="Psar")
//Bullish & Bearish labels
plotshape(showPsarLabels and dir == 1 and dir[1] == -1 ? psar : na, style=shape.triangledown, location=location.abovebar, color=color.green, text="Psar-Bullish", title="Chart-Psar-Bullish")
plotshape(showPsarLabels and dir == -1 and dir[1] == 1 and showPsarLabels ? psar : na, style=shape.triangleup, location=location.belowbar, color=color.red, text="Psar-Bearish", title="Chart-Psar-Bearish")
//Trigger Alert (only works if trigger set on tradingview.com site)
alertcondition(showPsarLabels and dir == 1 and dir[1] == -1 ? psar : na, title='Chart-Psar-Bullish')
alertcondition(showPsarLabels and dir == -1 and dir[1] == -1 ? psar : na, title='Chart-Psar-Bearish')
//BB Module-----------------------------------------------------------------------------------------
//Give end user the option if they want to show BB
showBB= input.bool(false,"Show Bollinger Bands", group="BB")
//Get BB values to use from the end user
getBBlength=input.int(defval=20, title="Chart-BB-Length",group="BB")
getBBDeviation=input.float(2.0, title="Chart-BB-Deveation",group="BB")
getBBlOffset=input.int(defval=0, title="Chart-BB-Offset",group="BB")
basis = ta.sma(close, getBBlength)
dev = getBBDeviation * ta.stdev(close, getBBlength)
setBBUpperlinecolor = basis + dev
setBBLowerlinecolor = basis-dev
//Plots the various BB lines Chart and provides option to change its color in the 'Settings' area
setBBLineatTop = plot(showBB ? setBBUpperlinecolor : na, "Chart-BB-Upper Line", color=#2962FF, offset = getBBlOffset)
plot(showBB ? basis: na, "Chart-BB-Middle Line", color=#FF6D00, offset = getBBlOffset)
setBBLineatBottom = plot(showBB ? setBBLowerlinecolor: na, "Chart-BB-Lower Line", color=#2962FF, offset = getBBlOffset)
//Plot BB background color Chart and provides option to change its color in the 'Settings' area
fill(setBBLineatTop, setBBLineatBottom, title = "Chart-BB-Background", color=color.rgb(33, 150, 243, 95))
//Give end user the option if they want to show BB
showBBPokingOut= input.bool(false,"Show BB Poking out",group="BB")
//Calculate BB bars stickingout
down = close < setBBLowerlinecolor
up = close > setBBUpperlinecolor
BBUp = ta.barssince(up)
BBDown = ta.barssince(down)
BBBearish = BBUp < BBDown and not (BBUp < BBDown)[1]
BBBullish = BBDown < BBUp and not (BBDown < BBUp)[1]
//Plot BB bars with symbol when above or below the BB fill area
plotshape(showBBPokingOut ? BBBearish : na, color=color.new(#008000, 0), style=shape.triangledown, location=location.abovebar, title='Chart-BB-Poking out-Bullish', text='Chart-BB-Poking out-Bullish')
plotshape(showBBPokingOut ? BBBullish : na, color=color.new(#ff0100, 0), style=shape.triangleup, location=location.belowbar, title='Chart-BB-Poking out-Bearish', text='Chart-BB-Poking out-Bearish')
//Trigger Alert (only works if trigger set on tradingview.com site)
//When bars go outside the BB cloud
alertcondition(showBBPokingOut ? BBBullish: na, title='Chart-BB-Poking out-Bullish')
alertcondition(showBBPokingOut ? BBBearish: na, title='Chart-BB-Poking out-Bearish')
//Table Module--------------------------------------------------------------------------------------
//Give end user the option if they want table displayed enabled or not
showInfoTable = input.bool(false,"Show Info Table (Display/Build it the way you want)",group="Table Of Details")
//Global variables - table portrait
var colum_Portrait = 0
var row_Portrait = 1
var colum2_Portrait = 1
var row2_Portrait = 1
//Global variables - table landscape
var colum_Landscape = 0
var row_Landscape = 0
var colum2_Landscape = 0
var row2_Landscape = 1
//Preset variables
noneNumber=0
noneText=""
heading="heading"
row="row"
color_order_change="color_order_change"
BUYNSELL="BUYNSELL"
MULTI="MULTI"
//Table Positions
bright = position.bottom_right
bleft = position.bottom_left
bcenter = position.bottom_center
tright = position.top_right
tleft = position.top_left
tcenter = position.top_center
mright = position.middle_right
mleft = position.middle_left
mcenter = position.middle_center
itablePosition = input.string(bleft, title="Table Position", options=[bright, bleft, bcenter, tright, tleft, tcenter, mright, mleft, mcenter],group="Table Of Details")
//Show table
createTableposition = table.new(itablePosition,99,99,border_width=4,border_color=color.gray, frame_color=color.gray, frame_width=4)
setCurrenciyPair = input.symbol("","Symbol",group="Table Of Details") //By default the script uses the current selected pair
setChartPeriod=input.timeframe(defval="",title="Time Period",group="Table Of Details") //By default the script uses the current all of the chart as the time period
//Table Layout
option1 = "Portrait"
option2 = "Landscape"
tableScale = input.string(option1, title="Table Layout", options=[option1, option2],group="Table Of Details")
createTable(heading_or_row, type, name, mainvalue, highvalue, lowvalue, endUserDisplayedValue, tip) =>
if heading_or_row == "heading"
//This if statement applies to table rows: meregcellheading1, meregcellheading2
if tableScale == "Portrait"
table.cell(createTableposition, colum_Portrait, row_Portrait, bgcolor=color.black, text_color=color.white, text=name)
table.cell(createTableposition, colum2_Portrait, row2_Portrait, bgcolor=color.black)
table.merge_cells(createTableposition, colum_Portrait, row_Portrait, colum2_Portrait, row2_Portrait)
if tableScale == "Landscape"
table.cell(createTableposition, colum_Landscape, row_Landscape, bgcolor=color.black, text_color=color.white, text=name)
table.cell(createTableposition, colum2_Landscape, row2_Landscape, bgcolor=color.black)
table.merge_cells(createTableposition, colum_Landscape, row_Landscape, colum2_Landscape, row2_Landscape)
if heading_or_row == "row"
//This if statement applies to table rows: lastopenprice, lastcloseprice, change, volume
color_lower_risk = color.green
color_medium_risk = color.orange
color_high_risk = color.red
if tableScale == "Portrait"
table.cell(createTableposition, colum_Portrait, row_Portrait, bgcolor=color.black, text_color=color.white, text=name, tooltip=tip)
table.cell(createTableposition, colum2_Portrait, row2_Portrait, bgcolor=mainvalue >= highvalue ? color_lower_risk : mainvalue <= lowvalue ? color_lower_risk : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
if tableScale == "Landscape"
table.cell(createTableposition, colum_Landscape, row_Landscape, bgcolor=color.black, text_color=color.white, text=name, tooltip=tip)
table.cell(createTableposition, colum2_Landscape, row2_Landscape, bgcolor=mainvalue >= highvalue ? color_lower_risk : mainvalue <= lowvalue ? color_lower_risk : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
if type == "color_order_change"
//This if statement applies to table rows: atr, cci, cmo
color_lower_risk = color.red
color_medium_risk = color.orange
color_high_risk = color.green
if tableScale == "Portrait"
table.cell(createTableposition, colum_Portrait, row_Portrait, bgcolor=color.black, text_color=color.white, text=name), tooltip=tip
table.cell(createTableposition, colum2_Portrait, row2_Portrait, bgcolor=mainvalue >= highvalue ? color_lower_risk : mainvalue <= lowvalue ? color_lower_risk : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
if tableScale == "Landscape"
table.cell(createTableposition, colum_Landscape, row_Landscape, bgcolor=color.black, text_color=color.white, text=name, tooltip=tip)
table.cell(createTableposition, colum2_Landscape, row2_Landscape, bgcolor=mainvalue >= highvalue ? color_lower_risk : mainvalue <= lowvalue ? color_lower_risk : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
if type == "BUYNSELL"
//This if statement applies to table rows: rsi, stochline1,stochline2, wpr, dem
color_sell = color.red
color_medium_risk = color.orange
color_buy = color.green
if tableScale == "Portrait"
table.cell(createTableposition, colum_Portrait, row_Portrait, bgcolor=color.black, text_color=color.white, text=name, tooltip=tip)
table.cell(createTableposition, colum2_Portrait, row2_Portrait, bgcolor=mainvalue >= highvalue ? color_sell : mainvalue <= lowvalue ? color_buy : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
if tableScale == "Landscape"
table.cell(createTableposition, colum_Landscape, row_Landscape, bgcolor=color.black, text_color=color.white, text=name, tooltip=tip)
table.cell(createTableposition, colum2_Landscape, row2_Landscape, bgcolor=mainvalue >= highvalue ? color_sell : mainvalue <= lowvalue ? color_buy : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
if type == "MULTI"
//This if statement applies to table rows: ao, macdline1, macdline2, macdhist, aroon, adx, roc, dmiplus, dminegative, vortexplus, vortexnegative
color_below_line = color.red
color_medium_risk = color.orange
color_above_line = color.green
if tableScale == "Portrait"
table.cell(createTableposition, colum_Portrait, row_Portrait, bgcolor=color.black, text_color=color.white, text=name, tooltip=tip)
table.cell(createTableposition, colum2_Portrait, row2_Portrait, bgcolor=mainvalue >= highvalue ? color_above_line : mainvalue <= lowvalue ? color_below_line : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
if tableScale == "Landscape"
table.cell(createTableposition, colum_Landscape, row_Landscape, bgcolor=color.black, text_color=color.white, text=name, tooltip=tip)
table.cell(createTableposition, colum2_Landscape, row2_Landscape, bgcolor=mainvalue >= highvalue ? color_above_line : mainvalue <= lowvalue ? color_below_line : color_medium_risk, text_color=color.white, text=endUserDisplayedValue)
//tradingview.com indicator formula for MACD
fast_ma = ta.sma(close, 12)
slow_ma = ta.sma(close, 26)
macd = fast_ma - slow_ma
signal = ta.sma(macd, 9)
//tradingview.com indicator formula for ADX
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
//tradingview.com indicator formula for ADX
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus-minus) / (sum == 0 ? 1 : sum), adxlen)
//tradingview.com indicator formula for DeM
per=14
demax = high > high[1] ? high - high[1] : 0
demin = low < low[1] ? low[1] - low : 0
demax_av = ta.sma(demax, per)
demin_av = ta.sma(demin, per)
//tradingview.com indicator formula for CMO
momm = ta.change(close)
f1(m) => m >= 0.0 ? m : 0.0
f2(m) => m >= 0.0 ? 0.0 : -m
m1 = f1(momm)
m2 = f2(momm)
sm1 = math.sum(m1, 9)
sm2 = math.sum(m2, 9)
percent(nom, div) => 100 * nom / div
//tradingview.com indicator formula for DMI
lensig = 14
len = 14
updmi = ta.change(high)
downdmi = -ta.change(low)
plusDM = na(updmi) ? na : (updmi > downdmi and updmi > 0 ? updmi : 0)
minusDM = na(downdmi) ? na : (downdmi > updmi and downdmi > 0 ? downdmi : 0)
trur = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / trur)
minus = fixnan(100 * ta.rma(minusDM, len) / trur)
//sum = plus + minus
//average directional index
//adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
////tradingview.com indicator formula for DVI
VMP = math.sum( math.abs( high - low[1]), 14 )
VMM = math.sum( math.abs( low - high[1]), 14)
STR = math.sum( ta.atr(1), 14)
VIP = VMP / STR
VIM = VMM / STR
//Shorten decimal points
truncate(number, decimals) =>
factor = math.pow(10, decimals)
int(number * factor) / factor
//Get end users input on wanted
Add_Row_Name_meregcellheading1 = input.bool(false,"---Add Below Associated Table Heading",group="Edit Table Heading/Market")
meregcellheading1=input(defval="Market", title="Table Heading", group="Edit Table Heading/Market")
//Get end users input on wanted
Add_Row_Name_lastopenprice = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Market")
Cell_Name_lastopenprice = input(defval="Candle Open", title="Table Heading", group="Edit Table Heading/Market")
//Get end users input on wanted
Add_Row_Name_lastcloseprice = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Market")
Cell_Name_lastcloseprice = input(defval="Last Closed", title="Table Heading", group="Edit Table Heading/Market")
//Get end users input on wanted
Add_Row_Name_change = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Market")
Cell_Name_change = input(defval="% Changed", title="Table Heading", group="Edit Table Heading/Market")
//Get end users input on wanted
Add_Row_Name_volume = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Market")
Cell_Name_volume = input(defval="Volume", title="Table Heading", group="Edit Table Heading/Market")
//Get end users input on wanted
Add_Row_Name_meregcellheading2 = input.bool(false,"---Add Below Associated Table Heading",group="Edit Table Heading")
meregcellheading2=input(defval="Oscillators", title="Table Heading", group="Edit Table Heading")
//Get end users input on wanted RSI
Add_Row_Name_rsi = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_rsi=input(defval="RSI", title="Table Heading", group="Edit Table Heading/Stat Threshold")
RSIOverbought = input.int(defval=70, title="RSI OverBought",group="Edit Table Heading/Stat Threshold")
RSIOversold = input.int(defval=30, title="RSI OverSold",group="Edit Table Heading/Stat Threshold")
tooltiprsi = "Green=Good time to Buy/Orange=Neutral/RED=Good time to Sell"
//Get end users input on wanted ATR
Add_Row_Name_atr = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_atr=input(defval="ATR", title="Table Heading", group="Edit Table Heading/Stat Threshold")
ATRHigh = input.int(defval=40, title="ATR High level of volatility",group="Edit Table Heading/Stat Threshold")
ATRLow = input.int(defval=28, title="ATR Low level of volatility",group="Edit Table Heading/Stat Threshold")
tooltipatr = "Green=High Movement/Orange=Neutral/Red=Low Movement"
//Get end users input on wanted Stochastic line 1 levels
Add_Row_Name_stochline1 = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_stochline1=input(defval="Stoch (Line 1)", title="Table Heading", group="Edit Table Heading/Stat Threshold")
StochOverbought = input.int(defval=80, title="Stoch OverBought",group="Edit Table Heading/Stat Threshold")
StochOversold = input.int(defval=30, title="Stoch OverSold",group="Edit Table Heading/Stat Threshold")
tooltipstochline1 = "Green=Good time to Buy/Orange=Neutral/RED=Good time to Sell"
//Get end users input on wanted Stochastic line 2 levels
Add_Row_Name_stochline2 = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_stochline2=input(defval="Stoch (Line 2)", title="Table Heading", group="Edit Table Heading/Stat Threshold")
StochHigh = input.int(defval=50, title="Stoch OverBought",group="Edit Table Heading/Stat Threshold")
StochLow = input.int(defval=49, title="Stoch OverSold",group="Edit Table Heading/Stat Threshold")
tooltipstochline2 = "Green=Good time to Buy/Orange=Neutral/RED=Good time to Sell"
//Get end users input on what config for William percent range
Add_Row_Name_wpr = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_wpr=input(defval="W%R", title="Table Heading", group="Edit Table Heading/Stat Threshold")
WpercentRMax = input.int(defval=-20, title="WPR OverSold",group="Edit Table Heading/Stat Threshold")
WpercentRMin = input.int(defval=-80, title="WPR OverBought",group="Edit Table Heading/Stat Threshold")
tooltiwpr = "Green=Good time to Buy/Orange=Neutral/RED=Good time to Sell"
//Get end users input on wanted CCI levels
Add_Row_Name_cci = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_cci=input(defval="CCI", title="Table Heading", group="Edit Table Heading/Stat Threshold")
CCIOverbought = input.int(defval=100, title="CCI OverBought",group="Edit Table Heading/Stat Threshold")
CCIOversold = input.int(defval=-100, title="CCI OverSold",group="Edit Table Heading/Stat Threshold")
tooltipcci = "Green=Good time to Buy/Orange=Neutral/RED=Good time to Sell"
//Get end users input on wanted AO levels
Add_Row_Name_ao = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_ao=input(defval="AO", title="Table Heading", group="Edit Table Heading/Stat Threshold")
AOAbove0 = input.int(defval=0, title="AO Above",group="Edit Table Heading/Stat Threshold")
AObelow0 = input.int(defval=-0, title="AO Below",group="Edit Table Heading/Stat Threshold")
tooltipao = "Green=High Movement/Orange=Neutral/Red=Low Movement"
//Get end users input on wanted MACD Line 1 levels
Add_Row_Name_macdline1 = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_macdline1=input(defval="MACD (Line 1)", title="Table Heading", group="Edit Table Heading/Stat Threshold")
MACDLine1Above0 = input.int(defval=0, title="MACD Line 1 Above",group="Edit Table Heading/Stat Threshold")
MACDLine1below0 = input.int(defval=-0, title="MACD Line 1 Below",group="Edit Table Heading/Stat Threshold")
tooltipmacdline1 = "Green=Buying Strength/Red=Selling Strength"
//Get end users input on wanted MACD Line 2 levels
Add_Row_Name_macdline2 = input.bool(false,"Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_macdline2=input(defval="MACD (Line 2)", title="Table Heading", group="Edit Table Heading/Stat Threshold")
MACDLine2Above0 = input.int(defval=0, title="MACD Line 2 Above",group="Edit Table Heading/Stat Threshold")
MACDLine2below0 = input.int(defval=-0, title="MACD Line 2 Below",group="Edit Table Heading/Stat Threshold")
tooltipmacdline2 = "Green=Buying Strength/Red=Selling Strength"
//Get end users input on wanted MACD Histogram levels
Add_Row_Name_macdhist = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_macdhist=input(defval="MACD (Hist)", title="Table Heading", group="Edit Table Heading/Stat Threshold")
MACDLineHistAbove0 = input.int(defval=0, title="MACD Line 2 Above",group="Edit Table Heading/Stat Threshold")
MACDLineHistbelow0 = input.int(defval=-0, title="MACD Line 2 Below",group="Edit Table Heading/Stat Threshold")
tooltipmacdhist = "Green=Buying Strength/Red=Selling Strength"
//Get end users input on wanted Aroon levels
Add_Row_Name_aroon = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_aroon=input(defval="Aroon", title="Table Heading", group="Edit Table Heading/Stat Threshold")
AroonHigh = input.int(defval=50, title="Aroon Above",group="Edit Table Heading/Stat Threshold")
AroonLow = input.int(defval=-50, title="Aroon Below",group="Edit Table Heading/Stat Threshold")
tooltiparoon = "Green=High Movement/Orange=Neutral/Red=Low Movement"
//Get end users input on wanted ADX levels
Add_Row_Name_adx = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_adx=input(defval="ADX", title="Table Heading", group="Edit Table Heading/Stat Threshold")
ADXHigh = input.int(defval=25, title="ADX Above",group="Edit Table Heading/Stat Threshold")
ADXLow = input.int(defval=-20, title="ADX Below",group="Edit Table Heading/Stat Threshold")
tooltipadx = "Green=High Movement/Orange=Neutral/Red=Low Movement"
//Get end users input on wanted DeMarker levels
Add_Row_Name_DeM = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_DeM = input(defval="DeM", title="Table Heading", group="Edit Table Heading/Stat Threshold")
DeMOverbought = input.float(defval=0.7, title="DeM Overbought",group="Edit Table Heading/Stat Threshold")
DeMOversold = input.float(defval=0.3, title="DeM Oversold",group="Edit Table Heading/Stat Threshold")
tooltipdem = "Green=Good time to Buy/Orange=Neutral/RED=Good time to Sell"
//Get end users input on wanted CMO levels
Add_Row_Name_cmo = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_cmo = input(defval="Chande", title="Table Heading", group="Edit Table Heading/Stat Threshold")
cmoOverbought = input.int(defval=50, title="CMO Overbought",group="Edit Table Heading/Stat Threshold")
cmoOversold = input.int(defval=-50, title="CMO Oversold",group="Edit Table Heading/Stat Threshold")
tooltipcmo = "Green=Good time to Buy/Orange=Neutral/RED=Good time to Sell"
//Get end users input on wanted ROC levels
Add_Row_Name_roc = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_roc = input(defval="ROC", title="Table Heading", group="Edit Table Heading/Stat Threshold")
rocOverbought = input.int(defval=0, title="ROC Overbought",group="Edit Table Heading/Stat Threshold")
rocOversold = input.int(defval=-0, title="ROC Oversold",group="Edit Table Heading/Stat Threshold")
tooltiproc = "Green=Good Momentum/Orange=Netural/Red=Low Momentem"
//Get end users input on wanted DMI Plus levels
Add_Row_Name_dmiplus = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_dmiplus = input(defval="DMI+", title="Table Heading", group="Edit Table Heading/Stat Threshold")
tooltipdmiplus = "Green=Good Momentum/Orange=Netural/Red=Low Momentem"
//Get end users input on wanted DMI Negative levels
Add_Row_Name_dminegative = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_dminegative = input(defval="DMI-", title="Table Heading", group="Edit Table Heading/Stat Threshold")
tooltipdminegative = "Red=High Sell Momentum/Orange=Netural/Green=Low Sell Momentum"
//Get end users input on wanted DMI Plus levels
Add_Row_Name_vortexplus = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_vortexplus= input(defval="VI+", title="Table Heading", group="Edit Table Heading/Stat Threshold")
tooltipvortexplus = "Green=Good Momentum/Orange=Netural/Red=Low Momentem"
//Get end users input on wanted DMI Negative levels
Add_Row_Name_vortexnegative = input.bool(false,"---Add Below Associated Table Line",group="Edit Table Heading/Stat Threshold")
Cell_Name_vortexnegative = input(defval="VI-", title="Table Heading", group="Edit Table Heading/Stat Threshold")
tooltipvortexnegative = "Red=High Sell Momentum/Orange=Netural/Green=Low Sell Momentum"
//Get chart data
getchartRealTimeLastOpenprice = request.security(setCurrenciyPair,setChartPeriod,open)
getchartRealTimeLastCloseprice = request.security(setCurrenciyPair,setChartPeriod,close)
getchartRealTimePriceChange = request.security(setCurrenciyPair,setChartPeriod,(ta.change(close)/close[1])*100)
getchartRealTimeVolume = request.security(setCurrenciyPair,setChartPeriod,volume)
getchartRealTimeRSIValue = request.security(setCurrenciyPair,setChartPeriod,truncate(ta.rsi(close,14),2))
getchartRealTimeATRValue = request.security(setCurrenciyPair,setChartPeriod,truncate(ta.atr(14),2))
getchartRealTimeStochValueLine1 = request.security(setCurrenciyPair,setChartPeriod, truncate(ta.stoch(close, high, low, 14),2))
getchartRealTimeStochValueLine2 = truncate(ta.sma(getchartRealTimeStochValueLine1, 3),2)
getchartRealTimeWPRValue = request.security(setCurrenciyPair,setChartPeriod,truncate(ta.wpr(14),2))
getchartRealTimeCCIValue = request.security(setCurrenciyPair,setChartPeriod, truncate(ta.sma(hlc3,20),2))
getchartRealTimeAOValue = request.security(setCurrenciyPair,setChartPeriod, truncate(ta.sma(hl2,5)-ta.sma(hl2,34),2))
getchartRealTimeMACDLine1Value = request.security(setCurrenciyPair,setChartPeriod, truncate(ta.ema(close, 12)-ta.ema(close, 26),2))
getchartRealTimeMACDLine2Value = request.security(setCurrenciyPair,setChartPeriod, truncate(ta.ema(close, 12)-ta.ema(close, 26),2))
getchartRealTimeMACDLine2ValueCalculate = ta.ema(getchartRealTimeMACDLine2Value,9)
getchartRealTimeMACDHistValueCalculate = macd - signal
getchartRealTimeAroonValue = truncate((100 * (ta.highestbars(high, 25+1) + 25)/25)-(100 * (ta.lowestbars(low, 25+1) + 25)/25),2)
getchartRealTimeADXValue = truncate(adx(14, 14),2)
getchartRealTimeDeMValue = truncate(demax_av / (demax_av + demin_av),2)
getchartRealTimeCMOValue = truncate(percent(sm1-sm2, sm1+sm2),2)
getchartRealTimeROCValue = truncate(100 * (close - close[9])/close[9],2)
getchartRealTimeDMIPlusValue = truncate(fixnan(100 * ta.rma(plusDM, len) / trur),2)
getchartRealTimeDMINegativeValue = truncate(fixnan(100 * ta.rma(minusDM, len) / trur),2)
getchartRealTimeVIPlusValue = truncate(VIP,2)
getchartRealTimeVINegativeValue = truncate(VIM,2)
//Convert chart data to string
tostringRealTimeLastOpenprice = str.tostring(getchartRealTimeLastOpenprice)
tostringRealTimeLastCloseprice = str.tostring(getchartRealTimeLastCloseprice)
tostringRealTimePriceChange = str.tostring(getchartRealTimePriceChange) +" %"
tostringRealTimeVolume=str.tostring(getchartRealTimeVolume)
tostringRealTimeRSIValue = str.tostring(math.round_to_mintick(getchartRealTimeRSIValue))
tostringRealTimeATRValue=str.tostring(math.round_to_mintick(getchartRealTimeATRValue))
tostringRealTimeStochValueLine1 = str.tostring(math.round_to_mintick(getchartRealTimeStochValueLine1))
tostringRealTimeStochValueLine2 = str.tostring(math.round_to_mintick(getchartRealTimeStochValueLine2))
tostringRealTimeWPRValue=str.tostring(math.round_to_mintick(getchartRealTimeWPRValue))
tostringRealTimeCCIValue = str.tostring(math.round_to_mintick((hlc3-getchartRealTimeCCIValue) / (0.015 * ta.dev(hlc3,20))))
tostringRealTimeAOValue = str.tostring(math.round_to_mintick(getchartRealTimeAOValue))
tostringtRealTimeMACDLine1Value = str.tostring(math.round_to_mintick(getchartRealTimeMACDLine1Value))
tostringtRealTimeMACDLine2Value = str.tostring(math.round_to_mintick(getchartRealTimeMACDLine2ValueCalculate))
tostringRealTimeMACDHistValue = str.tostring(math.round_to_mintick(getchartRealTimeMACDHistValueCalculate))
tostringtRealTimeAroonValue = str.tostring(math.round_to_mintick(getchartRealTimeAroonValue))
tostringtRealTimeADXValue = str.tostring(math.round_to_mintick(getchartRealTimeADXValue))
tostringtRealTimeDeMValue = str.tostring((getchartRealTimeDeMValue))
tostringtRealTimeCMOValue = str.tostring(math.round_to_mintick(getchartRealTimeCMOValue))
tostringtRealTimeROCValue = str.tostring(math.round_to_mintick(getchartRealTimeROCValue))
tostringtRealTimeDMIPlusValue = str.tostring(math.round_to_mintick(getchartRealTimeDMIPlusValue))
tostringtRealTimeDMINegativeValue = str.tostring(math.round_to_mintick(getchartRealTimeDMINegativeValue))
tostringtRealTimeVIPlusValue = str.tostring(math.round_to_mintick(getchartRealTimeVIPlusValue))
tostringtRealTimeVINegativeValue = str.tostring(math.round_to_mintick(getchartRealTimeVINegativeValue))
//Reset in use global variables (else script crashes) - table portrait
colum_Portrait := 0
row_Portrait := 1
colum2_Portrait := 1
row2_Portrait := 1
//Reset in use global variables (else script crashes) - table landscape
colum_Landscape := 0
row_Landscape := 0
colum2_Landscape := 0
row2_Landscape := 1
//Script process's only if setting is enabled
if barstate.islast and showInfoTable==true
if tableScale == option1
//Display Table-Portrait
if Add_Row_Name_meregcellheading1 == true
createTable(heading,noneText,meregcellheading1,noneNumber,noneNumber,noneNumber,noneText,noneText)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_lastopenprice == true
createTable(row,noneText, Cell_Name_lastopenprice, noneNumber, noneNumber, noneNumber, tostringRealTimeLastOpenprice, noneText)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_lastcloseprice == true
createTable(row,noneText, Cell_Name_lastcloseprice, noneNumber, noneNumber, noneNumber, tostringRealTimeLastCloseprice, noneText)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_change == true
createTable(row,noneText, Cell_Name_change, getchartRealTimePriceChange, noneNumber, noneNumber, tostringRealTimePriceChange, noneText)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_volume == true
createTable(row,noneText, Cell_Name_volume, noneNumber, noneNumber, noneNumber, tostringRealTimeVolume, noneText)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_meregcellheading2 == true
createTable(heading,noneText,meregcellheading2, noneNumber, noneNumber, noneNumber, noneText, noneText)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_rsi == true
createTable(row,BUYNSELL, Cell_Name_rsi, getchartRealTimeRSIValue, RSIOverbought, RSIOversold, tostringRealTimeRSIValue, tooltiprsi)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_atr == true
createTable(row,color_order_change, Cell_Name_atr, getchartRealTimeATRValue, ATRHigh, ATRLow, tostringRealTimeATRValue, tooltipatr)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_stochline1 == true
createTable(row,BUYNSELL, Cell_Name_stochline1, getchartRealTimeStochValueLine1, StochOverbought, StochOversold, tostringRealTimeStochValueLine1, tooltipstochline1)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_stochline2 == true
createTable(row,BUYNSELL, Cell_Name_stochline2, getchartRealTimeStochValueLine2, StochHigh, StochLow, tostringRealTimeStochValueLine2, tooltipstochline2)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_wpr == true
createTable(row,BUYNSELL, Cell_Name_wpr, getchartRealTimeWPRValue, WpercentRMax, WpercentRMin, tostringRealTimeWPRValue, tooltiwpr)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_cci == true
createTable(row,color_order_change, Cell_Name_cci, getchartRealTimeCCIValue, CCIOverbought, CCIOversold, tostringRealTimeCCIValue, tooltipcci)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_ao == true
createTable(row,MULTI, Cell_Name_ao, getchartRealTimeAOValue, AOAbove0, AObelow0, tostringRealTimeAOValue, tooltipao)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_macdline1 == true
createTable(row,MULTI, Cell_Name_macdline1, getchartRealTimeMACDLine1Value, MACDLine1Above0, MACDLine1below0, tostringtRealTimeMACDLine1Value, tooltipmacdline1)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_macdline2 == true
createTable(row,MULTI, Cell_Name_macdline2, getchartRealTimeMACDLine2ValueCalculate, MACDLine2Above0, MACDLine2below0, tostringtRealTimeMACDLine2Value, tooltipmacdline2)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_macdhist == true
createTable(row,MULTI, Cell_Name_macdhist, getchartRealTimeMACDHistValueCalculate, MACDLineHistAbove0, MACDLineHistbelow0, tostringRealTimeMACDHistValue, tooltipmacdhist)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_aroon == true
createTable(row,MULTI, Cell_Name_aroon, getchartRealTimeAroonValue, AroonHigh, AroonLow, tostringtRealTimeAroonValue, tooltiparoon)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_adx == true
createTable(row,MULTI, Cell_Name_adx, getchartRealTimeADXValue, ADXHigh, ADXLow, tostringtRealTimeADXValue, tooltipadx)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_DeM == true
createTable(row,BUYNSELL, Cell_Name_DeM, getchartRealTimeDeMValue, DeMOverbought, DeMOversold, tostringtRealTimeDeMValue, tooltipdem)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_cmo == true
createTable(row,BUYNSELL, Cell_Name_cmo, getchartRealTimeCMOValue, cmoOverbought, cmoOversold, tostringtRealTimeCMOValue, tooltipcmo)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_roc == true
createTable(row,MULTI, Cell_Name_roc, getchartRealTimeROCValue, rocOverbought, rocOversold, tostringtRealTimeROCValue, tooltiproc)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_dmiplus == true
createTable(row,MULTI, Cell_Name_dmiplus, getchartRealTimeDMIPlusValue, getchartRealTimeDMINegativeValue, getchartRealTimeDMINegativeValue, tostringtRealTimeDMIPlusValue, tooltipdmiplus)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_dminegative == true
createTable(row,MULTI, Cell_Name_dminegative, getchartRealTimeDMINegativeValue, getchartRealTimeDMIPlusValue, getchartRealTimeDMIPlusValue, tostringtRealTimeDMINegativeValue, tooltipdminegative)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_vortexplus == true
createTable(row,MULTI, Cell_Name_vortexplus, getchartRealTimeVIPlusValue, getchartRealTimeVINegativeValue, getchartRealTimeVINegativeValue, tostringtRealTimeVIPlusValue, tooltipvortexplus)
row_Portrait += 1
row2_Portrait += 1
if Add_Row_Name_vortexnegative == true
createTable(row,MULTI, Cell_Name_vortexnegative, getchartRealTimeVINegativeValue, getchartRealTimeVIPlusValue, getchartRealTimeVIPlusValue, tostringtRealTimeVINegativeValue, tooltipvortexnegative)
row_Portrait += 1
row2_Portrait += 1
if tableScale == option2
//Display Table-Landscape
if Add_Row_Name_meregcellheading1 == true
createTable(heading,noneText,meregcellheading1,noneNumber,noneNumber,noneNumber,noneText,noneText)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_lastopenprice == true
createTable(row,noneText, Cell_Name_lastopenprice, noneNumber, noneNumber, noneNumber, tostringRealTimeLastOpenprice, noneText)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_lastcloseprice == true
createTable(row,noneText, Cell_Name_lastcloseprice, noneNumber, noneNumber, noneNumber, tostringRealTimeLastCloseprice, noneText)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_change == true
createTable(row,noneText, Cell_Name_change, getchartRealTimePriceChange, noneNumber, noneNumber, tostringRealTimePriceChange, noneText)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_volume == true
createTable(row,noneText, Cell_Name_volume, noneNumber, noneNumber, noneNumber, tostringRealTimeVolume, noneText)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_meregcellheading2 == true
createTable(heading,noneText,meregcellheading2, noneNumber, noneNumber, noneNumber, noneText, noneText)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_rsi == true
createTable(row,BUYNSELL, Cell_Name_rsi, getchartRealTimeRSIValue, RSIOverbought, RSIOversold, tostringRealTimeRSIValue, tooltiprsi)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_atr == true
createTable(row,color_order_change, Cell_Name_atr, getchartRealTimeATRValue, ATRHigh, ATRLow, tostringRealTimeATRValue, tooltipatr)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_stochline1 == true
createTable(row,BUYNSELL, Cell_Name_stochline1, getchartRealTimeStochValueLine1, StochOverbought, StochOversold, tostringRealTimeStochValueLine1, tooltipstochline1)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_stochline2 == true
createTable(row,BUYNSELL, Cell_Name_stochline2, getchartRealTimeStochValueLine2, StochHigh, StochLow, tostringRealTimeStochValueLine2, tooltipstochline2)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_wpr == true
createTable(row,BUYNSELL, Cell_Name_wpr, getchartRealTimeWPRValue, WpercentRMax, WpercentRMin, tostringRealTimeWPRValue, tooltiwpr)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_cci == true
createTable(row,color_order_change, Cell_Name_cci, getchartRealTimeCCIValue, CCIOverbought, CCIOversold, tostringRealTimeCCIValue, tooltipcci)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_ao == true
createTable(row,MULTI, Cell_Name_ao, getchartRealTimeAOValue, AOAbove0, AObelow0, tostringRealTimeAOValue, tooltipao)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_macdline1 == true
createTable(row,MULTI, Cell_Name_macdline1, getchartRealTimeMACDLine1Value, MACDLine1Above0, MACDLine1below0, tostringtRealTimeMACDLine1Value, tooltipmacdline1)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_macdline2 == true
createTable(row,MULTI, Cell_Name_macdline2, getchartRealTimeMACDLine2ValueCalculate, MACDLine2Above0, MACDLine2below0, tostringtRealTimeMACDLine2Value, tooltipmacdline2)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_macdhist == true
createTable(row,MULTI, Cell_Name_macdhist, getchartRealTimeMACDHistValueCalculate, MACDLineHistAbove0, MACDLineHistbelow0, tostringRealTimeMACDHistValue, tooltipmacdhist)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_aroon == true
createTable(row,MULTI, Cell_Name_aroon, getchartRealTimeAroonValue, AroonHigh, AroonLow, tostringtRealTimeAroonValue, tooltiparoon)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_adx == true
createTable(row,MULTI, Cell_Name_adx, getchartRealTimeADXValue, ADXHigh, ADXLow, tostringtRealTimeADXValue, tooltipadx)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_DeM == true
createTable(row,BUYNSELL, Cell_Name_DeM, getchartRealTimeDeMValue, DeMOverbought, DeMOversold, tostringtRealTimeDeMValue, tooltipdem)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_cmo == true
createTable(row,BUYNSELL, Cell_Name_cmo, getchartRealTimeCMOValue, cmoOverbought, cmoOversold, tostringtRealTimeCMOValue, tooltipcmo)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_roc == true
createTable(row,MULTI, Cell_Name_roc, getchartRealTimeROCValue, rocOverbought, rocOversold, tostringtRealTimeROCValue, tooltiproc)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_dmiplus == true
createTable(row,MULTI, Cell_Name_dmiplus, getchartRealTimeDMIPlusValue, getchartRealTimeDMINegativeValue, getchartRealTimeDMINegativeValue, tostringtRealTimeDMIPlusValue, tooltipdmiplus)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_dminegative == true
createTable(row,MULTI, Cell_Name_dminegative, getchartRealTimeDMINegativeValue, getchartRealTimeDMIPlusValue, getchartRealTimeDMIPlusValue, tostringtRealTimeDMINegativeValue, tooltipdminegative)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_vortexplus == true
createTable(row,MULTI, Cell_Name_vortexplus, getchartRealTimeVIPlusValue, getchartRealTimeVINegativeValue, getchartRealTimeVINegativeValue, tostringtRealTimeVIPlusValue, tooltipvortexplus)
colum_Landscape += 1
colum2_Landscape += 1
if Add_Row_Name_vortexnegative == true
createTable(row,MULTI, Cell_Name_vortexnegative, getchartRealTimeVINegativeValue, getchartRealTimeVIPlusValue, getchartRealTimeVIPlusValue, tostringtRealTimeVINegativeValue, tooltipvortexnegative)
colum_Landscape += 1
colum2_Landscape += 1 |
LabTrend SSL [Loxx] | https://www.tradingview.com/script/cqfKrvTz-LabTrend-SSL-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 133 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("LabTrend SSL [Loxx]",
shorttitle='LTSSL [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
_iT3(src, per, hot, org)=>
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 (org)
alpha := 2.0 / (1.0 + per)
else
alpha := 2.0 / (2.0 + (per - 1.0) / 2.0)
_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
per = input.int(14, "Hilo Period", group = "Basic Settings")
Risk = input.int(3, "Risk", group = "Basic Settings")
atrper = input.int(10, "ATR Period", group = "Basic Settings")
sslper = input.int(10, "SSL Period", group = "SSL Settings")
t3hot = input.float(0.7, "T3 Factor", step = 0.01, maxval = 1, minval = 0, group = "SSL Settings")
t3swt = input.bool(false, "T3 Original?", group = "SSL Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = input.bool(true, "Show signals?", group = "UI Options")
smin = 0., smax = 0.
smin := ta.lowest(low, per)
smax := ta.highest(high, per)
bsmax = smax - (smax - smin) * (33.0 - Risk) / 100.0
bsmin = smin + (smax - smin) * (33.0 - Risk) / 100.0
trend = 0., trens = 0.
trens := nz(trens[1])
varHigh =_iT3(high, sslper, t3hot, t3swt)
varLow = _iT3(low, sslper, t3hot, t3swt)
if (close > bsmax)
trend := 1
trens := 1
if (close < bsmin)
trend := -1
trens := -1
barUp = 0., barDn = 0., arrUp = 0., arrDn = 0.
if (trend == 1)
barUp := varHigh
barDn := varLow
if (trend == -1)
barUp := varLow
barDn := varHigh
atr = ta.atr(atrper)
if (trens != nz(trens[1]))
if (trens == 1)
arrUp := 1
if (trens == -1)
arrDn := 1
plotshape(showsignals ? arrUp : na, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(showsignals ? arrDn : na, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
colorout = trend == 1 ? greencolor : trend == -1 ? redcolor: color.white
plot(barUp ? barUp : na, color = greencolor, linewidth = 3)
plot(barDn ? barDn : na, color = redcolor, linewidth = 3)
barcolor(colorbars ? colorout : na)
alertcondition(arrUp, title="Long", message="LabTrend SSL [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(arrDn, title="Short", message="LabTrend SSL [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
PA-Adaptive, Stepped-MA of Composite RSI [Loxx] | https://www.tradingview.com/script/hpgMj9fT-PA-Adaptive-Stepped-MA-of-Composite-RSI-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 46 | 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("PA-Adaptive, Stepped-MA of Composite RSI [Loxx]",
shorttitle='PAASMACRSI [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxpaaspecial/1
SM02 = 'Middle Cross'
SM03 = 'Trend'
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
_cRSI(src, period, depth, fast)=>
alpha = 0.
if (not fast)
alpha := 2.0/(1.0 + period)
else
alpha := 2.0/(2.0 + (period-1.0)/2.0)
CU = 0.
CD = 0., rsi = src
price = src
for k = 0 to depth
rsi := nz(rsi[1]) + alpha * (src - nz(rsi[1]))
price := rsi
if (nz(rsi[k+1]) >= nz(rsi[k]))
CD += nz(rsi[k+1]) - nz(rsi[k])
else
CU += nz(rsi[k]) - nz(rsi[k+1])
trsi = 0.
if (CU + CD != 0)
trsi := CU / (CU + CD)
trsi
_stepma(_sense, _size, stepMulti, phigh, plow, pprice)=>
sensitivity = _sense, stepSize = _size, _trend = 0.
if (_sense == 0)
sensitivity := 0.0001
if (_size == 0)
stepSize := 0.0001
out = 0.
size = sensitivity * stepSize
_smax = phigh + 2.0 * size * stepMulti
_smin = plow - 2.0 * size * stepMulti
_trend := nz(_trend[1])
if (pprice > nz(_smax[1]))
_trend := 1
if (pprice < nz(_smin[1]))
_trend := -1
if (_trend == 1)
if (_smin < nz(_smin[1]))
_smin := nz(_smin[1])
out := _smin + size * stepMulti
if (_trend == -1)
if (_smax > nz(_smax[1]))
_smax := nz(_smax[1])
out := _smax - size * stepMulti
[out, _trend]
smthtype = input.string("Kaufman", "Fast Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcin = input.string("Close", "Fast 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)"])
fregcycles = input.float(1.5, title = "PA Cycles", group= "Phase Accumulation Cycle Settings")
fregfilter = input.float(1.0, title = "PA Filter", group= "Phase Accumulation Cycle Settings")
rsidepth = input.int(2, "RSI Depth", group = "Basic Settings")
sense = input.float(4, "Sensitivity", group = "Basic Settings")
stsize = input.float(5, "Step Size", group = "Basic Settings")
stepmult = input.float(0.5, "Step Multiplier", group = "Basic Settings")
quick = input.bool(true, "Rapid Composite RSI?")
signalMode = input.string(SM03, 'Signal Type', options=[SM03, SM02], group = "Signal Settings")
showsignals = input.bool(true, "Show signals?", group = "UI Options")
colorbars = input.bool(true, "Color bars?", 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
int flen = math.floor(loxxpaaspecial.paa(src, fregcycles, fregfilter))
flen := flen < 1 ? 1 : flen
rsi = math.abs(_cRSI(src, flen, rsidepth, quick) * 100)
[val, trend] = _stepma(sense, stsize, stepmult, rsi, rsi, rsi)
mid = 50.
colorout = signalMode == SM02 ? (val > mid ? greencolor : redcolor) : (trend == 1 ? greencolor : trend == -1 ? redcolor : color.gray)
plot(val, color = colorout, linewidth = 2)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = signalMode == SM02 ? ta.crossover(val, mid) : trend == 1 and trend[1] == -1
goShort = signalMode == SM02 ? ta.crossunder(val, mid) : trend == -1 and trend[1] == 1
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="PA-Adaptive, Stepped-MA of Composite RSI [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="PA-Adaptive, Stepped-MA of Composite RSI [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
//forcing UI to leave space for signal prints
hline(-10, color = color.new(color.black, 100))
hline(110, color = color.new(color.black, 100))
|
Double CCI | https://www.tradingview.com/script/r6GFJtBZ-Double-CCI/ | josappe | https://www.tradingview.com/u/josappe/ | 47 | 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/
// © josappe
//@version=5
indicator(title='Double CCI', shorttitle='Double CCI', format=format.price, precision=0, timeframe='')
src = input(close, title='Source')
length_1 = input.int(10, title='Fast', minval=1)
length_2 = input.int(20, title='Slow', minval=2)
Null = input(true, title='Show Zero Line')
ma_1 = ta.sma(src, length_1)
ma_2 = ta.sma(src, length_2)
color cbuy = color.rgb(0, 255, 0, 60)
color csell = color.rgb(255, 0, 0, 60)
cci_1 = (src - ma_1) / (0.015 * ta.dev(src, length_1))
cci_2 = (src - ma_2) / (0.015 * ta.dev(src, length_2))
plot(cci_1, 'CCI Fast', color=color.rgb(255, 255, 0, 0), linewidth=1)
plot(cci_2, 'CCI Slow', color=color.rgb(255, 255, 255, 0), linewidth=2)
band0 = hline(Null ? 0 : na, color=color.rgb(200, 200, 200, 0), linestyle=hline.style_solid, linewidth=1, editable=0)
band1 = hline(100, 'Upper Band', color=cbuy, linestyle=hline.style_solid, editable=0)
band2 = hline(250, 'Top Band', color=cbuy, linestyle=hline.style_solid, editable=0)
band3 = hline(-100, 'Lower Band', color=csell, linestyle=hline.style_solid, editable=0)
band4 = hline(-250, 'Bottom Band', color=csell, linestyle=hline.style_solid, editable=0)
fill(band2, band1, color=cbuy, title='Background Buyers', editable=0, transp=90)
fill(band4, band3, color=csell, title='Background Sellers', editable=0, transp=90)
|
Currency Strength Index by zdmre | https://www.tradingview.com/script/K8gTuKfd-Currency-Strength-Index-by-zdmre/ | zdmre | https://www.tradingview.com/u/zdmre/ | 108 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zdmre
//@version=5
indicator("Currency Strength Index by zdmre")
// INPUTs
sym8 = input.symbol("FX_IDC:TRYUSD",title = "Your Symbol", tooltip='must be xxxUSD')
ShowEUR = input(true,"EUR")
ShowGBP = input(true,"GBP")
ShowAUD = input(true,"AUD")
ShowNZD = input(true,"NZD")
ShowJPY = input(true,"JPY")
ShowCNY = input(true,"CNY")
ShowCAD = input(true,"CAD")
ShowYOURs = input(true,"Your Symbol")
opt_textsize = input.string(size.small, 'Text Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge])
// CALC
rma = ta.rma(close, 200)
rq_sym1 = 1 / request.security("FX_IDC:USDEUR", "240", close , barmerge.gaps_off, barmerge.lookahead_off)
sym1_rma = 1 / request.security("FX_IDC:USDEUR", "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym2 = 1 / request.security("FX_IDC:USDGBP", "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym2_rma = 1 / request.security("FX_IDC:USDGBP", "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym3 = 1 / request.security("FX_IDC:USDAUD", "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym3_rma = 1 / request.security("FX_IDC:USDAUD", "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym4 = 1 / request.security("FX_IDC:USDNZD", "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym4_rma = 1 / request.security("FX_IDC:USDNZD", "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym5 = 1 / request.security("FOREXCOM:USDJPY", "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym5_rma = 1 / request.security("FOREXCOM:USDJPY", "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym6 = 1 / request.security("FX_IDC:USDCNY", "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym6_rma = 1 / request.security("FX_IDC:USDCNY", "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym7 = 1 / request.security("FOREXCOM:USDCAD", "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym7_rma = 1 / request.security("FOREXCOM:USDCAD", "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym8 = request.security(sym8, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym8_rma = request.security(sym8, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
str_sym1 = (rq_sym1 - sym1_rma)/rq_sym1 * 100
str_sym2 = (rq_sym2 - sym2_rma)/rq_sym2 * 100
str_sym3 = (rq_sym3 - sym3_rma)/rq_sym3 * 100
str_sym4 = (rq_sym4 - sym4_rma)/rq_sym4 * 100
str_sym5 = (rq_sym5 - sym5_rma)/rq_sym5 * 100
str_sym6 = (rq_sym6 - sym6_rma)/rq_sym6 * 100
str_sym7 = (rq_sym7 - sym7_rma)/rq_sym7 * 100
str_sym8 = (rq_sym8 - sym8_rma)/rq_sym8 * 100
// LABELs
ShowLabels = input(true, "Show Labels")
if (ShowLabels)
style = label.style_label_left
size = opt_textsize
if (ShowEUR)
label EUR_lbl = label.new(bar_index+1, str_sym1, "EUR", color=color.yellow, style=style, textcolor=color.black, size=size), label.delete(EUR_lbl[1])
if (ShowGBP)
label GBP_lbl = label.new(bar_index+1, str_sym2, "GBP", color=color.green, style=style, textcolor=color.black, size=size), label.delete(GBP_lbl[1])
if (ShowAUD)
label AUD_lbl = label.new(bar_index+1, str_sym3, "AUD", color=color.purple, style=style, textcolor=color.black, size=size), label.delete(AUD_lbl [1])
if (ShowNZD)
label NZD_lbl = label.new(bar_index+1, str_sym4, "NZD", color=color.blue, style=style, textcolor=color.white, size=size), label.delete(NZD_lbl[1])
if (ShowJPY)
label JPY_lbl = label.new(bar_index+1, str_sym5, "JPY", color=color.red, style=style, textcolor=color.black, size=size), label.delete(JPY_lbl[1])
if (ShowCNY)
label CNY_lbl = label.new(bar_index+1, str_sym6, "CNY", color=color.orange, style=style, textcolor=color.black, size=size), label.delete(CNY_lbl[1])
if (ShowCAD)
label CAD_lbl = label.new(bar_index+1, str_sym7, "CAD", color=color.teal,style=style, textcolor=color.black, size=size), label.delete(CAD_lbl[1])
if (ShowYOURs)
label YOURs_lbl = label.new(bar_index+1, str_sym8, syminfo.ticker(sym8), color=color.aqua, style=style, textcolor=color.black, size=size), label.delete(YOURs_lbl[1])
// TABLE
var tbis = table.new(position.middle_right, 3, 9, frame_color=color.black, frame_width=0, border_width=1, border_color=color.black)
table.cell(tbis, 0, 0, 'Currency', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 1, 0, 'Index', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 2, 0, 'Day', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 0, 1, 'EUR', bgcolor = color.yellow, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 0, 2, 'GBP', bgcolor = color.green, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 0, 3, 'AUD', bgcolor = color.purple, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 0, 4, 'NZD', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 0, 5, 'JPY', bgcolor = color.red, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 0, 6, 'CNY', bgcolor = color.orange, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 0, 7, 'CAD', bgcolor = color.teal, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 0, 8, syminfo.ticker(sym8), bgcolor = color.aqua, text_size=opt_textsize, text_color=color.black)
table.cell(tbis, 1, 1, str.tostring(str_sym1[0], '#,##0.00'), text_color=str_sym1[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym1[0] < 0 ? color.red : str_sym1[0] > 0 ? color.lime : color.black)
table.cell(tbis, 1, 2, str.tostring(str_sym2[0], '#,##0.00'), text_color=str_sym2[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym2[0] < 0 ? color.red : str_sym2[0] > 0 ? color.lime : color.black)
table.cell(tbis, 1, 3, str.tostring(str_sym3[0], '#,##0.00'), text_color=str_sym3[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym3[0] < 0 ? color.red : str_sym3[0] > 0 ? color.lime : color.black)
table.cell(tbis, 1, 4, str.tostring(str_sym4[0], '#,##0.00'), text_color=str_sym4[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym4[0] < 0 ? color.red : str_sym4[0] > 0 ? color.lime : color.black)
table.cell(tbis, 1, 5, str.tostring(str_sym5[0], '#,##0.00'), text_color=str_sym5[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym5[0] < 0 ? color.red : str_sym5[0] > 0 ? color.lime : color.black)
table.cell(tbis, 1, 6, str.tostring(str_sym6[0], '#,##0.00'), text_color=str_sym6[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym6[0] < 0 ? color.red : str_sym6[0] > 0 ? color.lime : color.black)
table.cell(tbis, 1, 7, str.tostring(str_sym7[0], '#,##0.00'), text_color=str_sym7[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym7[0] < 0 ? color.red : str_sym7[0] > 0 ? color.lime : color.black)
table.cell(tbis, 1, 8, str.tostring(str_sym8[0], '#,##0.00'), text_color=str_sym8[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym8[0] < 0 ? color.red : str_sym8[0] > 0 ? color.lime : color.black)
table.cell(tbis, 2, 1, str.tostring((str_sym1[0]-str_sym1[1]), '#,##0.00'), text_color=(str_sym1[0]-str_sym1[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym1[0]-str_sym1[1]) < 0 ? color.red : (str_sym1[0]-str_sym1[1]) > 0 ? color.lime : color.black)
table.cell(tbis, 2, 2, str.tostring((str_sym2[0]-str_sym2[1]), '#,##0.00'), text_color=(str_sym2[0]-str_sym2[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym2[0]-str_sym2[1]) < 0 ? color.red : (str_sym2[0]-str_sym2[1]) > 0 ? color.lime : color.black)
table.cell(tbis, 2, 3, str.tostring((str_sym3[0]-str_sym3[1]), '#,##0.00'), text_color=(str_sym3[0]-str_sym3[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym3[0]-str_sym3[1]) < 0 ? color.red : (str_sym3[0]-str_sym3[1]) > 0 ? color.lime : color.black)
table.cell(tbis, 2, 4, str.tostring((str_sym4[0]-str_sym4[1]), '#,##0.00'), text_color=(str_sym4[0]-str_sym4[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym4[0]-str_sym4[1]) < 0 ? color.red : (str_sym4[0]-str_sym4[1]) > 0 ? color.lime : color.black)
table.cell(tbis, 2, 5, str.tostring((str_sym5[0]-str_sym5[1]), '#,##0.00'), text_color=(str_sym5[0]-str_sym5[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym5[0]-str_sym5[1]) < 0 ? color.red : (str_sym5[0]-str_sym5[1]) > 0 ? color.lime : color.black)
table.cell(tbis, 2, 6, str.tostring((str_sym6[0]-str_sym6[1]), '#,##0.00'), text_color=(str_sym6[0]-str_sym6[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym6[0]-str_sym6[1]) < 0 ? color.red : (str_sym6[0]-str_sym6[1]) > 0 ? color.lime : color.black)
table.cell(tbis, 2, 7, str.tostring((str_sym7[0]-str_sym7[1]), '#,##0.00'), text_color=(str_sym7[0]-str_sym7[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym7[0]-str_sym7[1]) < 0 ? color.red : (str_sym7[0]-str_sym7[1]) > 0 ? color.lime : color.black)
table.cell(tbis, 2, 8, str.tostring((str_sym8[0]-str_sym8[1]), '#,##0.00'), text_color=(str_sym8[0]-str_sym8[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym8[0]-str_sym8[1]) < 0 ? color.red : (str_sym8[0]-str_sym8[1]) > 0 ? color.lime : color.black)
// LINEs
plot(ShowEUR ? str_sym1 : na, title="EUR", color=color.yellow)
plot(ShowGBP ? str_sym2 : na, title="GBP", color=color.green)
plot(ShowAUD ? str_sym3 : na, title="AUD", color=color.purple)
plot(ShowNZD ? str_sym4 : na, title="NZD", color=color.blue)
plot(ShowJPY ? str_sym5 : na, title="JPY", color=color.red)
plot(ShowCNY ? str_sym6 : na, title="CNY", color=color.orange)
plot(ShowCAD ? str_sym7 : na, title="CAD", color=color.teal)
plot(ShowYOURs ? str_sym8 : na, title="Your Symbol", color=color.aqua)
bandh = hline(5, title= "Upper Band", color=color.new(#787B86, 50), display=display.none)
band0 = hline(0, title= "USD", color=color.new(#787B86, 0))
bandl = hline(-5, title= "Lower Band", color=color.new(#787B86, 50), display=display.none) |
EMA Cross Cloud | https://www.tradingview.com/script/6puQzLJ4-EMA-Cross-Cloud/ | syntaxgeek | https://www.tradingview.com/u/syntaxgeek/ | 92 | 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="EMA Cross Cloud", shorttitle='EXC', overlay=true)
i_emaFastLength = input.int(title='EMA Fast Length', defval=8)
i_emaSlowLength = input.int(title='EMA Slow Length', defval=21)
i_emaMarketLength = input.int(title='EMA Market Length', defval=200)
i_emaTrailingStopLength = input.int(title='EMA Trailing Stop', defval=34)
v_emaMarket = ta.ema(close, i_emaMarketLength)
v_emaTS = ta.ema(close, i_emaTrailingStopLength)
v_emaFast = ta.ema(close, i_emaFastLength)
v_emaSlow = ta.ema(close, i_emaSlowLength)
v_uptrend = ta.crossover(v_emaFast, v_emaSlow)
v_downtrend = ta.crossunder(v_emaFast, v_emaSlow)
v_uptrendStopped = v_uptrend and low < v_emaMarket
v_downtrendStopped = v_downtrend and high > v_emaMarket
v_neutralColor = color.new(color.gray, 50)
v_trendColor = v_emaFast > v_emaSlow ? close < v_emaMarket ? v_neutralColor : color.rgb(102, 255, 0, 50) : close > v_emaMarket ? v_neutralColor : color.rgb(255, 0, 0, 50)
p_fast = plot(v_emaFast, title='Fast', color=color.new(color.green, 100))
p_slow = plot(v_emaSlow, title='Slow', color=color.new(color.red, 100))
p_market = plot(v_emaMarket, title='Market', color=color.white, linewidth=3)
p_ts = plot(v_emaTS, title='Stop', color=color.orange, style=plot.style_cross)
fill(p_fast, p_slow, color=v_trendColor)
plotchar(v_uptrend ? close : na, char='⏫', title='Uptrend')
plotchar(v_downtrend ? close : na, char='⏬', title='Downtrend')
alertcondition(v_uptrend, "EMA Cross Uptrend", "EMA Cross Uptrend {{ticker}} @ {{close}}")
alertcondition(v_downtrend, "EMA Cross Downtrend", "EMA Cross Downtrend {{ticker}} @ {{close}}")
alertcondition(v_uptrend or v_downtrend, "EMA Cross Trend Changed", "EMA Cross Trend Change {{ticker}} @ {{close}}")
alertcondition(v_uptrendStopped, "EMA Cross Uptrend Stopped", "EMA Cross Uptrend Stopped {{ticker}} @ {{low}}")
alertcondition(v_downtrendStopped, "EMA Cross Downtrend Stopped", "EMA Cross Downtrend Stopped {{ticker}} @ {{high}}") |
VIDYA DMI Oscillator w/ DSL Levels [Loxx] | https://www.tradingview.com/script/a0fynMXS-VIDYA-DMI-Oscillator-w-DSL-Levels-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("VIDYA DMI Oscillator w/ DSL Levels [Loxx]",
shorttitle='VDMIODSLL [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
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
_vidya(price, priceForCmo, cmoPeriod, smoothPeriod)=>
vidya_price = price
vidya_pricc = priceForCmo
sumUp = 0., sumDo = 0.
for k = 1 to cmoPeriod
diff = nz(vidya_pricc[k]) - nz(vidya_pricc[k-1])
if (diff > 0)
sumUp += diff
else
sumDo -= diff
vidya_value = 0.
vidya_value := nz(vidya_value[1]) +
((((sumUp + sumDo) != 0) ? math.abs((sumUp-sumDo)/(sumUp+sumDo)) : 1) *
2.00 / (1.00 + math.max(smoothPeriod, 1))) *
(vidya_price - nz(vidya_value[1]))
vidya_value
DmiPeriod= input.int(32, "DMI Period", minval = 1, group = "DMI Settings")
SignalPeriod = input.int(9, "DMI Signal Period", minval = 1, group = "DMI Settings")
type = input.string("SMA", "DMI Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "DMI Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
Smooth = input.int(2, "VIDYA CMO Period", minval = 1, group = "VIDYA Settings")
SmoothPeriod = input.int(5, "VIDYA Smoothing Period", minval = 1, group = "VIDYA Settings")
showsignals = input.bool(true, "Show signals?", group = "UI Options")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
dhh = high - nz(high[1])
dll = nz(low[1]) - low
tr = math.max(high, nz(close[1])) - math.min(low, nz(close[1]))
atr = ta.ema(tr, DmiPeriod)
plusDM = (dhh > dll and dhh>0) ? dhh : 0
minusDM = (dll > dhh and dll>0) ? dll : 0
plusDI = 100 * variant(type, plusDM, DmiPeriod) / atr
minusDI = 100 * variant(type, minusDM, DmiPeriod) / atr
stoch = _vidya(plusDI - minusDI, close, Smooth, SmoothPeriod)
levelu = 0.
leveld = 0.
alpha = 2.0 / (1.0 + SignalPeriod)
levelu := (stoch > 0) ? nz(levelu[1]) + alpha * (stoch - nz(levelu[1])) : nz(levelu[1])
leveld := (stoch < 0) ? nz(leveld[1]) + alpha * (stoch - nz(leveld[1])) : nz(leveld[1])
sig = stoch[1]
mid = 0.
state = 0.
if sigtype == SM02
if (stoch < sig)
state :=-1
if (stoch > sig)
state := 1
else if sigtype == SM03
if (stoch < mid)
state :=-1
if (stoch > mid)
state := 1
else if sigtype == SM04
if (stoch < leveld)
state :=-1
if (stoch > levelu)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(stoch, "DMI", color = colorout, linewidth = 3)
plot(levelu, "Level Up", color = bar_index % 2 ? color.gray : na)
plot(leveld, "Level Down", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(stoch, sig) : sigtype == SM03 ? ta.crossover(stoch, mid) : ta.crossover(stoch, levelu)
goShort = sigtype == SM02 ? ta.crossunder(stoch, sig) : sigtype == SM03 ? ta.crossunder(stoch, mid) : ta.crossunder(stoch, leveld)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="VIDYA DMI Oscillator w/ DSL Levels [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="VIDYA DMI Oscillator w/ DSL Levels [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
OBV CSI [mado] | https://www.tradingview.com/script/jdaNQ1lO/ | madoqa | https://www.tradingview.com/u/madoqa/ | 21 | 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/
// © madoqa
//@version=4
study(title="OBV CSI[mado]", shorttitle="OBV CSI[mado]", scale=scale.right, precision=2)
hline(50)
hline(30)
hline(70)
pos1 = input(5, title="label position 1")
pos2 = input(20, title="label position 2")
eurusd = security("EURUSD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
eurgbp = security("EURGBP", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
euraud = security("EURAUD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
eurjpy = security("EURJPY", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
eurcad = security("EURAUD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
eurchf = security("EURCHF", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
eurnzd = security("EURNZD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
usdjpy = security("USDJPY", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
usdcad = security("USDAUD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
usdchf = security("USDCHF", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
gbpusd = security("GBPUSD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
gbpaud = security("GBPAUD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
gbpjpy = security("GBPJPY", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
gbpcad = security("GBPCAD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
gbpchf = security("GBPCHF", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
gbpnzd = security("GBPNZD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
audusd = security("AUDUSD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
audnzd = security("AUDNZD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
audjpy = security("AUDJPY", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
audcad = security("AUDCAD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
audchf = security("AUDCHF", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
cadjpy = security("CADJPY", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
cadchf = security("CADCHF", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
chfjpy = security("CHFJPY", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
nzdusd = security("NZDUSD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
nzdchf = security("NZDCHF", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
nzdjpy = security("NZDJPY", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
nzdcad = security("NZDCAD", timeframe.period, rsi(cum(change(close) > 0 ? +volume : change(close)-1 < 0 ? -volume : 0 * volume), 14))
eur = (eurusd + eurgbp + euraud + eurjpy + eurcad + eurchf + eurnzd) / 7
usd = (100 - audusd + 100 - gbpusd + 100 - eurusd + usdjpy + usdcad + usdchf + 100 -
nzdusd) / 7
gbp = (gbpusd + 100 - eurgbp + gbpaud + gbpjpy + gbpcad + gbpchf) / 7
aud = (audusd + 100 - gbpaud + 100 - euraud + audjpy + audcad + audchf + audnzd) / 7
chf = (100 - usdchf + 100 - gbpchf + 100 - audchf + chfjpy + 100 - cadchf + 100 -
eurchf + 100 - nzdchf) / 7
jpy = (100 - usdjpy + 100 - gbpjpy + 100 - audjpy + 100 - chfjpy + 100 - cadjpy + 100 -
eurjpy + 100 - nzdjpy) / 7
cad = (100 - usdcad + 100 - gbpcad + 100 - audcad + cadchf + cadjpy + 100 - eurcad +
100 - nzdcad) / 7
nzd = (nzdusd + 100 - gbpnzd + 100 - audnzd + nzdchf + nzdjpy + 100 - eurnzd + nzdcad) /
7
eu = eur - usd
eg = eur - gbp
ea = eur - aud
ech = eur - chf
ej = eur - jpy
eca = eur - cad
en = eur - nzd
plot(eur, color=color.blue)
plot(usd, color=color.yellow)
plot(gbp, color=color.aqua)
plot(aud, color=color.green)
plot(chf, color=color.orange)
plot(jpy, color=color.white)
plot(cad, color=color.red)
plot(nzd, color=color.black)
eur1 = eur > usd ? 1 : 0
eur2 = eur > gbp ? 1 : 0
eur3 = eur > aud ? 1 : 0
eur4 = eur > chf ? 1 : 0
eur5 = eur > jpy ? 1 : 0
eur6 = eur > cad ? 1 : 0
eur7 = eur > nzd ? 1 : 0
eurp = (eur1 + eur2 + eur3 + eur4 + eur5 + eur6 + eur7) * pos1 + pos2
usd1 = usd > eur ? 1 : 0
usd2 = usd > gbp ? 1 : 0
usd3 = usd > aud ? 1 : 0
usd4 = usd > chf ? 1 : 0
usd5 = usd > jpy ? 1 : 0
usd6 = usd > cad ? 1 : 0
usd7 = usd > nzd ? 1 : 0
usdp = (usd1 + usd2 + usd3 + usd4 + usd5 + usd6 + usd7) * pos1 + pos2
gbp1 = gbp > usd ? 1 : 0
gbp2 = gbp > eur ? 1 : 0
gbp3 = gbp > aud ? 1 : 0
gbp4 = gbp > chf ? 1 : 0
gbp5 = gbp > jpy ? 1 : 0
gbp6 = gbp > cad ? 1 : 0
gbp7 = gbp > nzd ? 1 : 0
gbpp = (gbp1 + gbp2 + gbp3 + gbp4 + gbp5 + gbp6 + gbp7) * pos1 + pos2
aud1 = aud > usd ? 1 : 0
aud2 = aud > eur ? 1 : 0
aud3 = aud > gbp ? 1 : 0
aud4 = aud > chf ? 1 : 0
aud5 = aud > jpy ? 1 : 0
aud6 = aud > cad ? 1 : 0
aud7 = aud > nzd ? 1 : 0
audp = (aud1 + aud2 + aud3 + aud4 + aud5 + aud6 + aud7) * pos1 + pos2
chf1 = chf > usd ? 1 : 0
chf2 = chf > eur ? 1 : 0
chf3 = chf > gbp ? 1 : 0
chf4 = chf > aud ? 1 : 0
chf5 = chf > jpy ? 1 : 0
chf6 = chf > cad ? 1 : 0
chf7 = chf > nzd ? 1 : 0
chfp = (chf1 + chf2 + chf3 + chf4 + chf5 + chf6 + chf7) * pos1 + pos2
jpy1 = jpy > usd ? 1 : 0
jpy2 = jpy > eur ? 1 : 0
jpy3 = jpy > gbp ? 1 : 0
jpy4 = jpy > aud ? 1 : 0
jpy5 = jpy > chf ? 1 : 0
jpy6 = jpy > cad ? 1 : 0
jpy7 = jpy > nzd ? 1 : 0
jpyp = (jpy1 + jpy2 + jpy3 + jpy4 + jpy5 + jpy6 + jpy7) * pos1 + pos2
cad1 = cad > usd ? 1 : 0
cad2 = cad > eur ? 1 : 0
cad3 = cad > gbp ? 1 : 0
cad4 = cad > aud ? 1 : 0
cad5 = cad > chf ? 1 : 0
cad6 = cad > jpy ? 1 : 0
cad7 = cad > nzd ? 1 : 0
cadp = (cad1 + cad2 + cad3 + cad4 + cad5 + cad6 + cad7) * pos1 + pos2
nzd1 = nzd > usd ? 1 : 0
nzd2 = nzd > eur ? 1 : 0
nzd3 = nzd > gbp ? 1 : 0
nzd4 = nzd > aud ? 1 : 0
nzd5 = nzd > chf ? 1 : 0
nzd6 = nzd > jpy ? 1 : 0
nzd7 = nzd > cad ? 1 : 0
nzdp = (nzd1 + nzd2 + nzd3 + nzd4 + nzd5 + nzd6 + nzd7) * pos1 + pos2
plotshape(nzdp, text='NZD', style=shape.labeldown, location=location.absolute, color=color.black, textcolor=color.white, offset=3, show_last=1)
plotshape(audp, text='AUD', style=shape.labeldown, location=location.absolute, color=color.green, textcolor=color.white, offset=3, show_last=1)
plotshape(chfp, text='CHF', style=shape.labeldown, location=location.absolute, color=color.orange, textcolor=color.white, offset=3, show_last=1)
plotshape(jpyp, text='JPY', style=shape.labeldown, location=location.absolute, color=color.white, textcolor=color.black, offset=3, show_last=1)
plotshape(cadp, text='CAD', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=3, show_last=1)
plotshape(eurp, text='EUR', style=shape.labeldown, location=location.absolute, color=color.blue, textcolor=color.white, offset=3, show_last=1)
plotshape(usdp, text='USD', style=shape.labeldown, location=location.absolute, color=color.yellow, textcolor=color.black, offset=3, show_last=1)
plotshape(gbpp, text='GBP', style=shape.labeldown, location=location.absolute, color=color.aqua, textcolor=color.black, offset=3, show_last=1)
|
Pips-Stepped, R-squared Adaptive T3 [Loxx] | https://www.tradingview.com/script/2Hd2FEcT-Pips-Stepped-R-squared-Adaptive-T3-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("Pips-Stepped, R-squared Adaptive T3 [Loxx]",
shorttitle='PSRSAT3 [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
_t3rSqrdAdapt(float src, float period, bool original, bool trendFollow, bool adapt, float factor)=>
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 = factor
if adapt
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
_calcBaseUnit() =>
bool isForexSymbol = syminfo.type == "forex"
bool isYenPair = syminfo.currency == "JPY"
float out = isForexSymbol ? isYenPair ? 0.01 : 0.0001 : syminfo.mintick
out
_stepSizeCalc(type, per, sense, size)=>
float stma = 0.
float ATR0 = 0.
float ATRmax = 0.
float ATRmin = 0.
float out = 0
float alfa = 0
if (size == 0)
float avgrng = 0
float Weight = 0
for i = per-1 to 0
if (type == "SMA")
alfa := 1.0
else
alfa := 1.0 * (per - i) / per
avgrng += alfa * (nz(high[i]) - nz(low[i]))
Weight += alfa
ATR0 := avgrng / Weight
if (ATR0 > ATRmax)
ATRmax := ATR0
if (ATR0 < ATRmin)
ATRmin := ATR0
out := math.round(0.5 * sense * (ATRmax + ATRmin) / _calcBaseUnit())
else
out := sense * size
out
per = input.int(14, "Period", group = "T3 Settings")
t3hot = input.float(0.7, "T3 Factor (non-adaptive only)", step = 0.01, maxval = 1, minval = 0, group = "T3 Settings")
orig = input.bool(false, "Original?", group = "T3 Settings")
fllwtrnd = input.bool(true, "Trend follow? (adaptive only)", group = "T3 Settings")
adapt = input.bool(true, "Make it Adaptive?", group = "T3 Settings")
MA_Mode = input.string("SMA", "MA Type", options = ["SMA", "LWMA"], group = "Stepping Settings")
Percentage = input.float(0, "Percentage", step = 0.1, group = "Stepping Settings", tooltip = "Percentage of Up/Down Moving")
stepsize = input.int(20, "Step size", group = "Stepping Settings")
sense = input.float(5, "Sensivity", step = 0.1, minval = 0.1, group = "Stepping Settings")
HighLow = input.bool(false, "High/Low mode?", group = "Stepping Settings")
colorbars = input.bool(false, "Color bars?", group= "UI Options")
flat = input.bool(false, "Flat-level colroing?", group= "UI Options")
showSigs = input.bool(false, "Show signals?", group= "UI Options")
size = _stepSizeCalc(MA_Mode, per, sense, stepsize)
smax = 0., smin = 0.
if HighLow
smax := _t3rSqrdAdapt(low, per, orig, fllwtrnd, adapt, t3hot) + 2.0 * size * _calcBaseUnit()
smin := _t3rSqrdAdapt(high, per, orig, fllwtrnd, adapt, t3hot) - 2.0 * size * _calcBaseUnit()
else
smax := _t3rSqrdAdapt(low, per, orig, fllwtrnd, adapt, t3hot) + 2.0 * size * _calcBaseUnit()
smin := _t3rSqrdAdapt(low, per, orig, fllwtrnd, adapt, t3hot) - 2.0 * size * _calcBaseUnit()
trend = 0., out = 0.
trend := trend[1]
if (close > smax[1])
trend := 1
if (close < smin[1])
trend := -1
if (trend > 0)
if (smin < smin[1])
smin := smin[1]
out := smin + size * _calcBaseUnit()
else
if (smax > smax[1])
smax := smax[1]
out := smax - size * _calcBaseUnit()
val = out + Percentage / 100.0 * stepsize * _calcBaseUnit()
colorout = val > val[1] ? greencolor : val < val[1] ? redcolor : color.gray
goLong_pre = ta.crossover(val, val[1])
goShort_pre = ta.crossunder(val, val[1])
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch
goLong = goLong_pre and ta.change(contSwitch)
goShort = goShort_pre and ta.change(contSwitch)
plot(val,"Pips-Stepped, R-squared Adaptive T3", color = flat ? colorout : (contSwitch == 1 ? greencolor : redcolor), linewidth = 3)
barcolor(colorbars ? flat ? colorout : (contSwitch == 1 ? greencolor : redcolor) : 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="Pips-Stepped, R-squared Adaptive T3 [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Pips-Stepped, R-squared Adaptive T3 [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
STD-Filterd, R-squared Adaptive T3 w/ Dynamic Zones [Loxx] | https://www.tradingview.com/script/tGJZb4NF-STD-Filterd-R-squared-Adaptive-T3-w-Dynamic-Zones-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("STD-Filterd, R-squared Adaptive T3 w/ Dynamic Zones [Loxx]",
shorttitle='STDFRSAT3DZ [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
SM05 = 'Close'
_t3rSqrdAdapt(float src, float period, bool original, bool trendFollow, bool adapt, float factor)=>
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 = factor
if adapt
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
_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("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 = "T3 Settings")
t3hot = input.float(0.7, "T3 Factor (non-adaptive only)", step = 0.01, maxval = 1, minval = 0, group = "T3 Settings")
orig = input.bool(false, "Original?", group = "T3 Settings")
fllwtrnd = input.bool(true, "Trend follow? (adaptive only)", group = "T3 Settings")
adapt = input.bool(true, "Make it Adaptive?", group = "T3 Settings")
filterop = input.string("Both", "Filter Options", options = ["Price", "T3 Filter", "Both"], group= "Filter Settings")
filter = input.float(0, "Filter Devaitions", minval = 0, group= "Filter Settings")
filterperiod = input.int(1, "Filter Period", minval = 0, group= "Filter Settings")
dzper = input.int(35, "Dynamic Zone Period", group = "Levels Settings")
buyprob = input.float(0.1, "Dynamic Zone Buy Probability Level", group = "Levels Settings", maxval = 0.999, minval = 0.01, step = 0.01)
sellprob = input.float(0.1, "Dynamic Zone Sell Probability Level", group = "Levels Settings", maxval = 0.999, minval = 0.01, step = 0.01)
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04, SM05], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showSigs = input.bool(false, "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
price = filterop == "Both" or filterop == "Price" and filter > 0 ? _filt(src, filterperiod, filter) : src
t3in = _t3rSqrdAdapt(price, per, orig, fllwtrnd, adapt, t3hot)
t3 = filterop == "Both" or filterop == "T3 Filter" and filter > 0 ? _filt(t3in, filterperiod, filter) : t3in
sig = nz(t3[1])
bli = loxxdynamiczone.dZone("buy", t3, buyprob, dzper)
sli = loxxdynamiczone.dZone("sell", t3, sellprob, dzper)
zli = loxxdynamiczone.dZone("sell", t3, 0.5, dzper)
state = 0.
if sigtype == SM02
if (t3 < sig)
state :=-1
if (t3 > sig)
state := 1
else if sigtype == SM03
if (t3 < zli)
state :=-1
if (t3 > zli)
state := 1
else if sigtype == SM04
if (t3 < bli)
state :=-1
if (t3 > sli)
state := 1
else if sigtype == SM05
if (t3 < close)
state :=1
if (t3 > close)
state :=-1
top = plot(bli, "Top level", color = color.new(greencolor, 50), linewidth = 1)
bot = plot(sli, "Bottom level", color = color.new(redcolor, 50), linewidth = 1)
plot(zli, "Mid level", color = color.new(color.white, 10), linewidth = 1)
var color colorout = na
colorout := state == -1 ? redcolor : state == 1 ? greencolor : nz(colorout[1])
plot(t3, "T3", color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
goLong_pre = sigtype == SM02 ? ta.crossover(t3, sig) : sigtype == SM03 ? ta.crossover(t3, zli) : sigtype == SM04 ? ta.crossover(t3, sli) : ta.crossover(close, t3)
goShort_pre = sigtype == SM02 ? ta.crossunder(t3, sig) : sigtype == SM03 ? ta.crossunder(t3, zli) : sigtype == SM04 ? ta.crossunder(t3, bli) : ta.crossunder(close, t3)
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch
goLong = goLong_pre and ta.change(contSwitch)
goShort = goShort_pre and ta.change(contSwitch)
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-Filterd, R-squared Adaptive T3 w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="STD-Filterd, R-squared Adaptive T3 w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
EPS & Sales | https://www.tradingview.com/script/WiaFmLGR/ | Fred6724 | https://www.tradingview.com/u/Fred6724/ | 1,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/
// © Fred6724
//@version=5
indicator("EPS & Sales", overlay=true, max_labels_count = 500)
// === USER INPUTS ====
i_ArrowOnGraph = input(true, title='Displays Arrows', inline="1", group="Arrows")
i_salesOnGraph = input(false, title='Sales', inline="1", group="Arrows")
i_arrowSize = input.string(size.small, title='Arrow Size', options=[size.tiny,size.small,size.normal, size.large], inline="2", group="Arrows")
i_arrowColor = input(color.rgb(0,0,0,0), title='Arrow Colors', inline="3", group="Arrows")
i_posArrowColor= input(color.rgb(13,7,201,0), title='%Pos' ,group="Arrows", inline="3")
i_negArrowColor= input(color.red, title='%Neg' ,group="Arrows", inline="3")
i_tableSize = input.string(size.normal, title='Table Size', options=[size.tiny,size.small,size.normal, size.large] ,group="Table" ,inline="5")
i_posTable = input.string(defval=position.bottom_left, title='Table 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] ,group="Table" ,inline="6", tooltip = "Available in Weekly Table Only.")
i_tableStyle = input.string("Weekly", title = "Type of Table", options = ["Weekly", "Daily"], group="Table", inline="0")
i_frameWidth = input.int(1, title='Frame Width', group="Table", options= [0,1,2,3,4,5], inline="0.25")
i_frameColor = input(color.rgb(0, 0, 0), title='| Color' , group="Table", inline="0.25")
i_tableBorder = input(false, title='Table Border', group="Table", inline="0.5")
i_borderColor = input(color.rgb(0, 0, 0), title='| Color' ,group="Table", inline="0.5")
i_moreData = input(false, title='Less Quarters' ,group="Table", inline="1", tooltip = "Available in Weekly Table Only.")
i_alwaysDispP = input(false, title='Always display %Var', group="Table", inline="1", tooltip = "Available in Weekly Table Only.")
i_QoQ = input(false, title='QoQ Datas' ,group="Table" ,inline="2", tooltip = "Available in Weekly Table Only.")
i_compare = input(false, title='Show VS' ,group="Table" ,inline="2", tooltip = "Available in Weekly Table Only.")
i_surprises = input(false, title='% Surprise' ,group="Table", inline="3", tooltip = "Available in Weekly Table Only.")
i_posSurp = input(color.rgb(56,142,60,0), title='%Pos' ,group="Table", inline="3")
i_negSurp = input(color.red, title='%Neg' ,group="Table", inline="3")
i_grossMargin = input(false, title='Gross Margin' ,group="Table" ,inline="4")
i_ROE = input(false, title='Return On Equity' ,group="Table" ,inline="4")
i_resultBackgroundColorOdd = input(color.white, title='Odd Rows' ,group="Table", inline="7")
i_resultBackgroundColorEven = input(color.rgb(192,192,192,0), title='Even Rows' ,group="Table", inline="7")
i_RowAndColumnTextColor = input(color.black, title='Sideways Row & Column Text ' ,group="Table")
i_posColor = input(color.rgb(13,7,201,0), title='% Positive' ,group="Table", inline="8")
i_negColor = input(color.red, title='% Negative' ,group="Table", inline="8")
// Not input
datasize = 10
blankUnderUp = i_moreData == false ? 3 : 6 // Because there is a blank between the top of the table and the second line but Tradingview doesn't display it.
// Declare tables
// Weekly Table
var table epsTable = table.new(i_posTable, 15, 15, frame_color = i_frameColor, frame_width = i_frameWidth, border_width=i_tableBorder ? 1:0, border_color=i_borderColor)
// Daily Table
var table epsTableDa = table.new(position.bottom_center,17, 4, frame_color = i_frameColor, frame_width = i_frameWidth, border_width=i_tableBorder ? 1:0, border_color=i_borderColor)
// === FUNCTIONS AND CALCULATIONS ===.
// Current earnings per share
// Modified line to get (actual) and (standard) earnings with 'request.earnings'. HUGE key point here to have closer results to IBD - MarketSmith
EPS = request.earnings(syminfo.tickerid, earnings.actual, ignore_invalid_symbol=true, lookahead = barmerge.lookahead_on)
EPS_Standard = request.earnings(syminfo.tickerid, earnings.standardized, ignore_invalid_symbol=true, lookahead = barmerge.lookahead_on)
EPS_Estimate = request.earnings(syminfo.tickerid, earnings.estimate, ignore_invalid_symbol=true, lookahead = barmerge.lookahead_on) // To reduce the probability of not detecting a change if EPS are the same quarters over quarters
SALES = request.financial(syminfo.tickerid, "TOTAL_REVENUE", "FQ")
SALES_Estimate = request.financial(syminfo.tickerid, "SALES_ESTIMATES", "FQ")
SALES_GROWTH = request.financial(syminfo.tickerid, "REVENUE_ONE_YEAR_GROWTH", "FQ")
grossMargin = i_grossMargin ? request.financial(syminfo.tickerid, "GROSS_MARGIN", "FQ"):na
ROE = request.financial(syminfo.tickerid, "RETURN_ON_EQUITY", "FQ")
//Date
rev = request.financial(syminfo.tickerid,'TOTAL_REVENUE','FQ',barmerge.gaps_on, ignore_invalid_symbol=true)
// GET EPS NUMBERS FROM TRADINGVIEW
barSince = ta.barssince(EPS != EPS[1] or EPS_Standard != EPS_Standard[1] or EPS_Estimate != EPS_Estimate[1]) // To reduce the probability of not detecting a change if EPS are the same quarters over quarters
EPSTime = barSince == 0
// If the number of (bars since the value of EPS, is different, from previous EPS) equals 0, we are in an EPS event. (You can do it)
// (Better method, using the time since the last public EPS/Sales (Before we were using default 3M that was causing errors in case of non-regular period publishing))
// Now we are using sometimes Actual EPS, somtimes Standard EPS, based on my observations with MarketSmith numbers.
// Actual EPS
// Use if() function to get number before the first earning event - If return na we get the first EPS value except if the line before us already done it
firstEPS = ta.valuewhen(bar_index==0, EPS, 0)
actualEPS = ta.valuewhen(EPSTime, EPS, 0)
if(na(actualEPS))
actualEPS := firstEPS
actualEPS1 = ta.valuewhen(EPSTime, EPS, 1) // With "1" to search the previous EPS value, etc
if(na(actualEPS1) and actualEPS != firstEPS)
actualEPS1 := firstEPS
actualEPS2 = ta.valuewhen(EPSTime, EPS, 2)
if(na(actualEPS2) and actualEPS1 != firstEPS)
actualEPS2 := firstEPS
actualEPS3 = ta.valuewhen(EPSTime, EPS, 3)
if(na(actualEPS3) and actualEPS2 != firstEPS)
actualEPS3 := firstEPS
actualEPS4 = ta.valuewhen(EPSTime, EPS, 4)
if(na(actualEPS4) and actualEPS3 != firstEPS)
actualEPS4 := firstEPS
actualEPS5 = ta.valuewhen(EPSTime, EPS, 5)
if(na(actualEPS5) and actualEPS4 != firstEPS)
actualEPS5 := firstEPS
actualEPS6 = ta.valuewhen(EPSTime, EPS, 6)
if(na(actualEPS6) and actualEPS5 != firstEPS)
actualEPS6 := firstEPS
actualEPS7 = ta.valuewhen(EPSTime, EPS, 7)
if(na(actualEPS7) and actualEPS6 != firstEPS)
actualEPS7 := firstEPS
actualEPS8 = ta.valuewhen(EPSTime, EPS, 8)
if(na(actualEPS8) and actualEPS7 != firstEPS)
actualEPS8 := firstEPS
actualEPS9 = ta.valuewhen(EPSTime, EPS, 9)
if(na(actualEPS9) and actualEPS8 != firstEPS)
actualEPS9 := firstEPS
actualEPS10 = ta.valuewhen(EPSTime, EPS, 10)
if(na(actualEPS10) and actualEPS9 != firstEPS)
actualEPS10 := firstEPS
actualEPS11 = ta.valuewhen(EPSTime, EPS, 11)
if(na(actualEPS11) and actualEPS10 != firstEPS)
actualEPS11 := firstEPS
// Standard EPS
standardEPS = ta.valuewhen(EPSTime, EPS_Standard, 0)
standardEPS1 = ta.valuewhen(EPSTime, EPS_Standard, 1)
standardEPS2 = ta.valuewhen(EPSTime, EPS_Standard, 2)
standardEPS3 = ta.valuewhen(EPSTime, EPS_Standard, 3)
standardEPS4 = ta.valuewhen(EPSTime, EPS_Standard, 4)
standardEPS5 = ta.valuewhen(EPSTime, EPS_Standard, 5)
standardEPS6 = ta.valuewhen(EPSTime, EPS_Standard, 6)
standardEPS7 = ta.valuewhen(EPSTime, EPS_Standard, 7)
standardEPS8 = ta.valuewhen(EPSTime, EPS_Standard, 8)
standardEPS9 = ta.valuewhen(EPSTime, EPS_Standard, 9)
standardEPS10 = ta.valuewhen(EPSTime, EPS_Standard, 10)
standardEPS11 = ta.valuewhen(EPSTime, EPS_Standard, 11)
// Estimate EPS
estimateEPS = ta.valuewhen(EPSTime, EPS_Estimate, 0)
estimateEPS1 = ta.valuewhen(EPSTime, EPS_Estimate, 1)
estimateEPS2 = ta.valuewhen(EPSTime, EPS_Estimate, 2)
estimateEPS3 = ta.valuewhen(EPSTime, EPS_Estimate, 3)
estimateEPS4 = ta.valuewhen(EPSTime, EPS_Estimate, 4)
estimateEPS5 = ta.valuewhen(EPSTime, EPS_Estimate, 5)
estimateEPS6 = ta.valuewhen(EPSTime, EPS_Estimate, 6)
estimateEPS7 = ta.valuewhen(EPSTime, EPS_Estimate, 7)
// EPS Surprise
EpsSurprise0 = (actualEPS -estimateEPS )/math.abs(estimateEPS )*100
EpsSurprise1 = (actualEPS1-estimateEPS1)/math.abs(estimateEPS1)*100
EpsSurprise2 = (actualEPS2-estimateEPS2)/math.abs(estimateEPS2)*100
EpsSurprise3 = (actualEPS3-estimateEPS3)/math.abs(estimateEPS3)*100
EpsSurprise4 = (actualEPS4-estimateEPS4)/math.abs(estimateEPS4)*100
EpsSurprise5 = (actualEPS5-estimateEPS5)/math.abs(estimateEPS5)*100
EpsSurprise6 = (actualEPS6-estimateEPS6)/math.abs(estimateEPS6)*100
EpsSurprise7 = (actualEPS7-estimateEPS7)/math.abs(estimateEPS7)*100
// Same with Sales
// Use if() function to get number before the first earning event - If return na we get the first sales value except if the line before us already done it
firstSale = ta.valuewhen(bar_index==0, SALES, 0)
sales = ta.valuewhen(EPSTime, SALES, 0)
if(na(sales))
sales := firstSale
sales1 = ta.valuewhen(EPSTime, SALES, 1)
if(na(sales1) and sales != firstSale)
sales1 := firstSale
sales2 = ta.valuewhen(EPSTime, SALES, 2)
if(na(sales2) and sales1 != firstSale)
sales2 := firstSale
sales3 = ta.valuewhen(EPSTime, SALES, 3)
if(na(sales3) and sales2 != firstSale)
sales3 := firstSale
sales4 = ta.valuewhen(EPSTime, SALES, 4)
if(na(sales4) and sales3 != firstSale)
sales4 := firstSale
sales5 = ta.valuewhen(EPSTime, SALES, 5)
if(na(sales5) and sales4 != firstSale)
sales5 := firstSale
sales6 = ta.valuewhen(EPSTime, SALES, 6)
if(na(sales6) and sales5 != firstSale)
sales6 := firstSale
sales7 = ta.valuewhen(EPSTime, SALES, 7)
if(na(sales7) and sales6 != firstSale)
sales7 := firstSale
sales8 = ta.valuewhen(EPSTime, SALES, 8)
if(na(sales8) and sales7 != firstSale)
sales8 := firstSale
sales9 = ta.valuewhen(EPSTime, SALES, 9)
if(na(sales9) and sales8 != firstSale)
sales9 := firstSale
sales10 = ta.valuewhen(EPSTime, SALES, 10)
if(na(sales10) and sales9 != firstSale)
sales10 := firstSale
sales11 = ta.valuewhen(EPSTime, SALES, 11)
if(na(sales11) and sales10 != firstSale)
sales11 := firstSale
// Sales One Year Growth to get more Historical Data
// We use if() condition to get one more line
firstSaleGrowth = ta.valuewhen(bar_index==0, SALES_GROWTH, 0)
salesChange0 = ta.valuewhen(EPSTime, SALES_GROWTH, 0)
if(na(salesChange0))
salesChange0 := firstSaleGrowth
salesChange1 = ta.valuewhen(EPSTime, SALES_GROWTH, 1)
if(na(salesChange1) and salesChange0 != firstSaleGrowth)
salesChange1 := firstSaleGrowth
salesChange2 = ta.valuewhen(EPSTime, SALES_GROWTH, 2)
if(na(salesChange2) and salesChange1 != firstSaleGrowth)
salesChange2 := firstSaleGrowth
salesChange3 = ta.valuewhen(EPSTime, SALES_GROWTH, 3)
if(na(salesChange3) and salesChange2 != firstSaleGrowth)
salesChange3 := firstSaleGrowth
salesChange4 = ta.valuewhen(EPSTime, SALES_GROWTH, 4)
if(na(salesChange4) and salesChange3 != firstSaleGrowth)
salesChange4 := firstSaleGrowth
salesChange5 = ta.valuewhen(EPSTime, SALES_GROWTH, 5)
if(na(salesChange5) and salesChange4 != firstSaleGrowth)
salesChange5 := firstSaleGrowth
salesChange6 = ta.valuewhen(EPSTime, SALES_GROWTH, 6)
if(na(salesChange6) and salesChange5 != firstSaleGrowth)
salesChange6 := firstSaleGrowth
salesChange7 = ta.valuewhen(EPSTime, SALES_GROWTH, 7)
if(na(salesChange7) and salesChange6 != firstSaleGrowth)
salesChange7 := firstSaleGrowth
// Sometimes the sales number is actualised but not the sales variation..
if(salesChange0 == salesChange1 and not (na(sales4) or sales4 == 0))
salesChange0 := (sales - sales4)/math.abs(sales4)*100
// Case where earning are very close, should check if the % variation is good (VRRM Mar-22 - Dec-21) -> 70 90 and not 90 90
if(salesChange1 == salesChange0 and sales1 == sales)
salesChange1 := (sales1 - sales5)/math.abs(sales5)*100
if(salesChange2 == salesChange1 and sales2 == sales1)
salesChange2 := (sales2 - sales6)/math.abs(sales6)*100
if(salesChange3 == salesChange2 and sales3 == sales2)
salesChange3 := (sales3 - sales7)/math.abs(sales7)*100
if(salesChange4 == salesChange3 and sales4 == sales3)
salesChange4 := (sales4 - sales8)/math.abs(sales8)*100
if(salesChange5 == salesChange4 and sales5 == sales4)
salesChange5 := (sales5 - sales9)/math.abs(sales9)*100
if(salesChange6 == salesChange5 and sales6 == sales5)
salesChange6 := (sales6 - sales10)/math.abs(sales10)*100
if(salesChange7 == salesChange6 and sales7 == sales6)
salesChange7 := (sales7 - sales11)/math.abs(sales11)*100
// Sales Estimaate
salesEstimate = ta.valuewhen(EPSTime, SALES_Estimate, 0)
salesEstimate1 = ta.valuewhen(EPSTime, SALES_Estimate, 1)
salesEstimate2 = ta.valuewhen(EPSTime, SALES_Estimate, 2)
salesEstimate3 = ta.valuewhen(EPSTime, SALES_Estimate, 3)
salesEstimate4 = ta.valuewhen(EPSTime, SALES_Estimate, 4)
salesEstimate5 = ta.valuewhen(EPSTime, SALES_Estimate, 5)
salesEstimate6 = ta.valuewhen(EPSTime, SALES_Estimate, 6)
salesEstimate7 = ta.valuewhen(EPSTime, SALES_Estimate, 7)
// Detect same sales for TradingView bug correction (Same sales than previous display)
bool sameSales = SALES==sales1 and SALES_GROWTH==salesChange1
bool recentEarn = ta.barssince(EPSTime)<=6
// Function to define previous quarters gross margin & roe (Less precise than EPS and Sales Data)
f_grossMargin(i) =>
request.security(syminfo.tickerid, '3M', grossMargin[i])
f_roe(i) =>
request.security(syminfo.tickerid, '3M', ROE[i])
// Same with Gross Margin
// Use if() function to get number before the first earning event - If return na we get the first sales value except if the line before us already done it
firstGrossMargin = ta.valuewhen(bar_index==0, grossMargin, 0)
GM0 = ta.valuewhen(EPSTime, grossMargin, 0)
if(na(GM0))
GM0 := firstGrossMargin
GM1 = ta.valuewhen(EPSTime, grossMargin, 1)
if(na(GM1) and GM0 != firstGrossMargin)
GM1 := firstGrossMargin
GM2 = ta.valuewhen(EPSTime, grossMargin, 2)
if(na(GM2) and GM1 != firstGrossMargin)
GM2 := firstGrossMargin
GM3 = ta.valuewhen(EPSTime, grossMargin, 3)
if(na(GM3) and GM2 != firstGrossMargin)
GM3 := firstGrossMargin
GM4 = ta.valuewhen(EPSTime, grossMargin, 4)
if(na(GM4) and GM3 != firstGrossMargin)
GM4 := firstGrossMargin
GM5 = ta.valuewhen(EPSTime, grossMargin, 5)
if(na(GM5) and GM4 != firstGrossMargin)
GM5 := firstGrossMargin
GM6 = ta.valuewhen(EPSTime, grossMargin, 6)
if(na(GM6) and GM5 != firstGrossMargin)
GM6 := firstGrossMargin
GM7 = ta.valuewhen(EPSTime, grossMargin, 7)
if(na(GM7) and GM6 != firstGrossMargin)
GM7 := firstGrossMargin
// Same with Return On Equity
// Use if() function to get number before the first earning event - If return na we get the first sales value except if the line before us already done it
firstReturnOnEquity = ta.valuewhen(bar_index==0, ROE, 0)
ROE0 = ta.valuewhen(EPSTime, ROE, 0)
if(na(ROE0))
ROE0 := firstReturnOnEquity
ROE1 = ta.valuewhen(EPSTime, ROE, 1)
if(na(ROE1) and ROE0 != firstReturnOnEquity)
ROE1 := firstReturnOnEquity
ROE2 = ta.valuewhen(EPSTime, ROE, 2)
if(na(ROE2) and ROE1 != firstReturnOnEquity)
ROE2 := firstReturnOnEquity
ROE3 = ta.valuewhen(EPSTime, ROE, 3)
if(na(ROE3) and ROE2 != firstReturnOnEquity)
ROE3 := firstReturnOnEquity
ROE4 = ta.valuewhen(EPSTime, ROE, 4)
if(na(ROE4) and ROE3 != firstReturnOnEquity)
ROE4 := firstReturnOnEquity
ROE5 = ta.valuewhen(EPSTime, ROE, 5)
if(na(ROE5) and ROE4 != firstReturnOnEquity)
ROE5 := firstReturnOnEquity
ROE6 = ta.valuewhen(EPSTime, ROE, 6)
if(na(ROE6) and ROE5 != firstReturnOnEquity)
ROE6 := firstReturnOnEquity
ROE7 = ta.valuewhen(EPSTime, ROE, 7)
if(na(ROE7) and ROE6 != firstReturnOnEquity)
ROE7 := firstReturnOnEquity
// Calculation using IBD/Marketsmith principle : current quarter EPS vs the same quartar's EPS of previous year. (YoY)
EpsChange0 = actualEPS < 0 and actualEPS4 <= 0 ? na: actualEPS4 < 0 and standardEPS4 > 0 ? (EPS-actualEPS4) /math.abs(actualEPS4) *100:EPS < 0 and actualEPS4 > 0 ? na:(EPS-actualEPS4) /math.abs(actualEPS4) *100
EpsChange1 = actualEPS1 < 0 and actualEPS5 <= 0 ? na: actualEPS5 < 0 and standardEPS5 > 0 ? (actualEPS1-actualEPS5) /math.abs(actualEPS5) *100:actualEPS1 < 0 and actualEPS5 > 0 ? na:(actualEPS1-actualEPS5) /math.abs(actualEPS5) *100
EpsChange2 = actualEPS2 < 0 and actualEPS6 <= 0 ? na: actualEPS6 < 0 and standardEPS6 > 0 ? (actualEPS2-actualEPS6) /math.abs(actualEPS6) *100:actualEPS2 < 0 and actualEPS6 > 0 ? na:(actualEPS2-actualEPS6) /math.abs(actualEPS6) *100
EpsChange3 = actualEPS3 < 0 and actualEPS7 <= 0 ? na: actualEPS7 < 0 and standardEPS7 > 0 ? (actualEPS3-actualEPS7) /math.abs(actualEPS7) *100:actualEPS3 < 0 and actualEPS7 > 0 ? na:(actualEPS3-actualEPS7) /math.abs(actualEPS7) *100
EpsChange4 = actualEPS4 < 0 and actualEPS8 <= 0 ? na: actualEPS8 < 0 and standardEPS8 > 0 ? (actualEPS4-actualEPS8) /math.abs(actualEPS8) *100:actualEPS4 < 0 and actualEPS8 > 0 ? na:(actualEPS4-actualEPS8) /math.abs(actualEPS8) *100
EpsChange5 = actualEPS5 < 0 and actualEPS9 <= 0 ? na: actualEPS9 < 0 and standardEPS9 > 0 ? (actualEPS5-actualEPS9) /math.abs(actualEPS9) *100:actualEPS5 < 0 and actualEPS9 > 0 ? na:(actualEPS5-actualEPS9) /math.abs(actualEPS9) *100
EpsChange6 = actualEPS6 < 0 and actualEPS10 <= 0 ? na: actualEPS10 < 0 and standardEPS10 > 0 ? (actualEPS6-actualEPS10)/math.abs(actualEPS10)*100:actualEPS6 < 0 and actualEPS10 > 0 ? na:(actualEPS6-actualEPS10)/math.abs(actualEPS10)*100
EpsChange7 = actualEPS7 < 0 and actualEPS11 <= 0 ? na: actualEPS11 < 0 and standardEPS11 > 0 ? (actualEPS7-actualEPS11)/math.abs(actualEPS11)*100:actualEPS7 < 0 and actualEPS11 > 0 ? na:(actualEPS7-actualEPS11)/math.abs(actualEPS11)*100
// The case in which atual was - and standard was + was not taken into account, I added a condition to fix a ver low value in this case and have the '#' succesfully display
// because of the choice when fillCell.
// When EPS is negative we take the closer from 0 between standardized and reported
// We also use another variable to recognize when the calculation has been done with negative EPS (To display '#') // added this condition because 0.98 vs -0.16 = #712/713% not 999% APA
EpsChangeHash0 = actualEPS4 >= 0 ? na: actualEPS < 0 and standardEPS4 < 0 ? na:actualEPS4 < 0 and standardEPS4 > 0 ? (EPS-actualEPS4) /math.abs(actualEPS4) *100:actualEPS4 <= standardEPS4 and standardEPS4 >-0.01 ? (EPS-standardEPS4) /math.abs(standardEPS4) *100:(EPS-actualEPS4)/math.abs(actualEPS4)*100
EpsChangeHash1 = actualEPS5 >= 0 ? na:actualEPS1 < 0 and standardEPS5 < 0 ? na:actualEPS5 < 0 and standardEPS5 > 0 ? (actualEPS1-actualEPS5) /math.abs(actualEPS5) *100:actualEPS5 <= standardEPS5 and standardEPS5 >-0.01 ? (actualEPS1-standardEPS5) /math.abs(standardEPS5) *100:(actualEPS1-actualEPS5) /math.abs(actualEPS5) *100
EpsChangeHash2 = actualEPS6 >= 0 ? na:actualEPS2 < 0 and standardEPS6 < 0 ? na:actualEPS6 < 0 and standardEPS6 > 0 ? (actualEPS2-actualEPS6) /math.abs(actualEPS6) *100:actualEPS6 <= standardEPS6 and standardEPS6 >-0.01 ? (actualEPS2-standardEPS6) /math.abs(standardEPS6) *100:(actualEPS2-actualEPS6) /math.abs(actualEPS6) *100
EpsChangeHash3 = actualEPS7 >= 0 ? na:actualEPS3 < 0 and standardEPS7 < 0 ? na:actualEPS7 < 0 and standardEPS7 > 0 ? (actualEPS3-actualEPS7) /math.abs(actualEPS7) *100:actualEPS7 <= standardEPS7 and standardEPS7 >-0.01 ? (actualEPS3-standardEPS7) /math.abs(standardEPS7) *100:(actualEPS3-actualEPS7) /math.abs(actualEPS7) *100
EpsChangeHash4 = actualEPS8 >= 0 ? na:actualEPS4 < 0 and standardEPS8 < 0 ? na:actualEPS8 < 0 and standardEPS8 > 0 ? (actualEPS4-actualEPS8) /math.abs(actualEPS8) *100:actualEPS8 <= standardEPS8 and standardEPS8 >-0.01 ? (actualEPS4-standardEPS8) /math.abs(standardEPS8) *100:(actualEPS4-actualEPS8) /math.abs(actualEPS8) *100
EpsChangeHash5 = actualEPS9 >= 0 ? na:actualEPS5 < 0 and standardEPS9 < 0 ? na:actualEPS9 < 0 and standardEPS9 > 0 ? (actualEPS5-actualEPS9) /math.abs(actualEPS9) *100:actualEPS9 <= standardEPS9 and standardEPS9 >-0.01 ? (actualEPS5-standardEPS9) /math.abs(standardEPS9) *100:(actualEPS5-actualEPS9) /math.abs(actualEPS9) *100
EpsChangeHash6 = actualEPS10 >= 0 ? na:actualEPS6 < 0 and standardEPS10 < 0 ? na:actualEPS10 < 0 and standardEPS10 > 0 ? (actualEPS6-actualEPS10)/math.abs(actualEPS10)*100:actualEPS10 <= standardEPS10 and standardEPS10>-0.01 ? (actualEPS6-standardEPS10)/math.abs(standardEPS10)*100:(actualEPS6-actualEPS10)/math.abs(actualEPS10)*100
EpsChangeHash7 = actualEPS11 >= 0 ? na:actualEPS7 < 0 and standardEPS11 < 0 ? na:actualEPS11 < 0 and standardEPS11 > 0 ? (actualEPS7-actualEPS11)/math.abs(actualEPS11)*100:actualEPS11 <= standardEPS11 and standardEPS11>-0.01 ? (actualEPS7-standardEPS11)/math.abs(standardEPS11)*100:(actualEPS7-actualEPS11)/math.abs(actualEPS11)*100
// Due to comments I add a possibility to display the % variation even if the company is not profitable
if(i_alwaysDispP)
EpsChange0 := (actualEPS-actualEPS4 )/math.abs(actualEPS4) *100
EpsChange1 := (actualEPS1-actualEPS5 )/math.abs(actualEPS5) *100
EpsChange2 := (actualEPS2-actualEPS6 )/math.abs(actualEPS6) *100
EpsChange3 := (actualEPS3-actualEPS7 )/math.abs(actualEPS7) *100
EpsChange4 := (actualEPS4-actualEPS8 )/math.abs(actualEPS8) *100
EpsChange5 := (actualEPS5-actualEPS9 )/math.abs(actualEPS9) *100
EpsChange6 := (actualEPS6-actualEPS10)/math.abs(actualEPS10)*100
EpsChange7 := (actualEPS7-actualEPS11)/math.abs(actualEPS11)*100
// EPS QoQ (To prevent me from harassment in the comments :-) ... )
EpsChangeQoQ0 = (actualEPS -actualEPS1)/math.abs(actualEPS1)*100
EpsChangeQoQ1 = (actualEPS1-actualEPS2)/math.abs(actualEPS2)*100
EpsChangeQoQ2 = (actualEPS2-actualEPS3)/math.abs(actualEPS3)*100
EpsChangeQoQ3 = (actualEPS3-actualEPS4)/math.abs(actualEPS4)*100
EpsChangeQoQ4 = (actualEPS4-actualEPS5)/math.abs(actualEPS5)*100
EpsChangeQoQ5 = (actualEPS5-actualEPS6)/math.abs(actualEPS6)*100
EpsChangeQoQ6 = (actualEPS6-actualEPS7)/math.abs(actualEPS7)*100
EpsChangeQoQ7 = (actualEPS7-actualEPS8)/math.abs(actualEPS8)*100
// Sales Surprise
SalesSurprise0 = (sales - salesEstimate )/math.abs(salesEstimate )*100
SalesSurprise1 = (sales1 - salesEstimate1)/math.abs(salesEstimate1)*100
SalesSurprise2 = (sales2 - salesEstimate2)/math.abs(salesEstimate2)*100
SalesSurprise3 = (sales3 - salesEstimate3)/math.abs(salesEstimate3)*100
SalesSurprise4 = (sales4 - salesEstimate4)/math.abs(salesEstimate4)*100
SalesSurprise5 = (sales5 - salesEstimate5)/math.abs(salesEstimate5)*100
SalesSurprise6 = (sales6 - salesEstimate6)/math.abs(salesEstimate6)*100
SalesSurprise7 = (sales7 - salesEstimate7)/math.abs(salesEstimate7)*100
// Sales QoQ
salesChangeQoQ0 = (sales -sales1) /math.abs(sales1) *100
salesChangeQoQ1 = (sales1 -sales2) /math.abs(sales2) *100
salesChangeQoQ2 = (sales2 -sales3) /math.abs(sales3) *100
salesChangeQoQ3 = (sales3 -sales4) /math.abs(sales4) *100
salesChangeQoQ4 = (sales4 -sales5) /math.abs(sales5) *100
salesChangeQoQ5 = (sales5 -sales6) /math.abs(sales6) *100
salesChangeQoQ6 = (sales6 -sales7) /math.abs(sales7) *100
salesChangeQoQ7 = (sales7 -sales8) /math.abs(sales8) *100
//Adapting Format of Sales 98 000 000 to 98,0 M
Sales0M = (sales /1000000)
Sales1M = (sales1/1000000)
Sales2M = (sales2/1000000)
Sales3M = (sales3/1000000)
Sales4M = (sales4/1000000)
Sales5M = (sales5/1000000)
Sales6M = (sales6/1000000)
Sales7M = (sales7/1000000)
Sales8M = (sales8/1000000)
Sales9M = (sales9/1000000)
Sales10M = (sales10/1000000)
Sales11M = (sales11/1000000)
// If sales > 1000M we want it to be display in $Bil
if(sales >= 10000000000)
Sales0M := (sales /1000000000)
Sales1M := (sales1/1000000000)
Sales2M := (sales2/1000000000)
Sales3M := (sales3/1000000000)
Sales4M := (sales4/1000000000)
Sales5M := (sales5/1000000000)
Sales6M := (sales6/1000000000)
Sales7M := (sales7/1000000000)
Sales8M := (sales8/1000000000)
Sales9M := (sales9/1000000000)
Sales10M := (sales10/1000000000)
Sales11M := (sales11/1000000000)
// === TABLE FUNCTIONS === (Used for cells completion)
// Each function changes the display format in the cells
f_fillCell(_table, _column, _row, _value) =>
_c_color = i_posColor
_transp = 0
_cellText = str.tostring(_value, '0.00')
if(_cellText == 'NaN')
_cellText := 'N/A'
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// To have one digit after coma for sales
f_fillCell2(_table, _column, _row, _value) =>
_c_color = i_posColor
_transp = 0
_cellText = str.tostring(_value, '0.0')
if(_cellText == 'NaN')
_cellText := 'N/A'
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// For Sales comparison
f_fillCell2SALES(_table, _column, _row, _value, _value1) =>
_c_color = i_posColor
_transp = 0
_cellText1 = str.tostring(_value, '0.0')
_cellText2 = str.tostring(_value1,'0.0')
if(_cellText1 == 'NaN')
_cellText1 := 'N/A'
if(_cellText2 == 'NaN')
_cellText2 := 'N/A'
_cellText = _cellText1 + ' vs ' + _cellText2
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// EPS comparison (Only used to compare EPS for calculation with a 'if' further)
f_fillCellEPS(_table, _column, _row, _value, _value1) =>
_c_color = i_posColor
_transp = 0
_cellText1 = str.tostring(_value, '0.00')
_cellText2 = str.tostring(_value1,'0.00')
if(_cellText1 == 'NaN')
_cellText1 := 'N/A'
if(_cellText2 == 'NaN')
_cellText2 := 'N/A'
_cellText = _cellText1 + ' vs ' + _cellText2
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
f_fillCellComp(_table, _column, _row, _value) =>
_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = 0
// Recent modification made that I need to put the IBD/MarketSmith limitaton of +999% here
_cellText = _value > 999 ? '+999%': _value < -999 ? '-999%' :_value > 0 ? '+' + str.tostring(_value, '0') + '%':str.tostring(_value, '0') + '%'
if(_cellText == 'NaN%')
_cellText := 'N/A'
if(_cellText == '+0%')
_cellText := '0%'
if(_value == EpsChangeHash0)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
if(_value == EpsChangeHash1)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
if(_value == EpsChangeHash2)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
if(_value == EpsChangeHash3)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
if(_value == EpsChangeHash4)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
if(_value == EpsChangeHash5)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
if(_value == EpsChangeHash6)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
if(_value == EpsChangeHash7)
_cellText := _value > 999 ? '#+999%': _value < -999 ? '#-999%' : _value > 0 ? '#' + '+' + str.tostring(_value, '0') + '%':'#' + str.tostring(_value, '0') + '%'
// Color for even or odd row
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=_cellText=='0%' or _cellText=='N/A'?i_RowAndColumnTextColor:_c_color,text_size=i_tableSize)
// FOR %SURPRISES
f_fillCellCompSurp(_table, _column, _row, _value) =>
_c_color = _value >= 0 ? i_posSurp : i_negSurp
_transp = 0
// Recent modification made that I need to put the IBD/MarketSmith limitaton of +999% here
_cellText = _value > 999 ? '+999%': _value < -999 ? '-999%' :_value > 0 ? '+' + str.tostring(_value, '0') + '%':str.tostring(_value, '0') + '%'
if(_cellText == 'NaN%')
_cellText := 'N/A'
if(_cellText == '+0%')
_cellText := '0%'
// Color for even or odd row
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=_cellText=='0%' or _cellText=='N/A'?i_RowAndColumnTextColor:_c_color,text_size=i_tableSize)
//For QoQ EPS%
f_fillCellComp2(_table, _column, _row, _value) =>
_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = 0
// Recent modification made that I need to put the IBD/MarketSmith limitaton of +999% here
_cellText = _value > 999 ? '+999%':_value < -999 ? '-999%':_value > 0 ? '+' + str.tostring(_value, '0') + '%':str.tostring(_value, '0') + '%'
if(_cellText == 'NaN%')
_cellText := 'N/A'
// Color for even or odd row
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=_cellText=='N/A'? i_RowAndColumnTextColor:_c_color,text_size=i_tableSize)
// Function for Date
f_array(arrayId, val) =>
array.unshift(arrayId, val) // append vale to an array
array.pop(arrayId)
ftdate(_table, _column, _row, _value) =>
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(table_id = _table, column = _column, row = _row, text = _value, bgcolor = myColor, text_color = i_RowAndColumnTextColor, text_size = i_tableSize)
// For Date
var date = array.new_int(datasize)
if rev
f_array(date, time)
// For Daily Table
f_fillCellDa(_table, _column, _row, _value) =>
_c_color = i_posColor
_transp = 0
_cellText = str.tostring(_value, '0.00') + " |"
if(_cellText == 'NaN')
_cellText := 'N/A |'
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// To have one digit after coma for sales
f_fillCell2Da(_table, _column, _row, _value) =>
_c_color = i_posColor
_transp = 0
_cellText = str.tostring(_value, '0.0') + " |"
if(_cellText == 'NaN |')
_cellText := 'N/A |'
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
f_fillCellCompDa(_table, _column, _row, _value) =>
_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = 0
// Recent modification made that I need to put the IBD/MarketSmith limitaton of +999% here
_cellText = _value > 999 ? "+999% |": _value < -999 ? "-999% |" :_value > 0 ? '+' + str.tostring(_value, '0') + "% |":str.tostring(_value, '0') + "% |"
if(_cellText == "NaN% |")
_cellText := "N/A |"
if(_cellText == "+0% |")
_cellText := "0% |"
if(_value == EpsChangeHash0)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
if(_value == EpsChangeHash1)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
if(_value == EpsChangeHash2)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
if(_value == EpsChangeHash3)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
if(_value == EpsChangeHash4)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
if(_value == EpsChangeHash5)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
if(_value == EpsChangeHash6)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
if(_value == EpsChangeHash7)
_cellText := _value > 999 ? "#+999% |": _value < -999 ? "#-999% |" : _value > 0 ? "#" + "+" + str.tostring(_value, "0") + "% |":"#" + str.tostring(_value, "0") + "% |"
// Color for even or odd row
myColor = _row == 10 or _row == 8 or _row == 6 or _row == 4 ? i_resultBackgroundColorOdd:i_resultBackgroundColorEven
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(myColor, 0), text_color=_cellText=="0% |" or _cellText=="N/A |"?i_RowAndColumnTextColor:_c_color,text_size=i_tableSize)
// Function used to master the fill of cells - Weekly Table
condRepeatSameValueAtLastLine = actualEPS==actualEPS1 and standardEPS==standardEPS1 and EPS_Estimate==EPS_Estimate[1] // here I use 'and' instead of 'or' because we want to avoid the display bug of TradingView when the 2 last lines repeat themselves
if barstate.islast and i_tableStyle == "Weekly"
table.set_frame_color( epsTableDa, color.rgb(0,0,0,100))
table.set_border_color(epsTableDa, color.rgb(0,0,0,100))
// EPS DISPLAY
if(i_QoQ == false)
if(i_compare == true)
f_fillCellEPS(epsTable, 1, 10, condRepeatSameValueAtLastLine ? na:EPS,condRepeatSameValueAtLastLine ? na:actualEPS4)
f_fillCellEPS(epsTable, 1, 9, actualEPS1, actualEPS5)
f_fillCellEPS(epsTable, 1, 8, actualEPS2, actualEPS6)
f_fillCellEPS(epsTable, 1, 7, actualEPS3, actualEPS7)
f_fillCellEPS(epsTable, 1, 6, actualEPS4, actualEPS8)
if(i_moreData == false)
f_fillCellEPS(epsTable, 1, 5, actualEPS5, actualEPS9)
f_fillCellEPS(epsTable, 1, 4, actualEPS6, actualEPS10)
f_fillCellEPS(epsTable, 1, 3, actualEPS7, actualEPS11)
if(i_QoQ == true)
if(i_compare == true)
f_fillCellEPS(epsTable, 1, 10, condRepeatSameValueAtLastLine ? na:EPS,condRepeatSameValueAtLastLine ? na:actualEPS1)
f_fillCellEPS(epsTable, 1, 9, actualEPS1, actualEPS2)
f_fillCellEPS(epsTable, 1, 8, actualEPS2, actualEPS3)
f_fillCellEPS(epsTable, 1, 7, actualEPS3, actualEPS4)
f_fillCellEPS(epsTable, 1, 6, actualEPS4, actualEPS5)
if(i_moreData == false)
f_fillCellEPS(epsTable, 1, 5, actualEPS5, actualEPS6)
f_fillCellEPS(epsTable, 1, 4, actualEPS6, actualEPS7)
f_fillCellEPS(epsTable, 1, 3, actualEPS7, actualEPS8)
if(i_compare == false)
f_fillCell(epsTable, 1, 10, condRepeatSameValueAtLastLine ? na:EPS)
f_fillCell(epsTable, 1, 9, actualEPS1)
f_fillCell(epsTable, 1, 8, actualEPS2)
f_fillCell(epsTable, 1, 7, actualEPS3)
f_fillCell(epsTable, 1, 6, actualEPS4)
if(i_moreData == false)
f_fillCell(epsTable, 1, 5, actualEPS5)
f_fillCell(epsTable, 1, 4, actualEPS6)
f_fillCell(epsTable, 1, 3, actualEPS7)
// % CHANGE EPS
if(i_QoQ == false)
if(i_moreData == false)
f_fillCellComp(epsTable, 2, 3, i_alwaysDispP ? EpsChange7:EpsChangeHash7 > EpsChange7 ? EpsChangeHash7:EpsChange7)
f_fillCellComp(epsTable, 2, 4, i_alwaysDispP ? EpsChange6:EpsChangeHash6 > EpsChange6 ? EpsChangeHash6:EpsChange6)
f_fillCellComp(epsTable, 2, 5, i_alwaysDispP ? EpsChange5:EpsChangeHash5 > EpsChange5 ? EpsChangeHash5:EpsChange5)
f_fillCellComp(epsTable, 2, 6, i_alwaysDispP ? EpsChange4:EpsChangeHash4 > EpsChange4 ? EpsChangeHash4:EpsChange4)
f_fillCellComp(epsTable, 2, 7, i_alwaysDispP ? EpsChange3:EpsChangeHash3 > EpsChange3 ? EpsChangeHash3:EpsChange3)
f_fillCellComp(epsTable, 2, 8, i_alwaysDispP ? EpsChange2:EpsChangeHash2 > EpsChange2 ? EpsChangeHash2:EpsChange2)
f_fillCellComp(epsTable, 2, 9, i_alwaysDispP ? EpsChange1:EpsChangeHash1 > EpsChange1 ? EpsChangeHash1:EpsChange1)
f_fillCellComp(epsTable, 2, 10, condRepeatSameValueAtLastLine ? na:i_alwaysDispP ? EpsChange0:EpsChangeHash0 > EpsChange0 ? EpsChangeHash0:EpsChange0)
// % CHANGE EPS QoQ
if(i_QoQ == true)
if(i_moreData == false)
f_fillCellComp2(epsTable, 2, 3, EpsChangeQoQ7)
f_fillCellComp2(epsTable, 2, 4, EpsChangeQoQ6)
f_fillCellComp2(epsTable, 2, 5, EpsChangeQoQ5)
f_fillCellComp2(epsTable, 2, 6, EpsChangeQoQ4)
f_fillCellComp2(epsTable, 2, 7, EpsChangeQoQ3)
f_fillCellComp2(epsTable, 2, 8, EpsChangeQoQ2)
f_fillCellComp2(epsTable, 2, 9, EpsChangeQoQ1)
f_fillCellComp2(epsTable, 2, 10, EpsChangeQoQ0)
// %SURPRISE EPS
if(i_surprises)
if(i_moreData == false)
f_fillCellCompSurp(epsTable, 3, 3, EpsSurprise7)
f_fillCellCompSurp(epsTable, 3, 4, EpsSurprise6)
f_fillCellCompSurp(epsTable, 3, 5, EpsSurprise5)
f_fillCellCompSurp(epsTable, 3, 6, EpsSurprise4)
f_fillCellCompSurp(epsTable, 3, 7, EpsSurprise3)
f_fillCellCompSurp(epsTable, 3, 8, EpsSurprise2)
f_fillCellCompSurp(epsTable, 3, 9, EpsSurprise1)
f_fillCellCompSurp(epsTable, 3, 10, EpsSurprise0)
//SALES DISPLAY
if(i_QoQ == false)
if(i_compare == true)
f_fillCell2SALES(epsTable, 4, 10, condRepeatSameValueAtLastLine ? na:recentEarn and sameSales ? na:Sales0M,condRepeatSameValueAtLastLine ? na:Sales4M)
f_fillCell2SALES(epsTable, 4, 9, Sales1M, Sales5M)
f_fillCell2SALES(epsTable, 4, 8, Sales2M, Sales6M)
f_fillCell2SALES(epsTable, 4, 7, Sales3M, Sales7M)
f_fillCell2SALES(epsTable, 4, 6, Sales4M, Sales8M)
if(i_moreData == false)
f_fillCell2SALES(epsTable, 4, 5, Sales5M, Sales9M )
f_fillCell2SALES(epsTable, 4, 4, Sales6M, Sales10M)
f_fillCell2SALES(epsTable, 4, 3, Sales7M, Sales11M)
if(i_QoQ == true)
if(i_compare == true)
f_fillCell2SALES(epsTable, 4, 10, condRepeatSameValueAtLastLine ? na:recentEarn and sameSales ? na:Sales0M,condRepeatSameValueAtLastLine ? na:Sales1M)
f_fillCell2SALES(epsTable, 4, 9, Sales1M, Sales2M)
f_fillCell2SALES(epsTable, 4, 8, Sales2M, Sales3M)
f_fillCell2SALES(epsTable, 4, 7, Sales3M, Sales4M)
f_fillCell2SALES(epsTable, 4, 6, Sales4M, Sales5M)
if(i_moreData == false)
f_fillCell2SALES(epsTable, 4, 5, Sales5M, Sales6M)
f_fillCell2SALES(epsTable, 4, 4, Sales6M, Sales7M)
f_fillCell2SALES(epsTable, 4, 3, Sales7M, Sales8M)
// SALES Normal
if(i_compare == false)
f_fillCell2(epsTable, 4, 10, condRepeatSameValueAtLastLine ? na:recentEarn and sameSales ? na:Sales0M)
f_fillCell2(epsTable, 4, 9, Sales1M)
f_fillCell2(epsTable, 4, 8, Sales2M)
f_fillCell2(epsTable, 4, 7, Sales3M)
f_fillCell2(epsTable, 4, 6, Sales4M)
if(i_moreData == false)
f_fillCell2(epsTable, 4, 5, Sales5M)
f_fillCell2(epsTable, 4, 4, Sales6M)
f_fillCell2(epsTable, 4, 3, Sales7M)
// % CHANGE SALES YOY
if(i_QoQ == false)
if(i_moreData == false)
f_fillCellComp(epsTable, 5, 3, salesChange7)
f_fillCellComp(epsTable, 5, 4, salesChange6)
f_fillCellComp(epsTable, 5, 5, salesChange5)
f_fillCellComp(epsTable, 5, 6, salesChange4)
f_fillCellComp(epsTable, 5, 7, salesChange3)
f_fillCellComp(epsTable, 5, 8, salesChange2)
f_fillCellComp(epsTable, 5, 9, salesChange1)
f_fillCellComp(epsTable, 5, 10, condRepeatSameValueAtLastLine ? na:recentEarn and sameSales ? na:salesChange0)
if(i_QoQ == true)
if(i_moreData == false)
f_fillCellComp(epsTable, 5, 3, salesChangeQoQ7)
f_fillCellComp(epsTable, 5, 4, salesChangeQoQ6)
f_fillCellComp(epsTable, 5, 5, salesChangeQoQ5)
f_fillCellComp(epsTable, 5, 6, salesChangeQoQ4)
f_fillCellComp(epsTable, 5, 7, salesChangeQoQ3)
f_fillCellComp(epsTable, 5, 8, salesChangeQoQ2)
f_fillCellComp(epsTable, 5, 9, salesChangeQoQ1)
f_fillCellComp(epsTable, 5, 10, condRepeatSameValueAtLastLine ? na:recentEarn and sameSales ? na:salesChangeQoQ0)
// %SURPRISE SALES
if(i_surprises)
if(i_moreData == false)
f_fillCellCompSurp(epsTable, 6, 3, SalesSurprise7)
f_fillCellCompSurp(epsTable, 6, 4, SalesSurprise6)
f_fillCellCompSurp(epsTable, 6, 5, SalesSurprise5)
f_fillCellCompSurp(epsTable, 6, 6, SalesSurprise4)
f_fillCellCompSurp(epsTable, 6, 7, SalesSurprise3)
f_fillCellCompSurp(epsTable, 6, 8, SalesSurprise2)
f_fillCellCompSurp(epsTable, 6, 9, SalesSurprise1)
f_fillCellCompSurp(epsTable, 6, 10, SalesSurprise0)
// GROSS MARGIN
if(i_grossMargin == true)
if(i_moreData == false)
f_fillCellComp(epsTable, 7, 3, GM7)
f_fillCellComp(epsTable, 7, 4, GM6)
f_fillCellComp(epsTable, 7, 5, GM5)
f_fillCellComp(epsTable, 7, 6, GM4)
f_fillCellComp(epsTable, 7, 7, GM3)
f_fillCellComp(epsTable, 7, 8, GM2)
f_fillCellComp(epsTable, 7, 9, GM1)
f_fillCellComp(epsTable, 7, 10, GM0)
// ROE
if(i_ROE == true)
if(i_moreData == false)
f_fillCellComp(epsTable, 8, 3, ROE7)
f_fillCellComp(epsTable, 8, 4, ROE6)
f_fillCellComp(epsTable, 8, 5, ROE5)
f_fillCellComp(epsTable, 8, 6, ROE4)
f_fillCellComp(epsTable, 8, 7, ROE3)
f_fillCellComp(epsTable, 8, 8, ROE2)
f_fillCellComp(epsTable, 8, 9, ROE1)
f_fillCellComp(epsTable, 8, 10, ROE0)
// For Date MMM-yy
for i = 0 to datasize-blankUnderUp
if barstate.islast
ftdate(epsTable, 0, (datasize-i), str.format('{0, date, MMM-yy}', array.get(date, i)))
//Headings of Weekly Table
txt6 = i_QoQ ? "%Chg QoQ ":" %Chg "
txt8 = "Quarterly "
txt9 = " EPS($) "
txt10 = " Sales($Mil) "
if(sales >= 10000000000)
txt10 := " Sales($Bil) "
txt11 = i_QoQ ? "%Chg QoQ":" %Chg "
txt12 = " GM "
txt13 = " ROE "
txt14 = "%Surp "
// Side Column
table.cell(epsTable,2,0, text=txt6, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
if(i_QoQ == true)
table.cell(epsTable,2,0, text=txt6, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTable,0,0, text=txt8, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTable,1,0, text=txt9, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
//SALES HEADING
table.cell(epsTable,4,0, text=txt10, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTable,5,0, text=txt11, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
//GROSS MARGIN (table, line, row, txt..)
if(i_grossMargin == true)
table.cell(epsTable,7,0, text=txt12, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// ROE
if(i_ROE == true)
table.cell(epsTable,8,0, text=txt13, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// //Surprise
if(i_surprises)
table.cell(epsTable,3,0, text=txt14, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTable,6,0, text=txt14, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// Layout Weekly Table
// Date
if(not i_moreData)
for i = 3 to 5
for x = 0 to 2
table.cell_set_text_halign(epsTable, x, i, text_halign = text.align_right)
for x = 4 to 5
table.cell_set_text_halign(epsTable, x, i, text_halign = text.align_right)
for i = 6 to 10
for x = 0 to 2
table.cell_set_text_halign(epsTable, x, i, text_halign = text.align_right)
for x = 4 to 5
table.cell_set_text_halign(epsTable, x, i, text_halign = text.align_right)
// Align surprises
if(i_surprises)
if(not i_moreData)
for i = 3 to 5
table.cell_set_text_halign(epsTable, 3, i, text_halign = text.align_right)
table.cell_set_text_halign(epsTable, 6, i, text_halign = text.align_right)
for i = 6 to 10
table.cell_set_text_halign(epsTable, 3, i, text_halign = text.align_right)
table.cell_set_text_halign(epsTable, 6, i, text_halign = text.align_right)
// Align GM
if(i_grossMargin)
if(not i_moreData)
for i = 3 to 5
table.cell_set_text_halign(epsTable, 7, i, text_halign = text.align_right)
for i = 6 to 10
table.cell_set_text_halign(epsTable, 7, i, text_halign = text.align_right)
// Align ROE
if(i_ROE)
if(not i_moreData)
for i = 3 to 5
table.cell_set_text_halign(epsTable, 8, i, text_halign = text.align_right)
for i = 6 to 10
table.cell_set_text_halign(epsTable, 8, i, text_halign = text.align_right)
if barstate.islast and i_tableStyle == "Daily"
table.set_frame_color( epsTable, color.rgb(0,0,0,100))
table.set_border_color(epsTable, color.rgb(0,0,0,100))
// DISPLAY of the Daily Table **************************************************************************************
// Date
if(not i_tableBorder)
ftdate(epsTableDa, 12, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 0)) + " │")
ftdate(epsTableDa, 8, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 1)) + " │")
ftdate(epsTableDa, 4, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 2)) + " │")
ftdate(epsTableDa, 0, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 3)) + " │")
else
ftdate(epsTableDa, 12, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 0)) + " ")
ftdate(epsTableDa, 8, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 1)) + " ")
ftdate(epsTableDa, 4, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 2)) + " ")
ftdate(epsTableDa, 0, 0, " Qtr Ended " + str.format('{0, date,MMMMMMMMM dd, yyyy}', array.get(date, 3)) + " ")
table.cell(epsTableDa, 16, 0, text="EPS Due ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor ,text_size=i_tableSize)
// EPS 1
f_fillCell(epsTableDa, 12, 1, condRepeatSameValueAtLastLine ? na:EPS)
f_fillCell(epsTableDa, 8, 1, actualEPS1)
f_fillCell(epsTableDa, 4, 1, actualEPS2)
f_fillCell(epsTableDa, 0, 1, actualEPS3)
// vs
table.cell(epsTableDa, 13,1, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa, 9 ,1, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa, 5 ,1, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa, 1 ,1, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// EPS2
f_fillCell(epsTableDa, 14, 1, condRepeatSameValueAtLastLine ? na:actualEPS4)
f_fillCell(epsTableDa, 10, 1, actualEPS5)
f_fillCell(epsTableDa, 6, 1, actualEPS6)
f_fillCell(epsTableDa, 2, 1, actualEPS7)
// EPS%
if(not i_tableBorder)
f_fillCellCompDa(epsTableDa, 15, 1, condRepeatSameValueAtLastLine ? na:i_alwaysDispP ? EpsChange0:EpsChangeHash0 > EpsChange0 ? EpsChangeHash0:EpsChange0)
f_fillCellCompDa(epsTableDa, 11, 1, i_alwaysDispP ? EpsChange1:EpsChangeHash1 > EpsChange1 ? EpsChangeHash1:EpsChange1)
f_fillCellCompDa(epsTableDa, 7, 1, i_alwaysDispP ? EpsChange2:EpsChangeHash2 > EpsChange2 ? EpsChangeHash2:EpsChange2)
f_fillCellCompDa(epsTableDa, 3, 1, i_alwaysDispP ? EpsChange3:EpsChangeHash3 > EpsChange3 ? EpsChangeHash3:EpsChange3)
else
f_fillCellComp(epsTableDa, 15, 1, condRepeatSameValueAtLastLine ? na:i_alwaysDispP ? EpsChange0:EpsChangeHash0 > EpsChange0 ? EpsChangeHash0:EpsChange0)
f_fillCellComp(epsTableDa, 11, 1, i_alwaysDispP ? EpsChange1:EpsChangeHash1 > EpsChange1 ? EpsChangeHash1:EpsChange1)
f_fillCellComp(epsTableDa, 7, 1, i_alwaysDispP ? EpsChange2:EpsChangeHash2 > EpsChange2 ? EpsChangeHash2:EpsChange2)
f_fillCellComp(epsTableDa, 3, 1, i_alwaysDispP ? EpsChange3:EpsChangeHash3 > EpsChange3 ? EpsChangeHash3:EpsChange3)
// Sales 1
f_fillCell2(epsTableDa, 12, 2, condRepeatSameValueAtLastLine ? na:(EPSTime or EPSTime[1]) and sameSales ? na:Sales0M)
f_fillCell2(epsTableDa, 8, 2, Sales1M)
f_fillCell2(epsTableDa, 4, 2, Sales2M)
f_fillCell2(epsTableDa, 0, 2, Sales3M)
// vs
table.cell(epsTableDa, 13, 2, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa, 9 , 2, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa, 5 , 2, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa, 1 , 2, text=" vs ", bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// Sales 2
f_fillCell2(epsTableDa, 14, 2, condRepeatSameValueAtLastLine ? na:Sales4M)
f_fillCell2(epsTableDa, 10, 2, Sales5M)
f_fillCell2(epsTableDa, 6, 2, Sales6M)
f_fillCell2(epsTableDa, 2, 2, Sales7M)
// Sales%
if (not i_tableBorder)
f_fillCellCompDa(epsTableDa, 15, 2, condRepeatSameValueAtLastLine ? na:(EPSTime or EPSTime[1]) and sameSales ? na:salesChange0)
f_fillCellCompDa(epsTableDa, 11, 2, salesChange1)
f_fillCellCompDa(epsTableDa, 7, 2, salesChange2)
f_fillCellCompDa(epsTableDa, 3, 2, salesChange3)
else
f_fillCellComp(epsTableDa, 15, 2, condRepeatSameValueAtLastLine ? na:(EPSTime or EPSTime[1]) and sameSales ? na:salesChange0)
f_fillCellComp(epsTableDa, 11, 2, salesChange1)
f_fillCellComp(epsTableDa, 7, 2, salesChange2)
f_fillCellComp(epsTableDa, 3, 2, salesChange3)
// ROE
if (i_ROE == true)
if(not i_tableBorder)
f_fillCellCompDa(epsTableDa, 15, 3, ROE0)
f_fillCellCompDa(epsTableDa, 11, 3, ROE1)
f_fillCellCompDa(epsTableDa, 7, 3, ROE2)
f_fillCellCompDa(epsTableDa, 3, 3, ROE3)
else
f_fillCellComp(epsTableDa, 15, 3, ROE0)
f_fillCellComp(epsTableDa, 11, 3, ROE1)
f_fillCellComp(epsTableDa, 7, 3, ROE2)
f_fillCellComp(epsTableDa, 3, 3, ROE3)
if (i_grossMargin)
if(not i_tableBorder)
f_fillCellCompDa(epsTableDa, 15, 3, GM0)
f_fillCellCompDa(epsTableDa, 11, 3, GM1)
f_fillCellCompDa(epsTableDa, 7, 3, GM2)
f_fillCellCompDa(epsTableDa, 3, 3, GM3)
else
f_fillCellComp(epsTableDa, 15, 3, GM0)
f_fillCellComp(epsTableDa, 11, 3, GM1)
f_fillCellComp(epsTableDa, 7, 3, GM2)
f_fillCellComp(epsTableDa, 3, 3, GM3)
// Heandings For Daily Table
txt20 = "Sales ($Mil)"
if(sales >= 10000000000)
txt20 := "Sales ($Bil)"
txt21 = ""
if(i_ROE)
txt21 := "Return on Equity"
if(i_grossMargin)
txt21 := "Gross Margin"
// Data for Daily Table
table.cell(epsTableDa,16,1, text="Earnings ($) ", bgcolor=color.white, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa,16,2, text=txt20, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
table.cell(epsTableDa,16,3, text=txt21, bgcolor=i_resultBackgroundColorOdd, text_color=i_RowAndColumnTextColor,text_size=i_tableSize)
// Change BG Colors of all the table
for i = 0 to 16
for x = 0 to 3
table.cell_set_bgcolor(epsTableDa, i, x, i_resultBackgroundColorOdd)
// Text Align
// EPS and Sales at the left
table.cell_set_text_halign(epsTableDa, 0, 1, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 0, 2, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 4, 1, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 4, 2, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 8, 1, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 8, 2, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 12, 1, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 12, 2, text_halign = text.align_left)
// % figures
table.cell_set_text_halign(epsTableDa, 3, 1, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 3, 2, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 3, 3, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 7, 1, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 7, 2, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 7, 3, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 11, 1, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 11, 2, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 11, 3, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 15, 1, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 15, 2, text_halign = text.align_right)
table.cell_set_text_halign(epsTableDa, 15, 3, text_halign = text.align_right)
// Earnings info
table.cell_set_text_halign(epsTableDa, 16, 1, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 16, 2, text_halign = text.align_left)
table.cell_set_text_halign(epsTableDa, 16, 3, text_halign = text.align_left)
// Merge Cell
table.merge_cells(epsTableDa, 0, 0, 3, 0)
table.merge_cells(epsTableDa, 4, 0, 7, 0)
table.merge_cells(epsTableDa, 8, 0, 11, 0)
table.merge_cells(epsTableDa, 12, 0, 15, 0)
// Diplay Arrow on the graph with % variation EPS
selectEPS = ta.valuewhen(EPSTime, EpsChangeHash0, 0) > ta.valuewhen(EPSTime, EpsChange0, 0) // Time for Sales annoucement
EPSvalue = selectEPS ? ta.valuewhen(EPSTime, EpsChangeHash0, 0):ta.valuewhen(EPSTime, EpsChange0, 0)
salesValue = ta.valuewhen(EPSTime, salesChange0, 0) // Select the value of % sales change for the date of the arrow
//plotshape(EPSTime, style=shape.triangleup, color=color.new(color.silver, 0), location=location.bottom, size=size.tiny, text="", textcolor = color.white)
textLayout1 = i_salesOnGraph ? 'EPS & Sales':'EPS'
textLayout2 = EPSvalue > 999 ? '\n+999%':EPSvalue > 0 ? '\n+' + str.tostring(EPSvalue, '0') + '%':'\n' + str.tostring(EPSvalue, '0') + '%'
if(textLayout2 == '\nNaN%')
textLayout2 := '\nN/A'
if(textLayout2 == '\n+0%')
textLayout2 := '\n0%'
textLayout4 = (EPSTime or EPSTime[1]) and sameSales and barstate.islast ? 'NaN%':salesChange0 > 999 ? '+999%':salesChange0 > 0 ? '+' + str.tostring(salesChange0, '0') + '%':str.tostring(salesChange0, '0') + '%' // For Sales
if(textLayout4 == 'NaN%')
textLayout4 := 'N/A'
if(textLayout4 == '+0%')
textLayout4 := '0%'
// Here we check if we have to plot sales or not, depending on the result we display appropriate variables
if(EPSTime and i_ArrowOnGraph)
label1 = label.new(bar_index, bar_index, xloc=xloc.bar_index, yloc=yloc.belowbar, text=textLayout1, style=label.style_triangleup, color=color.new(color.aqua,100), textcolor=i_arrowColor, size=i_arrowSize)
if(not i_salesOnGraph)
label2 = label.new(bar_index, low, xloc=xloc.bar_index, yloc=yloc.belowbar, text=textLayout2, style=label.style_triangleup, color=i_arrowColor, textcolor=textLayout2=='\nN/A' or textLayout2=='\n0%' ? i_arrowColor:EPSvalue > -1 ? i_posArrowColor:i_negArrowColor, size=i_arrowSize)
if(i_salesOnGraph)
label2 = label.new(bar_index, low, xloc=xloc.bar_index, yloc=yloc.belowbar, text=textLayout2+' | '+textLayout4, style=label.style_triangleup, color=i_arrowColor, textcolor=textLayout2=='\nN/A' or textLayout2=='\n0%' ? i_arrowColor:EPSvalue > -1 ? i_posArrowColor:i_negArrowColor, size=i_arrowSize)
// Test for better arrow display but now the space between arrows and text isn't fix...
// offsetArrow = ta.lowest(low*0.85, 4) // Get the Lowest low of the 4 previous bars for correct diplay even in case of earning gap up
// if(EPSTime and i_ArrowOnGraph)
// label1 = label.new(bar_index, offsetArrow, xloc=xloc.bar_index, yloc=yloc.price, text="", style=label.style_triangleup, color=i_arrowColor, textcolor=i_arrowColor, size=i_arrowSize)
// label1Eps = label.new(bar_index, offsetArrow*0.85, xloc=xloc.bar_index, yloc=yloc.price, text=textLayout1, style=label.style_triangleup, color=color.new(color.aqua,100), textcolor=i_arrowColor, size=i_arrowSize)
// if(not i_salesOnGraph)
// label2 = label.new(bar_index, offsetArrow*0.81, xloc=xloc.bar_index, yloc=yloc.price, text=textLayout2, style=label.style_triangleup, color=color.new(color.aqua,100), textcolor=textLayout2=='\nN/A' or textLayout2=='\n0%' ? i_arrowColor:EPSvalue > -1 ? i_posArrowColor:i_negArrowColor, size=i_arrowSize)
// if(i_salesOnGraph)
// label2 = label.new(bar_index, offsetArrow*0.81, xloc=xloc.bar_index, yloc=yloc.price, text=textLayout2+' | '+textLayout4, style=label.style_triangleup, color=color.new(color.aqua,100), textcolor=textLayout2=='\nN/A' or textLayout2=='\n0%' ? i_arrowColor:EPSvalue > -1 ? i_posArrowColor:i_negArrowColor, size=i_arrowSize) |
Trend Momentum Divergence (TMD) | https://www.tradingview.com/script/FJq2emDF-Trend-Momentum-Divergence-TMD/ | Ian94patrick32 | https://www.tradingview.com/u/Ian94patrick32/ | 68 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Shout out to a few people for there script code to work with.
//@version=5
indicator(title='Trend Momentum Divergence', shorttitle='TMD', timeframe='')
// PVSRA
// From MT4 source:
// Situation "Climax"
// Bars with volume >= 200% of the average volume of the 10 previous chart TFs, and bars
// where the product of candle spread x candle volume is >= the highest for the 10 previous
// chart time TFs.
// Default Colors: Bull bars are green and bear bars are red.
// Situation "Volume Rising Above Average"
// Bars with volume >= 150% of the average volume of the 10 previous chart TFs.
// Default Colors: Bull bars are blue and bear are blue-violet.
// We want to be able to override where we get the volume data for the candles.
bool overridesym = input(title='Override chart symbol?', defval=false)
string pvsra_sym = input.symbol(title='Symbol', defval='INDEX:BTCUSD')
bool setcandlecolors = input(true, title='Set PVSRA candle colors?')
pvsra_security(sresolution, sseries) =>
request.security(overridesym ? pvsra_sym : syminfo.tickerid, sresolution, sseries[barstate.isrealtime ? 1 : 0], barmerge.gaps_off, barmerge.lookahead_off)
pvsra_security_1 = pvsra_security('', volume)
pvsra_volume = overridesym == true ? pvsra_security_1 : volume
pvsra_security_2 = pvsra_security('', high)
pvsra_high = overridesym == true ? pvsra_security_2 : high
pvsra_security_3 = pvsra_security('', low)
pvsra_low = overridesym == true ? pvsra_security_3 : low
pvsra_security_4 = pvsra_security('', close)
pvsra_close = overridesym == true ? pvsra_security_4 : close
pvsra_security_5 = pvsra_security('', open)
pvsra_open = overridesym == true ? pvsra_security_5 : open
//label.new(overridesym ? 0 : na, low, text = "PVSRA Override: " + pvsra_sym, xloc = xloc.bar_index, yloc=yloc.belowbar,style=label.style_label_down, size=size.huge)
// The below math matches MT4 PVSRA indicator source
// average volume from last 10 candles
sum_1 = math.sum(pvsra_volume, 10)
sum_2 = math.sum(volume, 10)
av = overridesym == true ? sum_1 / 10 : sum_2 / 10
//climax volume on the previous candle
value2 = overridesym == true ? pvsra_volume * (pvsra_high - pvsra_low) : volume * (high - low)
// highest climax volume of the last 10 candles
hivalue2 = ta.highest(value2, 10)
// VA value determines the bar color. va = 0: normal. va = 1: climax. va = 2: rising
iff_1 = pvsra_volume >= av * 1.5 ? 2 : 0
iff_2 = pvsra_volume >= av * 2 or value2 >= hivalue2 ? 1 : iff_1
iff_3 = volume >= av * 1.5 ? 2 : 0
iff_4 = volume >= av * 2 or value2 >= hivalue2 ? 1 : iff_3
va = overridesym == true ? iff_2 : iff_4
// Bullish or bearish coloring
isBull = overridesym == true ? pvsra_close > pvsra_open : close > open
CUColor = color.lime // Climax up (bull) bull and bear both start with b so it would be weird hence up down
CDColor = color.red // Climax down (bear)
AUColor = color.blue //Avobe average up (bull)
ADColor = color.fuchsia //Above average down (bear))
NUColor = #999999
NDColor = #4d4d4d
// candleColor = iff(climax,iff(isBull,CUColor,CDColor),iff(aboveA,iff(isBull,AUColor,ADColor),iff(isBull,NUColor,NDColor)))
iff_5 = va == 2 ? AUColor : NUColor
iff_6 = va == 1 ? CUColor : iff_5
iff_7 = va == 2 ? ADColor : NDColor
iff_8 = va == 1 ? CDColor : iff_7
candleColor = isBull ? iff_6 : iff_8
barcolor(setcandlecolors ? candleColor : na)
plot(pvsra_volume, style=plot.style_columns, linewidth=1, color=candleColor)
alertcondition(va > 0, title='Alert on Vector Candle', message='{{ticker}} Vector Candle on the {{interval}}')
grad(src)=>
color out = switch int(src)
0 => color.new(#1500FF , 20)
1 => color.new(#1709F6 , 20)
2 => color.new(#1912ED , 20)
3 => color.new(#1B1AE5 , 20)
4 => color.new(#1D23DC , 20)
5 => color.new(#1F2CD3 , 20)
6 => color.new(#2135CA , 20)
7 => color.new(#233EC1 , 20)
8 => color.new(#2446B9 , 20)
9 => color.new(#264FB0 , 20)
10 => color.new(#2858A7 , 20)
11 => color.new(#2A619E , 20)
12 => color.new(#2C6A95 , 20)
13 => color.new(#2E728D , 20)
14 => color.new(#307B84 , 20)
15 => color.new(#32847B , 20)
16 => color.new(#348D72 , 20)
17 => color.new(#36956A , 20)
18 => color.new(#389E61 , 20)
19 => color.new(#3AA758 , 20)
20 => color.new(#3CB04F , 20)
21 => color.new(#3EB946 , 20)
22 => color.new(#3FC13E , 20)
23 => color.new(#41CA35 , 20)
24 => color.new(#43D32C , 20)
25 => color.new(#45DC23 , 20)
26 => color.new(#47E51A , 20)
27 => color.new(#49ED12 , 20)
28 => color.new(#4BF609 , 20)
29 => color.new(#4DFF00 , 20)
30 => color.new(#53FF00 , 20)
31 => color.new(#59FF00 , 20)
32 => color.new(#5FFE00 , 20)
33 => color.new(#65FE00 , 20)
34 => color.new(#6BFE00 , 20)
35 => color.new(#71FE00 , 20)
36 => color.new(#77FD00 , 20)
37 => color.new(#7DFD00 , 20)
38 => color.new(#82FD00 , 20)
39 => color.new(#88FD00 , 20)
40 => color.new(#8EFC00 , 20)
41 => color.new(#94FC00 , 20)
42 => color.new(#9AFC00 , 20)
43 => color.new(#A0FB00 , 20)
44 => color.new(#A6FB00 , 20)
45 => color.new(#ACFB00 , 20)
46 => color.new(#B2FB00 , 20)
47 => color.new(#B8FA00 , 20)
48 => color.new(#BEFA00 , 20)
49 => color.new(#C4FA00 , 20)
50 => color.new(#CAF900 , 20)
51 => color.new(#D0F900 , 20)
52 => color.new(#D5F900 , 20)
53 => color.new(#DBF900 , 20)
54 => color.new(#E1F800 , 20)
55 => color.new(#E7F800 , 20)
56 => color.new(#EDF800 , 20)
57 => color.new(#F3F800 , 20)
58 => color.new(#F9F700 , 20)
59 => color.new(#FFF700 , 20)
60 => color.new(#FFEE00 , 20)
61 => color.new(#FFE600 , 20)
62 => color.new(#FFDE00 , 20)
63 => color.new(#FFD500 , 20)
64 => color.new(#FFCD00 , 20)
65 => color.new(#FFC500 , 20)
66 => color.new(#FFBD00 , 20)
67 => color.new(#FFB500 , 20)
68 => color.new(#FFAC00 , 20)
69 => color.new(#FFA400 , 20)
70 => color.new(#FF9C00 , 20)
71 => color.new(#FF9400 , 20)
72 => color.new(#FF8C00 , 20)
73 => color.new(#FF8300 , 20)
74 => color.new(#FF7B00 , 20)
75 => color.new(#FF7300 , 20)
76 => color.new(#FF6B00 , 20)
77 => color.new(#FF6200 , 20)
78 => color.new(#FF5A00 , 20)
79 => color.new(#FF5200 , 20)
80 => color.new(#FF4A00 , 20)
81 => color.new(#FF4200 , 20)
82 => color.new(#FF3900 , 20)
83 => color.new(#FF3100 , 20)
84 => color.new(#FF2900 , 20)
85 => color.new(#FF2100 , 20)
86 => color.new(#FF1900 , 20)
87 => color.new(#FF1000 , 20)
88 => color.new(#FF0800 , 20)
89 => color.new(#FF0000 , 20)
90 => color.new(#F60000 , 20)
91 => color.new(#DF0505 , 20)
92 => color.new(#C90909 , 20)
93 => color.new(#B20E0E , 20)
94 => color.new(#9B1313 , 20)
95 => color.new(#851717 , 20)
96 => color.new(#6E1C1C , 20)
97 => color.new(#572121 , 20)
98 => color.new(#412525 , 20)
99 => color.new(#2A2A2A , 20)
100 => color.new(#220027 , 20)
out
filter(float src, int len) =>
var float filter = na
filter := ta.cum((src + (src[1] * 2) + (src[2] * 2) + src[3])/6)
(filter - filter[len])/len
rsi(src, len) =>
RSI = ta.rsi(filter(src, 1), len)
f = -math.pow(math.abs(math.abs(RSI - 50) - 50), 1 + math.pow(len / 14, 0.618) - 1) / math.pow(50, math.pow(len / 14, 0.618) - 1) + 50
rsia = if RSI > 50
f + 50
else
-f + 50
rsia
length = input.int(8)
RSI = rsi(close, length)
barcolor(grad(RSI))
//// Indicators
// Blue Wave
n1 = input.int(9, 'Channel Length', group='Wave Length')
n2 = input.int(12, 'Average Length', group='Wave Length')
ap = ohlc4
esa = ta.ema(ap, n1)
D = ta.ema(math.abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * D)
tci = ta.ema(ci, n2)
wt1 = tci
wt2 = ta.sma(wt1, 3)
// MFI
mfi_upper = math.sum(volume * (ta.change(hlc3) <= 0 ? 0 : hlc3), 58)
mfi_lower = math.sum(volume * (ta.change(hlc3) >= 0 ? 0 : hlc3), 58)
_mfi_rsi(mfi_upper, mfi_lower) =>
if mfi_lower == 0
100
if mfi_upper == 0
0
100.0 - 100.0 / (1.0 + mfi_upper / mfi_lower)
mf = _mfi_rsi(mfi_upper, mfi_lower)
mfi = (mf - 50) * 2.5
//// Plots
mfi_color = mfi > 0 ? #009688 : #9c27b0
dot_color = wt1 < wt2 ? #FF0000 : #4CAF50
plot(wt1, style=plot.style_area, color=color.new(#90caf9, 50), title='Light Wave')
plot(wt2, style=plot.style_area, color=color.new(#2a2e39, 60), title='Dark Wave')
plot(mfi, 'MFI Area', style=plot.style_area, color=color.new(mfi_color, 80), linewidth=2)
plot(mfi, 'MFI Line', style=plot.style_line, color=color.new(#000000, 1.5), linewidth=1)
plot(ta.crossunder(wt1, wt2) or ta.crossover(wt1, wt2) ? wt2 : na, title='Dots', style=plot.style_circles, color=color.new(dot_color, 50), linewidth=2)
bgcolor(color.new(#000000, 80))
//plot
itvm = input(36, 'middle interval')
itvl = input(44, 'long interval')
source = input(close, 'source')
ord(seq, idx, itv) =>
p = seq[idx]
o = 1
s = 0
for i = 0 to itv - 1 by 1
if p < seq[i]
o += 1
o
else
if p == seq[i]
s += 1
o + (s - 1) / 2.0
o
c(itv) =>
sum = 0.0
for i = 0 to itv - 1 by 1
sum += math.pow(i + 1 - ord(source, i, itv), 2)
sum
sum
rci(itv) =>
(1.0 - 6.0 * c(itv) / (itv * (itv * itv - 1.0))) * 100.0
plot(rci(itvm), title='RCI middle', color=color.new(#0000FF, 0))
plot(rci(itvl), title='RCI long', color=color.new(#008000, 0))
src = close
len = input.int(14, title='RSI Length')
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 150 - 320 / (1 + up / down)
sma_f_p = input(defval=9, title='RSI SMA Period')
BBperiod=input(31,title="Bollinger Bands period")
BBpar=input(1.6,title="Bolliger Bands parameter")
h1 = hline(54, color=color.new(#ff0000,50), linestyle=hline.style_dotted, linewidth=1)
h2 = hline(23, color=#434651, linestyle=hline.style_dotted, linewidth=1)
fill (h1, h2, color=color.new(#ff0000, transp=90))
h3 = hline(-10, color=#2a2e39, linestyle=hline.style_dotted, linewidth=1)
h4 = hline(-42, color=color.new(#00e600,50), linestyle=hline.style_dotted, linewidth=1)
fill (h3, h4, color=color.new(#0e6000, transp=90))
h5 = hline(80, color=#434651, linestyle=hline.style_dotted, linewidth=1)
sma_rsi = ta.sma(rsi, sma_f_p)
dev =ta.stdev(rsi,BBperiod)
cband=ta.sma(rsi,BBperiod)
uband=cband+BBpar*dev
lband=cband-BBpar*dev
psma = plot(sma_rsi, title='RSI-SMA', color=color.new(#ff9800, 15), style=plot.style_line, linewidth=2)
plot(uband, "Upper Band", color=color.new(#2a2e39,0),linewidth=1)
plot(cband, "Middle Band", color=color.new(#363a55,0),linewidth=1)
plot(lband, "Lower Band", color=color.new(#2a2e39,0),linewidth=1)
plot(rsi, color=color.new(#d1d4dc, 35), linewidth=2, title='RSI')
smoothK = input.int(3, "K", minval=1)
smoothD = input.int(3, "D", minval=1)
lengthRSI = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
Src = input(close, title="RSI Source")
rsi1 = ta.rsi(Src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
plot(k, "K", color=color.new(#2962FF,40))
plot(d, "D", color=color.new(#FF6D00,40))
|
Grid Settings & MM | https://www.tradingview.com/script/xeum1H1r-grid-settings-mm/ | avgtrade | https://www.tradingview.com/u/avgtrade/ | 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/
// © avgtrade
//@version=5
indicator("Grid Settings & MM", overlay = true, max_labels_count = 5)
// << INPUT >>
// vvvvvvvvvvvv
// repaintInput = input.bool(false, "Position bars in the past")
HIGH = input.float(defval = 0.328, title = 'HighPrice')
LOW = input.float(defval = 0.215, title = 'LowPrice')
BALANCE = input.float(defval = 1000.00, title = 'Deposit')
GRIDS = input.int(defval = 5, title = 'Grids')
STEPS = input.int(defval = 5, title = 'Steps')
ORDER_COEF = input.float(defval = 1.2, title = 'c_Order')
PRICE_COEF = input.float(defval = 1.1, title = 'c_Price')
FIRST_LEVEL = input.float(defval = 0.5, title = 'FirstLevel')
BACK_HL = input.int(defval = 150, minval = 1, title = 'Back_H/L')
exp_steps = ORDER_COEF
if STEPS == 1
exp_steps := ORDER_COEF
if STEPS == 2
exp_steps := ORDER_COEF * ORDER_COEF
if STEPS == 3
exp_steps := ORDER_COEF * ORDER_COEF * ORDER_COEF
if STEPS == 4
exp_steps := ORDER_COEF * ORDER_COEF * ORDER_COEF * ORDER_COEF
if STEPS == 5
exp_steps := ORDER_COEF * ORDER_COEF * ORDER_COEF * ORDER_COEF * ORDER_COEF
hi = ta.highest(BACK_HL)
newHi = ta.change(hi)
highestBarOffset = - ta.highestbars(BACK_HL)
var lbh = label.new(na, na, "", style = label.style_none, textcolor = color.yellow, size = size.normal)
if newHi
labelText = str.tostring(hi, format.mintick)
label.set_xy(lbh, bar_index[highestBarOffset], hi)
label.set_text(lbh, labelText)
//label.set_yloc(lbl, yloc.belowbar)
else
label.set_x(lbh, bar_index[highestBarOffset])
lo = ta.lowest(BACK_HL)
newLo = ta.change(lo)
lowestBarOffset = - ta.lowestbars(BACK_HL)
var lbl = label.new(na, na, "", style = label.style_none, textcolor = color.yellow, size = size.normal)
if newLo
labelText = str.tostring(lo, format.mintick)
label.set_xy(lbl, bar_index[lowestBarOffset] + 5, lo)
label.set_text(lbl, labelText)
//label.set_yloc(lbl, yloc.belowbar)
else
label.set_x(lbl, bar_index[lowestBarOffset] + 5)
// << AO Cross >>
// vvvvvvvvvvvvvvv
aoValue = ta.ema(hl2,5) - ta.ema(hl2,34)
aoDown = ta.crossunder(aoValue, 0)
aoUp = ta.crossover(aoValue, 0)
// << PRICES >>
// vvvvvvvvvvvv
GRID = BALANCE / GRIDS
IMPULSE = (hi/lo-1)*100
FIX = ((HIGH/LOW-1)/2+(1-LOW/HIGH)/2)*50
USD1 = GRID / ((1 - exp_steps) / (1 - ORDER_COEF))
USD2 = USD1 * ORDER_COEF
USD3 = USD2 * ORDER_COEF
USD4 = USD3 * ORDER_COEF
USD5 = USD4 * ORDER_COEF
BUY1 = (HIGH + LOW) * FIRST_LEVEL
BUY2 = BUY1 - BUY1 * PRICE_COEF * FIX / (STEPS - 1) / 100
BUY3 = BUY2 - BUY2 * PRICE_COEF * PRICE_COEF * FIX / (STEPS - 1) / 100
BUY4 = BUY3 - BUY3 * PRICE_COEF * PRICE_COEF * PRICE_COEF * FIX / (STEPS - 1) / 100
BUY5 = BUY4 - BUY4 * PRICE_COEF * PRICE_COEF * PRICE_COEF * PRICE_COEF * FIX / (STEPS - 1) / 100
AMT1 = USD1 / BUY1
AMT2 = USD2 / BUY2
AMT3 = USD3 / BUY3
AMT4 = USD4 / BUY4
AMT5 = USD5 / BUY5
SUM1 = USD1
SUM2 = SUM1 + USD2
SUM3 = SUM2 + USD3
SUM4 = SUM3 + USD4
SUM5 = SUM4 + USD5
QTY1 = AMT1
QTY2 = QTY1 + AMT2
QTY3 = QTY2 + AMT3
QTY4 = QTY3 + AMT4
QTY5 = QTY4 + AMT5
SELL1 = BUY1 + BUY1 * FIX / 100
SELL2 = SUM2 / (QTY2) + SUM2 / (QTY2) * FIX / 100
SELL3 = SUM3 / (QTY3) + SUM3 / (QTY3) * FIX / 100
SELL4 = SUM4 / (QTY4) + SUM4 / (QTY4) * FIX / 100
SELL5 = SUM5 / (QTY5) + SUM5 / (QTY5) * FIX / 100
TP1 = SELL1 * QTY1 - SUM1
TP2 = SELL2 * QTY2 - SUM2
TP3 = SELL3 * QTY3 - SUM3
TP4 = SELL4 * QTY4 - SUM4
TP5 = SELL5 * QTY5 - SUM5
// << DISPLAY >>
// vvvvvvvvvvvvv
var table impulse = table.new(position.top_right, 1, 2)
table.cell(impulse, 0, 0, str.tostring(IMPULSE, '#.##'), text_color = color.yellow, text_size = size.small)
var table grid = table.new(position.bottom_left, 5, 6)
table.cell(grid, 0, 0, "Buy", text_color = color.green, bgcolor = color.black, text_size = size.small)
table.cell(grid, 1, 0, "Amount", text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 2, 0, "Sell", text_color = color.red, bgcolor = color.black, text_size = size.small)
table.cell(grid, 3, 0, "$$$", text_color = color.white, bgcolor = color.black, text_size = size.small)
table.cell(grid, 4, 0, "TP", text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 0, 1, str.tostring(BUY1, format.mintick), text_color = color.green, bgcolor = color.black, text_size = size.small)
table.cell(grid, 0, 2, str.tostring(BUY2, format.mintick), text_color = color.green, bgcolor = color.black, text_size = size.small)
table.cell(grid, 0, 3, str.tostring(BUY3, format.mintick), text_color = color.green, bgcolor = color.black, text_size = size.small)
table.cell(grid, 0, 4, str.tostring(BUY4, format.mintick), text_color = color.green, bgcolor = color.black, text_size = size.small)
table.cell(grid, 0, 5, str.tostring(BUY5, format.mintick), text_color = color.green, bgcolor = color.black, text_size = size.small)
table.cell(grid, 1, 1, str.tostring(AMT1, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 1, 2, str.tostring(AMT2, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 1, 3, str.tostring(AMT3, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 1, 4, str.tostring(AMT4, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 1, 5, str.tostring(AMT5, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 2, 1, str.tostring(SELL1, format.mintick), text_color = color.red, bgcolor = color.black, text_size = size.small)
table.cell(grid, 2, 2, str.tostring(SELL2, format.mintick), text_color = color.red, bgcolor = color.black, text_size = size.small)
table.cell(grid, 2, 3, str.tostring(SELL3, format.mintick), text_color = color.red, bgcolor = color.black, text_size = size.small)
table.cell(grid, 2, 4, str.tostring(SELL4, format.mintick), text_color = color.red, bgcolor = color.black, text_size = size.small)
table.cell(grid, 2, 5, str.tostring(SELL5, format.mintick), text_color = color.red, bgcolor = color.black, text_size = size.small)
table.cell(grid, 3, 1, str.tostring(SUM1, '#.##'), text_color = color.white, bgcolor = color.black, text_size = size.small)
table.cell(grid, 3, 2, str.tostring(SUM2, '#.##'), text_color = color.white, bgcolor = color.black, text_size = size.small)
table.cell(grid, 3, 3, str.tostring(SUM3, '#.##'), text_color = color.white, bgcolor = color.black, text_size = size.small)
table.cell(grid, 3, 4, str.tostring(SUM4, '#.##'), text_color = color.white, bgcolor = color.black, text_size = size.small)
table.cell(grid, 3, 5, str.tostring(SUM5, '#.##'), text_color = color.white, bgcolor = color.black, text_size = size.small)
table.cell(grid, 4, 1, str.tostring(TP1, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 4, 2, str.tostring(TP2, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 4, 3, str.tostring(TP3, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 4, 4, str.tostring(TP4, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
table.cell(grid, 4, 5, str.tostring(TP5, '#.##'), text_color = color.white, bgcolor = color.green, text_size = size.small)
printTable(txt) => var table t = table.new(position.top_left, 1, 1),
table.cell(t, 0, 0, txt, bgcolor = color.black, text_color = color.white, text_size = size.small)
printTable('...\n' +
'Depo = ' + str.tostring(BALANCE) + ' $\n' +
'Grids = ' + str.tostring(GRIDS) + '\n' +
'Grid = ' + str.tostring(GRID, '#.##') + ' $\n' +
'TP = ' + str.tostring(FIX, '#.##') + ' %')
//hiLine = line.new(bar_index - 20, HIGH, bar_index, HIGH, extend = extend.right, color = color.red, style = line.style_solid)
//lowLine = line.new(bar_index - 20, LOW, bar_index, LOW, extend = extend.right, color = color.blue, style = line.style_solid)
//firstLine = line.new(bar_index - 20, BUY1, bar_index, BUY1, extend = extend.right, color = color.green, style = line.style_solid)
//secondLine = line.new(bar_index - 20, BUY2, bar_index, BUY2, extend = extend.right, color = color.green, style = line.style_solid)
//thirdLine = line.new(bar_index - 20, BUY3, bar_index, BUY3, extend = extend.right, color = color.green, style = line.style_solid)
//fourthLine = line.new(bar_index - 20, BUY4, bar_index, BUY4, extend = extend.right, color = color.green, style = line.style_solid)
//fifthLine = line.new(bar_index - 20, BUY5, bar_index, BUY5, extend = extend.right, color = color.green, style = line.style_solid)
//hiLabel = label.new(bar_index + 10, HIGH, text =''+str.tostring(HIGH, format.mintick), style = label.style_none, textcolor = color.red)
//lowLabel = label.new(bar_index + 10, LOW, text =''+str.tostring(LOW, format.mintick), style = label.style_none, textcolor = color.blue)
//firstLabel = label.new(bar_index + 10, BUY1, text =''+str.tostring(BUY1, format.mintick), style = label.style_none, textcolor = color.green)
//secondLabel = label.new(bar_index + 10, BUY2, text =''+ str.tostring(BUY2, format.mintick), style = label.style_none, textcolor = color.green)
//thirdLabel = label.new(bar_index + 10, BUY3, text =''+ str.tostring(BUY3, format.mintick), style = label.style_none, textcolor = color.green)
//fourthLabel = label.new(bar_index + 10, BUY4, text =''+ str.tostring(BUY4, format.mintick), style = label.style_none, textcolor = color.green)
//fifthLabel = label.new(bar_index + 10, BUY5, text = ''+str.tostring(BUY5, format.mintick), style = label.style_none, textcolor = color.green) |
z_score_bgd | https://www.tradingview.com/script/pXI4CbDS-z-score-bgd/ | crashout75 | https://www.tradingview.com/u/crashout75/ | 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/
// © crashout75
//[email protected]
//@version=5
indicator(title = "z_score_bgd", overlay = true)
window = input(99, title="window")
int window2 = na
vSYMBOL = syminfo.ticker
print(txt) =>
// Create label on the first bar.
var lbl = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, color.gray, size.large, text.align_left)
// On next bars, update the label's x and y position, and the text it displays.
label.set_xy(lbl, bar_index, ta.highest(100)[1])
label.set_text(lbl, txt)
window2 := if (vSYMBOL == 'ATOMBTC')
18
else
window2 := if (vSYMBOL == 'AVAXBTC')
21
else
window2 := if (vSYMBOL == 'ETHBTC')
18
else
window2 := if (vSYMBOL == 'FTMBTC')
11
else
window2 := if (vSYMBOL == 'MATICBTC')
11
else
window2 := if (vSYMBOL == 'SOLBTC')
11
else
window2 := if (vSYMBOL == 'SOLETH')
16
else
20
window2 := if (window == 99)
window2
else
window
print("\n" + "(" + str.tostring(window2) + ")")
vSMA = ta.sma(close,window2)
vSTDDEV = ta.stdev(close,window2,true)
vZ = (close-vSMA)/vSTDDEV
bgcolor(vZ < -1 ? color.new(color.green,90):color.new(color.white,100) )
bgcolor(vZ < -2 ? color.new(color.green,80):color.new(color.white,100) )
bgcolor(vZ > 1 ? color.new(color.red,90):color.new(color.white,100) )
bgcolor(vZ > 2 ? color.new(color.red,80):color.new(color.white,100) )
plot(vSMA,color=color.blue) |
SMA Multi Time Frame Table V1.5 | https://www.tradingview.com/script/LnamY9kv-SMA-Multi-Time-Frame-Table-V1-5/ | jbritton001 | https://www.tradingview.com/u/jbritton001/ | 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/
// © jbritton001
// MA MTF v 1.0.9
// script will plot the smas on higher time frames
// Added Table
// Colored the MAs to make the plot colors
// fixed some floating issues .. along with corrected some request.security issues
// added XY code to where the table can be moved around
// fixed then broke ... fixed the data sourced in the Weekly coloumn but lost one
// added the wvma .. its plotted but NOT in the table as I have reached the number of security requests
// left in the commented out parts in case TV allows more then 40 security requests in the future
// removed a few settings along with the VWMA so this is only SMA
//@version=5
indicator(title="Multi Time Frame", shorttitle=" SMA MTF Ver: 1.5", overlay=true)
// BEGIN SCRIPT
// Custom function to truncate (cut) excess decimal places
truncate(_number, _decimalPlaces) =>
_factor = math.pow(10, _decimalPlaces)
int(_number * _factor) / _factor
s01=input.int(title="SMA 1", defval=5, group='SMA')
s02=input.int(title="SMA 2", defval=10, group='SMA')
s03=input.int(title="SMA 3", defval=20, group='SMA')
s04=input.int(title="SMA 4", defval=50, group='SMA')
s05=input.int(title="SMA 5", defval=120, group='SMA')
s06=input.int(title="SMA 6", defval=200, group='SMA')
// SMAs
sma1=ta.sma(close, s01)
sma2=ta.sma(close, s02)
sma3=ta.sma(close, s03)
sma4=ta.sma(close, s04)
sma5=ta.sma(close, s05)
sma6=ta.sma(close, s06)
// SMA Plots
plot(sma1, title='SMA 1', color=color.new(#9C27B0, 0)) // Purple
plot(sma2, title='SMA 2', color=color.new(#FFEB3B, 0)) // Yellow
plot(sma3, title='SMA 3', color=color.new(#00E676, 0)) // Lime Green
plot(sma4, title='SMA 4', color=color.new(#2196F3, 0)) // Blue
plot(sma5, title='SMA 5', color=color.gray) // White color.new(#FFFFFF, 0)
plot(sma6, title='SMA 6', color=color.new(#FF9800, 0)) // Orange
// MTF requests SMA
S1 = request.security(syminfo.tickerid, "60", sma1 , lookahead=barmerge.lookahead_on)
S2 = request.security(syminfo.tickerid, "D", sma1 , lookahead=barmerge.lookahead_on)
S3 = request.security(syminfo.tickerid, "W", sma1 , lookahead=barmerge.lookahead_on)
S4 = request.security(syminfo.tickerid, "M", sma1 , lookahead=barmerge.lookahead_on)
S5 = request.security(syminfo.tickerid, "3M", sma1 , lookahead=barmerge.lookahead_on)
S6 = request.security(syminfo.tickerid, "12M", sma1 , lookahead=barmerge.lookahead_on)
S7 = request.security(syminfo.tickerid, "60", sma2, lookahead=barmerge.lookahead_on)
S8 = request.security(syminfo.tickerid, "D", sma2, lookahead=barmerge.lookahead_on)
S9 = request.security(syminfo.tickerid, "W", sma2, lookahead=barmerge.lookahead_on)
S10 = request.security(syminfo.tickerid, "M", sma2, lookahead=barmerge.lookahead_on)
S11 = request.security(syminfo.tickerid, "3M", sma2, lookahead=barmerge.lookahead_on)
S12 = request.security(syminfo.tickerid, "12M", sma2, lookahead=barmerge.lookahead_on)
S13 = request.security(syminfo.tickerid, "60", sma3 , lookahead=barmerge.lookahead_on)
S14 = request.security(syminfo.tickerid, "D", sma3 , lookahead=barmerge.lookahead_on)
S15 = request.security(syminfo.tickerid, "W", sma3 , lookahead=barmerge.lookahead_on)
S16 = request.security(syminfo.tickerid, "M", sma3 , lookahead=barmerge.lookahead_on)
S17 = request.security(syminfo.tickerid, "3M", sma3 , lookahead=barmerge.lookahead_on)
S18 = request.security(syminfo.tickerid, "12M", sma3 , lookahead=barmerge.lookahead_on)
S19 = request.security(syminfo.tickerid, "60", sma4, lookahead=barmerge.lookahead_on)
S20 = request.security(syminfo.tickerid, "D", sma4, lookahead=barmerge.lookahead_on)
S21 = request.security(syminfo.tickerid, "W", sma4, lookahead=barmerge.lookahead_on)
S22 = request.security(syminfo.tickerid, "M", sma4, lookahead=barmerge.lookahead_on)
S23 = request.security(syminfo.tickerid, "3M", sma4, lookahead=barmerge.lookahead_on)
S24 = request.security(syminfo.tickerid, "12M", sma4, lookahead=barmerge.lookahead_on)
S25 = request.security(syminfo.tickerid, "60",sma5, lookahead=barmerge.lookahead_on)
S26 = request.security(syminfo.tickerid, "D", sma5, lookahead=barmerge.lookahead_on)
S27 = request.security(syminfo.tickerid, "W", sma5, lookahead=barmerge.lookahead_on)
S28 = request.security(syminfo.tickerid, "M", sma5, lookahead=barmerge.lookahead_on)
S29 = request.security(syminfo.tickerid, "3M", sma5, lookahead=barmerge.lookahead_on)
S30 = request.security(syminfo.tickerid, "12M", sma5, lookahead=barmerge.lookahead_on)
S31 = request.security(syminfo.tickerid, "60", sma6, lookahead=barmerge.lookahead_on)
S32 = request.security(syminfo.tickerid, "D", sma6, lookahead=barmerge.lookahead_on)
S33 = request.security(syminfo.tickerid, "W", sma6, lookahead=barmerge.lookahead_on)
S34 = request.security(syminfo.tickerid, "M", sma6, lookahead=barmerge.lookahead_on)
S35 = request.security(syminfo.tickerid, "3M", sma6, lookahead=barmerge.lookahead_on)
S36 = request.security(syminfo.tickerid, "12M", sma6, lookahead=barmerge.lookahead_on)
//Table
TblY = input.string("bottom", "Table Position", inline = "11", options = ["top", "middle", "bottom"])
TblX = input.string("right", "", inline = "11", options = ["left", "center", "right"])
testTable = table.new(TblY + "_" + TblX, columns = 10, rows = 10, border_width = 1,border_color = color.black,frame_width = 1,frame_color = color.red, bgcolor=color.gray)
if barstate.islastconfirmedhistory or barstate.isrealtime
t1 = str.tostring(s01)
t2 = str.tostring(s02)
t3 = str.tostring(s03)
t4 = str.tostring(s04)
t5 = str.tostring(s05)
t6 = str.tostring(s06)
table.cell(table_id = testTable, column = 0, row = 0, text = "SMA",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 1, row = 0, text = "Current",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 0, row = 1, text = t1 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 1, row = 1, text = str.tostring(truncate(sma1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.black)
table.cell(table_id = testTable, column = 0, row = 2, text = t2 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 1, row = 2, text = str.tostring(truncate(sma2,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = testTable, column = 0, row = 3, text = t3 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 1, row = 3, text = str.tostring(truncate(sma2,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = testTable, column = 0, row = 4, text = t4 ,text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 1, row = 4, text = str.tostring(truncate(sma4,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = testTable, column = 0, row = 5, text = t5,text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 1, row = 5, text = str.tostring(truncate(sma5,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = testTable, column = 0, row = 6, text = t6,text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 1, row = 6, text = str.tostring(truncate(sma6,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = testTable, column = 2, row = 0, text = "Hourly",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 2, row = 1, text = str.tostring(truncate(S1,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.black)
table.cell(table_id = testTable, column = 2, row = 2, text = str.tostring(truncate(S7,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = testTable, column = 2, row = 3, text = str.tostring(truncate(S13,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = testTable, column = 2, row = 4, text = str.tostring(truncate(S19,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = testTable, column = 2, row = 5, text = str.tostring(truncate(S25,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = testTable, column = 2, row = 6, text = str.tostring(truncate(S31,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = testTable, column = 3, row = 0, text = "Daily",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 3, row = 1, text = str.tostring(truncate(S2,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.black)
table.cell(table_id = testTable, column = 3, row = 2, text = str.tostring(truncate(S8,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = testTable, column = 3, row = 3, text = str.tostring(truncate(S14,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = testTable, column = 3, row = 4, text = str.tostring(truncate(S20,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = testTable, column = 3, row = 5, text = str.tostring(truncate(S26,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = testTable, column = 3, row = 6, text = str.tostring(truncate(S32,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = testTable, column = 4, row = 0, text = "Weekly",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 4, row = 1, text = str.tostring(truncate(S3,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.black)
table.cell(table_id = testTable, column = 4, row = 2, text = str.tostring(truncate(S9,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = testTable, column = 4, row = 3, text = str.tostring(truncate(S15,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = testTable, column = 4, row = 4, text = str.tostring(truncate(S21,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = testTable, column = 4, row = 5, text = str.tostring(truncate(S27,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = testTable, column = 4, row = 6, text = str.tostring(truncate(S33,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = testTable, column = 5, row = 0, text = "Montly",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 5, row = 1, text = str.tostring(truncate(S4,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.black)
table.cell(table_id = testTable, column = 5, row = 2, text = str.tostring(truncate(S10,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = testTable, column = 5, row = 3, text = str.tostring(truncate(S16,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = testTable, column = 5, row = 4, text = str.tostring(truncate(S22,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = testTable, column = 5, row = 5, text = str.tostring(truncate(S28,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = testTable, column = 5, row = 6, text = str.tostring(truncate(S34,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = testTable, column = 6, row = 0, text = "Quartly",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 6, row = 1, text = str.tostring(truncate(S5,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.black)
table.cell(table_id = testTable, column = 6, row = 2, text = str.tostring(truncate(S11,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = testTable, column = 6, row = 3, text = str.tostring(truncate(S17,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = testTable, column = 6, row = 4, text = str.tostring(truncate(S23,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = testTable, column = 6, row = 5, text = str.tostring(truncate(S29,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = testTable, column = 6, row = 6, text = str.tostring(truncate(S35,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
table.cell(table_id = testTable, column = 7, row = 0, text = "Yearly",text_size = size.normal,text_color = color.black)
table.cell(table_id = testTable, column = 7, row = 1, text = str.tostring(truncate(S6,2)),text_size = size.normal,bgcolor=color.new(#9C27B0, 0),text_color = color.black)
table.cell(table_id = testTable, column = 7, row = 2, text = str.tostring(truncate(S12,2)),text_size = size.normal,bgcolor=color.new(#FFEB3B, 0),text_color = color.black)
table.cell(table_id = testTable, column = 7, row = 3, text = str.tostring(truncate(S18,2)),text_size = size.normal,bgcolor=color.new(#00E676, 0),text_color = color.black)
table.cell(table_id = testTable, column = 7, row = 4, text = str.tostring(truncate(S24,2)),text_size = size.normal,bgcolor=color.new(#2196F3, 0),text_color = color.black)
table.cell(table_id = testTable, column = 7, row = 5, text = str.tostring(truncate(S30,2)),text_size = size.normal,bgcolor=color.new(#FFFFFF, 0),text_color = color.black)
table.cell(table_id = testTable, column = 7, row = 6, text = str.tostring(truncate(S36,2)),text_size = size.normal,bgcolor=color.new(#FF9800, 0),text_color = color.black)
// END OF CODE
// END OF CODE |
Moving Average Converging [LuxAlgo] | https://www.tradingview.com/script/srkcHQMv-Moving-Average-Converging-LuxAlgo/ | LuxAlgo | https://www.tradingview.com/u/LuxAlgo/ | 2,946 | 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/
// © LuxAlgo
//@version=5
indicator("Moving Average Converging [LuxAlgo]", overlay = true)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
length = input(100)
incr = input(10, "Increment")
fast = input(10)
src = input(close)
//-----------------------------------------------------------------------------}
//Calculations
//-----------------------------------------------------------------------------{
var ma = 0.
var fma = 0.
var alpha = 0.
var k = 1 / incr
upper = ta.highest(length)
lower = ta.lowest(length)
init_ma = ta.sma(src, length)
cross = ta.cross(src,ma)
alpha := cross ? 2 / (length + 1)
: src > ma and upper > upper[1] ? alpha + k
: src < ma and lower < lower[1] ? alpha + k
: alpha
ma := nz(ma[1] + alpha[1] * (src - ma[1]), init_ma)
fma := nz(cross ? math.avg(src, fma[1])
: src > ma ? math.max(src, fma[1]) + (src - fma[1]) / fast
: math.min(src, fma[1]) + (src - fma[1]) / fast,src)
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
css = fma > ma ? color.teal : color.red
plot0 = plot(fma, "Fast MA"
, color = #ff5d00
, transp = 100)
plot1 = plot(ma, "Converging MA"
, color = css)
fill(plot0, plot1, css
, "Fill"
, transp = 80)
//-----------------------------------------------------------------------------} |
R-sqrd Adapt. Fisher Transform w/ D. Zones & Divs. [Loxx] | https://www.tradingview.com/script/k4fpHEih-R-sqrd-Adapt-Fisher-Transform-w-D-Zones-Divs-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 221 | 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="R-sqrd Adapt. Fisher Transform w/ D. Zones & Divs. [Loxx]",
shorttitle='RSAFTDZ [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
_iRsq(src, per)=>
SumX = 0., SumXX = 0., SumXY = 0., SumYY = 0., SumY = 0.
for k = 0 to per-1 by 1
SumX += SumX+(k+1)
SumXX += SumXX+((k+1)*(k+1))
SumXY += SumXY+((k+1)*src)
SumYY += SumYY+(src*src)
SumY += SumY+src
Q1 = SumXY - SumX*SumY/per
Q2 = SumXX - SumX*SumX/per
Q3 = SumYY - SumY*SumY/per
iRsq= (Q1*Q1)/(Q2*Q3)
iRsq
round_(val) =>
val > .99 ? .999 : val < -.99 ? -.999 : val
val
_iFish(src, per)=>
high_ = ta.highest(src, per)
low_ = ta.lowest(src, per)
value = 0.0
value := round_(.66 * ((src - low_) / (high_ - low_) - .5) + .67 * nz(value[1]))
fish1 = 0.0
fish1 := .5 * math.log((1 + value) / (1 - value)) + .5 * nz(fish1[1])
fish1
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = input.string("Median", "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(9, minval=1, title="Period", group = "Basic Settings")
adaptfactor = input.float(0.25, "Adaptive Factor", step = 0.01, group = "Basic Settings")
adapt = input.bool(true, "Make it R-squared adaptive?", group = "Basic Settings")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buy1 = input.float(0.05, "Dynamic Zone Buy Probability Level 1", group = "Levels Settings")
sell1 = input.float(0.05, "Dynamic Zone Sell Probability Level 1", group = "Levels Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
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)
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "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
rsq = _iRsq(src, per)
perout = adapt ? math.ceil(per + per * (rsq-adaptfactor)) : per
perout := perout < 2 ? 1 : perout
perout := nz(perout, 1)
fish1 = _iFish(src, perout)
fish2 = nz(fish1[1])
middle = 0.
bl1 = loxxdynamiczone.dZone("buy", fish1, buy1, dzper)
sl1 = loxxdynamiczone.dZone("sell", fish1, sell1, dzper)
zli = loxxdynamiczone.dZone("sell", fish1, 0.5 , dzper)
state = 0.
if sigtype == SM02
if (fish1<fish2)
state :=-1
if (fish1>fish2)
state := 1
else if sigtype == SM03
if (fish1<zli)
state :=-1
if (fish1>zli)
state := 1
else if sigtype == SM04
if (fish1<bl1)
state :=-1
if (fish1>sl1)
state := 1
colorfish = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(fish1, color = colorfish, linewidth = 2)
plot(bl1, color = greencolor)
plot(sl1, color = redcolor)
plot(zli, color = bar_index % 2 ? color.white : na)
barcolor(colorbars ? colorfish : na)
goLong = sigtype == SM02 ? ta.crossover(fish1, fish2) : sigtype == SM03 ? ta.crossover(fish1, zli) : ta.crossover(fish1, sl1)
goShort = sigtype == SM02 ? ta.crossunder(fish1, fish2) : sigtype == SM03 ? ta.crossunder(fish1, zli) : ta.crossunder(fish1, bl1)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
osc = fish1
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
)
alertcondition(goLong, title="Long", message="R-squared Adaptive Fisher Transform w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="R-squared Adaptive Fisher Transform w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBearCond, title="Hidden Bear Divergence", message="R-squared Adaptive Fisher Transform w/ Dynamic Zones [Loxx]: Hidden Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bearCond, title="Regular Bear Divergence", message="R-squared Adaptive Fisher Transform w/ Dynamic Zones [Loxx]: Regular Bear Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(hiddenBullCond, title="Hidden Bull Divergence", message="R-squared Adaptive Fisher Transform w/ Dynamic Zones [Loxx]: Hidden Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(bullCond, title="Regular Bull Divergence", message="R-squared Adaptive Fisher Transform w/ Dynamic Zones [Loxx]: Regular Bull Divergence\nSymbol: {{ticker}}\nPrice: {{close}}")
|
The Investment Clock | https://www.tradingview.com/script/RYvFEPHs-The-Investment-Clock/ | BarefootJoey | https://www.tradingview.com/u/BarefootJoey/ | 49 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Original Author: © BarefootJoey
//
// Inspiration: https://macro-ops.com/the-investment-clock/
// Model: https://medium.com/@richardhwlin/how-does-investment-clock-work-c7d8fbbeb7bd
//
//@version=5
indicator("The Investment Clock", overlay=false)
// ----------------------- 🦶 BarefootJoey Theme ---------------------------- //
// Colors
red = color.red
green = color.green
fuchsia = color.fuchsia
yellow = color.yellow
aqua = color.aqua
orange = color.orange
// Groups
grg = "Growth"
gri = "Inflation"
grip = "Info Panel"
// --------------------- Inflation vs Growth YoY ---------------------------- //
// Growth
sustainable = input.float(2.5, "Sustainable Growth", minval=0, group=grg)
hline(sustainable, color=yellow, editable=false)
i_input = input.symbol("GDPC1", title="Growth Ticker", group=grg, tooltip="You may get errors if your chart is set to a different timeframe/ticker than 1d CPILFESL")
tickeri = request.security(i_input, "D", close)
tickero = (ta.change(tickeri,12) / tickeri[12]) *100
plot(tickero, title="Growth", color = tickero>tickero[1] ? yellow : tickero<tickero[1] ? fuchsia : color.gray)
// Inflation
sustainable2 = input.float(3, "Sustainable Inflation", minval=0, group=gri)
hline(sustainable2, color=aqua, editable=false)
i_input2 = input.symbol("CPILFESL", title="Inflation Ticker", group=gri, tooltip="You may get errors if your chart is set to a different timeframe/ticker than 1d CPILFESL")
tickeri2 = request.security(i_input2, "D", close)
tickero2 = (ta.change(tickeri2,12) / tickeri2[12]) *100
plot(tickero2, title="Inflation", color = tickero2>tickero2[1] ? aqua : tickero2<tickero2[1] ? orange : color.gray)
// Define High/Low Growth/Inflation
hg = tickero>sustainable
lg = tickero<sustainable
hi = tickero2>sustainable2
li = tickero2<sustainable2
// Define the 4 phases & indicate them via background color
// Overheat
overheat = hg and hi
overheatcol = overheat ? orange : na
overheatcolbg = overheat ? color.new(overheatcol,80) : na
bgcolor(overheatcolbg, title="🔥 Overheating Background")
// Stagflation
stagflation = lg and hi
stagflationcol = stagflation ? red : na
stagflationcolbg = stagflation ? color.new(stagflationcol,80) : na
bgcolor(stagflationcolbg, title="📉 Stagflation Background")
// Reflation
reflation = lg and li
reflationcol = reflation ? yellow : na
reflationcolbg = reflation ? color.new(reflationcol,80) : na
bgcolor(reflationcolbg, title="🎈 Reflation Background")
// Recovery
recovery = hg and li
recoverycol = recovery ? green : na
recoverycolbg = recovery ? color.new(recoverycol,80) : na
bgcolor(recoverycolbg, title="🤒 Recovery Background")
// ----------------------------- Info Panel --------------------------------- //
// Status
status = overheat ? "🔥 Overheating: Commodities ⛽"
: stagflation ? "📉 Stagflation: Cash 💰"
: recovery ? "🤒 Recovery: Stocks 📈"
: reflation ? "🎈 Reflation: Bonds 🎫"
: na
// Tooltip
ttip = overheat ? "📈 High Inflation\n🥵 Low Growth\n👟📉 Hold Cyclical Value\n🚜 Hold Industrials $IYJ\n🔴 Fading Info Tech $IYW 💻\n🔴 Fading Basic Materials $IYM 🧱\n🟢 Buying Oil & Gas $IYE ⛽\n👀 See Rate Hikes 📈\n🔮 Anticipate Stagflation or Recovery"
: stagflation ? "📉 Low Inflation\n🥵 Low Growth\n🍗📉 Hold Defensive Value\n⚡ Hold Utilities $IDU\n🟢 Buying Consumer Staples $IYK\n 🟢 Buying Healthcare $IYH 🩺\n🔴 Fading Oil & Gas $IYE ⛽\n🔮 Anticipate Reflation or Overheating"
: recovery ? "📉 Low Inflation\n💪 High Growth\n👟📈 Hold Cyclical Growth\n📞 Hold Telecom $IYZ\n🟢 Buying Info Tech $IYW 💻\n 🟢 Buying Basic Materials $IYM 🧱\n🔴 Fading Consumer Discretionary $IYC 🎮\n🔮 Anticipate Overheating or Reflation"
: reflation ? "📈 High Inflation\n💪 High Growth\n🍗📈 Hold Defensive Growth\n🏦 Hold Financials $IYF\n🔴 Fading Consumer Staples $IYK\n 🔴 Fading Healthcare $IYH 🩺\n🟢 Buying Consumer Discretionary $IYC 🎮\n👀 See Rate Cuts 📉\n🔮 Anticipate Recovery or Stagflation"
: na
// Text Color
txtcol = overheat ? overheatcol
: stagflation ? stagflationcol
: recovery ? recoverycol
: reflation ? reflationcol
: na
// Info Panel
position = input.string(position.bottom_center, "Info Panel Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left], group=grip)
size2 = input.string(size.small, "Info Panel Size", [size.tiny, size.small, size.normal, size.large, size.huge], group=grip)
var table Ticker = na
Ticker := table.new(position, 1, 1)
if barstate.islast // and showticker
table.cell(Ticker, 0, 0,
text = status,
text_size = size2,
text_color = txtcol,
tooltip = ttip)
// EoS made w/ ❤ by @BarefootJoey ✌💗📈 |
Carrey's Velocity and Acceleration | https://www.tradingview.com/script/2Vv5f4wz-Carrey-s-Velocity-and-Acceleration/ | CarreyTrades | https://www.tradingview.com/u/CarreyTrades/ | 67 | 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/
// © CarreyTrades
// This is initially based on the MA Speed indicator from TradeStation (https://www.tradingview.com/v/4j9HWCVA/)
// and expanded upon greatly. This implements 3 different variable MAs and calculates and plots
// both speed and acceleration of each. Also, a single line composite option is
// included for both speed and acceleration that changes color based on directional
// confluence of each MA's speed/acceleration. Additionally, optional labels are
// included to show where the 3 MAs are clustered, and a volatile move is expected,
// and where they are more distributed, expecting a temporary reversal.
//@version=5
indicator("Carrey's Velocity and Acceleration", overlay=false)
enableMA = input.bool(true, title="════ Enable Moving Average Rate of Change ════", group="MA")
q1 = input.bool(false, title="Enable 9/36/64 MA", inline="d", group="MA")
q2 = input.bool(false, title="Enable 9/24/49 MA", inline="d", group="MA")
q3 = input.bool(false, title="Enable 9/36/49 MA", inline="d", group="MA")
// accept user inputs for the types of moving average
enableMA1 = enableMA ? input.bool(true, title="Enable MA Velocity 1", inline="ma1", group="MA") : na
malength1 = q1 or q2 or q3 ? 9 : input.int(25, minval=1, title='MA Length 1', group="MA")
masrc1 = input(close, title='MA1 Source', group="MA")
matype1 = input.string("Hull", title='MA1 AvgType', options=["simple", "exponential", "Hull", "weighted", "volume weighted"], group="MA")
enableMA2 = enableMA ? input.bool(true, title="Enable MA Velocity 2", inline="ma2", group="MA") : na
malength2 = q1 or q3 ? 36 : q2 ? 24 :input.int(36, minval=1, title='MA Length 2', group="MA")
masrc2 = input(close, title='MA2 Source', group="MA")
matype2 = input.string("Hull", title='MA2 AvgType', options=["simple", "exponential", "Hull", "weighted", "volume weighted"], group="MA")
enableMA3 = enableMA ? input.bool(true, title="Enable MA Velocity 3", inline="ma3", group="MA") : na
malength3 = q1 ? 64 : q2 or q3 ? 49 : input.int(49, minval=1, title='MA Length 3', group="MA")
masrc3 = input(close, title='MA3 Source', group="MA")
matype3 = input.string("Hull", title='MA3 AvgType', options=["simple", "exponential", "Hull", "weighted", "volume weighted"], group="MA")
scale = input.float(2, title="Scale MA Plots", minval=0.1, maxval=25, step=0.1, group="MA")
dc = input.float(1, title="Acceleration Extreme", minval=1, maxval=100, group="MA")
dm = input.float(2, title="Acceleration Scale", minval=1, maxval=100, group="MA")
enablecomp = input.bool(false, title="Composite MA Speed?", inline="c", group="MA")
enabledp = input.bool(false, title="Composite MA Acceleration?", inline="c2", group="MA")
numa = input.string("Average", title="Velocity Composite Style", options=["Average", "Cumulative"], inline="c", group="MA")
numb = input.string("Average", title="Accel Composite Style", options=["Average", "Cumulative"], inline="c2", group="MA")
enabled1 = enableMA ? input.bool(false, title="Enable MA Acceleration 1", inline="ma1", group="MA") : na
enabled2 = enableMA ? input.bool(false, title="Enable MA Acceleration 2", inline="ma2", group="MA") : na
enabled3 = enableMA ? input.bool(false, title="Enable MA Acceleration 3", inline="ma3", group="MA") : na
enablecd = input.bool(false, title="Enable Velocity Cluster/Distribution Signals", inline="cd", group="MA")
clust = input.float(10, title="Cluster Percent Sensitivity", minval=1, maxval=1000, step=1, inline="cd", group="MA")
dist = input.float(150, title="Distribution Percent Sensitivity", minval=1, maxval=1000, step=1, inline="cd", group="MA")
cdl = input.int(3, title="Cluster/Distribution Lookback", tooltip="How many bars back before getting another Cluster/Distribution signal. This helps to avoid overlapping or constantly repeating signals", inline="cd1", group="MA")
ex = input.float(30, title="Extrema Levels", inline="cd2", group="MA")
// calculate moving averages
simplema1 = ta.sma(masrc1, malength1)
exponentialma1 = ta.ema(masrc1, malength1)
hullma1 = ta.wma(2 * ta.wma(masrc1, malength1 / 2) - ta.wma(masrc1, malength1), math.round(math.sqrt(malength1)))
weightedma1 = ta.wma(masrc1, malength1)
volweightedma1 = ta.vwma(masrc1, malength1)
simplema2 = ta.sma(masrc2, malength2)
exponentialma2 = ta.ema(masrc2, malength2)
hullma2 = ta.wma(2 * ta.wma(masrc2, malength2 / 2) - ta.wma(masrc2, malength2), math.round(math.sqrt(malength2)))
weightedma2 = ta.wma(masrc2, malength2)
volweightedma2 = ta.vwma(masrc2, malength2)
simplema3 = ta.sma(masrc3, malength3)
exponentialma3 = ta.ema(masrc3, malength3)
hullma3 = ta.wma(2 * ta.wma(masrc3, malength3 / 2) - ta.wma(masrc3, malength3), math.round(math.sqrt(malength3)))
weightedma3 = ta.wma(masrc3, malength3)
volweightedma3 = ta.vwma(masrc3, malength3)
// assign value based on user input
avgval1 = matype1 == "simple" ? simplema1 : matype1 == "exponential" ? exponentialma1 : matype1 == "Hull" ? hullma1 : matype1 == "weighted" ? weightedma1 : matype1 == "volume weighted" ? volweightedma1 : na
avgval2 = matype2 == "simple" ? simplema2 : matype2 == "exponential" ? exponentialma2 : matype2 == "Hull" ? hullma2 : matype2 == "weighted" ? weightedma2 : matype2 == "volume weighted" ? volweightedma2 : na
avgval3 = matype3 == "simple" ? simplema3 : matype3 == "exponential" ? exponentialma3 : matype3 == "Hull" ? hullma3 : matype3 == "weighted" ? weightedma3 : matype3 == "volume weighted" ? volweightedma3 : na
// Calculate MA speed
MA_speed1 = (avgval1 / avgval1[1] - 1)
MA_speed2 = (avgval2 / avgval2[1] - 1)
MA_speed3 = (avgval3 / avgval3[1] - 1)
// Second Derivative
d1 = (MA_speed1 / MA_speed1[1] - 1)
d2 = (MA_speed2 / MA_speed2[1] - 1)
d3 = (MA_speed3 / MA_speed3[1] - 1)
// set color
Pcolor1 = MA_speed1 > 0 ? color.orange : MA_speed1 < 0 ? color.yellow : na
Pcolor2 = MA_speed2 > 0 ? color.fuchsia : MA_speed2 < 0 ? color.aqua : na
Pcolor3 = MA_speed3 > 0 ? color.white : MA_speed3 < 0 ? color.gray : na
Pcolor4 = d1 > 0 ? color.blue : d1 < 0 ? color.purple : na
Pcolor5 = d2 > 0 ? color.green : d2 < 0 ? color.red : na
Pcolor6 = d3 > 0 ? color.olive : d3 < 0 ? color.teal : na
// Derivative Conditions
dd1 = d1 > 0 ? 1 : d1 < 0 ? -1 : na
dl1 = d1 > 0 ? color.green : d1 < 0 ? color.red : na
dd2 = d2 > 0 ? 1 : d2 < 0 ? -1 : na
dd3 = d3 > 0 ? 1 : d3 < 0 ? -1 : na
dp1 = d1 > dc*2.5 ? dc*2.5 : d1 < (-1)*dc*2.5 ? (-1)*dc*2.5 : d1
dp2 = d2 > dc*2.5 ? dc*2.5 : d2 < (-1)*dc*2.5 ? (-1)*dc*2.5 : d2
dp3 = d3 > dc*2.5 ? dc*2.5 : d3 < (-1)*dc*2.5 ? (-1)*dc*2.5 : d3
// Locate crossover
d1c = dd1[1] > dd1 ? -1 : dd1[1] < dd1 ? 1 : 0
d2c = dd2[1] > dd2 ? -1 : dd2[1] < dd2 ? 1 : 0
d3c = dd3[1] > dd3 ? -1 : dd3[1] < dd3 ? 1 : 0
//plotshape(enableMA? d1c : na, title='MA Confluence 1', location=location.top, style=shape.square, size=size.tiny, color=dl1)
//plotshape(enableMA? d2c : na, title='MA Confluence 2', location=location.bottom, style=shape.square, size=size.tiny, color=color.new(color.green, 20))
// Establish conditions
bull = MA_speed1 > MA_speed1[1] and MA_speed2 > MA_speed2[1] and MA_speed3 > MA_speed3[1] ? true : false
bear = MA_speed1 < MA_speed1[1] and MA_speed2 < MA_speed2[1] and MA_speed3 < MA_speed3[1] ? true : false
bull2 = dp1 > dp1[1] and dp2 > dp2[1] and dp3 > dp3[1] ? true : false
bear2 = dp1 < dp1[1] and dp2 < dp2[1] and dp3 < dp1[1] ? true : false
//plotshape(enableMA? bear : na, title='MA Confluence 1', location=location.top, style=shape.square, size=size.tiny, color=color.new(color.red, 20))
//plotshape(enableMA? bull : na, title='MA Confluence 2', location=location.bottom, style=shape.square, size=size.tiny, color=color.new(color.green, 20))
num1 = numa == "Average" ? 3 : 1
macomp = (MA_speed1 + MA_speed2 + MA_speed3) / num1
compcolor = bull ? color.green : bear ? color.red : color.gray
num2 = numb == "Average" ? 3 : 1
dcomp = (dp1 + dp2 + dp3) / num2
dcolor = bull2 ? color.lime : bear2 ? color.fuchsia : color.white
// Velocity Clusters and Distribution
atob = math.abs(MA_speed1 - MA_speed2)
atoc = math.abs(MA_speed1 - MA_speed3)
btoc = math.abs(MA_speed2 - MA_speed3)
cd1 = math.abs(atob / MA_speed2) * 100
cd2 = math.abs(atoc / MA_speed3) * 100
cd3 = math.abs(btoc / MA_speed3) * 100
cluster = cd1 < clust and cd2 < clust and cd3 < clust ? true : false
distribution = cd1 > dist/(malength2/malength1) and cd2 > dist and cd3 > dist/(malength3/malength2) ? true : false
lbc = ta.barssince(cluster[1])
lbd = ta.barssince(distribution[1])
lookbackc = lbc > cdl ? true : false
lookbackd = lbd > cdl ? true : false
locdu = MA_speed1 > 0 and MA_speed2 > 0 and bull ? true : false
locdd = MA_speed1 < 0 and MA_speed2 < 0 and bear ? true : false
loccu = (MA_speed1 + MA_speed2 > 0) ? true : false
loccd = (MA_speed1 + MA_speed2 < 0) ? true : false
sbu = 50000*MA_speed3 > ex ? true : false
sbe = 50000*MA_speed3 < -1 * ex ? true : false
buc = MA_speed2[1] <= MA_speed3[1] and MA_speed2 >= MA_speed3 ? true : false
bec = MA_speed2[1] >= MA_speed3[1] and MA_speed2 <= MA_speed3 ? true : false
plotshape(enableMA and enablecd and cluster and lookbackc and loccu and not(sbu)? 100 : na, title='MA Cluster Short', location=location.top, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 20), text="Cluster", textcolor=color.white)
plotshape(enableMA and enablecd and cluster and lookbackc and loccd and not(sbe)? 100 : na, title='MA Cluster Long', location=location.bottom, style=shape.labelup, size=size.tiny, color=color.new(color.green, 20), text="Cluster", textcolor=color.white)
plotshape(enableMA and enablecd and distribution and lookbackd and locdd ? -100 : na, title='MA Distribution Long', location=location.bottom, style=shape.labelup, size=size.tiny, color=color.new(color.green, 20), text="Dist", textcolor=color.white)
plotshape(enableMA and enablecd and distribution and lookbackd and locdu ? -100 : na, title='MA Distribution Short', location=location.top, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 20), text="Dist", textcolor=color.white)
plotshape(enableMA and enablecd and bec and sbu? 100 : na, title='MA Cross Short', location=location.top, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 20), text="Cross", textcolor=color.white)
plotshape(enableMA and enablecd and buc and sbe? 100 : na, title='MA Cross Long', location=location.bottom, style=shape.labelup, size=size.tiny, color=color.new(color.green, 20), text="Cross", textcolor=color.white)
// Plot output
plot(enableMA1 and not(enablecomp) ? 50000*MA_speed1*scale : na, color=color.new(Pcolor1, 0), linewidth=1)
plot(enableMA2 and not(enablecomp) ? 50000*MA_speed2*scale : na, color=color.new(Pcolor2, 0), linewidth=1)
plot(enableMA3 and not(enablecomp) ? 50000*MA_speed3*scale : na, color=color.new(Pcolor3, 0), linewidth=1)
plot(enableMA and enablecomp ? 50000*macomp*scale : na, title="Composite MA", color=color.new(compcolor, 0))
plot(enabled1 and not(enabledp) ? dp1 * scale * dm * 10 : na, color=color.new(Pcolor4, 0), linewidth=1, style=plot.style_histogram)
plot(enabled2 and not(enabledp) ? dp2 * scale * dm * 10 : na, color=color.new(Pcolor5, 0), linewidth=1, style=plot.style_histogram)
plot(enabled3 and not(enabledp) ? dp3 * scale * dm * 10 : na, color=color.new(Pcolor6, 0), linewidth=1, style=plot.style_histogram)
plot(enableMA and enabledp ? dcomp*scale*dm*10 : na, title="Composite MA", color=color.new(dcolor, 0), style=plot.style_histogram)
hline(enableMA ? 0 : na, title="Zero Point", color=color.gray, linestyle=hline.style_dashed)
hline(enableMA ? ex * scale : na, title="Strong Bull", color=color.green, linestyle=hline.style_dashed)
hline(enableMA ? -ex * scale : na, title="Strong Bear", color=color.red, linestyle=hline.style_dashed)
// VFI
enableV = input.bool(false, title="════ Enable VFI ════", group="VFI")
length = input(130, title='VFI length')
coef = input(0.2)
vcoef = input(2.5, title='Max. vol. cutoff')
vscale = input.float(1, title="VFI Scale")
signalLength = input(5)
smoothVFI = input(false)
ma(x, y) =>
sma_1 = ta.sma(x, y)
smoothVFI ? sma_1 : x
typical = hlc3
inter = math.log(typical) - math.log(typical[1])
vinter = ta.stdev(inter, 30)
cutoff = coef * vinter * close
vave = ta.sma(volume, length)[1]
vmax = vave * vcoef
vc = volume < vmax ? volume : vmax //min( volume, vmax )
mf = typical - typical[1]
iff_1 = mf < -cutoff ? -vc : 0
vcp = mf > cutoff ? vc : iff_1
vfi = ma(math.sum(vcp, length) / vave, 3) * vscale
vfima = ta.ema(vfi, signalLength)
d = vfi - vfima
showHisto = input(false)
plot(showHisto and enableV ? d : na, style=plot.style_histogram, color=color.new(#c6cff2, 50), linewidth=1)
plot(enableV ? vfima : na, title='EMA of vfi', color=color.new(#0040ff, 0))
plot(enableV ? vfi : na, title='vfi', color=color.new(#af7a4c, 0), linewidth=1)
|
R-squared Adaptive T3 [Loxx] | https://www.tradingview.com/script/kCaV0rij-R-squared-Adaptive-T3-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 89 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("R-squared Adaptive T3 [Loxx]",
shorttitle='RSAT3 [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
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 = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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")
orig = input.bool(false, "Original?", group = "Basic Settings")
fllwtrnd = input.bool(true, "Trend follow?", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showSigs = input.bool(false, "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
out = _t3rSqrdAdapt(src, per, orig, fllwtrnd)
sig = nz(out[1])
colorout = out > sig ? greencolor : out < sig ? redcolor : color.gray
plot(out, "R-Squared Adaptive T3 ", color = colorout, linewidth = 3)
barcolor(colorbars ? colorout: na)
goLong = colorout == greencolor and colorout[1] != greencolor
goShort = colorout == redcolor and colorout[1] != redcolor
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 [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="R-squared Adaptive T3 [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Variety-Filtered, Squeeze Moving Averages [Loxx] | https://www.tradingview.com/script/t0xt2nWn-Variety-Filtered-Squeeze-Moving-Averages-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 345 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Variety-Filtered, Squeeze Moving Averages [Loxx]",
shorttitle='VFSMA [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
_calcBaseUnit() =>
bool isForexSymbol = syminfo.type == "forex"
bool isYenPair = syminfo.currency == "JPY"
float result = isForexSymbol ? isYenPair ? 0.01 : 0.0001 : syminfo.mintick
result
greencolor = #2DD204
redcolor = #D2042D
fsmthtype = input.string("Kaufman", "Fast Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Fast MA Settings")
fastsrc = input.string("Close", "Fast Source", group= "Fast MA 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)"])
ftype = input.string("Exponential Moving Average - EMA", "Fast 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 = "Fast MA Settings")
fastper = input.int(5, "Fast Period", group= "Fast MA Settings")
ssmthtype = input.string("Kaufman", "Slow Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Slow MA Settings")
slowsrc = input.string("Close", "Slow Source", group= "Slow MA 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)"])
stype = input.string("Exponential Moving Average - EMA", "Slow 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 = "Slow MA Settings")
slowper = input.int(21, "Slow Period", group= "Slow MA Settings")
atrper = input.int(50, "ATR Period", group= "Filter Settings")
atrmult = input.float(.4, "ATR Multiplier", group= "Filter Settings")
pipsfiltin = input.int(36, "MA Threshhold Ticks", group= "Filter Settings")
filttype = input.string("ATR", "Filter type", options = ["ATR", "Pips"], group= "Filter Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showfillbands = input.bool(true, "Show fill bands?", group = "UI Options")
showsignals = 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)
outsrc(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
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
ma1 = variant(ftype, outsrc(fastsrc, fsmthtype), fastper)
ma2 = variant(stype, outsrc(slowsrc, ssmthtype), slowper)
madif = math.abs(ma1-ma2)
pipsout = _calcBaseUnit()
delta = filttype == "ATR" ? ta.atr(atrper) * atrmult / pipsout : pipsfiltin
out1 = 0., out2 = 0.
swithit = false
if (madif / pipsout < delta)
dPoint = delta * pipsout
out1 := ma2 + dPoint
out2 := ma2 - dPoint
swithit := true
else
swithit := false
e1 = plot(out1 ? out1 : na, "Upper band", color = out1 ? color.gray : na, style = plot.style_linebr)
e2 = plot(out1 ? out2 : na, "Lower band", color = out1 ? color.gray : na, style = plot.style_linebr)
fill(e1, e2, color = showfillbands ? (out1 ? color.new(color.gray, 20) : na) : na)
sqstrart = swithit and not nz(swithit[1])
sqzend = not swithit and nz(swithit[1])
goLong = sqzend and ma1 > ma2
goShort = sqzend and ma1 < ma2
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong ? 1 : goShort ? -1 : contSwitch
candleout = out1 ? color.white : contSwitch == 1 ? greencolor : redcolor
colorout = out1 ? color.gray : contSwitch == 1 ? greencolor : redcolor
barcolor(colorbars ? candleout : na)
plot(ma1, "Fast MA", color = colorout, linewidth = 2)
plot(ma2, "Slow MA", color = colorout, linewidth = 4)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(sqstrart, title="Squeeze Started", message="Variety-Filtered, Squeeze Moving Averages [Loxx]: Squeeze Started\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(sqzend, title="Squeeze Ended", message="Variety-Filtered, Squeeze Moving Averages [Loxx]: Squeeze Ended\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goLong, title="Long", message="Variety-Filtered, Squeeze Moving Averages [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Variety-Filtered, Squeeze Moving Averages [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Bullish Kicker | https://www.tradingview.com/script/bNVZT3lw-Bullish-Kicker/ | Amphibiantrading | https://www.tradingview.com/u/Amphibiantrading/ | 161 | 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/
// © amphibiantrading
//@version=5
indicator("Bullish Kicker", overlay=true)
//inputs
minKickBool = input.bool(true, 'Require Minimum Kick Amount', inline = '1')
minKick = input.float(1.,' ', minval = 0, step = .25, inline = '1')
oel_input = input(false, 'Only Show Open Equals Low kickers')
colorinput = input(color.blue, 'Arrow Color')
kicker = open[1] > close[1] and open > open[1]
oel_kicker = kicker and low == open
gapMin = kicker and ((open-close[1])/close[1])*100 >= minKick
plotshape(oel_kicker and oel_input and not minKickBool ? 1 : 0, style=shape.arrowup, size = size.small, color = colorinput, location=location.belowbar, display = display.pane)
plotshape(gapMin and minKickBool and not oel_input ? 1 : 0, style=shape.arrowup, size = size.small, color = colorinput, location=location.belowbar, display = display.pane)
plotshape(gapMin and oel_kicker and oel_input and minKickBool ? 1 : 0, style=shape.arrowup, size = size.small, color = colorinput, location=location.belowbar, display = display.pane)
plotshape(kicker and not oel_input and not minKickBool ? 1 : 0, style=shape.arrowup, size = size.small, color = colorinput, location=location.belowbar, display = display.pane)
|
Dynamic Zones of On Chart Stochastic [Loxx] | https://www.tradingview.com/script/onSZP2NS-Dynamic-Zones-of-On-Chart-Stochastic-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 121 | 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("Dynamic Zones of On Chart Stochastic [Loxx]",
shorttitle= "DZOCS [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Signal D'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
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
_iStoch(priceR, priceH, priceL, int period, int slowing)=>
_hi = priceH, _lo = priceL, _re = priceR, _ma = priceH, _mi= priceL
for k = 1 to period - 1
_mi := math.min(_mi, nz(_lo[k]))
_ma := math.max(_ma, nz(_hi[k]))
sumlow = 0.
sumhigh = 0.
for k = 1 to slowing - 1
sumlow += nz(_re[k]) - nz(_mi[k])
sumhigh += nz(_ma[k]) - nz(_mi[k])
out = 100.0 * sumlow/sumhigh
out
stper = input.int(13, "Stoch Period", group = "Basic Settings")
dper = input.int(13, "D Period", group = "Basic Settings")
sloper = input.int(8, "Slow Period", group = "Basic Settings")
type = input.string("SMA", "D Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "Basic Settings")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buyprob = input.float(0.1, "Dynamic Zone Buy Probability Level", group = "Levels Settings")
sellprob = input.float(0.1, "Dynamic Zone Sell Probability Level", group = "Levels Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "Show signals?", group = "UI Options")
stoValue = _iStoch(close, high, low, stper, sloper)
sigValue = variant(type, stoValue,dper)
max = ta.highest(high, dzper)
min = ta.lowest(low, dzper)
rng = max-min
k = min + rng * stoValue /100
d = min + rng * sigValue /100
bli = loxxdynamiczone.dZone("buy", k, buyprob, dzper)
sli = loxxdynamiczone.dZone("sell", k, sellprob, dzper)
zli = loxxdynamiczone.dZone("sell", k, 0.5, dzper)
state = 0.
if sigtype == SM02
if (k<d)
state :=-1
if (k>d)
state := 1
else if sigtype == SM03
if (k<zli)
state :=-1
if (k>zli)
state := 1
else if sigtype == SM04
if (k<bli)
state :=-1
if (k>sli)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(k, "K", color= colorout, linewidth = 3)
plot(d, "D", color= color.white, linewidth = 1)
plot(sli, "High Level", color = color.gray)
plot(bli, "Low Level" ,color = color.gray)
plot(zli, "Middle", color = color.gray)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(k, d) : sigtype == SM03 ? ta.crossover(k, zli) : ta.crossover(k, sli)
goShort = sigtype == SM02 ? ta.crossunder(k, d) : sigtype == SM03 ? ta.crossunder(k, zli) : ta.crossunder(k, bli)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goLong, title="Long", message="Dynamic Zones of On Chart Stochastic [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Dynamic Zones of On Chart Stochastic [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Fisher Transform w/ Dynamic Zones [Loxx] | https://www.tradingview.com/script/dqkU04U2-Fisher-Transform-w-Dynamic-Zones-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 114 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Fisher Transform w/ Dynamic Zones [Loxx]",
shorttitle='FTDZ [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxdynamiczone/3
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
smthtype = input.string("Kaufman", "HA Better Smoothing", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcoption = input.string("Median", "Source", group= "Basic 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(10, "Period", group = "Basic Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buy1 = input.float(0.05, "Dynamic Zone Buy Probability Level 1", group = "Levels Settings")
sell1 = input.float(0.05, "Dynamic Zone Sell Probability Level 1", group = "Levels Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "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 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
high_ = ta.highest(src, per)
low_ = ta.lowest(src, per)
round_(val) => val > .99 ? .999 : val < -.99 ? -.999 : val
value = 0.0
value := round_(.66 * ((src - low_) / (high_ - low_) - .5) + .67 * nz(value[1]))
fish = 0.0
fish := .5 * math.log((1 + value) / (1 - value)) + .5 * nz(fish[1])
fish2 = nz(fish[1])
bl1 = loxxdynamiczone.dZone("buy", fish, buy1, dzper)
sl1 = loxxdynamiczone.dZone("sell", fish, sell1, dzper)
zli = loxxdynamiczone.dZone("sell", fish, 0.5 , dzper)
state = 0.
if sigtype == SM02
if (fish<fish2)
state :=-1
if (fish>fish2)
state := 1
else if sigtype == SM03
if (fish<zli)
state :=-1
if (fish>zli)
state := 1
else if sigtype == SM04
if (fish<bl1)
state :=-1
if (fish>sl1)
state := 1
colorfish = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(fish, color = colorfish, linewidth = 3)
plot(bl1, color = greencolor)
plot(sl1, color = redcolor)
plot(zli, color = bar_index % 2 ? color.white : na)
barcolor(colorbars ? colorfish : na)
goLong = sigtype == SM02 ? ta.crossover(fish, fish2) : sigtype == SM03 ? ta.crossover(fish, zli) : ta.crossover(fish, sl1)
goShort = sigtype == SM02 ? ta.crossunder(fish, fish2) : sigtype == SM03 ? ta.crossunder(fish, zli) : ta.crossunder(fish, bl1)
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Fisher Transform w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Fisher Transform w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Average Price Line | https://www.tradingview.com/script/IPfcdRVA-Average-Price-Line/ | Leviathans | https://www.tradingview.com/u/Leviathans/ | 68 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Leviathans
//@version=5
indicator("Avg", overlay = true)
lineColor = input.color(#787B86, 'Line Color')
var float[] closes = array.new<float>()
timeLeft = chart.left_visible_bar_time
timeRight= chart.right_visible_bar_time
if time >= timeLeft and time < timeRight
array.unshift(closes, close)
avgClose = array.avg(closes)
var line avgLine = line.new(na, na, na, na, xloc.bar_time, extend.right, lineColor, style=line.style_dotted)
if barstate.islastconfirmedhistory or barstate.isrealtime
line.set_xy1(avgLine, timeLeft, avgClose)
line.set_xy2(avgLine, timeRight, avgClose)
plot(avgClose, '', color.new(#142E61, 80), show_last = 1) |
Corrected JMA [Loxx] | https://www.tradingview.com/script/fh40ou90-Corrected-JMA-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 88 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Corrected JMA [Loxx]",
shorttitle='CJMA [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
_corMa(src, work, per)=>
out = 0.
v1 = math.pow(ta.stdev(src, per), 2)
v2 = math.pow(nz(out[1]) - work, 2)
c = (v2 < v1 or v2 == 0) ? 0 : 1 - v1 / v2
out := nz(out[1]) + c * (work - nz(out[1]))
out
src = input.source(close, "Source", group = "Basic Settings")
per = input.int(10, "Period", group = "Basic Settings")
phs = 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")
work = loxxjuriktools.jurik_filt(src, per, phs)
out = _corMa(src, work, per)
sig = nz(out[1])
goLong_pre = ta.crossover(out, sig)
goShort_pre = ta.crossunder(out, sig)
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch
colorout = out == sig ? color.gray : work > out ? greencolor : redcolor
coloroutbars = work > out ? greencolor : redcolor
plot(out, "Corrected JMA", color = colorout, linewidth = 3)
plot(work, "JMA", color = bar_index % 2 ? coloroutbars : na, linewidth = 1)
barcolor(colorbars ? coloroutbars : na)
|
Price-Filtered Spearman Rank Correl. w/ Floating Levels [Loxx] | https://www.tradingview.com/script/FFvoEhzG-Price-Filtered-Spearman-Rank-Correl-w-Floating-Levels-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 136 | 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("Price-Filtered Spearman Rank Correl. w/ Floating Levels [Loxx]",
shorttitle= "PFSRCFL [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
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
_spearman(src, rank, coeff)=>
var m = matrix.new<float>(rank, 2, 0.)
for k = 0 to rank - 1
matrix.set(m, k, 0, nz(src[k]))
matrix.set(m, k, 1, k)
matrix.sort(m, 0, order.descending)
sum = 0.0
for k = 0 to rank - 1
sum += math.pow(matrix.get(m, k, 1) - k, 2)
out = 1 - 6.00 * sum / coeff
out
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("HA Median", "Source", group= "Basic 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)"])
type = input.string("SMA", "Source Filter Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "Basic Settings")
smth = input.int(1, "Source Smoothing Period", group = "Basic Settings", minval = 1)
rank = input.int(32, "Rank", group = "Basic Settings")
inpFlPeriod = input.int(32, "Floating Levels Period", group = "Floating Settings", minval = 1)
inpFlLevelUp = input.float(80 , "Level Up", group = "Floating Levels Settings")
inpFlLevelDown = input.float(20 , "Level Down", group = "Floating Levels Settings")
sigtype = input.string(SM04, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(true, "Color bars?", group = "UI Options")
showsignals = 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
filtsrc = variant(type, src, smth)
coeff = math.pow(rank, 3) - rank
out1 = _spearman(filtsrc, rank, coeff)
out2 = out1[1]
state = 0.
_min = ta.lowest(out1, inpFlPeriod)
_max = ta.highest(out1, inpFlPeriod)
_range = (_max-_min)/100.0
lvlup = _min + inpFlLevelUp *_range
lvldn = _min + inpFlLevelDown * _range
mid = _min + 50.0 * _range
if sigtype == SM02
if (out1<out2)
state :=-1
if (out1>out2)
state := 1
else if sigtype == SM03
if (out1<mid)
state :=-1
if (out1>mid)
state := 1
else if sigtype == SM04
if (out1<lvldn)
state :=-1
if (out1>lvlup)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
outpl = plot(out1, color = colorout, title="Fisher", linewidth = 2)
lvldnpl = plot(lvldn, "High Level", color = color.gray)
lvluppl = plot(lvlup, "Low Level" ,color = color.gray)
plot(mid, "Middle", color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(out1, out2) : sigtype == SM03 ? ta.crossover(out1, mid) : ta.crossover(out1, lvlup)
goShort = sigtype == SM02 ? ta.crossunder(out1, out2) : sigtype == SM03 ? ta.crossunder(out1, mid) : ta.crossunder(out1, lvldn)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Price-Filtered Spearman Rank Correl. w/ Floating Levels [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Price-Filtered Spearman Rank Correl. w/ Floating Levels [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Dynamic Zone of Bollinger Band Stops Line [Loxx] | https://www.tradingview.com/script/5aJhxlcY-Dynamic-Zone-of-Bollinger-Band-Stops-Line-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 79 | 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("Dynamic Zone of Bollinger Band Stops Line [Loxx]",
shorttitle= "DZBBSL [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxdynamiczone/3
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
_bbline(per, type, src, dev)=>
StdDev = ta.stdev(src, per)
ma = variant(type, src, per)
result = 0., _trend = 0.
smax = ma + (StdDev * dev)
smin = ma - (StdDev * dev)
_trend := nz(_trend[1])
if (close > nz(smax[1]))
_trend := 1
if (close < nz(smin[1]))
_trend := -1
if (_trend == 1)
if (smin < nz(smin[1]))
smin := nz(smin[1])
result := smin
if (_trend == -1)
if (smax > nz(smax[1]))
smax := nz(smax[1])
result := smax
result
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
per = input.int(20, "Period", group = "Basic Settings")
src = input.source(close, "Source", group = "Basic Settings")
dev = input.float(0.5, "Deviations Multiple", group = "Basic Settings")
type = input.string("SMA", "Source Filter Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "Basic Settings")
dzper = input.int(35, "Dynamic Zone Period", group = "Levels Settings")
buyprob = input.float(0.1, "Dynamic Zone Buy Probability Level", group = "Levels Settings")
sellprob = input.float(0.1, "Dynamic Zone Sell Probability Level", group = "Levels Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "Show signals?", group = "UI Options")
out = _bbline(per, type, src, dev)
sig = out[1]
bli = loxxdynamiczone.dZone("buy", out, buyprob, dzper)
sli = loxxdynamiczone.dZone("sell", out, sellprob, dzper)
zli = loxxdynamiczone.dZone("sell", out, 0.5, dzper)
state = 0.
if sigtype == SM02
if (out < sig)
state :=-1
if (out > sig)
state := 1
else if sigtype == SM03
if (out < zli)
state :=-1
if (out > zli)
state := 1
else if sigtype == SM04
if (out < bli)
state :=-1
if (out > sli)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(out, "BBLine", color= colorout, linewidth = 3)
plot(sli, "High Level", color = color.gray)
plot(bli, "Low Level" ,color = color.gray)
plot(zli, "Middle", color = color.white)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(out, sig) : sigtype == SM03 ? ta.crossover(out, zli) : ta.crossover(out, sli)
goShort = sigtype == SM02 ? ta.crossunder(out, sig) : sigtype == SM03 ? ta.crossunder(out, zli) : ta.crossunder(out, bli)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goLong, title="Long", message="Dynamic Zone of Bollinger Band Stops Line [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Dynamic Zone of Bollinger Band Stops Line [Loxx]]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Natural Market Mirror (NMM) and NMAs w/ Dynamic Zones [Loxx] | https://www.tradingview.com/script/qvcNFegU-Natural-Market-Mirror-NMM-and-NMAs-w-Dynamic-Zones-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 102 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Natural Market Mirror (NMM) and NMAs w/ Dynamic Zones [Loxx]",
shorttitle='NMMNMADZ [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxdynamiczone/3
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
twopoless(float src, int len)=>
a1 = 0., b1 = 0.
coef1 = 0., coef2 = 0., coef3 = 0.
filt = 0., trig = 0.
a1 := math.exp(-1.414 * math.pi / len)
b1 := 2 * a1 * math.cos(1.414 * math.pi / len)
coef2 := b1
coef3 := -a1 * a1
coef1 := 1 - coef2 - coef3
filt := coef1 * src + coef2 * nz(filt[1]) + coef3 * nz(filt[2])
filt := bar_index < 3 ? src : filt
trig := nz(filt[1])
filt
_nnmfunc(float src, int per)=>
float sum = 0.0
for i = 1 to per
sum += (src - nz(src[i])) / math.sqrt(i)
out = ((sum / per) * 1000.0)
out
_nmfper(float src, int per, int minPeriod, int smthper)=>
int maxlb = 0
float maxmomen = 0.0
float currPrice = twopoless(src, smthper)
for i = 1 to per
tmom = math.abs((src - nz(src[i])) / math.sqrt(i))
if (tmom > maxmomen)
maxmomen := tmom
maxlb := i
out = (math.max(maxlb, minPeriod))
out
_nmaratio(float src, int per, float iMom)=>
float momRatio = 0.0
float sumMomen = 0.0
float ratio = 0.0
for k = 1 to per
sumMomen += math.abs(nz(iMom[k]))
momRatio += nz(iMom[k]) * (math.sqrt(k + 1) - math.sqrt(k))
ratio := sumMomen != 0 ? math.abs(momRatio) / sumMomen : ratio
ratio
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
nmmper = input.int(40, "NMM Period", group = "Basic Settings")
nnmsmthper = input.int(1, "NMM Pre-smoothing, 2-Pole Super Smother Period", group = "Basic Settings")
ssmthper = input.int(10, "NMF 2-Pole Super Smother Period", group = "Basic Settings")
zone = input.string("NMM", "Core Output Source", options = ["NMF", "NMM", "NMA"], group = "Basic Settings")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buyprob = input.float(0.1, "Dynamic Zone Buy Probability Level", group = "Levels Settings")
sellprob = input.float(0.1, "Dynamic Zone Sell Probability Level", group = "Levels Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "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 = 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 = math.log(srcout)
nmm = _nnmfunc(twopoless(src, nnmsmthper), nmmper)
oneFifth = math.max(math.round(nmmper/5) ,1)
iMom = nmm - nz(nmm[1])
nma = 0., nmf = 0.
nma := nz(nma[1]) + _nmaratio(src, nmmper, iMom) * (nmm - nz(nma[1]))
nmf := nz(nmf[1]) + _nmaratio(src, _nmfper(src, 1, oneFifth, ssmthper), iMom) * (nmm - nz(nmf[1]))
out = zone == "NMM" ? nmm : zone == "NMF" ? nmf : nma
bli = loxxdynamiczone.dZone("buy", out, buyprob, dzper)
sli = loxxdynamiczone.dZone("sell", out, sellprob, dzper)
zli = loxxdynamiczone.dZone("sell", out, 0.5, dzper)
sig = out[1]
state = 0.
if sigtype == SM02
if (out < sig)
state :=-1
if (out > sig)
state := 1
else if sigtype == SM03
if (out < zli)
state :=-1
if (out > zli)
state := 1
else if sigtype == SM04
if (out < bli)
state :=-1
if (out > sli)
state := 1
lwnmm = zone == "NMM" ? 4 : 1
lwnmf = zone == "NMF" ? 4 : 1
lwnma = zone == "NMA" ? 4 : 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(nmm, "Natural Market Mirror", color = zone == "NMM" ? colorout : color.white, linewidth = lwnmm)
plot(nmf, "Natrual Moving Average Fast", color = bar_index % 2 ? zone == "NMF" ? colorout : color.white : na, linewidth = lwnmf)
plot(nma, "Natural Moving Averge Regular", color = bar_index % 4 ? zone == "NMA" ? colorout : color.yellow : na, linewidth = lwnma)
plot(bli, color = greencolor)
plot(sli, color = redcolor)
plot(zli, color = color.white)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(out, sig) : sigtype == SM03 ? ta.crossover(out, zli) : ta.crossover(out, sli)
goShort = sigtype == SM02 ? ta.crossunder(out, sig) : sigtype == SM03 ? ta.crossunder(out, zli) : ta.crossunder(out, bli)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.tiny)
alertcondition(goLong, title="Long", message="Natural Market Mirror {NMM) and NMAs w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Natural Market Mirror {NMM) and NMAs w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
RSI Precision Trend Candles [Loxx] | https://www.tradingview.com/script/t5ZeeiHO-RSI-Precision-Trend-Candles-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 260 | 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("RSI Precision Trend Candles [Loxx]",
shorttitle='RSIPTC [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
_ptrend(float _high, float _low, float _close, int _period, float _sense)=>
t_close = _close
t_range = _high - _low
t_avgr = t_range
t_trend = 0., t_avgd = 0., t_avgu = 0., t_minc = 0.,t_maxc = 0.
for i = 1 to _period
t_avgr += nz(t_range)
t_avgr /= _period
t_avgr *= _sense
t_trend := nz(t_trend[1])
t_avgd := nz(t_avgd[1])
t_avgu := nz(t_avgu[1])
t_minc := nz(t_minc[1])
t_maxc := nz(t_maxc[1])
switch int(nz(t_trend[1]))
0=>
if (_close > nz(t_avgu[1]))
t_minc := _close
t_avgd := _close - t_avgr
t_trend := 1
if (_close < nz(t_avgd[1]))
t_maxc := _close
t_avgu := _close + t_avgr
t_trend := -1
1=>
t_avgd := nz(t_minc[1]) - t_avgr
if (_close > nz(t_minc[1]))
t_minc := _close
if (_close < nz(t_avgd[1]))
t_maxc := _close
t_avgu := _close + t_avgr
t_trend := -1
-1=>
t_avgu := t_maxc[1] + t_avgr
if (_close < nz(t_maxc[1]))
t_maxc := _close
if (_close > nz(t_avgu[1]))
t_minc := _close
t_avgd := _close - t_avgr
t_trend := 1
t_trend
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
rsiper = input.int(14, "RSI Period", group = "Basic Settings")
rsihiloper = input.int(5, "RSI HiLo Period" , group = "Basic Settings")
avgper = input.int(30, "Average Period" , group = "Basic Settings")
sense = input.float(3, "sense" , group = "Basic Settings")
showsignals = input.bool(false, "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
rsi = ta.rsi(src, rsiper)
rhigh = ta.highest(rsi, rsihiloper)
rlow = ta.lowest(rsi, rsihiloper)
trend = _ptrend(rhigh, rlow, rsi, avgper, sense)
barcolor(trend == -1 ? redcolor : trend == 1 ? greencolor : color.gray)
goLong = trend == 1 and (trend[1] == -1 or trend[1] == 0)
goShort = trend == -1 and (trend[1] == 1 or trend[1] == 0)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goLong, title="Long", message="RSI Precision Trend Candles [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="RSI Precision Trend Candles [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Variety RSI w/ Fibonacci Auto Channel [Loxx] | https://www.tradingview.com/script/n5zZ0pLc-Variety-RSI-w-Fibonacci-Auto-Channel-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 180 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Variety RSI w/ Fibonacci Auto Channel [Loxx]",
shorttitle='VRSIFAC [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
import loxx/loxxvarietyrsi/1
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
SM02 = 'Signal'
SM03 = 'Middle Crossover'
SM04 = 'Fib Level 1 Crossover'
SM05 = 'Fib Level 2 Crossover'
SM06 = 'Fib Level 3 Crossover'
SM07 = 'Fib Level 4 Crossover'
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)
else if type == "VWMA"
sig := ta.rma(src, len)
sig
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
rsiper = input.int(15, "Period", group = "Basic Settings")
rsitype = input.string("Regular", "RSI type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed"], group = "Basic Settings")
smthper = input.int(15, "Smooth Period", group = "Basic Settings")
hlper = input.int(25, "Hilo Period", group = "Basic Settings")
type = input.string("SMA", "RSI Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA", "VWMA"], group = "Basic Settings")
lev1in = input.float(0.236, "Fib Level 1", group = "Fibonacci Levels Settings")
lev2in = input.float(0.382, "Fib Level 2", group = "Fibonacci Levels Settings")
lev3in = input.float(0.618, "Fib Level 3", group = "Fibonacci Levels Settings")
lev4in = input.float(0.764, "Fib Level 4", group = "Fibonacci Levels Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04, SM05, SM06, SM07], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "Show signals?", group = "UI Options")
fillgradient = input.bool(false, "Show gradient fill?", 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
rsimode = switch rsitype
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
srcout = variant(type, src, smthper)
rsi = loxxvarietyrsi.rsiVariety(rsimode, srcout, rsiper)
sig = nz(rsi[1])
ll = ta.lowest(rsi, hlper)
hh = ta.highest(rsi, hlper)
rng = hh-ll
trdUp = hh
trdDn = ll
mid = (hh+ll)/2
fupd = mid
fupu = trdUp
fdnu = mid
fdnd = trdDn
lev1 = ll + lev1in * rng
lev2 = ll + lev2in * rng
lev3 = ll + lev3in * rng
lev4 = ll + lev4in * rng
rsic = 0.
trdUpc = 0.
trdDnc = 0.
rsic := (rsi == hh and hh != ll) ? 1 : (rsi == ll and hh != ll) ? 2 : nz(rsic[1])
trdUpc := (trdUp > nz(trdUp[1])) ? 1 : (trdUp< nz(trdUp[1])) ? 2 : nz(trdUpc[1])
trdDnc := (trdDn > nz(trdDn[1])) ? 1 : (trdDn< nz(trdDn[1])) ? 2 : nz(trdDnc[1])
state = 0.
if sigtype == SM02
if (rsi < sig)
state :=-1
if (rsi > sig)
state := 1
else if sigtype == SM03
if (rsi < mid)
state :=-1
if (rsi > mid)
state := 1
else if sigtype == SM04
if (rsi < lev1)
state :=-1
if (rsi > lev1)
state := 1
else if sigtype == SM05
if (rsi < lev2)
state :=-1
if (rsi > lev2)
state := 1
else if sigtype == SM06
if (rsi < lev3)
state :=-1
if (rsi > lev3)
state := 1
else if sigtype == SM07
if (rsi < lev4)
state :=-1
if (rsi > lev4)
state := 1
colorout =
state == -1 ? redcolor :
state == 1 ? greencolor :
color.gray
lvllo = plot(lev1, color = bar_index % 2 ? greencolor : na)
plot(lev2, color = bar_index % 2 ? color.yellow : na)
plot(lev3, color = bar_index % 2 ? color.orange : na)
lvlhi =plot(lev4, color = bar_index % 2 ? redcolor : na)
plot(rsi, linewidth = 3, color = colorout)
goLong =
sigtype == SM02 ? ta.crossover(rsi, sig) :
sigtype == SM03 ? ta.crossover(rsi, mid) :
sigtype == SM04 ? ta.crossover(rsi, lev1) :
sigtype == SM05 ? ta.crossover(rsi, lev2) :
sigtype == SM06 ? ta.crossover(rsi, lev3) :
ta.crossover(rsi, lev4)
goShort =
sigtype == SM02 ? ta.crossunder(rsi, sig) :
sigtype == SM03 ? ta.crossunder(rsi, mid) :
sigtype == SM04 ? ta.crossunder(rsi, lev1) :
sigtype == SM05 ? ta.crossunder(rsi, lev2) :
sigtype == SM06 ? ta.crossunder(rsi, lev3) :
ta.crossunder(rsi, lev4)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.tiny)
alertcondition(goLong, title="Long", message="Variety RSI w/ Fibonacci Auto Channel [Loxx]: Long\nSymbol: {{ticker}}\nsrc: {{close}}")
alertcondition(goShort, title="Short", message="Variety RSI w/ Fibonacci Auto Channel [Loxx]: Short\nSymbol: {{ticker}}\nsrc: {{close}}")
lo = math.min(lev1, lev4)
hi = math.max(lev1, lev4)
color2 = color.from_gradient(rsi,lo, hi, redcolor, greencolor)
fill(lvllo, lvlhi, color = fillgradient ? hi != lo ? color.new(color2, 90) : color.new(colorout, 90) : na )
barcolor(colorbars ? hi != lo ? color2 : colorout: na)
|
Pips-Stepped MA of RSI Adaptive EMA [Loxx] | https://www.tradingview.com/script/OT9vDTMD-Pips-Stepped-MA-of-RSI-Adaptive-EMA-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 111 | 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("Pips-Stepped MA of RSI Adaptive EMA [Loxx]",
shorttitle='PSTPMARSIAEMA [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxvarietyrsi/1
greencolor = #2DD204
redcolor = #D2042D
_declen()=>
string mtckstr = str.tostring(syminfo.mintick)
string[] da = str.split(mtckstr, ".")
int temp = array.size(da)
float dlen = 0.
if syminfo.mintick < 1
dstr = array.get(da, 1)
dlen := str.length(dstr)
dlen
_stepma(float sense, float size, float stepMulti, phigh, plow, pprice)=>
float trend = 0.
float out = 0.
float sensitivity = sense == 0 ? 0.000001 : sense
float stepSize = size == 0 ? 0.000001 : size
float sizea = sensitivity * stepSize
float smax = phigh + 2.0 * sizea * stepMulti
float smin = plow - 2.0 * sizea * stepMulti
trend := nz(trend[1])
if (pprice > nz(smax[1]))
trend := 1
if (pprice < nz(smin[1]))
trend := -1
if (trend == 1)
if (smin < nz(smin[1]))
smin := nz(smin[1])
out := smin + sizea * stepMulti
if (trend == -1)
if (smax > nz(smax[1]))
smax := nz(smax[1])
out := smax - sizea * stepMulti
[out, trend]
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
rsiper = input.int(14, "RSI Period", group = "Basic Settings")
rsitype = input.string("Regular", "RSI type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed"], group = "RSI Settings")
sense = input.float(4, "Sensitivity", group = "Basic Settings")
stsize = input.float(5, "Step Size", 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
rsimode = switch rsitype
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
useSize = syminfo.mintick * math.pow(10, _declen() % 2)
rsiin = loxxvarietyrsi.rsiVariety(rsimode, src, rsiper)
sc = math.abs(rsiin / 100.0 - 0.5) * 2.0
rsi = 0.
rsi := nz(rsi[1]) + sc * (src - nz(rsi[1]))
[val, trend] = _stepma(sense, stsize, useSize, rsi, rsi, rsi)
colorout = trend == 1 ? greencolor : trend == -1 ? redcolor : color.gray
goLong = trend == 1 and trend[1] == -1
goShort = trend == -1 and trend[1] == 1
plot(val,"Pips-Stepped MA of RSI Adaptive EMA ", 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="Pips-Stepped MA of RSI Adaptive EMA [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Pips-Stepped MA of RSI Adaptive EMA [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Banknifty Volume - IN | https://www.tradingview.com/script/UgtVdMHt-Banknifty-Volume-IN/ | TradingTail | https://www.tradingview.com/u/TradingTail/ | 149 | 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/
// © mayurssupe
//@version=5
indicator(title="BankNity Volume",overlay=false,shorttitle = "Volume - IN")
//_symbol = input.symbol(defval="",title="Symbol")
_reversal = input.bool(defval = false,title="Non Repainted Trend Cloud",group = "Cloud",tooltip = "The Cloud is a crossover of Price and volume it is additional confirmation when trend will reverse, if the Cloud gets red means trend is changing towards bears vicerversa for Bull Side")
_revTF = input.timeframe(title="Set Timeframe for Trend Cloud",defval="",group="Cloud")
len = input.int(title="RSI Period",defval=9,group="Volume")
_tf = input.timeframe(title="Timeframe",defval="",group="Timeframe")
bn_wt = input(0.2, title="Banknifty Weightage",group = "Weightage")
sbi_wt = input(0.025, title="SBI Weightage",group = "Weightage")
axis_wt = input(0.11, title="Axis Weightage")
baroda_wt = input(0.018, title="Baroda Weightage",group = "Weightage")
pnb_wt = input(0.2, title="PNB Weightage",group = "Weightage")
fed_wt = input(0.025, title="FED Weightage",group = "Weightage")
idfc_wt = input(0.01, title="IDFC Weightage",group = "Weightage")
indusind_wt = input(0.02, title="Indusind Weightage",group = "Weightage")
icici_wt = input(0.20, title="ICICI Weightage",group = "Weightage")
bandhan_wt = input(0.02, title="Bandhan Weightage",group = "Weightage")
kotak_wt = input(0.15, title="Kotak Weightage",group = "Weightage")
hdfc_wt = input(0.26, title="HDFC Weightage",group = "Weightage")
vix_wt = input(0.35, title="IndVix Weightage",group = "Weightage")
//Ticker Id's
bn = "NSE:BANKNIFTY1!"
sbi = "NSE:SBIN"
axis = "NSE:AXISBANK"
baroda = "NSE:BANKBARODA"
pnb = "NSE:PNB"
fed = "BSE:FEDERALBNK"
idfc = "NSE:IDFCFIRSTB"
indusind = "NSE:INDUSINDBK"
icici = "NSE:ICICIBANK"
bandhan = "NSE:BANDHANBNK"
kotak = "NSE:KOTAKBANK"
hdfc = "NSE:HDFCBANK"
vix = "INDIAVIX"
//Sercuirty Fuctions
frsi(tickerid,src,length)=> request.security(tickerid,_tf,ta.rsi(src,length))
fvwap(src)=> request.security(syminfo.tickerid,_tf,ta.vwap(src))
trendDetSecurity(tf,exp) => request.security(syminfo.tickerid,tf,exp)
//Declaring every Ticker
bn1 = frsi(bn,close,len)
sb = frsi(sbi,close,len)
ax = frsi(axis,close,len)
bar = frsi(baroda,close,len)
pn = frsi(pnb,close,len)
fe = frsi(fed,close,len)
id = frsi(idfc,close,len)
_in = frsi(indusind,close,len)
ic = frsi(icici,close,len)
ban = frsi(bandhan,close,len)
ko = frsi(kotak,close,len)
hd = frsi(hdfc,close,len)
ind_v = frsi(vix,close,len)
average = (bn1 * bn_wt) + (sb * sbi_wt) + (ax * axis_wt) + (bar * baroda_wt) + (pn * pnb_wt) + (fe * fed_wt) + (id * idfc_wt) + (_in * indusind_wt) + (ic * icici_wt) + (ban * bandhan_wt) + (ko * kotak_wt ) + (hd * hdfc_wt ) + (ind_v * vix_wt )
//Average of All tickers
//average = math.avg(bn1,sb,ax,bar,pn,fe,id,_in,ic,ban,ko,hd,ind_v)
var int smoothingperiod = 124
avgColume = ta.hma((average - 50),smoothingperiod)
avgLine = avgColume / 2
//Banknifty
ma = ta.ema(avgColume,55)
//Two Moving avrage to identify the trend change
var int volTher = 22
_price = trendDetSecurity(_revTF,ta.ema(avgColume,3))[1] // Price
_volume = trendDetSecurity(_revTF,ta.wma(avgColume,21))[1] // volume
osc = 100 * (_price - _volume) / _price
longfilter = _price > _volume ? color.rgb(0, 238, 8,50) : _price < volume ? color.rgb(255, 123, 0,50) :color.gray
h1= plot(_reversal ? _price : na,title="Price",linewidth = 3,color=longfilter)
h2= plot(_reversal ? _volume : na,title="Volume",linewidth=3,color=longfilter)
plot(avgColume ? avgColume : 1,style=plot.style_columns,color=avgColume > ma ? color.aqua : avgColume < ma ? color.new(#e91e63,0) :color.silver,linewidth=3,trackprice=true,title="Volume")
fill(h1,h2,color=longfilter)
|
Variety RSI w/ Dynamic Zones [Loxx] | https://www.tradingview.com/script/d8YPvDj7-Variety-RSI-w-Dynamic-Zones-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 56 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Variety RSI w/ Dynamic Zones [Loxx]",
shorttitle='VRSIDZ [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxvarietyrsi/1
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
lightbluecolor = #4f6cdf
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Inner Crossover'
SM05 = 'Outer Crossover'
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)
else if type == "VWMA"
sig := ta.rma(src, len)
sig
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
rsiper = input.int(15, "Period", group = "Basic Settings")
rsitype = input.string("Regular", "RSI type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed"], group = "Basic Settings")
smthper = input.int(15, "Smooth Period", group = "Basic Settings")
type = input.string("SMA", "RSI Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA", "VWMA"], group = "Basic Settings")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buy1 = input.float(0.2, "Dynamic Zone Buy Probability Level 1", group = "Levels Settings", maxval = 0.49, step = 0.01)
buy2 = input.float(0.06, "Dynamic Zone Buy Probability Level 2", group = "Levels Settings", maxval = 0.49, step = 0.01)
sell1 = input.float(0.2, "Dynamic Zone Sell Probability Level 1", group = "Levels Settings", maxval = 0.49, step = 0.01)
sell2 = input.float(0.06, "Dynamic Zone Sell Probability Level 2", group = "Levels Settings", maxval = 0.49, step = 0.01)
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04, SM05], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "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
rsimode = switch rsitype
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
srcout = variant(type, src, smthper)
rsi = loxxvarietyrsi.rsiVariety(rsimode, srcout, rsiper)
sig = nz(rsi[1])
bl1 = loxxdynamiczone.dZone("buy", rsi, buy1, dzper)
bl2 = loxxdynamiczone.dZone("buy", rsi, buy2, dzper)
sl1 = loxxdynamiczone.dZone("sell", rsi, sell1, dzper)
sl2 = loxxdynamiczone.dZone("sell", rsi, sell2, dzper)
zli = loxxdynamiczone.dZone("sell", rsi, 0.5 , dzper)
state = 0.
if sigtype == SM02
if (rsi < sig)
state :=-1
if (rsi > sig)
state := 1
else if sigtype == SM03
if (rsi < zli)
state :=-1
if (rsi > zli)
state := 1
else if sigtype == SM04
if (rsi < bl1)
state :=-1
if (rsi > sl1)
state := 1
else if sigtype == SM05
if (rsi < bl2)
state :=-1
if (rsi > sl2)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(rsi, "RSI", color = colorout, linewidth = 3)
plot(bl1, "buy lvl 1", color = lightgreencolor)
plot(bl2, "buy lvl 2", color = greencolor)
plot(sl1, "sell lvl 1", color = lightredcolor)
plot(sl2, "sell lvl 1", color = redcolor)
plot(zli, "mid", color = color.silver)
barcolor(colorbars ? colorout : na)
goLong = colorout == greencolor and colorout[1] != greencolor
goShort = colorout == redcolor and colorout[1] != redcolor
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Variety RSI w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Variety RSI w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
hline(-10, color = color.new(color.white, 100), editable = false) // to force signal to not be covered
hline(110, color = color.new(color.white, 100), editable = false) // to force signal to not be covered
|
Corrected RSI w/ Floating Levels [Loxx] | https://www.tradingview.com/script/qpp48cVi-Corrected-RSI-w-Floating-Levels-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("Corrected RSI w/ Floating Levels [Loxx]",
shorttitle='CRSIFL [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
import loxx/loxxvarietyrsi/1
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Levels Crossover'
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
rsiper = input.int(32, "Period", group = "RSI Settings")
rsitype = input.string("RSX", "RSI type", options = ["RSX", "Regular", "Slow", "Rapid", "Harris", "Cuttler", "Ehlers Smoothed"], group = "RSI Settings")
crctper = input.int(0, "Correction Period", group = "RSI Settings")
lvlper = input.int(50, "Levels Period", group = "Levels Settings")
lvlup = input.int(90, "Level Up", group = "Levels Settings")
lvldn = input.int(10, "Level Down", group = "Levels Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "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
rsimode = switch rsitype
"RSX" => "rsi_rsx"
"Regular" => "rsi_rsi"
"Slow" => "rsi_slo"
"Rapid" => "rsi_rap"
"Harris" => "rsi_har"
"Cuttler" => "rsi_cut"
"Ehlers Smoothed" => "rsi_ehl"
=> "rsi_rsi"
devper = (crctper>0) ? crctper : (crctper<0) ? 0 : rsiper
lvlperout = (lvlper>1) ? lvlper : rsiper
val = loxxvarietyrsi.rsiVariety(rsimode, src, rsiper)
cor = 0.
v1 = math.pow(ta.stdev(val, devper), 2)
v2 = math.pow(nz(cor[1]) - val, 2)
c = (v2 < v1 or v2 == 0) ? 0 : 1 - v1 / v2
cor := nz(cor[1]) + c * (val - nz(cor[1]))
sig = nz(cor[1])
min = ta.lowest(cor, lvlperout)
max = ta.highest(cor, lvlperout)
rng = max - min
levelUp = min + lvlup * rng / 100.0
levelDn = min + lvldn * rng / 100.0
levelMi = (levelUp + levelDn) * 0.5
state = 0.
if sigtype == SM02
if (cor < sig)
state :=-1
if (cor > sig)
state := 1
else if sigtype == SM03
if (cor < levelMi)
state :=-1
if (cor > levelMi)
state := 1
else if sigtype == SM04
if (cor < levelDn)
state :=-1
if (cor > levelUp)
state := 1
colorcor = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(val, color = color.yellow, title= "RSI", linewidth = 1)
plot(cor, color = colorcor, title= "Corrected RSI", linewidth = 3)
plot(levelUp, "High Level", color = color.gray)
plot(levelDn, "Low Level" ,color = color.gray )
plot(levelMi, "Middle", color = bar_index % 2 ? color.white : na)
barcolor(colorbars ? colorcor : na)
goLong = sigtype == SM02 ? ta.crossover(cor, sig) : sigtype == SM03 ? ta.crossover(cor, levelMi) : ta.crossover(cor, levelUp)
goShort = sigtype == SM02 ? ta.crossunder(cor, sig) : sigtype == SM03 ? ta.crossunder(cor, levelMi) : ta.crossunder(cor, levelDn)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.tiny)
alertcondition(goLong, title="Long", message="Corrected RSI w/ Floating Levels [Loxx]: Long\nSymbol: {{ticker}}\nsrc: {{close}}")
alertcondition(goShort, title="Short", message="Corrected RSI w/ Floating Levels [Loxx]: Short\nSymbol: {{ticker}}\nsrc: {{close}}")
|
Nyquist Moving Average (NMA) MACD [Loxx] | https://www.tradingview.com/script/vmDtUvyZ-Nyquist-Moving-Average-NMA-MACD-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("Nyquist Moving Average (NMA) MACD [Loxx]",
shorttitle= "NMAMACD [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
SM02 = 'Signal'
SM03 = 'Middle Crossover'
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)
else if type == "VWMA"
sig := ta.rma(src, len)
sig
_nma(type, src, nper, smper)=>
smperout = smper
float lambda = nper / smper
if(lambda < 2.0)
lambda := 2.0
smperout := math.ceil(nper / 2.0)
alpha = lambda * (nper - 1.0) / (nper - lambda)
sample = variant(type, src, nper)
gamma = variant(type, sample, smperout)
nma = (alpha + 1.0) * sample - alpha * gamma
nma
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
NMA_Fast = input.int(12, "Fast Nyquist Period", group = "Basic Settings", tooltip = "must be at least twice of sample length")
NMA_Fast_sample = input.int(6, "Fast Sample Period", group = "Basic Settings")
ftype = input.string("SMA", "Fast MACD MA Type", options = ["EMA", "WMA", "RMA", "SMA", "VWMA"], group = "Basic Settings")
NMA_Slow = input.int(26, "Slow Nyquist Period", group = "Basic Settings", tooltip = "must be at least twice of sample length")
NMA_Slow_sample = input.int(13, "Slow Sample Period", group = "Basic Settings")
stype = input.string("SMA", "Slow MACD MA Type", options = ["EMA", "WMA", "RMA", "SMA", "VWMA"], group = "Basic Settings")
SignalSMA = input.int(9, "Signal Period", group = "Signal Settings")
Magnifier = input.float(1.5, "Signal Magnifier", group = "Signal Settings")
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignals = input.bool(false, "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
alpha = 2.0 / (SignalSMA + 1.0)
alpha_1 = 1.0 - alpha
macd = _nma(ftype, src, NMA_Fast, NMA_Fast_sample) - _nma(stype, src, NMA_Slow, NMA_Slow_sample)
sig = 0.
sig := alpha * macd + alpha_1 * nz(sig[1])
histo = (macd - sig) * Magnifier
state = 0.
mid = 0.
if sigtype == SM02
if (macd < sig)
state :=-1
if (macd > sig)
state := 1
else if sigtype == SM03
if (macd < mid)
state :=-1
if (macd > mid)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(macd, color = colorout, linewidth = 3)
plot(sig, color = color.white)
plot(histo, style = plot.style_histogram, color = color.new(color.white, 60))
plot(mid, "Middle", color = bar_index % 2 ? color.white : na)
barcolor(colorbars ? colorout : na)
goLong = sigtype == SM02 ? ta.crossover(macd, sig) : ta.crossover(macd, mid)
goShort = sigtype == SM02 ? ta.crossunder(macd, sig) : ta.crossunder(macd, mid)
plotshape(goLong and showsignals, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.tiny)
plotshape(goShort and showsignals, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.tiny)
alertcondition(goLong, title="Long", message="Nyquist Moving Average (NMA) MACD [Loxx] Long\nSymbol: {{ticker}}\nsrc: {{close}}")
alertcondition(goShort, title="Short", message="Nyquist Moving Average (NMA) MACD [Loxx]: Short\nSymbol: {{ticker}}\nsrc: {{close}}")
|
Custom Index | https://www.tradingview.com/script/ctBwRmE9-Custom-Index/ | EsIstTurnt | https://www.tradingview.com/u/EsIstTurnt/ | 114 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EsIstTurnt
//@version=5
indicator("My script")
//TimeFrame
tf = input.timeframe(defval='' ,title='TimeFrame ' ,group='resolution')
//Get Sources
source=input.source(close,title='Source ')
Tech =input.bool(true,title='Include Tech? ')
Oil =input.bool(true,title='Include Oil? ')
Payment=input.bool(true,title='Include Payment? ')
Banks =input.bool(true,title='Include Banks? ')
Health =input.bool(true,title='Include Health? ')
Manage =input.bool(true,title='Include Investment Management?')
MA =input.bool(true,title='Show Moving Averages?')
pTech =input.bool(false,title='Show Tech? ')
pOil =input.bool(false,title='Show Oil? ')
pPayment=input.bool(false,title='Show Payment? ')
pBanks =input.bool(false,title='Show Banks? ')
pHealth =input.bool(false,title='Show Health? ')
pFinance =input.bool(false,title='Show Investment Management?')
GoldsPoV=input.bool(false,title='Measure in Gold?')
//=input.bool(true,title='Include ?')
//=input.bool(true,title='Include ?')
s1 =request.security(input.symbol('META') ,tf,source)//Tech
s2 =request.security(input.symbol('AMZN') ,tf,source)
s3 =request.security(input.symbol('GOOG') ,tf,source)
s4 =request.security(input.symbol('AAPL') ,tf,source)
s5 =request.security(input.symbol('NFLX') ,tf,source)
s6 =request.security(input.symbol('INDEX:BTCUSD') ,tf,source)
s7 =request.security(input.symbol('INDEX:ETHUSD') ,tf,source)
s8 =request.security(input.symbol('NVDA') ,tf,source)
s9 =request.security(input.symbol('AMD') ,tf,source)
s10=request.security(input.symbol('INTC'),tf,source)
s11=request.security(input.symbol('XOM') ,tf,source)//Oil
s12=request.security(input.symbol('CVX') ,tf,source)
s13=request.security(input.symbol('USOIL') ,tf,source)
s14=request.security(input.symbol('BLK') ,tf,source)//Finance
s15=request.security(input.symbol('BRKB'),tf,source)
s16=request.security(input.symbol('SCHW') ,tf,source)
s17=request.security(input.symbol('MA') ,tf,source)//Payment
s18=request.security(input.symbol('V') ,tf,source)
s19=request.security(input.symbol('PYPL') ,tf,source)
s20=request.security(input.symbol('SQ') ,tf,source)
s21=request.security(input.symbol('JNJ') ,tf,source)//Health
s22=request.security(input.symbol('PFE') ,tf,source)
s23=request.security(input.symbol('AZN') ,tf,source)
s24=request.security(input.symbol('MRK') ,tf,source)
s25=request.security(input.symbol('BAC') ,tf,source)//Banks
s26=request.security(input.symbol('JPM') ,tf,source)
s27=request.security(input.symbol('WFC') ,tf,source)
s28=request.security(input.symbol('GS') ,tf,source)
s29=request.security(input.symbol('MS') ,tf,source)
tech =Tech ?GoldsPoV?(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10)/request.security('Gold',tf,source):s1+s2+s3+s4+s5+s6+s7+s8+s9+s10:0
oil =Oil ?GoldsPoV?(s11+s12+s13 )/request.security('Gold',tf,source):s11+s12+s13 :0
finance =Manage ?GoldsPoV?(s14+s15+s16 )/request.security('Gold',tf,source):s14+s15+s16 :0
payment=Payment ?GoldsPoV?(s17+s18+s19+s20 )/request.security('Gold',tf,source):s17+s18+s19+s20 :0
health =Health ?GoldsPoV?(s21+s22+s23+s24 )/request.security('Gold',tf,source):s21+s22+s23+s24 :0
banks =Banks ?GoldsPoV?(s25+s26+s27+s28+s29 )/request.security('Gold',tf,source):s25+s26+s27+s28+s29 :0
plot_tech =pTech ?s1+s2+s3+s4+s5+s6+s7+s8+s9:0
plot_oil =pOil ?s10+s11+s12+s13:0
plot_finance =pFinance ?s13+s14+s15:0
plot_payment=pPayment?s16+s17+s18+s19:0
plot_health =pHealth ?s20+s21+s22+s23:0
plot_banks =pBanks ?s24+s25+s26+s27+s28:0
combine=(tech+oil+finance+payment+health+banks)
ma1=ta.sma(combine,input.int(32))
ma2=ta.sma(combine,input.int(128))
ma3=ta.sma(combine,input.int(200))
ma4=ta.linreg(combine,input.int(64),0)
ma5=ta.linreg(combine,input.int(256),0)
ma6=ta.linreg(combine,input.int(512),0)
plot(MA?ma1:na,color=#02b78c)
plot(MA?ma2:na,color=#acfb00)
plot(MA?ma3:na,color=#b07f08)
plot(MA?ma4:na,color=#00afe5)
plot(MA?ma5:na,color=#45a808)
plot(MA?ma6:na,color=#c5e606)
plot(combine ,color=combine>combine[1]?#acfb00:#ff0000,linewidth=3)
plot(pTech?plot_tech :na,color=color.blue,linewidth=1)
plot(pOil?plot_oil :na,color=color.purple,linewidth=1)
plot(pFinance?plot_finance :na,color=color.white,linewidth=1)
plot(pPayment?plot_payment:na,color=color.orange,linewidth=1)
plot(pHealth?plot_health :na,color=color.red,linewidth=1)
|
Pips-Stepped, OMA-Filtered, Ocean NMA [Loxx] | https://www.tradingview.com/script/YZ5QPqfk-Pips-Stepped-OMA-Filtered-Ocean-NMA-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("Pips-Stepped, OMA-Filtered, Ocean NMA [Loxx]",
shorttitle='STDSOMAFONMA [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
_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
_filt(src, len, filter)=>
price = src
filtdev = filter * ta.stdev(src, len)
price := math.abs(price - price[1]) < filtdev ? price[1] : price
price
_oma(src, len, const, 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 = len
noise = 0.00000000001
minPeriod = averagePeriod/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 := math.ceil(((signal / noise) * (maxPeriod - minPeriod)) + minPeriod)
//calc jurik momentum
alpha = (2.0 + const) / (1.0 + const + 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
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
namper = input.int(40, "NMA Period", minval=1, group = "Basic Settings")
len = input.int(10, "Average Period", minval = 1, group = "Basic Settings")
const = input.float(-0.5, "Speed", step = .01, group = "Basic Settings")
adapt = input.bool(true, "Make it adaptive?", group = "Basic Settings")
steps = input.float(25.0, "Steps in Pips", group = "Pips Filter Settings")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showSigs = input.bool(true, "Show signals?", group= "UI Options")
flat = input.bool(true, "Flat-level colroing?", 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
maout = _oma(src, len, const, adapt)
mom = maout - nz(maout[1])
momRatio = 0., sumMomen = 0., ratio = 0.
for k = 0 to namper - 1
sumMomen += math.abs(nz(mom[k]))
momRatio += nz(mom[k]) * (math.sqrt(k + 1) - math.sqrt(k))
ratio := sumMomen != 0 ? math.abs(momRatio)/sumMomen : ratio
nma = 0.
nma := nz(nma[1]) + ratio * (src - nz(nma[1]))
val = 0.
_stepSize = (steps > 0 ? steps : 0) * syminfo.mintick * math.pow(10, _declen() % 2)
if (_stepSize > 0)
_diff = nma - nz(val[1])
val := nz(val[1]) + ((_diff < _stepSize and _diff > -_stepSize) ? 0 : int(_diff / _stepSize) * _stepSize)
else
val := (_stepSize > 0) ? math.round(nma / _stepSize) * _stepSize : nma
colorout = val > val[1] ? greencolor : val < val[1] ? redcolor : color.gray
goLong_pre = ta.crossover(val, val[1])
goShort_pre = ta.crossunder(val, val[1])
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch
goLong = goLong_pre and ta.change(contSwitch)
goShort = goShort_pre and ta.change(contSwitch)
plot(val,"Pips-Stepped, OMA-Filtered, Ocean NMA", color = flat ? colorout : (contSwitch == 1 ? greencolor : redcolor), linewidth = 3)
barcolor(colorbars ? contSwitch == 1 ? greencolor : redcolor : 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="Pips-Stepped, OMA-Filtered, Ocean NMA [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Pips-Stepped, OMA-Filtered, Ocean NMA [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Candle Strength Indicator | https://www.tradingview.com/script/huFhtWDE-Candle-Strength-Indicator/ | PtGambler | https://www.tradingview.com/u/PtGambler/ | 180 | 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/
// © PtGambler
//@version=5
indicator(title='Candle Strength Indicator', shorttitle='[Pt] CSI')
ma_len = input.int(10, "MA period")
smooth_len = input.int(5, "Smoothing period")
ma_len2 = input.int(5, "Signal line MA period")
smooth_len2 = input.int(3, "Signal line Smoothing period")
lbR = input(2, title='Pivot Lookback Right', group = "Divergence - Pivot based")
lbL = input(5, title='Pivot Lookback Left', group = "Divergence - Pivot based")
rangeUpper = input(60, title='Max of Lookback Range', group = "Divergence - Pivot based")
rangeLower = input(5, title='Min of Lookback Range', group = "Divergence - Pivot based")
plotBull = input(false, title='Plot Bullish', group = "Divergence - Pivot based")
plotHiddenBull = input(false, title='Plot Hidden Bullish', group = "Divergence - Pivot based")
plotBear = input(false, title='Plot Bearish', group = "Divergence - Pivot based")
plotHiddenBear = input(false, title='Plot Hidden Bearish', group = "Divergence - Pivot based")
upBar = (high - open) / open * 10000 + (close - open) / open * 10000
downBar = (low - open) / open * 10000 + (close - open) / open * 10000
m = math.avg(upBar, downBar)
ma = ta.rma(m,ma_len)
ma_smoothed = ta.sma(ma, smooth_len)
ma2 = ta.rma(m,ma_len2)
ma_smoothed2 = ta.sma(ma2, smooth_len2)
hline(0, color=color.gray, linestyle=hline.style_dashed)
ma_plot = plot(ma_smoothed, title='CSI', color = ma_smoothed > 0 and ma_smoothed > ma_smoothed[1] ? color.green : ma_smoothed > 0 and ma_smoothed < ma_smoothed[1] ? color.new(color.green,50) : ma_smoothed < 0 and ma_smoothed < ma_smoothed[1] ? color.red : color.new(color.red,50) , style = plot.style_columns)
ma2_plot = plot(ma_smoothed2, title='CSI signal', color = ma_smoothed2 > 0 ? color.green : color.red, linewidth = 2, display = display.none)
// Divergence (Pivot based) -------------------------------------------------------------
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
plFound = na(ta.pivotlow(ma_smoothed, lbL, lbR)) ? false : true
phFound = na(ta.pivothigh(ma_smoothed, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
//------------------------------------------------------------------------------
// Regular Bullish
// Osc: Higher Low
oscHL = ma_smoothed[lbR] > ta.valuewhen(plFound, ma_smoothed[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 ? ma_smoothed[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=2, color=bullCond ? bullColor : noneColor)
plotshape(bullCond ? ma_smoothed[lbR] : na, offset=-lbR, title='Regular Bullish Label', text=' Bull ', style=shape.labelup, location=location.absolute, color=color.new(bullColor, 0), textcolor=color.new(textColor, 0))
//------------------------------------------------------------------------------
// Hidden Bullish
// Osc: Lower Low
oscLL = ma_smoothed[lbR] < ta.valuewhen(plFound, ma_smoothed[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 ? ma_smoothed[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=2, color=hiddenBullCond ? hiddenBullColor : noneColor)
plotshape(hiddenBullCond ? ma_smoothed[lbR] : na, offset=-lbR, title='Hidden Bullish Label', text=' H Bull ', style=shape.labelup, location=location.absolute, color=color.new(bullColor, 0), textcolor=color.new(textColor, 0))
//------------------------------------------------------------------------------
// Regular Bearish
// Osc: Lower High
oscLH = ma_smoothed[lbR] < ta.valuewhen(phFound, ma_smoothed[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 ? ma_smoothed[lbR] : na, offset=-lbR, title='Regular Bearish', linewidth=2, color=bearCond ? bearColor : noneColor)
plotshape(bearCond ? ma_smoothed[lbR] : na, offset=-lbR, title='Regular Bearish Label', text=' Bear ', style=shape.labeldown, location=location.absolute, color=color.new(bearColor, 0), textcolor=color.new(textColor, 0))
//------------------------------------------------------------------------------
// Hidden Bearish
// Osc: Higher High
oscHH = ma_smoothed[lbR] > ta.valuewhen(phFound, ma_smoothed[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 ? ma_smoothed[lbR] : na, offset=-lbR, title='Hidden Bearish', linewidth=2, color=hiddenBearCond ? hiddenBearColor : noneColor)
plotshape(hiddenBearCond ? ma_smoothed[lbR] : na, offset=-lbR, title='Hidden Bearish Label', text=' H Bear ', style=shape.labeldown, location=location.absolute, color=color.new(bearColor, 0), textcolor=color.new(textColor, 0))
|
Dynamic Zones Polychromatic Momentum Candles [Loxx] | https://www.tradingview.com/script/FobvhfB1-Dynamic-Zones-Polychromatic-Momentum-Candles-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 153 | 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("Dynamic Zones Polychromatic Momentum Candles [Loxx]",
shorttitle='DZPMC [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxdynamiczone/3
import loxx/loxxjuriktools/1
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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")
smthper = input.int(5, "Jurik Smoothing Period", group = "Jurik Filter Settings")
phs = input.float(0, "Jurik Phase", group = "Jurik Filter Settings")
dzper = input.int(35, "Dynamic Zone Period", group = "Dynamic Zone Settings")
dzbuyprob = input.float(0.05, "Dynamic Zone Buy Probability", group = "Dynamic Zone Settings")
dzsellprob = input.float(0.05, "Dynamic Zone Buy Probability", group = "Dynamic Zone Settings")
clrup = input.color(greencolor, "Up color", group = "UI Options")
clrdn = input.color(redcolor, "Down color", 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
sumMom = 0.,sumWgh = 0.
for k = 0 to per - 1
weight = math.sqrt(k+1)
sumMom += (src - nz(src[k+1]))/weight
sumWgh += weight
out = 0.
out := sumWgh != 0 ? loxxjuriktools.jurik_filt(sumMom/sumWgh, smthper, phs) : loxxjuriktools.jurik_filt(0, smthper, phs)
obLine = loxxdynamiczone.dZone("buy", out, dzbuyprob, dzper)
osLine = loxxdynamiczone.dZone("sell", out, dzsellprob, dzper)
ratios = 0.
ratio = math.min(out, osLine)
ratio := math.max(ratio ,obLine)
ratio := (ratio-obLine)/(osLine-obLine)
ratios := ratio
colorout = color.from_gradient(100.0 * ratios, 0, 101, clrdn, clrup)
barcolor(colorout)
|
Hussarya Volume cumulated. Buy Sell. | https://www.tradingview.com/script/mzCuoULH/ | charthussars | https://www.tradingview.com/u/charthussars/ | 49 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © hussarya
//@version=5
indicator("hussarya wolume Buy And Sell cumulated updated", format=format.volume)
c = input(true, "Wolumen binance + bybit + coinbase + okx + kraken")
log = input(false, "skala logarytmiczna log10")
x = timeframe.period
binance = request.security("BINANCE:BTCUSDT", x, volume)
bybit = request.security("BYBIT:BTCUSDT", x, volume)
coinbase = request.security("COINBASE:BTCUSDT", x, volume)
ftx = request.security("OKX:BTCUSDT", x, volume)
kucoin = request.security("KRAKEN:BTCUSDT", x, volume)
volume2 = binance + bybit + coinbase + ftx + kucoin
volume_sum = if c == false
volume
else
volume2
zielona=((high-low)/(2*(high-low)-(close-open))) //sila zakupu
czerwona=((high-low)/(2*(high-low)-(open-close))) //sila sprzedazy
buy = if open > close
volume_sum * zielona
else
volume_sum - (volume_sum * czerwona)
sell = if open > close
(volume_sum - buy)
else
(volume_sum * czerwona)
c1 = if buy > sell
volume_sum
else
0 - volume_sum
a1 = buy
b1 = sell
//a1 /= if buy > sell
// buy
//else
// 0
//b1 = if buy < sell
// sell
//else
// 0
volume_sum_log = math.log10(volume_sum)
a1_log = math.log10(a1)
b1_log = math.log10(b1)
wol = if log == false
volume_sum
else
volume_sum_log
aa = if log == false
a1
else
a1_log
bb = if log == false
b1
else
b1_log
plot(wol, style=plot.style_columns, color=#CCCCCC, title="Total volume")
//plot(aa, style=plot.style_columns, color=#00cc00, title="Buy Volume")
plot(bb, style=plot.style_columns, color=#cc0000, title="Sell Volume")
plot(aa, style=plot.style_columns, color=#00cc00, title="Buy Volume")
|
Double Dynamic Zone RSX [Loxx] | https://www.tradingview.com/script/xz8ISBOU-Double-Dynamic-Zone-RSX-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 84 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Double Dynamic Zone RSX [Loxx]",
shorttitle='DDZRSX [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxrsx/1
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
per = input.int(14, "Period", group = "Basic Settings")
src = input.source(hlc3, "Source", group = "Basic Settings")
dzper = input.int(70, "Dynamic Zone Period", group = "Basic Settings")
buy1 = input.float(0.1 , "Dynamic Zone Buy Probability Level 1", group = "Levels Settings", maxval = 0.49)
buy2 = input.float(0.25 , "Dynamic Zone Buy Probability Level 2", group = "Levels Settings", maxval = 0.49)
sell1 = input.float(0.1 , "Dynamic Zone Sell Probability Level 1", group = "Levels Settings", maxval = 0.49)
sell2 = input.float(0.25 , "Dynamic Zone Sell Probability Level 2", group = "Levels Settings", maxval = 0.49)
rsx = loxxrsx.rsx(src, per)
buylout1 = loxxdynamiczone.dZone("buy", rsx, buy1, dzper)
buylout2 = loxxdynamiczone.dZone("buy", rsx, buy2, dzper)
sellout1 = loxxdynamiczone.dZone("sell", rsx, sell1, dzper)
sellout2 = loxxdynamiczone.dZone("sell", rsx, sell2, dzper)
midl = loxxdynamiczone.dZone("sell", rsx, 0.5, dzper)
plot(buylout1, "buy lvl 1", color = greencolor)
plot(buylout2, "buy lvl 2", color = bar_index % 2 ? greencolor : na)
plot(sellout1, "sell lvl 1", color = redcolor)
plot(sellout2, "sell lvl 1", color = bar_index % 2 ? redcolor : na)
plot(midl, "mid lvl", color = bar_index % 2 ? color.gray : na)
colorout = rsx < buylout1 ? greencolor : rsx > sellout1 ? redcolor : color.gray
plot(rsx, "RSX", color = colorout, linewidth = 2)
|
High volume zone | https://www.tradingview.com/script/ceOjGQmI-High-volume-zone/ | remtradepro | https://www.tradingview.com/u/remtradepro/ | 89 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © remtradepro
//@version=5
indicator("High volume zone", overlay=true)
i_res = input.timeframe('1', "Resolution", options=['1', '3','5','10','15'])
amount = input.int(1000, "Total volume", minval=1, maxval=100000, step=1)
max = input.int(2, "Max zone display per candle", minval=1, maxval=100000, step=1)
arrVolume = request.security_lower_tf(syminfo.tickerid, i_res, volume, false)
arrClose = request.security_lower_tf(syminfo.tickerid, i_res, close, false)
arrOpen = request.security_lower_tf(syminfo.tickerid, i_res, open, false)
bgColor = input.color(color.rgb(255,128,0,90), "Background Color")
borderColor = input.color(color.rgb(255,128,0,0), "Border Color")
textBgColor = input.color(color.rgb(255,128,0,100), "Text Background Color")
textColor = input.color(color.rgb(255,255,255,0), "Text Color")
var int myInc = 0
myInc := 0
arrDisplay = array.new_float(0,0)
arrDisplayClose = array.new_float(0,0)
arrDisplayOpen = array.new_float(0,0)
for index in arrVolume
if index > amount
if array.size(arrDisplay)<max
array.push(arrDisplay, math.round(array.get(arrVolume,myInc)))
array.push(arrDisplayClose, array.get(arrClose,myInc))
array.push(arrDisplayOpen, array.get(arrOpen,myInc))
box.new(left=bar_index[1], top= math.round(array.get(arrClose,myInc)), right=bar_index[0]+1, bottom=math.round(array.get(arrOpen,myInc)), bgcolor=bgColor, border_color=borderColor )
myInc +=1
label.new(array.size(arrDisplay)>0?bar_index:na, high, "v =" + str.tostring(arrDisplay), color=textBgColor, textcolor=textColor)
|
Variety Moving Averages w/ Dynamic Zones [Loxx] | https://www.tradingview.com/script/BEFQJaMj-Variety-Moving-Averages-w-Dynamic-Zones-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("Variety Moving Averages w/ Dynamic Zones [Loxx]",
shorttitle="VMAEZ [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
import loxx/loxxmas/1
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Outer Crossover'
SM05 = 'Inner Crossover'
smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "maout", "Kaufman"], group = "Basic Settings")
srcin = input.string("Close", "Source", group= "Basic 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)"])
type = input.string("Triple Exponential Moving Average - TEMA", "Price Filter Type", options = ["ADXvma - Average Directional Volatility Moving Average", "Ahrens Moving Average"
, "Alexander Moving Average - ALXMA", "Double Exponential Moving Average - DEMA", "Double Smoothed Exponential Moving Average - DSEMA"
, "Exponential Moving Average - EMA", "Fast Exponential Moving Average - FEMA", "Fractal Adaptive Moving Average - FRAMA"
, "Hull Moving Average - HMA", "IE/2 - Early maout 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")
maper = input.int(14, "Period", minval=1, group = "Basic Settings")
dzper = input.int(35, "Dynamic Zone Period", group = "Levels Settings")
buy1 = input.float(0.1 , "Dynamic Zone Buy Probability Level 1", group = "Levels Settings", maxval = 0.49)
buy2 = input.float(0.25 , "Dynamic Zone Buy Probability Level 2", group = "Levels Settings", maxval = 0.49)
sell1 = input.float(0.1 , "Dynamic Zone Sell Probability Level 1", group = "Levels Settings", maxval = 0.49)
sell2 = input.float(0.25 , "Dynamic Zone Sell Probability Level 2", group = "Levels Settings", maxval = 0.49)
sigtype = input.string(SM03, "Signal type", options = [SM02, SM03, SM04, SM05], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group= "UI Options")
ShowMiddleLine = input.bool(true, "Show middle line?", group = "UI Options")
filllevels = input.bool(false, "Show fill colors?", group = "UI Options")
showSigs = input.bool(false, "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 maout 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
maout = variant(type, src, maper)
sig = nz(maout[1])
bl1 = loxxdynamiczone.dZone("buy", maout, buy1, dzper)
bl2 = loxxdynamiczone.dZone("buy", maout, buy2, dzper)
sl1 = loxxdynamiczone.dZone("sell", maout, sell1, dzper)
sl2 = loxxdynamiczone.dZone("sell", maout, sell2, dzper)
zli = loxxdynamiczone.dZone("sell", maout, 0.5 , dzper)
state = 0.
if sigtype == SM02
if (maout<sig)
state :=-1
if (maout>sig)
state := 1
else if sigtype == SM03
if (maout<zli)
state :=-1
if (maout>zli)
state := 1
else if sigtype == SM04
if (maout<bl1)
state :=-1
if (maout>sl1)
state := 1
else if sigtype == SM05
if (maout<bl2)
state :=-1
if (maout>sl2)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(maout, color = colorout, linewidth = 3)
bl1pl = plot(bl1, "buy lvl 1", color = greencolor)
bl2pl = plot(bl2, "buy lvl 2", color = lightgreencolor)
sl1pl = plot(sl1, "sell lvl 1", color = redcolor)
sl2pl = plot(sl2, "sell lvl 1", color = lightredcolor)
midpl = plot(ShowMiddleLine ? zli : na, "mid lvl", color = color.white)
fill(bl1pl, bl2pl, color = filllevels ? color.new(greencolor, 85) : na)
fill(bl2pl, midpl, color = filllevels ? color.new(greencolor, 95): na)
fill(sl1pl, sl2pl, color = filllevels ? color.new(redcolor, 85): na)
fill(sl2pl, midpl, color = filllevels ? color.new(redcolor, 95): na)
barcolor(colorbars ? colorout : na)
goLong_pre =
sigtype == SM02 ? ta.crossover(maout, sig) :
sigtype == SM03 ? ta.crossover(maout, zli) :
sigtype == SM04 ? ta.crossover(maout, sl1) :
ta.crossover(maout, sl2)
goShort_pre =
sigtype == SM02 ? ta.crossunder(maout, sig) :
sigtype == SM03 ? ta.crossunder(maout, zli) :
sigtype == SM04 ? ta.crossunder(maout, bl1) :
ta.crossunder(maout, bl2)
contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch
goLong = goLong_pre and ta.change(contSwitch)
goShort = goShort_pre and ta.change(contSwitch)
alertcondition(goLong, title="Long", message="Variety Moving Averages w/ Dynamic Zones [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Variety Moving Averages w/ Dynamic Zones [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
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)
|
Dynamic Zone Range on OMA [Loxx] | https://www.tradingview.com/script/vAd9Sqbv-Dynamic-Zone-Range-on-OMA-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 43 | 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("Dynamic Zone Range on OMA [Loxx]",
shorttitle='DDZROMA [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxdynamiczone/3
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
SM02 = 'Slope'
SM03 = 'Middle Crossover'
SM04 = 'Inner Crossover'
SM05 = 'Outer Crossover'
_oma(src, len, const, 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 = len
noise = 0.00000000001
minPeriod = averagePeriod/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 := math.ceil(((signal / noise) * (maxPeriod - minPeriod)) + minPeriod)
//calc jurik momentum
alpha = (2.0 + const) / (1.0 + const + 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
HLR_Range = input.int(25, "HLR Range", group = "Basic Settings")
len = input.int(15, "Average Period", minval = 1, group = "Basic Settings")
const = input.float(.5, "Speed", step = .01, group = "Basic Settings")
adapt = input.bool(true, "Make it adaptive?", group = "Basic Settings")
dzper = input.int(70, "Dynamic Zone Period", group = "Levels Settings")
buy1 = input.float(0.2, "Dynamic Zone Buy Probability Level 1", group = "Levels Settings")
buy2 = input.float(0.06, "Dynamic Zone Buy Probability Level 2", group = "Levels Settings")
sell1 = input.float(0.2, "Dynamic Zone Sell Probability Level 1", group = "Levels Settings")
sell2 = input.float(0.06, "Dynamic Zone Sell Probability Level 2", group = "Levels Settings")
sigtype = input.string(SM02, "Signal type", options = [SM02, SM03, SM04, SM05], group = "Signal Settings")
colorbars = input.bool(false, "Color bars?", group= "UI Options")
ShowMiddleLine = input.bool(true, "Show middle line?", group = "UI Options")
filllevels = input.bool(false, "Show fill colors?", group = "UI Options")
showsignals = input.bool(false, "Show signals?", group = "UI Options")
hhv = _oma(ta.highest(high, HLR_Range), len, const, adapt)
llv = _oma(ta.lowest(low, HLR_Range), len, const, adapt)
m_pr = _oma((high + low)/2, len, const, adapt)
HLR_Buffer = 100.0 * (m_pr - llv) / (hhv - llv)
bl1 = loxxdynamiczone.dZone("buy", HLR_Buffer, buy1, dzper)
bl2 = loxxdynamiczone.dZone("buy", HLR_Buffer, buy2, dzper)
sl1 = loxxdynamiczone.dZone("sell", HLR_Buffer, sell1, dzper)
sl2 = loxxdynamiczone.dZone("sell", HLR_Buffer, sell2, dzper)
zli = loxxdynamiczone.dZone("sell", HLR_Buffer, 0.5 , dzper)
state = 0.
if sigtype == SM02
if (HLR_Buffer<nz(HLR_Buffer[1]))
state :=-1
if (HLR_Buffer>nz(HLR_Buffer[1]))
state := 1
else if sigtype == SM03
if (HLR_Buffer<zli)
state :=-1
if (HLR_Buffer>zli)
state := 1
else if sigtype == SM04
if (HLR_Buffer<bl1)
state :=-1
if (HLR_Buffer>sl1)
state := 1
else if sigtype == SM05
if (HLR_Buffer<bl2)
state :=-1
if (HLR_Buffer>sl2)
state := 1
colorout = state == -1 ? redcolor : state == 1 ? greencolor : color.gray
plot(HLR_Buffer, color = colorout, linewidth = 3)
bl1pl = plot(bl1, "buy lvl 1", color = bar_index % 3 ? lightgreencolor: na)
bl2pl = plot(bl2, "buy lvl 2", color = bar_index % 2 ? greencolor: na)
sl1pl = plot(sl1, "sell lvl 1", color = bar_index % 3 ? lightredcolor: na)
sl2pl = plot(sl2, "sell lvl 1", color = bar_index % 2 ? redcolor: na)
midpl = plot(ShowMiddleLine ? zli : na, "mid lvl", color = bar_index % 4 ? color.white : na)
fill(bl1pl, bl2pl, color = filllevels ? color.new(greencolor, 85) : na)
fill(bl2pl, midpl, color = filllevels ? color.new(greencolor, 95): na)
fill(sl1pl, sl2pl, color = filllevels ? color.new(redcolor, 85): na)
fill(sl2pl, midpl, color = filllevels ? color.new(redcolor, 95): na)
barcolor(colorbars ? colorout : na)
goLong = colorout == greencolor and colorout[1] == redcolor
goShort = colorout == redcolor and colorout[1] == greencolor
plotshape(goLong and showsignals, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(goShort and showsignals, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title="Long", message="Dynamic Zone Range on OMA [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Dynamic Zone Range on OMA [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.