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
|
---|---|---|---|---|---|---|---|---|
RSI Potential Divergence - Fontiramisu | https://www.tradingview.com/script/G1Vg0bGP-RSI-Potential-Divergence-Fontiramisu/ | Fontiramisu | https://www.tradingview.com/u/Fontiramisu/ | 264 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Author : @Fontiramisu
// The divergence part is inspired from divergence indicator by @tradingView team.
// Indicator showing potential divergences on RSI momentum.
//@version=5
indicator(title="RSI Potential Divergence - Fontiramisu", shorttitle="Potential Div RSI - Fontiramisu", timeframe="", timeframe_gaps=true)
import Fontiramisu/fontilab/7 as fontilab
// import Fontiramisu/fontlib/60 as fontilab
// ] ------------------ RSI ------------------ [
hline(0, "Zero Line", color=color.new(#787B86, 50))
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="RSI Settings")
maLengthInput = input.int(14, title="MA Length", group="RSI 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"
plot(rsi, "RSI", color=#7E57C2)
plot(rsiMA, "RSI-based MA", color=color.yellow, display=display.none)
rsiUpperBand = hline(75, "RSI Upper Band", linestyle=hline.style_dotted, color=color.new(color.white, 75))
hline(50, "RSI Middle Band", linestyle=hline.style_dotted, color=color.new(color.white, 85))
rsiLowerBand = hline(25, "RSI Lower Band", linestyle=hline.style_dotted, color=color.new(color.white, 75))
// ] -------------- Divergence Handle -------------- [
showDiv = input.bool(title="Show Divergence", defval=true, group="div settings")
lbR = input(title="Pivot Lookback Right", defval=5, group="div settings")
lbL = input(title="Pivot Lookback Left", defval=5, group="div settings")
rangeUpper = input(title="Max of Lookback Range", defval=60, group="div settings")
rangeLower = input(title="Min of Lookback Range", defval=5, group="div settings")
plotBull = input(title="Plot Bullish", defval=true, group="div settings")
plotBullPot = input(title="Plot Bullish Potential", defval=true, group="div settings")
plotHiddenBull = input(title="Plot Hidden Bullish", defval=false, group="div settings")
plotHiddenBullPot = input(title="Plot Hidden Bullish", defval=false, group="div settings")
plotBear = input(title="Plot Bearish", defval=true, group="div settings")
plotBearPot = input(title="Plot Bearish Potential Potential", defval=true, group="div settings")
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false, group="div settings")
plotHiddenBearPot = input(title="Plot Hidden Bearish Potential", defval=false, group="div settings")
bearColor = color.red
bearPotColor = color.new(color.red, 20)
bullColor = color.green
bullPotColor = color.new(color.green, 20)
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
textColorDivPot = color.new(color.white, 20)
noneColor = color.new(color.white, 100)
float osc = rsi
// Get pivots.
[plFound, phFound, plFoundPot, phFoundPot] = fontilab.getOscPivots(osc, lbL, lbR)
// Div for curent ut.
[bullDiv, bullDivPot, hiddenBullDiv, hiddenBullDivPot, bearDiv, bearDivPot, hiddenBearDiv, hiddenBearDivPot] =
fontilab.plotDivergences(osc, lbR, plFound, phFound, plFoundPot, phFoundPot, rangeLower, rangeUpper)
//------
// Regular Bullish
plot(
showDiv and plotBullPot and plFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullDiv ? bullColor : noneColor)
)
plotshape(
showDiv and plotBullPot and bullDivPot ? osc[1] : na,
offset= -1,
title="Regular Bullish Pot Label",
text="B",
style=shape.labelup,
location=location.absolute,
color=bullPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotBullPot and bullDiv ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text=" Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------
// Hidden Bullish
plot(
showDiv and plotHiddenBull and plFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullDiv ? hiddenBullColor : noneColor)
)
plotshape(
showDiv and plotHiddenBullPot and hiddenBullDivPot ? osc[1] : na,
offset=-1,
title="Hidden Bullish Pot Label",
text="H",
style=shape.labelup,
location=location.absolute,
color=bullPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotHiddenBull and hiddenBullDiv ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text=" H Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------
// Regular Bearish
plot(
showDiv and plotBearPot and phFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearDiv ? bearColor : noneColor)
)
plotshape(
showDiv and plotBearPot and bearDivPot ? osc[1] : na,
offset=-1,
title="Regular Bearish Pot Label",
text="B",
style=shape.labeldown,
location=location.absolute,
color=bearPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotBearPot and bearDiv ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text=" Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
//-----
// Hidden Bearish
plot(
showDiv and plotHiddenBear and phFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearDiv ? hiddenBearColor : noneColor)
)
plotshape(
showDiv and plotHiddenBearPot and hiddenBearDivPot ? osc[1] : na,
offset=-1,
title="Hidden Bearish Pot Label",
text="H",
style=shape.labeldown,
location=location.absolute,
color=bearPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotHiddenBear and hiddenBearDiv ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text=" H Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
// ]
|
MACD S/R signal indicator | https://www.tradingview.com/script/ZRjTWvqL-MACD-S-R-signal-indicator/ | miguel42815 | https://www.tradingview.com/u/miguel42815/ | 69 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © VenkatNarayanan
//@version=5
indicator('My indicator - moac123', overlay=true)
haTicker = ticker.heikinashi(syminfo.tickerid)
haClose = request.security(haTicker, timeframe.period, close)
haOpen = request.security(haTicker, timeframe.period, open)
haHigh = request.security(haTicker, timeframe.period, high)
haLow = request.security(haTicker, timeframe.period, low)
//MACD
fast_length = input(title="Fast Length", defval=12, group="MACD")
slow_length = input(title="Slow Length", defval=26, group="MACD")
src = haClose
signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9, group="MACD")
sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"], group="MACD")
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"], group="MACD")
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
//SMMA
smmalen = input.int(7, minval=1, title="SMMA Length", group="SMMA")
smmasrc = input(close, title="SMMA Source", group="SMMA")
smma = 0.0
_sma = ta.sma(smmasrc, smmalen)
smma := na(smma[1]) ? _sma : (smma[1] * (smmalen - 1) + smmasrc) / smmalen
plot(smma, title="SMMA", color=color.blue, linewidth=1)
//LSMA
lsmalength = input(title="LSMA Length", defval=25, group="LSMA")
lsmaoffset = input(title="LSMA Offset", defval=0, group="LSMA")
lsmasrc = input(close, title="LSMA Source", group="LSMA")
lsma = ta.linreg(lsmasrc, lsmalength, lsmaoffset)
plot(lsma, title="LSMA", color=color.yellow, linewidth=1)
//Calculation Resistance and Support using MACD Cross
lookback = input(title='Candle Lookback', defval=11, group="Support & Resistance")
var previoushigh = float(na)
var previouslow = float(na)
lookbackhigh = ta.highest(haHigh, lookback)
if ta.crossunder(macd,signal)
previoushigh := lookbackhigh
lookbacklow = ta.lowest(low, lookback)
if ta.crossunder(signal,macd)
previouslow := lookbacklow
lookbackavg = math.avg(previoushigh, previouslow)
plot(previoushigh, title="Resistance", color=color.red, linewidth=2)
plot(previouslow, title="Support", color=color.green, linewidth=2)
plot(lookbackavg, title='Average Resistance and Support', color=color.new(color.orange, 0), linewidth=2)
// signal plotting
isGreenCandle = (close > open)
isLong = false // A flag for going LONG
isLong := nz(isLong[1]) // Get the previous value of it
isShort = false // A flag for going SHORT
isShort := nz(isShort[1]) // Get the previous value of it
if (isLong and close[0] < lookbackavg)
isLong = false
if (isShort and close[0] > lookbackavg)
isShort = false
longConditions = close[0] > lookbackavg and lsma > lookbackavg and lsma > smma and not isLong and isGreenCandle and close[0] > lsma and close[0] < previoushigh
if (longConditions)
isLong := true
isShort := false
shortConditions = close[0] < lookbackavg and lsma < lookbackavg and lsma < smma and not isShort and not isGreenCandle and close[0] < lsma and close[0] > previouslow
if (shortConditions)
isLong := false
isShort := true
plotshape(longConditions, style=shape.triangleup,text='LONG',
color=color.green, title='Long')
plotshape(shortConditions, style=shape.triangledown,text='SHORT',
color=color.red, title='Short')
|
Windi-Scalper | https://www.tradingview.com/script/Ph5QD1tW-Windi-Scalper/ | TheWindicatorPro | https://www.tradingview.com/u/TheWindicatorPro/ | 40 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheWindicatorPro
//@version=4
study('Windi-scalp', overlay=true)
ema = ema(close, 200)
ema2 = ema(close, 100)
ema3 = ema(close, 50)
fast= ema(close,1)
plot(ema, color=color.new(color.red, 0))
plot(ema2, color=color.new(color.orange, 0))
plot(ema3, color=color.new(color.green, 0))
bull = ema > ema2
bull2 = ema2 > ema3
bear = ema < ema2
bear2 = ema2 < ema3
buy = bear and bear2
sell = bull and bull2
cross50 = cross(ema3, fast)
above= fast>ema3
bellow= fast<ema3
/////////////////////////
openBarPrevious = open[1]
closeBarPrevious = close[1]
openBarCurrent = open
closeBarCurrent = close
//If current bar open is less than equal to the previous bar close AND current bar open is less than previous bar open AND current bar close is greater than previous bar open THEN True
bullishEngulfing = openBarCurrent <= closeBarPrevious and openBarCurrent < openBarPrevious and
closeBarCurrent > openBarPrevious
//If current bar open is greater than equal to previous bar close AND current bar open is greater than previous bar open AND current bar close is less than previous bar open THEN True
bearishEngulfing = openBarCurrent >= closeBarPrevious and openBarCurrent > openBarPrevious and
closeBarCurrent < openBarPrevious
//bullishEngulfing/bearishEngulfing return a value of 1 or 0; if 1 then plot on chart, if 0 then don't plot
//plotshape(bullishEngulfing, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny)
//plotshape(bearishEngulfing, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.tiny)
alertcondition(bullishEngulfing, title="Bullish Engulfing", message="[CurrencyPair] [TimeFrame], Bullish candle engulfing previous candle")
alertcondition(bearishEngulfing, title="Bearish Engulfing", message="[CurrencyPair] [TimeFrame], Bearish candle engulfing previous candle")
sincebull= barssince(bullishEngulfing)
sincebear= barssince(bearishEngulfing)
allowup = sincebull <= 2
allowdown = sincebear <= 2
up= buy and allowup and cross50 and above
down= sell and allowdown and cross50 and bellow
plotshape(up, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny)
plotshape(down, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.tiny)
///// |
Zwei RSI | https://www.tradingview.com/script/n8dF1Q7T/ | moo31415 | https://www.tradingview.com/u/moo31415/ | 5 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © moo31415
//@version=5
indicator("Zwei EMAs")
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"
plot(rsi, "RSI", color=#7E57C2)
plot(rsiMA, "RSI-based MA", color=color.yellow)
rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green)
bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green)
fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill")
ma2(source2, length2, type2) =>
switch type2
"SMA2" => ta.sma(source2, length2)
"Bollinger Bands2" => ta.sma(source2, length2)
"EMA2" => ta.ema(source2, length2)
"SMMA (RMA)2" => ta.rma(source2, length2)
"WMA2" => ta.wma(source2, length2)
"VWMA2" => ta.vwma(source2, length2)
rsiLengthInput2 = input.int(14, minval=1, title="RSI Length2", group="RSI Settings2")
rsiSourceInput2 = input.source(close, "Source2", group="RSI Settings2")
maTypeInput2 = input.string("SMA2", title="MA Type2", options=["SMA2", "Bollinger Bands2", "EMA2", "SMMA (RMA)2", "WMA2", "VWMA2"], group="MA Settings2")
maLengthInput2 = input.int(14, title="MA Length2", group="MA Settings2")
bbMultInput2 = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev2", group="MA Settings2")
up2 = ta.rma(math.max(ta.change(rsiSourceInput2), 0), rsiLengthInput2)
down2 = ta.rma(-math.min(ta.change(rsiSourceInput2), 0), rsiLengthInput2)
rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))
rsiMA2 = ma2(rsi2, maLengthInput2, maTypeInput2)
isBB2 = maTypeInput2 == "Bollinger Bands2"
plot(rsi2, "RSI2", color=#7E57C2)
plot(rsiMA2, "RSI-based MA2", color=color.yellow)
rsiUpperBand2 = hline(70, "RSI Upper Band2", color=#787B86)
hline(50, "RSI Middle Band2", color=color.new(#787B86, 50))
rsiLowerBand2 = hline(30, "RSI Lower Band2", color=#787B86)
fill(rsiUpperBand2, rsiLowerBand2, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill2")
bbUpperBand2 = plot(isBB2 ? rsiMA2 + ta.stdev(rsi2, maLengthInput2) * bbMultInput2 : na, title = "Upper Bollinger Band2", color=color.green)
bbLowerBand2 = plot(isBB2 ? rsiMA2 - ta.stdev(rsi2, maLengthInput2) * bbMultInput2 : na, title = "Lower Bollinger Band", color=color.green)
fill(bbUpperBand2, bbLowerBand2, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill2")
plot(close)
|
Pro Trading Art - Insider Entry with alert | https://www.tradingview.com/script/XZDwRir9-Pro-Trading-Art-Insider-Entry-with-alert/ | protradingart | https://www.tradingview.com/u/protradingart/ | 99 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © protradingart
//@version=5
indicator("Pro Trading Art - Insider Entry with alert", "PTA - Insider Entry", format=format.volume)
// You can decide your own number.
goldenNumber = input(1.618, title="Golden Number")
volumeSMALen = input.int(defval=21, title="SMA Length", minval=4)
ma = input.bool(false, "Volume MA")
volumeSMA = ta.sma(volume, volumeSMALen)
goldenVolume = goldenNumber*volumeSMA
insiderColor = input.color(color.lime, "Insider Color")
baseColor = input.color(color.red, "Base Color")
bgColor = volume > goldenVolume ? insiderColor : baseColor
plot(volume, style=plot.style_histogram, color=bgColor)
plot(ma?volumeSMA:na, color=color.lime)
// Alert Section
if volume > goldenVolume
alert("Insider Intry in: "+str.tostring(syminfo.ticker))
|
Reductionism dot chart | https://www.tradingview.com/script/r5ErNIID-Reductionism-dot-chart/ | BillionaireLau | https://www.tradingview.com/u/BillionaireLau/ | 13 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BillionaireLau
//@version=5
indicator("Reductionism dot chart",overlay=true)
colorr = input.color(color.blue, "Plot Color")
plot(close,style= plot.style_circles, color = colorr )
plot(open,style= plot.style_circles, color = colorr )
plot(high,style= plot.style_circles, color = colorr )
plot(low,style= plot.style_circles, color = colorr )
|
Il mio script 1 | https://www.tradingview.com/script/ys1bRnNr/ | Matrix90 | https://www.tradingview.com/u/Matrix90/ | 1 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Matrix90
//@version=5
indicator("Il mio script")
plot(close)
|
Light or Dark Mode Tutorial - Luminance Detection | https://www.tradingview.com/script/gxKVXyX5-Light-or-Dark-Mode-Tutorial-Luminance-Detection/ | upslidedown | https://www.tradingview.com/u/upslidedown/ | 15 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © upslidedown
//
notes = "As a colorblind trader, I think accessibility is a big deal. This script auto detects the chart background color and optimizes text color based on luminance.\n"+
"Try changing the chart background color and see how this script changes the table printed on the chart.\n"+
"Luminance detection based on pine script new chart.bg_color feature, allowing lines, tables, etc to be optimized knowing the output color.\n"+
"This makes it simple to optimize scripts based off the knowledge that max luminance = 765, thus we skew TV to know that lum <= 383 is \"dark mode\" and lum > 383 is \"light mode\""
//@version=5
indicator("Light or Dark Mode Tutorial - Luminance Detection", overlay=true)
// --------------------------------
// this snippet is all you need!
bgcolor = chart.bg_color
r = color.r(bgcolor)
g = color.g(bgcolor)
b = color.b(bgcolor)
lum = r+g+b
is_dark = lum <= 383
auto_color_based_on_bgcolor = is_dark ? color.white : color.black // auto_color_based_on_bgcolor will change based on final contrast
// --------------------------------
// nothing else below is necessary, just prints the table for a demo
// add some extra notes
notes := notes + "\nLuminance: " + str.tostring(lum) + " (of max 765)\n" + "Dark mode is: " + str.tostring(is_dark)
// print a demo table to showcase how this could be used
var table demo = table.new(position.bottom_right, 1, 1)
if barstate.islast
// print a table cell with the notes above
table.cell(demo, 0, 0, notes, text_color=auto_color_based_on_bgcolor, text_halign=text.align_left)
// debug info for users interested in inspecting lum in console
plotchar(lum, "luminance", "", location = location.top) |
Gann Calculator | https://www.tradingview.com/script/uElRljtv-Gann-Calculator/ | akshayshinde73997 | https://www.tradingview.com/u/akshayshinde73997/ | 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/
// © akshayshinde73997
//@version=5
indicator("Gann Calculator", overlay=true)
toadd = 0.
incval = 0.
selectedprice = 0.
selectedprice := input(defval=9500.0, title="Type Your Start Price Here")
incval := input(defval=31.5, title="Increment Value")
toadd := incval
line.new(bar_index, selectedprice, bar_index[376], selectedprice, width = 1, color=color.white)
for i = 0 to 10
line.new(bar_index, selectedprice+(toadd*i), bar_index[376], selectedprice+(toadd*i), width = 1, style=line.style_solid)
line.new(bar_index, selectedprice-(toadd*i), bar_index[376], selectedprice-(toadd*i), width = 1, style=line.style_solid)
|
MA SLope Potential Divergence - Fontiramisu | https://www.tradingview.com/script/lkIt1bbk-MA-SLope-Potential-Divergence-Fontiramisu/ | Fontiramisu | https://www.tradingview.com/u/Fontiramisu/ | 70 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Author : @Fontiramisu
// The divergence part is inspired from divergence indicator by @tradingView team.
// Indicator showing potential divergences on MA's Slope momentum.
//@version=5
indicator(title="MA SLope Potential Divergence - Fontiramisu", shorttitle="Potential Div MA Slope - Fontiramisu", timeframe="", timeframe_gaps=true)
import Fontiramisu/fontilab/7 as fontilab
// ] ------------------------------ Slope MAs ------------------------------------------------ [
// INPUT
lenghtMaSlope = input.int(50, title="Lenght MA to slope", minval=20, tooltip="The MA we are going to take slope from", group="MA Slope")
typeMA = input.string(title = "MA Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Slope")
lenghtFastSma = input.int(5, minval=1, tooltip="The lenght of the fast slope (greenà", group="MA Slope")
lenghtSlowSma = input.int(40, minval=1, tooltip="The lenght of the slow slope", group="MA Slope")
hlineUpValue = input.int(100, minval=0, group="MA Slope")
hlineLowValue = input.int(-100, minval=-100, group="MA Slope")
// Calculate context MA
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
maToSlope = ma(close, lenghtMaSlope, typeMA)
// STANDARDISE SLOPE
// Multiplicator to have interprationnable results
multiplicator = 100000
// Calculating the PERCENTAGE SLOPE (not the strate slope)
// It's the slope of the percentage change from maToSlope to maToSlope[periodFast]
// So the slope is based on %
dyFastPeriod = (maToSlope - maToSlope[1]) / maToSlope
dySlowPeriod = (maToSlope - maToSlope[1]) / maToSlope
// Slope calculate (equal dy%/dx)
slopeContextMaFast = dyFastPeriod / 1 * multiplicator
slopeContextMaSlow = dySlowPeriod / 1 * multiplicator
// fast & slow SMA from slope
smaFastLenghtSlope = ta.sma(slopeContextMaFast, lenghtFastSma)
smaSlowLenghtSlope = ta.sma(slopeContextMaFast, lenghtSlowSma)
// Diff Slope calculate
diffSlopeFastSlow = smaFastLenghtSlope - smaSlowLenghtSlope
// Background Color from context slope
isOrangeSlopeContextMa = smaFastLenghtSlope < hlineUpValue and smaFastLenghtSlope >= 0 or smaFastLenghtSlope > hlineLowValue and smaFastLenghtSlope <= 0
isGreenSlopeContextMa = smaFastLenghtSlope >= hlineUpValue
isRedSlopeContextMa = smaFastLenghtSlope <= hlineLowValue
// Plot.
rsiUpperBand = hline(hlineUpValue, "Upper Band", linestyle=hline.style_dotted, color=color.new(color.white, 75))
hline(0, "Middle Band", linestyle=hline.style_dotted, color=color.new(color.white, 85))
rsiLowerBand = hline(hlineLowValue, "Lower Band", linestyle=hline.style_dotted, color=color.new(color.white, 75))
plot(diffSlopeFastSlow, "Diff Slope Fast vs Slow", color = color.new(color.yellow, 50), style = plot.style_histogram, display = display.all)
plot(smaFastLenghtSlope, "Slope's Fast SMA", color = color.green, display = display.all)
plot(smaSlowLenghtSlope, "Slope's Slow SMA", color = color.red, display = display.none)
// ] -------------- Divergence Handle -------------- [
showDiv = input.bool(title="Show Divergence", defval=true, group="div settings")
showSlopeDiv = input.bool(title="Show the Slope Divergences", defval=true, group="div settings")
showDiffSlopeDiv = input.bool(title="Show The Diff Slopes Divergences", defval=false, group="div settings")
lbR = input(title="Pivot Lookback Right", defval=5, group="div settings")
lbL = input(title="Pivot Lookback Left", defval=5, group="div settings")
rangeUpper = input(title="Max of Lookback Range", defval=60, group="div settings")
rangeLower = input(title="Min of Lookback Range", defval=5, group="div settings")
plotBull = input(title="Plot Bullish", defval=true, group="div settings")
plotBullPot = input(title="Plot Bullish Potential", defval=true, group="div settings")
plotHiddenBull = input(title="Plot Hidden Bullish", defval=false, group="div settings")
plotHiddenBullPot = input(title="Plot Hidden Bullish Potential", defval=false, group="div settings")
plotBear = input(title="Plot Bearish", defval=true, group="div settings")
plotBearPot = input(title="Plot Bearish Potential", defval=true, group="div settings")
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false, group="div settings")
plotHiddenBearPot = input(title="Plot Hidden Bearish Potential", defval=false, group="div settings")
bearColor = color.red
bearPotColor = color.new(color.red, 20)
bullColor = color.green
bullPotColor = color.new(color.green, 20)
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
textColorDivPot = color.new(color.white, 20)
noneColor = color.new(color.white, 100)
float osc = showSlopeDiv ? smaFastLenghtSlope : showDiffSlopeDiv ? diffSlopeFastSlow : na
// Get pivots.
[plFound, phFound, plFoundPot, phFoundPot] = fontilab.getOscPivots(osc, lbL, lbR)
// Div for curent ut.
[bullDiv, bullDivPot, hiddenBullDiv, hiddenBullDivPot, bearDiv, bearDivPot, hiddenBearDiv, hiddenBearDivPot] =
fontilab.plotDivergences(osc, lbR, plFound, phFound, plFoundPot, phFoundPot, rangeLower, rangeUpper)
//------
// Regular Bullish
plot(
showDiv and plotBullPot and plFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullDiv ? bullColor : noneColor)
)
plotshape(
showDiv and plotBullPot and bullDivPot ? osc[1] : na,
offset= -1,
title="Regular Bullish Pot Label",
text="B",
style=shape.labelup,
location=location.absolute,
color=bullPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotBullPot and bullDiv ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text=" Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------
// Hidden Bullish
plot(
showDiv and plotHiddenBull and plFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullDiv ? hiddenBullColor : noneColor)
)
plotshape(
showDiv and plotHiddenBullPot and hiddenBullDivPot ? osc[1] : na,
offset=-1,
title="Hidden Bullish Pot Label",
text="H",
style=shape.labelup,
location=location.absolute,
color=bullPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotHiddenBull and hiddenBullDiv ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text=" H Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
//------
// Regular Bearish
plot(
showDiv and plotBearPot and phFound ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearDiv ? bearColor : noneColor)
)
plotshape(
showDiv and plotBearPot and bearDivPot ? osc[1] : na,
offset=-1,
title="Regular Bearish Pot Label",
text="B",
style=shape.labeldown,
location=location.absolute,
color=bearPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotBearPot and bearDiv ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text=" Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
//-----
// Hidden Bearish
plot(
showDiv and plotHiddenBear and phFound ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearDiv ? hiddenBearColor : noneColor)
)
plotshape(
showDiv and plotHiddenBearPot and hiddenBearDivPot ? osc[1] : na,
offset=-1,
title="Hidden Bearish Pot Label",
text="H",
style=shape.labeldown,
location=location.absolute,
color=bearPotColor,
textcolor=textColorDivPot
)
plotshape(
showDiv and plotHiddenBear and hiddenBearDiv ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text=" H Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
// ]
|
Koalafied One-Time-Framing Candles | https://www.tradingview.com/script/9ZLLdoTC-Koalafied-One-Time-Framing-Candles/ | Koalafied_3 | https://www.tradingview.com/u/Koalafied_3/ | 98 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TJ_667
//@version=5
indicator("Koalafied OTF Candle", overlay = true)
//-------------------- INPUTS --------------------//
OTF_UP_col = input.color(color.new(color.blue, 0), "OTF Up Color")
OTF_DOWN_col = input.color(color.new(color.red, 0), "OTF Down Color")
OTF_NA_col = input.color(color.new(color.black, 100), "OTF NA Color")
_high = high
_low = low
//-------------------- CALC --------------------//
var int OTF_C = na
OTF_C := _low > _low[1] and _high < _high[1] ? OTF_C[1] : _low > _low[1] ? 1 : _high < _high[1] ? 2 : 3
OTF_C_col = OTF_C == 1 ? OTF_UP_col : OTF_C == 2 ? OTF_DOWN_col : OTF_NA_col
//-------------------- PLOT --------------------//
barcolor(barstate.isconfirmed ? OTF_C_col : OTF_NA_col) // Sets candle color once current bar is closed
|
Intraday predictive High Volume Activity sessions [BEA] | https://www.tradingview.com/script/Yes2eAxY-Intraday-predictive-High-Volume-Activity-sessions-BEA/ | TJalam | https://www.tradingview.com/u/TJalam/ | 285 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Badshah.E.Alam
//@version=5
indicator('Intraday predictive High Volume Activity sessions [BEA]',shorttitle="HVAS [BEA]",max_boxes_count=500,max_lines_count=500)
// High Volume Activity sessions [BEA] (HVAS [BEA])
////////////////////////////// No display if No volume of Chart TF is not Intraday{
var cumVol = 0.
cumVol += nz(volume)
if (barstate.islast and cumVol == 0)
runtime.error("No volume is provided by the data vendor.")
if (not timeframe.isintraday)
runtime.error("Only Intraday chart Timeframe works for this indicator.")
//}
////////////////////////////// Date range selection for the volume data to be captured{
rangeType = input.string(defval="30 Days", title="Date range:", options=["Custom", "30 Days", "90 Days", "180 Days", "Year to Date"], group="Limit by date")
startDate = input.time(title="Start Date (YYYY/DD/MM)",
defval=timestamp("1 Mar 2022 9:30 -0400"), group="Limit by date")
endDate = input.time(title="End Date (YYYY/DD/MM) ",
defval=timestamp("31 Dec 2200 16:00 -0400"), group="Limit by date")
// subtract number of days (in milliseconds) from current time
startDate := rangeType == "Custom" ? startDate :
rangeType == "30 Days" ? timenow - 2592000000 :
rangeType == "90 Days" ? timenow - 7776000000 :
rangeType == "180 Days" ? timenow - 15552000000 :
rangeType == "Year to Date" ? timestamp(syminfo.timezone, year(timenow), 01, 01, 00, 01) : na
inDateRange = (time >= startDate) and (time < endDate)
//}
////////////////////////////// Identify Today for plotting of Predictive volume only for current Day{
isToday = false
if time>= timenow - 86400000//year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time))
isToday := true
//}
////////////////////////////// Defining the size of matrix and arrays used {
// getting Daily change to calculate data only on day change
// getting Number of bars in a day for matrix size
d_change=timeframe.change("D")
intraday_bar_count=ta.barssince(d_change)
var int count_day=0
if d_change and inDateRange
count_day:=math.round(ta.cum(d_change?1:0))
dt =not d_change? time - time[1]:time[1] - time[2]
startCounting = false
startCounting := nz(startCounting[1], false)
if bar_index==0 and not nz(startCounting[1])
startCounting := true
if d_change and nz(startCounting[1])
startCounting := false
condCnt = startCounting ? 1 : 0
//}
////////////////////////////// Volume MA{
VolAvgLenght = input.int(title='MA Average Periods', defval=50, minval=0,group="MA period")
VolMa = ta.sma(volume, VolAvgLenght)
plot(VolMa, color=color.new(color.white, 0))
pred_vol_true = close>open?color.lime:color.red
plot(volume, color=pred_vol_true, style=plot.style_columns, title='Volume')
//}
////////////////////////////// Table positioning {
TablePos = input.string(title="Table Location", defval="Top Right",
options=["Top Right", "Middle Right", "Bottom Right",
"Top Center", "Middle Center", "Bottom Center",
"Top Left", "Middle Left", "Bottom Left"], group='Display')
_TablePos= TablePos== "Top Right" ? position.top_right:
TablePos== "Middle Right" ? position.middle_right:
TablePos== "Bottom Right" ? position.bottom_right:
TablePos== "Top Center" ? position.top_center:
TablePos== "Middle Center"? position.middle_center:
TablePos== "Bottom Center"? position.bottom_center:
TablePos== "Top Left" ? position.top_left:
TablePos== "Middle Left" ? position.middle_left:position.bottom_left
size = input.string(title="Table Size", defval="Small",
options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group='Display')
_size= size == "Auto" ? size.auto: size == "Huge" ? size.huge:
size == "Large"? size.large: size == "Normal"? size.normal:
size == "Small"? size.small: size.tiny
var t = table.new(
position=_TablePos, columns=5, rows=500, bgcolor=color.silver,
frame_color=color.gray, frame_width=2, border_color=color.black, border_width=1)
//}
////////////////////////////// Main Part begins{
//Calculate everything on bar close and only once on change of Day , the data will be same for the rest of the day
// lets enter the calculation if we are within the selected range and at least two days of data is there
var bool[] array_start_time_alert = array.new_bool()
number_of_bar_count_intraday=math.round(ta.cum(condCnt))
if inDateRange and count_day>=2 and d_change and barstate.isconfirmed //and session.islastbar_regular
// Definging marix , arrays
var matrix<float> matrix_v_data =matrix.new<float>(count_day-2, number_of_bar_count_intraday)
var float[] array_row_data = array.new_float( number_of_bar_count_intraday,na)
var box[] box_vol = array.new_box( number_of_bar_count_intraday,na)
var matrix<float> matrix_ma_data =matrix.new<float>(count_day-2, number_of_bar_count_intraday)
var float[] array_ma_row_data = array.new_float( number_of_bar_count_intraday,na)
var line[] line_ma = array.new_line( number_of_bar_count_intraday,na)
array_start_time_alert:=array.new_bool(number_of_bar_count_intraday,false)
// setting every day volume and volume MA data in the array and then to the matrix
for i=0 to number_of_bar_count_intraday-1
array.set(array_row_data, i, volume[i+1])
array.set(array_ma_row_data, i, VolMa[i+1])
// adding Data arrays to the matrix
matrix.add_row(matrix_v_data, count_day-2, array_row_data)
matrix.add_row(matrix_ma_data, count_day-2, array_ma_row_data)
//getting number of rows and coulmn in the matrix
r_=matrix.rows(matrix_v_data)
c_=matrix.columns(matrix_v_data)
var float avg_of_vol_col=na
var float avg_of_ma_col=na
if r_>1
for i=1 to c_
//extracting column for Volume average calculation for each bar of the day
subM1 =matrix.submatrix(matrix_v_data, 0, r_, i-1, i)
avg_of_vol_col= matrix.avg(subM1)
//extracting column for VolumeMA average calculation for each bar of the day
subM2 =matrix.submatrix(matrix_ma_data, 0, r_, i-1, i)
avg_of_ma_col= matrix.avg(subM2)
color_Vbar=avg_of_vol_col<avg_of_ma_col?color.new(color.blue,80):color.new(#0cbfe9,50)
color_ma=avg_of_vol_col<avg_of_ma_col?color.blue:#0cbfe9
array.set(array_start_time_alert,i-1,avg_of_vol_col>avg_of_ma_col)
//plotting Predictive Volume boxes for whole day ( Today and live market only)
//plotting Predictive VolumeMA lines for current whole day
if isToday
box.new(time+(math.abs(i-c_)*dt), avg_of_vol_col, time+(math.abs(i-c_-1)*dt), 0,xloc=xloc.bar_time, border_color=color_ma, border_style=line.style_dotted,border_color=color.red, bgcolor=color_Vbar)
line.new(time+(math.abs(i-c_)*dt), avg_of_ma_col, time+(math.abs(i-c_-1)*dt), avg_of_ma_col,xloc=xloc.bar_time, color=color_ma, style=line.style_solid,width=2)
//}
bar_col_high_volume=(array.size(array_start_time_alert)>0 and math.abs(array.size(array_start_time_alert)-intraday_bar_count-1)<array.size(array_start_time_alert)?array.get(array_start_time_alert,math.abs(array.size(array_start_time_alert)-intraday_bar_count-1)):false)
barcolor(bar_col_high_volume?color.new(color.fuchsia,0):na,title="Predictive Volume Barcolor")
////////////////////////////// Displaying some data in the table{
is_realtime=barstate.isrealtime?"Market Open":"Market Not open"
is_realtime_color=barstate.isrealtime? color.green: color.red
if barstate.islast and inDateRange
table.cell(t, 0, 0, "Title", bgcolor = color.blue,text_size=_size)
table.cell(t, 0, 1, "Bars in Intraday",text_size=_size)
table.cell(t, 0, 2, "Days of data used",text_size=_size)
table.cell(t, 0, 3, "Market Status",text_size=_size)
table.cell(t, 1, 0, "Value", bgcolor = color.blue,text_size=_size)
table.cell(t, 1, 1, str.tostring(number_of_bar_count_intraday ) , width = 15, bgcolor = color.green,text_size=_size)
table.cell(t, 1, 2, str.tostring(count_day ), width = 15, bgcolor = color.green,text_size=_size)
table.cell(t, 1, 3, is_realtime, width = 15, bgcolor =is_realtime_color,text_size=_size,tooltip="No Data will be plotted if Market is closed")
//} |
Koalafied Volume Extension Bubbles | https://www.tradingview.com/script/HJySznVE-Koalafied-Volume-Extension-Bubbles/ | Koalafied_3 | https://www.tradingview.com/u/Koalafied_3/ | 391 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TJ_667
//@version=5
indicator("Koalafied Volume Extension Bubbles", overlay = true, max_labels_count = 500)
// ---------- FUNCTIONS ---------- //
Z_score(_src, _length, MA_sel)=>
_mean = MA_sel == 'SMA' ? ta.sma(_src, _length) : MA_sel == 'EMA' ? ta.ema(_src, _length) : MA_sel == 'WMA' ? ta.wma(_src, _length) : na
_value = (_src - _mean) / (ta.stdev(_src, _length))
timeChange(period) =>
ta.change(time(period))
// ---------- INPUTS ---------- //
var GRP1 = "INPUTS"
len = input(21, "Z-Score MA Length", group = GRP1)
MA_sel = input.string(title='MA Selection', defval='SMA', options=['SMA', 'EMA', 'WMA'], group = GRP1)
deviation_1 = input(2.0, "Std Dev", group = GRP1)
deviation_2 = input(3.0, "Std Dev", group = GRP1)
size_circles = input.string(title='Bubble Size Selection', defval='Big', options=['Small', 'Big'], group = GRP1)
offset_circles = input(true, "Offset Volume Bubbles to Period Start", group = GRP1)
var GRP2 = "COLOR SELECTION"
_colup_ext2 = input.color(color.lime, "Bull Extension 2", group = GRP2)
_colup_ext1 = input.color(color.blue, "Bull Extension 1", group = GRP2)
_coldown_ext1 = input.color(color.red, "Bear Extension 1", group = GRP2)
_coldown_ext2 = input.color(color.purple, "Bear Extension 2", group = GRP2)
trans_circles = input.int(50, "Volume Bubble Transparency", group = GRP2)
// ---------- CALCS ---------- //
src = volume
vol = Z_score(src, len, MA_sel)
extension_1 = vol > deviation_1 and vol < deviation_2
extension_2 = vol > deviation_2
bull = close > open
bear = close < open
_devUp2 = extension_2 and bull
_devUp1 = extension_1 and bull
_devDown1 = extension_1 and bear
_devDown2 = extension_2 and bear
// Bubble offset calcs
_start = timeChange("D")
var int count = na
count := _start ? 0 : count + 1
circ_size = size_circles == "Small" ? true : false
// ---------- PLOTS ---------- //
if _devUp2
dn1 = label.new(bar_index[offset_circles ? count : 0], ((open + close) / 2), color = color.new(_colup_ext2, trans_circles), style = label.style_circle, size = circ_size ? size.auto : size.tiny)
if _devUp1
dn1 = label.new(bar_index[offset_circles ? count : 0], ((open + close) / 2), color = color.new(_colup_ext1, trans_circles), style = label.style_circle, size = circ_size ? size.auto : size.tiny)
if _devDown1
dn1 = label.new(bar_index[offset_circles ? count : 0], ((open + close) / 2), color = color.new(_coldown_ext1, trans_circles), style = label.style_circle, size = circ_size ? size.auto : size.tiny)
if _devDown2
dn1 = label.new(bar_index[offset_circles ? count : 0], ((open + close) / 2), color = color.new(_coldown_ext2, trans_circles), style = label.style_circle, size = circ_size ? size.auto : size.tiny)
// ---------- Alerts ---------- //
ext_alert = _devUp2 or _devUp1 or _devDown1 or _devDown2
alertcondition(ext_alert, "Volume Extension Alert", "VOL EXT")
|
Fx Session Range | https://www.tradingview.com/script/wrmFjT4z-Fx-Session-Range/ | a_guy_from_wall_street | https://www.tradingview.com/u/a_guy_from_wall_street/ | 283 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © hiimannshu
//@version=5
indicator(title='Fx Session Range', shorttitle=' Session Range', overlay=true)
string tip = "The timing of the sessions follows NewYork Timezone and taken from www.forex.timezoneconverter.com "
//------------------Genral Settings------------------------//
type = input.string("Range Box","Session Style",options = ["Range Box","BG Highlightlight"],group="General Settings",tooltip = tip)
fil = input.bool(true,"Fill session box ",group="General Settings")
br = input.bool(true,"Show box Borders ",group="General Settings")
show_lbl = input.bool(true,"",inline = "lbl",group="General Settings")
size = input.string("Normal","Label Size",options=["Tiny","Small","Normal","Huge"],inline = "lbl",group="General Settings")
show_day = input.bool(true,"Show day of the week",group="General Settings")
//------------------Asia session Inputs------------------------//
show_asian_range = input.bool(true, title='',inline="asian",group="Asia")
_asianSess =input.string("Asian Range","Assian Session ",options=["Sydney","Tokyo","Both","Asian Range"],inline="asian",group="Asia")
asia = input.session('1800-0301',"Asian Session",group="Asia")
asiabox_col = input.color(color.new(color.aqua, 90), ' ',inline="_ab",group="Asia")
asiaboxborder_col = input.color(color.new(color.black, 70), '',inline="_ab",group="Asia")
asiabrtype =input.string("Dotted"," ",options=["No border","Solid","Dashed","Dotted"],inline="_ab",group="Asia")
//------------------Sydney session Inputs------------------------//
sydney = input.session('1800-0201',"Sydney",group="Asia")
sydneybox_col = input.color(color.new(color.aqua, 90), ' ',inline="_sb",group="Asia")
sydneyboxborder_col = input.color(color.new(color.black, 70), '',inline="_sb",group="Asia")
sydneybrtype =input.string("Dotted"," ",options=["No border","Solid","Dashed","Dotted"],inline="_sb",group="Asia")
//------------------Tokyo session Inputs------------------------//
tokyo = input.session('1900-0301',"Tokyo",group="Asia")
tokyobox_col = input.color(color.new(color.aqua, 90), ' ',inline="_tb",group="Asia")
tokyoboxborder_col = input.color(color.new(color.black, 70), '',inline="_tb",group="Asia")
tokyobrtype =input.string("Dotted"," ",options=["No border","Solid","Dashed","Dotted"],inline="_tb",group="Asia")
//------------------Frankfurt session Inputs------------------------//
show_frankfurt_range = input.bool(false, title='',inline="frankfurt",group="Frankfurt")
frankfurt = input.session('0200-1001',"Frankfurt",inline="frankfurt",group="Frankfurt")
frankfurtbox_col = input.color(color.new(color.blue, 90), ' ',inline="_fb",group="Frankfurt")
frankfurtboxborder_col = input.color(color.new(color.black, 70), '',inline="_fb",group="Frankfurt")
frankfurtbrtype =input.string("Dotted"," ",options=["No border","Solid","Dashed","Dotted"],inline="_fb",group="Frankfurt")
//------------------London session Inputs------------------------//
show_london_range = input.bool(true, title='',inline="london",group="London")
london = input.session('0300-1101',"London",inline="london",group="London")
londonbox_col = input.color(color.new(color.rgb(102,187,106,0),90), ' ',inline="_lb",group="London")
londonboxborder_col = input.color(color.new(color.black, 70),'',inline="_lb",group="London")
londonbrtype =input.string("Dotted"," ",options=["No border","Solid","Dashed","Dotted"],inline="_lb",group="London")
//------------------New York session Inputs------------------------//
show_newyork_range = input.bool(true, title='',inline="ny",group="New York")
newyork = input.session('0800-1601',"New York",inline="ny",group="New York")
newyorkbox_col = input.color(color.new(color.rgb(250,161,164, 0),90), ' ',inline="_nyb",group="New York")
newyorkboxborder_col = input.color(color.new(color.black, 70), '',inline="_nyb",group="New York")
nybrtype =input.string("Dotted"," ",options=["No border","Solid","Dashed","Dotted"],inline="_nyb",group="New York")
//------------------Custom session Inputs------------------------//
show_custom_range = input.bool(false, title='',inline="cu",group="Custom Range")
custom = input.session('1700-1645',"Custom Range",inline="cu",group="Custom Range")
custom_col = input.color(color.new(color.rgb(250,161,164, 0),90), ' ',inline="_cub",group="Custom Range")
customboxborder_col = input.color(color.new(color.black, 70), '',inline="_cub",group="Custom Range")
custombrtype =input.string("Dotted"," ",options=["No border","Solid","Dashed","Dotted"],inline="_cub",group="Custom Range")
//------------------Genral Functions------------------------//
in_session(sess) =>
not na(time(timeframe.period, sess))
start_time(sess) =>
int startTime = na
startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1]
startTime
is_new_session(sess) =>
t = time("D", sess)
na(t[1]) and not na(t) or t[1] < t
br_styl(string style)=>
switch style
"No border" => line.style_solid
"Solid" => line.style_solid
"Dashed" => line.style_dashed
"Dotted" => line.style_dotted
=>line.style_dotted
lbl_size(string size)=>
switch size
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Huge" => size.huge
=>size.small
nofil(ses) =>
int ret = 0
if(ses == "No border" or br == false)
ret:=100
ret
else
ret
sessToShow(sess) =>
int ret = 0
if(sess == "Sydney")
ret:=1
ret
else if (sess == "Tokyo")
ret:=2
ret
else if (sess == "Both")
ret:=3
ret
else
ret
timeinrange(res, sess) => time(res, sess) != 0
_dow() =>
string day = " Monday"
if (dayofweek(time('D')) == dayofweek.monday and close )
day := " Tuesday"
day
else if(dayofweek(time('D')) == dayofweek.tuesday and close )
day := " Wednesday"
day
else if(dayofweek(time('D')) == dayofweek.wednesday and close)
day := " Thursday"
day
else if(dayofweek(time('D')) == dayofweek.thursday and close )
day := " Friday"
day
else if(dayofweek(time('D')) == dayofweek.friday and close )
day := " Saturday"
day
else if(dayofweek(time('D')) == dayofweek.saturday and close )
day :=" Sunday"
day
else if(dayofweek(time('D')) == dayofweek.sunday and close )
day
//------------------Variables------------------------//
current_tf = str.tonumber(timeframe.period)
bool valid_tf = current_tf <= 60
bool boxType = (type == "Range Box")
_lblSize = lbl_size(size)
_showLabel = ((show_lbl) and (fil or br)) ? 0:100
_sessToShow = sessToShow(_asianSess)
day = _dow()
//--------------------Asia Session---------------------//
asia_session = is_new_session(asia)
box _asiabox = box(na)
float _asialow = na
float _asiahigh = na
label _asialbl=label(na)
_asiastart = start_time(asia)
_asialow := asia_session ? low : in_session(asia) ? math.min(low, _asialow[1]) : na
_asiahigh := asia_session ? high : in_session(asia) ? math.max(high, _asiahigh[1]) : na
_asiabrtype = br_styl(asiabrtype)
_inasia = in_session(asia) and valid_tf
bool _show_asianRange = ((_sessToShow == 0) and show_asian_range )
int asbr = nofil(asiabrtype)
color _asiabox_col = fil?asiabox_col:color.new(color.black,100)
string _astxt = (_show_asianRange and show_lbl )? ((show_day)?"AS "+day:"AS") :""
if _inasia and boxType
if in_session(asia)[1]
label.delete(_asialbl[1])
box.delete(_asiabox[1])
if low < _asialow
_asialow := low
if high > _asiahigh
_asiahigh := high
if _show_asianRange
_asiabox := box.new(_asiastart, _asiahigh, time, _asialow, xloc=xloc.bar_time, bgcolor=_asiabox_col, border_color=color.new(asiaboxborder_col,asbr), border_style=_asiabrtype)
_asialbl:= label.new( x= _asiastart,y=_asiahigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(asiaboxborder_col,_showLabel),text= _astxt)
_asiabox
bgcolor(_show_asianRange and not(boxType) and timeinrange(timeframe.period, asia) ?_asiabox_col : na)
//--------------------Sydney Session---------------------//
sydney_session = is_new_session(sydney)
box _sydneybox = box(na)
float _sydneylow = na
float _sydneyhigh = na
label _sydneylbl=label(na)
_sydneystart = start_time(sydney)
_sydneylow := sydney_session ? low : in_session(sydney) ? math.min(low, _sydneylow[1]) : na
_sydneyhigh := sydney_session ? high : in_session(sydney) ? math.max(high, _sydneyhigh[1]) : na
_sydneybrtype = br_styl(sydneybrtype)
_insydney = in_session(sydney) and valid_tf
bool _show_sydneyRange = (((_sessToShow == 1) or (_sessToShow == 3)) and show_asian_range )
int sybr = nofil(sydneybrtype)
color _sydneybox_col = fil?sydneybox_col:color.new(color.black,100)
string _sytxt = (_show_sydneyRange and show_lbl )? ((show_day)?"SY "+day:"SY") :""
if _insydney and boxType
if in_session(sydney)[1]
label.delete(_sydneylbl[1])
box.delete(_sydneybox[1])
if low < _sydneylow
_sydneylow := low
if high > _sydneyhigh
_sydneyhigh := high
if _show_sydneyRange
_sydneybox := box.new(_sydneystart, _sydneyhigh, time, _sydneylow, xloc=xloc.bar_time, bgcolor=_sydneybox_col, border_color=color.new(sydneyboxborder_col,sybr), border_style=_sydneybrtype)
_sydneylbl:= label.new( x= _sydneystart,y=_sydneyhigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(sydneyboxborder_col,_showLabel),text= _sytxt )
_sydneybox
bgcolor(_show_sydneyRange and not(boxType) and timeinrange(timeframe.period, sydney) ?_sydneybox_col : na)
//--------------------Tokyo Session---------------------//
tokyo_session = is_new_session(tokyo)
box _tokyobox = box(na)
float _tokyolow = na
float _tokyohigh = na
label _tokyolbl=label(na)
_tokyostart = start_time(tokyo)
_tokyolow := tokyo_session ? low : in_session(tokyo) ? math.min(low, _tokyolow[1]) : na
_tokyohigh := tokyo_session ? high : in_session(tokyo) ? math.max(high, _tokyohigh[1]) : na
_tokyobrtype = br_styl(tokyobrtype)
_intokyo = in_session(tokyo) and valid_tf
bool _show_tokyoRange = (((_sessToShow == 2) or (_sessToShow == 3)) and show_asian_range )
int tybr = nofil(tokyobrtype)
color _tokyobox_col = fil?tokyobox_col:color.new(color.black,100)
string _tytxt = (_show_tokyoRange and show_lbl and not(_show_sydneyRange) )? ((show_day)?"TY "+day:"TY") :"TY"
if _intokyo and boxType
if in_session(tokyo)[1]
label.delete(_tokyolbl[1])
box.delete(_tokyobox[1])
if low < _tokyolow
_tokyolow := low
if high > _tokyohigh
_tokyohigh := high
if _show_tokyoRange
_tokyobox := box.new(_tokyostart, _tokyohigh, time, _tokyolow, xloc=xloc.bar_time, bgcolor=_tokyobox_col, border_color=color.new(tokyoboxborder_col,tybr), border_style=_tokyobrtype)
_tokyolbl:= label.new( x= _tokyostart,y=_tokyohigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(tokyoboxborder_col,_showLabel),text= _tytxt)
_tokyobox
bgcolor(_show_tokyoRange and not(boxType) and timeinrange(timeframe.period, tokyo) ?_tokyobox_col : na)
//--------------------Frankfurt Session---------------------//
frankfurt_session = is_new_session(frankfurt)
box _frankfurtbox = box(na)
float _frankfurtlow = na
float _frankfurthigh = na
label _frankfurtlbl=label(na)
_frankfurtstart = start_time(frankfurt)
_frankfurtlow := frankfurt_session ? low : in_session(frankfurt) ? math.min(low, _frankfurtlow[1]) : na
_frankfurthigh := frankfurt_session ? high : in_session(frankfurt) ? math.max(high, _frankfurthigh[1]) : na
_frankfurtbrtype = br_styl(frankfurtbrtype)
_infrankfurt= in_session(frankfurt) and valid_tf
int frbr = nofil(frankfurtbrtype)
color _frankfurtbox_col = fil?frankfurtbox_col:color.new(color.black,100)
string _frtxt = (show_frankfurt_range and show_lbl and not(show_asian_range))? ((show_day)?"FR "+day:"FR") :"FR"
if _infrankfurt and boxType
if in_session(frankfurt)[1]
label.delete(_frankfurtlbl[1])
box.delete(_frankfurtbox[1])
if low < _frankfurtlow
_frankfurtlow := low
if high > _frankfurthigh
_frankfurthigh := high
if show_frankfurt_range
_frankfurtbox := box.new(_frankfurtstart, _frankfurthigh, time, _frankfurtlow, xloc=xloc.bar_time, bgcolor=_frankfurtbox_col, border_color=color.new(frankfurtboxborder_col,frbr), border_style=_frankfurtbrtype)
_frankfurtlbl:= label.new( x= _frankfurtstart,y=_frankfurthigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(frankfurtboxborder_col,_showLabel),text= _frtxt)
_frankfurtbox
bgcolor(show_frankfurt_range and not(boxType) and timeinrange(timeframe.period, frankfurt) ?_frankfurtbox_col : na)
//--------------------London Session---------------------//
london_session = is_new_session(london)
box _londonbox = box(na)
float _londonlow = na
float _londonhigh = na
label _londonlbl=label(na)
_londonstart = start_time(london)
_londonlow := london_session ? low : in_session(london) ? math.min(low, _londonlow[1]) : na
_londonhigh := london_session ? high : in_session(london) ? math.max(high, _londonhigh[1]) : na
_inlondon = in_session(london) and valid_tf
_londonbrtype = br_styl(londonbrtype)
color _londonbox_col = fil?londonbox_col:color.new(color.black,100)
string _lntxt = (show_london_range and show_lbl and not(show_asian_range) and not(show_frankfurt_range))? ((show_day)?"LN "+day:"LN") :"LN"
int lobr = nofil(londonbrtype)
if _inlondon and boxType
if in_session(london)[1]
label.delete(_londonlbl[1])
box.delete(_londonbox[1])
if low < _londonlow
_londonlow := low
if high > _londonhigh
_londonhigh := high
if show_london_range
_londonbox := box.new(_londonstart, _londonhigh, time, _londonlow, xloc=xloc.bar_time, bgcolor=_londonbox_col, border_color=color.new(londonboxborder_col,lobr), border_style=_londonbrtype)
_londonlbl:= label.new( x= _londonstart,y=_londonhigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(londonboxborder_col,_showLabel),text= _lntxt)
_londonbox
bgcolor(show_london_range and not(boxType) and timeinrange(timeframe.period,london) ?_londonbox_col : na)
//--------------------New York Session---------------------//
newyork_session = is_new_session(newyork)
box _newyorkbox = box(na)
float _newyorklow = na
float _newyorkhigh = na
label _nylbl=label(na)
_newyorkstart = start_time(newyork)
_newyorklow := newyork_session ? low : in_session(newyork) ? math.min(low, _newyorklow[1]) : na
_newyorkhigh := newyork_session ? high : in_session(newyork) ? math.max(high, _newyorkhigh[1]) : na
_innewyork = in_session(newyork) and valid_tf
_newyorkbrtype = br_styl(nybrtype)
color _newyorkbox_col = fil?newyorkbox_col:color.new(color.black,100)
string _nytxt = (show_newyork_range and show_lbl and not(show_asian_range) and not(show_frankfurt_range ) and not(show_london_range))? ((show_day)?"NY "+day:"NY") :"NY"
int nybr = nofil(nybrtype)
if _innewyork and boxType
if in_session(newyork)[1]
label.delete(_nylbl[1])
box.delete(_newyorkbox[1])
if low < _newyorklow
_newyorklow := low
if high > _newyorkhigh
_newyorkhigh := high
if show_newyork_range
_newyorkbox := box.new(_newyorkstart, _newyorkhigh, time, _newyorklow, xloc=xloc.bar_time, bgcolor=_newyorkbox_col, border_color=color.new(newyorkboxborder_col,nybr), border_style=_newyorkbrtype)
_nylbl:= label.new( x= _newyorkstart,y=_newyorkhigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(newyorkboxborder_col,_showLabel),text= _nytxt)
_newyorkbox
if newyork_session and show_newyork_range
line.new(x1=_newyorkstart, y1=high, x2=_newyorkstart, y2=low, extend=extend.both,color=color.new(color.white,70), width=1, xloc=xloc.bar_time,style =line.style_dotted )
bgcolor(show_newyork_range and not(boxType) and timeinrange(timeframe.period, newyork) ?_newyorkbox_col : na)
//--------------------Custom Session---------------------//
custom_session = is_new_session(custom)
box _custombox = box(na)
float _customlow = na
float _customhigh = na
label _customlbl=label(na)
_customstart = start_time(custom)
_customlow := custom_session ? low : in_session(custom) ? math.min(low, _customlow[1]) : na
_customhigh := custom_session ? high : in_session(custom) ? math.max(high, _customhigh[1]) : na
_incustom = in_session(custom) and valid_tf
_custombrtype = br_styl(custombrtype)
color _custombox_col = fil?custom_col:color.new(color.black,100)
int cubr = nofil(custombrtype)
if _incustom and boxType
if in_session(custom)[1]
label.delete(_customlbl[1])
box.delete(_custombox[1])
if low < _customlow
_customlow := low
if high > _customhigh
_customhigh := high
if show_custom_range
_custombox := box.new(_customstart, _customhigh, time, _customlow, xloc=xloc.bar_time, bgcolor=custom_col, border_color=color.new(customboxborder_col,cubr), border_style=_custombrtype)
_customlbl:= label.new( x= _customstart,y=_customhigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(customboxborder_col,_showLabel),text= day)
_custombox
bgcolor(show_custom_range and not(boxType) and timeinrange(timeframe.period, custom) ?custom_col : na)
|
Rollin' pseudo-Bollinger Bands | https://www.tradingview.com/script/HitM4yXM-Rollin-pseudo-Bollinger-Bands/ | EsIstTurnt | https://www.tradingview.com/u/EsIstTurnt/ | 66 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EsIstTurnt
//@version=5
indicator("Rollin' pseudo-Bollinger Bands ")
//Integers the Boundary is Built upon
src=close>open and close>high[3]?high:low
len1 = input.int(title="Regression Length 1",defval=64 , minval=1)
len2 = input.int(title="Regression Length 2",defval=96 , minval=1)
len3 = input.int(title="Regression Length 3",defval=128, minval=1)
len4 = input.int(title="Regression Length 4",defval=256, minval=1)
len5 = input.int(title="Regression Length 5",defval=512, minval=1)
//User Options
maswitch = input.bool(true ,title='Curve Calc Mode 1/2 ')
hllevels = input.bool(false,title='Show HL Levels? ')
plotupper = input.bool(true ,title='Show Upper Extension Levels?')
plotlower = input.bool(true ,title='Show Lower Extension Levels?')
p_hl1 = input.bool(false,title='Show H/L Level 1? ')
p_hl2 = input.bool(false,title='Show H/L Level 2? ')
p_hl3 = input.bool(false,title='Show H/L Level 3? ')
p_hl4 = input.bool(false,title='Show H/L Level 4? ')
p_hl5 = input.bool(false,title='Show H/L Level 5? ')
tf = input.timeframe('',title='TimeFrame?')
//Get Sources and Make Boundary Lines
src1 = request.security (syminfo.ticker,tf,ta.ema(close,16))
src2 = request.security (syminfo.ticker,tf,ta.ema(close,32))
src3 = request.security (syminfo.ticker,tf,ta.ema(close,48))
src4 = request.security (syminfo.ticker,tf,ta.ema(close,64))
src5 = request.security (syminfo.ticker,tf,ta.ema(close,80))
up1 = ta.swma(ta.highest(high,8 ))
dn1 = ta.swma(ta.lowest (low ,8 ))
up2 = ta.swma(ta.highest(high,32))
dn2 = ta.swma(ta.lowest (low ,32))
up3 = ta.highest (high,48 )
dn3 = ta.lowest (low ,48 )
up4 = ta.highest (high,64 )
dn4 = ta.lowest (low ,64 )
up5 = ta.highest (high,360)
dn5 = ta.lowest (low ,360)
updngap1 = up1-dn1
updngap2 = up2-dn2
updngap3 = up3-dn3
updngap4 = up4-dn4
updngap5 = up5-dn5
out0 = maswitch?ta.linreg(ta.sma(close,8), 8, -8): ta.ema(ta.sma(close,8),8)
out1 = maswitch?ta.linreg(src1, len1, 0) : ta.ema(ta.linreg(src1,len1,0),len1/3)
out2 = maswitch?ta.linreg(src2, len2, 0) : ta.ema(ta.linreg(src2,len2,0),len2/3)
out3 = maswitch?ta.linreg(src3, len3, 0) : ta.ema(ta.linreg(src3,len3,0),len3/3)
out4 = maswitch?ta.linreg(src4, len4, 0) : ta.ema(ta.linreg(src4,len4,0),len4/3)
out5 = maswitch?ta.linreg(src5, len5, 0) : ta.ema(ta.linreg(src5,len5,0),len5/3)
line1 = up1>out5?up2:out5>out4?out5:out4>out3?out4:out3>out2?out3:out2>out1?out2:out1>out0?out1:out0
line2 = dn1<out5?dn2:out5<out4?out5:out4<out3?out4:out3<out2?out3:out2<out1?out2:out1
//Calculate Other Lines Based on Boundarys
gap1 = (line1-close)
gap2 = (close-line2)
gap3 = (line1-line2)
avline = math.avg(line1,line2)
avsma = ta.sma (avline,8 )
hllev1a = ta.swma (ta.vwap (ta.sma(avline+ ((updngap1)),64 )))
hllev2a = ta.swma (ta.vwap (ta.sma(avline+ ((updngap2)),64 )))
hllev3a = ta.swma (ta.vwap (ta.sma(avline+ ((updngap3)),64 )))
hllev4a = ta.swma (ta.vwap (ta.sma(avline+ ((updngap4)/2),64)))
hllev5a = ta.swma (ta.vwap (ta.sma(avline+ ((updngap5)/2),64)))
hllev1b = ta.swma (ta.vwap (ta.sma(avline- ((updngap1)),64 )))
hllev2b = ta.swma (ta.vwap (ta.sma(avline- ((updngap2)),64 )))
hllev3b = ta.swma (ta.vwap (ta.sma(avline- ((updngap3)),64 )))
hllev4b = ta.swma (ta.vwap (ta.sma(avline- ((updngap4)/2),64)))
hllev5b = ta.swma (ta.vwap (ta.sma(avline- ((updngap5)/2),64)))
line2a = ta.swma (line2+(input.float(0.068 ))*ta.highest(( gap3*2.68),64 ))
line2b = ta.swma (line2-(input.float(0.068 ))*ta.highest(( gap3*2.68),64 ))
line2c = ta.swma (line2+(input.float(0.2236))*ta.highest(( gap3*2.68),128))
line2d = ta.swma (line2+(input.float(0.1236))*ta.highest(( gap3*2.68),128))
line1a = ta.swma (line1-(input.float(0.068 ))*ta.highest(( gap3*2.68),64 ))
line1b = ta.swma (line1+(input.float(0.068 ))*ta.highest(( gap3*2.68),64 ))
line1c = ta.swma (line1-(input.float(0.2236))*ta.highest(( gap3*2.68),128))
line1d = ta.swma (line1-(input.float(0.1236))*ta.highest(( gap3*2.68),128))
//hlav1 = math.avg(hllev1a,hllev1b)
//hlav2 = math.avg(hllev2a,hllev2b)
//hlav3 = math.avg(hllev3a,hllev3b)
//hlav4 = math.avg(hllev4a,hllev4b)
//hlav5 = math.avg(hllev5a,hllev5b)
//Dots inversing what the Candles are doing relative to line1/line2
dot1 = close>avline?line2+gap1:na
dot2 = close<avline?line1-gap2:na
//Colors
hlcol = color.new(input.color(color.aqua),40)
gcol = color.new(input.color(color.gray),60)
//Plot It!
//p_up1 = plot(p_hl1?up1:na ,title='New Up Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_up2 = plot(p_hl2?up2:na ,title='New Up Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_up3 = plot(p_hl3?up3:na ,title='New Up Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_up4 = plot(p_hl4?up4:na ,title='New Up Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_up5 = plot(p_hl5?up5:na ,title='New Up Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
//p_dn1 = plot(p_hl1?dn1:na ,title='New Down Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_dn2 = plot(p_hl2?dn2:na ,title='New Down Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_dn3 = plot(p_hl3?dn3:na ,title='New Down Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_dn4 = plot(p_hl4?dn4:na ,title='New Down Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
p_dn5 = plot(p_hl5?dn5:na ,title='New Down Boundary' ,linewidth=1,color=hlcol ,style=plot.style_linebr )
l1 = plot(line1 ,title='Upper Boundary' ,linewidth=2,color=#ff0000 ,style=plot.style_linebr )
l2 = plot(line2 ,title='Lower Boundary' ,linewidth=2,color=#acfb00 ,style=plot.style_linebr )
p_av = plot(avsma ,title='Center Line' ,linewidth=2,color=color.white ,style=plot.style_linebr )
p_dot1= plot(dot1 ,title='Candle Inverse Dots' ,linewidth=1,color=color.green ,style=plot.style_circles)
p_dot2= plot(dot2 ,title='Candle Inverse Dots' ,linewidth=1,color=color.red ,style=plot.style_circles)
p_lv1a= plot(hllevels?p_hl1?hllev1a:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv2a= plot(hllevels?p_hl2?hllev2a:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv3a= plot(hllevels?p_hl3?hllev3a:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv4a= plot(hllevels?p_hl4?hllev4a:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv5a= plot(hllevels?p_hl5?hllev5a:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv1b= plot(hllevels?p_hl1?hllev1b:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv2b= plot(hllevels?p_hl2?hllev2b:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv3b= plot(hllevels?p_hl3?hllev3b:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv4b= plot(hllevels?p_hl4?hllev4b:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_lv5b= plot(hllevels?p_hl5?hllev5b:na:na ,title='High/Low Levels' ,linewidth=1,color=gcol ,style=plot.style_linebr )
p_out1= plot(out1 ,title='Linear Regression Curves',linewidth=1,color=color.black ,style=plot.style_linebr )
p_out2= plot(out2 ,title='Linear Regression Curves',linewidth=1,color=color.black ,style=plot.style_linebr )
p_out3= plot(out3 ,title='Linear Regression Curves',linewidth=1,color=color.black ,style=plot.style_linebr )
p_out4= plot(out4 ,title='Linear Regression Curves',linewidth=1,color=color.black ,style=plot.style_linebr )
p_out5= plot(out5 ,title='Linear Regression Curves',linewidth=2,color=out5>avline?#ff0000:#acfb00,transp=50 ,style=plot.style_cross )
l1a = plot(plotupper?line1a:na ,title ='line1a' ,linewidth=1,color=gcol ,style=plot.style_linebr )
l2a = plot(plotlower?line2a:na ,title ='line2a' ,linewidth=1,color=gcol ,style=plot.style_linebr )
l1b = plot(plotupper?line1b:na ,title ='line1b' ,linewidth=1,color=color.black ,style=plot.style_linebr )
l2b = plot(plotlower?line2b:na ,title ='line2b' ,linewidth=1,color=color.black ,style=plot.style_linebr )
l1c = plot(plotupper?line1c>line2?line1c:na:na ,title ='line1c ' ,linewidth=1,color=line1c>line2 ? color.maroon :na ,style=plot.style_linebr )
l2c = plot(plotlower?line2c<line1?line2c:na:na ,title ='line2c ' ,linewidth=1,color=line2c<line1 ? color.teal:na ,style=plot.style_linebr )
l1d = plot(plotupper?line1d>line2?line1d:na:na ,title ='line1d ' ,linewidth=1,color=line1d < close or close >close[2]or (line1 - close) > (close - line2) ? color.maroon :na)
l2d = plot(plotlower?line2d<line1?line2d:na:na ,title ='line2d ' ,linewidth=1,color=line2 > close or close <close[2]or (line1 - close) < (close - line2) ? color.teal:na )
fill(l1,l1c,color=color.new(#ff0000,85))
fill(l2,l2c,color=color.new(#acfb00,85))
fill(l1,l1d,color=color.new(#ff0000,95))
fill(l2,l2d,color=color.new(#acfb00,95))
//plot(hllevels?p_hl1?hlav1 :na:na,color=color.new(input.color(color.white),80),style=plot.style_linebr)
//plot(hllevels?p_hl2?hlav2 :na:na,color=color.new(input.color(color.white),80),style=plot.style_linebr)
//plot(hllevels?p_hl3?hlav3 :na:na,color=color.new(input.color(color.white),80),style=plot.style_linebr)
//plot(hllevels?p_hl4?hlav4 :na:na,color=color.new(input.color(color.white),80),style=plot.style_linebr)
//plot(hllevels?p_hl5?hlav5 :na:na,color=color.new(input.color(color.white),80),style=plot.style_linebr)
|
Visual RSI | https://www.tradingview.com/script/fFpFGsw3-Visual-RSI/ | RafaelZioni | https://www.tradingview.com/u/RafaelZioni/ | 518 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator(title='Visual RSI', overlay=true)
length = input(14)
overSold = input(35)
overBought = input(65)
p = close
vrsi = ta.rsi(p, length)
price = close
var bool long = na
var bool short = na
long := ta.crossover(vrsi, overSold)
short := ta.crossunder(vrsi, overBought)
var float last_open_long = na
var float last_open_short = na
last_open_long := long ? close : nz(last_open_long[1])
last_open_short := short ? close : nz(last_open_short[1])
mpoint=(last_open_long+last_open_short)/2
entry_value = last_open_long
entry_value1 = last_open_short
// Rounding levels to min tick
nround(x) =>
n = math.round(x / syminfo.mintick) * syminfo.mintick
n
//
disp_panels = input(true, title='Display info panels?')
fibs_label_off = input(40, title='fibs label offset')
fibs_label_size = input.string(size.normal, options=[size.tiny, size.small, size.normal, size.large, size.huge], title='fibs label size')
r1_x = timenow + math.round(ta.change(time) * fibs_label_off)
r1_y = last_open_short
text1 = 'High : ' + str.tostring(nround(last_open_short))
s1_y = last_open_long
text3 = 'low : ' + str.tostring(nround(last_open_long))
R1_label = disp_panels ? label.new(x=r1_x, y=r1_y, text=text1, xloc=xloc.bar_time, yloc=yloc.price, color=color.orange, style=label.style_label_down, textcolor=color.black, size=fibs_label_size) : na
S1_label = disp_panels ? label.new(x=r1_x, y=s1_y, text=text3, xloc=xloc.bar_time, yloc=yloc.price, color=color.lime, style=label.style_label_up, textcolor=color.black, size=fibs_label_size) : na
label.delete(R1_label[1])
label.delete(S1_label[1])
//
plot(mpoint, title='avreage', color=color.new(color.red, 40), style=plot.style_linebr, linewidth=3, trackprice=true, offset=-9999)
plot(last_open_short, title='high', color=color.new(color.red, 40), style=plot.style_linebr, linewidth=3, trackprice=true, offset=-9999)
plot(last_open_long, title='low', color=color.new(color.blue, 40), style=plot.style_linebr, linewidth=3, trackprice=true, offset=-9999)
//
trend = input(false)
if barstate.islast and trend == true
line z = line.new(bar_index[1], last_open_short[1], bar_index, last_open_short, extend=extend.both, color=color.red, style=line.style_dashed, width=1)
line f = line.new(bar_index[1], mpoint[1], bar_index, mpoint, extend=extend.both, color=color.blue, style=line.style_dashed, width=1)
line w = line.new(bar_index[1], last_open_long[1], bar_index, last_open_long, extend=extend.both, color=color.green, style=line.style_dashed, width=1)
line.delete(z[1])
line.delete(f[1])
line.delete(w[1])
//
len = input.int(200, minval=1)
off = 0
dev = input(2, 'Deviation')
c1 = close
lreg1 = ta.linreg(c1, len, off)
lreg_x1 = ta.linreg(c1, len, off + 1)
b1 = bar_index
s1 = lreg1 - lreg_x1
intr1 = lreg1 - b1 * s1
dS1 = 0.0
for i1 = 0 to len - 1 by 1
dS1 += math.pow(c1[i1] - (s1 * (b1 - i1) + intr1), 2)
dS1
de1 = math.sqrt(dS1 / len)
up1 = -de1 * dev + lreg1
down1 = de1 * dev + lreg1
//
//
t1 = 0
x11 = bar_index - len
x21 = bar_index
y11 = s1 * (bar_index - len) + intr1
y21 = lreg1
u1 = t1 <= 0 or bar_index < t1
if u1
line pr1 = line.new(x11, y11, x21, y21, xloc.bar_index, extend.right, color.red, width=1)
line.delete(pr1[1])
line px1 = line.new(x11, de1 * dev + y11, x21, de1 * dev + y21, xloc.bar_index, extend.right, width=1)
line.delete(px1[1])
line pz1 = line.new(x11, -de1 * dev + y11, x21, -de1 * dev + y21, xloc.bar_index, extend.right, width=1)
line.delete(pz1[1])
//
disp_panels1 = input(true, title='Display info panels?')
fibs_label_off1 = 0
fibs_label_size1 = input.string(size.normal, options=[size.tiny, size.small, size.normal, size.large, size.huge], title='label size')
r1_x1 = timenow + math.round(ta.change(time) * fibs_label_off1)
r1_y1 = up1
text11 = 'L : ' + str.tostring(nround(up1))
s1_y1 = down1
text31 = 'H : ' + str.tostring(nround(down1))
M1_y = lreg1
text21 = 'M : ' + str.tostring(nround(lreg1))
R1_label1 = disp_panels1 ? label.new(x=r1_x1, y=r1_y1, text=text11, xloc=xloc.bar_time, yloc=yloc.price, color=color.yellow, style=label.style_label_upper_left, textcolor=color.black, size=fibs_label_size1) : na
S1_label1 = disp_panels1 ? label.new(x=r1_x1, y=s1_y1, text=text31, xloc=xloc.bar_time, yloc=yloc.price, color=color.yellow, style=label.style_label_upper_left, textcolor=color.black, size=fibs_label_size1) : na
M1_label = disp_panels1 ? label.new(x=r1_x1, y=M1_y, text=text21, xloc=xloc.bar_time, yloc=yloc.price, color=color.yellow, style=label.style_label_upper_left, textcolor=color.black, size=fibs_label_size1) : na
label.delete(R1_label1[1])
label.delete(S1_label1[1])
label.delete(M1_label[1])
|
Parabolic SAR Oscillator [LuxAlgo] | https://www.tradingview.com/script/uc5DGskn-Parabolic-SAR-Oscillator-LuxAlgo/ | LuxAlgo | https://www.tradingview.com/u/LuxAlgo/ | 2,137 | 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("SAR Oscillator [LuxAlgo]")
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
acc = input.float(0.01, 'Acceleration'
, minval = 0
, maxval = 1
, step = .01)
inc = input.float(0.02, 'Increment'
, minval = 0
, maxval = 1
, step = .01)
lim = input.float(0.20, 'Maximum'
, minval = 0
, maxval = 1
, step = .1)
//Style
np_css = input.color(#2157f3, 'Normalized Price'
, group = 'Colors')
sp_css = input.color(#ffe400, 'Normalized SAR'
, group = 'Colors')
fill_css_0 = input.color(color.new(#FF0000, 0), 'Fill Gradient'
, inline = 'inline0'
, group = 'Colors')
fill_css_1 = input.color(color.new(#FFFF00, 80), ''
, inline = 'inline0'
, group = 'Colors')
fill_css_2 = input.color(color.new(#39FF14, 0), ''
, inline = 'inline0'
, group = 'Colors')
//-----------------------------------------------------------------------------}
//Calculation
//-----------------------------------------------------------------------------{
var max = 0.
var min = 0.
sar = ta.sar(acc, inc, lim)
cross = ta.cross(close, sar)
max := cross ? math.max(high, sar) : math.max(high, max)
min := cross ? math.min(low, sar) : math.min(low, min)
posc = ((close - sar) / (max - min) * 100)*-1
sosc = (((sar - min) / (max - min) - .5) * -200)*-1
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------{
gradient_0 = color.from_gradient(sosc, -100, 0, fill_css_0, fill_css_1)
gradient_1 = color.from_gradient(sosc, 0, 100, gradient_0, fill_css_2)
plot_0 = plot(posc, 'Normalized Price'
, color = np_css)
plot_1 = plot(sosc, 'Normalized SAR'
, color = sp_css)
plot(cross ? sosc : na, 'SAR Dots'
, color = sosc == -100 ? fill_css_2 : fill_css_0
, style = plot.style_circles
, linewidth = 4)
fill(plot_0, plot_1, gradient_1)
hline(50)
hline(-50) |
Chart VWAP | https://www.tradingview.com/script/QE4dq4ZM-Chart-VWAP/ | TradingView | https://www.tradingview.com/u/TradingView/ | 2,272 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TradingView
//@version=5
indicator("Chart VWAP", overlay = true)
// Chart VWAP
// v2 2023.01.19
// This code was written using the recommendations from the Pine Script™ User Manual's Style Guide:
// https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html
import PineCoders/VisibleChart/1 as PCvc
//#region ———————————————————— Constants and Inputs
// Constants
string AVG_TT = "Enables the average price line for all visible chart bars"
string OHLC_TT = "'Show chart OHLC levels' displays 4 lines at the open, high, low, and close of the visible chart range.
\n\n'Show HL and % to Close values' displays values on the high and low levels when 'Show Chart OHLC' is also enabled.
The percentage is the distance from the current price to the level."
string TT_STD = "The multiplier for the standard deviation bands offset above and below the VWAP. Example: 1.0 is 100% of the offset value.
\n\nNOTE: A value of 0.0 will hide the bands."
// Inputs
bool showAvgInput = input.bool(true, "Show Bar Average", tooltip = AVG_TT)
bool showOhlcInput = input.bool(false, "Show chart OHLC levels ", inline = "11")
bool showLevelInput = input.bool(true, "Show HL and % to Close values", inline = "11", tooltip = OHLC_TT)
float stdMultInput = input.float(0.0, "Standard Deviation Multiplier", inline = "12", minval = 0.0, step = 0.5, tooltip = TT_STD)
//#endregion
//#region ———————————————————— Functions
// @function Sets a horizontal line to the visible chart width at a specified level.
// @param lineId (line) The line identifier.
// @param level (series float) The price level for the line.
// @returns (void) Alters the left and right points of `lineId` to the visible chart width at a specified `level`.
setChartLine(line lineId, series float level) =>
line.set_xy1(lineId, chart.left_visible_bar_time, level)
line.set_xy2(lineId, chart.right_visible_bar_time, level)
// @function Calculates the percent difference between two prices.
// @param startPrice (series float) The begining point to calculate percent from.
// @param endPrice (series float) The end point to calculate percent to.
// @returns (float) A difference in percent between the `startPrice` and the `endPrice`
percent(series float startPrice, series float endPrice) =>
float result = (startPrice - endPrice) / endPrice * 100
// @function Calculates the volume weighted average price (VWAP) and upper and lower standard deviation bands of the visible bar range..
// @param src (series float) The source data for the calculation. Optional. Default is `hlc3`.
// @param stDev (simple float) Standard deviation for the upper and lower bands. Optional. Default is 1.
// @returns ([float, float, float]) A tuple containing the visible VWAP, upper band, and lower band values.
vVwap(series float src = hlc3, simple float stDev = 1) =>
bool startTime = time == chart.left_visible_bar_time
[vwap, upper, lower] = ta.vwap(src, startTime, stDev)
//#endregion
//#region ———————————————————— Calculations
// VWAP anchored on the leftmost visible bar.
[vwap, upper, lower] = vVwap(hlc3, stdMultInput)
// Average `close` of all visible bars.
float barAvg = PCvc.avg()
// OHLC values for the visible chart time range.
[chartOpen, chartHigh, chartLow, chartClose, chartVolume] = PCvc.ohlcv()
//#endregion
//#region ———————————————————— Visuals
// Plot the VWAP and avg bar price.
plot(vwap, "Chart VWAP", color.orange, 2)
plot(PCvc.barIsVisible() and showAvgInput ? barAvg : na, "Visible Avg.", color.new(color.gray, 50))
p1 = plot(stdMultInput != 0 ? upper : na, "Chart VWAP", color.green)
p2 = plot(stdMultInput != 0 ? lower : na, "Chart VWAP", color.green)
fill(p1, p2, color.new(color.green, 95), "Bands Fill")
// Relative x-coordinate time for the price/percent label (25% of the visible space's width, starting from the left).
int labelTime = PCvc.chartXTimePct(25)
// Show OHLC levels and HL values when enabled.
if showOhlcInput and barstate.islast
// Declare drawing objects once and set later.
var line chartHighLine = line.new(na, na, na, na, xloc.bar_time, extend.right, #4CAF5075, line.style_solid, 1)
var line chartLowLine = line.new(na, na, na, na, xloc.bar_time, extend.right, #f2364580, line.style_solid, 1)
var line chartOpenLine = line.new(na, na, na, na, xloc.bar_time, extend.right, color.gray, line.style_dotted, 1)
var line chartCloseLine = line.new(na, na, na, na, xloc.bar_time, extend.right, #787B8675, line.style_solid, 1)
var label chartHighLabel = label.new(na, na, "", xloc.bar_time, yloc.price, color(na), label.style_label_down, #4CAF5075)
var label chartLowLabel = label.new(na, na, "", xloc.bar_time, yloc.price, color(na), label.style_label_up, #f2364580)
// OHLC lines.
setChartLine(chartOpenLine, chartOpen)
setChartLine(chartHighLine, chartHigh)
setChartLine(chartLowLine, chartLow)
setChartLine(chartCloseLine, chartClose)
// Display high, low and percent to `close` values when enabled.
if showLevelInput
string labelFormat = "{0} ({1, number, #.##}%)"
// Reposition labels.
label.set_xy(chartHighLabel, labelTime, chartHigh)
label.set_xy(chartLowLabel, labelTime, chartLow)
// Update label values with each chart update.
label.set_text(chartHighLabel, str.format(labelFormat, str.tostring(chartHigh, format.mintick), percent(chartHigh, chartClose)))
label.set_text(chartLowLabel, str.format(labelFormat, str.tostring(chartLow, format.mintick), percent(chartLow, chartClose)))
//#endregion
|
Eurobond Curve | https://www.tradingview.com/script/EWAEVj0o-Eurobond-Curve/ | capriole_charles | https://www.tradingview.com/u/capriole_charles/ | 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/
// © capriole_charles
//@version=5
indicator('Eurobond Curve (Capriole Investments)')
thresh = input(0.3, "Warning Threshold")
gem2005 = request.security('gem2005', 'D', close)
gem2006 = request.security('gem2006', 'D', close)
gem2007 = request.security('gem2007', 'D', close)
gem2008 = request.security('gem2008', 'D', close)
gem2009 = request.security('gem2009', 'D', close)
gem2010 = request.security('gem2010', 'D', close)
gem2011 = request.security('gem2011', 'D', close)
gem2012 = request.security('gem2012', 'D', close)
gem2013 = request.security('gem2013', 'D', close)
gem2014 = request.security('gem2014', 'D', close)
gem2015 = request.security('gem2015', 'D', close)
gem2016 = request.security('gem2016', 'D', close)
gem2017 = request.security('gem2017', 'D', close)
gem2018 = request.security('gem2018', 'D', close)
gem2019 = request.security('gem2019', 'D', close)
gem2020 = request.security('gem2020', 'D', close)
gem2021 = request.security('gem2021', 'D', close)
gem2022 = request.security('gem2022', 'D', close)
gem2023 = request.security('gem2023', 'D', close)
gem2024 = request.security('gem2024', 'D', close)
gem2025 = request.security('gem2025', 'D', close)
gem2026 = request.security('gem2026', 'D', close)
gem2027 = request.security('gem2027', 'D', close)
gem2028 = request.security('gem2028', 'D', close)
gem2029 = request.security('gem2029', 'D', close)
gem2030 = request.security('gem2030', 'D', close)
gem2031 = request.security('gem2031', 'D', close)
gem2032 = request.security('gem2032', 'D', close)
near=year<=2004 ? gem2005 :
year==2005 ? gem2006 :
year==2006 ? gem2007 :
year==2007 ? gem2008 :
year==2008 ? gem2009 :
year==2009 ? gem2010 :
year==2010 ? gem2011 :
year==2011 ? gem2012 :
year==2012 ? gem2013 :
year==2013 ? gem2014 :
year==2014 ? gem2015 :
year==2015 ? gem2016 :
year==2016 ? gem2017 :
year==2017 ? gem2018 :
year==2018 ? gem2019 :
year==2019 ? gem2020 :
year==2020 ? gem2021 :
year==2021 ? gem2022 :
year==2022 ? gem2023 :
year==2023 ? gem2024 :
year==2024 ? gem2025 :
year==2025 ? gem2026 :
year==2026 ? gem2027 : gem2028
mid =year<=2004 ? gem2006 :
year==2005 ? gem2007 :
year==2006 ? gem2008 :
year==2007 ? gem2009 :
year==2008 ? gem2010 :
year==2009 ? gem2011 :
year==2010 ? gem2012 :
year==2011 ? gem2013 :
year==2012 ? gem2014 :
year==2013 ? gem2015 :
year==2014 ? gem2016 :
year==2015 ? gem2017 :
year==2016 ? gem2018 :
year==2017 ? gem2019 :
year==2018 ? gem2020 :
year==2019 ? gem2021 :
year==2020 ? gem2022 :
year==2021 ? gem2023 :
year==2022 ? gem2024 :
year==2023 ? gem2025 :
year==2024 ? gem2026 :
year==2025 ? gem2027 :
year==2026 ? gem2028 : gem2029
far =year<=2004 ? gem2009 :
year==2005 ? gem2010 :
year==2006 ? gem2011 :
year==2007 ? gem2012 :
year==2008 ? gem2013 :
year==2009 ? gem2014 :
year==2010 ? gem2015 :
year==2011 ? gem2016 :
year==2012 ? gem2017 :
year==2013 ? gem2018 :
year==2014 ? gem2019 :
year==2015 ? gem2020 :
year==2016 ? gem2021 :
year==2017 ? gem2022 :
year==2018 ? gem2023 :
year==2019 ? gem2024 :
year==2020 ? gem2025 :
year==2021 ? gem2026 :
year==2022 ? gem2027 :
year==2023 ? gem2028 :
year==2024 ? gem2029 :
year==2025 ? gem2030 :
year==2026 ? gem2031 : gem2032
plot(near,color=color.new(color.red,50))
plot(mid,color=color.new(color.purple,50))
plot(far,color=color.new(color.black,50))
warning = ta.barssince(mid-far<thresh)<10 and mid>far and near>far //and ta.barssince(mid-far<thresh)[10]>365
risky1 = ta.barssince(near<far)<10
risky2 = ta.barssince(mid<far)<10
bgcolor(warning ? color.new(color.orange,90):na)
bgcolor(risky1 ? color.new(color.red,90):na)
bgcolor(risky2 ? color.new(color.purple,90):na)
// Sourcing
var table_source = table(na)
table_source := table.new(position=position.bottom_left, columns=1, rows=1, bgcolor=color.white, border_width=1)
table.cell(table_source, 0, 0, text="Source: Capriole Investments Limited", bgcolor=color.white, text_color=color.black, width=20, height=7, text_size=size.normal, text_halign=text.align_left) |
Mehrdad banakar (volume / candle size) | https://www.tradingview.com/script/dka2KrY1-Mehrdad-banakar-volume-candle-size/ | Mehrdadcoin | https://www.tradingview.com/u/Mehrdadcoin/ | 10 | 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/
// © Mehrdadcoin
//@version=4
study("volume/candle size")
t=input(hl2,title="candles")
malengh=input(360)
zaribemasignal1=input(2.00)
zaribemasignal2=input(1.00)
bozorg_kardan_dasti_makhraj=input(2000)
kamkardansefr=input(7)
hamiduskuyi=(volume*hl2)
yilmaz=high-low+hl2/bozorg_kardan_dasti_makhraj
mehrdad=yilmaz/(hl2)
jam1=(hamiduskuyi/(pow(10,kamkardansefr)*mehrdad))
ma1=sma(jam1,malengh)*zaribemasignal1
plot(ma1,color=color.aqua)
ma2=sma(jam1,malengh)*zaribemasignal2
plot(ma2,color=color.aqua)
plot(jam1,color=jam1>ma1? color.new(color.red, 0):jam1>ma2?color.new(color.yellow, 0):jam1<ma2?color.new(color.gray, 0):na,style=plot.style_columns)
bgcolor(close < open ? color.new(color.red, 80) : color.new(color.green, 80))
|
MA Ribbon Annual | https://www.tradingview.com/script/9x48u1BR-MA-Ribbon-Annual/ | Ronald_Ryninger | https://www.tradingview.com/u/Ronald_Ryninger/ | 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/
// © Ron_C
//@version=5
indicator("MA Ribbon Annual")
//Inputs
avg_type = input.string("EMA", "Average Type", options=["EMA","SMA"])
annual_avg = input(252, "Annual Moving Avg Length")
month_step_down = input(21, "Monthly Step Down")
annual_ribbon = input.color(color.blue, "Annual Ribbon")
bull_ribbon = input.color(color.green, "Bull Ribbon")
bear_ribbon = input.color(color.red, "Bear Ribbon")
bull_fill = input.color(color.new(color.green, 80), "Bull Fill")
bear_fill = input.color(color.new(color.red, 80), "Bear Fill")
//Ribbion Colors
ribbon_color1 = annual_ribbon
ribbon_color2 = bull_ribbon
ribbon_color3 = bull_ribbon
ribbon_color4 = bull_ribbon
ribbon_color5 = bull_ribbon
ribbon_color6 = bull_ribbon
ribbon_color7 = bull_ribbon
ribbon_color8 = bull_ribbon
ribbon_color9 = bull_ribbon
ribbon_color10 = bull_ribbon
ribbon_color11 = bull_ribbon
ribbon_color12 = bull_ribbon
//Fill Color
fill_color1 = bull_fill
fill_color2 = bull_fill
fill_color3 = bull_fill
fill_color4 = bull_fill
fill_color5 = bull_fill
fill_color6 = bull_fill
fill_color7 = bull_fill
fill_color8 = bull_fill
fill_color9 = bull_fill
fill_color10 = bull_fill
fill_color11 = bull_fill
//Step Values
month_step_down1 = month_step_down
month_step_down2 = month_step_down*2
month_step_down3 = month_step_down*3
month_step_down4 = month_step_down*4
month_step_down5 = month_step_down*5
month_step_down6 = month_step_down*6
month_step_down7 = month_step_down*7
month_step_down8 = month_step_down*8
month_step_down9 = month_step_down*9
month_step_down10 = month_step_down*10
month_step_down11 = month_step_down*11
//Inital Avg plot values
avg1 = 0.0
avg2 = 0.0
avg3 = 0.0
avg4 = 0.0
avg5 = 0.0
avg6 = 0.0
avg7 = 0.0
avg8 = 0.0
avg9 = 0.0
avg10 = 0.0
avg11 = 0.0
avg12 = 0.0
// MA Values
if avg_type == "EMA"
avg1 := ta.ema(close, annual_avg)
if ta.ema(close,annual_avg-month_step_down1) < ta.ema(close,annual_avg)
ribbon_color2 := bear_ribbon
avg2 := ta.ema(close,annual_avg-month_step_down1)
if ta.ema(close,annual_avg-month_step_down2) < ta.ema(close,annual_avg)
ribbon_color3 := bear_ribbon
avg3 := ta.ema(close,annual_avg-month_step_down2)
if ta.ema(close,annual_avg-month_step_down3) < ta.ema(close,annual_avg)
ribbon_color4 := bear_ribbon
avg4 := ta.ema(close,annual_avg-month_step_down3)
if ta.ema(close,annual_avg-month_step_down4) < ta.ema(close,annual_avg)
ribbon_color5 := bear_ribbon
avg5 := ta.ema(close,annual_avg-month_step_down4)
if ta.ema(close,annual_avg-month_step_down5) < ta.ema(close,annual_avg)
ribbon_color6 := bear_ribbon
avg6 := ta.ema(close,annual_avg-month_step_down5)
if ta.ema(close,annual_avg-month_step_down6) < ta.ema(close,annual_avg)
ribbon_color7 := bear_ribbon
avg7 := ta.ema(close,annual_avg-month_step_down6)
if ta.ema(close,annual_avg-month_step_down7) < ta.ema(close,annual_avg)
ribbon_color8 := bear_ribbon
avg8 := ta.ema(close,annual_avg-month_step_down7)
if ta.ema(close,annual_avg-month_step_down8) < ta.ema(close,annual_avg)
ribbon_color9 := bear_ribbon
avg9 := ta.ema(close,annual_avg-month_step_down8)
if ta.ema(close,annual_avg-month_step_down9) < ta.ema(close,annual_avg)
ribbon_color10 := bear_ribbon
avg10 := ta.ema(close,annual_avg-month_step_down9)
if ta.ema(close,annual_avg-month_step_down10) < ta.ema(close,annual_avg)
ribbon_color11 := bear_ribbon
avg11 := ta.ema(close,annual_avg-month_step_down10)
if ta.ema(close,annual_avg-month_step_down11) < ta.ema(close,annual_avg)
ribbon_color12 := bear_ribbon
avg12 := ta.ema(close,annual_avg-month_step_down11)
else
avg1 := ta.sma(close, annual_avg)
if ta.sma(close,annual_avg-month_step_down1) < ta.sma(close,annual_avg)
ribbon_color2 := bear_ribbon
avg2 := ta.sma(close,annual_avg-month_step_down1)
if ta.sma(close,annual_avg-month_step_down2) < ta.sma(close,annual_avg)
ribbon_color3 := bear_ribbon
avg3 := ta.sma(close,annual_avg-month_step_down2)
if ta.sma(close,annual_avg-month_step_down3) < ta.sma(close,annual_avg)
ribbon_color4 := bear_ribbon
avg4 := ta.sma(close,annual_avg-month_step_down3)
if ta.sma(close,annual_avg-month_step_down4) < ta.sma(close,annual_avg)
ribbon_color5 := bear_ribbon
avg5 := ta.sma(close,annual_avg-month_step_down4)
if ta.sma(close,annual_avg-month_step_down5) < ta.sma(close,annual_avg)
ribbon_color6 := bear_ribbon
avg6 := ta.sma(close,annual_avg-month_step_down5)
if ta.sma(close,annual_avg-month_step_down6) < ta.sma(close,annual_avg)
ribbon_color7 := bear_ribbon
avg7 := ta.sma(close,annual_avg-month_step_down6)
if ta.sma(close,annual_avg-month_step_down7) < ta.sma(close,annual_avg)
ribbon_color8 := bear_ribbon
avg8 := ta.sma(close,annual_avg-month_step_down7)
if ta.sma(close,annual_avg-month_step_down8) < ta.sma(close,annual_avg)
ribbon_color9 := bear_ribbon
avg9 := ta.sma(close,annual_avg-month_step_down8)
if ta.sma(close,annual_avg-month_step_down9) < ta.sma(close,annual_avg)
ribbon_color10 := bear_ribbon
avg10 := ta.sma(close,annual_avg-month_step_down9)
if ta.sma(close,annual_avg-month_step_down10) < ta.sma(close,annual_avg)
ribbon_color11 := bear_ribbon
avg11 := ta.sma(close,annual_avg-month_step_down10)
if ta.sma(close,annual_avg-month_step_down11) < ta.sma(close,annual_avg)
ribbon_color12 := bear_ribbon
avg12 := ta.sma(close,annual_avg-month_step_down11)
//Fill Colors
if avg2 < avg1
fill_color1 := bear_fill
if avg3 < avg2
fill_color2 := bear_fill
if avg4 < avg3
fill_color3 := bear_fill
if avg5 < avg4
fill_color4 := bear_fill
if avg6 < avg5
fill_color5 := bear_fill
if avg7 < avg6
fill_color6 := bear_fill
if avg8 < avg7
fill_color7 := bear_fill
if avg9 < avg8
fill_color8 := bear_fill
if avg10 < avg9
fill_color9 := bear_fill
if avg11 < avg10
fill_color10 := bear_fill
if avg12 < avg11
fill_color11 := bear_fill
//Plots
p1 = plot(avg1, linewidth = 3, title="Annual Avg", color = ribbon_color1)
p2 = plot(avg2, title="Monthly Step Down 1", color = ribbon_color2)
p3 = plot(avg3, title="Monthly Step Down 2", color = ribbon_color3)
p4 = plot(avg4, title="Monthly Step Down 3", color = ribbon_color4)
p5 = plot(avg5, title="Monthly Step Down 4", color = ribbon_color5)
p6 = plot(avg6, title="Monthly Step Down 5", color = ribbon_color6)
p7 = plot(avg7, title="Monthly Step Down 6", color = ribbon_color7)
p8 = plot(avg8, title="Monthly Step Down 7", color = ribbon_color8)
p9 = plot(avg9, title="Monthly Step Down 8", color = ribbon_color9)
p10 = plot(avg10, title="Monthly Step Down 9", color = ribbon_color10)
p11 = plot(avg11, title="Monthly Step Down 10", color = ribbon_color11)
p12 = plot(avg12, linewidth = 3, title="Monthly Step Down 11", color = ribbon_color12)
fill(p1, p2, color=fill_color1, title = "Gap Slow Avg Step Down 1")
fill(p2, p3, color=fill_color2, title = "Step Down 1 Step Down 2")
fill(p3, p4, color=fill_color3, title = "Step Down 2 Step Down 3")
fill(p4, p5, color=fill_color4, title = "Step Down 3 Step Down 4")
fill(p5, p6, color=fill_color5, title = "Step Down 4 Step Down 5")
fill(p6, p7, color=fill_color6, title = "Step Down 5 Step Down 6")
fill(p7, p8, color=fill_color7, title = "Step Down 6 Step Down 7")
fill(p8, p9, color=fill_color8, title = "Step Down 7 Step Down 8")
fill(p9, p10, color=fill_color9, title = "Step Down 8 Step Down 9")
fill(p10, p11, color=fill_color10, title = "Step Down 9 Step Down 10")
fill(p11, p12, color=fill_color11, title = "Step Down 10 Step Down 11")
|
Dashboard (chlo) - v1 | https://www.tradingview.com/script/y8kUAE7S-Dashboard-chlo-v1/ | karthiksundaram111 | https://www.tradingview.com/u/karthiksundaram111/ | 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/
// © karthiksundaram111
//@version=5
indicator(title="Dashboard (chlo)", overlay=true)
// ---- Table Settings Start {----//
max = 160 //Maximum Length
min = 10 //Minimum Length
var stocks = "Shows Symbols for the selected Index"
var ltp = "Shows LTP of symbols"
dash_loc = input.session("Bottom 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(#237a27,'Buy Cell Color' ,group='Style Settings')
cell_dn = input.color(color.red,'Sell Cell Color' ,group='Style Settings')
cell_Neut = input.color(color.gray,'Neut Cell Color' ,group='Style Settings')
row_col = color.blue
col_col = color.blue
txt_col = color.white
cell_transp = input.int(60,'Cell Transparency' ,minval=0 ,maxval=100 ,group='Style Settings')
// ---- Table Settings End ----}//
// ---- Indicators Show/Hide Settings Start {----//
showLTP = input.bool(defval=true, title="Show LTP :", inline='indicator1', group="Columns Settings")
showhigh = input.bool(defval=true, title="Show high", inline='indicator1', group="Columns Settings")
showlow = input.bool(defval=true, title="Show low", inline='indicator1', group="Columns Settings")
showopen = input.bool(defval=true, title="Show open", inline='indicator1', group="Columns Settings")
// ---- Symbols Show/Hide Settings Start {----//
showSiv = input.bool(defval=true, title="Show India VIX", group="Rows Settings")
showS1 = input.bool(defval=true, title="Show Symbol 1 :", inline='SSym1', group="Rows Settings")
showS2 = input.bool(defval=true, title="Show Symbol 2", inline='SSym1', group="Rows Settings")
showS3 = input.bool(defval=true, title="Show Symbol 3 :", inline='SSym2', group="Rows Settings")
showS4 = input.bool(defval=true, title="Show Symbol 4", inline='SSym2', group="Rows Settings")
showS5 = input.bool(defval=true, title="Show Symbol 5 :", inline='SSym3', group="Rows Settings")
showS6 = input.bool(defval=true, title="Show Symbol 6", inline='SSym3', group="Rows Settings")
showS7 = input.bool(defval=true, title="Show Symbol 7 :", inline='SSym4', group="Rows Settings")
showS8 = input.bool(defval=true, title="Show Symbol 8", inline='SSym4', group="Rows Settings")
showS9 = input.bool(defval=true, title="Show Symbol 9 :", inline='SSym5', group="Rows Settings")
showS10 = input.bool(defval=true, title="Show Symbol 10", inline='SSym5', group="Rows Settings")
// ---- Symbols Show/Hide Settings end ----}//
//---- Index & Symbols Selection code start {----//
_Index = input.string('BankNifty', 'Dashboard for Index', options=['BankNifty', 'Nifty'], group='Symbol Settings')
t1 = _Index == 'BankNifty' ? input.symbol('NSE:BANKNIFTY', 'BNF Symbol 1', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:NIFTY', 'Nifty Symbol 1', inline='Nifty Symbol', group='Symbol Settings')
t2 = _Index == 'BankNifty' ? input.symbol('NSE:BANKNIFTY1!', 'BNF Symbol 2', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:NIFTY1!', 'Nifty Symbol 2', inline='Nifty Symbol', group='Symbol Settings')
t3 = _Index == 'BankNifty' ? input.symbol('NSE:HDFCBANK', 'BNF Symbol 3', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:RELIANCE', 'Nifty Symbol 3', inline='Nifty Symbol', group='Symbol Settings')
t4 = _Index == 'BankNifty' ? input.symbol('NSE:ICICIBANK', 'BNF Symbol 4', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:INFY', 'Nifty Symbol 4', inline='Nifty Symbol', group='Symbol Settings')
t5 = _Index == 'BankNifty' ? input.symbol('NSE:KOTAKBANK', 'BNF Symbol 5', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:HDFCBANK', 'Nifty Symbol 5', inline='Nifty Symbol', group='Symbol Settings')
t6 = _Index == 'BankNifty' ? input.symbol('NSE:AXISBANK', 'BNF Symbol 6', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:ICICIBANK', 'Nifty Symbol 6', inline='Nifty Symbol', group='Symbol Settings')
t7 = _Index == 'BankNifty' ? input.symbol('NSE:SBIN', 'BNF Symbol 7', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:HDFC', 'Nifty Symbol 7', inline='Nifty Symbol', group='Symbol Settings')
t8 = _Index == 'BankNifty' ? input.symbol('NSE:INDUSINDBK', 'BNF Symbol 8', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:TCS', 'Nifty Symbol 8', inline='Nifty Symbol', group='Symbol Settings')
t9 = _Index == 'BankNifty' ? input.symbol('NSE:AUBANK', 'BNF Symbol 9', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:KOTAKBANK', 'Nifty Symbol 9', inline='Nifty Symbol', group='Symbol Settings')
t10 = _Index == 'BankNifty' ? input.symbol('NSE:BANDHANBNK', 'BNF Symbol 10', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:LT', 'Nifty Symbol 10', inline='Nifty Symbol', group='Symbol Settings')
//---- Index & Symbols Selection code end ----}//
//---- get security values {----//
[ts1,ts1O,ts1H,ts1L] = request.security(t1,'D',[close,open,high,low])
//------------------
[ts2,ts2O,ts2H,ts2L] = request.security(t2,'D',[close,open,high,low])
//---------------
[ts3,ts3O,ts3H,ts3L] = request.security(t3,'D',[close,open,high,low])
//----------------
[ts4,ts4O,ts4H,ts4L] = request.security(t4,'D',[close,open,high,low])
//----------------
[ts5,ts5O,ts5H,ts5L] = request.security(t5,'D',[close,open,high,low])
//----------------
[ts6,ts6O,ts6H,ts6L] = request.security(t6,'D',[close,open,high,low])
//----------------
[ts7,ts7O,ts7H,ts7L] = request.security(t7,'D',[close,open,high,low])
//----------------
[ts8,ts8O,ts8H,ts8L] = request.security(t8,'D',[close,open,high,low])
//----------------
[ts9,ts9O,ts9H,ts9L] = request.security(t9,'D',[close,open,high,low])
//----------------
[ts10,ts10O,ts10H,ts10L] = request.security(t10,'D',[close,open,high,low])
//-------------- 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 ----}//
if (barstate.islast)
if showLTP
table.cell(t,2,1,'LTP',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60))
table.cell(t,3,1,'high',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60) )
table.cell(t,4,1,'low',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60))
table.cell(t,5,1,'open',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,60))
//---- Display Symbol-1 data code start {----//
if showS1
table.cell(t,1,3, str.replace_all(t1, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS1 and showLTP
table.cell(t,2,3, str.tostring(ts1, '#') ,text_color=color.green ,text_size=table_text_size)
if showS1 and showhigh
table.cell(t,3,3, str.tostring(ts1H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS1 and showlow
table.cell(t,4,3, str.tostring(ts1L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS1 and showopen
table.cell(t,5,3, str.tostring(ts1O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-2 data code start {----//
if showS2
table.cell(t,1,4, str.replace_all(t2, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS2 and showLTP
table.cell(t,2,4, str.tostring(ts2, '#') ,text_color=color.green,text_size=table_text_size)
if showS2 and showhigh
table.cell(t,3,4, str.tostring(ts2H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS2 and showlow
table.cell(t,4,4, str.tostring(ts2L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS2 and showopen
table.cell(t,5,4, str.tostring(ts2O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-3 data code start {----//
if showS3
table.cell(t,1,5, str.replace_all(t3, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS3 and showLTP
table.cell(t,2,5, str.tostring(ts3, '#') ,text_color=color.green, text_size=table_text_size)
if showS3 and showhigh
table.cell(t,3,5, str.tostring(ts3H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS3 and showlow
table.cell(t,4,5, str.tostring(ts3L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS3 and showopen
table.cell(t,5,5, str.tostring(ts3O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-4 data code start {----//
if showS4
table.cell(t,1,6, str.replace_all(t4, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS4 and showLTP
table.cell(t,2,6, str.tostring(ts4, '#') ,text_color=color.green ,text_size=table_text_size)
if showS3 and showhigh
table.cell(t,3,6, str.tostring(ts4H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS3 and showlow
table.cell(t,4,6, str.tostring(ts4L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS3 and showopen
table.cell(t,5,6, str.tostring(ts4O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-5 data code start {----//
if showS5
table.cell(t,1,7, str.replace_all(t5, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS5 and showLTP
table.cell(t,2,7, str.tostring(ts5, '#') ,text_color=color.green,text_size=table_text_size )
if showS5 and showhigh
table.cell(t,3,7, str.tostring(ts5H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS5 and showlow
table.cell(t,4,7, str.tostring(ts5L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS5 and showopen
table.cell(t,5,7, str.tostring(ts5O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-6 data code start {----//
if showS6
table.cell(t,1,8, str.replace_all(t6, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS6 and showLTP
table.cell(t,2,8, str.tostring(ts6, '#') ,text_color=color.green,text_size=table_text_size)
if showS6 and showhigh
table.cell(t,3,8, str.tostring(ts6H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS6 and showlow
table.cell(t,4,8, str.tostring(ts6L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS6 and showopen
table.cell(t,5,8, str.tostring(ts6O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-7 data code start {----//
if showS7
table.cell(t,1,9, str.replace_all(t7, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS7 and showLTP
table.cell(t,2,9, str.tostring(ts7, '#') ,text_color=color.green, text_size=table_text_size)
if showS7 and showhigh
table.cell(t,3,9, str.tostring(ts7H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS7 and showlow
table.cell(t,4,9, str.tostring(ts7L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS7 and showopen
table.cell(t,5,9, str.tostring(ts7O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-8 data code start {----//
if showS8
table.cell(t,1,10, str.replace_all(t8, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS8 and showLTP
table.cell(t,2,10, str.tostring(ts8, '#') ,text_color=color.green,text_size=table_text_size)
if showS8 and showhigh
table.cell(t,3,10, str.tostring(ts8H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS8 and showlow
table.cell(t,4,10, str.tostring(ts8L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS8 and showopen
table.cell(t,5,10, str.tostring(ts8O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-9 data code start {----//
if showS9
table.cell(t,1,11, str.replace_all(t9, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS9 and showLTP
table.cell(t,2,11, str.tostring(ts9, '#') ,text_color=color.green ,text_size=table_text_size )
if showS9 and showhigh
table.cell(t,3,11, str.tostring(ts9H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS9 and showlow
table.cell(t,4,11, str.tostring(ts9L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS9 and showopen
table.cell(t,5,11, str.tostring(ts9O, '#') ,text_color=color.black ,text_size=table_text_size)
//---- Display Symbol-10 data code start {----//
if showS10
table.cell(t,1,12, str.replace_all(t10, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,80))
if showS10 and showLTP
table.cell(t,2,12, str.tostring(ts10, '#') ,text_color=color.green ,text_size=table_text_size)
if showS10 and showhigh
table.cell(t,3,12, str.tostring(ts10H, '#') ,text_color=color.red ,text_size=table_text_size)
if showS10 and showlow
table.cell(t,4,12, str.tostring(ts10L, '#') ,text_color=color.orange ,text_size=table_text_size)
if showS10 and showopen
table.cell(t,5,12, str.tostring(ts10O, '#') ,text_color=color.black ,text_size=table_text_size)
|
Price Pivots for NSE Index & F&O Stocks | https://www.tradingview.com/script/iquCGjLd-Price-Pivots-for-NSE-Index-F-O-Stocks/ | Arun_K_Bhaskar | https://www.tradingview.com/u/Arun_K_Bhaskar/ | 526 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Arun_K_Bhaskar
//@version=5
// Updated on 24 June 2022
// Included Indexs: NIFTY, BANKNIFTY, FINNIFTY, MIDCPNIFTY, MCX
// Included Equities: All F&O listed stocks as per the updated date.
// Formula Reference: Intrangle - Straddle / Strangle By Saravanan_Ragavan
// Source Link: https://in.tradingview.com/script/BWsF0S4k-Intrangle-Straddle-Strangle/
indicator(title="Price Pivots for NSE Index & F&O Stocks", shorttitle="Price Pivots", overlay=true)
////////////////////////////////////////////////////////// F&O Index & Equity Symbols
// Symbols of Strike Price Difference 1
sym_001_spd_1 = "BHEL"
sym_002_spd_1 = "FEDERALBNK"
sym_003_spd_1 = "GMRINFRA"
sym_004_spd_1 = "IDEA"
sym_005_spd_1 = "IDFC"
sym_006_spd_1 = "IDFCFIRSTB"
sym_007_spd_1 = "IOC"
sym_008_spd_1 = "L_TFH"
sym_009_spd_1 = "NBCC"
sym_010_spd_1 = "NTPC"
sym_011_spd_1 = "PFC"
sym_012_spd_1 = "PNB"
sym_013_spd_1 = "SAIL"
// Symbols of Strike Price Difference 2.5
sym_014_spd_2_5 = "ABCAPITAL"
sym_015_spd_2_5 = "APOLLOTYRE"
sym_016_spd_2_5 = "ASHOKLEY"
sym_017_spd_2_5 = "BANKBARODA"
sym_018_spd_2_5 = "BEL"
sym_019_spd_2_5 = "COALINDIA"
sym_020_spd_2_5 = "CUB"
sym_021_spd_2_5 = "EXIDEIND"
sym_022_spd_2_5 = "FSL"
sym_023_spd_2_5 = "GAIL"
sym_024_spd_2_5 = "HINDCOPPER"
sym_025_spd_2_5 = "ITC"
sym_026_spd_2_5 = "MANAPPURAM"
sym_027_spd_2_5 = "MOTHERSON"
sym_028_spd_2_5 = "M_MFIN"
sym_029_spd_2_5 = "NATIONALUM"
sym_030_spd_2_5 = "NMDC"
sym_031_spd_2_5 = "ONGC"
sym_032_spd_2_5 = "PETRONET"
sym_033_spd_2_5 = "POWERGRID"
sym_034_spd_2_5 = "RBLBANK"
sym_035_spd_2_5 = "RECLTD"
// Symbols of Strike Price Difference 5
sym_036_spd_5 = "ABFRL"
sym_037_spd_5 = "AMARAJABAT"
sym_038_spd_5 = "AMBUJACEM"
sym_039_spd_5 = "BANDHANBNK"
sym_040_spd_5 = "BIOCON"
sym_041_spd_5 = "BPCL"
sym_042_spd_5 = "CANBK"
sym_043_spd_5 = "CROMPTON"
sym_044_spd_5 = "DABUR"
sym_045_spd_5 = "DELTACORP"
sym_046_spd_5 = "DLF"
sym_047_spd_5 = "GLENMARK"
sym_048_spd_5 = "GRANULES"
sym_049_spd_5 = "GSPL"
sym_050_spd_5 = "HDFCLIFE"
sym_051_spd_5 = "HINDPETRO"
sym_052_spd_5 = "IBULHSGFIN"
sym_053_spd_5 = "ICICIPRULI"
sym_054_spd_5 = "IEX"
sym_055_spd_5 = "IGL"
sym_056_spd_5 = "INDHOTEL"
sym_057_spd_5 = "INDIACEM"
sym_058_spd_5 = "INDUSTOWER"
sym_059_spd_5 = "LICHSGFIN"
sym_060_spd_5 = "MARICO"
sym_061_spd_5 = "NAM_INDIA"
sym_062_spd_5 = "RAIN"
sym_063_spd_5 = "STAR"
sym_064_spd_5 = "SUNTV"
sym_065_spd_5 = "TATAPOWER"
sym_066_spd_5 = "ZEEL"
sym_067_spd_5 = "ZYDUSLIFE"
// Symbols of Strike Price Difference 8.5
sym_068_spd_8_5 = "VEDL"
// Symbols of Strike Price Difference 10
sym_069_spd_10 = "ADANIPORTS"
sym_070_spd_10 = "APLLTD"
sym_071_spd_10 = "AUBANK"
sym_072_spd_10 = "AUROPHARMA"
sym_073_spd_10 = "AXISBANK"
sym_074_spd_10 = "BALRAMCHIN"
sym_075_spd_10 = "BERGEPAINT"
sym_076_spd_10 = "BHARATFORG"
sym_077_spd_10 = "BHARTIARTL"
sym_078_spd_10 = "BSOFT"
sym_079_spd_10 = "CANFINHOME"
sym_080_spd_10 = "CHAMBLFERT"
sym_081_spd_10 = "CIPLA"
sym_082_spd_10 = "COLPAL"
sym_083_spd_10 = "CONCOR"
sym_084_spd_10 = "COROMANDEL"
sym_085_spd_10 = "GODREJCP"
sym_086_spd_10 = "GUJGASLTD"
sym_087_spd_10 = "HINDALCO"
sym_088_spd_10 = "ICICIBANK"
sym_089_spd_10 = "JINDALSTEL"
sym_090_spd_10 = "JSWSTEEL"
sym_091_spd_10 = "JUBLFOOD"
sym_092_spd_10 = "LAURUSLABS"
sym_093_spd_10 = "LUPIN"
sym_094_spd_10 = "MCDOWELL_N"
sym_095_spd_10 = "MFSL"
sym_096_spd_10 = "MGL"
sym_097_spd_10 = "M_M"
sym_098_spd_100 = "OFSS"
sym_099_spd_10 = "RAMCOCEM"
sym_100_spd_10 = "SBICARD"
sym_101_spd_10 = "SBILIFE"
sym_102_spd_10 = "SBIN"
sym_103_spd_10 = "SRTRANSFIN"
sym_104_spd_10 = "SUNPHARMA"
sym_105_spd_10 = "SYNGENE"
sym_106_spd_10 = "TATACONSUM"
sym_107_spd_10 = "TATAMOTORS"
sym_108_spd_10 = "TORNTPOWER"
sym_109_spd_10 = "TVSMOTOR"
sym_110_spd_10 = "UPL"
sym_111_spd_10 = "WIPRO"
// Symbols of Strike Price Difference 20
sym_112_spd_20 = "AARTIIND"
sym_113_spd_20 = "ABB"
sym_114_spd_20 = "ACC"
sym_115_spd_20 = "ADANIENT"
sym_116_spd_20 = "ASTRAL"
sym_117_spd_20 = "BALKRISIND"
sym_118_spd_20 = "BATAINDIA"
sym_119_spd_20 = "BRITANNIA"
sym_120_spd_20 = "CHOLAFIN"
sym_121_spd_20 = "CUMMINSIND"
sym_122_spd_20 = "DALBHARAT"
sym_123_spd_100 = "EICHERMOT"
sym_124_spd_20 = "ESCORTS"
sym_125_spd_20 = "GNFC"
sym_126_spd_20 = "GODREJPROP"
sym_127_spd_20 = "GRASIM"
sym_128_spd_20 = "HAL"
sym_129_spd_20 = "HAVELLS"
sym_130_spd_20 = "HCLTECH"
sym_131_spd_20 = "HDFC"
sym_132_spd_20 = "HDFCAMC"
sym_133_spd_20 = "HDFCBANK"
sym_134_spd_20 = "HEROMOTOCO"
sym_135_spd_20 = "HINDUNILVR"
sym_136_spd_20 = "ICICIGI"
sym_137_spd_20 = "INDIGO"
sym_138_spd_20 = "INDUSINDBK"
sym_139_spd_20 = "INFY"
sym_140_spd_20 = "INTELLECT"
sym_141_spd_20 = "IPCALAB"
sym_142_spd_20 = "IRCTC"
sym_143_spd_20 = "KOTAKBANK"
sym_144_spd_20 = "LT"
sym_145_spd_20 = "MCX"
sym_146_spd_20 = "MUTHOOTFIN"
sym_147_spd_20 = "OBEROIRLTY"
sym_148_spd_20 = "PIDILITIND"
sym_149_spd_20 = "PVR"
sym_150_spd_50 = "RELIANCE"
sym_151_spd_20 = "SIEMENS"
sym_152_spd_20 = "TATACHEM"
sym_153_spd_20 = "TATACOMM"
sym_154_spd_20 = "TATASTEEL"
sym_155_spd_20 = "TECHM"
sym_156_spd_20 = "TRENT"
sym_157_spd_20 = "UBL"
sym_158_spd_20 = "VOLTAS"
sym_159_spd_20 = "WHIRLPOOL"
// Symbols of Strike Price Difference 50
sym_160_spd_50 = "ASIANPAINT"
sym_161_spd_50 = "BAJAJ_AUTO"
sym_162_spd_50 = "DEEPAKNTR"
sym_163_spd_50 = "DIVISLAB"
sym_164_spd_50 = "DRREDDY"
sym_165_spd_50 = "JKCEMENT"
sym_166_spd_50 = "LALPATHLAB"
sym_167_spd_50 = "METROPOLIS"
sym_168_spd_50 = "MPHASIS"
sym_169_spd_50 = "NIFTY"
sym_170_spd_50 = "PEL"
sym_171_spd_50 = "PIIND"
sym_172_spd_50 = "POLYCAB"
sym_173_spd_50 = "SRF"
sym_174_spd_50 = "TCS"
sym_175_spd_50 = "TITAN"
sym_176_spd_50 = "TORNTPHARM"
// Symbols of Strike Price Difference 100
sym_177_spd_100 = "APOLLOHOSP"
sym_178_spd_100 = "ATUL"
sym_179_spd_100 = "BAJFINANCE"
sym_180_spd_100 = "BANKNIFTY"
sym_181_spd_100 = "COFORGE"
sym_182_spd_100 = "DIXON"
sym_183_spd_100 = "FINNIFTY"
sym_184_spd_100 = "INDIAMART"
sym_185_spd_100 = "LTI"
sym_186_spd_100 = "LTTS"
sym_187_spd_100 = "MARUTI"
sym_188_spd_100 = "MINDTREE"
sym_189_spd_100 = "NAUKRI"
sym_190_spd_100 = "NAVINFLUOR"
sym_191_spd_100 = "NESTLEIND"
sym_192_spd_100 = "PERSISTENT"
sym_193_spd_100 = "ULTRACEMCO"
// Symbols of Strike Price Difference 200
sym_194_spd_200 = "MIDCPNIFTY"
// Symbols of Strike Price Difference 250
sym_195_spd_250 = "ABBOTINDIA"
sym_196_spd_50 = "ALKEM"
sym_197_spd_250 = "BAJAJFINSV"
sym_198_spd_250 = "BOSCHLTD"
sym_199_spd_250 = "SHREECEM"
// Symbols of Strike Price Difference 500
sym_200_spd_500 = "HONAUT"
sym_201_spd_500 = "MRF"
sym_202_spd_500 = "PAGEIND"
////////////////////////////////////////////////////////// Common Strike Price Difference in NSE F&O
spd_1 = 1
spd_2_5 = 2.5
spd_5 = 5
spd_8_5 = 8.5
spd_10 = 10
spd_20 = 20
spd_50 = 50
spd_100 = 100
spd_200 = 200
spd_250 = 250
spd_500 = 500
////////////////////////////////////////////////////////// Price Pivots
ttSrc = "• Custom: Enter the price manually after choosing the Source as Custom to show the Pivots at that price.\n• LTP: Pivot is calculated based on Last Traded Price.\n• Day Open: Pivot is calculated based on current day opening price.\n• PD Close: Pivot is calculated based on previous day closing price.\n• PD HL2: Pivot is calculated based on previous day average of High and Low.\n• PD HLC3: Pivot is calculated based on previous day average of High, Low and Close."
ttHis = "Increase numbers for prevoius pivots"
ttCus = "Enter price manually to calculate pivots of that price level"
gpPP = "Price Pivots"
show_pp = input.bool(true, title="Show Price Pivots", group=gpPP, inline="01")
show_pp_label = input.bool(true, title="Price Labels", group=gpPP, inline="01")
i_timeframe = input.string("D", title="Timeframe", options=["1", "3", "5", "15", "30", "45", "60", "120", "180", "240", "D", "5D", "W", "2W", "3W", "M", "3M", "6M", "12M"], group=gpPP)
i_source = input.string("PD Close", title="Source", options=["Custom", "LTP","Day Open", "PD Close", "PD HL2", "PD HLC3"], group=gpPP, tooltip=ttSrc)
i_pd_ltp_o = input.int(0, title="Historical (If Source is Day Open)", minval=0, group=gpPP, tooltip=ttHis)
i_pd_c_hl2_hlc3 = input.int(1, title="Historical (If Source is PD Close, HL2, HLC3)", minval=1, group=gpPP, tooltip=ttHis)
i_custom = input.float(0, title="Enter Price (If Source is Custom)", minval=0, group=gpPP, tooltip=ttCus)
////////////////////////////////////////////////////// OHLC
day_open = request.security(syminfo.tickerid, i_timeframe, open[i_pd_ltp_o], lookahead=barmerge.lookahead_on)
pd_high = request.security(syminfo.tickerid, i_timeframe, high[i_pd_c_hl2_hlc3], lookahead=barmerge.lookahead_on)
pd_low = request.security(syminfo.tickerid, i_timeframe, low[i_pd_c_hl2_hlc3], lookahead=barmerge.lookahead_on)
pd_close = request.security(syminfo.tickerid, i_timeframe, close[i_pd_c_hl2_hlc3], lookahead=barmerge.lookahead_on)
get_high = request.security(syminfo.tickerid, "60", high)
get_low = request.security(syminfo.tickerid, "60", low)
////////////////////////////////////////////////////// Source
price_input = i_source == "LTP" ? close[i_pd_ltp_o] :
i_source == "Day Open" ? day_open :
i_source == "PD Close" ? pd_close :
i_source == "PD HL2" ? math.avg(pd_high, pd_low) :
i_source == "PD HLC3" ? math.avg(pd_high, pd_low, pd_close) : i_custom
price_option = i_source == "Custom" ? i_custom : price_input
////////////////////////////////////////////////////// Price Levels Settings
ttR5 = "This number is for R5 which can be adjusted for extended price pivots"
ttS5 = "This number is for S5 which can be adjusted for extended price pivots"
i_r_col = input.color(color.silver, title="", group=gpPP, inline="05")
show_r_1 = input.bool(true, title="R1", group=gpPP, inline="05")
show_r_2 = input.bool(true, title="R2", group=gpPP, inline="05")
show_r_3 = input.bool(false, title="R3", group=gpPP, inline="05")
show_r_4 = input.bool(false, title="R4", group=gpPP, inline="05")
show_r_5 = input.bool(false, title="R5", group=gpPP, inline="05")
i_r_5x_level = input.int(4, minval=4, title="", group=gpPP, inline="05", tooltip=ttR5)
i_s_col = input.color(color.silver, title="", group=gpPP, inline="06")
show_s_1 = input.bool(true, title="S1", group=gpPP, inline="06")
show_s_2 = input.bool(true, title="S2", group=gpPP, inline="06")
show_s_3 = input.bool(false, title="S3", group=gpPP, inline="06")
show_s_4 = input.bool(false, title="S4", group=gpPP, inline="06")
show_s_5 = input.bool(false, title="S5", group=gpPP, inline="06")
i_s_5x_level = input.int(4, minval=4, title="", group=gpPP, inline="06", tooltip=ttS5)
i_pp_style = input.string(line.style_solid, title = "", options = [line.style_solid, line.style_dashed, line.style_dotted], group=gpPP, inline="07")
i_pp_width = input.int(1, title = "", minval=1, group=gpPP, inline="07")
show_avg = input.bool(false, title="Average Levels", group=gpPP, inline="08")
i_pp_avg_style = input.string(line.style_dashed, title = "", options = [line.style_solid, line.style_dashed, line.style_dotted], group=gpPP, inline="08")
i_pp_avg_width = input.int(1, title = "", minval=1, group=gpPP, inline="08")
i_extend = input.string("None", title="Extend Lines", options=["None", "Left", "Right", "Both"], group=gpPP, inline="09")
ext_option = i_extend == "None" ? extend.none : i_extend == "Left" ? extend.left : i_extend == "Right" ? extend.right : i_extend == "Both" ? extend.both : na
////////////////////////////////////////////////////////// Strike Price Difference Formula
// Strike Price Difference 1
upper_val_spd_1 = math.round(price_input[i_pd_ltp_o] / spd_1, 0) * spd_1
lower_val_spd_1 = math.round(price_input[i_pd_ltp_o] / spd_1, 0) * spd_1
upper_spd_1 = upper_val_spd_1 < price_input[i_pd_ltp_o] ? upper_val_spd_1 + spd_1 : upper_val_spd_1
lower_spd_1 = lower_val_spd_1 > price_input[i_pd_ltp_o] ? lower_val_spd_1 - spd_1 : lower_val_spd_1
// Strike Price Difference 2.5
upper_val_spd_2_5 = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
lower_val_spd_2_5 = math.round(price_input[i_pd_ltp_o] / spd_2_5, 0) * spd_2_5
upper_spd_2_5 = upper_val_spd_2_5 < price_input[i_pd_ltp_o] ? upper_val_spd_2_5 + spd_2_5 : upper_val_spd_2_5
lower_spd_2_5 = lower_val_spd_2_5 > price_input[i_pd_ltp_o] ? lower_val_spd_2_5 - spd_2_5 : lower_val_spd_2_5
// Strike Price Difference 5
upper_val_spd_5 = math.round(price_input[i_pd_ltp_o] / spd_5, 0) * spd_5
lower_val_spd_5 = math.round(price_input[i_pd_ltp_o] / spd_5, 0) * spd_5
upper_spd_5 = upper_val_spd_5 < price_input[i_pd_ltp_o] ? upper_val_spd_5 + spd_5 : upper_val_spd_5
lower_spd_5 = lower_val_spd_5 > price_input[i_pd_ltp_o] ? lower_val_spd_5 - spd_5 : lower_val_spd_5
// Strike Price Difference 8.5
upper_val_spd_8_5 = math.round(price_input[i_pd_ltp_o] / spd_8_5, 0) * spd_8_5
lower_val_spd_8_5 = math.round(price_input[i_pd_ltp_o] / spd_8_5, 0) * spd_8_5
upper_spd_8_5 = upper_val_spd_8_5 < price_input[i_pd_ltp_o] ? upper_val_spd_8_5 + spd_8_5 : upper_val_spd_8_5
lower_spd_8_5 = lower_val_spd_8_5 > price_input[i_pd_ltp_o] ? lower_val_spd_8_5 - spd_8_5 : lower_val_spd_8_5
// Strike Price Difference 10
upper_val_spd_10 = math.round(price_input[i_pd_ltp_o] / spd_10, 0) * spd_10
lower_val_spd_10 = math.round(price_input[i_pd_ltp_o] / spd_10, 0) * spd_10
upper_spd_10 = upper_val_spd_10 < price_input[i_pd_ltp_o] ? upper_val_spd_10 + spd_10 : upper_val_spd_10
lower_spd_10 = lower_val_spd_10 > price_input[i_pd_ltp_o] ? lower_val_spd_10 - spd_10 : lower_val_spd_10
// Strike Price Difference 20
upper_val_spd_20 = math.round(price_input[i_pd_ltp_o] / spd_20, 0) * spd_20
lower_val_spd_20 = math.round(price_input[i_pd_ltp_o] / spd_20, 0) * spd_20
upper_spd_20 = upper_val_spd_20 < price_input[i_pd_ltp_o] ? upper_val_spd_20 + spd_20 : upper_val_spd_20
lower_spd_20 = lower_val_spd_20 > price_input[i_pd_ltp_o] ? lower_val_spd_20 - spd_20 : lower_val_spd_20
// Strike Price Difference 50 // NIFTY
upper_val_spd_50 = math.round(price_input[i_pd_ltp_o] / spd_50, 0) * spd_50
lower_val_spd_50 = math.round(price_input[i_pd_ltp_o] / spd_50, 0) * spd_50
upper_spd_50 = upper_val_spd_50 < price_input[i_pd_ltp_o] ? upper_val_spd_50 + spd_50 : upper_val_spd_50
lower_spd_50 = lower_val_spd_50 > price_input[i_pd_ltp_o] ? lower_val_spd_50 - spd_50 : lower_val_spd_50
// Strike Price Difference 100 // BANK NIFTY
upper_val_spd_100 = math.round(price_input[i_pd_ltp_o] / spd_100, 0) * spd_100
lower_val_spd_100 = math.round(price_input[i_pd_ltp_o] / spd_100, 0) * spd_100
upper_spd_100 = upper_val_spd_100 < price_input[i_pd_ltp_o] ? upper_val_spd_100 + spd_100 : upper_val_spd_100
lower_spd_100 = lower_val_spd_100 > price_input[i_pd_ltp_o] ? lower_val_spd_100 - spd_100 : lower_val_spd_100
// Strike Price Difference 200
upper_val_spd_200 = math.round(price_input[i_pd_ltp_o] / spd_200, 0) * spd_200
lower_val_spd_200 = math.round(price_input[i_pd_ltp_o] / spd_200, 0) * spd_200
upper_spd_200 = upper_val_spd_200 < price_input[i_pd_ltp_o] ? upper_val_spd_200 + spd_200 : upper_val_spd_200
lower_spd_200 = lower_val_spd_200 > price_input[i_pd_ltp_o] ? lower_val_spd_200 - spd_200 : lower_val_spd_200
// Strike Price Difference 250
upper_val_spd_250 = math.round(price_input[i_pd_ltp_o] / spd_250, 0) * spd_250
lower_val_spd_250 = math.round(price_input[i_pd_ltp_o] / spd_250, 0) * spd_250
upper_spd_250 = upper_val_spd_250 < price_input[i_pd_ltp_o] ? upper_val_spd_250 + spd_250 : upper_val_spd_250
lower_spd_250 = lower_val_spd_250 > price_input[i_pd_ltp_o] ? lower_val_spd_250 - spd_250 : lower_val_spd_250
// Strike Price Difference 500
upper_val_spd_500 = math.round(price_input[i_pd_ltp_o] / spd_500, 0) * spd_500
lower_val_spd_500 = math.round(price_input[i_pd_ltp_o] / spd_500, 0) * spd_500
upper_spd_500 = upper_val_spd_500 < price_input[i_pd_ltp_o] ? upper_val_spd_500 + spd_500 : upper_val_spd_500
lower_spd_500 = lower_val_spd_500 > price_input[i_pd_ltp_o] ? lower_val_spd_500 - spd_500 : lower_val_spd_500
////////////////////////////////////////////////////////// Upper & Lower Strikes
upper_strike = syminfo.root == sym_001_spd_1 ? upper_spd_1 : syminfo.root == sym_069_spd_10 ? upper_spd_10 : syminfo.root == sym_136_spd_20 ? upper_spd_20 :
syminfo.root == sym_002_spd_1 ? upper_spd_1 : syminfo.root == sym_070_spd_10 ? upper_spd_10 : syminfo.root == sym_137_spd_20 ? upper_spd_20 :
syminfo.root == sym_003_spd_1 ? upper_spd_1 : syminfo.root == sym_071_spd_10 ? upper_spd_10 : syminfo.root == sym_138_spd_20 ? upper_spd_20 :
syminfo.root == sym_004_spd_1 ? upper_spd_1 : syminfo.root == sym_072_spd_10 ? upper_spd_10 : syminfo.root == sym_139_spd_20 ? upper_spd_20 :
syminfo.root == sym_005_spd_1 ? upper_spd_1 : syminfo.root == sym_073_spd_10 ? upper_spd_10 : syminfo.root == sym_140_spd_20 ? upper_spd_20 :
syminfo.root == sym_006_spd_1 ? upper_spd_1 : syminfo.root == sym_074_spd_10 ? upper_spd_10 : syminfo.root == sym_141_spd_20 ? upper_spd_20 :
syminfo.root == sym_007_spd_1 ? upper_spd_1 : syminfo.root == sym_075_spd_10 ? upper_spd_10 : syminfo.root == sym_142_spd_20 ? upper_spd_20 :
syminfo.root == sym_008_spd_1 ? upper_spd_1 : syminfo.root == sym_076_spd_10 ? upper_spd_10 : syminfo.root == sym_143_spd_20 ? upper_spd_20 :
syminfo.root == sym_009_spd_1 ? upper_spd_1 : syminfo.root == sym_077_spd_10 ? upper_spd_10 : syminfo.root == sym_144_spd_20 ? upper_spd_20 :
syminfo.root == sym_010_spd_1 ? upper_spd_1 : syminfo.root == sym_078_spd_10 ? upper_spd_10 : syminfo.root == sym_145_spd_20 ? upper_spd_20 :
syminfo.root == sym_011_spd_1 ? upper_spd_1 : syminfo.root == sym_079_spd_10 ? upper_spd_10 : syminfo.root == sym_146_spd_20 ? upper_spd_20 :
syminfo.root == sym_012_spd_1 ? upper_spd_1 : syminfo.root == sym_080_spd_10 ? upper_spd_10 : syminfo.root == sym_147_spd_20 ? upper_spd_20 :
syminfo.root == sym_013_spd_1 ? upper_spd_1 : syminfo.root == sym_081_spd_10 ? upper_spd_10 : syminfo.root == sym_148_spd_20 ? upper_spd_20 :
syminfo.root == sym_014_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_082_spd_10 ? upper_spd_10 : syminfo.root == sym_149_spd_20 ? upper_spd_20 :
syminfo.root == sym_015_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_083_spd_10 ? upper_spd_10 : syminfo.root == sym_150_spd_50 ? upper_spd_50 :
syminfo.root == sym_016_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_084_spd_10 ? upper_spd_10 : syminfo.root == sym_151_spd_20 ? upper_spd_20 :
syminfo.root == sym_017_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_085_spd_10 ? upper_spd_10 : syminfo.root == sym_152_spd_20 ? upper_spd_20 :
syminfo.root == sym_018_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_086_spd_10 ? upper_spd_10 : syminfo.root == sym_153_spd_20 ? upper_spd_20 :
syminfo.root == sym_019_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_087_spd_10 ? upper_spd_10 : syminfo.root == sym_154_spd_20 ? upper_spd_20 :
syminfo.root == sym_020_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_088_spd_10 ? upper_spd_10 : syminfo.root == sym_155_spd_20 ? upper_spd_20 :
syminfo.root == sym_021_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_089_spd_10 ? upper_spd_10 : syminfo.root == sym_156_spd_20 ? upper_spd_20 :
syminfo.root == sym_022_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_090_spd_10 ? upper_spd_10 : syminfo.root == sym_157_spd_20 ? upper_spd_20 :
syminfo.root == sym_023_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_091_spd_10 ? upper_spd_10 : syminfo.root == sym_158_spd_20 ? upper_spd_20 :
syminfo.root == sym_024_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_092_spd_10 ? upper_spd_10 : syminfo.root == sym_159_spd_20 ? upper_spd_20 :
syminfo.root == sym_025_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_093_spd_10 ? upper_spd_10 : syminfo.root == sym_160_spd_50 ? upper_spd_50 :
syminfo.root == sym_026_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_094_spd_10 ? upper_spd_10 : syminfo.root == sym_161_spd_50 ? upper_spd_50 :
syminfo.root == sym_027_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_095_spd_10 ? upper_spd_10 : syminfo.root == sym_162_spd_50 ? upper_spd_50 :
syminfo.root == sym_028_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_096_spd_10 ? upper_spd_10 : syminfo.root == sym_163_spd_50 ? upper_spd_50 :
syminfo.root == sym_029_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_097_spd_10 ? upper_spd_10 : syminfo.root == sym_164_spd_50 ? upper_spd_50 :
syminfo.root == sym_030_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_098_spd_100 ? upper_spd_100 : syminfo.root == sym_165_spd_50 ? upper_spd_50 :
syminfo.root == sym_031_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_099_spd_10 ? upper_spd_10 : syminfo.root == sym_166_spd_50 ? upper_spd_50 :
syminfo.root == sym_032_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_100_spd_10 ? upper_spd_10 : syminfo.root == sym_167_spd_50 ? upper_spd_50 :
syminfo.root == sym_033_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_101_spd_10 ? upper_spd_10 : syminfo.root == sym_168_spd_50 ? upper_spd_50 :
syminfo.root == sym_034_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_102_spd_10 ? upper_spd_10 : syminfo.root == sym_169_spd_50 ? upper_spd_50 :
syminfo.root == sym_035_spd_2_5 ? upper_spd_2_5 : syminfo.root == sym_103_spd_10 ? upper_spd_10 : syminfo.root == sym_170_spd_50 ? upper_spd_50 :
syminfo.root == sym_036_spd_5 ? upper_spd_5 : syminfo.root == sym_104_spd_10 ? upper_spd_10 : syminfo.root == sym_171_spd_50 ? upper_spd_50 :
syminfo.root == sym_037_spd_5 ? upper_spd_5 : syminfo.root == sym_105_spd_10 ? upper_spd_10 : syminfo.root == sym_172_spd_50 ? upper_spd_50 :
syminfo.root == sym_038_spd_5 ? upper_spd_5 : syminfo.root == sym_106_spd_10 ? upper_spd_10 : syminfo.root == sym_173_spd_50 ? upper_spd_50 :
syminfo.root == sym_039_spd_5 ? upper_spd_5 : syminfo.root == sym_107_spd_10 ? upper_spd_10 : syminfo.root == sym_174_spd_50 ? upper_spd_50 :
syminfo.root == sym_040_spd_5 ? upper_spd_5 : syminfo.root == sym_108_spd_10 ? upper_spd_10 : syminfo.root == sym_175_spd_50 ? upper_spd_50 :
syminfo.root == sym_041_spd_5 ? upper_spd_5 : syminfo.root == sym_109_spd_10 ? upper_spd_10 : syminfo.root == sym_176_spd_50 ? upper_spd_50 :
syminfo.root == sym_042_spd_5 ? upper_spd_5 : syminfo.root == sym_110_spd_10 ? upper_spd_10 : syminfo.root == sym_177_spd_100 ? upper_spd_100 :
syminfo.root == sym_043_spd_5 ? upper_spd_5 : syminfo.root == sym_111_spd_10 ? upper_spd_10 : syminfo.root == sym_178_spd_100 ? upper_spd_100 :
syminfo.root == sym_044_spd_5 ? upper_spd_5 : syminfo.root == sym_112_spd_20 ? upper_spd_20 : syminfo.root == sym_179_spd_100 ? upper_spd_100 :
syminfo.root == sym_045_spd_5 ? upper_spd_5 : syminfo.root == sym_113_spd_20 ? upper_spd_20 : syminfo.root == sym_180_spd_100 ? upper_spd_100 :
syminfo.root == sym_046_spd_5 ? upper_spd_5 : syminfo.root == sym_114_spd_20 ? upper_spd_20 : syminfo.root == sym_181_spd_100 ? upper_spd_100 :
syminfo.root == sym_047_spd_5 ? upper_spd_5 : syminfo.root == sym_115_spd_20 ? upper_spd_20 : syminfo.root == sym_182_spd_100 ? upper_spd_100 :
syminfo.root == sym_048_spd_5 ? upper_spd_5 : syminfo.root == sym_116_spd_20 ? upper_spd_20 : syminfo.root == sym_183_spd_100 ? upper_spd_100 :
syminfo.root == sym_049_spd_5 ? upper_spd_5 : syminfo.root == sym_117_spd_20 ? upper_spd_20 : syminfo.root == sym_184_spd_100 ? upper_spd_100 :
syminfo.root == sym_050_spd_5 ? upper_spd_5 : syminfo.root == sym_118_spd_20 ? upper_spd_20 : syminfo.root == sym_185_spd_100 ? upper_spd_100 :
syminfo.root == sym_051_spd_5 ? upper_spd_5 : syminfo.root == sym_119_spd_20 ? upper_spd_20 : syminfo.root == sym_186_spd_100 ? upper_spd_100 :
syminfo.root == sym_052_spd_5 ? upper_spd_5 : syminfo.root == sym_120_spd_20 ? upper_spd_20 : syminfo.root == sym_187_spd_100 ? upper_spd_100 :
syminfo.root == sym_053_spd_5 ? upper_spd_5 : syminfo.root == sym_121_spd_20 ? upper_spd_20 : syminfo.root == sym_188_spd_100 ? upper_spd_100 :
syminfo.root == sym_054_spd_5 ? upper_spd_5 : syminfo.root == sym_122_spd_20 ? upper_spd_20 : syminfo.root == sym_189_spd_100 ? upper_spd_100 :
syminfo.root == sym_055_spd_5 ? upper_spd_5 : syminfo.root == sym_123_spd_100 ? upper_spd_100 : syminfo.root == sym_190_spd_100 ? upper_spd_100 :
syminfo.root == sym_056_spd_5 ? upper_spd_5 : syminfo.root == sym_124_spd_20 ? upper_spd_20 : syminfo.root == sym_191_spd_100 ? upper_spd_100 :
syminfo.root == sym_057_spd_5 ? upper_spd_5 : syminfo.root == sym_125_spd_20 ? upper_spd_20 : syminfo.root == sym_192_spd_100 ? upper_spd_100 :
syminfo.root == sym_058_spd_5 ? upper_spd_5 : syminfo.root == sym_126_spd_20 ? upper_spd_20 : syminfo.root == sym_193_spd_100 ? upper_spd_100 :
syminfo.root == sym_059_spd_5 ? upper_spd_5 : syminfo.root == sym_127_spd_20 ? upper_spd_20 : syminfo.root == sym_194_spd_200 ? upper_spd_200 :
syminfo.root == sym_060_spd_5 ? upper_spd_5 : syminfo.root == sym_128_spd_20 ? upper_spd_20 : syminfo.root == sym_195_spd_250 ? upper_spd_250 :
syminfo.root == sym_061_spd_5 ? upper_spd_5 : syminfo.root == sym_129_spd_20 ? upper_spd_20 : syminfo.root == sym_196_spd_50 ? upper_spd_50 :
syminfo.root == sym_062_spd_5 ? upper_spd_5 : syminfo.root == sym_130_spd_20 ? upper_spd_20 : syminfo.root == sym_197_spd_250 ? upper_spd_250 :
syminfo.root == sym_063_spd_5 ? upper_spd_5 : syminfo.root == sym_131_spd_20 ? upper_spd_20 : syminfo.root == sym_198_spd_250 ? upper_spd_250 :
syminfo.root == sym_064_spd_5 ? upper_spd_5 : syminfo.root == sym_132_spd_20 ? upper_spd_20 : syminfo.root == sym_199_spd_250 ? upper_spd_250 :
syminfo.root == sym_065_spd_5 ? upper_spd_5 : syminfo.root == sym_133_spd_20 ? upper_spd_20 : syminfo.root == sym_200_spd_500 ? upper_spd_500 :
syminfo.root == sym_066_spd_5 ? upper_spd_5 : syminfo.root == sym_134_spd_20 ? upper_spd_20 : syminfo.root == sym_201_spd_500 ? upper_spd_500 :
syminfo.root == sym_067_spd_5 ? upper_spd_5 : syminfo.root == sym_135_spd_20 ? upper_spd_20 : syminfo.root == sym_202_spd_500 ? upper_spd_500 :
syminfo.root == sym_068_spd_8_5 ? upper_spd_8_5 : na
lower_strike = syminfo.root == sym_001_spd_1 ? lower_spd_1 : syminfo.root == sym_069_spd_10 ? lower_spd_10 : syminfo.root == sym_136_spd_20 ? lower_spd_20 :
syminfo.root == sym_002_spd_1 ? lower_spd_1 : syminfo.root == sym_070_spd_10 ? lower_spd_10 : syminfo.root == sym_137_spd_20 ? lower_spd_20 :
syminfo.root == sym_003_spd_1 ? lower_spd_1 : syminfo.root == sym_071_spd_10 ? lower_spd_10 : syminfo.root == sym_138_spd_20 ? lower_spd_20 :
syminfo.root == sym_004_spd_1 ? lower_spd_1 : syminfo.root == sym_072_spd_10 ? lower_spd_10 : syminfo.root == sym_139_spd_20 ? lower_spd_20 :
syminfo.root == sym_005_spd_1 ? lower_spd_1 : syminfo.root == sym_073_spd_10 ? lower_spd_10 : syminfo.root == sym_140_spd_20 ? lower_spd_20 :
syminfo.root == sym_006_spd_1 ? lower_spd_1 : syminfo.root == sym_074_spd_10 ? lower_spd_10 : syminfo.root == sym_141_spd_20 ? lower_spd_20 :
syminfo.root == sym_007_spd_1 ? lower_spd_1 : syminfo.root == sym_075_spd_10 ? lower_spd_10 : syminfo.root == sym_142_spd_20 ? lower_spd_20 :
syminfo.root == sym_008_spd_1 ? lower_spd_1 : syminfo.root == sym_076_spd_10 ? lower_spd_10 : syminfo.root == sym_143_spd_20 ? lower_spd_20 :
syminfo.root == sym_009_spd_1 ? lower_spd_1 : syminfo.root == sym_077_spd_10 ? lower_spd_10 : syminfo.root == sym_144_spd_20 ? lower_spd_20 :
syminfo.root == sym_010_spd_1 ? lower_spd_1 : syminfo.root == sym_078_spd_10 ? lower_spd_10 : syminfo.root == sym_145_spd_20 ? lower_spd_20 :
syminfo.root == sym_011_spd_1 ? lower_spd_1 : syminfo.root == sym_079_spd_10 ? lower_spd_10 : syminfo.root == sym_146_spd_20 ? lower_spd_20 :
syminfo.root == sym_012_spd_1 ? lower_spd_1 : syminfo.root == sym_080_spd_10 ? lower_spd_10 : syminfo.root == sym_147_spd_20 ? lower_spd_20 :
syminfo.root == sym_013_spd_1 ? lower_spd_1 : syminfo.root == sym_081_spd_10 ? lower_spd_10 : syminfo.root == sym_148_spd_20 ? lower_spd_20 :
syminfo.root == sym_014_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_082_spd_10 ? lower_spd_10 : syminfo.root == sym_149_spd_20 ? lower_spd_20 :
syminfo.root == sym_015_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_083_spd_10 ? lower_spd_10 : syminfo.root == sym_150_spd_50 ? lower_spd_50 :
syminfo.root == sym_016_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_084_spd_10 ? lower_spd_10 : syminfo.root == sym_151_spd_20 ? lower_spd_20 :
syminfo.root == sym_017_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_085_spd_10 ? lower_spd_10 : syminfo.root == sym_152_spd_20 ? lower_spd_20 :
syminfo.root == sym_018_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_086_spd_10 ? lower_spd_10 : syminfo.root == sym_153_spd_20 ? lower_spd_20 :
syminfo.root == sym_019_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_087_spd_10 ? lower_spd_10 : syminfo.root == sym_154_spd_20 ? lower_spd_20 :
syminfo.root == sym_020_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_088_spd_10 ? lower_spd_10 : syminfo.root == sym_155_spd_20 ? lower_spd_20 :
syminfo.root == sym_021_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_089_spd_10 ? lower_spd_10 : syminfo.root == sym_156_spd_20 ? lower_spd_20 :
syminfo.root == sym_022_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_090_spd_10 ? lower_spd_10 : syminfo.root == sym_157_spd_20 ? lower_spd_20 :
syminfo.root == sym_023_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_091_spd_10 ? lower_spd_10 : syminfo.root == sym_158_spd_20 ? lower_spd_20 :
syminfo.root == sym_024_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_092_spd_10 ? lower_spd_10 : syminfo.root == sym_159_spd_20 ? lower_spd_20 :
syminfo.root == sym_025_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_093_spd_10 ? lower_spd_10 : syminfo.root == sym_160_spd_50 ? lower_spd_50 :
syminfo.root == sym_026_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_094_spd_10 ? lower_spd_10 : syminfo.root == sym_161_spd_50 ? lower_spd_50 :
syminfo.root == sym_027_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_095_spd_10 ? lower_spd_10 : syminfo.root == sym_162_spd_50 ? lower_spd_50 :
syminfo.root == sym_028_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_096_spd_10 ? lower_spd_10 : syminfo.root == sym_163_spd_50 ? lower_spd_50 :
syminfo.root == sym_029_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_097_spd_10 ? lower_spd_10 : syminfo.root == sym_164_spd_50 ? lower_spd_50 :
syminfo.root == sym_030_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_098_spd_100 ? lower_spd_100 : syminfo.root == sym_165_spd_50 ? lower_spd_50 :
syminfo.root == sym_031_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_099_spd_10 ? lower_spd_10 : syminfo.root == sym_166_spd_50 ? lower_spd_50 :
syminfo.root == sym_032_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_100_spd_10 ? lower_spd_10 : syminfo.root == sym_167_spd_50 ? lower_spd_50 :
syminfo.root == sym_033_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_101_spd_10 ? lower_spd_10 : syminfo.root == sym_168_spd_50 ? lower_spd_50 :
syminfo.root == sym_034_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_102_spd_10 ? lower_spd_10 : syminfo.root == sym_169_spd_50 ? lower_spd_50 :
syminfo.root == sym_035_spd_2_5 ? lower_spd_2_5 : syminfo.root == sym_103_spd_10 ? lower_spd_10 : syminfo.root == sym_170_spd_50 ? lower_spd_50 :
syminfo.root == sym_036_spd_5 ? lower_spd_5 : syminfo.root == sym_104_spd_10 ? lower_spd_10 : syminfo.root == sym_171_spd_50 ? lower_spd_50 :
syminfo.root == sym_037_spd_5 ? lower_spd_5 : syminfo.root == sym_105_spd_10 ? lower_spd_10 : syminfo.root == sym_172_spd_50 ? lower_spd_50 :
syminfo.root == sym_038_spd_5 ? lower_spd_5 : syminfo.root == sym_106_spd_10 ? lower_spd_10 : syminfo.root == sym_173_spd_50 ? lower_spd_50 :
syminfo.root == sym_039_spd_5 ? lower_spd_5 : syminfo.root == sym_107_spd_10 ? lower_spd_10 : syminfo.root == sym_174_spd_50 ? lower_spd_50 :
syminfo.root == sym_040_spd_5 ? lower_spd_5 : syminfo.root == sym_108_spd_10 ? lower_spd_10 : syminfo.root == sym_175_spd_50 ? lower_spd_50 :
syminfo.root == sym_041_spd_5 ? lower_spd_5 : syminfo.root == sym_109_spd_10 ? lower_spd_10 : syminfo.root == sym_176_spd_50 ? lower_spd_50 :
syminfo.root == sym_042_spd_5 ? lower_spd_5 : syminfo.root == sym_110_spd_10 ? lower_spd_10 : syminfo.root == sym_177_spd_100 ? lower_spd_100 :
syminfo.root == sym_043_spd_5 ? lower_spd_5 : syminfo.root == sym_111_spd_10 ? lower_spd_10 : syminfo.root == sym_178_spd_100 ? lower_spd_100 :
syminfo.root == sym_044_spd_5 ? lower_spd_5 : syminfo.root == sym_112_spd_20 ? lower_spd_20 : syminfo.root == sym_179_spd_100 ? lower_spd_100 :
syminfo.root == sym_045_spd_5 ? lower_spd_5 : syminfo.root == sym_113_spd_20 ? lower_spd_20 : syminfo.root == sym_180_spd_100 ? lower_spd_100 :
syminfo.root == sym_046_spd_5 ? lower_spd_5 : syminfo.root == sym_114_spd_20 ? lower_spd_20 : syminfo.root == sym_181_spd_100 ? lower_spd_100 :
syminfo.root == sym_047_spd_5 ? lower_spd_5 : syminfo.root == sym_115_spd_20 ? lower_spd_20 : syminfo.root == sym_182_spd_100 ? lower_spd_100 :
syminfo.root == sym_048_spd_5 ? lower_spd_5 : syminfo.root == sym_116_spd_20 ? lower_spd_20 : syminfo.root == sym_183_spd_100 ? lower_spd_100 :
syminfo.root == sym_049_spd_5 ? lower_spd_5 : syminfo.root == sym_117_spd_20 ? lower_spd_20 : syminfo.root == sym_184_spd_100 ? lower_spd_100 :
syminfo.root == sym_050_spd_5 ? lower_spd_5 : syminfo.root == sym_118_spd_20 ? lower_spd_20 : syminfo.root == sym_185_spd_100 ? lower_spd_100 :
syminfo.root == sym_051_spd_5 ? lower_spd_5 : syminfo.root == sym_119_spd_20 ? lower_spd_20 : syminfo.root == sym_186_spd_100 ? lower_spd_100 :
syminfo.root == sym_052_spd_5 ? lower_spd_5 : syminfo.root == sym_120_spd_20 ? lower_spd_20 : syminfo.root == sym_187_spd_100 ? lower_spd_100 :
syminfo.root == sym_053_spd_5 ? lower_spd_5 : syminfo.root == sym_121_spd_20 ? lower_spd_20 : syminfo.root == sym_188_spd_100 ? lower_spd_100 :
syminfo.root == sym_054_spd_5 ? lower_spd_5 : syminfo.root == sym_122_spd_20 ? lower_spd_20 : syminfo.root == sym_189_spd_100 ? lower_spd_100 :
syminfo.root == sym_055_spd_5 ? lower_spd_5 : syminfo.root == sym_123_spd_100 ? lower_spd_100 : syminfo.root == sym_190_spd_100 ? lower_spd_100 :
syminfo.root == sym_056_spd_5 ? lower_spd_5 : syminfo.root == sym_124_spd_20 ? lower_spd_20 : syminfo.root == sym_191_spd_100 ? lower_spd_100 :
syminfo.root == sym_057_spd_5 ? lower_spd_5 : syminfo.root == sym_125_spd_20 ? lower_spd_20 : syminfo.root == sym_192_spd_100 ? lower_spd_100 :
syminfo.root == sym_058_spd_5 ? lower_spd_5 : syminfo.root == sym_126_spd_20 ? lower_spd_20 : syminfo.root == sym_193_spd_100 ? lower_spd_100 :
syminfo.root == sym_059_spd_5 ? lower_spd_5 : syminfo.root == sym_127_spd_20 ? lower_spd_20 : syminfo.root == sym_194_spd_200 ? lower_spd_200 :
syminfo.root == sym_060_spd_5 ? lower_spd_5 : syminfo.root == sym_128_spd_20 ? lower_spd_20 : syminfo.root == sym_195_spd_250 ? lower_spd_250 :
syminfo.root == sym_061_spd_5 ? lower_spd_5 : syminfo.root == sym_129_spd_20 ? lower_spd_20 : syminfo.root == sym_196_spd_50 ? lower_spd_50 :
syminfo.root == sym_062_spd_5 ? lower_spd_5 : syminfo.root == sym_130_spd_20 ? lower_spd_20 : syminfo.root == sym_197_spd_250 ? lower_spd_250 :
syminfo.root == sym_063_spd_5 ? lower_spd_5 : syminfo.root == sym_131_spd_20 ? lower_spd_20 : syminfo.root == sym_198_spd_250 ? lower_spd_250 :
syminfo.root == sym_064_spd_5 ? lower_spd_5 : syminfo.root == sym_132_spd_20 ? lower_spd_20 : syminfo.root == sym_199_spd_250 ? lower_spd_250 :
syminfo.root == sym_065_spd_5 ? lower_spd_5 : syminfo.root == sym_133_spd_20 ? lower_spd_20 : syminfo.root == sym_200_spd_500 ? lower_spd_500 :
syminfo.root == sym_066_spd_5 ? lower_spd_5 : syminfo.root == sym_134_spd_20 ? lower_spd_20 : syminfo.root == sym_201_spd_500 ? lower_spd_500 :
syminfo.root == sym_067_spd_5 ? lower_spd_5 : syminfo.root == sym_135_spd_20 ? lower_spd_20 : syminfo.root == sym_202_spd_500 ? lower_spd_500 :
syminfo.root == sym_068_spd_8_5 ? lower_spd_8_5 : na
////////////////////////////////////////////////////////// Strike Price Difference
spd = upper_strike - lower_strike
////////////////////////////////////////////////////////// Higher Strikes
upper_strike_2 = upper_strike + spd
upper_strike_3 = upper_strike + (2 * spd)
upper_strike_4 = upper_strike + (3 * spd)
upper_strike_5 = upper_strike + (i_r_5x_level * spd)
lower_strike_2 = lower_strike - spd
lower_strike_3 = lower_strike - (2 * spd)
lower_strike_4 = lower_strike - (3 * spd)
lower_strike_5 = lower_strike - (i_s_5x_level * spd)
////////////////////////////////////////////////////////// Average Levels
up_lo_avg = math.avg(upper_strike, lower_strike)
up_avg_2 = math.avg(upper_strike, upper_strike_2)
up_avg_3 = math.avg(upper_strike_2, upper_strike_3)
up_avg_4 = math.avg(upper_strike_3, upper_strike_4)
up_avg_5 = math.avg(upper_strike_4, upper_strike_5)
lo_avg_2 = math.avg(lower_strike, lower_strike_2)
lo_avg_3 = math.avg(lower_strike_2, lower_strike_3)
lo_avg_4 = math.avg(lower_strike_3, lower_strike_4)
lo_avg_5 = math.avg(lower_strike_4, lower_strike_5)
////////////////////////////////////////////////////////// Percentage from Close
up_percent_1 = ((close - upper_strike)/close)*100
up_percent_2 = ((close - upper_strike_2)/close)*100
up_percent_3 = ((close - upper_strike_3)/close)*100
up_percent_4 = ((close - upper_strike_4)/close)*100
up_percent_5 = ((close - upper_strike_5)/close)*100
lo_percent_1 = ((close - lower_strike)/close)*100
lo_percent_2 = ((close - lower_strike_2)/close)*100
lo_percent_3 = ((close - lower_strike_3)/close)*100
lo_percent_4 = ((close - lower_strike_4)/close)*100
lo_percent_5 = ((close - lower_strike_5)/close)*100
////////////////////////////////////////////////////////// Points from Close
up_points_1 = upper_strike - close
up_points_2 = upper_strike_2 - close
up_points_3 = upper_strike_3 - close
up_points_4 = upper_strike_4 - close
up_points_5 = upper_strike_5 - close
lo_points_1 = lower_strike - close
lo_points_2 = lower_strike_2 - close
lo_points_3 = lower_strike_3 - close
lo_points_4 = lower_strike_4 - close
lo_points_5 = lower_strike_5 - close
////////////////////////////////////////////////////////// Draw Lines & Labels
// Narest Strike Price
if show_pp
var line upper_line_1 = na
upper_line_1 := line.new(x1=bar_index - 225, y1=upper_strike, x2=bar_index + 10, y2=upper_strike, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(upper_line_1[1])
if show_pp_label
var label upper_label_1 = na
upper_label_1 := label.new(x=bar_index + 10, y=upper_strike, text=str.tostring(upper_strike, "#.## (") + str.tostring(up_percent_1, "#.##") + "%|" + str.tostring(up_points_1, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
label.delete(upper_label_1[1])
var line lower_line_1 = na
lower_line_1 := line.new(x1=bar_index - 225, y1=lower_strike, x2=bar_index + 10, y2=lower_strike, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(lower_line_1[1])
if show_pp_label
var label lower_label_1 = na
lower_label_1 := label.new(x=bar_index + 10, y=lower_strike, text=str.tostring(lower_strike, "#.## (") + str.tostring(lo_percent_1, "#.##") + "%|" + str.tostring(lo_points_1, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
label.delete(lower_label_1[1])
linefill.new(upper_line_1, lower_line_1, color.new(color.silver, 95))
if show_avg and show_pp
var line up_lo_line = na
up_lo_line := line.new(x1=bar_index - 225, y1=up_lo_avg, x2=bar_index + 10, y2=up_lo_avg, color=color.silver, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(up_lo_line[1])
// Upper Lines
if show_r_2 and show_pp
var line upper_line_2 = na
upper_line_2 := line.new(x1=bar_index - 225, y1=upper_strike_2, x2=bar_index + 10, y2=upper_strike_2, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(upper_line_2[1])
if show_pp_label
var label upper_label_2 = na
upper_label_2 := label.new(x=bar_index + 10, y=upper_strike_2, text=str.tostring(upper_strike_2, "#.## (") + str.tostring(up_percent_2, "#.##") + "%|" + str.tostring(up_points_2, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
label.delete(upper_label_2[1])
if show_avg
var line up_avg_2_line = na
up_avg_2_line := line.new(x1=bar_index - 225, y1=up_avg_2, x2=bar_index + 10, y2=up_avg_2, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(up_avg_2_line[1])
if show_r_3 and show_pp
var line upper_line_3 = na
upper_line_3 := line.new(x1=bar_index - 225, y1=upper_strike_3, x2=bar_index + 10, y2=upper_strike_3, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(upper_line_3[1])
if show_pp_label
var label upper_label_3 = na
upper_label_3 := label.new(x=bar_index + 10, y=upper_strike_3, text=str.tostring(upper_strike_3, "#.## (") + str.tostring(up_percent_3, "#.##") + "%|" + str.tostring(up_points_3, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
label.delete(upper_label_3[1])
if show_avg
var line up_avg_3_line = na
up_avg_3_line := line.new(x1=bar_index - 225, y1=up_avg_3, x2=bar_index + 10, y2=up_avg_3, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(up_avg_3_line[1])
if show_r_4 and show_pp
var line upper_line_4 = na
upper_line_4 := line.new(x1=bar_index - 225, y1=upper_strike_4, x2=bar_index + 10, y2=upper_strike_4, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(upper_line_4[1])
if show_pp_label
var label upper_label_4 = na
upper_label_4 := label.new(x=bar_index + 10, y=upper_strike_4, text=str.tostring(upper_strike_4, "#.## (") + str.tostring(up_percent_4, "#.##") + "%|" + str.tostring(up_points_4, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
label.delete(upper_label_4[1])
if show_avg
var line up_avg_4_line = na
up_avg_4_line := line.new(x1=bar_index - 225, y1=up_avg_4, x2=bar_index + 10, y2=up_avg_4, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(up_avg_4_line[1])
if show_r_5 and show_pp
var line upper_line_5 = na
upper_line_5 := line.new(x1=bar_index - 225, y1=upper_strike_5, x2=bar_index + 10, y2=upper_strike_5, color=i_r_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(upper_line_5[1])
if show_pp_label
var label upper_label_5 = na
upper_label_5 := label.new(x=bar_index + 10, y=upper_strike_5, text=str.tostring(upper_strike_5, "#.## (") + str.tostring(up_percent_5, "#.##") + "%|" + str.tostring(up_points_5, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_r_col)
label.delete(upper_label_5[1])
if show_avg
var line up_avg_5_line = na
up_avg_5_line := line.new(x1=bar_index - 225, y1=up_avg_5, x2=bar_index + 10, y2=up_avg_5, color=i_r_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(up_avg_5_line[1])
// Lower Lines
if show_s_2 and show_pp
var line lower_line_2 = na
lower_line_2 := line.new(x1=bar_index - 225, y1=lower_strike_2, x2=bar_index + 10, y2=lower_strike_2, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(lower_line_2[1])
if show_pp_label
var label lower_label_2 = na
lower_label_2 := label.new(x=bar_index + 10, y=lower_strike_2, text=str.tostring(lower_strike_2, "#.## (") + str.tostring(lo_percent_2, "#.##") + "%|" + str.tostring(lo_points_2, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
label.delete(lower_label_2[1])
if show_avg
var line lo_avg_2_line = na
lo_avg_2_line := line.new(x1=bar_index - 225, y1=lo_avg_2, x2=bar_index + 10, y2=lo_avg_2, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(lo_avg_2_line[1])
if show_s_3 and show_pp
var line lower_line_3 = na
lower_line_3 := line.new(x1=bar_index - 225, y1=lower_strike_3, x2=bar_index + 10, y2=lower_strike_3, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(lower_line_3[1])
if show_pp_label
var label lower_label_3 = na
lower_label_3 := label.new(x=bar_index + 10, y=lower_strike_3, text=str.tostring(lower_strike_3, "#.## (") + str.tostring(lo_percent_3, "#.##") + "%|" + str.tostring(lo_points_3, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
label.delete(lower_label_3[1])
if show_avg
var line lo_avg_3_line = na
lo_avg_3_line := line.new(x1=bar_index - 225, y1=lo_avg_3, x2=bar_index + 10, y2=lo_avg_3, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(lo_avg_3_line[1])
if show_s_4 and show_pp
var line lower_line_4 = na
lower_line_4 := line.new(x1=bar_index - 225, y1=lower_strike_4, x2=bar_index + 10, y2=lower_strike_4, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(lower_line_4[1])
if show_pp_label
var label lower_label_4 = na
lower_label_4 := label.new(x=bar_index + 10, y=lower_strike_4, text=str.tostring(lower_strike_4, "#.## (") + str.tostring(lo_percent_4, "#.##") + "%|" + str.tostring(lo_points_4, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
label.delete(lower_label_4[1])
if show_avg
var line lo_avg_4_line = na
lo_avg_4_line := line.new(x1=bar_index - 225, y1=lo_avg_4, x2=bar_index + 10, y2=lo_avg_4, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(lo_avg_4_line[1])
if show_s_5 and show_pp
var line lower_line_5 = na
lower_line_5 := line.new(x1=bar_index - 225, y1=lower_strike_5, x2=bar_index + 10, y2=lower_strike_5, color=i_s_col, width=i_pp_width, style=i_pp_style, extend=ext_option)
line.delete(lower_line_5[1])
if show_pp_label
var label lower_label_5 = na
lower_label_5 := label.new(x=bar_index + 10, y=lower_strike_5, text=str.tostring(lower_strike_5, "#.## (") + str.tostring(lo_percent_5, "#.##") + "%|" + str.tostring(lo_points_5, "#.##") + ")", style=label.style_label_left, color=color.new(color.white, 100), textcolor=i_s_col)
label.delete(lower_label_5[1])
if show_avg
var line lo_avg_5_line = na
lo_avg_5_line := line.new(x1=bar_index - 225, y1=lo_avg_5, x2=bar_index + 10, y2=lo_avg_5, color=i_s_col, width=i_pp_avg_width, style=i_pp_avg_style, extend=ext_option)
line.delete(lo_avg_5_line[1])
////////////////////////////////////////////////////////// Important Pivots
high_low_time = time(timeframe.period, "1015-1016")
pivot_time = time(timeframe.period, "1015-1530")
no_trade_time = time(timeframe.period, "0915-1014")
high_1hr = ta.valuewhen(no_trade_time, get_high, 0)
low_1hr = ta.valuewhen(no_trade_time, get_low, 0)
////////////////////////////////////////////////////// Price Levels Settings
gpL = "Important Pivots"
//i_r_col = input.color(color.rgb(240, 83, 80), title="", group=gpL, inline="01")
show_rz_1 = input.bool(true, title="R1", group=gpL, inline="01")
show_rz_2 = input.bool(false, title="R2", group=gpL, inline="01")
//s_color = input.color(color.rgb(38, 166, 154), title="", group=gpL, inline="02")
show_sz_1 = input.bool(true, title="S1", group=gpL, inline="01")
show_sz_2 = input.bool(false, title="S2", group=gpL, inline="01")
//show_last = input.bool(true, title="Hide Historical", group=gpL, inline="02")
//islast = show_last ? request.security(syminfo.tickerid, i_timeframe, barstate.islast, lookahead=barmerge.lookahead_on) : true
////////////////////////////////////////////////////////// Strike Price Difference Formula
// Strike Price Difference 1
upper_val_spd_1_plot = math.round(high_1hr / spd_1, 0) * spd_1
lower_val_spd_1_plot = math.round(low_1hr / spd_1, 0) * spd_1
upper_spd_1_plot = upper_val_spd_1_plot < high_1hr ? upper_val_spd_1_plot + spd_1 : upper_val_spd_1_plot
lower_spd_1_plot = lower_val_spd_1_plot > low_1hr ? lower_val_spd_1_plot - spd_1 : lower_val_spd_1_plot
// Strike Price Difference 2.5
upper_val_spd_2_5_plot = math.round(high_1hr / spd_2_5, 0) * spd_2_5
lower_val_spd_2_5_plot = math.round(low_1hr / spd_2_5, 0) * spd_2_5
upper_spd_2_5_plot = upper_val_spd_2_5_plot < high_1hr ? upper_val_spd_2_5_plot + spd_2_5 : upper_val_spd_2_5_plot
lower_spd_2_5_plot = lower_val_spd_2_5_plot > low_1hr ? lower_val_spd_2_5_plot - spd_2_5 : lower_val_spd_2_5_plot
// Strike Price Difference 5
upper_val_spd_5_plot = math.round(high_1hr / spd_5, 0) * spd_5
lower_val_spd_5_plot = math.round(low_1hr / spd_5, 0) * spd_5
upper_spd_5_plot = upper_val_spd_5_plot < high_1hr ? upper_val_spd_5_plot + spd_5 : upper_val_spd_5_plot
lower_spd_5_plot = lower_val_spd_5_plot > low_1hr ? lower_val_spd_5_plot - spd_5 : lower_val_spd_5_plot
// Strike Price Difference 8.5
upper_val_spd_8_5_plot = math.round(high_1hr / spd_8_5, 0) * spd_8_5
lower_val_spd_8_5_plot = math.round(low_1hr / spd_8_5, 0) * spd_8_5
upper_spd_8_5_plot = upper_val_spd_8_5_plot < high_1hr ? upper_val_spd_8_5_plot + spd_8_5 : upper_val_spd_8_5_plot
lower_spd_8_5_plot = lower_val_spd_8_5_plot > low_1hr ? lower_val_spd_8_5_plot - spd_8_5 : lower_val_spd_8_5_plot
// Strike Price Difference 10
upper_val_spd_10_plot = math.round(high_1hr / spd_10, 0) * spd_10
lower_val_spd_10_plot = math.round(low_1hr / spd_10, 0) * spd_10
upper_spd_10_plot = upper_val_spd_10_plot < high_1hr ? upper_val_spd_10_plot + spd_10 : upper_val_spd_10_plot
lower_spd_10_plot = lower_val_spd_10_plot > low_1hr ? lower_val_spd_10_plot - spd_10 : lower_val_spd_10_plot
// Strike Price Difference 20
upper_val_spd_20_plot = math.round(high_1hr / spd_20, 0) * spd_20
lower_val_spd_20_plot = math.round(low_1hr / spd_20, 0) * spd_20
upper_spd_20_plot = upper_val_spd_20_plot < high_1hr ? upper_val_spd_20_plot + spd_20 : upper_val_spd_20_plot
lower_spd_20_plot = lower_val_spd_20_plot > low_1hr ? lower_val_spd_20_plot - spd_20 : lower_val_spd_20_plot
// Strike Price Difference 50 // NIFTY
upper_val_spd_50_plot = math.round(high_1hr / spd_50, 0) * spd_50
lower_val_spd_50_plot = math.round(low_1hr / spd_50, 0) * spd_50
upper_spd_50_plot = upper_val_spd_50_plot < high_1hr ? upper_val_spd_50_plot + spd_50 : upper_val_spd_50_plot
lower_spd_50_plot = lower_val_spd_50_plot > low_1hr ? lower_val_spd_50_plot - spd_50 : lower_val_spd_50_plot
// Strike Price Difference 100 // BANK NIFTY
upper_val_spd_100_plot = math.round(high_1hr / spd_100, 0) * spd_100
lower_val_spd_100_plot = math.round(low_1hr / spd_100, 0) * spd_100
upper_spd_100_plot = upper_val_spd_100_plot < high_1hr ? upper_val_spd_100_plot + spd_100 : upper_val_spd_100_plot
lower_spd_100_plot = lower_val_spd_100_plot > low_1hr ? lower_val_spd_100_plot - spd_100 : lower_val_spd_100_plot
// Strike Price Difference 200
upper_val_spd_200_plot = math.round(high_1hr / spd_200, 0) * spd_200
lower_val_spd_200_plot = math.round(low_1hr / spd_200, 0) * spd_200
upper_spd_200_plot = upper_val_spd_200_plot < high_1hr ? upper_val_spd_200_plot + spd_200 : upper_val_spd_200_plot
lower_spd_200_plot = lower_val_spd_200_plot > low_1hr ? lower_val_spd_200_plot - spd_200 : lower_val_spd_200_plot
// Strike Price Difference 250
upper_val_spd_250_plot = math.round(high_1hr / spd_250, 0) * spd_250
lower_val_spd_250_plot = math.round(low_1hr / spd_250, 0) * spd_250
upper_spd_250_plot = upper_val_spd_250_plot < high_1hr ? upper_val_spd_250_plot + spd_250 : upper_val_spd_250_plot
lower_spd_250_plot = lower_val_spd_250_plot > low_1hr ? lower_val_spd_250_plot - spd_250 : lower_val_spd_250_plot
// Strike Price Difference 500
upper_val_spd_500_plot = math.round(high_1hr / spd_500, 0) * spd_500
lower_val_spd_500_plot = math.round(low_1hr / spd_500, 0) * spd_500
upper_spd_500_plot = upper_val_spd_500_plot < high_1hr ? upper_val_spd_500_plot + spd_500 : upper_val_spd_500_plot
lower_spd_500_plot = lower_val_spd_500_plot > low_1hr ? lower_val_spd_500_plot - spd_500 : lower_val_spd_500_plot
////////////////////////////////////////////////////////// Upper & Lower Strikes
upper_strike_plot = syminfo.root == sym_001_spd_1 ? upper_spd_1_plot : syminfo.root == sym_069_spd_10 ? upper_spd_10_plot : syminfo.root == sym_136_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_002_spd_1 ? upper_spd_1_plot : syminfo.root == sym_070_spd_10 ? upper_spd_10_plot : syminfo.root == sym_137_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_003_spd_1 ? upper_spd_1_plot : syminfo.root == sym_071_spd_10 ? upper_spd_10_plot : syminfo.root == sym_138_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_004_spd_1 ? upper_spd_1_plot : syminfo.root == sym_072_spd_10 ? upper_spd_10_plot : syminfo.root == sym_139_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_005_spd_1 ? upper_spd_1_plot : syminfo.root == sym_073_spd_10 ? upper_spd_10_plot : syminfo.root == sym_140_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_006_spd_1 ? upper_spd_1_plot : syminfo.root == sym_074_spd_10 ? upper_spd_10_plot : syminfo.root == sym_141_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_007_spd_1 ? upper_spd_1_plot : syminfo.root == sym_075_spd_10 ? upper_spd_10_plot : syminfo.root == sym_142_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_008_spd_1 ? upper_spd_1_plot : syminfo.root == sym_076_spd_10 ? upper_spd_10_plot : syminfo.root == sym_143_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_009_spd_1 ? upper_spd_1_plot : syminfo.root == sym_077_spd_10 ? upper_spd_10_plot : syminfo.root == sym_144_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_010_spd_1 ? upper_spd_1_plot : syminfo.root == sym_078_spd_10 ? upper_spd_10_plot : syminfo.root == sym_145_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_011_spd_1 ? upper_spd_1_plot : syminfo.root == sym_079_spd_10 ? upper_spd_10_plot : syminfo.root == sym_146_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_012_spd_1 ? upper_spd_1_plot : syminfo.root == sym_080_spd_10 ? upper_spd_10_plot : syminfo.root == sym_147_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_013_spd_1 ? upper_spd_1_plot : syminfo.root == sym_081_spd_10 ? upper_spd_10_plot : syminfo.root == sym_148_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_014_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_082_spd_10 ? upper_spd_10_plot : syminfo.root == sym_149_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_015_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_083_spd_10 ? upper_spd_10_plot : syminfo.root == sym_150_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_016_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_084_spd_10 ? upper_spd_10_plot : syminfo.root == sym_151_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_017_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_085_spd_10 ? upper_spd_10_plot : syminfo.root == sym_152_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_018_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_086_spd_10 ? upper_spd_10_plot : syminfo.root == sym_153_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_019_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_087_spd_10 ? upper_spd_10_plot : syminfo.root == sym_154_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_020_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_088_spd_10 ? upper_spd_10_plot : syminfo.root == sym_155_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_021_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_089_spd_10 ? upper_spd_10_plot : syminfo.root == sym_156_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_022_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_090_spd_10 ? upper_spd_10_plot : syminfo.root == sym_157_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_023_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_091_spd_10 ? upper_spd_10_plot : syminfo.root == sym_158_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_024_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_092_spd_10 ? upper_spd_10_plot : syminfo.root == sym_159_spd_20 ? upper_spd_20_plot :
syminfo.root == sym_025_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_093_spd_10 ? upper_spd_10_plot : syminfo.root == sym_160_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_026_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_094_spd_10 ? upper_spd_10_plot : syminfo.root == sym_161_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_027_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_095_spd_10 ? upper_spd_10_plot : syminfo.root == sym_162_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_028_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_096_spd_10 ? upper_spd_10_plot : syminfo.root == sym_163_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_029_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_097_spd_10 ? upper_spd_10_plot : syminfo.root == sym_164_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_030_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_098_spd_100 ? upper_spd_100_plot : syminfo.root == sym_165_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_031_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_099_spd_10 ? upper_spd_10_plot : syminfo.root == sym_166_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_032_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_100_spd_10 ? upper_spd_10_plot : syminfo.root == sym_167_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_033_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_101_spd_10 ? upper_spd_10_plot : syminfo.root == sym_168_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_034_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_102_spd_10 ? upper_spd_10_plot : syminfo.root == sym_169_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_035_spd_2_5 ? upper_spd_2_5_plot : syminfo.root == sym_103_spd_10 ? upper_spd_10_plot : syminfo.root == sym_170_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_036_spd_5 ? upper_spd_5_plot : syminfo.root == sym_104_spd_10 ? upper_spd_10_plot : syminfo.root == sym_171_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_037_spd_5 ? upper_spd_5_plot : syminfo.root == sym_105_spd_10 ? upper_spd_10_plot : syminfo.root == sym_172_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_038_spd_5 ? upper_spd_5_plot : syminfo.root == sym_106_spd_10 ? upper_spd_10_plot : syminfo.root == sym_173_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_039_spd_5 ? upper_spd_5_plot : syminfo.root == sym_107_spd_10 ? upper_spd_10_plot : syminfo.root == sym_174_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_040_spd_5 ? upper_spd_5_plot : syminfo.root == sym_108_spd_10 ? upper_spd_10_plot : syminfo.root == sym_175_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_041_spd_5 ? upper_spd_5_plot : syminfo.root == sym_109_spd_10 ? upper_spd_10_plot : syminfo.root == sym_176_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_042_spd_5 ? upper_spd_5_plot : syminfo.root == sym_110_spd_10 ? upper_spd_10_plot : syminfo.root == sym_177_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_043_spd_5 ? upper_spd_5_plot : syminfo.root == sym_111_spd_10 ? upper_spd_10_plot : syminfo.root == sym_178_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_044_spd_5 ? upper_spd_5_plot : syminfo.root == sym_112_spd_20 ? upper_spd_20_plot : syminfo.root == sym_179_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_045_spd_5 ? upper_spd_5_plot : syminfo.root == sym_113_spd_20 ? upper_spd_20_plot : syminfo.root == sym_180_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_046_spd_5 ? upper_spd_5_plot : syminfo.root == sym_114_spd_20 ? upper_spd_20_plot : syminfo.root == sym_181_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_047_spd_5 ? upper_spd_5_plot : syminfo.root == sym_115_spd_20 ? upper_spd_20_plot : syminfo.root == sym_182_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_048_spd_5 ? upper_spd_5_plot : syminfo.root == sym_116_spd_20 ? upper_spd_20_plot : syminfo.root == sym_183_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_049_spd_5 ? upper_spd_5_plot : syminfo.root == sym_117_spd_20 ? upper_spd_20_plot : syminfo.root == sym_184_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_050_spd_5 ? upper_spd_5_plot : syminfo.root == sym_118_spd_20 ? upper_spd_20_plot : syminfo.root == sym_185_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_051_spd_5 ? upper_spd_5_plot : syminfo.root == sym_119_spd_20 ? upper_spd_20_plot : syminfo.root == sym_186_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_052_spd_5 ? upper_spd_5_plot : syminfo.root == sym_120_spd_20 ? upper_spd_20_plot : syminfo.root == sym_187_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_053_spd_5 ? upper_spd_5_plot : syminfo.root == sym_121_spd_20 ? upper_spd_20_plot : syminfo.root == sym_188_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_054_spd_5 ? upper_spd_5_plot : syminfo.root == sym_122_spd_20 ? upper_spd_20_plot : syminfo.root == sym_189_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_055_spd_5 ? upper_spd_5_plot : syminfo.root == sym_123_spd_100 ? upper_spd_100_plot : syminfo.root == sym_190_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_056_spd_5 ? upper_spd_5_plot : syminfo.root == sym_124_spd_20 ? upper_spd_20_plot : syminfo.root == sym_191_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_057_spd_5 ? upper_spd_5_plot : syminfo.root == sym_125_spd_20 ? upper_spd_20_plot : syminfo.root == sym_192_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_058_spd_5 ? upper_spd_5_plot : syminfo.root == sym_126_spd_20 ? upper_spd_20_plot : syminfo.root == sym_193_spd_100 ? upper_spd_100_plot :
syminfo.root == sym_059_spd_5 ? upper_spd_5_plot : syminfo.root == sym_127_spd_20 ? upper_spd_20_plot : syminfo.root == sym_194_spd_200 ? upper_spd_200_plot :
syminfo.root == sym_060_spd_5 ? upper_spd_5_plot : syminfo.root == sym_128_spd_20 ? upper_spd_20_plot : syminfo.root == sym_195_spd_250 ? upper_spd_250_plot :
syminfo.root == sym_061_spd_5 ? upper_spd_5_plot : syminfo.root == sym_129_spd_20 ? upper_spd_20_plot : syminfo.root == sym_196_spd_50 ? upper_spd_50_plot :
syminfo.root == sym_062_spd_5 ? upper_spd_5_plot : syminfo.root == sym_130_spd_20 ? upper_spd_20_plot : syminfo.root == sym_197_spd_250 ? upper_spd_250_plot :
syminfo.root == sym_063_spd_5 ? upper_spd_5_plot : syminfo.root == sym_131_spd_20 ? upper_spd_20_plot : syminfo.root == sym_198_spd_250 ? upper_spd_250_plot :
syminfo.root == sym_064_spd_5 ? upper_spd_5_plot : syminfo.root == sym_132_spd_20 ? upper_spd_20_plot : syminfo.root == sym_199_spd_250 ? upper_spd_250_plot :
syminfo.root == sym_065_spd_5 ? upper_spd_5_plot : syminfo.root == sym_133_spd_20 ? upper_spd_20_plot : syminfo.root == sym_200_spd_500 ? upper_spd_500_plot :
syminfo.root == sym_066_spd_5 ? upper_spd_5_plot : syminfo.root == sym_134_spd_20 ? upper_spd_20_plot : syminfo.root == sym_201_spd_500 ? upper_spd_500_plot :
syminfo.root == sym_067_spd_5 ? upper_spd_5_plot : syminfo.root == sym_135_spd_20 ? upper_spd_20_plot : syminfo.root == sym_202_spd_500 ? upper_spd_500_plot :
syminfo.root == sym_068_spd_8_5 ? upper_spd_8_5_plot : na
lower_strike_plot = syminfo.root == sym_001_spd_1 ? lower_spd_1_plot : syminfo.root == sym_069_spd_10 ? lower_spd_10_plot : syminfo.root == sym_136_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_002_spd_1 ? lower_spd_1_plot : syminfo.root == sym_070_spd_10 ? lower_spd_10_plot : syminfo.root == sym_137_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_003_spd_1 ? lower_spd_1_plot : syminfo.root == sym_071_spd_10 ? lower_spd_10_plot : syminfo.root == sym_138_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_004_spd_1 ? lower_spd_1_plot : syminfo.root == sym_072_spd_10 ? lower_spd_10_plot : syminfo.root == sym_139_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_005_spd_1 ? lower_spd_1_plot : syminfo.root == sym_073_spd_10 ? lower_spd_10_plot : syminfo.root == sym_140_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_006_spd_1 ? lower_spd_1_plot : syminfo.root == sym_074_spd_10 ? lower_spd_10_plot : syminfo.root == sym_141_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_007_spd_1 ? lower_spd_1_plot : syminfo.root == sym_075_spd_10 ? lower_spd_10_plot : syminfo.root == sym_142_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_008_spd_1 ? lower_spd_1_plot : syminfo.root == sym_076_spd_10 ? lower_spd_10_plot : syminfo.root == sym_143_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_009_spd_1 ? lower_spd_1_plot : syminfo.root == sym_077_spd_10 ? lower_spd_10_plot : syminfo.root == sym_144_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_010_spd_1 ? lower_spd_1_plot : syminfo.root == sym_078_spd_10 ? lower_spd_10_plot : syminfo.root == sym_145_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_011_spd_1 ? lower_spd_1_plot : syminfo.root == sym_079_spd_10 ? lower_spd_10_plot : syminfo.root == sym_146_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_012_spd_1 ? lower_spd_1_plot : syminfo.root == sym_080_spd_10 ? lower_spd_10_plot : syminfo.root == sym_147_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_013_spd_1 ? lower_spd_1_plot : syminfo.root == sym_081_spd_10 ? lower_spd_10_plot : syminfo.root == sym_148_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_014_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_082_spd_10 ? lower_spd_10_plot : syminfo.root == sym_149_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_015_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_083_spd_10 ? lower_spd_10_plot : syminfo.root == sym_150_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_016_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_084_spd_10 ? lower_spd_10_plot : syminfo.root == sym_151_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_017_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_085_spd_10 ? lower_spd_10_plot : syminfo.root == sym_152_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_018_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_086_spd_10 ? lower_spd_10_plot : syminfo.root == sym_153_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_019_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_087_spd_10 ? lower_spd_10_plot : syminfo.root == sym_154_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_020_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_088_spd_10 ? lower_spd_10_plot : syminfo.root == sym_155_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_021_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_089_spd_10 ? lower_spd_10_plot : syminfo.root == sym_156_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_022_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_090_spd_10 ? lower_spd_10_plot : syminfo.root == sym_157_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_023_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_091_spd_10 ? lower_spd_10_plot : syminfo.root == sym_158_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_024_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_092_spd_10 ? lower_spd_10_plot : syminfo.root == sym_159_spd_20 ? lower_spd_20_plot :
syminfo.root == sym_025_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_093_spd_10 ? lower_spd_10_plot : syminfo.root == sym_160_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_026_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_094_spd_10 ? lower_spd_10_plot : syminfo.root == sym_161_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_027_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_095_spd_10 ? lower_spd_10_plot : syminfo.root == sym_162_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_028_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_096_spd_10 ? lower_spd_10_plot : syminfo.root == sym_163_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_029_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_097_spd_10 ? lower_spd_10_plot : syminfo.root == sym_164_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_030_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_098_spd_100 ? lower_spd_100_plot : syminfo.root == sym_165_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_031_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_099_spd_10 ? lower_spd_10_plot : syminfo.root == sym_166_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_032_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_100_spd_10 ? lower_spd_10_plot : syminfo.root == sym_167_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_033_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_101_spd_10 ? lower_spd_10_plot : syminfo.root == sym_168_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_034_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_102_spd_10 ? lower_spd_10_plot : syminfo.root == sym_169_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_035_spd_2_5 ? lower_spd_2_5_plot : syminfo.root == sym_103_spd_10 ? lower_spd_10_plot : syminfo.root == sym_170_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_036_spd_5 ? lower_spd_5_plot : syminfo.root == sym_104_spd_10 ? lower_spd_10_plot : syminfo.root == sym_171_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_037_spd_5 ? lower_spd_5_plot : syminfo.root == sym_105_spd_10 ? lower_spd_10_plot : syminfo.root == sym_172_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_038_spd_5 ? lower_spd_5_plot : syminfo.root == sym_106_spd_10 ? lower_spd_10_plot : syminfo.root == sym_173_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_039_spd_5 ? lower_spd_5_plot : syminfo.root == sym_107_spd_10 ? lower_spd_10_plot : syminfo.root == sym_174_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_040_spd_5 ? lower_spd_5_plot : syminfo.root == sym_108_spd_10 ? lower_spd_10_plot : syminfo.root == sym_175_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_041_spd_5 ? lower_spd_5_plot : syminfo.root == sym_109_spd_10 ? lower_spd_10_plot : syminfo.root == sym_176_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_042_spd_5 ? lower_spd_5_plot : syminfo.root == sym_110_spd_10 ? lower_spd_10_plot : syminfo.root == sym_177_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_043_spd_5 ? lower_spd_5_plot : syminfo.root == sym_111_spd_10 ? lower_spd_10_plot : syminfo.root == sym_178_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_044_spd_5 ? lower_spd_5_plot : syminfo.root == sym_112_spd_20 ? lower_spd_20_plot : syminfo.root == sym_179_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_045_spd_5 ? lower_spd_5_plot : syminfo.root == sym_113_spd_20 ? lower_spd_20_plot : syminfo.root == sym_180_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_046_spd_5 ? lower_spd_5_plot : syminfo.root == sym_114_spd_20 ? lower_spd_20_plot : syminfo.root == sym_181_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_047_spd_5 ? lower_spd_5_plot : syminfo.root == sym_115_spd_20 ? lower_spd_20_plot : syminfo.root == sym_182_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_048_spd_5 ? lower_spd_5_plot : syminfo.root == sym_116_spd_20 ? lower_spd_20_plot : syminfo.root == sym_183_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_049_spd_5 ? lower_spd_5_plot : syminfo.root == sym_117_spd_20 ? lower_spd_20_plot : syminfo.root == sym_184_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_050_spd_5 ? lower_spd_5_plot : syminfo.root == sym_118_spd_20 ? lower_spd_20_plot : syminfo.root == sym_185_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_051_spd_5 ? lower_spd_5_plot : syminfo.root == sym_119_spd_20 ? lower_spd_20_plot : syminfo.root == sym_186_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_052_spd_5 ? lower_spd_5_plot : syminfo.root == sym_120_spd_20 ? lower_spd_20_plot : syminfo.root == sym_187_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_053_spd_5 ? lower_spd_5_plot : syminfo.root == sym_121_spd_20 ? lower_spd_20_plot : syminfo.root == sym_188_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_054_spd_5 ? lower_spd_5_plot : syminfo.root == sym_122_spd_20 ? lower_spd_20_plot : syminfo.root == sym_189_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_055_spd_5 ? lower_spd_5_plot : syminfo.root == sym_123_spd_100 ? lower_spd_100_plot : syminfo.root == sym_190_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_056_spd_5 ? lower_spd_5_plot : syminfo.root == sym_124_spd_20 ? lower_spd_20_plot : syminfo.root == sym_191_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_057_spd_5 ? lower_spd_5_plot : syminfo.root == sym_125_spd_20 ? lower_spd_20_plot : syminfo.root == sym_192_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_058_spd_5 ? lower_spd_5_plot : syminfo.root == sym_126_spd_20 ? lower_spd_20_plot : syminfo.root == sym_193_spd_100 ? lower_spd_100_plot :
syminfo.root == sym_059_spd_5 ? lower_spd_5_plot : syminfo.root == sym_127_spd_20 ? lower_spd_20_plot : syminfo.root == sym_194_spd_200 ? lower_spd_200_plot :
syminfo.root == sym_060_spd_5 ? lower_spd_5_plot : syminfo.root == sym_128_spd_20 ? lower_spd_20_plot : syminfo.root == sym_195_spd_250 ? lower_spd_250_plot :
syminfo.root == sym_061_spd_5 ? lower_spd_5_plot : syminfo.root == sym_129_spd_20 ? lower_spd_20_plot : syminfo.root == sym_196_spd_50 ? lower_spd_50_plot :
syminfo.root == sym_062_spd_5 ? lower_spd_5_plot : syminfo.root == sym_130_spd_20 ? lower_spd_20_plot : syminfo.root == sym_197_spd_250 ? lower_spd_250_plot :
syminfo.root == sym_063_spd_5 ? lower_spd_5_plot : syminfo.root == sym_131_spd_20 ? lower_spd_20_plot : syminfo.root == sym_198_spd_250 ? lower_spd_250_plot :
syminfo.root == sym_064_spd_5 ? lower_spd_5_plot : syminfo.root == sym_132_spd_20 ? lower_spd_20_plot : syminfo.root == sym_199_spd_250 ? lower_spd_250_plot :
syminfo.root == sym_065_spd_5 ? lower_spd_5_plot : syminfo.root == sym_133_spd_20 ? lower_spd_20_plot : syminfo.root == sym_200_spd_500 ? lower_spd_500_plot :
syminfo.root == sym_066_spd_5 ? lower_spd_5_plot : syminfo.root == sym_134_spd_20 ? lower_spd_20_plot : syminfo.root == sym_201_spd_500 ? lower_spd_500_plot :
syminfo.root == sym_067_spd_5 ? lower_spd_5_plot : syminfo.root == sym_135_spd_20 ? lower_spd_20_plot : syminfo.root == sym_202_spd_500 ? lower_spd_500_plot :
syminfo.root == sym_068_spd_8_5 ? lower_spd_8_5_plot : na
////////////////////////////////////////////////////////// Strike Price Difference
spd_plot = upper_strike_plot - lower_strike_plot
////////////////////////////////////////////////////////// Higher Strikes
upper_strike_2_plot = upper_strike_plot + spd_plot
upper_strike_3_plot = upper_strike_plot + (2 * spd_plot)
lower_strike_2_plot = lower_strike_plot - spd_plot
lower_strike_3_plot = lower_strike_plot - (2 * spd_plot)
////////////////////////////////////////////////////////// First One Hour Highlight
//bgcolor(no_trade_time ? color.new(color.silver, 95) : na)
////////////////////////////////////////////////////////// Plot Important Pivots
rz_1_2_line = plot(pivot_time and show_rz_1 ? upper_strike_plot : na, "R1", style=plot.style_linebr, color=color.new(#EF5350, 0), linewidth=4)
rz_2_2_line = plot(pivot_time and show_rz_2 ? upper_strike_2_plot : na, "R2", style=plot.style_linebr, color=color.new(#EF5350, 0), linewidth=4)
sz_1_2_line = plot(pivot_time and show_sz_1 ? lower_strike_plot : na, "S1", style=plot.style_linebr, color=color.new(#26A69A, 0), linewidth=4)
sz_2_2_line = plot(pivot_time and show_sz_2 ? lower_strike_2_plot : na, "S2", style=plot.style_linebr, color=color.new(#26A69A, 0), linewidth=4)
////////////////////////////////////////////////////////// Time Markers
gpT = "Time (IST) (Vertical)"
show_time_01 = input.bool(true, title="", group=gpT, inline="_01")
i_hour_01 = input.int(10, minval=0, title="", group=gpT, inline="_01")
i_minute_01 = input.int(15, minval=0, title=":", group=gpT, inline="_01")
i_t_col_01 = input.color(color.silver, title="", group=gpT, inline="_01")
show_time_02 = input.bool(true, title="", group=gpT, inline="_02")
i_hour_02 = input.int(11, minval=0, title="", group=gpT, inline="_02")
i_minute_02 = input.int(15, minval=0, title=":", group=gpT, inline="_02")
i_t_col_02 = input.color(color.silver, title="", group=gpT, inline="_02")
show_time_03 = input.bool(false, title="", group=gpT, inline="_03")
i_hour_03 = input.int(12, minval=0, title="", group=gpT, inline="_03")
i_minute_03 = input.int(15, minval=0, title=":", group=gpT, inline="_03")
i_t_col_03 = input.color(color.silver, title="", group=gpT, inline="_03")
show_time_04 = input.bool(false, title="", group=gpT, inline="_04")
i_hour_04 = input.int(13, minval=0, title="", group=gpT, inline="_04")
i_minute_04 = input.int(15, minval=0, title=":", group=gpT, inline="_04")
i_t_col_04 = input.color(color.silver, title="", group=gpT, inline="_04")
show_time_05 = input.bool(true, title="", group=gpT, inline="_05")
i_hour_05 = input.int(14, minval=0, title="", group=gpT, inline="_05")
i_minute_05 = input.int(15, minval=0, title=":", group=gpT, inline="_05")
i_t_col_05 = input.color(color.silver, title="", group=gpT, inline="_05")
show_time_06 = input.bool(false, title="", group=gpT, inline="_06")
i_hour_06 = input.int(15, minval=0, title="", group=gpT, inline="_06")
i_minute_06 = input.int(15, minval=0, title=":", group=gpT, inline="_06")
i_t_col_06 = input.color(color.silver, title="", group=gpT, inline="_06")
i_t_style = input.string(line.style_dotted, title = "", options = [line.style_solid, line.style_dashed, line.style_dotted], group=gpT, inline="_07")
i_t_width = input.int(1, title = "", minval=1, group=gpT, inline="_07")
show_time_label = input.bool(true, title="Time Label", group=gpT, inline="_08")
if show_time_01
time_01 = timestamp("GMT+0530", year, month, dayofmonth, i_hour_01, i_minute_01, 00)
time_01_line = line.new(x1=time_01, y1=open, x2=time_01, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_01, style=i_t_style, width=i_t_width)
line.delete(time_01_line[1])
if show_time_label
var label time_01_label = na
time_01_label := label.new(x=time_01, y=high, text=str.tostring(i_hour_01) + ":" + str.tostring(i_minute_01), textcolor=i_t_col_01, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
label.delete(time_01_label[1])
// nd_time_01 = timestamp("GMT+0530", year, month , dayofmonth + 1, i_hour_01, i_minute_01, 00)
// nd_time_01_line = line.new(x1=nd_time_01, y1=open, x2=nd_time_01, y2=close, xloc=xloc.bar_time, extend=extend.both, color=color.new(color.silver, 0), style=i_t_style, width=i_t_width)
// line.delete(nd_time_01_line[1])
pd_time_02 = timestamp("GMT+0530", year, month , dayofmonth - 1, i_hour_05, i_minute_05, 00)
pd_time_02_line = line.new(x1=pd_time_02, y1=open, x2=pd_time_02, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_05, style=i_t_style, width=i_t_width)
line.delete(pd_time_02_line[1])
if show_time_label
var label pd_time_02_label = na
pd_time_02_label := label.new(x=pd_time_02, y=high, text=str.tostring(i_hour_05) + ":" + str.tostring(i_minute_05), textcolor=i_t_col_05, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
label.delete(pd_time_02_label[1])
if show_time_02
time_02 = timestamp("GMT+0530", year, month , dayofmonth, i_hour_02, i_minute_02, 00)
time_02_line = line.new(x1=time_02, y1=open, x2=time_02, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_02, style=i_t_style, width=i_t_width)
line.delete(time_02_line[1])
if show_time_label
var label time_02_label = na
time_02_label := label.new(x=time_02, y=high, text=str.tostring(i_hour_02) + ":" + str.tostring(i_minute_02), textcolor=i_t_col_02, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
label.delete(time_02_label[1])
if show_time_03
time_03 = timestamp("GMT+0530", year, month , dayofmonth, i_hour_03, i_minute_03, 00)
time_03_line = line.new(x1=time_03, y1=open, x2=time_03, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_03, style=i_t_style, width=i_t_width)
line.delete(time_03_line[1])
if show_time_label
var label time_03_label = na
time_03_label := label.new(x=time_03, y=high, text=str.tostring(i_hour_03) + ":" + str.tostring(i_minute_03), textcolor=i_t_col_03, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
label.delete(time_03_label[1])
if show_time_04
time_04 = timestamp("GMT+0530", year, month , dayofmonth, i_hour_04, i_minute_04, 00)
time_04_line = line.new(x1=time_04, y1=open, x2=time_04, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_04, style=i_t_style, width=i_t_width)
line.delete(time_04_line[1])
if show_time_label
var label time_04_label = na
time_04_label := label.new(x=time_04, y=high, text=str.tostring(i_hour_04) + ":" + str.tostring(i_minute_04), textcolor=i_t_col_04, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
label.delete(time_04_label[1])
if show_time_05
time_05 = timestamp("GMT+0530", year, month , dayofmonth, i_hour_05, i_minute_05, 00)
time_05_line = line.new(x1=time_05, y1=open, x2=time_05, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_05, style=i_t_style, width=i_t_width)
line.delete(time_05_line[1])
if show_time_label
var label time_05_label = na
time_05_label := label.new(x=time_05, y=high, text=str.tostring(i_hour_05) + ":" + str.tostring(i_minute_05), textcolor=i_t_col_05, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
label.delete(time_05_label[1])
if show_time_06
time_06 = timestamp("GMT+0530", year, month , dayofmonth, i_hour_06, i_minute_06, 00)
time_06_line = line.new(x1=time_06, y1=open, x2=time_06, y2=close, xloc=xloc.bar_time, extend=extend.both, color=i_t_col_06, style=i_t_style, width=i_t_width)
line.delete(time_06_line[1])
if show_time_label
var label time_06_label = na
time_06_label := label.new(x=time_06, y=high, text=str.tostring(i_hour_06) + ":" + str.tostring(i_minute_06), textcolor=i_t_col_06, textalign=text.align_center, color=color.new(color.white, 100), style=label.style_label_down, size=size.normal, xloc=xloc.bar_time, yloc=yloc.abovebar)
label.delete(time_06_label[1])
//linefill.new(pd_time_02_line, time_01_line, color.new(color.black, 95))
////////////////////////////////////////////////////////// Weekly Expiry Countdown Table
gpTb = "Table"
show_table = input.bool(true, title="Weekly Expiry Countdown", group=gpTb, inline="01")
count_down = dayofweek == dayofweek.friday ? "4" :
dayofweek == dayofweek.monday ? "3" :
dayofweek == dayofweek.tuesday ? "2" :
dayofweek == dayofweek.wednesday ? "1" :
dayofweek == dayofweek.thursday ? "0" : na
count_day = dayofweek == dayofweek.friday ? "Friday" :
dayofweek == dayofweek.monday ? "Monday" :
dayofweek == dayofweek.tuesday ? "Tuesday" :
dayofweek == dayofweek.wednesday ? "Wednesday" :
dayofweek == dayofweek.thursday ? "Thursday\nExpiry Day" : na
var table table_cell = table.new(position.top_right, 2, 1, border_width=1)
if barstate.islast and show_table
table.cell(table_cell, 0, 0, count_down, text_color=color.white, text_size=size.large, bgcolor=#2962FF, height=6)
table.cell(table_cell, 1, 0, count_day, text_color=#2962FF, text_size=size.small, bgcolor=color.white)
////////////////////////////////////////////////////////// END |
Abraham Trend [Loxx] | https://www.tradingview.com/script/z0mtJNUa-Abraham-Trend-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 106 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Abraham Trend [Loxx]",
shorttitle="AT [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
per = input.int(21, "Period", group = "Basic Settings")
mult = input.int(3, "Multiplier", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
hi = ta.highest(close, per)
lo = ta.lowest(close, per)
tr = ta.wma(math.max(high, nz(close[1]))-math.min(low, nz(close[1])), per)
hiLimit = hi - tr * mult
loLimit = lo + tr * mult
linein = 0.
lineincl = 0.
linein := nz(linein[1])
lineincl := nz(lineincl[1])
linein := close > loLimit and close>hiLimit ? hiLimit : linein
linein :=close < loLimit and close<hiLimit ? loLimit : linein
lineincl := close > linein ? 1 :lineincl
lineincl := close < linein ? 2 : lineincl
colorout = lineincl == 1 ? greencolor : lineincl == 2 ? redcolor : color.gray
barcolor(colorbars ? colorout : na)
plot(linein, "Abraham Trend", color = colorout, linewidth = 2)
|
Autodrawn Pivot Levels Indicator | https://www.tradingview.com/script/6RMpOw7c-Autodrawn-Pivot-Levels-Indicator/ | spiritualhealer117 | https://www.tradingview.com/u/spiritualhealer117/ | 19 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © spiritualhealer117
//@version=5
indicator("Pivot Levels")
len = int(input(14,"short length"))
llen = int(input(20,"long length"))
sens = float(input(0.5,"Sensitivity"))
sum = 0
std = ta.stdev(close,llen)
for i=0 to len
if (close[i] < (close + sens*std)) and (close[i] > (close-sens*std))
sum += 1
if sum >= 0.5*len
line.new(bar_index-len,close,bar_index,close,xloc.bar_index,color=color.new(color.orange,75),width=1,extend=extend.both)
|
ADR% / ATR / Market Cap | https://www.tradingview.com/script/mP4CLYtu-ADR-ATR-Market-Cap/ | rwak | https://www.tradingview.com/u/rwak/ | 115 | 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/
// © ArmerSchlucker
// Credit to MikeC / TheScrutiniser and GlinckEastwoot for ADR% formula
//@version=4
study(title="ADR% / ATR / Market Cap", overlay=true)
show_adrp = input(true, title="Show ADR%")
show_atr = input(false, title="Show ATR")
show_market_cap = input(true, title="Show Market Cap")
adrp_len = input(20, title="ADR% Length",
tooltip="The number of daily bars used in the calculation of the ADR%")
atr_len = input(14, title="ATR Length",
tooltip="The number of daily bars used in the calculation of the ATR")
bg_col = input(#00000000, title="Background Color")
adrp_col = input(color.white, title="Text Color (ADR%)")
atr_col = input(color.white, title="Text Color (ATR)")
market_cap_col = input(color.orange, title="Text Color (Market Cap)")
show_empty_row = input(false, title="Add an empty row above the displayed values",
tooltip="Serves the purpose of not having the pane icons overlap with the " +
"text in the table if multiple panes are shown and the chart pane is hovered")
arp = 100 * (sma(high / low, adrp_len) - 1)
adrp = security(syminfo.tickerid, 'D', arp)
atr = security(syminfo.tickerid, 'D', atr(atr_len))
market_cap = ((financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")) * close)
table t = table.new(position.bottom_right, 2, 4, bgcolor=bg_col)
if barstate.islast and timeframe.period != "W" and timeframe.period != "M"
if show_empty_row
table.cell(t, 0, 0, "")
table.cell(t, 1, 0, "")
if show_adrp
table.cell(t, 0, 1, "ADR%", text_color=adrp_col)
table.cell(t, 1, 1, tostring(round(adrp, 2)) + "%", text_color=adrp_col)
if show_atr
table.cell(t, 0, 2, "ATR", text_color=atr_col)
table.cell(t, 1, 2, tostring(round(atr, 2)), text_color=atr_col)
if show_market_cap
table.cell(t, 0, 3, "Market Cap", text_color=market_cap_col)
table.cell(t, 1, 3, tostring(round(market_cap)), text_color=market_cap_col) |
[FR]Wm | https://www.tradingview.com/script/dIJ95vc3-FR-Wm/ | FFriZz | https://www.tradingview.com/u/FFriZz/ | 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/
// © FFriZz
//@version=5
indicator('[FR]Wm','[FR]Wm', true)
import PineCoders/Time/3 as l
string ypos = input.string('top', 'WaterMark Position', inline='12', options=['top', 'middle', 'bottom'])
string xpos = input.string('right', '', inline='12', options=['left', 'right', 'center'])
int timeadj = input.int(-5,'Time Adj UTC (Match Chart UTC Time)',minval=-23,maxval = 25)
smh = input.bool(false,'Sec/Min/Hour -- Before TF(on) or After TF(off)',group = 'TF Label')
string s = input('s','Second TF',group = 's/m/h')
string m = input('m','Minute TF',group = 's/m/h')
string h = input('h','Hour TF' ,group = 's/m/h')
string Format_i = input.string('HH:mm:ss a','Format Select',group = 'Format',
options = ['Custom','HH:mm:ss a','dd/MM/yyyy','EEEE, dd/MM/yy','HH:mm a','d/MM','E, dd/MM','H:ss'])
if Format_i == 'Custom'
Format_i := input('M/d | E | h:mm a','Custom Format input' ,group = 'If ↟↟↟ Format Select is Custom',inline='')
string Examples_i = input.text_area(
'(Enter in Format Input ↟↟↟) Make your own format by Copying one of the examples provided, or building one using the letters under column (Sym.) and refrencing the examples provided\n\n' +
'------------------------------------------------\n' +
'Examples = HH:mm:ss a | dd/MM/yyyy | EEEE,dd/MM/yy\n' +
'Examples = HH:mm a | d/MM | E,dd/MM | H:ss \n' +
'-----------------------------------------------\n' +
'(Sym.) ↦ (Use Cases) ↦ (Ex.= Eamples)\n' +
'-----------------------------------------------\n' +
'y ↦ short ↦ Ex. Short Format' +
'y ↦ meidum ↦ Ex. Meidumn Format' +
'y ↦ full ↦ Ex. Full Format' +
'y ↦ Year ↦ Ex. 2018(yyyy),18(yy)\n' +
'M ↦ Month of year ↦ Ex. October(MMMM),Oct(MMM),10(MM)\n' +
'w ↦ Week of year ↦ Ex. 26\n' +
'W ↦ Week of month ↦ Ex. 2\n' +
'D ↦ Day of Year ↦ Ex. 266\n' +
'd ↦ Day of the month ↦ Ex. 09(dd),9(d)\n' +
'E ↦ Day name of week ↦ Ex. Tuesday(EEEE),Tues(E)\n' +
'u ↦ Day in week (1-7) ↦ Ex. 4\n' +
'a ↦ AM or PM marker ↦ Ex. AM or PM\n' +
'H ↦ Hour (0-23) ↦ Ex. 09(HH),9(H)\n' +
'h ↦ Hour (1-12) ↦ Ex. 05(hh),5(h)\n' +
'm ↦ Minute of hour ↦ Ex. 09(mm),5(m) \n' +
's ↦ Second of minute ↦ Ex. 05(ss),5(s)\n' +
'------------------------------------------------\n' +
'Can use ()[] on outsides or :/,. Between\n' +
'-----------------------------------------------\n',
'↟↟↟↟↟↟ Date/Time Format',group = 'If ↟↟↟ Format Select is Custom')
color color = input(color.new(#000000, transp=0),'Text Color')
string textsize = input.string('normal', 'Text size', options=['tiny', 'small', 'normal', 'large', 'huge', 'auto'])
string tva1 = input.string(text.align_center,'Text Align Vert',inline = 'ta1',options = [text.align_top, text.align_center, text.align_bottom])
string tha1 = input.string(text.align_center,'Text Align Horiz',inline = 'ta1',options = [text.align_left, text.align_center, text.align_right])
smh(s,m,h)=>
string TFM = ''
string TFP = timeframe.period
int TFS = timeframe.in_seconds()
if TFS < 60
TFM := smh ? s + str.tostring(TFS) :
str.tostring(TFS) + s
if TFS >= 60
TFM := smh ? m + TFP : TFP + m
if timeframe.isminutes
if str.tonumber(TFP) >= 60
TFM := smh ? h + str.tostring(str.tonumber(TFP) / 60) :
str.tostring(str.tonumber(TFP) / 60) + h
if timeframe.isdwm
TFM := TFP
TFM
TFM = smh(s,m,h)
///////////////////////////////////////////////////////////////////////////////
UTC = 3600000 * timeadj
var Session = ''
var int Sessionc = 0
tokyo ='Tokyo'
tokyos = 180000
tokyof = 030000
london ='London'
londons = 030000
londonf = 120000
newyork ='New York'
newyorks = 080000
newyorkf = 170000
noses = 'Sessions Closed'
nosess = 170000
nosesf = 200000
sestime = str.tonumber(str.replace_all(l.formattedTime(timenow + UTC),':',''))
TTtime = l.formattedTime(timenow + UTC, 'H:mm:ss a')
sep = ' ⇆ '
Session := ''
Sessionc := 0
var light = ''
if sestime > tokyos and sestime < tokyof
Sessionc += 2
Session := Session + tokyo
if sestime > londons and sestime < londonf
Sessionc += 1
Session := Session + (Sessionc > 1 ? ' ⇆ ' : '') + london
if sestime > newyorks and sestime < newyorkf
Session := Session + (Sessionc >= 1 ? ' ⇆ ' : '') + newyork
if sestime > nosess and sestime < nosesf
Session := ''
Session := noses
light := ' 🔴'
else
light := ' 🟢'
Tokyos = 24 + timeadj > 24 ? 0 + timeadj : 24 + timeadj < 0 ? 24 + timeadj : 24 + timeadj
Tokyof = 9 + timeadj > 24 ? 0 + timeadj : 9 + timeadj < 0 ? 24 + timeadj : 9 + timeadj
Londons = 7 + timeadj > 24 ? 0 + timeadj : 7 + timeadj < 0 ? 24 + timeadj : 7 + timeadj
Londonf = 16 + timeadj > 24 ? 0 + timeadj : 16 + timeadj < 0 ? 24 + timeadj : 16 + timeadj
Newyorks = 12 + timeadj > 24 ? 0 + timeadj : 12 + timeadj < 0 ? 24 + timeadj : 12 + timeadj
Newyorkf = 21 + timeadj > 24 ? 0 + timeadj : 21 + timeadj < 0 ? 24 + timeadj : 21 + timeadj
Nosess = 21 + timeadj > 24 ? 0 + timeadj : 21 + timeadj < 0 ? 24 + timeadj : 21 + timeadj
Nosesf = 24 + timeadj > 24 ? 0 + timeadj : 24 + timeadj < 0 ? 24 + timeadj : 24 + timeadj
TLovers = 7 + timeadj > 24 ? 0 + timeadj : 7 + timeadj < 0 ? 24 + timeadj : 7 + timeadj
TLoverf = 9 + timeadj > 24 ? 0 + timeadj : 9 + timeadj < 0 ? 24 + timeadj : 9 + timeadj
NLovers = 12 + timeadj > 24 ? 0 + timeadj : 12 + timeadj < 0 ? 24 + timeadj : 12 + timeadj
NLoverf = 16 + timeadj > 24 ? 0 + timeadj : 16 + timeadj < 0 ? 24 + timeadj : 16 + timeadj
var table watermark = table.new(ypos + '_' + xpos, 2, 2)
if barstate.islast
table.cell(watermark, 0, 0,l.formattedDate(timenow + UTC,Format_i) + '\n' +
str.tostring(syminfo.ticker) + ' | ' + TFM,
text_color = color, text_size=textsize ,text_valign = tva1,text_halign = tha1,
//
tooltip = '---------------- Sessions🕧 --------------\n' +
//
'--Tokyo: '+ str.tostring(Tokyos) +':00' +
(Tokyos >= 12 ? 'PM' : 'AM') + ' - ' + str.tostring(Tokyof) + ':00' +
(Tokyof >= 12 ? 'PM' : 'AM') + '\n' +
//
'--London: '+ str.tostring(Londons) +':00' +
(Londons >= 12 ? 'PM' : 'AM') + ' - ' + str.tostring(Londonf) + ':00' +
(Londonf >= 12 ? 'PM' : 'AM') + '\n' +
//
'--Tokyo/London: '+ str.tostring(TLovers) + ':00' +
(TLovers >= 12 ? 'PM' : 'AM') + ' - ' + str.tostring(TLoverf) + ':00' +
(TLoverf >= 12 ? 'PM' : 'AM') + '\n' +
//
'--New York: '+ str.tostring(Newyorks) +':00' +
(Newyorks >= 12 ? 'PM' : 'AM') + ' - ' + str.tostring(Newyorkf) + ':00' +
(Newyorkf >= 12 ? 'PM' : 'AM') + '\n' +
//
'--NY/London: '+ str.tostring(NLovers) +':00' +
(NLovers >= 12 ? 'PM' : 'AM') + ' - ' + str.tostring(NLoverf) + ':00' +
(NLoverf >= 12 ? 'PM' : 'AM') + '\n' +
//
'--Sessions Closed: '+ str.tostring(Nosess) +':00' +
(Nosess >= 12 ? 'PM' : 'AM') + ' - ' + str.tostring(Nosesf) + ':00' +
(Nosesf >= 12 ? 'PM' : 'AM') + '\n' +
//
'---------------------------------------------\n Session: ' + Session + light +
'\n ' + TTtime + '\n---------------------------------------------')
|
T3-Filterd SSL [Loxx] | https://www.tradingview.com/script/QzuCDS0i-T3-Filterd-SSL-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 225 | study | 5 | MPL-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-Filterd SSL [Loxx]",
shorttitle="T3FSSL [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
_ssl(per, clper, hot, org)=>
varHigh =_iT3(high, per, hot, org)
varLow = _iT3(low, per, hot, org)
varClose = _iT3(close, clper, hot, org)
Hlv = 0.
Hlv := varClose > varHigh ? 1 : varClose < varLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? varHigh : varLow
sslUp = Hlv < 0 ? varLow : varHigh
[sslUp, sslDown]
sslper = input.int(10, "SSL Period", group = "Basic Settings")
clsper = input.int(1, "Close Period", group = "Basic Settings", minval = 0)
t3hot = input.float(0.7, "T3 Factor", step = 0.01, maxval = 1, minval = 0, group = "T3 Settings")
t3swt = input.bool(false, "T3 Original?", group = "T3 Settings")
showSigs = input.bool(false, "Show signals?", group= "UI Options")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
[sslUp, sslDown] = _ssl(sslper, clsper, t3hot, t3swt)
plot(sslUp, color = greencolor, linewidth = 3)
plot(sslDown, color = redcolor, linewidth = 3)
barcolor(colorbars ? sslUp > sslDown ? greencolor : sslUp < sslDown ? redcolor : color.gray : na)
goUp = ta.crossover(sslUp, sslDown)
goDown = ta.crossover(sslDown, sslUp)
plotshape(showSigs and goUp, title = "Uptrend", color = color.yellow, textcolor = color.yellow, text = "UP", style = shape.triangleup, location = location.belowbar, size = size.tiny)
plotshape(showSigs and goDown, title = "Downtrend", color = color.fuchsia, textcolor = color.fuchsia, text = "DN", style = shape.triangledown, location = location.abovebar, size = size.tiny)
alertcondition(goUp, title = "Uptrend", message = "Variety-Filterd SSL [Loxx]: Uptrend\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goDown, title = "Downtrend", message = "Variety-Filterd SSL [Loxx]: Downtrend\nSymbol: {{ticker}}\nPrice: {{close}}")
|
bigmoney_wgb | https://www.tradingview.com/script/1MM9DilD/ | sam307210 | https://www.tradingview.com/u/sam307210/ | 25 | 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/
// © sam307210
//@version=4
study("bigmoney")
VAR1 = ema(highest(high,500), 21)
VAR2 = ema(highest(high,250), 21)
VAR3 = ema(highest(high,90),21)
VAR4 = ema(lowest(low,500),21)
VAR5 = ema(lowest(low,250),21)
VAR6 = ema(lowest(low,90),21)
VAR7 = ema((VAR4*0.96+VAR5*0.96+VAR6*0.96+VAR1*0.558+VAR2*0.558+VAR3*0.558)/6,21)
VAR8 = ema((VAR4*1.25+VAR5*1.23+VAR6*1.2+VAR1*0.55+VAR2*0.55+VAR3*0.65)/6,21)
VAR9 = ema((VAR4*1.3+VAR5*1.3+VAR6*1.3+VAR1*0.68+VAR2*0.68+VAR3*0.68)/6,21)
VARA = ema((VAR7*3+VAR8*2+VAR9)/6*1.738,21)
VARB = low[1]
VARC = ema((abs(low-VARB)),3) / ema((max(low-VARB,0)),3)*10
VARD = ema(iff(close*1.35<=VARA,VARC*10,VARC/10),3)
VARE = lowest(low,30)
VARF = highest(VARD,30)
big_money = ema(iff(low<=VARE,(VARD+VARF*2)/2,0),3)/618
big_money1 = iff(big_money>0,big_money,0)
plot(big_money, title='bigmoneyline',color=color.blue)
plot(big_money1, title='bigmoney',color=color.red,linewidth=3,style=plot.style_histogram)
|
Combo Z Score | https://www.tradingview.com/script/SSj3E7gQ-Combo-Z-Score/ | jroche1973 | https://www.tradingview.com/u/jroche1973/ | 39 | 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/
// © jroche1973
//@version=4
study("Combo Z Score", precision=6, overlay=false)
Length = input(252) //252
v_StdDevs = input(defval = 2.0, title="VIX Z Std Dev")
m_StdDevs = input(defval = 2.0, title="MOVE Z Std Dev")
show_m = input(type=input.bool, title="Show MOVE", defval=true)
show_v = input(type=input.bool, title="Show VIX", defval=true)
//show_b = input(type=input.bool, title="Apply %B", defval=true)
_bb_mult = input(title="BB mult", type=input.float, defval=2)
_bb_range = input(title="BB mean range", type=input.integer, defval=20)
//src = input(close)
MOVE = security("TVC:MOVE", timeframe.period, close)
VIX = security("VIX", timeframe.period, close)
VVIX = security("VVIX", timeframe.period, close)
[_bb_mid, _bb_hig, _bb_low] = bb(close, _bb_range, _bb_mult)
_bb_percent = (close - _bb_low) / (_bb_hig - _bb_low)
//Proxy of M of Move ie alt VVIX
iVIX = 1/VIX
//MOVE calcs
divM = MOVE/iVIX
m_basis = sma(divM, Length)
//zscore = (src - basis) / stdev(src, Length)
m_zscore = (divM - m_basis) / stdev(divM, Length)
plot(show_m? m_zscore: na, color=color.new(#55FF55, 0))
//plot( _bb_percent , color = color.new(color.yellow,0))
hline(m_StdDevs, color=color.white, linestyle=hline.style_dotted)
hline(-1 * m_StdDevs, color=color.white, linestyle=hline.style_dotted)
//m_color = color.new(color.black, 0)
//if show_b
// color m_color = m_zscore < 0 and _bb_percent > 0.5 ? color.new(color.white, 70): color.new(color.blue, 70) //we want white if not active
//else
// color m_color = m_zscore < 0 ? color.new(color.white, 70): color.new(color.blue, 70) //we want white if not active
color m_color = m_zscore < 0 ? color.new(color.white, 70): color.new(color.blue, 70) //we want white if not active
color mb_color = m_zscore < 0 and _bb_percent > 0.5 ? color.new(color.white, 70): color.new(color.blue, 70) //we want white if not active
//color apply_b = show_b ? mb_color : m_color
//is_b = _bb_percent < 0.5? true: false
use_b = _bb_percent < 0.5 ? true: false
//bgcolor(show_m ? color.new(m_color,70) : color.new(color.white, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'
//bgcolor(show_m ? color.new(apply_b,70) : color.new(color.white, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'
bgcolor(show_m and use_b ? color.new(m_color,70) : color.new(color.white, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'
//bgcolor(m_zscore < 0 ? color.new(color.white,70) : color.new(color.blue, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'
//VIX Calcs
divV = VIX/VVIX
v_basis = sma(divV, Length)
//zscore = (src - basis) / stdev(src, Length)
v_zscore = (divV - v_basis) / stdev(divV, Length)
plot(show_v? v_zscore: na, color=color.new(#7d070c, 0))
hline(v_StdDevs, color=color.white, linestyle=hline.style_dotted)
hline(-1 * v_StdDevs, color=color.white, linestyle=hline.style_dotted)
color v_color = v_zscore < 0 ? color.new(color.white, 70): color.new(color.red, 70) //we want white if not active
bgcolor(show_v and use_b? color.new(v_color,70) : color.new(color.white, 70)) // we want whatever color our status stipulates if 'on' or white if 'off'
|
Trenbolone | https://www.tradingview.com/script/AQHnYk6q/ | LeSif | https://www.tradingview.com/u/LeSif/ | 18 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MathieuClmn
//@version=4
study("Trenbolone", overlay = true, format = format.price, precision = 2, resolution = "")
Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
|
Listado CCL - price of the dollar in Argentina | https://www.tradingview.com/script/PMduVDWj/ | Teo_Trading | https://www.tradingview.com/u/Teo_Trading/ | 27 | 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
study("Listado CCL", overlay=true)
// Consulto los precios de close de diferentes Tickers basados en la fórmula de CCL
bmaClose = security("BCBA:BMA*10/NYSE:BMA", timeframe.period, close)
cepuClose = security("BCBA:CEPU*10/NYSE:CEPU", timeframe.period, close)
ggalClose = security("BCBA:GGAL*10/NASDAQ:GGAL", timeframe.period, close)
lomaClose = security("BCBA:LOMA*5/NYSE:LOMA", timeframe.period, close)
pamClose = security("BCBA:PAMP*25/NYSE:PAM", timeframe.period, close)
supvClose = security("BCBA:SUPV*5/NYSE:SUPV", timeframe.period, close)
tgsClose = security("BCBA:TGSU2*5/NYSE:TGS", timeframe.period, close)
ypfClose = security("BCBA:YPFD/NYSE:YPF", timeframe.period, close)
// Imprimo solo en la ultima barra
if(barstate.islast)
l = label.new(bar_index, na,
'Listado Cotizaciones CCL:\n\n'
+'BMA: '+tostring(bmaClose,'#.#')
+'\nCEPU: '+tostring(cepuClose,'#.#')
+'\nGGAL: '+tostring(ggalClose,'#.#')
+'\nLOMA: '+tostring(lomaClose,'#.#')
+'\nPAMPA: '+tostring(pamClose,'#.#')
+'\nSUPV: '+tostring(supvClose,'#.#')
+'\nTGS: '+tostring(tgsClose,'#.#')
+'\nYPF: '+tostring(ypfClose,'#.##'),
color=color.white,
textcolor=color.gray,
style=label.style_label_left,
yloc=yloc.belowbar,
size=size.normal,
textalign=text.align_left) |
Aditya Ukirde | https://www.tradingview.com/script/aVJgLMlB-Aditya-Ukirde/ | Aadiiiiii | https://www.tradingview.com/u/Aadiiiiii/ | 3 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Aadiiiiii
//@version=4
study(title="Aditya", shorttitle="Aditya Ukirde Indicator", overlay=true)
showpivot = input(defval = false, title="Show CPR")
showVWAP = input(title="Show VWAP", type=input.bool, defval=false)
showVWMA = input(title="Show VWMA", type=input.bool, defval=false)
showPSAR = input(title="Show PSAR", type=input.bool, defval=false)
showBB = input(title="Show BB", type=input.bool, defval=false)
showEMA9 = input(title="Show EMA-9", type=input.bool, defval=false)
showEMA20 = input(title="Show EMA-20", type=input.bool, defval=false)
showEMA50 = input(title="Show EMA-50", type=input.bool, defval=false)
showEMA100 = input(title="Show EMA-100", type=input.bool, defval=false)
showEMA200 = input(title="Show EMA-200", type=input.bool, defval=false)
showSMA9 = input(title="Show SMA-9", type=input.bool, defval=false)
showSMA20 = input(title="Show SMA -20", type=input.bool, defval=false)
showSMA50 = input(title="Show SMA-50", type=input.bool, defval=false)
showSMA100 = input(title="Show SMA-100", type=input.bool, defval=false)
showwMA9 = input(title="Show WMA-9", type=input.bool, defval=false)
showwMA20 = input(title="Show WMA-20", type=input.bool, defval=false)
showwMA50 = input(title="Show WMA-50", type=input.bool, defval=false)
showwMA100 = input(title="Show WMA-100", type=input.bool, defval=false)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// EMA - 9/20/50/100 ///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EMA9_Len = input(9, minval=1, title="EMA9_Length")
//EMA9_src = input(close, title="EMA9_Source")
//EMA9_offset = input(title="EMA9_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
EMA9_out = ema(close, EMA9_Len)
plot(showEMA9 ? EMA9_out:na, title="EMA9", color=color.yellow, offset=0)
EMA20_Len = input(20, minval=1, title="EMA20_Length")
//EMA20_src = input(close, title="EMA20_Source")
//EMA20_offset = input(title="EMA20_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
EMA20_out = ema(close, EMA20_Len)
plot(showEMA20 ? EMA20_out:na, title="EMA20", color=color.blue, offset=0)
EMA50_Len = input(50, minval=1, title="EMA50_Length")
//EMA50_src = input(close, title="EMA50_Source")
//EMA50_offset = input(title="EMA50_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
EMA50_out = ema(close, EMA50_Len)
plot(showEMA50 ? EMA50_out:na, title="EMA50", color=color.fuchsia, offset=0)
EMA100_Len = input(100, minval=1, title="EMA100_Length")
//EMA100_src = input(close, title="EMA100_Source")
//EMA100_offset = input(title="EMA100_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
EMA100_out = ema(close, EMA100_Len)
plot(showEMA100 ? EMA100_out:na, title="EMA100", color=color.aqua, offset=0)
EMA200_Len = input(200, minval=1, title="EMA200_Length")
//EMA200_src = input(close, title="EMA200_Source")
//EMA200_offset = input(title="EMA200_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
EMA200_out = ema(close, EMA200_Len)
plot(showEMA200 ? EMA200_out:na, title="EMA200", color=color.aqua, offset=0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////// SMA - 9/20/50/100/200 /////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SMA9_Len = input(9, minval=1, title="SMA9_Length")
//SMA9_src = input(close, title="SMA9_Source")
//SMA9_offset = input(title="SMA9_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
SMA9_out = sma(close, SMA9_Len)
plot(showSMA9 ? SMA9_out:na, title="SMA9", color=color.green, offset=0)
SMA20_Len = input(20, minval=1, title="SMA20_Length")
//SMA20_src = input(close, title="SMA20_Source")
//SMA20_offset = input(title="SMA20_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
SMA20_out = sma(close, SMA20_Len)
plot(showSMA20 ? SMA20_out:na, title="SMA20", color=color.red, offset=0)
SMA50_Len = input(50, minval=1, title="SMA50_Length")
//SMA50_src = input(close, title="SMA50_Source")
//SMA50_offset = input(title="SMA50_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
SMA50_out = sma(close, SMA50_Len)
plot(showSMA50 ? SMA50_out:na, title="SMA50", color=color.olive, offset=0)
SMA100_Len = input(100, minval=1, title="SMA100_Length")
//SMA100_src = input(close, title="SMA100_Source")
//SMA100_offset = input(title="SMA100_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
SMA100_out = sma(close, SMA100_Len)
plot(showSMA100 ? SMA100_out:na, title="SMA100", color=color.maroon, offset=0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// WMA - 9/20/50/100 ///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
wMA9_Len = input(9, minval=1, title="wMA9_Length")
//wMA9_src = input(close, title="wMA9_Source")
//wMA9_offset = input(title="wMA9_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
wMA9_out = wma(close, wMA9_Len)
plot(showwMA9 ? wMA9_out:na, title="wMA9", color=color.navy, offset=0)
wMA20_Len = input(20, minval=1, title="wMA20_Length")
//wMA20_src = input(close, title="wMA20_Source")
//wMA20_offset = input(title="wMA20_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
wMA20_out = wma(close, wMA20_Len)
plot(showwMA20 ? wMA20_out:na, title="wMA20", color=color.olive, offset=0)
wMA50_Len = input(50, minval=1, title="wMA50_Length")
//wMA50_src = input(close, title="wMA50_Source")
//wMA50_offset = input(title="wMA50_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
wMA50_out = wma(close, wMA50_Len)
plot(showwMA50 ? wMA50_out:na, title="wMA50", color=color.purple, offset=0)
wMA100_Len = input(100, minval=1, title="wMA100_Length")
//wMA100_src = input(close, title="wMA100_Source")
//wMA100_offset = input(title="wMA100_Offset", type=input.integer, defval=0, minval=-500, maxval=500)
wMA100_out = wma(close, wMA100_Len)
plot(showwMA100 ? wMA100_out:na, title="wMA100", color=color.gray, offset=0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////// VWAP /////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//vwaplength = input(title="VWAP Length", type=input.integer, defval=1)
//cvwap = ema(vwap,vwaplength)
cvwap1 = vwap(hlc3)
plotvwap = plot(showVWAP ? cvwap1 : na,title="VWAP",color=color.black, transp=0, linewidth=2)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////// VWMA /////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
vwma_length = 20 //input(title="VWMA Length", type=input.integer, defval=1)
vwma_1 = vwma(close,vwma_length)
plotvwma = plot(showVWMA ? vwma_1 : na, title="VWMA", color=color.blue, transp=0, linewidth=2)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////// PARABOLIC SAR //////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
start = 0.02 //input(0.02)
increment = 0.02 //input(0.02)
maximum = 0.2 //input(0.2, "Max Value")
psar_out = sar(start, increment, maximum)
plot(showPSAR ? psar_out : na, "ParabolicSAR", style=plot.style_cross, color=#2196f3)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////// BOLLINGER BAND////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
length = 20 //input(20, minval=1)
src = close //input(close, title="BB_Source")
mult = 2 //input(2.0, minval=0.001, maxval=50, title="BB_StdDev")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
p1 = plot(showBB ? upper : na, "Upper", color=color.teal, editable=false)
p2 = plot(showBB ? lower: na, "Lower", color=color.teal, editable=false)
plot(showBB ? basis : na, "Basis", color=#872323, editable=false)
fill(p1, p2, title = "Background", color=#198787, transp=95)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// CENTRAL PIVOT RANGE (CPR) //////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
res = input(title="Resolution", type=input.resolution, defval="D")
res1 = input(title="Resolution", type=input.resolution, defval="W")
res2 = input(title="Resolution", type=input.resolution, defval="M")
H = security(syminfo.tickerid, res, high[1], barmerge.gaps_off, barmerge.lookahead_on)
L = security(syminfo.tickerid, res, low[1], barmerge.gaps_off, barmerge.lookahead_on)
C = security(syminfo.tickerid, res, close[1], barmerge.gaps_off, barmerge.lookahead_on)
WH = security(syminfo.tickerid, res1, high[1], barmerge.gaps_off, barmerge.lookahead_on)
WL = security(syminfo.tickerid, res1, low[1], barmerge.gaps_off, barmerge.lookahead_on)
WC = security(syminfo.tickerid, res1, close[1], barmerge.gaps_off, barmerge.lookahead_on)
MH = security(syminfo.tickerid, res2, high[1], barmerge.gaps_off, barmerge.lookahead_on)
ML = security(syminfo.tickerid, res2, low[1], barmerge.gaps_off, barmerge.lookahead_on)
MC = security(syminfo.tickerid, res2, close[1], barmerge.gaps_off, barmerge.lookahead_on)
TTH = security(syminfo.tickerid, res, high, barmerge.gaps_off, barmerge.lookahead_on)
TTL = security(syminfo.tickerid, res, low, barmerge.gaps_off, barmerge.lookahead_on)
TTC = security(syminfo.tickerid, res, close, barmerge.gaps_off, barmerge.lookahead_on)
PP = (H + L + C) / 3
TC = (H + L)/2
BC = (PP - TC) + PP
R1 = (PP * 2) - L
R2 = PP + (H - L)
R3 = H + 2*(PP - L)
R4 = PP * 3 + (H - 3 * L)
S1 = (PP * 2) - H
S2 = PP - (H - L)
S3 = L - 2*(H - PP)
S4 = PP*3 - (3*H - L)
WPP = (WH + WL + WC)/3
WTC = (WH + WL)/2
WBC = (WPP - WTC) + WPP
MPP = (MH + ML + MC)/3
MTC = (MH + ML)/2
MBC = (MPP - MTC) + MPP
TOPP = (TTH + TTL + TTC)/3
TOTC = (TTH + TTL)/2
TOBC = (TOPP - TOTC) + TOPP
TR1 = (TOPP * 2) - TTL
TR2 = TOPP + (TTH - TTL)
TS1 = (TOPP * 2) - TTH
TS2 = TOPP - (TTH - TTL)
plot(showpivot ? PP : na, title="PP", style=plot.style_circles, color=color.orange, linewidth=2)
plot(showpivot ? TC : na, title="TC", style=plot.style_circles, color=color.blue, linewidth=2)
plot(showpivot ? BC : na, title="BC", style=plot.style_circles, color=color.blue, linewidth=2)
plot(showpivot ? WPP : na, title="WPP", style=plot.style_stepline, color=color.black, linewidth=2)
plot(showpivot ? WTC : na, title="WTC", style=plot.style_stepline, color=color.black, linewidth=2)
plot(showpivot ? WBC : na, title="WBC", style=plot.style_stepline, color=color.black, linewidth=2)
plot(showpivot ? MPP : na, title="MPP", style=plot.style_stepline, color=color.black, linewidth=3)
plot(showpivot ? MTC : na, title="MTC", style=plot.style_stepline, color=color.black, linewidth=3)
plot(showpivot ? MBC : na, title="MBC", style=plot.style_stepline, color=color.black, linewidth=3)
plot(showpivot ? S1 : na, title="S1", style=plot.style_stepline, color=color.black, linewidth=1)
plot(showpivot ? S2 : na, title="S2", style=plot.style_stepline, color=color.black, linewidth=1)
plot(showpivot ? S3 : na, title="S3", style=plot.style_stepline, color=color.black, linewidth=1)
plot(showpivot ? S4 : na, title="S4", style=plot.style_stepline, color=color.black, linewidth=1)
plot(showpivot ? R1 : na, title="R1", style=plot.style_stepline, color=color.black, linewidth=1)
plot(showpivot ? R2 : na, title="R2", style=plot.style_stepline, color=color.black, linewidth=1)
plot(showpivot ? R3 : na, title="R3", style=plot.style_stepline, color=color.black, linewidth=1)
plot(showpivot ? R4 : na, title="R4", style=plot.style_stepline, color=color.black, linewidth=1)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////// PREVIOUS DAY /////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
prevDayHigh = security(syminfo.tickerid, 'D', high[1], lookahead=true)
prevDayLow = security(syminfo.tickerid, 'D', low[1], lookahead=true)
plot( showpivot and prevDayHigh ? prevDayHigh : na, title="Prev Day High", style=plot.style_stepline, linewidth=1, color=color.red, transp=0)
plot( showpivot and prevDayLow ? prevDayLow : na, title="Prev Day Low", style=plot.style_stepline, linewidth=1, color=color.green, transp=0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////// PREVIOUS WEEKLY ///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
prevWeekHigh = security(syminfo.tickerid, 'W', high[1], lookahead=true)
prevWeekLow = security(syminfo.tickerid, 'W', low[1], lookahead=true)
plot( showpivot and prevWeekHigh ? prevWeekHigh : na, title="Prev Week High", style=plot.style_stepline, linewidth=2, color=color.red, transp=0)
plot( showpivot and prevWeekLow ? prevWeekLow : na, title="Prev Week Low", style=plot.style_stepline, linewidth=2, color=color.green, transp=0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////// PREVIOUS MONTH /////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
prevMonthHigh = security(syminfo.tickerid, 'M', high[1], lookahead=true)
prevMonthLow = security(syminfo.tickerid, 'M', low[1], lookahead=true)
plot( showpivot and prevMonthHigh ? prevMonthHigh : na, title="Prev Month High", style=plot.style_stepline, linewidth=3, color=color.red, transp=0)
plot( showpivot and prevMonthLow ? prevMonthLow : na, title="Prev Month Low", style=plot.style_stepline, linewidth=3, color=color.green, transp=0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////// NOT NECESSARY //////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// colours for the chart
//col0 = #6666ff
//col1 = #ebdc87
//col2 = #ffa36c
//col3 = #d54062
//colD = #799351
//plotF = input(defval=false, title="Plot 0.236", type=input.bool)
//supp0 = (PP - (0.236 * (H - L)))
//supp1 = (PP - (0.382 * (H - L)))
//supp2 = (PP - (0.618 * (H - L)))
//supp3 = (PP - (1 * (H - L)))
//res0 = (PP + (0.236 * (H - L)))
//res01 = (PP + (0.382 * (H - L)))
//res02 = (PP + (0.618 * (H - L)))
//res03 = (PP + (1 * (H - L)))
//plot(plotF ? supp0 : na, title="0.236", style=plot.style_stepline, color=color.orange , linewidth=1)
//plot(plotF ? res0 : na, title="0.236", style=plot.style_stepline, color=color.orange, linewidth=1) |
Bar Count for Backtesting | https://www.tradingview.com/script/nluWCID6-Bar-Count-for-Backtesting/ | KioseffTrading | https://www.tradingview.com/u/KioseffTrading/ | 75 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © KioseffTrading
//@version=5
indicator("Bar Count for Backtesting", overlay = true)
// ________________________________________________
// | |
// | --------------------------------- |
// | | K̲ i̲ o̲ s̲ e̲ f̲ f̲ T̲ r̲ a̲ d̲ i̲ n̲ g | |
// | | | |
// | | ƃ u ᴉ p ɐ ɹ ꓕ ⅎ ⅎ ǝ s o ᴉ ꓘ | |
// | -------------------------------- |
// | |
// |_______________________________________________|
barType = input.string(defval = "Time", options = ["Time", "Bars Back"], title = "Identify Bars Tested Using: ")
start = input.time(defval = timestamp("May 02 2022"), title = "Test Start Date",group = "If Date & Time",
tooltip = "Clicking the Table on the Chart Causes Two Vertical Lines to Appear. One Line Appears at the Testing Start Date; One Line Appears at the Testing End Date. The Lines Can Be Dragged to Narrow/Widen the Start and End Date Without Making Changes in the User Input Tab. Use This Feature to Quickly Isolate Portions of the Data Set.")
end = input.time(defval = timestamp("Jan 02 2023"), title = "Test End Date",group = "If Date & Time" ,
tooltip = "Clicking the Table on the Chart Causes Two Vertical Lines to Appear. One Line Appears at the Testing Start Date; One Line Appears at the Testing End Date. The Lines Can Be Dragged to Narrow/Widen the Start and End Date Without Making Changes in the User Input Tab. Use This Feature to Quickly Isolate Portions of the Data Set for Testing.")
barsBack = input.int(defval = 0, title = "Bars Back", group = "If Bars Back", minval = 0, step = 50)
dataDisplay = input.string(defval = "Table and Label", title = "Display Bars Tested: ", options = ["Label", "Table", "Table and Label"])
HH = ta.highest(high, 200)
var int [] barTrack = array.new_int(2)
var float [] timeTrack = array.new_float(1)
var table [] tab = array.new_table()
date() =>
start <= end ? time >= start and time <= end :
time <= start and time >= end
if barstate.isfirst
array.set(timeTrack, 0, timestamp(year, month, dayofmonth, hour, minute, second))
array.push(tab, table.new(position.bottom_right, 2, 2, bgcolor = color.new(color.white, 50), frame_color = #000000, border_color = #000000))
if barType == "Time"
if start > array.get(timeTrack, 0)
if date()[1] == false and date() == true
array.set(barTrack, 0, bar_index)
line.new(bar_index, close, bar_index, close + 1, extend = extend.both, width = 2, color = color.white)
else if start <= array.get(timeTrack, 0)
if barstate.isfirst
array.set(barTrack, 0, bar_index)
line.new(bar_index, close, bar_index, close + 1, extend = extend.both, width = 2, color = color.white)
if end < timenow
if date()[1] == true and date() == false
array.set(barTrack, 1, bar_index)
line.new(bar_index, close, bar_index, close + 1, extend = extend.both, width = 2, color = color.white)
else
if barstate.islast
array.set(barTrack, 1, bar_index)
line.new(bar_index, close, bar_index, close + 1, extend = extend.both, width = 2, color = color.white)
if dataDisplay != "Table"
if bar_index == array.get(barTrack, 1)
label.new(bar_index + 20,
HH,
text = str.tostring(array.get(barTrack, 1) >= array.get(barTrack, 0) ?
array.get(barTrack, 1) - array.get(barTrack, 0) :
array.get(barTrack, 0) - array.get(barTrack, 1), "##") + "\n Bars Tested",
textcolor = #000000,
color = color.new(color.white, 50),
style = label.style_label_left
)
if dataDisplay != "Label"
if bar_index == array.get(barTrack, 1)
table.cell(
array.get(tab, 0),
0,
0,
text = str.tostring(array.get(barTrack, 1) >= array.get(barTrack, 0) ?
array.get(barTrack, 1) - array.get(barTrack, 0) :
array.get(barTrack, 0) - array.get(barTrack, 1), "##") + "\n Bars Tested",
text_color = #000000
)
if barType == "Bars Back"
if bar_index == last_bar_index - barsBack and barsBack <= last_bar_index or barsBack > last_bar_index and bar_index == 0
if dataDisplay != "Table"
label.new(barsBack <= last_bar_index ? bar_index - 20 : bar_index + 1, close , text =
str.tostring(year, "##") + "/"
+ str.tostring(month, "##") + "/"
+ str.tostring(dayofmonth, "##") + "\n"
+ str.tostring(hour, "##") + ":"
+ str.tostring(minute, "##") + ":"
+ str.tostring(second, "##") + "\n"
+ str.tostring(barsBack <= last_bar_index ? barsBack : last_bar_index, "##") +
" Bars Tested",
color = color.new(color.white, 50),
textcolor = #000000,
style = label.style_label_right
)
line.new(bar_index, close, bar_index, close + 1, color = color.white, width = 2, extend = extend.both)
if dataDisplay != "Label"
table.cell(
array.get(tab, 0),
0,
0,
text =
str.tostring(year, "##") + "/"
+ str.tostring(month, "##") + "/"
+ str.tostring(dayofmonth, "##") + "\n"
+ str.tostring(hour, "##") + ":"
+ str.tostring(minute, "##") + ":"
+ str.tostring(second, "##") + "\n"
+ str.tostring(barsBack <= last_bar_index ? barsBack : last_bar_index, "##") +
" Bars Tested",
text_color = #000000
)
bgcolor(color = barType == "Time" and start <= end and time >= start and time <= end ?
color.new(color.white, 90) :
barType == "Time" and end < start and time >= end and time <= start ?
color.new(color.white, 90) :
barType == "Bars Back" and bar_index >= last_bar_index - barsBack ?
color.new(color.white, 90) :
na
)
|
EMA by DHIREN BHAGOJI | https://www.tradingview.com/script/OmLydi0P-EMA-by-DHIREN-BHAGOJI/ | bhagoji1075 | https://www.tradingview.com/u/bhagoji1075/ | 6 | 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/
// © EMA by DHIREN BHAGOJI
//@version=4
study(title="EMA by DHIREN BHAGOJI", shorttitle="EMA by DHIREN BHAGOJI", overlay=true)
showEMA20 = input(title="Show EMA-20", type=input.bool, defval=false)
showEMA50 = input(title="Show EMA-50", type=input.bool, defval=false)
showEMA200 = input(title="Show EMA-200", type=input.bool, defval=false)
/// EMA Code ///
EMA20_Len = input(20, minval=1, title="EMA20_Length")
EMA20_out = ema(close, EMA20_Len)
plot(showEMA20 ? EMA20_out:na, title="EMA - 20", color=color.red, offset=0, linewidth=1)
EMA50_Len = input(50, minval=1, title="EMA50_Length")
EMA50_out = ema(close, EMA50_Len)
plot(showEMA50 ? EMA50_out:na, title="EMA - 50", color=color.blue, offset=0, linewidth=2)
EMA200_Len = input(200, minval=1, title="EMA200_Length")
EMA200_out = ema(close, EMA200_Len)
plot(showEMA200 ? EMA200_out:na, title="EMA - 200", color=color.black, offset=0, linewidth=3) |
Bitcoin Support Bands | https://www.tradingview.com/script/iJOtjsPO-Bitcoin-Support-Bands/ | Ryukobushi | https://www.tradingview.com/u/Ryukobushi/ | 25 | 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/
// © Ryukobushi
//@version=4
study(title="Bitcoin Weekly Support Bands", overlay=true, resolution="W")
src = input(hl2, title="Source")
len0 = input(4, minval=1, title="4sma")
out0 = sma(src, len0)
len1 = input(4, minval=1, title="4ema")
out1 = ema(src, len1)
len2 = input(12, minval=1, title="12sma")
out2 = sma(src, len2)
len3 = input(12, minval=1, title="12ema")
out3 = ema(src, len3)
len4 = input(24, minval=1, title="24sma")
out4 = sma(src, len4)
len5 = input(24, minval=1, title="24ema")
out5 = ema(src, len5)
len6 = input(48, minval=1, title="48sma")
out6 = sma(src, len6)
len7 = input(48, minval=1, title="48ema")
out7 = ema(src, len7)
len8 = input(96, minval=1, title="96sma")
out8 = sma(src, len8)
len9 = input(96, minval=1, title="96ema")
out9 = ema(src, len9)
len10 = input(192, minval=1, title="192sma")
out10 = sma(src, len10)
len11 = input(192, minval=1, title="192ema")
out11 = ema(src, len11)
len12 = input(384, minval=1, title="384sma")
out12 = sma(src, len12)
len13 = input(384, minval=1, title="384ema")
out13 = ema(src, len13)
o0 = plot(out0, linewidth=2, color=color.silver, title="6sma")
o1 = plot(out1, linewidth=2, color=color.white, title="4ema")
o2 = plot(out2, linewidth=2, color=color.orange, title="16sma")
o3 = plot(out3, linewidth=2, color=color.red, title="14ema")
o4 = plot(out4, linewidth=2, color=color.olive, title="30sma")
o5 = plot(out5, linewidth=2, color=color.yellow, title="28ema")
o6 = plot(out6, linewidth=2, color=color.green, title="52sma")
o7 = plot(out7, linewidth=2, color=color.lime, title="50ema")
o8 = plot(out8, linewidth=2, color=color.blue, title="90sma")
o9 = plot(out9, linewidth=2, color=color.aqua, title="88ema")
o10 = plot(out10, linewidth=2, color=color.maroon, title="150sma")
o11 = plot(out11, linewidth=2, color=color.navy, title="148ema")
o12 = plot(out12, linewidth=2, color=color.fuchsia, title="300sma")
o13 = plot(out13, linewidth=2, color=color.purple, title="298ema")
fill(o0, o1, color=color.white)
fill(o2, o3, color=color.white)
fill(o4, o5, color=color.white)
fill(o6, o7, color=color.white)
fill(o8, o9, color=color.white)
fill(o10,o11, color=color.white)
fill(o12,o13, color=color.white) |
Alert example: multiple checked symbols and checked conditions | https://www.tradingview.com/script/MmBmCnuh-Alert-example-multiple-checked-symbols-and-checked-conditions/ | adolgov | https://www.tradingview.com/u/adolgov/ | 639 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © adolgov
//@version=5
indicator('One indicator - multiple (max 40) checked symbols and "infinite" number of checked conditions. Example')
// check any condition you needed to fire
checkForAlert()=>
alertMsg = ""
// check for highest high
if high > ta.highest(high,14)[1]
alertMsg += str.format("new high {0} for {1}!\n", high, syminfo.ticker)
// check for lowest low
if low < ta.lowest(low,14)[1]
alertMsg += str.format("new low {0} for {1}!\n", low, syminfo.ticker)
// check for odd
if bar_index % 2 == 0
alertMsg += str.format("bar index is odd for {0}!\n", syminfo.ticker)
// any other checks needed
alertMsg
fireAlert(ticker, freq = alert.freq_once_per_bar)=>
msg = request.security(ticker, timeframe.period, checkForAlert())
if str.length(msg) > 0
alert(msg, freq)
fireAlert("BTCUSD")
fireAlert("ETHUSD")
fireAlert("EURUSD")
fireAlert("USDJPY")
// more symbols here ... max 40 |
Star niks | https://www.tradingview.com/script/YeX2AIlv-Star-niks/ | naiknikunj1 | https://www.tradingview.com/u/naiknikunj1/ | 3 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © naiknikunj1
//@version=5
indicator('My script', overlay=true)
win_vwap = ta.vwap
// show plots
is_show = input(defval=false, title='show plots')
plot(is_show ? ta.vwap : na, color=color.new(color.black, 0))
buy_vwap = close > ta.vwap
sell_vwap = close < ta.vwap
//CCI
length = input.int(38, minval=1)
src = input(hlc3, title="CCI Source")
ma = ta.sma(src, length)
cci = (src - ma) / (0.015 * ta.dev(src, length))
plot(is_show?cci:na, "CCI", color=#2962FF)
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing")
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing")
smoothingLine = ma(cci, smoothingLength, typeMA)
plot(smoothingLine, title="Smoothing Line", color=#f37f20, display=display.none)
buy_cci=cci>100
sell_cci=cci<-100
//TDFI
lookback = input(13, title='Lookback')
filterHigh = input(0.05, title='Filter High')
filterLow = input(-0.05, title='Filter Low')
price = input(close, 'Period')
mma = ta.ema(price * 1000, lookback)
smma = ta.ema(mma, lookback)
impetmma = mma - mma[1]
impetsmma = smma - smma[1]
divma = math.abs(mma - smma)
averimpet = (impetmma + impetsmma) / 2
number = averimpet
pow = 3
result = float(na)
for i = 1 to pow - 1 by 1
if i == 1
result := number
result
result *= number
result
tdf = divma * result
ntdf = tdf / ta.highest(math.abs(tdf), lookback * 3)
c = ntdf > filterHigh ? color.green : ntdf < filterLow ? color.red : color.gray
plot(is_show?ntdf:na, linewidth=2, color=c)
buy_tdfi=ntdf>filterHigh
sell_tdfi=ntdf<filterLow
//heikenshi
EMAlength = input(225, 'EMA LENGTH?')
// Empty `table1` table ID.
var table table1 = na
// `table` type is unnecessary because `table.new()` returns "table" type.
var table2 = table.new(position.top_left, na, na)
Heisrc = ohlc4
haOpen = 0.0
haOpen := (Heisrc + nz(haOpen[1])) / 2
haC = (ohlc4 + nz(haOpen) + math.max(high, nz(haOpen)) + math.min(low, nz(haOpen))) / 4
EMA1 = ta.ema(haC, EMAlength)
EMA2 = ta.ema(EMA1, EMAlength)
EMA3 = ta.ema(EMA2, EMAlength)
TMA1 = 3 * EMA1 - 3 * EMA2 + EMA3
EMA4 = ta.ema(TMA1, EMAlength)
EMA5 = ta.ema(EMA4, EMAlength)
EMA6 = ta.ema(EMA5, EMAlength)
TMA2 = 3 * EMA4 - 3 * EMA5 + EMA6
IPEK = TMA1 - TMA2
YASIN = TMA1 + IPEK
EMA7 = ta.ema(hlc3, EMAlength)
EMA8 = ta.ema(EMA7, EMAlength)
EMA9 = ta.ema(EMA8, EMAlength)
TMA3 = 3 * EMA7 - 3 * EMA8 + EMA9
EMA10 = ta.ema(TMA3, EMAlength)
EMA11 = ta.ema(EMA10, EMAlength)
EMA12 = ta.ema(EMA11, EMAlength)
TMA4 = 3 * EMA10 - 3 * EMA11 + EMA12
IPEK1 = TMA3 - TMA4
YASIN1 = TMA3 + IPEK1
mavi = YASIN1
kirmizi = YASIN
longCond = mavi > kirmizi and mavi[1] <= kirmizi[1]
shortCond = mavi < kirmizi and mavi[1] >= kirmizi[1]
trendState = kirmizi < mavi ? true : kirmizi > mavi ? false : na
closePlot = plot(is_show?kirmizi:na, title='Close Line', color=color.new(#009900, 90), linewidth=10, style=plot.style_line)
openPlot = plot(is_show?mavi:na, title='Open Line', color=color.new(#CC0000, 90), linewidth=10, style=plot.style_line)
closePlotU = plot(trendState ? kirmizi : na, editable=false, transp=100)
openPlotU = plot(trendState ? mavi : na, editable=false, transp=100)
closePlotD = plot(trendState ? na : kirmizi, editable=false, transp=100)
openPlotD = plot(trendState ? na : mavi, editable=false, transp=100)
last_signal = 0
long_final = longCond and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == -1)
short_final = shortCond and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 1)
last_signal := long_final ? 1 : short_final ? -1 : last_signal[1]
plotshape(long_final, style=shape.labelup, location=location.belowbar, color=color.new(color.blue, 0), size=size.tiny, title='buy label', text='BUY', textcolor=color.new(color.white, 0))
plotshape(short_final, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny, title='sell label', text='SELL', textcolor=color.new(color.white, 0))
variable = true
if (long_final==true)
variable:=true
if (long_final==false and short_final==false and variable[1]==true)
variable=true
if(short_final==true)
variable:=false
if(long_final==false and short_final==false and variable[1]==false)
variable:=false
variable2 = if variable==false
true
else
false
// Constants
var P_COLORS = "Price colors"
// Inputs
var resolution = input.timeframe('1D', 'Resolution', tooltip="Which resolution do you want the past prices to be pulled from.\nDaily means it will take yesterday's values.")
var hidePast = input.bool(false, "Hide past prices")
var displayRes = input.timeframe('1D', 'Display resolution', tooltip='This only matters if you checked the option above.\nDaily means it will only show the past prices for today, and hide the rest.')
var displayTomorrow = input.bool(true, "Display tomorrow values", tooltip="Remember that the prices WILL change throughout the development of the day, since we, currently, can't predict the future.")
var colorOpen = input.color(color.orange, "Open", inline=P_COLORS, group=P_COLORS)
var colorHigh = input.color(color.teal, "High", inline=P_COLORS, group=P_COLORS)
var colorLow = input.color(color.red, "Low", inline=P_COLORS, group=P_COLORS)
var colorClose = input.color(color.blue, "Close", inline=P_COLORS, group=P_COLORS)
// Getting the values
currentTicker = ticker.new(syminfo.prefix, syminfo.ticker, syminfo.session)
f_pValues() => request.security(currentTicker, resolution, [open[1], high[1], low[1], close[1]], lookahead=barmerge.lookahead_on)
f_cValues() => request.security(currentTicker, resolution, [open, high, low, close], lookahead=barmerge.lookahead_on)
[tOpen, tHigh, tLow, tClose] = f_pValues()
[cOpen, cHigh, cLow, cClose] = f_cValues()
// Adjusting for extended sessions
// Since these hours are not counted in a daily graph, I have to make a big "gambiarra" in order for it to work out.
resInSec = timeframe.in_seconds(resolution)
dailySec = timeframe.in_seconds("1D")
resClose = request.security(currentTicker, resolution, time_close, lookahead=barmerge.lookahead_on)
// If the selected resolution is not intraday
if resInSec >= dailySec
// I can't just use session.isintraday because it would mess up the values when the resolution is greater than daily
// If the current bar closes after the bar of the chosen resolution, i.e.,
// we are in a pre-market session and the new session has not started
if time_close > resClose
// Then I need to update the values to match the current values, not the past ones.
// I really wish PS would just let me use the walrus operator (:=) with brackets here...
tOpen := cOpen
tHigh := cHigh
tLow := cLow
tClose := cClose
// Hiding past values
// I really wish I could use the brackets here... c'mon PS, I just have to declare the na with a floating type, it's not hard.
float yOpen = na
float yHigh = na
float yLow = na
float yClose = na
isLastBar = request.security(currentTicker, displayRes, barstate.islast, lookahead=barmerge.lookahead_on)
if not hidePast or (hidePast and isLastBar)
// Once again, you know what I wanted to do
yOpen := tOpen
yHigh := tHigh
yLow := tLow
yClose := tClose
// Display tomorrow values
// I was planning to use a fancy time calculation to set the tomorrow prices correctly,
// but PS doesn't let me use the next bar as a basis, so I will just leave this here,
// in case this ever gets implemented.
// tfInMs(tf) => int(timeframe.in_seconds(tf) * math.pow(10, 3))
var barsPerSession = int(timeframe.in_seconds(resolution) / timeframe.in_seconds(timeframe.period))
tomorrowLine(price, _color) =>
// line.new(last_bar_time + tfInMs(timeframe.period), price, last_bar_time + tfInMs(resolution), price, xloc.bar_time, color=_color)
line.new(last_bar_index + 1, price, last_bar_index + barsPerSession, price, xloc.bar_index, color=_color)
// label.new(last_bar_index + 1, price, str.tostring(price), xloc.bar_index, yloc.price, _color, label.style_label_lower_right, color.black, textalign=text.align_left)
if isLastBar and displayTomorrow
tomorrowLine(cOpen, colorOpen)
tomorrowLine(cHigh, colorHigh)
tomorrowLine(cLow, colorLow)
tomorrowLine(cClose, colorClose)
// Plots
plot(yHigh, "Yesterday's high", colorHigh, style=plot.style_stepline)
plot(yLow, "Yesterday's low", colorLow, style=plot.style_stepline)
yesH= if (close>yHigh)
true
else
false
yesL= if(close<yLow)
true
else
false
buy_order = buy_cci and buy_vwap and buy_tdfi and variable or yesH
sell_order = sell_cci and sell_vwap and sell_tdfi and variable2 or yesL
finally_buy=false
if(buy_order==true and long_final==true )
finally_buy:=true
else if(buy_order==true and long_final[1]==true )
finally_buy:=true
else if(buy_order==true and long_final[2]==true )
finally_buy:=true
else if(buy_order==true and long_final[3]==true )
finally_buy:=true
finally_sell=false
if(sell_order==true and short_final==true )
finally_sell:=true
else if(sell_order==true and short_final[1]==true )
finally_sell:=true
else if(sell_order==true and short_final[2]==true )
finally_sell:=true
else if(sell_order==true and short_final[3]==true )
finally_sell:=true
if (finally_buy[1]==true)
finally_buy:=false
else if (finally_buy[2]==true)
finally_buy:=false
else if (finally_buy[3]==true)
finally_buy:=false
if(finally_sell[1]==true)
finally_sell:=false
else if (finally_sell[2]==true)
finally_sell:=false
else if (finally_sell[3]==true)
finally_sell:=false
plotarrow(finally_buy?1:na,colorup=color.green,maxheight=150,minheight=100)
plotarrow(finally_sell?-1:na,colorup=color.red,maxheight=150,minheight=100)
alertcondition(finally_buy,title="buy alert s1")
alertcondition(finally_sell,title="sell alert s1") |
Volatility Ratio Adaptive RSX [Loxx] | https://www.tradingview.com/script/DekwQAqc-Volatility-Ratio-Adaptive-RSX-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 98 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Volatility Raito Adaptive RSX [Loxx]",
shorttitle="VRARSX [Loxx]",
overlay=false,
max_bars_back = 3000)
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
_calculate(src, per)=>
dev = ta.stdev(src, per)
devavg = ta.sma(dev, per)
out = dev/devavg
out
_rsx(src, len, spd)=>
src_out = 100 * src
mom0 = ta.change(src_out)
moa0 = math.abs(mom0)
Kg = 3 / (len + 2.0)
Hg = 1 - Kg
spdp1 = spd + 1.0
//mom
f28 = 0.0, f30 = 0.0
f28 := Kg * mom0 + Hg * nz(f28[1])
f30 := Hg * nz(f30[1]) + Kg * f28
mom1 = f28 * spdp1 - f30 * spd
f38 = 0.0, f40 = 0.0
f38 := Hg * nz(f38[1]) + Kg * mom1
f40 := Kg * f38 + Hg * nz(f40[1])
mom2 = f38 * spdp1 - f40 * spd
f48 = 0.0, f50 = 0.0
f48 := Hg * nz(f48[1]) + Kg * mom2
f50 := Kg * f48 + Hg * nz(f50[1])
mom_out = f48 * spdp1 - f50 * spd
//moa
f58 = 0.0, f60 = 0.0
f58 := Hg * nz(f58[1]) + Kg * moa0
f60 := Kg * f58 + Hg * nz(f60[1])
moa1 = f58 * spdp1 - f60 * spd
f68 = 0.0, f70 = 0.0
f68 := Hg * nz(f68[1]) + Kg * moa1
f70 := Kg * f68 + Hg * nz(f70[1])
moa2 = f68 * spdp1 - f70 * spd
f78 = 0.0, f80 = 0.0
f78 := Hg * nz(f78[1]) + Kg * moa2
f80 := Kg * f78 + Hg * nz(f80[1])
moa_out = f78 * spdp1 - f80 * spd
rsiout = math.max(math.min((mom_out / moa_out + 1.0) * 50.0, 100.00), 0.00)
rsiout
src = input.source(close, "Source", group = "Basic Settings")
per = input.int(14, "Period", group = "Basic Settings")
spd = input.float(0.5, "spd", step = 0.1, maxval = 1, minval = 0, group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
volRatio = _calculate(src, per)
val = _rsx(src, int(per/volRatio), spd)
signal = val[1]
middle = 50
colorout =
val > signal and val > middle ? greencolor :
val < signal and val > middle ? lightgreencolor :
val < signal and val < middle ? redcolor :
val > signal and val < middle ? lightredcolor :
color.gray
plot(val, color = colorout, linewidth = 2)
plot(middle, color = bar_index % 2 ? color.gray : na)
barcolor(colorbars ? colorout : na)
|
Jurik Filter TRIX Log [Loxx] | https://www.tradingview.com/script/lc8wDLQW-Jurik-Filter-TRIX-Log-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 53 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Jurik Filter TRIX Log [Loxx]",
shorttitle="JFTL [Loxx]",
overlay=false)
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
srcin = input.source(close, "Source", group = "Basic Settings")
per = input.int(14, "Period", group = "Basic Settings")
phs =input.float(0, "Juirk Phase", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
src = math.log(srcin)
workTrix1 = loxxjuriktools.jurik_filt(src, per, phs)
workTrix2 = loxxjuriktools.jurik_filt(workTrix1, per, phs)
workTrix3 = loxxjuriktools.jurik_filt(workTrix2, per, phs)
val = ta.change(workTrix3)
signal = nz(val[1])
middle = 0.
colorout = val > signal and val > middle ? greencolor :
val < signal and val > middle ? lightgreencolor :
val < signal and val < middle ? redcolor :
val > signal and val < middle ? lightredcolor :
color.gray
plot(middle, color = bar_index % 2 ? color.gray : na)
plot(val, color = colorout)
barcolor(colorbars ? colorout : na)
|
Custom Index | https://www.tradingview.com/script/cvuHqcmi-Custom-Index/ | akumidv | https://www.tradingview.com/u/akumidv/ | 35 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © akumidv
//@version=5
indicator("CustomIndex", overlay=false)
// TODO Improvements
// - add weight to normalized price
// - normalize weight to 100%
// - show on chart with price normalization - offset and multipler
// - label instad char for reloading
shouldNormalize = input.bool(true, title='Normalize price?', group='Base parameters')
shouldNormalizeByLast = input.bool(true, title='Renormalize price by last?', group='Base parameters')
shouldDrawTickers = input.bool(true, title='Show index components?', group='Base parameters')
shouldUseTicker1 = input.bool(true, title="", inline='tik1', group='Tikers')
tickerName1 = input.string('BINANCE:BTCUSDT', title='Ticker 1', inline='tik1', group='Tikers')
tickerWeight1 = input.int(10, title='Weight %', inline='tik1', group='Tikers')
shouldUseTicker2 = input.bool(true, title="", inline='tik2', group='Tikers')
tickerName2 = input.string('BINANCE:ETHUSDT', title='Ticker 2', inline='tik2', group='Tikers')
tickerWeight2 = input.int(10, title='Weight %', inline='tik2', group='Tikers')
shouldUseTicker3 = input.bool(true, title="", inline='tik3', group='Tikers')
tickerName3 = input.string('BINANCE:SOLUSDT', title='Ticker 3', inline='tik3', group='Tikers')
tickerWeight3 = input.int(10, title='Weight %', inline='tik3', group='Tikers')
shouldUseTicker4 = input.bool(true, title="", inline='tik4', group='Tikers')
tickerName4 = input.string('BINANCE:BNBUSDT', title='Ticker 4', inline='tik4', group='Tikers')
tickerWeight4 = input.int(10, title='Weight %', inline='tik4', group='Tikers')
shouldUseTicker5 = input.bool(true, title="", inline='tik5', group='Tikers')
tickerName5 = input.string('BINANCE:DOGEUSDT', title='Ticker 5', inline='tik5', group='Tikers')
tickerWeight5 = input.int(10, title='Weight %', inline='tik5', group='Tikers')
shouldUseTicker6 = input.bool(false, title="", inline='tik6', group='Tikers')
tickerName6 = input.string('BINANCE:AVAXUSDT', title='Ticker 6', inline='tik6', group='Tikers')
tickerWeight6 = input.int(10, title='Weight %', inline='tik6', group='Tikers')
shouldUseTicker7 = input.bool(false, title="", inline='tik7', group='Tikers')
tickerName7 = input.string('BINANCE:XRPUSDT', title='Ticker 7', inline='tik7', group='Tikers')
tickerWeight7 = input.int(10, title='Weight %', inline='tik7', group='Tikers')
shouldUseTicker8 = input.bool(false, title="", inline='tik8', group='Tikers')
tickerName8 = input.string('BINANCE:SANDUSDT', title='Ticker 8', inline='tik8', group='Tikers')
tickerWeight8 = input.int(10, title='Weight %', inline='tik8', group='Tikers')
shouldUseTicker9 = input.bool(false, title="", inline='tik9', group='Tikers')
tickerName9 = input.string('BINANCE:ATOMUSDT', title='Ticker 9', inline='tik9', group='Tikers')
tickerWeight9 = input.int(10, title='Weight %', inline='tik9', group='Tikers')
shouldUseTicker10 = input.bool(false, title="", inline='tik10', group='Tikers')
tickerName10 = input.string('BINANCE:MATICUSDT', title='Ticker 10', inline='tik10', group='Tikers')
tickerWeight10 = input.int(10, title='Weight %', inline='tik10', group='Tikers')
// Data preparation
var int NUMBER_OF_TICKETS = 10
var float[] tickerInitPrices = array.new_float(NUMBER_OF_TICKETS, na)
var float[] normTickerPrices = array.new_float(NUMBER_OF_TICKETS, na)
var float[] tickerWeights = array.from(float(tickerWeight1)/100, float(tickerWeight2)/100, float(tickerWeight3)/100, float(tickerWeight4)/100, float(tickerWeight5)/100,
float(tickerWeight6)/100, float(tickerWeight7)/100, float(tickerWeight8)/100, float(tickerWeight9)/100, float(tickerWeight10)/100)
var bool[] tickersUsage = array.from(shouldUseTicker1, shouldUseTicker2, shouldUseTicker3, shouldUseTicker4, shouldUseTicker5, shouldUseTicker6, shouldUseTicker7, shouldUseTicker8, shouldUseTicker9, shouldUseTicker10)
float[] tickerPrices = array.from(request.security(tickerName1, '',close), request.security(tickerName2, '',close),
request.security(tickerName3, '',close), request.security(tickerName4, '',close), request.security(tickerName5, '',close),
request.security(tickerName6, '',close), request.security(tickerName7, '',close),
request.security(tickerName8, '',close), request.security(tickerName9, '',close), request.security(tickerName10, '',close))
normalizeAllTickerPrices(arrInitPrice, arrCurPrice) =>
for i = 0 to NUMBER_OF_TICKETS - 1
float curPrice = array.get(arrCurPrice, i)
array.set(arrInitPrice, i, curPrice)
bool isNormalized = false
float indexPrice = 0
for i = 0 to NUMBER_OF_TICKETS - 1
float curPrice = array.get(tickerPrices, i)
if not array.get(tickersUsage, i) or na(curPrice)
continue
float initPrice = array.get(tickerInitPrices, i)
if na(initPrice) and not na(curPrice)
initPrice := curPrice
if shouldNormalizeByLast
normalizeAllTickerPrices(tickerInitPrices, tickerPrices)
isNormalized := true
else
array.set(tickerInitPrices, i, curPrice)
float normTickerPrice = shouldNormalize ? curPrice / initPrice : curPrice * array.get(tickerWeights, i)
array.set(normTickerPrices, i, normTickerPrice)
indexPrice := indexPrice + normTickerPrice
// // Drawing
plot(indexPrice, title='Index', color=color.blue)
plot(shouldDrawTickers and shouldUseTicker1 ? array.get(normTickerPrices, 0) : na, title='Ticker1', color=color.navy)
plot(shouldDrawTickers and shouldUseTicker2 ? array.get(normTickerPrices, 1) : na, title='Ticker2', color=color.maroon)
plot(shouldDrawTickers and shouldUseTicker3 ? array.get(normTickerPrices, 2) : na, title='Ticker3', color=color.olive)
plot(shouldDrawTickers and shouldUseTicker4 ? array.get(normTickerPrices, 3) : na, title='Ticker4', color=color.teal)
plot(shouldDrawTickers and shouldUseTicker5 ? array.get(normTickerPrices, 4) : na, title='Ticker5', color=color.fuchsia)
plot(shouldDrawTickers and shouldUseTicker6 ? array.get(normTickerPrices, 5) : na, title='Ticker6', color=color.silver)
plot(shouldDrawTickers and shouldUseTicker7 ? array.get(normTickerPrices, 6) : na, title='Ticker7', color=color.purple)
plot(shouldDrawTickers and shouldUseTicker8 ? array.get(normTickerPrices, 7) : na, title='Ticker8', color=color.lime)
plot(shouldDrawTickers and shouldUseTicker9 ? array.get(normTickerPrices, 8) : na, title='Ticker9', color=color.orange)
plot(shouldDrawTickers and shouldUseTicker10 ? array.get(normTickerPrices, 9) : na, title='Ticker10', color=color.aqua)
plotchar(isNormalized ? indexPrice * 1.05 : na, title='Reload', char='⟳', location=location.absolute, size=size.auto, color=color.black)
|
OMA (One More Average) RSI Histogram [Loxx] | https://www.tradingview.com/script/ChdpzGNv-OMA-One-More-Average-RSI-Histogram-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator("OMA (One More Average) RSI Histogram [Loxx]",
shorttitle="OMARSIH [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
_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
src = input.source(close, "Source", group = "Basic Settings")
const = input.float(1.5, "Speed", step = .01, group = "Basic Settings")
adapt = input.bool(true, "Make it adapotive?", group = "Basic Settings")
buylev = input.int(65, "Buy Level", group = "Basic Settings")
selllev = input.int(35, "Sell Level", group = "Basic Settings")
len = input.int(32, "Average Period", minval = 1, group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
chng = ta.change(src)
changn = _oma(chng, len, const, adapt)
changa = _oma(math.abs(chng), len, const, adapt)
rsi = (math.min(math.max(50.0 * (changn / math.max(changa, 0.0000001) + 1.0), 0), 100))
valc = 0.
valc := (rsi > buylev) ? 1 : (rsi < selllev) ? -1 : (rsi < buylev and rsi > selllev) ? 0 : nz(valc[1])
upH = (valc == 1) ? 1 : 0.
dnH = (valc == -1) ? 1 : 0.
nuH = (valc == 0) ? 1 : 0.
plot(nuH, "Mid", color = color.gray, style= plot.style_histogram)
plot(upH, "Up", color = greencolor , style= plot.style_histogram)
plot(dnH, "Down", color = redcolor, style= plot.style_histogram)
colorout = upH == 1 ? greencolor : dnH == 1 ? redcolor : color.gray
barcolor(colorbars ? colorout : na)
|
TR Unleaded Gasoline & Diesel Price by zdmre | https://www.tradingview.com/script/ZvqFM8VD-TR-Unleaded-Gasoline-Diesel-Price-by-zdmre/ | zdmre | https://www.tradingview.com/u/zdmre/ | 25 | study | 5 | MPL-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("TR Unleaded Gasoline & Diesel Price by zdmre")
kdv_jul_10 = timestamp("Jul 10 2023 00:00 +000")
otv_jul_16 = timestamp("Jul 16 2023 00:00 +000")
float p = 0
float k = 1
if time >= kdv_jul_10
k := 1.01694
if time >= otv_jul_16
p := 5
trgas = ta.sma(request.security("TVC:UKOIL*FX:USDTRY/159*2.1", "D", close),5)*1.03*k+p
trdsl = ta.sma(request.security("(NYMEX:GKS1!*FX:USDTRY+TVC:UKOIL*FX:USDTRY)*1.59*1.2/1.18/159", "D", close),5)*1.03*k+p
var tbis = table.new(position.middle_right, 2, 5, frame_color=color.black, frame_width=0, border_width=1, border_color=color.black)
table.cell(tbis, 0, 1, 'Unleaded Gasoline', bgcolor = color.blue, text_size=size.small, text_color=color.white)
table.cell(tbis, 0, 2, 'Diesel', bgcolor = color.yellow, text_size=size.small, text_color=color.black)
table.cell(tbis, 1, 1, str.tostring(trgas[0],'#.00 TL'), text_color=color.white, bgcolor= color.blue)
table.cell(tbis, 1, 2, str.tostring(trdsl[0],'#.00 TL'), text_color=color.black, bgcolor= color.yellow)
plot(trgas, title='Unleaded Gasoline', color=color.new(color.blue, 0), linewidth=2)
plot(trdsl, title='Diesel', color=color.new(color.yellow, 0), linewidth=2) |
Binance Futures Swap-Spot Basis Label | https://www.tradingview.com/script/LSgp5XnM-Binance-Futures-Swap-Spot-Basis-Label/ | king_mob | https://www.tradingview.com/u/king_mob/ | 20 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © king_mob
//@version=5
indicator("Swap-Spot Basis Label", overlay=true)
cursym = str.tostring(syminfo.tickerid)
symname = str.substring(cursym, 0, str.length(cursym) - 4)
spot = request.security(symname, timeframe.period, close)
basis1 = ((close-spot)/close)*100
basis = math.round(basis1, 4)
dt = time - time[1]
lineCol = (basis > 0) ? color.green : (basis < 0) ? color.red : color.black
lbl = label.new(time + 60*dt, close, xloc=xloc.bar_time, text=str.tostring(basis), style=label.style_none, textcolor=lineCol, size=size.small)
label.delete(lbl[1]) |
Jurik-Smoothed CCI w/ MA Deviation [Loxx] | https://www.tradingview.com/script/KC4ZXWms-Jurik-Smoothed-CCI-w-MA-Deviation-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 57 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Jurik-Smoothed CCI w/ MA Deviation [Loxx]",
shorttitle="JSCCIMAD [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxmas/1
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
maintype = input.string("Exponential Moving Average - EMA", "Deviation 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")
ccisrc = input.source(hlc3, "CCI Source", group = "Basic Settings")
cciper = input.int(32, "CCI Period", group = "Basic Settings")
jsmth = input.int(32, "Jurik Smoothing Period", group = "Basic Settings")
phs = input.float(0, "Jurik Phase", group = "Basic Settings")
inpLevelUp = input.int(100, "Overbought Level", group = "Basic Settings")
inpLevelDown = input.int(-100, "Oversold Level", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", 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
_emaDev(type, price, period)=>
alpha = 2.0/(1.0+period)
wEMAdev0 = price, wEMAdev1 = price
wEMAdev0 := variant(type, price, period)
wEMAdev1 := variant(type, price*price, period)
out = math.sqrt(period*(wEMAdev1 - wEMAdev0 * wEMAdev0) / math.max(period-1, 1))
out
_cci(type, src, len, smth, phase)=>
price = loxxjuriktools.jurik_filt(src, smth, phase)
avg = loxxjuriktools.jurik_filt(price, len, phase)
dev = math.max(_emaDev(type, price, len), -2e10)
val = (dev!=0) ? (price - avg) / (0.015 * dev) : 0.
val
middle = 0.
cci = _cci(maintype, ccisrc, cciper, jsmth, phs)
colorout =
cci > middle ? greencolor : redcolor
plot(inpLevelUp, color = bar_index % 2 ? color.gray : na)
plot(inpLevelDown, color = bar_index % 2 ? color.gray : na)
plot(middle, color = bar_index % 2 ? color.gray : na)
plot(cci, color = colorout, style = plot.style_line, linewidth = 2)
barcolor(colorbars ? colorout : na)
|
Lower time frame Intrabar Candles | https://www.tradingview.com/script/oYiPLEJA-Lower-time-frame-Intrabar-Candles/ | dman103 | https://www.tradingview.com/u/dman103/ | 337 | study | 5 | CC-BY-SA-4.0 | // This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/
// © dman103
// I was looking for an indicator to show me what a lower time frame is doing at the start, middle, and end of the candle, but I couldn't find one, hench,
// I made my own using Tradingview latest capabilities to fetch a lower time frame from a higher time frame chart.
// For example, if your chart is 1 hour and this indicator is set to a lower time frame of 15 minutes, then the Start, Middle, or End (Select which in settings) of the 15min candle will be displayed overlaying the 1-hour candle.
// This will always show you what the lower time frame candle is currently doing without the need to open an additional lower time frame chart. How cool is that?
// Remember to select a lower time frame in the settings than the chart time frame for it to work as expected.
// Added optional label to show lower time frame values (can be disabled via indicator settings).
// You can adjust the visuals of the chart candles at Chart Settings -> Symbol -> Body, Borders, or Wicks.
// You can also visually see better the lower time frame candles
//
// Note that lower time frame candles BORDER is set to WHITE by default, however, you can adjust the color of the candle (wicks, body, and border) of the 'LTF Candle' indicator inside its Settings -> Style
// Suitable for candles and designed to work in historical and real time.
// Will introduce in the future more interesting concepts based on lower time frame capabilities: https://www.tradingview.com/u/dman103/#published-scripts
// Follow and like if you like.
//@version=5
indicator("Lower time frame Intrabar Candles",'LTF Candle',overlay = true)
lower_time_frame= input.timeframe('5','Intrabar lower time frame', tooltip='Which lower time frame candle to overlay on the chart. Must be lower than the chart time frame.')
candle_to_display=input.string( "Candle End","Lower time frame Candle to overlay", options = ["Candle Start", "Candle End","Candle Middle"])
var candle_type= candle_to_display=='Candle End' ? 1 : candle_to_display=='Candle Start' ? 2 : 3
show_only_last_bar= input.bool(false,'Show only most recent lower time frame candle')
display_lower_tf_label = input.bool(false,'Display most recent candle values')
[l_open,l_high,l_low,l_close] = request.security_lower_tf(syminfo.tickerid, lower_time_frame,[open,high,low,close])
varip float high_value_get=0
varip float low_value_get=0
varip float open_value_get=0
varip float close_value_get=0
varip int pre_candle_length_ltf=0
if barstate.isconfirmed
pre_candle_length_ltf:=array.size(l_close)
if (array.size(l_close)>0)
high_value_get:= candle_type==1 and pre_candle_length_ltf==array.size(l_high) ? array.get(l_high,pre_candle_length_ltf-1) : candle_type==2 ? array.get(l_high,0) : candle_type==3 and pre_candle_length_ltf/2==array.size(l_high)/2 ? array.get(l_high,pre_candle_length_ltf/2) : na
low_value_get:= candle_type==1 and pre_candle_length_ltf==array.size(l_low)? array.get(l_low,pre_candle_length_ltf-1) : candle_type==2 ? array.get(l_low,0) : candle_type==3 and pre_candle_length_ltf/2==array.size(l_low)/2 ? array.get(l_low,pre_candle_length_ltf/2) : na
open_value_get:= candle_type==1 and pre_candle_length_ltf==array.size(l_open)? array.get(l_open,pre_candle_length_ltf-1) : candle_type==2 ? array.get(l_open,0) : candle_type==3 and pre_candle_length_ltf/2==array.size(l_open)/2 ? array.get(l_open,pre_candle_length_ltf/2) : na
close_value_get:= candle_type==1 and pre_candle_length_ltf==array.size(l_close)? array.get(l_close,pre_candle_length_ltf-1) : candle_type==2 ? array.get(l_close,0): candle_type==3 and pre_candle_length_ltf/2==array.size(l_close)/2 ? array.get(l_close,pre_candle_length_ltf/2) : na
h_tf=(array.size(l_high)>0 and (((barstate.islast or barstate.isrealtime) and show_only_last_bar) or show_only_last_bar==false)) ? high_value_get : na
l_tf=(array.size(l_low)>0 and (((barstate.islast or barstate.isrealtime) and show_only_last_bar) or show_only_last_bar==false)) ? low_value_get: na
o_tf=(array.size(l_open)>0 and (((barstate.islast or barstate.isrealtime) and show_only_last_bar) or show_only_last_bar==false)) ? open_value_get: na
c_tf=(array.size(l_close)>0 and (((barstate.islast or barstate.isrealtime) and show_only_last_bar) or show_only_last_bar==false)) ? close_value_get : na
close_value= c_tf
plotcandle(o_tf,h_tf,l_tf,close_value,color=close_value>o_tf ? color.new(#a5d6a7,60) : color.new(#faa1a4,60),wickcolor =close_value>o_tf ? color.new(color.lime,0) : color.new(color.red,0),bordercolor =color.white,show_last=show_only_last_bar ? 1 : na)
var label val_tf = na
if barstate.islast and display_lower_tf_label
val_tf:=label.new(bar_index, c_tf>o_tf ? low : high,
"■ Open " + str.tostring(o_tf) +
" ■ Close " + str.tostring(c_tf)+
"\n■ High " + str.tostring(h_tf) +
" ■ Low " + str.tostring(l_tf),color=c_tf>o_tf ? color.new(color.aqua,70) : color.new(color.red,70),style=c_tf>o_tf ?label.style_label_up : label.style_label_down, textcolor=color.white)
label.delete(val_tf[1])
|
William Blau Ergodic Tick Volume Indicator (TVI) [Loxx] | https://www.tradingview.com/script/Z4Pi5Cuh-William-Blau-Ergodic-Tick-Volume-Indicator-TVI-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 418 | study | 5 | MPL-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
// by William Blaus definition of ergodic tick volume indicator (TVI) it is an ergodic when periods are set to 32,5,1 and signal is set to 5.
indicator("William Blau Ergodic Tick Volume Indicator (TVI) [Loxx]",
shorttitle="WGETVI [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
bluecolor = #042dd2
_calcBaseUnit() =>
bool isForexSymbol = syminfo.type == "forex"
bool isYenPair = syminfo.currency == "JPY"
float result = isForexSymbol ? isYenPair ? 0.01 : 0.0001 : syminfo.mintick
result
maintype = input.string("Exponential Moving Average - EMA", "Core Moving 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")
emaper = input.int(32, "EMA Period", group = "Basic Settings")
avper = input.int(5, "Average Period", group = "Basic Settings")
smthper = input.int(1, "Smoothing Period", group = "Basic Settings")
signaltype = input.string("Exponential Moving Average - EMA", "Signal 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")
sigper = input.int(5, "Signal Period", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", 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
_tvi(type, avper, emaper, smthper)=>
upTic = (volume + (close - open) / _calcBaseUnit()) / 2
dnTic = volume - upTic
ema2 = variant(type, upTic, emaper)
ema4 = variant(type, dnTic, emaper)
avgUp = variant(type, ema2, avper)
avgDn = variant(type, ema4, avper)
ema5 = variant(type, 100.0 * (avgUp-avgDn) / (avgUp+avgDn), smthper)
val = (avgUp+avgDn != 0) ? ema5 : 0
val
val = _tvi(maintype, avper, emaper, smthper)
vals = variant(signaltype, val, sigper)
middle = 0.
colorout =
val > vals and val > middle ? bluecolor :
val < vals and val > middle ? greencolor :
val < vals and val < middle ? redcolor :
val > vals and val < middle ? color.yellow :
color.gray
plot(middle, color = bar_index % 2 ? color.gray : na)
plot(val, color = colorout, linewidth = 2, style = plot.style_histogram)
plot(vals, color = color.white)
barcolor(colorbars ? colorout : na)
|
The Real GBTC Premium (Capriole Investments) | https://www.tradingview.com/script/bXmhpmGq-The-Real-GBTC-Premium-Capriole-Investments/ | capriole_charles | https://www.tradingview.com/u/capriole_charles/ | 208 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © caprioleio
//@version=5
indicator('The Real GBTC Premium (Capriole Investments)', overlay=false)
// gbtc btc per share based on 2% fee per annum. Data is from 04 Dec 2020
ticker = input.string('OTC:GBTC', 'Grayscale ticker', options=['OTC:GBTC', 'FTX:GBTCUSD'])
btc = request.security('COINBASE:BTCUSD', timeframe.period, close)
gbtc = nz(request.security(ticker, timeframe.period, close))
gbtc_v = nz(request.security(ticker, timeframe.period, volume))
btc_per_share_data = 0.00090292 // as at 19/7/2023: https://grayscale.com/products/grayscale-bitcoin-trust/
btc_share_date = timestamp(2023, 7, 19, 00, 00)
gbtc_fee = 0.02
days_since_data = (time - btc_share_date) / (60 * 60 * 24 * 1000 * 1440 / timeframe.multiplier)
btc_per_share = btc_per_share_data * math.pow(1 - gbtc_fee, days_since_data / 365)
premium = (gbtc / (btc * btc_per_share) - 1) * 100
trading = not(gbtc == gbtc[1] and gbtc_v == gbtc_v[1])
premium_fin = 0.0
premium_fin := trading ? premium : premium_fin[1]
clr = premium_fin < 0 ? color.red : color.green
plot(trading ? premium : na, style=plot.style_columns, color=color.new(clr,0))
plot(premium_fin, style=plot.style_columns, color=color.new(clr,40))
var table_source = table(na)
table_source := table.new(position=position.bottom_left, columns=1, rows=1, bgcolor=color.white, border_width=1)
table.cell(table_source, 0, 0, text='Source: Capriole Investments Limited', bgcolor=color.white, text_color=color.black, width=20, height=7, text_size=size.normal, text_halign=text.align_left) |
Genesis Matrix [Loxx] | https://www.tradingview.com/script/45f7SAGU-Genesis-Matrix-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 238 | study | 5 | MPL-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("Genesis Matrix [Loxx]",
shorttitle="GM [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxmas/1
import loxx/loxxjuriktools/1
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
_calcBaseUnit() =>
bool isForexSymbol = syminfo.type == "forex"
bool isYenPair = syminfo.currency == "JPY"
float result = isForexSymbol ? isYenPair ? 0.01 : 0.0001 : syminfo.mintick
result
ccisrc = input.source(close, "CCI Source", group = "CCI Settings")
cciper = input.int(20, "CCI Period", group = "CCI Settings")
madev = input.int(14, "MA Deviation Period", group = "CCI Settings")
madevtype = input.string("Exponential Moving Average - EMA", "Deviation 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 = "CCI Settings")
jsmth = input.int(5, "Jurik Smoothing Period", group = "CCI Settings")
phs = input.float(0, "Jurik Phase", group = "CCI Settings")
t3src = input.source(close, "T3 Source", group = "T3 Settings")
t3per = input.int(8, "T3 Period", group = "T3 Settings")
t3hot = input.float(1, "T3 Factor", minval = 0, maxval = 1, step = 0.01, group = "T3 Settings")
tempswtch = input.bool(false, "T3 Original", group = "T3 Settings")
ssltype = input.string("Exponential Moving Average - EMA", "Deviation 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 = "SSL Settings")
sslper = input.int(20, "SSL Period", group = "SSL Settings")
clsper = input.int(1, "Close Period", group = "SSL Settings", minval =0)
tvitype = input.string("Exponential Moving Average - EMA", "Deviation 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 = "TVI Settings")
tviema = input.int(12, "TVI EMA Period", group = "TVI Settings")
tviavg = input.int(12, "TVI Average Period", group = "TVI Settings")
tvismth = input.int(5, "TVI Smoothing Period", group = "TVI Settings")
colorbars = input.bool(false, "Color bars?", 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
_emaDev(type, price, period)=>
alpha = 2.0/(1.0+period)
wEMAdev0 = price, wEMAdev1 = price
wEMAdev0 := variant(type, price, period)
wEMAdev1 := variant(type, price*price, period)
out = math.sqrt(period*(wEMAdev1 - wEMAdev0 * wEMAdev0) / math.max(period-1, 1))
out
_cci(type, src, len, malen, smth, phase)=>
price = loxxjuriktools.jurik_filt(src, smth, phase)
avg = loxxjuriktools.jurik_filt(price, len, phase)
dev = math.max(_emaDev(type, price, malen), -2e10)
val = (dev!=0) ? (price - avg) / (0.015 * dev) : 0.
val
_tvi(type, tr, s, u)=>
upTic = (volume + (close - open) / _calcBaseUnit()) / 2
dnTic = volume - upTic
ema2 = variant(type, upTic, s)
ema4 = variant(type, dnTic, s)
avgUp = variant(type, ema2, tr)
avgDn = variant(type, ema4, tr)
ema5 = variant(type, 100.0 * (avgUp-avgDn) / (avgUp+avgDn), u)
val = (avgUp+avgDn != 0) ? ema5 : 0
val
_ssl(type, len, clper)=>
varHigh = variant(type, high, len)
varLow = variant(type, low, len)
varClose = variant(type, close, clper)
Hlv = 0.
Hlv := varClose > varHigh ? 1 : varClose < varLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? varHigh : varLow
sslUp = Hlv < 0 ? varLow : varHigh
[sslUp, sslDown]
tvi = _tvi(tvitype, tviavg, tviema, tvismth)
[sslUp, sslDown] = _ssl(ssltype, sslper, clsper)
t3out = _iT3(t3src, t3per, t3hot, tempswtch)
cci = _cci(madevtype, ccisrc, cciper, madev, jsmth, phs)
plotshape(1, color = t3out > nz(t3out[1]) ? greencolor : redcolor, style = shape.square, location = location.absolute)
plotshape(2, color = sslUp > sslDown ? greencolor : redcolor, style = shape.square, location = location.absolute)
plotshape(3, color = cci > 0 ? greencolor : redcolor, style = shape.square, location = location.absolute)
plotshape(4, color = tvi > 0 ? greencolor : redcolor, style = shape.square, location = location.absolute)
colorout =
tvi > 0 and sslUp > sslDown and t3out > nz(t3out[1]) and cci > 0 ? greencolor :
tvi < 0 and sslUp < sslDown and t3out < nz(t3out[1]) and cci < 0 ? redcolor :
color.gray
barcolor(colorbars ? colorout : na)
goLong_pre = tvi > 0 and sslUp > sslDown and t3out > nz(t3out[1]) and cci > 0
goShort_pre = tvi < 0 and sslUp < sslDown and t3out < nz(t3out[1]) and cci < 0
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(colorout == redcolor ? 5 : na, style = shape.triangledown, location = location.absolute, size = size.auto, color = color.fuchsia)
plotshape(colorout == greencolor ? 0 : na, style = shape.triangleup, location = location.absolute, size = size.auto, color = color.yellow)
alertcondition(goLong, title="Long", message="Genesis Matrix [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Genesis Matrix [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
FATL, SATL, RFTL, & RSTL Digital Filters Raw [Loxx] | https://www.tradingview.com/script/KotkqgIC-FATL-SATL-RFTL-RSTL-Digital-Filters-Raw-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 98 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("FATL, SATL, RFTL, & RSTL Digital Filters Raw [Loxx]",
shorttitle = "FSRRDFR [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxfsrrdspfilts/1
greencolor = #2DD204
redcolor = #D2042D
dspinp = input.string("SATL - Slow Adaptive Trend Line", "Digital Filter Type", options = ["FATL - Fast Adaptive Trend Line", "SATL - Slow Adaptive Trend Line",
"RFTL - Reference Fast Trend Line", "RSTL - Reference Slow Trend Line"], group = "Digital Filter Settings")
src = input.source(close, title="Source", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group= "UI Options")
out =
dspinp == "FATL - Fast Adaptive Trend Line" ? loxxfsrrdspfilts.fatl(src) :
dspinp == "SATL - Slow Adaptive Trend Line" ? loxxfsrrdspfilts.satl(src) :
dspinp == "RFTL - Reference Fast Trend Line" ? loxxfsrrdspfilts.rftl(src) :
loxxfsrrdspfilts.rstl(src)
plot(out, color = out > out[1] ? greencolor : redcolor, linewidth = 3)
barcolor(colorbars ? out > out[1] ? greencolor : redcolor : na)
|
Jurik Filtered Perfect CCI (PCCI) [Loxx] | https://www.tradingview.com/script/F9k2KLt7-Jurik-Filtered-Perfect-CCI-PCCI-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("Jurik Filtered Perfect CCI (PCCI) [Loxx]",
shorttitle = "JFPCCI [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxfsrrdspfilts/1
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
dspinp = input.string("FATL - Fast Adaptive Trend Line", "Digital Filter Type", options = ["FATL - Fast Adaptive Trend Line", "SATL - Slow Adaptive Trend Line",
"RFTL - Reference Fast Trend Line", "RSTL - Reference Slow Trend Line"], group = "Digital Filter Settings")
src = input.source(hlc3, title="Source", group = "Basic Settings")
jper = input.int(5, title="Jurik Filter Period", group = "Basic Settings")
jphs = input.float(0, title="Jurik Filter Phase", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group= "UI Options")
out =
dspinp == "FATL - Fast Adaptive Trend Line" ? loxxfsrrdspfilts.fatl(src) :
dspinp == "SATL - Slow Adaptive Trend Line" ? loxxfsrrdspfilts.satl(src) :
dspinp == "RFTL - Reference Fast Trend Line" ? loxxfsrrdspfilts.rftl(src) :
loxxfsrrdspfilts.rstl(src)
val = loxxjuriktools.jurik_filt(src - out, jper, jphs)
colorout = val >= 0 ? greencolor : redcolor
val1p = plot(val, color = colorout, linewidth = 2)
zl = plot(0, color = bar_index % 2 ? color.gray : na, linewidth = 2)
barcolor(colorbars ? colorout : na)
fcolorout = val >= 0 ? color.new(greencolor, 90) : color.new(redcolor, 90)
fill(val1p, zl, color = fcolorout) |
HeikinAshi_Point (HA-P) | https://www.tradingview.com/script/dXWFqAu0-HeikinAshi-Point-HA-P/ | readCrypto | https://www.tradingview.com/u/readCrypto/ | 100 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © readCrypto
//@version=5
////////////////////////////////////////////////////////////
indicator(title='HeikinAshi_Point', shorttitle='HA-P', overlay=true)
/////////////////
// Heiken Ashi
srcClose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
srcOpen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
///////////////////////////////
// RSI
A = ta.ema(srcClose - srcClose[1] > 0 ? srcClose - srcClose[1] : 0, 14)
B = ta.ema(srcClose - srcClose[1] < 0 ? math.abs(srcClose - srcClose[1]) : 0, 14)
RS = A / B
rsi10 = 100 - 100 / (1 + RS)
bgcolor(color=rsi10 >= 70 ? color.new(color.maroon, 95) : rsi10 <= 30 ? color.new(color.blue, 95) : color.new(#FFFFFF, 100), title='RSI HA')
HAS = srcClose
HAS := srcClose[2] > srcOpen[2] and srcClose[1] > srcOpen[1] and srcClose[0] < srcOpen[0] and rsi10[2] >= 70 ? srcOpen[2] : HAS[1]
plot(HAS, color=color.new(color.aqua, 50), linewidth=3, style=plot.style_line, title='HA-High')
HAB = srcOpen
HAB := srcClose[2] < srcOpen[2] and srcClose[1] < srcOpen[1] and srcClose[0] > srcOpen[0] and rsi10[2] <= 30 ? srcOpen[2] : HAB[1]
plot(HAB, color=color.new(color.orange, 50), linewidth=3, style=plot.style_line, title='HA-Low') //, trackprice=true
p4 = plot(srcOpen, color=color.new(#FFFFFF, 100), title='H.A.')
p3 = plot(srcClose, color=color.new(#FFFFFF, 100), title='H.A.')
fill(p3, p4, color=srcClose > srcOpen ? color.new(#EF8E59, 50) : color.new(#59D3E3, 50), title='H.A.')
|
Fast and Slow Trend-Line Momentum [Loxx] | https://www.tradingview.com/script/J0xkuX4D-Fast-and-Slow-Trend-Line-Momentum-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("Fast and Slow Trend-Line Momentum [Loxx]",
shorttitle = "FSTLM [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxfsrrdspfilts/1
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
darkGreenColor = #1B7E02
darkRedColor = #93021F
src = input.source(close, title="Source", group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group= "UI Options")
FTLM = loxxfsrrdspfilts.fatl(src) - loxxfsrrdspfilts.rftl(src)
STLM = loxxfsrrdspfilts.satl(src) - loxxfsrrdspfilts.rstl(src)
coloroutf = FTLM >= 0 ? greencolor : redcolor
coloroutfs = STLM >= 0 ? greencolor : redcolor
zl = plot(0, color = bar_index % 2 ? color.gray : na)
outst = plot(STLM, color = coloroutfs, linewidth = 1)
outft = plot(FTLM, color = color.white, linewidth = 2)
fill(outft, zl, color = color.new(color.white, 70))
fill(outst, zl, color = color.new(coloroutfs, 80))
barcolor(colorbars ? coloroutf : na)
|
MTF CCI Bar | https://www.tradingview.com/script/CMtdAs5R/ | FX_masa | https://www.tradingview.com/u/FX_masa/ | 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/
// © FX_masa
//@version=5
indicator(title="MTF CCI Bar", overlay=false)
mtf = input.timeframe(defval="", title="MTF")
src = input(hlc3, title="Source")
cciPeriod = input.int(defval=20, title='CCI Period')
cci = ta.cci(src, cciPeriod)
mtfCCI = request.security(syminfo.tickerid, mtf, cci)
p = plot(0, color=color.new(color.gray, 0), editable=false)
p1 = plot(1, color=color.new(color.gray, 0), editable=false)
fill(p, p1, color=0 <= mtfCCI ? color.new(color.green, 0) : color.new(color.red, 0), title='CCI color') |
intraday barcount | https://www.tradingview.com/script/Nanc7g6M-intraday-barcount/ | avsr90 | https://www.tradingview.com/u/avsr90/ | 16 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © avsr90
//@version=5
indicator(title="intraday barcount ",overlay=true,max_bars_back=5000)
resSymtickerid=input.timeframe(defval="",title="ticker id resolution")
resSymtickeridOpen=input.timeframe(defval="D",title="open resolution")
openSymtickerid= request.security(syminfo.tickerid ,resSymtickeridOpen, close[1],barmerge.gaps_off, barmerge.lookahead_on)
closeSymtickerid= request.security(syminfo.tickerid ,resSymtickerid, close,barmerge.gaps_off, barmerge.lookahead_on)
condBarssince= ta.change(openSymtickerid)
LengthBars=int(math.max(1, nz(ta.barssince(condBarssince)) + 1))
Intra_bars_count() =>
openSymtickerid= request.security(syminfo.tickerid ,resSymtickeridOpen, close[1],barmerge.gaps_off, barmerge.lookahead_on)
closeSymtickerid= request.security(syminfo.tickerid ,resSymtickerid, close,barmerge.gaps_off, barmerge.lookahead_on)
condBarssince= ta.change(openSymtickerid)
LengthBars=int(math.max(1, nz(ta.barssince(condBarssince)) + 1))
greenBars = 0.00
redBars = 0.00
for i=1 to LengthBars
if ( close[i]>open[i])
greenBars:= greenBars+1
if not (close[i] > open[i])
redBars := redBars +1
[greenBars,redBars]
[greenB, redB] = Intra_bars_count()
difBars=greenB-redB
difPer=math.round_to_mintick((difBars/LengthBars)*100)
Op_Cl=math.round_to_mintick(closeSymtickerid-openSymtickerid)
plot(openSymtickerid,title="Open Intra day")
//Table
BT = 0
TW = 0
TH=0
TL = input.string("bottom_center", title='Select Table Position',options=["top_left","top_center","top_right",
"middle_left","middle_center","middle_right","bottom_left","bottom_center","bottom_right"] ,
tooltip="Default location is at bottom_center")
//RoundingPrecision = input.int(title='Indicator Rounding Precision', defval=2, minval=0, maxval=5)
TS = input.string("Auto", title='Select Table Text Size',options=["Auto","Huge","Large","Normal","Small",
"Tiny"] , tooltip="Default Text Size is Auto")
assignedposition = switch TL
"top_left" => position.top_left
"top_center" => position.top_center
"top_right" => position.top_right
"middle_left" => position.middle_left
"middle_center" => position.middle_center
"middle_right" => position.middle_right
"bottom_left" => position.bottom_left
"bottom_center" => position.bottom_center
"bottom_right" => position.bottom_right
celltextsize = switch TS
"Auto" => size.auto
"Huge" => size.huge
"Large" => size.large
"Normal" => size.normal
"Small" => size.small
"Tiny" => size.tiny
var table i = table.new (assignedposition,15, 9, color.yellow,border_width=BT)
if barstate.islast
table.cell(i, 1, 1, "INTRA DAY ",text_size=celltextsize,width=TW,height=TH,bgcolor=color.green)
table.cell(i, 2, 1, "NUMBER OF",text_size=celltextsize,width=TW,height=TH,bgcolor=color.green)
table.cell(i, 3, 1, "BARS AFTER",text_size=celltextsize,width=TW,height=TH,bgcolor=color.green)
table.cell(i, 4, 1, "DAY OPEN",text_size=celltextsize,width=TW,height=TH,bgcolor=color.green)
table.cell(i, 5, 1, " ",text_size=celltextsize,width=TW,height=TH,bgcolor=color.green)
table.cell(i, 6, 1, " ",text_size=celltextsize,width=TW,height=TH,bgcolor=color.green)
table.cell(i, 1, 2, "TotalBars",text_size=celltextsize,width=TW,height=TH,bgcolor=color.red)
table.cell(i, 2, 2, "GreenBars",text_size=celltextsize, width=TW,height=TH,bgcolor=color.red)
table.cell(i, 3, 2, "RedBars",text_size=celltextsize, width=TW,height=TH,bgcolor=color.red)
table.cell(i, 4, 2, "Difference",text_size=celltextsize, width=TW,height=TH,bgcolor=color.red)
table.cell(i, 5, 2, "%DifTotBars",text_size=celltextsize, width=TW,height=TH,bgcolor=color.red)
table.cell(i, 6, 2, "Open-Close",text_size=celltextsize, width=TW,height=TH,bgcolor=color.red)
table.cell(i, 1, 3, str.tostring(LengthBars) ,text_size=celltextsize, width=TW,height=TH)
table.cell(i, 2, 3, str.tostring(greenB) ,text_size=celltextsize, width=TW,text_color= color.green,height=TH)
table.cell(i, 3, 3, str.tostring(redB),text_size=celltextsize, width=TW,text_color=color.red,height=TH)
table.cell(i, 4, 3, str.tostring(difBars),text_size=celltextsize, width=TW,text_color=greenB>redB ?
color.green:color.red,height=TH)
table.cell(i, 5, 3, str.tostring(difPer),text_size=celltextsize, width=TW,text_color=greenB>redB ?
color.green:color.red,height=TH)
table.cell(i, 6, 3, str.tostring(Op_Cl),text_size=celltextsize, width=TW,text_color=Op_Cl>0 ?
color.green:color.red,height=TH)
|
Phase-Accumulation Adaptive RSX w/ Expanded Source Types [Loxx] | https://www.tradingview.com/script/V9iKMpIq-Phase-Accumulation-Adaptive-RSX-w-Expanded-Source-Types-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 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/
// © loxx
//@version=5
indicator(title="Phase-Accumulation Adaptive RSX w/ Expanded Source Types [Loxx]", shorttitle="PAARSXEST [Loxx]", overlay=false, max_bars_back = 3000)
import loxx/loxxexpandedsourcetypes/3
import loxx/loxxrsx/1
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
calcComp(src, period)=>
out = (
(0.0962 * src +
0.5769 * src[2] -
0.5769 * src[4] -
0.0962 * src[6]) * (0.075 * src[1] + 0.54))
out
_prout(src, mult, filt)=>
Smooth = 0., Detrender = 0.
I1 = 0., Q1 = 0., Period = 0., DeltaPhase = 0., InstPeriod = 0.
PhaseSum = 0., Phase = 0., _period = 0.
Smooth := bar_index > 5 ? (4 * src + 3 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 10 : Smooth
ts = calcComp(Smooth, Period)
Detrender := bar_index > 5 ? ts : Detrender
qs = calcComp(Detrender, Period)
Q1 := bar_index > 5 ? qs : Q1
I1 := bar_index > 5 ? nz(Detrender[3]) : I1
I1 := .15 * I1 + .85 * nz(I1[1])
Q1 := .15 * Q1 + .85 * nz(Q1[1])
Phase := nz(Phase[1])
Phase := math.abs(I1) > 0 ? 180.0 / math.pi * math.atan(math.abs(Q1 / I1)) : Phase
Phase := I1 < 0 and Q1 > 0 ? 180 - Phase : Phase
Phase := I1 < 0 and Q1 < 0 ? 180 + Phase : Phase
Phase := I1 > 0 and Q1 < 0 ? 360 - Phase : Phase
DeltaPhase := nz(Phase[1]) - Phase
DeltaPhase := nz(Phase[1]) < 90 and Phase > 270 ? 360 + nz(Phase[1]) - Phase : DeltaPhase
DeltaPhase := math.max(math.min(DeltaPhase, 60), 7)
InstPeriod := nz(InstPeriod[1])
PhaseSum := 0
count = 0
while (PhaseSum < mult * 360 and count < 4500)
PhaseSum += nz(DeltaPhase[count])
count := count + 1
InstPeriod := count > 0 ? count : InstPeriod
alpha = 2.0 / (1.0 + math.max(filt, 1))
_period := nz(_period[1]) + alpha * (InstPeriod - nz(_period[1]))
_period := math.floor(_period) < 1 ? 1 : math.floor(_period)
math.floor(_period)
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Basic Settings")
srcoption = 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)"])
regcycles = input.float(1, title = "EMA PA Cycles", group= "Basic Settings")
regfilter = input.float(0, title = "EMA PA Filter", group= "Basic Settings")
kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
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
int fout = math.floor(_prout(src, regcycles, regfilter))
val = loxxrsx.rsx(src, fout)
colorout = val > val[2] ? greencolor : val < val[2] ? redcolor : color.gray
plot(50, color = bar_index % 2 ? color.gray : na)
plot(val, color = colorout, linewidth = 2)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(val, val[1])
goShort = ta.crossunder(val, val[1])
alertcondition(goLong, title = "Long", message = "Phase Accumulation, EMA w/ Expanded Source Types [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "Phase Accumulation, EMA w/ Expanded Source Types [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Goertzel Cycle Period [Loxx] | https://www.tradingview.com/script/7a2NbfBL-Goertzel-Cycle-Period-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
//@description Goertzel algorithm to extract cycle periods for use in adaptive indicators see:https://en.wikipedia.org/wiki/Goertzel_algorithm
indicator("Goertzel Cycle Period [Loxx]", overlay = false, shorttitle="GCP [Loxx]", timeframe="", timeframe_gaps=true, max_bars_back = 3000)
//@function Extract cycle period using Goertzel Algorithm
//@param src, float, source of cycle data to be extracted.
//@param per, int, maximum look back window
//@returns int, Goertzel Cycle pereiod
_goertzel_cycle_period(float src, int per)=>
float[] goeWork1 = array.new_float(per * 3, 0.) //Power array
float[] goeWork2 = array.new_float(per * 3, 0.) //Theta array
float[] goeWork3 = array.new_float(per * 3, 0.) //Store cylces
float[] goeWork4 = array.new_float(per * 3, 0.) //Store ingest values
float temp1 = nz(src[3 * per - 1]) //get first bar for calculation
float temp2 = (src - temp1) / (3 * per - 1) // Real
float temp3 = 0. //Imaginary
for k = 3 * per - 1 to 1
float temp = src[k - 1] - (temp1 + temp2 * (3 * per - k))
array.set(goeWork4, k, temp)
array.set(goeWork3, k, 0.)
for k = 2 to per
float w = 0., float x = 0., float y = 0.
float z = math.pow(k, -1)
temp1 := 2.0 * math.cos(2.0 * math.pi * z)
//The first stage calculates an intermediate sequence, s[n]
for i = 3 * per-1 to 1
w := temp1 * x - y + nz(array.get(goeWork4, i))
y := x
x := w
// The second stage applies the following filter to y[n]
// 1. The first filter stage can be observed to be a second-order IIR filter with a direct-form structure TBD
// 2. The second-stage filter can be observed to be a FIR filter, since its calculations do not use any of its past outputs. TBD
// calculate Real component
temp2 := x - y / 2.0 * temp1
if (temp2 == 0.0)
temp2 := 0.0000001
// calculate Imaginary component
temp3 := y * math.sin(2.0 * math.pi * z)
// calculate Power
array.set(goeWork1, k, math.pow(temp2, 2) + math.pow(temp3, 2))
// calculate Theta
array.set(goeWork2, k, math.atan(temp3 / temp2))
if (temp2 < 0.0)
array.set(goeWork2, k, nz(array.get(goeWork2, k)) + math.pi)
else
if (temp3 < 0.0)
array.set(goeWork2, k, nz(array.get(goeWork2, k)) + 2.0 * math.pi)
// Parse cycles
for k = 3 to per - 1
if (nz(array.get(goeWork1, k)) > nz(array.get(goeWork1, k + 1)) and nz(array.get(goeWork1, k)) > nz(array.get(goeWork1, k-1)))
array.set(goeWork3, k, k * math.pow(10, -4))
else
array.set(goeWork3, k, 0.0)
// count cycles
int number_of_cycles = 0
for i = 0 to per + 1
if (nz(array.get(goeWork3, i)) > 0.0)
number_of_cycles := number_of_cycles + 1
number_of_cycles
src = input.source(close, "Source", group = "Basic Settings")
per = input.int(120, "Max Period", group = "Basic Settings")
cperout = _goertzel_cycle_period(src, per)
cperout := cperout < 1 ? 1 : cperout
plot(cperout, color = color.white, linewidth = 2)
|
Probability Density Function based MA MACD [Loxx] | https://www.tradingview.com/script/LEkdevxl-Probability-Density-Function-based-MA-MACD-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("Probability Density Function based MA MACD [Loxx]",
shorttitle="PDFMAMACD [Loxx]", overlay=false, max_bars_back = 3000)
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
src = input.source(close, "Source", group = "Basic Settings")
fper = input.int(12, "Fast Period", group = "Basic Settings")
sper = input.int(26, "Slow Period", group = "Basic Settings")
sigper = input.int(9, "Signal Period", group = "Basic Settings")
vari = input.float(1, "Variance", step = 0.1, minval = 0.1, group = "Basic Settings")
mean = input.float(1, "Mean", step = 0.1, minval = -1, maxval = 1, group = "Basic Settings")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
_pdf(_x, _variance, _mean)=>
out =
(1.0 / math.sqrt(2 * math.pi * _variance * _variance) *
math.exp(-((_x - _mean) * (_x - _mean)) / (2 * _variance * _variance)))
out
_pdfma(src, period, variance, mean)=>
maxx = 3.5
step = maxx / (period - 1)
m_coeffw = 0.
m_coeffs = array.new_float(period, 0.)
for k = 0 to period - 1
array.set(m_coeffs, k, _pdf(k * step, variance, mean * maxx))
m_coeffw += array.get(m_coeffs, k)
pern = period
_avg = 0.
for k = 0 to period - 1
if (pern < 0)
pern += period
_avg += nz(src[pern]) * nz(array.get(m_coeffs, k))
pern := pern -1
out = _avg / m_coeffw
out
fasma = _pdfma(src, fper, vari, mean)
sloma = _pdfma(src, sper, vari, mean)
macd = fasma-sloma
signal= _pdfma(macd, sigper, vari, mean)
colorout =
macd > signal and macd > 0 ? greencolor :
macd < signal and macd > 0 ? lightgreencolor :
macd < signal and macd < 0 ? redcolor :
macd > signal and macd < 0 ? lightredcolor :
color.gray
plot(signal, color = color.new(color.gray, 10), style = plot.style_histogram)
plot(macd, color = colorout, linewidth = 2)
barcolor(colorbars ? colorout : na)
|
JG RSI/MFI/divergence Indicator | https://www.tradingview.com/script/SYArUT5X-JG-RSI-MFI-divergence-Indicator/ | jrgoodland | https://www.tradingview.com/u/jrgoodland/ | 95 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jrgoodland
//@version=5
indicator(title="JG RSI/MFI/divergence Indicator", shorttitle="JG RSI/MFI/divs", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
// RSI //
rsilen = input.int(14, minval=1, title="Length")
rsisrc = input(close, "Source")
rsiup = ta.rma(math.max(ta.change(rsisrc), 0), rsilen)
rsidown = ta.rma(-math.min(ta.change(rsisrc), 0), rsilen)
rsi = rsidown == 0 ? 100 : rsiup == 0 ? 0 : 100 - (100 / (1 + rsiup / rsidown))
plot(rsi, "RSI", color=#F1F1F1, linewidth=2)
// Band //
band3 = hline(90, "Lower Band", color=#787B86, linestyle=hline.style_dashed)
band1 = hline(70, "Upper Band", color=#787B86, linestyle=hline.style_solid)
bandm = hline(50, "Middle Band", color=color.new(#787B86, 50))
band0 = hline(30, "Lower Band", color=#787B86, linestyle=hline.style_solid)
//band2 = hline(10, "Lower Band", color=#787B86, linestyle=hline.style_dashed)
fill(band1, band0, color=color.new(#f1f1f1, 93), title="Background")
// MFI //
length = input.int(title="Length", defval=14, minval=1, maxval=2000)
src = hlc3
mf = ta.mfi(src, length)
plot(mf, "MF", color=color.new(#4CAF50, 30), linewidth=2)
len = input.int(title="RSI Period", minval=1, defval=14)
divsrc = input(title="RSI Source", defval=close)
lbR = input(title="Pivot Lookback Right", defval=5)
lbL = input(title="Pivot Lookback Left", defval=5)
rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)
plotBull = input(title="Plot Bullish", defval=true)
plotHiddenBull = input(title="Plot Hidden Bullish", defval=true)
plotBear = input(title="Plot Bearish", defval=true)
plotHiddenBear = input(title="Plot Hidden Bearish", defval=true)
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 25)
hiddenBearColor = color.new(color.red, 25)
textColor = color.black
hiddenTextColor = color.black
noneColor = color.new(color.white, 100)
osc = ta.rsi(divsrc, len)
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=" Bull ",
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 Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=hiddenTextColor
)
//------------------------------------------------------------------------------
// 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=" Bear ",
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 Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=hiddenTextColor
) |
Defi Davinci Cheat Code | https://www.tradingview.com/script/R5bIbe1z-Defi-Davinci-Cheat-Code/ | JonathanHill19 | https://www.tradingview.com/u/JonathanHill19/ | 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/
// © JonathanHill19
//@version=5
indicator("Defi Davinci Cheat Code", overlay=true)
//Moving Averages
lengthema1 = input.int(50, "First MA Length", minval = 1)
lengthema2 = input.int(100, "2nd MA Length", minval =1)
ma = ta.ema(close, lengthema1)
ma2 = ta.ema(close, lengthema2)
plot(ma, "First MA", color=color.red)
plot(ma2, "Second MA", color=color.purple)
//BUY SELL SIGNAL
boxp = input (title="Signal Length", defval=25)
LL = ta.lowest(low, boxp)
k1 = ta.highest(high, boxp)
k2 = ta.highest(high, boxp - 1)
k3 = ta.highest(high, boxp - 2)
NH = ta.valuewhen(high > k1[1], high, 0)
box1 = k3 < k2
TopBox = ta.valuewhen(ta.barssince(high > k1[1]) == boxp - 2 and box1, NH, 0)
BottomBox = ta.valuewhen(ta.barssince(high > k1[1]) == boxp - 2 and box1, LL, 0)
plot(TopBox, linewidth=1, color=color.purple, title="Resistance")
plot(BottomBox, linewidth=1, color=color.black, title="Support")
Buy = ta.crossover(close, TopBox)
Sell = ta.crossunder(close, BottomBox)
alertcondition(Buy, title="Buy Signal", message="Buy")
alertcondition(Sell, title="Sell Signal", message="Sell")
plotshape(Buy, style=shape.labelup, location=location.belowbar, color=color.red, size=size.tiny, title="Buy Signal", text="Buy", textcolor=color.white)
plotshape(Sell, style=shape.labeldown, location=location.abovebar, color=color.purple, size=size.tiny, title="Sell Signal", text="Sell", textcolor=color.white)
//Lot Size Calculator
iBalance = input.float(2000, "Balance (USD)", minval = 0)
iRiskPercent = input.float(2, "Risk Percentage (%)", minval = 0)
iSLPipSize = input.float(12.5, "Stop Loss Pip Size (Pip)", minval = 0)
// Get exRate with USD
currency = "USD" == syminfo.currency ? "" : "USD"+syminfo.currency
exRate = "USD" == syminfo.currency ? 1 : request.security(currency, timeframe.period, close)
// Calculate lot size
exRateFlPoint = "JPY" == syminfo.currency ? 0.01 : 0.0001
lotSize = ((iBalance * (iRiskPercent/100) * exRate) / (iSLPipSize * exRateFlPoint)) / 100000
// Result text
resultLabelText = "Lot Size: " + str.tostring(lotSize, '#.##')
var resultLabel = label.new(
x=na,
y=na,
text="Lot Size Calculator",
textalign=text.align_center,
textcolor=color.black,
color=color.black,
style=label.style_label_left,
size=size.normal,
xloc = xloc.bar_index,
yloc = yloc.belowbar
)
//label.set_text(resultLabel, tostring(resultLabelText))
label.set_text(resultLabel, resultLabelText)
label.set_x(resultLabel, 0)
label.set_xloc(resultLabel, time, xloc.bar_time)
label.set_color(resultLabel, color.white)
label.set_size(resultLabel, size.normal)
|
Magnifying Glass (LTF Candles) by SiddWolf | https://www.tradingview.com/script/EImYMcxS-Magnifying-Glass-LTF-Candles-by-SiddWolf/ | SiddWolf | https://www.tradingview.com/u/SiddWolf/ | 287 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SiddWolf
//@version=5
indicator(title="Magnifying Glass (LTF Candles) by SiddWolf", shorttitle="Magnifying Glass 🔎 [SW]", overlay=false, max_labels_count=491)
candle_body = input.string(defval="🟩 🟥", title="Candle Body: ", options=["🟩 🟥", "🟢 🔴", "🔵 🟡", "🍏 🍎", "⚪ ⚪"], inline="candle_settings", group="Candle & Volume Settings")
bullish_candle = candle_body=="🟩 🟥"? "🟩" : candle_body=="🟢 🔴"? "🟢" : candle_body=="🔵 🟡"? "🔵" : candle_body=="🍏 🍎"? "🍏" : candle_body=="⚪ ⚪"? "⚪" : "🟩"
bearish_candle = candle_body=="🟩 🟥"? "🟥" : candle_body=="🟢 🔴"? "🔴" : candle_body=="🔵 🟡"? "🟡" : candle_body=="🍏 🍎"? "🍎" : candle_body=="⚪ ⚪"? "⚪" : "🟥"
highlight_oc = input.bool(defval=true, title="HighLight Open(🇴) Close(🇨)", group="Candle & Volume Settings")
volume_settings_tooltip = "➡️ Volume Color:\n\n✅ Yellow shades at the bottom represents intensity of volume.\n✅ You can change these colors on the basis of your preference.\n✅ \"Dark for High Volume, Light for Low Volume\":\n 🏿 = Highest Volume, 🏻 = Lowest Volume\n✅ \"Light for High Volume, Dark for Low Volume\":\n 🏻 = Highest Volume, 🏿 = Lowest Volume\n\n✅ Lower TimeFrame Candle's volume is also ranked, where 1 represents Highest Volume Traded and ranked in descending order"
vol_color_setting_a = "Dark for High Volume, Light for Low Volume"
vol_color_setting_b = "Light for High Volume, Dark for Low Volume"
high_vol_dark = input.string(defval=vol_color_setting_a, title="Volume Color", options=[vol_color_setting_a, vol_color_setting_b], inline="vol_settings", group="Candle & Volume Settings", tooltip=volume_settings_tooltip)
label_settings_tooltip = "➡️ Lables Settings:\n\n✅ Up: Label Color for Bullish Candles.\n✅ Down: Label Color for Bearish Candles.\n✅ Size: Label Size\n\n✅ A reminder: Move the Magnifying Glass indicator above chart and shrink it all the way up for best visual experience."
label_color_up_input = input.color(color.new(color.green, 60), title="Up", inline="Label Settings", group="Label Settings")
label_color_down_input = input.color(color.new(color.red, 60), title="Down", inline="Label Settings", group="Label Settings")
label_size_input = input.string(defval="Small", title="Size", options=["Tiny", "Small", "Big"], inline="Label Settings", group="Label Settings", tooltip=label_settings_tooltip)
mins_1 ="1 Min", mins_2 = "2 Mins", mins_3 = "3 Mins", mins_4 = "4 Mins", mins_5 = "5 Mins", mins_10 = "10 Mins", mins_15 = "15 Mins", mins_30 = "30 Mins", mins_45 = "45 Mins", mins_90 = "90 Mins", hrs_1 = "1 Hr", hrs_2 = "2 Hrs", hrs_3 = "3 Hrs", hrs_4 = "4 Hrs", hrs_6 = "6 Hrs", hrs_12 = "12 Hrs", days_1 = "1 Day", days_2 = "2 Days", weeks_1 = "1 Week", months_1 = "1 Month", months_2 = "2 Months", months_3 = "3 Months", mins_30_stocks = "30 Mins (Only for Stocks)", hrs_1_stocks = "1 Hr (Only for Stocks)"
show_special_tooltip = "➡️ Lower TimeFrame Resolution Settings:\n\n ✅ It is HIGHLY RECOMMENDED that you use One on these chart TimeFrames (given below), with Magnifying Glass indicator. The default ltf timeframe for each chart timeframe is given below. You can change it, as per your requirements.\n✅ This indicator plots Candles from Lower TimeFrame automatically. \n\n✅ This indicator magnifies candles upto 16x (due to label's limitation). For example if the Chart TimeFrame is 4 hours or 240 minutes, This value should be higher than 240/16 = 15. That means you can plot Lower timeframe candles of 15 minutes, 30 minutes, 60 minutes or 120 minutes in 4 hours chart.\n✅ Read Indicator Description for more details.\n✅ Don't forget to \"Save as Default\" when you change below ltf to save changes."
show_special = input.bool(true, title="Special LTF Settings", tooltip=show_special_tooltip, group="Lower TimeFrame Settings")
m_15_input = input.string(defval=mins_1, title="2 Minutes to 15 minutes", options=[mins_1, mins_2, mins_3, mins_5], group="Lower TimeFrame Settings")
m_30_input = input.string(defval=mins_2, title="16 Minutes to 30 Minutes Chart", options=[mins_2, mins_3, mins_5, mins_10, mins_15], group="Lower TimeFrame Settings")
m_60_input = input.string(defval=mins_5, title="1 Hour Chart", options=[mins_4, mins_5, mins_10, mins_15, mins_30], group="Lower TimeFrame Settings")
m_120_input = input.string(defval=mins_15, title="2 Hours Chart", options=[mins_10, mins_15, mins_30, hrs_1], group="Lower TimeFrame Settings")
m_240_input = input.string(defval=mins_15, title="4 Hours Chart", options=[mins_15, mins_30, hrs_1, hrs_2], group="Lower TimeFrame Settings")
m_360_input = input.string(defval=mins_30, title="6 Hours Chart", options=[mins_30, hrs_1, hrs_2], group="Lower TimeFrame Settings")
m_480_input = input.string(defval=mins_30, title="8 Hours Chart", options=[mins_30, hrs_1, hrs_2, hrs_4], group="Lower TimeFrame Settings")
m_720_input = input.string(defval=hrs_1, title="12 Hours Chart", options=[mins_45, hrs_1, hrs_2, hrs_4], group="Lower TimeFrame Settings")
d_1_input = input.string(defval=hrs_2, title="1 Day Chart", options=[mins_30_stocks, hrs_1_stocks, mins_90, hrs_2, hrs_4, hrs_6, hrs_12], tooltip="30 Minutes and 1 hour LTF Candle only works with stocks or indices that are traded less than 7 hours in a day", group="Lower TimeFrame Settings")
d_2_input = input.string(defval=hrs_4, title="2 Days Chart", options=[hrs_3, hrs_4, hrs_6, hrs_12, days_1], group="Lower TimeFrame Settings")
w_1_input = input.string(defval=hrs_12, title="1 Week Chart", options=[hrs_12, days_1], group="Lower TimeFrame Settings")
w_2_input = input.string(defval=days_1, title="2 Weeks Chart", options=[days_1, days_2], group="Lower TimeFrame Settings")
M_1_input = input.string(defval=days_2, title="1 Month Chart", options=[days_2, weeks_1], group="Lower TimeFrame Settings")
M_3_input = input.string(defval=weeks_1, title="3 Months Chart", options=[weeks_1, months_1], group="Lower TimeFrame Settings")
M_6_input = input.string(defval=months_1, title="6 Months Chart", options=[months_1, months_2, months_3], group="Lower TimeFrame Settings")
M_12_input = input.string(defval=months_1, title="12 Months Chart", options=[months_1, months_2, months_3], group="Lower TimeFrame Settings")
tf_mult = timeframe.multiplier
ltfStep_intraday() =>
string result =
switch
tf_mult <= 16 => "1"
tf_mult <= 32 => "2"
tf_mult <= 48 => "3"
tf_mult <= 64 => "4"
tf_mult <= 80 => "5"
tf_mult <= 160 => "10"
tf_mult <= 240 => "15"
tf_mult <= 480 => "30"
tf_mult <= 960 => "60"
tf_mult <= 1440 => "120"
special_tf_str(input_str) =>
string result =
switch
input_str == mins_1 => "1"
input_str == mins_2 => "2"
input_str == mins_3 => "3"
input_str == mins_4 => "4"
input_str == mins_5 => "5"
input_str == mins_10 => "10"
input_str == mins_15 => "15"
input_str == mins_30 or input_str == mins_30_stocks => "30"
input_str == mins_45 => "45"
input_str == mins_90 => "90"
input_str == hrs_1 or input_str == hrs_1_stocks => "60"
input_str == hrs_2 => "120"
input_str == hrs_3 => "180"
input_str == hrs_4 => "240"
input_str == hrs_6 => "360"
input_str == hrs_12 => "720"
input_str == days_1 => "1D"
input_str == days_2 => "2D"
input_str == weeks_1 => "1W"
input_str == months_1 => "1M"
input_str == months_2 => "2M"
input_str == months_3 => "3M"
ltfStep_special() =>
string result =
switch
timeframe.isintraday and tf_mult <= 15 => special_tf_str(m_15_input)
timeframe.isintraday and tf_mult <= 30 => special_tf_str(m_30_input)
timeframe.isintraday and tf_mult==60 => special_tf_str(m_60_input)
timeframe.isintraday and tf_mult==120 => special_tf_str(m_120_input)
timeframe.isintraday and tf_mult==240 => special_tf_str(m_240_input)
timeframe.isintraday and tf_mult==360 => special_tf_str(m_360_input)
timeframe.isintraday and tf_mult==480 => special_tf_str(m_480_input)
timeframe.isintraday and tf_mult==720 => special_tf_str(m_720_input)
(timeframe.isdaily and tf_mult == 1) or (timeframe.isintraday and tf_mult == 1440) == 1 => special_tf_str(d_1_input)
timeframe.isdaily and tf_mult == 2 => special_tf_str(d_2_input)
(timeframe.isdaily and tf_mult == 7) or (timeframe.isweekly and tf_mult == 1) => special_tf_str(w_1_input)
timeframe.isweekly and tf_mult == 2 => special_tf_str(w_2_input)
timeframe.ismonthly and tf_mult == 1 => special_tf_str(M_1_input)
timeframe.ismonthly and tf_mult == 3 => special_tf_str(M_3_input)
timeframe.ismonthly and tf_mult == 6 => special_tf_str(M_6_input)
timeframe.ismonthly and tf_mult == 12 => special_tf_str(M_12_input)
ltf_special_ret_val = ltfStep_special()
var string sidd_reso_var = show_special and ltf_special_ret_val!=""? ltf_special_ret_val : timeframe.isintraday ? ltfStep_intraday() : ""
ltf_res = str.tonumber(sidd_reso_var)
sidd_matrix = matrix.new<string>(22, 19, "⬛")
[ret_open_arr, ret_high_arr, ret_low_arr, ret_close_arr, ret_volume_arr] = request.security_lower_tf(syminfo.tickerid, sidd_reso_var, [open, high, low, close, volume])
main_candle_high = high
main_candle_low = low
main_candle_volume = volume
main_candle_range = main_candle_high-main_candle_low
close_arr_size = array.size(ret_close_arr)
if close_arr_size>16 and (d_1_input==mins_30_stocks or d_1_input==hrs_1_stocks)
runtime.error("30 Minutes and 1 Hours LTF candle in a daily chart only works for the securities that are traded 7 hours or less. Change TimeFrame in Settings")
for j=0 to 19
matrix.set(sidd_matrix, j, 1, highlight_oc ? " " : "")
matrix.set(sidd_matrix, j, close_arr_size-1+3, "")
matrix.set(sidd_matrix, 20, 0, "🇸")
matrix.set(sidd_matrix, 20, 1, highlight_oc ? " 🇮" : "")
matrix.set(sidd_matrix, 21, 0, "🇩")
matrix.set(sidd_matrix, 21, 1, highlight_oc ? " 🇩" : "")
matrix.set(sidd_matrix, 20, close_arr_size-1+3, " ")
matrix.set(sidd_matrix, 21, close_arr_size-1+3, " ")
if close_arr_size>0
for i = 0 to close_arr_size-1
open_ltf_candle = array.get(ret_open_arr, i)
high_ltf_candle = array.get(ret_high_arr, i)
low_ltf_candle = array.get(ret_low_arr, i)
close_ltf_candle = array.get(ret_close_arr, i)
pcent_by_5_openee = int(((main_candle_high-open_ltf_candle)/main_candle_range)*20)
pcent_by_5_openee := pcent_by_5_openee<1 ? 0 : pcent_by_5_openee>19 ? 19 : pcent_by_5_openee
pcent_by_5_highee = int(((main_candle_high-high_ltf_candle)/main_candle_range)*20)
pcent_by_5_highee := pcent_by_5_highee<1 ? 0 : pcent_by_5_highee>19 ? 19 : pcent_by_5_highee
pcent_by_5_lowee = int(((main_candle_high-low_ltf_candle)/main_candle_range)*20)
pcent_by_5_lowee := pcent_by_5_lowee<1 ? 0 : pcent_by_5_lowee>19 ? 19 : pcent_by_5_lowee
pcent_by_5_closeee = int(((main_candle_high-close_ltf_candle)/main_candle_range)*20)
pcent_by_5_closeee := pcent_by_5_closeee<1 ? 0 : pcent_by_5_closeee>19 ? 19 : pcent_by_5_closeee
is_green_candle = close_ltf_candle>open_ltf_candle
if i==0
matrix.set(sidd_matrix, pcent_by_5_openee, i+1, highlight_oc ? "🇴 " : "")
if i==close_arr_size-1
matrix.set(sidd_matrix, pcent_by_5_closeee, i+3, highlight_oc ? "🇨" : "")
if is_green_candle
if pcent_by_5_openee != pcent_by_5_closeee
for green_wicks_up = pcent_by_5_closeee to pcent_by_5_highee
matrix.set(sidd_matrix, green_wicks_up, i+2, " │ ")
for green_wicks_down = pcent_by_5_lowee to pcent_by_5_openee
matrix.set(sidd_matrix, green_wicks_down, i+2, " │ ")
for green_candles = pcent_by_5_openee to pcent_by_5_closeee
matrix.set(sidd_matrix, green_candles, i+2, bullish_candle)
else
if pcent_by_5_closeee != pcent_by_5_openee
for red_wicks_up = pcent_by_5_openee to pcent_by_5_highee
matrix.set(sidd_matrix, red_wicks_up, i+2, " │ ")
for red_wicks_down = pcent_by_5_closeee to pcent_by_5_lowee
matrix.set(sidd_matrix, red_wicks_down, i+2, " │ ")
for red_candles = pcent_by_5_closeee to pcent_by_5_openee
matrix.set(sidd_matrix, red_candles, i+2, bearish_candle)
vol_shade_str(rank) =>
string result =
switch
rank==1 => "⒈ "
rank==2 => "⒉ "
rank==3 => "⒊ "
rank==4 => "⒋ "
rank==5 => "⒌ "
rank==6 => "⒍ "
rank==7 => "⒎ "
rank==8 => "⒏ "
rank==9 => "⒐ "
rank==10 => "⒑ "
rank==11 => "⒒ "
rank==12 => "⒓ "
rank==13 => "⒔ "
rank==14 => "⒕ "
rank==15 => "⒖ "
rank==16 => "⒗ "
rank==17 => "⒘ "
rank==18 => "⒙ "
rank==19 => "⒚ "
rank==20 => "⒛ "
volume_arr_size = array.size(ret_volume_arr)
ret_volume_arr_copy = array.copy(ret_volume_arr)
array.sort(ret_volume_arr_copy, order.descending)
if volume_arr_size>0
for i = 0 to volume_arr_size-1
sort_rank = array.indexof(ret_volume_arr_copy, array.get(ret_volume_arr, i))+1
ranknum_str = vol_shade_str(sort_rank)
if i==0
matrix.set(sidd_matrix, 21, i+2, " "+ranknum_str)
else
matrix.set(sidd_matrix, 21, i+2, ranknum_str)
if sort_rank==1
matrix.set(sidd_matrix, 20, i+2, high_vol_dark==vol_color_setting_a ? "🏿" : "🏻")
else if sort_rank>1 and sort_rank<=int(close_arr_size/3)
matrix.set(sidd_matrix, 20, i+2, high_vol_dark==vol_color_setting_a ? "🏾" : "🏼")
else if sort_rank>int(close_arr_size/3) and sort_rank<=int(close_arr_size*2/3)
matrix.set(sidd_matrix, 20, i+2, high_vol_dark==vol_color_setting_a ? "🏽" : "🏽")
else if sort_rank>int(close_arr_size*2/3) and sort_rank<close_arr_size
matrix.set(sidd_matrix, 20, i+2, high_vol_dark==vol_color_setting_a ? "🏼" : "🏾")
else if sort_rank==close_arr_size
matrix.set(sidd_matrix, 20, i+2, high_vol_dark==vol_color_setting_a ? "🏻" : "🏿")
sidd_vol_profile_arr = array.new_float(20)
for i=0 to 19
row_vol_profile = 0.0
if volume_arr_size>0
for j = 0 to volume_arr_size-1
volume_ltf = array.get(ret_volume_arr, j)
matrix_get = matrix.get(sidd_matrix, i, j+2)
if matrix_get==" │ "
row_vol_profile := row_vol_profile+(0.6*volume_ltf)
else if matrix_get!="⬛"
row_vol_profile := row_vol_profile+(1*volume_ltf)
array.set(sidd_vol_profile_arr, i, row_vol_profile)
vol_profile_arr_copy = array.copy(sidd_vol_profile_arr)
array.sort(vol_profile_arr_copy, order.descending)
for i = 0 to 19
sort_rank = array.indexof(vol_profile_arr_copy, array.get(sidd_vol_profile_arr, i))+1
if sort_rank==1
matrix.set(sidd_matrix, i, 0, high_vol_dark==vol_color_setting_a ? "🏿" : "🏻")
else if sort_rank>1 and sort_rank<=int(20/3)
matrix.set(sidd_matrix, i, 0, high_vol_dark==vol_color_setting_a ? "🏾" : "🏼")
else if sort_rank>int(20/3) and sort_rank<=int(20*2/3)
matrix.set(sidd_matrix, i, 0, high_vol_dark==vol_color_setting_a ? "🏽" : "🏽")
else if sort_rank>int(20*2/3) and sort_rank<20
matrix.set(sidd_matrix, i, 0, high_vol_dark==vol_color_setting_a ? "🏼" : "🏾")
else if sort_rank==20
matrix.set(sidd_matrix, i, 0, high_vol_dark==vol_color_setting_a ? "🏻" : "🏿")
sidd_tooltip_str = ""
for i=0 to 21
if close_arr_size>0
for j = 0 to close_arr_size-1+3
matrix_get = matrix.get(sidd_matrix, i, j)
sidd_tooltip_str := sidd_tooltip_str+matrix_get
sidd_tooltip_str := sidd_tooltip_str+"\n"
exact_time_func() =>
string result =
switch
timeframe.isintraday and tf_mult <= 15 => m_15_input
timeframe.isintraday and tf_mult <= 30 => m_30_input
timeframe.isintraday and tf_mult==60 => m_60_input
timeframe.isintraday and tf_mult==120 => m_120_input
timeframe.isintraday and tf_mult==240 => m_240_input
timeframe.isintraday and tf_mult==360 => m_360_input
timeframe.isintraday and tf_mult==480 => m_480_input
timeframe.isintraday and tf_mult==720 => m_720_input
(timeframe.isdaily and tf_mult == 1) or (timeframe.isintraday and tf_mult == 1440) == 1 => (d_1_input==mins_30_stocks ? mins_30 : d_1_input==hrs_1_stocks ? hrs_1 : d_1_input)
timeframe.isdaily and tf_mult == 2 => d_2_input
(timeframe.isdaily and tf_mult == 7) or (timeframe.isweekly and tf_mult == 1) => w_1_input
timeframe.isweekly and tf_mult == 2 => w_2_input
timeframe.ismonthly and tf_mult == 1 => M_1_input
timeframe.ismonthly and tf_mult == 3 => M_3_input
timeframe.ismonthly and tf_mult == 6 => M_6_input
timeframe.ismonthly and tf_mult == 12 => M_12_input
time_exact = exact_time_func()
new_line_or_space = close_arr_size>10? " ": (highlight_oc ? "\n " : "\n ")
main_candle_range_pcent = math.round(((main_candle_high-main_candle_low)/(close>open?main_candle_low:main_candle_high))*100, 2)
wolf_pic = highlight_oc ? " 🐺" : "🐺"
sidd_tooltip_str := sidd_tooltip_str+ wolf_pic +" ✳️ Candle: "+ time_exact + new_line_or_space + "✳️ Range:" + str.tostring(main_candle_range_pcent) + "%"
label_size = label_size_input=="Tiny" ? size.tiny : label_size_input=="Small" ? size.small : size.normal
label_color = close>open ? label_color_up_input : label_color_down_input
label_id = label.new(bar_index, 1, text="", color=label_color, size=label_size, style=label.style_label_down)
label.set_tooltip(label_id, sidd_tooltip_str)
plot(1, style=plot.style_columns, color=label_color)
if (timeframe.isintraday and tf_mult/ltf_res>16) or (timeframe.isdaily and close_arr_size>16) or sidd_reso_var==""
runtime.error("Custom Lower TF Resolution Too Short. Use this indicator with one of the timeframes given in the Indicator Settings and check \"Special LTF Settings\".")
|
ZigZag_Punches_OH_OL | https://www.tradingview.com/script/AIoDJRcu-ZigZag-Punches-OH-OL/ | tomargirwar84 | https://www.tradingview.com/u/tomargirwar84/ | 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/
// © tomargirwar84
//@version=5
indicator("ZigZag_Punches_OH_OL", overlay=true, max_lines_count=500, max_labels_count=500)
dev_threshold = input.float(title="Deviation (%)", defval=5.0, minval=0.00001, maxval=100.0)
depth = input.int(title="Depth", defval=10, minval=1)
line_color = input(title="Line Color", defval=#2962FF)
extend_to_last_bar = input(title="Extend to Last Bar", defval=true)
display_reversal_price = input(title="Display Reversal Price", defval=true)
display_cumulative_volume = input(title="Display Cumulative Volume", defval=true)
display_reversal_price_change = input(title="Display Reversal Price Change", defval=true, inline="price rev")
difference_price = input.string("Absolute", "", options=["Absolute", "Percent"], inline="price rev")
pivots(src, length, isHigh) =>
p = nz(src[length])
if length == 0
[time, p]
else
isFound = true
for i = 0 to math.abs(length - 1)
if isHigh and src[i] > p
isFound := false
if not isHigh and src[i] < p
isFound := false
for i = length + 1 to 2 * length
if isHigh and src[i] >= p
isFound := false
if not isHigh and src[i] <= p
isFound := false
if isFound and length * 2 <= bar_index
[time[length], p]
else
[int(na), float(na)]
[iH, pH] = pivots(high, math.floor(depth / 2), true)
[iL, pL] = pivots(low, math.floor(depth / 2), false)
calc_dev(base_price, price) =>
100 * (price - base_price) / base_price
price_rotation_aggregate(price_rotation, pLast, cum_volume) =>
str = ""
if display_reversal_price
str += str.tostring(pLast, format.mintick) + " "
if display_reversal_price_change
str += price_rotation + " "
if display_cumulative_volume
str += "\n" + cum_volume
str
caption(isHigh, iLast, pLast, price_rotation, cum_volume) =>
price_rotation_str = price_rotation_aggregate(price_rotation, pLast, cum_volume)
if display_reversal_price or display_reversal_price_change or display_cumulative_volume
if not isHigh
label.new(iLast, pLast, text=price_rotation_str, style=label.style_none, xloc=xloc.bar_time, yloc=yloc.belowbar, textcolor=color.red)
else
label.new(iLast, pLast, text=price_rotation_str, style=label.style_none, xloc=xloc.bar_time, yloc=yloc.abovebar, textcolor=color.green)
price_rotation_diff(pLast, price) =>
if display_reversal_price_change
tmp_calc = price - pLast
str = difference_price == "Absolute"? (math.sign(tmp_calc) > 0? "+" : "") + str.tostring(tmp_calc, format.mintick) : (math.sign(tmp_calc) > 0? "+" : "-") + str.tostring((math.abs(tmp_calc) * 100)/pLast, format.percent)
str := "(" + str + ")"
str
else
""
var line lineLast = na
var label labelLast = na
var int iLast = 0
var float pLast = 0
var bool isHighLast = true // otherwise the last pivot is a low pivot
var int linesCount = 0
var float sumVol = 0
var float sumVolLast = 0
pivotFound(dev, isHigh, index, price) =>
if isHighLast == isHigh and not na(lineLast)
// same direction
if isHighLast ? price > pLast : price < pLast
if linesCount <= 1
line.set_xy1(lineLast, index, price)
line.set_xy2(lineLast, index, price)
label.set_xy(labelLast, index, price)
label.set_text(labelLast, price_rotation_aggregate(price_rotation_diff(line.get_y1(lineLast), price), price, str.tostring(sumVol + sumVolLast, format.volume)))
[lineLast, labelLast, isHighLast, false, sumVol + sumVolLast]
else
[line(na), label(na), bool(na), false, float(na)]
else // reverse the direction (or create the very first line)
if na(lineLast)
id = line.new(index, price, index, price, xloc=xloc.bar_time, color=line_color, width=2)
lb = caption(isHigh, index, price, price_rotation_diff(pLast, price), str.tostring(sumVol, format.volume))
[id, lb, isHigh, true, sumVol]
else
// price move is significant
if math.abs(dev) >= dev_threshold
id = line.new(iLast, pLast, index, price, xloc=xloc.bar_time, color=line_color, width=2)
lb = caption(isHigh, index, price, price_rotation_diff(pLast, price), str.tostring(sumVol, format.volume))
[id, lb, isHigh, true, sumVol]
else
[line(na), label(na), bool(na), false, float(na)]
sumVol += nz(volume[math.floor(depth / 2)])
if not na(iH) and not na(iL) and iH == iL
dev1 = calc_dev(pLast, pH)
[id2, lb2, isHigh2, isNew2, sum2] = pivotFound(dev1, true, iH, pH)
if isNew2
linesCount := linesCount + 1
if not na(id2)
lineLast := id2
labelLast := lb2
isHighLast := isHigh2
iLast := iH
pLast := pH
sumVolLast := sum2
sumVol := 0
dev2 = calc_dev(pLast, pL)
[id1, lb1, isHigh1, isNew1, sum1] = pivotFound(dev2, false, iL, pL)
if isNew1
linesCount := linesCount + 1
if not na(id1)
lineLast := id1
labelLast := lb1
isHighLast := isHigh1
iLast := iL
pLast := pL
sumVolLast := sum1
sumVol := 0
else
if not na(iH)
dev1 = calc_dev(pLast, pH)
[id, lb, isHigh, isNew, sum] = pivotFound(dev1, true, iH, pH)
if isNew
linesCount := linesCount + 1
if not na(id)
lineLast := id
labelLast := lb
isHighLast := isHigh
iLast := iH
pLast := pH
sumVolLast := sum
sumVol := 0
else
if not na(iL)
dev2 = calc_dev(pLast, pL)
[id, lb, isHigh, isNew, sum] = pivotFound(dev2, false, iL, pL)
if isNew
linesCount := linesCount + 1
if not na(id)
lineLast := id
labelLast := lb
isHighLast := isHigh
iLast := iL
pLast := pL
sumVolLast := sum
sumVol := 0
var line extend_line = na
var label extend_label = na
if extend_to_last_bar == true and barstate.islast == true
isHighLastPoint = not isHighLast
curSeries = isHighLastPoint ? high : low
if na(extend_line) and na(extend_label)
extend_line := line.new(line.get_x2(lineLast), line.get_y2(lineLast), time, curSeries, xloc=xloc.bar_time, color=line_color, width=2)
extend_label := caption(not isHighLast, time, curSeries, price_rotation_diff(line.get_y2(lineLast), curSeries), str.tostring(sumVol, format.volume))
line.set_xy1(extend_line, line.get_x2(lineLast), line.get_y2(lineLast))
line.set_xy2(extend_line, time, curSeries)
price_rotation = price_rotation_diff(line.get_y1(extend_line), curSeries)
remaingRealTimeVol = 0.
for i = math.abs(math.floor(depth / 2) - 1) to 0
remaingRealTimeVol += volume[i]
label.set_xy(extend_label, time, curSeries)
label.set_text(extend_label, price_rotation_aggregate(price_rotation, curSeries, str.tostring(sumVol+remaingRealTimeVol, format.volume)))
label.set_textcolor(extend_label, isHighLastPoint? color.green : color.red)
label.set_yloc(extend_label, yloc= isHighLastPoint? yloc.abovebar : yloc.belowbar)
bgcolor(high % 10 >= 9.9 ? color.new(color.green, transp=80) : na)
bgcolor(low % 10 >= 9.9 ? color.new(color.green, transp=80) : na)
plotshape(open == high, style = shape.labeldown, location = location.abovebar, color = color.red, text = "O = H", textcolor = color.white)
plotshape(open == low, style = shape.labelup, location = location.belowbar, color = color.green, text = "O = L", textcolor = color.white)
|
Squeeze Momentum Indicator + 2.0 | https://www.tradingview.com/script/bfJpf7gq-Squeeze-Momentum-Indicator-2-0/ | AlmaBuque59 | https://www.tradingview.com/u/AlmaBuque59/ | 80 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OskarGallard
//@version=5
indicator(shorttitle="SQZMOM [+]", title="Squeeze Momentum [Plus]", overlay=false)
// Function to select the type of source
get_src(Type) =>
if Type == "VWAP"
ta.vwap
else if Type == "Close"
close
else if Type == "Open"
open
else if Type == "HL2"
hl2
else if Type == "HLC3"
hlc3
else if Type == "OHLC4"
ohlc4
else if Type == "HLCC4"
hlcc4
else if Type == "Volume"
nz(volume) * (high - low)
else if Type == "High"
high
else if Type == "Low"
low
else if Type == "vwap(Close)"
ta.vwap(close)
else if Type == "vwap(Open)"
ta.vwap(open)
else if Type == "vwap(High)"
ta.vwap(high)
else if Type == "vwap(Low)"
ta.vwap(low)
else if Type == "AVG(vwap(H,L))"
math.avg(ta.vwap(high), ta.vwap(low))
else if Type == "AVG(vwap(O,C))"
math.avg(ta.vwap(open), ta.vwap(close))
else if Type == "OBV" // On Balance Volume
ta.obv
else if Type == "AccDist" // Accumulation Distribution
ta.accdist
else if Type == "PVT" // Price Volume Trend
ta.pvt
// Kaufman's Adaptive Moving Average - Fast and Slow Ends
fastK = 0.666 // KAMA Fast End
slowK = 0.0645 // KAMA Slow End
kama(x, t)=>
dist = math.abs(x[0] - x[1])
signal = math.abs(x - x[t])
noise = math.sum(dist, t)
effr = noise != 0 ? signal/noise : 1
sc = math.pow(effr*(fastK - slowK) + slowK,2)
KAMA = x
KAMA := nz(KAMA[1]) + sc*(x - nz(KAMA[1]))
KAMA
// Jurik Moving Average of @everget
jma(src, length, power, phase) =>
phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5
beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)
alpha = math.pow(beta, power)
JMA = 0.0
e0 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 = 0.0
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(JMA[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
JMA := e2 + nz(JMA[1])
JMA
cti(sm, src, cd) =>
di = (sm - 1.0) / 2.0 + 1.0
c1 = 2 / (di + 1.0)
c2 = 1 - c1
c3 = 3.0 * (cd * cd + cd * cd * cd)
c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
i1 = 0.0
i2 = 0.0
i3 = 0.0
i4 = 0.0
i5 = 0.0
i6 = 0.0
i1 := c1*src + c2*nz(i1[1])
i2 := c1*i1 + c2*nz(i2[1])
i3 := c1*i2 + c2*nz(i3[1])
i4 := c1*i3 + c2*nz(i4[1])
i5 := c1*i4 + c2*nz(i5[1])
i6 := c1*i5 + c2*nz(i6[1])
bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3)
bfr
a = 0.618
T3ma(src,Len) =>
e1 = ta.ema(src, Len)
e2 = ta.ema(e1, Len)
e3 = ta.ema(e2, Len)
e4 = ta.ema(e3, Len)
e5 = ta.ema(e4, Len)
e6 = ta.ema(e5, Len)
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
C1*e6+C2*e5+C3*e4+C4*e3
VIDYA(src,Len) =>
mom = ta.change(src)
upSum = math.sum(math.max(mom, 0), Len)
downSum = math.sum(-math.min(mom, 0), Len)
out = (upSum - downSum) / (upSum + downSum)
cmo = math.abs(out)
alpha = 2 / (Len + 1)
vidya = 0.0
vidya := src * alpha * cmo + nz(vidya[1]) * (1 - alpha * cmo)
vidya
// ZLEMA: Zero Lag
zema(_src, _len) =>
_alpha = (_len - 1) / 2
_zlema0 = (_src + (_src - _src[_alpha]))
_zlemaF = ta.ema(_zlema0, _len)
// ADX Weighted Moving Average of @Duyck
adx_weighted_ma(_src, _period) =>
[_diplus, _diminus, _adx] = ta.dmi(17, 14)
_vol_sum = 0.0
_adx_sum = 0.0
for i = 0 to _period
_vol_sum := _src[i] * _adx[i] + _vol_sum
_adx_sum := _adx[i] + _adx_sum
_volwma = _vol_sum / _adx_sum
// COVWMA - Coefficient of Variation Weighted Moving Average of @DonovanWall
covwma(a, b) =>
cov = ta.stdev(a, b) / ta.sma(a, b)
cw = a*cov
covwma = math.sum(cw, b) / math.sum(cov, b)
// FRAMA - Fractal Adaptive Moving Average of @DonovanWall
w = -4.6 // "Coefficient (if FRAMA)"
frama(a, b) =>
frama = 0.0
n3 = (ta.highest(high, b) - ta.lowest(low, b))/b
hd2 = ta.highest(high, b/2)
ld2 = ta.lowest(low, b/2)
n2 = (hd2 - ld2)/(b/2)
n1 = (hd2[b/2] - ld2[b/2])/(b/2)
dim = (n1 > 0) and (n2 > 0) and (n3 > 0) ? (math.log(n1 + n2) - math.log(n3))/math.log(2) : 0
alpha = math.exp(w*(dim - 1))
sc = (alpha < 0.01 ? 0.01 : (alpha > 1 ? 1 : alpha))
frama := ta.cum(1)<=2*b ? a : (a*sc) + nz(frama[1])*(1 - sc)
frama
// EMA RSI Adaptive of @glaz
rsi_ema(src, period) =>
RsiPeriod = 14
ema = 0.0
RSvoltl = math.abs(ta.rsi(close, RsiPeriod)-50)+1.0
multi = (5.0+100.0/RsiPeriod) / (0.06+0.92*RSvoltl+0.02*math.pow(RSvoltl,2))
pdsx = multi*period
alpha = 2.0 /(1.0+pdsx)
ema := nz(ema[1])+alpha*(ta.sma(close, period)-nz(ema[1]))
ema
ma(MAType, MASource, MAPeriod) =>
if MAPeriod > 0
if MAType == "SMA"
ta.sma(MASource, MAPeriod)
else if MAType == "EMA"
ta.ema(MASource, MAPeriod)
else if MAType == "WMA"
ta.wma(MASource, MAPeriod)
else if MAType == "RMA"
ta.rma(MASource, MAPeriod)
else if MAType == "HMA"
ta.hma(MASource, MAPeriod)
else if MAType == "DEMA"
e = ta.ema(MASource, MAPeriod)
2 * e - ta.ema(e, MAPeriod)
else if MAType == "TEMA"
e = ta.ema(MASource, MAPeriod)
3 * (e - ta.ema(e, MAPeriod)) + ta.ema(ta.ema(e, MAPeriod), MAPeriod)
else if MAType == "VWMA"
ta.vwma(MASource, MAPeriod)
else if MAType == "ALMA"
ta.alma(MASource, MAPeriod, .85, 6)
else if MAType == "CTI"
cti(MAPeriod, MASource, 0)
else if MAType == "KAMA"
kama(MASource, MAPeriod)
else if MAType == "SWMA"
ta.swma(MASource)
else if MAType == "JMA"
jma(MASource, MAPeriod, 2, 50)
else if MAType == "LSMA" // Least Squares
ta.linreg(MASource, MAPeriod, 0)
else if MAType == "Wild"
wild = MASource
wild := nz(wild[1]) + (MASource - nz(wild[1])) / MAPeriod
else if MAType == "Tillson T3"
T3ma(MASource, MAPeriod)
else if MAType == "VIDYA"
VIDYA(MASource, MAPeriod)
else if MAType == "DWMA" // Double Weighted Moving Average
ta.wma(ta.wma(MASource, MAPeriod), MAPeriod)
else if MAType == "DVWMA" // Double Volume-Weighted Moving Average
ta.vwma(ta.vwma(MASource, MAPeriod), MAPeriod)
else if MAType == "Zero Lag"
zema(MASource, MAPeriod)
else if MAType == "Median"
ta.median(MASource, MAPeriod)
else if MAType == "RSI EMA"
rsi_ema(MASource, MAPeriod)
else if MAType == "ADX MA"
adx_weighted_ma(MASource, MAPeriod)
else if MAType == "COVWMA"
covwma(MASource, MAPeriod)
else if MAType == "FRAMA"
frama(MASource, MAPeriod)
// Input - Squeeze Momentum Indicator
show_Momen = input.bool(true, "▷ Show Momentum ", inline="mom", group="Squeeze Momentum Indicator")
color_M = input.int(3, "Color Format", minval=1, maxval=5, inline="mom", group="Squeeze Momentum Indicator")
bgoff = input.bool(true, "Background Off", inline="mom", group="Squeeze Momentum Indicator")
lengthM = input.int(20, "MOM Length", minval=1, step=1, inline="M", group="Squeeze Momentum Indicator")
srcM = input.source(close, "Source", inline="M", group="Squeeze Momentum Indicator")
typeMom = input.string('SMA', "Type", inline = "M", group="Squeeze Momentum Indicator", options=["SMA", "EMA", "WMA", "DWMA", "ALMA", "VWMA", "DVWMA", "HMA", "Wild", "JMA", "KAMA", "Zero Lag", "Tillson T3", "VIDYA", "CTI", "RMA", "DEMA", "TEMA", "SWMA", "Median", "COVWMA", "FRAMA", "ADX MA", "RSI EMA"])
show_sqz = input.bool(true, "Show Squeeze [SQZ]", inline="S", group="Squeeze Momentum Indicator")
length = input.int(20, "Length", minval=1, step=1, inline="S", group="Squeeze Momentum Indicator")
src = input.source(ohlc4, "Source", inline="S", group="Squeeze Momentum Indicator")
bbmatype = input.string('SMA', "BB Calculation Type", inline = "bb", group="Squeeze Momentum Indicator", options=["SMA", "EMA", "WMA", "DWMA", "ALMA", "VWMA", "DVWMA", "HMA", "LSMA", "Wild", "JMA", "Zero Lag", "Tillson T3", "VIDYA", "KAMA", "CTI", "RMA", "DEMA", "TEMA", "SWMA", "Median", "COVWMA", "FRAMA", "ADX MA", "RSI EMA"])
multBB = input.float(2.0 , "BB MultFactor", step=0.25, inline = "bb", group="Squeeze Momentum Indicator") //Bollinger Bands Multiplier
kcmatype = input.string('EMA', "Keltner Channel Calculation Type", inline = "kc", group="Squeeze Momentum Indicator", options=["SMA", "EMA", "WMA", "DWMA", "ALMA", "VWMA", "DVWMA", "HMA", "LSMA", "Wild", "JMA", "Zero Lag", "Tillson T3", "VIDYA", "KAMA", "CTI", "RMA", "DEMA", "TEMA", "SWMA", "Median", "COVWMA", "FRAMA", "ADX MA", "RSI EMA"])
useTR = input.bool(true, "Use TrueRange (KC)", inline = "kc", group="Squeeze Momentum Indicator")
drdiv = input.bool(true, "Draw Divergence", inline="l1", group="Squeeze Momentum Indicator")
zeroSQZ = input.bool(false, "SQZ Zero Line", inline="l1", group="Squeeze Momentum Indicator")
darkm = input.bool(false, "Gray Background for Dark Mode", inline="l1", group="Squeeze Momentum Indicator")
////INPUTS ADX////
len = input.int(29, minval=0, title='ADX Length')
len_sm = input.int(54, minval=0, title='ADX Smooth')
rsi_len = input.int(23, minval=0, title='RSI Length')
fil = input.int(15, minval=0, maxval=100, title='Treshold')
ul = input.int(74, minval=50, maxval=100, title='Upline')
dl = input.int(30, minval=0, maxval=49, title='Downline')
ur = input(true, title='Use RSI signal?')
// Input - Hull Moving Average
show_Hull = input.bool(false, "Show Hull Signal", inline="hull0", group="Hull Moving Average")
bg_Hull = input.bool(true, "Background Hull", inline="hull0", group="Hull Moving Average")
h_Length = input.int(55, "Length", minval=1, step=1, inline = "hull", group="Hull Moving Average")
h_type = input.string("HMA", "Type", options=["HMA", "EHMA", "THMA", "AHMA"], inline = "hull", group="Hull Moving Average")
h_src = input.string("Close", "Source", inline = "hull", group="Hull Moving Average", options=["Close", "Open", "HL2", "HLC3", "OHLC4", "HLCC4", "VWAP", "High", "Low", "vwap(Close)", "vwap(Open)", "vwap(High)", "vwap(Low)", "AVG(vwap(H,L))", "AVG(vwap(O,C))", "OBV", "AccDist", "PVT", "Volume"])
// Input - Williams Vix Fix
sbcFilt = input.bool(false, "Show Signal For Filtered Entry [▲ FE ]", group="Williams Vix Fix") // Use FILTERED Criteria
sbcAggr = input.bool(false, "Show Signal For AGGRESSIVE Filtered Entry [▲ AE ]", group="Williams Vix Fix") // Use FILTERED Criteria
sbc = input.bool(false, "Show Signal if WVF WAS True and IS Now False [▼]", group="Williams Vix Fix") // Use Original Criteria
sbcc = input.bool(false, "Show Signal if WVF IS True [▼]", group="Williams Vix Fix") // Use Original Criteria
alert_AE = input.bool(false, '◁ Alert: [AGGRESSIVE Entry]', inline='AlertVF', group='Williams Vix Fix')
alert_FE = input.bool(false, '◁ Alert: [Filtered Entry]', inline='AlertVF', group='Williams Vix Fix')
// Inputs Tab Criteria
pd = input.int(22, "LookBack Period Standard Deviation High", group="Williams Vix Fix")
bbl = input.int(20, "Bolinger Band Length", group="Williams Vix Fix")
mult = input.float(2.0, "Bollinger Band Standard Devaition Up", minval=1, maxval=5, group="Williams Vix Fix")
lb = input.int(50, "Look Back Period Percentile High", group="Williams Vix Fix")
ph = input.float(.85, "Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%", group="Williams Vix Fix")
ltLB = input.int(40, minval=25, maxval=99, title="Long-Term Look Back Current Bar Has To Close Below This Value OR Medium Term--Default=40", group="Williams Vix Fix")
mtLB = input.int(14, minval=10, maxval=20, title="Medium-Term Look Back Current Bar Has To Close Below This Value OR Long Term--Default=14", group="Williams Vix Fix")
str = input.int(3, minval=1, maxval=9, title="Entry Price Action Strength--Close > X Bars Back---Default=3", group="Williams Vix Fix")
// Input - Elliott Wave Oscillator
show_EWO = input.bool(false, "▷ Show EWO Breaking Bands", inline="ewo0", group="Elliott Wave Oscillator")
diver_EWO = input.bool(true, "Draw Divergence", inline="ewo0", group="Elliott Wave Oscillator")
bg_EWO = input.bool(false, "Background", inline="ewo0", group="Elliott Wave Oscillator")
ma_fast = input.int(5, "Fast MA", inline="Fast", group="Elliott Wave Oscillator")
type_fast = input.string("SMA", "Fast MA Type", inline="Fast", group="Elliott Wave Oscillator", options=["SMA", "EMA", "WMA", "DWMA", "ALMA", "VWMA", "DVWMA", "HMA", "LSMA", "Wild", "JMA", "Zero Lag", "Tillson T3", "VIDYA", "KAMA", "CTI", "RMA", "DEMA", "TEMA", "SWMA", "Median", "COVWMA", "FRAMA", "ADX MA", "RSI EMA"])
ma_slow = input.int(34, "Slow MA", inline="Slow", group="Elliott Wave Oscillator")
type_slow = input.string("SMA", "Slow MA Type", inline="Slow", group="Elliott Wave Oscillator", options=["SMA", "EMA", "WMA", "ALMA", "DWMA", "VWMA", "DVWMA", "HMA", "LSMA", "Wild", "JMA", "Zero Lag", "Tillson T3", "VIDYA", "KAMA", "CTI", "RMA", "DEMA", "TEMA", "SWMA", "Median", "COVWMA", "FRAMA", "ADX MA", "RSI EMA"])
SRC = input.string("HL2", "Source", inline="ewo1", group="Elliott Wave Oscillator", options=["VWAP", "Close", "Open", "HL2", "HLC3", "OHLC4", "HLCC4", "High", "Low", "vwap(Close)", "vwap(Open)", "vwap(High)", "vwap(Low)", "AVG(vwap(H,L))", "AVG(vwap(O,C))", "OBV", "AccDist", "PVT", "Volume"])
show_bands = input.bool(true, "Show Breaking Bands", inline="ewo1", group="Elliott Wave Oscillator")
signal_ewo = input.bool(true, "Show Signal(EWO)", inline="ewo2", group="Elliott Wave Oscillator")
Len = input.int(1, "Length", minval=1, inline="ewo2", group="Elliott Wave Oscillator")
// Input - Expert Trend Locator
candles_XTL = input.bool(false, "Use XTL Bars Color", group="Expert Trend Locator")
period_xtl = input.int(26, "Length", minval=2, inline="xtl", group="Expert Trend Locator")
MA_Type2 = input.string("DVWMA", "Type", inline="xtl", group="Expert Trend Locator", options=["SMA", "EMA", "WMA", "DWMA", "ALMA", "VWMA", "DVWMA", "HMA", "LSMA", "Wild", "JMA", "Zero Lag", "Tillson T3", "VIDYA", "KAMA", "CTI", "RMA", "DEMA", "TEMA", "SWMA", "Median", "COVWMA", "FRAMA", "ADX MA", "RSI EMA"])
src_xtl = input.string("HLC3", "Source", inline="xtl", group="Expert Trend Locator", options=["VWAP", "Close", "Open", "HL2", "HLC3", "OHLC4", "HLCC4", "High", "Low", "vwap(Close)", "vwap(Open)", "vwap(High)", "vwap(Low)", "AVG(vwap(H,L))", "AVG(vwap(O,C))", "OBV", "AccDist", "PVT", "Volume"])
fixed_Value = input.int(37, "Threshold Level", minval=10, group="Expert Trend Locator", inline="xtl2")
uTrad = input.bool(false, "Use the traditional CCI formula", group="Expert Trend Locator", inline="xtl2")
color_xtlUP = input.color(#00BFFF, "Trend Up", group="Expert Trend Locator", inline="ColXTL")
color_xtlNe = input.color(#FFFFFF, "Neutral", group="Expert Trend Locator", inline="ColXTL")
color_xtlDN = input.color(#FF4000, "Trend Down", group="Expert Trend Locator", inline="ColXTL")
// Divergences
group_divergences = "Divergences For Momentum and Elliott Wave Oscillator"
plotBull = input.bool(true, "Plot Bullish", inline="bull", group=group_divergences)
plotHiddenBull = input.bool(false, "Plot Hidden Bullish", inline="bull", group=group_divergences)
plotBear = input.bool(true, "Plot Bearish", inline="bear", group=group_divergences)
plotHiddenBear = input.bool(false, "Plot Hidden Bearish", inline="bear", group=group_divergences)
delay_plot_til_closed = input.bool(true, "Delay plot until candle is closed (don't repaint)", group=group_divergences)
usex2LB = input.bool(true, "Lookback 2 Pivots?", group=group_divergences)
lbR = input.int(1, "Pivot Lookback Right", group=group_divergences)
lbL = input.int(2, "Pivot Lookback Left", group=group_divergences)
rangeLower = input.int(1, "Min of Lookback Range", group=group_divergences)
rangeUpper = input.int(60, "Max of Lookback Range", group=group_divergences)
//______________________________________________________________________________
// Elliott Wave Oscillator (EWO) Breaking Bands
// https://www.tradingview.com/script/UcBJKm4O/
//______________________________________________________________________________
src_ewo = get_src(SRC)
ewo1 = ma(type_fast, src_ewo, ma_fast) - ma(type_slow, src_ewo, ma_slow)
AvgEWO = ta.ema(ewo1, Len)
UpperBand = ewo1
UpperBand := nz(UpperBand[1])
if ewo1 > 0
UpperBand := (UpperBand[1] + 0.0555*(ewo1 - UpperBand[1]))
LowerBand = ewo1
LowerBand := nz(LowerBand[1])
if ewo1 < 0
LowerBand := (LowerBand[1] + 0.0555*(ewo1 - LowerBand[1]))
red_orange = #FF4000
chartreuse = #80FF00
coral = #FF8080
lavender = #8080FF
color_in = ewo1 > LowerBand and ewo1 < 0 ? #7F4040 : ewo1 > 0 and ewo1 < UpperBand ? #40407F : na
background = ewo1 > 0 ? color.new(#00FFFF, 85) : color.new(#FF0000, 85)
color_ewo = ewo1 > UpperBand ? lavender : ewo1 < LowerBand ? coral : color_in
plot(show_EWO ? ewo1 : na, title="EWO", color = color_ewo, style = plot.style_columns)
color_sig = AvgEWO > 0 ? chartreuse : red_orange
plot(show_EWO and signal_ewo ? AvgEWO : na, title = "Signal(EWO)", color = color_sig, linewidth = 2)
plot(show_EWO and show_bands ? UpperBand : na, title = "Upper Band", color = #EFEFBF)
plot(show_EWO and show_bands ? LowerBand : na, title = "Lower Band", color = #EFEFBF)
bgcolor(bg_EWO ? background : na, title = "Background EWO")
//_________________________________________________________________________________
// Based on "Squeeze Momentum Indicator" - Author:@LazyBear and @J-Streak
// https://www.tradingview.com/script/nqQ1DT5a-Squeeze-Momentum-Indicator-LazyBear/
// https://www.tradingview.com/script/557GijRq-JS-Squeeze-Pro-2/
//_________________________________________________________________________________
// Bollinger Bands Basis Line
basis = ma(bbmatype, src, length)
// Keltner Channel Basis Line
basiskc = ma(kcmatype, src, length)
// Keltner Channel Range
range_src = useTR ? ta.tr : (high - low)
range_kc = ma(kcmatype, range_src, length)
// Keltner Channel Low Multiplier
multlowKC = 2.0
// Keltner Channel Mid Multiplier
multmidKC = 1.5
// Keltner Channel High Multiplier
multhighKC = 1.0
// Bollinger Bands
dev = multBB * ta.stdev(src, length)
upperBB = basis + dev
lowerBB = basis - dev
// Keltner Channel Bands Low
upperKCl = basiskc + range_kc * multlowKC
lowerKCl = basiskc - range_kc * multlowKC
// Keltner Channel Bands Mid
upperKCm = basiskc + range_kc * multmidKC
lowerKCm = basiskc - range_kc * multmidKC
// Keltner Channel Bands High
upperKCh = basiskc + range_kc * multhighKC
lowerKCh = basiskc - range_kc * multhighKC
//------------------------{ Squeeze Momentum Basics }------------------------------------
// Momentum
ma_momentum = ma(typeMom, srcM, lengthM)
sz = ta.linreg(srcM - math.avg(math.avg(ta.highest(high, lengthM), ta.lowest(low, lengthM)), ma_momentum), lengthM, 0)
// Momentum Conditions
sc1 = sz >= 0
sc2 = sz < 0
sc3 = sz >= sz[1]
sc4 = sz < sz[1]
// Squeeze On
lowsqz = lowerBB > lowerKCl and upperBB < upperKCl
lsf = lowsqz == false
midsqz = lowerBB > lowerKCm and upperBB < upperKCm
msf = midsqz == false
highsqz = lowerBB > lowerKCh and upperBB < upperKCh
hsf = highsqz == false
//-----------------------{ Color Components }-----------------------------------
// Color Conditions
clr1 = sc1 and sc3 ? #00EEFF :
sc1 and sc4 ? #000EFF : sc2 and sc4 ? #FF0000 : sc2 and sc3 ? #FFE500 : color.gray
clr2 = sc1 and sc3 ? #00bcd4 :
sc1 and sc4 ? #0D47A1 : sc2 and sc4 ? #BA68C8 : sc2 and sc3 ? #9C27B0 : #673AB7
clr3 = sc1 and sc3 ? #15FF00 : sc1 and sc4 ? #388E3C :
sc2 and sc4 ? #F44336 : sc2 and sc3 ? #B71C1C : color.gray
clr4 = sc1 and sc3 ? #fff59d :
sc1 and sc4 ? #FFD600 : sc2 and sc4 ? #FFCC80 : sc2 and sc3 ? #FF9800 : #702700
clr5 = sc1 and sc3 ? #2196F3 :
sc1 and sc4 ? #0D47A1 : sc2 and sc4 ? #EF9A9A : sc2 and sc3 ? #D32F2F : #CE93D8
choice = color_M == 1 ? clr1 : color_M == 2 ? clr2 :
color_M == 3 ? clr3 : color_M == 4 ? clr4 : color_M == 5 ? clr5 : na
//-----------------{ Indicator Components and Plots }---------------------------
// Squeeze Dot Colors
orange_red = #FF4000 // Original Squeeze
golden_yellow = #FFE500 // High Squeeze
sqzproc = highsqz ? golden_yellow : midsqz ? orange_red : lowsqz ? color.gray : na
// Squeeze Dot Plot Above
sqzpro = zeroSQZ ? na : highsqz ? highsqz : midsqz ? midsqz : lowsqz ? lowsqz : na
plotshape(show_sqz ? sqzpro : na, title="Squeeze Dots Top", style=shape.circle, location=location.top, color=sqzproc)
// Momentum Plot
plot(show_Momen ? sz : na, title="Squeeze Momentum", color=choice, style=plot.style_columns)
// Plot Zero Line
color_zero = highsqz ? golden_yellow : midsqz ? orange_red : lowsqz ? color.gray : clr3
plot(zeroSQZ ? 0 : na, title="Squeeze Zero Line", color=color_zero, linewidth=2, style=plot.style_circles)
// Background Conditions
bg1_dark = color.new(color.gray, 95)
bg2_dark = color.new(#673AB7, 95)
bg3_dark = color.new(color.gray, 95)
bg4_dark = color.new(#FFD600, 95)
bg5_dark = color.new(#CE93D8, 95)
bgc_dark = bgoff ? na : color_M == 1 ? bg1_dark : color_M == 2 ? bg2_dark :
color_M == 3 ? bg3_dark : color_M == 4 ? bg4_dark : color_M == 5 ? bg5_dark : na
clr1_bg = sc1 and sc3 ? color.new(#00EEFF, 80) :
sc1 and sc4 ? color.new(#000EFF, 80) : sc2 and sc4 ? color.new(#FF0000, 80) : sc2 and sc3 ? color.new(#FFE500, 80) : color.new(color.gray, 80)
clr2_bg = sc1 and sc3 ? color.new(#00bcd4, 80) :
sc1 and sc4 ? color.new(#0D47A1, 80) : sc2 and sc4 ? color.new(#BA68C8, 80) : sc2 and sc3 ? color.new(#9C27B0, 80) : color.new(#673AB7, 80)
clr3_bg = sc1 and sc3 ? color.new(#15FF00, 80) : sc1 and sc4 ? color.new(#388E3C, 80) :
sc2 and sc4 ? color.new(#F44336, 80) : sc2 and sc3 ? color.new(#B71C1C, 80) : color.new(color.gray, 80)
clr4_bg = sc1 and sc3 ? color.new(#fff59d, 80) :
sc1 and sc4 ? color.new(#FFD600, 80) : sc2 and sc4 ? color.new(#FFCC80, 80) : sc2 and sc3 ? color.new(#FF9800, 80) : color.new(#702700, 80)
clr5_bg = sc1 and sc3 ? color.new(#2196F3, 80) :
sc1 and sc4 ? color.new(#0D47A1, 80) : sc2 and sc4 ? color.new(#EF9A9A, 80) : sc2 and sc3 ? color.new(#D32F2F, 80) : color.new(#CE93D8, 80)
choice_bg = color_M == 1 ? clr1_bg : color_M == 2 ? clr2_bg :
color_M == 3 ? clr3_bg : color_M == 4 ? clr4_bg : color_M == 5 ? clr5_bg : na
// Background Colors
bgcolor(darkm ? bgc_dark : na, title = "Gray Background", editable=false)
bgcolor(bgoff ? na : choice_bg, title = "Momentum Background")
//___________________________________________________________________________________________
// Based on "Better Divergence On Any Indicator" - Author: @DoctaBot
// https://www.tradingview.com/script/tbrsp75I-Better-Divergence-On-Any-Indicator-DoctaBot/
//___________________________________________________________________________________________
osc = show_Momen and drdiv ? sz : show_EWO and diver_EWO ? ewo1 : na
bearColor = color.new(color.red, 0)
bullColor = color.new(color.lime, 0)
hiddenBullColor = color.new(#00945F, 15)
hiddenBearColor = color.new(#990040, 15)
textColor = color.new(color.white, 0)
textColor2 = color.new(color.black, 0)
repaint = (not(delay_plot_til_closed) or barstate.ishistory or barstate.isconfirmed)
plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond, occurence) =>
bars = (bar_index - ta.valuewhen(cond, bar_index, occurence))
rangeLower <= bars and bars <= rangeUpper
oscPLCur = ta.valuewhen(plFound, osc[lbR], 0) //Current Oscillator Pivot Low
oscPL1 = ta.valuewhen(plFound, osc[lbR], 1) //Last Oscillator Pivot Low
oscPL2 = ta.valuewhen(plFound, osc[lbR], 2) //2 Back Oscillator Pivot Low
oscPLCurBar = ta.valuewhen(plFound, bar_index - lbR, 0) //Current Oscillator Pivot Low Bar Index
oscPL1Bar = ta.valuewhen(plFound, bar_index - lbR, 1) //Last Oscillator Pivot Low Bar Index
oscPL2Bar = ta.valuewhen(plFound, bar_index - lbR, 2) //2 Back Oscillator Pivot Low Bar Index
oscPHCur = ta.valuewhen(phFound, osc[lbR], 0) //Current Oscillator Pivot High
oscPH1 = ta.valuewhen(phFound, osc[lbR], 1) //Last Oscillator Pivot High
oscPH2 = ta.valuewhen(phFound, osc[lbR], 2) //2 Back Oscillator Pivot High
oscPHCurBar = ta.valuewhen(phFound, bar_index - lbR, 0) //Current Oscillator Pivot High Bar Index
oscPH1Bar = ta.valuewhen(phFound, bar_index - lbR, 1) //Last Oscillator Pivot High Bar Index
oscPH2Bar = ta.valuewhen(phFound, bar_index - lbR, 2) //2 Back Oscillator Pivot High Bar Index
oscPL2Slope = (osc[lbR] - oscPL2)/((bar_index - lbR) - oscPL2Bar) //Slope Between Pivot Lows
oscPL2Lim = ((oscPL1Bar - oscPL2Bar)*(oscPL2Slope)) + oscPL2 //Pivot Low Oscillator Intersect Limit
oscPH2Slope = (osc[lbR] - oscPH2)/((bar_index - lbR) - oscPH2Bar) //Slope Between Pivot Highs
oscPH2Lim = ((oscPH1Bar - oscPH2Bar)*(oscPH2Slope)) + oscPH2 //Pivot High Oscillator Intersect Limit
// Oscilator Pivots
oscHL1 = (osc[lbR] > oscPL1 and _inRange(plFound, 1)) //Osc. Higher Low compared to previous
oscHL2 = (osc[lbR] > oscPL2 and _inRange(plFound, 2) and oscPL1 > oscPL2Lim) //Osc. Higher Low compared to 2 back with no intersection
oscLL1 = (osc[lbR] < oscPL1 and _inRange(plFound, 1)) //Osc. Lower Low compared to previous
oscLL2 = (osc[lbR] < oscPL2 and _inRange(plFound, 2) and oscPL1 > oscPL2Lim) //Osc. Lower Low compared to 2 back with no intersection
oscLH1 = (osc[lbR] < oscPH1 and _inRange(phFound, 1)) //Osc. Lower High compared to previous
oscLH2 = (osc[lbR] < oscPH2 and _inRange(phFound, 2) and oscPH1 < oscPH2Lim) //Osc. Lower High compared to 2 back with no intersection
oscHH1 = (osc[lbR] > oscPH1 and _inRange(phFound, 1)) //Osc. Higher High compared to previous
oscHH2 = (osc[lbR] > oscPH2 and _inRange(phFound, 2) and oscPH1 < oscPH2Lim) //Osc. Higher High compared to 2 back with no intersection
// Price Pivots
priceLL1 = ta.lowest(close, lbR + 2) < ta.valuewhen(plFound, ta.lowest(close, lbR + 2), 1) //Price Lower Low compared to previous
priceLL2 = ta.lowest(close, lbR + 2) < ta.valuewhen(plFound, ta.lowest(close, lbR + 2), 2) //Price Lower Low compared to 2 back
priceHL1 = ta.lowest(close, lbR + 2) > ta.valuewhen(plFound, ta.lowest(close, lbR + 2), 1) //Price Higher Low compared to previous
priceHL2 = ta.lowest(close, lbR + 2) > ta.valuewhen(plFound, ta.lowest(close, lbR + 2), 2) //Price Higher Low compared to 2 back
priceHH1 = ta.highest(close, lbR + 2) > ta.valuewhen(phFound, ta.highest(close, lbR + 2), 1) //Price Higher High compared to previous
priceHH2 = ta.highest(close, lbR + 2) > ta.valuewhen(phFound, ta.highest(close, lbR + 2), 2) //Price Higher High compared to 2 back
priceLH1 = ta.highest(close, lbR + 2) < ta.valuewhen(phFound, ta.highest(close, lbR + 2), 1) //Price Lower High compared to previous
priceLH2 = ta.highest(close, lbR + 2) < ta.valuewhen(phFound, ta.highest(close, lbR + 2), 2) //Price Lower High compared to 2 back
// Conditions
bullCond1 = plotBull and plFound and repaint and (priceLL1 and oscHL1) and osc < 0
bullCond2 = plotBull and plFound and repaint and (usex2LB ? (priceLL2 and oscHL2) : false) and osc < 0
hiddenBullCond1 = plotHiddenBull and plFound and repaint and (priceHL1 and oscLL1) and osc < 0
hiddenBullCond2 = plotHiddenBull and plFound and repaint and (usex2LB ? (priceHL2 and oscLL2) : false) and osc < 0
bearCond1 = plotBear and phFound and repaint and (priceHH1 and oscLH1) and osc > 0
bearCond2 = plotBear and phFound and repaint and (usex2LB ? (priceHH2 and oscLH2) : false) and osc > 0
hiddenBearCond1 = plotHiddenBear and phFound and repaint and (priceLH1 and oscHH1) and osc > 0
hiddenBearCond2 = plotHiddenBear and phFound and repaint and (usex2LB ? (priceLH2 and oscHH2) : false) and osc > 0
f_drawLine(_x1, _x2, _y1, _y2, _color, _width) =>
line.new(
x1 = _x1,
x2 = _x2,
y1 = _y1,
y2 = _y2,
color = _color,
width = _width,
xloc = xloc.bar_index
)
// Plot Bull Lines
if plFound
f_drawLine(
bullCond1 or hiddenBullCond1 ? oscPL1Bar : bullCond2 or hiddenBullCond2 ? oscPL2Bar : oscPLCurBar,
oscPLCurBar,
bullCond1 or hiddenBullCond1 ? oscPL1 : bullCond2 or hiddenBullCond2 ? oscPL2 : oscPLCur,
oscPLCur,
bullCond1 or bullCond2 ? bullColor : hiddenBullColor,
2)
// Plot Bear Lines
if phFound
f_drawLine(
bearCond1 or hiddenBearCond1 ? oscPH1Bar : bearCond2 or hiddenBearCond2 ? oscPH2Bar : oscPHCurBar,
oscPHCurBar,
bearCond1 or hiddenBearCond1 ? oscPH1 : bearCond2 or hiddenBearCond2 ? oscPH2 : oscPHCur,
oscPHCur,
bearCond1 or bearCond2 ? bearColor : hiddenBearColor,
2)
// Plot Bull Labels
plotshape(
bullCond1 or bullCond2 ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text=" R ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor2
)
// Plot Hidden Bull Labels
plotshape(
hiddenBullCond1 or hiddenBullCond2 ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text=" H ",
style=shape.labelup,
location=location.absolute,
color=hiddenBullColor,
textcolor=textColor
)
// Plot Bear Labels
plotshape(
bearCond1 or bearCond2 ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text=" R ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
// Plot Hidden Bear Labels
plotshape(
hiddenBearCond1 or hiddenBearCond2 ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text=" H ",
style=shape.labeldown,
location=location.absolute,
color=hiddenBearColor,
textcolor=textColor
)
// Alerts
if bullCond1 or bullCond2
alert("Regular Bull Divergence", alert.freq_once_per_bar_close )
if hiddenBullCond1 or hiddenBullCond2
alert("Hidden Bull Divergence", alert.freq_once_per_bar_close )
if bearCond1 or bearCond2
alert("Regular Bear Divergence", alert.freq_once_per_bar_close )
if hiddenBearCond1 or hiddenBearCond2
alert("Hidden Bear Divergence", alert.freq_once_per_bar_close )
alertcondition(bullCond1 or bullCond2, title = "Regular Bull Divergence", message = "Regular Bull Divergence")
alertcondition(hiddenBullCond1 or hiddenBullCond2, title = "Hidden Bull Divergence", message = "Hidden Bull Divergence")
alertcondition(bearCond1 or bearCond2, title = "Regular Bear Divergence", message = "Regular Bear Divergence")
alertcondition(hiddenBearCond1 or hiddenBearCond2, title = "Hidden Bear Divergence", message = "Hidden Bear Divergence")
////CALCULATIONS////
//ADX//
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_sm) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len_sm) / truerange)
sum = plus + minus
adx_ = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), len)
adx = (plus - minus) * adx_
//RSI//
rsi = ta.rsi(close, rsi_len)
////COLORS ADX////
col = plus > minus ? #00FF00 : minus > plus ? #FF0000 : na
col := adx_ <= fil ? col[1] : plus > minus ? #00FF00 : minus > plus ? #FF0000 : na
rsi_col = rsi >= ul ? #FF0000 : rsi <= dl ? #00FF00 : na
rsi_crossup_col = ta.crossunder(rsi, ul) ? #FF0000 : na
rsi_crossdown_col = ta.crossover(rsi, dl) ? #00FF00 : na
////PLOTS ADX////
plot(adx, color=col, title='ADX', linewidth=3, transp=0)
bgcolor(ur ? rsi_col : na, transp=50)
bgcolor(ur ? rsi_crossup_col : na, transp=0)
bgcolor(ur ? rsi_crossdown_col : na, transp=0)
//_____________________________________________________________________________________
// Hull Moving Average
//_____________________________________________________________________________________
// EHMA
EHMA(_src, _length) => ta.ema((2 * ta.ema(_src, _length / 2)) - ta.ema(_src, _length), math.round(math.sqrt(_length)))
// THMA
THMA(_src, _length) => ta.wma(ta.wma(_src, _length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length)
// Adaptive HMA
AHMA(_src, _length) => ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length), math.floor(math.sqrt(_length)))
// Hull type
hull_type(type, src, len) =>
type == "HMA" ? ta.hma(src, len) : type == "EHMA" ? EHMA(src, len) : type == "THMA" ? THMA(src, len/2) : AHMA(src, len)
xHMA = hull_type(h_type, get_src(h_src), h_Length)
longHMA = ta.crossover(xHMA[0], xHMA[2])
shortHMA = ta.crossunder(xHMA[0], xHMA[2])
hull_color = xHMA[0] > xHMA[2] ? color.new(#45CEA2, 85) : color.new(#CE4571, 85)
bgcolor(bg_Hull ? hull_color : na, title = "Hull Background")
plotshape(show_Hull and longHMA, title="Long Cross", color=color.new(#45CEA2, 10), style=shape.triangleup, location=location.bottom, size=size.tiny, text='H')
plotshape(show_Hull and shortHMA, title="Short Cross", color=color.new(#CE4571, 10), style=shape.triangledown, location=location.top, size=size.tiny, text='H')
//______________________________________________________________________________
// The Expert Trend Locator - XTL
//______________________________________________________________________________
media = ma(MA_Type2, get_src(src_xtl), period_xtl)
cciNT = (get_src(src_xtl) - media) / (0.015 * ta.dev(get_src(src_xtl), period_xtl))
cciT = (get_src(src_xtl) - media) / (0.015 * ta.dev(math.abs(get_src(src_xtl) - media), period_xtl))
values = uTrad ? cciT : cciNT
var color color_XTL = na
if (values < -fixed_Value)
color_XTL := color_xtlDN // Bear
if (-fixed_Value <= values and values <= fixed_Value)
color_XTL := color_xtlNe // Neutral
if (values > fixed_Value)
color_XTL := color_xtlUP // Bull
barcolor(candles_XTL ? color_XTL : na, title="XTL", editable=false)
//_____________________________________________________________________________________
// Based on "Williams_Vix_Fix_V3_Upper_Text_Plots" - Author: @ChrisMoody
// https://www.tradingview.com/script/1ffumXy5-CM-Williams-Vix-Fix-V3-Upper-Text-Plots/
// https://www.ireallytrade.com/newsletters/VIXFix.pdf
//_____________________________________________________________________________________
// Williams Vix Fix Formula
wvf = ((ta.highest(close, pd)-low)/(ta.highest(close, pd)))*100
sDev = mult * ta.stdev(wvf, bbl)
midLine = ta.sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (ta.highest(wvf, lb)) * ph
// Filtered Criteria
upRange = low > low[1] and close > high[1]
upRange_Aggr = close > close[1] and close > open[1]
// Filtered Criteria
filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh))
filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and not (wvf < upperBand and wvf < rangeHigh)
// Alerts Criteria
alert1 = wvf >= upperBand or wvf >= rangeHigh ? 1 : 0
alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and wvf < upperBand and wvf < rangeHigh ? 1 : 0
cond_FE = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered
alert3 = cond_FE ? 1 : 0
cond_AE = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr
alert4 = cond_AE ? 1 : 0
plotshape(sbcc and alert1 ? alert1 : na, "WVF Is True", color=color.new(#80FF00, 60), style=shape.triangledown, location=location.bottom, size=size.tiny)
plotshape(sbc and alert2 ? alert2 : na, "WVF Was True - Now False", color=color.new(#008080, 60), style=shape.triangledown, location=location.bottom, size=size.tiny)
plotshape(sbcAggr and alert4 ? alert4 : na, "Aggressive Entry", color=color.new(#80FF00, 20), style=shape.triangleup, location=location.bottom, size=size.tiny, text='AE')
plotshape(sbcFilt and alert3 ? alert3 : na, "Filtered Entry", color=color.new(#80FF00, 20), style=shape.triangleup, location=location.bottom, size=size.tiny, text='FE')
if alert_AE and cond_AE
alert('Symbol = (' + syminfo.tickerid + ') \n TimeFrame = (' + timeframe.period + ') \n Current Price (' + str.tostring(close) + ') \n Aggressive Entry [VixFix].', alert.freq_once_per_bar_close)
if alert_FE and cond_FE
alert('Symbol = (' + syminfo.tickerid + ') \n TimeFrame = (' + timeframe.period + ') \n Current Price (' + str.tostring(close) + ') \n Filtered Entry [VixFix].', alert.freq_once_per_bar_close)
|
LNL Pullback Arrows | https://www.tradingview.com/script/xnjQZfS1-LNL-Pullback-Arrows/ | lnlcapital | https://www.tradingview.com/u/lnlcapital/ | 629 | study | 5 | MPL-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
//
// L&L Pullback Arrows
//
// Pullback Arrows helps to visualize the best possible entries for trend following setups ("buying the dip")
//
// Includes four different types of arrows = aggresive(aggro), moderate(halfsize), conservative(fullsize) and the rare (offers the best risk/reward during the trend)
//
// The goal of these arrows is to force the traders to scale in & out of trades which is in my opinion crucial when it comes to trend following strategies
//
// With the Pullback arrows, trader can pick his own approach and risk level thanks to four different types of arrows
//
// Created by © L&L Capital
//
indicator("LNL Pullback Arrows",shorttitle="Pullback Arrows", overlay=true)
// Inputs
fastema = input(21,title="EMA Cloud Fast")
slowema = input(55,title="EMA Cloud Slow")
stoplinefactor = input(1.0,title="StopLine Factor")
// DMI Bars Calculations
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, 14)
plus = fixnan(100 * ta.rma(plusDM, 14) / trur)
minus = fixnan(100 * ta.rma(minusDM, 14) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), 14)
DMIPOS = (plus > minus) and (adx > 20)
DMINEG = (minus > plus) and (adx > 20)
DMINEU = (adx < 20)
// Higher Time Frame MACD Calculations
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
mtfMacd = request.security(syminfo.tickerid, "W", macdLine)
mtfSignal = request.security(syminfo.tickerid, "W", signalLine)
MACDUp = mtfMacd >= mtfSignal
MACDDn = mtfMacd <= mtfSignal
// EMAs & Keltner Channel Calculations
ADXAggro = adx > 30
RedCandle = open[1] > close[1]
GreenCandle = open[1] < close[1]
StackedEMAsUp = ta.ema(close, 8) > ta.ema(close, 21) and ta.ema(close, 34) > ta.ema(close, 55)
StackedEMAsDn = ta.ema(close, 8) < ta.ema(close, 21) and ta.ema(close, 34) < ta.ema(close, 55)
MA21 = hl2 < ta.ema(close, 21)
MA21s = hl2 > ta.ema(close, 21)
MA55 = hl2 > ta.ema(close, 55)
MA55s = hl2 < ta.ema(close, 55)
MAAgro = low < ta.ema(close, 5) and low > ta.ema(close, 13)
MAAgros = high > ta.ema(close, 5) and high < ta.ema(close, 13)
kma = ta.ema(close, 21)
rangema = ta.ema(ta.tr, 21)
upper = kma + rangema * 0.5
lower = kma - rangema * 0.5
upper1 = kma + rangema * 1
lower1 = kma - rangema * 1
upper2 = kma + rangema * 2
lower2 = kma - rangema * 2
KeltnerLongBelow = hl2 < upper
KeltnerLongAbove = hl2 > lower1
KeltnerLongBelow1 = hl2 < lower
KeltnerLongTarget = high > upper2
KeltnerLongTarget2 = hl2 >= upper1
KeltnerShortTarget = low < lower2
KeltnerShortTarget2 = hl2 <= lower1
KeltnerShortBelow = hl2 > lower
KeltnerShortAbove = hl2 < upper1
KeltnerShortAbove1 = hl2 > upper
// Pullback Arrows Calculations
RareArrowUp = StackedEMAsUp and KeltnerLongBelow1 and MA55 and DMIPOS and MACDUp
RareArrowDn = StackedEMAsDn and KeltnerShortAbove1 and MA55s and DMINEG and MACDDn
FullSizeArrowUp = StackedEMAsUp and not(RareArrowUp) and KeltnerLongAbove and MA21 and DMIPOS and MACDUp
FullSizeArrowDn = StackedEMAsDn and not(RareArrowDn) and KeltnerShortAbove and MA21s and DMINEG and MACDDn
HalfSizeArrowUp = StackedEMAsUp and not(FullSizeArrowUp) and not(RareArrowUp) and KeltnerLongBelow and KeltnerLongAbove and DMIPOS and MACDUp
HalfSizeArrowDn = StackedEMAsDn and not(FullSizeArrowDn) and not(RareArrowDn) and KeltnerShortBelow and KeltnerShortAbove and DMINEG and MACDDn
AggroArrowUp = StackedEMAsUp and not(HalfSizeArrowUp) and MAAgro and DMIPOS and RedCandle and ADXAggro and MACDUp
AggroArrowDn = StackedEMAsDn and not(HalfSizeArrowDn) and MAAgros and DMINEG and GreenCandle and ADXAggro and MACDDn
// Pullback Arrows Plots
plotshape(AggroArrowUp, title='Aggro Up',style=shape.triangleup,location=location.belowbar,color=#8cff00,size=size.tiny,display=display.none)
plotshape(AggroArrowDn, title='Aggro Down',style=shape.triangledown,location=location.abovebar,color=#faa1a4,size=size.tiny,display=display.none)
plotshape(HalfSizeArrowUp,title='HalfSize Up',style=shape.triangleup,location=location.belowbar,color=#1b5e20,size=size.tiny)
plotshape(HalfSizeArrowDn,title='HalfSize Down',style=shape.triangledown,location=location.abovebar,color=#730000,size=size.tiny)
plotshape(FullSizeArrowUp,title='FullSize Up',style=shape.triangleup,location=location.belowbar,color=#009900,size=size.small)
plotshape(FullSizeArrowDn,title='FullSize Down',style=shape.triangledown,location=location.abovebar,color=#cc0000,size=size.small)
plotshape(RareArrowUp,title='Rare Up',style=shape.triangleup,location=location.belowbar,color=(color.purple),size=size.small)
plotshape(RareArrowDn,title='Rare Down',style=shape.triangledown,location=location.abovebar,color=(color.purple),size=size.small)
// Simple EMA Cloud Calculations + Plots
ema_1 = ta.ema(close,fastema)
ema_2 = ta.ema(close,slowema)
ema1 = plot(ema_1,title="Fast EMA",color=color.black,display=display.none)
ema2 = plot(ema_2,title="Slow EMA",color=color.black,display=display.none)
Cloudup = ema_1 > ema_2
Clouddown = ema_1 < ema_2
Cloud = Cloudup ? color.green : Clouddown ? color.red : na
fill(ema1,ema2,title="EMA Cloud",color = Cloud, transp = 80)
// Pullback StopLine Calculations + Plots *UPDATE*
KeltnerLineUp = kma - rangema * stoplinefactor
KeltnerLineDn = kma + rangema * stoplinefactor
MALine21 = ta.ema(close, 21)
MALine55 = ta.ema(close, 55)
StopLineTrendUp = MALine21 > MALine55 and hl2 > KeltnerLineUp
StopLineTrendDn = MALine21 < MALine55 and hl2 < KeltnerLineDn
StopLineColor = StopLineTrendUp ? #27c22e : #ff0000
StopLine = StopLineTrendUp ? KeltnerLineUp : StopLineTrendDn ? KeltnerLineDn : na
plotchar(StopLine, title='StopLine',char="-",location=location.absolute,color=StopLineColor,size=size.tiny,editable = true)
|
FATL, SATL, RFTL, & RSTL Digital Signal Filter Smoother [Loxx] | https://www.tradingview.com/script/B3hl90F2-FATL-SATL-RFTL-RSTL-Digital-Signal-Filter-Smoother-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 97 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("FATL, SATL, RFTL, & RSTL Digital Signal Filter (DSP) Smoother [Loxx]",
shorttitle = "FSRRDFSC [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
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(30, "Period", group = "Baseline Settings")
maintype = input.string("Simple Moving Average - SMA", "Baseline 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 = "Baseline Settings")
dspfilttype = input.string("FATL - Fast Adaptive Trend Line", "Digital Filter Type", options = ["FATL - Fast Adaptive Trend Line", "SATL - Slow Adaptive Trend Line",
"RFTL - Reference Fast Trend Line", "RSTL - Reference Slow Trend Line"], group = "Digital Filter Settings")
bbper= input.int(30, "Bollinger Bands Period", group = "Bollinger Bands Settings")
atrper= input.int(15, "ATR Period", group = "Keltner Channels Settings")
bandtype = input.string("Keltner Channels", "Bands Type", options = ["Keltner Channels", "Bollinger Bands"], group = "Keltner Channels Settings")
atrType = input.string('Smoothed Moving Average - SMMA', title='Range Smoothing MA',
options=["Exponential Moving Average - EMA", "Smoothed Moving Average - SMMA",
"Linear Weighted Moving Average - LWMA", "Simple Moving Average - SMA", "Super Smoother"],
group = "Keltner Channels Settings")
BandsStyle = input.string("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Keltner Channels Style", group = "Keltner Channels Settings")
minMult = input.int(1, "Min Multiplier", group = "Shared Settings")
midMult = input.int(2, "Mid Multiplier", group = "Shared Settings")
maxMult = input.int(3, "Max Multiplier", group = "Shared Settings")
showmin = input.bool(true, "Show min channels?", group = "UI Options")
showmid = input.bool(true, "Show mid channels?", group = "UI Options")
showmax = input.bool(true, "Show max channels?", group = "UI Options")
fillcolor = input.bool(true, "Show fill color?", group = "UI Options")
colorbars = input.bool(false, "Color bars?", 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)
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
variant_atr(type, src, len) =>
sig = 0.0
if type == "Simple Moving Average - SMA"
[t, s, b] = loxxmas.sma(src, len)
sig := s
else if type == "Exponential Moving Average - EMA"
[t, s, b] = loxxmas.ema(src, len)
sig := s
else if type == "Linear Weighted Moving Average - LWMA"
[t, s, b] = loxxmas.lwma(src, len)
sig := s
else if type == "Smoothed Moving Average - SMMA"
[t, s, b] = loxxmas.smma(src, len)
sig := s
else if type == "Super Smoother"
[t, s, b] = loxxmas.super(src, len)
sig := s
sig
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, sig, special]
fatl_val = 0.4360409450 *
src + 0.3658689069 *
src[1] + 0.2460452079 *
src[2] + 0.1104506886 *
src[3] - 0.0054034585 *
src[4] - 0.0760367731 *
src[5] - 0.0933058722 *
src[6] - 0.0670110374 *
src[7] - 0.0190795053 *
src[8] + 0.0259609206 *
src[9] + 0.0502044896 *
src[10] + 0.0477818607 *
src[11] + 0.0249252327 *
src[12] - 0.0047706151 *
src[13] - 0.0272432537 *
src[14] - 0.0338917071 *
src[15] - 0.0244141482 *
src[16] - 0.0055774838 *
src[17] + 0.0128149838 *
src[18] + 0.0226522218 *
src[19] + 0.0208778257 *
src[20] + 0.0100299086 *
src[21] - 0.0036771622 *
src[22] - 0.0136744850 *
src[23] - 0.0160483392 *
src[24] - 0.0108597376 *
src[25] - 0.0016060704 *
src[26] + 0.0069480557 *
src[27] + 0.0110573605 *
src[28] + 0.0095711419 *
src[29] + 0.0040444064 *
src[30] - 0.0023824623 *
src[31] - 0.0067093714 *
src[32] - 0.0072003400 *
src[33] - 0.0047717710 *
src[34] + 0.0005541115 *
src[35] + 0.0007860160 *
src[36] + 0.0130129076 *
src[37] + 0.0040364019 *
src[38]
rftl_val = -0.0025097319 *
src + 0.0513007762 *
src[1] + 0.1142800493 *
src[2] + 0.1699342860 *
src[3] + 0.2025269304 *
src[4] + 0.2025269304 *
src[5] + 0.1699342860 *
src[6] + 0.1142800493 *
src[7] + 0.0513007762 *
src[8] - 0.0025097319 *
src[9] - 0.0353166244 *
src[10] - 0.0433375629 *
src[11] - 0.0311244617 *
src[12] - 0.0088618137 *
src[13] + 0.0120580088 *
src[14] + 0.0233183633 *
src[15] + 0.0221931304 *
src[16] + 0.0115769653 *
src[17] - 0.0022157966 *
src[18] - 0.0126536111 *
src[19] - 0.0157416029 *
src[20] - 0.0113395830 *
src[21] - 0.0025905610 *
src[22] + 0.0059521459 *
src[23] + 0.0105212252 *
src[24] + 0.0096970755 *
src[25] + 0.0046585685 *
src[26] - 0.0017079230 *
src[27] - 0.0063513565 *
src[28] - 0.0074539350 *
src[29] - 0.0050439973 *
src[30] - 0.0007459678 *
src[31] + 0.0032271474 *
src[32] + 0.0051357867 *
src[33] + 0.0044454862 *
src[34] + 0.0018784961 *
src[35] - 0.0011065767 *
src[36] - 0.0031162862 *
src[37] - 0.0033443253 *
src[38] - 0.0022163335 *
src[39] + 0.0002573669 *
src[40] + 0.0003650790 *
src[41] + 0.0060440751 *
src[42] + 0.0018747783 *
src[43]
satl_val = 0.0982862174 *
src + 0.0975682269 *
src[1] + 0.0961401078 *
src[2] + 0.0940230544 *
src[3] + 0.0912437090 *
src[4] + 0.0878391006 *
src[5] + 0.0838544303 *
src[6] + 0.0793406350 *
src[7] + 0.0743569346 *
src[8] + 0.0689666682 *
src[9] + 0.0632381578 *
src[10] + 0.0572428925 *
src[11] + 0.0510534242 *
src[12] + 0.0447468229 *
src[13] + 0.0383959950 *
src[14] + 0.0320735368 *
src[15] + 0.0258537721 *
src[16] + 0.0198005183 *
src[17] + 0.0139807863 *
src[18] + 0.0084512448 *
src[19] + 0.0032639979 *
src[20] - 0.0015350359 *
src[21] - 0.0059060082 *
src[22] - 0.0098190256 *
src[23] - 0.0132507215 *
src[24] - 0.0161875265 *
src[25] - 0.0186164872 *
src[26] - 0.0205446727 *
src[27] - 0.0219739146 *
src[28] - 0.0229204861 *
src[29] - 0.0234080863 *
src[30] - 0.0234566315 *
src[31] - 0.0231017777 *
src[32] - 0.0223796900 *
src[33] - 0.0213300463 *
src[34] - 0.0199924534 *
src[35] - 0.0184126992 *
src[36] - 0.0166377699 *
src[37] - 0.0147139428 *
src[38] - 0.0126796776 *
src[39] - 0.0105938331 *
src[40] - 0.0084736770 *
src[41] - 0.0063841850 *
src[42] - 0.0043466731 *
src[43] - 0.0023956944 *
src[44] - 0.0005535180 *
src[45] + 0.0011421469 *
src[46] + 0.0026845693 *
src[47] + 0.0040471369 *
src[48] + 0.0052380201 *
src[49] + 0.0062194591 *
src[50] + 0.0070340085 *
src[51] + 0.0076266453 *
src[52] + 0.0080376628 *
src[53] + 0.0083037666 *
src[54] + 0.0083694798 *
src[55] + 0.0082901022 *
src[56] + 0.0080741359 *
src[57] + 0.0077543820 *
src[58] + 0.0073260526 *
src[59] + 0.0068163569 *
src[60] + 0.0062325477 *
src[61] + 0.0056078229 *
src[62] + 0.0049516078 *
src[63] + 0.0161380976 *
src[64]
rstl_val = -0.0074151919 *
src - 0.0060698985 *
src[1] - 0.0044979052 *
src[2] - 0.0027054278 *
src[3] - 0.0007031702 *
src[4] + 0.0014951741 *
src[5] + 0.0038713513 *
src[6] + 0.0064043271 *
src[7] + 0.0090702334 *
src[8] + 0.0118431116 *
src[9] + 0.0146922652 *
src[10] + 0.0175884606 *
src[11] + 0.0204976517 *
src[12] + 0.0233865835 *
src[13] + 0.0262218588 *
src[14] + 0.0289681736 *
src[15] + 0.0315922931 *
src[16] + 0.0340614696 *
src[17] + 0.0363444061 *
src[18] + 0.0384120882 *
src[19] + 0.0402373884 *
src[20] + 0.0417969735 *
src[21] + 0.0430701377 *
src[22] + 0.0440399188 *
src[23] + 0.0446941124 *
src[24] + 0.0450230100 *
src[25] + 0.0450230100 *
src[26] + 0.0446941124 *
src[27] + 0.0440399188 *
src[28] + 0.0430701377 *
src[29] + 0.0417969735 *
src[30] + 0.0402373884 *
src[31] + 0.0384120882 *
src[32] + 0.0363444061 *
src[33] + 0.0340614696 *
src[34] + 0.0315922931 *
src[35] + 0.0289681736 *
src[36] + 0.0262218588 *
src[37] + 0.0233865835 *
src[38] + 0.0204976517 *
src[39] + 0.0175884606 *
src[40] + 0.0146922652 *
src[41] + 0.0118431116 *
src[42] + 0.0090702334 *
src[43] + 0.0064043271 *
src[44] + 0.0038713513 *
src[45] + 0.0014951741 *
src[46] - 0.0007031702 *
src[47] - 0.0027054278 *
src[48] - 0.0044979052 *
src[49] - 0.0060698985 *
src[50] - 0.0074151919 *
src[51] - 0.0085278517 *
src[52] - 0.0094111161 *
src[53] - 0.0100658241 *
src[54] - 0.0104994302 *
src[55] - 0.0107227904 *
src[56] - 0.0107450280 *
src[57] - 0.0105824763 *
src[58] - 0.0102517019 *
src[59] - 0.0097708805 *
src[60] - 0.0091581551 *
src[61] - 0.0084345004 *
src[62] - 0.0076214397 *
src[63] - 0.0067401718 *
src[64] - 0.0058083144 *
src[65] - 0.0048528295 *
src[66] - 0.0038816271 *
src[67] - 0.0029244713 *
src[68] - 0.0019911267 *
src[69] - 0.0010974211 *
src[70] - 0.0002535559 *
src[71] + 0.0005231953 *
src[72] + 0.0012297491 *
src[73] + 0.0018539149 *
src[74] + 0.0023994354 *
src[75] + 0.0028490136 *
src[76] + 0.0032221429 *
src[77] + 0.0034936183 *
src[78] + 0.0036818974 *
src[79] + 0.0038037944 *
src[80] + 0.0038338964 *
src[81] + 0.0037975350 *
src[82] + 0.0036986051 *
src[83] + 0.0035521320 *
src[84] + 0.0033559226 *
src[85] + 0.0031224409 *
src[86] + 0.0028550092 *
src[87] + 0.0025688349 *
src[88] + 0.0022682355 *
src[89] + 0.0073925495 *
src[90]
filtout =
dspfilttype == "FATL - Fast Adaptive Trend Line" ? fatl_val :
dspfilttype == "SATL - Slow Adaptive Trend Line" ? rftl_val :
dspfilttype == "RFTL - Reference Fast Trend Line" ? rftl_val :
satl_val
atrout =
BandsStyle == "True Range" ? ta.tr(true) :
BandsStyle == "Average True Range" ? variant_atr(atrType, ta.tr(true), atrper) :
variant_atr(atrType, high - low, atrper)
[avg, _, _] = variant(maintype, filtout, per)
dev = bandtype == "Keltner Channels" ? atrout : ta.stdev(filtout, bbper)
minUp = avg + dev * minMult
midUp = avg + dev * midMult
maxUp = avg + dev * maxMult
minDn = avg - dev * minMult
midDn = avg - dev * midMult
maxDn = avg - dev * maxMult
colorout = avg > avg[1] ? greencolor : redcolor
midplot = plot(avg, color = colorout, linewidth = 2)
plot(showmin ? minUp : na, "minUp", color = color.new(greencolor, 50))
plot(showmin ? minDn : na, "minDn", color = color.new(redcolor, 50))
plot(showmid ? midUp : na, "midUp", color = color.new(greencolor, 50))
plot(showmid ? midDn : na, "midDn", color = color.new(redcolor, 50))
mupplot = plot(showmax ? maxUp : na, "maxUp", color = color.new(greencolor, 50))
mdnplot = plot(showmax ? maxDn : na, "maxDn", color = color.new(redcolor, 50))
fill(mupplot, midplot, fillcolor ? color.new(greencolor, 95) : na)
fill(mdnplot, midplot, fillcolor ? color.new(redcolor, 95) : na)
barcolor(colorbars ? colorout : na)
|
3-Pole Super Smoother w/ EMA-Deviation-Corrected Stepping [Loxx] | https://www.tradingview.com/script/ix6HfjgF-3-Pole-Super-Smoother-w-EMA-Deviation-Corrected-Stepping-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("3-Pole Super Smoother w/ EMA-Deviation-Corrected Stepping [Loxx]",
shorttitle = "3PSSEMADCS [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/4
greencolor = #2DD204
redcolor = #D2042D
_ssf3(src, length) =>
arg = math.pi / length
a1 = math.exp(-arg)
b1 = 2 * a1 * math.cos(1.738 * arg)
c1 = math.pow(a1, 2)
coef4 = math.pow(c1, 2)
coef3 = -(c1 + b1 * c1)
coef2 = b1 + c1
coef1 = 1 - coef2 - coef3 - coef4
src1 = nz(src[1], src)
src2 = nz(src[2], src1)
src3 = nz(src[3], src2)
ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1], src1) + coef3 * nz(ssf[2], src2) + coef4 * nz(ssf[3], src3)
ssf
_corEmaDev(avg, price, period)=>
ema0 = 0., ema1 = 0., corr = 0.
alpha = 2.0 / (1.0 + period)
ema0 := ta.ema(price, period)
ema1 := ta.ema(price*price, period)
_deviation = math.max(math.sqrt(period * (ema1 - ema0 * ema0) / math.max(period - 1, 1)), 0.0)
v1 = math.pow(_deviation, 2)
v2 = math.pow(nz(corr[1]) - avg, 2)
c = (v2 < v1 or v2 == 0) ? 0 : 1 - v1 / v2
corr := nz(corr[1]) + c * (avg - nz(corr[1]))
corr
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= "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)
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
avg2 = _ssf3(src, per)
val = _corEmaDev(avg2, src, per)
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,"Corrected 3P super smoother", color = 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 = "3-Pole Super Smoother w/ EMA-Deviation-Corrected Stepping [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "3-Pole Super Smoother w/ EMA-Deviation-Corrected Stepping [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Zero-lag, 3-Pole Super Smoother [Loxx] | https://www.tradingview.com/script/6diRXJD2-Zero-lag-3-Pole-Super-Smoother-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("Zero-lag, 3-Pole Super Smoother [Loxx]",
shorttitle = "ZLAG3PSS [Loxx]",
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
_ssf3(src, length) =>
arg = math.pi / length
a1 = math.exp(-arg)
b1 = 2 * a1 * math.cos(1.738 * arg)
c1 = math.pow(a1, 2)
coef4 = math.pow(c1, 2)
coef3 = -(c1 + b1 * c1)
coef2 = b1 + c1
coef1 = 1 - coef2 - coef3 - coef4
src1 = nz(src[1], src)
src2 = nz(src[2], src1)
src3 = nz(src[3], src2)
ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1], src1) + coef3 * nz(ssf[2], src2) + coef4 * nz(ssf[3], src3)
ssf
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(21, "Period", group= "Basic Settings")
colorbars = input.bool(false, "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)
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
avg1 = _ssf3(src, per)
avg2 = _ssf3(avg1, per)
val = 2.0 * avg1 - avg2
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,"Zlag super smoother", color = contSwitch == 1 ? greencolor : redcolor, linewidth = 3)
barcolor(colorbars ? contSwitch == 1 ? greencolor : redcolor : na)
|
Binance Big Open Interest Delta Change v2 | https://www.tradingview.com/script/WxK6fThd-Binance-Big-Open-Interest-Delta-Change-v2/ | king_mob | https://www.tradingview.com/u/king_mob/ | 130 | 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/
// © king_mob
//@version=4
study("Big OI Delta Change v2")
cursym = tostring(syminfo.tickerid)
symname = tostring(cursym + "_OI")
uchoc = security(symname, timeframe.period, close)
uchoo = security(symname, timeframe.period, open)
delt = abs(uchoo-uchoc)
len = input(type=input.integer, title="MA Length", defval = 50)
deltma = sma(delt, len)
mltp = input(type=input.float, title="multiplier", defval=3)
deltmp = deltma*mltp
a1 = delt > deltmp and uchoc > uchoo
a2 = delt > deltmp and uchoc < uchoo
a3 = delt < deltmp
bgcolor(a1 ? color.blue : na, title="BIG OI OPEN", transp=70)
bgcolor(a2 ? color.orange : na, title="BIG OI CLOSE", transp=70)
bgcolor(a3 ? color.white : na, title="n/a", transp=0)
|
Fractal Candles | https://www.tradingview.com/script/AqdJEnqI-Fractal-Candles/ | roaffix | https://www.tradingview.com/u/roaffix/ | 107 | 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/
// © roaffix
// @version=4
// Fractal Candles | Toxic QR
study("Fractal Candles", shorttitle="Fractals", overlay=true)
x = input(title="Calculate Fractal by X candles", defval=5, minval=3)
index = if x%2
ceil(x/2)-1
else
round(x/2)-1
higher_fractal = if high[index] == highest(high, x)
high[index]
else
na
lower_fractal = if low[index] == lowest(low, x)
low[index]
else
na
plotshape(higher_fractal, style=shape.triangledown, location=location.abovebar, offset=-index, color=color.black)
plotshape(lower_fractal, style=shape.triangleup, location=location.belowbar, offset=-index, color=color.black) |
PopGun Trading, PG Pattern Detector | https://www.tradingview.com/script/zzIXINAG/ | Roul_Charts | https://www.tradingview.com/u/Roul_Charts/ | 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/
// © Roul_Charts
//@version=5
// PopGun Trading, PG Pattern Detector
// PG Detection by Wes Bennett (sorry - we work without ATR Calculation, and a lot of the ATR targets where unreachable)
// PG Box and CandleSize Calculation by Hawky_4s
// For the greatest Community
// June 2022
indicator(title='PopGun Trading, PG Pattern Detector', shorttitle="PG Tool", overlay=true)
// Inputs
GP0 = '===== Input ====='
PG_Box = input.bool(title='Show PG Box?', defval=false, group=GP0)
Bar_Color = input.bool(title='Change Bar Color on PG Candle?', defval=true, group=GP0)
Background_Color = input.bool(title='Change Background Color on PG Candle?', defval=true, group=GP0)
GP1 = '===== Targets ====='
Target1 = input.bool(title='Show Target 1?', defval=true, group=GP1)
Target2 = input.bool(title='Show Target 2?', defval=true, group=GP1)
Target3 = input.bool(title='Show Target 3?', defval=true, group=GP1)
Target4 = input.bool(title='Show Target 4?', defval=false, group=GP1)
Target5 = input.bool(title='Show Target 5?', defval=false, group=GP1)
Target6 = input.bool(title='Show Target 6?', defval=false, group=GP1)
// PG Detection
PG_Detector = high[2] >= high[1] and high[1] <= high and low[2] <= low[1] and low[1] >= low
//Not in Use as we think: a Pop Gun is neutral and the next candles will decide the bullish/bearish breakout. But i want to establish a switch to activate this extra mode...
// PG_Bull = high[2] >= high[1] and high[1] <= high and low[2] <= low[1] and low[1] >= low and close >= high[1]
// PG_Bear = high[2] >= high[1] and high[1] <= high and low[2] <= low[1] and low[1] >= low and close <= low[1]
//
// Calculations
//
candleSize = math.abs(high - low)
PG_high = high
PG_low = low
bulltarget1 = high + candleSize
bulltarget2 = high + candleSize * 2
bulltarget3 = high + candleSize * 3
bulltarget4 = high + candleSize * 4
bulltarget5 = high + candleSize * 5
bulltarget6 = high + candleSize * 6
beartarget1 = low - candleSize
beartarget2 = low - candleSize * 2
beartarget3 = low - candleSize * 3
beartarget4 = low - candleSize * 4
beartarget5 = low - candleSize * 5
beartarget6 = low - candleSize * 6
// Future Evaluations
// PG Breakout Calculation for next Version
//isUp = close > open
//isDown = close <= open
//isOutsideUp = high > high[1] and low < low[1] and isUp
//isOutsideDown = high > high[1] and low < low[1] and isDown
//isInside = high < high[1] and low > low[1]
//
// PG BOX
//
if PG_Box and PG_Detector
string labelText = "High:" + str.tostring(high, format.mintick) + "\n" +
"Low:" + str.tostring(low, format.mintick) + "\n" +
"Size:" + str.tostring(candleSize, format.mintick) + "\n\n" +
"Targets above:\n" +
"1. " + str.tostring(bulltarget1, format.mintick) + "\n" +
"2. " + str.tostring(bulltarget2, format.mintick) + "\n" +
"3. " + str.tostring(bulltarget3, format.mintick) + "\n\n" +
"Targets below:\n" +
"1. " + str.tostring(beartarget1, format.mintick) + "\n" +
"2. " + str.tostring(beartarget2, format.mintick) + "\n" +
"3. " + str.tostring(beartarget3, format.mintick)
label.new( x = bar_index, y = math.max(high, high[1]), text = labelText, textalign = text.align_left, color = color.new(color.orange, 50), textcolor = color.new(color.white, 0), style = label.style_label_lower_right, size = size.large)
//
// Activate Alert Menu
//
alertcondition(PG_Detector, title='PopGun Trigger', message='PG detected!')
//
// Plots and Colors
//
bgcolor((PG_Detector and Background_Color) ? color.new(color.rgb(179, 179, 179),80) : na, title='PG Candle Background')
barcolor((PG_Detector and Bar_Color) ? color.new(color.rgb(185, 46, 209),0) : na, title='PG Candle Color')
plot((PG_Detector and Target1) ? bulltarget1 : na, style=plot.style_circles, linewidth=6, title='Bullish Trade Target 1', color=color.new(color.rgb(102, 255, 102), 0))
plot((PG_Detector and Target2) ? bulltarget2 : na, style=plot.style_circles, linewidth=5, title='Bullish Trade Target 2', color=color.new(color.rgb(51, 204, 51), 0))
plot((PG_Detector and Target3) ? bulltarget3 : na, style=plot.style_circles, linewidth=4, title='Bullish Trade Target 3', color=color.new(color.rgb(0, 153, 51), 0))
plot((PG_Detector and Target4) ? bulltarget4 : na, style=plot.style_circles, linewidth=3, title='Bullish Trade Target 4', color=color.new(color.rgb(0, 153, 51), 0))
plot((PG_Detector and Target5) ? bulltarget5 : na, style=plot.style_circles, linewidth=2, title='Bullish Trade Target 5', color=color.new(color.rgb(0, 153, 51), 0))
plot((PG_Detector and Target6) ? bulltarget6 : na, style=plot.style_circles, linewidth=1, title='Bullish Trade Target 6', color=color.new(color.rgb(0, 153, 51), 0))
plot((PG_Detector and Target1) ? beartarget1 : na, style=plot.style_circles, linewidth=6, title='Bearish Trade Target 1', color=color.new(color.rgb(255, 0, 0), 0))
plot((PG_Detector and Target2) ? beartarget2 : na, style=plot.style_circles, linewidth=5, title='Bearish Trade Target 2', color=color.new(color.rgb(224, 31, 31), 0))
plot((PG_Detector and Target3) ? beartarget3 : na, style=plot.style_circles, linewidth=4, title='Bearish Trade Target 3', color=color.new(color.rgb(179, 0, 0), 0))
plot((PG_Detector and Target4) ? beartarget4 : na, style=plot.style_circles, linewidth=3, title='Bearish Trade Target 4', color=color.new(color.rgb(179, 0, 0), 0))
plot((PG_Detector and Target5) ? beartarget5 : na, style=plot.style_circles, linewidth=2, title='Bearish Trade Target 5', color=color.new(color.rgb(179, 0, 0), 0))
plot((PG_Detector and Target6) ? beartarget6 : na, style=plot.style_circles, linewidth=1, title='Bearish Trade Target 6', color=color.new(color.rgb(179, 0, 0), 0))
|
Movable Stop + Trail + Alert | https://www.tradingview.com/script/QgPhGdlx-Movable-Stop-Trail-Alert/ | coocoolikoo | https://www.tradingview.com/u/coocoolikoo/ | 97 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © coocoolikoo
//@version=5
indicator(title="movable SL and Trail + alert",shorttitle="Movable STOP + Trail + Alert",overlay=true)
y = input.price(0,'Entry',group='Lines', inline= 'Entry', confirm=true)
yBarTime = input.time(0,'',group='Lines', inline= 'Entry', confirm=true)
x = input.price(0,'Stop',group='Lines', inline= 'Stop', confirm=true)
xBarTime = input.time(0,'',group='Lines', inline= 'Stop', confirm=true)
//xTime = input.time(0,'',group='XABC', inline= '1', confirm=true)
activetrail = input.bool(defval=false, title = "Trail Stop Loss ",confirm=false)
activehalftp = input.bool(defval=false, title = "half target ",confirm=false)
lookback = input.int(defval=10, title="trail lookback", step = 1)
RR = input.int(defval=1, title="RR", step = 1)
atr = ta.atr(14)
/////
/////////////
stopsize=(y-x)
var stop = 0.0
var tp = 0.0
var tp1 = 0.0
if time > xBarTime
stop := ta.valuewhen(time > xBarTime,x,1)
tp := (stopsize* RR) +y
if activehalftp
tp1 := (stopsize* RR/2) +y
else
tp1 := na
////////////////
//////////////
var trailprice = 0.0
traillong = ta.lowest(low,lookback) - atr
trailshort = ta.highest(high,lookback) + atr
// Check for trailing stop update
if time >= xBarTime and barstate.isconfirmed and activetrail and (y>x)
// Trail long
if (trailprice < traillong or trailprice==0)
trailprice := traillong
if time >= xBarTime and barstate.isconfirmed and activetrail and (y<x)
// Trail short
if (trailprice > trailshort or trailprice==0)
trailprice := trailshort
////////////////
if trailprice != 0.0 and (low <= trailprice) and (y>x)
trailprice := na
if trailprice != 0.0 and high >= trailprice and (y<x)
trailprice := na
colorT = (x<y) and (trailprice < x) ? na : (x<y) and (trailprice > x) ? color.red : (x > y) and (trailprice > x) ? na : (x>y) and (trailprice < x) ? color.red : na
p1=plot((time > xBarTime ) ? x : na ,title="Stop Loss" ,color=color.red,style=plot.style_linebr)
p2=plot(time > yBarTime ? y : na ,title="Entry", color=color.gray,style=plot.style_linebr)
p3=plot(time > xBarTime ? tp : na ,title="Target", color=color.green,style=plot.style_linebr)
p5=plot(time > xBarTime ? tp1 : na ,title="Target", color=color.green,style=plot.style_linebr)
p4=plot((time > xBarTime) and activetrail ? trailprice : na ,title="trail stop long", color=colorT,style=plot.style_linebr)
//////ALERTS
if (y>x)
if (low < x)
alert("STOP REACHEAD !" + str.tostring(low), alert.freq_once_per_bar)
if (high > tp)
alert("TARGET REACHED !"+ str.tostring(high), alert.freq_once_per_bar)
if activehalftp and (high > tp1)
alert("HALF TARGET REACHED !"+ str.tostring(high), alert.freq_once_per_bar)
if activetrail and (low < trailprice)
alert("Price (" + str.tostring(low) + ") Hit the Trail stop.", alert.freq_once_per_bar)
if (y<x)
if (high > x)
alert("STOP REACHEAD !" + str.tostring(low), alert.freq_once_per_bar)
if (low < tp)
alert("TARGET REACHED !"+ str.tostring(high), alert.freq_once_per_bar)
if activehalftp and (low < tp1)
alert("HALF TARGET REACHED !"+ str.tostring(high), alert.freq_once_per_bar)
if activetrail and (high > trailprice)
alert("Price (" + str.tostring(high) + ") Hit the Trail stop.", alert.freq_once_per_bar)
StoplossPer = (y-x)/y*100
TargetPer = StoplossPer*RR
///table
drawTable = input.bool(true, "On/Off Table")
Xvalue = str.format("{0,number,currency}", x)
Yvalue = str.format("{0,number,currency}", y)
TPvalue = str.format("{0,number,currency}", tp)
HTPvalue = str.format("{0,number,currency}", tp1)
SLP = str.format("{0,number,#.#}", StoplossPer)
TPP = str.format("{0,number,#.#}", TargetPer)
var testTable = table.new(position = position.top_right, columns = 2, rows = 10 , bgcolor = color.rgb(0,8,12,100), border_width = 1)
if barstate.islast and drawTable
table.cell(table_id = testTable, column = 0, row = 0, text = "RR : " + str.tostring(RR),bgcolor=color.rgb(139, 137, 140,35),text_color=color.white)
table.cell(table_id = testTable, column = 0, row = 2, text = "SL : " + str.tostring(Xvalue), bgcolor=color.rgb(255, 0, 0,35),text_color=color.white)
table.cell(table_id = testTable, column = 0, row = 3, text = "E : " + str.tostring(Yvalue), bgcolor=color.rgb(139, 137, 140,35),text_color=color.white)
table.cell(table_id = testTable, column = 0, row = 4, text = "TP : " + str.tostring(TPvalue) , bgcolor=color.rgb(66, 255, 0,35),text_color=color.white)
if activetrail
table.cell(table_id = testTable, column = 0, row = 1, text = "Trail on " , bgcolor=color.rgb(255, 0, 0,35),text_color=color.white)
if activehalftp
table.cell(table_id = testTable, column = 0, row = 5, text = "HalfTP " + str.tostring(HTPvalue), bgcolor=color.rgb(66, 255, 0,35),text_color=color.white)
////label
labelon = input.bool(defval=true, title = "Labels ",confirm=false)
SLper = ((y-x)/y)*100
TPper = SLper * RR
HalfTPper = SLper * RR / 2
if y < x
SLper := -1 * SLper
TPper := -1 * TPper
HalfTPper := -1 * HalfTPper
s1 = str.format("{0,number,#.#}", SLper) // returns: 1.3
s2 = str.format("{0,number,#.#}", TPper) // returns: 1.3
s3 = str.format("{0,number,#.#}", HalfTPper) // returns: 1.3
if labelon
lab1 = label.new(bar_index, close, text=s2+"%", style=label.style_label_left,textcolor=color.white,tooltip="TP %")
label.set_xloc(lab1, time, xloc.bar_time)
label.set_color(lab1, color=color.new(color.green,50))
label.set_size(lab1, size.normal)
label.set_y(lab1, tp)
label.delete(lab1[1])
///SL
lab2 = label.new(bar_index, close, text=s1+"%", style=label.style_label_left,textcolor=color.white,tooltip="SL %")
label.set_xloc(lab2, time, xloc.bar_time)
label.set_color(lab2, color=color.new(color.red,50))
label.set_size(lab2, size.normal)
label.set_y(lab2, x)
label.delete(lab2[1])
if activehalftp
///halftp
lab3 = label.new(bar_index, close, text=s3+"%", style=label.style_label_left,textcolor=color.white,tooltip="HalfTP %")
label.set_xloc(lab3, time, xloc.bar_time)
label.set_color(lab3, color=color.new(color.green,50))
label.set_size(lab3, size.normal)
label.set_y(lab3, tp1)
label.delete(lab3[1]) |
Candle Imbalance | https://www.tradingview.com/script/RUimT03z-Candle-Imbalance/ | r_oshiro | https://www.tradingview.com/u/r_oshiro/ | 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/
// © r_oshiro
//@version=5
indicator("Candle Imbalance", overlay = true)
period = input(120, "Period")
bullishBars = 0.0
bearishBars = 0.0
for offset = 0 to period - 1
if close[offset] > open[offset]
bullishBars := bullishBars + 1
else
bearishBars := bearishBars + 1
bullishPc = math.ceil((bullishBars / period) * 100)
bearishPc = math.ceil((bearishBars / period) * 100)
printTable(txt) => var table t = table.new(position.top_right, 1, 1), table.cell(t, 0, 0, txt, bgcolor = color.yellow)
printTable("•Cutrim Theory•\n----------------\n Bullish bars: " + str.tostring(bullishBars) + " (" + str.tostring(bullishPc) + "%) \nBearish Bars: " + str.tostring(bearishBars)+ " (" + str.tostring(bearishPc) + "%)")
|
Range Bound Channel Index (RBCI) w/ Expanded Source Types [Loxx] | https://www.tradingview.com/script/QcvpUhxM-Range-Bound-Channel-Index-RBCI-w-Expanded-Source-Types-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 109 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Range Bound Channel Index (RBCI) [Loxx]",
shorttitle = "RBCI [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
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)"])
BBPeriod= input.int(100, "Bollinger Bands Period", group = "Basic Settings")
mult1 = input.int(1, "BB Multiplier 1", group = "Basic Settings")
mult2 = input.int(2, "BB Multiplier 2", group = "Basic Settings")
colorbars = input.bool(false, "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)
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
RBCI = - 35.524181940 *
src[0] - 29.333989650 *
src[1] - 18.427744960 *
src[2] - 5.3418475670 *
src[3] + 7.0231636950 *
src[4] + 16.176281560 *
src[5] + 20.656621040 *
src[6] + 20.326611580 *
src[7] + 16.270239060 *
src[8] + 10.352401270 *
src[9] + 4.5964239920 *
src[10] + 0.5817527531 *
src[11] - 0.9559211961 *
src[12] - 0.2191111431 *
src[13] + 1.8617342810 *
src[14] + 4.0433304300 *
src[15] + 5.2342243280 *
src[16] + 4.8510862920 *
src[17] + 2.9604408870 *
src[18] + 0.1815496232 *
src[19] - 2.5919387010 *
src[20] - 4.5358834460 *
src[21] - 5.1808556950 *
src[22] - 4.5422535300 *
src[23] - 3.0671459820 *
src[24] - 1.4310126580 *
src[25] - 0.2740437883 *
src[26] + 0.0260722294 *
src[27] - 0.5359717954 *
src[28] - 1.6274916400 *
src[29] - 2.7322958560 *
src[30] - 3.3589596820 *
src[31] - 3.2216514550 *
src[32] - 2.3326257940 *
src[33] - 0.9760510577 *
src[34] + 0.4132650195 *
src[35] + 1.4202166770 *
src[36] + 1.7969987350 *
src[37] + 1.5412722800 *
src[38] + 0.8771442423 *
src[39] + 0.1561848839 *
src[40] - 0.2797065802 *
src[41] - 0.2245901578 *
src[42] + 0.3278853523 *
src[43] + 1.1887841480 *
src[44] + 2.0577410750 *
src[45] + 2.6270409820 *
src[46] + 2.6973742340 *
src[47] + 2.2289941280 *
src[48] + 1.3536792430 *
src[49] + 0.3089253193 *
src[50] - 0.6386689841 *
src[51] - 1.2766707670 *
src[52] - 1.5136918450 *
src[53] - 1.3775160780 *
src[54] - 1.6156173970 *
src[55]
avg = ta.sma(RBCI, BBPeriod)
dev = ta.stdev(RBCI, BBPeriod)
up1 = avg + dev * mult1
up2 = avg + dev * mult2
dn1 = avg - dev * mult1
dn2 = avg - dev * mult2
colorout = -RBCI >= - avg ? greencolor : redcolor
plot(-RBCI, color = colorout, linewidth = 2)
plot(-up1, color = bar_index % 2 ? color.gray : na, linewidth = 1)
plot(-up2, color = bar_index % 2 ? color.gray : na, linewidth = 2)
plot(-dn1, color = bar_index % 2 ? color.gray : na, linewidth = 1)
plot(-dn2, color = bar_index % 2 ? color.gray : na, linewidth = 2)
ld = plot(-avg, color = color.white)
barcolor(colorbars ? colorout : na)
|
CFB Adaptive MOGALEF Bands [Loxx] | https://www.tradingview.com/script/LY0HXf0C-CFB-Adaptive-MOGALEF-Bands-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 103 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("CFB Adaptive MOGALEF Bands [Loxx]", overlay = true, shorttitle='CFBAMB [Loxx]', timeframe="", timeframe_gaps=true)
import loxx/loxxjuriktools/1
greencolor = #2DD204
redcolor = #D2042D
_rngcalc(src, int BandsPeriod, rngper)=>
lsum = (BandsPeriod + 1) * loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(low, rngper, 0), rngper, 0)
hsum = (BandsPeriod + 1) * loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(high, rngper, 0), rngper, 0)
sumw = (BandsPeriod + 1)
lsum := math.sum(BandsPeriod * nz(loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(low, rngper, 0), rngper, 0)), BandsPeriod)
hsum := math.sum(BandsPeriod * nz(loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(high, rngper, 0), rngper, 0)), BandsPeriod)
sumw := BandsPeriod * BandsPeriod
out = (hsum / sumw - lsum / sumw)
out
src = input.source(close, "Source", group = "Basic Settings")
inpPeriod = input.int(8, "Period", group = "Basic Settings")
bandstype = input.string("CFB Adaptive Range", "Source", options = ["Standard Deviation", "CFB Adaptive Range"], group = "Basic Settings")
devup = input.int(2, "Level Up Multiplier", group = "Basic Settings")
devdn = input.int(2, "Level Down Multiplier", group = "Basic Settings")
inpDeviationsPeriod = input.int(7, "Deviation Period", group = "Basic Settings")
rangePeriod = input.int(5, "Range Period", group = "Basic Settings")
nlen = input.int(50, "CFB Normal Period", minval = 1, group = "CFB Ingest Settings")
cfb_len = input.int(10, "CFB Depth", maxval = 10, group = "CFB Ingest Settings")
smth = input.int(8, "CFB Smooth Period", minval = 1, group = "CFB Ingest Settings")
slim = input.int(10, "CFB Short Limit", minval = 1, group = "CFB Ingest Settings")
llim = input.int(20, "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")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showfill = input.bool(true, "Fill Levels?", group = "UI Options")
linreg = ta.linreg(src, inpPeriod, 0)
levup = linreg
levdn = linreg
levmi = linreg
levup := nz(levup[1])
levdn := nz(levdn[1])
levmi := nz(levmi[1])
deviation = ta.stdev(linreg, inpDeviationsPeriod)
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))
rngout = bandstype == "Standard Deviation" ? deviation : _rngcalc(src, len_out_cfb, rangePeriod)
if (linreg > nz(levup[1]) or linreg < nz(levdn[1]))
levup := linreg + devup * rngout
levdn := linreg - devdn * rngout
levmi := linreg
up = plot(levup, "Level Up", color = greencolor)
dn = plot(levdn, "Level Down", color = redcolor)
mid = plot(levmi, "Mid", color = color.white)
fill(up, mid, color = showfill ? color.new(greencolor, 95) : na)
fill(dn, mid, color = showfill ? color.new(redcolor, 95) : na)
barcolor(colorbars ? close > levmi ? greencolor : redcolor : na)
|
Phase-Accumulation Adaptive EMA w/ Expanded Source Types [Loxx] | https://www.tradingview.com/script/TDAGCscR-Phase-Accumulation-Adaptive-EMA-w-Expanded-Source-Types-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 44 | study | 5 | MPL-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="Phase Accumulation, EMA w/ Expanded Source Types [Loxx]", shorttitle="PAEMAEST [Loxx]", overlay=true, max_bars_back = 3000)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
EMA(x, t) =>
_ema = x
_ema := na(_ema[1]) ? x : (x - nz(_ema[1])) * (2 / (t + 1)) + nz(_ema[1])
_ema
calcComp(src, period)=>
out = (
(0.0962 * src +
0.5769 * src[2] -
0.5769 * src[4] -
0.0962 * src[6]) * (0.075 * src[1] + 0.54))
out
_prout(src, mult, filt)=>
Smooth = 0.00
Detrender = 0.00
I1 = 0.00
Q1 = 0.00
Period = 0.00
DeltaPhase = 0.00
InstPeriod = 0.00
PhaseSum = 0.00
Phase = 0.
_period = 0.
Smooth := bar_index > 5 ? (4 * src + 3 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 10 : Smooth
ts = calcComp(Smooth, Period)
Detrender := bar_index > 5 ? ts : Detrender
qs = calcComp(Detrender, Period)
Q1 := bar_index > 5 ? qs : Q1
I1 := bar_index > 5 ? nz(Detrender[3]) : I1
I1 := .15 * I1 + .85 * nz(I1[1])
Q1 := .15 * Q1 + .85 * nz(Q1[1])
Phase := nz(Phase[1])
Phase := math.abs(I1) > 0 ? 180.0 / math.pi * math.atan(math.abs(Q1 / I1)) : Phase
Phase := I1 < 0 and Q1 > 0 ? 180 - Phase : Phase
Phase := I1 < 0 and Q1 < 0 ? 180 + Phase : Phase
Phase := I1 > 0 and Q1 < 0 ? 360 - Phase : Phase
DeltaPhase := nz(Phase[1]) - Phase
DeltaPhase := nz(Phase[1]) < 90 and Phase > 270 ? 360 + nz(Phase[1]) - Phase : DeltaPhase
DeltaPhase := math.max(math.min(DeltaPhase, 60), 7)
InstPeriod := nz(InstPeriod[1])
PhaseSum := 0
count = 0
while (PhaseSum < mult * 360 and count < 4500)
PhaseSum += nz(DeltaPhase[count])
count := count + 1
InstPeriod := count > 0 ? count : InstPeriod
alpha = 2.0 / (1.0 + math.max(filt, 1))
_period := nz(_period[1]) + alpha * (InstPeriod - nz(_period[1]))
_period := math.floor(_period) < 1 ? 1 : math.floor(_period)
math.floor(_period)
smthtype = input.string("Kaufman", "Heiken-Ashi 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)"])
regcycles = input.float(1, title = "EMA PA Cycles", group= "Basic Settings")
regfilter = input.float(1, title = "EMA PA Filter", group= "Basic Settings")
kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
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
int fout = math.floor(_prout(src, regcycles, regfilter))
val = EMA(src, fout)
colorout = val > val[1]? greencolor : redcolor
plot(val, color = colorout, linewidth = 3)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(val, val[1])
goShort = ta.crossunder(val, val[1])
alertcondition(goLong, title = "Long", message = "Phase Accumulation, EMA w/ Expanded Source Types [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "Phase Accumulation, EMA w/ Expanded Source Types [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Future Preview | https://www.tradingview.com/script/BAR25Pky-Future-Preview/ | DFS_trading | https://www.tradingview.com/u/DFS_trading/ | 75 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DFS_trading
//@version=5
indicator("Future Preview", overlay=true)
typeS = input.string("Long","Order Type",["Long","Short"],confirm=true)
showTime = input.bool(true,"Show order open time",confirm=true)
openTime = input.time(timestamp("01 JUL 2022 00:00 -0000"), "open time",confirm=true)
if not showTime
openTime := timestamp("01 JAN 2020 00:00 -0000")
openPrice = input.price(0,"Open Price (USDT)",confirm=true)
margin = input.float(100,"Cash (USDT)")
leverage = input.float(10,"leverage")
tradingFee = input.float(0.06,"commission taker(%)")
showNum = input.bool(false,"show Cash")
hasTargetP = input.bool(false,"Take Profit",inline="TP")
targetP = input.float(0,"| TP price",inline="TP")
hasTargetL = input.bool(false,"Stop Loss",inline="SL")
targetL = input.float(0,"| SL price",inline="SL")
winC = input.color(color.green,"profit color",inline="color",group="drawing")
lossC = input.color(color.red,"loss color",inline="color",group="drawing")
bgTrans = input.float(80,"background color transparency",minval=0.0, maxval=100.0, step=5.0,inline="color",group="drawing")
sizeS = input.string("Large","Font Size",["Large","Normal","Small"],group="drawing")
textsize = size.large
if str.contains(sizeS,"Normal")
textsize := size.normal
if str.contains(sizeS,"Small")
textsize := size.small
var long = true
openColor=winC
if str.contains(typeS,"Short")
long := false
if not long
openColor := lossC
rtColor=winC
var preview = box.new(0,0,0,0)
box.delete(preview)
var openB = box.new(bar_index+5,openPrice,bar_index+25,openPrice)
box.delete(openB)
oBtop = 0.0
oBbot = 0
openB := box.new(bar_index+5,openPrice,bar_index+25,openPrice)
if close > openPrice
box.set_top(openB,openPrice)
box.set_bottom(openB, openPrice * 0.9999)
box.set_text_valign(openB,text.align_top)
else
box.set_top(openB, openPrice * 1.0001)
box.set_bottom(openB,openPrice)
box.set_text_valign(openB,text.align_bottom)
priceChange = close - openPrice
priceChangePerc = math.round(priceChange / openPrice,5)
change = priceChange
if not long
change := 0 - change
changePerc = math.round(change/openPrice,5)
openFee = margin * leverage * tradingFee * 0.01
newMargin = math.round(margin * (1+changePerc*leverage),2)
closeFee = newMargin * leverage * tradingFee * 0.01
profit = math.round(newMargin - margin - closeFee - openFee,2)
if profit < 0
rtColor := lossC
tpC= color.rgb(0,0,0,255) // transparent color
preview := box.new(bar_index+5,close*1.001,right=bar_index+25,bottom=close)
if close < openPrice
box.set_top(preview,close)
box.set_bottom(preview,close*0.999)
box.set_text_valign(preview,text.align_top)
else
box.set_text_valign(preview,text.align_bottom)
box.set_bgcolor(preview,tpC)
box.set_border_color(preview,tpC)
box.set_text_color(preview,rtColor)
st = typeS
if profit > 0
st += " Gaining profit"
else
st += " Loss"
if showNum
st += "\nGain: " + str.tostring(profit) +""
st += "\nGain percentage: " + str.tostring(math.round(profit/margin*100,2)) + "%"
st += "\nPrice Change: "
st += priceChange > 0 ? "↑ " : "↓ "
st += str.tostring(priceChangePerc*100) + "%"
box.set_text_halign(preview,text.align_left)
box.set_text(preview, st)
box.set_text_size(preview,textsize)
box.set_bgcolor(openB,tpC)
box.set_border_color(openB,tpC)
box.set_text_color(openB,rtColor)
ot = "Open Price:" + str.tostring(openPrice)
box.set_text(openB,ot)
box.set_text_size(openB,textsize)
box.set_text_halign(openB,text.align_left)
var openPriceL = line.new(x1=openTime,y1=openPrice, x2 = openTime+1, y2=openPrice, xloc=xloc.bar_time, extend=extend.right,color=openColor,width=2)
var openTimeL = line.new(x1=openTime,y1=openPrice,x2=openTime,y2=openPrice*1.001,xloc=xloc.bar_time,extend=extend.both,color=openColor)
var markL = line.new(x1=bar_index+5,y1=close,x2=bar_index+25,y2=close)
line.delete(markL)
markL := line.new(x1=bar_index+5,y1=close,x2=bar_index+25,y2=close,color=rtColor,width=2)
var markLv = line.new(x1=bar_index+15,y1=close,x2=bar_index+15,y2=openPrice)
line.delete(markLv)
markLv := line.new(x1=bar_index+15,y1=close,x2=bar_index+15,y2=openPrice,color=rtColor,width=2,xloc=xloc.bar_index)
var markB = box.new(openTime,openPrice,time,close,xloc=xloc.bar_time)
box.delete(markB)
markB := box.new(openTime,openPrice,openTime+1,close,xloc=xloc.bar_time,border_color=tpC,border_width=0,extend=extend.right,bgcolor=color.new(rtColor,bgTrans))
// target profit
var targetPL = line.new(x1=bar_index,y1=targetP,x2=bar_index+5,y2=targetP)
line.delete(targetPL)
var targetPB = box.new(left=bar_index+25,top=targetP*1.05,right=bar_index+40,bottom=targetP)
box.delete(targetPB)
if hasTargetP
tk = 1.05
bk = 1.0
if not long
tk := 1.0
bk := 0.95
targetPB := box.new(bar_index+25,targetP*tk,bar_index+45,targetP*bk,bgcolor=tpC,border_color=tpC)
targetPT = "TP Price:" + str.tostring(targetP)
tpc = math.abs(targetP-openPrice)
tpcs = tpc
if not long
tpcs := - tpcs
tpcsp = tpcs / openPrice
tpcsp := math.round(tpcsp,5)
tpcp = tpc / openPrice
tpnm = math.round(margin * (1+tpcp*leverage),2)
tpp = tpnm - margin - openFee - tpnm*leverage*tradingFee * 0.01
tpp := math.round(tpp,2)
if showNum
targetPT += "\nProfit:" + str.tostring(tpp)
tppp = math.round(tpp / margin,5) // target profit profit percentage
targetPT += "\nProfit Rate:" + str.tostring(tppp*100) + "%"
targetPT += "\nPrice Change:"
targetPT += tpcsp > 0 ? "↑ " : "↓ "
targetPT += str.tostring(tpcsp*100) + "%"
box.set_text(targetPB,targetPT)
box.set_text_color(targetPB,color.new(winC,30))
box.set_text_valign(targetPB,text.align_bottom)
if not long
box.set_text_valign(targetPB,text.align_top)
box.set_text_size(targetPB,textsize)
targetPL := line.new(x1=bar_index+25,y1=targetP,x2=bar_index+45,y2=targetP, color=winC,extend=extend.both)
// target loss
var targetLL = line.new(x1=bar_index+25,y1=targetL,x2=bar_index+40,y2=targetL)
line.delete(targetLL)
var targetLB = box.new(left=bar_index+25,top=targetL*1.05,right=bar_index+40,bottom=targetL)
box.delete(targetLB)
if hasTargetL
tk = 1.0
bk = 0.95
if not long
tk := 1.05
bk := 1.0
targetLB := box.new(bar_index+25,targetL*tk,bar_index+45,targetL*bk,bgcolor=tpC,border_color=tpC)
targetLT = "SL Price:" + str.tostring(targetL)
tlc = math.abs(targetL-openPrice)
tlcs = tlc
if long
tlcs := - tlcs
tlcsp = tlcs / openPrice
tlcsp := math.round(tlcsp,5)
tlcp = tlc / openPrice
tlnm = math.round(margin * (1+tlcp*leverage),2)
tlp = margin - tlnm - openFee - tlnm*leverage*tradingFee * 0.01
tlp := math.round(tlp,2)
if showNum
targetLT += "\nLoss:" + str.tostring(tlp)
tlpp = math.round(tlp / margin,5)
targetLT += "\nLoss Rate:" + str.tostring(tlpp*100) + "%"
targetLT += "\nPrice Change:"
targetLT += tlcsp > 0 ? "↑ " : "↓ "
targetLT += str.tostring(tlcsp*100) + "%"
box.set_text(targetLB,targetLT)
box.set_text_color(targetLB,color.new(lossC,30))
box.set_text_valign(targetLB,text.align_top)
if not long
box.set_text_valign(targetLB,text.align_bottom)
box.set_text_size(targetLB,textsize)
targetLL := line.new(x1=bar_index-5,y1=targetL,x2=bar_index+ 40,y2=targetL, color=color.new(lossC,30),extend=extend.both)
|
support and resistance by qutubkoreja | https://www.tradingview.com/script/QK3OzVQf-support-and-resistance-by-qutubkoreja/ | qutubkoreja | https://www.tradingview.com/u/qutubkoreja/ | 177 | 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/
// © qutubkoreja
//@version=4
study("Bullseye Borders", overlay=true, max_bars_back = 600, precision=2)
//DC Channels
length = input(55, minval=1, title="DC Length")
lower = lowest (length)
upper = highest(length)
basis = avg(upper, lower)
uppp = avg(upper, basis)
dwww = avg(lower, basis)
up1= avg(upper, uppp)
dw1 = avg(lower,dwww)
up2 = avg(uppp, up1)
dw2 = avg(dwww, dw1)
up3 = avg(upper, up1)
dw3 = avg(lower, dw1)
up4 = avg(basis, up2)
dw4 = avg(basis, dw2)
up5 = avg(basis, up4)
dw5 = avg(basis, dw4)
p0 = plot(basis, color=color.orange, title="Middle Line", linewidth=1, transp=100)
p1 = plot(up1, "Up1", color=color.red, title="Up1", linewidth=1, transp=100)
p2 = plot(dw1, "Dw1", color=color.green, title="Dw1", linewidth=1, transp=100)
p3 = plot(up2, "Up2", color=color.red, title="Up2", linewidth=1, transp=100)
p4 = plot(dw2, "Dw2", color=color.green, title="Dw2", linewidth=1, transp=100)
p5 = plot(up3, "Up3", color=color.maroon, title="Up3", linewidth=1, transp=0)
p6 = plot(dw3, "Dw3", color=color.navy,title="Dw3", linewidth=1, transp=0)
p7 = plot(up4, "Up4", color=color.blue, title="Up4", linewidth=1, transp=100)
p8 = plot(dw4, "Dw4", color=color.blue, title="Dw4", linewidth=1, transp=100)
p9 = plot(up5, "Up5", color=color.orange, title="Up5", linewidth=1, transp=0)
p10 = plot(dw5, "Dw5", color=color.orange, title="Dw5", linewidth=1, transp=0)
fill(p7, p8, color=color.blue, transp=100, title="Middle Area")
fill(p3, p1, color=color.red, transp=70, title="Short Area")
fill(p4, p2, color=color.green, transp=70, title="Long Area")
fill(p9, p10, color=color.orange, transp=70, title="Stop Area")
// Script for Boring Candles
BcB_Ratio = input(30, title="Tight Candle Body <=(%)",minval=5, maxval=95)
C2BR=(abs(open-close)*100/abs(high-low))
barcolor(C2BR<=BcB_Ratio ? color.navy:na)
//ALMA Alert Line (if you want to use price for alert)
src = input(close, title="Source")
len = input(5, title="Arnaud Legoux MA Length", type=input.integer, minval=1)
offset = input(0.9, title="ALMA Offset", type=input.float, minval=0.0001)
sigma = input(21, title="ALMA Sigma Value", type=input.integer, minval=1)
Alma = alma(src, len, offset, sigma)
plot(Alma, color=color.black, linewidth=1, transp=100)
// Script for the Last Hifh and Low (Breakout Trend Follower)
pvtLenL = 3
pvtLenR = 3
pvthi_ = pivothigh(high, pvtLenL, pvtLenR)
pvtlo_ = pivotlow(low, pvtLenL, pvtLenR)
stopBuff = input(0.0, minval=-2, maxval=2, title="Multi")
stopPerc = stopBuff*.01
stopLevel = valuewhen(pvtlo_, low[pvtLenR], 0)
stopLevel2 = stopLevel - stopLevel*stopPerc
plot(stopLevel2, style=plot.style_line, color=color.aqua, show_last=1, linewidth=2, transp=0, trackprice=true)
buyLevel = valuewhen(pvthi_, high[pvtLenR], 0)
buyLevel2 = buyLevel + buyLevel*stopPerc
plot(buyLevel2, style=plot.style_line, color=color.red, show_last=1, linewidth=2, transp=0, trackprice=true) |
[FR]Custom Candles/FVG/nSideBar | https://www.tradingview.com/script/jdTVOd7P-FR-Custom-Candles-FVG-nSideBar/ | FFriZz | https://www.tradingview.com/u/FFriZz/ | 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/
// © FFriZz
//@version=5
indicator("Custom Candles",overlay = true,max_lines_count = 500,max_labels_count = 500,max_boxes_count = 500,explicit_plot_zorder = true)
//Inputs//
//Bar Switch//
MESSAGE = input.text_area("🔥 🔥 🔥 🔥 🔥 Custom Candles 🔥 🔥 🔥 🔥 🔥\nDon't hide your Candles!! Turn the transparency in chart settings down or\nyou can check the boxes and turn them off very inconvenient if you have\nyour candles turned off when changing charts.. I've now learned.. =D\nand this removes the Price Label on the Y-axis/bar countdown/and ticker\nwould still move to top of object tree..\n\n⇩ ⇩ ⇩ ⇩ ⇩ ⇩ ⇩ ⇩ ----- UPDATES ----- ⇩ ⇩ ⇩ ⇩ ⇩ ⇩ ⇩\n\n-I added a Price Line option so now you can have a \nSolid-Dashed-Dotted and Arrow Style for the Price Line with a Price Label\nthat you can move along the X-axis and the Price Line is adjustable from\nleft to right\n-I added a price line that you can make how ever you want\n-I added added an option to change color of price line by tick\n-Theres a couple of labels that will change direction with price aswell\nand now there is a tooltip that has OHLC values just hover over the label\n\nI posted pictures on the chart of the indicator download if you didn't \nunderstand what settings exactly I'm referring too\n\nMessage me if you have any questions, or if there is a bug\nits hard to catch everything\nI understand this is over kill but after people liked it I figured id make it as customizable as possible\n\nHope you enjoy!\n💲💰 FFriZz 💰💲\n",'README')
SLIM = input.bool(false,'SLIM Candles' ,group = 'Candle MODE',inline = '')
NORMAL = input.bool(true,'NORMAL Candles' ,group = 'Candle MODE',inline = '')
if SLIM == true
NORMAL := false
if NORMAL == true
SLIM := false
//Price Line//
pllineonoff = input.bool(true ,'Price Line | On/Off?' ,group = 'Price Line')
lstyle = input.string('Solid','Price Line Style',options = ['Solid','Dashed','Dotted','Arrow Right','Arrow Left','Arrow Both'] ,group = 'Price Line', inline = 'a')
plinew = input.int(1 ,'Width -->' ,group = 'Price Line', inline = 'a')
extend = input.string('Extend Both','Extend Price Line',options = ['Extend Both','Extend None','Extend Right','Extend Left'] ,group = 'Price Line', inline = 'a')
offset1 = input.int(0,'Price Line offset Left -->' ,group = 'Price Line', inline = 'b', maxval = 0)
offset2 = input.int(5,'Price Line offset Right -->' ,group = 'Price Line', inline = 'b', minval = 0)
linetick = input.bool(true ,'Change Line Color on Up/Down Ticks | On/Off?' ,group = 'Price Line')
//Price Label//
pllabelonoff = input.bool(true ,'Price Label | On/Off?' ,group = 'Price Label', inline = 'd')
labeloffset = input.int(5,'Label offset -->' ,group = 'Price Label', inline = 'e')
lblsize = input.string('Normal','Label Size',options = ['Auto','Tiny','Small','Normal','Large','Huge'] ,group = 'Price Label', inline = 'e')
lblstyle = input.string('arrow','Price Label Style -->' ,options = ['NONE','arrow','circle','cross','diamond','label_center','label_down','label_left','label_lower_left','label_lower_right','label_right','label_up','label_upper_left','label_upper_right','square','flag','triangle'] ,group = 'Price Label' ,inline = 'h')
lbltick = input.bool(true ,'Change Label Color on Up/Down Ticks | On/Off?' ,group = 'Price Label')
//FVG//
FVG = input.bool(true ,'FVG | On/Off?' ,group = 'FVG')
FVGplot = input.bool(true ,'FVG Type | (Big FVG = On) | (SLIM FVG = off)' ,group = 'FVG')
FVGw = input.int(2 ,'Small FVG Width -->' ,group = 'FVG' ,inline = '1')
//Inside Bar//
ISB = input.bool(true ,'INSIDE BAR | On/Off?' ,group = 'INSIDE-Bar' ,inline = '')
ISBplot = input.bool(false ,'ISB Type | (Big ISB = On) | (SLIM ISB = off)' ,group = 'INSIDE-Bar' ,inline = '')
ISBw = input.int (2 ,'Big ISB Width -->' ,group = 'INSIDE-Bar' ,inline = '')
upc = open < close
//Colors//
labelbgup = input.color(color.lime ,'Label --> Up' ,group = 'Price Label' ,inline = 'f')
labelbgdown = input.color(color.red ,'Down' ,group = 'Price Label' ,inline = 'f')
labeltextup = input.color(#000000 ,'Label Text --> Up' ,group = 'Price Label' ,inline = 'g')
labeltextdown = input.color(#000000 ,'Down' ,group = 'Price Label' ,inline = 'g')
PriceCup = input.color(color.lime ,'Price Line --> Up' ,group = 'Price Line' ,inline = 'c')
PriceCdown = input.color(color.red ,'Down' ,group = 'Price Line' ,inline = 'c')
BULLfvgc = input.color(color.white ,'BullFVG -->' ,group = 'FVG' ,inline = '1')
BEARfvgc = input.color(color.white ,'BearFVG --> ' ,group = 'FVG' ,inline = '1')
//?: Colors//
ISBc = upc ? input.color(color.white ,'ISB --> Bull' ,group = 'INSIDE-Bar' ,inline = '3') :
input.color(color.white ,'Bear' ,group = 'INSIDE-Bar' ,inline = '3')
NORMALtwickc = upc ? input.color(color.red ,'NORMAL | Top Wick --> Up' ,group = 'NORMAL Candle' ,inline = 'tw') :
input.color(color.red ,'Down' ,group = 'NORMAL Candle' ,inline = 'tw')
NORMALbwickc = upc ? input.color(color.lime ,'NORMAL | Bottom Wick --> Up' ,group = 'NORMAL Candle' ,inline = 'bw') :
input.color(color.lime ,'Down' ,group = 'NORMAL Candle' ,inline = 'bw')
NORMALbodyc = upc ? input.color(#000000 ,'NORMAL | Body --> Up' ,group = 'NORMAL Candle' ,inline = 'body') :
input.color(#000000 ,'Down' ,group = 'NORMAL Candle' ,inline = 'body')
NORMALborderc = upc ? input.color(#000000 ,'NORMAL | Border --> Up' ,group = 'NORMAL Candle' ,inline = 'border') :
input.color(#000000 ,'Down' ,group = 'NORMAL Candle' ,inline = 'border')
SLIMtwickc = upc ? input.color(color.red ,'SLIM | Top Wick --> Up' ,group = 'SLIM Candle' ,inline = 'tw') :
input.color(color.red ,'Down' ,group = 'SLIM Candle' ,inline = 'tw')
SLIMbwickc = upc ? input.color(color.lime ,'SLIM | Bottom Wick --> Up' ,group = 'SLIM Candle' ,inline = 'bw') :
input.color(color.lime ,'Down' ,group = 'SLIM Candle' ,inline = 'bw')
SLIMbodyc = upc ? input.color(#000000 ,'SLIM | Body --> Up' ,group = 'SLIM Candle' ,inline = 'bs') :
input.color(#000000 ,'Down' ,group = 'SLIM Candle' ,inline = 'bs')
SLIMborderctop = upc ? input.color(#000000 ,'SLIM | Top (o,c) --> Up' ,group = 'SLIM Candle' ,inline = 'bordert') :
input.color(#000000 ,'Down' ,group = 'SLIM Candle' ,inline = 'bordert')
SLIMbordercbot = upc ? input.color(#000000 ,'SLIM | Bottom (o,c) --> Up' ,group = 'SLIM Candle' ,inline = 'borderb') :
input.color(#000000 ,'Down' ,group = 'SLIM Candle' ,inline = 'borderb')
SLIMoc = input.bool (true ,'SLIM Bar | (Open and Close Line) | On/Off?' ,group = 'SLIM Candle' ,inline = 'bs')
//Tick & Bar Color Change//
varip bool lblip = na
varip bool lineip = na
varip ipclose = close
int ip = 0
if ta.change(close)
if ipclose > close
ip := -1
if ipclose < close
ip := 1
ipclose := close
if lbltick
lblip := ip > 0
if linetick
lineip := ip > 0
PriceC = linetick ? lineip ? PriceCup : PriceCdown : upc ? PriceCup : PriceCdown
labelbg = lbltick ? lblip ? labelbgup : labelbgdown : upc ? labelbgup : labelbgdown
labeltext = lbltick ? lblip ? labeltextup : labeltextdown : upc ? labeltextup : labeltextdown
//Vars - Conditions//
sbt = upc ? close : open
sbb = upc ? open : close
ISBar = ISB and high < high[1] and low > low[1]
BearFVG = high < low[2] and FVG
BullFVG = low > high[2] and FVG
FVGc = BullFVG ? BULLfvgc : BEARfvgc
//Switches//
Linestyle = switch lstyle
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
'Arrow Right' => line.style_arrow_right
'Arrow Left' => line.style_arrow_left
'Arrow Both' => line.style_arrow_both
=> na
Extend = switch extend
'Extend Both' => extend.both
'Extend None' => extend.none
'Extend Right' => extend.right
'Extend Left' => extend.left
=> na
Labelstyle = switch lblstyle
'arrow' => lbltick ? lblip ? label.style_arrowup : label.style_arrowdown : upc ? label.style_arrowup : label.style_arrowdown
'circle' => label.style_circle
'cross' => label.style_cross
'diamond' => label.style_diamond
'label_center' => label.style_label_center
'label_down' => label.style_label_down
'label_left' => label.style_label_left
'label_lower_left' => label.style_label_lower_left
'label_lower_right' => label.style_label_lower_right
'label_right' => label.style_label_right
'label_up' => label.style_label_up
'label_upper_left' => label.style_label_upper_left
'label_upper_right' => label.style_label_upper_right
'square' => label.style_square
'flag' => label.style_flag
'triangle' => lbltick ? lblip ? label.style_triangleup : label.style_triangledown : upc ? label.style_triangleup : label.style_triangledown
=> label.style_none
Labelsize = switch lblsize
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal
'Large' => size.large
'Huge' => size.huge
'Auto' => size.auto
=> na
// FVGs w/ Lines//
if (BullFVG or BearFVG) and not FVGplot
line1 = line.new(
bar_index - 1,
BearFVG ? low[2] : high[2],
bar_index - 1,
BearFVG ? high : low,
width = FVGw,
color = FVGc
)
// ISBs w/ Lines for an adjustable ISB Width//
if ISBar and ISBplot
line2 = line.new(
bar_index,
open,
bar_index,
close,
width = ISBw,
color = ISBc
)
//SLIM top and bot wicks//
plotcandle(SLIM ? sbt : na, high ,high, sbt, color = na ,bordercolor = na ,wickcolor = SLIMtwickc ,editable = false)
plotcandle(SLIM ? sbb : na, low ,low , sbb, color = na ,bordercolor = na ,wickcolor = SLIMbwickc ,editable = false)
//SLIM borders//
plotcandle(SLIM ? sbt : na ,sbt ,sbt ,sbt ,color = na ,bordercolor = SLIMoc ? SLIMborderctop : na ,wickcolor = na ,editable = false)
plotcandle(SLIM ? sbb : na ,sbb ,sbb ,sbb ,color = na ,bordercolor = SLIMoc ? SLIMbordercbot : na ,wickcolor = na ,editable = false)
//SLIM body//
plotcandle(SLIM ? close : na ,open ,open ,close ,color = na ,bordercolor = na ,wickcolor = ISBar ? ISBc : SLIMbodyc ,editable = false)
//NORMAL border,body,wicks//
plotcandle(NORMAL ? open : na ,high , low ,close ,color = ISBar and not ISBplot ? ISBc : NORMALbodyc ,bordercolor = NORMALborderc ,wickcolor = na ,editable = false)
plotcandle(NORMAL ? sbt : na ,high ,high , sbt ,color = na ,bordercolor = na ,wickcolor = NORMALtwickc ,editable = false)
plotcandle(NORMAL ? sbb : na ,low , low , sbb ,color = na ,bordercolor = na ,wickcolor = NORMALbwickc ,editable = false)
//Sticking with the Theme custom Price/Line and Label//
var label Label = na
var line Line = na
if pllabelonoff
label.delete(Label)
Label := label.new(bar_index + labeloffset, close, text = str.tostring(close) + (Labelstyle == 'NONE' ? '\n\n' : ''), color = labelbg, style = Labelstyle, textcolor = labeltext, size = Labelsize, tooltip =
'---- OHLC ----\n' + 'Open: ' + str.tostring(open) + '\nHigh: ' + str.tostring(high) + '\nLow: ' + str.tostring(low) + '\nClose: ' + str.tostring(close))
if pllineonoff
line.delete(Line)
Line := line.new(bar_index + offset1, close, last_bar_index + offset2, close, extend = Extend, color = PriceC, style = Linestyle, width = plinew)
// Another Option For Price Line ⇊ //
// plot(close, color = color.lime, show_last = 1, offset = -99999999, trackprice = true)
//To make sure the FVG plotting pairs are skipping a bar incase of back to back FVG's
bool BearFVGp = false
bool BullFVGp = false
if BearFVG
BearFVGp := true
if BearFVGp == true and BearFVGp[1] == true
BearFVGp := false
if BullFVG
BullFVGp := true
if BullFVGp == true and BullFVGp[1] == true
BullFVGp := false
BullGO1 = BullFVG and BullFVGp
BearGO1 = BearFVG and BearFVGp
BullGO2 = BullFVG and BullGO1 == false
BearGO2 = BearFVG and BearGO1 == false
//Bear-Bull FVG plots//
//Plots Need Sequences to prevent the fills from forming to plot lines and covering 2 bars if another FVG is on next Bar
//Can have Bear and Bull in each plot pair because you cant have a Bull and Bear FVG on the Same bar
//-- Pair 1 -- //
p1 = plot(FVGplot ?
BearGO1 ? low[2] : BullGO1 ? low : na : na,
style = plot.style_stepline,
offset=-1, display = display.none,
editable = false)
p2 = plot(FVGplot ?
BearGO1 ? high : BullGO1 ? high[2] : na : na,
style = plot.style_stepline,
offset=-1, display = display.none,
editable = false)
fill(p1,p2,color = FVGc[1], editable = false)
//-- Pair 2 -- //
p3 = plot(FVGplot ?
BearGO2 ? low[2] : BullGO2 ? low : na : na,
style = plot.style_stepline,
offset=-1, display = display.none,
editable = false)
p4 = plot(FVGplot ?
BearGO2 ? high : BullGO2 ? high[2] : na : na,
style = plot.style_stepline,
offset=-1, display = display.none,
editable = false)
fill(p3,p4,color = FVGc[1], editable = false)
|
BT Leading Candle Indicator | https://www.tradingview.com/script/s80XW3Pk-BT-Leading-Candle-Indicator/ | Baiju89 | https://www.tradingview.com/u/Baiju89/ | 96 | 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/
// © Baiju89
//@version=4
study("BT Leading Candle Indicator", overlay=false)
//functions
xrf(values, length) =>
r_val = float(na)
if length >= 1
for i = 0 to length by 1
if na(r_val) or not na(values[i])
r_val := values[i]
r_val
r_val
xsa(src,len,wei) =>
sumf = 0.0
ma = 0.0
out = 0.0
sumf := nz(sumf[1]) - nz(src[len]) + src
ma := na(src[len]) ? na : sumf/len
out := na(out[1]) ? ma : (src*wei+out[1]*(len-wei))/len
out
// inputs
n1 = input(30, title="n1", type=input.integer, minval = 1)
//threshold lines
h1 = hline(80,color=color.red, linestyle=hline.style_dotted)
h2 = hline(20, color=color.yellow, linestyle=hline.style_dotted)
h3 = hline(30,color=color.lime, linestyle=hline.style_dotted)
h4 = hline(90, color=color.fuchsia, linestyle=hline.style_dotted)
fill(h2,h3,color=color.yellow,transp=70)
fill(h1,h4,color=color.fuchsia,transp=70)
//KDJ indicator
rsv = (close-lowest(low,n1))/(highest(high,n1)-lowest(low,n1))*100
k = xsa(rsv,3,1)
d = xsa(k,3,1)
buysig = iff(d<25 and crossover(k,d) ,30,0)
selsig = iff(d>75 and crossunder(d,k) ,70,100)
//plot buy and sell signal
ple = plot(buysig,color=color.green, linewidth=1,style=plot.style_area, transp=0)
pse = plot(selsig,color=color.red, linewidth=2,style=plot.style_line, transp=0)
//plot KD candles
plotcandle(k, d, k, d, color=k>=d?color.green:na)
plotcandle(k, d, k, d, color=d>k?color.red:na)
// KDJ leading line
var1 = (close-sma(close,13))/sma(close,13)*100
var2 = (close-sma(close,26))/sma(close,21)*100
var3 = (close-sma(close,90))/sma(close,34)*100
var4 = (var1+3*var2+9*var3)/13
var5 = (100-abs(var4))
var10 = lowest(low,10)
var13 = highest(high,25)
leadingline = ema((close-var10)/(var13-var10)*4,4)*25
pbias = plot(leadingline,color=k>=d?color.green:color.red, linewidth=4,style=plot.style_line, transp=10)
|
STD-Stepped, CFB-Adaptive Jurik Filter w/ Variety Levels [Loxx] | https://www.tradingview.com/script/R6ieGJn8-STD-Stepped-CFB-Adaptive-Jurik-Filter-w-Variety-Levels-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 80 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("STD-Stepped, CFB-Adaptive Jurik Filter w/ Variety Levels [Loxx]",
shorttitle='STDSCFBADJFVL [Loxx] [Loxx]',
overlay = true,
timeframe="",
timeframe_gaps = true)
import loxx/loxxjuriktools/1
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
_filt(src, len, filter)=>
price = src
filtdev = filter * ta.stdev(src, len)
price := math.abs(price - price[1]) < filtdev ? price[1] : price
price
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = input.string("HAB Trend Biased (Extreme)", "Source", group= "Source Settings",
options =
["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average", "Average Median Body", "Trend Biased", "Trend Biased (Extreme)",
"HA Close", "HA Open", "HA High", "HA Low", "HA Median", "HA Typical", "HA Weighted", "HA Average", "HA Average Median Body", "HA Trend Biased", "HA Trend Biased (Extreme)",
"HAB Close", "HAB Open", "HAB High", "HAB Low", "HAB Median", "HAB Typical", "HAB Weighted", "HAB Average", "HAB Average Median Body", "HAB Trend Biased", "HAB Trend Biased (Extreme)"])
phase = input.float(0, "Jurik Phase", group= "Basic Settings")
double = input.string("Single", "Jurik Smoothing Double", options = ["Single", "Double"], group= "Basic Settings")
doubleatr = input.string("Single", "Jurik ATR Adaption Smoothing Double", options = ["Single", "Double"], group= "Basic Settings")
filterop = input.string("Both", "Filter Options", options = ["Price", "Jurik 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")
leveltype = input.string("Floating", "Levels Type", options = ["Floating", "Quantile"], group= "Levels Settings")
levelper = input.int(35, "Levels Period", minval = 0, group= "Levels Settings")
flLevelUp = input.float(90, "Levels Up Level %", group = "Levels Settings")
flLevelDown = input.float(20, "Levels Down Level %", group = "Levels Settings")
nlen = input.int(50, "CFB Normal Period", minval = 1, group = "CFB Ingest Settings")
cfb_len = input.int(10, "CFB Depth", maxval = 10, group = "CFB Ingest Settings")
smth = input.int(8, "CFB Smooth Period", minval = 1, group = "CFB Ingest Settings")
slim = input.int(10, "CFB Short Limit", minval = 1, group = "CFB Ingest Settings")
llim = input.int(20, "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")
colorbars = input.bool(true, "Color bars?", group= "UI Options")
showfloat = input.bool(true, "Show Levels?", group = "UI Options")
showfill = input.bool(true, "Fill Levels?", group = "UI Options")
colorneut = input.bool(true, "Use neutral zones?", group = "UI Options")
showSigs = input.bool(true, "Show signals?", group= "UI Options")
showBg = input.bool(false, "Color background??", group= "UI Options")
kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
float src = switch srcoption
"Close" => loxxexpandedsourcetypes.rclose()
"Open" => loxxexpandedsourcetypes.ropen()
"High" => loxxexpandedsourcetypes.rhigh()
"Low" => loxxexpandedsourcetypes.rlow()
"Median" => loxxexpandedsourcetypes.rmedian()
"Typical" => loxxexpandedsourcetypes.rtypical()
"Weighted" => loxxexpandedsourcetypes.rweighted()
"Average" => loxxexpandedsourcetypes.raverage()
"Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
"Trend Biased" => loxxexpandedsourcetypes.rtrendb()
"Trend Biased (Extreme)" => loxxexpandedsourcetypes.rtrendbext()
"HA Close" => loxxexpandedsourcetypes.haclose(haclose)
"HA Open" => loxxexpandedsourcetypes.haopen(haopen)
"HA High" => loxxexpandedsourcetypes.hahigh(hahigh)
"HA Low" => loxxexpandedsourcetypes.halow(halow)
"HA Median" => loxxexpandedsourcetypes.hamedian(hamedian)
"HA Typical" => loxxexpandedsourcetypes.hatypical(hatypical)
"HA Weighted" => loxxexpandedsourcetypes.haweighted(haweighted)
"HA Average" => loxxexpandedsourcetypes.haaverage(haaverage)
"HA Average Median Body" => loxxexpandedsourcetypes.haavemedbody(haclose, haopen)
"HA Trend Biased" => loxxexpandedsourcetypes.hatrendb(haclose, haopen, hahigh, halow)
"HA Trend Biased (Extreme)" => loxxexpandedsourcetypes.hatrendbext(haclose, haopen, hahigh, halow)
"HAB Close" => loxxexpandedsourcetypes.habclose(smthtype, amafl, amasl, kfl, ksl)
"HAB Open" => loxxexpandedsourcetypes.habopen(smthtype, amafl, amasl, kfl, ksl)
"HAB High" => loxxexpandedsourcetypes.habhigh(smthtype, amafl, amasl, kfl, ksl)
"HAB Low" => loxxexpandedsourcetypes.hablow(smthtype, amafl, amasl, kfl, ksl)
"HAB Median" => loxxexpandedsourcetypes.habmedian(smthtype, amafl, amasl, kfl, ksl)
"HAB Typical" => loxxexpandedsourcetypes.habtypical(smthtype, amafl, amasl, kfl, ksl)
"HAB Weighted" => loxxexpandedsourcetypes.habweighted(smthtype, amafl, amasl, kfl, ksl)
"HAB Average" => loxxexpandedsourcetypes.habaverage(smthtype, amafl, amasl, kfl, ksl)
"HAB Average Median Body" => loxxexpandedsourcetypes.habavemedbody(smthtype, amafl, amasl, kfl, ksl)
"HAB Trend Biased" => loxxexpandedsourcetypes.habtrendb(smthtype, amafl, amasl, kfl, ksl)
"HAB Trend Biased (Extreme)" => loxxexpandedsourcetypes.habtrendbext(smthtype, amafl, amasl, kfl, ksl)
=> haclose
cfb_draft = loxxjuriktools.jcfb(src, cfb_len, smth)
cfb_pre = doubleatr ==
"Double" ? 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))
price = filterop == "Both" or filterop == "Price" and filter > 0 ? _filt(src, filterperiod, filter) : src
jmaout = double ==
"Double" ? loxxjuriktools.jurik_filt(loxxjuriktools.jurik_filt(price, len_out_cfb, phase), len_out_cfb, phase) :
loxxjuriktools.jurik_filt(price, len_out_cfb, phase)
out = filterop == "Both" or filterop == "Jurik Filter" and filter > 0 ? _filt(jmaout, filterperiod, filter) : jmaout
mini = ta.lowest(out, levelper)
maxi = ta.highest(out, levelper)
rrange = maxi-mini
maxq = ta.percentile_linear_interpolation(out, levelper, flLevelUp)
minq = ta.percentile_linear_interpolation(out, levelper, flLevelDown)
midq = (maxq + minq)/2
flu = leveltype == "Floating" ? mini + flLevelUp * rrange/100.0 : maxq
fld = leveltype == "Floating" ? mini + flLevelDown * rrange/100.0 : minq
flm = leveltype == "Floating" ? mini + 0.5 * rrange : midq
top = plot(showfloat ? flu : na, "Top level", color = color.new(greencolor, 50), linewidth = 1)
bot = plot(showfloat ? fld : na, "Bottom level", color = color.new(redcolor, 50), linewidth = 1)
mid = plot(showfloat ? flm : na, "Mid level", color = color.new(color.white, 10), linewidth = 1)
fill(top, mid, title = "Top level fill color", color = showfill ? color.new(greencolor, 95) : na)
fill(bot, mid,title = "Bottom level fill color", color = showfill ? color.new(redcolor, 95) : na)
coloroutneut =
out > out[1] and out > flu ? greencolor :
out < out[1] and out < fld ? redcolor :
color.gray
colorout =
out > out[1] ? greencolor :
redcolor
plot(out,"Adaptive Jurik Filter", color = colorneut ? coloroutneut : colorout, linewidth = 3)
barcolor(colorbars ? colorneut ? coloroutneut : colorout : na)
goLong_pre = colorneut ? ta.crossover(out, flu) : ta.crossover(out, out[1])
goShort_pre = colorneut ? ta.crossunder(out, fld) : ta.crossunder(out, out[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)
plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.small)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.small)
alertcondition(goLong, title="Long", message="Ehlers Step OTF: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Ehlers Step OTF: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
coloroutneutbg =
out > out[1] and out > flu ? color.new(greencolor, 95) :
out < out[1] and out < fld ? color.new(redcolor, 95) :
na
coloroutbg =
out > out[1] ? color.new(greencolor, 95) :
color.new(redcolor, 95)
bgcolor(showBg ? colorneut ? coloroutneutbg : coloroutbg : na)
|
Pips Stepped VHF-Adaptive VMA w/ Expanded Source Types [Loxx] | https://www.tradingview.com/script/Ag2g44iE-Pips-Stepped-VHF-Adaptive-VMA-w-Expanded-Source-Types-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 132 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("Pips Stepped VHF-Adaptive VMA w/ Expanded Source Types [Loxx]",
shorttitle = "PSVHFAVMA [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
_calcBaseUnit() =>
bool isForexSymbol = syminfo.type == "forex"
bool isYenPair = syminfo.currency == "JPY"
float result = isForexSymbol ? isYenPair ? 0.01 : 0.0001 : syminfo.mintick
result
smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Source Settings")
srcoption = input.string("HAB Trend Biased (Extreme)", "Source", group= "Source Settings",
options =
["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average", "Average Median Body", "Trend Biased", "Trend Biased (Extreme)",
"HA Close", "HA Open", "HA High", "HA Low", "HA Median", "HA Typical", "HA Weighted", "HA Average", "HA Average Median Body", "HA Trend Biased", "HA Trend Biased (Extreme)",
"HAB Close", "HAB Open", "HAB High", "HAB Low", "HAB Median", "HAB Typical", "HAB Weighted", "HAB Average", "HAB Average Median Body", "HAB Trend Biased", "HAB Trend Biased (Extreme)"])
inpPeriod = input.int(10, "VMA Period", group = "Basic Settings")
inpPeriod2 = input.int(15, "VHF Period", group = "Basic Settings")
steps = input.float(4.0, "Steps in Pips", 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)
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
_stepSize = (steps > 0 ? steps : 0) * _calcBaseUnit() * math.pow(10, _declen() % 2)
avg = 0.
alpha = 2.0 / (1.0 + inpPeriod)
vmaxrsi = ta.highest(src, inpPeriod2)
vminrsi = ta.lowest(src, inpPeriod2)
noisersi = math.sum(math.abs(ta.change(src)), inpPeriod2)
vhfrsi = math.abs(vmaxrsi - vminrsi) / noisersi
avg := nz(avg[1]) + (alpha * vhfrsi * 2.0) * (src - nz(avg[1]))
val = 0.
valc = 0.
vals = 0.
if (_stepSize > 0)
_diff = avg - nz(val[1])
val := nz(val[1]) + ((_diff < _stepSize and _diff > -_stepSize) ? 0 : int(_diff / _stepSize) * _stepSize)
else
val := (_stepSize > 0) ? math.round(avg / _stepSize) * _stepSize : avg
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,"Stepped VMA", color = 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.small)
plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.small)
alertcondition(goLong, title="Long", message="Pips Stepped VHF-Adaptive VMA w/ Expanded Source Types [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title="Short", message="Pips Stepped VHF-Adaptive VMA w/ Expanded Source Types [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
|
Diversified Investment EMA Cross Strategy Simulator | https://www.tradingview.com/script/IywefNS2-Diversified-Investment-EMA-Cross-Strategy-Simulator/ | Dicargo_Beam | https://www.tradingview.com/u/Dicargo_Beam/ | 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/
// © Dicargo_Beam
//@version=5
indicator("Diversified Investment EMA Cross Only Long Strategy Capital Change",format=format.inherit,precision=0)
//Thank you Pinecoders. About security function without repainting
f_security(_sym, _res, _src) =>
barstate.isconfirmed? request.security(_sym, _res, _src[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1] :na
Plot = input.string("Total Assets Capital Change",title="Capital Change Graph", options=["Total Assets Capital Change", "Each Asset Capital Change", "Asset 1 Capital Change", "Asset 2 Capital Change", "Asset 3 Capital Change", "Asset 4 Capital Change", "Asset 5 Capital Change", "Asset 6 Capital Change", "Asset 7 Capital Change", "Asset 8 Capital Change"])
//Start Date
start_year = input.int(2016, "Start Year")
start_month = input.int(1, "Start Month")
start_day = input.int(1, "Start Day")
bool start = false
if barstate.isconfirmed
start := time > timestamp(start_year, start_month, start_day)
initial_capital = input.float(1000.0,"Initial Capital")
loss_percent = -input.float(2.00,"Loss Percent %",tooltip = "Stop loss when the asset price falls by ?%")/100
commission = 1-input.float(0.0200,"Commission %")/100
c1 = input.color(#FA5858,"", inline="1")
c2 = input.color(#F7BE81,"", inline="2")
c3 = input.color(#F4FA58,"", inline="3")
c4 = input.color(#2EFE2E,"", inline="4")
c5 = input.color(#2EFEF7,"", inline="5")
c6 = input.color(#2E64FE,"", inline="6")
c7 = input.color(#AC58FA,"", inline="7")
c8 = input.color(#FE2EC8,"", inline="8")
Asset_1 = input.symbol("COMEX:GC1!", title = "Asset 1 (Gold) ", inline="1") //Gold
Asset_2 = input.symbol("CBOT:ZC1!", title = "Asset 2 (Corn) ", inline="2") //Corn
Asset_3 = input.symbol("ICEUS:SB1!", title = "Asset 3 (Sugar) ", inline="3") //Sugar
Asset_4 = input.symbol("CME:LE1!", title = "Asset 4 (Cattle) ", inline="4") //Cattle
Asset_5 = input.symbol("CME:6J1!", title = "Asset 5 (Japanese yen) ", inline="5") //Japanese yen
Asset_6 = input.symbol("CBOT:ZN1!", title = "Asset 6 (10y T-Note) ", inline="6") //10 Year T-Note Futures
Asset_7 = input.symbol("COMEX:SI1!", title = "Asset 7 (Silver) ", inline="7") //Silver
Asset_8 = input.symbol("NYMEX:CL1!", title = "Asset 8 (Crude Oil) ", inline="8") //Crude Oil WTI
//array(0 price, 1 entry_price, 2 exit_price, 3 input_capital, 4 output_capital, 5 direction (1,-1), 6 on_trade (1, 0))
var float[] asset_1 = array.new_float(7)
var float[] asset_2 = array.new_float(7)
var float[] asset_3 = array.new_float(7)
var float[] asset_4 = array.new_float(7)
var float[] asset_5 = array.new_float(7)
var float[] asset_6 = array.new_float(7)
var float[] asset_7 = array.new_float(7)
var float[] asset_8 = array.new_float(7)
_get_value(arr, ticker, loss_percent, commission) =>
if start and not start[1]
array.set(arr, 3, initial_capital/8)
array.set(arr, 4, initial_capital/8)
array.set(arr, 6, 0)
c = f_security(ticker,"D",close)
sep = f_security(ticker,"D",ta.ema(close,50)-ta.ema(close,200))
array.set(arr, 0, c)
array.set(arr, 5, sep > 0? 1 : -1)
profit = array.get(arr,0)/array.get(arr,1)-1
//set entry and on trade
if ta.crossover(array.get(arr,5),0)
array.set(arr, 1, c)
array.set(arr,6, 1)
//set exit and off trade
else if ta.crossunder(array.get(arr,5),0)
array.set(arr,6, 0)
array.set(arr,2, c)
else if profit < loss_percent and profit[1] > loss_percent
array.set(arr,6, 0)
array.set(arr,2, c)
//capital change
if array.get(arr,6) == 1
array.set(arr,4,array.get(arr,0)/array.get(arr,1) * array.get(arr,3)*commission)
else if array.get(arr,6) == 0 and array.get(arr,6)[1] == 1
array.set(arr,4,array.get(arr,2)/array.get(arr,1) * array.get(arr,3)*commission)
else if array.get(arr,6) == 0 and array.get(arr,6)[1] == 0
array.set(arr,3,array.get(arr,4))
if barstate.isconfirmed and start
_get_value(asset_1, Asset_1, loss_percent, commission)
_get_value(asset_2, Asset_2, loss_percent, commission)
_get_value(asset_3, Asset_3, loss_percent, commission)
_get_value(asset_4, Asset_4, loss_percent, commission)
_get_value(asset_5, Asset_5, loss_percent, commission)
_get_value(asset_6, Asset_6, loss_percent, commission)
_get_value(asset_7, Asset_7, loss_percent, commission)
_get_value(asset_8, Asset_8, loss_percent, commission)
bool p0 = false, p1 = false, p2 = false, p3 = false, p4 = false, p5 = false, p6 = false, p7 = false, p8 = false
if Plot == "Total Assets Capital Change"
p0 := true
else if Plot == "Each Asset Capital Change"
p1 := true, p2 := true, p3:=true, p4:=true, p5:=true, p6:=true, p7:=true, p8:=true
else if Plot == "Asset 1 Capital Change"
p1 := true
else if Plot == "Asset 2 Capital Change"
p2 := true
else if Plot == "Asset 3 Capital Change"
p3 := true
else if Plot == "Asset 4 Capital Change"
p4 := true
else if Plot == "Asset 5 Capital Change"
p5 := true
else if Plot == "Asset 6 Capital Change"
p6 := true
else if Plot == "Asset 7 Capital Change"
p7 := true
else if Plot == "Asset 8 Capital Change"
p8 := true
t_cap = array.get(asset_1,4)+array.get(asset_2,4)+array.get(asset_3,4)+array.get(asset_4,4)+array.get(asset_5,4)+array.get(asset_6,4)+array.get(asset_7,4)+array.get(asset_8,4)
a1_cap = array.get(asset_1,4), a2_cap = array.get(asset_2,4), a3_cap = array.get(asset_3,4), a4_cap = array.get(asset_4,4)
a5_cap = array.get(asset_5,4), a6_cap = array.get(asset_6,4), a7_cap = array.get(asset_7,4), a8_cap = array.get(asset_8,4)
plot(p0? t_cap:na, title = "Total Assets Capital Change", color=#F6CED8)
plot(p1? a1_cap:na, title = "Asset 1 Capital Change", color=c1)
plot(p2? a2_cap:na, title = "Asset 2 Capital Change", color=c2)
plot(p3? a3_cap:na, title = "Asset 3 Capital Change", color=c3)
plot(p4? a4_cap:na, title = "Asset 4 Capital Change", color=c4)
plot(p5? a5_cap:na, title = "Asset 5 Capital Change", color=c5)
plot(p6? a6_cap:na, title = "Asset 6 Capital Change", color=c6)
plot(p7? a7_cap:na, title = "Asset 7 Capital Change", color=c7)
plot(p8? a8_cap:na, title = "Asset 8 Capital Change", color=c8)
plot(start and p0? initial_capital : na, title = "Initial Capital", color=color.gray)
plot(start and (not(p0) or Plot == "Each Asset Capital Change")? initial_capital/8 : na, title = "Initial Capital / 8", color=color.gray)
signal(arr) =>
if array.get(arr,6)==1 and array.get(arr,6)[1]==0
1
else if array.get(arr,6)==0 and array.get(arr,6)[1]==1
0
_label(Plot) =>
bool buy = false
bool sell = false
float y = 0.0
var label buy_label = na
var label sell_label = na
if Plot == "Asset 1 Capital Change"
buy := signal(asset_1) == 1
sell := signal(asset_1) == 0
y := array.get(asset_1,4)
else if Plot == "Asset 2 Capital Change"
buy := signal(asset_2) == 1
sell := signal(asset_2) == 0
y := array.get(asset_2,4)
else if Plot == "Asset 3 Capital Change"
buy := signal(asset_3) == 1
sell := signal(asset_3) == 0
y := array.get(asset_3,4)
else if Plot == "Asset 4 Capital Change"
buy := signal(asset_4) == 1
sell := signal(asset_4) == 0
y := array.get(asset_4,4)
else if Plot == "Asset 5 Capital Change"
buy := signal(asset_5) == 1
sell := signal(asset_5) == 0
y := array.get(asset_5,4)
else if Plot == "Asset 6 Capital Change"
buy := signal(asset_6) == 1
sell := signal(asset_6) == 0
y := array.get(asset_6,4)
else if Plot == "Asset 7 Capital Change"
buy := signal(asset_7) == 1
sell := signal(asset_7) == 0
y := array.get(asset_7,4)
else if Plot == "Asset 8 Capital Change"
buy := signal(asset_8) == 1
sell := signal(asset_8) == 0
y := array.get(asset_8,4)
if buy
buy_label := label.new(bar_index, y*0.98, color=color.green, size=size.tiny, style=label.style_label_up, text="buy", textcolor=color.white)
if sell
sell_label := label.new(bar_index, y*1.02, color=color.red, size=size.tiny, style=label.style_label_down, text = "sell", textcolor=color.white)
_label(Plot)
var table Table = na
Table := table.new(position = position.bottom_right, columns = 1, rows = 8, bgcolor = na, border_width = 1)
if barstate.islast
table.cell(Table, column = 0, row = 0, text = "1. " + Asset_1, text_color= c1, text_halign = text.align_left)
table.cell(Table, column = 0, row = 1, text = "2. " + Asset_2, text_color= c2, text_halign = text.align_left)
table.cell(Table, column = 0, row = 2, text = "3. " + Asset_3, text_color= c3, text_halign = text.align_left)
table.cell(Table, column = 0, row = 3, text = "4. " + Asset_4, text_color= c4, text_halign = text.align_left)
table.cell(Table, column = 0, row = 4, text = "5. " + Asset_5, text_color= c5, text_halign = text.align_left)
table.cell(Table, column = 0, row = 5, text = "6. " + Asset_6, text_color= c6, text_halign = text.align_left)
table.cell(Table, column = 0, row = 6, text = "7. " + Asset_7, text_color= c7, text_halign = text.align_left)
table.cell(Table, column = 0, row = 7, text = "8. " + Asset_8, text_color= c8, text_halign = text.align_left)
|
SMA EMA Bands [CraftyChaos] | https://www.tradingview.com/script/1LHCxB3C-SMA-EMA-Bands-CraftyChaos/ | CraftyChaos | https://www.tradingview.com/u/CraftyChaos/ | 20 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CraftyChaos
//
// @version=5
//
// Generates Bands between EMA and SMA and their average. I find price tends to hit one of these lines, and sometimes
// the average of the two.
indicator("SMA EMA Bands [CraftyChaos]", overlay=true)
// INPUTS
p1 = input(9, "Nine Period")
p2 = input(20, "Short Period")
p3 = input(50, "Medium Period")
p4 = input(200, "Long Period")
// COLORS
color p1c1 = color.gray
color p1c2 = color.gray
color p2c1 = #ce93d8
color p2c2 = #ba68c8
color p3c1 = #26c6da
color p3c2 = #0097a7
color p4c1 = #fbc02d
color p4c2 = #f57f17
// TA
p1ema = ta.ema(close,p1)
p1sma = ta.sma(close,p1)
p2ema = ta.ema(close,p2)
p2sma = ta.sma(close,p2)
p3ema = ta.ema(close,p3)
p3sma = ta.sma(close,p3)
p4ema = ta.ema(close,p4)
p4sma = ta.sma(close,p4)
// COLORS AGAIN
color p1cf = p1ema > p1sma ? color.new(p1c1,90) : color.new(p1c2,90)
color p2cf = p2ema > p2sma ? color.new(p2c1,90) : color.new(p2c2,90)
color p3cf = p3ema > p3sma ? color.new(p3c1,90) : color.new(p3c2,90)
color p4cf = p4ema > p4sma ? color.new(p4c1,90) : color.new(p4c2,90)
// PLOTS
p1p1 = plot(p1ema, color=p1c1)
p1p2 = plot(p1sma, color=p1c2)
p1p3 = plot((p1sma+p1ema)/2,color=p1c1, style=plot.style_cross)
p2p1 = plot(p2ema, color=p2c1)
p2p2 = plot(p2sma, color=p2c2)
p2p3 = plot((p2sma+p2ema)/2,color=p2c1, style=plot.style_cross)
p3p1 = plot(p3ema, color=p3c1)
p3p2 = plot(p3sma, color=p3c2)
p3p3 = plot((p3sma+p3ema)/2,color=p3c1, style=plot.style_cross)
p4p1 = plot(p4ema, color=p4c1)
p4p2 = plot(p4sma, color=p4c2)
p4p3 = plot((p4sma+p4ema)/2,color=p4c1, style=plot.style_cross)
// FILLS
fill(p1p1, p1p2, color=p1cf)
fill(p2p1, p2p2, color=p2cf)
fill(p3p1, p3p2, color=p3cf)
fill(p4p1, p4p2, color=p4cf) |
Bobbin Detector | https://www.tradingview.com/script/v7M14fDf-Bobbin-Detector/ | coinsspor | https://www.tradingview.com/u/coinsspor/ | 565 | 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/
// © coinsspor
//@version=4
study("Bobbin Detector", overlay =true)
i = input(title="Bobbin Sensibility", type=input.float, defval=2.5, minval=0.1, maxval=10,step=0.1)
BW = input(title="Bobbin Box Width", type=input.integer, defval=140, minval=50, maxval=500,step=5)
bobin4a=close<close[1] and close[1]>close[2] and close[2]<close[3] and close[3]>close[4]
bobin4b=close>close[1] and close[1]<close[2] and close[2]>close[3] and close[3]<close[4]
Dizibobin4 = array.new_float()
array.unshift(Dizibobin4, abs(close-open))
array.unshift(Dizibobin4, abs(close[1]-open[1]))
array.unshift(Dizibobin4, abs(close[2]-open[2]))
array.unshift(Dizibobin4, abs(close[3]-open[3]))
buyuk4=array.max(Dizibobin4)
kucuk4=array.min(Dizibobin4)
oran4=buyuk4/kucuk4
kapanis4ENB=max(close,close[1],close[2],close[3])
acilis4ENK=min(open,open[1],open[2],open[3])
var box bobinkutu = na
if (( bobin4a or bobin4b )and oran4<=i)
bobinkutu := box.new(left=bar_index-4, top=kapanis4ENB,right=bar_index + BW, border_color=color.red ,bottom=acilis4ENK,border_width=1, bgcolor=color.new(color.red, 80))
|
even_better_sinewave_mod | https://www.tradingview.com/script/RZHPy8H2-even-better-sinewave-mod/ | palitoj_endthen | https://www.tradingview.com/u/palitoj_endthen/ | 58 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © palitoj_endthen
//@version=5
indicator(title = 'even_better_sinewave_modified', shorttitle = 'even_better_sinewave', overlay = false, timeframe = '', timeframe_gaps = true)
// input
hp_period = input.int(defval = 89, title = 'High-pass Period', group = 'Value', tooltip = 'Determines the length of High-pass period.')
src = input.source(defval = ohlc4, title = 'Source', group = 'Options', tooltip = 'Determines the input data, default to ohlc4, user could change to other input e.g. close.')
apply_bar_color = input.bool(defval = false, title = 'Bar color', group = 'Options', tooltip = 'Determines whether to apply bar color, based on even better sinewave indicator signal')
// variable
alpha1 = 0.0
hp = 0.0
filt = 0.0
wave = 0.0
pwr = 0.0
// even better sinewave
// high-pass filter
pi = 2*math.asin(1)
alpha1 := (math.cos(.707*2*pi/hp_period) + math.sin(.707*2*pi/hp_period)-1)/math.cos(.707*2*pi/hp_period)
hp := (1-alpha1/2)*(1-alpha1/2)*(src-2*src[1]+src[2])+2*(1-alpha1)*nz(hp[1])-(1-alpha1)*(1-alpha1)*nz(hp[2])
// smoothed (modified)
filt := (7*hp+6*hp[1]+5*hp[2]+4*hp[3]+3*hp[4]+2*hp[5]+hp[6])/28
// 3 bar average of wave amplitude and power
wave := (filt+filt[1]+filt[2])/3
pwr := (filt*filt+filt[1]*filt[1]+filt[2]*filt[2])/3
// normalize
wave := wave/math.sqrt(pwr)
// Visualize
// color condition
con = 0
if wave < -.8
con := con
else if wave > wave[1]
con := 1
else if wave > .8
con := 1
else if wave < wave[1]
con := con
color_ = con == 1 ? color.green : color.red
// sine wave
p1 = plot(wave, color = color_, linewidth = 3)
plot(wave*.8, color = color.new(color.aqua, 80))
// threshold
// h1 = hline(.85, linewidth = 1, color = color.new(color.yellow, 50), linestyle = hline.style_solid)
// h2 = hline(.75, linewidth = 1, color = color.new(color.yellow, 50), linestyle = hline.style_solid)
// fill(h1, h2, color = color.new(color.yellow, 80))
// h3 = hline(-.75, linewidth = 1, color = color.new(color.yellow, 50), linestyle = hline.style_solid)
// h4 = hline(-.85, linewidth = 1, color = color.new(color.yellow, 50), linestyle = hline.style_solid)
// fill(h3, h4, color = color.new(color.yellow, 80))
// bar color
barcolor(apply_bar_color ? color_ : na)
// create alert
alertcondition(con == 1 , title = 'Entry', message = 'Buy/Long entry point detected')
alertcondition(con == 0, title = 'Close', message = 'Sell/Short entry point detected')
|
ATR-Adaptive, Smoothed Laguerre RSI [Loxx] | https://www.tradingview.com/script/0tppbG2J-ATR-Adaptive-Smoothed-Laguerre-RSI-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 184 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator("ATR-Adaptive, Smoothed Laguerre RSI [Loxx]",
shorttitle = "ATRASLRSI [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
_lagfiltosc(src, per) =>
_gamma = 1.0 - 10.0 / (per + 9.0)
L0 = 0.0, L1 = 0.0, L2 = 0.0, L3 = 0.0
L0 := (1 - _gamma) * src + _gamma * nz(L0[1])
L1 := -_gamma * L0 + nz(L0[1]) + _gamma * nz(L1[1])
L2 := -_gamma * L1 + nz(L1[1]) + _gamma * nz(L2[1])
L3 := -_gamma * L2 + nz(L2[1]) + _gamma * nz(L3[1])
CU = 0., CD = 0.
if (L0 >= L1)
CU := L0 - L1
else
CD := L1 - L0
if (L1 >= L2)
CU += L1 - L2
else
CD += L2 - L1
if (L2 >= L3)
CU += L2 - L3
else
CD += L3 - L2
out = ((CU + CD != 0) ? CU / (CU + CD) : 0)
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)"])
atrper = input.int(15, "ATR Period", group = "Basic Settings")
srcsmth = input.int(5, "Source Smoothing Period", group = "Basic Settings")
inpLevelUp = input.float(0.85, "Upper Boundary", group = "Basic Settings")
inpLevelDown = input.float(0.15, "Lower Boundary", group = "Basic Settings")
colorbars = input.bool(false, "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)
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
atr = ta.atr(atrper)
prevMax = atr
prevMin = atr
for k = 2 to atrper
if (prevMax < nz(atr[k]))
prevMax := nz(atr[k])
if (prevMin > nz(atr[k]))
prevMin := nz(atr[k])
srcout = ta.ema(src, srcsmth)
_max = prevMax > atr ? prevMax : atr
_min = prevMin < atr ? prevMin : atr
_coeff = (_min != _max) ? 1.0 - (atr - _min) / (_max - _min) : 0.5
val = _lagfiltosc(srcout, atrper * (_coeff + 0.75))
valc = (val > inpLevelUp) ? 1 : (val < inpLevelDown) ? 2 : 0
plval = plot(val, color = valc == 1 ? greencolor : valc == 2 ? redcolor : na, linewidth = 3)
plot(val, color = valc == 0 ? color.gray : na, linewidth = 1)
plup = plot(inpLevelUp, color = bar_index % 2 ? color.gray : na)
pldn = plot(inpLevelDown, color = bar_index % 2 ? color.gray : na)
fill(plup, plval, color = valc == 1 ? greencolor : na)
fill(pldn, plval, color = valc == 2 ? redcolor : na)
barcolor(colorbars ? valc == 1 ? greencolor : valc == 2 ? redcolor : color.gray : na)
|
CHN BUY SELL | https://www.tradingview.com/script/F1dJ0hDq-CHN-BUY-SELL/ | CHN_indicator | https://www.tradingview.com/u/CHN_indicator/ | 363 | 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/
// © HamidBox
//@version=4
study("CHN BUY SELL", overlay=true, shorttitle="CHN BUY SELL")
//Inputs
rsiL = input(title="RSI Length", type=input.integer, defval=14)
rsiOBI = input(title="RSI Overbought", type=input.integer, defval=70)
rsiOSI = input(title="RSI Oversold", type=input.integer, defval=30)
fibLevel = input(title="Hammer Body Size", type=input.float, defval=0.333, step=0.01)
BullBearEngulf = input(title="Bullish Bearish Engulfing", type=input.bool, defval=true)
hammerShooting = input(title="Hammer Shooting Bar", type=input.bool, defval=false)
twoBullBearBar = input(title="Two Bull Bear Bar", type=input.bool, defval=false)
//RSI VALUE
myRsi = rsi(close , rsiL)
//RSI OVERBOUGHT / OVERSOLD
rsiOB = myRsi >= rsiOBI
rsiOS = myRsi <= rsiOSI
///////////=Hammer & Shooting star=/////////////
bullFib = (low - high) * fibLevel + high
bearFib = (high - low) * fibLevel + low
// Determine which price source closses or open highest/lowest
bearCandle = close < open ? close : open
bullCandle = close > open ? close : open
// Determine if we have a valid hammer or shooting star
hammer = (bearCandle >= bullFib) and rsiOS
shooting = (bullCandle <= bearFib) and rsiOB
twoGreenBars = (close > open and close[1] > open[1]) and rsiOS
twoRedBars = (close < open and close[1] < open[1]) and rsiOB
/////////////////////////////////////////////
// Engulfing candles
bullE = (close > open[1] and close[1] < open[1])
//or hammer or twoGreenBars
bearE = close < open[1] and close[1] > open[1]
//or shooting or twoRedBars
///////////////////////////////////////////
// ((x) y) farmula defination is: X is gona be executed before Y,
TradeSignal = ((rsiOS or rsiOS[1]) and bullE) or ((rsiOB or rsiOB[1]) and bearE)
if (TradeSignal and bearE and BullBearEngulf)
label.new(x= bar_index, y= na, text="Sell", yloc= yloc.abovebar,color= color.maroon, textcolor= color.white, style= label.style_label_down, size=size.normal)
plotshape(TradeSignal and bearE and BullBearEngulf, title="Overbought", location=location.abovebar, color=color.orange, style=shape.triangleup, size=size.auto, text="")
if (TradeSignal and bullE and BullBearEngulf)
label.new(x= bar_index, y= na, text="Buy", yloc= yloc.belowbar,color= color.green, textcolor= color.white, style= label.style_label_up, size=size.normal)
plotshape(TradeSignal and bullE and BullBearEngulf, title="Oversold", location=location.belowbar, color=color.lime, style=shape.triangleup, size=size.auto, text="")
//////////////////////////////
if (shooting and hammerShooting)
label.new(x= bar_index, y= na, text="SS", yloc= yloc.abovebar,color= color.purple, textcolor= color.white, style= label.style_label_down, size=size.normal)
plotshape(shooting and hammerShooting, title="Overbought + hammer/shooting", location=location.abovebar, color=color.purple, style=shape.triangledown, size=size.auto, text="")
if (hammer and hammerShooting)
label.new(x= bar_index, y= na, text="HMR", yloc= yloc.belowbar,color= color.blue, textcolor= color.white, style= label.style_label_up, size=size.normal)
plotshape(hammer and hammerShooting, title="Oversold + hammer/shooting", location=location.belowbar, color=color.lime, style=shape.triangledown, size=size.auto, text="")
///////////////////////////
if (twoGreenBars and twoBullBearBar)
label.new(x= bar_index, y= na, text="2Bull", yloc= yloc.belowbar,color= color.olive, textcolor= color.white, style= label.style_label_up, size=size.normal)
plotshape(twoGreenBars and twoBullBearBar, title="Oversold + 2bulls", location=location.belowbar, color=color.lime, style=shape.triangledown, size=size.auto, text="")
if (twoRedBars and twoBullBearBar)
label.new(x= bar_index, y= na, text="2Bear", yloc= yloc.abovebar,color= color.red, textcolor= color.white, style= label.style_label_down, size=size.normal)
plotshape(twoRedBars and twoBullBearBar, title="Overbought + 2bears", location=location.abovebar, color=color.blue, style=shape.triangledown, size=size.auto, text="")
// Send Alert if Candle meets our condition
alertcondition(TradeSignal, title="RSI SIGNAL", message="RSI Signal Detected fot {{ticker}}")
src = close, len = input(7, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
//coloring method below
src1 = close, len1 = input(70, minval=1, title="UpLevel")
src2 = close, len2 = input(30, minval=1, title="DownLevel")
orange = color.orange
purple = color.purple
isup() => rsi > len1
isdown() => rsi < len2
barcolor(isup() ? orange : isdown() ? purple : na )
|
RSI - S&P Sector ETFs | https://www.tradingview.com/script/dky8hLPw-RSI-S-P-Sector-ETFs/ | All_Verklempt | https://www.tradingview.com/u/All_Verklempt/ | 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/
// © All_Verklempt
//@version=5
indicator("RSI S&P Sectors", "", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
//
// Inputs
rsiLengthInput = input.int(14, minval=1, title="RSI Length")
rsiSourceInput = input.source(close, title="RSI Source")
//
// Symbol Calls
symbolrsi01 = request.security("BATS:XLK", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi02 = request.security("BATS:XLV", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi03 = request.security("BATS:XLF", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi04 = request.security("BATS:XLY", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi05 = request.security("BATS:XLC", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi06 = request.security("BATS:XLI", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi07 = request.security("BATS:XLP", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi08 = request.security("BATS:XLE", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi09 = request.security("BATS:XLU", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi10 = request.security("BATS:XLB", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
symbolrsi11 = request.security("BATS:XLRE", timeframe.period, ta.rsi(rsiSourceInput, rsiLengthInput) ,lookahead=barmerge.lookahead_on)
//
// Plot Information
plot(symbolrsi01, title="XLK", color=#801922)
plot(symbolrsi02, title="XLV", color=#f57c00)
plot(symbolrsi03, title="XLF", color=#fbc02d)
plot(symbolrsi04, title="XLY", color=#388e3c)
plot(symbolrsi05, title="XLC", color=#056656)
plot(symbolrsi06, title="XLI", color=#0097a7)
plot(symbolrsi07, title="XLP", color=#1848cc)
plot(symbolrsi08, title="XLE", color=#512da8)
plot(symbolrsi09, title="XLU", color=#7b1fa2)
plot(symbolrsi10, title="XLB", color=#c2185b)
plot(symbolrsi11, title="XLRE", color=#f06292)
rsiUpperBand = hline(70, "RSI Upper Band", color=#e3dac9)
hline(50, "RSI Middle Band", color=color.new(#e3dac9, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#e3dac9) |
APA-Adaptive, Ehlers Early Onset Trend [Loxx] | https://www.tradingview.com/script/ieVGZXw5-APA-Adaptive-Ehlers-Early-Onset-Trend-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 90 | study | 5 | MPL-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='APA-Adaptive, Ehlers Early Onset Trend [Loxx]',
shorttitle='APAAEEOT [Loxx]',
overlay = false,
timeframe="",
timeframe_gaps = true)
greencolor = #2DD204
redcolor = #D2042D
_f_hp(_src, int max_len) =>
c = 360 * math.pi / 180
_alpha = (1 - math.sin(c / max_len)) / math.cos(c / max_len)
_hp = 0.0
_hp := 0.5 * (1 + _alpha) * (_src - nz(_src[1])) + _alpha * nz(_hp[1])
_hp
_f_ess(_src, int _len) =>
s = 1.414 //sqrt 2
_a = math.exp(-s * math.pi / _len)
_b = 2 * _a * math.cos(s * math.pi / _len)
_c2 = _b
_c3 = -_a * _a
_c1 = 1 - _c2 - _c3
_out = 0.0
_out := _c1 * (_src + nz(_src[1])) / 2 + _c2 * nz(_out[1], nz(_src[1], _src)) + _c3 * nz(_out[2], nz(_src[2], nz(_src[1], _src)))
_out
_auto_dom_imp(src, min_len, max_len, ave_len) =>
c = 2 * math.pi
s = 1.414
filt = _f_ess(_f_hp(src, max_len), min_len)
arr_size = max_len * 2
var corr = array.new_float(arr_size, initial_value=0)
var cospart = array.new_float(arr_size, initial_value=0)
var sinpart = array.new_float(arr_size, initial_value=0)
var sqsum = array.new_float(arr_size, initial_value=0)
var r1 = array.new_float(arr_size, initial_value=0)
var r2 = array.new_float(arr_size, initial_value=0)
var pwr = array.new_float(arr_size, initial_value=0)
for lag = 0 to max_len by 1
m = ave_len == 0 ? lag : ave_len
Sx = 0.0
Sy = 0.0
Sxx = 0.0
Syy = 0.0
Sxy = 0.0
for i = 0 to m - 1 by 1
x = nz(filt[i])
y = nz(filt[lag + i])
Sx += x
Sy += y
Sxx += x * x
Sxy += x * y
Syy += y * y
Syy
if (m * Sxx - Sx * Sx) * (m * Syy - Sy * Sy) > 0
array.set(corr, lag, (m * Sxy - Sx * Sy) / math.sqrt((m * Sxx - Sx * Sx) * (m * Syy - Sy * Sy)))
for period = min_len to max_len by 1
array.set(cospart, period, 0)
array.set(sinpart, period, 0)
for n = ave_len to max_len by 1
array.set(cospart, period, nz(array.get(cospart, period)) + nz(array.get(corr, n)) * math.cos(c * n / period))
array.set(sinpart, period, nz(array.get(sinpart, period)) + nz(array.get(corr, n)) * math.sin(c * n / period))
array.set(sqsum, period, math.pow(nz(array.get(cospart, period)), 2) + math.pow(nz(array.get(sinpart, period)), 2))
for period = min_len to max_len by 1
array.set(r2, period, nz(array.get(r1, period)))
array.set(r1, period, 0.2 * math.pow(nz(array.get(sqsum, period)), 2) + 0.8 * nz(array.get(r2, period)))
maxpwr = 0.0
for period = min_len to max_len by 1
if nz(array.get(r1, period)) > maxpwr
maxpwr := nz(array.get(r1, period))
for period = ave_len to max_len by 1
array.set(pwr, period, nz(array.get(r1, period)) / maxpwr)
peakpwr = 0.0
for period = min_len to max_len by 1
if nz(array.get(pwr, period)) > peakpwr
peakpwr := nz(array.get(pwr, period))
spx = 0.0, sp = 0.0
for period = min_len to max_len by 1
if nz(array.get(pwr, period)) >= 0.5
spx += period * nz(array.get(pwr, period))
sp += nz(array.get(pwr, period))
for period = min_len to max_len by 1
if peakpwr >= 0.25 and nz(array.get(pwr, period)) >= 0.25
spx += period * nz(array.get(pwr, period))
sp += nz(array.get(pwr, period))
dominantcycle = 0.0
dominantcycle := sp != 0 ? spx / sp : dominantcycle
dominantcycle := sp < 0.25 ? dominantcycle[1] : dominantcycle
dominantcycle := dominantcycle < 1 ? 1 : dominantcycle
dominantcycle
_eot(LPPeriod, K) =>
Pk = 0.
Filt = _f_ess(_f_hp(close, LPPeriod), LPPeriod)
Pk := math.abs(Filt) > 0.991 * nz(Pk[1]) ? math.abs(Filt) : 0.991 * nz(Pk[1])
X = nz(Filt / Pk)
q = (X + K) / (K * X + 1)
q
Q1 = input.float(0.8, "Q1", group = "Basic Settings")
Q2 = input.float(0.4, "Q2", group = "Basic Settings")
auto_src = input.source(close, "Auto Source", group = "Autocorrelation Periodogram Settings")
auto_min = input.int(10, title='Auto Minnimum Length',minval = 1, group = "Autocorrelation Periodogram Settings")
auto_max = input.int(48, title='Auto Maximum Length', minval = 1, group = "Autocorrelation Periodogram Settings")
auto_avg = input.int(3, title='Auto Average Length', minval = 1, group = "Autocorrelation Periodogram Settings")
masterdom = _auto_dom_imp(auto_src, auto_min, auto_max, auto_avg)
int dcout = math.floor(masterdom) < 1 ? 1 : math.floor(masterdom)
qup = _eot(dcout, Q1)
qdn = _eot(dcout, Q2)
plot(qup, color = greencolor, linewidth = 2)
plot(qdn, color = redcolor, linewidth = 2)
plot(0, color = bar_index % 2 ? color.gray : na)
|
RSI, Stoch Rsi, EMA, SMA, & ROC | https://www.tradingview.com/script/nVHzlb69-RSI-Stoch-Rsi-EMA-SMA-ROC/ | iss1700 | https://www.tradingview.com/u/iss1700/ | 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/
// © iss1700
//@version=5
indicator("RSI, Stoch Rsi, EMA, & SMA")
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(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", "EMA" ], group="MA Settings")
maLengthInput = input.int(14, title="MA Length", 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)
plot(rsi, "RSI", color=#32CD32)
plot(rsiMA, "RSI-based MA", color=#FF1493)
rsiUpperBand = hline(50, "Middle Zone", color=#808080)
K = input.int(3, "K", minval=1)
D = 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),K)
d = ta.sma(k,D)
plot(k, "K", color=#2962FF)
plot(d, "D", color=#FF6D00)
top = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
bottom = hline(20, "Lower Band", color=#787B86)
fill(top,bottom, color=color.rgb(207, 159, 255,90), title="Background")
length = input.int(9, minval=1)
source = input(close, "Source")
roc = 100 * (source - source[length])/source[length]
plot(roc, color=#FFFFFF, title="ROC")
hline(0, color=#808080, title="Zero Line")
|
Alpha Max | https://www.tradingview.com/script/thkzsQx7-Alpha-Max/ | AlgoWolf | https://www.tradingview.com/u/AlgoWolf/ | 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/
// author © CryptoWolf,@kivancozbilginc
// developer © CyrptoWolf,,@kivancozbilginc
//@version=5
indicator('AlphaTrend', shorttitle='AMax', overlay=true, format=format.price, precision=2, timeframe='')
coeff = input.float(1, 'Multiplier', step=0.1)
AP = input(14, 'Common Period')
ATR = ta.sma(ta.tr, AP)
src = input(close)
showsignalsk = input(title='Show Signals?', defval=true)
novolumedata = input(title='Change calculation (no volume data)?', defval=false)
upT = low - ATR * coeff
downT = high + ATR * coeff
AlphaTrend = 0.0
AlphaTrend := (novolumedata ? ta.rsi(src, AP) >= 50 : ta.mfi(hlc3, AP) >= 50) ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT
color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B
k1 = plot(AlphaTrend, color=color.new(#0022FC, 0), linewidth=3)
k2 = plot(AlphaTrend[2], color=color.new(#FC0400, 0), linewidth=3)
fill(k1, k2, color=color1)
trimaxlength =input(10,'AlphaMaxLength')
trimaxsrc = input(close)
//----
ama = 0.
hh = math.max(math.sign(ta.change(ta.highest(trimaxlength))),0)
ll = math.max(math.sign(ta.change(ta.lowest(trimaxlength))*-1),0)
tc = math.pow(ta.sma(hh or ll ? 1 : 0,trimaxlength),2)
ama := nz(ama[1]+tc*(trimaxsrc-ama[1]),src)
plot(ama,"Plot",#ff1100,2)
buyAlphaSignalk = ta.crossover(AlphaTrend, AlphaTrend[2])
sellAlphaSignalk = ta.crossunder(AlphaTrend, AlphaTrend[2])
buySignalk = (ta.crossover(ama, AlphaTrend[2]) and ama > ama[1]) or buyAlphaSignalk
sellSignalk = (ta.crossunder(ama, AlphaTrend[2]) and ama < ama[1]) or sellAlphaSignalk
K1 = ta.barssince(buySignalk)
K2 = ta.barssince(sellSignalk)
O1 = ta.barssince(buySignalk[1])
O2 = ta.barssince(sellSignalk[1])
plotshape(buySignalk and showsignalsk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 0))
plotshape(sellSignalk and showsignalsk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0))
alertcondition(buySignalk and O1 > K2, title='Potential BUY Alarm', message='BUY SIGNAL!')
alertcondition(sellSignalk and O2 > K1, title='Potential SELL Alarm', message='SELL SIGNAL!')
alertcondition(buySignalk[1] and O1[1] > K2, title='Confirmed BUY Alarm', message='BUY SIGNAL APPROVED!')
alertcondition(sellSignalk[1] and O2[1] > K1, title='Confirmed SELL Alarm', message='SELL SIGNAL APPROVED!')
alertcondition(ta.cross(close, AlphaTrend), title='Price Cross Alert', message='Price - AlphaTrend Crossing!')
alertcondition(ta.crossover(low, AlphaTrend), title='Candle CrossOver Alarm', message='LAST BAR is ABOVE ALPHATREND')
alertcondition(ta.crossunder(high, AlphaTrend), title='Candle CrossUnder Alarm', message='LAST BAR is BELOW ALPHATREND!')
alertcondition(ta.cross(close[1], AlphaTrend[1]), title='Price Cross Alert After Bar Close', message='Price - AlphaTrend Crossing!')
alertcondition(ta.crossover(low[1], AlphaTrend[1]), title='Candle CrossOver Alarm After Bar Close', message='LAST BAR is ABOVE ALPHATREND!')
alertcondition(ta.crossunder(high[1], AlphaTrend[1]), title='Candle CrossUnder Alarm After Bar Close', message='LAST BAR is BELOW ALPHATREND!')
|
Intermediate Williams %R w/ Discontinued Signal Lines [Loxx] | https://www.tradingview.com/script/Cj4UJ1le-Intermediate-Williams-R-w-Discontinued-Signal-Lines-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 126 | study | 5 | MPL-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("Intermediate Williams %R w/ Discontinued Signal Lines [Loxx]",
shorttitle = "IWPRDSL [Loxx]",
overlay = false,
timeframe="",
timeframe_gaps = true)
import loxx/loxxexpandedsourcetypes/3
import loxx/loxxmas/1
greencolor = #2DD204
redcolor = #D2042D
darkGreenColor = #1B7E02
darkRedColor = #93021F
_pr(src, len) =>
max = ta.highest(len)
min = ta.lowest(len)
temp = 100 * (src - max) / (max - min)
temp
smthtype = input.string("AMA", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group= "Basic Settings")
srcoption = 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)"])
len = input.int(15, "Period", group= "Basic Settings", minval = 1)
smthlen = input.int(1, "Smoothing Period", group = "Basic Settings")
maintype = input.string("Simple Moving Average - SMA", "W%R Moving Average 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")
siglen = input.int(15, "Signal Period", group= "Basic Settings", minval = 1)
sigtype = input.string("Simple Moving Average - SMA", "Signal Moving Average 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")
dsllen = input.int(10, "Discontinued Signal Lines (DSL) Period", group = "Basic Settings")
dsltype = input.string("Exponential Moving Average - EMA", "DSL Moving Average Type", options = ["Exponential Moving Average - EMA", "Fast Exponential Moving Average - FEMA", "No DSL Smoothing"],
group = "Basic Settings")
overb = input.int(-20, "Overbought", group = "Basic Settings")
overs = input.int(-80, "Oversold", group = "Basic Settings")
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")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showsignal = input.bool(false, "Show Signal Line?", group = "UI Options")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
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
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, sig, special]
levu = 0., levd = 0., fdn = 0.
[out, _, _] = variant(maintype, _pr(src, len), smthlen)
out := smthlen > 1 ? out : _pr(src, len)
dslAlpha = dsltype == "Exponential Moving Average - EMA" ? 2.0 / (1.0 + siglen) : dsltype == "Fast Exponential Moving Average - FEMA" ? (2.0 / (2.0 + (siglen - 1.0) / 2.0)) : 0
levu := (out > -50) ? nz(levu[1]) + dslAlpha * (out - nz(levu[1])) : nz(levu[1])
levd := (out < -50) ? nz(levd[1]) + dslAlpha * (out - nz(levd[1])) : nz(levd[1])
finup = dsltype == "No DSL Smoothing" ? overb : levu
findn = dsltype == "No DSL Smoothing" ? overs : levd
lmid = (finup + findn)/2
colorout = out >= finup ? darkGreenColor : out <= findn ? darkRedColor : color.gray
colorout1 = out >= finup ? greencolor : out <= findn ? redcolor : color.gray
lu = plot(finup, color = bar_index % 2 ? color.gray : na)
ld = plot(findn, color = bar_index % 2 ? color.gray : na)
lm = plot(out, color = colorout, linewidth = 2)
fill(lu, lm, color = out >= finup ? greencolor: na)
fill(lm, ld, color = out <= findn ? redcolor : na)
barcolor(colorbars ? colorout1 : na)
[sig, _, _] = variant(sigtype, out, siglen)
sigplot = plot(showsignal ? sig : na, color = bar_index % 2 ? color.white : na, linewidth = 2)
|
Adaptive Price Zone | https://www.tradingview.com/script/AzkoAdVR/ | EduardoMattje | https://www.tradingview.com/u/EduardoMattje/ | 7 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EduardoMattje
//@version=5
indicator("Adaptive Price Zone", overlay=true)
var length = input.int(5, "EMA length", minval=2)
var deviationFactor = input.float(1.5, "Deviation factor", minval=0.0)
var offset = input.int(0, "Offset")
var useTR = input.bool(false, "Use TR", tooltip="Use the true range for the volatility instead of the high and low difference.")
getRange() =>
if useTR
ta.tr
else
high - low
volatility = ta.ema(ta.ema(getRange(), length), length)
getBand(signal) =>
hl2 + (volatility * deviationFactor * signal)
apzUpper = getBand(1)
apzLower = getBand(-1)
plot(apzUpper, "Upper band", color.red, offset=offset)
plot(apzLower, "Lower band", offset=offset)
|
Fake break | https://www.tradingview.com/script/GyCraAZi-Fake-break/ | salarkamjoo | https://www.tradingview.com/u/salarkamjoo/ | 434 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © salarkamjoo
// $KMagician/*
//@version=5
indicator("fake break", overlay=true)
// Inputs ----------------------------------------------------------------------
atrStrength = input.float(1.2, "Candle strength")
// Call Average True Range Indicator -------------------------------------------
atr = ta.atr(14)
// Call Average True Range Indicator -------------------------------------------
body = math.abs(close - open)
// Conditions ------------------------------------------------------------------
candleColor = close>open ? true : false
sellFb = candleColor == false and
candleColor[1] == true and
body > atrStrength * atr and
body[1] > atrStrength * atr[1] and
body > 0.75 * body[1]
buyFb = candleColor == true and
candleColor[1] == false and
body > atrStrength * atr and
body[1] > atrStrength * atr[1] and
body > 0.75 * body[1]
// Plot Shapes -----------------------------------------------------------------
plotshape(sellFb,
"sell fake-break",
shape.triangledown,
location.abovebar,
color.yellow,
text="FB-D",
textcolor=color.yellow)
plotshape(buyFb,
"buy fake-break",
shape.triangleup,
location.belowbar,
color.aqua,
text="FB-U",
textcolor=color.aqua)
// Alert's Message -------------------------------------------------------------
txt = sellFb ? "Fake Break Down":
buyFb? "Fake Break Up": ""
if sellFb or buyFb
alert(txt, alert.freq_once_per_bar_close) |
Crypto VCR | https://www.tradingview.com/script/dfcNT4uO-Crypto-VCR/ | TraderVikashICT | https://www.tradingview.com/u/TraderVikashICT/ | 30 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Vikashprajapati
//Session Local Time DST OFF (UCT+0) DST ON (UTC+0) DST ON 2022 DST OFF 2022 DST ON 2023 DST OFF 2023 DST ON 2024 DST OFF 2024
//London 8am-430pm 0800-1630 0700-1530 March, 27 October, 30 March, 26 October, 29 March, 31 October, 27
//NewYork 930am-4pm 1430-2100 1330-2000 March, 13 November, 6 March, 12 November, 5 March, 10 November, 3
//Tokyo 9am-3pm 0000-0600 0000-0600 N/A N/A N/A N/A N/A N/A
//@version=5
indicator('Vikash VCR', overlay=true, max_bars_back=300,max_boxes_count=500, max_lines_count=500, max_labels_count=500)
// Config
label_offset_input = input.int(group='Label offsets', title='General', defval=5, inline='labeloffset1')
pivot_offset_input = input.int(group='Label offsets', title='Pivots', defval=-5, inline='labeloffset1')
adr_offset_input = input.int(group='Label offsets', title='ADR', defval=25, inline='labeloffset1')
adr_offset_input_50 = input.int(group='Label offsets', title='50% ADR', defval=85, inline='labeloffset1')
rd_offset_input = input.int(group='Label offsets', title='RD/W', defval=45, inline='labeloffset1')
rd_offset_input_50 = input.int(group='Label offsets', title='50% RD/W', defval=85, inline='labeloffset1')
showEmas = input.bool(group='EMAs', title='Show EMAs?', defval=true, inline='showemas')
labelEmas = input.bool(group='EMAs', title='EMA Labels?', defval=false, inline='showemas')
oneEmaColor = input.color(group='EMAs', title='50', defval=color.rgb(31, 188, 211, 0), inline='emacolors')
twoEmaColor = input.color(group='EMAs', title='200', defval=color.rgb(255, 255, 255, 0), inline='emacolors')
//Daily Pivot Points
showLevelOnePivotPoints = input.bool(group='Pivot Points', title='Show Level: 1 R/S?', defval=false, inline='pivotlevels')
showLevelTwoPivotPoints = input.bool(group='Pivot Points', title='2 R/S?', defval=false, inline='pivotlevels')
showLevelThreePivotPoints = input.bool(group='Pivot Points', title=' 3 R/S?', defval=false, inline='pivotlevels')
showPivotLabels = input.bool(group='Pivot Points', title='Show labels?', defval=true, inline='pivotlevels')
string rsStyleX = input.string(group='Pivot Points', defval='Dashed', title='R/S Levels Line Style', options=['Dotted', 'Dashed', 'Solid'], inline='pivotcolorsRS')
rsStyle = rsStyleX == 'Dotted' ? line.style_dotted : (rsStyleX == 'Dashed' ? line.style_dashed : (rsStyleX == 'Solid' ? line.style_solid : line.style_dashed))
activeM = input.bool(group='Pivot Points', title='Show M levels?', defval=true, inline='mlevels')
showMLabels = input.bool(group='Pivot Points', title='Labels?', defval=true, inline='mlevels')
extendPivots = input.bool(group='Pivot Points', title='Extend lines in both directions?', defval=false)
pivotColor = input.color(group='Pivot Points', title='Colors: Pivot Point', defval=color.rgb(254, 234, 78, 50), inline='pivotcolors')
pivotLabelColor = input.color(group='Pivot Points', title='Pivot Point Label', defval=color.rgb(254, 234, 78, 50), inline='pivotcolors')
mColor = input.color(group='Pivot Points', title='Colors: M Levels', defval=color.rgb(255, 255, 255, 50), inline='pivotcolors1')
mLabelColor = input.color(group='Pivot Points', title='M Levels Label', defval=color.rgb(255, 255, 255, 50), inline='pivotcolors1')
string mStyleX = input.string(group='Pivot Points', defval='Dashed', title='M Levels Line Style', options=['Dotted', 'Dashed', 'Solid'], inline='pivotcolors2')
mStyle = mStyleX == 'Dotted' ? line.style_dotted : (mStyleX == 'Dashed' ? line.style_dashed : (mStyleX == 'Solid' ? line.style_solid : line.style_dashed))
showDayHighLow = input.bool(group="Yesterday's and Last Week's High/low", title='Show Hi/Lo: Daily?', defval=true, inline='highlow')
showWeekHighLow = input.bool(group="Yesterday's and Last Week's High/low", title='Weekly?', defval=true, inline='highlow')
showDayHighLowLabels = input.bool(group="Yesterday's and Last Week's High/low", title='Show labels?', defval=true, inline='highlow')
showADR = input.bool(group='Average Daily Range - ADR', title='Show ADR?', defval=true, inline='adr')
showADR_DO = input.bool(group='Average Daily Range - ADR', title='Use Daily Open (DO) calc?', defval=false, inline='adr', tooltip='Measure the ADR from the daily open. This will make the ADR static throughout the day. ADR is usually measured taking today high and low. Since todays high and low will change throughout the day, some might prefer to have a static range instead.')
showADRLabels = input.bool(group='Average Daily Range - ADR', title='Labels?', defval=true, inline='adr1')
showADRRange = input.bool(group='Average Daily Range - ADR', title='Range label?', defval=false, inline='adr1')
showADR_50 = input.bool(group='Average Daily Range - ADR', title='Show 50% ADR?', defval=false, inline='adr1')
aDRRange = input.int(group='Average Daily Range - ADR', title='ADR length (days)?', defval=14, minval=1, maxval=31, step=1, inline='adr2', tooltip="Defaults taken from mt4. This defines how many days back to take into consideration when calculating the ADR")
adrColor = input.color(group='Average Daily Range - ADR', title='ADR Color', defval=color.new(color.silver, 50), inline='adr3')
string adrStyleX = input.string(group='Average Daily Range - ADR', defval='Dotted', title='ADR Line Style', options=['Dotted', 'Dashed', 'Solid'], inline='adr3')
adrStyle = adrStyleX == 'Dotted' ? line.style_dotted : (adrStyleX == 'Dashed' ? line.style_dashed : (adrStyleX == 'Solid' ? line.style_solid : line.style_dotted))
showAWR = input.bool(group='Average Weekly Range - AWR', title='Show AWR?', defval=false, inline='awr')
showAWR_WO = input.bool(group='Average Weekly Range - AWR', title='Use Weekly Open (WO) calc?', defval=false, inline='awr', tooltip='Measure the AWR from the weekly open. This will make the AWR static throughout the week. AWR is usually measured taking this weeks high and low. Since this weeks high and low will change throughout the week, some might prefer to have a static range instead.')
showAWRLabels = input.bool(group='Average Weekly Range - AWR', title='Labels?', defval=true, inline='awr1')
showAWRRange = input.bool(group='Average Weekly Range - AWR', title='Range label?', defval=false, inline='awr1')
showAWR_50 = input.bool(group='Average Weekly Range - AWR', title='Show 50% AWR?', defval=false, inline='awr1')
aWRRange = input.int(group='Average Weekly Range - AWR', title='AWR length (weeks)?', defval=4, minval=1, maxval=52, step=1, inline='awr2', tooltip="Defaults taken from mt4. This defines how many weeks back to take into consideration when calculating the AWR")
awrColor = input.color(group='Average Weekly Range - AWR', title='AWR Color', defval=color.new(color.orange, 50), inline='awr3')
string awrStyleX = input.string(group='Average Weekly Range - AWR', defval='Dotted', title='AWR Line Style', options=['Dotted', 'Dashed', 'Solid'], inline='awr3')
awrStyle = awrStyleX == 'Dotted' ? line.style_dotted : (awrStyleX == 'Dashed' ? line.style_dashed : (awrStyleX == 'Solid' ? line.style_solid : line.style_dotted))
showAMR = input.bool(group='Average Monthly Range - AMR', title='Show AMR?', defval=false, inline='amr')
showAMR_MO = input.bool(group='Average Monthly Range - AMR', title='Use Monthly Open (MO) calc?', defval=false, inline='amr',tooltip='Measure the AMR from the monthly open. This will make the AMR static throughout the month. AMR is usually measured taking this months high and low. Since this months high and low will change throughout the month, some might prefer to have a static range instead.')
showAMRLabels = input.bool(group='Average Monthly Range - AMR', title='Labels?', defval=true, inline='amr1')
showAMRRange = input.bool(group='Average Monthly Range - AMR', title='Range label?', defval=false, inline='amr1')
showAMR_50 = input.bool(group='Average Monthly Range - AMR', title='Show 50% AMR?', defval=false, inline='amr1')
aMRRange = input.int(group='Average Monthly Range - AMR', title='AMR length (months)?', defval=6, minval=1, maxval=12, step=1, inline='amr2', tooltip="Defaults taken from mt4. This defines how many months back to take into consideration when calculating the AMR")
amrColor = input.color(group='Average Monthly Range - AMR', title='AMR Color', defval=color.new(color.red, 50), inline='amr3')
string amrStyleX = input.string(group='Average Monthly Range - AMR', defval='Dotted', title='AMR Line Style', options=['Dotted', 'Dashed', 'Solid'], inline='amr3')
amrStyle = amrStyleX == 'Dotted' ? line.style_dotted : (amrStyleX == 'Dashed' ? line.style_dashed : (amrStyleX == 'Solid' ? line.style_solid : line.style_dotted))
showRD = input.bool(group='Range Daily Hi/Lo - RD Hi/Lo', title='Show RD?', defval=false, inline='rd')
showRD_DO = input.bool(group='Range Daily Hi/Lo - RD Hi/Lo', title='Use Daily Open (DO) calc?', defval=false, inline='rd',tooltip='Measure the RD from the daily open. This will make the RD static throughout the day. RD is usually measured taking todays high and low. Since today high and low will change throughout the day, some might prefer to have a static range instead.')
showRDLabels = input.bool(group='Range Daily Hi/Lo - RD Hi/Lo', title='Labels?', defval=true, inline='rd1')
showRDRange = input.bool(group='Range Daily Hi/Lo - RD Hi/Lo', title='Range label?', defval=false, inline='rd1')
showRD_50 = input.bool(group='Range Daily Hi/Lo - RD Hi/Lo', title='Show 50% RD?', defval=false, inline='rd1')
rdRange = input.int(group='Range Daily Hi/Lo - RD Hi/Lo', title='RD length (days)?', defval=15, minval=1, maxval=31, step=1, inline='rd2', tooltip="Defaults taken from Trader At Home PVSRA documentation. This defines how many days back to take into consideration when calculating the RD")
rdColor = input.color(group='Range Daily Hi/Lo - RD Hi/Lo', title='RD Color', defval=color.new(color.red, 30), inline='rd3')
string rdStyleX = input.string(group='Range Daily Hi/Lo - RD Hi/Lo', defval='Solid', title='RD Line Style', options=['Dotted', 'Dashed', 'Solid'], inline='rd3')
rdStyle = rdStyleX == 'Dotted' ? line.style_dotted : (rdStyleX == 'Dashed' ? line.style_dashed : (rdStyleX == 'Solid' ? line.style_solid : line.style_dotted))
showRW = input.bool(group='Range Weekly Hi/Lo - RW Hi/Lo', title='Show RW?', defval=false, inline='rw')
showRW_WO = input.bool(group='Range Weekly Hi/Lo - RW Hi/Lo', title='Use Weekly Open (WO) calc?', defval=false, inline='rw', tooltip='Measure the RW from the weekly open. This will make the RW static throughout the week. RW is usually measured taking this weeks high and low. Since this weeks high and low will change throughout the week, some might prefer to have a static range instead.')
showRWLabels = input.bool(group='Range Weekly Hi/Lo - RW Hi/Lo', title='Labels?', defval=true, inline='rw1')
showRWRange = input.bool(group='Range Weekly Hi/Lo - RW Hi/Lo', title='Range label?', defval=false, inline='rw1')
showRW_50 = input.bool(group='Range Weekly Hi/Lo - RW Hi/Lo', title='Show 50% RW?', defval=false, inline='rw1')
rwRange = input.int(group='Range Weekly Hi/Lo - RW Hi/Lo', title='RW length (weeks)?', defval=13, minval=1, maxval=52, step=1, inline='rw2', tooltip="Defaults taken from Trader At Home PVSRA documentation. This defines how many weeks back to take into consideration when calculating the RW")
rwColor = input.color(group='Range Weekly Hi/Lo - RW Hi/Lo', title='RW Color', defval=color.new(color.blue, 30), inline='rw3')
string rwStyleX = input.string(group='Range Weekly Hi/Lo - RW Hi/Lo', defval='Solid', title='RW Line Style', options=['Dotted', 'Dashed', 'Solid'], inline='rw3')
rwStyle = rwStyleX == 'Dotted' ? line.style_dotted : (rwStyleX == 'Dashed' ? line.style_dashed : (rwStyleX == 'Solid' ? line.style_solid : line.style_dotted))
showAdrTable = input.bool(group='ADR/ADRx3/AWR/AMR Table', title='Show ADR Table', inline='adrt', defval=true)
showAdrPips = input.bool(group='ADR/ADRx3/AWR/AMR Table', title='Show ADR PIPS', inline='adrt', defval=true) and showAdrTable
showAdrCurrency = input.bool(group='ADR/ADRx3/AWR/AMR Table', title='Show ADR Currency', inline='adrt', defval=false) and showAdrTable
showRDPips = input.bool(group='ADR/ADRx3/AWR/AMR Table', title='Show RD PIPS', inline='adrt', defval=false) and showAdrTable
showRDCurrency = input.bool(group='ADR/ADRx3/AWR/AMR Table', title='Show RD Currency', inline='adrt', defval=false) and showAdrTable
choiceAdrTable = input.string(group='ADR/ADRx3/AWR/AMR Table', title='ADR Table postion', inline='adrt', defval='top_right', options=['top_right', 'top_left', 'top_center', 'bottom_right', 'bottom_left', 'bottom_center'])
adrTableBgColor = input.color(group='ADR/ADRx3/AWR/AMR Table', title='ADR Table: Background Color', inline='adrtc', defval=color.rgb(93, 96, 107, 70))
adrTableTxtColor = input.color(group='ADR/ADRx3/AWR/AMR Table', title='Text Color', inline='adrtc', defval=color.rgb(31, 188, 211, 0))
/// market boxes and daily open only on intraday
bool show = timeframe.isminutes and timeframe.multiplier <= 240 and timeframe.multiplier >= 1
time_now_exchange = timestamp(year, month, dayofmonth, hour, minute, second)
bool show_dly = timeframe.isminutes //and timeframe.multiplier < 240
bool show_rectangle9 = input.bool(group='Daily Open', defval=true, title='Show: line ?', inline='dopenconf') and show_dly
bool show_label9 = input.bool(group='Daily Open', defval=true, title='Label?', inline='dopenconf') and show_rectangle9 and show_dly
bool showallDly = input.bool(group='Daily Open', defval=false, title='Show historical daily opens?', inline='dopenconf')
color sess9col = input.color(group='Daily Open', title='Daily Open Color', defval=color.rgb(254, 234, 78, 0), inline='dopenconf1')
bool overridesym = input.bool(group='PVSRA', title='Override chart symbol?', defval=false, inline='pvsra')
string pvsra_sym = input.symbol(group='PVSRA', title='', defval='INDEX:BTCUSD', tooltip='You can use INDEX:BTCUSD or you can combine multiple feeds, for example \'(BINANCE:BTCUSDT+COINBASE:BTCUSD)\'. Note that adding too many will slow things down.', inline='pvsra')
string rectStyle = input.string(group='Market sessions', defval='Dashed', title='Line style of Market Session hi/lo line', options=['Dashed', 'Solid'])
sessLineStyle = line.style_dashed
bool show_markets = input.bool(true, group='Market sessions', title='Show Market Sessions?', tooltip='Turn on or off all market sessions') and show
bool show_markets_weekends = input.bool(false, group='Market sessions', title='Show Market Session on Weekends?', tooltip='Turn on or off market sessions in the weekends. Note do not turn this on for exchanges that dont have weekend data like OANDA') and show
string weekend_sessions = ':1234567'
string no_weekend_sessions = ':23456'
bool show_rectangle1 = input.bool(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session1conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label1 = input.bool(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval=true, title='Label?', inline='session1conf') and show_rectangle1 and show_markets
bool show_or1 = input.bool(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session1conf', tooltip='This controls the shaded area for the session') and show_rectangle1 and show_markets
string sess1Label = input.string(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval='London', title='Name:', inline='session1style')
color sess1col = input.color(group='Market session: London (0800-1630 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(120, 123, 134, 75), inline='session1style')
color sess1colLabel = input.color(group='Market session: London (0800-1630 UTC+0) - DST Aware', title='Label', defval=color.rgb(120, 123, 134, 0), inline='session1style')
string sess1TimeX = '0800-1630'//input.session(group='Market session: London (0800-1630 UTC+0)', defval='0800-1630', title='Time (UTC+0):', inline='session1style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST and times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess1Time = show_markets_weekends ? sess1TimeX + weekend_sessions : sess1TimeX + no_weekend_sessions
bool show_rectangle2 = input.bool(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session2conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label2 = input.bool(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval=true, title='Label?', inline='session2conf') and show_rectangle2 and show_markets
bool show_or2 = input.bool(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session2conf', tooltip='This controls the shaded area for the session') and show_rectangle2 and show_markets
string sess2Label = input.string(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval='NewYork', title='Name:', inline='session2style')
color sess2col = input.color(group='Market session: New York (1430-2100 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(251, 86, 91, 75), inline='session2style')
color sess2colLabel = input.color(group='Market session: New York (1430-2100 UTC+0) - DST Aware', title='Label', defval=color.rgb(253, 84, 87, 25), inline='session2style')
string sess2TimeX = '1430-2100'//input.session(group='Market session: New York (1430-2100 UTC+0)', defval='1430-2100', title='Time (UTC+0):', inline='session2style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess2Time = show_markets_weekends ? sess2TimeX + weekend_sessions : sess2TimeX + no_weekend_sessions
bool show_rectangle3 = input.bool(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session3conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label3 = input.bool(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval=true, title='Label?', inline='session3conf') and show_rectangle3 and show_markets
bool show_or3 = input.bool(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session3conf', tooltip='This controls the shaded area for the session') and show_rectangle3 and show_markets
string sess3Label = input.string(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval='Tokyo', title='Name:', inline='session3style')
color sess3col = input.color(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(80, 174, 85, 75), inline='session3style')
color sess3colLabel = input.color(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', title='Label', defval=color.rgb(80, 174, 85, 25), inline='session3style')
string sess3TimeX = '0000-0600'//input.session(group='Market session: Tokyo (0000-0600 UTC+0)', defval='0000-0600', title='Time (UTC+0):', inline='session3style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess3Time = show_markets_weekends ? sess3TimeX + weekend_sessions : sess3TimeX + no_weekend_sessions
bool show_rectangle4 = input.bool(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session4conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label4 = input.bool(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval=true, title='Label?', inline='session4conf') and show_rectangle4 and show_markets
bool show_or4 = input.bool(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session4conf', tooltip='This controls the shaded area for the session') and show_rectangle4 and show_markets
string sess4Label = input.string(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval='HongKong', title='Name:', inline='session4style')
color sess4col = input.color(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(128, 127, 23, 75), inline='session4style')
color sess4colLabel = input.color(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', title='Label', defval=color.rgb(128, 127, 23, 25), inline='session4style')
string sess4TimeX = '0130-0800'//input.session(group='Market session: Hong Kong (0130-0800 UTC+0)', defval='0130-0800', title='Time (UTC+0):', inline='session4style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess4Time = show_markets_weekends ? sess4TimeX + weekend_sessions : sess4TimeX + no_weekend_sessions
bool show_rectangle5 = input.bool(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session5conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label5 = input.bool(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval=true, title='Label?', inline='session5conf') and show_rectangle5 and show_markets
bool show_or5 = input.bool(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session5conf', tooltip='This controls the shaded area for the session') and show_rectangle5 and show_markets
string sess5Label = input.string(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval='Sydney', title='Name:', inline='session5style')
color sess5col = input.color(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(37, 228, 123, 75), inline='session5style')
color sess5colLabel = input.color(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', title='Label', defval=color.rgb(37, 228, 123, 25), inline='session5style')
string sess5TimeX = '2200-0600'//input.session(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0)', defval='2200-0600', title='Time (UTC+0):', inline='session5style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess5Time = show_markets_weekends ? sess5TimeX + weekend_sessions : sess5TimeX + no_weekend_sessions
bool show_rectangle6 = input.bool(group='Market session: EU Brinks (0800-0900 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session6conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label6 = input.bool(group='Market session: EU Brinks (0800-0900 UTC+0) - DST Aware', defval=true, title='Label?', inline='session6conf') and show_rectangle6 and show_markets
bool show_or6 = input.bool(group='Market session: EU Brinks (0800-0900 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session6conf', tooltip='This controls the shaded area for the session') and show_rectangle6 and show_markets
string sess6Label = input.string(group='Market session: EU Brinks (0800-0900 UTC+0) - DST Aware', defval='EU Brinks', title='Name:', inline='session6style')
color sess6col = input.color(group='Market session: EU Brinks (0800-0900 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(255, 255, 255, 65), inline='session6style')
color sess6colLabel = input.color(group='Market session: EU Brinks (0800-0900 UTC+0) - DST Aware', title='Label', defval=color.rgb(255, 255, 255, 25), inline='session6style')
string sess6TimeX = '0800-0900'//input.session(group='Market session: EU Brinks (0800-0900 UTC+0)', defval='0800-0900', title='Time (UTC+0):', inline='session6style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess6Time = show_markets_weekends ? sess6TimeX + weekend_sessions : sess6TimeX + no_weekend_sessions
bool show_rectangle7 = input.bool(group='Market session: US Brinks (1400-1500 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session7conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label7 = input.bool(group='Market session: US Brinks (1400-1500 UTC+0) - DST Aware', defval=true, title='Label?', inline='session7conf') and show_rectangle7 and show_markets
bool show_or7 = input.bool(group='Market session: US Brinks (1400-1500 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session7conf', tooltip='This controls the shaded area for the session') and show_rectangle7 and show_markets
string sess7Label = input.string(group='Market session: US Brinks (1400-1500 UTC+0) - DST Aware', defval='US Brinks', title='Name:', inline='session7style')
color sess7col = input.color(group='Market session: US Brinks (1400-1500 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(255, 255, 255, 65), inline='session7style')
color sess7colLabel = input.color(group='Market session: US Brinks (1400-1500 UTC+0) - DST Aware', title='Label', defval=color.rgb(255, 255, 255, 25), inline='session7style')
string sess7TimeX = '1400-1500'//input.session(group='Market session: US Brinks (1400-1500 UTC+0)', defval='1400-1500', title='Time (UTC+0):', inline='session7style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess7Time = show_markets_weekends ? sess7TimeX + weekend_sessions : sess7TimeX + no_weekend_sessions
bool show_rectangle8 = input.bool(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval=false, title='Show: session?', inline='session8conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
bool show_label8 = input.bool(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval=true, title='Label?', inline='session8conf') and show_rectangle8 and show_markets
bool show_or8 = input.bool(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session8conf', tooltip='This controls the shaded area for the session') and show_rectangle8 and show_markets
string sess8Label = input.string(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval='Frankfurt', title='Name:', inline='session8style')
color sess8col = input.color(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(253, 152, 39, 75), inline='session8style')
color sess8colLabel = input.color(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', title='Label', defval=color.rgb(253, 152, 39, 25), inline='session8style')
string sess8TimeX = '0700-1630'//input.session(group='Market session: Frankfurt (0700-1630 UTC+0)', defval='0700-1630', title='Time (UTC+0):', inline='session8style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
sess8Time = show_markets_weekends ? sess8TimeX + weekend_sessions : sess8TimeX + no_weekend_sessions
bool showPsy = timeframe.isminutes and (timeframe.multiplier == 60 or timeframe.multiplier == 30 or timeframe.multiplier == 15 or timeframe.multiplier == 5 or timeframe.multiplier == 3 or timeframe.multiplier == 1)
bool show_psylevels = input.bool(group='Weekly Psy Levels (valid tf 1h/30min/15min/5min/3min/1min)', defval=true, title='Show: Levels?', inline='psyconf') and showPsy
bool show_psylabel = input.bool(group='Weekly Psy Levels (valid tf 1h/30min/15min/5min/3min/1min)', defval=true, title='Labels?', inline='psyconf', tooltip="The Psy High/Low will only show on these timeframes: 1h/30min/15min/5min/3min/1min. It is disabled on all others. This is because the calculation requires a candle to start at the correct time for Sydney/Tokyo but in other timeframes the data does not have values at the designated time for the Sydney/Tokyo sessions.") and show_psylevels
bool showallPsy = input.bool(group='Weekly Psy Levels (valid tf 1h/30min/15min/5min/3min/1min)', defval=false, title='Show historical psy levels?', inline='psyconf') and show_psylevels
color psycolH = input.color(group='Weekly Psy Levels (valid tf 1h/30min/15min/5min/3min/1min)', title='Psy Hi Color', defval=color.new(color.orange, 30), inline='psyconf1')
color psycolL = input.color(group='Weekly Psy Levels (valid tf 1h/30min/15min/5min/3min/1min)', title='Psy Low Color', defval=color.new(color.orange, 30), inline='psyconf1')
string psyType = input.string(group='Weekly Psy Levels (valid tf 1h/30min/15min/5min/3min/1min)', defval='crypto', title='Psy calc type', options=['crypto', 'forex'], inline='psyconf12', tooltip="Are you looking at Crypto or Forex? Crypto calculations start with the Sydney session on Saturday night. Forex calculations start with the Tokyo session on Monday morning. Note some exchanges like Oanda do not have sessions on the weekends so you might be forced to select Forex for exchanges like Oanda even when looking at symbols like BITCOIN on Oanda.")
showDstTable = input.bool(group='Daylight Saving Time Info (DST)', title='Show DST Table : ', inline='dstt', defval=false)
choiceDstTable = input.string(group='Daylight Saving Time Info (DST)', title='DST Table postion', inline='dstt', defval='bottom_center', options=['top_right', 'top_left', 'top_center', 'bottom_right', 'bottom_left', 'bottom_center'])
dstTableBgColor = input.color(group='Daylight Saving Time Info (DST)', title='DST Table: Background Color', inline='dsttc', defval=color.rgb(93, 96, 107, 70))
dstTableTxtColor = input.color(group='Daylight Saving Time Info (DST)', title='Text Color', inline='dsttc', defval=color.rgb(31, 188, 211, 0))
//Non repainting security
f_security(_symbol, _res, _src, _repaint) =>
request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1]
// Basic vars (needed in functions)
// Only render intraday
validTimeFrame = timeframe.isintraday == true
// If above the 5 minute, we start drawing yesterday. below, we start today
levelsstart = timeframe.isseconds == true or timeframe.isminutes == true and timeframe.multiplier < 5 ? time('D') : time('D') - 86400 * 1000
//levelsstartbar = ta.barssince(levelsstart)
// Functions
// new_bar: check if we're on a new bar within the session in a given resolution
new_bar(res) =>
ta.change(time(res)) != 0
// adr: Calculate average daily range for a given length
adr(length, barsBack) =>
// This is effectively an atr, which is what is used in MT4 to get those levels. FWIW, true range can be also calculated with tr(true)
trueRange = na(high[1]) ? high - low : math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1]))
// Switched to SMA from RMA because somehow it matches MT4 better
ta.sma(trueRange[barsBack], length)
// adr_high: Calculate the ADR high given an ADR
adr_high(adr, from_do) =>
retVal = 0.0
if not from_do
retVal := high - low < adr ? low + adr : close >= open ? low + adr : high
else
retVal := open + adr
retVal
// adr_low: Calculate the ADR low given an ADR
adr_low(adr, from_do) =>
retVal = 0.0
if not from_do
retVal := high - low < adr ? high - adr : close >= open ? low : high - adr
else
retVal := open - adr
retVal
// to_pips: Convert to pips
to_pips(val) =>
pipSizeCalc = syminfo.mintick * (syminfo.type == "forex" ? 10 : 1)
returnVal = val/pipSizeCalc
returnVal
pivot_label_x_offset = time_close + pivot_offset_input * timeframe.multiplier * 60 * 1000
label_x_offset = time_close + label_offset_input * timeframe.multiplier * 60 * 1000
adr_label_x_offset = time_close + adr_offset_input * timeframe.multiplier * 60 * 1000
adr_label_x_offset_50 = time_close + adr_offset_input_50 * timeframe.multiplier * 60 * 1000
rd_label_x_offset = time_close + rd_offset_input * timeframe.multiplier * 60 * 1000
rd_label_x_offset_50 = time_close + rd_offset_input_50 * timeframe.multiplier * 60 * 1000
//Right_Label
r_label(ry, rtext, rstyle, rcolor, valid) =>
var label rLabel = na
if valid and barstate.isrealtime
rLabel := label.new(x=label_x_offset, y=ry, text=rtext, xloc=xloc.bar_time, style=rstyle, textcolor=rcolor, textalign=text.align_right)
label.delete(rLabel[1])
rLabel
//Right_Label
r_label_offset(ry, rtext, rstyle, rcolor, valid, labelOffset) =>
if valid and barstate.isrealtime
rLabel = label.new(x=labelOffset, y=ry, text=rtext, xloc=xloc.bar_time, style=rstyle, textcolor=rcolor, textalign=text.align_right)
label.delete(rLabel[1])
draw_line(x_series, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, xLabelOffset) =>
var line x_line = na
if validTimeFrame and new_bar(res) //and barstate.isnew
x_line := line.new(bar_index, x_series, bar_index+1, x_series, extend=xExtend, color=xColor, style=xStyle, width=xWidth)
line.delete(x_line[1])
if not na(x_line) and not new_bar(res)//and line.get_x2(x_line) != bar_index
line.set_x2(x_line, bar_index)
line.set_y1(x_line,x_series)
line.set_y2(x_line,x_series)
if isLabelValid //showADRLabels and validTimeFrame
x_label = label.new(xLabelOffset, x_series, tag, xloc=xloc.bar_time, style=label.style_none, textcolor=xColor)
label.delete(x_label[1])
draw_line_DO(x_series, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, xLabelOffset) =>
var line x_line = na
if new_bar(res) and validTimeFrame
line.set_x2(x_line, bar_index)
line.set_extend(x_line, extend.none)
x_line := line.new(bar_index, x_series, bar_index, x_series, extend=xExtend, color=xColor, style=xStyle, width=xWidth)
line.delete(x_line[1])
if not na(x_line) and line.get_x2(x_line) != bar_index
line.set_x2(x_line, bar_index)
if isLabelValid //showADRLabels and validTimeFrame
x_label = label.new(xLabelOffset, x_series, tag, xloc=xloc.bar_time, style=label.style_none, textcolor=xColor)
label.delete(x_label[1])
draw_pivot(pivot_level, res, tag, pivotColor, pivotLabelColor, pivotStyle, pivotWidth, pivotExtend, isLabelValid) =>
var line pivot_line = na
// Start drawing yesterday
if validTimeFrame and new_bar(res)//and barstate.isnew
//line.set_x2(pivot_line, bar_index)
//line.set_extend(pivot_line, extend.none)
pivot_line := line.new(bar_index, pivot_level, bar_index, pivot_level, extend=pivotExtend, color=pivotColor, style=pivotStyle, width=pivotWidth)
line.delete(pivot_line[1])
if not na(pivot_line) and not new_bar(res)//line.get_x2(pivot_line) != bar_index
line.set_x2(pivot_line, bar_index)
line.set_y1(pivot_line,pivot_level)
line.set_y2(pivot_line,pivot_level)
if isLabelValid //showADRLabels and validTimeFrame
pivot_label = label.new(pivot_label_x_offset, pivot_level, tag, xloc=xloc.bar_time, style=label.style_none, textcolor=pivotLabelColor, textalign=text.align_right)
label.delete(pivot_label[1])
if not barstate.islast
line.set_x2(pivot_line, x=bar_index)
else
line.set_xloc(pivot_line, levelsstart, time_close + 1 * 86400000, xloc=xloc.bar_time)
pivot_line
//Emas
oneEmaLength = 50
twoEmaLength = 200
oneEma = ta.ema(close, oneEmaLength)
plot(showEmas ? oneEma : na, color=oneEmaColor, title='50 Ema')
twoEma = ta.ema(close, twoEmaLength)
plot(showEmas ? twoEma : na, color=twoEmaColor, title='200 Ema')
//Label emas
r_label(oneEma, '50 Ema', label.style_none, oneEmaColor, labelEmas) //ry, rtext, rstyle, rcolor,valid
r_label(twoEma, '200 Ema', label.style_none, twoEmaColor, labelEmas)
// Get Daily price data
dayHigh = f_security(syminfo.tickerid, 'D', high, false)
dayLow = f_security(syminfo.tickerid, 'D', low, false)
dayOpen = f_security(syminfo.tickerid, 'D', open, false)
dayClose = f_security(syminfo.tickerid, 'D', close, false)
//Compute Values
pivotPoint = (dayHigh + dayLow + dayClose) / 3
// Updated 2021-03-25 by infernix
pivR1 = 2 * pivotPoint - dayLow
pivS1 = 2 * pivotPoint - dayHigh
pivR2 = pivotPoint - pivS1 + pivR1
pivS2 = pivotPoint - pivR1 + pivS1
pivR3 = 2 * pivotPoint + dayHigh - 2 * dayLow
pivS3 = 2 * pivotPoint - (2 * dayHigh - dayLow)
//Plot Values
//plot(validTimeFrame and showLevelOnePivotPoints? pivotPoint : na, linewidth = 1, color = color.yellow, style = plot.style_circles, transp = 25, title = "Daily Pivot Point", show_last = plot_bars)
pivline = draw_pivot(validTimeFrame and (showLevelOnePivotPoints or showLevelTwoPivotPoints or showLevelThreePivotPoints or activeM) ? pivotPoint : na, 'D', 'PP', pivotColor, pivotLabelColor, mStyle, 1, extendPivots ? extend.both : extend.right, showPivotLabels and validTimeFrame)
pivr1line = draw_pivot(validTimeFrame and showLevelOnePivotPoints ? pivR1 : na, 'D', 'R1', color.new(color.green, 50), color.new(color.green, 50), rsStyle, 1, extendPivots ? extend.both : extend.right, showLevelOnePivotPoints and showPivotLabels and validTimeFrame)
pivs1line = draw_pivot(validTimeFrame and showLevelOnePivotPoints ? pivS1 : na, 'D', 'S1', color.new(color.red, 50), color.new(color.red, 50), rsStyle, 1, extendPivots ? extend.both : extend.right, showLevelOnePivotPoints and showPivotLabels and validTimeFrame)
pivr2line = draw_pivot(validTimeFrame and showLevelTwoPivotPoints ? pivR2 : na, 'D', 'R2', color.new(color.green, 50), color.new(color.green, 50), rsStyle, 1, extendPivots ? extend.both : extend.right, showLevelTwoPivotPoints and showPivotLabels and validTimeFrame)
pivs2line = draw_pivot(validTimeFrame and showLevelTwoPivotPoints ? pivS2 : na, 'D', 'S2', color.new(color.red, 50), color.new(color.red, 50), rsStyle, 1, extendPivots ? extend.both : extend.right, showLevelTwoPivotPoints and showPivotLabels and validTimeFrame)
pivr3line = draw_pivot(validTimeFrame and showLevelThreePivotPoints ? pivR3 : na, 'D', 'R3', color.new(color.green, 50), color.new(color.green, 50), rsStyle, 1, extendPivots ? extend.both : extend.right, showLevelThreePivotPoints and showPivotLabels and validTimeFrame)
pivs3line = draw_pivot(validTimeFrame and showLevelThreePivotPoints ? pivS3 : na, 'D', 'S3', color.new(color.red, 50), color.new(color.red, 50), rsStyle, 1, extendPivots ? extend.both : extend.right, showLevelThreePivotPoints and showPivotLabels and validTimeFrame)
// Daily H/L
weekHigh = f_security(syminfo.tickerid, 'W', high, false)
weekLow = f_security(syminfo.tickerid, 'W', low, false)
validDHLTimeFrame = timeframe.isintraday == true
validWHLTimeFrame = timeframe.isintraday == true or timeframe.isdaily == true
isToday = year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time)
isThisWeek = year(timenow) == year(time) and weekofyear(timenow) == weekofyear(time)
plot(validDHLTimeFrame and showDayHighLow and (showDayHighLow ? true : isToday) ? dayHigh : na, linewidth=2, color=color.new(color.blue, 50), style=plot.style_stepline, title="YDay Hi")
plot(validDHLTimeFrame and showDayHighLow and (showDayHighLow ? true : isToday) ? dayLow : na, linewidth=2, color=color.new(color.blue, 50), style=plot.style_stepline, title="YDay Lo")
r_label(dayHigh, 'YDay Hi', label.style_none, color.blue, validDHLTimeFrame and showDayHighLow and showDayHighLowLabels) //ry, rtext, rstyle, rcolor, valid
r_label(dayLow, 'YDay Lo', label.style_none, color.blue, validDHLTimeFrame and showDayHighLow and showDayHighLowLabels)
plot(validWHLTimeFrame and showWeekHighLow and (showWeekHighLow ? true : isThisWeek) ? weekHigh : na, linewidth=2, color=color.new(color.green, 60), style=plot.style_stepline, title="LWeek Hi")
plot(validWHLTimeFrame and showWeekHighLow and (showWeekHighLow ? true : isThisWeek) ? weekLow : na, linewidth=2, color=color.new(color.green, 60), style=plot.style_stepline, title="LWeek Lo")
r_label(weekHigh, 'LWeek Hi', label.style_none, color.green, validWHLTimeFrame and showWeekHighLow and showDayHighLowLabels) //ry, rtext, rstyle, rcolor, valid
r_label(weekLow, 'LWeek Lo', label.style_none, color.green, validWHLTimeFrame and showWeekHighLow and showDayHighLowLabels)
// 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.
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
r_label(high - (high - low) / 2, 'PVSRA Override Active!', label.style_none, color.orange, overridesym) //ry, rtext, rstyle, rcolor, valid
//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(candleColor)
alertcondition(va > 0, title='Alert on Any Vector Candle', message='{{ticker}} Vector Candle on the {{interval}}')
alertcondition(candleColor == color.lime, title='Green Vector Candle', message='{{ticker}} Green Vector Candle on the {{interval}} Note: alert triggers in real time before the candle is closed unless you choose "once per bar close" option - ie the alert might trigger at some point and the pa after that could change the vector color completely. Use with caution.')
alertcondition(candleColor == color.red, title='Red Vector Candle', message='{{ticker}} Red Vector Candle on the {{interval}} Note: alert triggers in real time before the candle is closed unless you choose "once per bar close" option- ie the alert might trigger at some point and the pa after that could change the vector color completely. Use with caution.')
alertcondition(candleColor == color.blue, title='Blue Vector Candle', message='{{ticker}} Blue Vector Candle on the {{interval}} Note: alert triggers in real time before the candle is closed unless you choose "once per bar close" option- ie the alert might trigger at some point and the pa after that could change the vector color completely. Use with caution.')
alertcondition(candleColor == color.fuchsia, title='Purple Vector Candle', message='{{ticker}} Purple Vector Candle on the {{interval}} Note: alert triggers in real time before the candle is closed unless you choose "once per bar close" option- ie the alert might trigger at some point and the pa after that could change the vector color completely. Use with caution.')
redGreen = candleColor == color.lime and candleColor[1] == color.red
greenRed = candleColor == color.red and candleColor[1] == color.lime
redBlue = candleColor == color.blue and candleColor[1] == color.red
blueRed = candleColor == color.red and candleColor[1] == color.blue
greenPurpule = candleColor == color.fuchsia and candleColor[1] == color.lime
purpleGreen = candleColor == color.lime and candleColor[1] == color.fuchsia
bluePurpule = candleColor == color.fuchsia and candleColor[1] == color.blue
purpleBlue = candleColor == color.blue and candleColor[1] == color.fuchsia
alertcondition(redGreen, title='Red/Green Vector Candle Pattern', message='{{ticker}} Red/Green Vector Candle Pattern on the {{interval}}')
alertcondition(greenRed, title='Green/Red Vector Candle Pattern', message='{{ticker}} Green/Red Vector Candle Pattern on the {{interval}}')
alertcondition(redBlue, title='Red/Blue Vector Candle Pattern', message='{{ticker}} Red/Blue Vector Candle Pattern on the {{interval}}')
alertcondition(blueRed, title='Blue/Red Vector Candle Pattern', message='{{ticker}} Blue/Red Vector Candle Pattern on the {{interval}}')
alertcondition(greenPurpule, title='Green/Purple Vector Candle Pattern', message='{{ticker}} Green/Purple Vector Candle Pattern on the {{interval}}')
alertcondition(purpleGreen, title='Purple/Green Vector Candle Pattern', message='{{ticker}} Purple/Green Vector Candle Pattern on the {{interval}}')
alertcondition(bluePurpule, title='Blue/Purple Vector Candle Pattern', message='{{ticker}} Blue/Purple Vector Candle Pattern on the {{interval}}')
alertcondition(purpleBlue, title='Purple/Blue Vector Candle Pattern', message='{{ticker}} Purple/Blue Vector Candle Pattern on the {{interval}}')
//ADR
// Daily ADR
day_adr = request.security(syminfo.tickerid, 'D', adr(aDRRange,1), lookahead=barmerge.lookahead_on)
day_adr_high = request.security(syminfo.tickerid, 'D', showADR_DO ? adr_high(day_adr, true) : adr_high(day_adr, false), lookahead=barmerge.lookahead_on)
day_adr_low = request.security(syminfo.tickerid, 'D', showADR_DO ? adr_low(day_adr, true) : adr_low(day_adr, false), lookahead=barmerge.lookahead_on)
day_adr_high_50 = day_adr_high - (day_adr/2)
day_adr_low_50 = day_adr_low + (day_adr/2)
if showADR
string hl = 'Hi-ADR'+ (showADR_DO?'(DO)':'')
string ll = 'Lo-ADR'+ (showADR_DO?'(DO)':'')
draw_line(day_adr_high, 'D', hl, adrColor, adrStyle, 2, extend.right, showADRLabels and validTimeFrame, adr_label_x_offset)
draw_line(day_adr_low, 'D', ll, adrColor, adrStyle, 2, extend.right, showADRLabels and validTimeFrame, adr_label_x_offset)
r_label_offset((day_adr_high + day_adr_low) / 2, 'ADR ' + str.format('{0,number,#.##}', to_pips(day_adr)) + 'PIPS|' + str.tostring(day_adr, format.mintick) + syminfo.currency, label.style_none, adrColor, showADRLabels and validTimeFrame and showADRRange, adr_label_x_offset) //ry, rtext, rstyle, rcolor, valid
if showADR and showADR_50
string hl = '50% Hi-ADR'+ (showADR_DO?'(DO)':'')
string ll = '50% Lo-ADR'+ (showADR_DO?'(DO)':'')
draw_line(day_adr_high_50, 'D', hl, adrColor, adrStyle, 2, extend.right, showADRLabels and validTimeFrame, adr_label_x_offset_50)
draw_line(day_adr_low_50, 'D', ll, adrColor, adrStyle, 2, extend.right, showADRLabels and validTimeFrame, adr_label_x_offset_50)
r_label_offset((day_adr_high_50 + day_adr_low_50) / 2, '50% ADR ' + str.format('{0,number,#.##}', to_pips(day_adr/2)) + 'PIPS|' + str.tostring(day_adr/2, format.mintick) + syminfo.currency, label.style_none, adrColor, showADRLabels and validTimeFrame and showADRRange, adr_label_x_offset_50) //ry, rtext, rstyle, rcolor, valid
alertcondition(close >= day_adr_high and day_adr_high != 0.0 , "ADR High reached", "PA has reached the calculated ADR High")
alertcondition(close <= day_adr_low and day_adr_low != 0.0 , "ADR Low reached", "PA has reached the calculated ADR Low")
alertcondition(close >= day_adr_high_50 and day_adr_high_50 != 0.0 , "50% of ADR High reached", "PA has reached 50% of the calculated ADR High")
alertcondition(close <= day_adr_low_50 and day_adr_low_50 != 0.0 , "50% ADR Low reached", "PA has reached 50% the calculated ADR Low")
//Weekly ADR
week_adr = request.security(syminfo.tickerid, 'W', adr(aWRRange,1), lookahead=barmerge.lookahead_on)
week_adr_high = request.security(syminfo.tickerid, 'W', showAWR_WO ? adr_high(week_adr, true) : adr_high(week_adr, false), lookahead=barmerge.lookahead_on)
week_adr_low = request.security(syminfo.tickerid, 'W', showAWR_WO ? adr_low(week_adr, true) : adr_low(week_adr, false), lookahead=barmerge.lookahead_on)
week_adr_high_50 = week_adr_high - (week_adr/2)
week_adr_low_50 = week_adr_low + (week_adr/2)
if showAWR
string hl = 'Hi-AWR'+ (showAWR_WO?'(WO)':'')
string ll = 'Lo-AWR'+ (showAWR_WO?'(WO)':'')
draw_line(week_adr_high, 'W', hl, awrColor, awrStyle, 1, extend.right, showAWRLabels and validTimeFrame, adr_label_x_offset)
draw_line(week_adr_low, 'W', ll, awrColor, awrStyle, 1, extend.right, showAWRLabels and validTimeFrame, adr_label_x_offset)
r_label_offset((week_adr_high + week_adr_low) / 2, 'AWR ' + str.format('{0,number,#.##}', to_pips(week_adr)) + 'PIPS|' + str.tostring(week_adr, format.mintick) + syminfo.currency, label.style_none, awrColor, showAWRLabels and validTimeFrame and showAWRRange, adr_label_x_offset) //ry, rtext, rstyle, rcolor, valid
if showAWR and showAWR_50
string hl = '50% Hi-AWR'+ (showAWR_WO?'(WO)':'')
string ll = '50% Lo-AWR'+ (showAWR_WO?'(WO)':'')
draw_line(week_adr_high_50, 'W', hl, awrColor, awrStyle, 1, extend.right, showAWRLabels and validTimeFrame, adr_label_x_offset_50)
draw_line(week_adr_low_50, 'W', ll, awrColor, awrStyle, 1, extend.right, showAWRLabels and validTimeFrame, adr_label_x_offset_50)
r_label_offset((week_adr_high_50 + week_adr_low_50) / 2, '50% AWR ' + str.format('{0,number,#.##}', to_pips(week_adr/2)) + 'PIPS|' + str.tostring(week_adr/2, format.mintick) + syminfo.currency, label.style_none, awrColor, showAWRLabels and validTimeFrame and showAWRRange, adr_label_x_offset_50) //ry, rtext, rstyle, rcolor, valid
alertcondition(close >= week_adr_high and week_adr_high != 0 , "AWR High reached", "PA has reached the calculated AWR High")
alertcondition(close <= week_adr_low and week_adr_low != 0 , "AWR Low reached", "PA has reached the calculated AWR Low")
alertcondition(close >= week_adr_high_50 and week_adr_high_50 != 0 , "50% of AWR High reached", "PA has reached 50% of the calculated AWR High")
alertcondition(close <= week_adr_low_50 and week_adr_low_50 != 0 , "50% AWR Low reached", "PA has reached 50% of the calculated AWR Low")
//Monthly ADR
month_adr = request.security(syminfo.tickerid, 'M', adr(aMRRange,1), lookahead=barmerge.lookahead_on)
month_adr_high = request.security(syminfo.tickerid, 'M', showAMR_MO ? adr_high(month_adr, true) : adr_high(month_adr, false), lookahead=barmerge.lookahead_on)
month_adr_low = request.security(syminfo.tickerid, 'M', showAMR_MO ? adr_low(month_adr, true) : adr_low(month_adr, false), lookahead=barmerge.lookahead_on)
month_adr_high_50 = month_adr_high - (month_adr/2)
month_adr_low_50 = month_adr_low + (month_adr/2)
if showAMR and timeframe.isminutes and timeframe.multiplier >= 3
string hl = 'Hi-AMR'+ (showAMR_MO?'(MO)':'')
string ll = 'Lo-AMR'+ (showAMR_MO?'(MO)':'')
draw_line(month_adr_high, 'M', hl, amrColor, amrStyle, 1, extend.right, showAMRLabels and validTimeFrame, adr_label_x_offset)
draw_line(month_adr_low, 'M', ll, amrColor, amrStyle, 1, extend.right, showAMRLabels and validTimeFrame, adr_label_x_offset)
r_label_offset((month_adr_high + month_adr_low) / 2, 'AMR ' + str.format('{0,number,#.##}', to_pips(month_adr)) + 'PIPS|' + str.tostring(month_adr, format.mintick) + syminfo.currency, label.style_none, amrColor, showAMRLabels and validTimeFrame and showAMRRange,adr_label_x_offset) //ry, rtext, rstyle, rcolor, valid
if showAMR and showAMR_50 and timeframe.isminutes and timeframe.multiplier >= 3
string hl = '50% Hi-AMR'+ (showAMR_MO?'(MO)':'')
string ll = '50% Lo-AMR'+ (showAMR_MO?'(MO)':'')
draw_line(month_adr_high_50, 'M', hl, amrColor, amrStyle, 1, extend.right, showAMRLabels and validTimeFrame, adr_label_x_offset_50)
draw_line(month_adr_low_50, 'M', ll, amrColor, amrStyle, 1, extend.right, showAMRLabels and validTimeFrame, adr_label_x_offset_50)
r_label_offset((month_adr_high_50 + month_adr_low_50) / 2, '50% AMR ' + str.format('{0,number,#.##}', to_pips(month_adr/2)) + 'PIPS|' + str.tostring(month_adr/2, format.mintick) + syminfo.currency, label.style_none, amrColor, showAMRLabels and validTimeFrame and showAMRRange,adr_label_x_offset_50) //ry, rtext, rstyle, rcolor, valid
alertcondition(close >= month_adr_high and month_adr_high != 0 , "AMR High reached", "PA has reached the calculated AMR High")
alertcondition(close <= month_adr_low and month_adr_low != 0 , "AMR Low reached", "PA has reached the calculated AMR Low")
alertcondition(close >= month_adr_high_50 and month_adr_high_50 != 0 , "50% of AMR High reached", "PA has reached 50% of the calculated AMR High")
alertcondition(close <= month_adr_low_50 and month_adr_low_50 != 0 , "50% of AMR Low reached", "PA has reached 50% of the calculated AMR Low")
//Range Daily Hi/Lo
day_rd = request.security(syminfo.tickerid, 'D', adr(rdRange, 1), lookahead=barmerge.lookahead_on)
day_range_high = request.security(syminfo.tickerid, 'D', showRD_DO ? adr_high(day_rd, true) : adr_high(day_rd, false), lookahead=barmerge.lookahead_on)
day_range_low = request.security(syminfo.tickerid, 'D', showRD_DO ? adr_low(day_rd, true) : adr_low(day_rd, false), lookahead=barmerge.lookahead_on)
day_range_high_50 = day_range_high - (day_rd/2)
day_range_low_50 = day_range_low + (day_rd/2)
if showRD
string hl = 'RD-Hi'+ (showRD_DO?'(DO)':'')
string ll = 'RD-Lo'+ (showRD_DO?'(DO)':'')
draw_line(day_range_high, 'D', hl, rdColor, rdStyle, 2, extend.right, showRDLabels and validTimeFrame, rd_label_x_offset)
draw_line(day_range_low, 'D', ll, rdColor, rdStyle, 2, extend.right, showRDLabels and validTimeFrame, rd_label_x_offset)
r_label_offset((day_range_high + day_range_low) / 2, 'RD ' + str.format('{0,number,#.##}', to_pips(day_rd)) + 'PIPS|' + str.tostring(day_rd/2, format.mintick) + syminfo.currency, label.style_none, rdColor, showRDLabels and validTimeFrame and showRDRange, rd_label_x_offset) //ry, rtext, rstyle, rcolor, valid
if showRD and showRD_50
string hl = '50% RD-Hi'+ (showRD_DO?'(DO)':'')
string ll = '50% RD-Lo'+ (showRD_DO?'(DO)':'')
draw_line(day_range_high_50, 'D', hl, rdColor, rdStyle, 2, extend.right, showRDLabels and validTimeFrame, rd_label_x_offset_50)
draw_line(day_range_low_50, 'D', ll, rdColor, rdStyle, 2, extend.right, showRDLabels and validTimeFrame, rd_label_x_offset_50)
r_label_offset((day_range_high_50 + day_range_high_50) / 2, '50% RD ' + str.format('{0,number,#.##}', to_pips(day_rd/2)) + 'PIPS|' + str.tostring(day_rd/2, format.mintick) + syminfo.currency, label.style_none, rdColor, showRDLabels and validTimeFrame and showRDRange, rd_label_x_offset_50) //ry, rtext, rstyle, rcolor, valid
alertcondition(close >= day_range_high and day_range_high != 0 , "Range Daily High reached", "PA has reached the calculated Range Daily High")
alertcondition(close <= day_range_low and day_range_low != 0 , "Range Daily Low reached", "PA has reached the calculated Range Daily Low")
alertcondition(close >= day_range_high_50 and day_range_high_50 != 0 , "50% of Range Daily High reached", "PA has reached 50% of the calculated Range Daily High")
alertcondition(close <= day_range_low_50 and day_range_low_50 != 0 , "50% of Range Daily Low reached", "PA has reached 50% of the calculated Range Daily Low")
//Range Weekly Hi/Lo
week_rd = request.security(syminfo.tickerid, 'W', adr(rwRange, 1), lookahead=barmerge.lookahead_on)
week_range_high = request.security(syminfo.tickerid, 'W', showRW_WO ? adr_high(week_rd, true) : adr_high(week_rd, false), lookahead=barmerge.lookahead_on)
week_range_low = request.security(syminfo.tickerid, 'W', showRW_WO ? adr_low(week_rd, false) : adr_low(week_rd, false), lookahead=barmerge.lookahead_on)
week_range_high_50 = week_range_high - (week_rd/2)
week_range_low_50 = week_range_low + (week_rd/2)
if showRW
string hl = 'RW-Hi'+ (showRW_WO?'(WO)':'')
string ll = 'RW-Lo'+ (showRW_WO?'(WO)':'')
draw_line(week_range_high, 'D', hl, rwColor, rwStyle, 2, extend.right, showRWLabels and validTimeFrame, rd_label_x_offset)
draw_line(week_range_low, 'D', ll, rwColor, rwStyle, 2, extend.right, showRWLabels and validTimeFrame, rd_label_x_offset)
r_label_offset((week_range_high + week_range_low) / 2, 'RW ' + str.format('{0,number,#.##}', to_pips(week_rd)) + 'PIPS|' + str.tostring(week_rd/2, format.mintick) + syminfo.currency, label.style_none, rwColor, showRWLabels and validTimeFrame and showRWRange,rd_label_x_offset) //ry, rtext, rstyle, rcolor, valid
if showRW and showRW_50
string hl = '50% RW-Hi'+ (showRW_WO?'(WO)':'')
string ll = '50% RW-Lo'+ (showRW_WO?'(WO)':'')
draw_line(week_range_high_50, 'D', hl, rwColor, rwStyle, 2, extend.right, showRWLabels and validTimeFrame, rd_label_x_offset_50)
draw_line(week_range_low_50, 'D', ll, rwColor, rwStyle, 2, extend.right, showRWLabels and validTimeFrame, rd_label_x_offset_50)
r_label_offset((week_range_high_50 + week_range_low_50) / 2, '50% RW ' + str.format('{0,number,#.##}', to_pips(week_rd/2)) + 'PIPS|' + str.tostring(week_rd/2, format.mintick) + syminfo.currency, label.style_none, rwColor, showRWLabels and validTimeFrame and showRWRange, rd_label_x_offset_50) //ry, rtext, rstyle, rcolor, valid
alertcondition(close >= week_range_high and week_range_high != 0 , "Range Weekly High reached", "PA has reached the calculated Range Weekly High")
alertcondition(close <= week_range_low and week_range_low != 0 , "Range Weekly Low reached", "PA has reached the calculated Range Weekly Low")
alertcondition(close >= week_range_high_50 and week_range_high_50 != 0 , "50% of Range Weekly High reached", "PA has reached 50% of the calculated Range Weekly High")
alertcondition(close <= week_range_low_50 and week_range_low_50 != 0 , "50% of Range Weekly Low reached", "PA has reached 50% of the calculated Range Weekly Low")
if barstate.islast and showAdrTable and validTimeFrame
if showAdrPips or showAdrCurrency
var table panel = table.new(choiceAdrTable, 2, 16, bgcolor=adrTableBgColor)
// Table header.
table.cell(panel, 0, 0, '')
table.cell(panel, 1, 0, '')
if showAdrPips
table.cell(panel, 0, 2, 'ADR', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 2, str.format('{0,number,#.##}', to_pips(day_adr)) + "PIPS" , text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 3, 'ADRx3', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 3, str.format('{0,number,#.##}', to_pips(day_adr) * 3)+ "PIPS", text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 4, 'AWR', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 4, str.format('{0,number,#.##}', to_pips(week_adr)) + "PIPS", text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 5, 'AMR', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 5, str.format('{0,number,#.##}', to_pips(month_adr)) + "PIPS", text_color=adrTableTxtColor, text_halign=text.align_left)
if showAdrCurrency
table.cell(panel, 0, 6, 'ADR', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 6, str.tostring(day_adr, format.mintick) + syminfo.currency, text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 7, 'ADRx3', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 7, str.tostring(day_adr * 3, format.mintick) + syminfo.currency, text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 8, 'AWR', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 8, str.tostring(week_adr, format.mintick) + syminfo.currency, text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 9, 'AMR', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 9, str.tostring(month_adr, format.mintick) + syminfo.currency, text_color=adrTableTxtColor, text_halign=text.align_left)
if showRDPips
table.cell(panel, 0, 10, 'RD', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 10, str.format('{0,number,#.##}', to_pips(day_rd)) + "PIPS" , text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 11, 'RDx3', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 11, str.format('{0,number,#.##}', to_pips(day_rd) * 3)+ "PIPS", text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 12, 'RW', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 12, str.format('{0,number,#.##}', to_pips(week_adr)) + "PIPS", text_color=adrTableTxtColor, text_halign=text.align_left)
if showRDCurrency
table.cell(panel, 0, 13, 'RD', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 13, str.tostring(day_rd, format.mintick) + syminfo.currency, text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 14, 'RDx3', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 14, str.tostring(day_rd * 3, format.mintick) + syminfo.currency, text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 0, 15, 'RW', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(panel, 1, 15, str.tostring(week_rd, format.mintick) + syminfo.currency, text_color=adrTableTxtColor, text_halign=text.align_left)
// M - Levels
//Calculate Pivot Point
// 2021-03025 updated by infernix
//M calculations
m0C = (pivS2 + pivS3) / 2
m1C = (pivS1 + pivS2) / 2
m2C = (pivotPoint + pivS1) / 2
m3C = (pivotPoint + pivR1) / 2
m4C = (pivR1 + pivR2) / 2
m5C = (pivR2 + pivR3) / 2
m0line = draw_pivot(validTimeFrame and activeM and m0C ? m0C : na, 'D', 'M0', mColor, mLabelColor, mStyle, 1, extendPivots ? extend.both : extend.right, showMLabels and validTimeFrame)
m1line = draw_pivot(validTimeFrame and activeM and m1C ? m1C : na, 'D', 'M1', mColor, mLabelColor, mStyle, 1, extendPivots ? extend.both : extend.right, showMLabels and validTimeFrame)
m2line = draw_pivot(validTimeFrame and activeM and m2C ? m2C : na, 'D', 'M2', mColor, mLabelColor, mStyle, 1, extendPivots ? extend.both : extend.right, showMLabels and validTimeFrame)
m3line = draw_pivot(validTimeFrame and activeM and m3C ? m3C : na, 'D', 'M3', mColor, mLabelColor, mStyle, 1, extendPivots ? extend.both : extend.right, showMLabels and validTimeFrame)
m4line = draw_pivot(validTimeFrame and activeM and m4C ? m4C : na, 'D', 'M4', mColor, mLabelColor, mStyle, 1, extendPivots ? extend.both : extend.right, showMLabels and validTimeFrame)
m5line = draw_pivot(validTimeFrame and activeM and m5C ? m5C : na, 'D', 'M5', mColor, mLabelColor, mStyle, 1, extendPivots ? extend.both : extend.right, showMLabels and validTimeFrame)
//*****************
// Market sessions
//*****************
splitSessionString(sessXTime) =>
//session stirng looks like this: 0000-0000:1234567 ie start time, end time, day of the week
//we need to parse the sessXTime string into hours and min for start and end times so we can use those in the timestampfunction below
//string times contains "0000-2300" as an example
string times = array.get(str.split(sessXTime, ':'), 0)
//string startTime contains "0000"
string startTime = array.get(str.split(times, '-'), 0)
//string endTime contains "2300"
string endTime = array.get(str.split(times, '-'), 1)
//now we need to get the start hour and start min, sing 0 index - hour is the characters in index 0 and index 1 while min is the chars at index 2 and 3
string[] startTimeChars = str.split(startTime, '')
string[] endTimeChars = str.split(endTime, '')
//so now startHour contains 00 and start min contains 00
string startHour = array.get(startTimeChars, 0) + array.get(startTimeChars, 1)
string startMin = array.get(startTimeChars, 2) + array.get(startTimeChars, 3)
//so now endHour contains 23 and end min contains 00
string endHour = array.get(endTimeChars, 0) + array.get(endTimeChars, 1)
string endMin = array.get(endTimeChars, 2) + array.get(endTimeChars, 3)
[startHour, startMin, endHour, endMin]
calc_session_startend(sessXTime, gmt) =>
[startHour, startMin, endHour, endMin] = splitSessionString(sessXTime)
targetstartTimeX = timestamp(gmt, year, month, dayofmonth, math.round(str.tonumber(startHour)), math.round(str.tonumber(startMin)), 00)
targetendTimeX = timestamp(gmt, year, month, dayofmonth, math.round(str.tonumber(endHour)), math.round(str.tonumber(endMin)), 00)
time_now = timestamp(year, month, dayofmonth, hour, minute, 00)
midnight_exchange = timestamp(year, month, dayofmonth, 00, 00, 00)
//if start hour is greater than end hour we are dealing with a session that starts towards the end of one day
//and ends the next day. ie advance the end time by 24 hours - its the next day
bool adjusted = false
if gmt == 'GMT+0'
if math.round(str.tonumber(startHour)) > math.round(str.tonumber(endHour))
if time_now - targetstartTimeX >= 0
targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
adjusted := true
targetendTimeX
if gmt == 'GMT+1'
if math.round(str.tonumber(startHour)) == 0
startHour := '24'
if math.round(str.tonumber(endHour)) == 0
endHour := '24'
if math.round(str.tonumber(startHour))-1 > math.round(str.tonumber(endHour))-1
if time_now - targetstartTimeX >= 0
targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
adjusted := true
targetendTimeX
//now is the exchange is at some utc offset and the market session crosses days even when start hour is not greater than end hour
//we still need to adjust the end time.
if targetstartTimeX < midnight_exchange and midnight_exchange < targetendTimeX and not adjusted
targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
targetendTimeX
[targetstartTimeX,targetendTimeX]
draw_open_range(sessXTime, sessXcol, show_orX, gmt)=>
if show_orX
// Initialize variables on bar zero only, so they preserve their values across bars.
var hi = float(na)
var lo = float(na)
var box hiLoBox = na
// Detect changes in timeframe.
session = time(timeframe.period, sessXTime, gmt)
bool newTF = session and not session[1]
if newTF
// New bar in higher timeframe; reset values and create new lines and box.
[targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime, gmt)
sessionDuration = math.round(math.abs(time - targetendTimeX)/(timeframe.multiplier*60*1000))
hi := high
lo := low
hiLoBox := box.new(bar_index, hi, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, lo, border_color = na, bgcolor = sessXcol)
int(na)
else
if timeframe.multiplier == 1 and (na(session[1]) and not na(session) or session[1] < session)
box.set_right(hiLoBox, bar_index+1)
int(na)
draw_session_hilo(sessXTime, show_rectangleX, show_labelX, sessXcolLabel, sessXLabel, gmt)=>
if show_rectangleX
// Initialize variables on bar zero only, so they preserve their values across bars.
var hi = float(0)
var lo = float(10000000000.0)
var line line_t = na
var line line_b = na
var label line_label = na
// var box hiLoBox = na
// Detect changes in timeframe.
session = time(timeframe.period, sessXTime, gmt)
sessLineStyleX = rectStyle == 'Solid' ? line.style_solid : line.style_dashed
bool newTF = session and not session[1]
hi := newTF ? high : session ? math.max(high, hi[1]) : hi[1]
lo := newTF ? low : session ? math.min(low, lo[1]) : lo[1]
if newTF
beginIndex = bar_index
[targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime, gmt)
sessionDuration = math.round(math.abs(time - targetendTimeX)/(timeframe.multiplier*60*1000))
line_t := line.new(beginIndex, hi, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, hi, xloc=xloc.bar_index, style=sessLineStyleX, color=sessXcolLabel)
line_b := line.new(beginIndex, lo, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, lo, xloc=xloc.bar_index, style=sessLineStyleX, color=sessXcolLabel)
line.delete(line_t[1])
line.delete(line_b[1])
if show_labelX
line_label := label.new(beginIndex, hi, sessXLabel, xloc=xloc.bar_index, textcolor=sessXcolLabel, style=label.style_none, size=size.normal, textalign=text.align_right)
label.delete(line_label[1])
int(na)
else
if na(session[1]) and not na(session) or session[1] < session
if timeframe.multiplier == 1
line.set_x2(line_t,bar_index+1)
line.set_x2(line_b,bar_index+1)
line.set_y1(line_t,hi)
line.set_y2(line_t,hi)
line.set_y1(line_b,lo)
line.set_y2(line_b,lo)
if show_labelX and not na(line_label)
label.set_y(line_label, hi)
int(na)
//*****************************//
// Daylight Savings Time Flags //
//*****************************//
int previousSunday = dayofmonth - dayofweek + 1
bool nyDST = na
bool ukDST = na
bool sydDST = na
if month < 3 or month > 11
nyDST := false
ukDST := false
sydDST := true
else if month > 4 and month < 10
nyDST := true
ukDST := true
sydDST := false
else if month == 3
nyDST := previousSunday >= 8
ukDST := previousSunday >= 24
sydDST := true
else if month == 4
nyDST := true
ukDST := true
sydDST := previousSunday <= 0
else if month == 10
nyDST := true
ukDST := previousSunday <= 24
sydDST := previousSunday >= 0
else // month == 11
nyDST := previousSunday <= 0
ukDST := false
sydDST := true
if ukDST
draw_open_range(sess1Time,sess1col,show_or1,'GMT+1')
draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel, sess1Label, 'GMT+1')
else
draw_open_range(sess1Time,sess1col,show_or1,'GMT+0')
draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel, sess1Label, 'GMT+0')
if nyDST
draw_open_range(sess2Time,sess2col,show_or2,'GMT+1')
draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel, sess2Label, 'GMT+1')
else
draw_open_range(sess2Time,sess2col,show_or2,'GMT+0')
draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel, sess2Label, 'GMT+0')
// Tokyo
draw_open_range(sess3Time,sess3col,show_or3,'GMT+0')
draw_session_hilo(sess3Time, show_rectangle3, show_label3, sess3colLabel, sess3Label, 'GMT+0')
// Hong Kong
draw_open_range(sess4Time,sess4col,show_or4,'GMT+0')
draw_session_hilo(sess4Time, show_rectangle4, show_label4, sess4colLabel, sess4Label, 'GMT+0')
if sydDST
draw_open_range(sess5Time,sess5col,show_or5,'GMT+1')
draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel, sess5Label, 'GMT+1')
else
draw_open_range(sess5Time,sess5col,show_or5,'GMT+0')
draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel, sess5Label, 'GMT+0')
//eu brinks is for london
if ukDST
draw_open_range(sess6Time,sess6col,show_or6,'GMT+1')
draw_session_hilo(sess6Time, show_rectangle6, show_label6, sess6colLabel, sess6Label, 'GMT+1')
else
draw_open_range(sess6Time,sess6col,show_or6,'GMT+0')
draw_session_hilo(sess6Time, show_rectangle6, show_label6, sess6colLabel, sess6Label, 'GMT+0')
//us brinks is ny
if nyDST
draw_open_range(sess7Time,sess7col,show_or7,'GMT+1')
draw_session_hilo(sess7Time, show_rectangle7, show_label7, sess7colLabel, sess7Label, 'GMT+1')
else
draw_open_range(sess7Time,sess7col,show_or7,'GMT+0')
draw_session_hilo(sess7Time, show_rectangle7, show_label7, sess7colLabel, sess7Label, 'GMT+0')
//becuase frankfurt changes with london
if ukDST
draw_open_range(sess8Time,sess8col,show_or8,'GMT+1')
draw_session_hilo(sess8Time, show_rectangle8, show_label8, sess8colLabel, sess8Label, 'GMT+1')
else
draw_open_range(sess8Time,sess8col,show_or8,'GMT+0')
draw_session_hilo(sess8Time, show_rectangle8, show_label8, sess8colLabel, sess8Label, 'GMT+0')
//************//
// Psy Levels //
//************//
var int oneWeekMillis = (7 * 24 * 60 * 60 * 1000)
// Timestamp any of the 6 previous days in the week (such as last Wednesday at 21 hours GMT)
timestampPreviousDayOfWeek(previousDayOfWeek, hourOfDay, GMTOffset) =>
int dayofweekOffset = na
int previousDayOfMonth = na
int psySessionStartTime = na
int returnValue = na
//today we onlu care about Monday - forec and Saturday for crypto - if that changes in the future this code will need to be updated
if previousDayOfWeek == "Monday"
dayofweekOffset := (dayofweek(time, GMTOffset) - 1 + 6) % 7
if previousDayOfWeek == "Saturday"
dayofweekOffset := (dayofweek(time, GMTOffset) - 1 + 1) % 7
previousDayOfMonth := dayofmonth(time, GMTOffset) - dayofweekOffset
//based on time we are on the day where the psy levels will change - now we need to determine if we are before or after the
//time when the psy levels will chnge
//today is Saturday or Monday dayofweekOffset will be equal to zero and we are checking if the current time is before the psy level change
//we also need to be minful of GMTOffset. using and hourOfDay != 00 because if we switch at midnight we dont have to do anything
if dayofweekOffset == 0 and GMTOffset == "GMT" and hourOfDay >= hour(time,GMTOffset) and hourOfDay != 00
//even thou today is saturday we are still not past the change time - subract a week because it is not time to change yet
returnValue := timestamp(GMTOffset, year, month, previousDayOfMonth, hourOfDay, 00, 00) - oneWeekMillis
//same as previous but handling GMT+1
else if dayofweekOffset == 0 and GMTOffset == "GMT+1" and hourOfDay -1 >= hour(time,GMTOffset) //and 0 != minute(time,GMTOffset)
returnValue := timestamp(GMTOffset, year, month, previousDayOfMonth, hourOfDay, 00, 00) - oneWeekMillis
//default - we have already switched some time ago
else
returnValue := timestamp(GMTOffset, year, month, previousDayOfMonth, hourOfDay, 00, 00)
returnValue
int psySession = na
int psySessionStartDay = na
int psySessionStartTime = na
bool inPsySession = na
float psyHi = na
float psyLo = na
string psyHiLabel = na
string psyLoLabel = na
//only do the calc if the user has not disabled the psy levels
if show_psylevels
//4 hour res based on how mt4 does it
//mt4 code
//int Li_4 = iBarShift(NULL, PERIOD_H4, iTime(NULL, PERIOD_W1, Li_0)) - 2 - Offset;
//ObjectCreate("PsychHi", OBJ_TREND, 0, Time[0], iHigh(NULL, PERIOD_H4, iHighest(NULL, PERIOD_H4, MODE_HIGH, 2, Li_4)), iTime(NULL, PERIOD_W1, 0), iHigh(NULL, PERIOD_H4,
//iHighest(NULL, PERIOD_H4, MODE_HIGH, 2, Li_4)));
//so basically because the session is 8 hours and we are looking at a 4 hour resolution we only need to take the highest high an lowest low of 2 bars
//we use the gmt offset to adjust the 0000-0800 session to Sydney open which is at 2100 during dst and at 2200 otherwize. (dst - spring foward, fall back)
//keep in mind sydney is in the souther hemisphere so dst is oposite of when london and new york go into dst
if psyType == 'crypto'
if sydDST
psySession := time('240', '2200-0600:1', "GMT+1")
psySessionStartTime := timestampPreviousDayOfWeek('Saturday', 22, 'GMT+1')
else
psySession := time('240', '2200-0600:1', "GMT")
psySessionStartTime := timestampPreviousDayOfWeek('Saturday', 22, 'GMT')
else
psySession := time('240', '0000-0800:2', "GMT")
psySessionStartTime := timestampPreviousDayOfWeek('Monday', 00, 'GMT')
inPsySession := na(psySession) ? false : true
if inPsySession
// When entering a new psy session, initialize hi/lo
if not inPsySession[1]
psyHi := high
psyLo := low
psyHiLabel := 'Psy-Hi calculating...'
psyLoLabel := 'Psy-Lo calculating...'
// After initialization, calculate psy hi/lo
else
psyHi := math.max(high, psyHi[1])
psyLo := math.min(low, psyLo[1])
//stylePsy := line.style_dashed //this does not work for style correctly but it does for the label which is odd
psyHiLabel := 'Psy-Hi calculating...'
psyLoLabel := 'Psy-Lo calculating...'
// When not in the psy session, use the last value of psyHi and psyLo
else
psyHi := psyHi[1]
psyLo := psyLo[1]
psyHiLabel := 'Psy-Hi'
psyLoLabel := 'Psy-Lo'
// Draw Psy Level Lines
if (barstate.islast) and not showallPsy and show_psylevels
// Extend line back to the previous start time (after Psy-Hi/Lo have been calculated)
psyHiLine = line.new(time, psyHi, psySessionStartTime, psyHi, xloc.bar_time, extend.none, psycolH)
line.delete(psyHiLine[1])
psyLoLine = line.new(time, psyLo, psySessionStartTime, psyLo, xloc.bar_time, extend.none, psycolL)
line.delete(psyLoLine[1])
// Write Psy Level Labels - same label regardless if line.new or plot used
r_label(psyHi, psyHiLabel, label.style_none, psycolH, show_psylabel)
r_label(psyLo, psyLoLabel, label.style_none, psycolL, show_psylabel)
// Plot Historical Psy Level
plot(showPsy and show_psylevels and showallPsy ? psyHi : na, color=psycolH, style=plot.style_stepline, linewidth=2, editable=false, title="Psy-Hi") //, offset=psy_plot_offset)
plot(showPsy and show_psylevels and showallPsy ? psyLo : na, color=psycolL, style=plot.style_stepline, linewidth=2, editable=false, title="Psy-Lo") //, offset=psy_plot_offset)
//***********
// Daily open
//***********
getdayOpen()=>
in_sessionDly = time('D', '24x7')
bool isDly = ta.change(time('D'))//ta.change(in_sessionDly)//in_sessionDly and not in_sessionDly[1]
var dlyOpen = float(na)
if isDly
dlyOpen := open
dlyOpen
daily_open = getdayOpen()
//this plot is only to show historical values when the option is selected.
plot(show_rectangle9 and validTimeFrame and showallDly ? daily_open : na, color=sess9col, style=plot.style_stepline, linewidth=2, editable=false, title="Daily Open")
if showallDly
//if historical values are selected to be shown - then add a label to the plot
r_label(daily_open, 'Daily Open', label.style_none, sess9col, validTimeFrame and show_label9)
showallDly
else
if show_rectangle9
//othewise we draw the line and label together - showing only todays line.
draw_line_DO(daily_open, 'D', 'Daily Open', sess9col, line.style_solid, 1, extend.none, validTimeFrame and show_label9, label_x_offset)
//London DST Starts Last Sunday of March DST Edns Last Sunday of October
//New York DST Starts 2nd Sunday of March DST Edns 1st Sunday of November
//Sydney DST Start on 1st Sunday of October DST ends 1st Sunday of Arpil
//Frankfurt DST Starts Last Sunday of March DST Edns Last Sunday of October
if barstate.islast and showDstTable
var table dstTable = table.new(choiceDstTable, 2, 8, bgcolor=dstTableBgColor)
//general
table.cell(dstTable, 0, 0, 'London DST Starts Last Sunday of March | DST Ends Last Sunday of October', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(dstTable, 0, 1, 'New York DST Starts 2nd Sunday of March | DST Ends 1st Sunday of November', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(dstTable, 0, 2, 'Tokyo does not observe DST', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(dstTable, 0, 3, 'Hong Kong does not observe DST', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(dstTable, 0, 4, 'Sydney DST Start on 1st Sunday of October | DST Ends 1st Sunday of Arpil', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(dstTable, 0, 5, 'EU Brinks DST Starts Last Sunday of March | DST Ends Last Sunday of October', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(dstTable, 0, 6, 'US Brinks DST Starts 2nd Sunday of March | DST Ends 1st Sunday of November', text_color=adrTableTxtColor, text_halign=text.align_left)
table.cell(dstTable, 0, 7, 'Frankfurt DST Starts Last Sunday of March | DST Ends Last Sunday of October', text_color=adrTableTxtColor, text_halign=text.align_left) |
RK1383_2022_FRM | https://www.tradingview.com/script/Pn26364d-RK1383-2022-FRM/ | RK1383 | https://www.tradingview.com/u/RK1383/ | 22 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RK1383
//@version=5
//indicator checks the fibonacci levels based on moving averages and makes buy and sell decision based on the RSI and MFI
// the moving average length is also based on the fibonacci numbers
indicator(title = "RK1383_2022_FRM", overlay = true)
//input data_Fibonacci
period = input(34, title="Fibonacci Avaraging period", tooltip = "select fibonacci numbers 8, 13, 21, 34, 55, 89, 144, 233")
price = input(hlc3, title="price")
mult = input(2.0, title="miltiplier")
//input data_moving average
ma_period = input (9, title="moving average period")
ma_price = input (hlc3, title="MA price")
//technical indicators
//trend:moving average crossovers
P_SMA = ta.sma(ma_price, ma_period)
P_WMA = ta.wma(ma_price, ma_period)
P_CO = P_WMA - P_SMA
//plot (P_CO, "Crossover", style = plot.style_columns)
//fibonacci bolinger bands
F_baseline = ta.wma(price,period)
deviation = ta.stdev(price,period) * mult
F_U_1= F_baseline + (0.236 * deviation)
F_U_2= F_baseline + (0.382*deviation)
F_U_3= F_baseline + (0.5*deviation)
F_U_4= F_baseline + (0.618*deviation)
F_U_5= F_baseline + (0.764*deviation)
F_U= F_baseline + (1*deviation)
F_L_1= F_baseline - (0.236 * deviation)
F_L_2= F_baseline - (0.382*deviation)
F_L_3= F_baseline - (0.5*deviation)
F_L_4= F_baseline - (0.618*deviation)
F_L_5= F_baseline - (0.764*deviation)
F_L= F_baseline - (1*deviation)
plot(F_baseline, color=color.new(color.green,10), linewidth=2)
plot(F_U_1, title="0.236",color=color.new(color.white,10), linewidth=1)
plot(F_U_2, title="0.382",color=color.new(color.white,10), linewidth=1)
plot(F_U_3, title="0.500",color=color.new(color.white,10), linewidth=1)
plot(F_U_4, title="0.618",color=color.new(color.white,10), linewidth=1)
plot(F_U_5, title="0.764",color=color.new(color.white,10), linewidth=1)
plot(F_U, title="1.000",color=color.new(color.red,10), linewidth=2)
plot(F_L_1, title="0.236",color=color.new(color.white,10), linewidth=1)
plot(F_L_2, title="0.382",color=color.new(color.white,10), linewidth=1)
plot(F_L_3, title="0.500",color=color.new(color.white,10), linewidth=1)
plot(F_L_4, title="0.618",color=color.new(color.white,10), linewidth=1)
plot(F_L_5, title="0.764",color=color.new(color.white,10), linewidth=1)
plot(F_L, title="1.000",color=color.new(color.red,10), linewidth=2)
//Volume: volume using MFI for selected period for close and hlc values.
//momentum: momentum using RSI for selected period for close and hlc values.
mfi = ta.mfi(price, 13)
rsi = ta.rsi(price, 13)
//buysignal = close > F_U ? rsi > 70 ? mfi > 80 ? true : na :na :na
sellsignal = close[1] > F_U[1] ? close <F_U_5? rsi > 60 ? mfi > 50 ? high : na :na :na :na
plotshape(sellsignal, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 50), textcolor=color.new(color.white, 0))
buysignal = low[1] < F_L[1] ? close > F_L_5? rsi <50 ? low :na :na: na
plotshape(buysignal, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 50), textcolor=color.new(color.white, 0))
//ma crossovers
//WSMA_CO = ta.crossover(P_WMA, P_SMA)
//WSMA_CU = ta.crossunder(P_WMA, P_SMA)
//plot(rsi, "RSI", color=#7E57C2)
//plot (mfi, "MFI", color=#FF9800)
//plot(P_SMA, "SMA", color=#7E57C2)
//rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
//mfiUpperBand = hline(80, "MFI Upper Band", color=#787B86)
//hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
//rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
//mfiLowerBand = hline(20, "MFI Lower Band", color=#787B86)
//fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 80), title="RSI Background Fill")
//fill(mfiUpperBand, mfiLowerBand, color=color.rgb(10, 50, 100, 70), title="MFI Background Fill")
//plot(close)
|
psk 15min levels | https://www.tradingview.com/script/1Tzw65US-psk-15min-levels/ | psk337 | https://www.tradingview.com/u/psk337/ | 4 | 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/
// ©psk337
//////i copied the code and made it as per mine not my orignal code and rights reseved to admin@ TRADEMASTER EDUTECH
//@version=4
study(title="psk 15min levels ", shorttitle=" psk15minlev ", overlay=true)
up15on = input(true, title="15 Minute Opening Range High")
down15on = input(true, title="15 Minute Opening Range Low")
is_newbar(res) => change(time(res)) != 0
adopt(r, s) => security(syminfo.tickerid, r, s)
//high_range = valuewhen(is_newbar('D'),high,0)
//low_range = valuewhen(is_newbar('D'),low,0)
high_rangeL = valuewhen(is_newbar('D'),high,0)
low_rangeL = valuewhen(is_newbar('D'),low,0)
diff = (high_rangeL-low_rangeL)/2
diff2 = (high_rangeL-low_rangeL)
diffavg = (high_rangeL-low_rangeL)/2
diffval = (high_rangeL-low_rangeL)/2
up15 = plot(up15on ? adopt('15', high_rangeL): na, color = #009900, linewidth=1,style=plot.style_line)
down15 = plot(down15on ? adopt('15', low_rangeL): na, color = #ff0000, linewidth=1,style=plot.style_line)
diffup15 = plot(up15on ? adopt('15', (high_rangeL+diff)): na, color = #009900, linewidth=1,style=plot.style_line)
diffdown15 = plot(down15on ? adopt('15', (low_rangeL-diff)): na, color = #ff0000, linewidth=1,style=plot.style_line)
diff2up15 = plot(up15on ? adopt('15', (high_rangeL+diff2)): na, color = #009900, linewidth=1,style=plot.style_line)
diff2down15 = plot(down15on ? adopt('15', (low_rangeL-diff2)): na, color = #ff0000, linewidth=1,style=plot.style_line)
diffavgdown15 = plot(down15on ? adopt('15', (low_rangeL+diff)): na, color = #ff0000, linewidth=1,style=plot.style_line)
diffvaldown15 = plot(down15on ? adopt('15', (diffval)): na, color = #ff0000, linewidth=1,style=plot.style_line) |
Hotch Session | https://www.tradingview.com/script/I7t6NiJb-Hotch-Session/ | Hotchachachaaa | https://www.tradingview.com/u/Hotchachachaaa/ | 103 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Hotchachachaaa
//@version=5
indicator("Hotch Session",overlay=true,max_bars_back=500)
tz = "UTC"
tsAsia = input.bool( title="Show Asian Session", defval=true, group = "Asian Trade Session")
startHourAsia = input.int( title="Asia Start hour", defval=0, minval=0, maxval=23, group = "Asian Trade Session")
startMinuteAsia = input.int( title="Asia Start minute", defval=0, minval=0, maxval=59, group = "Asian Trade Session")
endHour2Asia = input.int( title="Asia End hour", defval=8, minval=0, maxval=23, group = "Asian Trade Session")
endMinute2Asia = input.int( title="Asia End minute", defval=0, minval=0, maxval=59, group = "Asian Trade Session")
tsEurope = input.bool( title="Show European Session", defval=true, group = "European Trade Session")
startHourEurope = input.int( title="Europen Start hour", defval=8, minval=0, maxval=23, group = "European Trade Session")
startMinuteEurope = input.int( title="Europen Start minute", defval=00, minval=0, maxval=59, group = "European Trade Session")
endHour2Europe = input.int( title="Europen End hour", defval=14, minval=0, maxval=23, group = "European Trade Session")
endMinute2Europe = input.int( title="Europen End minute", defval=0, minval=0, maxval=59, group = "European Trade Session")
tsAmericas = input.bool( title="Show American Session", defval=true, group = "American Trade Session")
startHourAmericas = input.int( title="Americas Start hour", defval=12, minval=0, maxval=23, group = "American Trade Session")
startMinuteAmericas = input.int( title="Americas Start minute", defval=30, minval=0, maxval=59, group = "American Trade Session")
endHour2Americas = input.int( title="Americas End hour", defval=16, minval=0, maxval=23, group = "American Trade Session")
endMinute2Americas = input.int( title="Americas End minute", defval=0, minval=0, maxval=59, group = "American Trade Session")
tsCustom = input.bool( title="Show Custom Session", defval=false, group = "Custom Trade Session")
startHourCustom = input.int( title="Custom Start hour", defval=16, minval=0, maxval=23, group = "Custom Trade Session")
startMinuteCustom = input.int( title="Custom Start minute", defval=00, minval=0, maxval=59, group = "Custom Trade Session")
endHour2Custom = input.int( title="Custom End hour", defval=20, minval=0, maxval=23, group = "Custom Trade Session")
endMinute2Custom = input.int( title="Custom End minute", defval=0, minval=0, maxval=59, group = "Custom Trade Session")
displayCustomBG = input.bool( title="Show Custom Background", defval=false, group = "Custom Trade Session")
showMon = input(title="Monday", defval=true, group = "Trade Session")
showTue = input(title="Tuesday", defval=true, group = "Trade Session")
showWed = input(title="Wednesday", defval=true, group = "Trade Session")
showThu = input(title="Thursday", defval=true, group = "Trade Session")
showFri = input(title="Friday", defval=true, group = "Trade Session")
showSat = input(title="Saturday", defval=false, group = "Trade Session")
showSun = input(title="Sunday", defval=false, group = "Trade Session")
tzYear = year(time, tz)
tzMonth = month(time, tz)
tzDay = dayofmonth(time, tz)
tzDayOfWeek = dayofweek(time, tz)
displayBG = input.bool(title="Display Session as Background Color", defval = true)
displayHiLo = input.bool(title="Display Session High/Low", defval= true)
////////////////asia session
startTime1Asia = timestamp(tz, tzYear, tzMonth, tzDay, startHourAsia, startMinuteAsia)
endTime1Asia = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Asia, endMinute2Asia)
activeAsia = if startTime1Asia <= time and time <= endTime1Asia and tsAsia
if tzDayOfWeek == dayofweek.monday and showMon
true
else if tzDayOfWeek == dayofweek.tuesday and showTue
true
else if tzDayOfWeek == dayofweek.wednesday and showWed
true
else if tzDayOfWeek == dayofweek.thursday and showThu
true
else if tzDayOfWeek == dayofweek.friday and showFri
true
else if tzDayOfWeek == dayofweek.saturday and showSat
true
else if tzDayOfWeek == dayofweek.sunday and showSun
true
else
false
else
false
var float Asiahigh = na
var float Asialow = na
bgColorAsia = color.new(color.red,85)
rangeColorAsia = activeAsia[1] ? color.new(color.red,0): color.new(color.red,100)
AsiaLookback= nz(ta.barssince(ta.change(activeAsia))) + 1
if activeAsia
Asiahigh := nz(ta.highest(high,AsiaLookback))
Asialow := nz(ta.lowest(low,AsiaLookback))
if not activeAsia[1]
Asiahigh := high[1]
Asialow := low[1]
plot(displayHiLo?Asiahigh :na , color= rangeColorAsia, title= "Asia High",linewidth=2)
plot(displayHiLo?Asialow :na, color= rangeColorAsia, title= "Asia Low",linewidth=2)
bgcolor(activeAsia and displayBG ? bgColorAsia : na, title = "Asia Session Background")
////////////////Europe session
startTime1Europe = timestamp(tz, tzYear, tzMonth, tzDay, startHourEurope, startMinuteEurope)
endTime1Europe = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Europe, endMinute2Europe)
activeEurope = if startTime1Europe <= time and time <= endTime1Europe and tsEurope
if tzDayOfWeek == dayofweek.monday and showMon
true
else if tzDayOfWeek == dayofweek.tuesday and showTue
true
else if tzDayOfWeek == dayofweek.wednesday and showWed
true
else if tzDayOfWeek == dayofweek.thursday and showThu
true
else if tzDayOfWeek == dayofweek.friday and showFri
true
else if tzDayOfWeek == dayofweek.saturday and showSat
true
else if tzDayOfWeek == dayofweek.sunday and showSun
true
else
false
else
false
var float Europehigh = na
var float Europelow = na
bgColorEurope = color.new(color.green,85)
rangeColorEurope = activeEurope[1] ? color.new(color.green,0): color.new(color.green,100)
EuropeLookback= nz(ta.barssince(ta.change(activeEurope))) + 1
if activeEurope
Europehigh := nz(ta.highest(high,EuropeLookback))
Europelow := nz(ta.lowest(low,EuropeLookback))
if not activeEurope[1]
Europehigh := high[1]
Europelow := low[1]
plot(displayHiLo?Europehigh:na , color= rangeColorEurope, title= "Europe High",linewidth=2)
plot(displayHiLo?Europelow :na , color= rangeColorEurope, title= "Europe Low",linewidth=2)
bgcolor(activeEurope and displayBG ? bgColorEurope : na, title = "Europe Session Background")
////////////////Americas session
startTime1Americas = timestamp(tz, tzYear, tzMonth, tzDay, startHourAmericas, startMinuteAmericas)
endTime1Americas = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Americas, endMinute2Americas)
activeAmericas = if startTime1Americas <= time and time <= endTime1Americas and tsAmericas
if tzDayOfWeek == dayofweek.monday and showMon
true
else if tzDayOfWeek == dayofweek.tuesday and showTue
true
else if tzDayOfWeek == dayofweek.wednesday and showWed
true
else if tzDayOfWeek == dayofweek.thursday and showThu
true
else if tzDayOfWeek == dayofweek.friday and showFri
true
else if tzDayOfWeek == dayofweek.saturday and showSat
true
else if tzDayOfWeek == dayofweek.sunday and showSun
true
else
false
else
false
var float Americashigh = na
var float Americaslow = na
bgColorAmericas = color.new(color.blue,85)
rangeColorAmericas = activeAmericas[1] ? color.new(color.blue,0): color.new(color.blue,100)
AmericasLookback= nz(ta.barssince(ta.change(activeAmericas))) + 1
if activeAmericas
Americashigh := nz(ta.highest(high,AmericasLookback))
Americaslow := nz(ta.lowest(low,AmericasLookback))
if not activeAmericas[1]
Americashigh := high[1]
Americaslow := low[1]
plot(displayHiLo?Americashigh:na , color= rangeColorAmericas, title= "Americas High",linewidth=2)
plot(displayHiLo?Americaslow:na , color= rangeColorAmericas, title= "Americas Low",linewidth=2)
bgcolor(activeAmericas and displayBG ? bgColorAmericas : na, title = "Americas Session Background")
////////////////Custom session
startTime1Custom = timestamp(tz, tzYear, tzMonth, tzDay, startHourCustom, startMinuteCustom)
endTime1Custom = timestamp(tz, tzYear, tzMonth, tzDay, endHour2Custom, endMinute2Custom)
activeCustom = if startTime1Custom <= time and time <= endTime1Custom and tsCustom
if tzDayOfWeek == dayofweek.monday and showMon
true
else if tzDayOfWeek == dayofweek.tuesday and showTue
true
else if tzDayOfWeek == dayofweek.wednesday and showWed
true
else if tzDayOfWeek == dayofweek.thursday and showThu
true
else if tzDayOfWeek == dayofweek.friday and showFri
true
else if tzDayOfWeek == dayofweek.saturday and showSat
true
else if tzDayOfWeek == dayofweek.sunday and showSun
true
else
false
else
false
var float Customhigh = na
var float Customlow = na
bgColorCustom = color.new(color.yellow,85)
rangeColorCustom = activeCustom[1] ? color.new(color.yellow,0): color.new(color.yellow,100)
CustomLookback= nz(ta.barssince(ta.change(activeCustom))) + 1
if activeCustom
Customhigh := nz(ta.highest(high,CustomLookback))
Customlow :=nz(ta.lowest(low,CustomLookback))
if not activeCustom[1]
Customhigh := high[1]
Customlow := low[1]
plot(displayHiLo?Customhigh:na , color= rangeColorCustom, title= "Custom High",linewidth=2)
plot(displayHiLo?Customlow:na , color= rangeColorCustom, title= "Custom Low",linewidth=2)
bgcolor(activeCustom and displayBG and displayCustomBG ? bgColorCustom : na, title = "Custom Session Background") |
HorseShoe - At Nalı | https://www.tradingview.com/script/XGNndRHA-HorseShoe-At-Nal%C4%B1/ | coinsspor | https://www.tradingview.com/u/coinsspor/ | 196 | 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/
// © coinsspor
//@version=4
study("HorseShoe - At Nalı", overlay =true)
bearish_ATnali_4renk_sarti=close<close[1] and close[1]>close[2] and close[2]<close[3] and close[3]>close[4]
bullish_ATnali_4renk_sarti=close>close[1] and close[1]<close[2] and close[2]>close[3] and close[3]<close[4]
BirDortUzun_IkiUcKisa_sarti= (abs(close-open) > abs(close[1]-open[1]) and abs(close-open) > abs(close[2]-open[2])) and (abs(close[3]-open[3]) > abs(close[1]-open[1]) and abs(close[3]-open[3]) > abs(close[2]-open[2]))
barcolor( bearish_ATnali_4renk_sarti and BirDortUzun_IkiUcKisa_sarti ? color.red : na)
//plotshape( (bearish_ATnali_4renk_sarti and BirDortUzun_IkiUcKisa_sarti), style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
plotchar((bearish_ATnali_4renk_sarti and BirDortUzun_IkiUcKisa_sarti),location=location.abovebar, char='🐴',color=color.red, size=size.tiny)
//plotchar((bearish_ATnali_4renk_sarti and BirDortUzun_IkiUcKisa_sarti),location=location.belowbar, char='Ʊ',color=color.red, size=size.tiny)
barcolor( bullish_ATnali_4renk_sarti and BirDortUzun_IkiUcKisa_sarti ? color.green : na)
//plotchar((bullish_ATnali_4renk_sarti and BirDortUzun_IkiUcKisa_sarti),location=location.abovebar, char='Ʊ',color=color.green, size=size.tiny)
plotchar((bullish_ATnali_4renk_sarti and BirDortUzun_IkiUcKisa_sarti),location=location.belowbar, char='🦄',color=color.green, size=size.tiny) |
Phase Accumulation, Smoothed Williams %R Histogram [Loxx] | https://www.tradingview.com/script/qCgSzDQB-Phase-Accumulation-Smoothed-Williams-R-Histogram-Loxx/ | loxx | https://www.tradingview.com/u/loxx/ | 112 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx
//@version=5
indicator(title="Phase Accumulation, Smoothed Williams %R Histogram [Loxx]", shorttitle="PAWPRSH [Loxx]", overlay=false, max_bars_back = 3000)
import loxx/loxxexpandedsourcetypes/3
greencolor = #2DD204
redcolor = #D2042D
lightgreencolor = #96E881
lightredcolor = #DF4F6C
EMA(x, t) =>
_ema = x
_ema := na(_ema[1]) ? x : (x - nz(_ema[1])) * (2 / (t + 1)) + nz(_ema[1])
_ema
calcComp(src, period)=>
out = (
(0.0962 * src +
0.5769 * src[2] -
0.5769 * src[4] -
0.0962 * src[6]) * (0.075 * src[1] + 0.54))
out
_a_jurik_filt(src, len, phase) =>
//static variales
volty = 0.0, avolty = 0.0, vsum = 0.0, bsmax = src, bsmin = src
len1 = math.max(math.log(math.sqrt(0.5 * (len-1))) / math.log(2.0) + 2.0, 0)
len2 = math.sqrt(0.5 * (len - 1)) * len1
pow1 = math.max(len1 - 2.0, 0.5)
div = 1.0 / (10.0 + 10.0 * (math.min(math.max(len-10, 0), 100)) / 100)
//Price volatility
del1 = src - nz(bsmax[1])
del2 = src - nz(bsmin[1])
volty := math.abs(del1) > math.abs(del2) ? math.abs(del1) : math.abs(del2)
//Relative price volatility factor
vsum := nz(vsum[1]) + div * (volty - nz(volty[10]))
avolty := nz(avolty[1]) + (2.0 / (math.max(4.0 * len, 30) + 1.0)) * (vsum - nz(avolty[1]))
dVolty = avolty > 0 ? volty / avolty : 0
dVolty := math.max(1, math.min(math.pow(len1, 1.0/pow1), dVolty))
//Jurik volatility bands
bet = len2 / (len2 + 1)
pow2 = math.pow(dVolty, pow1)
Kv = math.pow(bet, math.sqrt(pow2))
bsmax := del1 > 0 ? src : src - Kv * del1
bsmin := del2 < 0 ? src : src - Kv * del2
//Jurik Dynamic Factor
phaseRatio = math.max(math.min(phase, 100), -100) / 100.0 + 1.5
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
alpha = math.pow(beta, pow2)
//1st stage - prelimimary smoothing by adaptive EMA
jma = 0.0, ma1 = 0.0, det0 = 0.0, e2 = 0.0
ma1 := (1 - alpha) * src + alpha * nz(ma1[1])
//2nd stage - one more prelimimary smoothing by Kalman filter
det0 := (src - ma1) * (1 - beta) + beta * nz(det0[1])
ma2 = ma1 + phaseRatio * det0
//3rd stage - final smoothing by unique Jurik adaptive filter
e2 := (ma2 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
jma
_pr(src, len) =>
max = ta.highest(high, len)
min = ta.lowest(low, len)
temp = 50 + (-100) * (max - src) / (max - min)
temp
_prout(src, mult, filt)=>
Smooth = 0.00
Detrender = 0.00
I1 = 0.00
Q1 = 0.00
Period = 0.00
DeltaPhase = 0.00
InstPeriod = 0.00
PhaseSum = 0.00
Phase = 0.
_period = 0.
Smooth := bar_index > 5 ? (4 * src + 3 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 10 : Smooth
ts = calcComp(Smooth, Period)
Detrender := bar_index > 5 ? ts : Detrender
qs = calcComp(Detrender, Period)
Q1 := bar_index > 5 ? qs : Q1
I1 := bar_index > 5 ? nz(Detrender[3]) : I1
I1 := .15 * I1 + .85 * nz(I1[1])
Q1 := .15 * Q1 + .85 * nz(Q1[1])
Phase := nz(Phase[1])
Phase := math.abs(I1) > 0 ? 180.0 / math.pi * math.atan(math.abs(Q1 / I1)) : Phase
Phase := I1 < 0 and Q1 > 0 ? 180 - Phase : Phase
Phase := I1 < 0 and Q1 < 0 ? 180 + Phase : Phase
Phase := I1 > 0 and Q1 < 0 ? 360 - Phase : Phase
DeltaPhase := nz(Phase[1]) - Phase
DeltaPhase := nz(Phase[1]) < 90 and Phase > 270 ? 360 + nz(Phase[1]) - Phase : DeltaPhase
DeltaPhase := math.max(math.min(DeltaPhase, 60), 7)
InstPeriod := nz(InstPeriod[1])
PhaseSum := 0
count = 0
while (PhaseSum < mult * 360 and count < 4500)
PhaseSum += nz(DeltaPhase[count])
count := count + 1
InstPeriod := count > 0 ? count : InstPeriod
alpha = 2.0 / (1.0 + math.max(filt, 1))
_period := nz(_period[1]) + alpha * (InstPeriod - nz(_period[1]))
_period := math.floor(_period) < 1 ? 1 : math.floor(_period)
math.floor(_period)
smthtype = input.string("AMA", "Heiken-Ashi 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)"])
smlen = input.int(35, title = "Smoothing Period", group= "Basic Settings")
regcycles = input.float(5, title = "WR% Cycles", group= "Basic Settings")
macycles = input.float(0.25, title = "Signal Cyles", group= "Basic Settings")
regfilter = input.float(1, title = "WR% filter", group= "Basic Settings")
mafilter = input.float(1, title = "Signal filter", group= "Basic Settings")
kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")
colorbars = input.bool(false, "Color bars?", group = "UI Options")
showSigs = input.bool(false, "Show signals?", group= "UI Options")
haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)
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
int fout = math.floor(_prout(src, regcycles, regfilter))
int sout = math.floor(_prout(src, macycles, mafilter))
pr = _pr(close, fout)
pr1 = _a_jurik_filt(pr, smlen, 0)
sig = EMA(pr1, sout)
colorout =
pr1 > sig and pr1 >= 0 ? greencolor :
pr1 < sig and pr1 >= 0 ? lightgreencolor :
pr1 < sig and pr1 < 0 ? redcolor :
lightredcolor
plot(pr1, color = colorout , style = plot.style_histogram)
plot(sig, color = color.white)
barcolor(colorbars ? colorout : na)
goLong = ta.crossover(pr1, 0)
goShort = ta.crossunder(pr1, 0)
plotshape(showSigs and goLong, title = "Long", color = greencolor, textcolor = greencolor, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto)
plotshape(showSigs and goShort, title = "Short", color = redcolor, textcolor = redcolor, text = "S", style = shape.triangledown, location = location.top, size = size.auto)
alertcondition(goLong, title = "Long", message = "Phase Accumulation, Smoothed Williams %R Histogram [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}")
alertcondition(goShort, title = "Short", message = "Phase Accumulation, Smoothed Williams %R Histogram [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.