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
Speculative Growth Map (FOR BITCOIN)
https://www.tradingview.com/script/5KsBokAs-Speculative-Growth-Map-FOR-BITCOIN/
xxMubeen
https://www.tradingview.com/u/xxMubeen/
17
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © xxMubeen //@version=5 indicator("Speculative Growth Map", overlay=true) t = input.int(3, minval=0, title="Deviations") s = input.int(12, minval=0, title="Length") d = input.int(2, minval= 0, title="Smoothing") l1 = ta.ema(close[t]*1.01, s) l2 = ta.ema(close[t]*1.05, s) l3 = ta.ema(close[t]*1.075, s) l4 = ta.ema(close[t]*1.10, s) s1 = ta.ema(close[t]*0.99, s) s2 = ta.ema(close[t]*0.95, s) s3 = ta.ema(close[t]*0.925, s) s4 = ta.ema(close[t]*0.90, s) var a = s4 if low < s4 a := low[d] var b = l4 if high > l4 b := high[d] ab = (a+b)*0.40 ba = (a+b)*0.80 plot (l1, color=color.red) plot (l2, color=color.red) plot (l3, color=color.red) plot (l4, color=color.red) plot (s1, color=color.green) plot (s2, color=color.green) plot (s3, color=color.green) plot (s4, color=color.green) plot (ab, color=color.yellow) plot (ba, color=color.yellow)
tickerTracker MFI Oscillator
https://www.tradingview.com/script/Gef440sE-tickerTracker-MFI-Oscillator/
Options360
https://www.tradingview.com/u/Options360/
34
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Options360 // original release: 1/12/2021, update +2=11x tickers total & add a trackprice line: 12/26/2022, update 3/2/2023 MFI or RSI option // @version=5 indicator("tickerTracker") num = input.int(13, "Length") src = input(ohlc4, 'source') mfirsi = input(true, title="MFI or RSI", tooltip="MFI checked or RSI unchecked") expr = mfirsi ? ta.mfi(src, num) : ta.rsi(src, num) plot(expr, color=color.white) plot(expr, color=color.new(color.white, 0), title='track', trackprice=true, offset=-9999, display=display.none) spy = input.symbol("SPY", "Symbol") _spy = request.security(spy, timeframe.period, expr) plot(_spy, title='SPY', color=color.white) qqq = input.symbol("QQQ", "Symbol") _qqq = request.security(qqq, timeframe.period, expr) plot(_qqq, title='QQQ', color=#008eff) iwm = input.symbol("IWM", "Symbol") _iwm = request.security(iwm, timeframe.period, expr) plot(_iwm, title='IWM', color=#eaff00) dia = input.symbol("DIA", "Symbol") _dia = request.security(dia, timeframe.period, expr) plot(_dia, title='DIA', color=#ff7700) vti = input.symbol("VTI", "Symbol") _vti = request.security(vti, timeframe.period, expr) plot(_vti, title='VTI', color=#ffffff) btcusd = input.symbol("BTC", "Symbol") btc = request.security(btcusd, timeframe.period, expr) plot(btc, title='BTC', color=#eaff00) ethusd = input.symbol("ETH", "Symbol") eth = request.security(ethusd, timeframe.period, expr) plot(eth, title='ETH', color=#2dff00) ltcusd = input.symbol("LTC", "Symbol") ltc = request.security(ltcusd, timeframe.period, expr) plot(ltc, title='LTC', color=#da00ff) adausd = input.symbol("ADA", "Symbol") ada = request.security(adausd, timeframe.period, expr) plot(ada, title='ADA', color=#ff0202) dogeusd = input.symbol("DOGE", "Symbol") doge = request.security(dogeusd, timeframe.period, expr) plot(doge, title='DOGE', color=#ffffff) h1 = hline(100, "top", color=#989595, linestyle=hline.style_dotted) h2 = hline(75, "75", color=#989595, linestyle=hline.style_dotted) h3 = hline(50, "mid", color=#989595, linestyle=hline.style_dotted) h4 = hline(25, "25", color=#989595, linestyle=hline.style_dotted) h5 = hline(0, "bot", color=#989595, linestyle=hline.style_dotted)
Basic Shannon Entropy & Derivatives
https://www.tradingview.com/script/aEunvjUW-Basic-Shannon-Entropy-Derivatives/
mtbdork
https://www.tradingview.com/u/mtbdork/
37
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mtbdork //@version=5 indicator("Shannon Entropy", precision=6) Source = close RANGE = input.int(defval = 30, title = "Tail Length", minval = 2, maxval = 365*4, step=5) Entropy = input.bool(title="Shannon Entropy", defval=true) EntropyR = input.bool(title="Shannon Entropy RMSt", defval=true) EntropyRate = input.bool(title="Shannon Entropy Rate of Change", defval=false) EntropyRateR = input.bool(title="Shannon Entropy Rate of Change RMSt", defval=false) EntropyConc = input.bool(title="Shannon Entropy Concavity (second derivative)", defval=false) EntropyConcR = input.bool(title="Shannon Entropy Concavity (second derivative) RMSt", defval=false) ddt(a) => (a - a[1]) d2dt2(a) => (a - 2*a[1] + a[2] )/4 RMSt(a) => n = 1 v = a*a float R = 0 for i = 1 to RANGE v := v + a[i] * a[i] n := n + 1 R := math.sqrt(v/n) P = Source/RANGE S = ta.cum(P*math.log(P)) plot( Entropy ? S : na ,color=color.red) plot( EntropyR ? RMSt(S) : na ,color=color.orange) plot( EntropyRate ? ddt(S) : na ,color=color.white) plot( EntropyRateR ? RMSt(ddt(S)) : na ,color=color.aqua) plot( EntropyConc ? d2dt2(S) : na ,color=color.blue) plot( EntropyConcR ? RMSt(d2dt2(S)) : na ,color=color.green) //Enjoy!
Volume Adaptive Chikou Scalping Study
https://www.tradingview.com/script/nYutTJPT-Volume-Adaptive-Chikou-Scalping-Study/
MightyZinger
https://www.tradingview.com/u/MightyZinger/
376
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/ // © MightyZinger //@version=4 study(shorttitle="MZ Adaptive Scalping",title="Volume Adaptive Chikou Scalping Study", overlay=true) timeFrameticker = input("",type=input.resolution, title="Timeframe") uha =input(true, title="Use Heikin Ashi Candles for Volume") uha2 =input(false, title="Use Heikin Ashi Candles for Chikou Calculations") // Use only Heikinashi Candles for all calculations haclose = uha ? security(heikinashi(syminfo.tickerid), timeFrameticker, close) : security(syminfo.tickerid, timeFrameticker, close) haopen = uha ? security(heikinashi(syminfo.tickerid), timeFrameticker, open) : security(syminfo.tickerid, timeFrameticker, open) hahigh = security(syminfo.tickerid, timeFrameticker, high) halow = security(syminfo.tickerid, timeFrameticker, low) src = security(heikinashi(syminfo.tickerid), timeFrameticker, close) vol = security(syminfo.tickerid, timeFrameticker, volume) // INPUT RESOLUTION highMAresolution = input("",type=input.resolution, title="High MA Resolution") lowMAresolution = input("",type=input.resolution, title="Low MA Resolution") haMAhigh = security(syminfo.tickerid, highMAresolution, high) haMAhigh_close = uha2 ? security(heikinashi(syminfo.tickerid), highMAresolution, close) : security(syminfo.tickerid, highMAresolution, close) haMAlow = security(syminfo.tickerid, lowMAresolution, low) haMAlow_close = uha2 ?security(heikinashi(syminfo.tickerid), lowMAresolution, close) : security(syminfo.tickerid, lowMAresolution, close) // INPUT LENGTHS highminLength = input(20, minval=1, title="High MA Min Length", inline="h_len") highmaxLength = input(50, minval=1, title="High MA Max Length", inline="h_len") lowminLength = input(20, minval=1, title="Low MA Min Length", inline="l_len") lowmaxLength = input(50, minval=1, title="Low MA Max Length", inline="l_len") // Adaptive Length Checks grp1 = "Adapt Dynamic Length Based on (Max Length if both left unchecked)" grp2 = "Signals Confirmations Based on" ch1 = "Volume" ch2 = "Volatility" adaptPerc = input(3.141, minval = 0, maxval = 100, title="Adapting Percentage:", group = grp1) / 100.0 volume_chk = input(true, title= ch1, group= grp1, inline="len_chks") volat_chk = input(true, title= ch2, group= grp1, inline="len_chks") t_volume_chk = input(true, title= ch1, group= grp2, inline="trd_chks") t_volat_chk = input(false, title= ch2, group= grp2, inline="trd_chks") ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Volume and other Inputs // Volume Oscillator Types Input osc1 = "TFS Volume Oscillator" osc2 = "On Balance Volume" osc3 = "Klinger Volume Oscillator" osc4 = "Cumulative Volume Oscillator" osc5 = "Volume Zone Oscillator" osctype = input(title="Volume Oscillator Type", type=input.string, group="MZ RVSI Indicator Parameters", defval = osc1, options=[osc1, osc2, osc3, osc4, osc5]) volLen = input(30, minval=1,title="Volume Length", group="MZ RVSI Indicator Parameters") rvsiLen = input(14, minval=1,title="RVSI Period", group="MZ RVSI Indicator Parameters") vBrk = input(50, minval=1,title="RVSI Break point", group="MZ RVSI Indicator Parameters") atrFlength = input(14, title="ATR Fast Length", group="Volatility Dynamic Optimization Parameters") atrSlength = input(46, title="ATR Slow Length", group="Volatility Dynamic Optimization Parameters") ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Dynamic Length Function ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// dyn_Len(volume_chk, volat_chk, volume_Break, high_Volatility, adapt_Pct, minLength, maxLength) => var float result = avg(minLength,maxLength) para = (volume_chk == true and volat_chk == false) ? volume_Break : (volume_chk == false and volat_chk == true) ? high_Volatility : (volume_chk == true and volat_chk == true) ? volume_Break and high_Volatility : na result := iff(para, max(minLength, result * (1 - adapt_Pct)), min(maxLength, result * (1 + adapt_Pct))) result // Up/Down parameter function to mark market dynamics _uppara(volume_chk, volat_chk, vol_Brk_up, high_Volatility) => bool up_para = 0.0 if volume_chk == true and volat_chk == false up_para := vol_Brk_up if volume_chk == false and volat_chk == true up_para := high_Volatility if volume_chk == true and volat_chk == true up_para := high_Volatility and vol_Brk_up if volume_chk == false and volat_chk == false up_para := na up_para _dnpara(volume_chk, volat_chk, vol_Brk_dn, high_Volatility) => bool dn_para = 0.0 if volume_chk == true and volat_chk == false dn_para := vol_Brk_dn if volume_chk == false and volat_chk == true dn_para := high_Volatility if volume_chk == true and volat_chk == true dn_para := high_Volatility and vol_Brk_dn if volume_chk == false and volat_chk == false dn_para := na dn_para ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Volume Oscillator Functions ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Volume Zone Oscillator zone(_src, _type, _len) => vp = _src > _src[1] ? _type : _src < _src[1] ? -_type : _src == _src[1] ? 0 : 0 z = 100 * (ema(vp, _len) / ema(_type, _len)) vzo(vol_src, _close) => float result = 0 zLen = input(21, "VZO Length", minval=1, group="Volume Zone Oscillator Parameters") result := zone(_close, vol_src, zLen) result // Cumulative Volume Oscillator _rate(cond, tw, bw, body) => ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) ret := nz(ret) == 0 ? 0.5 : ret ret cvo(vol_src, _open, _high, _low, _close) => float result = 0 ema1len = input(defval = 8, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters") ema2len = input(defval = 21, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters") obvl = "On Balance Volume" cvdo = "Cumulative Volume Delta" pvlt = "Price Volume Trend" cvtype = input(defval = pvlt, options = [obvl, cvdo, pvlt], group="Cumulative Volume Oscillator Parameters") tw = _high - max(_open, _close) bw = min(_open, _close) - _low body = abs(_close - _open) deltaup = vol_src * _rate(_open <= _close , tw, bw, body) deltadown = vol_src * _rate(_open > _close , tw, bw, body) delta = _close >= _open ? deltaup : -deltadown cumdelta = cum(delta) float ctl = na ctl := cumdelta cv = cvtype == obvl ? obv : cvtype == cvdo ? ctl : pvt ema1 = ema(cv,ema1len) ema2 = ema(cv,ema2len) result := ema1 - ema2 result // Volume Oscillator function vol_osc(type, vol_src, vol_Len, _open, _high, _low, _close) => float result = 0 if type=="TFS Volume Oscillator" nVolAccum = sum(iff(_close > _open, vol_src, iff(_close < _open, -vol_src, 0)) ,vol_Len) result := nVolAccum / vol_Len if type=="On Balance Volume" result := cum(sign(change(_close)) * vol_src) if type=="Klinger Volume Oscillator" FastX = input(34, minval=1,title="Volume Fast Length", group="KVO Parameters") SlowX = input(55, minval=1,title="Volume Slow Length", group="KVO Parameters") xTrend = iff(_close > _close[1], vol * 100, -vol * 100) xFast = ema(xTrend, FastX) xSlow = ema(xTrend, SlowX) result := xFast - xSlow if type=="Cumulative Volume Oscillator" result := cvo(vol_src, _open, _high, _low, _close) if type=="Volume Zone Oscillator" result := vzo(vol_src, _close) result ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // MA of Volume Oscillator Source volMA = sma(vol_osc(osctype,vol,volLen,haopen,hahigh,halow,haclose) , rvsiLen) // HMA can also be used just like used in RVSI's original Indicator // RSI of Volume Oscillator Data rsivol = rsi(volMA, rvsiLen) rvsi = hma(rsivol, rvsiLen) // Volume Breakout Condition volBrkUp = rvsi > vBrk // and rvsiSlp >= flat volBrkDn = rvsi < vBrk //or rvsiSlp <= -flat // //Volatility Meter highVolatility = atr(atrFlength) > atr(atrSlength) ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// high_dyna = dyn_Len(volume_chk, volat_chk, volBrkUp, highVolatility, adaptPerc, highminLength, highmaxLength) low_dyna = dyn_Len(volume_chk, volat_chk, volBrkUp, highVolatility, adaptPerc, lowminLength, lowmaxLength) plotchar(high_dyna, "Slow MA Dynamic Length", "", location.top, color.green) plotchar(low_dyna, "Fast MA Dynamic Length", "", location.top, color.yellow) // Linear Regression highma = linreg(haMAhigh , int(high_dyna), 0) lowma = linreg(haMAlow , int(low_dyna), 0) swing = iff(haMAhigh_close > highma[int(high_dyna)], 1, iff(haMAlow_close < lowma[int(low_dyna)], -1, 0)) _high = highest(haMAhigh, int(high_dyna)) _low = lowest(haMAlow, int(low_dyna)) var float stop = 0.0 stop := iff(swing==1, _low, iff(swing==-1, _high, stop[1])) ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Signals up_para = _uppara(t_volume_chk, t_volat_chk, volBrkUp, highVolatility) dn_para = _dnpara(t_volume_chk, t_volat_chk, volBrkDn, highVolatility) _up = src > stop and up_para _dn = src < stop and dn_para buy = _up and not _up[1] sell = _dn and not _dn[1] var sig = 0 if buy and sig <= 0 sig := 1 if sell and sig >= 0 sig := -1 longsignal = sig == 1 and (sig != 1)[1] shortsignal = sig == -1 and (sig != -1)[1] linecolor = iff(stop < haMAlow, color.green, color.red) stop_plot = plot(stop, linewidth=4, color=linecolor, transp = 80) //plot(highma, title='High MA', color=color.olive, linewidth=2) //plot(lowma, title='Low MA', color=color.teal, linewidth=2) plotshape(longsignal, style = shape.triangleup, color = color.green, location = location.belowbar, text = "Long", size = size.small) plotshape(shortsignal, style = shape.triangledown, color = color.red, location = location.abovebar, text = "Short", size = size.small) // Envelop Parameters showEnv = input(true, title="Show Envelope", group="ENVELOPE DISTANCE ZONE") atr_mult = input(10, title="Distance (Envelope) Multiplier", step=.1, group="ENVELOPE DISTANCE ZONE") env_atr = input(40, title="Envelope ATR Length", group="ENVELOPE DISTANCE ZONE") env_MA = stop dev = atr_mult * atr(env_atr) // Bands m1 = input(0.236, minval=0, step=0.01, title="Fib 1", group= "Fibonacci Parameters", inline = "fibs1") m2 = input(0.382, minval=0, step=0.01, title="Fib 2", group= "Fibonacci Parameters", inline = "fibs1") m3 = input(0.5, minval=0, step=0.01, title="Fib 3", group= "Fibonacci Parameters", inline = "fibs1") m4 = input(0.618, minval=0, step=0.01, title="Fib 4", group= "Fibonacci Parameters", inline = "fibs1") m5 = input(0.764, minval=0, step=0.01, title="Fib 5", group= "Fibonacci Parameters", inline = "fibs1") m6 = input(1, minval=0, step=0.01, title="Fib 6", group= "Fibonacci Parameters", inline = "fibs1") m7 = input(1.618, minval=0, step=0.01, title="Fib 7", group= "Fibonacci Parameters", inline = "fibs1") m8 = input(2.618, minval=0, step=0.01, title="Fib 8", group= "Fibonacci Parameters", inline = "fibs1") upper_1= iff(src > stop, env_MA + (m1*dev), env_MA - (m1*dev)) upper_2= iff(src > stop, env_MA + (m2*dev), env_MA - (m2*dev)) upper_3= iff(src > stop, env_MA + (m3*dev), env_MA - (m3*dev)) upper_4= iff(src > stop, env_MA + (m4*dev), env_MA - (m4*dev)) upper_5= iff(src > stop, env_MA + (m5*dev), env_MA - (m5*dev)) upper_6= iff(src > stop, env_MA + (m6*dev), env_MA - (m6*dev)) // Plotting Envelope Distance Zone p1 = plot(showEnv ? upper_1 : na, color=color.new(color.red, 50), linewidth=1, title="0.236") p2 = plot(showEnv ? upper_2 : na, color=color.new(color.red, 50), linewidth=1, title="0.382") p3 = plot(showEnv ? upper_3 : na, color=color.new(color.aqua, 50), linewidth=3, title="0.5") p4 = plot(showEnv ? upper_4 : na, color=color.new(color.blue, 50), linewidth=1, title="0.618") p5 = plot(showEnv ? upper_5 : na, color=color.new(color.blue, 50), linewidth=1, title="0.764") p6 = plot(showEnv ? upper_6 : na, color=color.new(color.blue, 50), linewidth=2, title="1") fill(p1, stop_plot, color=color.red, transp=95) fill(p5, p6, color=color.green, transp=95) // For Strategy Entries //if (longsignal) // strategy.entry("BUY", strategy.long, when = window()) //if (shortsignal) // strategy.entry("SELL", strategy.short, when = window())
Percentage Range Indicator
https://www.tradingview.com/script/jJgsfyMA-Percentage-Range-Indicator/
rex_wolfe
https://www.tradingview.com/u/rex_wolfe/
82
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rex_wolfe // Percentage Range Indicator - Ford // Version 1.2 //@version=5 indicator("Percentage Range Indicator - Ford", shorttitle = "PRI Ford") // Get user input length = input.int(title = "Length", defval = 168, step = 1, minval = 1, tooltip = "Number of periods to apply smoothing.") smoothing = input.string(title = "Smoothing", defval = "SMA", options=["SMA", "EMA", "WMA"], tooltip = "SMA - simple moving average, EMA - exponential moving average, WMA - weighted moving average.") // Declare variables var rp = float(0) var arp = float(0) // Calculate range percent rp := (high - low) / hl2 * 100 // Calculate smoothed range percent if smoothing == "SMA" arp := ta.sma(rp, length) else if smoothing == "EMA" arp := ta.ema(rp, length) else if smoothing == "WMA" arp := ta.wma(rp, length) // Plot indicator plot (rp, title = "Range percent", color = color.new(color.silver, 60), style = plot.style_histogram) plot(arp, title = "Smoothed average range percent", color = color.new(color.blue, 0), style = plot.style_line) // Roger, Candy, Elwood, Blacky, Bill. Not yet, Captain Chaos, not yet.
EMA deviations
https://www.tradingview.com/script/BgUzJdLc-EMA-deviations/
mnln
https://www.tradingview.com/u/mnln/
16
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/ // © mnln //@version=4 study("EMA deviations", overlay=true) length = input(title="ema length", type=input.integer, defval=9) ema = ema(close, length) emaplus1 = ema * 1.01 emaplushalf = ema * 1.005 emaminus1 = ema * 0.99 emaminushalf = ema * 0.995 plot(ema, color=color.aqua) plot(emaplus1, color=color.red) plot(emaplushalf, color=color.gray) plot(emaminus1, color=color.green) plot(emaminushalf, color=color.gray)
Peter Lynch Value
https://www.tradingview.com/script/Y5bvwFfr-Peter-Lynch-Value/
trustingHope39780
https://www.tradingview.com/u/trustingHope39780/
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/ // © AntoineLeo //@version=4 study("Peter Lynch Value", overlay=true) EPS = financial(syminfo.tickerid, "EARNINGS_PER_SHARE", "TTM") PERatio=input(30, title="P/E Ratio", step=1) fairprice= EPS > 0 ? PERatio*EPS : na plot(fairprice, color=color.green) //FairPriceEstimate earningestimate = financial(syminfo.tickerid, "EARNINGS_ESTIMATE", "FY") fairpriceestimate= earningestimate > 0 ? PERatio*earningestimate : na plot(fairpriceestimate)
Time Session Filter - Visual Only - @Davi117
https://www.tradingview.com/script/M35XkQ4D-Time-Session-Filter-Visual-Only-Davi117/
DaviG
https://www.tradingview.com/u/DaviG/
111
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © DaviG //@version=5 indicator("Time Filter", overlay=true) transparency = input.int(title="Time Filter background transparency", defval=80) gmtSelect = input.string(title="Select Local Time Zone", defval="GMT+2", options=["GMT-7", "GMT-6", "GMT-5", "GMT-4", "GMT-3", "GMT-2", "GMT-1", "GMT", "GMT+1", "GMT+2", "GMT+3","GMT+4","GMT+5","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12","GMT+13"], confirm=true) // === INPUT TIME RANGE === betweenTime = input.session('0600-1700', title = "Time Filter") // '0000-0000' is anytime to enter isTime(_position) => // create function "within window of time" isTime = na(time(timeframe.period, _position + ':1234567', gmtSelect)) // current time is "within window of time" bgcolor(color = isTime(betweenTime) ? color.new(color.red,transparency) : color.new(color.green,transparency)) //
Key Levels (Time Frames - Weekly,Monthly,Quarterly,Yearly)
https://www.tradingview.com/script/GDBKh0a1-Key-Levels-Time-Frames-Weekly-Monthly-Quarterly-Yearly/
gunebakan
https://www.tradingview.com/u/gunebakan/
774
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/ // © gunebakan //@version=4 study("Key Levels (Time Frames - Weekly,Monthly,Quarterly,Yearly)", shorttitle = "Key Levels (Time Frames-W,M,Q,Y)", overlay = true) distanceright = input(defval = 20, title = "Distance", type = input.integer) labelsize = input(defval="Medium",title="Text Size", options=["Small", "Medium", "Large"]) linesize = input(defval="Small",title="Line Width", options=["Small", "Medium", "Large"]) var show_tails = input(defval = false, title = "Always Show", type = input.bool) var check_4h = 0 var check_4h_high = 1 var check_4h_low = 2 var check_4h_mid = 3 var check_daily = 10 var check_previous_daily = 11 var check_previous_daily_high = 12 var check_previous_daily_low = 13 var check_previous_daily_mid = 14 var check_weekly = 20 var check_weekly_low = 21 var check_weekly_high = 22 var check_previous_weekly = 23 var check_monthly = 30 var check_monthly_high = 31 var check_monthly_low = 32 var check_monthly_mid = 33 var check_previous_monthly = 34 var check_quarterly = 40 var check_quarterly_high = 41 var check_quarterly_low = 42 var check_quarterly_mid = 43 var check_previous_quarterly = 44 var check_yearly = 50 var check_yearly_high = 51 var check_yearly_low = 52 var check_yearly_mid = 53 var check_previous_yearly = 54 var check_monday_high = 61 var check_monday_low = 62 var check_monday_mid = 63 [daily_time, daily_open] = security(syminfo.tickerid, 'D', [time, open], lookahead = barmerge.lookahead_on) [dailypo_time, dailyp_open] = security(syminfo.tickerid, 'D', [time[1], open[1]], lookahead = barmerge.lookahead_on) [dailyph_time, dailyp_high] = security(syminfo.tickerid, 'D', [time[1], high[1]], lookahead = barmerge.lookahead_on) [dailypl_time, dailyp_low] = security(syminfo.tickerid, 'D', [time[1], low[1]], lookahead = barmerge.lookahead_on) dailyp_mid = (dailyp_low + dailyp_high ) / 2 cdailyp_high = security(syminfo.tickerid, 'D',high, lookahead = barmerge.lookahead_on) cdailyp_low = security(syminfo.tickerid, 'D',low, lookahead = barmerge.lookahead_on) var monday_time = time var monday_high = high var monday_low = low var monday_mid = (monday_high + monday_low ) / 2 [weekly_time, weekly_open] = security(syminfo.tickerid, 'W', [time, open], lookahead = barmerge.lookahead_on) [weeklypo_time, weeklyp_open] = security(syminfo.tickerid, 'W', [time[1], open[1]], lookahead = barmerge.lookahead_on) [weeklyph_time, weeklyp_high] = security(syminfo.tickerid, 'W', [time[1], high[1]], lookahead = barmerge.lookahead_on) [weeklypl_time, weeklyp_low] = security(syminfo.tickerid, 'W', [time[1], low[1]], lookahead = barmerge.lookahead_on) weekly_mid_open = (weeklyp_high + weeklyp_low ) / 2 [monthly_time, monthly_open] = security(syminfo.tickerid, 'M', [time, open], lookahead = barmerge.lookahead_on) [monthlypo_time, monthlyp_open] = security(syminfo.tickerid, 'M', [time[1], open[1]], lookahead = barmerge.lookahead_on) [monthlyph_time, monthlyp_high] = security(syminfo.tickerid, 'M', [time[1], high[1]], lookahead = barmerge.lookahead_on) [monthlypl_time, monthlyp_low] = security(syminfo.tickerid, 'M', [time[1], low[1]], lookahead = barmerge.lookahead_on) monthly_mid_open = (monthlyp_high + monthlyp_low ) / 2 [quarterly_time, quarterly_open] = security(syminfo.tickerid, '3M', [time, open], lookahead = barmerge.lookahead_on) [quarterlypo_time, quarterlyp_open] = security(syminfo.tickerid, '3M', [time[1], open[1]], lookahead = barmerge.lookahead_on) [quarterlyph_time, quarterlyp_high] = security(syminfo.tickerid, '3M', [time[1], high[1]], lookahead = barmerge.lookahead_on) [quarterlypl_time, quarterlyp_low] = security(syminfo.tickerid, '3M', [time[1], low[1]], lookahead = barmerge.lookahead_on) quarterly_mid = (quarterlyp_high + quarterlyp_low ) / 2 [yearly_time, yearly_open] = security(syminfo.tickerid, '12M', [time, open], lookahead = barmerge.lookahead_on) [yearlypo_time, yearlyp_open] = security(syminfo.tickerid, '12M', [time[1], open[1]], lookahead = barmerge.lookahead_on) [yearlyph_time, yearlyp_high] = security(syminfo.tickerid, '12M', [time, high], lookahead = barmerge.lookahead_on) [yearlypl_time, yearlyp_low] = security(syminfo.tickerid, '12M', [time, low], lookahead = barmerge.lookahead_on) yearly_mid = (yearlyp_high + yearlyp_low ) / 2 [intra_time, intra_open] = security(syminfo.tickerid, '240', [time, open], lookahead = barmerge.lookahead_on) [intraph_time, intrap_high] = security(syminfo.tickerid, '240', [time[1], high[1]], lookahead = barmerge.lookahead_on) [intrapl_time, intrap_low] = security(syminfo.tickerid, '240', [time[1], low[1]], lookahead = barmerge.lookahead_on) //------------------------------ Inputs ------------------------------- var is_daily_enabled = input(defval = true, title = "Daily Open", type = input.bool, group = "Daily",inline = "Daily") var is_previous_daily_open_enabled = input(defval = false, title = "Previous Daily Open", type = input.bool, group = "Daily",inline = "Daily") var is_dailyrange_enabled = input(defval = false, title = "Previous H/L", type = input.bool, group = "Daily", inline = "Daily") var is_dailym_enabled = input(defval = false, title = "Previous Mid", type = input.bool, group = "Daily", inline = "Daily") var is_monday_enabled = input(defval = true, title = "Monday Range", type = input.bool, group = "Monday Range", inline = "Monday") var is_monday_mid = input(defval = true, title = "Monday Mid", type = input.bool, group = "Monday Range", inline = "Monday") var untested_monday = false var is_weekly_enabled = input(defval = true, title = "Weekly Open", type = input.bool, group = "Weekly", inline = "Weekly") var is_previous_weekly_open_enabled = input(defval = true, title = "Previous Weekly Open", type = input.bool, group = "Weekly", inline = "Weekly") var is_weeklyrange_enabled = input(defval = true, title = "Previous H/L", type = input.bool, group = "Weekly", inline = "Weekly") var is_previous_weekly_mid_enabled = input(defval = true, title = "Previous Mid", type = input.bool, group = "Weekly", inline = "Weekly") var is_monthly_enabled = input(defval = true, title = "Monthly Open", type = input.bool, group = "Monthly", inline = "Monthly") var is_previous_monthly_open_enabled = input(defval = true, title = "Previous Monthly Open", type = input.bool, group = "Monthly", inline = "Monthly") var is_monthlyrange_enabled = input(defval = true, title = "Previous H/L", type = input.bool, group = "Monthly", inline = "Monthly") var is_previous_monthly_mid_enabled = input(defval = true, title = "Previous Mid", type = input.bool, group = "Monthly", inline = "Monthly") var is_quarterly_enabled = input(defval = true, title = "Quarterly Open", type = input.bool, group = "Quarterly", inline = "Quarterly") var is_previous_quarterly_open_enabled = input(defval = false, title = "Previous Quarterly Open", type = input.bool, group = "Quarterly", inline = "Quarterly") var is_quarterlyrange_enabled = input(defval = false, title = "Previous H/L", type = input.bool, group = "Quarterly", inline = "Quarterly") var is_previous_quarterly_mid_enabled = input(defval = false, title = "Previous Mid", type = input.bool, group = "Quarterly", inline = "Quarterly") var is_yearly_enabled = input(defval = true, title = "Yearly Open", type = input.bool, group = "Yearly", inline = "Yearly") var is_previous_yearly_enabled = input(defval = false, title = "Previous Yearly Open", type = input.bool, group = "Yearly", inline = "Yearly") var is_yearlyrange_enabled = input(defval = false, title = "Current H/L", type = input.bool, group = "Yearly", inline = "Yearly") var is_yearly_mid_enabled = input(defval = false, title = "Current Mid", type = input.bool, group = "Yearly", inline = "Yearly") var is_intra_enabled = input(defval = false, title = "4H Open", type = input.bool, group = "4H", inline = "4H") var is_intrarange_enabled = input(defval = false, title = "Previous H/L", type = input.bool, group = "4H", inline = "4H") var is_intram_enabled = input(defval = false, title = "Previous Mid", type = input.bool, group = "4H", inline = "4H") DailyColor = input(title="Daily Color", type = input.color, defval = #08bcd4, group = "Daily") MondayColor = input(title="Monday Color", type = input.color, defval = color.white, group = "Monday Range") WeeklyColor = input(title="Weekly Color", type = input.color, defval = color.yellow, group = "Weekly") MonthlyColor = input(title="Monthly Color", type = input.color, defval = color.green, group = "Monthly") YearlyColor = input(title="Yearly Color", type = input.color, defval = color.red, group = "Yearly") QuarterlyColor = input(title="Quarterly Color", type = input.color, defval = color.orange, group = "Quarterly") IntraColor = input(title="4H Color", type = input.color, defval = color.purple, group = "4H") //if is_monday_enabled == true and dayofweek == dayofweek.monday if (is_monday_enabled == true or is_monday_mid == true) and dayofweek == dayofweek.monday monday_time := daily_time monday_high := cdailyp_high monday_low := cdailyp_low monday_mid := (monday_high + monday_low ) / 2 linewidthint = 1 if linesize == "Small" linewidthint := 1 if linesize == "Medium" linewidthint := 2 if linesize == "Large" linewidthint := 3 var DEFAULT_LINE_WIDTH = linewidthint var DEFAULT_TAIL_WIDTH = linewidthint fontsize = size.small if labelsize == "Small" fontsize := size.small if labelsize == "Medium" fontsize := size.normal if labelsize == "Large" fontsize := size.large var DEFAULT_LABEL_SIZE = fontsize var DEFAULT_LABEL_STYLE = label.style_none var DEFAULT_EXTEND_RIGHT = distanceright check_intersection_open(label_id, check_period) => if daily_open==weekly_open if is_daily_enabled and is_weekly_enabled if check_period==check_daily or check_period==check_weekly label.set_text(label_id, "DO / WO") if daily_open==monthly_open if is_daily_enabled and is_monthly_enabled if check_period==check_daily or check_period==check_monthly label.set_text(label_id, "DO / MO") if daily_open==quarterly_open if is_daily_enabled and is_quarterly_enabled if check_period==check_daily or check_period==check_quarterly label.set_text(label_id, "DO / QO") if daily_open==yearly_open if is_daily_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_yearly label.set_text(label_id, "DO / YO") if weekly_open==monthly_open if is_weekly_enabled and is_monthly_enabled if check_period==check_weekly or check_period==check_monthly label.set_text(label_id, "WO / MO") if weekly_open==quarterly_open if is_weekly_enabled and is_quarterly_enabled if check_period==check_weekly or check_period==check_quarterly label.set_text(label_id, "WO / QO") if weekly_open==yearly_open if is_weekly_enabled and is_yearly_enabled if check_period==check_weekly or check_period==check_yearly label.set_text(label_id, "WO / YO") if monthly_open==quarterly_open if is_monthly_enabled and is_quarterly_enabled if check_period==check_monthly or check_period==check_quarterly label.set_text(label_id, "MO / QO") if monthly_open==yearly_open if is_monthly_enabled and is_yearly_enabled if check_period==check_monthly or check_period==check_yearly label.set_text(label_id, "MO / YO") if quarterly_open==yearly_open if is_quarterly_enabled and is_yearly_enabled if check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "QO / YO") if weeklyp_high==monthlyp_high if is_weeklyrange_enabled and is_monthlyrange_enabled if check_period==check_weekly_high or check_period==check_monthly_high label.set_text(label_id, "PWH / PMH") if weeklyp_low==monthlyp_low if is_weeklyrange_enabled and is_monthlyrange_enabled if check_period==check_weekly_low or check_period==check_monthly_low label.set_text(label_id, "PWL / PML") if weeklyp_high==yearlyp_high if is_weeklyrange_enabled and is_yearlyrange_enabled if check_period==check_weekly_high or check_period==check_yearly_high label.set_text(label_id, "PWH / YH") if weeklyp_low==yearlyp_low if is_weeklyrange_enabled and is_yearlyrange_enabled if check_period==check_weekly_low or check_period==check_yearly_low label.set_text(label_id, "PWL / YL") if monthlyp_high==quarterlyp_high if is_monthlyrange_enabled and is_quarterlyrange_enabled if check_period==check_monthly_high or check_period==check_quarterly_high label.set_text(label_id, "PMH / PQH") if monthlyp_low==quarterlyp_low if is_monthlyrange_enabled and is_quarterlyrange_enabled if check_period==check_monthly_low or check_period==check_quarterly_low label.set_text(label_id, "PML / PQL") if monthlyp_high==yearlyp_high if is_monthlyrange_enabled and is_yearlyrange_enabled if check_period==check_monthly_high or check_period==check_yearly_high label.set_text(label_id, "PMH / YH") if monthlyp_low==yearlyp_low if is_monthlyrange_enabled and is_yearlyrange_enabled if check_period==check_monthly_low or check_period==check_yearly_low label.set_text(label_id, "PML / YL") if quarterlyp_high==yearlyp_high if is_quarterlyrange_enabled and is_yearlyrange_enabled if check_period==check_quarterly_high or check_period==check_yearly_high label.set_text(label_id, "PQH / YH") if quarterlyp_low==yearlyp_low if is_quarterlyrange_enabled and is_yearlyrange_enabled if check_period==check_quarterly_low or check_period==check_yearly_low label.set_text(label_id, "PQL / YL") if dailyp_high==yearlyp_high if is_dailyrange_enabled and is_yearlyrange_enabled if check_period==check_previous_daily_high or check_period==check_yearly_high label.set_text(label_id, "PDH / YH") if dailyp_low==yearlyp_low if is_dailyrange_enabled and is_yearlyrange_enabled if check_period==check_previous_daily_low or check_period==check_yearly_low label.set_text(label_id, "PDL / YL") if weeklyp_low==yearlyp_low if is_weeklyrange_enabled and is_yearlyrange_enabled if check_period==check_weekly_low or check_period==check_yearly_low label.set_text(label_id, "PWL / YL") if dailyp_high==weeklyp_high if is_dailyrange_enabled and is_dailyrange_enabled if check_period==check_previous_daily_high or check_period==check_weekly_high label.set_text(label_id, "PDH / PWH") if dailyp_low==weeklyp_low if is_dailyrange_enabled and is_dailyrange_enabled if check_period==check_previous_daily_low or check_period==check_weekly_low label.set_text(label_id, "PDL / PWL") if monday_high==dailyp_high if is_monday_enabled and is_dailyrange_enabled if check_period==check_monday_high or check_period==check_previous_daily_high label.set_text(label_id, "MondayH / PDH") if monday_low==dailyp_low if is_monday_enabled and is_dailyrange_enabled if check_period==check_monday_low or check_period==check_previous_daily_low label.set_text(label_id, "MondayL / PDL") if monday_mid==dailyp_mid if is_monday_mid and is_dailyrange_enabled if check_period==check_monday_mid or check_period==check_previous_daily_mid label.set_text(label_id, "MondayM / PDM") if dailyp_open==monthly_open if is_previous_daily_open_enabled and is_monthly_enabled if check_period==check_previous_daily or check_period==check_monthly label.set_text(label_id, "PDO / MO") if monthly_mid_open==yearly_mid if is_previous_monthly_mid_enabled and is_yearly_mid_enabled if check_period==check_monthly_mid or check_period==check_yearly_mid label.set_text(label_id, "PMM / YM") if weeklyp_high==monthlyp_high and monthlyp_high==yearlyp_high if is_weeklyrange_enabled and is_monthlyrange_enabled and is_yearlyrange_enabled if check_period==check_weekly_high or check_period==check_monthly_high or check_period==check_yearly_high label.set_text(label_id, "PWH / PMH / YH") if weeklyp_low==monthlyp_low and monthlyp_low==yearlyp_low if is_weeklyrange_enabled and is_monthlyrange_enabled and is_yearlyrange_enabled if check_period==check_weekly_low or check_period==check_monthly_low or check_period==check_yearly_low label.set_text(label_id, "PWL / PML / YL") if intrap_high==monday_high and timeframe.isintraday if is_intrarange_enabled and is_monday_enabled if check_period==check_4h_high or check_period==check_monday_high label.set_text(label_id, "P4hH / MondayH") if intra_open==daily_open and timeframe.isintraday if is_intra_enabled and is_daily_enabled if check_period==check_4h or check_period==check_daily label.set_text(label_id, "4hO / DO") if intra_open==daily_open and daily_open==weekly_open and timeframe.isintraday if is_intra_enabled and is_daily_enabled and is_weekly_enabled if check_period==check_4h or check_period==check_daily or check_period==check_weekly label.set_text(label_id, "4hO / DO / WO") if intra_open==daily_open and daily_open==weekly_open and weekly_open==monthly_open and timeframe.isintraday if is_intra_enabled and is_daily_enabled and is_weekly_enabled and is_monthly_enabled if check_period==check_4h or check_period==check_daily or check_period==check_monthly label.set_text(label_id, "4hO / DO / WO / MO") //------------------- if weeklyp_low==monthlyp_low and monthlyp_low==yearlyp_low if is_weeklyrange_enabled and is_monthlyrange_enabled and is_yearlyrange_enabled if check_period==check_weekly_low or check_period==check_monthly_low or check_period==check_yearly_low label.set_text(label_id, "PWL / PML / YL") if daily_open==weekly_open and weekly_open==monthly_open if is_daily_enabled and is_weekly_enabled and is_monthly_enabled if check_period==check_daily or check_period==check_weekly or check_period==check_monthly label.set_text(label_id, "DO / WO / MO") if daily_open==weekly_open and weekly_open==quarterly_open if is_daily_enabled and is_weekly_enabled and is_quarterly_enabled if check_period==check_daily or check_period==check_weekly or check_period==check_quarterly label.set_text(label_id, "DO / WO / QO") if daily_open==weekly_open and weekly_open==yearly_open if is_daily_enabled and is_weekly_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_weekly or check_period==check_yearly label.set_text(label_id, "DO / WO / YO") if daily_open==monthly_open and monthly_open==quarterly_open if is_daily_enabled and is_monthly_enabled and is_quarterly_enabled if check_period==check_daily or check_period==check_monthly or check_period==check_quarterly label.set_text(label_id, "DO / MO / QO") if dailyp_open==monthly_open and monthly_open==quarterly_open if is_previous_daily_open_enabled and is_monthly_enabled and is_quarterly_enabled if check_period==check_previous_daily or check_period==check_monthly or check_period==check_quarterly label.set_text(label_id, "PDO / MO / QO") if daily_open==monthly_open and monthly_open==yearly_open if is_daily_enabled and is_monthly_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_monthly or check_period==check_yearly label.set_text(label_id, "DO / MO / YO") if daily_open==quarterly_open and quarterly_open==yearly_open if is_daily_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "DO / QO / YO") if weekly_open==monthly_open and monthly_open==quarterly_open if is_weekly_enabled and is_monthly_enabled and is_quarterly_enabled if check_period==check_weekly or check_period==check_monthly or check_period==check_quarterly label.set_text(label_id, "WO / MO / QO") if weekly_open==monthly_open and monthly_open==yearly_open if is_weekly_enabled and is_monthly_enabled and is_yearly_enabled if check_period==check_weekly or check_period==check_monthly or check_period==check_yearly label.set_text(label_id, "WO / MO / YO") if weekly_open==quarterly_open and quarterly_open==yearly_open if is_weekly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_weekly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "WO / QO / YO") if monthly_open==quarterly_open and quarterly_open==yearly_open if is_monthly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_monthly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "MO / QO / YO") if daily_open==weekly_open and weekly_open==monthly_open and monthly_open==quarterly_open if is_daily_enabled and is_weekly_enabled and is_monthly_enabled and is_quarterly_enabled if check_period==check_daily or check_period==check_weekly or check_period==check_monthly or check_period==check_quarterly label.set_text(label_id, "DO / WO / MO / QO") if daily_open==weekly_open and weekly_open==monthly_open and monthly_open==yearly_open if is_daily_enabled and is_weekly_enabled and is_monthly_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_weekly or check_period==check_monthly or check_period==check_yearly label.set_text(label_id, "DO / WO / MO / YO") if dailyp_open==monthly_open and monthly_open==quarterly_open and quarterly_open==yearly_open if is_previous_daily_open_enabled and is_monthly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_previous_daily or check_period==check_monthly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "PDO / MO / QO / YO") if daily_open==monthly_open and monthly_open==quarterly_open and quarterly_open==yearly_open if is_daily_enabled and is_monthly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_monthly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "DO / MO / QO / YO") if daily_open==weekly_open and weekly_open==quarterly_open and quarterly_open==yearly_open if is_daily_enabled and is_weekly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_weekly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "DO / WO / QO / YO") if weekly_open==monthly_open and monthly_open==quarterly_open and quarterly_open==yearly_open if is_weekly_enabled and is_monthly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_weekly or check_period==check_monthly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "WO / MO / QO / YO") if daily_open==weekly_open and weekly_open==monthly_open and monthly_open==quarterly_open and quarterly_open==yearly_open if is_daily_enabled and is_weekly_enabled and is_monthly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_daily or check_period==check_weekly or check_period==check_monthly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "DO / WO / MO / QO / YO") //PWO combinations if weeklyp_open==monthly_open and monthly_open==quarterly_open and quarterly_open==yearly_open if is_previous_weekly_open_enabled and is_monthly_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_previous_weekly or check_period==check_monthly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "PWO / MO / QO / YO") if weeklyp_open==monthly_open and monthly_open==quarterly_open if is_previous_weekly_open_enabled and is_monthly_enabled and is_quarterly_enabled if check_period==check_previous_weekly or check_period==check_monthly or check_period==check_quarterly label.set_text(label_id, "PWO / MO / QO") if weeklyp_open==monthly_open and monthly_open==quarterly_open if is_previous_weekly_open_enabled and is_monthly_enabled and is_yearly_enabled if check_period==check_previous_weekly or check_period==check_monthly or check_period==check_yearly label.set_text(label_id, "PWO / MO / YO") if weeklyp_open==quarterly_open and quarterly_open==yearly_open if is_previous_weekly_open_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_previous_weekly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "PWO / QO / YO") if weeklyp_open==monthly_open if is_previous_weekly_open_enabled and is_monthly_enabled if check_period==check_previous_weekly or check_period==check_monthly label.set_text(label_id, "PWO / MO") if weeklyp_open==quarterly_open if is_previous_weekly_open_enabled and is_quarterly_enabled if check_period==check_previous_weekly or check_period==check_quarterly label.set_text(label_id, "PWO / QO") if weeklyp_open==yearly_open if is_previous_weekly_open_enabled and is_yearly_enabled if check_period==check_previous_weekly or check_period==check_yearly label.set_text(label_id, "PWO / YO") if monthlyp_open==quarterly_open if is_previous_monthly_open_enabled and is_quarterly_enabled if check_period==check_previous_monthly or check_period==check_quarterly label.set_text(label_id, "PMO / QO ") if monthlyp_open==yearly_open if is_previous_monthly_open_enabled and is_yearly_enabled if check_period==check_previous_monthly or check_period==check_yearly label.set_text(label_id, "PMO / YO") if monthlyp_open==quarterly_open and quarterly_open==yearly_open if is_previous_monthly_open_enabled and is_quarterly_enabled and is_yearly_enabled if check_period==check_previous_monthly or check_period==check_quarterly or check_period==check_yearly label.set_text(label_id, "PMO / QO / YO") if dailyp_open==weekly_open if is_previous_daily_open_enabled and is_weekly_enabled if check_period==check_previous_daily or check_period==check_weekly label.set_text(label_id, "PDO / WO") if dailyp_open==weekly_open and weekly_open==monthly_open if is_previous_daily_open_enabled and is_weekly_enabled and is_monthly_enabled if check_period==check_previous_daily or check_period==check_weekly or check_period==check_monthly label.set_text(label_id, "PDO / WO / MO") //------------------------------ Plotting ------------------------------ var can_show_daily = is_daily_enabled and timeframe.isintraday var can_show_weekly = is_weekly_enabled and not timeframe.isweekly and not timeframe.ismonthly var can_show_monthly = is_monthly_enabled and not timeframe.ismonthly var can_show_quarterly = is_quarterly_enabled and not (timeframe.period == "3M") get_limit_right() => _bar = min(time - time[1], time[1] - time[2]) time + _bar * (DEFAULT_EXTEND_RIGHT) // the following code doesn't need to be processed on every candle if barstate.islast is_weekly_open = dayofweek == dayofweek.monday is_monthly_open = dayofmonth == 1 can_draw_daily = (is_weekly_enabled ? not is_weekly_open : true) and (is_monthly_enabled ? not is_monthly_open : true) can_draw_weekly = is_monthly_enabled ? not (is_monthly_open and is_weekly_open) : true can_draw_intra = is_intra_enabled and timeframe.isintraday can_draw_intrah = is_intrarange_enabled and timeframe.isintraday can_draw_intral = is_intrarange_enabled and timeframe.isintraday can_draw_intram = is_intram_enabled and timeframe.isintraday // 4H Open if can_draw_intra intra_limit_right = get_limit_right() var intra_line = line.new(x1 = intra_time, x2 = intra_limit_right, y1 = intra_open, y2 = intra_open, color = IntraColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var intra_label = label.new(x = intra_limit_right, y = intra_open, style = DEFAULT_LABEL_STYLE, textcolor = IntraColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(intra_line, intra_time) line.set_x2(intra_line, intra_limit_right) line.set_y1(intra_line, intra_open) line.set_y2(intra_line, intra_open) label.set_x(intra_label, intra_limit_right) label.set_y(intra_label, intra_open) label.set_text(intra_label, "4hO") label.set_tooltip(intra_label, "4h Open") check_intersection_open(intra_label, check_4h) // Previous 4H High if can_draw_intrah //if is_intrarange_enabled intrah_limit_right = get_limit_right() var intrah_line = line.new(x1 = intraph_time, x2 = intrah_limit_right, y1 = intrap_high, y2 = intrap_high, color = IntraColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var intrah_label = label.new(x = intrah_limit_right, y = intrap_high, style = DEFAULT_LABEL_STYLE, textcolor = IntraColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(intrah_line, intraph_time) line.set_x2(intrah_line, intrah_limit_right) line.set_y1(intrah_line, intrap_high) line.set_y2(intrah_line, intrap_high) label.set_x(intrah_label, intrah_limit_right) label.set_y(intrah_label, intrap_high) label.set_text(intrah_label, "P4hH") label.set_tooltip(intrah_label, "Previous 4h High") check_intersection_open(intrah_label, check_4h_high) // Previous 4H Low if can_draw_intral intral_limit_right = get_limit_right() var intral_line = line.new(x1 = intrapl_time, x2 = intral_limit_right, y1 = intrap_low, y2 = intrap_low, color = IntraColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var intral_label = label.new(x = intral_limit_right, y = intrap_low, style = DEFAULT_LABEL_STYLE, textcolor = IntraColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(intral_line, intrapl_time) line.set_x2(intral_line, intral_limit_right) line.set_y1(intral_line, intrap_low) line.set_y2(intral_line, intrap_low) label.set_x(intral_label, intral_limit_right) label.set_y(intral_label, intrap_low) label.set_text(intral_label, "P4hL") label.set_tooltip(intral_label, "Previous 4h Low") check_intersection_open(intral_label, check_4h_low) // Previous 4H Mid if can_draw_intram intram_limit_right = get_limit_right() intram_time = intraph_time intram_open = (intrap_low + intrap_high ) / 2 var intram_line = line.new(x1 = intram_time, x2 = intram_limit_right, y1 = intram_open, y2 = intram_open, color = IntraColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var intram_label = label.new(x = intram_limit_right, y = intram_open, style = DEFAULT_LABEL_STYLE, textcolor = IntraColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(intram_line, intram_time) line.set_x2(intram_line, intram_limit_right) line.set_y1(intram_line, intram_open) line.set_y2(intram_line, intram_open) label.set_x(intram_label, intram_limit_right) label.set_y(intram_label, intram_open) label.set_text(intram_label, "P4hM") label.set_tooltip(intram_label, "Previous 4h Mid") check_intersection_open(intram_label, check_4h_mid) // MONDAY if is_monday_enabled monday_limit_right = get_limit_right() //monday_limit_right = time + _bar * (DEFAULT_EXTEND_RIGHT) var monday_line = line.new(x1 = monday_time, x2 = monday_limit_right, y1 = monday_high, y2 = monday_high, color = MondayColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var monday_label = label.new(x = monday_limit_right, y = monday_high, style = DEFAULT_LABEL_STYLE, textcolor = MondayColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(monday_line, monday_time) line.set_x2(monday_line, monday_limit_right) line.set_y1(monday_line, monday_high) line.set_y2(monday_line, monday_high) label.set_x(monday_label, monday_limit_right) label.set_y(monday_label, monday_high) label.set_text(monday_label, "MondayH") label.set_tooltip(monday_label, "Monday High") check_intersection_open(monday_label, check_monday_high) if is_monday_enabled monday_limit_right = get_limit_right() var monday_low_line = line.new(x1 = monday_time, x2 = monday_limit_right, y1 = monday_low, y2 = monday_low, color = MondayColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var monday_low_label = label.new(x = monday_limit_right, y = monday_low, style = DEFAULT_LABEL_STYLE, textcolor = MondayColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(monday_low_line, monday_time) line.set_x2(monday_low_line, monday_limit_right) line.set_y1(monday_low_line, monday_low) line.set_y2(monday_low_line, monday_low) label.set_x(monday_low_label, monday_limit_right) label.set_y(monday_low_label, monday_low) label.set_text(monday_low_label, "MondayL") label.set_tooltip(monday_low_label, "Monday Low") check_intersection_open(monday_low_label, check_monday_low) if is_monday_mid mondaym_limit_right = get_limit_right() //monday_mid = (monday_high + monday_low ) / 2 var mondaym_line = line.new(x1 = monday_time, x2 = mondaym_limit_right, y1 = monday_mid, y2 = monday_mid, color = MondayColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var mondaym_label = label.new(x = mondaym_limit_right, y = monday_mid, style = DEFAULT_LABEL_STYLE, textcolor = MondayColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(mondaym_line, monday_time) line.set_x2(mondaym_line, mondaym_limit_right) line.set_y1(mondaym_line, monday_mid) line.set_y2(mondaym_line, monday_mid) label.set_x(mondaym_label, mondaym_limit_right) label.set_y(mondaym_label, monday_mid) label.set_text(mondaym_label, "MondayM") label.set_tooltip(mondaym_label, "Monday Mid") check_intersection_open(mondaym_label, check_monday_mid) // DAILY OPEN //if can_show_daily and can_draw_daily if is_daily_enabled daily_limit_right = get_limit_right() var daily_line = line.new(x1 = daily_time, x2 = daily_limit_right, y1 = daily_open, y2 = daily_open, color = DailyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var daily_label = label.new(x = daily_limit_right, y = daily_open, style = DEFAULT_LABEL_STYLE, textcolor = DailyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(daily_line, daily_time) line.set_x2(daily_line, daily_limit_right) line.set_y1(daily_line, daily_open) line.set_y2(daily_line, daily_open) label.set_x(daily_label, daily_limit_right) label.set_y(daily_label, daily_open) label.set_text(daily_label, "DO") label.set_tooltip(daily_label, "Daily Open") check_intersection_open(daily_label, check_daily) // PREVIOUS DAILY OPEN if is_previous_daily_open_enabled dailyp_limit_right = get_limit_right() var dailyp_line = line.new(x1 = dailypo_time, x2 = dailyp_limit_right, y1 = dailyp_open, y2 = dailyp_open, color = DailyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var dailyp_label = label.new(x = dailyp_limit_right, y = dailyp_open, style = DEFAULT_LABEL_STYLE, textcolor = DailyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(dailyp_line, dailypo_time) line.set_x2(dailyp_line, dailyp_limit_right) line.set_y1(dailyp_line, dailyp_open) line.set_y2(dailyp_line, dailyp_open) label.set_x(dailyp_label, dailyp_limit_right) label.set_y(dailyp_label, dailyp_open) label.set_text(dailyp_label, "PDO") label.set_tooltip(dailyp_label, "Previous Daily Open") check_intersection_open(dailyp_label, check_previous_daily) // PREVIOUS DAILY HIGH if is_dailyrange_enabled dailyh_limit_right = get_limit_right() var dailyh_line = line.new(x1 = dailyph_time, x2 = dailyh_limit_right, y1 = dailyp_high, y2 = dailyp_high, color = DailyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var dailyh_label = label.new(x = dailyh_limit_right, y = dailyp_high, style = DEFAULT_LABEL_STYLE, textcolor = DailyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(dailyh_line, dailyph_time) line.set_x2(dailyh_line, dailyh_limit_right) line.set_y1(dailyh_line, dailyp_high) line.set_y2(dailyh_line, dailyp_high) label.set_x(dailyh_label, dailyh_limit_right) label.set_y(dailyh_label, dailyp_high) label.set_text(dailyh_label, "PDH") label.set_tooltip(dailyh_label, "Previous Daily High") check_intersection_open(dailyh_label, check_previous_daily_high) // PREVIOUS DAILY LOW if is_dailyrange_enabled dailyl_limit_right = get_limit_right() var dailyl_line = line.new(x1 = dailypl_time, x2 = dailyl_limit_right, y1 = dailyp_low, y2 = dailyp_low, color = DailyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var dailyl_label = label.new(x = dailyl_limit_right, y = dailyp_low, style = DEFAULT_LABEL_STYLE, textcolor = DailyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(dailyl_line, dailypl_time) line.set_x2(dailyl_line, dailyl_limit_right) line.set_y1(dailyl_line, dailyp_low) line.set_y2(dailyl_line, dailyp_low) label.set_x(dailyl_label, dailyl_limit_right) label.set_y(dailyl_label, dailyp_low) label.set_text(dailyl_label, "PDL") label.set_tooltip(dailyl_label, "Previous Daily Low") check_intersection_open(dailyl_label, check_previous_daily_low) // DAILY MID if is_dailym_enabled dailym_limit_right = get_limit_right() dailym_time = dailyph_time var dailym_line = line.new(x1 = dailym_time, x2 = dailym_limit_right, y1 = dailyp_mid, y2 = dailyp_mid, color = DailyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var dailym_label = label.new(x = dailym_limit_right, y = dailyp_mid, style = DEFAULT_LABEL_STYLE, textcolor = DailyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(dailym_line, dailym_time) line.set_x2(dailym_line, dailym_limit_right) line.set_y1(dailym_line, dailyp_mid) line.set_y2(dailym_line, dailyp_mid) label.set_x(dailym_label, dailym_limit_right) label.set_y(dailym_label, dailyp_mid) label.set_text(dailym_label, "PDM") label.set_tooltip(dailym_label, "Previous Day Mid") check_intersection_open(dailym_label, check_previous_daily_mid) // WEEKLY OPEN //if can_show_weekly and can_draw_weekly if is_weekly_enabled weekly_limit_right = get_limit_right() var weekly_line = line.new(x1 = weekly_time, x2 = weekly_limit_right, y1 = weekly_open, y2 = weekly_open, color = WeeklyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var weekly_label = label.new(x = weekly_limit_right, y = weekly_open, style = DEFAULT_LABEL_STYLE, textcolor = WeeklyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(weekly_line, weekly_time) line.set_x2(weekly_line, weekly_limit_right) line.set_y1(weekly_line, weekly_open) line.set_y2(weekly_line, weekly_open) label.set_x(weekly_label, weekly_limit_right) label.set_y(weekly_label, weekly_open) label.set_text(weekly_label, "WO") label.set_tooltip(weekly_label, "Weekly Open") // // the weekly open can be the daily open too (monday) // // only the weekly will be draw, in these case we update its label // if is_weekly_open and can_show_daily // label.set_text(weekly_label, "DO / WO ") check_intersection_open(weekly_label, check_weekly) // PREVIOUS WEEKLY OPEN if is_previous_weekly_open_enabled weeklyo_limit_right = get_limit_right() var weeklyo_line = line.new(x1 = weeklypo_time, x2 = weeklyo_limit_right, y1 = weeklyp_open, y2 = weeklyp_open, color = WeeklyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var weeklyo_label = label.new(x = weeklyo_limit_right, y = weeklyp_open, style = DEFAULT_LABEL_STYLE, textcolor = WeeklyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(weeklyo_line, weeklypo_time) line.set_x2(weeklyo_line, weeklyo_limit_right) line.set_y1(weeklyo_line, weeklyp_open) line.set_y2(weeklyo_line, weeklyp_open) label.set_x(weeklyo_label, weeklyo_limit_right) label.set_y(weeklyo_label, weeklyp_open) label.set_text(weeklyo_label, "PWO") label.set_tooltip(weeklyo_label, "Previous Weekly Open") check_intersection_open(weeklyo_label, check_previous_weekly) // WEEKLY HIGH if is_weeklyrange_enabled weeklyh_limit_right = get_limit_right() var weeklyh_line = line.new(x1 = weeklyph_time, x2 = weeklyh_limit_right, y1 = weeklyp_high, y2 = weeklyp_high, color = WeeklyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var weeklyh_label = label.new(x = weeklyh_limit_right, y = weeklyp_high, style = DEFAULT_LABEL_STYLE, textcolor = WeeklyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(weeklyh_line, weeklyph_time) line.set_x2(weeklyh_line, weeklyh_limit_right) line.set_y1(weeklyh_line, weeklyp_high) line.set_y2(weeklyh_line, weeklyp_high) label.set_x(weeklyh_label, weeklyh_limit_right) label.set_y(weeklyh_label, weeklyp_high) label.set_text(weeklyh_label, "PWH") label.set_tooltip(weeklyh_label, "Previous Weekly High") check_intersection_open(weeklyh_label, check_weekly_high) // WEEKLY LOW if is_weeklyrange_enabled weeklyl_limit_right = get_limit_right() var weeklyl_line = line.new(x1 = weekly_time, x2 = weeklyl_limit_right, y1 = weekly_open, y2 = weekly_open, color = WeeklyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var weeklyl_label = label.new(x = weeklyl_limit_right, y = weeklyp_low, text = "PWL", style = DEFAULT_LABEL_STYLE, textcolor = WeeklyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(weeklyl_line, weeklypl_time) line.set_x2(weeklyl_line, weeklyl_limit_right) line.set_y1(weeklyl_line, weeklyp_low) line.set_y2(weeklyl_line, weeklyp_low) label.set_x(weeklyl_label, weeklyl_limit_right) label.set_y(weeklyl_label, weeklyp_low) label.set_text(weeklyl_label, "PWL") label.set_tooltip(weeklyl_label, "Previous Weekly Low") check_intersection_open(weeklyl_label, check_weekly_low) // WEEKLY MID if is_previous_weekly_mid_enabled weeklym_limit_right = get_limit_right() var weeklym_line = line.new(x1 = weekly_time, x2 = weeklym_limit_right, y1 = weekly_mid_open, y2 = weekly_mid_open, color = WeeklyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var weeklym_label = label.new(x = weeklym_limit_right, y = weekly_mid_open, style = DEFAULT_LABEL_STYLE, textcolor = WeeklyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(weeklym_line, weeklypl_time) line.set_x2(weeklym_line, weeklym_limit_right) line.set_y1(weeklym_line, weekly_mid_open) line.set_y2(weeklym_line, weekly_mid_open) label.set_x(weeklym_label, weeklym_limit_right) label.set_y(weeklym_label, weekly_mid_open) label.set_text(weeklym_label, "PWM") label.set_tooltip(weeklym_label, "Previous Weekly Mid") // MONTHLY OPEN //if can_show_monthly if is_monthly_enabled monthly_limit_right = get_limit_right() var monthlyLine = line.new(x1 = monthly_time, x2 = monthly_limit_right, y1 = monthly_open, y2 = monthly_open, color = MonthlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var monthlyLabel = label.new(x = monthly_limit_right, y = monthly_open, style = DEFAULT_LABEL_STYLE, textcolor = MonthlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(monthlyLine, monthly_time) line.set_x2(monthlyLine, monthly_limit_right) line.set_y1(monthlyLine, monthly_open) line.set_y2(monthlyLine, monthly_open) label.set_x(monthlyLabel, monthly_limit_right) label.set_y(monthlyLabel, monthly_open) label.set_text(monthlyLabel, "MO") label.set_tooltip(monthlyLabel, "Monthly Open") check_intersection_open(monthlyLabel, check_monthly) ///////////////////////////////////////////////////////////////////////////// // the monthly open can be the weekly open (monday 1st) and/or daily open too // only the monthly will be draw, in these case we update its label // if is_monthly_open // if can_show_daily // label.set_text(monthlyLabel, "DO / MO ") // if is_weekly_open // if can_show_weekly // label.set_text(monthlyLabel, "WO / MO ") // if can_show_daily and can_show_weekly // label.set_text(monthlyLabel, "DO / WO / MO ") // the start of the line is drew from the first week of the month // if the first day of the weekly candle (monday) is the 2nd of the month // we fix the start of the line position on the previous weekly candle if timeframe.isweekly and dayofweek(monthly_time) != dayofweek.monday line.set_x1(monthlyLine, monthly_time - (weekly_time - weekly_time[1])) // PREVIOUS MONTHLY OPEN if is_previous_monthly_open_enabled monthlyo_limit_right = get_limit_right() var monthlyo_line = line.new(x1 = monthly_time, x2 = monthlyo_limit_right, y1 = monthlyp_open, y2 = monthlyp_open, color = MonthlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var monthlyo_label = label.new(x = monthlyo_limit_right, y = monthlyp_open, style = DEFAULT_LABEL_STYLE, textcolor = MonthlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(monthlyo_line, monthlypo_time) line.set_x2(monthlyo_line, monthlyo_limit_right) line.set_y1(monthlyo_line, monthlyp_open) line.set_y2(monthlyo_line, monthlyp_open) label.set_x(monthlyo_label, monthlyo_limit_right) label.set_y(monthlyo_label, monthlyp_open) label.set_text(monthlyo_label, "PMO") label.set_tooltip(monthlyo_label, "Previous Monthly Open") check_intersection_open(monthlyo_label, check_previous_monthly) // PREVIOUS MONTHLY LOW if is_monthlyrange_enabled monthlyl_limit_right = get_limit_right() var monthlyl_line = line.new(x1 = monthly_time, x2 = monthlyl_limit_right, y1 = monthlyp_low, y2 = monthlyp_low, color = MonthlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var monthlyl_label = label.new(x = monthlyl_limit_right, y = monthlyp_low, style = DEFAULT_LABEL_STYLE, textcolor = MonthlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(monthlyl_line, monthlypl_time) line.set_x2(monthlyl_line, monthlyl_limit_right) line.set_y1(monthlyl_line, monthlyp_low) line.set_y2(monthlyl_line, monthlyp_low) label.set_x(monthlyl_label, monthlyl_limit_right) label.set_y(monthlyl_label, monthlyp_low) label.set_text(monthlyl_label, "PML") label.set_tooltip(monthlyl_label, "Previous Monthly Low") check_intersection_open(monthlyl_label, check_monthly_low) // PREVIOUS MONTHLY HIGH if is_monthlyrange_enabled monthlyh_limit_right = get_limit_right() var monthlyh_line = line.new(x1 = monthly_time, x2 = monthlyh_limit_right, y1 = monthlyp_high, y2 = monthlyp_high, color = MonthlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var monthlyh_label = label.new(x = monthlyh_limit_right, y = monthlyp_high, style = DEFAULT_LABEL_STYLE, textcolor = MonthlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(monthlyh_line, monthlypl_time) line.set_x2(monthlyh_line, monthlyh_limit_right) line.set_y1(monthlyh_line, monthlyp_high) line.set_y2(monthlyh_line, monthlyp_high) label.set_x(monthlyh_label, monthlyh_limit_right) label.set_y(monthlyh_label, monthlyp_high) label.set_text(monthlyh_label, "PMH") label.set_tooltip(monthlyh_label, "Previous Monthly High") check_intersection_open(monthlyh_label, check_monthly_high) // MONTHLY MID if is_previous_monthly_mid_enabled monthlym_limit_right = get_limit_right() var monthlym_line = line.new(x1 = monthly_time, x2 = monthlym_limit_right, y1 = monthly_mid_open, y2 = monthly_mid_open, color = MonthlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var monthlym_label = label.new(x = monthlym_limit_right, y = monthly_mid_open, style = DEFAULT_LABEL_STYLE, textcolor = MonthlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(monthlym_line, monthlypl_time) line.set_x2(monthlym_line, monthlym_limit_right) line.set_y1(monthlym_line, monthly_mid_open) line.set_y2(monthlym_line, monthly_mid_open) label.set_x(monthlym_label, monthlym_limit_right) label.set_y(monthlym_label, monthly_mid_open) label.set_text(monthlym_label, "PMM") label.set_tooltip(monthlym_label, "Previous Monthly Mid") check_intersection_open(monthlym_label, check_monthly_mid) // QUARTERLY OPEN //var Quarterly_label if is_quarterly_enabled quarterly_limit_right = get_limit_right() var quarterly_line = line.new(x1 = quarterly_time, x2 = quarterly_limit_right, y1 = quarterly_open, y2 = quarterly_open, color = QuarterlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var Quarterly_label = label.new(x = quarterly_limit_right, y = quarterly_open, style = DEFAULT_LABEL_STYLE, textcolor = QuarterlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(quarterly_line, quarterly_time) line.set_x2(quarterly_line, quarterly_limit_right) line.set_y1(quarterly_line, quarterly_open) line.set_y2(quarterly_line, quarterly_open) label.set_x(Quarterly_label, quarterly_limit_right) label.set_y(Quarterly_label, quarterly_open) label.set_text(Quarterly_label, "QO") label.set_tooltip(Quarterly_label, "Quarterly Open") check_intersection_open(Quarterly_label, check_quarterly) // if (( monthly_open == quarterly_open) and (quarterly_open == yearly_open)) // //label.set_text(monthlyLabel, "MO / QO / YO ") // label.set_text(Quarterly_label, "MO / QO / YO ") // PREVIOUS QUARTERLY OPEN if is_previous_quarterly_open_enabled previous_quarterly_openlimit_right = get_limit_right() var previous_quarterly_open_line = line.new(x1 = quarterlypo_time, x2 = previous_quarterly_openlimit_right, y1 = quarterlyp_open, y2 = quarterlyp_open, color = QuarterlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var previous_quarterly_open_label = label.new(x = previous_quarterly_openlimit_right, y = quarterlyp_open, style = DEFAULT_LABEL_STYLE, textcolor = QuarterlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(previous_quarterly_open_line, quarterlypo_time) line.set_x2(previous_quarterly_open_line, previous_quarterly_openlimit_right) line.set_y1(previous_quarterly_open_line, quarterlyp_open) line.set_y2(previous_quarterly_open_line, quarterlyp_open) label.set_x(previous_quarterly_open_label, previous_quarterly_openlimit_right) label.set_y(previous_quarterly_open_label, quarterlyp_open) label.set_text(previous_quarterly_open_label, "PQO") label.set_tooltip(previous_quarterly_open_label, "Previous Quarterly Open") check_intersection_open(previous_quarterly_open_label, check_previous_quarterly) // QUARTERLY HIGH if is_quarterlyrange_enabled Quarterlyh_limit_right = get_limit_right() var Quarterlyh_line = line.new(x1 = quarterlyph_time, x2 = Quarterlyh_limit_right, y1 = quarterlyp_high, y2 = quarterlyp_high, color = QuarterlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var Quarterlyh_label = label.new(x = Quarterlyh_limit_right, y = quarterlyp_high, style = DEFAULT_LABEL_STYLE, textcolor = QuarterlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(Quarterlyh_line, quarterlyph_time) line.set_x2(Quarterlyh_line, Quarterlyh_limit_right) line.set_y1(Quarterlyh_line, quarterlyp_high) line.set_y2(Quarterlyh_line, quarterlyp_high) label.set_x(Quarterlyh_label, Quarterlyh_limit_right) label.set_y(Quarterlyh_label, quarterlyp_high) label.set_text(Quarterlyh_label, "PQH") label.set_tooltip(Quarterlyh_label, "Previous Quarterly High") check_intersection_open(Quarterlyh_label, check_quarterly_high) // QUARTERLY LOW if is_quarterlyrange_enabled Quarterlyl_limit_right = get_limit_right() var Quarterlyl_line = line.new(x1 = quarterlypl_time, x2 = Quarterlyl_limit_right, y1 = quarterlyp_low, y2 = quarterlyp_low, color = QuarterlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var Quarterlyl_label = label.new(x = Quarterlyl_limit_right, y = quarterlyp_low, style = DEFAULT_LABEL_STYLE, textcolor = QuarterlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(Quarterlyl_line, quarterlypl_time) line.set_x2(Quarterlyl_line, Quarterlyl_limit_right) line.set_y1(Quarterlyl_line, quarterlyp_low) line.set_y2(Quarterlyl_line, quarterlyp_low) label.set_x(Quarterlyl_label, Quarterlyl_limit_right) label.set_y(Quarterlyl_label, quarterlyp_low) label.set_text(Quarterlyl_label, "PQL") label.set_tooltip(Quarterlyl_label, "Previous Quarterly Low") check_intersection_open(Quarterlyl_label, check_quarterly_low) // QUARTERLY MID if is_previous_quarterly_mid_enabled quarterlym_limit_right = get_limit_right() //quarterly_mid = (quarterlyp_high + quarterlyp_low ) / 2 var quarterlym_line = line.new(x1 = quarterlypl_time, x2 = quarterlym_limit_right, y1 = quarterly_mid, y2 = quarterly_mid, color = QuarterlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var quarterlym_label = label.new(x = quarterlym_limit_right, y = quarterly_mid, style = DEFAULT_LABEL_STYLE, textcolor = QuarterlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(quarterlym_line, quarterlypl_time) line.set_x2(quarterlym_line, quarterlym_limit_right) line.set_y1(quarterlym_line, quarterly_mid) line.set_y2(quarterlym_line, quarterly_mid) label.set_x(quarterlym_label, quarterlym_limit_right) label.set_y(quarterlym_label, quarterly_mid) label.set_text(quarterlym_label, "PQM") label.set_tooltip(quarterlym_label, "Previous Quarterly Mid") check_intersection_open(quarterlym_label, check_quarterly_mid) // YEARLY OPEN if is_yearly_enabled yearly_limit_right = get_limit_right() var yearly_line = line.new(x1 = yearly_time, x2 = yearly_limit_right, y1 = yearly_open, y2 = yearly_open, color = YearlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var yearly_label = label.new(x = yearly_limit_right, y = yearly_open, style = DEFAULT_LABEL_STYLE, textcolor = YearlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(yearly_line, yearly_time) line.set_x2(yearly_line, yearly_limit_right) line.set_y1(yearly_line, yearly_open) line.set_y2(yearly_line, yearly_open) label.set_x(yearly_label, yearly_limit_right) label.set_y(yearly_label, yearly_open) label.set_text(yearly_label, "YO") label.set_tooltip(yearly_label, "Yearly Open") check_intersection_open(yearly_label, check_yearly) // if ((monthly_open == quarterly_open) and (quarterly_open == yearly_open)) // //label.set_text(monthlyLabel, "MO / QO / YO ") // label.set_text(yearly_label, "MO / QO / YO ") // PREVIOUS YEARLY OPEN if is_previous_yearly_enabled yearlypo_limit_right = get_limit_right() var yearlypo_line = line.new(x1 = yearlypo_time, x2 = yearlypo_limit_right, y1 = yearlyp_open, y2 = yearlyp_open, color = YearlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var yearlypo_label = label.new(x = yearlypo_limit_right, y = yearlyp_open, style = DEFAULT_LABEL_STYLE, textcolor = YearlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(yearlypo_line, yearlypo_time) line.set_x2(yearlypo_line, yearlypo_limit_right) line.set_y1(yearlypo_line, yearlyp_open) line.set_y2(yearlypo_line, yearlyp_open) label.set_x(yearlypo_label, yearlypo_limit_right) label.set_y(yearlypo_label, yearlyp_open) label.set_text(yearlypo_label, "PYO") label.set_tooltip(yearlypo_label, "Previous Yearly Open") check_intersection_open(yearlypo_label, check_previous_yearly) // YEARLY LOW if is_yearlyrange_enabled yearlyl_limit_right = get_limit_right() var yearlyl_line = line.new(x1 = yearlypl_time, x2 = yearlyl_limit_right, y1 = yearlyp_low, y2 = yearlyp_low, color = YearlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var yearlyl_label = label.new(x = yearlyl_limit_right, y = yearlyp_low, style = DEFAULT_LABEL_STYLE, textcolor = YearlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(yearlyl_line, yearlypl_time) line.set_x2(yearlyl_line, yearlyl_limit_right) line.set_y1(yearlyl_line, yearlyp_low) line.set_y2(yearlyl_line, yearlyp_low) label.set_x(yearlyl_label, yearlyl_limit_right) label.set_y(yearlyl_label, yearlyp_low) label.set_text(yearlyl_label, "YL") label.set_tooltip(yearlyl_label, "Yearly Low") check_intersection_open(yearlyl_label, check_yearly_low) // YEARLY HIGH if is_yearlyrange_enabled yearlyh_limit_right = get_limit_right() var yearlyh_line = line.new(x1 = yearlyph_time, x2 = yearlyh_limit_right, y1 = yearlyp_high, y2 = yearlyp_high, color = YearlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var yearlyh_label = label.new(x = yearlyh_limit_right, y = yearlyp_high, style = DEFAULT_LABEL_STYLE, textcolor = YearlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(yearlyh_line, yearlyph_time) line.set_x2(yearlyh_line, yearlyh_limit_right) line.set_y1(yearlyh_line, yearlyp_high) line.set_y2(yearlyh_line, yearlyp_high) label.set_x(yearlyh_label, yearlyh_limit_right) label.set_y(yearlyh_label, yearlyp_high) label.set_text(yearlyh_label, "YH") label.set_tooltip(yearlyh_label, "Yearly High") check_intersection_open(yearlyh_label, check_yearly_high) // YEARLY MID if is_yearly_mid_enabled yearlym_limit_right = get_limit_right() //yearly_mid = (yearlyp_high + yearlyp_low ) / 2 var yearlym_line = line.new(x1 = yearlypl_time, x2 = yearlym_limit_right, y1 = yearly_mid, y2 = yearly_mid, color = YearlyColor, width = DEFAULT_LINE_WIDTH, xloc = xloc.bar_time) var yearlym_label = label.new(x = yearlym_limit_right, y = yearly_mid, style = DEFAULT_LABEL_STYLE, textcolor = YearlyColor, size = DEFAULT_LABEL_SIZE, xloc = xloc.bar_time) line.set_x1(yearlym_line, yearlypl_time) line.set_x2(yearlym_line, yearlym_limit_right) line.set_y1(yearlym_line, yearly_mid) line.set_y2(yearlym_line, yearly_mid) label.set_x(yearlym_label, yearlym_limit_right) label.set_y(yearlym_label, yearly_mid) label.set_text(yearlym_label, "PYM") label.set_tooltip(yearlym_label, "Yearly Mid") check_intersection_open(yearlym_label, check_yearly_mid) // ALERTS // Create alert conditions isMondayHigh() => cross(monday_high, close) alertcondition(isMondayHigh(), title="Monday High", message="Monday High, {{ticker}}, price = {{close}}, volume = {{volume}}") isMondayLow() => cross(monday_low, close) alertcondition(isMondayLow(), title="Monday Low", message="Monday Low, {{ticker}}, price = {{close}}, volume = {{volume}}") isMondayMid() => cross(monday_mid, close) alertcondition(isMondayMid(), title="Monday Mid", message="Monday Mid, {{ticker}}, price = {{close}}, volume = {{volume}}") isWeeklyOpen() => cross(weekly_open, close) alertcondition(isWeeklyOpen(), title="Weekly Open", message="Weekly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousWeeklyOpen() => cross(weeklyp_open, close) alertcondition(isPreviousWeeklyOpen(), title="Previous Weekly Open", message="Previous Weekly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousWeeklyHigh() => cross(weeklyp_high, close) alertcondition(isPreviousWeeklyHigh(), title="Previous Weekly High", message="Previous Weekly High, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousWeeklyLow() => cross(weeklyp_low, close) alertcondition(isPreviousWeeklyLow(), title="Previous Weekly Low", message="Previous Weekly Low, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousWeeklyMid() => cross(weekly_mid_open, close) alertcondition(isPreviousWeeklyMid(), title="Previous Weekly Mid", message="Previous Weekly Mid, {{ticker}}, price = {{close}}, volume = {{volume}}") isMonthlyOpen() => cross(monthly_open, close) alertcondition(isMonthlyOpen(), title="Monthly Open", message="Monthly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousMonthlyOpen() => cross(monthlyp_open, close) alertcondition(isPreviousMonthlyOpen(), title="Previous Monthly Open", message="Previous Monthly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousMonthlyHigh() => cross(monthlyp_high, close) alertcondition(isPreviousMonthlyHigh(), title="Previous Monthly High", message="Previous Monthly High, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousMonthlyLow() => cross(monthlyp_low, close) alertcondition(isPreviousMonthlyLow(), title="Previous Monthly Low", message="Previous Monthly Low, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousMonthlyMid() => cross(monthly_mid_open, close) alertcondition(isPreviousMonthlyMid(), title="Previous Monthly Mid", message="Previous Monthly Mid, {{ticker}}, price = {{close}}, volume = {{volume}}") isQuarterlyOpen() => cross(quarterly_open, close) alertcondition(isQuarterlyOpen(), title="Quarterly Open", message="Quarterly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousQuarterlyOpen() => cross(quarterlyp_open, close) alertcondition(isPreviousQuarterlyOpen(), title="Previous Quarterly Open", message="Previous Quarterly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousQuarterlyHigh() => cross(quarterlyp_high, close) alertcondition(isPreviousQuarterlyHigh(), title="Previous Quarterly High", message="Previous Quarterly High, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousQuarterlyLow() => cross(quarterlyp_low, close) alertcondition(isPreviousQuarterlyLow(), title="Previous Quarterly Low", message="Previous Quarterly Low, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousQuarterlyMid() => cross(quarterly_mid, close) alertcondition(isPreviousQuarterlyMid(), title="Previous Quarterly Mid", message="Previous Quarterly Mid, {{ticker}}, price = {{close}}, volume = {{volume}}") isYearlyOpen() => cross(yearly_open, close) alertcondition(isYearlyOpen(), title="Yearly Open", message="Yearly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isPreviousYearlyOpen() => cross(yearlyp_open, close) alertcondition(isPreviousYearlyOpen(), title="Previous Yearly Open", message="Previous Yearly Open, {{ticker}}, price = {{close}}, volume = {{volume}}") isYearlyMid() => cross(yearly_mid, close) alertcondition(isYearlyMid(), title="Yearly Mid", message="Yearly Mid, {{ticker}}, price = {{close}}, volume = {{volume}}")
MACD_STO-SAMI
https://www.tradingview.com/script/YADZogUZ/
sami1i
https://www.tradingview.com/u/sami1i/
23
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © sami1i //@version=4 study("MACD_STO-SAMI",overlay=true) //المدخلات ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// MACD = input(false, title="-<><><><><><><><[MACD]><><><><><><><>-") [m,s,h] = macd(close, 12, 26,9) fast_length = input(title="Fast Length", defval=12) slow_length = input(title="Slow Length", defval=26) src = input(title="Source", defval=close) signal_length = input(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) sma_source = input(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) sma_signal = input(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) STO = input(false, title="-<><><><><><><><[STO]><><><><><><><>-") periodK = input(8, title="%K Length", minval=1) smoothK = input(5, title="%K Smoothing", minval=1) periodD = input(5, title="%D Smoothing", minval=1) k = sma(stoch(close, high, low, periodK), smoothK) d = sma(k, periodD) SMA = input(false, title="-<><><><><><><><[SMA]><><><><><><><>-") len = input(50, minval=1, title="Length") src1 = input(close, title="Source") offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500) out = sma(src1, len) plot(out, color=color.yellow, title="MA", offset=offset) ////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// highlew = input(false, title="-<><><><><><><><[HH HL LL LH]><><><><><><><>-") lb = input(defval = 10, title="Left Bars") rb = input(defval = 10, title="Right Bars") mb = lb + rb + 1 // الاختصارات S1=(m>0 and(crossover(m,s))) S2=(m>0 and(crossunder(m,s))) S3=(crossover(m,s)) S4=(crossunder(m,s)) A1=(m<0 and k>80 and close < out) A2=(m>0 and k<20 and close > out) A3=(m>0 and k<=60 and k>=45) A4=(m<0 and k<=60 and k>=45) A5=(m>0 and k<d and k<=60 and k>=45) A6=(m<0 and k>d and k<=60 and k>=45) A7=(m>0 and k<d and k<=65 and k>=60) A8=(m<0 and k>d and k<=45 and k>=40) // الاشارات barcolor(color=(S1)?color.green:na) barcolor(color=(S2)?color.yellow:na) barcolor(color=(S3)?color.blue:na) barcolor(color=(S4)?color.red:na ) plotshape( A5 ,title="m>0 and k<d and k<=60 and k>=45", location=location.belowbar, style=shape.triangleup, size=size.tiny, color=#26f70c, transp=0) plotshape( A6 ,title="m<0 and k>d and k<=60 and k>=45", location=location.abovebar, style=shape.triangledown, size=size.tiny, color=#fa051b, transp=0) plotshape( A7 ,title="m>0 and k<d and k<=65 and k>=60", location=location.belowbar, style=shape.labelup, size=size.tiny, color=#00a207, transp=0) plotshape( A8 ,title="m<0 and k>d and k<=45 and k>=40", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=#ee0971, transp=0) bgcolor(A1?color.red:na,title="Sell",transp=0) bgcolor(A2?color.green:na,title="Buy",transp=0) plotshape(iff(not na(high[mb]), iff(highestbars(mb) == -lb, high[lb], na), na), style =shape.labeldown, text="pH",textcolor=color.white, transp=50, location = location.abovebar, color = color.red, size = size.tiny, offset = -lb) plotshape(iff(not na(low[mb]), iff(lowestbars(mb) == -lb, low[lb], na), na), style =shape.labelup, text="pL", textcolor=color.white, transp=50,location = location.belowbar, color = color.lime, size = size.tiny, offset = -lb) // التنبية alertcondition(A1,title= "Sell",message="Sell") alertcondition(A2,title="Buy",message="Buy")
MACD_STO-SAMI
https://www.tradingview.com/script/j82us1GE/
sami1i
https://www.tradingview.com/u/sami1i/
60
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/ // © sami1i //@version=4 study("MACD_STO-SAMI",overlay=true) //المدخلات ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// MACD = input(false, title="-<><><><><><><><[MACD]><><><><><><><>-") [m,s,h] = macd(close, 12, 26,9) fast_length = input(title="Fast Length", defval=12) slow_length = input(title="Slow Length", defval=26) src = input(title="Source", defval=close) signal_length = input(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) sma_source = input(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) sma_signal = input(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) STO = input(false, title="-<><><><><><><><[STO]><><><><><><><>-") periodK = input(8, title="%K Length", minval=1) smoothK = input(5, title="%K Smoothing", minval=1) periodD = input(5, title="%D Smoothing", minval=1) k = sma(stoch(close, high, low, periodK), smoothK) d = sma(k, periodD) SMA = input(false, title="-<><><><><><><><[SMA]><><><><><><><>-") len = input(50, minval=1, title="Length") src1 = input(close, title="Source") offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500) out = sma(src1, len) plot(out, color=color.yellow, title="MA", offset=offset) ////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////// highlew = input(false, title="-<><><><><><><><[HH HL LL LH]><><><><><><><>-") lb = input(defval = 10, title="Left Bars") rb = input(defval = 10, title="Right Bars") mb = lb + rb + 1 // الاختصارات S1=(m>0 and(crossover(m,s))) S2=(m>0 and(crossunder(m,s))) S3=(crossover(m,s)) S4=(crossunder(m,s)) A1=(m<0 and k>80 and close < out) A2=(m>0 and k<20 and close > out) A3=(m>0 and k<=60 and k>=45) A4=(m<0 and k<=60 and k>=45) A5=(m>0 and k<d and k<=60 and k>=45) A6=(m<0 and k>d and k<=60 and k>=45) A7=(m>0 and k<d and k<=65 and k>=60) A8=(m<0 and k>d and k<=45 and k>=40) // الاشارات barcolor(color=(S1)?color.green:na) barcolor(color=(S2)?color.yellow:na) barcolor(color=(S3)?color.blue:na) barcolor(color=(S4)?color.red:na ) plotshape( A5 ,title="m>0 and k<d and k<=60 and k>=45", location=location.belowbar, style=shape.triangleup, size=size.tiny, color=#26f70c, transp=0) plotshape( A6 ,title="m<0 and k>d and k<=60 and k>=45", location=location.abovebar, style=shape.triangledown, size=size.tiny, color=#fa051b, transp=0) plotshape( A7 ,title="m>0 and k<d and k<=65 and k>=60", location=location.belowbar, style=shape.labelup, size=size.tiny, color=#00a207, transp=0) plotshape( A8 ,title="m<0 and k>d and k<=45 and k>=40", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=#ee0971, transp=0) bgcolor(A1?color.red:na,title="Sell",transp=0) bgcolor(A2?color.green:na,title="Buy",transp=0) plotshape(iff(not na(high[mb]), iff(highestbars(mb) == -lb, high[lb], na), na), style =shape.labeldown, text="pH",textcolor=color.white, transp=50, location = location.abovebar, color = color.red, size = size.tiny, offset = -lb) plotshape(iff(not na(low[mb]), iff(lowestbars(mb) == -lb, low[lb], na), na), style =shape.labelup, text="pL", textcolor=color.white, transp=50,location = location.belowbar, color = color.lime, size = size.tiny, offset = -lb) // التنبية alertcondition(A1,title= "Sell",message="Sell") alertcondition(A2,title="Buy",message="Buy")
Manual Backtest - Flat the Chart
https://www.tradingview.com/script/kWJCyRGD-Manual-Backtest-Flat-the-Chart/
SimoneMicucci00
https://www.tradingview.com/u/SimoneMicucci00/
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/ // © SimoneMicucci00 //@version=5 indicator("Manual Backtest", "flat the market", overlay = true) plot(10000000, color = #000000) plot(-10000000, color = #000000)
Simple Daily Weekly Monthly Yearly
https://www.tradingview.com/script/OzSZZFZo-Simple-Daily-Weekly-Monthly-Yearly/
Tennkeii
https://www.tradingview.com/u/Tennkeii/
24
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/ // © Toastimane //@version=4 //Keeps track of the previous close and open of the current security. study("Daily Weekly Monthly Yearly", shorttitle="DWMY", overlay = true) //---------------------------- Inputs ------------------------------ var i_dailyOpenPeriod = input(defval = 1, title = "Daily Open Period", group = "Settings", minval = 0) var i_dailyClosePeriod = input(defval = 1, title = "Daily Close Period", group = "Settings", minval = 0) var i_weeklyOpenPeriod = input(defval = 1, title = "Weekly Open Period", group = "Settings", minval = 0) var i_weeklyClosePeriod = input(defval = 1, title = "Weekly Close Period", group = "Settings", minval = 0) var i_monthlyOpenPeriod = input(defval = 1, title = "Monthly Open Period", group = "Settings", minval = 0) var i_monthlyClosePeriod = input(defval = 1, title = "Monthly Close Period", group = "Settings", minval = 0) var i_yearlyOpenPeriod = input(defval = 1, title = "Yearly Open Period", group = "Settings", minval = 0) var i_yearlyClosePeriod = input(defval = 1, title = "Yearly Close Period", group = "Settings", minval = 0) //---------------------------- Colors ------------------------------ color color1 = color.blue color color2 = color.green color color3 = color.red color color4 = color.yellow color color5 = color.navy color color6 = color.olive color color7 = color.maroon color color8 = color.orange [dailyOpen, dailyClose] = security(syminfo.tickerid, 'D', [open[i_dailyOpenPeriod], close[i_dailyClosePeriod]], lookahead = barmerge.lookahead_on) [weeklyOpen, weeklyClose] = security(syminfo.tickerid, 'W', [open[i_weeklyOpenPeriod], close[i_weeklyClosePeriod]], lookahead = barmerge.lookahead_on) [monthlyOpen, monthlyClose] = security(syminfo.tickerid, 'M', [open[i_monthlyOpenPeriod], close[i_monthlyClosePeriod]], lookahead = barmerge.lookahead_on) [yearlyOpen, yearlyClose] = security(syminfo.tickerid, '12M', [open[i_yearlyOpenPeriod], close[i_yearlyClosePeriod]], lookahead = barmerge.lookahead_on) //---------------------------- Previous Opens ------------------------------ plot(dailyOpen, "PDO", color1, 3, show_last = 1, trackprice = true) plot(weeklyOpen, "PWO", color2, 3, show_last = 1, trackprice = true) plot(monthlyOpen, "PMO", color3, 3, show_last = 1, trackprice = true) plot(yearlyOpen, "PYO", color4, 3, show_last = 1, trackprice = true) //---------------------------- Previous Closes ------------------------------ plot(dailyClose, "PDC", color5, 3, show_last = 1, trackprice = true) plot(weeklyClose, "PWC", color6, 3, show_last = 1, trackprice = true) plot(monthlyClose, "PMC", color7, 3, show_last = 1, trackprice = true) plot(yearlyClose, "PYC", color8, 3, show_last = 1, trackprice = true)
[Nic] Intraday Vix Labels
https://www.tradingview.com/script/PwG1keXm-Nic-Intraday-Vix-Labels/
NicTheMajestic
https://www.tradingview.com/u/NicTheMajestic/
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/ // © NicTheMajestic //@version=5 indicator("[Nic] Vix Labels", overlay=true) tblPos = input(position.bottom_right, "Position") lblText = input(color.white, "Label Color") lblBg = input(color.blue, "Label Bg") TF2 = input.timeframe("30", "TimeFrame2", group='TimeFrame Settings', options=['5', '15', '30', '60', '120', '4H', 'D', '2D', '5D', 'W', '2W', '4W', 'M', 'Q', 'Y']) TF3 = input.timeframe("60", "TimeFrame3", group='TimeFrame Settings', options=['5', '15', '30', '60', '120', '4H', 'D', '2D', '5D', 'W', '2W', '4W', 'M', 'Q', 'Y']) TF4 = input.timeframe("120", "TimeFrame4", group='TimeFrame Settings', options=['5', '15', '30', '60', '120', '4H', 'D', '2D', '5D', 'W', '2W', '4W', 'M', 'Q', 'Y']) DRAW1 = input.bool(false, "Draw Symbol1", group='Symbol Settings') SYM1 = input.symbol("SPY", group='Symbol Settings') DRAW2 = input.bool(false, "Draw Symbol2", group='Symbol Settings') SYM2 = input.symbol("QQQ", group='Symbol Settings') DRAW3 = input.bool(false, "Draw Symbol3", group='Symbol Settings') SYM3 = input.symbol("IWM", group='Symbol Settings') DRAW4 = input.bool(true, "Draw Symbol4", group='Symbol Settings') SYM4 = input.symbol("PCC", group='Symbol Settings') DRAW5 = input.bool(true, "Draw Symbol5", group='Symbol Settings') SYM5 = input.symbol("VIX9D", group='Symbol Settings') DRAW6 = input.bool(true, "Draw Symbol6", group='Symbol Settings') SYM6 = input.symbol("VVIX", group='Symbol Settings') var table tablo = table.new(tblPos,7,7,border_width=1,border_color=color.gray, frame_color=color.gray, frame_width=0) // get change in Percentage values f_getPercent(_p1, _p2) => (_p1 - _p2) * 100 / _p2 f_drawRow(_security, row) => [o, _sec] = request.security(_security, 'D', [open, close]) _pre = request.security(_security, 'D',close[1]) _cha = _sec - _pre _pct = f_getPercent(_sec, _pre) _pct1 = f_getPercent(_sec, o) table.cell(tablo,1,row,bgcolor=color.black,text_color=color.white, text=str.tostring(_sec)) table.cell(tablo,2,row,bgcolor= (_pct > 0 ? color.green : color.red), text_color=color.white, text=str.tostring(_pct, '#.##')) table.cell(tablo,3,row,bgcolor= (_pct1 > 0 ? color.green : color.red), text_color=color.white, text=str.tostring(_pct1, '#.##')) _pct2 = f_getPercent(_sec, request.security(_security, TF2, close[1])) table.cell(tablo,4,row,bgcolor= (_pct2 > 0 ? color.green : color.red), text_color=color.white, text=str.tostring(_pct2, '#.##')) _pct3 = f_getPercent(_sec, request.security(_security, TF3, close[1])) table.cell(tablo,5,row,bgcolor= (_pct3 > 0 ? color.green : color.red), text_color=color.white, text=str.tostring(_pct3, '#.##')) _pct4 = f_getPercent(_sec, request.security(_security, TF4, close[1])) table.cell(tablo,6,row,bgcolor= (_pct4 > 0 ? color.green : color.red), text_color=color.white, text=str.tostring(_pct4, '#.##')) f_isfirstDay = ta.change(time("D")) if barstate.islast table.cell(tablo,0,0,bgcolor=color.black,text_color=color.white, text="Symbol") table.cell(tablo,1,0,bgcolor=color.black,text_color=color.white, text="Price") table.cell(tablo,2,0,bgcolor=color.black,text_color=color.white, text="Day %") table.cell(tablo,3,0,bgcolor=color.black,text_color=color.white, text="Intra %") table.cell(tablo,4,0,bgcolor=color.black,text_color=color.white, text=str.tostring(TF2)) table.cell(tablo,5,0,bgcolor=color.black,text_color=color.white, text=str.tostring(TF3)) table.cell(tablo,6,0,bgcolor=color.black,text_color=color.white, text=str.tostring(TF4)) if DRAW1 table.cell(tablo,0,1,bgcolor=color.black,text_color=color.white, text=str.tostring(SYM1)) if DRAW2 table.cell(tablo,0,2,bgcolor=color.black,text_color=color.white, text=str.tostring(SYM2)) if DRAW3 table.cell(tablo,0,3,bgcolor=color.black,text_color=color.white, text=str.tostring(SYM3)) if DRAW4 table.cell(tablo,0,4,bgcolor=color.black,text_color=color.white, text=str.tostring(SYM4)) if DRAW5 table.cell(tablo,0,5,bgcolor=color.black,text_color=color.white, text=str.tostring(SYM5)) if DRAW6 table.cell(tablo,0,6,bgcolor=color.black,text_color=color.white, text=str.tostring(SYM6)) if DRAW1 f_drawRow(SYM1, 1) if DRAW2 f_drawRow(SYM2, 2) if DRAW3 f_drawRow(SYM3, 3) if DRAW4 f_drawRow(SYM4, 4) if DRAW5 f_drawRow(SYM5, 5) if DRAW6 f_drawRow(SYM6, 6)
Customizable Gap Finder++
https://www.tradingview.com/script/g3WQTYkv/
remtradepro
https://www.tradingview.com/u/remtradepro/
76
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ProfessorZoom //@version=5 indicator('Gap Finder++', overlay=true, max_bars_back=4000) // Inputs var barsBack = input.int(title='Bars to Check For', defval=4000, group='Main Settings', minval=50, maxval=4000, step=1) var extendUnFilled = input.bool(title='Extend Unfilled Gap Boxes', defval=true, group='Main Settings') var showFilledBoxes = input.bool(title='Show Filled Gap Boxes', defval=true, group='Main Settings') var gapFilledLabelColor = input.color(title='Gap Filled Label Color', defval=color.white, group='Main Settings') var hideAllFilledStuff = input.bool(title='Hide All Filled Gap Stuff', defval=true, group='Main Settings') var showLabels = input.bool(title='Show Gap Notification Labels', defval=false, group='Main Settings') var gapUpLabelColor = input.color(title='Gap Up Label Color', defval=color.rgb(255, 255, 255, 10), group='Gap Up') var gapUpBackgroundColor = input.color(title='Gap Up Border Color', defval=color.rgb(255, 128, 128, 90), group='Gap Up') var gapUpBorderColor = input.color(title='Gap Up Background Color', defval=color.rgb(255, 255, 255, 100), group='Gap Up') var gapDownLabelColor = input.color(title='Gap Down Label Color', defval=color.rgb(255, 255, 255, 10), group='Gap Down') var gapDownBackgroundColor = input.color(title='Gap Down Border Color', defval=color.rgb(64, 255, 200, 94), group='Gap Down') var gapDownBorderColor = input.color(title='Gap Down Background Color', defval=color.rgb(255, 255, 255, 100), group='Gap Down') // Really wish we could write classes // Gap Ups var gapUpBarsAgo = array.new_int() var gapUpRight = array.new_int() var gapUpLeft = array.new_int() var gapUpHighs = array.new_float() var gapUpLows = array.new_float() var gapUpClosed = array.new_int() // Gap Downs var gapDownBarsAgo = array.new_int() var gapDownRight = array.new_int() var gapDownLeft = array.new_int() var gapDownHighs = array.new_float() var gapDownLows = array.new_float() var gapDownClosed = array.new_int() // We take the current bar and look back // what we do here is to go back back back back if barstate.islast // Check for gaps for i = 0 to barsBack by 1 // Gap Ups if low[i] > high[i + 1] if showLabels label.new(bar_index[i], high[i], 'Gap Up', color=gapUpLabelColor) array.push(gapUpBarsAgo, i) array.push(gapUpRight, bar_index[i]) array.push(gapUpLeft, bar_index[i + 1]) array.push(gapUpHighs, low[i]) array.push(gapUpLows, high[i + 1]) // Gap Downs if high[i] < low[i + 1] if showLabels label.new(bar_index[i], high[i], 'Gap Down', color=gapUpLabelColor) array.push(gapDownBarsAgo, i) array.push(gapDownRight, bar_index[i]) array.push(gapDownLeft, bar_index[i + 1]) array.push(gapDownHighs, low[i + 1]) array.push(gapDownLows, high[i]) // [GAP UP] Check if any gaps are filled if array.size(gapUpBarsAgo) > 0 for i = 0 to array.size(gapUpRight) - 1 by 1 for j = array.get(gapUpBarsAgo, i) to 0 by 1 if low[j] <= array.get(gapUpLows, i) if showFilledBoxes and hideAllFilledStuff == false box.new(left=array.get(gapUpLeft, i), top=array.get(gapUpHighs, i), right=bar_index[j], bottom=array.get(gapUpLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapUpBackgroundColor, border_color=gapUpBorderColor) //if hideAllFilledStuff == false and showLabels //label.new(bar_index[j], low[j], "Gap Filled", color=gapFilledLabelColor, style=label.style_label_up) array.push(gapUpClosed, array.get(gapUpRight, i)) break for i = 0 to array.size(gapUpRight) - 1 by 1 for j = array.get(gapUpBarsAgo, i) to 0 by 1 if array.includes(gapUpClosed, array.get(gapUpRight, i)) == false if low[j] <= array.get(gapUpHighs, i) array.set(gapUpHighs, i, low[j]) // [GAP UP] Draw unfilled gap boxes for i = 0 to array.size(gapUpRight) - 1 by 1 if array.includes(gapUpClosed, array.get(gapUpRight, i)) == false box.new(left=array.get(gapUpLeft, i), top=array.get(gapUpHighs, i), right=bar_index, bottom=array.get(gapUpLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapUpBackgroundColor, border_color=gapUpBorderColor, extend=extendUnFilled ? extend.right : extend.none) // [GAP DOWN] Check if any gaps are filled if array.size(gapDownBarsAgo) > 0 for i = 0 to array.size(gapDownRight) - 1 by 1 for j = array.get(gapDownBarsAgo, i) to 0 by 1 if high[j] >= array.get(gapDownHighs, i) if showFilledBoxes and hideAllFilledStuff == false box.new(left=array.get(gapDownLeft, i), top=array.get(gapDownHighs, i), right=bar_index[j], bottom=array.get(gapDownLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapDownBackgroundColor, border_color=gapDownBorderColor) if hideAllFilledStuff == false and showLabels label.new(bar_index[j], high[j], 'Gap Filled', color=gapFilledLabelColor, style=label.style_label_down) array.push(gapDownClosed, array.get(gapDownRight, i)) break for i = 0 to array.size(gapDownRight) - 1 by 1 for j = array.get(gapDownBarsAgo, i) to 0 by 1 if array.includes(gapDownClosed, array.get(gapDownRight, i)) == false if high[j] >= array.get(gapDownLows, i) array.set(gapDownLows, i, high[j]) // [GAP DOWN] Draw unfilled gap boxes for i = 0 to array.size(gapDownRight) - 1 by 1 if array.includes(gapDownClosed, array.get(gapDownRight, i)) == false box.new(left=array.get(gapDownLeft, i), top=array.get(gapDownHighs, i), right=bar_index, bottom=array.get(gapDownLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapDownBackgroundColor, border_color=gapDownBorderColor, extend=extendUnFilled ? extend.right : extend.none)
Litt Internals Pro
https://www.tradingview.com/script/znm0fBkf-Litt-Internals-Pro/
Steadylit
https://www.tradingview.com/u/Steadylit/
140
study
5
MPL-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("Litt Internals Pro") instructions = input.bool(title='Instructions', defval=true, inline='1', tooltip = "The Litt Internal Pro is based on the four major U.S. Equity Indexes. This is to not be used for any other markets. If you need more information on any of the indexes, you can google or watch YouTube videos on what they are. Typically if we are looking for to be long we want to see all four of the indexes green and have buy ratings. If we are looking to be short we want to see all four of the indexes red and have sell ratings. If you see Overbought or Oversold ratings it may be best to wait for a pullback to get long or not take the trade at all. \n\nFor the stocks that you trade, you should know what index they are in. The reason for this is that you can still take trades if not all four indexes are aligned the same color. For example, maybe small caps (IWM) are on a hot streak and seeing buying momentum from insitutions meanwhile tech (QQQ), is being sold. If you held a long in a company that is in IWM then you could be more comfortable holding your long position. Meanwhile, if you held a long position in a stock that is in QQQ then you might want to cut your loss or take profit. There are multiple different use cases for this indicator so it is best to look for outside resources on more information on the indexes and what stocks are in each index. This can be a very powerful tool to see sector rotation by hedge funds and institutions.") color_up = input.color(color.new(#27a69b,0), title='Bull Color', inline='3', group='Internal Settings') color_down = input.color(color.new(#b63632,0), title='Bear Color', inline='3', group='Internal Settings') spy = request.security("SPY", "", ta.rsi(close,50), lookahead = barmerge.lookahead_on) ym = request.security("DIA", "", ta.rsi(close,50), lookahead = barmerge.lookahead_on) qqq = request.security("QQQ", "", ta.rsi(close,50), lookahead = barmerge.lookahead_on) iwm = request.security("IWM", "", ta.rsi(close,50), lookahead = barmerge.lookahead_on) avg = math.avg(spy,ym,qqq,iwm) plot(avg, color = color.new(#000000,0), title = 'Internal Oscillator Outline', linewidth = 5, style = plot.style_line, editable = false) avg_plot = plot(avg, color = avg > 50 ? color_up : color_down, title = 'Internal Oscillator', linewidth = 2, style = plot.style_line, editable = false) midline = plot(50, color = color.new(color.gray,50), title = "Midline", editable = false) bull_color = color.from_gradient(avg, ta.lowest(avg, 20), ta.highest(avg, 20), color.new(color_up,65), color_up) bear_color = color.from_gradient(avg, ta.lowest(avg, 20), ta.highest(avg, 20), color_down, color.new(color_down,65)) fill(avg_plot, midline, color = avg > 50 ? bull_color : bear_color, editable = false) f_bb(src, length, mult, mult2) => float basis = ta.sma(src, length) float dev = ta.stdev(src, length) [basis, basis + dev * mult, basis - dev * mult, basis + dev * mult2, basis - dev * mult2] [middle, upper, lower, upper2, lower2] = f_bb(avg, 200, 2.5 ,3) upper_1 = plot(upper, title = 'Strong Overbought Reading', color = color.new(#d32f2f, 80),editable = false) lower_1 = plot(lower, title = 'Strong Oversold Reading', color = color.new(#26a69a, 80),editable = false) upper_2 = plot(upper2,title = 'Xtreme Overbought Reading', color = color.new(#d32f2f, 80),editable = false) lower_2 = plot(lower2,title = 'Xtreme Oversold Reading', color = color.new(#26a69a, 80),editable = false) fill(upper_1, upper_2, color = color.new(color_down,90), title = "Overbought Area") fill(lower_1, lower_2, color = color.new(color_up,90), title = "Oversold Area") pct_chg(symbol) => chg = request.security(symbol, "D", math.round((close - close[1]) / close[1] * 100,2), lookahead = barmerge.lookahead_on) chg_color = chg >= 0 ? color.new(color_up,40) : color.new(color_down,40) [chg, chg_color] [spy_chg, spy_chg_color] = pct_chg("SPY") [dia_chg, dia_chg_color] = pct_chg("DIA") [qqq_chg, qqq_chg_color] = pct_chg("QQQ") [iwm_chg, iwm_chg_color] = pct_chg("IWM") rating(number) => return_rating = number > 70 ? "Overbought" : number >= 60 ? "Strong Buy" : number >= 50 ? "Buy" : number < 20 ? "Oversold" : number <= 40 ? "Strong Sell" : number < 50 ? "Sell" : " " return_color = number > 70 ? color.new(color_up,70) : number >= 50 ? color.new(color_up,40) : number < 20 ? color.new(color_up,70) : number < 50 ? color.new(color_down,40) : na [return_rating, return_color] [spy_rating, spy_color] = rating(spy) [dia_rating, dia_color] = rating(ym) [qqq_rating, qqq_color] = rating(qqq) [iwm_rating, iwm_color] = rating(iwm) //TABLE show_dashboard = input.bool(title='Dashboard', defval=true, inline='1', group='Dashboard Settings') LabelSize = input.string(defval='Medium', options=['Small', 'Medium', 'Large'], title='Dashboard Size', inline='2', group='Dashboard Settings') label_size = LabelSize == 'Small' ? size.small : LabelSize == 'Medium' ? size.normal : LabelSize == 'Large' ? size.large : size.small positioning = position.middle_right dashboard_color = input.color(color.new(#131722, 0), title='BG Color', inline='2', group='Dashboard Settings') dashboard_text = input.color(#ffffff, title='Text Color', inline='2', group='Dashboard Settings') dashboard_bull = color.new(color_up,40) dashboard_bear = color.new(color_down,40) var table t = table.new(positioning, 5, 30,frame_color=color.new(#000000, 100), frame_width=0, border_color=color.new(#000000,100), border_width=0) if barstate.islast and show_dashboard //Column 1 table.cell(t, 0, 0, text=' ', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 0, 1, text=' ', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 0, 2, text='SPY', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 0, 3, text='QQQ', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 0, 4, text='DIA', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 0, 5, text='IWM', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 0, 5, text=' ', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 0, 5, text=' ', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) // //Column2 table.cell(t, 1, 0, text=' 🔥Litt Internals🔥', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 1, 1, text=' % Chg', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 1, 2, text=str.tostring(spy_chg)+ "%", width=0, bgcolor=spy_chg_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 1, 3, text=str.tostring(qqq_chg)+ "%", width=0, bgcolor=qqq_chg_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 1, 4, text=str.tostring(dia_chg)+ "%", width=0, bgcolor=dia_chg_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 1, 5, text=str.tostring(iwm_chg)+ "%", width=0, bgcolor=iwm_chg_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) // //Column3 table.cell(t, 2, 0, text=' ', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 2, 1, text=' Rating', width=0, bgcolor=dashboard_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 2, 2, text=spy_rating, width=0, bgcolor=spy_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 2, 3, text=qqq_rating, width=0, bgcolor=qqq_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 2, 4, text=dia_rating, width=0, bgcolor=dia_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center) table.cell(t, 2, 5, text=iwm_rating, width=0, bgcolor=iwm_color, text_color=dashboard_text, text_size=label_size, text_halign=text.align_center)
Dominator Plus- Darshan Hirpara
https://www.tradingview.com/script/zakAI2f3-Dominator-Plus-Darshan-Hirpara/
DarshanHirpara
https://www.tradingview.com/u/DarshanHirpara/
14
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/ // © Dominator Plus- Darshan Hirpara //@version=4 study(title="Dominator Plus- Darshan Hirpara", shorttitle="Dominator Plus", precision=2,max_bars_back=200) // This indicator is a modified version of the TradingView "Technicals Ratings" indicator. // The technical indicators were not changes even their parameters as well //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // INPUTS AND GLOBAL VARIABLES DECLARATION // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////{ //-----------------------------------------------------------------------------------------------------------------------------------------------------// // - ASSETS AND RESOLUTIONS //{ res_1 = input( defval="60", title="Resolution 1", group="Resolution", inline='resolutions', type=input.resolution ) res_2 = input( defval="240", title="Resolution 2", group="Resolution", inline='resolutions', type=input.resolution ) res_3 = input( defval="D", title="Resolution 3", group="Resolution", inline='resolutions', type=input.resolution ) switch= input( defval= false, title='Second set?', group="Resolution", inline='resolutions', type=input.bool ) asset_01=not switch?input( defval="BINANCE:HOTUSDT", title="Asset 01", group="Assets set 1", inline='A1', type=input.symbol ): input( defval="BINANCE:NBSUSDT", title="Asset 13", group="Assets set 2", inline='B1', type=input.symbol ) asset_02=not switch?input( defval="BINANCE:MKRUSDT", title="Asset 02", group="Assets set 1", inline='A1', type=input.symbol ): input( defval="BINANCE:PERLUSDT", title="Asset 14", group="Assets set 2", inline='B1', type=input.symbol ) asset_03=not switch?input( defval="BINANCE:MATICUSDT", title="Asset 03", group="Assets set 1", inline='A2', type=input.symbol ): input( defval="BINANCE:STORJUSDT", title="Asset 15", group="Assets set 2", inline='B2', type=input.symbol ) asset_04=not switch?input( defval="BINANCE:NEOUSDT", title="Asset 04", group="Assets set 1", inline='A2', type=input.symbol ): input( defval="BINANCE:DODOUSDT", title="Asset 16", group="Assets set 2", inline='B2', type=input.symbol ) asset_05=not switch?input( defval="BINANCE:VETUSDT", title="Asset 05", group="Assets set 1", inline='A3', type=input.symbol ): input( defval="BINANCE:AUDIOUSDT", title="Asset 17", group="Assets set 2", inline='B3', type=input.symbol ) asset_06=not switch?input( defval="BINANCE:DENTUSDT", title="Asset 06", group="Assets set 1", inline='A3', type=input.symbol ): input( defval="BINANCE:ETHUSDT", title="Asset 18", group="Assets set 2", inline='B3', type=input.symbol ) asset_07=not switch?input( defval="BINANCE:AXSUSDT", title="Asset 07", group="Assets set 1", inline='A4', type=input.symbol ): input( defval="BINANCE:BTCUSDT", title="Asset 19", group="Assets set 2", inline='B4', type=input.symbol ) asset_08=not switch?input( defval="BINANCE:NBSUSDT", title="Asset 08", group="Assets set 1", inline='A4', type=input.symbol ): input( defval="BINANCE:CHZUSDT", title="Asset 20", group="Assets set 2", inline='B4', type=input.symbol ) asset_09=not switch?input( defval="BINANCE:ADAUSDT", title="Asset 09", group="Assets set 1", inline='A5', type=input.symbol ): input( defval="BINANCE:FTMUSDT", title="Asset 21", group="Assets set 2", inline='B5', type=input.symbol ) asset_10=not switch?input( defval="BINANCE:SOLUSDT", title="Asset 10", group="Assets set 1", inline='A5', type=input.symbol ): input( defval="BINANCE:ONEUSDT", title="Asset 22", group="Assets set 2", inline='B5', type=input.symbol ) asset_11=not switch?input( defval="BINANCE:WINUSDT", title="Asset 11", group="Assets set 1", inline='A6', type=input.symbol ): input( defval="BINANCE:XVSUSDT", title="Asset 23", group="Assets set 2", inline='B6', type=input.symbol ) asset_12=not switch?input( defval="BINANCE:MTLUSDT", title="Asset 12", group="Assets set 1", inline='A6', type=input.symbol ): input( defval="BINANCE:DOGEUSDT", title="Asset 24", group="Assets set 2", inline='B6', type=input.symbol ) //} //-----------------------------------------------------------------------------------------------------------------------------------------------------// // - ANALYSIS AND VISUALIZATION //{ ratingSignal= input( defval="All", title="Rating base", group="Analysis and visualization", inline='table ration', type=input.string, options = ["MAs", "Oscillators", "All"] ) poscol= input( defval=color.green, title="Buy Color", group="Analysis and visualization", inline='Colors', type=input.color ) neutralcolor= input( defval=color.yellow, title="Neutral Color", group="Analysis and visualization", inline='Colors', type=input.color ) negcol= input( defval=color.red, title="Sell Color", group="Analysis and visualization", inline='Colors', type=input.color ) //} //-----------------------------------------------------------------------------------------------------------------------------------------------------// // - TABLE SETTINGS //{ // - Table position //{ tbl_rows= input( defval=4 , title='Table rows', group="Table position", inline='rows', type=input.integer, options=[3,4,6,12] ) hide_infoboard= input( defval=false, title="hide", group="Table position", inline="rows", type=input.bool ) pos_y_infoboard= input( defval="top", title='Infoboard', group="Table position", inline="Infoboard", type=input.string, options=["top", "middle", "bottom"] ) pos_x_infoboard= input( defval="right", title='Infoboard', group="Table position", inline="Infoboard", type=input.string, options=['left', 'center', 'right'] ) //} // - Table colors //{ border_color= input( defval=color.silver, title="Border color", group="Table settings", inline="Border color", type=input.color ) border_trans= input( defval=50, title="transparency", group="Table settings", inline="Border color", type=input.integer, minval=0, maxval=100, step=10 ) border_width= input( defval=1, title="width", group="Table settings", inline="Border color", type=input.integer, minval=0, maxval=3, step=1 ) frame_color= input( defval=color.black, title="Frame color", group="Table settings", inline="Frame color", type=input.color ) frame_trans= input( defval=10, title="transparency", group="Table settings", inline="Frame color", type=input.integer, minval=0, maxval=100, step=10 ) frame_width= input( defval=2, title="width", group="Table settings", inline="Frame color", type=input.integer, minval=0, maxval=5, step=1 ) //} // - Header column //{ bgcolor_c= input( defval=color.gray, title="Head col color", group="Header columns", inline="Column color", type=input.color ) bgtrans_c= input( defval=20, title="transparency", group="Header columns", inline="Column color", type=input.integer, minval=0, maxval=100, step=10 ) font_color_c= input( defval=color.white, title="Font color", group="Header columns", inline="Column font", type=input.color ) font_trans_c= input( defval=0, title="transparency", group="Header columns", inline="Column font", type=input.integer, minval=0, maxval=100, step=10 ) font_size_c= input( defval="small", title="size", group="Header columns", inline="Column font", type=input.string, options=["auto","tiny","small","normal","large","huge"] ) halign_c= input( defval='center', title="Horizontal alignment", group="Header columns", inline="Column align", type=input.string, options=['left', 'center', 'right'] ) //} // - Header row //{ bgcolor_r= input( defval=color.white, title="Head row color", group="Header rows", inline="Row color", type=input.color ) bgtrans_r= input( defval=0, title="transparency", group="Header rows", inline="Row color", type=input.integer, minval=0, maxval=100, step=10 ) font_color_r= input( defval=color.black, title="Font color", group="Header rows", inline="Row font", type=input.color ) font_trans_r= input( defval=0, title="transparency", group="Header rows", inline="Row font", type=input.integer, minval=0, maxval=100, step=10 ) font_size_r= input( defval="small", title="size", group="Header rows", inline="Row font", type=input.string, options=["auto","tiny","small","normal","large","huge"] ) halign_r= input( defval='left', title="Horizontal alignment", group="Header rows", inline="Row align", type=input.string, options=['left', 'center', 'right'] ) //} // - Cells //{ bgcolor= input( defval=color.black, title="Cell color", group="Cell settings", inline="BG color", type=input.color ) bgtrans= input( defval=20, title="transparency", group="Cell settings", inline="BG color", type=input.integer, minval=0, maxval=100, step=10 ) font_color= input( defval=color.white, title="Font color", group="Cell settings", inline="Font color", type=input.color ) font_trans= input( defval=20, title="transparency", group="Cell settings", inline="Font color", type=input.integer, minval=0, maxval=100, step=10 ) font_size= input( defval="small", title="size", group="Cell settings", inline="Font color", type=input.string, options=["auto","tiny","small","normal","large","huge"] ) halign= input( defval='center', title="Horizontal alignment", group="Cell settings", inline="Font align", type=input.string, options=['left', 'center', 'right'] ) //} // - Global variables //{ var int tbl_columns= 12/tbl_rows //} //} //-----------------------------------------------------------------------------------------------------------------------------------------------------//} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // FUNCTIONS: GENERAL // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////{ //-----------------------------------------------------------------------------------------------------------------------------------------------------// // - Generate size proverty form string //{ f_size(f_size_name) => if f_size_name == "tiny" size.tiny else if f_size_name == "small" size.small else if f_size_name == "normal" size.normal else if f_size_name == "large" size.large else if f_size_name == "huge" size.huge else size.auto //} //-----------------------------------------------------------------------------------------------------------------------------------------------------// // - Generate alignment proverty form string //{ f_align(f_align_name) => if f_align_name == "left" text.align_left else if f_align_name == "right" text.align_right else text.align_center //} //-----------------------------------------------------------------------------------------------------------------------------------------------------//} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TABLE INITIALIZATION // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////{ //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // CREATE TABLE PROPERTY VALUE //{ var infoboard = table.new( position= pos_y_infoboard+"_"+pos_x_infoboard, columns= 50, rows= 200, border_color = color.new(border_color,border_trans), border_width = border_width, frame_color = color.new(frame_color,frame_trans), frame_width = frame_width, bgcolor= color.new(bgcolor,bgtrans) ) //} //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // CREATE HEADER TABLE COLUMNS ROWS. VALUE BACKGROUNG COLOR TEXT COLOR HORIZONTAL ALIGNMENT. TEXT SIZE VERTICAL ALIGNMENT //{ if barstate.isfirst and not hide_infoboard table.cell (table_id=infoboard, column=0, row=0, text="Factors", bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) table.cell (table_id=infoboard, column=1, row=0, text="Assets", bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) table.cell (table_id=infoboard, column=2, row=0, text="Res: "+res_1, bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) table.cell (table_id=infoboard, column=3, row=0, text="Res: "+res_2, bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) table.cell (table_id=infoboard, column=4, row=0, text="Res: "+res_3, bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) //} //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TECHNICAL RATINGS CALCULATION // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////{ StrongBound = 0.5 WeakBound = 0.1 count_rising(plot) => v_plot = plot > 0 ? plot : -plot var count = 0 if v_plot == 0 count := 0 else if v_plot >= v_plot[1] count := min(5, count + 1) else if v_plot < v_plot[1] count := max(1, count - 1) count f_position_condition(f_tradeSignal)=> f_poscond = f_tradeSignal > WeakBound f_negcond = f_tradeSignal < -WeakBound f_posseries = f_poscond ? f_tradeSignal : 0 f_negseries = f_negcond ? f_tradeSignal : 0 f_poscount = count_rising(f_posseries) f_negcount = count_rising(f_negseries) f_pc = f_poscond ? f_poscount : f_negcond ? f_negcount : 0 [f_poscond,f_negcond,f_posseries,f_negseries,f_poscount,f_negcount,f_pc] getTimeOfNextBar() => currentTime = time(timeframe.period) changeTime = change(currentTime) minChange = if (not na(changeTime)) var float minChange = changeTime minChange := min(minChange, changeTime) int(currentTime + minChange) calcRatingStatus(value) => if -StrongBound > value "Strong Sell" else if value < -WeakBound "Sell" else if value > StrongBound "Strong Buy" else if value > WeakBound "Buy" else "Neutral" getSignal(ratingTotal_1, ratingOther, ratingMA) => float _res = ratingTotal_1 if ratingSignal == "MAs" _res := ratingMA if ratingSignal == "Oscillators" _res := ratingOther _res f_color(f_tradeSignal)=> f_col_buy = color.from_gradient(f_tradeSignal, 0.0, 0.2, neutralcolor, poscol) f_col_sell = color.from_gradient(f_tradeSignal, -0.2, 0.0, negcol, neutralcolor) f_col_gradient = color.from_gradient(f_tradeSignal, -0.2, 0.2, f_col_sell, f_col_buy) f_col_gradient colorTransp(col, transp) => red = color.r(col) green = color.g(col) blue = color.b(col) color.rgb(red, green, blue, transp) // Awesome Oscillator AO() => sma(hl2, 5) - sma(hl2, 34) // Stochastic RSI StochRSI() => rsi1 = rsi(close, 14) K = sma(stoch(rsi1, rsi1, rsi1, 14), 3) D = sma(K, 3) [K, D] // Ultimate Oscillator tl() => close[1] < low ? close[1]: low uo(ShortLen, MiddlLen, LongLen) => Value1 = sum(tr, ShortLen) Value2 = sum(tr, MiddlLen) Value3 = sum(tr, LongLen) Value4 = sum(close - tl(), ShortLen) Value5 = sum(close - tl(), MiddlLen) Value6 = sum(close - tl(), LongLen) float UO = na if Value1 != 0 and Value2 != 0 and Value3 != 0 var0 = LongLen / ShortLen var1 = LongLen / MiddlLen Value7 = (Value4 / Value1) * (var0) Value8 = (Value5 / Value2) * (var1) Value9 = (Value6 / Value3) UO := (Value7 + Value8 + Value9) / (var0 + var1 + 1) UO // Ichimoku Cloud donchian(len) => avg(lowest(len), highest(len)) ichimoku_cloud() => conversionLine = donchian(9) baseLine = donchian(26) leadLine1 = avg(conversionLine, baseLine) leadLine2 = donchian(52) [conversionLine, baseLine, leadLine1, leadLine2] calcRatingMA(ma, src) => na(ma) or na(src) ? na : (ma == src ? 0 : ( ma < src ? 1 : -1 )) calcRating(buy, sell) => buy ? 1 : ( sell ? -1 : 0 ) f_drawInfo(f_ratingTotal,f_ratingOther,f_ratingMA,f_ratingOtherC,f_ratingMAC,f_tradeSignal)=> f_MAText = f_ratingMAC == 0 ? "" : calcRatingStatus(f_ratingMA) + "\n" f_OtherText = f_ratingOtherC == 0 ? "" : calcRatingStatus(f_ratingOther) + "\n" f_TotaText = calcRatingStatus(f_ratingTotal) [f_poscond,f_negcond,f_posseries,f_negseries,f_poscount,f_negcount,f_pc]= f_position_condition(f_tradeSignal) info_text= f_MAText+ f_OtherText + f_TotaText info_text calcRatingAll() => //============== MA ================= SMA10 = sma(close, 10) SMA20 = sma(close, 20) SMA30 = sma(close, 30) SMA50 = sma(close, 50) SMA100 = sma(close, 100) SMA200 = sma(close, 200) EMA10 = ema(close, 10) EMA20 = ema(close, 20) EMA30 = ema(close, 30) EMA50 = ema(close, 50) EMA100 = ema(close, 100) EMA200 = ema(close, 200) HullMA9 = hma(close, 9) // Volume Weighted Moving Average (VWMA) VWMA = vwma(close, 20) [IC_CLine, IC_BLine, IC_Lead1, IC_Lead2] = ichimoku_cloud() // ======= Other ============= // Relative Strength Index, RSI RSI = rsi(close,14) // Stochastic lengthStoch = 14 smoothKStoch = 3 smoothDStoch = 3 kStoch = sma(stoch(close, high, low, lengthStoch), smoothKStoch) dStoch = sma(kStoch, smoothDStoch) // Commodity Channel Index, CCI CCI = cci(close, 20) // Average Directional Index float adxValue = na, float adxPlus = na, float adxMinus = na [P, M, V] = dmi(14, 14) adxValue := V adxPlus := P adxMinus := M // Awesome Oscillator ao = AO() // Momentum Mom = mom(close, 10) // Moving Average Convergence/Divergence, MACD [macdMACD, signalMACD, _] = macd(close, 12, 26, 9) // Stochastic RSI [Stoch_RSI_K, Stoch_RSI_D] = StochRSI() // Williams Percent Range WR = wpr(14) // Bull / Bear Power BullPower = high - ema(close, 13) BearPower = low - ema(close, 13) // Ultimate Oscillator UO = uo(7,14,28) if not na(UO) UO := UO * 100 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// PriceAvg = ema(close, 50) DownTrend = close < PriceAvg UpTrend = close > PriceAvg // calculate trading recommendation based on SMA/EMA float ratingMA = 0 float ratingMAC = 0 if not na(SMA10) ratingMA := ratingMA + calcRatingMA(SMA10, close) ratingMAC := ratingMAC + 1 if not na(SMA20) ratingMA := ratingMA + calcRatingMA(SMA20, close) ratingMAC := ratingMAC + 1 if not na(SMA30) ratingMA := ratingMA + calcRatingMA(SMA30, close) ratingMAC := ratingMAC + 1 if not na(SMA50) ratingMA := ratingMA + calcRatingMA(SMA50, close) ratingMAC := ratingMAC + 1 if not na(SMA100) ratingMA := ratingMA + calcRatingMA(SMA100, close) ratingMAC := ratingMAC + 1 if not na(SMA200) ratingMA := ratingMA + calcRatingMA(SMA200, close) ratingMAC := ratingMAC + 1 if not na(EMA10) ratingMA := ratingMA + calcRatingMA(EMA10, close) ratingMAC := ratingMAC + 1 if not na(EMA20) ratingMA := ratingMA + calcRatingMA(EMA20, close) ratingMAC := ratingMAC + 1 if not na(EMA30) ratingMA := ratingMA + calcRatingMA(EMA30, close) ratingMAC := ratingMAC + 1 if not na(EMA50) ratingMA := ratingMA + calcRatingMA(EMA50, close) ratingMAC := ratingMAC + 1 if not na(EMA100) ratingMA := ratingMA + calcRatingMA(EMA100, close) ratingMAC := ratingMAC + 1 if not na(EMA200) ratingMA := ratingMA + calcRatingMA(EMA200, close) ratingMAC := ratingMAC + 1 if not na(HullMA9) ratingHullMA9 = calcRatingMA(HullMA9, close) ratingMA := ratingMA + ratingHullMA9 ratingMAC := ratingMAC + 1 if not na(VWMA) ratingVWMA = calcRatingMA(VWMA, close) ratingMA := ratingMA + ratingVWMA ratingMAC := ratingMAC + 1 float ratingIC = na if not (na(IC_Lead1) or na(IC_Lead2) or na(close) or na(close[1]) or na(IC_BLine) or na(IC_CLine)) ratingIC := calcRating( IC_Lead1 > IC_Lead2 and close > IC_Lead1 and close < IC_BLine and close[1] < IC_CLine and close > IC_CLine, IC_Lead2 > IC_Lead1 and close < IC_Lead2 and close > IC_BLine and close[1] > IC_CLine and close < IC_CLine) if not na(ratingIC) ratingMA := ratingMA + ratingIC ratingMAC := ratingMAC + 1 ratingMA := ratingMAC > 0 ? ratingMA / ratingMAC : na float ratingOther = 0 float ratingOtherC = 0 ratingRSI = RSI if not(na(ratingRSI) or na(ratingRSI[1])) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + calcRating(ratingRSI < 30 and ratingRSI[1] < ratingRSI, ratingRSI > 70 and ratingRSI[1] > ratingRSI) if not(na(kStoch) or na(dStoch) or na(kStoch[1]) or na(dStoch[1])) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + calcRating(kStoch < 20 and dStoch < 20 and kStoch > dStoch and kStoch[1] < dStoch[1], kStoch > 80 and dStoch > 80 and kStoch < dStoch and kStoch[1] > dStoch[1]) ratingCCI = CCI if not(na(ratingCCI) or na(ratingCCI[1])) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + calcRating(ratingCCI < -100 and ratingCCI > ratingCCI[1], ratingCCI > 100 and ratingCCI < ratingCCI[1]) if not(na(adxValue) or na(adxPlus[1]) or na(adxMinus[1]) or na(adxPlus) or na(adxMinus)) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + calcRating(adxValue > 20 and adxPlus[1] < adxMinus[1] and adxPlus > adxMinus, adxValue > 20 and adxPlus[1] > adxMinus[1] and adxPlus < adxMinus) if not(na(ao) or na(ao[1])) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + calcRating(crossover(ao,0) or (ao > 0 and ao[1] > 0 and ao > ao[1] and ao[2] > ao[1]), crossunder(ao,0) or (ao < 0 and ao[1] < 0 and ao < ao[1] and ao[2] < ao[1])) if not(na(Mom) or na(Mom[1])) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + calcRating(Mom > Mom[1], Mom < Mom[1]) if not(na(macdMACD) or na(signalMACD)) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + calcRating(macdMACD > signalMACD, macdMACD < signalMACD) float ratingStoch_RSI = na if not(na(DownTrend) or na(UpTrend) or na(Stoch_RSI_K) or na(Stoch_RSI_D) or na(Stoch_RSI_K[1]) or na(Stoch_RSI_D[1])) ratingStoch_RSI := calcRating( DownTrend and Stoch_RSI_K < 20 and Stoch_RSI_D < 20 and Stoch_RSI_K > Stoch_RSI_D and Stoch_RSI_K[1] < Stoch_RSI_D[1], UpTrend and Stoch_RSI_K > 80 and Stoch_RSI_D > 80 and Stoch_RSI_K < Stoch_RSI_D and Stoch_RSI_K[1] > Stoch_RSI_D[1]) if not na(ratingStoch_RSI) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + ratingStoch_RSI float ratingWR = na if not(na(WR) or na(WR[1])) ratingWR := calcRating(WR < -80 and WR > WR[1], WR > -20 and WR < WR[1]) if not na(ratingWR) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + ratingWR float ratingBBPower = na if not(na(UpTrend) or na(DownTrend) or na(BearPower) or na(BearPower[1]) or na(BullPower) or na(BullPower[1])) ratingBBPower := calcRating( UpTrend and BearPower < 0 and BearPower > BearPower[1], DownTrend and BullPower > 0 and BullPower < BullPower[1]) if not na(ratingBBPower) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + ratingBBPower float ratingUO = na if not(na(UO)) ratingUO := calcRating(UO > 70, UO < 30) if not na(ratingUO) ratingOtherC := ratingOtherC + 1 ratingOther := ratingOther + ratingUO ratingOther := ratingOtherC > 0 ? ratingOther / ratingOtherC : na float ratingTotal = 0 float ratingTotalC = 0 if not na(ratingMA) ratingTotal := ratingTotal + ratingMA ratingTotalC := ratingTotalC + 1 if not na(ratingOther) ratingTotal := ratingTotal + ratingOther ratingTotalC := ratingTotalC + 1 ratingTotal := ratingTotalC > 0 ? ratingTotal / ratingTotalC : na [ratingTotal,ratingOther,ratingMA,ratingOtherC,ratingMAC] f_security(f_tickerid, f_resolution)=> [ratingTotal_low,ratingOther_low,ratingMA_low,ratingOtherC_low,ratingMAC_low]=security(f_tickerid, f_resolution, calcRatingAll()) //} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // SECURITY CALL AND UPDATE TABLE // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////{ f_fill_table(f_ticker,i)=> [ratingTotal_low,ratingOther_low,ratingMA_low,ratingOtherC_low,ratingMAC_low]= security(f_ticker, res_1, calcRatingAll()) [ratingTotal_mid,ratingOther_mid,ratingMA_mid,ratingOtherC_mid,ratingMAC_mid]= security(f_ticker, res_2, calcRatingAll()) [ratingTotal_high,ratingOther_high,ratingMA_high,ratingOtherC_high,ratingMAC_high]= security(f_ticker, res_3, calcRatingAll()) tradeSignal_low = getSignal(ratingTotal_low, ratingOther_low, ratingMA_low) info_text_low = f_drawInfo(ratingTotal_low,ratingOther_low,ratingMA_low,ratingOtherC_low,ratingMAC_low,tradeSignal_low) col_gradient_low = f_color(tradeSignal_low) tradeSignal_mid = getSignal(ratingTotal_mid, ratingOther_mid, ratingMA_mid) info_text_mid = f_drawInfo(ratingTotal_mid,ratingOther_mid,ratingMA_mid,ratingOtherC_mid,ratingMAC_mid,tradeSignal_mid) col_gradient_mid = f_color(tradeSignal_mid) tradeSignal_high = getSignal(ratingTotal_high, ratingOther_high, ratingMA_high) info_text_high = f_drawInfo(ratingTotal_high,ratingOther_high,ratingMA_high,ratingOtherC_high,ratingMAC_high,tradeSignal_high) col_gradient_high = f_color(tradeSignal_high) f_ticker_id=str.replace_all(f_ticker,"BINANCE:","") ci=floor((i-1)/tbl_rows)*4 ri=i-int((i-1)/tbl_rows)*tbl_rows if ci==0 table.cell (table_id=infoboard, column=0, row=i, text="Moving Averages\nOscillators\nAll", bgcolor=color.new(color.silver,bgtrans_r), text_color=color.new(font_color_r,font_trans_r), text_halign=text.align_left, text_size=f_size(font_size_r), text_valign=text.align_center) if i==1 for tbl_c=0 to tbl_columns-1 table.cell (table_id=infoboard, column=tbl_c*4+1, row=0, text="Assets", bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) table.cell (table_id=infoboard, column=tbl_c*4+2, row=0, text="Res: "+res_1, bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) table.cell (table_id=infoboard, column=tbl_c*4+3, row=0, text="Res: "+res_2, bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) table.cell (table_id=infoboard, column=tbl_c*4+4, row=0, text="Res: "+res_3, bgcolor=color.new(bgcolor_c,bgtrans_c), text_color=color.new(font_color_c,font_trans_c), text_halign=f_align(halign_c), text_size=f_size(font_size_c), text_valign=text.align_center) //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // CREATE HEADER TABLE COLUMNS ROWS VALUE BACKGROUNG COLOR TEXT COLOR HORIZONTAL ALIGNMENT. TEXT SIZE VERTICAL ALIGNMENT ROW STEP //{ table.cell (table_id=infoboard, column=ci+1, row=ri, text=f_ticker_id, bgcolor=color.new(bgcolor_r,bgtrans_r), text_color=color.new(font_color_r,font_trans_r), text_halign=f_align(halign_r), text_size=f_size(font_size_r), text_valign=text.align_center) table.cell (table_id=infoboard, column=ci+2, row=ri, text=info_text_low, bgcolor=col_gradient_low, text_color=color.new(font_color,font_trans), text_halign=f_align(halign), text_size=f_size(font_size), text_valign=text.align_center) table.cell (table_id=infoboard, column=ci+3, row=ri, text=info_text_mid, bgcolor=col_gradient_mid, text_color=color.new(font_color,font_trans), text_halign=f_align(halign), text_size=f_size(font_size), text_valign=text.align_center) table.cell (table_id=infoboard, column=ci+4, row=ri, text=info_text_high, bgcolor=col_gradient_high, text_color=color.new(font_color,font_trans), text_halign=f_align(halign), text_size=f_size(font_size), text_valign=text.align_center) //} //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ASSET CALLS // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////{ if barstate.islast and not hide_infoboard for i = 1 to 12 if i==1 f_fill_table(asset_01,i) else if i==2 f_fill_table(asset_02,i) else if i==3 f_fill_table(asset_03,i) else if i==4 f_fill_table(asset_04,i) else if i==5 f_fill_table(asset_05,i) else if i==6 f_fill_table(asset_06,i) else if i==7 f_fill_table(asset_07,i) else if i==8 f_fill_table(asset_08,i) else if i==9 f_fill_table(asset_09,i) else if i==10 f_fill_table(asset_10,i) else if i==11 f_fill_table(asset_11,i) else if i==12 f_fill_table(asset_12,i) //}
FX Profit Calculator
https://www.tradingview.com/script/L1Myn2YT/
only_fibonacci
https://www.tradingview.com/u/only_fibonacci/
371
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © only_fibonacci //@version=5 indicator("FX Profit Calculator",overlay=true) standart= 1 tp = input.price(title = "TP",confirm=true,defval =standart) buyOrder = input.price(title = "Order",confirm=true,defval =standart) sl = input.price(title = "SL",defval=standart,confirm=true) lot = input.float(defval=0.1,title="LOT",minval=0.001,step=0.002) unit=100000*lot gap = math.abs(tp-buyOrder) variable_profit= gap*unit buy = tp>buyOrder and buyOrder>sl sell = tp<buyOrder and buyOrder<sl percent=input.int(defval=3,step=1,minval=1,title="Percent") float multiplier = (100+percent)/100 leverage = input.int(defval=100,step=10,title="Leverage") isParity(parity)=> parity==currency.USD ? 1 : request.security(parity+currency.USD,"D",close) guarantee = unit*isParity(syminfo.basecurrency)/leverage basePrice= isParity(syminfo.currency) profit=variable_profit*basePrice stop = buy ? (sl-buyOrder)*unit*basePrice : (buyOrder-sl)*unit*basePrice openPosition = input.bool(false,title = "Is the position open?") status = buy ? (close-buyOrder)*unit*basePrice : (buyOrder-close)*unit*basePrice string orderType = buy ? "BUY" : sell ? "SELL" : "" if barstate.islast if tp<close*multiplier and sl>close/multiplier and (buy or sell) tpline=line.new(x1=bar_index[10],y1=tp,x2=bar_index,y2=tp,color=color.green,extend=extend.right,width=2) slline=line.new(x1=bar_index[10],y1=sl,x2=bar_index,y2=sl,color=color.red,extend=extend.right,width=2) boline=line.new(x1=bar_index[10],y1=buyOrder,x2=bar_index,y2=buyOrder,color=color.purple,extend=extend.right,width=2) var label = label.new(bar_index+20, tp, text="Profit : "+str.tostring(profit), style=label.style_label_lower_left,color=color.black,textcolor=color.white) var label2 = label.new(bar_index+20, sl, text="Stop : "+str.tostring(stop), style=label.style_label_lower_left,color=color.black,textcolor=color.white) var label3 = label.new(bar_index+20, buyOrder, text="Order : "+str.tostring(buyOrder)+"\nGuarantee : "+str.tostring(guarantee)+"\nPosition SIDE : "+orderType, style=label.style_label_lower_left,color=color.black,textcolor=color.white) if openPosition and (buy or sell) poslabel = label.new(bar_index+50, buyOrder, text="Status : "+str.tostring(status), style=label.style_label_lower_left,color=color.black,textcolor=status<0 ? color.red : color.green) else if tp>close*multiplier or sl<close/multiplier or (buy==false and sell==false) var label1 = label.new(bar_index+20, low, text="Please Update Indicator Settings", style=label.style_label_lower_left,color=color.black,textcolor=color.white)
Donchian Range, RSI, and Levels System
https://www.tradingview.com/script/QqSV1nO2-Donchian-Range-RSI-and-Levels-System/
animecummer
https://www.tradingview.com/u/animecummer/
137
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 indicator('Donchian RSI and Support & Resistance Levels Ribbon System', shorttitle='Donchian Ribbon', overlay=true, timeframe="", timeframe_gaps=true) //DONCHIAN MA donchian(_length) => math.avg(ta.lowest(_length), ta.highest(_length)) //input donchianon = input(true, 'Donchian Channel on?', inline="0", group='Donchian Channel') dclength = input.int(20, minval=2, inline="0", title="", group='Donchian Channel') donchianrainbow2 = input(false, 'RSI Rainbow?', inline="0", group='Donchian Channel') color regularfill = input.color(color.rgb(33, 150, 243, 0), '', group='Donchian Channel', inline='00') color uplim = input.color(color.new(color.red, 0), '', group='Donchian Channel', inline='00') color dnlim = input.color(color.new(color.green, 0), '', group='Donchian Channel', inline='00') transparencyvalue2 = input.int(95, minval=0, maxval=100, title="Channel Fill Transparency", group='Donchian Channel', inline='00') ribbonon = input(true, 'Donchian Ribbon on?', inline="0", group='Donchian Moving Average Ribbon') donchianrainbow = input(true, 'RSI Rainbow?', inline="0", group='Donchian Moving Average Ribbon') color bullma = input.color(color.new(#26a69a, 50), '', inline='00', group='Donchian Moving Average Ribbon') color bearma = input.color(color.new(#ff5252, 50), '', inline='00', group='Donchian Moving Average Ribbon') transparencyvaluema = input.int(50, minval=0, maxval=100, title="                    Ribbon Transparency", group='Donchian Moving Average Ribbon', inline='00') transparencyvalue = if ribbonon == true transparencyvaluema else 100 len2=input(2, inline='00') len3=input(3, inline='00') len4=input(4, inline='00') len5=input(5, inline='01') len6=input(6, inline='01') len7=input(7, inline='01') len8=input(8, inline='02') len9=input(9, inline='02') len10=input(10, inline='02') len11=input(11, inline='03') len12=input(12, inline='03') len13=input(13, inline='03') len14=input(14, inline='04') len15=input(15, inline='04') len16=input(16, inline='04') len17=input(17, inline='05') len18=input(18, inline='05') len19=input(19, inline='05') len20=input(20, inline='06') len21=input(21, inline='06') len22=input(22, inline='06') don2=donchian(len2) don3=donchian(len3) don4=donchian(len4) don5=donchian(len5) don6=donchian(len6) don7=donchian(len7) don8=donchian(len8) don9=donchian(len9) don10=donchian(len10) don11=donchian(len11) don12=donchian(len12) don13=donchian(len13) don14=donchian(len14) don15=donchian(len15) don16=donchian(len16) don17=donchian(len17) don18=donchian(len18) don19=donchian(len19) don20=donchian(len20) don21=donchian(len21) don22=donchian(len22) //grad var grad = array.new_color(na) if barstate.isfirst array.push(grad, color.new(color.gray, transparencyvalue)) array.push(grad, color.new(#800080, transparencyvalue)) array.push(grad, color.new(#890089, transparencyvalue)) array.push(grad, color.new(#910091, transparencyvalue)) array.push(grad, color.new(#9a009a, transparencyvalue)) array.push(grad, color.new(#a300a3, transparencyvalue)) array.push(grad, color.new(#ab00ab, transparencyvalue)) array.push(grad, color.new(#b400b4, transparencyvalue)) array.push(grad, color.new(#bd00bd, transparencyvalue)) array.push(grad, color.new(#c700c7, transparencyvalue)) array.push(grad, color.new(#d000d0, transparencyvalue)) array.push(grad, color.new(#d900d9, transparencyvalue)) array.push(grad, color.new(#e200e2, transparencyvalue)) array.push(grad, color.new(#ec00ec, transparencyvalue)) array.push(grad, color.new(#f500f5, transparencyvalue)) array.push(grad, color.new(#ff00ff, transparencyvalue)) array.push(grad, color.new(#ff00f0, transparencyvalue)) array.push(grad, color.new(#ff00e1, transparencyvalue)) array.push(grad, color.new(#ff00d2, transparencyvalue)) array.push(grad, color.new(#ff00c4, transparencyvalue)) array.push(grad, color.new(#ff00b7, transparencyvalue)) array.push(grad, color.new(#ff00aa, transparencyvalue)) array.push(grad, color.new(#ff009d, transparencyvalue)) array.push(grad, color.new(#ff0091, transparencyvalue)) array.push(grad, color.new(#ff0086, transparencyvalue)) array.push(grad, color.new(#ff187c, transparencyvalue)) array.push(grad, color.new(#ff2972, transparencyvalue)) array.push(grad, color.new(#ff3669, transparencyvalue)) array.push(grad, color.new(#ff4160, transparencyvalue)) array.push(grad, color.new(#ff4a59, transparencyvalue)) array.push(grad, color.new(#ff5252, transparencyvalue)) array.push(grad, color.new(#ff5a4e, transparencyvalue)) array.push(grad, color.new(#ff624a, transparencyvalue)) array.push(grad, color.new(#ff6a45, transparencyvalue)) array.push(grad, color.new(#ff7240, transparencyvalue)) array.push(grad, color.new(#ff7b3b, transparencyvalue)) array.push(grad, color.new(#ff8336, transparencyvalue)) array.push(grad, color.new(#ff8c30, transparencyvalue)) array.push(grad, color.new(#ff942a, transparencyvalue)) array.push(grad, color.new(#ff9d23, transparencyvalue)) array.push(grad, color.new(#ffa61c, transparencyvalue)) array.push(grad, color.new(#ffaf12, transparencyvalue)) array.push(grad, color.new(#ffb805, transparencyvalue)) array.push(grad, color.new(#ffc100, transparencyvalue)) array.push(grad, color.new(#ffca00, transparencyvalue)) array.push(grad, color.new(#ffd300, transparencyvalue)) array.push(grad, color.new(#ffdc00, transparencyvalue)) array.push(grad, color.new(#ffe500, transparencyvalue)) array.push(grad, color.new(#ffed00, transparencyvalue)) array.push(grad, color.new(#fff600, transparencyvalue)) array.push(grad, color.new(#ffff00, transparencyvalue)) array.push(grad, color.new(#eefd1d, transparencyvalue)) array.push(grad, color.new(#ddfb2d, transparencyvalue)) array.push(grad, color.new(#ccf83a, transparencyvalue)) array.push(grad, color.new(#bcf546, transparencyvalue)) array.push(grad, color.new(#adf150, transparencyvalue)) array.push(grad, color.new(#9eee59, transparencyvalue)) array.push(grad, color.new(#8fea62, transparencyvalue)) array.push(grad, color.new(#81e66a, transparencyvalue)) array.push(grad, color.new(#74e172, transparencyvalue)) array.push(grad, color.new(#66dc79, transparencyvalue)) array.push(grad, color.new(#5ad87f, transparencyvalue)) array.push(grad, color.new(#4dd385, transparencyvalue)) array.push(grad, color.new(#41cd8a, transparencyvalue)) array.push(grad, color.new(#36c88f, transparencyvalue)) array.push(grad, color.new(#2cc393, transparencyvalue)) array.push(grad, color.new(#24bd96, transparencyvalue)) array.push(grad, color.new(#1fb798, transparencyvalue)) array.push(grad, color.new(#1eb299, transparencyvalue)) array.push(grad, color.new(#21ac9a, transparencyvalue)) array.push(grad, color.new(#26a69a, transparencyvalue)) array.push(grad, color.new(#26aca0, transparencyvalue)) array.push(grad, color.new(#26b1a6, transparencyvalue)) array.push(grad, color.new(#25b7ad, transparencyvalue)) array.push(grad, color.new(#24bdb3, transparencyvalue)) array.push(grad, color.new(#24c3ba, transparencyvalue)) array.push(grad, color.new(#23c9c0, transparencyvalue)) array.push(grad, color.new(#21cfc7, transparencyvalue)) array.push(grad, color.new(#20d5ce, transparencyvalue)) array.push(grad, color.new(#1edbd4, transparencyvalue)) array.push(grad, color.new(#1be1db, transparencyvalue)) array.push(grad, color.new(#18e7e2, transparencyvalue)) array.push(grad, color.new(#15ede9, transparencyvalue)) array.push(grad, color.new(#10f3f0, transparencyvalue)) array.push(grad, color.new(#09f9f8, transparencyvalue)) array.push(grad, color.new(#00ffff, transparencyvalue)) array.push(grad, color.new(#00f5ff, transparencyvalue)) array.push(grad, color.new(#00ebff, transparencyvalue)) array.push(grad, color.new(#00e1ff, transparencyvalue)) array.push(grad, color.new(#00d6ff, transparencyvalue)) array.push(grad, color.new(#00cbff, transparencyvalue)) array.push(grad, color.new(#00bfff, transparencyvalue)) array.push(grad, color.new(#00b3ff, transparencyvalue)) array.push(grad, color.new(#00a6ff, transparencyvalue)) array.push(grad, color.new(#0099ff, transparencyvalue)) array.push(grad, color.new(#008aff, transparencyvalue)) array.push(grad, color.new(#007bff, transparencyvalue)) array.push(grad, color.new(#0069ff, transparencyvalue)) array.push(grad, color.new(#0055ff, transparencyvalue)) array.push(grad, color.new(#003bff, transparencyvalue)) array.push(grad, color.new(#0000ff, transparencyvalue)) lower = ta.lowest(dclength) upper = ta.highest(dclength) dma = math.round(math.avg(lower, upper)) rsival = math.round(ta.rsi(dma, dclength)) gradcolor = array.get(grad, rsival) basecolor = donchianrainbow2 ? color.new(gradcolor, 0) : regularfill //envelopes plots dc1 = plot(donchianon ? upper : na, title='Upper Channel Limit', color=donchianrainbow2 ? color.new(basecolor, 0) : uplim, linewidth=1, style=plot.style_stepline) dc2 = plot(donchianon ? lower : na, title='Lower Channel Limit', color=donchianrainbow2 ? color.new(basecolor, 0) : dnlim, linewidth=1, style=plot.style_stepline) dcfill = color.new(gradcolor, transparencyvalue2) dccolor = donchianrainbow2 ? color.new(dcfill, 95) : regularfill fill(dc1, dc2, color=color.new(dccolor, transparencyvalue2), title='Fill') p2 = plot(don2, title='Donchian 2', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don2, len2) / 1)) : don2 >= don2[1] ? bullma : bearma) p3 = plot(don3, title='Donchian 3', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don3, len3) / 1)) : don3 >= don3[1] ? bullma : bearma) p4 = plot(don4, title='Donchian 4', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don4, len4) / 1)) : don4 >= don4[1] ? bullma : bearma) p5 = plot(don5, title='Donchian 5', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don5, len5) / 1)) : don5 >= don5[1] ? bullma : bearma) p6 = plot(don6, title='Donchian 6', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don6, len6) / 1)) : don6 >= don6[1] ? bullma : bearma) p7 = plot(don7, title='Donchian 7', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don7, len7) / 1)) : don7 >= don7[1] ? bullma : bearma) p8 = plot(don8, title='Donchian 8', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don8, len8) / 1)) : don8 >= don8[1] ? bullma : bearma) p9 = plot(don9, title='Donchian 9', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don9, len9) / 1)) : don9 >= don9[1] ? bullma : bearma) p10 = plot(don10, title='Donchian 10', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don10, len10) / 1)) : don10 >= don10[1] ? bullma : bearma) p11 = plot(don11, title='Donchian 11', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don11, len11) / 1)) : don11 >= don11[1] ? bullma : bearma) p12 = plot(don12, title='Donchian 12', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don12, len12) / 1)) : don12 >= don12[1] ? bullma : bearma) p13 = plot(don13, title='Donchian 13', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don13, len13) / 1)) : don13 >= don13[1] ? bullma : bearma) p14 = plot(don14, title='Donchian 14', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don14, len14) / 1)) : don14 >= don14[1] ? bullma : bearma) p15 = plot(don15, title='Donchian 15', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don15, len15) / 1)) : don15 >= don15[1] ? bullma : bearma) p16 = plot(don16, title='Donchian 16', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don16, len16) / 1)) : don16 >= don16[1] ? bullma : bearma) p17 = plot(don17, title='Donchian 17', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don17, len17) / 1)) : don17 >= don17[1] ? bullma : bearma) p18 = plot(don18, title='Donchian 18', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don18, len18) / 1)) : don18 >= don18[1] ? bullma : bearma) p19 = plot(don19, title='Donchian 19', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don19, len19) / 1)) : don19 >= don19[1] ? bullma : bearma) p20 = plot(don20, title='Donchian 20', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don20, len20) / 1)) : don20 >= don20[1] ? bullma : bearma) p21 = plot(don21, title='Donchian 21', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don21, len21) / 1)) : don21 >= don21[1] ? bullma : bearma) p22 = plot(don22, title='Donchian 22', linewidth=1, color = donchianrainbow ? array.get(grad, math.round(ta.rsi(don22, len22) / 1)) : don22 >= don22[1] ? bullma : bearma)
Session Levels - Ultimate Range Indicator
https://www.tradingview.com/script/KHHBUpqy-Session-Levels-Ultimate-Range-Indicator/
ArdOfCrypto
https://www.tradingview.com/u/ArdOfCrypto/
805
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ArdOfCrypto //@version=5 indicator("Session Levels", overlay=true, max_bars_back=1000, max_lines_count=500, max_labels_count=500, max_boxes_count=50) // Sessions and inputs i_timezone = input.string(defval="America/Chicago", title="Timezone Selection", options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Exchange Timezone, or your own. Whatever works best for you.") i_GlobexSession = input.session(title="Globex", defval="1700-0830", group="Session Settings", inline="GS") // Globex (Overnight) Session, Monday - Friday 17:00 - 0830. Globex opens at 5pm CST and closes when the US session starts 8:30CST. i_GlobexSessionCol = input.color(title="Session",tooltip="Globex Session Highlight Color", defval=color.silver, group="Session Settings", inline="GS") // Globex (Overnight) Session, color setting for background highlights i_GlobexLevelCol = input.color(title="Levels",tooltip="Globex Levels Color", defval=color.gray, group="Session Settings", inline="GS") // Globex (Overnight) Session, color setting for level lines i_AsianSession = input.session(title="Asian", defval="1900-0200", group="Session Settings", inline="AS") // Asian Session, Monday - Friday i_AsianSessionCol = input.color(title="Session",tooltip="Asian Session Highlight Color", defval=color.white, group="Session Settings", inline="AS") // Asian Session, color setting for background highlights, 1st hr box and High and Low lines i_AsianLevelCol = input.color(title="Levels",tooltip="Asian Levels Color", defval=color.gray, group="Session Settings", inline="AS") // Asian Session, color setting for level lines i_LondonSession = input.session(title="London", defval="0300-1100", group="Session Settings", inline="LS") // London Session, Monday - Friday i_LondonSessionCol = input.color(title="Session",tooltip="London Session Highlight Color", defval=color.green, group="Session Settings", inline="LS") // London Session, color setting for background highlights, 1st hr box and High and Low lines i_LondonLevelCol = input.color(title="Levels",tooltip="London Levels Color", defval=color.gray, group="Session Settings", inline="LS") // London Session, color setting for level lines i_NewYorkSession = input.session(title="New York", defval="0800-1600", group="Session Settings", inline="NY") // New York Session i_NYSessionCol = input.color(title="Session",tooltip="New York Session Highlight Color", defval=color.blue, group="Session Settings", inline="NY") // New York Session, color setting for background highlights, 1st hr box and High and Low lines i_NYLevelCol = input.color(title="Levels",tooltip="New York Level Color", defval=color.gray, group="Session Settings", inline="NY") // New York Session, color setting for level lines i_NewYorkORoffset = input.int(title="New York Open Offset", tooltip="New York Session Opening Range Starts after x minutes", defval=30, minval=0, maxval=59, group="Session Settings") // New York Opening Range Initial Balance Opening Minute i_NYSessionEndHour = input.int(title="NY CashSession End Hour", defval=16, minval=0, maxval=23, group="Session Settings", inline="NYE") // New York Session Opening Hour i_NYSessionEndMin = input.int(title="Min.", defval=59, minval=0, maxval=59, group="Session Settings", inline="NYE", tooltip="This is where all the lines and drawings end. Must be Less than the start of Globex") // New York Session Opening Minute GlobexSession = time(timeframe.period, i_GlobexSession, i_timezone) // Calculate time for the Globex/Overnight session. AsianSession = time(timeframe.period, i_AsianSession, i_timezone) // Calculate time for the Asian Session. LondonSession = time(timeframe.period, i_LondonSession, i_timezone) // Calculate time for the London Session. NewYorkSession = time(timeframe.period, i_NewYorkSession, i_timezone) // Calculate time for the New York Session. var CashSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) srcHi = input(high, "Source for Highs", inline="Sources", group="Source") // Set Source for Highs used in calculations srcLo = input(low, "Source for Lows", inline="Sources", group="Source") // Set Source for Lows used in calculations showGlobex = input.bool(defval=true, title="Globex Overnight", tooltip="Show Globex Background Highlight", group="Session Highlight") showAsian = input.bool(defval=false, title="Asian", tooltip="Show Asian Background Highlight", group="Session Highlight") showLondon = input.bool(defval=false, title="London", tooltip="Show London Background Highlight", group="Session Highlight") showNewYork = input.bool(defval=true, title="New York", tooltip="Show NY Background Highlight", group="Session Highlight") showOpenbar = input.bool(defval=true, title="NY IB Opening Bar", tooltip="Show bar before the NY Initial Balance Highlight", group="Session Highlight") showGlobexDrawings = input.bool(defval=true, title="Show Globex/Overnight Levels", tooltip="Show Globex/Overnight Drawings", group="Drawings") showGlobexTodayDraw = input.bool(defval=true, title="Show Globex Todays Drawings Only", tooltip="Removes all historic drawings for cleaner charts", group="Drawings") showAsianDrawings = input.bool(defval=false, title="Show Asian Levels", tooltip="Show Asian Session Drawings ", group="Drawings") showAsianTodayDraw = input.bool(defval=false, title="Show Asian Todays Drawings Only", tooltip="Removes all historic drawings for cleaner charts", group="Drawings") showAsianOR = input.bool(defval=false, title="Show Asian Opening Range", tooltip="Show Asian Session Initial Balance Box ", group="Drawings") showAsianORStdev = input.bool(defval=false, title="Show Asian OR STDEV Projections", tooltip="Show Asian Standard Deviation Levels and Labels on Opening Range", group="Drawings") showLondonDrawings = input.bool(defval=false, title="Show London Levels", tooltip="Show London Session Drawings ", group="Drawings") showLondonTodayDraw = input.bool(defval=false, title="Show London Todays Drawings Only", tooltip="Removes all historic drawings for cleaner charts", group="Drawings") showLondonOR = input.bool(defval=false, title="Show London Opening Range", tooltip="Show London Session Initial Balance Box ", group="Drawings") showLondonORStdev = input.bool(defval=false, title="Show London OR STDEV Projections", tooltip="Show London Standard Deviation Levels and Labels on Opening Range", group="Drawings") showNewYorkDrawings = input.bool(defval=true, title="Show New York Levels", tooltip="Show New York Session Session Drawings ", group="Drawings") showNewYorkTodayDraw= input.bool(defval=false, title="Show New York Todays Drawings Only", tooltip="Removes all historic drawings for cleaner charts", group="Drawings") showNewYorkOR = input.bool(defval=true, title="Show New York Opening Range", tooltip="Show New York Session Initial Balance Box ", group="Drawings") showNewYorkORStdev = input.bool(defval=false, title="Show New York OR STDEV Projections", tooltip="Show New York Standard Deviation Levels and Labels on Opening Range", group="Drawings") enableNewYorkalarms = input.bool(defval=false, title="Enable Alarms for the NY Session", tooltip="Alarms when price crosses: Globex Hi and Low; Hi, Lo, 50% OR Levels and 0.5 and 1.0 STDEV Levels", group="Alarms") showLabels = input.bool(defval=true, title="Show labels on Level Lines ", tooltip="Show Session Labels on every line", group="Drawings") showPDO = input.bool(defval=false, title="Show Previous Day Open - ", tooltip="Show Previous Days's Open line", group="HTF Levels", inline="PDO") i_PDOcol = input.color(title="Color", tooltip="Previous Day Open Line Color", defval=color.white, group="HTF Levels", inline="PDO") showPDC = input.bool(defval=true, title="Show Previous Day Close - ", tooltip="Show Previous Days's Closing line", group="HTF Levels", inline="PDC") i_PDCcol = input.color(title="Color", tooltip="Previous Day Close Line Color", defval=color.orange, group="HTF Levels", inline="PDC") showPWO = input.bool(defval=true, title="Show Previous Week Open - ", tooltip="Show Previous Week's Opening price line", group="HTF Levels", inline="PWO") i_PWOcol = input.color(title="Color", tooltip="Previous Week Open Line Color", defval=color.lime, group="HTF Levels", inline="PWO") showPWC = input.bool(defval=false, title="Show Previous Week Close - ", tooltip="Show Previous Week's Closing line", group="HTF Levels", inline="PWC") i_PWCcol = input.color(title="Color", tooltip="Previous Week Close Line Color", defval=color.purple, group="HTF Levels", inline="PWC") showHTFLabels = input.bool(defval=true, title="Show Labels on HTF Levels", tooltip="Show Labels on Previous HTF Levels", group="HTF Levels") showDebug = input.bool(defval=false, title="Show Debug Value Plots", tooltip="View values in the data window", group="Debug Settings") // Toggle display of debugging information via plots showDebugLabels = input.bool(defval=false, title="Show Debugging Labels", tooltip="View values in labels above certain candles", group="Debug Settings") // Toggle display of debugging information in labels // Get HTF Values PreviousDayClose = request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on) // Get the Previous Day's closing price PreviousDayOpen = request.security(syminfo.tickerid, "D", open[1], lookahead = barmerge.lookahead_on) // Get the Previous Day's opening price PreviousWeekClose = request.security(syminfo.tickerid, "W", close[1], lookahead = barmerge.lookahead_on) // Get the Previous Week's closing price PreviousWeekOpen = request.security(syminfo.tickerid, "W", open[1], lookahead = barmerge.lookahead_on) // Get the Previous Week's opening price // Set variables for the sessions // Globex Overnight session var float Globex_hi = na // High for the Globex Session var float Globex_75 = na // 75% level for the Globex Session var float Globex_50 = na // 50% level for the Globex Session var float Globex_25 = na // 25% level for the Globex Session var float Globex_lo = na // Low for the Globex Session var Globex_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex High line var Globex_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex 75% line var Globex_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex 50% line var Globex_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex 25% line var Globex_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol) // Globex Low line var GlobexHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var Globex75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var Globex50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var Globex25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var GlobexLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var GlobexSessionStart = time // To register the timestap when the Globex Overnight Session begins // Asian Session var float Asian_hi = na // High for the Asian Session var float Asian_75 = na // 75% level for the Asian Session var float Asian_50 = na // 50% level for the Asian Session var float Asian_25 = na // 25% level for the Asian Session var float Asian_lo = na // Low for the Asian Session var Asian_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian High line var Asian_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian 75% line var Asian_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian 50% line var Asian_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian 25% line var Asian_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian Low line var AsianHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var Asian75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var Asian50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var Asian25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianSessionStart = time // To register the timestap when the Asian Session begins var AsianORStart = time var AsianOREnd = time + 3600000 // Add one hour in milliseconds // Asian Opening Range (1st Hour) var float AsianHr1hi = na // High for the 1st Hour Session var float AsianHr1mid = na // 50% of the 1st Hour Session var float AsianHr1lo = na // Low for the 1st Hour Session var AsianOR_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range High var AsianOR_line_mid = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range Middle var AsianOR_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range Low var AsianOR_line_hi05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal ) // Opening Range High 0.5 STDEV of OR var AsianOR_line_hi10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR var AsianOR_line_hi15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR var AsianOR_line_hi175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR var AsianOR_line_hi20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR var AsianOR_line_hi225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR var AsianOR_line_hi25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR var AsianOR_line_hi30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR var AsianOR_line_lo05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon ) // Opening Range Low 0.5 STDEV of OR var AsianOR_line_lo10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR var AsianOR_line_lo15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR var AsianOR_line_lo175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR var AsianOR_line_lo20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR var AsianOR_line_lo225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR var AsianOR_line_lo25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR var AsianOR_line_lo30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR var AsianORBox = box.new(left=AsianORStart, top=na, right=AsianOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_AsianSessionCol, 100), bgcolor=color.new(i_AsianSessionCol, 70)) var AsianORLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelHigh = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelHigh05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelHigh10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelHigh20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelHigh30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelLow = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelLow05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelLow10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelLow20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelLow30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var AsianORLabelMid = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // *** // London Session var float London_hi = na // High for the London Session var float London_75 = na // 75% level for the London Session var float London_50 = na // 50% level for the London Session var float London_25 = na // 25% level for the London Session var float London_lo = na // Low for the London Session var London_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonLevelCol) // London High line var London_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonLevelCol) // London 75% line var London_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonLevelCol) // London 50% line var London_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonLevelCol) // London 25% line var London_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonLevelCol) // London Low line var LondonHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var London75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var London50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var London25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonSessionStart = time // To register the timestap when the London Session begins var LondonORStart = time var LondonOREnd = time + 3600000 // Add one hour in milliseconds // London Opening Range (1st Hour) var float LondonHr1hi = na // High for the 1st Hour Session var float LondonHr1mid = na // 50% of the 1st Hour Session var float LondonHr1lo = na // Low for the 1st Hour Session var LondonOR_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range High var LondonOR_line_mid = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range Middle var LondonOR_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range Low var LondonOR_line_hi05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal ) // Opening Range High 0.5 STDEV of OR var LondonOR_line_hi10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR var LondonOR_line_hi15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR var LondonOR_line_hi175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR var LondonOR_line_hi20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR var LondonOR_line_hi225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR var LondonOR_line_hi25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR var LondonOR_line_hi30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR var LondonOR_line_lo05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon ) // Opening Range Low 0.5 STDEV of OR var LondonOR_line_lo10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR var LondonOR_line_lo15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR var LondonOR_line_lo175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR var LondonOR_line_lo20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR var LondonOR_line_lo225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR var LondonOR_line_lo25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR var LondonOR_line_lo30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR var LondonORBox = box.new(left=LondonORStart, top=na, right=LondonOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_LondonSessionCol, 100), bgcolor=color.new(i_LondonSessionCol, 70)) var LondonORLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelHigh = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelHigh05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelHigh10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelHigh20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelHigh30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelLow = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelLow05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelLow10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelLow20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelLow30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var LondonORLabelMid = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // *** // New York Session var float NewYork_hi = na // High for the NewYork Session var float NewYork_75 = na // 75% level for the NewYork Session var float NewYork_50 = na // 50% level for the NewYork Session var float NewYork_25 = na // 25% level for the NewYork Session var float NewYork_lo = na // Low for the NewYork Session var NewYork_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork High line var NewYork_line_75 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork 75% line var NewYork_line_50 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork 50% line var NewYork_line_25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork 25% line var NewYork_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYLevelCol) // NewYork Low line var NewYorkHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYork75Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYork50Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYork25Label = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkSessionStart = time // To register the timestap when the NewYork Session begins var NewYorkORStart = NewYorkSessionStart + (i_NewYorkORoffset * 60000) // Add the offset in milliseconds var NewYorkOREnd = NewYorkORStart + 3600000 // Add one hour in milliseconds // NewYork Opening Range (1st Hour) var float NewYorkHr1hi = na // High for the 1st Hour Session var float NewYorkHr1mid = na // 50% of the 1st Hour Session var float NewYorkHr1lo = na // Low for the 1st Hour Session var NewYorkOR_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range High var NewYorkOR_line_mid = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Middle var NewYorkOR_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Low var NewYorkOR_line_hi05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal) // Opening Range High 0.5 STDEV of OR var NewYorkOR_line_hi10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR var NewYorkOR_line_hi15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR var NewYorkOR_line_hi175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR var NewYorkOR_line_hi20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR var NewYorkOR_line_hi225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR var NewYorkOR_line_hi25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR var NewYorkOR_line_hi30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR var NewYorkOR_line_lo05 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon) // Opening Range Low 0.5 STDEV of OR var NewYorkOR_line_lo10 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR var NewYorkOR_line_lo15 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR var NewYorkOR_line_lo175 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR var NewYorkOR_line_lo20 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR var NewYorkOR_line_lo225 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR var NewYorkOR_line_lo25 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR var NewYorkOR_line_lo30 = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR var NewYorkORBox = box.new(left=NewYorkORStart, top=na, right=NewYorkOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_NYSessionCol, 100), bgcolor=color.new(i_NYSessionCol, 70)) var NewYorkORLabelHigh = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelHigh05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelHigh10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelHigh20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelHigh30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelLow = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelLow05 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelLow10 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelLow20 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelLow30 = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) var NewYorkORLabelMid = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // *** // Create Labels // Create initial Debug label l_debug = label.new(x=na, y=na, text="Debug") label.set_text(l_debug, "D") label.set_color(l_debug, color=color.new(color.green, 60)) label.set_textcolor(l_debug, color.white) label.set_yloc(l_debug, yloc.abovebar) label.set_style(l_debug, label.style_label_down) label.set_size(l_debug, size.tiny) // *** // // ALERTS Configuration for use during NY Session // // Function to trigger alerts when price crosses the Globex / Overnight Low during the NY Session f_triggerGlobexLow()=> _co = ta.crossover(close, Globex_lo) _cu = ta.crossunder(close, Globex_lo) if _co and NewYorkSession and enableNewYorkalarms alert("Price (" + str.tostring(close) + ") crossing over Globex Low (" + str.tostring(Globex_lo) + ")", alert.freq_once_per_bar) else if _cu and NewYorkSession alert("Price (" + str.tostring(close) + ") crossing under Globex Low (" + str.tostring(Globex_lo) + ")", alert.freq_once_per_bar) // // Function to trigger alerts when price crosses the Globex / Overnight High during the NY Session f_triggerGlobexHigh()=> _co = ta.crossover(close, Globex_hi) _cu = ta.crossunder(close, Globex_hi) if _co and NewYorkSession and enableNewYorkalarms alert("Price (" + str.tostring(close) + ") crossing over Globex High (" + str.tostring(Globex_hi) + ")", alert.freq_once_per_bar) else if _cu and NewYorkSession alert("Price (" + str.tostring(close) + ") crossing under Globex High (" + str.tostring(Globex_hi) + ")", alert.freq_once_per_bar) // // Function to trigger alerts when price crosses the NY Opening Range 50% level during the NY Session f_triggerNewYorkOR50perc()=> _NewYorkOR50perc = (NewYorkHr1lo+(NewYorkHr1hi-NewYorkHr1lo)/2) _co = ta.crossover(close, _NewYorkOR50perc) _cu = ta.crossunder(close, _NewYorkOR50perc) if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms alert("Price (" + str.tostring(close) + ") crossing over NY OR 50% (" + str.tostring(_NewYorkOR50perc) + ")", alert.freq_once_per_bar) else if _cu and NewYorkSession and time > NewYorkOREnd alert("Price (" + str.tostring(close) + ") crossing under NY OR 50% (" + str.tostring(_NewYorkOR50perc) + ")", alert.freq_once_per_bar) // // Function to trigger alerts when price crosses the NY Opening Range STDEV 0.5 level during the NY Session f_triggerNewYorkSTDEVpos05()=> _NewYorkSTDEVpos05=(NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)/2) _co = ta.crossover(close, _NewYorkSTDEVpos05) _cu = ta.crossunder(close, _NewYorkSTDEVpos05) if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms alert("Price (" + str.tostring(close) + ") crossing over NY STDEV 0.5 (" + str.tostring(_NewYorkSTDEVpos05) + ")", alert.freq_once_per_bar) else if _cu and NewYorkSession and time > NewYorkOREnd alert("Price (" + str.tostring(close) + ") crossing under NY STDEV 0.5 (" + str.tostring(_NewYorkSTDEVpos05) + ")", alert.freq_once_per_bar) // // Function to trigger alerts when price crosses the NY Opening Range STDEV 1.0 level during the NY Session f_triggerNewYorkSTDEVpos10()=> _NewYorkSTDEVpos10=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo) _co = ta.crossover(close, _NewYorkSTDEVpos10) _cu = ta.crossunder(close, _NewYorkSTDEVpos10) if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms alert("Price (" + str.tostring(close) + ") crossing over NY STDEV 1.0 (" + str.tostring(_NewYorkSTDEVpos10) + ")", alert.freq_once_per_bar) else if _cu and NewYorkSession and time > NewYorkOREnd alert("Price (" + str.tostring(close) + ") crossing under NY STDEV 1.0 (" + str.tostring(_NewYorkSTDEVpos10) + ")", alert.freq_once_per_bar) // // Function to trigger alerts when price crosses the NY Opening Range STDEV 0.5 level during the NY Session f_triggerNewYorkSTDEVneg05()=> _NewYorkSTDEVneg05=(NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)/2) _co = ta.crossover(close, _NewYorkSTDEVneg05) _cu = ta.crossunder(close, _NewYorkSTDEVneg05) if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms alert("Price (" + str.tostring(close) + ") crossing over NY STDEV -0.5 (" + str.tostring(_NewYorkSTDEVneg05) + ")", alert.freq_once_per_bar) else if _cu and NewYorkSession and time > NewYorkOREnd alert("Price (" + str.tostring(close) + ") crossing under NY STDEV -0.5 (" + str.tostring(_NewYorkSTDEVneg05) + ")", alert.freq_once_per_bar) // // Function to trigger alerts when price crosses the NY Opening Range STDEV 1.0 level during the NY Session f_triggerNewYorkSTDEVneg10()=> _NewYorkSTDEVneg10=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo) _co = ta.crossover(close, _NewYorkSTDEVneg10) _cu = ta.crossunder(close, _NewYorkSTDEVneg10) if _co and NewYorkSession and time > NewYorkOREnd and enableNewYorkalarms alert("Price (" + str.tostring(close) + ") crossing over NY STDEV -1.0 (" + str.tostring(_NewYorkSTDEVneg10) + ")", alert.freq_once_per_bar) else if _cu and NewYorkSession and time > NewYorkOREnd alert("Price (" + str.tostring(close) + ") crossing under NY STDEV -1.0 (" + str.tostring(_NewYorkSTDEVneg10) + ")", alert.freq_once_per_bar) // // End of Alert functions // *** // Function for determining the Start of a Session (taken from the Pinescript manual: https://www.tradingview.com/pine-script-docs/en/v5/concepts/Sessions.html ) sessionBegins(sess) => t = time("", sess , i_timezone) timeframe.isintraday and (not barstate.isfirst) and na(t[1]) and not na(t) // End function // Start Logic //bool isNewDate = ta.change(time("D")) // Determine if new day has started. This is used to create new lines and labels. // *** Here the actual sessions begin: // // Begin Globex Session Code if sessionBegins(i_GlobexSession) // When a new Globex Session is started GlobexSessionStart := time // Store the Session Starting timestamp CashSessionEndTime := timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) if CashSessionEndTime < GlobexSessionStart // If the CashSessionEndTime is in the past, then add 1 day CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should // We are entering Globex Session hours; reset hi/lo. Globex_hi := srcHi Globex_lo := srcLo Globex_75 := Globex_lo+(Globex_hi-Globex_lo)*0.75 Globex_50 := Globex_lo+(Globex_hi-Globex_lo)*0.5 Globex_25 := Globex_lo+(Globex_hi-Globex_lo)*0.25 // Initialize the drawings for today if showGlobexDrawings // Keep or Remove all historic levels if showGlobexTodayDraw // If true then delete all old objects line.delete(Globex_line_hi[1]) line.delete(Globex_line_75[1]) line.delete(Globex_line_50[1]) line.delete(Globex_line_25[1]) line.delete(Globex_line_lo[1]) label.delete(GlobexHighLabel[1]) label.delete(Globex75Label[1]) label.delete(Globex50Label[1]) label.delete(Globex25Label[1]) label.delete(GlobexLowLabel[1]) // Create new objects for today Globex_line_hi := line.new(x1=GlobexSessionStart, y1=Globex_hi, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_hi, color=i_GlobexLevelCol) // Globex High line Globex_line_75 := line.new(x1=GlobexSessionStart, y1=Globex_75, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_75, color=i_GlobexLevelCol) // Globex 75% line Globex_line_50 := line.new(x1=GlobexSessionStart, y1=Globex_50, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_50, color=i_GlobexLevelCol) // Globex 50% line Globex_line_25 := line.new(x1=GlobexSessionStart, y1=Globex_25, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_25, color=i_GlobexLevelCol) // Globex 25% line Globex_line_lo := line.new(x1=GlobexSessionStart, y1=Globex_lo, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Globex_lo, color=i_GlobexLevelCol) // Globex Low line GlobexHighLabel := label.new(x=GlobexSessionStart, y=Globex_hi, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) Globex75Label := label.new(x=GlobexSessionStart, y=Globex_75, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) Globex50Label := label.new(x=GlobexSessionStart, y=Globex_50, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) Globex25Label := label.new(x=GlobexSessionStart, y=Globex_25, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) GlobexLowLabel := label.new(x=GlobexSessionStart, y=Globex_lo, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) label.set_tooltip(GlobexHighLabel, "Globex High") label.set_tooltip(Globex75Label, "Globex 75%") label.set_tooltip(Globex50Label, "Globex 50%") label.set_tooltip(Globex25Label, "Globex 25%") label.set_tooltip(GlobexLowLabel, "Globex Low") else if GlobexSession // We are in allowed GlobexSession hours; track hi/lo. Globex_hi := math.max(srcHi, Globex_hi) Globex_lo := math.min(srcLo, Globex_lo) if (Globex_hi > Globex_hi[1]) Globex_75 := Globex_lo+(Globex_hi-Globex_lo)*0.75 Globex_50 := Globex_lo+(Globex_hi-Globex_lo)*0.5 Globex_25 := Globex_lo+(Globex_hi-Globex_lo)*0.25 if showGlobexDrawings line.set_xy1(id=Globex_line_hi, x=time, y=Globex_hi) line.set_xy2(id=Globex_line_hi, x=CashSessionEndTime, y=Globex_hi) line.set_xy1(id=Globex_line_75, x=GlobexSessionStart, y=Globex_75) line.set_xy2(id=Globex_line_75, x=CashSessionEndTime, y=Globex_75) line.set_xy1(id=Globex_line_50, x=GlobexSessionStart, y=Globex_50) line.set_xy2(id=Globex_line_50, x=CashSessionEndTime, y=Globex_50) line.set_xy1(id=Globex_line_25, x=GlobexSessionStart, y=Globex_25) line.set_xy2(id=Globex_line_25, x=CashSessionEndTime, y=Globex_25) if showLabels label.set_xy(id=GlobexHighLabel, x=CashSessionEndTime, y=Globex_hi) label.set_xy(id=Globex75Label, x=CashSessionEndTime, y=Globex_75) label.set_xy(id=Globex50Label, x=CashSessionEndTime, y=Globex_50) label.set_xy(id=Globex25Label, x=CashSessionEndTime, y=Globex_25) label.set_xy(id=GlobexLowLabel, x=CashSessionEndTime, y=Globex_lo) if (Globex_lo < Globex_lo[1]) Globex_75 := Globex_lo+(Globex_hi-Globex_lo)*0.75 Globex_50 := Globex_lo+(Globex_hi-Globex_lo)*0.5 Globex_25 := Globex_lo+(Globex_hi-Globex_lo)*0.25 if showGlobexDrawings line.set_xy1(id=Globex_line_lo, x=time, y=Globex_lo) line.set_xy2(id=Globex_line_lo, x=CashSessionEndTime, y=Globex_lo) line.set_xy1(id=Globex_line_75, x=GlobexSessionStart, y=Globex_75) line.set_xy2(id=Globex_line_75, x=CashSessionEndTime, y=Globex_75) line.set_xy1(id=Globex_line_50, x=GlobexSessionStart, y=Globex_50) line.set_xy2(id=Globex_line_50, x=CashSessionEndTime, y=Globex_50) line.set_xy1(id=Globex_line_25, x=GlobexSessionStart, y=Globex_25) line.set_xy2(id=Globex_line_25, x=CashSessionEndTime, y=Globex_25) if showLabels label.set_xy(id=GlobexHighLabel, x=CashSessionEndTime, y=Globex_hi) label.set_xy(id=Globex75Label, x=CashSessionEndTime, y=Globex_75) label.set_xy(id=Globex50Label, x=CashSessionEndTime, y=Globex_50) label.set_xy(id=Globex25Label, x=CashSessionEndTime, y=Globex_25) label.set_xy(id=GlobexLowLabel, x=CashSessionEndTime, y=Globex_lo) // END Globex Session Code // *** // Begin Asian Session Code if sessionBegins(i_AsianSession) // When a new Asian Session is started AsianSessionStart := time // Store the Session Starting timestamp CashSessionEndTime := timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) if CashSessionEndTime < AsianSessionStart // If the CashSessionEndTime is in the past, then add 1 day CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should AsianORStart := AsianSessionStart // There is no offset like the NY session. AsianOREnd := AsianSessionStart + 3600000 // Add one hour in milliseconds // We are entering Asian Session hours; reset hi/lo. Asian_hi := srcHi Asian_lo := srcLo Asian_75 := Asian_lo+(Asian_hi-Asian_lo)*0.75 Asian_50 := Asian_lo+(Asian_hi-Asian_lo)*0.5 Asian_25 := Asian_lo+(Asian_hi-Asian_lo)*0.25 AsianHr1hi := srcHi AsianHr1lo := srcLo // Show debug info if showDebugLabels label.set_xloc(l_debug, x=bar_index, xloc=xloc.bar_index) label.set_tooltip(l_debug, "AsianSessionStart: " + str.tostring(AsianSessionStart) + "\nCashSessionEndTime: " + str.tostring(CashSessionEndTime) + "\nAsianORStart: " + str.tostring(AsianORStart) + "\nAsianOREnd: " + str.tostring(AsianOREnd)) // End of debug code // Initialize the drawings for today if showAsianDrawings // Keep or Remove all historic levels if showAsianTodayDraw // If true then delete all old objects line.delete(Asian_line_hi[1]) line.delete(Asian_line_75[1]) line.delete(Asian_line_50[1]) line.delete(Asian_line_25[1]) line.delete(Asian_line_lo[1]) label.delete(AsianHighLabel[1]) label.delete(Asian75Label[1]) label.delete(Asian50Label[1]) label.delete(Asian25Label[1]) label.delete(AsianLowLabel[1]) if showAsianOR // Delete historic Opening Range objects box.delete(AsianORBox[1]) line.delete(AsianOR_line_hi[1]) line.delete(AsianOR_line_mid[1]) line.delete(AsianOR_line_lo[1]) label.delete(AsianORLabelHigh[1]) label.delete(AsianORLabelLow[1]) label.delete(AsianORLabelMid[1]) if showAsianORStdev // Delete historic Opening Range STDEV objects label.delete(AsianORLabelHigh05[1]) label.delete(AsianORLabelHigh10[1]) label.delete(AsianORLabelHigh20[1]) label.delete(AsianORLabelHigh30[1]) label.delete(AsianORLabelLow05[1]) label.delete(AsianORLabelLow10[1]) label.delete(AsianORLabelLow20[1]) label.delete(AsianORLabelLow30[1]) line.delete(AsianOR_line_hi05[1]) line.delete(AsianOR_line_hi10[1]) line.delete(AsianOR_line_hi15[1]) line.delete(AsianOR_line_hi175[1]) line.delete(AsianOR_line_hi20[1]) line.delete(AsianOR_line_hi225[1]) line.delete(AsianOR_line_hi25[1]) line.delete(AsianOR_line_hi30[1]) line.delete(AsianOR_line_lo05[1]) line.delete(AsianOR_line_lo10[1]) line.delete(AsianOR_line_lo15[1]) line.delete(AsianOR_line_lo175[1]) line.delete(AsianOR_line_lo20[1]) line.delete(AsianOR_line_lo225[1]) line.delete(AsianOR_line_lo25[1]) line.delete(AsianOR_line_lo30[1]) // Create new objects for today Asian_line_hi := line.new(x1=AsianSessionStart, y1=Asian_hi, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Asian_hi, color=i_AsianLevelCol) // Asian High line Asian_line_75 := line.new(x1=AsianSessionStart, y1=Asian_75, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Asian_75, color=i_AsianLevelCol) // Asian 75% line Asian_line_50 := line.new(x1=AsianSessionStart, y1=Asian_50, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Asian_50, color=i_AsianLevelCol) // Asian 50% line Asian_line_25 := line.new(x1=AsianSessionStart, y1=Asian_25, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Asian_25, color=i_AsianLevelCol) // Asian 25% line Asian_line_lo := line.new(x1=AsianSessionStart, y1=Asian_lo, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=Asian_lo, color=i_AsianLevelCol) // Asian Low line AsianHighLabel := label.new(x=AsianSessionStart, y=Asian_hi, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) Asian75Label := label.new(x=AsianSessionStart, y=Asian_75, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) Asian50Label := label.new(x=AsianSessionStart, y=Asian_50, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) Asian25Label := label.new(x=AsianSessionStart, y=Asian_25, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianLowLabel := label.new(x=AsianSessionStart, y=Asian_lo, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) label.set_tooltip(AsianHighLabel, "Asian High") label.set_tooltip(Asian75Label, "Asian 75%") label.set_tooltip(Asian50Label, "Asian 50%") label.set_tooltip(Asian25Label, "Asian 25%") label.set_tooltip(AsianLowLabel,"Asian Low") if showAsianOR // The Asian 1st hour Opening Range initialization // Create new drawing objects AsianOR_line_hi := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range High AsianOR_line_mid := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range Middle AsianOR_line_lo := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol) // Opening Range Low AsianORBox := box.new(left=AsianSessionStart, top=na, right=AsianOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_AsianSessionCol, 100), bgcolor=color.new(i_AsianSessionCol, 70)) //AsianORLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelHigh := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelLow := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelMid := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) if showAsianORStdev AsianOR_line_hi05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal) // Opening Range High 0.5 STDEV of OR AsianOR_line_hi10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR AsianOR_line_hi15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR AsianOR_line_hi175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR AsianOR_line_hi20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR AsianOR_line_hi225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR AsianOR_line_hi25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR AsianOR_line_hi30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR AsianOR_line_lo05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon) // Opening Range Low 0.5 STDEV of OR AsianOR_line_lo10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR AsianOR_line_lo15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR AsianOR_line_lo175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR AsianOR_line_lo20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR AsianOR_line_lo225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR AsianOR_line_lo25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR AsianOR_line_lo30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR AsianORLabelHigh05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelHigh10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelHigh20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelHigh30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelLow05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelLow10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelLow20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) AsianORLabelLow30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) else if AsianSession // We are in allowed Asian Session hours; track hi/lo. Asian_hi := math.max(srcHi, Asian_hi) Asian_lo := math.min(srcLo, Asian_lo) if (Asian_hi > Asian_hi[1]) Asian_75 := Asian_lo+(Asian_hi-Asian_lo)*0.75 Asian_50 := Asian_lo+(Asian_hi-Asian_lo)*0.5 Asian_25 := Asian_lo+(Asian_hi-Asian_lo)*0.25 if showAsianDrawings line.set_xy1(id=Asian_line_hi, x=time, y=Asian_hi) line.set_xy2(id=Asian_line_hi, x=CashSessionEndTime, y=Asian_hi) line.set_xy1(id=Asian_line_75, x=AsianSessionStart, y=Asian_75) line.set_xy2(id=Asian_line_75, x=CashSessionEndTime, y=Asian_75) line.set_xy1(id=Asian_line_50, x=AsianSessionStart, y=Asian_50) line.set_xy2(id=Asian_line_50, x=CashSessionEndTime, y=Asian_50) line.set_xy1(id=Asian_line_25, x=AsianSessionStart, y=Asian_25) line.set_xy2(id=Asian_line_25, x=CashSessionEndTime, y=Asian_25) if showLabels label.set_xy(id=AsianHighLabel, x=CashSessionEndTime, y=Asian_hi) label.set_xy(id=Asian75Label, x=CashSessionEndTime, y=Asian_75) label.set_xy(id=Asian50Label, x=CashSessionEndTime, y=Asian_50) label.set_xy(id=Asian25Label, x=CashSessionEndTime, y=Asian_25) label.set_xy(id=AsianLowLabel,x=CashSessionEndTime, y=Asian_lo) if (Asian_lo < Asian_lo[1]) Asian_75 := Asian_lo+(Asian_hi-Asian_lo)*0.75 Asian_50 := Asian_lo+(Asian_hi-Asian_lo)*0.5 Asian_25 := Asian_lo+(Asian_hi-Asian_lo)*0.25 if showAsianDrawings line.set_xy1(id=Asian_line_lo, x=time, y=Asian_lo) line.set_xy2(id=Asian_line_lo, x=CashSessionEndTime, y=Asian_lo) line.set_xy1(id=Asian_line_75, x=AsianSessionStart, y=Asian_75) line.set_xy2(id=Asian_line_75, x=CashSessionEndTime, y=Asian_75) line.set_xy1(id=Asian_line_50, x=AsianSessionStart, y=Asian_50) line.set_xy2(id=Asian_line_50, x=CashSessionEndTime, y=Asian_50) line.set_xy1(id=Asian_line_25, x=AsianSessionStart, y=Asian_25) line.set_xy2(id=Asian_line_25, x=CashSessionEndTime, y=Asian_25) if showLabels label.set_xy(id=AsianHighLabel, x=CashSessionEndTime, y=Asian_hi) label.set_xy(id=Asian75Label, x=CashSessionEndTime, y=Asian_75) label.set_xy(id=Asian50Label, x=CashSessionEndTime, y=Asian_50) label.set_xy(id=Asian25Label, x=CashSessionEndTime, y=Asian_25) label.set_xy(id=AsianLowLabel, x=CashSessionEndTime, y=Asian_lo) if showAsianOR and (time >= AsianSessionStart and time <= AsianOREnd) // If the Opening Range is active // Calculate and Store the OR High and 50% - Needed for Alerts and Box drawing AsianHr1hi := math.max(srcHi, AsianHr1hi) AsianHr1lo := math.min(srcLo, AsianHr1lo) AsianHr1mid := AsianHr1lo+(AsianHr1hi-AsianHr1lo)*0.5 // Show debug info if showDebugLabels label.set_xloc(l_debug, x=bar_index, xloc=xloc.bar_index) label.set_tooltip(l_debug, "AsianSessionStart: " + str.tostring(AsianSessionStart) + "\nCurrentBartime: " + str.tostring(time) + "\nAsianORStart: " + str.tostring(AsianORStart) + "\nAsianOREnd: " + str.tostring(AsianOREnd) + "\nAsianHr1hi: " + str.tostring(AsianHr1hi) + "\nAsianHr1lo: " + str.tostring(AsianHr1lo)) // End of debug code if (AsianHr1hi > AsianHr1hi[1]) // Plot the 1st Hour Box box.set_lefttop(id=AsianORBox, left=AsianSessionStart, top=AsianHr1hi) box.set_rightbottom(id=AsianORBox, right=AsianOREnd, bottom=AsianHr1lo) // Plot the 1st Hour hi/low Levels line.set_xy1(id=AsianOR_line_hi, x=AsianSessionStart, y=AsianHr1hi) line.set_xy2(id=AsianOR_line_hi, x=CashSessionEndTime, y=AsianHr1hi) line.set_xy1(id=AsianOR_line_mid, x=AsianOREnd, y=AsianHr1mid) line.set_xy2(id=AsianOR_line_mid, x=CashSessionEndTime, y=AsianHr1mid) line.set_xy1(id=AsianOR_line_lo, x=AsianSessionStart, y=AsianHr1lo) line.set_xy2(id=AsianOR_line_lo, x=CashSessionEndTime, y=AsianHr1lo) if showLabels label.set_text(id=AsianORLabelHigh, text="OR High") label.set_xy(id=AsianORLabelHigh, x=CashSessionEndTime, y=AsianHr1hi) label.set_text(id=AsianORLabelMid, text="OR 50%") label.set_xy(id=AsianORLabelMid, x=CashSessionEndTime, y=AsianHr1mid) label.set_text(id=AsianORLabelLow, text="OR Low") label.set_xy(id=AsianORLabelLow, x=CashSessionEndTime, y=AsianHr1lo) if (AsianHr1lo < AsianHr1lo[1]) // Plot the 1st Hour Box box.set_lefttop(id=AsianORBox, left=AsianSessionStart, top=AsianHr1hi) box.set_rightbottom(id=AsianORBox, right=AsianOREnd, bottom=AsianHr1lo) // Plot the 1st Hour hi/low Levels line.set_xy1(id=AsianOR_line_hi, x=AsianSessionStart, y=AsianHr1hi) line.set_xy2(id=AsianOR_line_hi, x=CashSessionEndTime, y=AsianHr1hi) line.set_xy1(id=AsianOR_line_mid, x=AsianOREnd, y=AsianHr1mid) line.set_xy2(id=AsianOR_line_mid, x=CashSessionEndTime, y=AsianHr1mid) line.set_xy1(id=AsianOR_line_lo, x=AsianSessionStart, y=AsianHr1lo) line.set_xy2(id=AsianOR_line_lo, x=CashSessionEndTime, y=AsianHr1lo) if showLabels label.set_text(id=AsianORLabelHigh, text="OR High") label.set_xy(id=AsianORLabelHigh, x=CashSessionEndTime, y=AsianHr1hi) label.set_text(id=AsianORLabelMid, text="OR 50%") label.set_xy(id=AsianORLabelMid, x=CashSessionEndTime, y=AsianHr1mid) label.set_text(id=AsianORLabelLow, text="OR Low") label.set_xy(id=AsianORLabelLow, x=CashSessionEndTime, y=AsianHr1lo) if showAsianOR and time == AsianOREnd and showAsianORStdev // (At the exact end of Asian OR, calculate and draw the STDev levels ) // Plot the Positive IB STDEVs line.set_xy1(id=AsianOR_line_hi05, x=AsianOREnd+1000000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*0.5) line.set_xy2(id=AsianOR_line_hi05, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*0.5) line.set_xy1(id=AsianOR_line_hi10, x=AsianOREnd+1800000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)) line.set_xy2(id=AsianOR_line_hi10, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)) line.set_xy1(id=AsianOR_line_hi15, x=AsianOREnd+3600000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*1.5) line.set_xy2(id=AsianOR_line_hi15, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*1.5) line.set_xy1(id=AsianOR_line_hi175, x=AsianOREnd+5000000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*1.75) line.set_xy2(id=AsianOR_line_hi175, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*1.75) line.set_xy1(id=AsianOR_line_hi20, x=AsianOREnd+7200000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*2) line.set_xy2(id=AsianOR_line_hi20, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*2) line.set_xy1(id=AsianOR_line_hi225, x=AsianOREnd+8800000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*2.25) line.set_xy2(id=AsianOR_line_hi225, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*2.25) line.set_xy1(id=AsianOR_line_hi25, x=AsianOREnd+10800000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*2.5) line.set_xy2(id=AsianOR_line_hi25, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*2.5) line.set_xy1(id=AsianOR_line_hi30, x=AsianOREnd+12800000, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*3) line.set_xy2(id=AsianOR_line_hi30, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*3) // Plot the Negative IB STDEVs line.set_xy1(id=AsianOR_line_lo05, x=AsianOREnd+1000000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*0.5) line.set_xy2(id=AsianOR_line_lo05, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*0.5) line.set_xy1(id=AsianOR_line_lo10, x=AsianOREnd+1800000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)) line.set_xy2(id=AsianOR_line_lo10, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)) line.set_xy1(id=AsianOR_line_lo15, x=AsianOREnd+3600000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*1.5) line.set_xy2(id=AsianOR_line_lo15, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*1.5) line.set_xy1(id=AsianOR_line_lo175, x=AsianOREnd+5000000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*1.75) line.set_xy2(id=AsianOR_line_lo175, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*1.75) line.set_xy1(id=AsianOR_line_lo20, x=AsianOREnd+7200000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*2) line.set_xy2(id=AsianOR_line_lo20, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*2) line.set_xy1(id=AsianOR_line_lo225, x=AsianOREnd+8800000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*2.25) line.set_xy2(id=AsianOR_line_lo225, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*2.25) line.set_xy1(id=AsianOR_line_lo25, x=AsianOREnd+10800000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*2.5) line.set_xy2(id=AsianOR_line_lo25, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*2.5) line.set_xy1(id=AsianOR_line_lo30, x=AsianOREnd+12800000, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*3) line.set_xy2(id=AsianOR_line_lo30, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*3) // Plot the IB STDEV Labels if showLabels label.set_text(id=AsianORLabelHigh05, text="0.5 OR") label.set_xy(id=AsianORLabelHigh05, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)/2) label.set_text(id=AsianORLabelHigh10, text="1.0 OR") label.set_xy(id=AsianORLabelHigh10, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)) label.set_text(id=AsianORLabelHigh20, text="2.0 OR") label.set_xy(id=AsianORLabelHigh20, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*2) label.set_text(id=AsianORLabelHigh30, text="3.0 OR") label.set_xy(id=AsianORLabelHigh30, x=CashSessionEndTime, y=AsianHr1hi+(AsianHr1hi-AsianHr1lo)*3) label.set_text(id=AsianORLabelLow05, text="-0.5 OR") label.set_xy(id=AsianORLabelLow05, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)/2) label.set_text(id=AsianORLabelLow10, text="-1.0 OR") label.set_xy(id=AsianORLabelLow10, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)) label.set_text(id=AsianORLabelLow20, text="-2.0 OR") label.set_xy(id=AsianORLabelLow20, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*2) label.set_text(id=AsianORLabelLow30, text="-3.0 OR") label.set_xy(id=AsianORLabelLow30, x=CashSessionEndTime, y=AsianHr1lo-(AsianHr1hi-AsianHr1lo)*3) // END Asian Session Code // *** // Begin London Session Code if sessionBegins(i_LondonSession) // When a new London Session is started LondonSessionStart := time // Store the Session Starting timestamp CashSessionEndTime := timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) if CashSessionEndTime < LondonSessionStart // If the CashSessionEndTime is in the past, then add 1 day CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should LondonORStart := LondonSessionStart // No offset needed here, like in the NY session. LondonOREnd := LondonORStart + 3600000 // Add one hour in milliseconds // We are entering London Session hours; reset hi/lo. London_hi := srcHi London_lo := srcLo London_75 := London_lo+(London_hi-London_lo)*0.75 London_50 := London_lo+(London_hi-London_lo)*0.5 London_25 := London_lo+(London_hi-London_lo)*0.25 // Reset the Hr1 price tracking vars LondonHr1hi := srcHi LondonHr1lo := srcLo // Show debug info if showDebugLabels label.set_xloc(l_debug, x=bar_index, xloc=xloc.bar_index) label.set_tooltip(l_debug, "LondonSessionStart: " + str.tostring(LondonSessionStart) + "\nCashSessionEndTime: " + str.tostring(CashSessionEndTime) + "\nLondonORStart: " + str.tostring(LondonORStart) + "\nLondonOREnd: " + str.tostring(LondonOREnd) + "\nLondonHr1hi: " + str.tostring(LondonHr1hi) + "\nLondonHr1lo: " + str.tostring(LondonHr1lo)) // End of debug code // Initialize the drawings for today if showLondonDrawings // Keep or Remove all historic levels if showLondonTodayDraw // If true then delete all old objects line.delete(London_line_hi[1]) line.delete(London_line_75[1]) line.delete(London_line_50[1]) line.delete(London_line_25[1]) line.delete(London_line_lo[1]) label.delete(LondonHighLabel[1]) label.delete(London75Label[1]) label.delete(London50Label[1]) label.delete(London25Label[1]) label.delete(LondonLowLabel[1]) if showLondonOR // Delete historic Opening Range objects box.delete(LondonORBox[1]) line.delete(LondonOR_line_hi[1]) line.delete(LondonOR_line_mid[1]) line.delete(LondonOR_line_lo[1]) label.delete(LondonORLabelHigh[1]) label.delete(LondonORLabelLow[1]) label.delete(LondonORLabelMid[1]) if showLondonORStdev // Delete historic Opening Range STDEV objects label.delete(LondonORLabelHigh05[1]) label.delete(LondonORLabelHigh10[1]) label.delete(LondonORLabelHigh20[1]) label.delete(LondonORLabelHigh30[1]) label.delete(LondonORLabelLow05[1]) label.delete(LondonORLabelLow10[1]) label.delete(LondonORLabelLow20[1]) label.delete(LondonORLabelLow30[1]) line.delete(LondonOR_line_hi05[1]) line.delete(LondonOR_line_hi10[1]) line.delete(LondonOR_line_hi15[1]) line.delete(LondonOR_line_hi175[1]) line.delete(LondonOR_line_hi20[1]) line.delete(LondonOR_line_hi225[1]) line.delete(LondonOR_line_hi25[1]) line.delete(LondonOR_line_hi30[1]) line.delete(LondonOR_line_lo05[1]) line.delete(LondonOR_line_lo10[1]) line.delete(LondonOR_line_lo15[1]) line.delete(LondonOR_line_lo175[1]) line.delete(LondonOR_line_lo20[1]) line.delete(LondonOR_line_lo225[1]) line.delete(LondonOR_line_lo25[1]) line.delete(LondonOR_line_lo30[1]) // Create new objects for today London_line_hi := line.new(x1=LondonSessionStart, y1=London_hi, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=London_hi, color=i_NYLevelCol) // London High line London_line_75 := line.new(x1=LondonSessionStart, y1=London_75, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=London_75, color=i_NYLevelCol) // London 75% line London_line_50 := line.new(x1=LondonSessionStart, y1=London_50, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=London_50, color=i_NYLevelCol) // London 50% line London_line_25 := line.new(x1=LondonSessionStart, y1=London_25, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=London_25, color=i_NYLevelCol) // London 25% line London_line_lo := line.new(x1=LondonSessionStart, y1=London_lo, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=London_lo, color=i_NYLevelCol) // London Low line LondonHighLabel := label.new(x=LondonSessionStart, y=London_hi, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) London75Label := label.new(x=LondonSessionStart, y=London_75, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) London50Label := label.new(x=LondonSessionStart, y=London_50, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) London25Label := label.new(x=LondonSessionStart, y=London_25, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonLowLabel := label.new(x=LondonSessionStart, y=London_lo, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) label.set_tooltip(LondonHighLabel, "London High") label.set_tooltip(London75Label, "London 75%") label.set_tooltip(London50Label, "London 50%") label.set_tooltip(London25Label, "London 25%") label.set_tooltip(LondonLowLabel,"London Low") if showLondonOR // The London 1st hour Opening Range initialization // Create new drawing objects LondonOR_line_hi := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range High LondonOR_line_mid := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range Middle LondonOR_line_lo := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol) // Opening Range Low LondonORBox := box.new(left=LondonORStart, top=na, right=LondonOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_LondonSessionCol, 100), bgcolor=color.new(i_LondonSessionCol, 70)) //LondonORLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelHigh := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelLow := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelMid := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) if showLondonORStdev LondonOR_line_hi05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal) // Opening Range High 0.5 STDEV of OR LondonOR_line_hi10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR LondonOR_line_hi15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR LondonOR_line_hi175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR LondonOR_line_hi20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR LondonOR_line_hi225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR LondonOR_line_hi25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR LondonOR_line_hi30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR LondonOR_line_lo05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon) // Opening Range Low 0.5 STDEV of OR LondonOR_line_lo10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR LondonOR_line_lo15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR LondonOR_line_lo175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR LondonOR_line_lo20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR LondonOR_line_lo225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR LondonOR_line_lo25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR LondonOR_line_lo30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR LondonORLabelHigh05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelHigh10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelHigh20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelHigh30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelLow05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelLow10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelLow20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) LondonORLabelLow30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) else if LondonSession // We are in allowed London Session hours; track hi/lo. London_hi := math.max(srcHi, London_hi) London_lo := math.min(srcLo, London_lo) if (London_hi > London_hi[1]) London_75 := London_lo+(London_hi-London_lo)*0.75 London_50 := London_lo+(London_hi-London_lo)*0.5 London_25 := London_lo+(London_hi-London_lo)*0.25 if showLondonDrawings line.set_xy1(id=London_line_hi, x=time, y=London_hi) line.set_xy2(id=London_line_hi, x=CashSessionEndTime, y=London_hi) line.set_xy1(id=London_line_75, x=LondonSessionStart, y=London_75) line.set_xy2(id=London_line_75, x=CashSessionEndTime, y=London_75) line.set_xy1(id=London_line_50, x=LondonSessionStart, y=London_50) line.set_xy2(id=London_line_50, x=CashSessionEndTime, y=London_50) line.set_xy1(id=London_line_25, x=LondonSessionStart, y=London_25) line.set_xy2(id=London_line_25, x=CashSessionEndTime, y=London_25) if showLabels label.set_xy(id=LondonHighLabel, x=CashSessionEndTime, y=London_hi) label.set_xy(id=London75Label, x=CashSessionEndTime, y=London_75) label.set_xy(id=London50Label, x=CashSessionEndTime, y=London_50) label.set_xy(id=London25Label, x=CashSessionEndTime, y=London_25) label.set_xy(id=LondonLowLabel,x=CashSessionEndTime, y=London_lo) if (London_lo < London_lo[1]) London_75 := London_lo+(London_hi-London_lo)*0.75 London_50 := London_lo+(London_hi-London_lo)*0.5 London_25 := London_lo+(London_hi-London_lo)*0.25 if showLondonDrawings line.set_xy1(id=London_line_lo, x=time, y=London_lo) line.set_xy2(id=London_line_lo, x=CashSessionEndTime, y=London_lo) line.set_xy1(id=London_line_75, x=LondonSessionStart, y=London_75) line.set_xy2(id=London_line_75, x=CashSessionEndTime, y=London_75) line.set_xy1(id=London_line_50, x=LondonSessionStart, y=London_50) line.set_xy2(id=London_line_50, x=CashSessionEndTime, y=London_50) line.set_xy1(id=London_line_25, x=LondonSessionStart, y=London_25) line.set_xy2(id=London_line_25, x=CashSessionEndTime, y=London_25) if showLabels label.set_xy(id=LondonHighLabel, x=CashSessionEndTime, y=London_hi) label.set_xy(id=London75Label, x=CashSessionEndTime, y=London_75) label.set_xy(id=London50Label, x=CashSessionEndTime, y=London_50) label.set_xy(id=London25Label, x=CashSessionEndTime, y=London_25) label.set_xy(id=LondonLowLabel, x=CashSessionEndTime, y=London_lo) if showLondonOR and time >= LondonORStart and time <= LondonOREnd // If the Opening Range is active // Calculate and Store the OR High and 50% - Needed for Alerts and Box drawing LondonHr1hi := math.max(srcHi, LondonHr1hi) LondonHr1lo := math.min(srcLo, LondonHr1lo) LondonHr1mid := LondonHr1lo+(LondonHr1hi-LondonHr1lo)*0.5 // Show debug info if showDebugLabels label.set_xloc(l_debug, x=bar_index, xloc=xloc.bar_index) label.set_tooltip(l_debug, "LondonSessionStart: " + str.tostring(LondonSessionStart) + "\nCashSessionEndTime: " + str.tostring(CashSessionEndTime) + "\nLondonORStart: " + str.tostring(LondonORStart) + "\nLondonOREnd: " + str.tostring(LondonOREnd) + "\nLondonHr1hi: " + str.tostring(LondonHr1hi) + "\nLondonHr1lo: " + str.tostring(LondonHr1lo)) // End of debug code if (LondonHr1hi > LondonHr1hi[1]) // Plot the 1st Hour Box box.set_lefttop(id=LondonORBox, left=LondonORStart, top=LondonHr1hi) box.set_rightbottom(id=LondonORBox, right=LondonOREnd, bottom=LondonHr1lo) // Plot the 1st Hour hi/low Levels line.set_xy1(id=LondonOR_line_hi, x=LondonORStart, y=LondonHr1hi) line.set_xy2(id=LondonOR_line_hi, x=CashSessionEndTime, y=LondonHr1hi) line.set_xy1(id=LondonOR_line_mid, x=LondonOREnd, y=LondonHr1mid) line.set_xy2(id=LondonOR_line_mid, x=CashSessionEndTime, y=LondonHr1mid) line.set_xy1(id=LondonOR_line_lo, x=LondonORStart, y=LondonHr1lo) line.set_xy2(id=LondonOR_line_lo, x=CashSessionEndTime, y=LondonHr1lo) if showLabels label.set_text(id=LondonORLabelHigh, text="OR High") label.set_xy(id=LondonORLabelHigh, x=CashSessionEndTime, y=LondonHr1hi) label.set_text(id=LondonORLabelMid, text="OR 50%") label.set_xy(id=LondonORLabelMid, x=CashSessionEndTime, y=LondonHr1mid) label.set_text(id=LondonORLabelLow, text="OR Low") label.set_xy(id=LondonORLabelLow, x=CashSessionEndTime, y=LondonHr1lo) if (LondonHr1lo < LondonHr1lo[1]) // Plot the 1st Hour Box box.set_lefttop(id=LondonORBox, left=LondonORStart, top=LondonHr1hi) box.set_rightbottom(id=LondonORBox, right=LondonOREnd, bottom=LondonHr1lo) // Plot the 1st Hour hi/low Levels line.set_xy1(id=LondonOR_line_hi, x=LondonORStart, y=LondonHr1hi) line.set_xy2(id=LondonOR_line_hi, x=CashSessionEndTime, y=LondonHr1hi) line.set_xy1(id=LondonOR_line_mid, x=LondonOREnd, y=LondonHr1mid) line.set_xy2(id=LondonOR_line_mid, x=CashSessionEndTime, y=LondonHr1mid) line.set_xy1(id=LondonOR_line_lo, x=LondonORStart, y=LondonHr1lo) line.set_xy2(id=LondonOR_line_lo, x=CashSessionEndTime, y=LondonHr1lo) if showLabels label.set_text(id=LondonORLabelHigh, text="OR High") label.set_xy(id=LondonORLabelHigh, x=CashSessionEndTime, y=LondonHr1hi) label.set_text(id=LondonORLabelMid, text="OR 50%") label.set_xy(id=LondonORLabelMid, x=CashSessionEndTime, y=LondonHr1mid) label.set_text(id=LondonORLabelLow, text="OR Low") label.set_xy(id=LondonORLabelLow, x=CashSessionEndTime, y=LondonHr1lo) if showLondonOR and time == LondonOREnd and showLondonORStdev // (At the exact end of London OR, calculate and draw the STDev levels ) // Plot the Positive IB STDEVs line.set_xy1(id=LondonOR_line_hi05, x=LondonOREnd+1000000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*0.5) line.set_xy2(id=LondonOR_line_hi05, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*0.5) line.set_xy1(id=LondonOR_line_hi10, x=LondonOREnd+1800000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)) line.set_xy2(id=LondonOR_line_hi10, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)) line.set_xy1(id=LondonOR_line_hi15, x=LondonOREnd+3600000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*1.5) line.set_xy2(id=LondonOR_line_hi15, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*1.5) line.set_xy1(id=LondonOR_line_hi175, x=LondonOREnd+5000000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*1.75) line.set_xy2(id=LondonOR_line_hi175, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*1.75) line.set_xy1(id=LondonOR_line_hi20, x=LondonOREnd+7200000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*2) line.set_xy2(id=LondonOR_line_hi20, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*2) line.set_xy1(id=LondonOR_line_hi225, x=LondonOREnd+8800000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*2.25) line.set_xy2(id=LondonOR_line_hi225, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*2.25) line.set_xy1(id=LondonOR_line_hi25, x=LondonOREnd+10800000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*2.5) line.set_xy2(id=LondonOR_line_hi25, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*2.5) line.set_xy1(id=LondonOR_line_hi30, x=LondonOREnd+12800000, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*3) line.set_xy2(id=LondonOR_line_hi30, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*3) // Plot the Negative IB STDEVs line.set_xy1(id=LondonOR_line_lo05, x=LondonOREnd+1000000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*0.5) line.set_xy2(id=LondonOR_line_lo05, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*0.5) line.set_xy1(id=LondonOR_line_lo10, x=LondonOREnd+1800000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)) line.set_xy2(id=LondonOR_line_lo10, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)) line.set_xy1(id=LondonOR_line_lo15, x=LondonOREnd+3600000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*1.5) line.set_xy2(id=LondonOR_line_lo15, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*1.5) line.set_xy1(id=LondonOR_line_lo175, x=LondonOREnd+5000000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*1.75) line.set_xy2(id=LondonOR_line_lo175, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*1.75) line.set_xy1(id=LondonOR_line_lo20, x=LondonOREnd+7200000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*2) line.set_xy2(id=LondonOR_line_lo20, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*2) line.set_xy1(id=LondonOR_line_lo225, x=LondonOREnd+8800000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*2.25) line.set_xy2(id=LondonOR_line_lo225, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*2.25) line.set_xy1(id=LondonOR_line_lo25, x=LondonOREnd+10800000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*2.5) line.set_xy2(id=LondonOR_line_lo25, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*2.5) line.set_xy1(id=LondonOR_line_lo30, x=LondonOREnd+12800000, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*3) line.set_xy2(id=LondonOR_line_lo30, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*3) // Plot the IB STDEV Labels if showLabels label.set_text(id=LondonORLabelHigh05, text="0.5 OR") label.set_xy(id=LondonORLabelHigh05, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)/2) label.set_text(id=LondonORLabelHigh10, text="1.0 OR") label.set_xy(id=LondonORLabelHigh10, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)) label.set_text(id=LondonORLabelHigh20, text="2.0 OR") label.set_xy(id=LondonORLabelHigh20, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*2) label.set_text(id=LondonORLabelHigh30, text="3.0 OR") label.set_xy(id=LondonORLabelHigh30, x=CashSessionEndTime, y=LondonHr1hi+(LondonHr1hi-LondonHr1lo)*3) label.set_text(id=LondonORLabelLow05, text="-0.5 OR") label.set_xy(id=LondonORLabelLow05, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)/2) label.set_text(id=LondonORLabelLow10, text="-1.0 OR") label.set_xy(id=LondonORLabelLow10, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)) label.set_text(id=LondonORLabelLow20, text="-2.0 OR") label.set_xy(id=LondonORLabelLow20, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*2) label.set_text(id=LondonORLabelLow30, text="-3.0 OR") label.set_xy(id=LondonORLabelLow30, x=CashSessionEndTime, y=LondonHr1lo-(LondonHr1hi-LondonHr1lo)*3) // END London Session Code // *** // Begin NewYork Session Code if sessionBegins(i_NewYorkSession) // When a new NewYork Session is started NewYorkSessionStart := time // Store the Session Starting timestamp CashSessionEndTime := timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) if CashSessionEndTime < NewYorkSessionStart // If the CashSessionEndTime is in the past, then add 1 day CashSessionEndTime := CashSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should NewYorkORStart := NewYorkSessionStart + (i_NewYorkORoffset * 60000) // Add the offset in milliseconds NewYorkOREnd := NewYorkORStart + 3600000 // Add one hour in milliseconds // We are entering NewYork Session hours; reset hi/lo. NewYork_hi := srcHi NewYork_lo := srcLo NewYork_75 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.75 NewYork_50 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.5 NewYork_25 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.25 // Initialize the drawings for today if showNewYorkDrawings // Keep or Remove all historic levels if showNewYorkTodayDraw // If true then delete all old objects line.delete(NewYork_line_hi[1]) line.delete(NewYork_line_75[1]) line.delete(NewYork_line_50[1]) line.delete(NewYork_line_25[1]) line.delete(NewYork_line_lo[1]) label.delete(NewYorkHighLabel[1]) label.delete(NewYork75Label[1]) label.delete(NewYork50Label[1]) label.delete(NewYork25Label[1]) label.delete(NewYorkLowLabel[1]) if showNewYorkOR // Delete historic Opening Range objects box.delete(NewYorkORBox[1]) line.delete(NewYorkOR_line_hi[1]) line.delete(NewYorkOR_line_mid[1]) line.delete(NewYorkOR_line_lo[1]) label.delete(NewYorkORLabelHigh[1]) label.delete(NewYorkORLabelLow[1]) label.delete(NewYorkORLabelMid[1]) if showNewYorkORStdev // Delete historic Opening Range STDEV objects label.delete(NewYorkORLabelHigh05[1]) label.delete(NewYorkORLabelHigh10[1]) label.delete(NewYorkORLabelHigh20[1]) label.delete(NewYorkORLabelHigh30[1]) label.delete(NewYorkORLabelLow05[1]) label.delete(NewYorkORLabelLow10[1]) label.delete(NewYorkORLabelLow20[1]) label.delete(NewYorkORLabelLow30[1]) line.delete(NewYorkOR_line_hi05[1]) line.delete(NewYorkOR_line_hi10[1]) line.delete(NewYorkOR_line_hi15[1]) line.delete(NewYorkOR_line_hi175[1]) line.delete(NewYorkOR_line_hi20[1]) line.delete(NewYorkOR_line_hi225[1]) line.delete(NewYorkOR_line_hi25[1]) line.delete(NewYorkOR_line_hi30[1]) line.delete(NewYorkOR_line_lo05[1]) line.delete(NewYorkOR_line_lo10[1]) line.delete(NewYorkOR_line_lo15[1]) line.delete(NewYorkOR_line_lo175[1]) line.delete(NewYorkOR_line_lo20[1]) line.delete(NewYorkOR_line_lo225[1]) line.delete(NewYorkOR_line_lo25[1]) line.delete(NewYorkOR_line_lo30[1]) // Create new objects for today NewYork_line_hi := line.new(x1=NewYorkSessionStart, y1=NewYork_hi, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_hi, color=i_NYLevelCol) // NewYork High line NewYork_line_75 := line.new(x1=NewYorkSessionStart, y1=NewYork_75, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_75, color=i_NYLevelCol) // NewYork 75% line NewYork_line_50 := line.new(x1=NewYorkSessionStart, y1=NewYork_50, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_50, color=i_NYLevelCol) // NewYork 50% line NewYork_line_25 := line.new(x1=NewYorkSessionStart, y1=NewYork_25, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_25, color=i_NYLevelCol) // NewYork 25% line NewYork_line_lo := line.new(x1=NewYorkSessionStart, y1=NewYork_lo, x2=CashSessionEndTime, xloc=xloc.bar_time, y2=NewYork_lo, color=i_NYLevelCol) // NewYork Low line NewYorkHighLabel := label.new(x=NewYorkSessionStart, y=NewYork_hi, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYork75Label := label.new(x=NewYorkSessionStart, y=NewYork_75, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYork50Label := label.new(x=NewYorkSessionStart, y=NewYork_50, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYork25Label := label.new(x=NewYorkSessionStart, y=NewYork_25, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkLowLabel := label.new(x=NewYorkSessionStart, y=NewYork_lo, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) label.set_tooltip(NewYorkHighLabel, "New York High") label.set_tooltip(NewYork75Label, "New York 75%") label.set_tooltip(NewYork50Label, "New York 50%") label.set_tooltip(NewYork25Label, "New York 25%") label.set_tooltip(NewYorkLowLabel,"New York Low") if showNewYorkOR // The NewYork 1st hour Opening Range initialization // Create new drawing objects NewYorkOR_line_hi := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range High NewYorkOR_line_mid := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Middle NewYorkOR_line_lo := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionCol) // Opening Range Low NewYorkORBox := box.new(left=NewYorkORStart, top=na, right=NewYorkOREnd, bottom=na, xloc=xloc.bar_time, border_width=2, border_color=color.new(i_NYSessionCol, 100), bgcolor=color.new(i_NYSessionCol, 70)) //NewYorkORLabel := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelHigh := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelLow := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelMid := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) if showNewYorkORStdev NewYorkOR_line_hi05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.teal) // Opening Range High 0.5 STDEV of OR NewYorkOR_line_hi10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 1.0 STDEV of OR NewYorkOR_line_hi15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.5 STDEV of OR NewYorkOR_line_hi175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 1.75 STDEV of OR NewYorkOR_line_hi20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 2.0 STDEV of OR NewYorkOR_line_hi225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.25 STDEV of OR NewYorkOR_line_hi25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range High 2.5 STDEV of OR NewYorkOR_line_hi30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.green) // Opening Range High 3.0 STDEV of OR NewYorkOR_line_lo05 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.maroon) // Opening Range Low 0.5 STDEV of OR NewYorkOR_line_lo10 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 1.0 STDEV of OR NewYorkOR_line_lo15 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.5 STDEV of OR NewYorkOR_line_lo175 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 1.75 STDEV of OR NewYorkOR_line_lo20 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 2.0 STDEV of OR NewYorkOR_line_lo225 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.25 STDEV of OR NewYorkOR_line_lo25 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.gray) // Opening Range Low 2.5 STDEV of OR NewYorkOR_line_lo30 := line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=color.red) // Opening Range Low 3.0 STDEV of OR NewYorkORLabelHigh05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelHigh10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelHigh20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelHigh30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelLow05 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelLow10 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelLow20 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) NewYorkORLabelLow30 := label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) else if NewYorkSession // We are in allowed New York Session hours; track hi/lo. NewYork_hi := math.max(srcHi, NewYork_hi) NewYork_lo := math.min(srcLo, NewYork_lo) if (NewYork_hi > NewYork_hi[1]) NewYork_75 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.75 NewYork_50 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.5 NewYork_25 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.25 if showNewYorkDrawings line.set_xy1(id=NewYork_line_hi, x=time, y=NewYork_hi) line.set_xy2(id=NewYork_line_hi, x=CashSessionEndTime, y=NewYork_hi) line.set_xy1(id=NewYork_line_75, x=NewYorkSessionStart, y=NewYork_75) line.set_xy2(id=NewYork_line_75, x=CashSessionEndTime, y=NewYork_75) line.set_xy1(id=NewYork_line_50, x=NewYorkSessionStart, y=NewYork_50) line.set_xy2(id=NewYork_line_50, x=CashSessionEndTime, y=NewYork_50) line.set_xy1(id=NewYork_line_25, x=NewYorkSessionStart, y=NewYork_25) line.set_xy2(id=NewYork_line_25, x=CashSessionEndTime, y=NewYork_25) if showLabels label.set_xy(id=NewYorkHighLabel, x=CashSessionEndTime, y=NewYork_hi) label.set_xy(id=NewYork75Label, x=CashSessionEndTime, y=NewYork_75) label.set_xy(id=NewYork50Label, x=CashSessionEndTime, y=NewYork_50) label.set_xy(id=NewYork25Label, x=CashSessionEndTime, y=NewYork_25) label.set_xy(id=NewYorkLowLabel,x=CashSessionEndTime, y=NewYork_lo) if (NewYork_lo < NewYork_lo[1]) NewYork_75 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.75 NewYork_50 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.5 NewYork_25 := NewYork_lo+(NewYork_hi-NewYork_lo)*0.25 if showNewYorkDrawings line.set_xy1(id=NewYork_line_lo, x=time, y=NewYork_lo) line.set_xy2(id=NewYork_line_lo, x=CashSessionEndTime, y=NewYork_lo) line.set_xy1(id=NewYork_line_75, x=NewYorkSessionStart, y=NewYork_75) line.set_xy2(id=NewYork_line_75, x=CashSessionEndTime, y=NewYork_75) line.set_xy1(id=NewYork_line_50, x=NewYorkSessionStart, y=NewYork_50) line.set_xy2(id=NewYork_line_50, x=CashSessionEndTime, y=NewYork_50) line.set_xy1(id=NewYork_line_25, x=NewYorkSessionStart, y=NewYork_25) line.set_xy2(id=NewYork_line_25, x=CashSessionEndTime, y=NewYork_25) if showLabels label.set_xy(id=NewYorkHighLabel, x=CashSessionEndTime, y=NewYork_hi) label.set_xy(id=NewYork75Label, x=CashSessionEndTime, y=NewYork_75) label.set_xy(id=NewYork50Label, x=CashSessionEndTime, y=NewYork_50) label.set_xy(id=NewYork25Label, x=CashSessionEndTime, y=NewYork_25) label.set_xy(id=NewYorkLowLabel, x=CashSessionEndTime, y=NewYork_lo) if showNewYorkOR and time >= NewYorkORStart and time <= NewYorkOREnd // If the Opening Range is active if time == NewYorkORStart // Reset the Hr1 price tracking vars NewYorkHr1hi := srcHi NewYorkHr1lo := srcLo // Calculate and Store the OR High and 50% - Needed for Alerts and Box drawing NewYorkHr1hi := math.max(srcHi, NewYorkHr1hi) NewYorkHr1lo := math.min(srcLo, NewYorkHr1lo) NewYorkHr1mid := NewYorkHr1lo+(NewYorkHr1hi-NewYorkHr1lo)*0.5 if (NewYorkHr1hi > NewYorkHr1hi[1]) // Plot the 1st Hour Box box.set_lefttop(id=NewYorkORBox, left=NewYorkORStart, top=NewYorkHr1hi) box.set_rightbottom(id=NewYorkORBox, right=NewYorkOREnd, bottom=NewYorkHr1lo) // Plot the 1st Hour hi/low Levels line.set_xy1(id=NewYorkOR_line_hi, x=NewYorkORStart, y=NewYorkHr1hi) line.set_xy2(id=NewYorkOR_line_hi, x=CashSessionEndTime, y=NewYorkHr1hi) line.set_xy1(id=NewYorkOR_line_mid, x=NewYorkORStart+(time-NewYorkORStart), y=NewYorkHr1mid) line.set_xy2(id=NewYorkOR_line_mid, x=CashSessionEndTime, y=NewYorkHr1mid) line.set_xy1(id=NewYorkOR_line_lo, x=NewYorkORStart, y=NewYorkHr1lo) line.set_xy2(id=NewYorkOR_line_lo, x=CashSessionEndTime, y=NewYorkHr1lo) if showLabels label.set_text(id=NewYorkORLabelHigh, text="OR High") label.set_xy(id=NewYorkORLabelHigh, x=CashSessionEndTime, y=NewYorkHr1hi) label.set_text(id=NewYorkORLabelMid, text="OR 50%") label.set_xy(id=NewYorkORLabelMid, x=CashSessionEndTime, y=NewYorkHr1mid) label.set_text(id=NewYorkORLabelLow, text="OR Low") label.set_xy(id=NewYorkORLabelLow, x=CashSessionEndTime, y=NewYorkHr1lo) if (NewYorkHr1lo < NewYorkHr1lo[1]) // Plot the 1st Hour Box box.set_lefttop(id=NewYorkORBox, left=NewYorkORStart, top=NewYorkHr1hi) box.set_rightbottom(id=NewYorkORBox, right=NewYorkOREnd, bottom=NewYorkHr1lo) // Plot the 1st Hour hi/low Levels line.set_xy1(id=NewYorkOR_line_hi, x=NewYorkORStart, y=NewYorkHr1hi) line.set_xy2(id=NewYorkOR_line_hi, x=CashSessionEndTime, y=NewYorkHr1hi) line.set_xy1(id=NewYorkOR_line_mid, x=NewYorkORStart+(time-NewYorkORStart), y=NewYorkHr1mid) line.set_xy2(id=NewYorkOR_line_mid, x=CashSessionEndTime, y=NewYorkHr1mid) line.set_xy1(id=NewYorkOR_line_lo, x=NewYorkORStart, y=NewYorkHr1lo) line.set_xy2(id=NewYorkOR_line_lo, x=CashSessionEndTime, y=NewYorkHr1lo) if showLabels label.set_text(id=NewYorkORLabelHigh, text="OR High") label.set_xy(id=NewYorkORLabelHigh, x=CashSessionEndTime, y=NewYorkHr1hi) label.set_text(id=NewYorkORLabelMid, text="OR 50%") label.set_xy(id=NewYorkORLabelMid, x=CashSessionEndTime, y=NewYorkHr1mid) label.set_text(id=NewYorkORLabelLow, text="OR Low") label.set_xy(id=NewYorkORLabelLow, x=CashSessionEndTime, y=NewYorkHr1lo) if showNewYorkOR and time == NewYorkOREnd and showNewYorkORStdev // (At the exact end of NewYork OR, calculate and draw the STDev levels ) // Plot the Positive IB STDEVs line.set_xy1(id=NewYorkOR_line_hi05, x=NewYorkOREnd+1000000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*0.5) line.set_xy2(id=NewYorkOR_line_hi05, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*0.5) line.set_xy1(id=NewYorkOR_line_hi10, x=NewYorkOREnd+1800000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)) line.set_xy2(id=NewYorkOR_line_hi10, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)) line.set_xy1(id=NewYorkOR_line_hi15, x=NewYorkOREnd+3600000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*1.5) line.set_xy2(id=NewYorkOR_line_hi15, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*1.5) line.set_xy1(id=NewYorkOR_line_hi175, x=NewYorkOREnd+5000000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*1.75) line.set_xy2(id=NewYorkOR_line_hi175, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*1.75) line.set_xy1(id=NewYorkOR_line_hi20, x=NewYorkOREnd+7200000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*2) line.set_xy2(id=NewYorkOR_line_hi20, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*2) line.set_xy1(id=NewYorkOR_line_hi225, x=NewYorkOREnd+8800000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*2.25) line.set_xy2(id=NewYorkOR_line_hi225, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*2.25) line.set_xy1(id=NewYorkOR_line_hi25, x=NewYorkOREnd+10800000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*2.5) line.set_xy2(id=NewYorkOR_line_hi25, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*2.5) line.set_xy1(id=NewYorkOR_line_hi30, x=NewYorkOREnd+12800000, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*3) line.set_xy2(id=NewYorkOR_line_hi30, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*3) // Plot the Negative IB STDEVs line.set_xy1(id=NewYorkOR_line_lo05, x=NewYorkOREnd+1000000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*0.5) line.set_xy2(id=NewYorkOR_line_lo05, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*0.5) line.set_xy1(id=NewYorkOR_line_lo10, x=NewYorkOREnd+1800000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)) line.set_xy2(id=NewYorkOR_line_lo10, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)) line.set_xy1(id=NewYorkOR_line_lo15, x=NewYorkOREnd+3600000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*1.5) line.set_xy2(id=NewYorkOR_line_lo15, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*1.5) line.set_xy1(id=NewYorkOR_line_lo175, x=NewYorkOREnd+5000000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*1.75) line.set_xy2(id=NewYorkOR_line_lo175, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*1.75) line.set_xy1(id=NewYorkOR_line_lo20, x=NewYorkOREnd+7200000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*2) line.set_xy2(id=NewYorkOR_line_lo20, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*2) line.set_xy1(id=NewYorkOR_line_lo225, x=NewYorkOREnd+8800000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*2.25) line.set_xy2(id=NewYorkOR_line_lo225, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*2.25) line.set_xy1(id=NewYorkOR_line_lo25, x=NewYorkOREnd+10800000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*2.5) line.set_xy2(id=NewYorkOR_line_lo25, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*2.5) line.set_xy1(id=NewYorkOR_line_lo30, x=NewYorkOREnd+12800000, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*3) line.set_xy2(id=NewYorkOR_line_lo30, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*3) // Plot the IB STDEV Labels if showLabels label.set_text(id=NewYorkORLabelHigh05, text="0.5 OR") label.set_xy(id=NewYorkORLabelHigh05, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)/2) label.set_text(id=NewYorkORLabelHigh10, text="1.0 OR") label.set_xy(id=NewYorkORLabelHigh10, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)) label.set_text(id=NewYorkORLabelHigh20, text="2.0 OR") label.set_xy(id=NewYorkORLabelHigh20, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*2) label.set_text(id=NewYorkORLabelHigh30, text="3.0 OR") label.set_xy(id=NewYorkORLabelHigh30, x=CashSessionEndTime, y=NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)*3) label.set_text(id=NewYorkORLabelLow05, text="-0.5 OR") label.set_xy(id=NewYorkORLabelLow05, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)/2) label.set_text(id=NewYorkORLabelLow10, text="-1.0 OR") label.set_xy(id=NewYorkORLabelLow10, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)) label.set_text(id=NewYorkORLabelLow20, text="-2.0 OR") label.set_xy(id=NewYorkORLabelLow20, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*2) label.set_text(id=NewYorkORLabelLow30, text="-3.0 OR") label.set_xy(id=NewYorkORLabelLow30, x=CashSessionEndTime, y=NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)*3) // END NewYork Session Code // *** // New York Initial Balance Logic // Determine the opening Bar - depending of Resolution open_bar = switch timeframe.period "1" => time_close(timeframe.period, "0829-0830", i_timezone) "3" => time_close(timeframe.period, "0827-0830", i_timezone) "5" => time_close(timeframe.period, "0825-0830", i_timezone) "15" => time_close(timeframe.period, "0815-0830", i_timezone) "30" => time_close(timeframe.period, "0800-0830", i_timezone) // End Opening bar code // ****** // End of session code // ------------------------------------------------------------------------------- // Previous Day's Open if showPDO and timeframe.isintraday // Plot the Previous Day's Open line and label _CashSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) var PDOpen_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousDayOpen, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousDayOpen, color=i_PDOcol) // Create the price line of the Previous Days Open var PDOLabel = label.new(x=na, y=na, xloc=xloc.bar_time, text="PDO", color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // Create the label for the Previous Days Open line line.set_xy1(id=PDOpen_line, x=_CashSessionEndTime-86400000, y=PreviousDayOpen) // Draw the PDO Line from the Previous Day's open to the end of the current session line.set_xy2(id=PDOpen_line, x=_CashSessionEndTime, y=PreviousDayOpen) // Draw the PDO Line from the Previous Day's open to the end of the current session if showHTFLabels label.set_xy(id=PDOLabel, x=_CashSessionEndTime, y=PreviousDayOpen) // PDO Label placement label.set_tooltip(PDOLabel, "Previous Day Open: " + str.tostring(PreviousDayOpen)) // PDO Label tooltip with PD Open value // END Previous Day's Open // Previous Day's Close if showPDC and timeframe.isintraday // Plot the Previous Day's Close line and label _CashSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) var PDClose_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousDayClose, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousDayClose, color=i_PDCcol) // Create the price line of the Previous Days Close var PDCLabel = label.new(x=na, y=na, xloc=xloc.bar_time, text="PDC", color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) line.set_xy1(id=PDClose_line, x=_CashSessionEndTime-86400000, y=PreviousDayClose) // Draw the PDC Line from the Previous Day's close to the end of the current session line.set_xy2(id=PDClose_line, x=_CashSessionEndTime, y=PreviousDayClose) // Draw the PDC Line from the Previous Day's close to the end of the current session if showHTFLabels label.set_xy(id=PDCLabel, x=_CashSessionEndTime, y=PreviousDayClose) // PDC Label placement label.set_tooltip(PDCLabel, "Previous Day Close: " + str.tostring(PreviousDayClose)) // PDC Label tooltip with PDC value // END Previous Day's Close // Previous Week's Open if showPWO and timeframe.isintraday // Plot the Previous Week's Open line and label _CashSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) var PWOpen_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousWeekOpen, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousWeekOpen, color=i_PWOcol) // Create the price line of the Previous Week Open var PWOLabel = label.new(x=na, y=na, xloc=xloc.bar_time, text="PWO", color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // Create the label for the Previous Week Open line line.set_xy1(id=PWOpen_line, x=_CashSessionEndTime-86400000, y=PreviousWeekOpen) // Draw the PWO Line from the Previous Week's open to the end of the current session line.set_xy2(id=PWOpen_line, x=_CashSessionEndTime, y=PreviousWeekOpen) // Draw the PWO Line from the Previous Week's open to the end of the current session if showHTFLabels label.set_xy(id=PWOLabel, x=_CashSessionEndTime, y=PreviousWeekOpen) // PWO Label placement label.set_tooltip(PWOLabel, "Previous Week Open: " + str.tostring(PreviousWeekOpen)) // PWO Label tooltip with CW Open value // END Current Week's Open // Previous Week's Close if showPWC and timeframe.isintraday // Plot the Previous Week's Close line and label _CashSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) var PWClose_line = line.new(x1=_CashSessionEndTime[1], y1=PreviousWeekClose, x2=_CashSessionEndTime, xloc=xloc.bar_time, y2=PreviousWeekClose, color=i_PWCcol) // Create the price line of the Previous Weeks Close var PWCLabel = label.new(x=na, y=na, xloc=xloc.bar_time, text="PWC", color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) line.set_xy1(id=PWClose_line, x=_CashSessionEndTime-86400000, y=PreviousWeekClose) // Draw the PWC Line from the Previous Week's close to the end of the current session line.set_xy2(id=PWClose_line, x=_CashSessionEndTime, y=PreviousWeekClose) // Draw the PWC Line from the Previous Week's close to the end of the current session if showHTFLabels label.set_xy(id=PWCLabel, x=_CashSessionEndTime, y=PreviousWeekClose) // PWC Label placement label.set_tooltip(PWCLabel, "Previous Week Close: " + str.tostring(PreviousWeekClose)) // PWC Label tooltip with PWC value // END Previous Week's Close // ALERTS! // Check if price crosses key levels and generate alerts f_triggerGlobexLow() // Price crosses the Globex Overnight Low level? f_triggerGlobexHigh() // Price crosses the Globex Overnight High level? f_triggerNewYorkOR50perc() // When the New York Opening Range has ended... check to see if the 50% level is crossed f_triggerNewYorkSTDEVpos05() // When the New York Opening Range has ended... check to see if the STDEV 0.5 level is crossed f_triggerNewYorkSTDEVpos10() // When the New York Opening Range has ended... check to see if the STDEV 1.0 level is crossed f_triggerNewYorkSTDEVneg05() // When the New York Opening Range has ended... check to see if the STDEV -0.5 level is crossed f_triggerNewYorkSTDEVneg10() // When the New York Opening Range has ended... check to see if the STDEV -1.0 level is crossed // End of Alert section // Start Plotting bgcolor(showGlobex == true and time == GlobexSession ? color.new(i_GlobexSessionCol,90) : na) // Highlight the Globex (Overnight) Range bgcolor(showOpenbar == true and open_bar ? color.new(i_NYSessionCol, 75) : na) // Highlight the Bar before the New York Cash Open bgcolor(showAsian == true and time == AsianSession ? color.new(i_AsianSessionCol,90) : na) // Highlight the Asian Range bgcolor(showLondon == true and time == LondonSession ? color.new(i_LondonSessionCol,90) : na) // Highlight the London Range bgcolor(showNewYork == true and time == NewYorkSession ? color.new(i_NYSessionCol,90) : na) // Highlight the NewYork Range // Debug plots plot(showDebug ? NewYorkHr1lo : na, title='NewYorkHr1lo', color=color.new(#00ffaa, 70)) plot(showDebug ? NewYorkHr1mid : na, title='NewYorkHr1mid', color=color.new(#00ffaa, 70)) plot(showDebug ? NewYorkHr1hi : na, title='NewYorkHr1hi', color=color.new(#00ffaa, 70)) plot(showDebug ? NewYork_hi : na, title='NewYork_hi', color=color.new(#00ffaa, 70)) plot(showDebug ? NewYork_lo : na, title='NewYork_lo', color=color.new(#00ffaa, 70)) plot(showDebug ? (NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo)/2) : na, title='NewYorkSTDEVpos05', color=color.new(#00ffaa, 70)) plot(showDebug ? NewYorkHr1hi+(NewYorkHr1hi-NewYorkHr1lo) : na, title='NewYorkSTDEVpos10', color=color.new(#00ffaa, 70)) plot(showDebug ? (NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo)/2) : na, title='NewYorkSTDEVneg05', color=color.new(#00ffaa, 70)) plot(showDebug ? NewYorkHr1lo-(NewYorkHr1hi-NewYorkHr1lo) : na, title='NewYorkSTDEVneg10', color=color.new(#00ffaa, 70))
Probability Cones
https://www.tradingview.com/script/Cp49eQt5-Probability-Cones/
joebaus
https://www.tradingview.com/u/joebaus/
1,574
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © joebaus //@version=5 // ———————————————————— Acknowledgements { // - Fortunate, a good friend who helped me significantly start my research. // - Telugu Traders Community, for their video on calculating cones. // - Savva Shanaev, for his NEDL tutorial on the Laplace distribution. // - JeylaniB, for his Pine Script V5 extension for VS Studio Code. // - PineCoders and TradingView, for great Pine documentation and features. // - @RicardoSantos, for example code and idea of the Select Date feature. // - Anton Berlin, for his discussions on statistical interpretations. // } // ———————————————————— Indicator { indicator( shorttitle = "Probability Cones", title = "Probability Cones", max_lines_count = 500, max_bars_back = 5000, overlay = true) // } // ———————————————————— Constants { // All tooltip constants are prefixed with "T_". T_SRC = "The data source to use for calculating the probability cones." T_DEV = "Select the calculation method for the cone deviations." T_LOOKBACK = "The number of bars sampled for the probability calculations. Minimum value: 1 and Maximum value: 5000" T_FORECAST = "The number of bars to project the probability cones forward. At 70 bars with all cones enabled, TradingView's line limitations will be hit, and the indicator will begin to remove earlier lines. Either keep this input below 70 or hide cones to get extra drawing lines." T_FILLS = "The background color highlights between cone lines." T_BARSBACK = "The number of bars + or - to position the probability cones." T_CONELOCK = "Enables Anchor Type inputs. Keeps the cone origin stationary based on the Anchor Type selected. When disabled, cone origin will use a rolling window placement using the Bars Back to Place Cones input." T_ANCHOR = "Select the method to anchor the probability cone origin." T_DATE = "Keeps the cone origin stationary at the selected date." T_HTF = "Sets the cone's origin to the beginning of a specified timeframe. Updates the cones automatically when a new period begins." T_OFFSET = "The number of bars + or - to position cones after being anchored. Only effects the Higher Timeframe Anchor Type." T_MEAN = "Select the desired mean for the cones. The Auto setting will use the default, recommended means for the current Deviation input. By default: Standard uses Average, Laplace and Absolute Deviation use Median." T_MEANDRIFT = "Adds or removes the drift to the cones caused by the mean's increasing or decreasing value in the future. Turning \"Use Mean Drift\" off projects forward only the initial value of the mean, and shifts the values of the cone's deviation lines relative to the mean." // All group constants are prefixed with "G_". G_SETTINGS = "Cone Settings" G_ANCHOR = "Anchor Settings ⚓" G_MEAN = "Mean Settings" G_CONE1_SETTINGS = "First Cone's Settings" G_CONE2_SETTINGS = "Second Cone's Settings" G_CONE3_SETTINGS = "Third Cone's Settings" // Constants for i_deviation DEV_STANDARD = "Standard" DEV_LAPLACE = "Laplace Stdev" DEV_MAD = "Absolute" // Constants for i_anchorType AT_BAR = "Bar" AT_DATE = "Select Date" AT_HTF = "Higher Timeframe" // Constants for i_mu MU_AUTO = "Auto" MU_AVERAGE = "Average" MU_MEDIAN = "Median" // Constants for f_lineStyle() LINE_STYLE_SOLID = "Solid" LINE_STYLE_DASHED = "Dashed" LINE_STYLE_DOTTED = "Dotted" // Inline constants. INLINE_CONE_DEV = "Cone Deviations" INLINE_CONE_STYLE = "Cone Line Styles" INLINE_CONE_COLOR = "Cone Line Colors" INLINE_CONE_WIDTH = "Cone Line Widths" INLINE_FILL_COLOR = "Fill Color" INLINE_FILL_BOOL = "Fill Bool" INLINE_MEAN_1 = "Mean Inline Settings 1" INLINE_MEAN_2 = "Mean Inline Settings 2" // } // ———————————————————— Inputs { // Here is how the cone in variables are written: // Cone Order: "first", "second", or "third" cone. // Position: Upper "Up" or lower "Dn" line of the cone. // Attribute: "Color", "Width", etc. // All inputs prefixed with "i_", all arrays prefixed with "a_". // E.g. i_firstUpColor is the input for the first cone's, upper line, color. // ———————————————————— General Settings Inputs { i_src = input.source( defval = close, title = "Source", tooltip = T_SRC, group = G_SETTINGS) i_deviation = input.string( defval = DEV_STANDARD, title = "Deviation", options = [DEV_STANDARD, DEV_LAPLACE, DEV_MAD], tooltip = T_DEV, group = G_SETTINGS) i_lookBack = input.int( defval = 500, title = "Bar Lookback", minval = 1, maxval = 5000, tooltip = T_LOOKBACK, group = G_SETTINGS) i_forecast = input.int( defval = 30, title = "Bar Forecast", minval = 1, tooltip = T_FORECAST, group = G_SETTINGS) i_meanDriftBool = input.bool( defval = true, title = "Use Mean Drift", tooltip = T_MEANDRIFT, group = G_SETTINGS) i_fillBool = input.bool( defval = true, title = "Show Fills", tooltip = T_FILLS, group = G_SETTINGS) // } // ———————————————————— Anchor Settings { i_barsBack = input.int( defval = 20, title = "Bars Back to Place Cones", tooltip = T_BARSBACK, group = G_ANCHOR) i_coneLock = input.bool( defval = false, title = "Lock Cones to Anchor Type", tooltip = T_CONELOCK, group = G_ANCHOR) i_anchorType = input.string( defval = AT_BAR, title = "Anchor Type", options = [AT_BAR, AT_DATE, AT_HTF], tooltip = T_ANCHOR, group = G_ANCHOR) // @RicardoSantos contribution i_anchorDate = time == input.time( defval = timestamp("2022-01-01"), title = "Select Date to Place Cones", tooltip = T_DATE, group = G_ANCHOR) i_anchorHtf = input.timeframe( defval = "W", title = "Higher Timeframe Anchor", tooltip = T_HTF, group = G_ANCHOR) i_anchorOffset = input.int( defval = 1, title = "HTF Anchor Offset", tooltip = T_OFFSET, group = G_ANCHOR) // } // ———————————————————— Mean Input Settings { i_muBool = input.bool( defval = true, title = "Show Mean", group = G_MEAN) i_muCalc = input.string( defval = MU_AUTO, title = "Mean Calculation", options = [MU_AUTO, MU_AVERAGE, MU_MEDIAN], tooltip = T_MEAN, inline = INLINE_MEAN_1, group = G_MEAN) i_muColor = input.color( defval = color.new(color.orange, 0), title = "Color", inline = INLINE_MEAN_2, group = G_MEAN) i_muWidth = input.int( defval = 2, title = "Width", minval = 1, maxval = 4, inline = INLINE_MEAN_2, group = G_MEAN) i_muLineStyle = input.string( defval = LINE_STYLE_DOTTED, title = "Line Style", options = [LINE_STYLE_SOLID, LINE_STYLE_DASHED, LINE_STYLE_DOTTED], inline = INLINE_MEAN_2, group = G_MEAN) // } // ———————————————————— First Cone's Input Settings { i_firstConeBool = input.bool( defval = true, title = "Show First Cone", group = G_CONE1_SETTINGS) i_firstUpColor = input.color( defval = color.new(color.green, 0), title = "Upper Cone Color", inline = INLINE_CONE_COLOR, group = G_CONE1_SETTINGS) i_firstDnColor = input.color( defval = color.new(color.green, 0), title = "Lower Cone Color", inline = INLINE_CONE_COLOR, group = G_CONE1_SETTINGS) i_firstUpDev = input.float( defval = 1, title = "Upper Deviation", step = 0.01, inline = INLINE_CONE_DEV, group = G_CONE1_SETTINGS) // Dn cone deviation inputs are positive, and made negative later. i_firstDnDev = input.float( defval = 1, title = "Lower Deviation", step = 0.01, inline = INLINE_CONE_DEV, group = G_CONE1_SETTINGS) i_firstUpLineStyle = input.string( defval = LINE_STYLE_DOTTED, title = "Upper Line Style", options = [LINE_STYLE_SOLID, LINE_STYLE_DASHED, LINE_STYLE_DOTTED], inline = INLINE_CONE_STYLE, group = G_CONE1_SETTINGS) i_firstDnLineStyle = input.string( defval = LINE_STYLE_DOTTED, title = "Lower Line Style", options = [LINE_STYLE_SOLID, LINE_STYLE_DASHED, LINE_STYLE_DOTTED], inline = INLINE_CONE_STYLE, group = G_CONE1_SETTINGS) i_firstUpWidth = input.int( defval = 2, title = "Upper Cone Width", minval = 1, maxval = 4, inline = INLINE_CONE_WIDTH, group = G_CONE1_SETTINGS) i_firstDnWidth = input.int( defval = 2, title = "Lower Cone Width", minval = 1, maxval = 4, inline = INLINE_CONE_WIDTH, group = G_CONE1_SETTINGS) i_firstUpFillBool = input.bool( defval = true, title = "Show Upper Fill", inline = INLINE_FILL_BOOL, group = G_CONE1_SETTINGS) i_firstDnFillBool = input.bool( defval = true, title = "Show Lower Fill", inline = INLINE_FILL_BOOL, group = G_CONE1_SETTINGS) i_firstUpFill = input.color( defval = color.new(color.green, 95), title = "Upper Fill Color", inline = INLINE_FILL_COLOR, group = G_CONE1_SETTINGS) i_firstDnFill = input.color( defval = color.new(color.green, 95), title = "Lower Fill Color", inline = INLINE_FILL_COLOR, group = G_CONE1_SETTINGS) // } // ———————————————————— Second Cone's Input Settings { i_secondConeBool = input.bool( defval = true, title = "Show Second Cone", group = G_CONE2_SETTINGS) i_secondUpColor = input.color( defval = color.new(color.blue, 0), title = "Upper Cone Color", inline = INLINE_CONE_COLOR, group = G_CONE2_SETTINGS) i_secondDnColor = input.color( defval = color.new(color.blue, 0), title = "Lower Cone Color", inline = INLINE_CONE_COLOR, group = G_CONE2_SETTINGS) i_secondUpDev = input.float( defval = 2, title = "Upper Deviation", step = 0.01, inline = INLINE_CONE_DEV, group = G_CONE2_SETTINGS) // Dn cone deviation inputs are positive, and made negative later. i_secondDnDev = input.float( defval = 2, title = "Lower Deviation", step = 0.01, inline = INLINE_CONE_DEV, group = G_CONE2_SETTINGS) i_secondUpLineStyle = input.string( defval = LINE_STYLE_DOTTED, title = "Upper Line Style", options = [LINE_STYLE_SOLID, LINE_STYLE_DASHED, LINE_STYLE_DOTTED], inline = INLINE_CONE_STYLE, group = G_CONE2_SETTINGS) i_secondDnLineStyle = input.string( defval = LINE_STYLE_DOTTED, title = "Lower Line Style", options = [LINE_STYLE_SOLID, LINE_STYLE_DASHED, LINE_STYLE_DOTTED], inline = INLINE_CONE_STYLE, group = G_CONE2_SETTINGS) i_secondWidthUp = input.int( defval = 2, title = "Upper Cone Width", minval = 1, maxval = 4, inline = INLINE_CONE_WIDTH, group = G_CONE2_SETTINGS) i_secondDnWidth = input.int( defval = 2, title = "Lower Cone Width", minval = 1, maxval = 4, inline = INLINE_CONE_WIDTH, group = G_CONE2_SETTINGS) i_secondUpFillBool = input.bool( defval = true, title = "Show Upper Fill", inline = INLINE_FILL_BOOL, group = G_CONE2_SETTINGS) i_secondDnFillBool = input.bool( defval = true, title = "Show Lower Fill", inline = INLINE_FILL_BOOL, group = G_CONE2_SETTINGS) i_secondUpFill = input.color( defval = color.new(color.blue, 95), title = "Fill Upper Color", inline = INLINE_FILL_COLOR, group = G_CONE2_SETTINGS) i_secondDnFill = input.color( defval = color.new(color.blue, 95), title = "Fill Lower Color", inline = INLINE_FILL_COLOR, group = G_CONE2_SETTINGS) // } // ———————————————————— Third Cone's Input Settings { i_thirdConeBool = input.bool( defval = true, title = "Show Third Cone", group = G_CONE3_SETTINGS) i_thirdUpColor = input.color( defval = color.new(color.red, 0), title = "Upper Cone Color", inline = INLINE_CONE_COLOR, group = G_CONE3_SETTINGS) i_thirdDnColor = input.color( defval = color.new(color.red, 0), title = "Lower Cone Color", inline = INLINE_CONE_COLOR, group = G_CONE3_SETTINGS) i_thirdUpDev = input.float( defval = 3, title = "Upper Deviation", step = 0.01, inline = INLINE_CONE_DEV, group = G_CONE3_SETTINGS) // Dn cone deviation inputs are positive, made negative later. i_thirdDnDev = input.float( defval = 3, title = "Lower Deviation", step = 0.01, inline = INLINE_CONE_DEV, group = G_CONE3_SETTINGS) i_thirdUpLineStyle = input.string( defval = LINE_STYLE_DOTTED, title = "Upper Line Style", options = [LINE_STYLE_SOLID, LINE_STYLE_DASHED, LINE_STYLE_DOTTED], inline = INLINE_CONE_STYLE, group = G_CONE3_SETTINGS) i_thirdDnLineStyle = input.string( defval = LINE_STYLE_DOTTED, title = "Lower Line Style", options = [LINE_STYLE_SOLID, LINE_STYLE_DASHED, LINE_STYLE_DOTTED], inline = INLINE_CONE_STYLE, group = G_CONE3_SETTINGS) i_thirdUpWidth = input.int( defval = 2, title = "Upper Cone Width", minval = 1, maxval = 4, inline = INLINE_CONE_WIDTH, group = G_CONE3_SETTINGS) i_thirdDnWidth = input.int( defval = 2, title = "Lower Cone Width", minval = 1, maxval = 4, inline = INLINE_CONE_WIDTH, group = G_CONE3_SETTINGS) i_thirdUpFillBool = input.bool( defval = true, title = "Show Upper Fill", inline = INLINE_FILL_BOOL, group = G_CONE3_SETTINGS) i_thirdDnFillBool = input.bool( defval = true, title = "Show Lower Fill", inline = INLINE_FILL_BOOL, group = G_CONE3_SETTINGS) i_thirdUpFill = input.color( defval = color.new(color.red, 95), title = "Fill Upper Color", inline = INLINE_FILL_COLOR, group = G_CONE3_SETTINGS) i_thirdDnFill = input.color( defval = color.new(color.red, 95), title = "Fill Lower Color", inline = INLINE_FILL_COLOR, group = G_CONE3_SETTINGS) // } // } // ———————————————————— Calculations { // ———————————————————— Array Index Variables { // coneForecast adds 1 to i_forecast. // This prevents an array from being a length making the forecast 1 bar short. coneForecast = i_forecast + 1 // coneForecastIndex stops repetitition in "for" loops. // While i_forecast is equivalent, this variable is explicit for indexing. coneForecastIndex = coneForecast - 1 // } // ———————————————————— Cone Origin Anchor Variables { // Barlock variable barLock = ta.valuewhen(barstate.isnew == true, bar_index, 0) // Date Select, anchor variable // @RicardoSantos contribution var int dateAnchor = na // Last time i_anchorDate was true, get bar_index and set to dateAnchor. if i_anchorDate == true dateAnchor := bar_index // Get the close of the prior, historical higher timeframe. // barmerge.lookahead_on resolves historical cone anchor repaints. higherTimeframe = request.security( symbol = syminfo.tickerid, timeframe = i_anchorHtf, expression = close[1], lookahead = barmerge.lookahead_on) // Find the numbers of barssince the start a new candle based on i_anchorHtf. htfAnchor = ta.barssince(higherTimeframe[1] != higherTimeframe) // If i_coneLock is enabled, use the respective anchorBarIndex bar_index input. // Otherwise, default back to the i_barsBack input. anchorBar = switch i_coneLock true => bar_index - i_barsBack - (bar_index - barLock[1] - 1) false => bar_index - i_barsBack anchorDate = switch i_coneLock true => dateAnchor false => bar_index - i_barsBack anchorHtf = switch i_coneLock true => bar_index - htfAnchor - i_anchorOffset false => bar_index - i_barsBack // What bar index to start displaying the cones. Used for f_coneLine(). anchorBarIndex = switch i_anchorType AT_BAR => anchorBar AT_DATE => anchorDate AT_HTF => anchorHtf // If i_coneLock is enabled, use the respective i_anchorType subscript input. // Otherwise, default back to the i_barsBack input. anchorBarSub = switch i_coneLock true => i_barsBack + (bar_index - barLock[1] - 1) false => i_barsBack anchorDateSub = switch i_coneLock true => bar_index - dateAnchor false => i_barsBack anchorHtfSub = switch i_coneLock true => htfAnchor + i_anchorOffset false => i_barsBack // Get the equivalent anchorBarIndex value to use as a subscript[] for variables. // Used in "Devation and Mean Switches", and "Cone Value Array" sections. anchorBarIndexSub = switch i_anchorType AT_BAR => anchorBarSub AT_DATE => anchorDateSub AT_HTF => anchorHtfSub // } // ———————————————————— Log Returns Variables { logReturns = math.log(i_src / i_src[1]) logReturnsMed = ta.median(logReturns, i_lookBack) logReturnsAvg = ta.sma(logReturns, i_lookBack) logReturnsDev = ta.stdev(logReturns, i_lookBack) // } // ———————————————————— Mean Switches { // Based on i_deviation, select the mean. meanAuto = switch i_deviation DEV_STANDARD => logReturnsAvg[anchorBarIndexSub] DEV_LAPLACE => logReturnsMed[anchorBarIndexSub] DEV_MAD => logReturnsMed[anchorBarIndexSub] // Based on the mean input, return autoMean or a manually selected mean. meanSwitch = switch i_muCalc MU_AUTO => meanAuto MU_AVERAGE => logReturnsAvg MU_MEDIAN => logReturnsMed // } // ———————————————————— Absolute Deviation Calculation { a_absDev = array.new_float(i_lookBack, na) for i = 0 to i_lookBack - 1 _absDev = math.abs(logReturns[i] - meanSwitch) // Absolute Deviation Calculation array.set(id = a_absDev, index = i, value = _absDev) absDev = array.avg(id = a_absDev) // Absolute Deviation // } // ———————————————————— Laplace Standard Deviation Calculation { laplaceVar = 2 * math.pow(absDev, 2) laplaceStdev = math.sqrt(laplaceVar) // } // ———————————————————— Devation Switches { devSelectUp = switch i_deviation DEV_STANDARD => logReturnsDev[anchorBarIndexSub] DEV_LAPLACE => laplaceStdev[anchorBarIndexSub] DEV_MAD => absDev[anchorBarIndexSub] devSelectDn = switch i_deviation DEV_STANDARD => logReturnsDev[anchorBarIndexSub] DEV_LAPLACE => laplaceStdev[anchorBarIndexSub] DEV_MAD => absDev[anchorBarIndexSub] // } // ———————————————————— a_conePeriod and a_conePeriodSqrt { // Holds an increasing int series: 1, 2, 3... up to coneForecast // This counts the number of bars to forecast the cones forward. a_conePeriod = array.new_int(size = coneForecast, initial_value = na) // Holds square root of a_conePeriod. // When multiplied by a deviation, generates the a cone line's curve. a_conePeriodSqrt = array.new_float(size = coneForecast, initial_value = na) for i = 0 to coneForecastIndex int _conePeriod = na _conePeriod := i + 1 array.set(id = a_conePeriod, index = i, value = _conePeriod) _conePeriodSqrt = math.sqrt(number = _conePeriod) array.set(id = a_conePeriodSqrt, index = i, value = _conePeriodSqrt) // } // ———————————————————— conePeriod and DevSqrt Arrays { a_conePeriodAvg = array.new_float(size = coneForecast, initial_value = na) // Arrays for the three cones. a_firstUpDevSqrt = array.new_float(size = coneForecast, initial_value = na) a_firstDnDevSqrt = array.new_float(size = coneForecast, initial_value = na) a_secondUpDevSqrt = array.new_float(size = coneForecast, initial_value = na) a_secondDnDevSqrt = array.new_float(size = coneForecast, initial_value = na) a_thirdUpDevSqrt = array.new_float(size = coneForecast, initial_value = na) a_thirdDnDevSqrt = array.new_float(size = coneForecast, initial_value = na) for i = 0 to coneForecastIndex // When i_meanDriftBool is true, multiply the mean by a_conePeriod at i // If false, set the initial mean value, from i to coneForecastIndex, to a_conePeriodAvg _conePeriodAvg = switch i_meanDriftBool true => meanSwitch * array.get(id = a_conePeriod, index = i) false => meanSwitch array.set(id = a_conePeriodAvg, index = i, value = _conePeriodAvg) // Multiply the stdev of log returns by the sqrt of the cone period. _firstUpDevSqrt = i_firstUpDev * devSelectUp * array.get(id = a_conePeriodSqrt, index = i) array.set(id = a_firstUpDevSqrt, index = i, value = _firstUpDevSqrt) _firstDnDevSqrt = i_firstDnDev * devSelectDn * array.get(id = a_conePeriodSqrt, index = i) array.set(id = a_firstDnDevSqrt, index = i, value = _firstDnDevSqrt) _secondUpDevSqrt = i_secondUpDev * devSelectUp * array.get(id = a_conePeriodSqrt, index = i) array.set(id = a_secondUpDevSqrt, index = i, value = _secondUpDevSqrt) _secondDnDevSqrt = i_secondDnDev * devSelectDn * array.get(id = a_conePeriodSqrt, index = i) array.set(id = a_secondDnDevSqrt, index = i, value = _secondDnDevSqrt) _thirdUpDevSqrt = i_thirdUpDev * devSelectUp * array.get(id = a_conePeriodSqrt, index = i) array.set(id = a_thirdUpDevSqrt, index = i, value = _thirdUpDevSqrt) _thirdDnDevSqrt = i_thirdDnDev * devSelectDn * array.get(id = a_conePeriodSqrt, index = i) array.set(id = a_thirdDnDevSqrt, index = i, value = _thirdDnDevSqrt) // } // ———————————————————— Percent Arrays { a_firstUpPercent = array.new_float(size = coneForecast, initial_value = na) a_firstDnPercent = array.new_float(size = coneForecast, initial_value = na) a_secondUpPercent = array.new_float(size = coneForecast, initial_value = na) a_secondDnPercent = array.new_float(size = coneForecast, initial_value = na) a_thirdUpPercent = array.new_float(size = coneForecast, initial_value = na) a_thirdDnPercent = array.new_float(size = coneForecast, initial_value = na) for i = 0 to coneForecastIndex // If i_meanDriftBool is true, a_conePeriodAvg equals meanSwitch for i to coneForecastIndex _firstUpPercent = array.get(id = a_conePeriodAvg, index = i) + array.get(id = a_firstUpDevSqrt, index = i) array.set(id = a_firstUpPercent, index = i, value = _firstUpPercent) _firstDnPercent = array.get(id = a_conePeriodAvg, index = i) - array.get(id = a_firstDnDevSqrt, index = i) array.set(id = a_firstDnPercent, index = i, value = _firstDnPercent) _secondUpPercent = array.get(id = a_conePeriodAvg, index = i) + array.get(id = a_secondUpDevSqrt, index = i) array.set(id = a_secondUpPercent, index = i, value = _secondUpPercent) _secondDnPercent = array.get(id = a_conePeriodAvg, index = i) - array.get(id = a_secondDnDevSqrt, index = i) array.set(id = a_secondDnPercent, index = i, value = _secondDnPercent) _thirdUpPercent = array.get(id = a_conePeriodAvg, index = i) + array.get(id = a_thirdUpDevSqrt, index = i) array.set(id = a_thirdUpPercent, index = i, value = _thirdUpPercent) _thirdDnPercent = array.get(id = a_conePeriodAvg, index = i) - array.get(id = a_thirdDnDevSqrt, index = i) array.set(id = a_thirdDnPercent, index = i, value = _thirdDnPercent) // } // ———————————————————— Cone Value Arrays { a_meanValue = array.new_float(size = coneForecast, initial_value = na) a_firstUpValue = array.new_float(size = coneForecast, initial_value = na) a_firstDnValue = array.new_float(size = coneForecast, initial_value = na) a_secondUpValue = array.new_float(size = coneForecast, initial_value = na) a_secondDnValue = array.new_float(size = coneForecast, initial_value = na) a_thirdUpValue = array.new_float(size = coneForecast, initial_value = na) a_thirdDnValue = array.new_float(size = coneForecast, initial_value = na) for i = 0 to coneForecastIndex _a_meanValue = i_src[anchorBarIndexSub] * math.exp( array.get(id = a_conePeriodAvg, index = i) ) array.set(id = a_meanValue, index = i, value = _a_meanValue) _firstUpConeValue = i_src[anchorBarIndexSub] * math.exp( array.get(id = a_firstUpPercent, index = i) ) array.set(id = a_firstUpValue, index = i, value = _firstUpConeValue) _firstDnConeValue = i_src[anchorBarIndexSub] * math.exp( array.get(id = a_firstDnPercent, index = i) ) array.set(id = a_firstDnValue, index = i, value = _firstDnConeValue) _secondUpConeValue = i_src[anchorBarIndexSub] * math.exp( array.get(id = a_secondUpPercent, index = i) ) array.set(id = a_secondUpValue, index = i, value = _secondUpConeValue) _secondDnConeValue = i_src[anchorBarIndexSub] * math.exp( array.get(id = a_secondDnPercent, index = i) ) array.set(id = a_secondDnValue, index = i, value = _secondDnConeValue) _thirdUpConeValue = i_src[anchorBarIndexSub] * math.exp( array.get(id = a_thirdUpPercent, index = i) ) array.set(id = a_thirdUpValue, index = i, value = _thirdUpConeValue) _thirdDnConeValue = i_src[anchorBarIndexSub] * math.exp( array.get(id = a_thirdDnPercent, index = i) ) array.set(id = a_thirdDnValue, index = i, value = _thirdDnConeValue) // } // } // ———————————————————— Lines and Fills { // ———————————————————— Draw Functions { // ———————————————————— Line Style Function { f_lineStyle(_lineStyle) => // @param _lineStyle, user input line style variable. _output = switch _lineStyle LINE_STYLE_SOLID => line.style_solid LINE_STYLE_DASHED => line.style_dashed LINE_STYLE_DOTTED => line.style_dotted // } // ———————————————————— Cone Line Function { f_coneLine(_a_coneValue, _color, _style, _width, _coneToggle) => // @param _a_coneValue, the array holding the cone's forecast values. // @param _color, line color variable. // @param _style, line style variable. // @param _width, line width variable. // @param _coneToggle, bool input for this line. var _a_coneLine = array.new_line(size = coneForecast, initial_value = na) // Offset "i" to get the next _a_coneValue to use as y2 in _coneLine. _a_x2Period = array.new_int(size = coneForecast, initial_value = na) // If the respective cone and line input toggles are on, display the line. if _coneToggle == true // For loop to generate offset "i" array in _a_x2Period for i = 0 to coneForecastIndex - 1 // Index is one shorter than "i". _x2Period = i + 1 // Create offset index value from "i". array.set(id = _a_x2Period, index = i, value = _x2Period) for i = 0 to coneForecastIndex _coneX1 = anchorBarIndex + i _coneX2 = anchorBarIndex + array.get(id = _a_x2Period, index = i) line _coneLine = na _coneLine := line.new( x1 = _coneX1, y1 = array.get(id = _a_coneValue, index = i ), x2 = _coneX2, y2 = array.get(id = _a_coneValue, index = array.get(id = _a_x2Period, index = i) ), xloc = xloc.bar_index, extend = extend.none, color = _color, style = _style, width = _width) array.push(id = _a_coneLine, value = _coneLine) if array.size(id = _a_coneLine) > coneForecast _ln = array.shift(id = _a_coneLine) line.delete(id = _ln) _a_coneLine // } // ———————————————————— Cone Fill Function { f_coneFill(_a_line1, _a_line2, _color, _i_fillBool) => // @param _a_line1, is the first line's array for the fill function. // @param _a_line2, is the second line's array for the fill function. // @param _color, color variable. // @param _i_fillBool, bool input for this fill. _a_linefill = array.new_linefill() if i_fillBool == true // i_fillBool is a global variable. if _i_fillBool == true // _i_fillBool is a local variable. for i = 0 to coneForecastIndex line _line1 = na line _line2 = na _line1 := array.get(id = _a_line1, index = i) _line2 := array.get(id = _a_line2, index = i) _linefill = linefill.new(_line1, _line2, _color) array.push(id = _a_linefill, value = _linefill) if array.size(id = _a_linefill) > coneForecast _ln = array.shift(id = _a_linefill) linefill.delete(id = _ln) // } // } // ———————————————————— Draw Indicator { // ———————————————————— Draw Lines { meanLine = f_coneLine( a_meanValue, i_muColor, f_lineStyle(i_muLineStyle), i_muWidth, i_muBool) firstUpLine = f_coneLine( a_firstUpValue, i_firstUpColor, f_lineStyle(i_firstUpLineStyle), i_firstUpWidth, i_firstConeBool) firstDnLine = f_coneLine( a_firstDnValue, i_firstDnColor, f_lineStyle(i_firstDnLineStyle), i_firstDnWidth, i_firstConeBool) secondUpLine = f_coneLine( a_secondUpValue, i_secondUpColor, f_lineStyle(i_secondUpLineStyle), i_secondWidthUp, i_secondConeBool) secondDnLine = f_coneLine( a_secondDnValue, i_secondDnColor, f_lineStyle(i_secondDnLineStyle), i_secondDnWidth, i_secondConeBool) thirdUpLine = f_coneLine( a_thirdUpValue, i_thirdUpColor, f_lineStyle(i_thirdUpLineStyle), i_thirdUpWidth, i_thirdConeBool) thirdDnLine = f_coneLine( a_thirdDnValue, i_thirdDnColor, f_lineStyle(i_thirdDnLineStyle), i_thirdDnWidth, i_thirdConeBool) // } // ———————————————————— Draw Fills f_coneFill(meanLine, firstUpLine, i_firstUpFill, i_firstUpFillBool) f_coneFill(meanLine, firstDnLine, i_firstDnFill, i_firstDnFillBool) f_coneFill(firstUpLine, secondUpLine, i_secondUpFill, i_secondUpFillBool) f_coneFill(firstDnLine, secondDnLine, i_secondDnFill, i_secondDnFillBool) f_coneFill(secondUpLine, thirdUpLine, i_thirdUpFill, i_thirdUpFillBool) f_coneFill(secondDnLine, thirdDnLine, i_thirdDnFill, i_thirdDnFillBool) // } // }
BTC Futures Basis
https://www.tradingview.com/script/jvhRyOes-BTC-Futures-Basis/
daylad
https://www.tradingview.com/u/daylad/
61
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © daylad //@version=5 indicator("BTC Futures Basis", precision=2) cnA = input.symbol("BITMEX:XBTUSDTH22", "A") cnB = input.symbol("BITMEX:XBTM22", "B") cnC = input.symbol("BINANCE:BTCH2022", "C") cnD = input.symbol("BINANCE:BTCM2022", "D") cnE = input.symbol("DERIBIT:BTC25H22", "E") cnF = input.symbol("DERIBIT:BTC24M22", "F") cnG = input.symbol("OKEX:BTCUSDT25H2022", "G") cnH = input.symbol("OKEX:BTCUSDT24M2022", "H") cnI = input.symbol("FTX:BTC0325", "I") cnJ = input.symbol("FTX:BTC0624", "J") cnK = input.symbol("CME:BTC2!", "K") spot = request.security("COINBASE:BTCUSD", "1", ohlc4) ftA = request.security(cnA, "1", ohlc4) ftB = request.security(cnB, "1", ohlc4) ftC = request.security(cnC, "1", ohlc4) ftD = request.security(cnD, "1", ohlc4) ftE = request.security(cnE, "1", ohlc4) ftF = request.security(cnF, "1", ohlc4) ftG = request.security(cnG, "1", ohlc4) ftH = request.security(cnH, "1", ohlc4) ftI = request.security(cnI, "1", ohlc4) ftJ = request.security(cnJ, "1", ohlc4) ftK = request.security(cnK, "1", ohlc4, gaps = barmerge.gaps_on) prA = (ftA-spot)/spot prB = (ftB-spot)/spot prC = (ftC-spot)/spot prD = (ftD-spot)/spot prE = (ftE-spot)/spot prF = (ftF-spot)/spot prG = (ftG-spot)/spot prH = (ftH-spot)/spot prI = (ftI-spot)/spot prJ = (ftJ-spot)/spot prK = (ftK-spot)/spot var string GP2 = "Display" string tableYposInput = input.string("top", "Panel position", inline = "11", options = ["top", "middle", "bottom"], group = GP2) string tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"], group = GP2) var table panel = table.new(tableYposInput + "_" + tableXposInput, 2, 12, frame_color=#000000, frame_width=1) if barstate.islast table.cell(panel, 0, 0, "Contract", bgcolor = #C2C2C2) table.cell(panel, 1, 0, "Basis", bgcolor = #9F9F9F) table.cell(panel, 0, 1, cnA, bgcolor = #FF5AAF) table.cell(panel, 1, 1, str.tostring(prA, "#.##" + "%"), bgcolor = #FF5AAF) table.cell(panel, 0, 2, cnB, bgcolor = #9F0162) table.cell(panel, 1, 2, str.tostring(prB, "#.##" + "%"), bgcolor = #9F0162) table.cell(panel, 0, 3, cnC, bgcolor = #FFC33B) table.cell(panel, 1, 3, str.tostring(prC, "#.##" + "%"), bgcolor = #FFC33B) table.cell(panel, 0, 4, cnD, bgcolor = #FF6E3A) table.cell(panel, 1, 4, str.tostring(prD, "#.##" + "%"), bgcolor = #FF6E3A) table.cell(panel, 0, 5, cnE, bgcolor = #00C2F9) table.cell(panel, 1, 5, str.tostring(prE, "#.##" + "%"), bgcolor = #00C2F9) table.cell(panel, 0, 6, cnF, bgcolor = #008DF9) table.cell(panel, 1, 6, str.tostring(prF, "#.##" + "%"), bgcolor = #008DF9) table.cell(panel, 0, 7, cnG, bgcolor = #FFC4D4) table.cell(panel, 1, 7, str.tostring(prG, "#.##" + "%"), bgcolor = #FFC4D4) table.cell(panel, 0, 8, cnH, bgcolor = #A40122) table.cell(panel, 1, 8, str.tostring(prH, "#.##" + "%"), bgcolor = #A40122) table.cell(panel, 0, 9, cnI, bgcolor = #00FCCF) table.cell(panel, 1, 9, str.tostring(prI, "#.##" + "%"), bgcolor = #00FCCF) table.cell(panel, 0, 10, cnJ, bgcolor = #00FB1D) table.cell(panel, 1, 10, str.tostring(prJ, "#.##" + "%"), bgcolor = #00FB1D) table.cell(panel, 0, 11, cnK, bgcolor = #9F24E2) table.cell(panel, 1, 11, str.tostring(prK, "#.##" + "%"), bgcolor = #9F24E2) hline(0, "Backwardation Level", color=color.new(#BCBCBC, 0)) plot(prA*100, "A", color=color.new(#FF5AAF, 0)) plot(prB*100, "B", color=color.new(#9F0162, 0)) plot(prC*100, "C", color=color.new(#FFC33B, 0)) plot(prD*100, "D", color=color.new(#FF6E3A, 0)) plot(prE*100, "E", color=color.new(#00C2F9, 0)) plot(prF*100, "F", color=color.new(#008DF9, 0)) plot(prG*100, "G", color=color.new(#FFC4D4, 0)) plot(prH*100, "H", color=color.new(#A40122, 0)) plot(prI*100, "I", color=color.new(#00FCCF, 0)) plot(prJ*100, "J", color=color.new(#00FB1D, 0)) plot(prK*100, "K", color=color.new(#9F24E2, 0)) //Alert function lvl = input.float(0.01, "Get an alert when basis crosses below this %:", step=0.01) bwA = ta.crossover(lvl, prE*100) bwB = ta.crossover(lvl, prG*100) bwC = ta.crossover(lvl, prI*100) if bwA or bwB or bwC alert("BACKWARDATION", alert.freq_once_per_bar) plotchar(bwA, "BWD", "▼", location.top, color=#FF0000, size = size.tiny)
XLNX-AMD arb calc
https://www.tradingview.com/script/BIRtJgbp-XLNX-AMD-arb-calc/
pmok3
https://www.tradingview.com/u/pmok3/
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/ // © pmok3 //@version=5 indicator("XLNX-AMD arb calc") amd = request.security("AMD", "1D", close) xlnx = request.security("XLNX", "1D", close) arb = ( amd * 1.7234 - xlnx ) / xlnx * 100 plot(arb)
Ichimoku Cloud Distance
https://www.tradingview.com/script/cjN52SkI-Ichimoku-Cloud-Distance/
NgUTech
https://www.tradingview.com/u/NgUTech/
66
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/ // © NgUTech //@version=4 study(title="Ichimoku Cloud Distance", shorttitle="ΔCloud") cloudSettings = input('Doubled Crypto',options=['Standard','Crypto','Doubled Crypto'],title="Cloud Settings") distanceMode = input('Hybrid',options=['Distance to Center','Distance to Edge','Hybrid'],title="Distance Mode") hybridModeScaleMethod = input('Timeframe-dependent',options=['Simple','Timeframe-dependent'],title="Hybrid Mode Scale Method") hybridModeScaleFactor = input(title="Hybrid Mode Scale Factor", type=input.float, defval=1, minval=1, step=1) thicknessScaleMethod = input('Timeframe-dependent',options=['Simple','Timeframe-dependent'],title="Thickness Scale Method") thicknessScaleFactor = input(title="Thickness Scale Factor", type=input.float, defval=1, minval=1, step=1) hybridIntervalColor = input(title="Hybrid Cloud (-1, 1) Interval Color", type=input.color, defval=color.new(color.white, 90)) bullishCloudColor = input(title="Bullish Cloud Color", type=input.color, defval=color.rgb(67, 160, 71, 90)) bearishCloudColor = input(title="Bearish Cloud Color", type=input.color, defval=color.rgb(244, 67, 54, 90)) displayTkCrosses = input(title="Display TK Crosses", type=input.bool, defval=false) fillBackground = input(title="Fill Background", type=input.bool, defval=false) conversionPeriods = cloudSettings == 'Standard' ? 9 : cloudSettings == 'Crypto' ? 10 : 20 basePeriods = cloudSettings == 'Standard' ? 26 : cloudSettings == 'Crypto' ? 30 : 60 laggingSpan2Periods = cloudSettings == 'Standard' ? 52 : cloudSettings == 'Crypto' ? 60 : 120 displacement = cloudSettings == 'Standard' ? 26 : cloudSettings == 'Crypto' ? 30 : 30 donchian(len) => avg(lowest(len), highest(len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) offset = displacement - 1 bullishCloud = leadLine1[offset] > leadLine2[offset] bearishCloud = not bullishCloud crossover2(series1, series2) => series1[1] < series2[1] and series1 > series2 or crossover(series1, series2) baseLineBearishCross = crossover2(baseLine, conversionLine) baseLineBullishCross = crossover2(conversionLine, baseLine) center = (leadLine1[offset] + leadLine2[offset])/2 timeframe = timeframe.ismonthly ? 86400*30*timeframe.multiplier : (timeframe.isweekly ? 86400*7*timeframe.multiplier : (timeframe.isdaily ? 86400*timeframe.multiplier : (timeframe.isminutes ? 60*timeframe.multiplier : timeframe.multiplier))) scale(val) => (val-1)*(hybridModeScaleMethod == 'Timeframe-dependent' ? 11929.5*pow(timeframe, -0.6470469) : 1)*hybridModeScaleFactor + 1 getDistance(val, offset) => priceBelowBearishCloud = bearishCloud and val < leadLine1[offset] priceAboveBearishCloud = bearishCloud and val > leadLine2[offset] priceBelowBullishCloud = bullishCloud and val < leadLine2[offset] priceAboveBullishCloud = bullishCloud and val > leadLine1[offset] if nz(leadLine1[offset]) == 0 or nz(leadLine2[offset]) == 0 distance = 0 else if distanceMode == 'Distance to Center' distance = val > center ? val/center - 1 : -center/val + 1 else if distanceMode == 'Hybrid' distance = priceBelowBearishCloud ? -scale(leadLine1[offset]/val) : (priceAboveBearishCloud ? scale(val/leadLine2[offset]) : (priceBelowBullishCloud ? -scale(leadLine2[offset]/val) : priceAboveBullishCloud ? scale(val/leadLine1[offset]) : (bullishCloud ? (val > center ? 1/(leadLine1[offset]-center)*(val-center) : -1/(center-leadLine2[offset])*(center-val)) : (val < center ? -1/(center-leadLine1[offset])*(center-val) : 1/(leadLine2[offset]-center)*(val-center))))) else distance = priceBelowBearishCloud ? -leadLine1[offset]/val + 1 : (priceAboveBearishCloud ? val/leadLine2[offset] - 1 : (priceBelowBullishCloud ? -leadLine2[offset]/val + 1 : priceAboveBullishCloud ? val/leadLine1[offset] - 1 : 0)) cloudDistance = getDistance(close, offset) conversionLineDistance = getDistance(conversionLine, offset) baseLineDistance = getDistance(baseLine, offset) laggingDistance = getDistance(close, offset*2) if barstate.islastconfirmedhistory and distanceMode == 'Hybrid' box.new(left=bar_index, top=1, right=bar_index, bottom=-1, extend=extend.both, xloc=xloc.bar_index, border_width=0, bgcolor=hybridIntervalColor) hline(0, "Zero", color=#787B86) zero = plot(0, offset=offset, color=color.rgb(0, 0, 0, 100), title="Zero", display=display.none) cloudThickness = abs(leadLine1 - leadLine2)/center thicknessScale = thicknessScaleMethod == 'Timeframe-dependent' ? (distanceMode == 'Hybrid' ? 37114.9335600234*pow(timeframe, -0.787826324127987)-0.00000188481158058423*timeframe+25.3717700469544 : 0.08382861154789754*pow(timeframe, 0.3390020697495657)) : 1 cloudThicknessPlot = plot(cloudThickness*thicknessScale*thicknessScaleFactor, offset=offset, color=color.rgb(0, 0, 0, 100), title="Cloud (Kumo) Thickness Outline") fill(zero, cloudThicknessPlot, color=leadLine1 > leadLine2 ? bullishCloudColor : bearishCloudColor, title="Cloud (Kumo) Thickness Background") plot(laggingDistance, offset=-offset, color=color.rgb(67, 160, 71, 70), title="Lagging (Chikou) Span Distance", display=display.none) plot(conversionLineDistance, color=color.rgb(41, 98, 255), title="Conversion (Tenkan-Sen) Line Distance") plot(baseLineDistance, color=color.rgb(183, 28, 28), title="Base (Kijun-Sen) Line Distance") plot(cloudDistance, color=color.orange, linewidth=2, title="Price Distance") bgcolor(displayTkCrosses and baseLineBearishCross ? color.rgb(255, 0, 0) : (displayTkCrosses and baseLineBullishCross ? color.rgb(0, 255, 0) : (fillBackground ? (bullishCloud ? bullishCloudColor : bearishCloudColor) : color.rgb(0 , 0, 0, 100))))
Permabull Profit Ratio
https://www.tradingview.com/script/gEXSOA5b-Permabull-Profit-Ratio/
slopip
https://www.tradingview.com/u/slopip/
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/ // © slopip //@version=5 indicator("Permabull Profit Ratio", overlay=false, scale=scale.right) import slopip/bullratio/1 as br len = input.int(21, "Number of candles- 0 for start of chart") bullratio = br.bullratio(len) colors = (bullratio) < 0 ? color.red: color.green plot(bullratio, color=colors) hline(0, title="Zero", color=color.gray, linestyle=hline.style_dashed)
MA-cédé
https://www.tradingview.com/script/nwckngwp/
Arthur_Detaille
https://www.tradingview.com/u/Arthur_Detaille/
7
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/ // © Arthur_Detaille //@version=4 study("MERCURY", overlay=false) length = input(8, minval=1, title="QUICK") length2 = input(64, minval=1, title="SLOW") lengthSignal = input(32, minval = 1, title="SIGNAL") quick = avg(highest(close, length), lowest(close, length)) slow = avg(highest(close, length2), lowest(close, length2)) CD = (quick - slow)/close * 100 SIGNAL = sma(CD, lengthSignal) color_blue = #0000ff p2 = plot(series=CD, color=color.blue, trackprice=true, linewidth=2) p3 = plot(0, color=color.white) // fill(p2, p3, color=color_blue, transp=50) p = plot(SIGNAL, color=color.orange, linewidth=2, trackprice=true)
Multiple Ticker Trader
https://www.tradingview.com/script/0p4qZuRg-Multiple-Ticker-Trader/
barnabygraham
https://www.tradingview.com/u/barnabygraham/
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/ // © barnabygraham //@version=5 indicator("Multiple Ticker Trader", shorttitle="Multi-Ticker Trader",overlay=true) typ1 = "Live" typ2 = "Testing" live = input.string('Live',title="Live or Test?", options=[typ1, typ2]) use1 = input("AAPL", title="Ticker 1") use2 = input("MSFT", title="Ticker 2") use3 = input("GOOGL", title="Ticker 3") use4 = input("TLT", title="Ticker 4") use5 = input("GS", title="Ticker 5") use6 = input("FB", title="Ticker 6") use7 = input("BRK.A", title="Ticker 7") use8 = input("QQQ", title="Ticker 8") use9 = input("JPM", title="Ticker 9") use10 = input("UNH", title="Ticker 10") high1 = request.security(use1,'',high) high2 = request.security(use2,'',high) high3 = request.security(use3,'',high) high4 = request.security(use4,'',high) high5 = request.security(use5,'',high) high6 = request.security(use6,'',high) high7 = request.security(use7,'',high) high8 = request.security(use8,'',high) high9 = request.security(use9,'',high) high10 = request.security(use10,'',high) close1 = na(request.security(use1,'',close)) ? 0 : request.security(use1,'',close) close2 = na(request.security(use2,'',close)) ? 0 : request.security(use2,'',close) close3 = na(request.security(use3,'',close)) ? 0 : request.security(use3,'',close) close4 = na(request.security(use4,'',close)) ? 0 : request.security(use4,'',close) close5 = na(request.security(use5,'',close)) ? 0 : request.security(use5,'',close) close6 = na(request.security(use6,'',close)) ? 0 : request.security(use6,'',close) close7 = na(request.security(use7,'',close)) ? 0 : request.security(use7,'',close) close8 = na(request.security(use8,'',close)) ? 0 : request.security(use8,'',close) close9 = na(request.security(use9,'',close)) ? 0 : request.security(use9,'',close) close10 = na(request.security(use10,'',close)) ? 0 : request.security(use10,'',close) // buy from ATH var float highestHigh1 = 0 var float highestHigh2 = 0 var float highestHigh3 = 0 var float highestHigh4 = 0 var float highestHigh5 = 0 var float highestHigh6 = 0 var float highestHigh7 = 0 var float highestHigh8 = 0 var float highestHigh9 = 0 var float highestHigh10 = 0 if high1 > highestHigh1 highestHigh1 := high1 if high2 > highestHigh2 highestHigh2 := high2 if high3 > highestHigh3 highestHigh3 := high3 if high4 > highestHigh4 highestHigh4 := high4 if high5 > highestHigh5 highestHigh5 := high5 if high6 > highestHigh6 highestHigh6 := high6 if high7 > highestHigh7 highestHigh7 := high7 if high8 > highestHigh8 highestHigh8 := high8 if high9 > highestHigh9 highestHigh9 := high9 if high10 > highestHigh10 highestHigh10 := high10 buyzoneA = input(0.9,"Buy % 1") buyzoneB = input(0.8,"Buy % 2") buyzoneC = input(0.7,"Buy % 3") buyzoneD = input(0.6,"Buy % 4") buyzoneE = input(0.5,"Buy % 5") sellzone = input(0.99,"Sell %") buyzoneA1=highestHigh1*buyzoneA buyzoneB1=highestHigh1*buyzoneB buyzoneC1=highestHigh1*buyzoneC buyzoneD1=highestHigh1*buyzoneD buyzoneE1=highestHigh1*buyzoneE sellzone1=highestHigh1*sellzone buyzoneA2=highestHigh2*buyzoneA buyzoneB2=highestHigh2*buyzoneB buyzoneC2=highestHigh2*buyzoneC buyzoneD2=highestHigh2*buyzoneD buyzoneE2=highestHigh2*buyzoneE sellzone2=highestHigh2*sellzone buyzoneA3=highestHigh3*buyzoneA buyzoneB3=highestHigh3*buyzoneB buyzoneC3=highestHigh3*buyzoneC buyzoneD3=highestHigh3*buyzoneD buyzoneE3=highestHigh3*buyzoneE sellzone3=highestHigh3*sellzone buyzoneA4=highestHigh4*buyzoneA buyzoneB4=highestHigh4*buyzoneB buyzoneC4=highestHigh4*buyzoneC buyzoneD4=highestHigh4*buyzoneD buyzoneE4=highestHigh4*buyzoneE sellzone4=highestHigh4*sellzone buyzoneA5=highestHigh5*buyzoneA buyzoneB5=highestHigh5*buyzoneB buyzoneC5=highestHigh5*buyzoneC buyzoneD5=highestHigh5*buyzoneD buyzoneE5=highestHigh5*buyzoneE sellzone5=highestHigh5*sellzone buyzoneA6=highestHigh6*buyzoneA buyzoneB6=highestHigh6*buyzoneB buyzoneC6=highestHigh6*buyzoneC buyzoneD6=highestHigh6*buyzoneD buyzoneE6=highestHigh6*buyzoneE sellzone6=highestHigh6*sellzone buyzoneA7=highestHigh7*buyzoneA buyzoneB7=highestHigh7*buyzoneB buyzoneC7=highestHigh7*buyzoneC buyzoneD7=highestHigh7*buyzoneD buyzoneE7=highestHigh7*buyzoneE sellzone7=highestHigh7*sellzone buyzoneA8=highestHigh8*buyzoneA buyzoneB8=highestHigh8*buyzoneB buyzoneC8=highestHigh8*buyzoneC buyzoneD8=highestHigh8*buyzoneD buyzoneE8=highestHigh8*buyzoneE sellzone8=highestHigh8*sellzone buyzoneA9=highestHigh9*buyzoneA buyzoneB9=highestHigh9*buyzoneB buyzoneC9=highestHigh9*buyzoneC buyzoneD9=highestHigh9*buyzoneD buyzoneE9=highestHigh9*buyzoneE sellzone9=highestHigh9*sellzone buyzoneA10=highestHigh10*buyzoneA buyzoneB10=highestHigh10*buyzoneB buyzoneC10=highestHigh10*buyzoneC buyzoneD10=highestHigh10*buyzoneD buyzoneE10=highestHigh10*buyzoneE sellzone10=highestHigh10*sellzone //End Buy from all time high //////////////////////////// SETTINGS3=input(true,title="----- Backtest Range -----") beginYear = input(2018, title="Start Year") beginMonth = input(1, title="Start Month") beginDay = input(1, title="Start Day") endYear = input(2025, title="End Year") endMonth = input(1, title="End Month") endDay = input(1, title="End Day") begin = timestamp(beginYear,beginMonth,beginDay,0,0)//backtest period end = timestamp(endYear,endMonth,endDay,0,0) //////////////////////////// var intrades = 0 var in1 = 0 var in2 = 0 var in3 = 0 var in4 = 0 var in5 = 0 var in6 = 0 var in7 = 0 var in8 = 0 var in9 = 0 var in10 = 0 maxtrades = input(25,title="Maximum Simultaneous Positions (each scale in counts as one)") var startingAccountValue = input(100,title="Starting Account Value (For Backtesting)") var realCashInAccount = input(100,title="Real Cash In Account") var totalCash = realCashInAccount var totalCashTest = startingAccountValue //var runningTotal = totalCash + var leverage = input(1,title="Leverage") var netpnl = 0.0 var runningTotal = 0.0 + startingAccountValue // currently only used on closed trades runningTotalTest = runningTotal //var leveragedcashpertrade = (leverage*totalCash)/maxtrades leveragedcash = leverage*startingAccountValue leveragedcashpertrade = live == "Live" ? (leverage*(startingAccountValue))/maxtrades : (leverage*(runningTotal))/maxtrades var cash1 = 0.0 var cash2 = 0.0 var cash3 = 0.0 var cash4 = 0.0 var cash5 = 0.0 var cash6 = 0.0 var cash7 = 0.0 var cash8 = 0.0 var cash9 = 0.0 var cash10 = 0.0 marketValue1 = (cash1*close1) marketValue2 = (cash2*close2) marketValue3 = (cash3*close3) marketValue4 = (cash4*close4) marketValue5 = (cash5*close5) marketValue6 = (cash6*close6) marketValue7 = (cash7*close7) marketValue8 = (cash8*close8) marketValue9 = (cash9*close9) marketValue10 = (cash10*close10) var pnl1 = 0.0 var pnl2 = 0.0 var pnl3 = 0.0 var pnl4 = 0.0 var pnl5 = 0.0 var pnl6 = 0.0 var pnl7 = 0.0 var pnl8 = 0.0 var pnl9 = 0.0 var pnl10 = 0.0 var pnl1_2 = 0.0 var pnl2_2 = 0.0 var pnl3_2 = 0.0 var pnl4_2 = 0.0 var pnl5_2 = 0.0 var pnl6_2 = 0.0 var pnl7_2 = 0.0 var pnl8_2 = 0.0 var pnl9_2 = 0.0 var pnl10_2 = 0.0 openvalue = marketValue1 + marketValue2 + marketValue3 + marketValue4 + marketValue5 + marketValue6 + marketValue7 + marketValue8 + marketValue9 + marketValue10 openunleveragedvalue = openvalue/maxtrades openpnl = (marketValue1-pnl1) + (marketValue2-pnl2) + (marketValue3-pnl3) + (marketValue4-pnl4) + (marketValue5-pnl5) + (marketValue6-pnl6) + (marketValue7-pnl7) + (marketValue8-pnl8) + (marketValue9-pnl9) + (marketValue10-pnl10) liveRunningTotal = runningTotal + openpnl plot(intrades) plot(runningTotal,color=color.yellow) plot(liveRunningTotal,color= liveRunningTotal > runningTotal ? color.green : color.red) //plot(openpnl,color=color.red) maxdrawdown=1/leverage Liquidated = openpnl < (runningTotal*maxdrawdown) ? true : false var liq2 = false var liq = false if liq2 == false liq := openpnl + (openvalue*maxdrawdown) < 0 ? true : false if liq == true liq2 := true liquidationLabel = liq2[1]==false and liq2 ? label.new(bar_index,close,text="LIQUIDATED",style=label.style_xcross, color=color.red, textcolor=color.red, size=size.large) : na // table var table divTable = table.new(position.bottom_right, 18, 3, color.new(#ffffff,100), color.new(#ff0000,50),0, color.new(#ffff55,50),0) //if barstate.islast table.cell(divTable, 1, 0, use1, text_color=color.new(color.red,50)) table.cell(divTable, 2, 0, use2, text_color=color.new(color.red,50)) table.cell(divTable, 3, 0, use3, text_color=color.new(color.red,50)) table.cell(divTable, 4, 0, use4, text_color=color.new(color.red,50)) table.cell(divTable, 5, 0, use5, text_color=color.new(color.red,50)) table.cell(divTable, 6, 0, use6, text_color=color.new(color.red,50)) table.cell(divTable, 7, 0, use7, text_color=color.new(color.red,50)) table.cell(divTable, 8, 0, use8, text_color=color.new(color.red,50)) table.cell(divTable, 9, 0, use9, text_color=color.new(color.red,50)) table.cell(divTable, 10, 0, use10, text_color=color.new(color.red,50)) table.cell(divTable, 11, 0, "Starting $", text_color=color.new(color.red,50)) table.cell(divTable, 12, 0, "Closed P&L", text_color=color.new(color.red,50)) table.cell(divTable, 13, 0, "Open Value (live)", text_color=color.new(color.red,50)) table.cell(divTable, 14, 0, "Liquidated?", text_color=color.new(color.red,50)) table.cell(divTable, 15, 0, "Open P&L", text_color=color.new(color.red,50)) table.cell(divTable, 16, 0, "Open Unleveraged Value (live)", text_color=color.new(color.red,50)) table.cell(divTable, 17, 0, "Open Value (test)", text_color=color.new(color.red,50)) // table.cell(divTable, 18, 0, "test", text_color=color.new(color.red,50)) table.cell(divTable, 1, 1, in1 ? str.tostring(cash1) : "", text_color=color.new(color.red,50)) table.cell(divTable, 2, 1, in2 ? str.tostring(cash2) : "", text_color=color.new(color.red,50)) table.cell(divTable, 3, 1, in3 ? str.tostring(cash3) : "", text_color=color.new(color.red,50)) table.cell(divTable, 4, 1, in4 ? str.tostring(cash4) : "", text_color=color.new(color.red,50)) table.cell(divTable, 5, 1, in5 ? str.tostring(cash5) : "", text_color=color.new(color.red,50)) table.cell(divTable, 6, 1, in6 ? str.tostring(cash6) : "", text_color=color.new(color.red,50)) table.cell(divTable, 7, 1, in7 ? str.tostring(cash7) : "", text_color=color.new(color.red,50)) table.cell(divTable, 8, 1, in8 ? str.tostring(cash8) : "", text_color=color.new(color.red,50)) table.cell(divTable, 9, 1, in9 ? str.tostring(cash9) : "", text_color=color.new(color.red,50)) table.cell(divTable, 10, 1, in10 ? str.tostring(cash10) : "", text_color=color.new(color.red,50)) table.cell(divTable, 11, 1, str.tostring(startingAccountValue), text_color=color.new(color.red,50)) table.cell(divTable, 12, 1, str.tostring(math.round(netpnl)), text_color=color.new(color.red,50)) table.cell(divTable, 13, 1, str.tostring(math.round(openvalue)), text_color=color.new(color.red,50)) table.cell(divTable, 14, 1, str.tostring(liq2), text_color=color.new(color.red,50)) table.cell(divTable, 15, 1, str.tostring(math.round(openpnl)), text_color=color.new(color.red,50)) table.cell(divTable, 16, 1, str.tostring(openunleveragedvalue), text_color=color.new(color.red,50)) table.cell(divTable, 17, 1, str.tostring(math.round(runningTotal)), text_color=color.new(color.red,50)) // table.cell(divTable, 18, 1, str.tostring(("test")), text_color=color.new(color.red,50)) table.cell(divTable, 1, 2, str.tostring(math.round(pnl1_2+marketValue1)), text_color=color.new(color.red,50)) table.cell(divTable, 2, 2, str.tostring(math.round(pnl2_2+marketValue2)), text_color=color.new(color.red,50)) table.cell(divTable, 3, 2, str.tostring(math.round(pnl3_2+marketValue3)), text_color=color.new(color.red,50)) table.cell(divTable, 4, 2, str.tostring(math.round(pnl4_2+marketValue4)), text_color=color.new(color.red,50)) table.cell(divTable, 5, 2, str.tostring(math.round(pnl5_2+marketValue5)), text_color=color.new(color.red,50)) table.cell(divTable, 6, 2, str.tostring(math.round(pnl6_2+marketValue6)), text_color=color.new(color.red,50)) table.cell(divTable, 7, 2, str.tostring(math.round(pnl7_2+marketValue7)), text_color=color.new(color.red,50)) table.cell(divTable, 8, 2, str.tostring(math.round(pnl8_2+marketValue8)), text_color=color.new(color.red,50)) table.cell(divTable, 9, 2, str.tostring(math.round(pnl9_2+marketValue9)), text_color=color.new(color.red,50)) table.cell(divTable, 10, 2, str.tostring(math.round(pnl10_2+marketValue10)), text_color=color.new(color.red,50)) if time >=begin and time <=end // EXITS // SHORTS // CLOSES // EXITS // SHORTS // CLOSES // EXITS // SHORTS // CLOSES // closeTicker1 = close1 > sellzone1 closeTicker2 = close2 > sellzone2 closeTicker3 = close3 > sellzone3 closeTicker4 = close4 > sellzone4 closeTicker5 = close5 > sellzone5 closeTicker6 = close6 > sellzone6 closeTicker7 = close7 > sellzone7 closeTicker8 = close8 > sellzone8 closeTicker9 = close9 > sellzone9 closeTicker10 = close10 > sellzone10 if (closeTicker1 and in1 > 0) intrades := intrades-in1 in1 := 0 pnl1_2 := pnl1_2 + ((cash1*close1)-pnl1) netpnl := netpnl + pnl1_2 runningTotal := runningTotal + pnl1_2 cash1 := 0 pnl1 := 0 if (closeTicker2 and in2 > 0) intrades := intrades-in2 in2 := 0 pnl2_2 := pnl2_2 + ((cash2*close2)-pnl2) netpnl := netpnl + pnl2_2 runningTotal := runningTotal + pnl2_2 cash2 := 0 pnl2 := 0 if (closeTicker3 and in3 > 0) intrades := intrades-in3 in3 := 0 pnl3_2 := pnl3_2 + ((cash3*close3)-pnl3) netpnl := netpnl + pnl3_2 runningTotal := runningTotal + pnl3_2 cash3 := 0 pnl3 := 0 if (closeTicker4 and in4 > 0) intrades := intrades-in4 in4 := 0 pnl4_2 := pnl4_2 + ((cash4*close4)-pnl4) netpnl := netpnl + pnl4_2 runningTotal := runningTotal + pnl4_2 cash4 := 0 pnl4 := 0 if (closeTicker5 and in5 > 0) intrades := intrades-in5 in5 := 0 pnl5_2 := pnl5_2 + ((cash5*close5)-pnl5) netpnl := netpnl + pnl5_2 runningTotal := runningTotal + pnl5_2 cash5 := 0 pnl5 := 0 if (closeTicker6 and in6 > 0) intrades := intrades-in6 in6 := 0 pnl6_2 := pnl6_2 + ((cash6*close6)-pnl6) netpnl := netpnl + pnl6_2 runningTotal := runningTotal + pnl6_2 cash6 := 0 pnl6 := 0 if (closeTicker7 and in7 > 0) intrades := intrades-in7 in7 := 0 pnl7_2 := pnl7_2 + ((cash7*close7)-pnl7) netpnl := netpnl + pnl7_2 runningTotal := runningTotal + pnl7_2 cash7 := 0 pnl7 := 0 if (closeTicker8 and in8 > 0) intrades := intrades-in8 in8 := 0 pnl8_2 := pnl8_2 + ((cash8*close8)-pnl8) netpnl := netpnl + pnl8_2 runningTotal := runningTotal + pnl8_2 cash8 := 0 pnl8 := 0 if (closeTicker9 and in9 > 0) intrades := intrades-in9 in9 := 0 pnl9_2 := pnl9_2 + ((cash9*close9)-pnl9) netpnl := netpnl + pnl9_2 runningTotal := runningTotal + pnl9_2 cash9 := 0 pnl9 := 0 if (closeTicker10 and in10 > 0) intrades := intrades-in10 in10 := 0 pnl10_2 := pnl10_2 + ((cash10*close10)-pnl10) netpnl := netpnl + pnl10_2 runningTotal := runningTotal + pnl10_2 cash10 := 0 pnl10 := 0 // ENTRIES // LONGS // BUYS // ENTRIES // LONGS // BUYS // ENTRIES // LONGS // BUYS // long1scale1 = (close1 < buyzoneA1) and use1 != "" long1scale2 = (close1 < buyzoneB1) and use1 != "" long1scale3 = (close1 < buyzoneC1) and use1 != "" long1scale4 = (close1 < buyzoneD1) and use1 != "" long1scale5 = (close1 < buyzoneE1) and use1 != "" if ((intrades < maxtrades) and (((long1scale1) and (in1 == 0)) or ((long1scale2) and (in1 == 1)) or ((long1scale3) and (in1 == 2)) or ((long1scale4) and (in1 == 3)) or ((long1scale5) and (in1 == 4)))) cash1 := cash1 + math.round(leveragedcashpertrade/close1,2) intrades := intrades+1 in1 := in1 + 1 pnl1 := (cash1*close1) long2scale1 = (close2 < buyzoneA2) and use2 != "" long2scale2 = (close2 < buyzoneB2) and use2 != "" long2scale3 = (close2 < buyzoneC2) and use2 != "" long2scale4 = (close2 < buyzoneD2) and use2 != "" long2scale5 = (close2 < buyzoneE2) and use2 != "" if ((intrades < maxtrades) and (((long2scale1) and (in2 == 0)) or ((long2scale2) and (in2 == 1)) or ((long2scale3) and (in2 == 2)) or ((long2scale4) and (in2 == 3)) or ((long2scale5) and (in2 == 4)))) cash2 := cash2 + math.round(leveragedcashpertrade/close2,2) intrades := intrades+1 in2 := in2 + 1 pnl2 := (cash2*close2) long3scale1 = (close3 < buyzoneA3) and use3 != "" long3scale2 = (close3 < buyzoneB3) and use3 != "" long3scale3 = (close3 < buyzoneC3) and use3 != "" long3scale4 = (close3 < buyzoneD3) and use3 != "" long3scale5 = (close3 < buyzoneE3) and use3 != "" if ((intrades < maxtrades) and (((long3scale1) and (in3 == 0)) or ((long3scale2) and (in3 == 1)) or ((long3scale3) and (in3 == 2)) or ((long3scale4) and (in3 == 3)) or ((long3scale5) and (in3 == 4)))) cash3 := cash3 + math.round(leveragedcashpertrade/close3,2) intrades := intrades+1 in3 := in3 + 1 pnl3 := (cash3*close3) long4scale1 = (close4 < buyzoneA4) and use4 != "" long4scale2 = (close4 < buyzoneB4) and use4 != "" long4scale3 = (close4 < buyzoneC4) and use4 != "" long4scale4 = (close4 < buyzoneD4) and use4 != "" long4scale5 = (close4 < buyzoneE4) and use4 != "" if ((intrades < maxtrades) and (((long4scale1) and (in4 == 0)) or ((long4scale2) and (in4 == 1)) or ((long4scale3) and (in4 == 2)) or ((long4scale4) and (in4 == 3)) or ((long4scale5) and (in4 == 4)))) cash4 := cash4 + math.round(leveragedcashpertrade/close4,2) intrades := intrades+1 in4 := in4 + 1 pnl4 := (cash4*close4) long5scale1 = (close5 < buyzoneA5) and use5 != "" long5scale2 = (close5 < buyzoneB5) and use5 != "" long5scale3 = (close5 < buyzoneC5) and use5 != "" long5scale4 = (close5 < buyzoneD5) and use5 != "" long5scale5 = (close5 < buyzoneE5) and use5 != "" if ((intrades < maxtrades) and (((long5scale1) and (in5 == 0)) or ((long5scale2) and (in5 == 1)) or ((long5scale3) and (in5 == 2)) or ((long5scale4) and (in5 == 3)) or ((long5scale5) and (in5 == 4)))) cash5 := cash5 + math.round(leveragedcashpertrade/close5,2) intrades := intrades+1 in5 := in5 + 1 pnl5 := (cash5*close5) long6scale1 = (close6 < buyzoneA6) and use6 != "" long6scale2 = (close6 < buyzoneB6) and use6 != "" long6scale3 = (close6 < buyzoneC6) and use6 != "" long6scale4 = (close6 < buyzoneD6) and use6 != "" long6scale5 = (close6 < buyzoneE6) and use6 != "" if ((intrades < maxtrades) and (((long6scale1) and (in6 == 0)) or ((long6scale2) and (in6 == 1)) or ((long6scale3) and (in6 == 2)) or ((long6scale4) and (in6 == 3)) or ((long6scale5) and (in6 == 4)))) cash6 := cash6 + math.round(leveragedcashpertrade/close6,2) intrades := intrades+1 in6 := in6 + 1 pnl6 := (cash6*close6) long7scale1 = (close7 < buyzoneA7) and use7 != "" long7scale2 = (close7 < buyzoneB7) and use7 != "" long7scale3 = (close7 < buyzoneC7) and use7 != "" long7scale4 = (close7 < buyzoneD7) and use7 != "" long7scale5 = (close7 < buyzoneE7) and use7 != "" if ((intrades < maxtrades) and (((long7scale1) and (in7 == 0)) or ((long7scale2) and (in7 == 1)) or ((long7scale3) and (in7 == 2)) or ((long7scale4) and (in7 == 3)) or ((long7scale5) and (in7 == 4)))) cash7 := cash7 + math.round(leveragedcashpertrade/close7,2) intrades := intrades+1 in7 := in7 + 1 pnl7 := (cash7*close7) long8scale1 = (close8 < buyzoneA8) and use8 != "" long8scale2 = (close8 < buyzoneB8) and use8 != "" long8scale3 = (close8 < buyzoneC8) and use8 != "" long8scale4 = (close8 < buyzoneD8) and use8 != "" long8scale5 = (close8 < buyzoneE8) and use8 != "" if ((intrades < maxtrades) and (((long8scale1) and (in8 == 0)) or ((long8scale2) and (in8 == 1)) or ((long8scale3) and (in8 == 2)) or ((long8scale4) and (in8 == 3)) or ((long8scale5) and (in8 == 4)))) cash8 := cash8 + math.round(leveragedcashpertrade/close8,2) intrades := intrades+1 in8 := in8 + 1 pnl8 := (cash8*close8) long9scale1 = (close9 < buyzoneA9) and use9 != "" long9scale2 = (close9 < buyzoneB9) and use9 != "" long9scale3 = (close9 < buyzoneC9) and use9 != "" long9scale4 = (close9 < buyzoneD9) and use9 != "" long9scale5 = (close9 < buyzoneE9) and use9 != "" if ((intrades < maxtrades) and (((long9scale1) and (in9 == 0)) or ((long9scale2) and (in9 == 1)) or ((long9scale3) and (in9 == 2)) or ((long9scale4) and (in9 == 3)) or ((long9scale5) and (in9 == 4)))) cash9 := cash9 + math.round(leveragedcashpertrade/close9,2) intrades := intrades+1 in9 := in9 + 1 pnl9 := (cash9*close9) long10scale1 = (close10 < buyzoneA10) and use10 != "" long10scale2 = (close10 < buyzoneB10) and use10 != "" long10scale3 = (close10 < buyzoneC10) and use10 != "" long10scale4 = (close10 < buyzoneD10) and use10 != "" long10scale5 = (close10 < buyzoneE10) and use10 != "" if ((intrades < maxtrades) and (((long10scale1) and (in10 == 0)) or ((long10scale2) and (in10 == 1)) or ((long10scale3) and (in10 == 2)) or ((long10scale4) and (in10 == 3)) or ((long10scale5) and (in10 == 4)))) cash10 := cash10 + math.round(leveragedcashpertrade/close10,2) intrades := intrades+1 in10 := in10 + 1 pnl10 := (cash10*close10) BuyArrow1 = in1[1] < in1 SellArrow1= in1[1] > in1 BuyArrow2 = in2[1] < in2 SellArrow2= in2[1] > in2 BuyArrow3 = in3[1] < in3 SellArrow3= in3[1] > in3 BuyArrow4 = in4[1] < in4 SellArrow4= in4[1] > in4 BuyArrow5 = in5[1] < in5 SellArrow5= in5[1] > in5 BuyArrow6 = in6[1] < in6 SellArrow6= in6[1] > in6 BuyArrow7 = in7[1] < in7 SellArrow7= in7[1] > in7 BuyArrow8 = in8[1] < in8 SellArrow8= in8[1] > in8 BuyArrow9 = in9[1] < in9 SellArrow9= in9[1] > in9 BuyArrow10 = in10[1] < in10 SellArrow10= in10[1] > in10 buy1 = BuyArrow1 ? use1 + str.tostring(in1) + "\n" : "" sell1 = SellArrow1 ? use1 + str.tostring(in1[1]) + "\n" : "" buy2 = BuyArrow2 ? use2 + str.tostring(in2) + "\n" : "" sell2 = SellArrow2 ? use2 + str.tostring(in2[1]) + "\n" : "" buy3 = BuyArrow3 ? use3 + str.tostring(in3) + "\n" : "" sell3 = SellArrow3 ? use3 + str.tostring(in3[1]) + "\n" : "" buy4 = BuyArrow4 ? use4 + str.tostring(in4) + "\n" : "" sell4 = SellArrow4 ? use4 + str.tostring(in4[1]) + "\n" : "" buy5 = BuyArrow5 ? use5 + str.tostring(in5) + "\n" : "" sell5 = SellArrow5 ? use5 + str.tostring(in5[1]) + "\n" : "" buy6 = BuyArrow6 ? use6 + str.tostring(in6) + "\n" : "" sell6 = SellArrow6 ? use6 + str.tostring(in6[1]) + "\n" : "" buy7 = BuyArrow7 ? use7 + str.tostring(in7) + "\n" : "" sell7 = SellArrow7 ? use7 + str.tostring(in7[1]) + "\n" : "" buy8 = BuyArrow8 ? use8 + str.tostring(in8) + "\n" : "" sell8 = SellArrow8 ? use8 + str.tostring(in8[1]) + "\n" : "" buy9 = BuyArrow9 ? use9 + str.tostring(in9) + "\n" : "" sell9 = SellArrow9 ? use9 + str.tostring(in9[1]) + "\n" : "" buy10 = BuyArrow10 ? use10 + str.tostring(in10) + "\n" : "" sell10 = SellArrow10 ? use10 + str.tostring(in10[1]) + "\n" : "" buyLabel = BuyArrow1 or BuyArrow2 or BuyArrow3 or BuyArrow4 or BuyArrow5 or BuyArrow6 or BuyArrow7 or BuyArrow8 or BuyArrow9 or BuyArrow10 ? label.new(bar_index,high*0.9,text=buy1+buy2+buy3+buy4+buy5+buy6+buy7+buy8+buy9+buy10,style=label.style_triangleup, color=color.green, textcolor=color.green, size=size.normal) : na sellLabel= SellArrow1 or SellArrow2 or SellArrow3 or SellArrow4 or SellArrow5 or SellArrow6 or SellArrow7 or SellArrow8 or SellArrow9 or SellArrow10 ? label.new(bar_index,low*1.1,text=sell1+sell2+sell3+sell4+sell5+sell6+sell7+sell8+sell9+sell10,style=label.style_triangledown, color=color.red, textcolor=color.red, size=size.normal) : na // RETURNS TABLE // // monthly returns // Inputs leftBars = 2//input(2) rightBars = 1//input(1) prec = 2//input(2, title='Return Precision') // Pivot Points swh = ta.pivothigh(leftBars, rightBars) swl = ta.pivotlow(leftBars, rightBars) hprice = 0.0 hprice := not na(swh) ? swh : hprice[1] lprice = 0.0 lprice := not na(swl) ? swl : lprice[1] le = false le := not na(swh) ? true : le[1] and high > hprice ? false : le[1] se = false se := not na(swl) ? true : se[1] and low < lprice ? false : se[1] /////////////////// // MONTHLY TABLE // new_month = month(time) != month(time[1]) new_year = year(time) != year(time[1]) eq = runningTotal //Liquidated == false ? (runningTotal) : 0 //+ openvalue // strategy.equity // Initial capital + net pnl + open pnl bar_pnl = eq / eq[1] - 1 cur_month_pnl = 0.0 cur_year_pnl = 0.0 // Current Monthly P&L cur_month_pnl := new_month ? 0.0 : (1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1 // Current Yearly P&L cur_year_pnl := new_year ? 0.0 : (1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1 // Arrays to store Yearly and Monthly P&Ls var month_pnl = array.new_float(0) var month_time = array.new_int(0) var year_pnl = array.new_float(0) var year_time = array.new_int(0) last_computed = false if not na(cur_month_pnl[1]) and (new_month)// or barstate.islast) if last_computed[1] array.pop(month_pnl) array.pop(month_time) array.push(month_pnl, cur_month_pnl[1]) array.push(month_time, time[1]) if not na(cur_year_pnl[1]) and (new_year)// or barstate.islast) if last_computed[1] array.pop(year_pnl) array.pop(year_time) array.push(year_pnl, cur_year_pnl[1]) array.push(year_time, time[1]) last_computed := barstate.islast ? true : nz(last_computed[1]) // Monthly P&L Table var monthly_table = table(na) if barstate.islast monthly_table := table.new(position.bottom_left, columns=14, rows=array.size(year_pnl) + 2, border_width=1) table.cell(monthly_table, 0, 0, '', bgcolor=#cccccc) table.cell(monthly_table, 1, 0, 'Jan', bgcolor=#cccccc) table.cell(monthly_table, 2, 0, 'Feb', bgcolor=#cccccc) table.cell(monthly_table, 3, 0, 'Mar', bgcolor=#cccccc) table.cell(monthly_table, 4, 0, 'Apr', bgcolor=#cccccc) table.cell(monthly_table, 5, 0, 'May', bgcolor=#cccccc) table.cell(monthly_table, 6, 0, 'Jun', bgcolor=#cccccc) table.cell(monthly_table, 7, 0, 'Jul', bgcolor=#cccccc) table.cell(monthly_table, 8, 0, 'Aug', bgcolor=#cccccc) table.cell(monthly_table, 9, 0, 'Sep', bgcolor=#cccccc) table.cell(monthly_table, 10, 0, 'Oct', bgcolor=#cccccc) table.cell(monthly_table, 11, 0, 'Nov', bgcolor=#cccccc) table.cell(monthly_table, 12, 0, 'Dec', bgcolor=#cccccc) table.cell(monthly_table, 13, 0, 'Year', bgcolor=#999999) for yi = 0 to array.size(year_pnl) - 1 by 1 table.cell(monthly_table, 0, yi + 1, str.tostring(year(array.get(year_time, yi))), bgcolor=#cccccc) y_color = array.get(year_pnl, yi) > 0 ? color.new(color.green, transp=50) : color.new(color.red, transp=80) table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100, prec)), bgcolor=y_color, text_color=color.white) for mi = 0 to array.size(month_time) - 1 by 1 m_row = year(array.get(month_time, mi)) - year(array.get(year_time, 0)) + 1 m_col = month(array.get(month_time, mi)) m_color = array.get(month_pnl, mi) > 0 ? color.new(color.green, transp=70) : color.new(color.red, transp=90) table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100, prec)), bgcolor=m_color, text_color=color.white)
Volume based support resistance with Swing
https://www.tradingview.com/script/xHVjHuDT-Volume-based-support-resistance-with-Swing/
Ankit_1618
https://www.tradingview.com/u/Ankit_1618/
381
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/ // © Ankit_1618 //@version=4 study("Volume based support resistance with Swing", overlay=true) length = input(20) mid_point = hlc3 basis_vol = sma(volume, length) sd2_vol = basis_vol + stdev(volume, length) // plot(volume, style=plot.style_columns, color=close>open ? color.green : close<open ? color.red : color.orange) // plot(basis_vol, color=color.red) // plot(sd2_vol, color=color.blue) up_fractal_volume = volume > basis_vol extreme_volume = volume > basis_vol and volume > sd2_vol var hv_sr = 0. var ev_sr = 0. if up_fractal_volume hv_sr := mid_point if extreme_volume ev_sr := mid_point plot(hv_sr, color= hv_sr!=hv_sr[1] ? na : color.gray) plot(ev_sr, color= ev_sr!=ev_sr[1] ? na : color.blue, linewidth=2) plot(mid_point, color=color.purple, style=plot.style_circles) //SWING Levels // based on William's Fractal indicator n = 2 up_fractal = high down_fractal = low up = ((up_fractal[n+2] < up_fractal[n]) and (up_fractal[n+1] < up_fractal[n]) and (up_fractal[n-1] < up_fractal[n]) and (up_fractal[n-2] < up_fractal[n])) or ((up_fractal[n+3] < up_fractal[n]) and (up_fractal[n+2] < up_fractal[n]) and (up_fractal[n+1] == up_fractal[n]) and (up_fractal[n-1] < up_fractal[n]) and (up_fractal[n-2] < up_fractal[n])) or ((up_fractal[n+4] < up_fractal[n]) and (up_fractal[n+3] < up_fractal[n]) and (up_fractal[n+2] == up_fractal[n]) and (up_fractal[n+1] <= up_fractal[n]) and (up_fractal[n-1] < up_fractal[n]) and (up_fractal[n-2] < up_fractal[n])) or ((up_fractal[n+5] < up_fractal[n]) and (up_fractal[n+4] < up_fractal[n]) and (up_fractal[n+3] == up_fractal[n]) and (up_fractal[n+2] == up_fractal[n]) and (up_fractal[n+1] <= up_fractal[n]) and (up_fractal[n-1] < up_fractal[n]) and (up_fractal[n-2] < up_fractal[n])) or ((up_fractal[n+6] < up_fractal[n]) and (up_fractal[n+5] < up_fractal[n]) and (up_fractal[n+4] == up_fractal[n]) and (up_fractal[n+3] <= up_fractal[n]) and (up_fractal[n+2] == up_fractal[n]) and (up_fractal[n+1] <= up_fractal[n]) and (up_fractal[n-1] < up_fractal[n]) and (up_fractal[n-2] < up_fractal[n])) down = ((down_fractal[n+2] > down_fractal[n]) and (down_fractal[n+1] > down_fractal[n]) and (down_fractal[n-1] > down_fractal[n]) and (down_fractal[n-2] > down_fractal[n])) or ((down_fractal[n+3] > down_fractal[n]) and (down_fractal[n+2] > down_fractal[n]) and (down_fractal[n+1] == down_fractal[n]) and (down_fractal[n-1] > down_fractal[n]) and (down_fractal[n-2] > down_fractal[n])) or ((down_fractal[n+4] > down_fractal[n]) and (down_fractal[n+3] > down_fractal[n]) and (down_fractal[n+2] == down_fractal[n]) and (down_fractal[n+1] >= down_fractal[n]) and (down_fractal[n-1] > down_fractal[n]) and (down_fractal[n-2] > down_fractal[n])) or ((down_fractal[n+5] > down_fractal[n]) and (down_fractal[n+4] > down_fractal[n]) and (down_fractal[n+3] == down_fractal[n]) and (down_fractal[n+2] == down_fractal[n]) and (down_fractal[n+1] >= down_fractal[n]) and (down_fractal[n-1] > down_fractal[n]) and (down_fractal[n-2] > down_fractal[n])) or ((down_fractal[n+6] > down_fractal[n]) and (down_fractal[n+5] > down_fractal[n]) and (down_fractal[n+4] == down_fractal[n]) and (down_fractal[n+3] >= down_fractal[n]) and (down_fractal[n+2] == down_fractal[n]) and (down_fractal[n+1] >= down_fractal[n]) and (down_fractal[n-1] > down_fractal[n]) and (down_fractal[n-2] > down_fractal[n])) LowerHigh = up and up_fractal[n] < valuewhen(up, up_fractal[n], 1) HigherHigh = up and up_fractal[n] > valuewhen(up, up_fractal[n], 1) EqualHigh = up and up_fractal[n] == valuewhen(up, up_fractal[n], 1) LowerLow = down and down_fractal[n] < valuewhen(down, down_fractal[n], 1) HigherLow = down and down_fractal[n] > valuewhen(down, down_fractal[n], 1) EqualLow = down and down_fractal[n] == valuewhen(down, down_fractal[n], 1) plotshape(LowerHigh, style=shape.labeldown, text='lh', location=location.abovebar, offset=-2, color=na,textcolor=color.red, transp=0) plotshape(HigherHigh, style=shape.labeldown, text='hh', location=location.abovebar, offset=-2, color=na,textcolor=color.green, transp=0) plotshape(EqualHigh, style=shape.labeldown, text='EH', location=location.abovebar, offset=-2, color=na,textcolor=color.gray, transp=0) plotshape(LowerLow, style=shape.labelup, text='ll', location=location.belowbar, offset=-2, color=na,textcolor=color.red, transp=0) plotshape(HigherLow, style=shape.labelup, text='hl', location=location.belowbar, offset=-2, color=na,textcolor=color.green, transp=0) plotshape(EqualLow, style=shape.labelup, text='EL', location=location.belowbar, offset=-2, color=na,textcolor=color.gray, transp=0)
Watermark Light - JD
https://www.tradingview.com/script/RecckLBf-Watermark-Light-JD/
Duyck
https://www.tradingview.com/u/Duyck/
154
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Duyck //@version=5 indicator("Watermark Light - JD", shorttitle = "Watermark Light", overlay = true) // Inputs //{ wm_size = input.string(size.huge, title = "watermark size", options = [size.tiny, size.small, size.normal, size.large, size.huge], inline = "WM") wm_col = input.color (color.new(color.gray, 60), title = "", inline = "WM") wm_posV = input.string("top", title = "", options = ["top", "middle", "bottom"], inline = "WM") wm_posH = input.string("center", title = "", options = ["left", "center", "right"], inline = "WM") slot1 = input.string("Timeframe", options = ["Timeframe", "Ticker", "Custom Text", "Empty"]) slot2 = input.string("Ticker", options = ["Timeframe", "Ticker", "Custom Text", "Empty"]) slot3 = input.string("Empty", options = ["Timeframe", "Ticker", "Custom Text", "Empty"]) custom_txt = input.string("custom text", title = "custom text") //} // Set Watermark //{ var watermark = table.new(wm_posV + "_" + wm_posH, 1, 1) period = timeframe.period string watermark_txt = "" string TF_txt = "" string Ticker_txt = "" TF_txt := switch period == "S" => "1S" period == "60" => "1H" period == "120" => "2H" period == "180" => "3H" period == "240" => "4H" period == "360" => "6H" => period + (timeframe.isminutes ? "M" : "") Ticker_txt := ((syminfo.type == "crypto" or syminfo.type == "forex") ? (syminfo.basecurrency + "/" + syminfo.currency) : syminfo.ticker) slot1_txt = switch slot1 "Timeframe" => TF_txt "Ticker" => Ticker_txt "Custom Text" => custom_txt "Empty" => "" slot2_txt = switch slot2 "Timeframe" => TF_txt "Ticker" => Ticker_txt "Custom Text" => custom_txt "Empty" => "" slot3_txt = switch slot3 "Timeframe" => TF_txt "Ticker" => Ticker_txt "Custom Text" => custom_txt "Empty" => "" watermark_txt := slot1_txt + (slot1_txt == "" ? "" : "\n") + slot2_txt + (slot2_txt == "" ? "" : "\n") + slot3_txt // if barstate.isfirst table.cell_set_text (watermark, 0, 0, text = watermark_txt) table.cell_set_text_color(watermark, 0, 0, text_color = wm_col) table.cell_set_text_size (watermark, 0, 0, text_size = wm_size) //}
RSI Multi Length [LuxAlgo]
https://www.tradingview.com/script/1O935I6Y-RSI-Multi-Length-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
3,373
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("RSI Multi Length [LuxAlgo]") max = input(20,'Maximum Length') min = input(10,'Minimum Length') overbought = input.float(70,step=10) oversold = input.float(30,step=10) src = input(close) //---- rsi_avg_dn_css = input(#ff5d00,'Average RSI Gradient',group='Style',inline='inline1') rsi_avg_up_css = input(#2157f3,'',group='Style',inline='inline1') upper_css = input(#0cb51a,'Upper Level',group='Style') lower_css = input(#ff1100,'Lower Level',group='Style') ob_area = input(color.new(#0cb51a,70),'Overbought Area',group='Style') os_area = input(color.new(#ff1100,70),'Oversold Area',group='Style') //---- N = max-min+1 diff = nz(src - src[1]) var num = array.new_float(N,0) var den = array.new_float(N,0) //---- k = 0 overbuy = 0 oversell = 0 avg = 0. for i = min to max alpha = 1/i num_rma = alpha*diff + (1-alpha)*array.get(num,k) den_rma = alpha*math.abs(diff) + (1-alpha)*array.get(den,k) rsi = 50*num_rma/den_rma + 50 avg += rsi overbuy := rsi > overbought ? overbuy + 1 : overbuy oversell := rsi < oversold ? oversell + 1 : oversell array.set(num,k,num_rma) array.set(den,k,den_rma) k += 1 //---- avg_rsi = avg/N buy_rsi_ma = 0. sell_rsi_ma = 0. buy_rsi_ma := nz(buy_rsi_ma[1] + overbuy/N*(avg_rsi - buy_rsi_ma[1]),avg_rsi) sell_rsi_ma := nz(sell_rsi_ma[1] + oversell/N*(avg_rsi - sell_rsi_ma[1]),avg_rsi) //---- var tb = table.new(position.top_right,2,2) if barstate.islast table.cell(tb,0,0,'Overbought',text_color=color.gray,bgcolor=na) table.cell(tb,1,0,'Oversold',text_color=color.gray,bgcolor=na) table.cell(tb,0,1,str.tostring(overbuy/N*100,'#.##')+' %',text_color=#26a69a,bgcolor=color.new(#26a69a,80)) table.cell(tb,1,1,str.tostring(oversell/N*100,'#.##')+' %',text_color=#ef5350,bgcolor=color.new(#ef5350,80)) //---- css = color.from_gradient(avg_rsi,sell_rsi_ma,buy_rsi_ma,rsi_avg_dn_css,rsi_avg_up_css) plot(avg_rsi,'Average Multi Length RSI',color=css) up = plot(buy_rsi_ma,'Upper Channel',color=upper_css) dn = plot(sell_rsi_ma,'Lower Channel',color=lower_css) per_over = plot(overbuy/N*100,'Overbought Area',color=color.new(ob_area,100),editable=false) per_under = plot(100 - oversell/N*100,'Oversold Area',color=color.new(os_area,100),editable=false) upper = plot(100,color=na,editable=false,display=display.none) lower = plot(0,color=na,editable=false,display=display.none) fill(per_over,lower,ob_area) fill(upper,per_under,os_area) fill(up,dn,color.new(css,90)) hline(50,color=color.new(color.gray,50))
S&P500 VIX Volatility Warning Indicator
https://www.tradingview.com/script/57OlrwM1-S-P500-VIX-Volatility-Warning-Indicator/
TradeAutomation
https://www.tradingview.com/u/TradeAutomation/
67
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // @version = 5 // Author = TradeAutomation indicator("S&P500 VIX Volatility Warning Indicator", shorttitle="SP500 VIX Volatility Warning") // Pull in VIX data res = input.timeframe(title="VIX Resolution", defval="60") vix = request.security("CBOE:VIX", res, high) // Calculates the Variance and Defines the Volatility Warning mean = ta.sma(vix, input.int(2400, "Mean Length For Variance Calc")) SquaredDifference = math.pow(vix-mean, 2) VolWarningLength = input.int(20, "Sustain Warning For X Bars", step=5) SquaredDifferenceThreshold = input.int(100, "Variance Threshold", tooltip="The indicator will go up once the variance exceeds this threshold") VolatilityWarning = ta.highest(SquaredDifference, VolWarningLength)>SquaredDifferenceThreshold Warning = VolatilityWarning ? 1 : 0 // Plot PlotVarianceInput = input.bool(false, "Plot the Variance?") IndicatorColor = Warning > 0.5 ? color.red : Warning < 0.5 ? color.purple : na plot(Warning, color=IndicatorColor, linewidth=2) VariancePlot = PlotVarianceInput == true ? SquaredDifference : na plot(VariancePlot, color=color.purple) hline(input(1, "Custom H-Line"))
[JL] n Bars Average True Range
https://www.tradingview.com/script/vv9qfpLV-JL-n-Bars-Average-True-Range/
Jesse.Lau
https://www.tradingview.com/u/Jesse.Lau/
10
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Jesse.Lau //@version=5 indicator(title="[JL] n Bars Average True Range", shorttitle="nATR", overlay=false, timeframe="", timeframe_gaps=true) length = input.int(title="nATR Length", defval=120, minval=1) n = input.int(title="nBars", defval=12, minval=1) smoothing = input.string(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"]) ma_function(source, length) => switch smoothing "RMA" => ta.rma(source, length) "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) => ta.wma(source, length) n_true_range() => math.max(ta.highest(high,n) - ta.lowest(low,n), math.max(math.abs(ta.highest(high,n) - close[n+1]), math.abs(ta.lowest(low,n) - close[n+1]))) plot(ma_function(n_true_range(), length), title = "nATR", color=color.new(#B71C1C, 0))
Financial Statement Indicator by zdmre
https://www.tradingview.com/script/wiJMcWZ7-Financial-Statement-Indicator-by-zdmre/
zdmre
https://www.tradingview.com/u/zdmre/
593
study
5
MPL-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('Financial Statement Indicator by zdmre', format=format.volume) period = input.string('FY', 'Financial Period', options=['FQ', 'FY'], tooltip='FQ: Financial Quarter\nFY: Financial Year') plotdata = input.string('EPS', 'Plot Data', options=['Revenue', 'Net Margin', 'EPS', 'EPS-D', 'P/E']) int datasize = input.int(8, 'Data size', minval=2)+2 opt_textsize = input.string(size.small, 'Text Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group='table') opt_textcolor = input(color.white, "Text Color", tooltip='Title') opt_datatextcolor = input(color.black, "Text Color", tooltip='Data') opt_panelbgcolor = input(color.blue, "Background Color", tooltip='Panel') opt_cellbgcolor = input(color.orange, "Cell Background Color", tooltip='Non-filtered Cell') is_opt_pos = input.string(position.middle_left, 'Table \nPosition\n #1', options= [position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group='table') t_1 = input.bool(true, title = "TABLE-1 Income Statement", group = "table") t_2 = input.bool(true, title = "TABLE-2 Balance Sheet", group = "table") t_3 = input.bool(true, title = "TABLE-3 Statistics & Cash Flow", group = "table") t_4 = input.bool(true, title = "TABLE-4 Statistics (Others)", group = "table") //Filtering colorGroup = 'Filtering Data by Color' showValueFilter = input(true, title='Enabled', group = colorGroup , tooltip='if enabled, tables colored with below data. Otherwise, with periods.') m_val = input.float(15, title = 'Net/Op Margin Filter', group=colorGroup, tooltip='Net Margin & Operating Margin - Income Statement - Table 1.\n\nIIf NM/OM > value, cell to green; else cell to red\ndefval=5') //Table-1 epsval = input.float(0, title = 'EPS', group=colorGroup, tooltip='Earning per Share value & EPS Estimated - Income Statement - Table 1.\n\nIIf EPS > value, cell to green; else cell to red\ndefval=0') peval = input.float(15, title = 'P/E', group=colorGroup, tooltip='Price to Earnings Ratio value (FY) - Income Statement - Table 1.\n\nIIf 0 < P/E < value, cell to green; else cell to red \ndefval=15') //Table-2 deval = input.float(0.5, title = 'D/E', group=colorGroup, tooltip='Debt/Equity Ratio value - Balance Sheet - Table 2.\n\nIIf D/E < value, cell to green; else cell to red \ndefval=0.5') pbval = input.float(3, title = 'P/B', group=colorGroup, tooltip='Price to Book Value - Balance Sheet -Table 2.\n\nIIf 0 < P/B < value, cell to green; else cell to red \ndefval=3 ') //Table-3 roeval = input.float(10, title = 'ROE', group=colorGroup, tooltip='Return on Equity value - Statistics - Table 3.\n\nIIf ROE > value, cell to green; else cell to red \ndefval=10 ') roepbval = input.float(3, title = 'ROE/PB', group=colorGroup, tooltip='Return on Equity / Price to Book Ratio - Balance Sheet -Table 2.\n\nIIf ROE/PB > value, cell to green; else cell to red \ndefval=3 ') roaval = input.float(5, title = 'ROA', group=colorGroup, tooltip='Return on Asset value - Statistics - Table 3.\n\nIIf ROA > value, cell to green; else cell to red \ndefval=5') roicval = input.float(7, title = 'ROIC', group=colorGroup, tooltip='Return on Investment Capital value - Statistics - Table 3.\n\nIIf ROIC > value, cell to green; else cell to red \ndefval=7') qrval = input.float(1, title = 'QR', group=colorGroup, tooltip='Quick Ratio value - Statistics - Table 3.\n\nIIf QR > value, cell to green; else cell to red \ndefval=1') //Table-4 dyieldval = input.float(2, title = 'Dividend Yield', group=colorGroup, tooltip='Dividend Yield - Statistics - Table 4.\n\nIf Dividend Yield < value, cell to red; else cell to green\ndefval=2') pegval = input.float(1, title = 'PEG', group=colorGroup, tooltip='PEG - Statistics - Table 4.\n\nIf PEG Yield > value, cell to red; else cell to green\ndefval=1 ') peforw = input.float(15, title = 'P/E Forward', group=colorGroup, tooltip='P/E Forward - Statistics - Table 4.\n\nIf P/E Forward < value, cell to red; else cell to green\ndefval=15') sgr = input.float(5, title = 'SGR', group=colorGroup, tooltip='Sustainable Growth Rate - Statistics - Table 4.\n\nIf SGR < value, cell to red; else cell to green\ndefval=5') altmanval = input.float(1.8, title = 'Altman Z-Score', group=colorGroup, tooltip='Altman Z-Score - Statistics - Table 4.\n\nIf Altman < value, cell to red; else cell to green\ndefval=1.8 ') beneishval = input.float(-1.78, title = 'Beneish Model', group=colorGroup, tooltip='Beneish Model - Statistics - Table 4.\n\nIf Beneish < value, cell to green; else cell to red\ndefval=-1.78 ') springateval = input.float(0.862, title = 'Springate Score', group=colorGroup, tooltip='Springate Score - Statistics - Table 4.\n\nIf Springate < value, cell to red; else cell to green\ndefval=0.862 ') zmijval = input.float(0.5, title = 'Zmijewski Score', group=colorGroup, tooltip='Zmijewski Score - Statistics - Table 4.\n\nIf Zmijewski < value, cell to red; else cell to green\ndefval=0.5 ') //Timestamp get_Fin_data(_finID, _period) => request.financial(symbol=syminfo.tickerid, financial_id=_finID, period=_period, gaps=barmerge.gaps_on, ignore_invalid_symbol=true) symtemp ="ESD_FACTSET:" + syminfo.prefix + ";" + syminfo.ticker earningsPublishTimeYear = request.security(symtemp + ";EARNINGS", "3M", time, lookahead=barmerge.lookahead_on) // Income Statement eps = get_Fin_data('EARNINGS_PER_SHARE_BASIC', period) opmar = get_Fin_data('OPERATING_MARGIN', period) netmar = get_Fin_data('NET_MARGIN',period) pe = close/get_Fin_data('EARNINGS_PER_SHARE_BASIC', "TTM") revenue = get_Fin_data('TOTAL_REVENUE', period) epsest = get_Fin_data('EARNINGS_ESTIMATE', period) // Balance Sheet curasst = get_Fin_data('TOTAL_CURRENT_ASSETS', period) // bs01 ttasst = get_Fin_data('TOTAL_ASSETS', period) // bs02 tteq = get_Fin_data('TOTAL_EQUITY', period) // bs03 pb = close / get_Fin_data('BOOK_VALUE_PER_SHARE', period) // bs05 tdebt = get_Fin_data('TOTAL_DEBT', period) de = tdebt/tteq // Statistics & Cash Flow roe = get_Fin_data('RETURN_ON_EQUITY', period) roepb = get_Fin_data('RETURN_ON_EQUITY_ADJUST_TO_BOOK', period) roa = get_Fin_data('RETURN_ON_ASSETS', period) qr = get_Fin_data('QUICK_RATIO', period) roic = get_Fin_data('RETURN_ON_INVESTED_CAPITAL', period) fcf = get_Fin_data('FREE_CASH_FLOW', period) // Statistics (Others) altman = get_Fin_data('ALTMAN_Z_SCORE', period) beneish = get_Fin_data('BENEISH_M_SCORE', period) dpayout = get_Fin_data('DIVIDEND_PAYOUT_RATIO', period) dyield = get_Fin_data('DIVIDENDS_YIELD', period) graham = get_Fin_data('GRAHAM_NUMBERS', period) piotroski = get_Fin_data('PIOTROSKI_F_SCORE', period) peg = get_Fin_data('PEG_RATIO', period) peforward = get_Fin_data('PRICE_EARNINGS_FORWARD', period) springate = get_Fin_data('SPRINGATE_SCORE', period) sgrowthrate = get_Fin_data('SUSTAINABLE_GROWTH_RATE', period) zmij = get_Fin_data('ZMIJEWSKI_SCORE', period) datatoplot = plotdata == 'EPS' ? eps : plotdata == 'Revenue' ? revenue : plotdata == 'Net Margin' ? netmar : plotdata == 'P/E' ? pe : na //Table-1 var date = array.new_int(datasize) // Date (year) var datem_ = array.new_int(datasize) // Date (month) var is01 = array.new_float(datasize) // Revenue var is02 = array.new_float(datasize) // Net margin var is03 = array.new_float(datasize) // EPS var is04 = array.new_float(datasize) //Operating margin var is05 = array.new_float(datasize) //P/E Ratio var is06 = array.new_float(datasize) // EPS Estimate //Table-2 var bs01 = array.new_float(datasize) // Current Asset var bs02 = array.new_float(datasize) // Total Asset var bs03 = array.new_float(datasize) // Total Equity var bs04 = array.new_float(datasize) // Price to Book var bs05 = array.new_float(datasize) // Total Debt var bs06 = array.new_float(datasize) // D/E Ratio var bs07 = array.new_float(datasize) // BETA //Table-3 var cf01 = array.new_float(datasize) // roe var cf02 = array.new_float(datasize) // roa var cf03 = array.new_float(datasize) // roic var cf04 = array.new_float(datasize) // qr var cf05 = array.new_float(datasize) // fcf var cf06 = array.new_float(datasize) // roe/pb //Table-4 var st01 = array.new_float(datasize) // altman var st02 = array.new_float(datasize) // beneish var st03 = array.new_float(datasize) // dpayout var st04 = array.new_float(datasize) // dyield var st06 = array.new_float(datasize) // graham var st07 = array.new_float(datasize) // piotroski var st08 = array.new_float(datasize) // peforward var st09 = array.new_float(datasize) // springate var st10 = array.new_float(datasize) // sgrowthrate var st11 = array.new_float(datasize) // zmij var st12 = array.new_float(datasize) //peg // BETA Calc symbolMarket = input.symbol("NDX", "Beta Benchmark") lengthbeta = input(title = "Beta Period", defval=252) symov = request.security(symbolMarket, 'D', close) retass = ((close - close[1])/close) retsym = ((symov - symov[1])/symov) asstd = ta.stdev(retass, lengthbeta) marktstd = ta.stdev(retsym, lengthbeta) Beta = ta.correlation(retass, retsym, lengthbeta) * asstd / marktstd if not na(datatoplot) label.new(bar_index, datatoplot, text=str.tostring(plotdata == 'EPS' ? datatoplot : plotdata == 'Revenue' ? datatoplot / 1000000 : plotdata == 'Net Margin' ? datatoplot : datatoplot, plotdata == 'EPS' ? '#,##0.000' : plotdata == 'Revenue' ? '#,##0' + ' M' : plotdata == 'Net Income' ? '#,##0' : '#,##0.000'),size=opt_textsize, textcolor=color.white) array.push(date, earningsPublishTimeYear) array.push(datem_, time) array.push(is01, revenue) array.push(is02, netmar) array.push(is03, eps) array.push(is04, opmar) array.push(is05, pe) array.push(is06, epsest) array.shift(date) array.shift(datem_) array.shift(is01) array.shift(is02) array.shift(is03) array.shift(is04) array.shift(is05) array.shift(is06) // Table-2 array.push(bs01, curasst) array.push(bs02, ttasst) array.push(bs03, tteq) array.push(bs04, pb) array.push(bs05, tdebt) array.push(bs06, de) array.push(bs07, Beta) array.shift(bs01) array.shift(bs02) array.shift(bs03) array.shift(bs04) array.shift(bs05) array.shift(bs06) array.shift(bs07) // Table-3 array.push(cf01, roe) array.push(cf02, roa) array.push(cf03, roic) array.push(cf04, qr) array.push(cf05, fcf) array.push(cf06, roepb) array.shift(cf01) array.shift(cf02) array.shift(cf03) array.shift(cf04) array.shift(cf05) array.shift(cf06) // Table-4 array.push(st01, altman) array.push(st02, beneish) array.push(st03, dpayout) array.push(st04, dyield) array.push(st06, graham) array.push(st07, piotroski) array.push(st08, peforward) array.push(st09, springate) array.push(st10, sgrowthrate) array.push(st11, zmij) array.push(st12, peg) array.shift(st01) array.shift(st02) array.shift(st03) array.shift(st04) array.shift(st06) array.shift(st07) array.shift(st08) array.shift(st09) array.shift(st10) array.shift(st11) array.shift(st12) //Table with Datas var tbis = table.new(is_opt_pos, 35, datasize, frame_color=color.black, frame_width=1, border_width=1, border_color=color.black) headerColor = color.new(color.blue, 20) if barstate.isfirst table.cell(tbis, 0, 0, text = "", bgcolor = headerColor) table.merge_cells(tbis, 0, 0, 1, 0) if t_1 table.cell(tbis, 2, 0, text = "Income Statement", bgcolor = headerColor, text_color=color.white) table.merge_cells(tbis, 2, 0, 7, 0) if t_2 table.cell(tbis, 9, 0, text = "Balance Sheet", bgcolor = headerColor, text_color=color.white) table.merge_cells(tbis, 9, 0, 15, 0) if t_3 table.cell(tbis, 17, 0, text = "Statistics & Cash Flow", bgcolor = headerColor, text_color=color.white) table.merge_cells(tbis, 17, 0, 22, 0) if t_4 table.cell(tbis, 24, 0, text = "Statistics (Others)", bgcolor = headerColor, text_color=color.white) table.merge_cells(tbis, 24, 0, 34, 0) if barstate.islast and t_1 and ( t_2 or t_3 or t_4 ) table.cell(tbis, 8, 0, '', bgcolor = color.black) table.merge_cells(tbis, 8, 0, 8, datasize-1) if barstate.islast and t_2 and (t_3 or t_4) table.cell(tbis, 16, 0, '', bgcolor = color.black) table.merge_cells(tbis, 16, 0, 16, datasize-1) if barstate.islast and t_3 and t_4 table.cell(tbis, 23, 0, '', bgcolor = color.black) table.merge_cells(tbis, 23, 0, 23, datasize-1) if barstate.islast and t_1 table.cell(tbis, 0, 1, '', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 1, 1, 'Period', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 2, 1, 'Revenue', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 3, 1, 'Net\nMargin %', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 4, 1, 'Operating\nMargin %', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 5, 1, 'EPS', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(epsval)) table.cell(tbis, 6, 1, 'EPS\nEst', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(epsval)) table.cell(tbis, 7, 1, 'P/E', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(peval)) if barstate.islast and t_2 table.cell(tbis, 0, 1, '', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 1, 1, 'Period', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 9, 1, 'Current \nAsset', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 10, 1, 'Total \nAsset', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 11, 1, 'Total \nEquity', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 12, 1, 'P/B', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(pbval)) table.cell(tbis, 13, 1, 'Total\nDebt', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 14, 1, 'D/E', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(deval)) table.cell(tbis, 15, 1, 'β', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: 1") if barstate.islast and t_3 table.cell(tbis, 0, 1, '', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 1, 1, 'Period', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 17, 1, 'ROE', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(roeval)) table.cell(tbis, 18, 1, 'ROE/\nPB', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(roepbval)) table.cell(tbis, 19, 1, 'ROA', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(roaval)) table.cell(tbis, 20, 1, 'ROIC', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(roicval)) table.cell(tbis, 21, 1, 'Quick\nRatio', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(qrval)) table.cell(tbis, 22, 1, 'Free \nCash Flow', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) if barstate.islast and t_4 table.cell(tbis, 0, 1, '', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 1, 1, 'Period', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 24, 1, 'Dividend\nPayout', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 25, 1, 'Dividend\nYield', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(dyieldval)) table.cell(tbis, 26, 1, 'PEG', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(pegval)) table.cell(tbis, 27, 1, 'P/E\nForward', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(peforw)) table.cell(tbis, 28, 1, 'SGR', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(sgr)) table.cell(tbis, 29, 1, 'Altman', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(altmanval)) table.cell(tbis, 30, 1, 'Beneish', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(beneishval)) table.cell(tbis, 31, 1, 'Graham', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 32, 1, 'Piotroski', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) table.cell(tbis, 33, 1, 'Springate', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(springateval)) table.cell(tbis, 34, 1, 'Zmijewski', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor, tooltip="Control Value: "+str.tostring(zmijval)) for i = 2 to datasize-1 by 1 if barstate.islast and (t_1 or t_2 or t_3 or t_4) table.cell(tbis, 0, i, str.tostring(i), bgcolor = opt_panelbgcolor, text_size=opt_textsize) table.cell(tbis, 1, i, (str.format('{0, date, Y}', array.get(date, i))+str.format('{0, date, MMM}', array.get(datem_, i))), bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor) if barstate.islast and t_1 table.cell(tbis, 2, i, str.tostring(array.get(is01, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is01, i)) ? opt_datatextcolor : array.get(is01, i) <= array.get(is01, i - 1) ? #FF6961 : color.lime) // Revenue table.cell(tbis, 3, i, str.tostring(array.get(is02, i) / 1, '#,##0')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is02, i)) ? opt_datatextcolor : array.get(is02, i) <= array.get(is02, i - 1) ? #FF6961 : color.lime) // Net Margin table.cell(tbis, 4, i, str.tostring(array.get(is04, i) / 1, '#,##0')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is04, i)) ? opt_datatextcolor : array.get(is04, i) <= array.get(is04, i - 1) ? #FF6961 : color.lime) // Operating Margin table.cell(tbis, 5, i, str.tostring(array.get(is03, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is03, i)) ? opt_datatextcolor : array.get(is03, i) <= array.get(is03, i - 1) ? #FF6961 : color.lime) // EPS table.cell(tbis, 6, i, str.tostring(array.get(is06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is06, i)) ? opt_datatextcolor : array.get(is06, i) <= array.get(is06, i - 1) ? #FF6961 : color.lime) // EPS est table.cell(tbis, 7, i, str.tostring(array.get(is05, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is05, i)) ? opt_datatextcolor : array.get(is05, i) >= array.get(is05, i - 1) ? #FF6961 : array.get(is05, i) <= 0 ? #FF6961 : color.lime) //P/E Ratio if barstate.islast and showValueFilter and t_1 table.cell(tbis, 3, i, str.tostring(array.get(is02, i) / 1, '#,##0')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is02, i)) ? opt_datatextcolor : array.get(is02, i) <= m_val ? opt_cellbgcolor : color.lime) // Net Margin table.cell(tbis, 4, i, str.tostring(array.get(is04, i) / 1, '#,##0')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is04, i)) ? opt_datatextcolor : array.get(is04, i) <= m_val ? opt_cellbgcolor : color.lime) // Operating Margin table.cell(tbis, 5, i, str.tostring(array.get(is03, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is03, i)) ? opt_datatextcolor : array.get(is03, i) <= epsval ? #FF6961 : color.lime) // EPS table.cell(tbis, 6, i, str.tostring(array.get(is06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is06, i)) ? opt_datatextcolor : array.get(is06, i) <= epsval ? #FF6961 : color.lime) // EPS est table.cell(tbis, 7, i, str.tostring(array.get(is05, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is05, i)) ? opt_datatextcolor : array.get(is05, i) >= peval ? #FF6961 : array.get(is05, i) <= 0 ? #FF6961 : color.lime) //P/E Ratio //Non-filtered table.cell(tbis, 2, i, str.tostring(array.get(is01, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(is01, i)) ? opt_datatextcolor : array.get(is01, i) <= array.get(is01, i - 1) ? opt_cellbgcolor : color.lime) // Revenue || NON-FILTERED if barstate.islast and t_2 table.cell(tbis, 9, i, str.tostring(array.get(bs01, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs01, i)) ? opt_datatextcolor : array.get(bs01, i) <= array.get(bs01, i - 1) ? #FF6961 : color.lime) // Current Asset table.cell(tbis, 10, i, str.tostring(array.get(bs02, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs02, i)) ? opt_datatextcolor : array.get(bs02, i) <= array.get(bs02, i - 1) ? #FF6961 : color.lime) // Total Asset table.cell(tbis, 11, i, str.tostring(array.get(bs03, i)/ 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs03, i)) ? opt_datatextcolor : array.get(bs03, i) <= array.get(bs03, i - 1) ? #FF6961 : color.lime) // Total Equity table.cell(tbis, 12, i, str.tostring(array.get(bs04, i), '#,##0.0'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs04, i)) ? opt_datatextcolor : array.get(bs04, i) >= array.get(bs04, i - 1) ? #FF6961 : array.get(bs04, i) <= 0 ? #FF6961 : color.lime) // Price to Book table.cell(tbis, 13, i, str.tostring(array.get(bs05, i)/ 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs05, i)) ? opt_datatextcolor : array.get(bs05, i) >= array.get(bs05, i - 1) ? #FF6961 : color.lime) // Total Debt table.cell(tbis, 14, i, str.tostring(array.get(bs06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs06, i)) ? opt_datatextcolor : array.get(bs06, i) >= array.get(bs06, i - 1) ? #FF6961 : array.get(bs06, i) < 0 ? #FF6961 : color.lime) // D/E Ratio table.cell(tbis, 15, i, str.tostring(array.get(bs07, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs07, i)) ? opt_datatextcolor : math.abs(array.get(bs07, i)) >= math.abs(array.get(bs07, i - 1)) ? #d14dff : #00ffff ) // BETA if barstate.islast and showValueFilter and t_2 table.cell(tbis, 12, i, str.tostring(array.get(bs04, i), '#,##0.0'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs04, i)) ? opt_datatextcolor : array.get(bs04, i) >= pbval ? #FF6961 : array.get(bs04, i) <= 0 ? #FF6961 : color.lime) // Price to Book table.cell(tbis, 14, i, str.tostring(array.get(bs06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs06, i)) ? opt_datatextcolor : array.get(bs06, i) >= deval ? #FF6961 : array.get(bs06, i) < 0 ? #FF6961 : color.lime) // D/E Ratio table.cell(tbis, 15, i, str.tostring(array.get(bs07, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(bs07, i)) ? opt_datatextcolor : math.abs(array.get(bs07, i)) >= 1 ? #d14dff : #00ffff ) // Beta //Non-filtered table.cell(tbis, 9, i, str.tostring(array.get(bs01, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=array.get(bs01, i) <= array.get(bs01, i - 1) ? opt_cellbgcolor : color.lime) // Current Asset || NON-FILTERED table.cell(tbis, 10, i, str.tostring(array.get(bs02, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=array.get(bs02, i) <= array.get(bs02, i - 1) ? opt_cellbgcolor : color.lime) // Total Asset || NON-FILTERED table.cell(tbis, 11, i, str.tostring(array.get(bs03, i)/ 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=array.get(bs03, i) <= array.get(bs03, i - 1) ? opt_cellbgcolor : color.lime) // Total Equity || NON-FILTERED table.cell(tbis, 13, i, str.tostring(array.get(bs05, i)/ 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=array.get(bs05, i) >= array.get(bs05, i - 1) ? opt_cellbgcolor : color.lime) // Total Debt || NON-FILTERED if barstate.islast and t_3 table.cell(tbis, 17, i, str.tostring(array.get(cf01, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf01, i)) ? opt_datatextcolor : array.get(cf01, i) <= array.get(cf01, i - 1) ? #FF6961 : color.lime) // roe table.cell(tbis, 18, i, str.tostring(array.get(cf06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf06, i)) ? opt_datatextcolor : array.get(cf06, i) <= array.get(cf06, i - 1) ? #FF6961 : color.lime) // roe/pb table.cell(tbis, 19, i, str.tostring(array.get(cf02, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf02, i)) ? opt_datatextcolor : array.get(cf02, i) <= array.get(cf02, i - 1) ? #FF6961 : color.lime) // roa table.cell(tbis, 20, i, str.tostring(array.get(cf03, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf03, i)) ? opt_datatextcolor : array.get(cf03, i) <= array.get(cf03, i - 1) ? #FF6961 : color.lime) // roic table.cell(tbis, 21, i, str.tostring(array.get(cf04, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf04, i)) ? opt_datatextcolor : array.get(cf04, i) <= array.get(cf04, i - 1) ? #FF6961 : color.lime) // qr table.cell(tbis, 22, i, str.tostring(array.get(cf05, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf05, i)) ? opt_datatextcolor : array.get(cf05, i) <= array.get(cf05, i - 1) ? #FF6961 : color.lime) // fcf if barstate.islast and showValueFilter and t_3 table.cell(tbis, 17, i, str.tostring(array.get(cf01, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf01, i)) ? opt_datatextcolor : array.get(cf01, i) <= roeval ? #FF6961 : color.lime) // roe table.cell(tbis, 18, i, str.tostring(array.get(cf06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf06, i)) ? opt_datatextcolor : array.get(cf06, i) <= roepbval ? #FF6961 : color.lime) // roe/pb table.cell(tbis, 19, i, str.tostring(array.get(cf02, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf02, i)) ? opt_datatextcolor : array.get(cf02, i) <= roaval ? #FF6961 : color.lime) // roa table.cell(tbis, 20, i, str.tostring(array.get(cf03, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf03, i)) ? opt_datatextcolor : array.get(cf03, i) <= roicval ? #FF6961 : color.lime) // roic table.cell(tbis, 21, i, str.tostring(array.get(cf04, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf04, i)) ? opt_datatextcolor : array.get(cf04, i) <= qrval ? #FF6961 : color.lime) // qr //Non-filtered table.cell(tbis, 22, i, str.tostring(array.get(cf05, i) / 1000000, '#,##0' + 'M'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(cf05, i)) ? opt_datatextcolor : array.get(cf05, i) <= array.get(cf05, i - 1) ? opt_cellbgcolor : color.lime) // fcf || NON-FILTERED if barstate.islast and t_4 table.cell(tbis, 24, i, str.tostring(array.get(st03, i), '#,##0.00')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st03, i)) ? opt_datatextcolor : array.get(st03, i) <= array.get(st03, i - 1) ? #FF6961 : color.lime) // dpayout table.cell(tbis, 25, i, str.tostring(array.get(st04, i), '#,##0.00')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st04, i)) ? opt_datatextcolor : array.get(st04, i) <= array.get(st04, i - 1) ? #FF6961 : color.lime) // dyield table.cell(tbis, 26, i, str.tostring(array.get(st12, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st12, i)) ? opt_datatextcolor : array.get(st12, i) >= array.get(st12, i - 1) or array.get(st12, i) > 1 ? #FF6961 : color.lime) // peg table.cell(tbis, 27, i, str.tostring(array.get(st08, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st08, i)) ? opt_datatextcolor : array.get(st08, i) >= array.get(st08, i - 1) ? #FF6961 : color.lime) // peforward table.cell(tbis, 28, i, str.tostring(array.get(st10, i), '#,##0.00')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st10, i)) ? opt_datatextcolor : array.get(st10, i) <= array.get(st10, i - 1) ? #FF6961 : color.lime) // sgrowthrate table.cell(tbis, 29, i, str.tostring(array.get(st01, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st01, i)) ? opt_datatextcolor : array.get(st01, i) >= array.get(st01, i - 1) ? #FF6961 : color.lime) // altman table.cell(tbis, 30, i, str.tostring(array.get(st02, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st02, i)) ? opt_datatextcolor : array.get(st02, i) >= array.get(st02, i - 1) ? #FF6961 : color.lime) // beneish table.cell(tbis, 31, i, str.tostring(array.get(st06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st06, i)) ? opt_datatextcolor : #a9cce3) // graham table.cell(tbis, 32, i, str.tostring(array.get(st07, i), '#,##0'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st07, i)) ? opt_datatextcolor : array.get(st07, i) <= array.get(st07, i - 1) ? #FF6961 : color.lime) // piotroski table.cell(tbis, 33, i, str.tostring(array.get(st09, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st09, i)) ? opt_datatextcolor : array.get(st09, i) <= array.get(st09, i - 1) ? #FF6961 : color.lime) // springate table.cell(tbis, 34, i, str.tostring(array.get(st11, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st11, i)) ? opt_datatextcolor : array.get(st11, i) >= array.get(st11, i - 1) ? #FF6961 : color.lime) // zmij if barstate.islast and showValueFilter and t_4 table.cell(tbis, 24, i, str.tostring(array.get(st03, i), '#,##0.00')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st03, i)) ? opt_datatextcolor : array.get(st03, i) >= 70 ? opt_cellbgcolor : color.lime) // dpayout table.cell(tbis, 25, i, str.tostring(array.get(st04, i), '#,##0.00')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st04, i)) ? opt_datatextcolor : array.get(st04, i) <= dyieldval ? #FF6961 : color.lime) // dyield table.cell(tbis, 26, i, str.tostring(array.get(st12, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st12, i)) ? opt_datatextcolor : array.get(st12, i) >= pegval or array.get(st12, i) < 0 ? #FF6961 : color.lime) // peg table.cell(tbis, 27, i, str.tostring(array.get(st08, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st08, i)) ? opt_datatextcolor : array.get(st08, i) >= peforw ? #FF6961 : color.lime) // peforward table.cell(tbis, 28, i, str.tostring(array.get(st10, i), '#,##0.00')+'%', text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st10, i)) ? opt_datatextcolor : array.get(st10, i) <= sgr ? #FF6961 : color.lime) // sgrowthrate table.cell(tbis, 29, i, str.tostring(array.get(st01, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st01, i)) ? opt_datatextcolor : array.get(st01, i) <= altmanval ? #FF6961 : color.lime) // altman// table.cell(tbis, 30, i, str.tostring(array.get(st02, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st02, i)) ? opt_datatextcolor : array.get(st02, i) >= beneishval ? #FF6961 : color.lime) // beneish table.cell(tbis, 32, i, str.tostring(array.get(st07, i), '#,##0'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st07, i)) ? opt_datatextcolor : array.get(st07, i) <= 0 ? #c0392b : array.get(st07, i) <= 1 ? #ec7063 : array.get(st07, i) <= 2 ? #e67e22 : array.get(st07, i) <= 3 ? #fad7a0 : array.get(st07, i) <= 4 ? #85c1e9 : array.get(st07, i) <= 5 ? #a9cce3 : array.get(st07, i) <= 6 ? #a9dfbf : array.get(st07, i) <= 7 ? #7dcea0 : array.get(st07, i) <= 8 ? #52be80 : color.lime) // piotroski table.cell(tbis, 33, i, str.tostring(array.get(st09, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st09, i)) ? opt_datatextcolor : array.get(st09, i) <= springateval ? #FF6961 : color.lime) // springate table.cell(tbis, 34, i, str.tostring(array.get(st11, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st11, i)) ? opt_datatextcolor : array.get(st11, i) <= zmijval and array.get(st11, i) >= 0 ? #FF6961 : color.lime) // zmij //Non-filtered table.cell(tbis, 31, i, str.tostring(array.get(st06, i), '#,##0.00'), text_size=opt_textsize, text_color=opt_datatextcolor, bgcolor=na(array.get(st06, i)) ? opt_datatextcolor : #a9cce3) // graham || NON-FILTERED plot(datatoplot, style=plot.style_circles, linewidth=4, join=true)
Pi Frame (Dynamic)
https://www.tradingview.com/script/efBZHKyj-Pi-Frame-Dynamic/
fvideira
https://www.tradingview.com/u/fvideira/
29
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © fvideira //@version=5 indicator("Pi Frame (Dynamic)", overlay=true) // Study of Pi levels from Eliza123123's quantative trading series: https://youtu.be/S7UMA__wz74 // Inputs piStd = input.bool(true, "Standard Multiples", inline = "Standard", group = "Pi Constant 3.14159") StdCol = input.color(color.new(color.black, 0), "", inline = "Standard", group = "Pi Constant 3.14159") piPrime = input.bool(true, "Prime Multiples", inline = "Prime", group = "Pi Constant 3.14159") PrimeCol = input.color(color.new(color.silver, 0), "", inline = "Prime", group = "Pi Constant 3.14159") piMulti = input.bool(true, "Multples of 10", inline = "Multi", group = "Pi Constant 3.14159") MultiCol = input.color(color.new(color.orange, 10), "", inline = "Multi", group = "Pi Constant 3.14159") extendRight = input.bool(false, "Extend Lines") var extending = extend.none if extendRight extending := extend.right if not extendRight extending := extend.none // Scale Factors & Constants scale = 0.0 if close >= 10000 scale := 1000 if close >= 1000 and close <=9999.999999 scale := 100 if close >= 100 and close <=999.999999 scale := 10 if close >= 10 and close <=99.999999 scale := 1 if close >= 1 and close <=9.999999 scale := 0.1 if close >= 0.1 and close <=0.999999 scale := 0.01 if close >= 0.01 and close <=0.099999 scale := 0.001 if close >= 0.001 and close <=0.009999 scale := 0.0001 // Variables pi = 3.14159 * scale pi1 = 0.0 pi2 = 0.0 pi3 = 0.0 pi4 = 0.0 pi5 = 0.0 pi6 = 0.0 pi7 = 0.0 pi8 = 0.0 pi9 = 0.0 pi10 = 0.0 pi11 = 0.0 pi12 = 0.0 pi13 = 0.0 pi14 = 0.0 pi15 = 0.0 pi16 = 0.0 pi17 = 0.0 pi18 = 0.0 pi19 = 0.0 pi20 = 0.0 pi21 = 0.0 pi22 = 0.0 pi23 = 0.0 pi24 = 0.0 pi25 = 0.0 pi26 = 0.0 pi27 = 0.0 pi28 = 0.0 pi29 = 0.0 pi30 = 0.0 pi31 = 0.0 pi32 = 0.0 pi33 = 0.0 pi34 = 0.0 pi35 = 0.0 pi36 = 0.0 pi37 = 0.0 pi38 = 0.0 // If clauses (for inputs to work as on/off) if piStd pi4 := pi*4 pi6 := pi*6 pi8 := pi*8 pi9 := pi*9 pi12 := pi*12 pi14 := pi*14 pi15 := pi*15 pi16 := pi*16 pi18 := pi*18 pi21 := pi*21 pi22 := pi*22 pi24 := pi*24 pi25 := pi*25 pi26 := pi*26 pi27 := pi*27 pi28 := pi*28 pi32 := pi*32 pi33 := pi*33 pi34 := pi*34 pi35 := pi*35 pi36 := pi*36 pi38 := pi*38 else pi4 := na pi6 := na pi8 := na pi9 := na pi12 := na pi14 := na pi15 := na pi16 := na pi18 := na pi21 := na pi22 := na pi24 := na pi25 := na pi26 := na pi27 := na pi28 := na pi32 := na pi33 := na pi34 := na pi35 := na pi36 := na pi38 := na if piPrime pi1 := pi*1 pi2 := pi*2 pi3 := pi*3 pi5 := pi*5 pi7 := pi*7 pi11 := pi*11 pi13 := pi*13 pi17 := pi*17 pi19 := pi*19 pi23 := pi*23 pi29 := pi*29 pi31 := pi*31 pi37 := pi*37 else pi1 := na pi2 := na pi3 := na pi5 := na pi7 := na pi11 := na pi13 := na pi17 := na pi19 := na pi23 := na pi29 := na pi31 := na pi37 := na if piMulti pi10 := pi*10 pi20 := pi*20 pi30 := pi*30 else pi10 := na pi20 := na pi30 := na // Plots lpi1 = line.new(bar_index[4999], pi1, bar_index, pi1, color = PrimeCol, width = 1, extend = extending) lpi2 = line.new(bar_index[4999], pi2, bar_index, pi2, color = PrimeCol, width = 1, extend = extending) lpi3 = line.new(bar_index[4999], pi3, bar_index, pi3, color = PrimeCol, width = 1, extend = extending) lpi4 = line.new(bar_index[4999], pi4, bar_index, pi4, color = StdCol, width = 1, extend = extending) lpi5 = line.new(bar_index[4999], pi5, bar_index, pi5, color = PrimeCol, width = 1, extend = extending) lpi6 = line.new(bar_index[4999], pi6, bar_index, pi6, color = StdCol, width = 1, extend = extending) lpi7 = line.new(bar_index[4999], pi7, bar_index, pi7, color = PrimeCol, width = 1, extend = extending) lpi8 = line.new(bar_index[4999], pi8, bar_index, pi8, color = StdCol, width = 1, extend = extending) lpi9 = line.new(bar_index[4999], pi9, bar_index, pi9, color = PrimeCol, width = 1, extend = extending) lpi10 = line.new(bar_index[4999], pi10, bar_index, pi10, color = MultiCol, width = 1, extend = extending) lpi11 = line.new(bar_index[4999], pi11, bar_index, pi11, color = PrimeCol, width = 1, extend = extending) lpi12 = line.new(bar_index[4999], pi12, bar_index, pi12, color = StdCol, width = 1, extend = extending) lpi13 = line.new(bar_index[4999], pi13, bar_index, pi13, color = PrimeCol, width = 1, extend = extending) lpi14 = line.new(bar_index[4999], pi14, bar_index, pi14, color = StdCol, width = 1, extend = extending) lpi15 = line.new(bar_index[4999], pi15, bar_index, pi15, color = StdCol, width = 1, extend = extending) lpi16 = line.new(bar_index[4999], pi16, bar_index, pi16, color = StdCol, width = 1, extend = extending) lpi17 = line.new(bar_index[4999], pi17, bar_index, pi17, color = PrimeCol, width = 1, extend = extending) lpi18 = line.new(bar_index[4999], pi18, bar_index, pi18, color = StdCol, width = 1, extend = extending) lpi19 = line.new(bar_index[4999], pi19, bar_index, pi19, color = PrimeCol, width = 1, extend = extending) lpi20 = line.new(bar_index[4999], pi20, bar_index, pi20, color = MultiCol, width = 1, extend = extending) lpi21 = line.new(bar_index[4999], pi21, bar_index, pi21, color = StdCol, width = 1, extend = extending) lpi22 = line.new(bar_index[4999], pi22, bar_index, pi22, color = StdCol, width = 1, extend = extending) lpi23 = line.new(bar_index[4999], pi23, bar_index, pi23, color = PrimeCol, width = 1, extend = extending) lpi24 = line.new(bar_index[4999], pi24, bar_index, pi24, color = StdCol, width = 1, extend = extending) lpi25 = line.new(bar_index[4999], pi25, bar_index, pi25, color = StdCol, width = 1, extend = extending) lpi26 = line.new(bar_index[4999], pi26, bar_index, pi26, color = StdCol, width = 1, extend = extending) lpi27 = line.new(bar_index[4999], pi27, bar_index, pi27, color = PrimeCol, width = 1, extend = extending) lpi28 = line.new(bar_index[4999], pi28, bar_index, pi28, color = StdCol, width = 1, extend = extending) lpi29 = line.new(bar_index[4999], pi29, bar_index, pi29, color = PrimeCol, width = 1, extend = extending) lpi30 = line.new(bar_index[4999], pi30, bar_index, pi30, color = MultiCol, width = 1, extend = extending) lpi31 = line.new(bar_index[4999], pi31, bar_index, pi31, color = PrimeCol, width = 1, extend = extending) lpi32 = line.new(bar_index[4999], pi32, bar_index, pi32, color = StdCol, width = 1, extend = extending) lpi33 = line.new(bar_index[4999], pi33, bar_index, pi33, color = StdCol, width = 1, extend = extending) lpi34 = line.new(bar_index[4999], pi34, bar_index, pi34, color = StdCol, width = 1, extend = extending) lpi35 = line.new(bar_index[4999], pi35, bar_index, pi35, color = StdCol, width = 1, extend = extending) lpi36 = line.new(bar_index[4999], pi36, bar_index, pi36, color = StdCol, width = 1, extend = extending) lpi37 = line.new(bar_index[4999], pi37, bar_index, pi37, color = PrimeCol, width = 1, extend = extending) lpi38 = line.new(bar_index[4999], pi38, bar_index, pi38, color = StdCol, width = 1, extend = extending) //////
Period Dollar Cost Average Backtester
https://www.tradingview.com/script/OtiTmYxZ-Period-Dollar-Cost-Average-Backtester/
ThiagoSchmitz
https://www.tradingview.com/u/ThiagoSchmitz/
62
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ThiagoSchmitz //@version=5 indicator("Period Dollar Cost Average Backtester", "PDCA BAcktester", precision=8) float amount = input.float(10.0, "Amount to buy") float fee = input.float(0.1, "Broker Fee %") int frequency = input.int(1, "Frequency", inline="frequency") string unit = input.string("hours", "", options=["minutes", "hours", "days"], inline="frequency") int startDate = input.time(timestamp("Jan 01 2018"), "Starting Date") int endDate = input.time(timestamp("Jan 01 2022"), "Ending Date") float cellWidth = input.float(14.0, "Info Cell Width", group="panel", inline="cell") float cellHeight = input.float(10.0, "Info Cell Height", group="panel", inline="cell") var float coins = 0.0 var float invested = 0.0 var float firstEntry = 0.0 var float totalFee = 0.0 var bool configured = false var float grossProfit = 0.0 var float grossLoss = 0.0 var int totalTrades = 0 var float drawdown = 0.0 var float maxRelativeDrawdown = 0.0 var int maxConsecutiveWins = 0 var int maxConsecutiveLosses = 0 var int consecutiveWins = 0 var int consecutiveLosses = 0 var int winningTrades = 0 var int losingTrades = 0 var table info = table.new(position.middle_right, 10,10, #212121, #313131, 1, #313131, 1) bool window = time >= startDate and time < endDate if not configured table.cell(info, 0, 0, "Total Invested: $0.00", cellWidth, cellHeight, color.green, text.align_left) table.cell(info, 1, 0, "Total Net Profit: $0.00", cellWidth, cellHeight, color.fuchsia, text.align_left) table.cell(info, 0, 1, "Holding Profit: $0.00", cellWidth, cellHeight, color.yellow, text.align_left) table.cell(info, 1, 1, "Entry Price: $0.00", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 2, "Gross Profit: $0.00", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 1, 2, "Gross Loss: $0.00", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 3, "Profit Factor: 0", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 1, 3, "Profit/Trade: $0.00", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 4, "Recovery Factor: 0.00", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 1, 4, "Total Asset: 0.00", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 5, "Absolute Drawdown: $0.00 (0.00%)", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 1, 5, "Relative Drawdown: $0.00 (0.00%)", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 6, "Total Trades: 0", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 1, 6, "Total Fee: $0.00 (0.00%)", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 7, "Total Losing Trades: 0", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 1, 7, "Total Winning Trades: 0", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 8, "Max Consecutive Wins: 0", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 1, 8, "Max Consecutive Losses: 0", cellWidth, cellHeight, #BDBDBD, text.align_left) configured := true trigger = switch unit "days" => dayofmonth(time) % frequency == 0 and hour(time) == 0 and minute(time) == 0 "hours" => hour(time) % frequency == 0 and minute(time) == 0 "minutes" => minute(time) % frequency == 0 float holdingProfit = firstEntry > 0 ? (invested / firstEntry) * close : 0.0 // quote float convertedProfit = coins * close float change = math.abs(ta.change(convertedProfit)) float netProfit = grossProfit / grossLoss if window float relativeDrawdown = 0.0 if trigger float mult = 1.0 totalTrades := totalTrades + 1 if timeframe.isdaily and unit == "hours" mult := 24.0 / frequency else if timeframe.isdaily and unit == "minutes" mult := 1440 / frequency else if timeframe.isintraday and unit == "minutes" mult := timeframe.multiplier / frequency else if timeframe.isintraday and unit == "hours" and timeframe.multiplier > 60 mult := (timeframe.multiplier / 60) / frequency invested := invested + (amount * mult) float tradeFee = (amount * mult) * fee / 100 coins := coins + ((amount * mult) / close) - (tradeFee / close) totalFee := totalFee + tradeFee if firstEntry == 0.0 firstEntry := close if convertedProfit > convertedProfit[1] grossProfit := grossProfit + change winningTrades := winningTrades + 1 else if convertedProfit < convertedProfit[1] grossLoss := grossLoss + change losingTrades := losingTrades + 1 if grossLoss - grossProfit > drawdown drawdown := grossLoss - grossProfit if convertedProfit > nz(convertedProfit[1]) consecutiveWins := consecutiveWins + 1 maxConsecutiveWins := maxConsecutiveWins < consecutiveWins ? consecutiveWins : maxConsecutiveWins consecutiveLosses := 0 relativeDrawdown := 0 else if convertedProfit < nz(convertedProfit[1]) consecutiveLosses := consecutiveLosses + 1 maxConsecutiveLosses := maxConsecutiveLosses < consecutiveLosses ? consecutiveLosses : maxConsecutiveLosses relativeDrawdown := relativeDrawdown + change maxRelativeDrawdown := maxRelativeDrawdown < relativeDrawdown ? relativeDrawdown : maxRelativeDrawdown consecutiveWins := 0 else consecutiveLosses := 0 consecutiveWins := 0 relativeDrawdown := 0 table.cell_set_text(info, 0, 0, "Total Invested: $" + str.tostring(math.round(invested, 2))) table.cell_set_text(info, 1, 0, "Total Net Profit: $" + str.tostring(math.round(grossProfit - grossLoss, 2)) + " (" + str.tostring(math.round((grossProfit - grossLoss) * 100 / invested, 2)) + "%)") if firstEntry > 0 table.cell_set_text(info, 0, 1, "Holding Profit: $" + str.tostring(math.round(holdingProfit, 2)) + " (" + str.tostring(math.round(holdingProfit * 100 / invested, 2)) + "%)") table.cell_set_text(info, 1, 1, "Entry Price: $" + str.tostring(math.round(firstEntry, 2))) table.cell_set_text(info, 0, 2, "Gross Profit: $" + str.tostring(math.round(grossProfit, 2))) table.cell_set_text(info, 1, 2, "Gross Loss: $" + str.tostring(math.round(grossLoss, 2))) table.cell_set_text(info, 0, 3, "Profit Factor: " + str.tostring(math.round(netProfit, 2))) table.cell_set_text(info, 1, 3, "Profit/Trade: $" + str.tostring(math.round((grossProfit - grossLoss) / totalTrades, 2))) table.cell_set_text(info, 0, 4, "Recovery Factor: " + str.tostring(math.round(netProfit / maxRelativeDrawdown, 8))) table.cell_set_text(info, 1, 4, "Total Asset Bought: " + str.tostring(math.round(coins, 8))) table.cell_set_text(info, 0, 5, "Absolute Drawdown: $" + str.tostring(math.round(drawdown, 2)) + " (" + str.tostring(math.round(drawdown * 100 / invested, 3)) + "%)") table.cell_set_text(info, 1, 5, "Relative Drawdown: $" + str.tostring(math.round(maxRelativeDrawdown, 2)) + " (" + str.tostring(math.round(maxRelativeDrawdown * 100 / invested, 3)) + "%)") table.cell_set_text(info, 0, 6, "Total Trades: " + str.tostring(totalTrades)) table.cell_set_text(info, 1, 6, "Total Fee: $" + str.tostring(math.round(totalFee, 2)) + " (" + str.tostring(math.round(totalFee * 100 / invested, 3)) + "%)") table.cell_set_text(info, 0, 7, "Total Winning Trades: " + str.tostring(winningTrades)) table.cell_set_text(info, 1, 7, "Total Losing Trades: " + str.tostring(losingTrades)) table.cell_set_text(info, 0, 8, "Max Consecutive Wins: " + str.tostring(maxConsecutiveWins)) table.cell_set_text(info, 1, 8, "Max Consecutive Losses: " + str.tostring(maxConsecutiveLosses)) plot(window and firstEntry > 0 ? holdingProfit : na, "Holding Profit", color.yellow) plot(window ? convertedProfit : na, "Converted Profit", color.fuchsia) plot(window ? invested : na, "Invested Amount", color.lime, 2)
How Old Is this Bull Run Getting? Check MA Test Bars Since
https://www.tradingview.com/script/SgGMKJRi-How-Old-Is-this-Bull-Run-Getting-Check-MA-Test-Bars-Since/
TradeStation
https://www.tradingview.com/broker/TradeStation/
557
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/ // © TradeStation //@version=4 //MA test bars since plots how many bars since price touched or crossed a given moving. It's color coded green (last price above MA) or red (last price under MA) //MA types are: // 1 - simple // 2 - exponential // 3 - Hull // 4 - weighted // 5 - volume weighted study(title="MA test bars since") length = input(50, minval=1, title="Length") src = input(close, title="Source") matype = input(1, minval=1, maxval=5, title="AvgType") simplema = sma(src,length) exponentialma = ema(src,length) hullma = wma(2*wma(src, length/2)-wma(src, length), round(sqrt(length))) weightedma = wma(src, length) volweightedma = vwma(src, length) avgval = matype==1 ? simplema : matype==2 ? exponentialma : matype==3 ? hullma : matype==4 ? weightedma : matype==5 ? volweightedma : na var counter = 0 var Pcolor = color.gray // this counts bars if (( low>avgval ) or (high < avgval )) counter := counter + 1 // these next expressions set counter to 0 because the condition has been met // this detects price touching but not crossing if (( high > avgval) and (low< avgval) ) counter :=0 // these detects price gapping under if ((close<avgval) and (close[1]>avgval[1])) counter :=0 // these detects price gapping above if ((close>avgval) and (close[1]<avgval[1])) counter :=0 // set the line color based on above/below MA if ( close<avgval) Pcolor := color.red if ( close>avgval) Pcolor := color.green plot(counter, color=Pcolor, style=plot.style_histogram, linewidth=3)
Indicator: Gap Finder [KL]
https://www.tradingview.com/script/2QA79kTC-Indicator-Gap-Finder-KL/
DojiEmoji
https://www.tradingview.com/u/DojiEmoji/
179
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © DojiEmoji //@version=5 indicator(title="Gap Finder [KL]", overlay=true) var string TYPE_PERCENT = "Percentage" var string TYPE_ABS = "Absolute" var string FILLED_DEL = "Delete" var string FILLED_KEEP = "Show as dotted lines" var int extend_len = 100 // Settings var string thres_type = input.string(TYPE_PERCENT, options=[TYPE_ABS, TYPE_PERCENT], title="Threshold type") var float thres_pcnt = input.float(0, title="Threshold (%)", minval=0, maxval=100)/100 var float thres_point = input.float(0, title="Threshold (points)", minval=0) var color col_up = input.color(color.new(#00ff0a, 0), title="Gap up", inline="Color") var color col_down = input.color(color.new(#ff160C, 0), title="Gap down", inline="Color") var bool _extend_lns = input.bool(false, title="Extend lines", tooltip="Suggested chart settings -> Scale price chart only") var string extend_lns = _extend_lns ? extend.right : extend.none var bool wick_fill = input.bool(true, title="Gap touched by wick considered as filled") var string _choice = input.string(FILLED_DEL, options=[FILLED_DEL, FILLED_KEEP], title="Lines for filled gaps") var bool del_lns = _choice == FILLED_DEL // For comparison: p1,p2,p3,p4 float p1_upGap = math.max(open, close)[1] float p2_upGap = low float p3_dnGap = math.min(open, close)[1] float p4_dnGap = high // Finding gaps bool gap_up = false if thres_type == TYPE_PERCENT gap_up := (p2_upGap > p1_upGap and math.abs(p2_upGap/p1_upGap - 1) > thres_pcnt) else if thres_type == TYPE_ABS gap_up := (p2_upGap > p1_upGap and math.abs(p2_upGap - p1_upGap) > thres_point) bool gap_down = false if thres_type == TYPE_PERCENT gap_down := (p4_dnGap < p3_dnGap and math.abs(p4_dnGap/p3_dnGap - 1) > thres_pcnt) else if thres_type == TYPE_ABS gap_down := (p4_dnGap < p3_dnGap and math.abs(p4_dnGap - p3_dnGap) > thres_point) // Inserting lines var line[] arr_upgap = array.new_line() var line[] arr_dngap = array.new_line() if gap_up float _p = p1_upGap line ln = line.new(bar_index, _p, bar_index+extend_len, _p, xloc.bar_index, extend_lns, col_up) array.push(arr_upgap, ln) else if gap_down float _p = p3_dnGap line ln = line.new(bar_index, _p, bar_index+extend_len, _p, xloc.bar_index, extend_lns, col_down) array.push(arr_dngap, ln) // Search for filled gaps, remove them from array if array.size(arr_upgap) > 0 for i=0 to array.size(arr_upgap) - 1 line ln = array.pop(arr_upgap) float _y = line.get_y1(ln) float _src_fill = wick_fill ? low : close if _src_fill < _y and high[1] > _y if del_lns line.delete(ln) else line.set_style(ln, line.style_dotted) line.set_x2(ln, bar_index) line.set_extend(ln, extend.none) else array.unshift(arr_upgap, ln) if array.size(arr_dngap) > 0 for i=0 to array.size(arr_dngap) - 1 ln = array.pop(arr_dngap) _y = line.get_y1(ln) _src_fill = wick_fill ? high : close if _src_fill > _y and low[1] < _y if del_lns line.delete(ln) else line.set_style(ln, line.style_dotted) line.set_x2(ln, bar_index) line.set_extend(ln, extend.none) else array.unshift(arr_dngap, ln) // Alerts alertcondition(gap_up or gap_down, title = "Gap up/down", message = "{{ticker}} just gapped.")
Sessions with High/Low Diff
https://www.tradingview.com/script/ZR4yxhA4-Sessions-with-High-Low-Diff/
SamAccountX
https://www.tradingview.com/u/SamAccountX/
138
study
5
MPL-2.0
// This source code provided free and open-source as defined by the terms of the Mozilla Public License 2.0 (https://mozilla.org/MPL/2.0/) // with the following additional requirements: // // 1. Citations for sources and references must be maintained and updated when appropriate // 2. Links to strategy references included in indicator tooptips and/or alerts should be retained to give credit to the original source // while also providing a freely available source of information on proper use and interpretation // // Author: SamAccountX // // The main purpose of this indicator is to facilitate backtesting, but it may also be useful for traders to easily identify the current // active/open trading sessions on lower-timeframe charts. // // This indicator also tracks the session high/low difference and plots it as a label on the last candle of the session once the last // bar of that session has finished printing and a new candle openend. The position and direction of the label is based on the // session open and close - if the session open is greater than the session close (which would equate to the equivilent of a red candle), // the label will be printed UNDER the last candle, and vice versa if the session close is above the session open. // // The number printed inside the label is the difference between the session high and the session low, scaled to the minimum tick value of the chart. // // Note: There is a Pinescript maximum of 500 lables allowed on any chart. While I could have gotten fancy and done some wizardry with label arrays, // I didn't really see a point to it. If labels are enabled for all 4 sessions at the same time, that would still have them available for the past 125 // sessions, which would be about 6 months (approx 252 trading days per year, and this would cover 125 of them). If you limit to 2 sessions, you double // your potential look-back to almost a year (250 days ot of the 252 average trading days each year), and for a single session, you double it yet again // to just under 2 years. // // While it would be easy to add alerts on sessions opening/closing, I didn't see a purpose or value in that as it would be little more than a // glorified alarm clock. If I get enough demand to add them, I will gladly consider it. // // //@version=5 indicator(title='Sessions with High/Low Diff', shorttitle='Sess w/ H/L', overlay=true, max_labels_count=500) // Inputs // // session windows g_Sessions = 'Session Settings' showLondonSession = input.bool(title='', defval=true, group=g_Sessions, inline='showLondonSession') londonSession = input.session(title='London Session', defval='0300-1200', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showLondonSession') showNYSession = input.bool(title='', defval=true, group=g_Sessions, inline='showNYSession') nySession = input.session(title='New York Session', defval='0800-1700', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showNYSession') showTokyoSession = input.bool(title='', defval=true, group=g_Sessions, inline='showTokyoSession') tokyoSession = input.session(title='Tokyo Session', defval='2000-0400', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showTokyoSession') showSydneySession = input.bool(title='', defval=true, group=g_Sessions, inline='showSydneySession') sydneySession = input.session(title='Sydney Session', defval='1700-0200', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showSydneySession') // // Low/High Resolution // res = input.timeframe(title='Session High/Low Timeframe', defval='D', options=['D', 'W', 'M'], group='Session High/Low Resolution', tooltip='Select the time interval to use for identifying ' + // 'the session-high and session-low data points. This affects what is shown on the chart as the session high/low. For timeframes less than 1 week, the daily value is recommended.') // // Color inputs g_Colors = 'Color inputs' londonBGColor = input.color(title='London Session - Background:', group=g_Colors, defval=color.rgb(0, 255, 0, 90), inline='lc', tooltip='Colors to use for identifying London/Europe session info') londonTextColor = input.color(title='Label Text:', group=g_Colors, defval=color.rgb(0, 0, 0, 0), inline='lc', tooltip='Colors to use for identifying London/Europe session info') nyBGColor = input.color(title='New York Session - Background:', group=g_Colors, inline="nc", defval=color.rgb(255, 0, 0, 90), tooltip='Colors to use for identifying New York/US session info') nyTextColor = input.color(title='Label Text:', group=g_Colors, inline="nc", defval=color.rgb(255, 255, 255, 0), tooltip='Colors to use for identifying New York/US session info') asiaBGColor = input.color(title='Tokyo Session - Background:', group=g_Colors, inline="tc", defval=color.rgb(255, 255, 0, 90), tooltip='Colors to use for identifying Tokyo/Asia session info') asiaTextColor = input.color(title='Label Text:', group=g_Colors, inline="tc", defval=color.rgb(0, 0, 0, 0), tooltip='Colors to use for identifying Tokyo/Asia session info') ausBGColor = input.color(title='Sydney Session - Background:', group=g_Colors, inline="ss", defval=color.rgb(0, 255, 255, 90), tooltip='Colors to use for identifying Sydney/Australia session info') ausTextColor = input.color(title='Label Text:', group=g_Colors, inline="ss", defval=color.rgb(0, 0, 0, 0), tooltip='Colors to use for identifying Sydney/Australia session info') // // High/Low control inputs doHighLowDiffLabels = input.bool(title='Label session high/low difference', defval=false, group='hlControls', tooltip='Show labels indicating difference between session high and session low') // Functions // // Function to determine if current bar falls into the input session isInSession(session) => barSessionTime = time(timeframe.period, session) inSession = not na(barSessionTime) inSession // Force-pull price via security function to help ensure consistency on non-standard chart types... // // Explicitly define our ticker to help ensure that we're always getting ACTUAL price instead of relying on the input // ticker info and input vars (as they tend to inherit the type from what's displayed on the current chart) realPriceTicker = ticker.new(prefix=syminfo.prefix, ticker=syminfo.ticker) // // This MAY be unnecessary, but in testing I've found some oddities when trying to use this on varying chart types // like on the HA chart, where the source referece for the price skews to the values for the current chart type // instead of the expected pure-price values. For example, the 'source=close' reference - 'close' would be actual price // close on a normal candlestick chart, but would be the HA close on the HA chart. [o, h, l, c] = request.security(symbol=realPriceTicker, timeframe='', expression=[open, high, low, close], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off) // Session - London // // Full-height fill bgcolor(color=isInSession(londonSession) and showLondonSession ? londonBGColor : na, title='London Session', editable=false) // // Track session high/low var float londonSessionHigh = na var float londonSessionLow = na var float londonSessionOpen = na var float londonSessionClose = na var bool isLondonSessionStart = false isInLondonSession = isInSession(londonSession) if (isInLondonSession) // In session, check for session start... if (not isInLondonSession[1]) // Start of session, reset high and low tracking vars londonSessionHigh := h londonSessionLow := l isLondonSessionStart := true londonSessionOpen := o else londonSessionHigh := math.max(h, londonSessionHigh[1]) londonSessionLow := math.min(l, londonSessionLow[1]) // Being a bit lazy here and updating close every candle instead of explicitly // waiting for the last candle close to grab the session close value, but the result // will still be the same... londonSessionClose := c // Calculate session high/low diff // plot(title="LondonHigh", series=isInLondonSession ? londonSessionHigh : na, color=londonBGColor, style=plot.style_circles) // plot(title="LondonLow", series=isInLondonSession ? londonSessionLow : na, color=londonBGColor, style=plot.style_circles) londonSessDiff = londonSessionHigh[1] - londonSessionLow[1] // Plot session high/low diff as label if enables if (isInLondonSession[1] and not isInLondonSession and doHighLowDiffLabels and showLondonSession) r = color.r(londonBGColor) g = color.g(londonBGColor) b = color.b(londonBGColor) isCloseBelowOpen = londonSessionClose < londonSessionOpen ? true : false label.new(bar_index[1], isCloseBelowOpen ? londonSessionLow : londonSessionHigh, str.tostring(londonSessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=londonTextColor) // Session - New York bgcolor(color=isInSession(nySession) and showNYSession ? nyBGColor : na, title='New York Session', editable=false) // // Track session high/low var float nySessionHigh = na var float nySessionLow = na var float nySessionOpen = na var float nySessionClose = na var bool isNYSessionStart = false isInNYSession = isInSession(nySession) if (isInNYSession) // In session, check for session start... if (not isInNYSession[1]) // Start of session, reset high and low tracking vars nySessionHigh := h nySessionLow := l isNYSessionStart := true nySessionOpen := o else nySessionHigh := math.max(h, nySessionHigh[1]) nySessionLow := math.min(l, nySessionLow[1]) // Being a bit lazy here and updating close every candle instead of explicitly // waiting for the last candle close to grab the session close value, but the result // will still be the same... nySessionClose := c // Calculate session high/low diff nySessDiff = nySessionHigh[1] - nySessionLow[1] // Plot session high/low diff as label if enables if (isInNYSession[1] and not isInNYSession and doHighLowDiffLabels and showNYSession) r = color.r(nyBGColor) g = color.g(nyBGColor) b = color.b(nyBGColor) isCloseBelowOpen = nySessionClose < nySessionOpen ? true : false label.new(bar_index[1], isCloseBelowOpen ? nySessionLow : nySessionHigh, str.tostring(nySessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=nyTextColor) // Session - Tokyo bgcolor(color=isInSession(tokyoSession) and showTokyoSession ? asiaBGColor : na, title='Tokyo Session', editable=false) // // Track session high/low var float tokyoSessionHigh = na var float tokyoSessionLow = na var float tokyoSessionOpen = na var float tokyoSessionClose = na var bool isTokyoSessionStart = false isInTokyoSession = isInSession(tokyoSession) if (isInTokyoSession) // In session, check for session start... if (not isInTokyoSession[1]) // Start of session, reset high and low tracking vars tokyoSessionHigh := h tokyoSessionLow := l isTokyoSessionStart := true tokyoSessionOpen := o else tokyoSessionHigh := math.max(h, tokyoSessionHigh[1]) tokyoSessionLow := math.min(l, tokyoSessionLow[1]) // Being a bit lazy here and updating close every candle instead of explicitly // waiting for the last candle close to grab the session close value, but the result // will still be the same... tokyoSessionClose := c // Calculate session high/low diff tokyoSessDiff = tokyoSessionHigh[1] - tokyoSessionLow[1] // Plot session high/low diff as label if enables if (isInTokyoSession[1] and not isInTokyoSession and doHighLowDiffLabels and showTokyoSession) r = color.r(asiaBGColor) g = color.g(asiaBGColor) b = color.b(asiaBGColor) isCloseBelowOpen = tokyoSessionClose < tokyoSessionOpen ? true : false label.new(bar_index[1], isCloseBelowOpen ? tokyoSessionLow : tokyoSessionHigh, str.tostring(tokyoSessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=asiaTextColor) // Session - Sydney bgcolor(color=isInSession(sydneySession) and showSydneySession ? ausBGColor : na, title='Sydney Session', editable=false) // // Track session high/low var float sydneySessionHigh = na var float sydneySessionLow = na var float sydneySessionOpen = na var float sydneySessionClose = na var bool isSydneySessionStart = false isInSydneySession = isInSession(sydneySession) if (isInSydneySession) // In session, check for session start... if (not isInSydneySession[1]) // Start of session, reset high and low tracking vars sydneySessionHigh := h sydneySessionLow := l isSydneySessionStart := true sydneySessionOpen := o else sydneySessionHigh := math.max(h, sydneySessionHigh[1]) sydneySessionLow := math.min(l, sydneySessionLow[1]) // Being a bit lazy here and updating close every candle instead of explicitly // waiting for the last candle close to grab the session close value, but the result // will still be the same... sydneySessionClose := c // Calculate session high/low diff sydneySessDiff = sydneySessionHigh[1] - sydneySessionLow[1] // Plot session high/low diff as label if enables if (isInSydneySession[1] and not isInSydneySession and doHighLowDiffLabels and showSydneySession) r = color.r(ausBGColor) g = color.g(ausBGColor) b = color.b(ausBGColor) isCloseBelowOpen = sydneySessionClose < sydneySessionOpen ? true : false label.new(bar_index[1], isCloseBelowOpen ? sydneySessionLow : sydneySessionHigh, str.tostring(sydneySessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=ausTextColor)
Deviation Bands
https://www.tradingview.com/script/g7YhzEwi-Deviation-Bands/
Electrified
https://www.tradingview.com/u/Electrified/
572
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Electrified //@version=5 //@description Plots the 1, 2 and 3 standard deviations from the mean as bands of color (hot and cold). Useful in identifying likely points of mean reversion. indicator("Deviation Bands", overlay=true) import Electrified/DataCleaner/7 as Data import Electrified/MovingAverages/10 as MA SMA = 'SMA', EMA = 'EMA', WMA = 'WMA', VWMA = 'VWMA', VAWMA = 'VAWMA' import Electrified/Time/7 MINUTES = "Minutes", DAYS = "Days", BARS = "Bars" hot = color.orange, hot_clear = color.new(hot, 100) cold = color.blue, cold_clear = color.new(cold, 100) SOURCE = "Source", LENGTH = "Length" src = input.source(hlc3, SOURCE, inline = SOURCE) var type = input.string(WMA, "", inline = SOURCE, options=[SMA,EMA,WMA,VWMA,VAWMA]) var len = Time.spanToIntLen( input.float(200, LENGTH, minval=0.5, step=0.5, inline=LENGTH), input.string(BARS, "", options = [BARS, MINUTES, DAYS], inline=LENGTH, tooltip = "The length of the source measurement.")) var useSource = input.bool(false, "Use source as mean", "With this selected, the source becomes the mean and the deviation is then calculated using HLC3.\nMode and Length will then have no effect.") DEVIATION = "Deviation Calculation" var mLen = Time.spanToIntLen( input.float(1200, LENGTH, minval=0.5, step=0.5, inline=LENGTH, group=DEVIATION), input.string(BARS, "", options = [BARS, MINUTES, DAYS], inline=LENGTH, group=DEVIATION, tooltip = "The length of the deviation measurement.")) var maxDev = input.float(4, "Maximum Outlier Level", group=DEVIATION, minval=0) BIAS = "Deviation Bias" // Bias causes the bands to deviate from the mean based upon previous deviations. var bLen = Time.spanToIntLen( input.float(1200, LENGTH, minval=0.5, step=0.5, inline=LENGTH, group=BIAS), input.string(BARS, "", options = [BARS, MINUTES, DAYS], inline=LENGTH, group=BIAS, tooltip = "The number of bars to determine the bias.\nExample: if for the last (bias length) bars the values tended to be greater than the mean, the bias would tend to be positive.")) var bMul = input.float(0.0, "Multiplier", group=BIAS, step = 0.1, tooltip = "Set this to zero if no bias is desired.") ma = useSource ? src : MA.get(type, len, src) // Derive a baseline +/- ratio away from the mean. ma_d = ((useSource ? hlc3 : src) - ma)/ma cleaned = Data.naOutliers(ma_d, mLen, maxDev) // Is the deviation biased? bias = bMul == 0.0 ? 0.0 : MA.wma(bLen, cleaned) * ma * bMul // MA.wma is used to fill in NA gaps. biasedMa = ma + bias // What is the standard deviation? stdev = ta.stdev(cleaned, mLen) * ma // Set levels. upper1 = biasedMa + stdev lower1 = biasedMa - stdev upper2 = upper1 + stdev lower2 = lower1 - stdev upper3 = upper2 + stdev lower3 = lower2 - stdev // Plot levels from highest to lowest. Line-width=4 to make a larget hit area for the mouse to click on. pUpper3 = plot(upper3, "+3", hot_clear, 4) pUpper2 = plot(upper2, "+2", hot_clear, 4) pUpper1 = plot(upper1, "+1", hot_clear, 4) plot(ma, "Mean", color.new(color.silver, 75), 1, style=plot.style_circles) pLower1 = plot(lower1, "-1", cold_clear, 4) pLower2 = plot(lower2, "-2", cold_clear, 4) pLower3 = plot(lower3, "-3", cold_clear, 4) hot1A = color.new(hot, 90) hot2A = color.new(hot, 75) hot2B = color.new(hot, 85) hot3B = color.new(hot, 100) cold1A = color.new(cold, 90) cold2A = color.new(cold, 75) cold2B = color.new(cold, 85) cold3B = color.new(cold, 100) fill(pUpper1, pUpper2, upper1, upper2, hot1A, hot2A, "+1 to +2 Band") fill(pUpper2, pUpper3, upper2, upper3, hot2B, hot3B, "+2 to +3 Band") fill(pLower1, pLower2, lower1, lower2, cold1A, cold2A, "-1 to -2 Band") fill(pLower2, pLower3, lower2, lower3, cold2B, cold3B, "-2 to -3 Band")
MTF Market Structure Highs and Lows
https://www.tradingview.com/script/QAsQsAH6-MTF-Market-Structure-Highs-and-Lows/
geneclash
https://www.tradingview.com/u/geneclash/
1,192
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © geneclash //@version=5 indicator("MTF Market Structure Highs and Lows",overlay=true,max_bars_back = 5000) drawLine = input(true,title="Draw Vertical Line to Latest Alert") filterBW = input(false, title="filter Bill Williams Fractals:") LabelsOffset = input(50) isRegularFractal(mode) => ret = mode == 1 ? high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0] : mode == -1 ? low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0] : false isBWFractal(mode) => ret = mode == 1 ? high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0] : mode == -1 ? low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0] : false dt = time - time[1] GetLastPivots() => var float LastPh_v = na var float LastPl_v = na var int LastPh_t = na var int LastPl_t = na filteredtopf = filterBW ? isRegularFractal(1) : isBWFractal(1) filteredbotf = filterBW ? isRegularFractal(-1) : isBWFractal(-1) if filteredtopf LastPh_v := high[2] LastPh_t := time[2] if filteredbotf LastPl_v := low[2] LastPl_t := time[2] [LastPh_v,LastPh_t,LastPl_v,LastPl_t] ShowY = input.bool(false,title="Use Monthly Levels") ColorHY = input.color(color.black,inline='y1',title="High") ColorLY = input.color(color.black,inline='y1',title="Low ") StyleY = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='y1',title="") WidthY = input.int(1,title="",inline="y1") Show1 = input.bool(true,title="Use Weekly Levels") ColorH1 = input.color(color.black,inline='l1',title="High") ColorL1 = input.color(color.black,inline='l1',title="Low ") Style1 = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='l1',title="") Width1 = input.int(1,title="",inline="l1") Show2 = input.bool(true,title="Use Daily Levels") ColorH2 = input.color(color.black,inline='l2',title="High") ColorL2 = input.color(color.black,inline='l2',title="Low") Style2 = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='l2',title="") Width2 = input.int(1,title="",inline="l2") Show3 = input.bool(true,title="Show 4H Levels") ColorH3 = input.color(color.black,inline='l3',title="High") ColorL3 = input.color(color.black,inline='l3',title="Low ") Style3 = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='l3',title="") Width3 = input.int(1,title="",inline="l3") Show4 = input.bool(true,title="Show 1H Levels") ColorH4 = input.color(color.black,inline='l4',title="High") ColorL4 = input.color(color.black,inline='l4',title="Low") Style4 = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='l4',title="") Width4 = input.int(1,title="",inline="l4") Show5 = input.bool(false,title="Show 30m Levels") ColorH5 = input.color(color.black,inline='l5',title="High") ColorL5 = input.color(color.black,inline='l5',title="Low") Style5 = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='l5',title="") Width5 = input.int(1,title="",inline="l5") Show6 = input.bool(false,title="Show 15m Levels") ColorH6 = input.color(color.black,inline='l6',title="High") ColorL6 = input.color(color.black,inline='l6',title="Low") Style6 = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='l6',title="") Width6 = input.int(1,title="",inline="l6") Show7 = input.bool(false,title="Show 5m Levels") ColorH7 = input.color(color.black,inline='l7',title="High") ColorL7 = input.color(color.black,inline='l7',title="Low") Style7 = input.string("Dotted",options=["Solid","Dotted","Dashed"],inline='l7',title="") Width7 = input.int(1,title="",inline="l7") LabelColor = input.color(color.purple) TextColor = input.color(color.black) StyleToEnum(s) => if s == 'Solid' line.style_solid else if s == 'Dotted' line.style_dotted else line.style_dashed [LastPh_vY,LastPh_tY_,LastPl_vY,LastPl_tY_] = request.security(syminfo.tickerid,"M", GetLastPivots()) [LastPh_v1,LastPh_t1_,LastPl_v1,LastPl_t1_] = request.security(syminfo.tickerid,"W", GetLastPivots()) [LastPh_v2,LastPh_t2_,LastPl_v2,LastPl_t2_] = request.security(syminfo.tickerid,"D", GetLastPivots()) [LastPh_v3,LastPh_t3_,LastPl_v3,LastPl_t3_] = request.security(syminfo.tickerid,"240", GetLastPivots()) [LastPh_v4,LastPh_t4_,LastPl_v4,LastPl_t4_] = request.security(syminfo.tickerid,"60", GetLastPivots()) [LastPh_v5,LastPh_t5_,LastPl_v5,LastPl_t5_] = request.security(syminfo.tickerid,"30", GetLastPivots()) [LastPh_v6,LastPh_t6_,LastPl_v6,LastPl_t6_] = request.security(syminfo.tickerid,"15", GetLastPivots()) [LastPh_v7,LastPh_t7_,LastPl_v7,LastPl_t7_] = request.security(syminfo.tickerid,"5", GetLastPivots()) line lhY = na, line llY = na line lh1 = na, line ll1 = na line lh2 = na, line ll2 = na line lh3 = na, line ll3 = na line lh4 = na, line ll4 = na line lh5 = na, line ll5 = na line lh6 = na, line ll6 = na line lh7 = na, line ll7 = na label lblhY = na, label lbllY = na label lblh1 = na, label lbll1 = na label lblh2 = na, label lbll2 = na label lblh3 = na, label lbll3 = na label lblh4 = na, label lbll4 = na label lblh5 = na, label lbll5 = na label lblh6 = na, label lbll6 = na label lblh7 = na, label lbll7 = na var Pl_Y_trigger = false, var Pl_1_trigger = false, var Pl_2_trigger = false, var Pl_3_trigger = false, var Pl_4_trigger = false, var Pl_5_trigger = false, var Pl_6_trigger = false, var Pl_7_trigger = false var Ph_Y_trigger = false, var Ph_1_trigger = false, var Ph_2_trigger = false, var Ph_3_trigger = false, var Ph_4_trigger = false, var Ph_5_trigger = false, var Ph_6_trigger = false, var Ph_7_trigger = false //Reset Trigger if ta.change(LastPh_v7) Ph_7_trigger := false if ta.change(LastPh_v6) Ph_6_trigger := false if ta.change(LastPh_v5) Ph_5_trigger := false if ta.change(LastPh_v4) Ph_4_trigger := false if ta.change(LastPh_v3) Ph_3_trigger := false if ta.change(LastPh_v2) Ph_2_trigger := false if ta.change(LastPh_v1) Ph_1_trigger := false if ta.change(LastPh_vY) Ph_Y_trigger := false if ta.change(LastPl_v4) Pl_4_trigger := false if ta.change(LastPl_v3) Pl_3_trigger := false if ta.change(LastPl_v2) Pl_2_trigger := false if ta.change(LastPl_v1) Pl_1_trigger := false if ta.change(LastPl_vY) Pl_Y_trigger := false FindT(t,v) => int result = time begin = (time - t) / dt if begin < 5000 for i = begin to 0 if high[i] == v or low[i] == v result := t + (begin-i) * dt break result else t LastPl_tY = FindT(LastPl_tY_,LastPl_vY) LastPh_tY = FindT(LastPh_tY_,LastPh_vY) LastPl_t1 = FindT(LastPl_t1_,LastPl_v1) LastPh_t1 = FindT(LastPh_t1_,LastPh_v1) LastPl_t2 = FindT(LastPl_t2_,LastPl_v2) LastPh_t2 = FindT(LastPh_t2_,LastPh_v2) LastPl_t3 = FindT(LastPl_t3_,LastPl_v3) LastPh_t3 = FindT(LastPh_t3_,LastPh_v3) LastPl_t4 = FindT(LastPl_t4_,LastPl_v4) LastPh_t4 = FindT(LastPh_t4_,LastPh_v4) LastPl_t5 = FindT(LastPl_t5_,LastPl_v5) LastPh_t5 = FindT(LastPh_t5_,LastPh_v5) LastPl_t6 = FindT(LastPl_t6_,LastPl_v6) LastPh_t6 = FindT(LastPh_t6_,LastPh_v6) LastPl_t7 = FindT(LastPl_t7_,LastPl_v7) LastPh_t7 = FindT(LastPh_t7_,LastPh_v7) ////// LastPl_Yalert = ta.crossunder(low,LastPl_vY) and Pl_Y_trigger == false LastPh_Yalert = ta.crossover(high,LastPh_vY) and Ph_Y_trigger == false LastPl_1alert = ta.crossunder(low,LastPl_v1) and Pl_1_trigger == false LastPh_1alert = ta.crossover(high,LastPh_v1) and Ph_1_trigger == false LastPl_2alert = ta.crossunder(low,LastPl_v2) and Pl_2_trigger == false LastPh_2alert = ta.crossover(high,LastPh_v2) and Ph_2_trigger == false LastPl_3alert = ta.crossunder(low,LastPl_v3) and Pl_3_trigger == false LastPh_3alert = ta.crossover(high,LastPh_v3) and Ph_3_trigger == false LastPl_4alert = ta.crossunder(low,LastPl_v4) and Pl_4_trigger == false LastPh_4alert = ta.crossover(high,LastPh_v4) and Ph_4_trigger == false LastPl_5alert = ta.crossunder(low,LastPl_v5) and Pl_5_trigger == false LastPh_5alert = ta.crossover(high,LastPh_v5) and Ph_5_trigger == false LastPl_6alert = ta.crossunder(low,LastPl_v6) and Pl_6_trigger == false LastPh_6alert = ta.crossover(high,LastPh_v6) and Ph_6_trigger == false LastPl_7alert = ta.crossunder(low,LastPl_v7) and Pl_7_trigger == false LastPh_7alert = ta.crossover(high,LastPh_v7) and Ph_7_trigger == false alertcondition(LastPl_Yalert or LastPh_Yalert,title="04- M high/Low cross alert",message="M high/Low cross alert") alertcondition(LastPl_1alert or LastPh_1alert,title="05- W high/Low cross alert",message="W high/Low cross alert") alertcondition(LastPl_2alert or LastPh_2alert,title="06- D high/Low cross alert",message="D high/Low cross alert") alertcondition(LastPl_3alert or LastPh_3alert,title="07- 240 high/Low cross alert",message="240 high/Low cross alert") alertcondition(LastPl_4alert or LastPh_4alert,title="08- 60 high/Low cross alert",message="60 high/Low cross alert") alertcondition(LastPl_5alert or LastPh_5alert,title="09- 30 high/Low cross alert",message="30 high/Low cross alert") alertcondition(LastPl_6alert or LastPh_6alert,title="10- 15 high/Low cross alert",message="15 high/Low cross alert") alertcondition(LastPl_7alert or LastPh_7alert,title="11- 5 high/Low cross alert",message="5 high/Low cross alert") ShowYa=input(false,"Show Previous alert points M") Show1a=input(false,"Show Previous alert points W") Show2a=input(false,"Show Previous alert points D") Show3a=input(false,"Show Previous alert points 240") Show4a=input(false,"Show Previous alert points 60") Show5a=input(false,"Show Previous alert points 30") Show6a=input(false,"Show Previous alert points 15") Show7a=input(false,"Show Previous alert points 5") ShowAlla = input(false,"Show Previous Any alert points") bgcolor(LastPl_Yalert and ShowYa?color.new(color.red,80):na) bgcolor(LastPh_Yalert and ShowYa?color.new(color.green,80):na) bgcolor(LastPl_1alert and Show1a?color.new(color.red,80):na) bgcolor(LastPh_1alert and Show1a?color.new(color.green,80):na) bgcolor(LastPl_2alert and Show2a?color.new(color.red,80):na) bgcolor(LastPh_2alert and Show2a?color.new(color.green,80):na) bgcolor(LastPl_3alert and Show3a?color.new(color.red,80):na) bgcolor(LastPh_3alert and Show3a?color.new(color.green,80):na) bgcolor(LastPl_4alert and Show4a?color.new(color.red,80):na) bgcolor(LastPh_4alert and Show4a?color.new(color.green,80):na) bgcolor(LastPl_5alert and Show5a?color.new(color.red,80):na) bgcolor(LastPh_5alert and Show5a?color.new(color.green,80):na) bgcolor(LastPl_6alert and Show6a?color.new(color.red,80):na) bgcolor(LastPh_6alert and Show6a?color.new(color.green,80):na) bgcolor(LastPl_7alert and Show7a?color.new(color.red,80):na) bgcolor(LastPh_7alert and Show7a?color.new(color.green,80):na) anyLowAlertCond = (LastPl_Yalert or LastPl_1alert or LastPl_2alert or LastPl_3alert or LastPl_4alert or LastPl_5alert or LastPl_6alert or LastPl_7alert) anyHighAlertCond = (LastPh_Yalert or LastPh_1alert or LastPh_2alert or LastPh_3alert or LastPh_4alert or LastPh_5alert or LastPh_6alert or LastPh_7alert) bgcolor(anyLowAlertCond and ShowAlla?color.new(color.green,80):na) bgcolor(anyHighAlertCond and ShowAlla?color.new(color.red,80):na) var line alertLine = na if (anyLowAlertCond or anyHighAlertCond) and drawLine alertLine := line.new(bar_index,high,bar_index,low,extend=extend.both,color=color.navy) line.delete(alertLine[1]) alertcondition(anyLowAlertCond or anyHighAlertCond,title="01- Any Level Cross Alert",message="Any Level Cross Alert") alertcondition(anyLowAlertCond,title="02- Any Level (Low) Cross Alert",message="Any Level (Low) Cross Alert") alertcondition(anyHighAlertCond,title="03- Any Level (High) Cross Alert",message="Any Level (High) Cross Alert") //Set Trigger if LastPl_Yalert Pl_Y_trigger := true if LastPh_Yalert Ph_Y_trigger := true if LastPl_1alert Pl_1_trigger := true if LastPh_1alert Ph_1_trigger := true if LastPl_2alert Pl_2_trigger := true if LastPh_2alert Ph_2_trigger := true if LastPl_3alert Pl_3_trigger := true if LastPh_3alert Ph_3_trigger := true if LastPl_4alert Pl_4_trigger := true if LastPh_4alert Ph_4_trigger := true if LastPl_5alert Pl_5_trigger := true if LastPh_5alert Ph_5_trigger := true if LastPl_6alert Pl_6_trigger := true if LastPh_6alert Ph_6_trigger := true if LastPl_7alert Pl_7_trigger := true if LastPh_7alert Ph_7_trigger := true if barstate.islast if ShowY lhY := line.new(LastPh_tY,LastPh_vY,time,LastPh_vY,xloc=xloc.bar_time,color=ColorHY,style=StyleToEnum(StyleY),extend=extend.right,width=WidthY) line.delete(lhY[1]) llY := line.new(LastPl_tY,LastPl_vY,time,LastPl_vY,xloc=xloc.bar_time,color=ColorLY,style=StyleToEnum(StyleY),extend=extend.right,width=WidthY) line.delete(llY[1]) lblhY := label.new(bar_index + LabelsOffset,LastPh_vY,"Monthly MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblhY[1]) lbllY := label.new(bar_index + LabelsOffset,LastPl_vY,"Monthly MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbllY[1]) if Show1 lh1 := line.new(LastPh_t1,LastPh_v1,time,LastPh_v1,xloc=xloc.bar_time,color=ColorH1,style=StyleToEnum(Style1),extend=extend.right,width=Width1) line.delete(lh1[1]) ll1 := line.new(LastPl_t1,LastPl_v1,time,LastPl_v1,xloc=xloc.bar_time,color=ColorL1,style=StyleToEnum(Style1),extend=extend.right,width=Width1) line.delete(ll1[1]) lblh1 := label.new(bar_index + LabelsOffset,LastPh_v1,"Weekly MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblh1[1]) lbll1 := label.new(bar_index + LabelsOffset,LastPl_v1,"Weekly MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbll1[1]) if Show2 lh2 := line.new(LastPh_t2,LastPh_v2,time,LastPh_v2,xloc=xloc.bar_time,color=ColorH2,style=StyleToEnum(Style2),extend=extend.right,width=Width2) line.delete(lh2[1]) ll2 := line.new(LastPl_t2,LastPl_v2,time,LastPl_v2,xloc=xloc.bar_time,color=ColorL2,style=StyleToEnum(Style2),extend=extend.right,width=Width2) line.delete(ll2[1]) lblh2 := label.new(bar_index + LabelsOffset,LastPh_v2,"Daily MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblh2[1]) lbll2 := label.new(bar_index + LabelsOffset,LastPl_v2,"Daily MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbll2[1]) if Show3 lh3 := line.new(LastPh_t3,LastPh_v3,time,LastPh_v3,xloc=xloc.bar_time,color=ColorH3,style=StyleToEnum(Style3),extend=extend.right,width=Width3) line.delete(lh3[1]) ll3 := line.new(LastPl_t3,LastPl_v3,time,LastPl_v3,xloc=xloc.bar_time,color=ColorL3,style=StyleToEnum(Style3),extend=extend.right,width=Width3) line.delete(ll3[1]) lblh3 := label.new(bar_index + LabelsOffset,LastPh_v3,"4H MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblh3[1]) lbll3 := label.new(bar_index + LabelsOffset,LastPl_v3,"4H MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbll3[1]) if Show4 lh4 := line.new(LastPh_t4,LastPh_v4,time,LastPh_v4,xloc=xloc.bar_time,color=ColorH4,style=StyleToEnum(Style4),extend=extend.right,width=Width4) line.delete(lh4[1]) ll4 := line.new(LastPl_t4,LastPl_v4,time,LastPl_v4,xloc=xloc.bar_time,color=ColorL4,style=StyleToEnum(Style4),extend=extend.right,width=Width4) line.delete(ll4[1]) lblh4 := label.new(bar_index + LabelsOffset,LastPh_v4,"1H MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblh4[1]) lbll4 := label.new(bar_index + LabelsOffset,LastPl_v4,"1H MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbll4[1]) if Show5 lh5 := line.new(LastPh_t5,LastPh_v5,time,LastPh_v5,xloc=xloc.bar_time,color=ColorH5,style=StyleToEnum(Style5),extend=extend.right,width=Width5) line.delete(lh5[1]) ll5 := line.new(LastPl_t5,LastPl_v5,time,LastPl_v5,xloc=xloc.bar_time,color=ColorL5,style=StyleToEnum(Style5),extend=extend.right,width=Width5) line.delete(ll5[1]) lblh5 := label.new(bar_index + LabelsOffset,LastPh_v5,"30m MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblh5[1]) lbll5 := label.new(bar_index + LabelsOffset,LastPl_v5,"30m MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbll5[1]) if Show6 lh6 := line.new(LastPh_t6,LastPh_v6,time,LastPh_v6,xloc=xloc.bar_time,color=ColorH6,style=StyleToEnum(Style6),extend=extend.right,width=Width6) line.delete(lh6[1]) ll6 := line.new(LastPl_t6,LastPl_v6,time,LastPl_v6,xloc=xloc.bar_time,color=ColorL6,style=StyleToEnum(Style6),extend=extend.right,width=Width6) line.delete(ll6[1]) lblh6 := label.new(bar_index + LabelsOffset,LastPh_v6,"15m MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblh6[1]) lbll6 := label.new(bar_index + LabelsOffset,LastPl_v6,"15m MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbll6[1]) if Show7 lh7 := line.new(LastPh_t7,LastPh_v7,time,LastPh_v7,xloc=xloc.bar_time,color=ColorH7,style=StyleToEnum(Style7),extend=extend.right,width=Width7) line.delete(lh7[1]) ll7 := line.new(LastPl_t7,LastPl_v7,time,LastPl_v7,xloc=xloc.bar_time,color=ColorL7,style=StyleToEnum(Style7),extend=extend.right,width=Width7) line.delete(ll7[1]) lblh7 := label.new(bar_index + LabelsOffset,LastPh_v7,"5m MS High",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lblh7[1]) lbll7 := label.new(bar_index + LabelsOffset,LastPl_v7,"5m MS Low",color=LabelColor,style=label.style_none,textcolor=TextColor,textalign=text.align_right,size=size.small) label.delete(lbll7[1])
Adaptive Ehlers Deviation Scaled Moving Average (AEDSMA)
https://www.tradingview.com/script/ks8m6BcG-Adaptive-Ehlers-Deviation-Scaled-Moving-Average-AEDSMA/
MightyZinger
https://www.tradingview.com/u/MightyZinger/
260
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 indicator("Adaptive Ehlers Deviation Scaled Moving Average (AEDSMA)", shorttitle="MZ AEDSMA", overlay=true) import MightyZinger/RVSI/1 as mz timeframe = input.timeframe("", "Timeframe") uha =input(true, title="Use Heikin Ashi Candles for Volume Oscillator Calculations") // Use only Heikinashi Candles for all calculations haclose = uha ? ohlc4 : close f_ha_open() => haopen = float(na) haopen := na(haopen[1]) ? (open + close) / 2 : (nz(haopen[1]) + nz(haclose[1])) / 2 haopen haopen = uha ? f_ha_open() : open hahigh = high halow = low vol = volume ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Source Options ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // ─── Different Sources Options List ───► [ string SRC_Tv = 'Use traditional TradingView Sources ' string SRC_Wc = '(high + low + (2 * close)) / 4' string SRC_Wo = 'close+high+low-2*open' string SRC_Wi = '(close+high+low) / 3' string SRC_Ex = 'close>open ? high : low' string SRC_Hc = 'Heikin Ashi Close' string src_grp = 'Source Parameters' // ●───────── Inputs ─────────● { diff_src = input.string(SRC_Wi, '→ Different Sources Options', options=[SRC_Tv, SRC_Wc, SRC_Wo, SRC_Wi, SRC_Ex, SRC_Hc], group=src_grp) i_sourceSetup = input.source(close, '  ‍↳ Source Setup', group=src_grp) uha_src = input.bool(true, title='‍↳ Use Heikin Ashi Candles for Different Source Calculations', group=src_grp) i_Symmetrical = input.bool(true, '‍↳ Apply Symmetrically Weighted Moving Average at the price source (May Result Repainting)', group=src_grp) // Heikinashi Candles for calculations h_close = uha_src ? ohlc4 : close h_open = uha_src ? f_ha_open() : open h_high = high h_low = low // Get Source src_o = diff_src == SRC_Wc ? (high + low + 2 * h_close) / 4 : diff_src == SRC_Wo ? h_close + h_high + h_low - 2 * h_open : diff_src == SRC_Wi ? (h_close + h_high + h_low) / 3 : diff_src == SRC_Ex ? h_close > h_open ? h_high : h_low : diff_src == SRC_Hc ? ohlc4 : i_sourceSetup src_f = i_Symmetrical ? ta.swma(src_o) : src_o // Symmetrically Weighted Moving Average? ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // AEDSMA Envelop and Signals Checks showEnv = input.bool(true, title='Show AEDSMA Envelope', group='AEDSMA ENVELOPE DISTANCE ZONE') mult = input.float(2.7, title='Distance (Envelope) Multiplier', step=.1, group='AEDSMA ENVELOPE DISTANCE ZONE') env_atr = input.int(40, title='Envelope ATR Length', group='AEDSMA ENVELOPE DISTANCE ZONE') showSignals = input.bool(true, title='Show Possible Signals', group='Signals Plotting') ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Dynamic Inputs ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // AEDSMA Parameters grp1 = 'AEDSMA Parameters' grp2 = 'Adapt AEDSMA Dynamic Length Based on (Max Length if both left unchecked)' grp3 = 'Show Signals and AEDSMA Dynamic Coloring Based on' minLength = input.int(50, title='AEDSMA Minimum Length:', group=grp1) maxLength = input.int(255, title='AEDSMA Maximum Length:', group=grp1) adaptPerc = input.float(3.141, minval=0, maxval=100, title='AEDSMA Adapting Percentage:', group=grp1) / 100.0 ssfLength = input.int(title='EDSMA - Super Smoother Filter Length', minval=1, defval=20, group=grp1) ssfPoles = input.int(title='EDSMA - Super Smoother Filter Poles', defval=2, options=[2, 3], group=grp1) // AEDSMA Adaptive Length Checks ch1 = 'Slope' ch2 = 'Volume' ch3 = 'Volatility' volume_chk = input.bool(true, title=ch2, group=grp2, inline='len_chks') volat_chk = input.bool(true, title=ch3, group=grp2, inline='len_chks') t_slp_chk = input.bool(true, title=ch1, group=grp3, inline='trd_chks') t_volume_chk = input.bool(true, title=ch2, group=grp3, inline='trd_chks') t_volat_chk = input.bool(true, title=ch3, group=grp3, inline='trd_chks') ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Volume and other Inputs // Volume Oscillator Types Input osc1 = 'TFS Volume Oscillator' osc2 = 'On Balance Volume' osc3 = 'Klinger Volume Oscillator' osc4 = 'Cumulative Volume Oscillator' osc5 = 'Volume Zone Oscillator' osctype = input.string(title='Volume Oscillator Type', group='MZ RVSI Indicator Parameters', defval=osc1, options=[osc1, osc2, osc3, osc4, osc5]) rvsiLen = input.int(14, minval=1, title='RVSI Period', group='MZ RVSI Indicator Parameters') vBrk = input.int(50, minval=1, title='RVSI Break point', group='MZ RVSI Indicator Parameters') atrFlength = input.int(14, title='ATR Fast Length', group='Volatility Dynamic Optimization Parameters') atrSlength = input.int(46, title='ATR Slow Length', group='Volatility Dynamic Optimization Parameters') slopePeriod = input.int(34, title='Slope Period', group='Slope Dynamic Optimization Parameters') slopeInRange = input.int(25, title='Slope Initial Range', group='Slope Dynamic Optimization Parameters') flat = input.int(17, title='Consolidation area is when slope below:', group='Slope Dynamic Optimization Parameters') ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// DSMA Function ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Pre-reqs get2PoleSSF(src, length) => PI = 2 * math.asin(1) arg = math.sqrt(2) * PI / length a1 = math.exp(-arg) b1 = 2 * a1 * math.cos(arg) c2 = b1 c3 = -math.pow(a1, 2) c1 = 1 - c2 - c3 ssf = 0.0 ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2]) ssf get3PoleSSF(src, length) => PI = 2 * math.asin(1) arg = PI / length a1 = math.exp(-arg) b1 = 2 * a1 * math.cos(1.738 * arg) c1 = math.pow(a1, 2) coef2 = b1 + c1 coef3 = -(c1 + b1 * c1) coef4 = math.pow(c1, 2) coef1 = 1 - coef2 - coef3 - coef4 ssf = 0.0 ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3]) ssf // MA Main function dsma(src, len) => float result = 0.0 zeros = src - nz(src[2]) avgZeros = (zeros + zeros[1]) / 2 // Ehlers Super Smoother Filter ssf = ssfPoles == 2 ? get2PoleSSF(avgZeros, ssfLength) : get3PoleSSF(avgZeros, ssfLength) // Rescale filter in terms of Standard Deviations stdev = ta.stdev(ssf, len) scaledFilter = stdev != 0 ? ssf / stdev : 0 alpha = 5 * math.abs(scaledFilter) / len edsma = 0.0 edsma := alpha * src + (1 - alpha) * nz(edsma[1]) result := edsma result ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Dynamic Length Function ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// dyn_Len(volume_chk, volat_chk, volume_Break, high_Volatility, adapt_Pct, minLength, maxLength) => var float result = math.avg(minLength, maxLength) para = volume_chk == true and volat_chk == false ? volume_Break : volume_chk == false and volat_chk == true ? high_Volatility : volume_chk == true and volat_chk == true ? volume_Break and high_Volatility : na result := para ? math.max(minLength, result * (1 - adapt_Pct)) : math.min(maxLength, result * (1 + adapt_Pct)) result //Slope calculation to determine whether market is in trend, or in consolidation or choppy, or might about to change current trend calcslope(_ma, src, slope_period, range_1) => pi = math.atan(1) * 4 highestHigh = ta.highest(slope_period) lowestLow = ta.lowest(slope_period) slope_range = range_1 / (highestHigh - lowestLow) * lowestLow dt = (_ma[2] - _ma) / src * slope_range c = math.sqrt(1 + dt * dt) xAngle = math.round(180 * math.acos(1 / c) / pi) maAngle = dt > 0 ? -xAngle : xAngle maAngle //MA coloring function to mark market dynamics dyn_col(slp_chk, volume_chk, volat_chk, slp, _flat, vol_Brk_up, vol_Brk_dn, high_Volatility, col_1, col_2, col_3, col_4, col_r) => slp_up = slp_chk ? slp > _flat : na slp_dn = slp_chk ? slp <= -_flat : na slp_cons = slp_chk ? slp <= _flat and slp > -flat : na vol_up = volume_chk ? vol_Brk_up and slp_up : slp_up vol_dn = volume_chk ? vol_Brk_dn and slp_dn : slp_dn up_voltility = volat_chk ? high_Volatility and vol_up : vol_up dn_voltility = volat_chk ? high_Volatility and vol_dn : vol_dn c1 = up_voltility c2 = slp_up c3 = slp_cons c4 = dn_voltility c5 = slp_dn col = c1 ? col_1 : c2 ? col_2 : c3 ? col_r : c4 ? col_3 : c5 ? col_4 : c2 == c3 == c5 == na ? col_r : col_r col ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Relative Volume Strength Index (MZ RVSI) ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // TFS Volume Oscillator tfs_volLen = input.int(30, minval=1,title="Volume Length", group="TFS Volume Oscillator") // Volume Zone Oscillator vzo_Len = input.int(21, "VZO Length", minval=1, group="Volume Zone Oscillator Parameters") // Volume Oscillator function kvo_FastX = input.int(34, minval=1,title="Volume Fast Length", group="KVO Parameters") kvo_SlowX = input.int(55, minval=1,title="Volume Slow Length", group="KVO Parameters") // Cumulative Volume Oscillator cvo(vol_src, rvsiLen, _open, _high, _low, _close) => float result = 0 ema1len = input.int(defval = 8, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters") ema2len = input.int(defval = 21, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters") obvl = "On Balance Volume" cvdo = "Cumulative Volume Delta" pvlt = "Price Volume Trend" cvtype = input.string(defval = pvlt, options = [obvl, cvdo, pvlt], group="Cumulative Volume Oscillator Parameters") _obv = mz.rvsi_cvo_obv(ema1len, ema2len, rvsiLen) _pvt = mz.rvsi_cvo_pvt(ema1len, ema2len, rvsiLen) _cvd = mz.rvsi_cvo_cvd(vol_src, ema1len, ema2len, rvsiLen, _open, _high, _low, _close) result := cvtype == obvl ? _obv : cvtype == cvdo ? _cvd : _pvt result vol_osc(type, vol_src, _rvsiLen, _open, _high, _low, _close) => float _rvsi = 0 if type=="TFS Volume Oscillator" _rvsi := mz.rvsi_tfs(vol_src, tfs_volLen, _rvsiLen, _open, _close) if type=="On Balance Volume" _rvsi := mz.rvsi_obv(vol_src, _close, _rvsiLen) if type=="Klinger Volume Oscillator" _rvsi := mz.rvsi_kvo(vol_src, _close, kvo_FastX, kvo_SlowX, _rvsiLen) if type=="Cumulative Volume Oscillator" _rvsi := cvo(vol_src, _rvsiLen, _open, _high, _low, _close) if type=="Volume Zone Oscillator" _rvsi := mz.rvsi_vzo(vol_src, _close, vzo_Len, _rvsiLen) _rvsi ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // RSI of Volume Oscillator Data rvsi = request.security(syminfo.tickerid, timeframe, vol_osc(osctype,vol,rvsiLen,haopen,hahigh,halow,haclose)) // Volume Breakout Condition volBrkUp = rvsi > vBrk volBrkDn = rvsi < vBrk //Volatility Meter highVolatility = request.security(syminfo.tickerid, timeframe, ta.atr(atrFlength) > ta.atr(atrSlength)) ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// aedsma_dyna = dyn_Len(volume_chk, volat_chk, volBrkUp, highVolatility, adaptPerc, minLength, maxLength) aedsma = request.security(syminfo.tickerid, timeframe, dsma(src_f, int(aedsma_dyna))) aedsma_slope = calcslope(aedsma, src_f, slopePeriod, slopeInRange) up_col = color.lime dn_col = color.red aedsma_dyn_col = request.security(syminfo.tickerid, timeframe, dyn_col(t_slp_chk, t_volume_chk, t_volat_chk, aedsma_slope, flat, volBrkUp, volBrkDn, highVolatility, up_col, color.fuchsia, dn_col, color.gray, color.yellow)) ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// //Plotting AEDSMA plot(aedsma, 'MZ AEDSMA', aedsma_dyn_col, 4) plotchar(aedsma_dyna, 'AEDSMA Dynamic Length', '', location.top, color.new(color.green, 0)) plotchar(rvsi, 'RVSI', '', location.top, color.new(color.red, 0)) // Enveloping AEDSMA with ATR bands f_warn_col(_close , _low, _high, lower, upper, b_col, t_col, b_warn, t_warn) => var col = color.rgb(170,219,30,60) if _low > lower and _high < upper col := color.from_gradient(_close, lower, upper, b_col, t_col) if _low < lower col := b_warn if _high > upper col := t_warn col // 1/2 distance zone env_MA = aedsma utl = request.security(syminfo.tickerid, timeframe, env_MA + mult * ta.atr(env_atr)) ltl = request.security(syminfo.tickerid, timeframe, env_MA - mult * ta.atr(env_atr)) // One distance zone ttl = request.security(syminfo.tickerid, timeframe, env_MA + mult * 1.7 * ta.atr(env_atr)) btl = request.security(syminfo.tickerid, timeframe, env_MA - mult * 1.7 * ta.atr(env_atr)) ttl2 = request.security(syminfo.tickerid, timeframe, env_MA + mult * 2 * ta.atr(env_atr)) btl2 = request.security(syminfo.tickerid, timeframe, env_MA - mult * 2 * ta.atr(env_atr)) // 1/2 of the 1/2. for tighter SL or trailing stp_utl = request.security(syminfo.tickerid, timeframe, env_MA + mult / 2 * ta.atr(env_atr)) stp_ltl = request.security(syminfo.tickerid, timeframe, env_MA - mult / 2 * ta.atr(env_atr)) // Plotting AEDSMA Envelope Distance Zone env_col_s = aedsma_dyn_col warn_col = request.security(syminfo.tickerid, timeframe, f_warn_col(close , low, high, btl, ttl, color.green, color.red, color.rgb(8,255,8), color.rgb(255,198,0))) plot(showEnv ? utl : na, color=color.new(warn_col,50)) plot(showEnv ? ltl : na, color=color.new(warn_col,50)) t1 = plot(showEnv ? ttl : na, color=color.new(warn_col,50)) b1 = plot(showEnv ? btl : na, color=color.new(warn_col,50)) t2 = plot(showEnv ? ttl2 : na, color=color.new(warn_col,50)) b2 = plot(showEnv ? btl2 : na, color=color.new(warn_col,50)) s_utl = plot(showEnv ? stp_utl : na, color=na) s_ltl = plot(showEnv ? stp_ltl : na, color=na) colEnv = showEnv ? env_col_s : na fill(s_utl, s_ltl, color=color.new(colEnv, 85)) fill(t1, t2, color=color.new(warn_col,80)) fill(b1, b2, color=color.new(warn_col,80)) // Caution for price crossing outer distance zones of envelop. can act as TP top_out = high > ttl bot_out = low < btl quickWarn = top_out and not top_out[1] or bot_out and not bot_out[1] upWarn = top_out and not top_out[1] dnWarn = bot_out and not bot_out[1] // Signals _up = aedsma_dyn_col == up_col _dn = aedsma_dyn_col == dn_col buy = _up and not _up[1] sell = _dn and not _dn[1] var sig = 0 if buy and sig <= 0 sig := 1 sig if sell and sig >= 0 sig := -1 sig longsignal = sig == 1 and (sig != 1)[1] shortsignal = sig == -1 and (sig != -1)[1] // Plotting Signals atrPos = 0.72 * ta.atr(5) plotshape(showSignals and buy ? aedsma - atrPos : na, style=shape.circle, color=color.new(#AADB1E, 0), location=location.absolute, size=size.tiny) plotshape(showSignals and sell ? aedsma + atrPos : na, style=shape.circle, color=color.new(#E10600, 0), location=location.absolute, size=size.tiny) plotshape(showSignals and longsignal ? ltl - atrPos : na, style=shape.triangleup, color=color.new(color.green, 0), location=location.absolute, size=size.small) plotshape(showSignals and shortsignal ? utl + atrPos : na, style=shape.triangledown, color=color.new(color.red, 0), location=location.absolute, size=size.small) plotchar(showSignals and upWarn ? high + atrPos : dnWarn ? low - atrPos : na, color=upWarn ? #E10600 : dnWarn ? #AADB1E : na, location=location.absolute, char='⚑', size=size.tiny) // Alerts if buy alert('Possible Buy Signal at' + str.tostring(close), alert.freq_once_per_bar_close) if sell alert('Possible Sell Signal at' + str.tostring(close), alert.freq_once_per_bar_close) if longsignal alert('Possible Long Term Buy Signal at' + str.tostring(close), alert.freq_once_per_bar_close) if shortsignal alert('Possible Long Term Sell Signal at' + str.tostring(close), alert.freq_once_per_bar_close) if quickWarn and top_out alert('Price has just crossed above top AEDSMA zone', alert.freq_once_per_bar_close) if quickWarn and bot_out alert('Price has just crossed below bottom AEDSMA zone', alert.freq_once_per_bar_close) // Live Dynamic Length Table on Chart var length_table = table(na) length_table := table.new(position.bottom_right, columns=2, rows=1, border_width=1) table.cell(length_table, 0, 0, 'AEDSMA Dynamic Length', bgcolor=#cccccc) table.cell(length_table, 1, 0, str.tostring(int(aedsma_dyna)), bgcolor=#cccccc)
Doji-creators
https://www.tradingview.com/script/zmZdi4lg-Doji-creators/
snktshrma
https://www.tradingview.com/u/snktshrma/
47
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © snktshrma //@version=5 indicator("Doji-creators", overlay = true) var box hiLoBox = na var box hiLBox = na pips = input.float(1,minval=0.1,title="Pips") candles = input.int(5,minval=1,title="Candle") reward = input.int(1,minval=1,title="Reward") Precision = input.float(0.1, minval=0.0001, title="Precision") barcolor(math.abs(open[1] - close[1]) <= (high[1] - low[1]) * Precision and (close >= high[1] or close <= low[1]) ? color.yellow : na,0,false) if (math.abs(open[1] - close[1]) <= (high[1] - low[1]) * Precision and (close >= high[1])) hiLoBox := box.new(bar_index[1], (high + (high - low[1])*reward), bar_index+candles, high, border_color = na, bgcolor = color.new(color.green,60)) hiLBox := box.new(bar_index[1], high, bar_index+candles, low[1]-pips, border_color = na, bgcolor = color.new(color.red,60)) alert("Doji breakout upside", alert.freq_once_per_bar_close) else if (math.abs(open[1] - close[1]) <= (high[1] - low[1]) * Precision and (close <= low[1])) hiLoBox := box.new(bar_index[1], low, bar_index+candles, (low + (low - high[1])*reward), border_color = na, bgcolor = color.new(color.green,60)) hiLBox := box.new(bar_index[1], high[1]+pips, bar_index+candles, low, border_color = na, bgcolor = color.new(color.red,60)) alert("Doji breakout down", alert.freq_once_per_bar_close)
Average_Vol
https://www.tradingview.com/script/dO9fHycq/
Makaveli227
https://www.tradingview.com/u/Makaveli227/
2
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Makaveli227 //@version=5 indicator("Average_Vol") i_date = input.time(timestamp("20 Oct 2021 6:00 +0300"), "Date", confirm = true) From_Open_Mode = input.bool(false, "From_Open_Mode") var Vol = 0.0 var Average_Vol = 0.0 var Max_Candle_Vol = 0.0 var Average_Of_Candle = 0.0 f_average(_src) => // _src : series to average. var _cumTotal = 0.0 var _cumCount = 0.0 _cumTotal := _cumTotal + _src _cumCount := _cumCount + 1 Resultat = _cumTotal / _cumCount Average_Of_Candle := (open + close) / 2 if (From_Open_Mode) Max_Candle_Vol := math.max((open - low), (high-open)) else Max_Candle_Vol := (high - low) if time >= i_date Vol := Max_Candle_Vol / Average_Of_Candle * 100.0 Average_Vol := f_average(Vol) plot(Vol, "Vol") plot(Average_Vol, "Avg_Vol", color.orange)
Supertrend Explorer Second_40
https://www.tradingview.com/script/8sQcwZKb-Supertrend-Explorer-Second-40/
taner7
https://www.tradingview.com/u/taner7/
86
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/ // © KivancOzbilgic //derived the screener logic from @ zzzcrypto123 //@version=4 study("Supertrend Explorer", shorttitle="StEx", overlay=true) 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) t41 = input(title="BIST:HALKB", defval="BIST:HALKB") t42 = input(title="BIST:ZRGYO", defval="BIST:ZRGYO") t43 = input(title="BIST:BRYAT", defval="BIST:BRYAT") t44 = input(title="BIST:KRDMA", defval="BIST:KRDMA") t45 = input(title="BIST:KRDMD", defval="BIST:KRDMD") t46 = input(title="BIST:KRDMB", defval="BIST:KRDMB") t47 = input(title="BIST:PGSUS", defval="BIST:PGSUS") t48 = input(title="BIST:OYAKC", defval="BIST:OYAKC") t49 = input(title="BIST:BANVT", defval="BIST:BANVT") t50 = input(title="BIST:AKFGY", defval="BIST:AKFGY") t51 = input(title="BIST:AGHOL", defval="BIST:AGHOL") t52 = input(title="BIST:BRISA", defval="BIST:BRISA") t53 = input(title="BIST:VESTL", defval="BIST:VESTL") t54 = input(title="BIST:OTKAR", defval="BIST:OTKAR") t55 = input(title="BIST:DOAS", defval="BIST:DOAS") t56 = input(title="BIST:QNBFL", defval="BIST:QNBFL") t57 = input(title="BIST:SOKM", defval="BIST:SOKM") t58 = input(title="BIST:EKGYO", defval="BIST:EKGYO") t59 = input(title="BIST:TKFEN", defval="BIST:TKFEN") t60 = input(title="BIST:ISMEN", defval="BIST:ISMEN") t61 = input(title="BIST:KOZAA", defval="BIST:KOZAA") t62 = input(title="BIST:DOHOL", defval="BIST:DOHOL") t63 = input(title="BIST:SELEC", defval="BIST:SELEC") t64 = input(title="BIST:MGROS", defval="BIST:MGROS") t65 = input(title="BIST:NUHCM", defval="BIST:NUHCM") t66 = input(title="BIST:PKENT", defval="BIST:PKENT") t67 = input(title="BIST:AYGAZ", defval="BIST:AYGAZ") t68 = input(title="BIST:KORDS", defval="BIST:KORDS") t69 = input(title="BIST:TBORG", defval="BIST:TBORG") t70 = input(title="BIST:MPARK", defval="BIST:MPARK") t71 = input(title="BIST:SARKY", defval="BIST:SARKY") t72 = input(title="BIST:ULKER", defval="BIST:ULKER") t73 = input(title="BIST:TURSG", defval="BIST:TURSG") t74 = input(title="BIST:JANTS", defval="BIST:JANTS") t75 = input(title="BIST:DEVA", defval="BIST:DEVA") t76 = input(title="BIST:ECILC", defval="BIST:ECILC") t77 = input(title="BIST:EGEEN", defval="BIST:EGEEN") t78 = input(title="BIST:CRFSA", defval="BIST:CRFSA") t79 = input(title="BIST:ALARK", defval="BIST:ALARK") t80 = input(title="BIST:ECZYT", defval="BIST:ECZYT") //transparency changed var TRANSP = 40 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.new(color.green, TRANSP)) plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, TRANSP), textcolor=color.white) 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.new(color.red, TRANSP)) plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, TRANSP), textcolor=color.white) 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!") showscr = input(true, title="Show Screener Label") posX_scr = input(20, title="Pos. Label x-axis") posY_scr = input(1, title="Pos. Size Label y-axis") colinput = input(title="Label Color", defval="Blue", options=["White", "Black", "Red", "Green", "Yellow", "Blue"]) col = color.gray if colinput=="White" col:=color.white if colinput=="Black" col:=color.black if colinput=="Red" col:=color.red if colinput=="Green" col:=color.green if colinput=="Yellow" col:=color.yellow if colinput=="Blue" col:=color.blue Supertrend(Multiplier, Periods) => Up=hl2-(Multiplier*atr) Dn=hl2+(Multiplier*atr) TrendUp = 0.0 TrendUp := close[1]>TrendUp[1] ? max(Up,TrendUp[1]) : Up TrendDown = 0.0 TrendDown := close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn Trend = 0.0 Trend := close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1) Tsl = Trend==1? TrendUp: TrendDown S_Buy = Trend == 1 ? 1 : 0 S_Sell = Trend != 1 ? 1 : 0 [Trend, Tsl] [Trend, Tsl] = Supertrend(Multiplier, Periods) TrendReversal = Trend != Trend[1] [t041, s041] = security(t41, timeframe.period, Supertrend(Multiplier, Periods)) [t042, s042] = security(t42, timeframe.period, Supertrend(Multiplier, Periods)) [t043, s043] = security(t43, timeframe.period, Supertrend(Multiplier, Periods)) [t044, s044] = security(t44, timeframe.period, Supertrend(Multiplier, Periods)) [t045, s045] = security(t45, timeframe.period, Supertrend(Multiplier, Periods)) [t046, s046] = security(t46, timeframe.period, Supertrend(Multiplier, Periods)) [t047, s047] = security(t47, timeframe.period, Supertrend(Multiplier, Periods)) [t048, s048] = security(t48, timeframe.period, Supertrend(Multiplier, Periods)) [t049, s049] = security(t49, timeframe.period, Supertrend(Multiplier, Periods)) [t050, s050] = security(t50, timeframe.period, Supertrend(Multiplier, Periods)) [t051, s051] = security(t51, timeframe.period, Supertrend(Multiplier, Periods)) [t052, s052] = security(t52, timeframe.period, Supertrend(Multiplier, Periods)) [t053, s053] = security(t53, timeframe.period, Supertrend(Multiplier, Periods)) [t054, s054] = security(t54, timeframe.period, Supertrend(Multiplier, Periods)) [t055, s055] = security(t55, timeframe.period, Supertrend(Multiplier, Periods)) [t056, s056] = security(t56, timeframe.period, Supertrend(Multiplier, Periods)) [t057, s057] = security(t57, timeframe.period, Supertrend(Multiplier, Periods)) [t058, s058] = security(t58, timeframe.period, Supertrend(Multiplier, Periods)) [t059, s059] = security(t59, timeframe.period, Supertrend(Multiplier, Periods)) [t060, s060] = security(t60, timeframe.period, Supertrend(Multiplier, Periods)) [t061, s061] = security(t61, timeframe.period, Supertrend(Multiplier, Periods)) [t062, s062] = security(t62, timeframe.period, Supertrend(Multiplier, Periods)) [t063, s063] = security(t63, timeframe.period, Supertrend(Multiplier, Periods)) [t064, s064] = security(t64, timeframe.period, Supertrend(Multiplier, Periods)) [t065, s065] = security(t65, timeframe.period, Supertrend(Multiplier, Periods)) [t066, s066] = security(t66, timeframe.period, Supertrend(Multiplier, Periods)) [t067, s067] = security(t67, timeframe.period, Supertrend(Multiplier, Periods)) [t068, s068] = security(t68, timeframe.period, Supertrend(Multiplier, Periods)) [t069, s069] = security(t69, timeframe.period, Supertrend(Multiplier, Periods)) [t070, s070] = security(t70, timeframe.period, Supertrend(Multiplier, Periods)) [t071, s071] = security(t71, timeframe.period, Supertrend(Multiplier, Periods)) [t072, s072] = security(t72, timeframe.period, Supertrend(Multiplier, Periods)) [t073, s073] = security(t73, timeframe.period, Supertrend(Multiplier, Periods)) [t074, s074] = security(t74, timeframe.period, Supertrend(Multiplier, Periods)) [t075, s075] = security(t75, timeframe.period, Supertrend(Multiplier, Periods)) [t076, s076] = security(t76, timeframe.period, Supertrend(Multiplier, Periods)) [t077, s077] = security(t77, timeframe.period, Supertrend(Multiplier, Periods)) [t078, s078] = security(t78, timeframe.period, Supertrend(Multiplier, Periods)) [t079, s079] = security(t79, timeframe.period, Supertrend(Multiplier, Periods)) [t080, s080] = security(t80, timeframe.period, Supertrend(Multiplier, Periods)) //** tr01 = t01 != t01[1], up01 = t01 == 1, dn01 = t01 == -1 tr41 = t041 != t041[1], up41 = t041 == 1, dn41 = t041 == -1 tr42 = t042 != t042[1], up42 = t042 == 1, dn42 = t042 == -1 tr43 = t043 != t043[1], up43 = t043 == 1, dn43 = t043 == -1 tr44 = t044 != t044[1], up44 = t044 == 1, dn44 = t044 == -1 tr45 = t045 != t045[1], up45 = t045 == 1, dn45 = t045 == -1 tr46 = t046 != t046[1], up46 = t046 == 1, dn46 = t046 == -1 tr47 = t047 != t047[1], up47 = t047 == 1, dn47 = t047 == -1 tr48 = t048 != t048[1], up48 = t048 == 1, dn48 = t048 == -1 tr49 = t049 != t049[1], up49 = t049 == 1, dn49 = t049 == -1 tr50 = t050 != t050[1], up50 = t050 == 1, dn50 = t050 == -1 tr51 = t051 != t051[1], up51 = t051 == 1, dn51 = t051 == -1 tr52 = t052 != t052[1], up52 = t052 == 1, dn52 = t052 == -1 tr53 = t053 != t053[1], up53 = t053 == 1, dn53 = t053 == -1 tr54 = t054 != t054[1], up54 = t054 == 1, dn54 = t054 == -1 tr55 = t055 != t055[1], up55 = t055 == 1, dn55 = t055 == -1 tr56 = t056 != t056[1], up56 = t056 == 1, dn56 = t056 == -1 tr57 = t057 != t057[1], up57 = t057 == 1, dn57 = t057 == -1 tr58 = t058 != t058[1], up58 = t058 == 1, dn58 = t058 == -1 tr59 = t059 != t059[1], up59 = t059 == 1, dn59 = t059 == -1 tr60 = t060 != t060[1], up60 = t060 == 1, dn60 = t060 == -1 tr61 = t061 != t061[1], up61 = t061 == 1, dn61 = t061 == -1 tr62 = t062 != t062[1], up62 = t062 == 1, dn62 = t062 == -1 tr63 = t063 != t063[1], up63 = t063 == 1, dn63 = t063 == -1 tr64 = t064 != t064[1], up64 = t064 == 1, dn64 = t064 == -1 tr65 = t065 != t065[1], up65 = t065 == 1, dn65 = t065 == -1 tr66 = t066 != t066[1], up66 = t066 == 1, dn66 = t066 == -1 tr67 = t067 != t067[1], up67 = t067 == 1, dn67 = t067 == -1 tr68 = t068 != t068[1], up68 = t068 == 1, dn68 = t068 == -1 tr69 = t069 != t069[1], up69 = t069 == 1, dn69 = t069 == -1 tr70 = t070 != t070[1], up70 = t070 == 1, dn70 = t070 == -1 tr71 = t071 != t071[1], up71 = t071 == 1, dn71 = t071 == -1 tr72 = t072 != t072[1], up72 = t072 == 1, dn72 = t072 == -1 tr73 = t073 != t073[1], up73 = t073 == 1, dn73 = t073 == -1 tr74 = t074 != t074[1], up74 = t074 == 1, dn74 = t074 == -1 tr75 = t075 != t075[1], up75 = t075 == 1, dn75 = t075 == -1 tr76 = t076 != t076[1], up76 = t076 == 1, dn76 = t076 == -1 tr77 = t077 != t077[1], up77 = t077 == 1, dn77 = t077 == -1 tr78 = t078 != t078[1], up78 = t078 == 1, dn78 = t078 == -1 tr79 = t079 != t079[1], up79 = t079 == 1, dn79 = t079 == -1 tr80 = t080 != t080[1], up80 = t080 == 1, dn80 = t080 == -1 pot_label = 'Potential Reversal: \n' pot_label := tr41 ? pot_label + t41 + '\n' : pot_label pot_label := tr42 ? pot_label + t42 + '\n' : pot_label pot_label := tr43 ? pot_label + t43 + '\n' : pot_label pot_label := tr44 ? pot_label + t44 + '\n' : pot_label pot_label := tr45 ? pot_label + t45 + '\n' : pot_label pot_label := tr46 ? pot_label + t46 + '\n' : pot_label pot_label := tr47 ? pot_label + t47 + '\n' : pot_label pot_label := tr48 ? pot_label + t48 + '\n' : pot_label pot_label := tr49 ? pot_label + t49 + '\n' : pot_label pot_label := tr50 ? pot_label + t50 + '\n' : pot_label pot_label := tr51 ? pot_label + t51 + '\n' : pot_label pot_label := tr52 ? pot_label + t52 + '\n' : pot_label pot_label := tr53 ? pot_label + t53 + '\n' : pot_label pot_label := tr54 ? pot_label + t54 + '\n' : pot_label pot_label := tr55 ? pot_label + t55 + '\n' : pot_label pot_label := tr56 ? pot_label + t56 + '\n' : pot_label pot_label := tr57 ? pot_label + t57 + '\n' : pot_label pot_label := tr58 ? pot_label + t58 + '\n' : pot_label pot_label := tr59 ? pot_label + t59 + '\n' : pot_label pot_label := tr60 ? pot_label + t60 + '\n' : pot_label pot_label := tr61 ? pot_label + t61 + '\n' : pot_label pot_label := tr62 ? pot_label + t62 + '\n' : pot_label pot_label := tr63 ? pot_label + t63 + '\n' : pot_label pot_label := tr64 ? pot_label + t64 + '\n' : pot_label pot_label := tr65 ? pot_label + t65 + '\n' : pot_label pot_label := tr66 ? pot_label + t66 + '\n' : pot_label pot_label := tr67 ? pot_label + t67 + '\n' : pot_label pot_label := tr68 ? pot_label + t68 + '\n' : pot_label pot_label := tr69 ? pot_label + t69 + '\n' : pot_label pot_label := tr70 ? pot_label + t70 + '\n' : pot_label pot_label := tr71 ? pot_label + t71 + '\n' : pot_label pot_label := tr72 ? pot_label + t72 + '\n' : pot_label pot_label := tr73 ? pot_label + t73 + '\n' : pot_label pot_label := tr74 ? pot_label + t74 + '\n' : pot_label pot_label := tr75 ? pot_label + t75 + '\n' : pot_label pot_label := tr76 ? pot_label + t76 + '\n' : pot_label pot_label := tr77 ? pot_label + t77 + '\n' : pot_label pot_label := tr78 ? pot_label + t78 + '\n' : pot_label pot_label := tr79 ? pot_label + t79 + '\n' : pot_label pot_label := tr80 ? pot_label + t80 + '\n' : pot_label scr_label = 'Confirmed Reversal: \n' scr_label := tr41[1] ? scr_label + t41 + '\n' : scr_label scr_label := tr42[1] ? scr_label + t42 + '\n' : scr_label scr_label := tr43[1] ? scr_label + t43 + '\n' : scr_label scr_label := tr44[1] ? scr_label + t44 + '\n' : scr_label scr_label := tr45[1] ? scr_label + t45 + '\n' : scr_label scr_label := tr46[1] ? scr_label + t46 + '\n' : scr_label scr_label := tr47[1] ? scr_label + t47 + '\n' : scr_label scr_label := tr48[1] ? scr_label + t48 + '\n' : scr_label scr_label := tr49[1] ? scr_label + t49 + '\n' : scr_label scr_label := tr50[1] ? scr_label + t50 + '\n' : scr_label scr_label := tr51[1] ? scr_label + t51 + '\n' : scr_label scr_label := tr52[1] ? scr_label + t52 + '\n' : scr_label scr_label := tr53[1] ? scr_label + t53 + '\n' : scr_label scr_label := tr54[1] ? scr_label + t54 + '\n' : scr_label scr_label := tr55[1] ? scr_label + t55 + '\n' : scr_label scr_label := tr56[1] ? scr_label + t56 + '\n' : scr_label scr_label := tr57[1] ? scr_label + t57 + '\n' : scr_label scr_label := tr58[1] ? scr_label + t58 + '\n' : scr_label scr_label := tr59[1] ? scr_label + t59 + '\n' : scr_label scr_label := tr60[1] ? scr_label + t60 + '\n' : scr_label scr_label := tr61[1] ? scr_label + t61 + '\n' : scr_label scr_label := tr62[1] ? scr_label + t62 + '\n' : scr_label scr_label := tr63[1] ? scr_label + t63 + '\n' : scr_label scr_label := tr64[1] ? scr_label + t64 + '\n' : scr_label scr_label := tr65[1] ? scr_label + t65 + '\n' : scr_label scr_label := tr66[1] ? scr_label + t66 + '\n' : scr_label scr_label := tr67[1] ? scr_label + t67 + '\n' : scr_label scr_label := tr68[1] ? scr_label + t68 + '\n' : scr_label scr_label := tr69[1] ? scr_label + t69 + '\n' : scr_label scr_label := tr70[1] ? scr_label + t70 + '\n' : scr_label scr_label := tr71[1] ? scr_label + t71 + '\n' : scr_label scr_label := tr72[1] ? scr_label + t72 + '\n' : scr_label scr_label := tr73[1] ? scr_label + t73 + '\n' : scr_label scr_label := tr74[1] ? scr_label + t74 + '\n' : scr_label scr_label := tr75[1] ? scr_label + t75 + '\n' : scr_label scr_label := tr76[1] ? scr_label + t76 + '\n' : scr_label scr_label := tr77[1] ? scr_label + t77 + '\n' : scr_label scr_label := tr78[1] ? scr_label + t78 + '\n' : scr_label scr_label := tr79[1] ? scr_label + t79 + '\n' : scr_label scr_label := tr80[1] ? scr_label + t80 + '\n' : scr_label f_colorscr (_valscr ) => _valscr ? #00000000 : na f_printscr (_txtscr ) => var _lblscr = label(na), label.delete(_lblscr ), _lblscr := label.new( time + (time-time[1])*posX_scr , ohlc4[posY_scr], _txtscr , xloc.bar_time, yloc.price, f_colorscr ( showscr ), textcolor = showscr ? col : na, size = size.large, style=label.style_label_lower_left ) f_printscr ( scr_label + '\n' + pot_label) st_security(_symbol, _res, _src) => security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0]) ST_Trend = st_security(syminfo.tickerid, timeframe.period, Trend) ST_Tsl = st_security(syminfo.tickerid, timeframe.period, Tsl)
Supertrend Explorer First_40
https://www.tradingview.com/script/G37fZA1y-Supertrend-Explorer-First-40/
taner7
https://www.tradingview.com/u/taner7/
51
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/ // © KivancOzbilgic //derived the screener logic from @ zzzcrypto123 //@version=4 study("Supertrend Explorer", shorttitle="StEx", overlay=true) 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) t1 = input(title="BIST:QNBFB", defval="BIST:QNBFB") t2 = input(title="BIST:EREGL", defval="BIST:EREGL") t3 = input(title="BIST:KCHOL", defval="BIST:KCHOL") t4 = input(title="BIST:FROTO", defval="BIST:FROTO") t5 = input(title="BIST:ENKAI", defval="BIST:ENKAI") t6 = input(title="BIST:ISDMR", defval="BIST:ISDMR") t7 = input(title="BIST:SASA", defval="BIST:SASA") t8 = input(title="BIST:ASELS", defval="BIST:ASELS") t9 = input(title="BIST:GARAN", defval="BIST:GARAN") t10 = input(title="BIST:TUPRS", defval="BIST:TUPRS") t11 = input(title="BIST:TOASO", defval="BIST:TOASO") t12 = input(title="BIST:SISE", defval="BIST:SISE") t13 = input(title="BIST:TCELL", defval="BIST:TCELL") t14 = input(title="BIST:BIMAS", defval="BIST:BIMAS") t15 = input(title="BIST:KENT", defval="BIST:KENT") t16 = input(title="BIST:AKBNK", defval="BIST:AKBNK") t17 = input(title="BIST:TTKOM", defval="BIST:TTKOM") t18 = input(title="BIST:ISCTR", defval="BIST:ISCTR") t19 = input(title="BIST:ISBTR", defval="BIST:ISBTR") t20 = input(title="BIST:ISKUR", defval="BIST:ISKUR") t21 = input(title="BIST:ARCLK", defval="BIST:ARCLK") t22 = input(title="BIST:KLNMA", defval="BIST:KLNMA") t23 = input(title="BIST:THYAO", defval="BIST:THYAO") t24 = input(title="BIST:YKBNK", defval="BIST:YKBNK") t25 = input(title="BIST:SAHOL", defval="BIST:SAHOL") t26 = input(title="BIST:GUBRF", defval="BIST:GUBRF") t27 = input(title="BIST:CCOLA", defval="BIST:CCOLA") t28 = input(title="BIST:PETKM", defval="BIST:PETKM") t29 = input(title="BIST:KOZAL", defval="BIST:KOZAL") t30 = input(title="BIST:AEFES", defval="BIST:AEFES") t31 = input(title="BIST:ENJSA", defval="BIST:ENJSA") t32 = input(title="BIST:VAKBN", defval="BIST:VAKBN") t33 = input(title="BIST:PRKAB", defval="BIST:PRKAB") t34 = input(title="BIST:HEKTS", defval="BIST:HEKTS") t35 = input(title="BIST:AKSEN", defval="BIST:AKSEN") t36 = input(title="BIST:TAVHL", defval="BIST:TAVHL") t37 = input(title="BIST:VESBE", defval="BIST:VESBE") t38 = input(title="BIST:DOCO", defval="BIST:DOCO") t39 = input(title="BIST:TTRAK", defval="BIST:TTRAK") t40 = input(title="BIST:AKSA", defval="BIST:AKSA") //transparency changed var TRANSP = 40 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.new(color.green, TRANSP)) plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, TRANSP), textcolor=color.white) 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.new(color.red, TRANSP)) plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, TRANSP), textcolor=color.white) 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!") showscr = input(true, title="Show Screener Label") posX_scr = input(20, title="Pos. Label x-axis") posY_scr = input(1, title="Pos. Size Label y-axis") colinput = input(title="Label Color", defval="Blue", options=["White", "Black", "Red", "Green", "Yellow", "Blue"]) col = color.gray if colinput=="White" col:=color.white if colinput=="Black" col:=color.black if colinput=="Red" col:=color.red if colinput=="Green" col:=color.green if colinput=="Yellow" col:=color.yellow if colinput=="Blue" col:=color.blue Supertrend(Multiplier, Periods) => Up=hl2-(Multiplier*atr) Dn=hl2+(Multiplier*atr) TrendUp = 0.0 TrendUp := close[1]>TrendUp[1] ? max(Up,TrendUp[1]) : Up TrendDown = 0.0 TrendDown := close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn Trend = 0.0 Trend := close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1) Tsl = Trend==1? TrendUp: TrendDown S_Buy = Trend == 1 ? 1 : 0 S_Sell = Trend != 1 ? 1 : 0 [Trend, Tsl] [Trend, Tsl] = Supertrend(Multiplier, Periods) TrendReversal = Trend != Trend[1] [t01, s01] = security(t1, timeframe.period, Supertrend(Multiplier, Periods)) [t02, s02] = security(t2, timeframe.period, Supertrend(Multiplier, Periods)) [t03, s03] = security(t3, timeframe.period, Supertrend(Multiplier, Periods)) [t04, s04] = security(t4, timeframe.period, Supertrend(Multiplier, Periods)) [t05, s05] = security(t5, timeframe.period, Supertrend(Multiplier, Periods)) [t06, s06] = security(t6, timeframe.period, Supertrend(Multiplier, Periods)) [t07, s07] = security(t7, timeframe.period, Supertrend(Multiplier, Periods)) [t08, s08] = security(t8, timeframe.period, Supertrend(Multiplier, Periods)) [t09, s09] = security(t9, timeframe.period, Supertrend(Multiplier, Periods)) [t010, s010] = security(t10, timeframe.period, Supertrend(Multiplier, Periods)) [t011, s011] = security(t11, timeframe.period, Supertrend(Multiplier, Periods)) [t012, s012] = security(t12, timeframe.period, Supertrend(Multiplier, Periods)) [t013, s013] = security(t13, timeframe.period, Supertrend(Multiplier, Periods)) [t014, s014] = security(t14, timeframe.period, Supertrend(Multiplier, Periods)) [t015, s015] = security(t15, timeframe.period, Supertrend(Multiplier, Periods)) [t016, s016] = security(t16, timeframe.period, Supertrend(Multiplier, Periods)) [t017, s017] = security(t17, timeframe.period, Supertrend(Multiplier, Periods)) [t018, s018] = security(t18, timeframe.period, Supertrend(Multiplier, Periods)) [t019, s019] = security(t19, timeframe.period, Supertrend(Multiplier, Periods)) [t020, s020] = security(t20, timeframe.period, Supertrend(Multiplier, Periods)) [t021, s021] = security(t21, timeframe.period, Supertrend(Multiplier, Periods)) [t022, s022] = security(t22, timeframe.period, Supertrend(Multiplier, Periods)) [t023, s023] = security(t23, timeframe.period, Supertrend(Multiplier, Periods)) [t024, s024] = security(t24, timeframe.period, Supertrend(Multiplier, Periods)) [t025, s025] = security(t25, timeframe.period, Supertrend(Multiplier, Periods)) [t026, s026] = security(t26, timeframe.period, Supertrend(Multiplier, Periods)) [t027, s027] = security(t27, timeframe.period, Supertrend(Multiplier, Periods)) [t028, s028] = security(t28, timeframe.period, Supertrend(Multiplier, Periods)) [t029, s029] = security(t29, timeframe.period, Supertrend(Multiplier, Periods)) [t030, s030] = security(t30, timeframe.period, Supertrend(Multiplier, Periods)) [t031, s031] = security(t31, timeframe.period, Supertrend(Multiplier, Periods)) [t032, s032] = security(t32, timeframe.period, Supertrend(Multiplier, Periods)) [t033, s033] = security(t33, timeframe.period, Supertrend(Multiplier, Periods)) [t034, s034] = security(t34, timeframe.period, Supertrend(Multiplier, Periods)) [t035, s035] = security(t35, timeframe.period, Supertrend(Multiplier, Periods)) [t036, s036] = security(t36, timeframe.period, Supertrend(Multiplier, Periods)) [t037, s037] = security(t37, timeframe.period, Supertrend(Multiplier, Periods)) [t038, s038] = security(t38, timeframe.period, Supertrend(Multiplier, Periods)) [t039, s039] = security(t39, timeframe.period, Supertrend(Multiplier, Periods)) [t040, s040] = security(t40, timeframe.period, Supertrend(Multiplier, Periods)) //** tr01 = t01 != t01[1], up01 = t01 == 1, dn01 = t01 == -1 tr01 = t01 != t01[1], up01 = t01 == 1, dn01 = t01 == -1 tr02 = t02 != t02[1], up02 = t02 == 1, dn02 = t02 == -1 tr03 = t03 != t03[1], up03 = t03 == 1, dn03 = t03 == -1 tr04 = t04 != t04[1], up04 = t04 == 1, dn04 = t04 == -1 tr05 = t05 != t05[1], up05 = t05 == 1, dn05 = t05 == -1 tr06 = t06 != t06[1], up06 = t06 == 1, dn06 = t06 == -1 tr07 = t07 != t07[1], up07 = t07 == 1, dn07 = t07 == -1 tr08 = t08 != t08[1], up08 = t08 == 1, dn08 = t08 == -1 tr09 = t09 != t09[1], up09 = t09 == 1, dn09 = t09 == -1 tr10 = t010 != t010[1], up10 = t010 == 1, dn10 = t010 == -1 tr11 = t011 != t011[1], up11 = t011 == 1, dn11 = t011 == -1 tr12 = t012 != t012[1], up12 = t012 == 1, dn12 = t012 == -1 tr13 = t013 != t013[1], up13 = t013 == 1, dn13 = t013 == -1 tr14 = t014 != t014[1], up14 = t014 == 1, dn14 = t014 == -1 tr15 = t015 != t015[1], up15 = t015 == 1, dn15 = t015 == -1 tr16 = t016 != t016[1], up16 = t016 == 1, dn16 = t016 == -1 tr17 = t017 != t017[1], up17 = t017 == 1, dn17 = t017 == -1 tr18 = t018 != t018[1], up18 = t018 == 1, dn18 = t018 == -1 tr19 = t019 != t019[1], up19 = t019 == 1, dn19 = t019 == -1 tr20 = t020 != t020[1], up20 = t020 == 1, dn20 = t020 == -1 tr21 = t021 != t021[1], up21 = t021 == 1, dn21 = t021 == -1 tr22 = t022 != t022[1], up22 = t022 == 1, dn22 = t022 == -1 tr23 = t023 != t023[1], up23 = t023 == 1, dn23 = t023 == -1 tr24 = t024 != t024[1], up24 = t024 == 1, dn24 = t024 == -1 tr25 = t025 != t025[1], up25 = t025 == 1, dn25 = t025 == -1 tr26 = t026 != t026[1], up26 = t026 == 1, dn26 = t026 == -1 tr27 = t027 != t027[1], up27 = t027 == 1, dn27 = t027 == -1 tr28 = t028 != t028[1], up28 = t028 == 1, dn28 = t028 == -1 tr29 = t029 != t029[1], up29 = t029 == 1, dn29 = t029 == -1 tr30 = t030 != t030[1], up30 = t030 == 1, dn30 = t030 == -1 tr31 = t031 != t031[1], up31 = t031 == 1, dn31 = t031 == -1 tr32 = t032 != t032[1], up32 = t032 == 1, dn32 = t032 == -1 tr33 = t033 != t033[1], up33 = t033 == 1, dn33 = t033 == -1 tr34 = t034 != t034[1], up34 = t034 == 1, dn34 = t034 == -1 tr35 = t035 != t035[1], up35 = t035 == 1, dn35 = t035 == -1 tr36 = t036 != t036[1], up36 = t036 == 1, dn36 = t036 == -1 tr37 = t037 != t037[1], up37 = t037 == 1, dn37 = t037 == -1 tr38 = t038 != t038[1], up38 = t038 == 1, dn38 = t038 == -1 tr39 = t039 != t039[1], up39 = t039 == 1, dn39 = t039 == -1 tr40 = t040 != t040[1], up40 = t040 == 1, dn40 = t040 == -1 pot_label = 'Potential Reversal: \n' pot_label := tr01 ? pot_label + t1 + '\n' : pot_label pot_label := tr02 ? pot_label + t2 + '\n' : pot_label pot_label := tr03 ? pot_label + t3 + '\n' : pot_label pot_label := tr04 ? pot_label + t4 + '\n' : pot_label pot_label := tr05 ? pot_label + t5 + '\n' : pot_label pot_label := tr06 ? pot_label + t6 + '\n' : pot_label pot_label := tr07 ? pot_label + t7 + '\n' : pot_label pot_label := tr08 ? pot_label + t8 + '\n' : pot_label pot_label := tr09 ? pot_label + t9 + '\n' : pot_label pot_label := tr10 ? pot_label + t10 + '\n' : pot_label pot_label := tr11 ? pot_label + t11 + '\n' : pot_label pot_label := tr12 ? pot_label + t12 + '\n' : pot_label pot_label := tr13 ? pot_label + t13 + '\n' : pot_label pot_label := tr14 ? pot_label + t14 + '\n' : pot_label pot_label := tr15 ? pot_label + t15 + '\n' : pot_label pot_label := tr16 ? pot_label + t16 + '\n' : pot_label pot_label := tr17 ? pot_label + t17 + '\n' : pot_label pot_label := tr18 ? pot_label + t18 + '\n' : pot_label pot_label := tr19 ? pot_label + t19 + '\n' : pot_label pot_label := tr20 ? pot_label + t20 + '\n' : pot_label pot_label := tr21 ? pot_label + t21 + '\n' : pot_label pot_label := tr22 ? pot_label + t22 + '\n' : pot_label pot_label := tr23 ? pot_label + t23 + '\n' : pot_label pot_label := tr24 ? pot_label + t24 + '\n' : pot_label pot_label := tr25 ? pot_label + t25 + '\n' : pot_label pot_label := tr26 ? pot_label + t26 + '\n' : pot_label pot_label := tr27 ? pot_label + t27 + '\n' : pot_label pot_label := tr28 ? pot_label + t28 + '\n' : pot_label pot_label := tr29 ? pot_label + t29 + '\n' : pot_label pot_label := tr30 ? pot_label + t30 + '\n' : pot_label pot_label := tr31 ? pot_label + t31 + '\n' : pot_label pot_label := tr32 ? pot_label + t32 + '\n' : pot_label pot_label := tr33 ? pot_label + t33 + '\n' : pot_label pot_label := tr34 ? pot_label + t34 + '\n' : pot_label pot_label := tr35 ? pot_label + t35 + '\n' : pot_label pot_label := tr36 ? pot_label + t36 + '\n' : pot_label pot_label := tr37 ? pot_label + t37 + '\n' : pot_label pot_label := tr38 ? pot_label + t38 + '\n' : pot_label pot_label := tr39 ? pot_label + t39 + '\n' : pot_label pot_label := tr40 ? pot_label + t40 + '\n' : pot_label scr_label = 'Confirmed Reversal: \n' scr_label := tr01[1] ? scr_label + t1 + '\n' : scr_label scr_label := tr02[1] ? scr_label + t2 + '\n' : scr_label scr_label := tr03[1] ? scr_label + t3 + '\n' : scr_label scr_label := tr04[1] ? scr_label + t4 + '\n' : scr_label scr_label := tr05[1] ? scr_label + t5 + '\n' : scr_label scr_label := tr06[1] ? scr_label + t6 + '\n' : scr_label scr_label := tr07[1] ? scr_label + t7 + '\n' : scr_label scr_label := tr08[1] ? scr_label + t8 + '\n' : scr_label scr_label := tr09[1] ? scr_label + t9 + '\n' : scr_label scr_label := tr10[1] ? scr_label + t10 + '\n' : scr_label scr_label := tr11[1] ? scr_label + t11 + '\n' : scr_label scr_label := tr12[1] ? scr_label + t12 + '\n' : scr_label scr_label := tr13[1] ? scr_label + t13 + '\n' : scr_label scr_label := tr14[1] ? scr_label + t14 + '\n' : scr_label scr_label := tr15[1] ? scr_label + t15 + '\n' : scr_label scr_label := tr16[1] ? scr_label + t16 + '\n' : scr_label scr_label := tr17[1] ? scr_label + t17 + '\n' : scr_label scr_label := tr18[1] ? scr_label + t18 + '\n' : scr_label scr_label := tr19[1] ? scr_label + t19 + '\n' : scr_label scr_label := tr20[1] ? scr_label + t20 + '\n' : scr_label scr_label := tr21[1] ? scr_label + t21 + '\n' : scr_label scr_label := tr22[1] ? scr_label + t22 + '\n' : scr_label scr_label := tr23[1] ? scr_label + t23 + '\n' : scr_label scr_label := tr24[1] ? scr_label + t24 + '\n' : scr_label scr_label := tr25[1] ? scr_label + t25 + '\n' : scr_label scr_label := tr26[1] ? scr_label + t26 + '\n' : scr_label scr_label := tr27[1] ? scr_label + t27 + '\n' : scr_label scr_label := tr28[1] ? scr_label + t28 + '\n' : scr_label scr_label := tr29[1] ? scr_label + t29 + '\n' : scr_label scr_label := tr30[1] ? scr_label + t30 + '\n' : scr_label scr_label := tr31[1] ? scr_label + t31 + '\n' : scr_label scr_label := tr32[1] ? scr_label + t32 + '\n' : scr_label scr_label := tr33[1] ? scr_label + t33 + '\n' : scr_label scr_label := tr34[1] ? scr_label + t34 + '\n' : scr_label scr_label := tr35[1] ? scr_label + t35 + '\n' : scr_label scr_label := tr36[1] ? scr_label + t36 + '\n' : scr_label scr_label := tr37[1] ? scr_label + t37 + '\n' : scr_label scr_label := tr38[1] ? scr_label + t38 + '\n' : scr_label scr_label := tr39[1] ? scr_label + t39 + '\n' : scr_label scr_label := tr40[1] ? scr_label + t40 + '\n' : scr_label f_colorscr (_valscr ) => _valscr ? #00000000 : na f_printscr (_txtscr ) => var _lblscr = label(na), label.delete(_lblscr ), _lblscr := label.new( time + (time-time[1])*posX_scr , ohlc4[posY_scr], _txtscr , xloc.bar_time, yloc.price, f_colorscr ( showscr ), textcolor = showscr ? col : na, size = size.normal, style=label.style_label_center ) f_printscr ( scr_label + '\n' + pot_label) st_security(_symbol, _res, _src) => security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0]) ST_Trend = st_security(syminfo.tickerid, timeframe.period, Trend) ST_Tsl = st_security(syminfo.tickerid, timeframe.period, Tsl)
Confluence Zones & Midpoints
https://www.tradingview.com/script/8DSg0feX-Confluence-Zones-Midpoints/
fvideira
https://www.tradingview.com/u/fvideira/
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/ // © fvideira // Study of Confluence Zone & Midpoints levels from Eliza123123's quantative trading series: https://youtu.be/C9hUlmPLVEk //@version=5 indicator("Confluence Zones & Midpoints", overlay=true) // Inputs Confluence = input.bool(true, "On/Off", "", inline = "Line Colours", group = "Confluence Zones") ConfluenceCol = input.color(color.new(color.aqua, 20), "", inline = "Line Colours", group = "Confluence Zones") Midpoint = input.bool(true, "On/Off", "", inline = "Colour", group = "Midpoint") MidpointCol = input.color(color.new(color.fuchsia, 80), "", inline = "Colour", group = "Midpoint") extendRight = input.bool(false, "Extend Lines") var extending = extend.none if extendRight extending := extend.right if not extendRight extending := extend.none Table = input.bool(true, "On/Off", inline = "Col", group = "Table") TableColUp = input.color(color.new(color.blue, 50), "Table Top", inline = "Col1", group = "Table") TableColDown = input.color(color.new(color.fuchsia, 50), "Table Bottom", inline = "Col2", group = "Table") TxtCol = input.color(color.new(color.white, 25), "Text", inline = "Col3", group = "Table") // Scale Factors & Constants scale = 0.0 if close >= 10000 scale := 1000 if close >= 1000 and close <=9999.999999 scale := 100 if close >= 100 and close <=999.999999 scale := 10 if close >= 10 and close <=99.999999 scale := 1 if close >= 1 and close <=9.999999 scale := 0.1 if close >= 0.1 and close <=0.999999 scale := 0.01 if close >= 0.01 and close <=0.099999 scale := 0.001 if close >= 0.001 and close <=0.009999 scale := 0.0001 e = 2.71828, pi = 3.14159 // Variables z_1_low = 3 * scale, z_1_high = pi * scale z_2_low = (4*e) * scale, z_2_high = 11 * scale z_3_low = 19 * scale, z_3_high = (7*e) * scale z_4_low = (15*e) * scale, z_4_high = (13*pi) * scale z_5_low = 47 * scale, z_5_high = (15*pi) * scale z_6_low = (19*pi) * scale, z_6_high = (22*e) * scale z_7_low = (25*pi) * scale, z_7_high = (29*e) * scale z_8_low = (30*e) * scale, z_8_high = (26*pi) * scale // If clauses (for inputs to work as on/off) if Confluence ConfluenceCol else ConfluenceCol := na if Midpoint MidpointCol else MidpointCol := na // Plots z1 = line.new(bar_index[4999], z_1_low, bar_index, z_1_low, color = ConfluenceCol, width = 1, extend = extending) z2 = line.new(bar_index[4999], z_1_high, bar_index, z_1_high, color = ConfluenceCol, width = 1, extend = extending) z3 = line.new(bar_index[4999], z_2_low, bar_index, z_2_low, color = ConfluenceCol, width = 1, extend = extending) z4 = line.new(bar_index[4999], z_2_high, bar_index, z_2_high, color = ConfluenceCol, width = 1, extend = extending) z5 = line.new(bar_index[4999], z_3_low, bar_index, z_3_low, color = ConfluenceCol, width = 1, extend = extending) z6 = line.new(bar_index[4999], z_3_high, bar_index, z_3_high, color = ConfluenceCol, width = 1, extend = extending) z7 = line.new(bar_index[4999], z_4_low, bar_index, z_4_low, color = ConfluenceCol, width = 1, extend = extending) z8 = line.new(bar_index[4999], z_4_high, bar_index, z_4_high, color = ConfluenceCol, width = 1, extend = extending) z9 = line.new(bar_index[4999], z_5_low, bar_index, z_5_low, color = ConfluenceCol, width = 1, extend = extending) z10 = line.new(bar_index[4999], z_5_high, bar_index, z_5_high, color = ConfluenceCol, width = 1, extend = extending) z11 = line.new(bar_index[4999], z_6_low, bar_index, z_6_low, color = ConfluenceCol, width = 1, extend = extending) z12 = line.new(bar_index[4999], z_6_high, bar_index, z_6_high, color = ConfluenceCol, width = 1, extend = extending) z13 = line.new(bar_index[4999], z_7_low, bar_index, z_7_low, color = ConfluenceCol, width = 1, extend = extending) z14 = line.new(bar_index[4999], z_7_high, bar_index, z_7_high, color = ConfluenceCol, width = 1, extend = extending) z15 = line.new(bar_index[4999], z_8_low, bar_index, z_8_low, color = ConfluenceCol, width = 1, extend = extending) z16 = line.new(bar_index[4999], z_8_high, bar_index, z_8_high, color = ConfluenceCol, width = 1, extend = extending) midpoint1 = (z_1_high + z_2_low) / 2, mp1 = line.new(bar_index[4999], midpoint1, bar_index, midpoint1, color = MidpointCol, width = 1, extend = extending) midpoint2 = (z_2_high + z_3_low) / 2, mp2 = line.new(bar_index[4999], midpoint2, bar_index, midpoint2, color = MidpointCol, width = 1, extend = extending) midpoint3 = (z_3_high + z_4_low) / 2, mp3 = line.new(bar_index[4999], midpoint3, bar_index, midpoint3, color = MidpointCol, width = 1, extend = extending) midpoint4 = (z_4_high + z_5_low) / 2, mp4 = line.new(bar_index[4999], midpoint4, bar_index, midpoint4, color = MidpointCol, width = 1, extend = extending) midpoint5 = (z_5_high + z_6_low) / 2, mp5 = line.new(bar_index[4999], midpoint5, bar_index, midpoint5, color = MidpointCol, width = 1, extend = extending) midpoint6 = (z_6_high + z_7_low) / 2, mp6 = line.new(bar_index[4999], midpoint6, bar_index, midpoint6, color = MidpointCol, width = 1, extend = extending) midpoint7 = (z_7_high + z_8_low) / 2, mp7 = line.new(bar_index[4999], midpoint7, bar_index, midpoint7, color = MidpointCol, width = 1, extend = extending) // Distances from levels dist1 = math.abs(close - z_1_low), dist2 = math.abs(close - z_1_high) dist3 = math.abs(close - z_2_low), dist4 = math.abs(close - z_2_high) dist5 = math.abs(close - z_3_low), dist6 = math.abs(close - z_3_high) dist7 = math.abs(close - z_4_low), dist8 = math.abs(close - z_4_high) dist9 = math.abs(close - z_5_low), dist10 = math.abs(close - z_5_high) dist11 = math.abs(close - z_6_low), dist12 = math.abs(close - z_6_high) dist13 = math.abs(close - z_7_low), dist14 = math.abs(close - z_7_high) dist15 = math.abs(close - z_8_low), dist16 = math.abs(close - z_8_high) closest_zone = math.min(dist1, dist2, dist3, dist4, dist5, dist6, dist7, dist8, dist9, dist10, dist11, dist12, dist13, dist14, dist15, dist16) closest_zone_percent = (closest_zone / close) * 100 mdist1 = math.abs(close - midpoint1) mdist2 = math.abs(close - midpoint2) mdist3 = math.abs(close - midpoint3) mdist4 = math.abs(close - midpoint4) mdist5 = math.abs(close - midpoint5) mdist6 = math.abs(close - midpoint6) mdist7 = math.abs(close - midpoint7) closest_midpoint = math.min(mdist1, mdist2, mdist3, mdist4, mdist5, mdist6, mdist7) closest_mid_percent = (closest_midpoint / close) * 100 abovezone1 = string(""), belowzone1 = string("") abovezone2 = string(""), belowzone2 = string("") abovezone3 = string(""), belowzone3 = string("") abovezone4 = string(""), belowzone4 = string("") abovezone5 = string(""), belowzone5 = string("") abovezone6 = string(""), belowzone6 = string("") abovezone7 = string(""), belowzone7 = string("") abovezone8 = string(""), belowzone8 = string("") abovemidpoint1 = string(""), belowmidpoint1 = string("") abovemidpoint2 = string(""), belowmidpoint2 = string("") abovemidpoint3 = string(""), belowmidpoint3 = string("") abovemidpoint4 = string(""), belowmidpoint4 = string("") abovemidpoint5 = string(""), belowmidpoint5 = string("") abovemidpoint6 = string(""), belowmidpoint6 = string("") abovemidpoint7 = string(""), belowmidpoint7 = string("") // Above or below for zones if close < ((z_1_low + z_1_high) / 2) and close > 0.001 * scale abovezone1 := "above" belowzone1 := na if close > ((z_1_low + z_1_high) / 2) and close < midpoint1 abovezone1 := na belowzone1 := "below" if close < 0.001 * scale abovezone1 := na belowzone1 := na if close > midpoint2 abovezone1 := na belowzone1 := na if close < ((z_2_low + z_2_high) / 2) and close > midpoint1 abovezone2 := "above" belowzone2 := na if close > ((z_2_low + z_2_high) / 2) and close < midpoint2 abovezone2 := na belowzone2 := "below" if close < midpoint1 abovezone2 := na belowzone2 := na if close > midpoint2 abovezone2 := na belowzone2 := na if close < ((z_3_low + z_3_high) / 2) and close > midpoint2 abovezone3 := "above" belowzone3 := na if close > ((z_3_low + z_3_high) / 2) and close < midpoint3 abovezone3 := na belowzone3 := "below" if close < midpoint2 abovezone3 := na belowzone3 := na if close > midpoint3 abovezone3 := na belowzone3 := na if close < ((z_4_low + z_4_high) / 2) and close > midpoint3 abovezone4 := "above" belowzone4 := na if close > ((z_4_low + z_4_high) / 2) and close < midpoint4 abovezone4 := na belowzone4 := "below" if close < midpoint3 abovezone4 := na belowzone4 := na if close > midpoint4 abovezone4 := na belowzone4 := na if close < ((z_5_low + z_5_high) / 2) and close > midpoint4 abovezone5 := "above" belowzone5 := na if close > ((z_5_low + z_5_high) / 2) and close < midpoint5 abovezone5 := na belowzone5 := "below" if close < midpoint4 abovezone5 := na belowzone5 := na if close > midpoint5 abovezone5 := na belowzone5 := na if close < ((z_6_low + z_6_high) / 2) and close > midpoint5 abovezone6 := "above" belowzone6 := na if close > ((z_6_low + z_6_high) / 2) and close < midpoint6 abovezone6 := na belowzone6 := "below" if close < midpoint5 abovezone6 := na belowzone6 := na if close > midpoint6 abovezone6 := na belowzone6 := na if close < ((z_7_low + z_7_high) / 2) and close > midpoint6 abovezone7 := "above" belowzone7 := na if close > ((z_7_low + z_7_high) / 2) and close < midpoint7 abovezone7 := na belowzone7 := "below" if close < midpoint6 abovezone7 := na belowzone7 := na if close > midpoint7 abovezone7 := na belowzone7 := na if close < ((z_8_low + z_8_high) / 2) and close > midpoint7 abovezone8 := "above" belowzone8 := na if close > ((z_8_low + z_8_high) / 2) and close < 100 * scale abovezone8 := na belowzone8 := "below" if close < midpoint7 abovezone8 := na belowzone8 := na if close > 100 * scale abovezone8 := na belowzone8 := na // Above or below for midpoints if close < midpoint1 and close > 0.001 * scale abovemidpoint1 := "above" belowmidpoint1 := na if close > midpoint1 and close < ((midpoint1 + midpoint2) / 2) abovemidpoint1 := na belowmidpoint1 := "below" if close < 0.001 * scale abovemidpoint1 := na belowmidpoint1 := na if close > ((midpoint1 + midpoint2) / 2) abovemidpoint1 := na belowmidpoint1 := na if close < midpoint2 and close > ((midpoint1 + midpoint2) / 2) abovemidpoint2 := "above" belowmidpoint2 := na if close > midpoint2 and close < ((midpoint2 + midpoint3) / 2) abovemidpoint2 := na belowmidpoint2 := "below" if close < ((midpoint1 + midpoint2) / 2) abovemidpoint2 := na belowmidpoint2 := na if close > ((midpoint2 + midpoint3) / 2) abovemidpoint2 := na belowmidpoint2 := na if close < midpoint3 and close > ((midpoint2 + midpoint3) / 2) abovemidpoint3 := "above" belowmidpoint3 := na if close > midpoint3 and close < ((midpoint3 + midpoint4) / 2) abovemidpoint3 := na belowmidpoint3 := "below" if close < ((midpoint2 + midpoint3) / 2) abovemidpoint3 := na belowmidpoint3 := na if close > ((midpoint3 + midpoint4) / 2) abovemidpoint3 := na belowmidpoint3 := na if close < midpoint4 and close > ((midpoint3 + midpoint4) / 2) abovemidpoint4 := "above" belowmidpoint4 := na if close > midpoint4 and close < ((midpoint4 + midpoint5) / 2) abovemidpoint4 := na belowmidpoint4 := "below" if close < ((midpoint3 + midpoint4) / 2) abovemidpoint4 := na belowmidpoint4 := na if close > ((midpoint4 + midpoint5) / 2) abovemidpoint4 := na belowmidpoint4 := na if close < midpoint5 and close > ((midpoint4 + midpoint5) / 2) abovemidpoint5 := "above" belowmidpoint5 := na if close > midpoint5 and close < ((midpoint5 + midpoint6) / 2) abovemidpoint5 := na belowmidpoint5 := "below" if close < ((midpoint4 + midpoint5) / 2) abovemidpoint5 := na belowmidpoint5 := na if close > ((midpoint5 + midpoint6) / 2) abovemidpoint5 := na belowmidpoint5 := na if close < midpoint6 and close > ((midpoint5 + midpoint6) / 2) abovemidpoint6 := "above" belowmidpoint6 := na if close > midpoint6 and close < ((midpoint6 + midpoint7) / 2) abovemidpoint6 := na belowmidpoint6 := "below" if close < ((midpoint5 + midpoint6) / 2) abovemidpoint6 := na belowmidpoint6 := na if close > ((midpoint6 + midpoint7) / 2) abovemidpoint6 := na belowmidpoint6 := na if close < midpoint7 and close > ((midpoint6 + midpoint7) / 2) abovemidpoint7 := "above" belowmidpoint7 := na if close > midpoint7 and close < 100 * scale abovemidpoint7 := na belowmidpoint7 := "below" if close < ((midpoint6 + midpoint7) / 2) abovemidpoint7 := na belowmidpoint7 := na if close > 100 * scale abovemidpoint7 := na belowmidpoint7 := na abovezone = abovezone1 + abovezone2 + abovezone3 + abovezone4 + abovezone5 + abovezone6 + abovezone7 + abovezone8 belowzone = belowzone1 + belowzone2 + belowzone3 + belowzone4 + belowzone5 + belowzone6 + belowzone7 + belowzone8 abovemidpoint = abovemidpoint1 + abovemidpoint2 + abovemidpoint3 + abovemidpoint4 + abovemidpoint5 + abovemidpoint6 + abovemidpoint7 belowmidpoint = belowmidpoint1 + belowmidpoint2 + belowmidpoint3 + belowmidpoint4 + belowmidpoint5 + belowmidpoint6 + belowmidpoint7 abovebelowzone = abovezone + belowzone abovebelowmidpoint = abovemidpoint + belowmidpoint // Table var dataTable = table.new(position = position.top_right, columns = 1, rows = 2, bgcolor = color.new(color.blue, 40)) if Table if barstate.islast table.cell(table_id = dataTable, column = 0, row = 0, text = "Nearest Zone: " + str.tostring(closest_zone_percent) + "% " + str.tostring(abovebelowzone), bgcolor = TableColUp, text_color = TxtCol) table.cell(table_id = dataTable, column = 0, row = 1, text = "Nearest Midpoint: " + str.tostring(closest_mid_percent) + "% " + str.tostring(abovebelowmidpoint), bgcolor = TableColDown, text_color = TxtCol) else na
vix_vx_regression
https://www.tradingview.com/script/X18dDIhO-vix-vx-regression/
voided
https://www.tradingview.com/u/voided/
18
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © voided //@version=5 indicator("vix_vx_regression", overlay = true) // regression function import voided/regress/1 // inputs len = input(252, "length") // script vix = request.security("VIX", "D", close - close[1]) vx1 = request.security("VX1!", "D", close - close[1]) vx2 = request.security("VX2!", "D", close - close[1]) [ vx1_alpha, vx1_beta, vx1_r2 ] = regress.regress(vix, vx1, len) [ vx2_alpha, vx2_beta, vx2_r2 ] = regress.regress(vix, vx2, len) // output if barstate.islast lbl_clr = color.new(color.green, 70) fmt = "#.####" t = table.new(position.top_right, 3, 4) table.cell(t, 0, 0, str.tostring(len), bgcolor = color.new(color.fuchsia, 70)) table.cell(t, 1, 0, "vx1", bgcolor = lbl_clr) table.cell(t, 2, 0, "vx2", bgcolor = lbl_clr) table.cell(t, 0, 1, "alpha", bgcolor = lbl_clr) table.cell(t, 1, 1, str.tostring(vx1_alpha, fmt)) table.cell(t, 2, 1, str.tostring(vx2_alpha, fmt)) table.cell(t, 0, 2, "beta", bgcolor = lbl_clr) table.cell(t, 1, 2, str.tostring(vx1_beta, fmt)) table.cell(t, 2, 2, str.tostring(vx2_beta, fmt)) table.cell(t, 0, 3, "r^2", bgcolor = lbl_clr) table.cell(t, 1, 3, str.tostring(vx1_r2, fmt)) table.cell(t, 2, 3, str.tostring(vx2_r2, fmt))
Ichimoku Analysis Tool by TheSocialCryptoClub
https://www.tradingview.com/script/qQNi1e8E-Ichimoku-Analysis-Tool-by-TheSocialCryptoClub/
TheSocialCryptoClub
https://www.tradingview.com/u/TheSocialCryptoClub/
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/ // © TheSocialCryptoClub //@version=5 indicator("Ichimoku Analysis Tool", overlay=true) // functions donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) // input declarations tenkan_len = input.int(9, title="Tenkan Length") kijun_len = input.int(26, title="Kijun Length") senkou_b_len = input.int(52, title="Seknou Span B Lenght") higher_timeframe = input.timeframe("W", "Higher Timeframe") tenkan = donchian(tenkan_len) kijun = donchian(kijun_len) senkou_a = math.avg(tenkan, kijun) senkou_b = donchian(senkou_b_len) chikou = close tenkan_high = request.security(syminfo.tickerid,higher_timeframe,donchian(tenkan_len)) kijun_high = request.security(syminfo.tickerid,higher_timeframe,donchian(kijun_len)) senkou_a_high = request.security(syminfo.tickerid,higher_timeframe,math.avg(tenkan_high, kijun_high)) senkou_b_high = request.security(syminfo.tickerid,higher_timeframe, donchian(senkou_b_len)) chikou_high = request.security(syminfo.tickerid,higher_timeframe,close) plot(tenkan, color=color.blue, title="Tenkan Current Time Frame", linewidth=1) plot(tenkan_high, color=color.aqua, title="Tenkan Highest Time Frame", linewidth=2) plot(kijun, color=color.maroon, title="Kijun Current Time Frame", linewidth=1) plot(kijun_high, color=color.red, title="Kijun Highest Time Frame", linewidth=2) // senkou_a_high_plot = plot(senkou_a_high, offset = kijun_len - 1, color=#A5D6A7, title="Seknou Span A") // senkou_b_high_plot = plot(senkou_b_high, offset = kijun_len - 1, color=#EF9A9A, title="Senkou Span B") plot(chikou, offset=-kijun_len+1, color=#43A047, title="Chikou") senkou_a_plot = plot(senkou_a, offset = kijun_len - 1, color=#A5D6A7, title="Seknou Span A") senkou_b_plot = plot(senkou_b, offset = kijun_len - 1, color=#EF9A9A, title="Senkou Span B") fill(senkou_a_plot, senkou_b_plot, color = senkou_a > senkou_b ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90)) table summary_table = table.new(position.top_right, columns=2, rows=28,bgcolor=#0F0F0F,border_width=1,border_color=#000000) table_bgcolor = #0F0F0F table_bgcolor_content = #1A2421 table_text_color = #D3D3D3 table_text_color_content = #FFFFFF table.cell(summary_table,0,0,"Symbol", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,0,syminfo.tickerid, text_color=table_text_color, bgcolor=table_bgcolor_content) table.cell(summary_table,0,1,"Timeframe", text_color=#D3D3D3, bgcolor=table_bgcolor) table.cell(summary_table,1,1,timeframe.period, text_color=#D3D3D3, bgcolor=table_bgcolor_content) kumo_direction_text = senkou_a > senkou_b ? "Uptrend" : "Downtrend" kumo_direction_color = senkou_a > senkou_b ? color.lime : color.red table.cell(summary_table,0,2,"Kumo Direction", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,2, kumo_direction_text, text_color=table_text_color_content, bgcolor=kumo_direction_color) kumo_twist_bars = ta.barssince(ta.cross(senkou_a, senkou_b)) table.cell(summary_table,0,3,"Kumo Twist Bars", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,3, str.tostring(kumo_twist_bars), text_color=table_text_color_content, bgcolor=table_bgcolor_content) kumo_with = math.abs(senkou_a - senkou_b) / close * 100 table.cell(summary_table,0,4,"Kumo Width", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,4, str.tostring(math.round(kumo_with,2)) + "%", text_color=table_text_color_content, bgcolor=table_bgcolor_content) senkou_b_direction = senkou_b > senkou_b[1] ? "Uptrend" : (senkou_b < senkou_b[1] ? "Downtrend" : "Flat") senkou_b_color = senkou_b > senkou_b[1] ? color.lime : (senkou_b < senkou_b[1] ? color.red : color.gray) table.cell(summary_table,0,5,"Senkou Span B", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,5, senkou_b_direction, text_color=table_text_color_content, bgcolor=senkou_b_color) senkou_a_direction = senkou_a > senkou_a[1] ? "Uptrend" : (senkou_a < senkou_a[1] ? "Downtrend" : "Flat") senkou_a_color = senkou_a > senkou_a[1] ? color.lime : (senkou_a < senkou_a[1] ? color.red : color.gray) table.cell(summary_table,0,6,"Senkou Span A", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,6, senkou_a_direction, text_color=table_text_color_content, bgcolor=senkou_a_color) price_vs_kumo = (close > senkou_b[tenkan_len-1]) and (close > senkou_a[tenkan_len-1]) ? "Uptrend" : ((close < senkou_b[tenkan_len-1]) and (close < senkou_a[tenkan_len-1]) ? "Downtrend" : "Flat") price_vs_kumo_color = (close > senkou_b[tenkan_len-1]) and (close > senkou_a[tenkan_len-1]) ? color.lime : ((close < senkou_b[tenkan_len-1]) and (close < senkou_a[tenkan_len-1]) ? color.red : color.gray) table.cell(summary_table,0,7,"Price vs Kumo", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,7, price_vs_kumo, text_color=table_text_color_content, bgcolor=price_vs_kumo_color) price_vs_future_kumo = (close > senkou_b) and (close > senkou_a) ? "Uptrend" : ((close < senkou_b) and (close < senkou_a) ? "Downtrend" : "Flat") price_vs_future_kumo_color = (close > senkou_b) and (close > senkou_a) ? color.lime : ((close < senkou_b) and (close < senkou_a) ? color.red : color.gray) table.cell(summary_table,0,8,"Price vs Future Kumo", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,8, price_vs_future_kumo, text_color=table_text_color_content, bgcolor=price_vs_future_kumo_color) price_vs_kijun = (close > kijun) ? "Uptrend" : ((close < kijun) ? "Downtrend" : "Flat") price_vs_kijun_color = (close > kijun) ? color.lime : ((close < kijun) ? color.red : color.gray) table.cell(summary_table,0,9,"Price vs Kijun", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,9, price_vs_kijun, text_color=table_text_color_content, bgcolor=price_vs_kijun_color) price_vs_chikou = (close > close[kijun_len]) ? "Uptrend" : ((close < close[kijun_len]) ? "Downtrend" : "Flat") price_vs_chikou_color = (close > close[kijun_len]) ? color.lime : ((close < close[kijun_len]) ? color.red : color.gray) table.cell(summary_table,0,10,"Price vs Chikou", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,10, price_vs_chikou, text_color=table_text_color_content, bgcolor=price_vs_chikou_color) kijun_direction = (kijun > kijun[1]) ? "Uptrend" : ((kijun < kijun[1]) ? "Downtrend" : "Flat") kijun_direction_color = (kijun > kijun[1]) ? color.lime : ((kijun < kijun[1]) ? color.red : color.gray) table.cell(summary_table,0,11,"Kijun Direction", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,11, kijun_direction, text_color=table_text_color_content, bgcolor=kijun_direction_color) kijun_vs_kumo = (kijun > senkou_b[kijun_len-1]) and (kijun > senkou_a[kijun_len-1]) ? "Uptrend" : ((kijun < senkou_b[kijun_len-1]) and (kijun < senkou_a[kijun_len-1]) ? "Downtrend" : "Flat") kijun_vs_kumo_color = (kijun > senkou_b[kijun_len-1]) and (kijun > senkou_a[kijun_len-1]) ? color.lime : ((kijun < senkou_b[kijun_len-1]) and (kijun < senkou_a[kijun_len-1]) ? color.red : color.gray) table.cell(summary_table,0,12,"Kijun vs Kumo", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,12, kijun_vs_kumo, text_color=table_text_color_content, bgcolor=kijun_vs_kumo_color) tenkan_kijun_cross = ta.barssince(ta.cross(tenkan, kijun)) table.cell(summary_table,0,13,"Tenkan/Kijun Cross Bars", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,13, str.tostring(tenkan_kijun_cross), text_color=table_text_color_content, bgcolor=table_bgcolor_content) price_vs_tenkan = (close > tenkan) ? "Uptrend" : ((close < tenkan) ? "Downtrend" : "Flat") price_vs_tenkan_color = (close > tenkan) ? color.lime : ((close < tenkan) ? color.red : color.gray) table.cell(summary_table,0,14,"Price vs Tenkan", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,14, price_vs_tenkan, text_color=table_text_color_content, bgcolor=price_vs_tenkan_color) tenkan_direction = (tenkan > tenkan[1]) ? "Uptrend" : ((tenkan < tenkan[1]) ? "Downtrend" : "Flat") tenkan_direction_color = (tenkan > tenkan[1]) ? color.lime : ((tenkan < tenkan[1]) ? color.red : color.gray) table.cell(summary_table,0,15,"Tenkan Direction", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,15, tenkan_direction, text_color=table_text_color_content, bgcolor=tenkan_direction_color) tenkan_vs_kumo = (tenkan > senkou_b[kijun_len-1]) and (tenkan > senkou_a[kijun_len-1]) ? "Uptrend" : ((tenkan < senkou_b[kijun_len-1]) and (tenkan < senkou_a[kijun_len-1]) ? "Downtrend" : "Flat") tenkan_vs_kumo_color = (tenkan > senkou_b[kijun_len-1]) and (tenkan > senkou_a[kijun_len-1]) ? color.green : ((tenkan < senkou_b[kijun_len-1]) and (tenkan < senkou_a[kijun_len-1]) ? color.red : color.gray) table.cell(summary_table,0,16,"Tenkan vs Kumo", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,16, tenkan_vs_kumo, text_color=table_text_color_content, bgcolor=tenkan_vs_kumo_color) tenkan_vs_future_kumo = (tenkan > senkou_b) and (tenkan > senkou_a) ? "Uptrend" : ((tenkan < senkou_b) and (tenkan < senkou_a) ? "Downtrend" : "Flat") tenkan_vs_future_kumo_color = (tenkan > senkou_b) and (tenkan > senkou_a) ? color.lime : ((tenkan < senkou_b) and (tenkan < senkou_a) ? color.red : color.gray) table.cell(summary_table,0,17,"Tenkan vs Future Kumo", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,17, tenkan_vs_future_kumo, text_color=table_text_color_content, bgcolor=tenkan_vs_future_kumo_color) tenkan_vs_kijun = tenkan > kijun ? "Uptrend" : "Downtrend" tenkan_vs_kijun_color = tenkan > kijun ? color.lime : color.red table.cell(summary_table,0,18,"Tenkan vs Kijun", text_color=table_text_color, bgcolor=table_bgcolor) table.cell(summary_table,1,18, tenkan_vs_kijun, text_color=table_text_color_content, bgcolor=tenkan_vs_kijun_color)
[JL] EMA Trading Zone
https://www.tradingview.com/script/gbhKa72z-JL-EMA-Trading-Zone/
Jesse.Lau
https://www.tradingview.com/u/Jesse.Lau/
116
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Jesse.Lau //@version=5 indicator('[JL] EMA Trading Zone', shorttitle="EMATZ",overlay=true) //////////// // INPUTS // // MASLOPE mas_len = input.int( 50, title = "EMA Short Length", minval=1) mas_len2 = input.int( 200, title = "EMA Long Length", minval=1) mas_level = input.int( 20, title = "MA Slope level", minval=0) backlen = input.int( 20, title = "Back Length", minval=1) atrperiod = input.int( 10, title = "ATR period", minval=1) atrindex = input.float( 2, title = "ATR index", minval=0.1, step = 0.1) e = ta.ema(close, mas_len) el = ta.ema(close, mas_len2) rad2degree=180 / 3.141592653589793238462643 //pi ma_s = 0.0 ma_s2 = 0.0 for i=1 to backlen ma_s := ma_s + rad2degree*math.atan((e[0]-nz(e[i]))/math.abs(nz(e[i])-nz(e[2*i]))) ma_s2 := ma_s2 + rad2degree*math.atan((el[0]-nz(el[i]))/math.abs(nz(el[i])-nz(el[2*i]))) ma_slope = ma_s/backlen ma_slope2 = ma_s2/backlen color1 = ma_slope > mas_level ? color.lime : ma_slope < -1 * mas_level ? color.red : color.blue color2 = ma_slope2 > mas_level ? #ADFF2F : ma_slope2 < -1 * mas_level ? #FA8072 : color.blue color = ma_slope > mas_level and ma_slope2 > mas_level ? color.lime : ma_slope < -1 * mas_level and ma_slope2 < -1 * mas_level ? color.red : color.blue e1 = e + atrindex*ta.atr(atrperiod) e2 = e - atrindex*ta.atr(atrperiod) l1=plot(e1, color=color.blue, title="e1line",linewidth=1) l2=plot(e2, color=color.blue, title="e2line",linewidth=1) fill(l1, l2, title = "Background", color=color, transp=60) plot(e, color=color1, linewidth=2) plot(el, color=color2, linewidth=2)
Number Frame
https://www.tradingview.com/script/jDflOuR4-Number-Frame/
fvideira
https://www.tradingview.com/u/fvideira/
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/ // © fvideira //@version=5 indicator("Number Frame", overlay=true) // Study of number levels from Eliza123123's quantative trading series: https://youtu.be/S7UMA__wz74 // number Const. numberStd = input.bool(true, "Standard Multiples", group = "Number Multiples") numberPrime = input(true, "Prime Multiples", group = "Number Multiples") numberMulti = input(true, "Multiples of 10", group = "Number Multiples") nb = input.float(3.14159, "Number Input", minval = 0, maxval = 10, step = 0.00001, tooltip = "Up to 5 decimal places") // Scale Factors & Constants scale = 0.0 if close >= 10000 scale := 1000 if close >= 1000 and close <=9999.999999 scale := 100 if close >= 100 and close <=999.999999 scale := 10 if close >= 10 and close <=99.999999 scale := 1 if close >= 1 and close <=9.999999 scale := 0.1 if close >= 0.1 and close <=0.999999 scale := 0.01 if close >= 0.01 and close <=0.099999 scale := 0.001 if close >= 0.001 and close <=0.009999 scale := 0.0001 // Variables number = nb * scale number1 = 0.0 number2 = 0.0 number3 = 0.0 number4 = 0.0 number5 = 0.0 number6 = 0.0 number7 = 0.0 number8 = 0.0 number9 = 0.0 number10 = 0.0 number11 = 0.0 number12 = 0.0 number13 = 0.0 number14 = 0.0 number15 = 0.0 number16 = 0.0 number17 = 0.0 number18 = 0.0 number19 = 0.0 number20 = 0.0 number21 = 0.0 number22 = 0.0 number23 = 0.0 number24 = 0.0 number25 = 0.0 number26 = 0.0 number27 = 0.0 number28 = 0.0 number29 = 0.0 number30 = 0.0 number31 = 0.0 number32 = 0.0 number33 = 0.0 number34 = 0.0 number35 = 0.0 number36 = 0.0 number37 = 0.0 number38 = 0.0 // If clauses (for inputs to work as on/off) if numberStd number4 := number*4 number6 := number*6 number8 := number*8 number9 := number*9 number12 := number*12 number14 := number*14 number15 := number*15 number16 := number*16 number18 := number*18 number21 := number*21 number22 := number*22 number24 := number*24 number25 := number*25 number26 := number*26 number27 := number*27 number28 := number*28 number32 := number*32 number33 := number*33 number34 := number*34 number35 := number*35 number36 := number*36 number38 := number*38 else number4 := na number6 := na number8 := na number9 := na number12 := na number14 := na number15 := na number16 := na number18 := na number21 := na number22 := na number24 := na number25 := na number26 := na number27 := na number28 := na number32 := na number33 := na number34 := na number35 := na number36 := na number38 := na if numberPrime number1 := number*1 number2 := number*2 number3 := number*3 number5 := number*5 number7 := number*7 number11 := number*11 number13 := number*13 number17 := number*17 number19 := number*19 number23 := number*23 number29 := number*29 number31 := number*31 number37 := number*37 else number1 := na number2 := na number3 := na number5 := na number7 := na number11 := na number13 := na number17 := na number19 := na number23 := na number29 := na number31 := na number37 := na if numberMulti number10 := number*10 number20 := number*20 number30 := number*30 else number10 := na number20 := na number30 := na // Plots plot(number, color = color.new(color.silver, 10)), plot(number2, color = color.new(color.silver, 0)), plot(number3, color = color.new(color.silver, 0)), plot(number4, color = color.new(color.black, 0)), plot(number5, color = color.new(color.silver, 0)), plot(number6, color = color.new(color.black, 0)), plot(number7, color = color.new(color.silver, 0)), plot(number8, color = color.new(color.black, 0)), plot(number9, color = color.new(color.black, 0)), plot(number10, color = color.new(color.orange, 10)), plot(number11, color = color.new(color.silver, 0)), plot(number12, color = color.new(color.black, 0)), plot(number13, color = color.new(color.silver, 0)), plot(number14, color = color.new(color.black, 0)), plot(number15, color = color.new(color.black, 0)), plot(number16, color = color.new(color.black, 0)), plot(number17, color = color.new(color.silver, 0)), plot(number18, color = color.new(color.black, 0)), plot(number19, color = color.new(color.silver, 0)), plot(number20, color = color.new(color.orange, 10)), plot(number21, color = color.new(color.black, 0)), plot(number22, color = color.new(color.black, 0)), plot(number23, color = color.new(color.silver, 0)), plot(number24, color = color.new(color.black, 0)), plot(number25, color = color.new(color.black, 0)), plot(number26, color = color.new(color.black, 0)), plot(number27, color = color.new(color.black, 0)), plot(number28, color = color.new(color.black, 0)), plot(number29, color = color.new(color.silver, 0)), plot(number30, color = color.new(color.orange, 10)), plot(number31, color = color.new(color.silver, 0)), plot(number32, color = color.new(color.black, 0)), plot(number33, color = color.new(color.black, 0)), plot(number34, color = color.new(color.black, 0)), plot(number35, color = color.new(color.black, 0)), plot(number36, color = color.new(color.black, 0)), plot(number37, color = color.new(color.silver, 0)), plot(number38, color = color.new(color.black, 0)) ///
Stage Analysis
https://www.tradingview.com/script/tzQaOzmV-Stage-Analysis/
EquityCraze
https://www.tradingview.com/u/EquityCraze/
306
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © EquityCraze //@version=5 indicator(title='Stage Analysis', overlay=true) period = timeframe.period valid_periods = period == 'D' or period == 'W' // function to convert daily period to weekly period get_sma_period(sma_input) => if period == 'D' int(sma_input) else int(sma_input / 5) dma50_days = get_sma_period(50) dma150_days = get_sma_period(150) dma200_days = get_sma_period(200) dma50_days_visible = input(title='dma50_days', defval=false) dma150_days_visible = input(title='dma150_days', defval=false) dma200_days_visible = input(title='dma200_days', defval=false) show_50_pointer = input(title='50X150', defval=true) show_150_pointer = input(title='150X200', defval=true) show_200_pointer = input(title='50X200', defval=true) DMA50 = ta.sma(close, dma50_days) DMA150 = ta.sma(close, dma150_days) DMA200 = ta.sma(close, dma200_days) if show_50_pointer and show_150_pointer and ta.crossunder(DMA50, DMA150) and valid_periods stage3_starting = label.new(bar_index, na, yloc=yloc.price, color=color.yellow, style=label.style_label_down, size=size.tiny) label.set_y(stage3_starting, DMA50) label.set_tooltip(stage3_starting, str.tostring(dma150_days) + ' x ' + str.tostring(dma50_days)) if show_50_pointer and show_150_pointer and ta.crossover(DMA50, DMA150) and valid_periods stage2_starting = label.new(bar_index, na, yloc=yloc.price, color=color.green, style=label.style_label_up, size=size.tiny) label.set_y(stage2_starting, DMA50) label.set_tooltip(stage2_starting, str.tostring(dma50_days) + ' x ' + str.tostring(dma150_days)) if show_50_pointer and show_200_pointer and ta.crossunder(DMA50, DMA200) and valid_periods stage4 = label.new(bar_index, na, yloc=yloc.price, color=color.red, style=label.style_label_down, size=size.tiny) label.set_y(stage4, DMA50) label.set_tooltip(stage4, str.tostring(dma200_days) + ' x ' + str.tostring(dma50_days)) if show_50_pointer and show_200_pointer and ta.crossover(DMA50, DMA200) and valid_periods stage2_accumulation = label.new(bar_index, na, yloc=yloc.price, color=color.green, style=label.style_label_up, size=size.tiny) label.set_y(stage2_accumulation, DMA50) label.set_tooltip(stage2_accumulation, str.tostring(dma50_days) + ' x ' + str.tostring(dma200_days)) if show_150_pointer and show_200_pointer and ta.crossunder(DMA150, DMA200) and valid_periods stage3_starting = label.new(bar_index, na, yloc=yloc.price, color=color.yellow, style=label.style_label_down, size=size.tiny) label.set_y(stage3_starting, DMA150) label.set_tooltip(stage3_starting, str.tostring(dma200_days) + ' x ' + str.tostring(dma150_days)) if show_150_pointer and show_200_pointer and ta.crossover(DMA150, DMA200) and valid_periods stage2_confirmed = label.new(bar_index, na, yloc=yloc.price, color=color.yellow, style=label.style_label_up, size=size.tiny) label.set_y(stage2_confirmed, DMA150) label.set_tooltip(stage2_confirmed, str.tostring(dma150_days) + ' x ' + str.tostring(dma200_days)) plot(dma50_days_visible and valid_periods ? DMA50 : na, color=color.new(color.green, 10), linewidth=1) plot(dma150_days_visible and valid_periods ? DMA150 : na, color=color.new(color.yellow, 20), linewidth=2) plot(dma200_days_visible and valid_periods ? DMA200 : na, color=color.new(color.red, 30), linewidth=3)
Euler Frame (Dynamic)
https://www.tradingview.com/script/TQgH9hye-Euler-Frame-Dynamic/
fvideira
https://www.tradingview.com/u/fvideira/
17
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © fvideira //@version=5 indicator("Euler Frame (Dynamic)", overlay=true) // Study of Euler levels from Eliza123123's quantative trading series: https://youtu.be/S7UMA__wz74 // Inputs euStd = input.bool(true, "Standard Multiples", inline = "Standard", group = "Euler Constant 2.71828") StdCol = input.color(color.new(color.navy, 0), "", inline = "Standard", group = "Euler Constant 2.71828") euPrime = input.bool(true, "Prime Multiples", inline = "Prime", group = "Euler Constant 2.71828") PrimeCol = input.color(color.new(color.white, 0), "", inline = "Prime", group = "Euler Constant 2.71828") euMulti = input.bool(true, "Multples of 10", inline = "Multi", group = "Euler Constant 2.71828") MultiCol = input.color(color.new(color.fuchsia, 10), "", inline = "Multi", group = "Euler Constant 2.71828") extendRight = input.bool(false, "Extend Lines") var extending = extend.none if extendRight extending := extend.right if not extendRight extending := extend.none // Scale Factors & Constants scale = 0.0 if close >= 10000 scale := 1000 if close >= 1000 and close <=9999.999999 scale := 100 if close >= 100 and close <=999.999999 scale := 10 if close >= 10 and close <=99.999999 scale := 1 if close >= 1 and close <=9.999999 scale := 0.1 if close >= 0.1 and close <=0.999999 scale := 0.01 if close >= 0.01 and close <=0.099999 scale := 0.001 if close >= 0.001 and close <=0.009999 scale := 0.0001 // Variables e = 2.71828 * scale pi = 3.14159 e1 = 0.0 e2 = 0.0 e3 = 0.0 e4 = 0.0 e5 = 0.0 e6 = 0.0 e7 = 0.0 e8 = 0.0 e9 = 0.0 e10 = 0.0 e11 = 0.0 e12 = 0.0 e13 = 0.0 e14 = 0.0 e15 = 0.0 e16 = 0.0 e17 = 0.0 e18 = 0.0 e19 = 0.0 e20 = 0.0 e21 = 0.0 e22 = 0.0 e23 = 0.0 e24 = 0.0 e25 = 0.0 e26 = 0.0 e27 = 0.0 e28 = 0.0 e29 = 0.0 e30 = 0.0 e31 = 0.0 e32 = 0.0 e33 = 0.0 e34 = 0.0 e35 = 0.0 e36 = 0.0 e37 = 0.0 e38 = 0.0 // If clauses (for inputs to work as on/off) if euStd e4 := e*4 e6 := e*6 e8 := e*8 e9 := e*9 e12 := e*12 e14 := e*14 e15 := e*15 e16 := e*16 e18 := e*18 e21 := e*21 e22 := e*22 e24 := e*24 e25 := e*25 e26 := e*26 e27 := e*27 e28 := e*28 e32 := e*32 e33 := e*33 e34 := e*34 e35 := e*35 e36 := e*36 e38 := e*38 else e4 := na e6 := na e8 := na e9 := na e12 := na e14 := na e15 := na e16 := na e18 := na e21 := na e22 := na e24 := na e25 := na e26 := na e27 := na e28 := na e32 := na e33 := na e34 := na e35 := na e36 := na e38 := na if euPrime e1 := e*1 e2 := e*2 e3 := e*3 e5 := e*5 e7 := e*7 e11 := e*11 e13 := e*13 e17 := e*17 e19 := e*19 e23 := e*23 e29 := e*29 e31 := e*31 e37 := e*37 else e1 := na e2 := na e3 := na e5 := na e7 := na e11 := na e13 := na e17 := na e19 := na e23 := na e29 := na e31 := na e37 := na if euMulti e10 := e*10 e20 := e*20 e30 := e*30 else e10 := na e20 := na e30 := na // Plots le1 = line.new(bar_index[4999], e1, bar_index, e1, color = PrimeCol, width = 1, extend = extending) le2 = line.new(bar_index[4999], e2, bar_index, e2, color = PrimeCol, width = 1, extend = extending) le3 = line.new(bar_index[4999], e3, bar_index, e3, color = PrimeCol, width = 1, extend = extending) le4 = line.new(bar_index[4999], e4, bar_index, e4, color = StdCol, width = 1, extend = extending) le5 = line.new(bar_index[4999], e5, bar_index, e5, color = PrimeCol, width = 1, extend = extending) le6 = line.new(bar_index[4999], e6, bar_index, e6, color = StdCol, width = 1, extend = extending) le7 = line.new(bar_index[4999], e7, bar_index, e7, color = PrimeCol, width = 1, extend = extending) le8 = line.new(bar_index[4999], e8, bar_index, e8, color = StdCol, width = 1, extend = extending) le9 = line.new(bar_index[4999], e9, bar_index, e9, color = PrimeCol, width = 1, extend = extending) le10 = line.new(bar_index[4999], e10, bar_index, e10, color = MultiCol, width = 1, extend = extending) le11 = line.new(bar_index[4999], e11, bar_index, e11, color = PrimeCol, width = 1, extend = extending) le12 = line.new(bar_index[4999], e12, bar_index, e12, color = StdCol, width = 1, extend = extending) le13 = line.new(bar_index[4999], e13, bar_index, e13, color = PrimeCol, width = 1, extend = extending) le14 = line.new(bar_index[4999], e14, bar_index, e14, color = StdCol, width = 1, extend = extending) le15 = line.new(bar_index[4999], e15, bar_index, e15, color = StdCol, width = 1, extend = extending) le16 = line.new(bar_index[4999], e16, bar_index, e16, color = StdCol, width = 1, extend = extending) le17 = line.new(bar_index[4999], e17, bar_index, e17, color = PrimeCol, width = 1, extend = extending) le18 = line.new(bar_index[4999], e18, bar_index, e18, color = StdCol, width = 1, extend = extending) le19 = line.new(bar_index[4999], e19, bar_index, e19, color = PrimeCol, width = 1, extend = extending) le20 = line.new(bar_index[4999], e20, bar_index, e20, color = MultiCol, width = 1, extend = extending) le21 = line.new(bar_index[4999], e21, bar_index, e21, color = StdCol, width = 1, extend = extending) le22 = line.new(bar_index[4999], e22, bar_index, e22, color = StdCol, width = 1, extend = extending) le23 = line.new(bar_index[4999], e23, bar_index, e23, color = PrimeCol, width = 1, extend = extending) le24 = line.new(bar_index[4999], e24, bar_index, e24, color = StdCol, width = 1, extend = extending) le25 = line.new(bar_index[4999], e25, bar_index, e25, color = StdCol, width = 1, extend = extending) le26 = line.new(bar_index[4999], e26, bar_index, e26, color = StdCol, width = 1, extend = extending) le27 = line.new(bar_index[4999], e27, bar_index, e27, color = PrimeCol, width = 1, extend = extending) le28 = line.new(bar_index[4999], e28, bar_index, e28, color = StdCol, width = 1, extend = extending) le29 = line.new(bar_index[4999], e29, bar_index, e29, color = PrimeCol, width = 1, extend = extending) le30 = line.new(bar_index[4999], e30, bar_index, e30, color = MultiCol, width = 1, extend = extending) le31 = line.new(bar_index[4999], e31, bar_index, e31, color = PrimeCol, width = 1, extend = extending) le32 = line.new(bar_index[4999], e32, bar_index, e32, color = StdCol, width = 1, extend = extending) le33 = line.new(bar_index[4999], e33, bar_index, e33, color = StdCol, width = 1, extend = extending) le34 = line.new(bar_index[4999], e34, bar_index, e34, color = StdCol, width = 1, extend = extending) le35 = line.new(bar_index[4999], e35, bar_index, e35, color = StdCol, width = 1, extend = extending) le36 = line.new(bar_index[4999], e36, bar_index, e36, color = StdCol, width = 1, extend = extending) le37 = line.new(bar_index[4999], e37, bar_index, e37, color = PrimeCol, width = 1, extend = extending) le38 = line.new(bar_index[4999], e38, bar_index, e38, color = StdCol, width = 1, extend = extending) //////
Manual Harmonic Projections - With interactive inputs
https://www.tradingview.com/script/iACTCSJu-Manual-Harmonic-Projections-With-interactive-inputs/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
1,090
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("Manual Harmonic Projections - With interactive inputs", overlay=true) import HeWhoMustNotBeNamed/eHarmonicpatternsExtended/6 as hp import HeWhoMustNotBeNamed/arrayutils/17 as pa x = input.price(0,'X',group='XABC', inline= '1', confirm=true) xBarTime = input.time(0,'',group='XABC', inline= '1', confirm=true) a = input.price(0,'A',group='XABC', inline= '2', confirm=true) aBarTime = input.time(0,'',group='XABC', inline= '2', confirm=true) b = input.price(0,'B',group='XABC', inline= '3', confirm=true) bBarTime = input.time(0,'',group='XABC', inline= '3', confirm=true) c = input.price(0,'C',group='XABC', inline= '4', confirm=true) cBarTime = input.time(0,'',group='XABC', inline= '4', confirm=true) showXABCD = input.bool(true, title='Show XABCD', group='Display', inline='showHide') showRatios = input.bool(true, title='Show Ratios', group='Display', inline='showHide') fillMajorTriangles = input.bool(true, title="Fill XAB/BCD", group="Display", inline="fill1") majorFillTransparency = input.int(70, step=5, title="", group="Display", inline="fill1") fillMinorTriangles = input.bool(true, title="Fill ABC/XBD", group="Display", inline="fill2") minorFillTransparency = input.int(90, step=5, title="", group="Display", inline="fill2") errorPercent = input.int(8, group="Miscellaneous") patternColor = input.color(color.purple, group="Miscellaneous") classic = input.bool(true, title="Classic Patterns", group="Category", inline="ca") anti = input.bool(true, title="Anti/Alternate Patterns", group="Category", inline="ca") nonStandard = input.bool(true, title="Nonstandard", group="Category", inline="ca") gartley = input.bool(true, title='Gartley       ', group='Classic Patterns', inline="c1") bat = input.bool(true, title='Bat      ', group='Classic Patterns', inline="c1") butterfly = input.bool(true, title='Butterfly   ', group='Classic Patterns', inline="c1") crab = input.bool(true, title='Crab', group='Classic Patterns', inline="c1") deepCrab = input.bool(true, title='Deep Crab   ', group='Classic Patterns', inline="c2") cypher = input.bool(true, title='Cypher   ', group='Classic Patterns', inline="c2") shark = input.bool(true, title='Shark      ', group='Classic Patterns', inline="c2") nenStar = input.bool(true, title='Nenstar', group='Classic Patterns', inline="c2") antiNenStar = input.bool(true, title='Anti Nenstar   ', group='Anti Patterns', inline="a1") antiShark = input.bool(true, title='Anti Shark', group='Anti Patterns', inline="a1") antiCypher = input.bool(true, title='Anti Cypher ', group='Anti Patterns', inline="a1") antiCrab = input.bool(true, title='Anti Crab', group='Anti Patterns', inline="a1") antiButterfly = input.bool(true, title='Anti Butterfly', group='Anti Patterns', inline="a2") antiBat = input.bool(true, title='Anti Bat  ', group='Anti Patterns', inline="a2") antiGartley = input.bool(true, title='Anti Gartley', group='Anti Patterns', inline="a2") navarro200 = input.bool(true, title='Navarro 200', group='Anti Patterns', inline="a2") fiveZero = input.bool(true, title='Five Zero', group='Non Standard', inline="a1") threeDrives = input.bool(true, title='Three Drives', group='Non Standard', inline="a1") whiteSwann = input.bool(true, title='White Swann', group='Non Standard', inline="a1") blackSwann = input.bool(true, title='Black Swann', group='Non Standard', inline="a1") seaPony = input.bool(true, title='Sea Pony', group='Non Standard', inline="a2") leonardo = input.bool(true, title='Leonardo', group='Non Standard', inline="a2") oneTwoOne = input.bool(true, title='121', group='Non Standard', inline="a2") snorm = input.bool(true, title='Snorm', group='Non Standard', inline="a2") totalPattern = input.bool(true, title='Total', group='Non Standard', inline="a2") NUMBER_OF_PATTERNS = 25 enableGartley = classic and gartley enableBat = classic and bat enableButterfly = classic and butterfly enableCrab = classic and crab enableDeepCrab = classic and deepCrab enableCypher = classic and cypher enableShark = classic and shark enableNenStar = classic and nenStar enableAntiNenStar = anti and antiNenStar enableAntiShark = anti and antiShark enableAntiCypher = anti and antiCypher enableAntiCrab = anti and antiCrab enableAntiButterfly = anti and antiButterfly enableAntiBat = anti and antiBat enableAntiGartley = anti and antiGartley enableNavarro200 = anti and navarro200 enableFiveZero = nonStandard and fiveZero enableThreeDrives = nonStandard and threeDrives enableWhiteSwann = nonStandard and whiteSwann enableBlackSwann = nonStandard and blackSwann enableSeaPony = nonStandard and seaPony enableLeonardo = nonStandard and leonardo enableOneTwoOne = nonStandard and oneTwoOne enableSnorm = nonStandard and snorm enableTotal = nonStandard and totalPattern flags = array.new_bool() array.push(flags, enableGartley) array.push(flags, enableCrab) array.push(flags, enableDeepCrab) array.push(flags, enableBat) array.push(flags, enableButterfly) array.push(flags, enableShark) array.push(flags, enableCypher) array.push(flags, enableNenStar) array.push(flags, enableAntiNenStar) array.push(flags, enableAntiShark) array.push(flags, enableAntiCypher) array.push(flags, enableAntiCrab) array.push(flags, enableAntiButterfly) array.push(flags, enableAntiBat) array.push(flags, enableAntiGartley) array.push(flags, enableNavarro200) array.push(flags, enableFiveZero) array.push(flags, enableThreeDrives) array.push(flags, enableWhiteSwann) array.push(flags, enableBlackSwann) array.push(flags, enableSeaPony) array.push(flags, enableLeonardo) array.push(flags, enableOneTwoOne) array.push(flags, enableSnorm) array.push(flags, enableTotal) f_draw_pattern_line(y1, y2, x1, x2, lineColor, width, style) => targetLine = line.new(y1=y1, y2=y2, x1=x1, x2=x2, color=lineColor, width=width, style=style) targetLine f_draw_pattern_label(y, x, txt, textcolor, style, yloc, size) => targetLabel = label.new(y=y, x=x, text=txt, textcolor=textcolor, style=style, yloc=yloc, size=size) targetLabel f_draw_entry_box(y1, y2, x1, linecolor, labelColor, labelText) => x2 = x1 + 20 y = (y1 + y2) / 2 xloc = xloc.bar_index transp = 70 entryBox = box.new(x1, y1, x2, y2, linecolor, 1, line.style_dotted, xloc=xloc, bgcolor=color.new(labelColor, transp), text=labelText, text_color=color.silver, text_size=size.small) draw_xabc(x, a, b, c, xBar, aBar, bBar, cBar, dir, labelColor, patterns, consolidatedStartRange, consolidatedEndRange, consolidatedPatternLabels) => hasPatterns = array.includes(patterns, true), isCypher = array.get(patterns, 6) xa = f_draw_pattern_line(y1=x, y2=a, x1=xBar, x2=aBar, lineColor=labelColor, width=1, style=line.style_solid) ab = f_draw_pattern_line(y1=a, y2=b, x1=aBar, x2=bBar, lineColor=labelColor, width=1, style=line.style_solid) bc = f_draw_pattern_line(y1=b, y2=c, x1=bBar, x2=cBar, lineColor=labelColor, width=1, style=line.style_solid) xb = f_draw_pattern_line(y1=x, y2=b, x1=xBar, x2=bBar, lineColor=labelColor, width=1, style=line.style_dashed) ac = f_draw_pattern_line(y1=a, y2=c, x1=aBar, x2=cBar, lineColor=labelColor, width=1, style=line.style_dotted) if(fillMajorTriangles and hasPatterns) xaab = linefill.new(xa, ab, color.new(labelColor, majorFillTransparency)) xbab = linefill.new(xb, ab, color.new(labelColor, majorFillTransparency)) if(fillMinorTriangles and hasPatterns) abbc = linefill.new(ab, bc, color.new(labelColor, minorFillTransparency)) acbc = linefill.new(ac, bc, color.new(labelColor, minorFillTransparency)) if showXABCD gap = ta.tr xLabel = f_draw_pattern_label(y=(dir>0?x-gap:x+gap), x=xBar, txt='X', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) aLabel = f_draw_pattern_label(y=(dir>0?a+gap:a-gap), x=aBar, txt='A', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) bLabel = f_draw_pattern_label(y=(dir>0?b-gap:b+gap), x=bBar, txt='B', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) cLabel = f_draw_pattern_label(y=(dir>0?c+gap:c-gap), x=cBar, txt='C', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) if showRatios xabRatio = math.round(math.abs(a - b) / math.abs(x - a), 3) xabRatioBar = (xBar + bBar) / 2 abcRatio = math.round(math.abs(b - c) / math.abs(a - b), 3) abcRatioBar = (aBar + cBar) / 2 axcRatio = math.round(math.abs(x - c) / math.abs(x - a), 3) xabRatioPrice = line.get_price(xb, xabRatioBar) abcRatioPrice = line.get_price(ac, abcRatioBar) abcRatioLabelText = str.tostring(abcRatio) + '(ABC)' + (isCypher ? '\n' + str.tostring(axcRatio) + '(AXC)' : '') xabLabel = f_draw_pattern_label(y=xabRatioPrice, x=xabRatioBar, txt=str.tostring(xabRatio) + '(XAB)', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) abcLabel = f_draw_pattern_label(y=abcRatioPrice, x=abcRatioBar, txt=abcRatioLabelText, textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) if(hasPatterns) sortOrder = pa.get_sort_order(consolidatedStartRange, -dir) for i=0 to array.size(consolidatedStartRange)-1 index = array.get(sortOrder, i) y1 = array.get(consolidatedStartRange, index) y2 = array.get(consolidatedEndRange, index) if(i==0) d = (y1+y2)/2 dBar = bar_index cd = f_draw_pattern_line(y1=c, y2=d, x1=cBar, x2=dBar, lineColor=labelColor, width=1, style=line.style_solid) bd = f_draw_pattern_line(y1=b, y2=d, x1=bBar, x2=dBar, lineColor=labelColor, width=1, style=line.style_dashed) xd = f_draw_pattern_line(y1=x, y2=d, x1=xBar, x2=dBar, lineColor=labelColor, width=1, style=line.style_dotted) if showRatios bcdRatio = math.round(math.abs(c - d) / math.abs(b - c), 3) bcdRatioBar = (bBar + dBar) / 2 xadRatio = math.round(math.abs(a - d) / math.abs(x - a), 3) xadRatioBar = (xBar + dBar) / 2 xcdRatio = math.round(math.abs(d - c) / math.abs(x - c), 3) bcdRatioPrice = line.get_price(bd, bcdRatioBar) xadRatioPrice = line.get_price(xd, xadRatioBar) xadRatioLabelText = str.tostring(xadRatio) + '(XAD)' + (isCypher ? '\n' + str.tostring(xcdRatio) + '(XCD)' : '') bcdLabel = f_draw_pattern_label(y=bcdRatioPrice, x=bcdRatioBar, txt=str.tostring(bcdRatio) + '(BCD)', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) xadLabel = f_draw_pattern_label(y=xadRatioPrice, x=xadRatioBar, txt=xadRatioLabelText, textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) if fillMajorTriangles bccd = linefill.new(bc, cd, color.new(labelColor, majorFillTransparency)) bdcd = linefill.new(bd, cd, color.new(labelColor, majorFillTransparency)) if fillMinorTriangles xbbd = linefill.new(xb, bd, color.new(labelColor, minorFillTransparency)) xdbd = linefill.new(xd, bd, color.new(labelColor, minorFillTransparency)) labelText = array.get(consolidatedPatternLabels, index) f_draw_entry_box(y1, y2, bar_index, labelColor, labelColor, labelText) get_prz_range(float x, float a, float b, float c, bool[] patternArray, simple int start_adj=0, simple int end_adj=0)=> startRange = array.new_float(16, na) endRange = array.new_float(16, na) if(array.includes(patternArray, true)) //Gartley pa.getrange(x, a, 0.786, 0.786, b, c, 1.272, 1.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 0) //Crab pa.getrange(x, a, 1.618, 1.618, b, c, 2.240, 3.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 1) //DeepCrab pa.getrange(x, a, 1.618, 1.618, b, c, 2.000, 3.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 2) //Bat pa.getrange(x, a, 0.886, 0.886, b, c, 1.618, 2.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 3) //Butterfly pa.getrange(x, a, 1.272, 1.618, b, c, 1.618, 2.618, 0, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 4) //Shark pa.getrange(x, a, 0.886, 0.886, b, c, 1.618, 2.236, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 5) //Cypher pa.getrange(x, c, 0.786, 0.786, x, c, 0.786, 0.786, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 6) //NenStar pa.getrange(x, a, 1.272, 1.272, b, c, 1.272, 2.000, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 7) //Anti NenStar pa.getrange(x, a, 0.786, 0.786, b, c, 1.618, 2.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 8) //Anti Shark pa.getrange(x, a, 1.130, 1.130, b, c, 1.618, 2.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 9) //Anti Cypher pa.getrange(x, a, 1.272, 1.272, b, c, 1.618, 2.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 10) //Anti Crab pa.getrange(x, a, 0.618, 0.618, b, c, 1.618, 2.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 11) //Anti Butterfly pa.getrange(x, a, 0.618, 0.786, b, c, 1.272, 1.272, 0, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 12) //Anti Bat pa.getrange(x, a, 1.128, 1.128, b, c, 2.000, 2.618, errorPercent, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 13) //Anti Gartley pa.getrange(x, a, 1.272, 1.618, b, c, 1.168, 1.618, 0, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 14) //Navarro200 pa.getrange(x, a, 0.886, 1.127, b, c, 0.886, 3.618, 0, errorPercent, start_adj, end_adj, patternArray, startRange, endRange, 15) [startRange, endRange] normalize_prz_range(patterns, patternLabels, startRange, endRange)=> consolidatedStartRange = array.new_float() consolidatedEndRange = array.new_float() consolidatedPatternLabels = array.new_string() merged = false for idx=0 to array.size(patterns)-1 flag = array.get(patterns, idx) if(flag) lbl = array.get(patternLabels, idx) start = array.get(startRange, idx) end = array.get(endRange, idx) dir = start > end ? 1 : -1 createNewRange = true for i =0 to array.size(consolidatedStartRange)==0? na : array.size(consolidatedStartRange)-1 oStart = array.get(consolidatedStartRange, i) oEnd = array.get(consolidatedEndRange, i) overlappingStart = (start*dir < oStart*dir and start*dir > oEnd*dir) or (oStart*dir < start*dir and oStart*dir > end*dir) overlappingEnd = (end*dir < oStart*dir and end*dir > oEnd*dir) or (oEnd*dir < start*dir and oEnd*dir > end*dir) if(overlappingStart or overlappingEnd) newStart = dir > 0? math.max(start, oStart) : math.min(start, oStart) newEnd = dir > 0? math.min(end, oEnd) : math.max(end, oEnd) array.set(consolidatedStartRange, i, newStart) array.set(consolidatedEndRange, i, newEnd) newLabel=array.get(consolidatedPatternLabels, i)+'\n'+lbl array.set(consolidatedPatternLabels, i, newLabel) createNewRange := false merged := true break if(createNewRange) array.push(consolidatedStartRange, start) array.push(consolidatedEndRange, end) array.push(consolidatedPatternLabels, lbl) [consolidatedStartRange, consolidatedEndRange, consolidatedPatternLabels, merged] merge_ranges(StartRange, EndRange, PatternLabels)=> consolidatedStartRange = array.new_float() consolidatedEndRange = array.new_float() consolidatedPatternLabels = array.new_string() merged = false for idx = 0 to (array.size(StartRange)==0? na : array.size(EndRange)-1) start = array.get(StartRange, idx) end = array.get(EndRange, idx) lbl = array.get(PatternLabels, idx) dir = start > end ? 1 : -1 createNewRange = true for i =0 to array.size(consolidatedStartRange)==0? na : array.size(consolidatedStartRange)-1 oStart = array.get(consolidatedStartRange, i) oEnd = array.get(consolidatedEndRange, i) overlappingStart = (start*dir < oStart*dir and start*dir > oEnd*dir) or (oStart*dir < start*dir and oStart*dir > end*dir) overlappingEnd = (end*dir < oStart*dir and end*dir > oEnd*dir) or (oEnd*dir < start*dir and oEnd*dir > end*dir) if(overlappingStart or overlappingEnd) newStart = dir > 0? math.max(start, oStart) : math.min(start, oStart) newEnd = dir > 0? math.min(end, oEnd) : math.max(end, oEnd) array.set(consolidatedStartRange, i, newStart) array.set(consolidatedEndRange, i, newEnd) newLabel=array.get(consolidatedPatternLabels, i)+'\n'+lbl array.set(consolidatedPatternLabels, i, newLabel) createNewRange := false merged := true break if(createNewRange) array.push(consolidatedStartRange, start) array.push(consolidatedEndRange, end) array.push(consolidatedPatternLabels, lbl) [consolidatedStartRange, consolidatedEndRange, consolidatedPatternLabels, merged] var printed = false patternLabels = hp.getSupportedPatterns() if(barstate.islast and not printed) patterns = hp.isHarmonicProjection(x, a, b, c, flags, errorPercent = errorPercent) int xBar = na int aBar = na int bBar = na int cBar = na offset = 0 while(na(xBar) or na(aBar) or na(bBar) or na(cBar)) bartime = time[offset] if(na(xBar) and bartime == xBarTime) xBar := bar_index - offset if(na(aBar) and bartime == aBarTime) aBar := bar_index - offset if(na(bBar) and bartime == bBarTime) bBar := bar_index - offset if(na(cBar) and bartime == cBarTime) cBar := bar_index - offset offset+=1 [startRange, endRange] = hp.get_projection_range(x, a, b, c, patterns) [consolidatedStartRange, consolidatedEndRange, consolidatedPatternLabels, merged] = normalize_prz_range(patterns, patternLabels, startRange, endRange) while(merged) [newStartRange, newEndRange, newLabels, newMerged] = merge_ranges(consolidatedStartRange, consolidatedEndRange, consolidatedPatternLabels) consolidatedStartRange := newStartRange consolidatedEndRange := newEndRange consolidatedPatternLabels := newLabels merged := newMerged dir = c > b? 1 : -1 draw_xabc(x, a, b, c, xBar, aBar, bBar, cBar, dir, patternColor, patterns, consolidatedStartRange, consolidatedEndRange, consolidatedPatternLabels) printed := true
ShareGenius Swing Trading (SST)
https://www.tradingview.com/script/HLtNtX91-ShareGenius-Swing-Trading-SST/
mhussainxeo
https://www.tradingview.com/u/mhussainxeo/
57
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/ // source/reference: https://swingtradingsheets.blogspot.com/?view=classic // atulkharadi //@version=4 study(title="Modified DC for SST", shorttitle="GTT Price Table", overlay=true) length = input(20, minval=1) profit = input(10, minval=1) HIGH20 = highest(length) LOW20 = lowest(length) TARGET = HIGH20*(100+profit)/100 plot(HIGH20,"HIGH20", color = color.blue) plot(LOW20,"LOW20", color = color.red) plot(TARGET,"TARGET", color = color.green) var table gttTable = table.new(position.top_right, 5, 5, bgcolor=color.white, frame_color=color.white, frame_width=2, border_width=2) SST="TODAY SST\n" + "PRICE" table.cell(gttTable, 0, 0, text=SST, bgcolor=color.silver, text_color=color.white) if barstate.islast High20D="20D HIGH\n" + tostring(round(HIGH20,2)) table.cell(gttTable, 1, 0, text=High20D, bgcolor=color.blue, text_color=color.white) Low20D="20D LOW\n" + tostring(round(LOW20,2)) table.cell(gttTable, 2, 0, text=Low20D, bgcolor=color.red, text_color=color.white) TargetPrice="TARGET\n" + tostring(round(TARGET,2)) table.cell(gttTable, 3, 0, text=TargetPrice, bgcolor=color.green, text_color=color.white) ////////////End of Code
Litt Institutional Levels
https://www.tradingview.com/script/s0VPLY3b-Litt-Institutional-Levels/
Steadylit
https://www.tradingview.com/u/Steadylit/
207
study
5
MPL-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("Litt Institutional Levels", overlay = true) instructions = input.bool(title='Instructions', defval=true, inline='1', tooltip = "The Litt Institutional Levels Indicator plots previous timeperiods Highs, Lows, and Closes. Institutions track these levels and will use them as support and resistance to enter and exit their positions. Not every algorithm is a machine-learning wizard. Institutions still use these relatively simple levels to conduct their trades. The best way to use The Litt Institutional Levels Indicator is to find overlapping levels. These areas or lines are called confluence levels and will act as a stronger level than a single line. \n\nFor the labeling, Y stands for Yesterday and L stands for Last. For example, LMC would equal Last Months Close. LQH, would equal Last Quarters High. YL, would equal Yeserdays Low.") daily_levels = input.bool(true, title = "Daily Levels", group = "Daily Levels") daily_line_color = input.color(color.new(color.silver, 20), title = "Line Color", group = "Daily Levels", inline = '2') daily_text_color = input.color(color.new(color.white, 20), title = "Label Text Color", group = "Daily Levels", inline = '2') weekly_levels = input.bool(true, title = "Weekly Levels", group = "Weekly Levels") weekly_line_color = input.color(color.new(color.yellow, 20), title = "Line Color", group = "Weekly Levels", inline = '2') weekly_text_color = input.color(color.new(color.yellow, 20), title = "Label Text Color", group = "Weekly Levels", inline = '2') monthly_levels = input.bool(true, title = "Monthly Levels", group = "Monthly Levels") monthly_line_color = input.color(color.new(color.blue, 20), title = "Line Color", group = "Monthly Levels", inline = '2') monthly_text_color = input.color(color.new(color.blue, 20), title = "Label Text Color", group = "Monthly Levels", inline = '2') qtr_levels = input.bool(true, title = "Quarterly Levels", group = "Quarterly Levels") qtr_line_color = input.color(color.new(color.red, 20), title = "Line Color", group = "Quarterly Levels", inline = '2') qtr_text_color = input.color(color.new(color.red, 20), title = "Label Text Color", group = "Quarterly Levels", inline = '2') yearly_levels = input.bool(true, title = "Yearly Levels", group = "Yearly Levels") yearly_line_color = input.color(color.new(color.orange, 20), title = "Line Color", group = "Yearly Levels", inline = '2') yearly_text_color = input.color(color.new(color.orange, 20), title = "Label Text Color", group = "Yearly Levels", inline = '2') timeChange(period) => ta.change(time(period)) institution_function(time_period, line_color, text_color, text_text) => is_new_period = timeChange(time_period) var first_bar_in_period = 0 first_bar_in_period := is_new_period ? time : first_bar_in_period[1] highs = request.security(syminfo.tickerid,time_period, high[1], lookahead=barmerge.lookahead_on) lows = request.security(syminfo.tickerid,time_period, low[1], lookahead=barmerge.lookahead_on) closes = request.security(syminfo.tickerid,time_period, close[1], lookahead=barmerge.lookahead_on) high_line = line.new(first_bar_in_period, highs, time, y2 = highs, xloc = xloc.bar_time, extend = extend.right, color = line_color, style = line.style_dotted, width = 2) line.delete(high_line[1]) low_line = line.new(first_bar_in_period, lows, time, y2 = lows, xloc = xloc.bar_time, extend = extend.right, color = line_color, style = line.style_dotted, width = 2) line.delete(low_line[1]) close_line = line.new(first_bar_in_period, closes, time, y2 = closes, xloc = xloc.bar_time, extend = extend.right, color = line_color, style = line.style_dotted, width = 2) line.delete(close_line[1]) high_label = label.new(x = bar_index + 70, y = highs, text = text_text + "H", style = label.style_none, textcolor = text_color) label.delete(high_label[1]) low_label = label.new(x = bar_index + 70, y = lows, text = text_text + "L", style = label.style_none, textcolor = text_color) label.delete(low_label[1]) close_label = label.new(x = bar_index + 70, y = closes, text = text_text + "C", style = label.style_none, textcolor = text_color) label.delete(close_label[1]) if daily_levels institution_function("D",daily_line_color, daily_text_color, "Y") if weekly_levels institution_function("W",weekly_line_color, weekly_text_color, "LW") if monthly_levels institution_function("M",monthly_line_color, monthly_text_color, "LM") if qtr_levels institution_function("3M",qtr_line_color, qtr_text_color, "LQ") if yearly_levels institution_function("12M",yearly_line_color, yearly_text_color, "LY") //TABLE show_dashboard = input.bool(title='Color Legend', defval=true, inline='1', group='Dashboard Settings') LabelSize = input.string(defval='Medium', options=['Small', 'Medium', 'Large'], title='Dashboard Size', inline='2', group='Dashboard Settings') label_size = LabelSize == 'Small' ? size.small : LabelSize == 'Medium' ? size.normal : LabelSize == 'Large' ? size.large : size.small positioning = position.top_right var table t = table.new(positioning, 5, 1,frame_color=color.new(#000000, 100), frame_width=0, border_color=color.new(#000000,100), border_width=0) if barstate.islast and show_dashboard //Column 1 table.cell(t, 0, 0, text='D', width=0, bgcolor=daily_line_color, text_color=color.white, text_size=label_size, text_halign=text.align_center) table.cell(t, 1, 0, text='W', width=0, bgcolor=weekly_line_color, text_color=color.white, text_size=label_size, text_halign=text.align_center) table.cell(t, 2, 0, text='M', width=0, bgcolor=monthly_line_color, text_color=color.white, text_size=label_size, text_halign=text.align_center) table.cell(t, 3, 0, text='Q', width=0, bgcolor=qtr_line_color, text_color=color.white, text_size=label_size, text_halign=text.align_center) table.cell(t, 4, 0, text='Y', width=0, bgcolor=yearly_line_color, text_color=color.white, text_size=label_size, text_halign=text.align_center)
All for One Moving Average
https://www.tradingview.com/script/DcebJ0F8-All-for-One-Moving-Average/
darkbrewery
https://www.tradingview.com/u/darkbrewery/
32
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © darkbrewery // @version=5 // Thank-you: SGJoe and DTKing for their help with the switch! kurtisbu for the hand-holding! Franklin Moormann (cheatcountry) for the Ehlers & Kaufman MA indicator("All for One Moving Average", "A41MA", true) ///// Inputs ///// MA_TF = input.timeframe ('','TimeFrame', inline='L1') Repaint = input (false,'Repainting', inline='L1') Use_HA = input (false,'Heikin Ashi', inline='L1') MA_Type = input.string ("EMA", 'Type', ["SMA","EMA","DEMA","TEMA","QEMA","WMA","VWMA","HMA","SWMA","ALMA","LMA","RMA","WWMA","TMA","EKMA"], inline="L2") MA_Input = input.source (close, 'Src', inline='L2') MA_L1 = input.int (20, 'Len', 1, 200, inline='L2') MA_Off1 = input.float (0.85, 'Offset', 0, 3, 0.01, inline='L3') MA_Sig1 = input.int (6, 'Σ', 0, 10, tooltip="Offset & Σ only apply to ALMA", inline='L3') MA_S1 = request.security (Use_HA?ticker.heikinashi(syminfo.tickerid):syminfo.tickerid, MA_TF, MA_Input[Repaint?0:barstate.isrealtime?1:0])[Repaint?0:barstate.isrealtime?0:1] ///// Calculate Moving Average ///// MA_1 = switch MA_Type "SMA" => ta.sma (MA_S1,MA_L1) "EMA" => ta.ema (MA_S1,MA_L1) "DEMA" => 2* ta.ema (MA_S1, MA_L1) - ta.ema(ta.ema(MA_S1, MA_L1), MA_L1) "TEMA" => 3*(ta.ema (MA_S1, MA_L1) - ta.ema(ta.ema(MA_S1, MA_L1), MA_L1)) + ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1) "QEMA" => 5* ta.ema (MA_S1,MA_L1) - 10 * ta.ema(ta.ema(MA_S1, MA_L1), MA_L1) + 10 * ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1) - 5 * ta.ema(ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1), MA_L1) + ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1), MA_L1), MA_L1) "WMA" => ta.wma (MA_S1,MA_L1) "VWMA" => ta.vwma (MA_S1,MA_L1) "HMA" => ta.hma (MA_S1,MA_L1) "SWMA" => ta.swma (MA_S1) "ALMA" => ta.alma (MA_S1, MA_L1, MA_Off1, MA_Sig1) "LMA" => ta.linreg (MA_S1, MA_L1, 0) "RMA" => ta.rma (MA_S1,MA_L1) "WWMA" => Wilder_MA1 = .0 Wilder_MA1 := 1 / MA_L1 * MA_S1 + (1 - 1 / MA_L1) * nz(Wilder_MA1[1]) "TMA" => ta.sma(ta.sma(MA_S1,MA_L1),MA_L1) "EKMA" => KA_D1 = .0 for int i = 0 to MA_L1 - 1 by 1 KA_D1 += math.abs(nz(MA_S1[i]) - nz(MA_S1[i + 1])) KA_EF1 = KA_D1 != 0 ? math.min(math.abs(MA_S1 - nz(MA_S1[MA_L1 - 1])) / KA_D1, 1) : 0 KAMA1 = .0 KAMA1 := (math.pow((0.6667 * KA_EF1) + 0.0645, 2) * MA_S1) + ((1 - math.pow((0.6667 * KA_EF1) + 0.0645, 2)) * nz(KAMA1[1])) ///// Draw it up ///// plot(MA_1, title='A41MA', color=color.yellow)
Color Palette Options
https://www.tradingview.com/script/tALzk3Qa-Color-Palette-Options/
darkbrewery
https://www.tradingview.com/u/darkbrewery/
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/ // © darkbrewery 2021 //@version=5 indicator("Color Palette Options", overlay=true) Color_Palette = input.string('Synth Wave','Bar Colors', options = ['Synth Wave', 'Neon', 'Pastel', 'Charcoal'], tooltip = "Right-click bars on the chart, then goto: 'Visual Order' -> 'Bring to Front' --OR-- Click 'Chart Options' then Uncheck 'Body', 'Borders' and 'Wick'") Bull = close >= open S_Body = Bull ? #00fff9 : #E93479 S_Wick = Bull ? #00b8ff : #F62E97 N_Body = Bull ? #00D3BA : #FF3FBF N_Wick = Bull ? #00B1A9 : #EE2EAE P_Body = Bull ? #c8e1cc : #ff7c7c P_Wick = Bull ? #b8d8be : #ef6969 C_Body = Bull ? #777777 : #333333 C_Wick = Bull ? #999999 : #444444 [Candle_C, Wick_C] = switch Color_Palette 'Synth Wave' => [S_Body, S_Wick] 'Neon' => [N_Body, N_Wick] 'Pastel' => [P_Body, P_Wick] 'Charcoal' => [C_Body, C_Wick] plotcandle(open, high, low, close, color = Candle_C, wickcolor = Wick_C, bordercolor = Wick_C, editable = false)
Moving Average - 365/2/2/2/2 - @DaviG117
https://www.tradingview.com/script/lARx7FLs-Moving-Average-365-2-2-2-2-DaviG117/
DaviG
https://www.tradingview.com/u/DaviG/
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/ // © DaviG //@version=5 indicator("MA - 365/2/2/2/2", overlay=true, timeframe="") ma1Input = input.string(title="MA Type 1 - 365", defval="EMA",options=["EMA","SMA","RMA","WMA","VWMA","HMA","KAMA","P-KAMA"], tooltip="365") ma2Input = input.string(title="MA Type 2 - 182.42" , defval="EMA",options=["EMA","SMA","RMA","WMA","VWMA","HMA","KAMA","P-KAMA"], tooltip="365/2") ma3Input = input.string(title="MA Type 3 - 91.25", defval="EMA",options=["EMA","SMA","RMA","WMA","VWMA","HMA","KAMA","P-KAMA"], tooltip="365/2/2") ma4Input = input.string(title="MA Type 4 - 45.625", defval="EMA",options=["EMA","SMA","RMA","WMA","VWMA","HMA","KAMA","P-KAMA"], tooltip="365/2/2/2") ma5Input = input.string(title="MA Type 5 - 22.8125", defval="EMA",options=["EMA","SMA","RMA","WMA","VWMA","HMA","KAMA","P-KAMA"], tooltip="365/2/2/2/2") fillSwitch = input.bool(title="Fill between lines?", defval=true) //KAMA Function kama(_src,_len) => xPrice = _src xvnoise = math.abs(xPrice - xPrice[1]) nAMA = 0.0 nfastend = 0.666 nslowend = 0.0645 nsignal = math.abs(xPrice - xPrice[_len]) nnoise = math.sum(xvnoise, _len) nefratio = nnoise != 0 ? nsignal / nnoise : 0 nsmooth = math.pow(nefratio * (nfastend - nslowend) + nslowend, 2) nAMA := nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1])) //P-Kama pKama(_src,_len) => // length = input(100),factor = input(3.),src = input(close),sp = input(false,title="Self Powered") //---- factor = 3 er = math.abs(ta.change(_src,_len))/math.sum(math.abs(ta.change(_src)),_len) // pow = sp ? 1/er : factor per = math.pow(math.abs(ta.change(_src,_len))/math.sum(math.abs(ta.change(_src)),_len),factor) //---- a = 0.0 a := per * _src + (1 - per) * nz(a[1],_src) //---- // plot(a,title="P-KAMA",color=#f57f17,linewidth=2,transp=0) len1 = 365 len2 = 365 / 2 len3 = 365 / 2 / 2 len4 = 365 / 2 / 2 / 2 len5 = 365 / 2 / 2 / 2 / 2 maFunction(_len,_type) => switch _type "EMA" => ta.ema(close, _len) "SMA" => ta.sma(close, _len) "RMA" => ta.rma(close, _len) "WMA" => ta.wma(close, _len) "VWMA" => ta.vwma(close, _len) "HMA" => ta.hma(close, _len) "KAMA" => kama(close, _len) "P-KAMA"=> pKama(close, _len) => runtime.error("No matching MA type found!") na ma1 = maFunction(len1,ma1Input) ma2 = maFunction(len2,ma2Input) ma3 = maFunction(len3,ma3Input) ma4 = maFunction(len4,ma4Input) ma5 = maFunction(len5,ma5Input) p1 = plot(ma1,color=color.green, linewidth=2, title="MA Type 1 - 365") p2 = plot(ma2,color=color.rgb(255,244,157), linewidth=2, title="MA Type 2 - 182.42") p3 = plot(ma3,color=color.rgb(255,183,77), linewidth=2, title="MA Type 3 - 91.25") p4 = plot(ma4,color=color.rgb(247,81,95), linewidth=2, title="MA Type 4 - 45.625") p5 = plot(ma5,color=color.rgb(242,53,69), linewidth=2, title="MA Type 5 - 22.8125") fill(p1,p2,color= fillSwitch ? color.new(color.green,80) : na) fill(p2,p3,color= fillSwitch ? color.rgb(255,244,157,80) : na) fill(p3,p4,color= fillSwitch ? color.rgb(255,183,77,80) : na) fill(p4,p5,color= fillSwitch ? color.rgb(242,53,69,80) : na)
MA with options
https://www.tradingview.com/script/AgzL1YqD-MA-with-options/
degendcrypto
https://www.tradingview.com/u/degendcrypto/
52
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Shad0wCrypt0 //@version=5 indicator("MA with options", shorttitle = 'MA type', overlay= true) //User can select the MA type and length of his choice //defining the first MA length as 12 and creating the drop down menu for the MA type //Similarly the length and option menus are created for 6 MAs MA1 = input(12, 'Length of MA1') MA1_type= input.string(defval="EMA", title = 'MA1 Type', options = ["SMA", "EMA", "RMA", "WMA", "VWMA"]) MA2 = input(21, 'Length of MA2') MA2_type= input.string(defval="EMA", title = 'MA2 Type', options = ["SMA", "EMA", "RMA", "WMA", "VWMA"]) MA3 = input(34, 'Length of MA3') MA3_type= input.string(defval="EMA", title = 'MA3 Type', options = ["SMA", "EMA", "RMA", "WMA", "VWMA"]) MA4 = input(50, 'Length of MA4') MA4_type= input.string(defval="SMA", title = 'MA4 Type', options = ["SMA", "EMA", "RMA", "WMA", "VWMA"]) MA5 = input(100, 'Length of MA5') MA5_type= input.string(defval="SMA",title = 'MA5 Type', options = ["SMA", "EMA", "RMA", "WMA", "VWMA"]) MA6 = input(200, 'Length of MA6') MA6_type= input.string(defval="SMA", title = 'MA6 Type', options = ["SMA", "EMA", "RMA", "WMA", "VWMA"]) //Conditional statements for plotting the type of MA based on the user selection. //The IF and ELSE statements are applied for all the 6 MAs MA_1 = if MA1_type == 'SMA' ta.sma(close, MA1) else if MA1_type == 'EMA' ta.ema(close, MA1) else if MA1_type == 'RMA' ta.rma(close, MA1) else if MA1_type == 'WMA' ta.wma(close, MA1) else if MA1_type == 'VWMA' ta.vwma(close, MA1) MA_2 = if MA2_type == 'SMA' ta.sma(close, MA2) else if MA2_type == 'EMA' ta.ema(close, MA2) else if MA2_type == 'RMA' ta.rma(close, MA2) else if MA2_type == 'WMA' ta.wma(close, MA2) else if MA2_type == 'VWMA' ta.vwma(close, MA2) MA_3 = if MA3_type == 'SMA' ta.sma(close, MA3) else if MA3_type == 'EMA' ta.ema(close, MA3) else if MA3_type == 'RMA' ta.rma(close, MA3) else if MA3_type == 'WMA' ta.wma(close, MA3) else if MA3_type == 'VWMA' ta.vwma(close, MA3) MA_4 = if MA4_type == 'SMA' ta.sma(close, MA4) else if MA4_type == 'EMA' ta.ema(close, MA4) else if MA4_type == 'RMA' ta.rma(close, MA4) else if MA4_type == 'WMA' ta.wma(close, MA4) else if MA4_type == 'VWMA' ta.vwma(close, MA4) MA_5 = if MA5_type == 'SMA' ta.sma(close, MA5) else if MA5_type == 'EMA' ta.ema(close, MA5) else if MA5_type == 'RMA' ta.rma(close, MA5) else if MA5_type == 'WMA' ta.wma(close, MA5) else if MA5_type == 'VWMA' ta.vwma(close, MA5) MA_6 = if MA6_type == 'SMA' ta.sma(close, MA6) else if MA6_type == 'EMA' ta.ema(close, MA6) else if MA6_type == 'RMA' ta.rma(close, MA6) else if MA6_type == 'WMA' ta.wma(close, MA6) else if MA6_type == 'VWMA' ta.vwma(close, MA6) //To plot all the Moving Averages on the chart with different colours. plot(MA_1, 'ma1', color= color.blue) plot(MA_2, 'ma2', color= color.purple) plot(MA_3, 'ma3', color= color.orange) plot(MA_4, 'ma4', color= color.yellow) plot(MA_5, 'ma5', color= color.gray) plot(MA_6, 'ma6', color= color.aqua) //EMA Crossover between EMA21 and EMA34. The crossover and crossunder function is used for MA2 and MA3 EMA_crossover = ta.crossover(MA_2,MA_3) EMA_crossunder = ta.crossunder(MA_2,MA_3) //The buy and sell signals are plotted plotshape(EMA_crossover, title='BUY Signal', style=shape.triangleup, location=location.belowbar, color=color.green, text="BUY", textcolor=color.green, size=size.small) plotshape(EMA_crossunder, title='SELL Signal', style=shape.triangledown, location=location.abovebar, color=color.red, text="SELL", textcolor=color.red, size=size.small)
BABA 24/7 - Alibaba price chart all exchanges combined
https://www.tradingview.com/script/g19tmA4Z-BABA-24-7-Alibaba-price-chart-all-exchanges-combined/
Ursohaha
https://www.tradingview.com/u/Ursohaha/
12
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/ // // © Ursohaha //@version=4 study("BABA 24/7", overlay=false) ust = tickerid("NYSE", "BABA", session.extended) hkt = tickerid("HKEX", "9988", session.extended) [usop, uscl, ushi, uslo] = security(ust, timeframe.period, [open,close,high, low], gaps=barmerge.gaps_on) [hkop, hkcl, hkhi, hklo] = security(hkt, timeframe.period, [open,close,high, low], gaps=barmerge.gaps_on) [euop, eucl, euhi, eulo] = security("XETR:AHLA", timeframe.period, [open,close,high, low], gaps=barmerge.gaps_on) USDHKD = security("OANDA:USDHKD",timeframe.period, close) USDEUR = security("OANDA:EURUSD",timeframe.period, close) op = na(usop)? (na(hkop)? (na(euop)?na:euop*USDEUR): hkop*8/USDHKD):usop cl = na(uscl)? (na(hkcl)? (na(eucl)?na:eucl*USDEUR): hkcl*8/USDHKD):uscl hi = na(ushi)? (na(hkhi)? (na(euhi)?na:euhi*USDEUR): hkhi*8/USDHKD):ushi lo = na(uslo)? (na(hklo)? (na(eulo)?na:eulo*USDEUR): hklo*8/USDHKD):uslo plot(cl, color=cl>=op?#00cc5000:#ff110000, title="close") plot(op, color=#aaaaaa00, title="open", display=display.none) plot(hi, color=#aaaaaa00, title="high", display=display.none) plot(lo, color=#aaaaaa00, title="low", display=display.none) plotcandle(op, hi, lo, cl, color=cl>=op?color.green:color.red, wickcolor=cl>=op?color.green:color.red, bordercolor=cl>=op?color.green:color.red, title="Candles") bgcolor(na(uscl) and not na(hkcl)?#FFEB3B08:na, title="HK session") bgcolor(na(uscl) and not na(eucl)?#2196f308:na, title="EU session") var priceline = line.new(0, 0, 0, 0, xloc=xloc.bar_index, color=#00000000, extend = extend.both) var pricelabel = label.new(0, 0, "-", style=label.style_none) if(not na(cl)) line.set_color(priceline, cl>=op?#4CAF5055:#FF525255) line.set_xy1(priceline, bar_index, cl) line.set_xy2(priceline, bar_index-1, cl) label.set_textcolor(pricelabel, cl>=op?color.green:color.red) label.set_text(pricelabel, tostring(cl,'.00')) label.set_xy(pricelabel, bar_index+15, cl)
Moving Averages Different Type & Source
https://www.tradingview.com/script/XTGg4iIH-Moving-Averages-Different-Type-Source/
tradersoumya
https://www.tradingview.com/u/tradersoumya/
52
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tradersoumya //@version=5 indicator('Moving Averages Different Type & Source', shorttitle='MA', overlay=true) toggleColor = input(defval=true, title='Toggle Color on Crossovers') MA1Visible = input.bool(title='MA1', defval=true, inline='I1', group='Moving Averages') MA2Visible = input.bool(title='MA2', defval=true, inline='I2', group='Moving Averages') MA3Visible = input.bool(title='MA3', defval=true, inline='I3', group='Moving Averages') MA4Visible = input.bool(title='MA4', defval=true, inline='I4', group='Moving Averages') MA5Visible = input.bool(title='MA5', defval=true, inline='I5', group='Moving Averages') MA6Visible = input.bool(title='MA6', defval=true, inline='I6', group='Moving Averages') MA1Length = input.int(title='Len', minval=1, maxval=500, defval=9, inline='I1', group='Moving Averages') MA2Length = input.int(title='Len', minval=1, maxval=500, defval=20, inline='I2', group='Moving Averages') MA3Length = input.int(title='Len', minval=1, maxval=500, defval=50, inline='I3', group='Moving Averages') MA4Length = input.int(title='Len', minval=1, maxval=500, defval=100, inline='I4', group='Moving Averages') MA5Length = input.int(title='Len', minval=1, maxval=500, defval=150, inline='I5', group='Moving Averages') MA6Length = input.int(title='Len', minval=1, maxval=500, defval=200, inline='I6', group='Moving Averages') MA1Type = input.string(title='Type', options=['SMA','EMA'], defval='SMA', inline='I1', group='Moving Averages') MA2Type = input.string(title='Type', options=['SMA','EMA'], defval='EMA', inline='I2', group='Moving Averages') MA3Type = input.string(title='Type', options=['SMA','EMA'], defval='EMA', inline='I3', group='Moving Averages') MA4Type = input.string(title='Type', options=['SMA','EMA'], defval='EMA', inline='I4', group='Moving Averages') MA5Type = input.string(title='Type', options=['SMA','EMA'], defval='EMA', inline='I5', group='Moving Averages') MA6Type = input.string(title='Type', options=['SMA','EMA'], defval='EMA', inline='I6', group='Moving Averages') MA1Source = input.source(title='Src', defval=high, inline='I1', group='Moving Averages') MA2Source = input.source(title='Src', defval=close, inline='I2', group='Moving Averages') MA3Source = input.source(title='Src', defval=close, inline='I3', group='Moving Averages') MA4Source = input.source(title='Src', defval=close, inline='I4', group='Moving Averages') MA5Source = input.source(title='Src', defval=close, inline='I5', group='Moving Averages') MA6Source = input.source(title='Src', defval=close, inline='I6', group='Moving Averages') //*************************************************************************************** // Plot moving averages //*************************************************************************************** MA1 = MA1Type == 'SMA' ? ta.sma(MA1Source, MA1Length) : ta.ema(MA1Source, MA1Length) MA2 = MA2Type == 'SMA' ? ta.sma(MA2Source, MA2Length) : ta.ema(MA2Source, MA2Length) MA3 = MA3Type == 'SMA' ? ta.sma(MA3Source, MA3Length) : ta.ema(MA3Source, MA3Length) MA4 = MA4Type == 'SMA' ? ta.sma(MA4Source, MA4Length) : ta.ema(MA4Source, MA4Length) MA5 = MA5Type == 'SMA' ? ta.sma(MA5Source, MA5Length) : ta.ema(MA5Source, MA5Length) MA6 = MA6Type == 'SMA' ? ta.sma(MA6Source, MA6Length) : ta.ema(MA6Source, MA6Length) plotColor1 = toggleColor ? close < MA1 ? color.red : color.lime : color.maroon plotColor2 = toggleColor ? close < MA2 ? color.red : color.lime : color.red plotColor3 = toggleColor ? close < MA3 ? color.red : color.lime : color.green plotColor4 = toggleColor ? close < MA4 ? color.red : color.lime : color.blue plotColor5 = toggleColor ? close < MA5 ? color.red : color.lime : color.orange plotColor6 = toggleColor ? close < MA6 ? color.red : color.lime : color.yellow plot(MA1Visible and MA1 ? MA1 : na, color=plotColor1, linewidth=1) plot(MA2Visible and MA2 ? MA2 : na, color=plotColor2, linewidth=2) plot(MA3Visible and MA3 ? MA3 : na, color=plotColor3, linewidth=3) plot(MA4Visible and MA4 ? MA4 : na, color=plotColor4, linewidth=4) plot(MA5Visible and MA5 ? MA5 : na, color=plotColor5, linewidth=5) plot(MA6Visible and MA6 ? MA6 : na, color=plotColor6, linewidth=6) //======MA Table========// baseSymbol = request.security(syminfo.tickerid, timeframe.period, close) var table maTable = table.new(position.top_right, 1, 10, border_width=1) table.cell(maTable, 0, 0, 'MA', bgcolor=color.new(color.blue, 0), text_color=color.white) table.cell(maTable, 0, 1, str.tostring(math.round(MA1)), bgcolor=baseSymbol >= MA1 ? color.new(color.green, 0) : color.new(color.red, 0), text_color=color.white) table.cell(maTable, 0, 2, str.tostring(math.round(MA2)), bgcolor=baseSymbol >= MA2 ? color.new(color.green, 0) : color.new(color.red, 0), text_color=color.white) table.cell(maTable, 0, 3, str.tostring(math.round(MA3)), bgcolor=baseSymbol >= MA3 ? color.new(color.green, 0) : color.new(color.red, 0), text_color=color.white) table.cell(maTable, 0, 4, str.tostring(math.round(MA4)), bgcolor=baseSymbol >= MA4 ? color.new(color.green, 0) : color.new(color.red, 0), text_color=color.white) table.cell(maTable, 0, 5, str.tostring(math.round(MA5)), bgcolor=baseSymbol >= MA5 ? color.new(color.green, 0) : color.new(color.red, 0), text_color=color.white) table.cell(maTable, 0, 6, str.tostring(math.round(MA6)), bgcolor=baseSymbol >= MA6 ? color.new(color.green, 0) : color.new(color.red, 0), text_color=color.white)
EMA/MA Cross + BB + Alerts
https://www.tradingview.com/script/q4oLQ58T-EMA-MA-Cross-BB-Alerts/
revolution05
https://www.tradingview.com/u/revolution05/
33
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © revolution05 /////// u/ tmyerskerry for the math on slope and look back period /////// ///////Multiple Parts to Code - Part 1 EMA/SMA - Part 2 Bollinger Band - Part 3 /////// //@version=5 indicator(title="EMA/MA + BB + Alerts ", shorttitle="EMA/SMA+BB", overlay=true) lookback_period=input(defval=100) radians_to_degrees=180/3.14159265359 signal = ta.ema(close, 200) len1 = input(9, title="EMA #1 - Primary Cross") src1 = input(close, title="EMA Source #1") out1 = ta.ema(src1, len1) plot(out1, title="EMA #1",color=color.yellow) len2 = input(13, title="EMA #2") src2 = input(close, title="EMA Source #2") out2 = ta.ema(src2, len2) plot(out2, title="EMA #2",color=color.green) len3 = input(34, title="EMA #3 - Secondary Cross") src3 = input(close, title="SMA Source #3") out3 = ta.ema(src3, len3) plot(out3, title="EMA #3",color=color.gray) len4 = input(55, title="EMA #4") src4 = input(close, title="EMA Source #4") out4 = ta.ema(src4, len4) plot(out4, title="EMA #4") len5 = input(50, title="SMA #1") src5 = input(close, title="SMA Source #1") out5 = ta.sma(src5, len5) plot(out5, title="SMA #1",color=color.red) len6 = input(100, title="SMA #2") src6 = input(close, title="SMA Source #2") out6 = ta.sma(src6, len6) plot(out6, title="SMA #2",color=color.green) len7 = input(200, title="SMA #3 - ") src7 = input(close, title="SMA Source #3") out7 = ta.sma(src7, len7) plot(out7, title="SMA #3",color=color.purple) len8 = input(1, title="SMA #4") src8 = input(close, title="SMA Source #4") out8 = ta.sma(src8, len8) plot(out8, title="SMA #4") len9 = input(1, title="SMA #5") src9 = input(close, title="SMA Source #5") out9 = ta.sma(src9, len9) plot(out9, title="SMA #5") len10 = input(1, title="SMA #6") src10 = input(close, title="SMA Source #6") out10 = ta.sma(src10, len10) plot(out10, title="SMA #6") signal_slope = radians_to_degrees*math.atan((signal[0]-nz(signal[lookback_period]))/lookback_period) plotshape(signal_slope > 0 and ta.crossover(out1,out3),title= "Strong Long",style=shape.arrowup, location=location.belowbar,color=color.green, size=size.huge) plotshape(signal_slope < 0 and ta.crossover(out1,out3),title= "Weak Long", style=shape.arrowup, location=location.belowbar,color=color.yellow, size=size.huge) plotshape(signal_slope < 0 and ta.crossunder(out1,out3),title= "Strong Short", style=shape.arrowdown, location=location.abovebar,color=color.red, size=size.huge) plotshape(signal_slope > 0 and ta.crossunder(out1,out3),title= "Weak Short", style=shape.arrowdown, location=location.abovebar,color=color.orange, size=size.huge) ////Bollinger Band Code [middle, upper, lower] = ta.bb(close, 20, 2) plot(middle, title="Middle BB", color=color.blue) p1PlotID = plot(upper, title="Upper BB", color=color.white) p2PlotID = plot(lower, title="Lower BB", color=color.white) crossUp = ta.crossover(high, upper) crossDn = ta.crossunder(low, lower) var TRANSP = 90 fill(p1PlotID, p2PlotID, color = color.new(color.white, TRANSP),title="BB Shadow") bgcolor(crossUp ? color.new(color.green, TRANSP) : crossDn ? color.new(color.red, TRANSP) : na, title="Outside BB Shadow") //// Code for alerts
On Balance Volume with candles
https://www.tradingview.com/script/lOFoIbsN-On-Balance-Volume-with-candles/
siddhugaddi
https://www.tradingview.com/u/siddhugaddi/
71
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/ // © siddhugaddi //@version=4 study("On Balance Volume", "OBV") linestyle = input(defval = 'Candle', title = "Style", options = ['Candle', 'Line']) hacandle = input(defval = false, title = "Heikin Ashi Candles?") showma1 = input(defval = false, title = "SMA 1", inline = "ma1") ma1len = input(defval = 50, title = "", minval = 1, inline = "ma1") ma1col = input(defval = color.lime, title = "", inline = "ma1") showma2 = input(defval = false, title = "SMA 2", inline = "ma2") ma2len = input(defval = 200, title = "", minval = 1, inline = "ma2") ma2col = input(defval = color.red, title = "", inline = "ma2") showema1 = input(defval = false, title = "EMA 1", inline = "ema1") ema1len = input(defval = 13, title = "", minval = 1, inline = "ema1") ema1col = input(defval = color.lime, title = "", inline = "ema1") showema2 = input(defval = false, title = "EMA 2", inline = "ema2") ema2len = input(defval = 50, title = "", minval = 1, inline = "ema2") ema2col = input(defval = color.red, title = "", inline = "ema2") showema3 = input(defval = false, title = "EMA 3", inline = "ema3") ema3len = input(defval = 200, title = "", minval = 1, inline = "ema3") ema3col = input(defval = color.yellow, title = "", inline = "ema3") colorup = input(defval = color.lime, title = "Body", inline = "bcol") colordown = input(defval = color.red, title = "", inline = "bcol") bcolup = input(defval = #74e05e, title = "Border", inline = "bocol") bcoldown = input(defval = #ffad7d, title = "", inline = "bocol") wcolup = input(defval = #b5b5b8, title = "Wicks", inline = "wcol") wcoldown = input(defval = #b5b5b8, title = "", inline = "wcol") tw = high - max(open, close) bw = min(open, close) - low body = abs(close - open) _rate(cond) => ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) ret := nz(ret) == 0 ? 0.5 : ret ret deltaup = volume * _rate(open <= close) deltadown = volume * _rate(open > close) delta = close >= open ? deltaup : -deltadown cumdelta = cum(delta) float ctl = na float o = na float h = na float l = na float c = na if linestyle == 'Candle' o := cumdelta[1] h := max(cumdelta, cumdelta[1]) l := min(cumdelta, cumdelta[1]) c := cumdelta ctl else ctl := cumdelta plot(ctl, title = "CDV Line", color = color.blue, linewidth = 2) float haclose = na float haopen = na float hahigh = na float halow = na haclose := (o + h + l + c) / 4 haopen := na(haopen[1]) ? (o + c) / 2 : (haopen[1] + haclose[1]) / 2 hahigh := max(h, max(haopen, haclose)) halow := min(l, min(haopen, haclose)) c_ = hacandle ? haclose : c o_ = hacandle ? haopen : o h_ = hacandle ? hahigh : h l_ = hacandle ? halow : l plotcandle(o_, h_, l_, c_, title='CDV Candles', color = o_ <= c_ ? colorup : colordown, bordercolor = o_ <= c_ ? bcolup : bcoldown, wickcolor = o_ <= c_ ? bcolup : bcoldown) plot(showma1 and linestyle == "Candle" ? sma(c_, ma1len) : na, title = "SMA 1", color = ma1col) plot(showma2 and linestyle == "Candle" ? sma(c_, ma2len) : na, title = "SMA 2", color = ma2col) plot(showema1 and linestyle == "Candle" ? ema(c_, ema1len) : na, title = "EMA 1", color = ema1col) plot(showema2 and linestyle == "Candle" ? ema(c_, ema2len) : na, title = "EMA 2", color = ema2col) plot(showema3 and linestyle == "Candle" ? ema(c_, ema3len) : na, title = "EMA 3", color = ema3col)
Co-Relation by Onur
https://www.tradingview.com/script/PYCLuB0w-Co-Relation-by-Onur/
SenatorVonShaft
https://www.tradingview.com/u/SenatorVonShaft/
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/ // © onurenginogutcu //@version=4 study("Co-Relation by Onur" , overlay = false) sym = input(title="Symbol", type=input.symbol, defval="BINANCE:BTCUSDT") per = input(title="Period", type=input.integer, defval=200, minval=50, maxval=1500) float topxy = 0 float topx = 0 float topy = 0 float topx2 = 0 float topy2 = 0 symClose = security(sym, "", close) cur = close for periyot = 0 to (per - 1) topxy := topxy + (symClose[periyot] * cur[periyot]) topx := topx + (cur [periyot]) topy := topy + (symClose[periyot]) topx2 := topx2 + (cur [periyot] * cur [periyot]) topy2 := topy2 + (symClose[periyot] * symClose[periyot]) calc = (topxy - ((topx * topy) / per)) / (sqrt ((topx2 - ((topx * topx)/per)) * (topy2 - ((topy * topy)/per)))) * 100 /////////////////////////////////////////// colText = calc<0 ? color.red : color.green dt = time - time[1] if barstate.islast label.new(time - 15*dt, calc, text = (tostring (sym) + " Corelation - %" + tostring(calc)), textcolor=color.new(colText,0), style=label.style_none, xloc=xloc.bar_time) //////////////////////////////////////////// hline(0, color=color.gray, linestyle=hline.style_dashed) hline(100, color=color.green, linestyle=hline.style_dotted) hline(-100, color=color.red, linestyle=hline.style_dotted) plot (calc , color=color.yellow)
US Bond Yield Magma Curve
https://www.tradingview.com/script/ZEtAa0cj-US-Bond-Yield-Magma-Curve/
giancarlopagliaroli
https://www.tradingview.com/u/giancarlopagliaroli/
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/ // © giancarlopagliaroli //@version=5 indicator('US Bond Yield Magma Curve (automiamo.com)', precision=6, overlay=false) us3M = input.symbol(title= '3M Bond Yield', defval='TVC:US03M') us01 = input.symbol(title= '1 Year Bond Yield', defval='TVC:US01Y') us02 = input.symbol(title= '2 Year Bond Yield', defval='TVC:US02Y') us03 = input.symbol(title= '3 Year Bond Yield', defval='TVC:US03Y') us05 = input.symbol(title='5 Year Bond Yield', defval='TVC:US05Y') us07 = input.symbol(title='10 Year Bond Yield', defval='TVC:US07Y') us10 = input.symbol(title='10 Year Bond Yield', defval='TVC:US10Y') us20 = input.symbol(title='20 Year Bond Yield', defval='TVC:US20Y') us30 = input.symbol(title='30 Year Bond Yield', defval='TVC:US30Y') diff_30_10 = request.security(us30, timeframe.period, close) - request.security(us10, timeframe.period, close) diff_20_10 = request.security(us20, timeframe.period, close) - request.security(us10, timeframe.period, close) diff_7_10 = request.security(us07, timeframe.period, close) - request.security(us10, timeframe.period, close) diff_5_10 = request.security(us05, timeframe.period, close) - request.security(us10, timeframe.period, close) diff_3_10 = request.security(us03, timeframe.period, close) - request.security(us10, timeframe.period, close) diff_2_10 = request.security(us02, timeframe.period, close) - request.security(us10, timeframe.period, close) diff_1_10 = request.security(us01, timeframe.period, close) - request.security(us10, timeframe.period, close) diff_3M_10 = request.security(us3M, timeframe.period, close) - request.security(us10, timeframe.period, close) plot(0, title = "10Y", color = color.green, linewidth = 4 ) plot(diff_30_10, title = "30Y-10Y Diff", color = color.blue, linewidth = 3 ) plot(diff_20_10,title = "20Y-10Y Diff", color = color.blue, linewidth = 2) plot(diff_7_10,title = "07Y-10Y Diff", color = color.orange, linewidth = 2) plot(diff_5_10,title = "05Y-10Y Diff", color = color.orange, linewidth = 3) plot(diff_3_10,title = "03Y-10Y Diff", color = color.orange, linewidth = 4) plot(diff_2_10,title = "02Y-10Y Diff", color = color.red, linewidth = 3) plot(diff_1_10,title = "01Y-10Y Diff", color = color.yellow, linewidth = 3) plot(diff_3M_10,title = "03M-10Y Diff", color = color.yellow, linewidth = 4)
RSI DIF
https://www.tradingview.com/script/oHkanH9A-RSI-DIF/
irannemohammad
https://www.tradingview.com/u/irannemohammad/
14
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/ // © trade320x24x7 //@version=4 study(title="RSI DIF", shorttitle="RSI DIF", format=format.price, precision=2, resolution="") len = input(14, minval=1, title="Length") src = input(close, "Source", type = input.source) 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)) len2 = input(28, minval=1, title="Length") up2 = rma(max(change(src), 0), len2) down2 = rma(-min(change(src), 0), len2) rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2)) dif=rsi-rsi2 plot(dif, "DIF RSI 14&28", color=#8E1599) band1 = hline(0, "Zero", color=#C0C0C0) band2 = hline(-4, "Zero", color=#C0C0C0) band3 = hline(7, "Zero", color=#C0C0C0)
Smamaema
https://www.tradingview.com/script/7xjjtqRi-Smamaema/
alintheter
https://www.tradingview.com/u/alintheter/
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/ // © alintheter //@version=4 study(title="Smaema", shorttitle="SMMAEma", overlay=true, resolution="") len = input(200, minval=1, title="LengthSMA") src = input(close, title="SourceSMA") smma = 0.0 smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len len2 = input(200, minval=1, title="LengthMA") src2 = input(close, title="SourceMA") offset = input(title="OffsetMA", type=input.integer, defval=0, minval=-500, maxval=500) out = sma(src2, len2) lema1 = input(200, minval=1, title="LEMA1") lema2 = input(100, minval=1, title="LEMA2") lema3 = input(50, minval=1, title="LEMA3") plot(out, color=color.blue, title="MA", offset=offset) plot(smma, color=color.red,title="SMA") plot(ema(close, lema1), color=#FF7000, linewidth=1, title='200 Day EMA') plot(ema(close, lema2), color=#0088FA, linewidth=1, title='100 Day EMA') plot(ema(close, lema3), color=#FA00D0, linewidth=1, title='50 Day EMA')
Speed Diamond
https://www.tradingview.com/script/8RV10OTt-Speed-Diamond/
SamRecio
https://www.tradingview.com/u/SamRecio/
64
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SamRecio //@version=5 indicator("Speed Diamond",shorttitle ="♦", overlay = true) in_target = input.float(1,step = 1, title = "Target", minval = 0) select = input.string("Percent", options = ["Percent", "Ticks", "Price"], title = "Target Type") green = input.color(color.rgb(38,208,124), inline = "c") red = input.color(color.rgb(237,29,36), inline = "c") target = select == "Percent"?close*(in_target*0.01):select == "Ticks"?in_target*0.25:select == "Price"?in_target:na lowpt = close - (target) highpt = close + (target) speed = for i = 0 to 3600 outside = close < lowpt[i] or close > highpt[i] if outside break i prg = close > close[speed]?green:close < close[speed]?red:color.gray ud = close > close[speed]?close - target:close < close[speed]?close + target:close[speed] var label point = label.new(bar_index - speed , close, color = prg, style = label.style_diamond, size = size.small) var line line1 = line.new(bar_index - speed, close[speed], bar_index + 1, close[speed], color = prg) var label num = label.new(bar_index, ud, color = prg, style = label.style_none, text = str.tostring(speed)) if 0 == 0 label.set_x(point,bar_index - speed) label.set_y(point,close) label.set_color(point,prg) line.set_x1(line1, bar_index - speed) line.set_y1(line1,ud) line.set_x2(line1,bar_index + 1) line.set_y2(line1,ud) line.set_color(line1,prg) label.set_x(num, bar_index) label.set_y(num, ud) label.set_text(num,str.tostring(speed)) label.set_textcolor(num,prg)
RedK Smooth And Lazy Moving Average (SALMA)
https://www.tradingview.com/script/JWdrXD3I-RedK-Smooth-And-Lazy-Moving-Average-SALMA/
RedKTrader
https://www.tradingview.com/u/RedKTrader/
1,067
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RedKTrader //@version=5 indicator('RedK SmoothAndLazyMA', shorttitle='SALMA v2.0', overlay=true, timeframe='', timeframe_gaps=false) // Corrects price points within specific StdDev band before calculting a smoothed WMA price = input(close, 'Source') length = input.int(10, 'Length', minval=1) smooth = input.int(3, 'Extra Smooth [1 = None]', minval=1) mult = input.float(0.3, minval=0.05, maxval=3, step=0.05, title='Width', inline = 'SD Channel', group='Volatility Filter (SD Channel)') sd_len = input.int(5, minval=1, title='Length', inline = 'SD Channel', group='Volatility Filter (SD Channel)') baseline = ta.wma(price, sd_len) dev = mult * ta.stdev(price, sd_len) upper = baseline + dev lower = baseline - dev cprice = price > upper ? upper : price < lower ? lower : price // Uncomment these code lines to expose the base StdDev channel used as volatility filter //plot (baseline, "Base MA") //plot(upper, "Upper Band", color=color.green) //plot(lower, "Lower Band", color=color.red) REMA = ta.wma(ta.wma(cprice, length), smooth) c_up = color.new(#33ff00, 0) c_dn = color.new(#ff1111, 0) REMA_up = REMA > REMA[1] plot(REMA, title='SALMA', color=REMA_up ? c_up : c_dn, linewidth=3) // ====================================================================================================== // add optional MA's - to enable us to track what many other traders are working with // These MA's will be hidden by default until user exposes them as needed in the Settings // the below code is based on the built-in MA Ribbon in the TV library - with some modifications // ====================================================================== f_ma(source, length, type) => type == 'SMA' ? ta.sma(source, length) : type == 'EMA' ? ta.ema(source, length) : ta.wma(source, length) // ====================================================================== gr_ma = 'Optional MA\'s' t_ma1 = 'MA #1' t_ma2 = 'MA #2' show_ma1 = input.bool(false, t_ma1, inline=t_ma1, group=gr_ma) ma1_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma1, group=gr_ma) ma1_source = input.source(close, '', inline=t_ma1, group=gr_ma) ma1_length = input.int(50, '', minval=1, inline=t_ma1, group=gr_ma) ma1_color = #9c27b0 ma1 = f_ma(ma1_source, ma1_length, ma1_type) plot(show_ma1 ? ma1 : na, color=color.new(ma1_color, 0), title=t_ma1, linewidth=1) show_ma2 = input.bool(false, t_ma2, inline=t_ma2, group=gr_ma) ma2_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma2, group=gr_ma) ma2_source = input.source(close, '', inline=t_ma2, group=gr_ma) ma2_length = input.int(100, '', minval=1, inline=t_ma2, group=gr_ma) ma2_color = #1163f6 ma2 = f_ma(ma2_source, ma2_length, ma2_type) plot(show_ma2 ? ma2 : na, color=color.new(ma2_color, 0), title=t_ma2, linewidth=1)
Hammer / Shooting Star Scanner
https://www.tradingview.com/script/9vLoGLK4-Hammer-Shooting-Star-Scanner/
Hampeh
https://www.tradingview.com/u/Hampeh/
161
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Hampeh //@version=5 indicator(title="Hammer / Shooting Star Scanner", shorttitle="HSS Scanner", overlay=true) csbody = math.abs(close - open) bodyshadowratio = input(title="Minimum Ratio Shadow Over Body", defval=2.0) //scanner algorithms hammervalid() => (close[1] >= close and open[1] >= close) and (close[1] >= open and open[1] >= open) ? true : false shootingstarvalid() => (close[1] <= close and open[1] <= close) and (close[1] <= open and open[1] <= open) ? true : false hammer = hammervalid() and (csbody > 0) and (((close == high) and math.abs(open - low) > csbody * bodyshadowratio) or ((open == high) and math.abs(close - low) > csbody * bodyshadowratio)) shootingstar = shootingstarvalid() and (csbody > 0) and (((close == low) and math.abs(open - high) > csbody * bodyshadowratio) or ((open == low) and math.abs(close - high) > csbody * bodyshadowratio)) //chart plotters plotshape(hammer, style=shape.arrowup, location=location.belowbar, color=color.green, text='H') plotshape(shootingstar, style=shape.arrowdown, location=location.abovebar, color=color.red, text='SS') alertcondition(shootingstar, title = "Alert Hammer / Shooting Star", message = 'ALERT : SHOOTING STAR DETECTED') alertcondition(hammer, title = "Alert Hammer / Shooting Star", message = 'ALERT : HAMMER STAR DETECTED')
[H] Multi Coin Compare
https://www.tradingview.com/script/q99miZGB-H-Multi-Coin-Compare/
UnknownUnicorn17545852
https://www.tradingview.com/u/UnknownUnicorn17545852/
65
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Hermetism // Some Credits to @Violent and @HomelessLemon //@version=5 indicator(title='[H] Compare', shorttitle='[H] Compare', overlay=true) t = input.bool(true, title='Show Table', group='Table', tooltip='Show the table') tablePositionY = input.string('top', title='Y-Position', options=['top', 'middle', 'bottom'], group="Table", inline="1") tablePositionX = input.string('right', title='X-Position', options=['left', 'center', 'right'], group="Table", inline="1") var table dataTable = table.new(tablePositionY + '_' + tablePositionX, 1, 5, border_width=7) //////////////////////////////////////////////////////////////////////////////// // Compare //////////////////////////////////////////////////////////////////////////////// int compareNumber = input.int(3, maxval=5, title='Number of Comparisons', tooltip='Maximum of 5') compareSym = input.symbol('BINANCE:SHIBUSDT', 'Compare Symbol', group="Coin One") compareRes = input.timeframe('60', 'Timeframe', group="Coin One") compareMult = input.bool(title='Multiply', defval=true, tooltip='If the coin you are comparing has a lower price than the main symbol you will need to multiply instead of divide', group="Coin One") compareDiv = input.float(1397367240.7179794, 'Divider', minval=1, step=0.1, tooltip='The amount to divide the current price for the comparison', group="Coin One") compareColor = input(title='Compare Color', defval=#ff9800, group="Coin One") compareSource = input.source(close, "Source", group="Coin One") comparePrice = request.security(compareSym, compareRes, compareSource) compareSym1 = input.symbol('BINANCE:LTCUSDT', 'Compare Symbol', group="Coin Two") compareRes1 = input.timeframe('60', 'Timeframe', group="Coin Two") compareMult1 = input.bool(title='Multiply', defval=true, tooltip='If the coin you are comparing has a lower price than the main symbol you will need to multiply instead of divide', group="Coin Two") compareDiv1 = input.float(290.9133288227, 'Divider', minval=1, step=0.1, tooltip='The amount to divide the current price for the comparison', group="Coin Two") compareColor1 = input(title='Compare Color', defval=#3179f5, group="Coin Two") compareSource1 = input.source(close, "Source", group="Coin Two") comparePrice1 = request.security(compareSym1, compareRes1, compareSource1) compareSym2 = input.symbol('BINANCE:ETHUSDT', 'Compare Symbol', group="Coin Three") compareRes2 = input.timeframe('60', 'Timeframe', group="Coin Three") compareMult2 = input.bool(title='Multiply', defval=true, tooltip='If the symbol you are comparing has a lower price than the main symbol you will need to multiply instead of divide', group="Coin Three") compareDiv2 = input.float(12.9467280124, 'Divider', minval=1, step=0.1, tooltip='The amount to divide the current price for the comparison', group="Coin Three") compareColor2 = input(title='Compare Color', defval=#ab47bc, group="Coin Three") compareSource2 = input.source(close, "Source", group="Coin Three") comparePrice2 = request.security(compareSym2, compareRes2, compareSource2) compareSym3 = input.symbol('BINANCE:DOGEUSDT', 'Compare Symbol', group="Coin Four") compareRes3 = input.timeframe('60', 'Timeframe', group="Coin Four") compareMult3 = input.bool(title='Multiply', defval=true, tooltip='If the symbol you are comparing has a lower price than the main symbol you will need to multiply instead of divide', group="Coin Four") compareDiv3 = input.float(236637.259218492, 'Divider', minval=1, step=0.1, tooltip='The amount to divide the current price for the comparison', group="Coin Four") compareColor3 = input(title='Compare Color', defval=#ffeb3b, group="Coin Four") compareSource3 = input.source(close, "Source", group="Coin Four") comparePrice3 = request.security(compareSym3, compareRes3, compareSource3) compareSym4 = input.symbol('BINANCE:DOTUSDT', 'Compare Symbol', group="Coin Five") compareRes4 = input.timeframe('60', 'Timeframe', group="Coin Five") compareMult4 = input.bool(title='Multiply', defval=true, tooltip='If the symbol you are comparing has a lower price than the main symbol you will need to multiply instead of divide', group="Coin Five") compareDiv4 = input.float(741071.8717683557, 'Divider', minval=1, step=0.1, tooltip='The amount to divide the current price for the comparison', group="Coin Five") compareColor4 = input(title='Compare Color', defval=#26c6da, group="Coin Five") compareSource4 = input.source(close, "Source", group="Coin Five") comparePrice4 = request.security(compareSym4, compareRes4, compareSource4) plot(compareMult ? compareNumber >= 1 ? comparePrice * compareDiv : na : compareNumber >= 1 ? comparePrice / compareDiv : na, '[1] Compare Price', color=compareColor, style=plot.style_stepline, linewidth=2) plot(compareMult1 ? compareNumber >= 2 ? comparePrice1 * compareDiv1 : na : compareNumber >= 2 ? comparePrice1 / compareDiv1 : na, '[2] Compare Price', color=compareColor1, style=plot.style_stepline, linewidth=2) plot(compareMult2 ? compareNumber >= 3 ? comparePrice2 * compareDiv2 : na : compareNumber >= 3 ? comparePrice2 / compareDiv2 : na, '[3] Compare Price', color=compareColor2, style=plot.style_stepline, linewidth=2) plot(compareMult3 ? compareNumber >= 4 ? comparePrice3 * compareDiv3 : na : compareNumber >= 4 ? comparePrice3 / compareDiv3 : na, '[4] Compare Price', color=compareColor3, style=plot.style_stepline, linewidth=2) plot(compareMult4 ? compareNumber >= 5 ? comparePrice4 * compareDiv4 : na : compareNumber >= 5 ? comparePrice4 / compareDiv4 : na, '[5] Compare Price', color=compareColor4, style=plot.style_stepline, linewidth=2) //////////////////////////////////////////////////////////////////////////////// // Output //////////////////////////////////////////////////////////////////////////////// if barstate.islast and t==true and compareNumber>0 compareText = compareSym + " " + str.tostring(comparePrice, format="0.##########") compareText1 = compareSym1 + " " + str.tostring(comparePrice1, format="0.##########") compareText2 = compareSym2 + " " + str.tostring(comparePrice2, format="0.##########") compareText3 = compareSym3 + " " + str.tostring(comparePrice3, format="0.##########") compareText4 = compareSym4 + " " + str.tostring(comparePrice4, format="0.##########") tableBgColor = input(color.rgb(120, 123, 134, 85), "Table Background Color", group="Table") if(compareNumber>=1) table.cell(dataTable, 0, 0, text=compareText, bgcolor=tableBgColor, text_color=compareColor) if(compareNumber>=2) table.cell(dataTable, 0, 1, text=compareText1, bgcolor=tableBgColor, text_color=compareColor1) if(compareNumber>=3) table.cell(dataTable, 0, 2, text=compareText2, bgcolor=tableBgColor, text_color=compareColor2) if(compareNumber>=4) table.cell(dataTable, 0, 3, text=compareText3, bgcolor=tableBgColor, text_color=compareColor3) if(compareNumber>=5) table.cell(dataTable, 0, 4, text=compareText4, bgcolor=tableBgColor, text_color=compareColor4)
PA Trading v1
https://www.tradingview.com/script/MxlI2kNM/
ortakyer
https://www.tradingview.com/u/ortakyer/
90
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/ // © ortakyer //@version=4 study("PA Trading v1",overlay=true) fark = time-time[1] offset = input(26, title="Çizgi Uzunlukları") //Günlük, haftalık ve aylık zaman dilimlerinden bilgi çekemi [gZaman,gAcilis] = security(syminfo.tickerid, "D", [time,open]) [hZaman,hAcilis] = security(syminfo.tickerid, "W", [time,open]) [aZaman,aAcilis,aEnYuksek,aEnDusuk] = security(syminfo.tickerid, "M", [time,open,high,low]) [hZamanOnceki,hAcilisOnceki] = security(syminfo.tickerid, "W", [time[1],open[1]]) [aZamanOnceki,aAcilisOnceki,aEnYuksekOnceki,aEnDusukOnceki] = security(syminfo.tickerid, "M", [time[1],open[1],high[1],low[1]]) var market_open_day_of_week = input(title="Açılış Günü Seçin", type=input.string, options=["Monday"], defval="Monday") // Some exchanges open sunday evening vs crypto std monday monday_open_time = security(syminfo.tickerid, "D", time("D"), lookahead = barmerge.lookahead_on) monday_high = security(syminfo.tickerid, "D", high, lookahead = barmerge.lookahead_on) monday_low = security(syminfo.tickerid, "D", low, lookahead = barmerge.lookahead_on) monday_midpoint = avg(monday_high, monday_low) monday = input(#007FFF, "Monday", type = input.color, group = "Çizgi Renkleri", inline="a") is_monday() => dayofweek(time("D")) == (market_open_day_of_week == "Sunday" ? dayofweek.sunday : dayofweek.monday) and close ? true : false var can_show_monday_range = not timeframe.isweekly and not timeframe.ismonthly and not timeframe.isseconds // dont show above daily or below minutes // Calculate the bars until the end of the week // timeframe.multiplier is either daily or minutes bars_until_end_of_week = if timeframe.isdaily 7 else (1440 / timeframe.multiplier) * 7 // (mins in day / multiplier) * days in a week line_end_right = monday_open_time + (time - time[1]) * bars_until_end_of_week // try and extend line until the end of the week if is_monday() // Monday high monday_high_text = "Monday High " var monday_high_line = line.new(x1 = monday_open_time, x2 = line_end_right, y1 = monday_high, y2 = monday_high, color = monday, width = 1, xloc = xloc.bar_time) var monday_high_label = label.new(x = line_end_right, y = monday_open_time, text = monday_high_text, style=label.style_label_left,color=color.new(color.black,100), textcolor = monday, size = size.small, xloc = xloc.bar_time) line.set_x1(monday_high_line, monday_open_time) line.set_x2(monday_high_line, line_end_right) line.set_y1(monday_high_line, monday_high) line.set_y2(monday_high_line, monday_high) label.set_x(monday_high_label, line_end_right) label.set_y(monday_high_label, monday_high) // Monday low monday_low_text = "Monday Low " var monday_low_line = line.new(x1 = monday_open_time, x2 = line_end_right, y1 = monday_low, y2 = monday_low, color = monday, width = 1, xloc = xloc.bar_time) var monday_low_label = label.new(x = line_end_right, y = monday_open_time, text = monday_low_text, style=label.style_label_left,color=color.new(color.black,100), textcolor = monday, size = size.small, xloc = xloc.bar_time) line.set_x1(monday_low_line, monday_open_time) line.set_x2(monday_low_line, line_end_right) line.set_y1(monday_low_line, monday_low) line.set_y2(monday_low_line, monday_low) label.set_x(monday_low_label, line_end_right) label.set_y(monday_low_label, monday_low) //Günlük açılış gunlukCizgiRengi= input(color.orange, group = "Çizgi Renkleri", inline="a", title="DO") gunlukCizgiUzunlugu = input(defval = 1, title="DO", group = "Çizgi Kalınlıkları", tooltip="Çizgi Kalınlığı Giriniz",minval = 1, maxval = 4) gAcilisCizgi = line.new(gZaman, gAcilis,time+(offset*fark),gAcilis,xloc=xloc.bar_time,width=gunlukCizgiUzunlugu,color=gunlukCizgiRengi) line.delete(gAcilisCizgi[1]) gAcilisEtiket = label.new(time+(offset*fark), gAcilis,xloc=xloc.bar_time,text="DO",textcolor=color.orange, tooltip=tostring(gAcilis),style=label.style_label_left,color=color.new(color.black,100)) label.delete(gAcilisEtiket[1]) //Haftalık açılış haftalikCizgiRengi= input(color.orange, group = "Çizgi Renkleri",inline="a", title="WO") haftalikCizgiUzunlugu = input(defval = 1, title="WO", group = "Çizgi Kalınlıkları" ,tooltip="Çizgi Kalınlığı Giriniz",minval = 1, maxval = 4) hAcilisCizgi = line.new(hZaman, hAcilis,time+(offset*fark),hAcilis,xloc=xloc.bar_time,width=haftalikCizgiUzunlugu,color=haftalikCizgiRengi) line.delete(hAcilisCizgi[1]) ghaftalikCizgiRengi= input(color.blue, group = "Çizgi Renkleri",inline="b", title="PWO") ghaftalikCizgiUzunlugu = input(defval = 1, title="PWO", group = "Çizgi Kalınlıkları",tooltip="Çizgi Kalınlığı Giriniz", minval = 1, maxval = 4) ghAcilisCizgi = line.new(hZamanOnceki, hAcilisOnceki,time+(offset*fark),hAcilisOnceki, xloc=xloc.bar_time, width=ghaftalikCizgiUzunlugu, color=ghaftalikCizgiRengi) line.delete(ghAcilisCizgi[1]) hAcilisEtiket = label.new(time+(offset*fark), hAcilis,xloc=xloc.bar_time,text="WO",textcolor=color.orange,tooltip=tostring(hAcilis),style=label.style_label_left,color=color.new(color.black,100)) label.delete(hAcilisEtiket[1]) ghAcilisEtiket = label.new(time+(offset*fark), hAcilisOnceki,xloc=xloc.bar_time,text="PWO",textcolor=color.blue,tooltip=tostring(hAcilisOnceki),style=label.style_label_left,color=color.new(color.black,100)) label.delete(ghAcilisEtiket[1]) //Aylık açılış aylikcizgirengi = input(color.orange, group = "Çizgi Renkleri",inline="a", title="MO") aylikcizgiuzunlugu = input(defval = 1, title="MO", group = "Çizgi Kalınlıkları" , tooltip="Çizgi Kalınlığı Giriniz",minval = 1, maxval = 4) aAcilisCizgi = line.new(aZaman, aAcilis,time+(offset*fark),aAcilis,xloc=xloc.bar_time,width=aylikcizgiuzunlugu,color=aylikcizgirengi) line.delete(aAcilisCizgi[1]) paylikCizgiRengi = input(color.blue, group = "Çizgi Renkleri",inline="b", title="PMO") paylikCizgiUzunlugu = input(defval = 1, title="PMO", group = "Çizgi Kalınlıkları" , tooltip="Çizgi Kalınlığı Giriniz",minval = 1, maxval = 4) gaAcilisCizgi = line.new(aZamanOnceki, aAcilisOnceki,time+(offset*fark),aAcilisOnceki,xloc=xloc.bar_time,width=paylikCizgiUzunlugu,color=paylikCizgiRengi) line.delete(gaAcilisCizgi[1]) aAcilisEtiket = label.new(time+(offset*fark), aAcilis,xloc=xloc.bar_time,text="MO",textcolor=color.orange , tooltip=tostring(aAcilis),style=label.style_label_left,color=color.new(color.black,100)) label.delete(aAcilisEtiket[1]) gaAcilisEtiket =label.new(time+(offset*fark), aAcilisOnceki,xloc=xloc.bar_time,text="PMO",textcolor=color.blue , tooltip=tostring(aAcilisOnceki),style=label.style_label_left,color=color.new(color.black,100)) label.delete(gaAcilisEtiket[1])
[Multi-layers][VDT]
https://www.tradingview.com/script/G33jC16u/
FCCMTT92
https://www.tradingview.com/u/FCCMTT92/
14
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © FCCMTT92 //@version=5 // indicator(title="[Multi-layers][VDT]", shorttitle="[Multi-layers][VDT]", overlay=true) // //****************************************************************************** // Ichimoku Cloud //****************************************************************************** // ichi_enable = input.bool(defval=true, title="Ichimoku Cloud Enable") conversionPeriods = input.int(9, minval=1, title="Conversion Line Length") basePeriods = input.int(26, minval=1, title="Base Line Length") laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length") displacement = input.int(26, minval=1, title="Displacement") donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = math.avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) plot(ichi_enable ? conversionLine : na, color=#2962FF, title="Conversion Line") plot(ichi_enable ? baseLine: na, color=#B71C1C, title="Base Line") plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span") p1 = plot(ichi_enable ? leadLine1 : na, offset = displacement - 1, color=#00FF00, title="Leading Span A") p2 = plot(ichi_enable ? leadLine2 : na, offset = displacement - 1, color=#FF0000, title="Leading Span B") fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90)) // //****************************************************************************** // EMA //****************************************************************************** // //ema_enable = input.bool(defval=true, title="EMA Enable all") enb1 = input.bool(defval=true, title="EMA1 Enable") len1 = input.int(7, minval=1, title="Length_EMA1") src1 = input(close, title="Source_EMA1") out1 = ta.ema(src1, len1) plot (enb1 ? out1 : na , title="EMA1", color=#FF8C00) enb2 = input.bool(defval=true, title="EMA2 Enable") len2 = input.int(60, minval=1, title="Length_EMA2") src2 = input(close, title="Source_EMA2") out2 = ta.ema(src1, len2) plot (enb2 ? out2 : na, title="EMA2", color=#FF1493) enb3 = input.bool(defval=true, title="EMA3 Enable") len3 = input.int(200, minval=1, title="Length_EMA3") src3 = input(close, title="Source_EMA3") out3 = ta.ema(src3, len3) plot (enb3 ? out3 : na, title="EMA3", color=#9400D3) // //****************************************************************************** // SMA //****************************************************************************** // enb4 = input.bool(defval=true, title="SMA1 Enable") len4 = input.int(20, minval=1, title="Length_SMA1") src4 = input(close, title="Source_SMA1") out4 = ta.sma(src4, len4) plot (enb4 ? out4 : na, title="SMA1", color=#DEB887) enb5 = input.bool(defval=true, title="SMA2 Enable") len5 = input.int(50, minval=1, title="Length_SMA2") src5 = input(close, title="Source_SMA2") out5 = ta.sma(src5, len5) plot (enb5 ? out5 : na, title="SMA2", color=#FFB6C1) enb6 = input.bool(defval=true, title="SMA3 Enable") len6 = input.int(200, minval=1, title="Length_SMA3") src6 = input(close, title="Source_EMA3") out6 = ta.sma(src6, len6) plot (enb6 ? out6 : na, title="SMA3", color=#DDA0DD) //END
isamuch - 2MA Cross and Stop Loss
https://www.tradingview.com/script/jzBrYkw7-isamuch-2MA-Cross-and-Stop-Loss/
muchinw
https://www.tradingview.com/u/muchinw/
22
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SamSignal //@version=4 study("isamuch - 2MA Cross and Stop Loss", overlay=true, max_bars_back=999, max_labels_count=500) // ==================== // Global Variable // ==================== src = input(close, title = "Data Source") // ==================== // MA Cross // ==================== type = input(title = "Moving Average Type", defval = "EMA", options = ["SMA", "EMA", "WMA"]) fastLength = input(12, title = "Fast Length") slowLength = input(26, title = "Slow Length") float fastMa = na float slowMa = na if(type == "SMA") fastMa := sma(src, fastLength) slowMa := sma(src, slowLength) else if (type == "EMA") fastMa := ema(src, fastLength) slowMa := ema(src, slowLength) else fastMa := wma(src, fastLength) slowMa := wma(src, slowLength) fastL = plot(fastMa, title="Fast Ma", color=color.green, linewidth=1) slowL = plot(slowMa, title="Slow Ma", color=color.red, linewidth=1) plot(crossunder(slowMa, fastMa) ? fastMa : na, style = plot.style_cross, color=color.blue, linewidth = 3) plot(crossover(slowMa, fastMa) ? fastMa : na, style = plot.style_cross, color=color.red, linewidth = 3) fillcolor = fastMa > slowMa ? color.green : color.red fill(fastL,slowL,fillcolor) // ==================== // Stop Loss // ==================== previousBearBar = 1 for i=1 to 999 if fastMa[i] > slowMa[i] previousBearBar := i break lowestPrice = lowest(low, previousBearBar) previousBullBar = 1 for i=1 to 999 if fastMa[i] < slowMa[i] previousBullBar := i break highestPrice = highest(high, previousBullBar) // ==================== // Function // ==================== getMsg(title, entryPrice, stopLoss, risk) => msg = "Entry Price: " + tostring(entryPrice, "#,###.########") + "\nStop Loss: " + tostring(stopLoss, "#,###.#######") + "\n(" + tostring(risk, "#.##") + "%)" getMsgExitPrice(exitPrice) => msg = "Exit Price: " + tostring(exitPrice, "#,###.#####") // ==================== // Position Type // ==================== positionType = input(title="Position Type", type=input.string, defval="long", options=["long", "short", "long & short"]) // ==================== // Calculate // ==================== if crossover(fastMa, slowMa) if positionType == "long" or positionType == "long & short" msg = getMsg("BUY", close, lowestPrice, (((lowestPrice * 100) / close ) - 100)) buyLabel = label.new(bar_index, close, text=msg, color=color.navy, textcolor=color.white, style=label.style_label_up, yloc=yloc.belowbar) alert(msg, alert.freq_once_per_bar_close) else msg = getMsgExitPrice(close) buyLabel = label.new(bar_index, close, text=msg, color=color.black, textcolor=color.white, style=label.style_label_up, yloc=yloc.belowbar) alert(msg, alert.freq_once_per_bar_close) if crossunder(fastMa, slowMa) if positionType == "short" or positionType == "long & short" msg = getMsg("SELL", close, highestPrice, (((close * 100) / highestPrice ) - 100)) sellLabel = label.new(bar_index, close, text=msg, color=color.olive, textcolor=color.white, style=label.style_label_down, yloc=yloc.abovebar) alert(msg, alert.freq_once_per_bar_close) else msg = getMsgExitPrice(close) sellLabel = label.new(bar_index, close, text=msg, color=color.black, textcolor=color.white, style=label.style_label_down, yloc=yloc.abovebar) alert(msg, alert.freq_once_per_bar_close)
Manual Harmonic Patterns - With interactive inputs
https://www.tradingview.com/script/hjjizROg-Manual-Harmonic-Patterns-With-interactive-inputs/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
2,256
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("Manual Harmonic Patterns - With interactive inputs", overlay=true) import HeWhoMustNotBeNamed/eHarmonicpatternsExtended/6 as hp import HeWhoMustNotBeNamed/utils/1 as pa x = input.price(0,'X',group='XABCD', inline= '1', confirm=true) xBarTime = input.time(0,'',group='XABCD', inline= '1', confirm=true) a = input.price(0,'A',group='XABCD', inline= '2', confirm=true) aBarTime = input.time(0,'',group='XABCD', inline= '2', confirm=true) b = input.price(0,'B',group='XABCD', inline= '3', confirm=true) bBarTime = input.time(0,'',group='XABCD', inline= '3', confirm=true) c = input.price(0,'C',group='XABCD', inline= '4', confirm=true) cBarTime = input.time(0,'',group='XABCD', inline= '4', confirm=true) d = input.price(0,'D',group='XABCD', inline= '5', confirm=true) dBarTime = input.time(0,'',group='XABCD', inline= '5', confirm=true) showXABCD = input.bool(true, title='Show XABCD', group='Display', inline='showHide') showRatios = input.bool(true, title='Show Ratios', group='Display', inline='showHide') fillMajorTriangles = input.bool(true, title="Fill XAB/BCD", group="Display", inline="fill1") majorFillTransparency = input.int(70, step=5, title="", group="Display", inline="fill1") fillMinorTriangles = input.bool(true, title="Fill ABC/XBD", group="Display", inline="fill2") minorFillTransparency = input.int(90, step=5, title="", group="Display", inline="fill2") errorPercent = input.int(8, group="Miscellaneous") przType = input.string("XAD Range", "PRZ Type", options=["XAD Range", "BCD+XAD Range"], group='Miscellaneous') useCombinedPrz = (przType == "BCD+XAD Range") patternColor = input.color(color.purple, group="Miscellaneous") classic = input.bool(true, title="Classic Patterns", group="Category", inline="ca") anti = input.bool(true, title="Anti/Alternate Patterns", group="Category", inline="ca") nonStandard = input.bool(true, title="Nonstandard", group="Category", inline="ca") gartley = input.bool(true, title='Gartley       ', group='Classic Patterns', inline="c1") bat = input.bool(true, title='Bat      ', group='Classic Patterns', inline="c1") butterfly = input.bool(true, title='Butterfly   ', group='Classic Patterns', inline="c1") crab = input.bool(true, title='Crab', group='Classic Patterns', inline="c1") deepCrab = input.bool(true, title='Deep Crab   ', group='Classic Patterns', inline="c2") cypher = input.bool(true, title='Cypher   ', group='Classic Patterns', inline="c2") shark = input.bool(true, title='Shark      ', group='Classic Patterns', inline="c2") nenStar = input.bool(true, title='Nenstar', group='Classic Patterns', inline="c2") antiNenStar = input.bool(true, title='Anti Nenstar   ', group='Anti Patterns', inline="a1") antiShark = input.bool(true, title='Anti Shark', group='Anti Patterns', inline="a1") antiCypher = input.bool(true, title='Anti Cypher ', group='Anti Patterns', inline="a1") antiCrab = input.bool(true, title='Anti Crab', group='Anti Patterns', inline="a1") antiButterfly = input.bool(true, title='Anti Butterfly', group='Anti Patterns', inline="a2") antiBat = input.bool(true, title='Anti Bat  ', group='Anti Patterns', inline="a2") antiGartley = input.bool(true, title='Anti Gartley', group='Anti Patterns', inline="a2") navarro200 = input.bool(true, title='Navarro 200', group='Anti Patterns', inline="a2") fiveZero = input.bool(true, title='Five Zero', group='Non Standard', inline="a1") threeDrives = input.bool(true, title='Three Drives', group='Non Standard', inline="a1") whiteSwann = input.bool(true, title='White Swann', group='Non Standard', inline="a1") blackSwann = input.bool(true, title='Black Swann', group='Non Standard', inline="a1") seaPony = input.bool(true, title='Sea Pony', group='Non Standard', inline="a2") leonardo = input.bool(true, title='Leonardo', group='Non Standard', inline="a2") oneTwoOne = input.bool(true, title='121', group='Non Standard', inline="a2") snorm = input.bool(true, title='Snorm', group='Non Standard', inline="a2") totalPattern = input.bool(true, title='Total', group='Non Standard', inline="a2") NUMBER_OF_PATTERNS = 25 enableGartley = classic and gartley enableBat = classic and bat enableButterfly = classic and butterfly enableCrab = classic and crab enableDeepCrab = classic and deepCrab enableCypher = classic and cypher enableShark = classic and shark enableNenStar = classic and nenStar enableAntiNenStar = anti and antiNenStar enableAntiShark = anti and antiShark enableAntiCypher = anti and antiCypher enableAntiCrab = anti and antiCrab enableAntiButterfly = anti and antiButterfly enableAntiBat = anti and antiBat enableAntiGartley = anti and antiGartley enableNavarro200 = anti and navarro200 enableFiveZero = nonStandard and fiveZero enableThreeDrives = nonStandard and threeDrives enableWhiteSwann = nonStandard and whiteSwann enableBlackSwann = nonStandard and blackSwann enableSeaPony = nonStandard and seaPony enableLeonardo = nonStandard and leonardo enableOneTwoOne = nonStandard and oneTwoOne enableSnorm = nonStandard and snorm enableTotal = nonStandard and totalPattern flags = array.new_bool() array.push(flags, enableGartley) array.push(flags, enableCrab) array.push(flags, enableDeepCrab) array.push(flags, enableBat) array.push(flags, enableButterfly) array.push(flags, enableShark) array.push(flags, enableCypher) array.push(flags, enableNenStar) array.push(flags, enableAntiNenStar) array.push(flags, enableAntiShark) array.push(flags, enableAntiCypher) array.push(flags, enableAntiCrab) array.push(flags, enableAntiButterfly) array.push(flags, enableAntiBat) array.push(flags, enableAntiGartley) array.push(flags, enableNavarro200) array.push(flags, enableFiveZero) array.push(flags, enableThreeDrives) array.push(flags, enableWhiteSwann) array.push(flags, enableBlackSwann) array.push(flags, enableSeaPony) array.push(flags, enableLeonardo) array.push(flags, enableOneTwoOne) array.push(flags, enableSnorm) array.push(flags, enableTotal) get_prz_range(x, a, b, c, patterns, errorPercent, prc_entry=0, prc_stop=0)=> [boxStart, boxEnd] = if useCombinedPrz hp.get_prz_range(x, a, b, c, patterns, errorPercent, prc_entry, prc_stop) else hp.get_prz_range_xad(x, a, b, c, patterns, errorPercent, prc_entry, prc_stop) [boxStart, boxEnd] f_draw_pattern_line(y1, y2, x1, x2, lineColor, width, style) => targetLine = line.new(y1=y1, y2=y2, x1=x1, x2=x2, color=lineColor, width=width, style=style) targetLine f_draw_pattern_label(y, x, txt, textcolor, style, yloc, size) => targetLabel = label.new(y=y, x=x, text=txt, textcolor=textcolor, style=style, yloc=yloc, size=size) targetLabel draw_xabcd(x, a, b, c, d, xBar, aBar, bBar, cBar, dBar, dir, labelColor, patterns) => hasPatterns = array.includes(patterns, true), isCypher = array.get(patterns, 6) xa = f_draw_pattern_line(y1=x, y2=a, x1=xBar, x2=aBar, lineColor=labelColor, width=1, style=line.style_solid) ab = f_draw_pattern_line(y1=a, y2=b, x1=aBar, x2=bBar, lineColor=labelColor, width=1, style=line.style_solid) bc = f_draw_pattern_line(y1=b, y2=c, x1=bBar, x2=cBar, lineColor=labelColor, width=1, style=line.style_solid) cd = f_draw_pattern_line(y1=c, y2=d, x1=cBar, x2=dBar, lineColor=labelColor, width=1, style=line.style_solid) xb = f_draw_pattern_line(y1=x, y2=b, x1=xBar, x2=bBar, lineColor=labelColor, width=1, style=line.style_dashed) bd = f_draw_pattern_line(y1=b, y2=d, x1=bBar, x2=dBar, lineColor=labelColor, width=1, style=line.style_dashed) ac = f_draw_pattern_line(y1=a, y2=c, x1=aBar, x2=cBar, lineColor=labelColor, width=1, style=line.style_dotted) xd = f_draw_pattern_line(y1=x, y2=d, x1=xBar, x2=dBar, lineColor=labelColor, width=1, style=line.style_dotted) if(fillMajorTriangles and hasPatterns) xaab = linefill.new(xa, ab, color.new(labelColor, majorFillTransparency)) xbab = linefill.new(xb, ab, color.new(labelColor, majorFillTransparency)) bccd = linefill.new(bc, cd, color.new(labelColor, majorFillTransparency)) bdcd = linefill.new(bd, cd, color.new(labelColor, majorFillTransparency)) if(fillMinorTriangles and hasPatterns) abbc = linefill.new(ab, bc, color.new(labelColor, minorFillTransparency)) acbc = linefill.new(ac, bc, color.new(labelColor, minorFillTransparency)) xbbd = linefill.new(xb, bd, color.new(labelColor, minorFillTransparency)) xdbd = linefill.new(xd, bd, color.new(labelColor, minorFillTransparency)) if showXABCD gap = ta.tr/10 xLabel = f_draw_pattern_label(y=(dir>0?x-gap:x+gap), x=xBar, txt='X', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) aLabel = f_draw_pattern_label(y=(dir>0?a+gap:a-gap), x=aBar, txt='A', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) bLabel = f_draw_pattern_label(y=(dir>0?b-gap:b+gap), x=bBar, txt='B', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) cLabel = f_draw_pattern_label(y=(dir>0?c+gap:c-gap), x=cBar, txt='C', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) dLabel = f_draw_pattern_label(y=(dir>0?d-gap:d+gap), x=dBar, txt='D', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) if showRatios xabRatio = math.round(math.abs(a - b) / math.abs(x - a), 3) xabRatioBar = (xBar + bBar) / 2 abcRatio = math.round(math.abs(b - c) / math.abs(a - b), 3) abcRatioBar = (aBar + cBar) / 2 bcdRatio = math.round(math.abs(c - d) / math.abs(b - c), 3) bcdRatioBar = (bBar + dBar) / 2 xadRatio = math.round(math.abs(a - d) / math.abs(x - a), 3) xadRatioBar = (xBar + dBar) / 2 axcRatio = math.round(math.abs(x - c) / math.abs(x - a), 3) xcdRatio = math.round(math.abs(d - c) / math.abs(x - c), 3) xabRatioPrice = line.get_price(xb, xabRatioBar) abcRatioPrice = line.get_price(ac, abcRatioBar) bcdRatioPrice = line.get_price(bd, bcdRatioBar) xadRatioPrice = line.get_price(xd, xadRatioBar) abcRatioLabelText = str.tostring(abcRatio) + '(ABC)' + (isCypher ? '\n' + str.tostring(axcRatio) + '(AXC)' : '') xadRatioLabelText = str.tostring(xadRatio) + '(XAD)' + (isCypher ? '\n' + str.tostring(xcdRatio) + '(XCD)' : '') xabLabel = f_draw_pattern_label(y=xabRatioPrice, x=xabRatioBar, txt=str.tostring(xabRatio) + '(XAB)', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) abcLabel = f_draw_pattern_label(y=abcRatioPrice, x=abcRatioBar, txt=abcRatioLabelText, textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) bcdLabel = f_draw_pattern_label(y=bcdRatioPrice, x=bcdRatioBar, txt=str.tostring(bcdRatio) + '(BCD)', textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) xadLabel = f_draw_pattern_label(y=xadRatioPrice, x=xadRatioBar, txt=xadRatioLabelText, textcolor=labelColor, style=label.style_none, yloc=yloc.price, size=size.small) f_draw_entry_box(y1, y2, x1, linecolor, labelColor, labelText) => x2 = x1 + 20 y = (y1 + y2) / 2 xloc = xloc.bar_index transp = 70 entryBox = box.new(x1, y1, x2, y2, linecolor, 1, line.style_dotted, xloc=xloc, bgcolor=color.new(labelColor, transp), text=labelText, text_color=labelColor, text_size=size.small) var printed = false patternLabels = hp.getSupportedPatterns() if(barstate.islast and not printed) patterns = hp.isHarmonicPattern(x, a, b, c, d, flags, errorPercent = errorPercent) int xBar = na int aBar = na int bBar = na int cBar = na int dBar = na offset = 0 while(na(xBar) or na(aBar) or na(bBar) or na(cBar) or na(dBar)) bartime = time[offset] if(na(xBar) and bartime == xBarTime) xBar := bar_index - offset if(na(aBar) and bartime == aBarTime) aBar := bar_index - offset if(na(bBar) and bartime == bBarTime) bBar := bar_index - offset if(na(cBar) and bartime == cBarTime) cBar := bar_index - offset if(na(dBar) and bartime == dBarTime) dBar := bar_index - offset offset+=1 dir = c > d? 1 : -1 draw_xabcd(x, a, b, c, d, xBar, aBar, bBar, cBar, dBar, dir, patternColor, patterns) [dStart, dEnd] = get_prz_range(x, a, b, c, patterns, errorPercent) lbl = pa.getConsolidatedLabel(patterns, patternLabels) f_draw_entry_box(dStart, dEnd, dBar+5, patternColor, patternColor, lbl) printed := true
Pi Price Levels
https://www.tradingview.com/script/cqMgfKa0-Pi-Price-Levels/
fvideira
https://www.tradingview.com/u/fvideira/
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/ // © fvideira //@version=5 indicator("Pi Price Levels", overlay=true) // Study of Pi levels from Eliza123123's quantative trading series: https://youtu.be/S7UMA__wz74 // Pi Const. piStd = input.bool(true, "Standard Multiples", group = "Pi Constant 3.14159") piPrime = input(true, "Prime Multiples", group = "Pi Constant 3.14159") piMulti = input(true, "Multiples of 10", group = "Pi Constant 3.14159") // Scale Factors & Constants scale = 0.0 if close >= 10000 scale := 1000 if close >= 1000 and close <=9999.999999 scale := 100 if close >= 100 and close <=999.999999 scale := 10 if close >= 10 and close <=99.999999 scale := 1 if close >= 1 and close <=9.999999 scale := 0.1 if close >= 0.1 and close <=0.999999 scale := 0.01 if close >= 0.01 and close <=0.099999 scale := 0.001 if close >= 0.001 and close <=0.009999 scale := 0.0001 // Variables pi = 3.14159 * scale pi1 = 0.0 pi2 = 0.0 pi3 = 0.0 pi4 = 0.0 pi5 = 0.0 pi6 = 0.0 pi7 = 0.0 pi8 = 0.0 pi9 = 0.0 pi10 = 0.0 pi11 = 0.0 pi12 = 0.0 pi13 = 0.0 pi14 = 0.0 pi15 = 0.0 pi16 = 0.0 pi17 = 0.0 pi18 = 0.0 pi19 = 0.0 pi20 = 0.0 pi21 = 0.0 pi22 = 0.0 pi23 = 0.0 pi24 = 0.0 pi25 = 0.0 pi26 = 0.0 pi27 = 0.0 pi28 = 0.0 pi29 = 0.0 pi30 = 0.0 pi31 = 0.0 pi32 = 0.0 pi33 = 0.0 pi34 = 0.0 pi35 = 0.0 pi36 = 0.0 pi37 = 0.0 pi38 = 0.0 // If clauses (for inputs to work as on/off) if piStd pi4 := pi*4 pi6 := pi*6 pi8 := pi*8 pi9 := pi*9 pi12 := pi*12 pi14 := pi*14 pi15 := pi*15 pi16 := pi*16 pi18 := pi*18 pi21 := pi*21 pi22 := pi*22 pi24 := pi*24 pi25 := pi*25 pi26 := pi*26 pi27 := pi*27 pi28 := pi*28 pi32 := pi*32 pi33 := pi*33 pi34 := pi*34 pi35 := pi*35 pi36 := pi*36 pi38 := pi*38 else pi4 := na pi6 := na pi8 := na pi9 := na pi12 := na pi14 := na pi15 := na pi16 := na pi18 := na pi21 := na pi22 := na pi24 := na pi25 := na pi26 := na pi27 := na pi28 := na pi32 := na pi33 := na pi34 := na pi35 := na pi36 := na pi38 := na if piPrime pi1 := pi*1 pi2 := pi*2 pi3 := pi*3 pi5 := pi*5 pi7 := pi*7 pi11 := pi*11 pi13 := pi*13 pi17 := pi*17 pi19 := pi*19 pi23 := pi*23 pi29 := pi*29 pi31 := pi*31 pi37 := pi*37 else pi1 := na pi2 := na pi3 := na pi5 := na pi7 := na pi11 := na pi13 := na pi17 := na pi19 := na pi23 := na pi29 := na pi31 := na pi37 := na if piMulti pi10 := pi*10 pi20 := pi*20 pi30 := pi*30 else pi10 := na pi20 := na pi30 := na // Plots plot(pi, color = color.new(color.silver, 10)), plot(pi2, color = color.new(color.silver, 0)), plot(pi3, color = color.new(color.silver, 0)), plot(pi4, color = color.new(color.black, 0)), plot(pi5, color = color.new(color.silver, 0)), plot(pi6, color = color.new(color.black, 0)), plot(pi7, color = color.new(color.silver, 0)), plot(pi8, color = color.new(color.black, 0)), plot(pi9, color = color.new(color.black, 0)), plot(pi10, color = color.new(color.orange, 10)), plot(pi11, color = color.new(color.silver, 0)), plot(pi12, color = color.new(color.black, 0)), plot(pi13, color = color.new(color.silver, 0)), plot(pi14, color = color.new(color.black, 0)), plot(pi15, color = color.new(color.black, 0)), plot(pi16, color = color.new(color.black, 0)), plot(pi17, color = color.new(color.silver, 0)), plot(pi18, color = color.new(color.black, 0)), plot(pi19, color = color.new(color.silver, 0)), plot(pi20, color = color.new(color.orange, 10)), plot(pi21, color = color.new(color.black, 0)), plot(pi22, color = color.new(color.black, 0)), plot(pi23, color = color.new(color.silver, 0)), plot(pi24, color = color.new(color.black, 0)), plot(pi25, color = color.new(color.black, 0)), plot(pi26, color = color.new(color.black, 0)), plot(pi27, color = color.new(color.black, 0)), plot(pi28, color = color.new(color.black, 0)), plot(pi29, color = color.new(color.silver, 0)), plot(pi30, color = color.new(color.orange, 10)), plot(pi31, color = color.new(color.silver, 0)), plot(pi32, color = color.new(color.black, 0)), plot(pi33, color = color.new(color.black, 0)), plot(pi34, color = color.new(color.black, 0)), plot(pi35, color = color.new(color.black, 0)), plot(pi36, color = color.new(color.black, 0)), plot(pi37, color = color.new(color.silver, 0)), plot(pi38, color = color.new(color.black, 0)) ///
Fear and Greed Intraday Index
https://www.tradingview.com/script/2aEUXE7k-Fear-and-Greed-Intraday-Index/
barnabygraham
https://www.tradingview.com/u/barnabygraham/
181
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © barnabygraham // 1 to 7 are the original variables which this indicator is based upon. I've added others to add range, diversification and to improve the greed signals so that they (are more likely to) occur before downward moves. //@version=5 indicator("Fear and Greed Intraday Index", overlay=false, timeframe="", timeframe_gaps=true) length=input(1, "Length (Smoothing)") LengthSMA=input(125,"Length of SMAs") compression=input(5,"Compression") // 1. Advancers minus decliners - the original index uses NYSE 52 week high/lows. That's now variable #14. ADD = request.security('ADD', "", close) ADD2 = ADD/30 ADDma= ta.ema(ADD2,5) ADDavg=((ADD2*2)+ADDma)/3 ADD3 = ADDavg > 100 ? 100 : ADDavg < -100 ? -100 : ADDavg //plot(ADD3) // 2. Volume Breadth - VOLD VOLD = request.security('VOLD', '', hlc3) VOLD2 = VOLD/4000000 VOLDma= ta.ema(VOLD2,5) VOLDavg=((VOLD2*2)+VOLDma)/3 VOLD3 = VOLDavg > 100 ? 100 : VOLDavg < -100 ? -100 : VOLDavg //plot(VOLD3) // 3. Market momentum - Changing this to use RSI instead of to compare against an SMA SPY = request.security('SPY', '', close) momentum = (ta.rsi(SPY,14)-50)*2 momo = momentum > 100 ? 100 : momentum < -100 ? -100 : momentum //plot(momo) // 5. Safe haven demand; stocks vs bonds TLT = request.security('TLT','',close) TLTma = ((-TLT/ta.sma(-TLT,LengthSMA))*-800)+800 TLT2 = na(TLTma) ? 0 : TLTma SvB2 = (TLT2 + momentum) SvB = SvB2 > 100 ? 100 : SvB2 < -100 ? -100 : SvB2 //plot(SvB) // 6. HYG vs TLT, high yeild vs low yeild HYG2 = request.security('HYG','',close) HYG = na(HYG2) ? 0 : HYG2 HYGma = ((HYG/ta.sma(HYG,LengthSMA))*800)-800 HTG2 = na(HYGma) ? 0 : HYGma HvL2 = HTG2+TLT2 > 100 ? 100 : HTG2+TLT2 < -100 ? -100 : HTG2+TLT2 HvL = (ta.rsi(HvL2,14)-50)*2 //plot(HvL) // 7. VIX - Volatility VIX = request.security('VIX', '', close) VIX2=(((VIX-10)*5)-100)*-1 VIX4 = VIX2 > 100 ? 100 : VIX2 < -100 ? -100 : VIX2 VIX3 = (ta.rsi(VIX4,5)-50)*2 //plot(VIX3) // 8. Risk Sentiment - XBI vs XLP; Biotech vs staples XBI = request.security('XBI','',close) XLP = request.security('XLP','',close) xlprsi = (ta.rsi(XLP,14)-50)*-2 XBIrsi = (ta.rsi(XBI,5)-50)*2 XVIvsXLP2 = ta.hma(XBIrsi+xlprsi,50) XVIvsXLP = XVIvsXLP2 > 100 ? 100 : XVIvsXLP2 < -100 ? -100 : XVIvsXLP2 //plot(XVIvsXLP) // 9. VUG vs VTV; growth vs value VUG = request.security('VUG','',close) VTV = request.security('VTV','',close) GvV = (ta.rsi((ta.roc(VTV,30)+ta.roc(VUG,30)),5)-50)*2 GvVz= GvV > 100 ? 100 : GvV < -100 ? -100 : GvV GvVzFin=na(GvVz) ? 0 : GvVz //plot(GvVzFin) // 10. DXY rate of change DXY = request.security('DXY', '', close) DXYROC=ta.roc(DXY,50)*-50 DXYz = DXYROC > 100 ? 100 : DXYROC < -100 ? -100 : DXYROC //plot(DXYz) // 11. Aussie Dollar rate of change AUDUSD = request.security('AUDUSD','',close) AUDROC = ta.roc(AUDUSD,200)*50 AUDz = AUDROC > 100 ? 100 : AUDROC < -100 ? -100 : AUDROC //plot(AUDz) // 12. SPY / VIX 10-day correlation - Early greed signals - (I felt this indicator was lacking appropriate greed signals before adding these) SPYVIXa=ta.correlation(SPY,VIX,100) SPYVIX10=(((SPYVIXa)*69)+60) SPYVIXa10=SPYVIX10 > 100 ? 100 : SPYVIX10 < -100 ? -100 : SPYVIX10 //plot(SPYVIXa10) // 13. SPY / VIX 20-day correlation - Early greed signals - (I felt this indicator was lacking appropriate greed signals before adding these) SPYVIXb=ta.correlation(SPY,VIX,200) SPYVIX20=(((SPYVIXb)*69)+60) SPYVIXb20=SPYVIX20 > 100 ? 100 : SPYVIX20 < -100 ? -100 : SPYVIX20 //plot(SPYVIXb20) // // 18. this is just an idea for now and may be better to use GS or some other large investment bank.... let me know if you have any ideas about this // IBKR = request.financial('NASDAQ:IBKR', 'TOTAL_LIABILITIES' ,'FQ', barmerge.gaps_on) // IBKRSMA = (ta.ema(IBKR,2)) // IBKRfin = IBKR/IBKRSMA // IBKRfin2=ta.highest((((IBKRfin)-1.01)*2000),10) // plot(IBKRfin2) subTotal = ((ADD3 + VOLD3 + momo + SvB + HvL + VIX3 + XVIvsXLP + GvVzFin + DXYz + AUDz + SPYVIXa10 + SPYVIXb20) / compression) Total = subTotal > 100 ? 100 : subTotal < -100 ? -100 : subTotal Final = ta.ema(Total,length) plot = plot(Final, color=color.from_gradient(Total, -100, 100, #17CC00, #FF0000)) hline(0, linestyle=hline.style_dotted, color=color.new(color.white,85)) hline(50, linestyle=hline.style_dotted, color=color.new(color.red,70)) hline(100, linestyle=hline.style_dotted, color=color.new(color.red,50)) hline(-50, linestyle=hline.style_dotted, color=color.new(color.green,70)) hline(-100, linestyle=hline.style_dotted, color=color.new(color.green,50)) //Fill colouring // fillColorHigh =color.from_gradient(Final, 75, 100, color.new(#FF0000,100), #FF0000) // fillColorLow = color.from_gradient(Final, -100, -75, #17CC00,color.new(#17CC00,100)) // p1 = plot(75, color=color.new(color.gray,100)) // p2 = plot(-75,color=color.new(color.gray,100)) // fill(plot,p1,fillColorHigh) // fill(plot,p2,fillColorLow)
Euler Price Levels
https://www.tradingview.com/script/YNwQ237c-Euler-Price-Levels/
fvideira
https://www.tradingview.com/u/fvideira/
23
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © fvideira //@version=5 indicator("Euler Price Levels", overlay=true) // Study of Euler levels from Eliza123123's quantative trading series: https://youtu.be/S7UMA__wz74 // Inputs euStd = input.bool(true, "Standard Multiples", group = "Euler Constant 2.71828") euPrime = input.bool(true, "Prime Multiples", group = "Euler Constant 2.71828") euMulti = input.bool(true, "Multples of 10", group = "Euler Constant 2.71828") // Scale Factors & Constants scale = 0.0 if close >= 10000 scale := 1000 if close >= 1000 and close <=9999.999999 scale := 100 if close >= 100 and close <=999.999999 scale := 10 if close >= 10 and close <=99.999999 scale := 1 if close >= 1 and close <=9.999999 scale := 0.1 if close >= 0.1 and close <=0.999999 scale := 0.01 if close >= 0.01 and close <=0.099999 scale := 0.001 if close >= 0.001 and close <=0.009999 scale := 0.0001 // Variables e = 2.71828 * scale pi = 3.14159 e1 = 0.0 e2 = 0.0 e3 = 0.0 e4 = 0.0 e5 = 0.0 e6 = 0.0 e7 = 0.0 e8 = 0.0 e9 = 0.0 e10 = 0.0 e11 = 0.0 e12 = 0.0 e13 = 0.0 e14 = 0.0 e15 = 0.0 e16 = 0.0 e17 = 0.0 e18 = 0.0 e19 = 0.0 e20 = 0.0 e21 = 0.0 e22 = 0.0 e23 = 0.0 e24 = 0.0 e25 = 0.0 e26 = 0.0 e27 = 0.0 e28 = 0.0 e29 = 0.0 e30 = 0.0 e31 = 0.0 e32 = 0.0 e33 = 0.0 e34 = 0.0 e35 = 0.0 e36 = 0.0 e37 = 0.0 e38 = 0.0 // If clauses (for inputs to work as on/off) if euStd e4 := e*4 e6 := e*6 e8 := e*8 e9 := e*9 e12 := e*12 e14 := e*14 e15 := e*15 e16 := e*16 e18 := e*18 e21 := e*21 e22 := e*22 e24 := e*24 e25 := e*25 e26 := e*26 e27 := e*27 e28 := e*28 e32 := e*32 e33 := e*33 e34 := e*34 e35 := e*35 e36 := e*36 e38 := e*38 else e4 := na e6 := na e8 := na e9 := na e12 := na e14 := na e15 := na e16 := na e18 := na e21 := na e22 := na e24 := na e25 := na e26 := na e27 := na e28 := na e32 := na e33 := na e34 := na e35 := na e36 := na e38 := na if euPrime e1 := e*1 e2 := e*2 e3 := e*3 e5 := e*5 e7 := e*7 e11 := e*11 e13 := e*13 e17 := e*17 e19 := e*19 e23 := e*23 e29 := e*29 e31 := e*31 e37 := e*37 else e1 := na e2 := na e3 := na e5 := na e7 := na e11 := na e13 := na e17 := na e19 := na e23 := na e29 := na e31 := na e37 := na if euMulti e10 := e*10 e20 := e*20 e30 := e*30 else e10 := na e20 := na e30 := na // Plots plot(e, color = color.new(color.white, 0)), plot(e2, color = color.new(color.white, 0)), plot(e3, color = color.new(color.white, 0)), plot(e4, color = color.new(color.navy, 0)), plot(e5, color = color.new(color.white, 0)), plot(e6, color = color.new(color.navy, 0)), plot(e7, color = color.new(color.white, 0)), plot(e8, color = color.new(color.navy, 0)), plot(e9, color = color.new(color.navy, 0)), plot(e10, color = color.new(color.fuchsia, 10)), plot(e11, color = color.new(color.white, 0)), plot(e12, color = color.new(color.navy, 0)), plot(e13, color = color.new(color.white, 0)), plot(e14, color = color.new(color.navy, 0)), plot(e15, color = color.new(color.navy, 0)), plot(e16, color = color.new(color.navy, 0)), plot(e17, color = color.new(color.white, 0)), plot(e18, color = color.new(color.navy, 0)), plot(e19, color = color.new(color.white, 0)), plot(e20, color = color.new(color.fuchsia, 10)), plot(e21, color = color.new(color.navy, 0)), plot(e22, color = color.new(color.navy, 0)), plot(e23, color = color.new(color.white, 0)), plot(e24, color = color.new(color.navy, 0)), plot(e25, color = color.new(color.navy, 0)), plot(e26, color = color.new(color.navy, 0)), plot(e27, color = color.new(color.navy, 0)), plot(e28, color = color.new(color.navy, 0)), plot(e29, color = color.new(color.white, 0)), plot(e30, color = color.new(color.fuchsia, 10)), plot(e31, color = color.new(color.white, 0)), plot(e32, color = color.new(color.navy, 0)), plot(e33, color = color.new(color.navy, 0)), plot(e34, color = color.new(color.navy, 0)), plot(e35, color = color.new(color.navy, 0)), plot(e36, color = color.new(color.navy, 0)), plot(e37, color = color.new(color.white, 0)), plot(e38, color = color.new(color.navy, 0)) //////
VWAP Bands - Event Based [LuxAlgo]
https://www.tradingview.com/script/x20TQQYT-VWAP-Bands-Event-Based-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
2,113
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("Event Based VWAP Bands [LUX]","EB-VWAP [LuxAlgo]",overlay=true) start = input.time(0,confirm=true) from_bar0 = input(false,'Start At First Bar') length = input(14,group='VWAP') mult = input(2.,group='VWAP') source = input.string('close', options=['open','high','low','close','hl2','hlc3','ohlc4'],group='VWAP') //---- event = input.string('Periodic', options=['Periodic','Higher High','Lower Low','Trend Change','Start','External Cross','External Event'], group='Event') ext_src = input.source(open,'External Cross/Event') //---- var t = 0 var csum_num = 0. var csum_den = 0. var var_num = 0. var var_den = 0. //---- src = switch source 'open' => open 'high' => high 'low' => low 'close' => close 'hl2' => hl2 'hlc3' => hlc3 'ohlc4' => ohlc4 //---- upper = ta.highest(length) lower = ta.lowest(length) os = math.round(ta.stoch(src,src,src,length)/100) //---- start_time = from_bar0 ? true : time >= start event_condition = switch event 'Periodic' => t%length == 0 'Higher High' => upper > upper[1] 'Lower Low' => lower < lower[1] 'Trend Change' => os != os[1] 'Start' => false 'External Cross' => ta.cross(src,ext_src) 'External Event' => ext_src != 0 if start_time csum_num += src*volume csum_den += volume var_num += src*src*volume t += 1 if event_condition csum_num := src*volume csum_den := volume var_num := src*src*volume //---- pvwap = csum_num/csum_den dev = math.sqrt(var_num/csum_den - pvwap*pvwap)*mult //---- up = plot(event_condition ? na : pvwap + dev,'Upper',color=#2157f3,style=plot.style_linebr) plot(event_condition ? na : pvwap,'Basis',color=#ff5d00,style=plot.style_linebr) dn = plot(event_condition ? na : pvwap - dev,'Lower',color=#ff1100,style=plot.style_linebr) fill(up,dn,color=color.new(#2157f3,80))
Levels Of Fear [AstrideUnicorn]
https://www.tradingview.com/script/jnBFmEYE-Levels-Of-Fear-AstrideUnicorn/
AstrideUnicorn
https://www.tradingview.com/u/AstrideUnicorn/
255
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © AstrideUnicorn //@version=5 indicator("Levels Of Fear", overlay=true) // Define the source price series for the indicator calculations source = close // The indicator inputs length = input.int(defval=60, minval=30, maxval=150, title = "Window", tooltip="Higher values are better for measuring deeper and longer declines.") stability = input.int(defval=10, minval=10, maxval=20, title = "Levels Stability", tooltip="The higher the value is, the more stable and long the levels are, but the lag slightly increases.") mode = input.string(defval="Cool Guys Mode", options=['Cool Guys Mode','Serious Guys Mode']) // Calculate the current base level as the resent highest price current_high = ta.highest(high,length) // Calculate the rolling standard deviation of the source price stdev = ta.stdev(source,4*length) // Define the condition that a decline has started (the price is below current // high for a specified amount of bars) condition1 = ta.highest(current_high,stability) == ta.lowest(current_high,stability) // During a decline don't update the rolling standard deviation on each bar, // to fix the distance between the levels of fear if condition1 stdev:=stdev[1] // Calculate the levels of fear fear_level_1 = current_high - 1*stdev fear_level_2 = current_high - 2*stdev fear_level_3 = current_high - 3*stdev fear_level_4 = current_high - 4*stdev fear_level_5 = current_high - 5*stdev fear_level_6 = current_high - 6*stdev fear_level_7 = current_high - 7*stdev // Store the previous value of base level current_high_previous = ta.valuewhen(condition1==true, current_high, 1) // Define the conditional color of the fear levels to make them visible only //during a decline fear_levels_color = condition1?color.red:na // Plot the levels of fear plot(fear_level_1, color= fear_levels_color, linewidth=1) plot(fear_level_2, color= fear_levels_color, linewidth=2) plot(fear_level_3, color= fear_levels_color, linewidth=3) plot(fear_level_4, color= fear_levels_color, linewidth=4) plot(fear_level_5, color= fear_levels_color, linewidth=5) plot(fear_level_6, color= fear_levels_color, linewidth=6) plot(fear_level_7, color= fear_levels_color, linewidth=7) // Prolongate the levels of fear when a decline is over and a rebound has started fear_levels_color_previous = condition1==false?color.red:na plot(ta.valuewhen(condition1==true, fear_level_1, 1), color= fear_levels_color_previous, linewidth=1) plot(ta.valuewhen(condition1==true, fear_level_2, 1), color= fear_levels_color_previous, linewidth=2) plot(ta.valuewhen(condition1==true, fear_level_3, 1), color= fear_levels_color_previous, linewidth=3) plot(ta.valuewhen(condition1==true, fear_level_4, 1), color= fear_levels_color_previous, linewidth=4) plot(ta.valuewhen(condition1==true, fear_level_5, 1), color= fear_levels_color_previous, linewidth=5) plot(ta.valuewhen(condition1==true, fear_level_6, 1), color= fear_levels_color_previous, linewidth=6) plot(ta.valuewhen(condition1==true, fear_level_7, 1), color= fear_levels_color_previous, linewidth=7) // Condition that defines the position of the fear levels labels: on the fourth // bar after a new set of fear levels is formed. draw_label_condition = ta.barssince(condition1[1]==false and condition1==true)==3 // Condition that checks if the mode for the labels is the Cool Guys Mode coolmode = mode == "Cool Guys Mode" // Plot the labels if the Cool Guys Mode is selected plotchar(coolmode and draw_label_condition?fear_level_1:na,location=location.absolute, char = "😌", size=size.small) plotchar(coolmode and draw_label_condition?fear_level_2:na,location=location.absolute, char = "🤔", size=size.small) plotchar(coolmode and draw_label_condition?fear_level_3:na,location=location.absolute, char = "🤨", size=size.small) plotchar(coolmode and draw_label_condition?fear_level_4:na,location=location.absolute, char = "😮", size=size.small) plotchar(coolmode and draw_label_condition?fear_level_5:na,location=location.absolute, char = "🤬", size=size.small) plotchar(coolmode and draw_label_condition?fear_level_6:na,location=location.absolute, char = "😖", size=size.small) plotchar(coolmode and draw_label_condition?fear_level_7:na,location=location.absolute, char = "😱", size=size.small) // Plot the labels if the Serious Guys Mode is selected plotchar(coolmode==false and draw_label_condition?fear_level_1:na,location=location.absolute, char = "1", size=size.small) plotchar(coolmode==false and draw_label_condition?fear_level_2:na,location=location.absolute, char = "2", size=size.small) plotchar(coolmode==false and draw_label_condition?fear_level_3:na,location=location.absolute, char = "3", size=size.small) plotchar(coolmode==false and draw_label_condition?fear_level_4:na,location=location.absolute, char = "4", size=size.small) plotchar(coolmode==false and draw_label_condition?fear_level_5:na,location=location.absolute, char = "5", size=size.small) plotchar(coolmode==false and draw_label_condition?fear_level_6:na,location=location.absolute, char = "6", size=size.small) plotchar(coolmode==false and draw_label_condition?fear_level_7:na,location=location.absolute, char = "7", size=size.small)
Cyclic RSI High Low With Noise Filter
https://www.tradingview.com/script/2zKoLmRP-Cyclic-RSI-High-Low-With-Noise-Filter/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
717
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RozaniGhani-RG //@version=5 indicator('Cyclic RSI High Low With Noise Filter', 'cRSI') // 0. Inputs // 1. Variables and calculations // 2. Custom functions // 3. Construct // 4. Plot, fill and hline // ————————————————————————————————————————————————————————————————————————————— 0. Inputs { i_s_switch = input.string('Cyclic RSI', 'RSI or Cyclic RSI', options = ['RSI', 'Cyclic RSI']) i_src = input.source(close, 'Source', inline = '0') i_i_len = input.int(13, 'Length', inline = '0', minval = 1) i_b_line = input.bool(false, 'Show line', tooltip = 'Best used plot is disabled') i_b_plot = input.bool(true, 'Show plot', tooltip = 'Best used line is disabled') i_b_fill = input.bool(true, 'Show fill', tooltip = 'Only for Cyclic RSI') i_s_noise = input.string('none', 'Remove Noise', options = ['none', '35 < value < 65', '50 < value < 65', '35 < value < 50']) i_s_label = input.string('arrow', 'Noise label', options = ['both', 'OB/OS', 'arrow'], tooltip = 'Beginner use both') i_s_alert = input.string('Once Per Bar Close', 'Frequency', options = ['Once Per Bar Close', 'Once Per Bar', 'All'], group ='Alert') _freq = i_s_alert == 'Once Per Bar Close' ? alert.freq_once_per_bar_close : i_s_alert == 'Once Per Bar' ? alert.freq_once_per_bar : alert.freq_all // } // 1. Variables and calculations // ————————————————————————————————————————————————————————————————————————————— 1.1 Cyclic RSI formula { // Credits to WhenToTrade crsi = 0.0 vibration = 10 torque = 0.618 / (vibration + 1) phasingLag = (vibration - 1) / 0.618 rsi = ta.rsi(i_src, i_i_len) crsi := torque * (2 * rsi - rsi[phasingLag]) + (1 - torque) * nz(crsi[1]) // } // ————————————————————————————————————————————————————————————————————————————— 1.2 Cyclic RSI formula { float osc = switch i_s_switch 'Cyclic RSI' => crsi 'RSI' => rsi // } // ————————————————————————————————————————————————————————————————————————————— 1.3 Zigzag formula { // Credits to LonesomeTheBlue float ph = ta.highestbars(high, i_i_len) == 0 ? osc : na float pl = ta.lowestbars(low, i_i_len) == 0 ? osc : na var int dir = 0 dir := ph and na(pl) ? 1 : pl and na(ph) ? -1 : dir var max_array_size = 10 var arr_zz = array.new_float(0) older_zz = array.copy(arr_zz) dirchanged = ta.change(dir) // } // 2. Custom functions // ————————————————————————————————————————————————————————————————————————————— 2.1 Zigzag functions { // Credits to LonesomeTheBlue add_to_zigzag(_id, float value, int bindex) => array.unshift(_id, bindex) array.unshift(_id, value) if array.size(_id) > max_array_size array.pop(_id) array.pop(_id) update_zigzag(_id, float value, int bindex, int dir) => if array.size(_id) == 0 add_to_zigzag(_id, value, bindex) else if dir == 1 and value > array.get(_id, 0) or dir == -1 and value < array.get(_id, 0) array.set(_id, 0, value) array.set(_id, 1, bindex) 0. if ph or pl if dirchanged add_to_zigzag(arr_zz, dir == 1 ? ph : pl, bar_index) else update_zigzag(arr_zz, dir == 1 ? ph : pl, bar_index, dir) // } // ————————————————————————————————————————————————————————————————————————————— 2.2 Remove noise { f_noise() => filter_noise = switch i_s_noise '35 < value < 65' => array.get(arr_zz, 2) <= 65 and array.get(arr_zz, 2) >= 35 '50 < value < 65' => array.get(arr_zz, 2) >= 35 '30 < value < 50' => array.get(arr_zz, 2) <= 65 // 2.3 Noise label [str_OB, str_OS] = switch i_s_label 'both' => ['OB\n▼', '▲\nOS'] 'OB/OS' => [ 'OB', 'OS'] 'arrow' => [ '▼', '▲'] // } // ————————————————————————————————————————————————————————————————————————————— 3. Construct { if array.size(arr_zz) >= 6 // Variables var line line_zz = na var label label_zz = na // Bools for or bool bool_or_1 = array.get(arr_zz, 0) != array.get(older_zz, 0) bool bool_or_2 = array.get(arr_zz, 1) != array.get(older_zz, 1) // Bools for and bool bool_n_1 = array.get(arr_zz, 2) == array.get(older_zz, 2) bool bool_n_2 = array.get(arr_zz, 3) == array.get(older_zz, 3) // Bools for more than and less than bool bool_0_mt_4 = array.get(arr_zz, 0) > array.get(arr_zz, 4) bool bool_0_lt_4 = array.get(arr_zz, 0) < array.get(arr_zz, 4) if bool_or_1 or bool_or_2 if bool_n_1 and bool_n_2 line.delete(line_zz) label.delete(label_zz) if f_noise() label.delete(label_zz) if i_b_line line_zz := line.new( x1 = math.round(array.get(arr_zz, 1)), y1 = array.get(arr_zz, 0), x2 = math.round(array.get(arr_zz, 3)), y2 = array.get(arr_zz, 2), color = color.gray, width = 2) str_label = dir == 1 ? bool_0_mt_4 ? str_OB : '◍' : bool_0_lt_4 ? str_OS : '◍' col_label = dir == 1 ? bool_0_mt_4 ? color.red : color.teal : bool_0_lt_4 ? color.teal : color.red label_zz := label.new(x = math.round(array.get(arr_zz, 1)), y = array.get(arr_zz, 0), text = str_label, color = color.new(color.blue, 100), textcolor = col_label, style=dir == 1 ? label.style_label_down : label.style_label_up) label_zz if bool_0_mt_4 alert(syminfo.ticker + ' ' + i_s_switch + ' ' + str.tostring(osc, ' (#.00)') + ' ' + str_OB, _freq) if bool_0_lt_4 alert(syminfo.ticker + ' ' + i_s_switch + ' ' + str.tostring(osc, ' (#.00)') + ' ' + str_OB, _freq) // } // ————————————————————————————————————————————————————————————————————————————— 4. Plot, fill and hline { p_rsi = plot(i_s_switch == 'RSI' ? rsi : na, 'RSI', color.new(color.yellow, i_b_plot ? 0 : 100), linewidth = 2) p_crsi = plot(i_s_switch == 'Cyclic RSI' ? crsi : na, 'CRSI', color.new(color.yellow, i_b_plot ? 0 : 100), linewidth = 2) p_os = plot(30, 'OS', color.new(color.teal, i_b_plot ? 0 : 50)) p_ob = plot(70, 'OB', color.new(color.red, i_b_plot ? 0 : 50)) fill(p_os, p_crsi, color.new(color.teal, i_b_fill ? 65 : 100)) fill(p_ob, p_crsi, color.new(color.red, i_b_fill ? 65 : 100)) hline(50) // }
T/K CROSS
https://www.tradingview.com/script/7Uyn9Q3J-T-K-CROSS/
theforlornson
https://www.tradingview.com/u/theforlornson/
36
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © theforlornson //@version=5 indicator("T/K CROSS", overlay=true) // Getting inputs TenkanSenPeriod = input.int(9, minval=1, title="TenkanSen Period") KijunSenPeriod= input.int(26, minval=1, title="KijunSen Period") // Ichimoku function donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) // Calculation TenkanSen = donchian(TenkanSenPeriod) KijunSen = donchian(KijunSenPeriod) // plot plot(TenkanSen, color=color.blue) plot(KijunSen, color=color.red) // crossovers plotshape(ta.crossover(TenkanSen,KijunSen) ? 1 : na, style=shape.cross, color=color.aqua, location=location.belowbar, size=size.small) plotshape(ta.crossunder(TenkanSen,KijunSen) ? 1 : na, style=shape.cross, color=color.orange, location=location.abovebar, size=size.small)
Fear and Greed Index
https://www.tradingview.com/script/EnH9KbD6-Fear-and-Greed-Index/
barnabygraham
https://www.tradingview.com/u/barnabygraham/
535
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © barnabygraham // 1 to 7 are the original variables which this indicator is based upon. I've added others to add range, diversification and to improve the greed signals so that they (are more likely to) occur before downward moves. //@version=5 indicator("Fear and Greed Index", overlay=false, timeframe="D", timeframe_gaps=true) length=input(1, "Length (Smoothing)") LengthSMA=input(125,"Length of SMAs") // 1. Advancers minus decliners - the original index uses NYSE 52 week high/lows. That's now variable #14. ADD = request.security('ADD', "D", close) ADD2 = ADD/30 ADDma= ta.ema(ADD2,5) ADDavg=((ADD2*2)+ADDma)/3 ADD4 = ADDavg > 100 ? 100 : ADDavg < -100 ? -100 : ADDavg ADD3 = na(ADD4) ? 0 : ADD4 //plot(ADD3) // 2. Volume Breadth - VOLD VOLD = request.security('VOLD', 'D', hlc3) VOLD2 = VOLD/20000000 VOLDma= ta.ema(VOLD2,5) VOLDavg=((VOLD2*2)+VOLDma)/3 VOLD4 = VOLDavg > 100 ? 100 : VOLDavg < -100 ? -100 : VOLDavg VOLD3 = na(VOLD4) ? 0 : VOLD4 //plot(VOLD3) // 3. Market momentum - SPY vs simple moving average SPY = request.security('SPY', 'D', close) Spy125sma = ta.sma(SPY,LengthSMA) momentum = ((SPY/Spy125sma)-0.95)*400 momo2 = momentum > 100 ? 100 : momentum < -100 ? -100 : momentum momo = na(momo2) ? 0 : momo2 //plot(momo) // 4. Put to Call ratio - Ticker 'PC' occasionally doesn't work - (this may be the cause if the script breaks) if so, and you want results now, you can replace PC with PCSP or any other PUT:CALL ratio symbol of your choice. PC = request.security('PC', 'D', close) PC2 = ((PC*100)-100)*-1.5 PC3 = PC2 > 100 ? 100 : PC2 < -100 ? 100 : PC2 PC4 = na(PC3) ? 0 : PC3 //plot(PC4) // 5. Safe haven demand; stocks vs bonds TLT = request.security('TLT','D',close) TLTma = ((-TLT/ta.sma(-TLT,LengthSMA))*-800)+800 TLT2 = na(TLTma) ? 0 : TLTma SvB2 = (TLT2 + momentum)/2 SvB = na(SvB2) ? 0 : SvB2 //plot(SvB) // 6. HYG vs TLT, high yeild vs low yeild HYG2 = request.security('HYG','D',close) HYG = na(HYG2) ? 0 : HYG2 HYGma = ((HYG/ta.sma(HYG,LengthSMA))*800)-800 HTG2 = na(HYGma) ? 0 : HYGma HvL2 = HTG2+TLT2 > 100 ? 100 : HTG2+TLT2 < -100 ? -100 : HTG2+TLT2 HvL = na(HvL2) ? 0 : HvL2 //(HvL) // 7. VIX - Volatility VIX = request.security('VIX', 'D', close) VIX2=(((VIX-10)*5)-100)*-1 VIX4 = VIX2 > 100 ? 100 : VIX2 < -100 ? -100 : VIX2 VIX3 = na(VIX4) ? 0 : VIX4 //plot(VIX3) // 8. Risk Sentiment - XBI vs XLP; Biotech vs staples XBI = request.security('XBI','D',close) XLP = request.security('XLP','D',close) xlp50sma = ta.sma(XLP,LengthSMA) xlpmomentum = ((XLP/xlp50sma)-0.95)*400 xlpmomo2 = xlpmomentum > 100 ? 100 : xlpmomentum < -100 ? -100 : xlpmomentum XBI50sma = ta.sma(XBI,LengthSMA) XBImomentum = ((XBI/XBI50sma)-0.95)*400 XBImomo = XBImomentum > 100 ? 100 : XBImomentum < -100 ? -100 : XBImomentum XVIvsXLP2 = XBImomo-xlpmomo2 XVIvsXLP = na(XVIvsXLP2) ? 0 : XVIvsXLP2 //plot(XVIvsXLP) // 9. VUG vs VTV; growth vs value VUG = request.security('VUG','D',close) VTV = request.security('VTV','D',close) GvV = (ta.roc(VTV,30)+ta.roc(VUG,30))*5 GvVz= GvV > 100 ? 100 : GvV < -100 ? -100 : GvV GvVzFin=na(GvVz) ? 0 : GvVz //plot(GvVzFin) // 10. DXY rate of change DXY = request.security('DXY', 'D', close) DXYROC=ta.roc(DXY,100)*-5 DXYz2 = DXYROC > 100 ? 100 : DXYROC < -100 ? -100 : DXYROC DXYz = na(DXYz2) ? 0 : DXYz2 //plot(DXYz) // 11. Aussie Dollar rate of change AUDUSD = request.security('AUDUSD','D',close) AUDROC = ta.roc(AUDUSD,69)*5 AUDz2 = AUDROC > 100 ? 100 : AUDROC < -100 ? -100 : AUDROC AUDz = na(AUDz2) ? 0 : AUDz2 //plot(AUDz) // 12. SPY / VIX 10-day correlation - Early greed signals - (I felt this indicator was lacking appropriate greed signals before adding these) SPYVIXa=ta.correlation(SPY,VIX,10) SPYVIX10=(((SPYVIXa)*69)+60) SPYVIXa102=SPYVIX10 > 100 ? 100 : SPYVIX10 < -100 ? -100 : SPYVIX10 SPYVIXa10 = na(SPYVIXa102) ? 0 : SPYVIXa102 //plot(SPYVIXa10) // 13. SPY / VIX 20-day correlation - Early greed signals - (I felt this indicator was lacking appropriate greed signals before adding these) SPYVIXb=ta.correlation(SPY,VIX,20) SPYVIX20=(((SPYVIXb)*69)+60) SPYVIXb202=SPYVIX20 > 100 ? 100 : SPYVIX20 < -100 ? -100 : SPYVIX20 SPYVIXb20 = na(SPYVIXb202) ? 0 : SPYVIXb202 //plot(SPYVIXb20) // 14. NYSE 52 week highs vs 52 week lows HIGN = request.security('HIGN','D',close) LOWN = request.security('LOWN','D',close) HIGNSMA = ta.sma(HIGN,1000) LOWNSMA = ta.sma(LOWN,1000) HIGNr = (HIGN/HIGNSMA)*15 LOWNr = (LOWN/LOWNSMA)*-5 HighsAndLows=(HIGNr+LOWNr) HisLows2=HighsAndLows > 100 ? 100 : HighsAndLows < -100 ? -100 : HighsAndLows HisLows = na(HisLows2) ? 0 : HisLows2 // plot(HisLows) // 15. SPY Short Volume SSV = request.security('SPY_SHORT_VOLUME','D',close) SSVsma=ta.sma(SSV,LengthSMA) SSVf=(SSV/SSVsma) SSVf2 = na(SSVf) ? 0 : ((SSVf*-30)+30) SSVf32=SSVf2 > 1 ? SSVf2*5 : SSVf2 < -100 ? -100 : SSVf2 SSVf3 = na(SSVf32) ? 0 : SSVf32 //plot(SSVf3) // 16. % of stocks above/below moving averages Per5MA = request.security('MMFD','D',close) Per20MA = request.security('MMTW','D',close) Per50MA = request.security('MMFI','D',close) Per100MA= request.security('MMOH','D',close) Per150MA= request.security('MMOF','D',close) Per200MA= request.security('MMTH','D',close) PerAverage=(Per5MA+Per20MA+Per50MA+Per100MA+Per150MA+Per200MA)/6 PerFin2=na(PerAverage) ? 0 : (PerAverage*2)-100 PerFin = na(PerFin2) ? 0 : PerFin2 //plot(PerFin) // 17. McClellan Oscillator ai = request.security('ADVN','D',close) di = request.security('DECN','D',close) rana=1000 * (ai-di)/(ai+di) e1=ta.ema(rana, 19) e2=ta.ema(rana, 39) mo=e1-e2 mcclellan2 = mo > 100 ? 100 : mo < -100 ? -100 : mo mcclellan = na(mcclellan2) ? 0 : mcclellan2 //plot(mcclellan) // // 18. this is just an idea for now and may be better to use GS or some other large investment bank.... let me know if you have any ideas about this // IBKR = request.financial('NASDAQ:IBKR', 'TOTAL_LIABILITIES' ,'FQ', barmerge.gaps_on) // IBKRSMA = (ta.ema(IBKR,2)) // IBKRfin = IBKR/IBKRSMA // IBKRfin2=ta.highest((((IBKRfin)-1.01)*2000),10) // plot(IBKRfin2) subTotal = ((ADD3 + VOLD3 + momo + PC4 + SvB + HvL + VIX3 + XVIvsXLP + GvVzFin + DXYz + AUDz + SPYVIXa10 + SPYVIXb20 + HisLows + SSVf3 + PerFin + mcclellan) / 8) Total = subTotal > 100 ? 100 : subTotal < -100 ? -100 : subTotal Final = ta.ema(Total,length) plot = plot(Final, color=color.from_gradient(Total, -100, 100, #17CC00, #FF0000)) hline(0, linestyle=hline.style_dotted, color=color.new(color.white,85)) hline(50, linestyle=hline.style_dotted, color=color.new(color.red,70)) hline(100, linestyle=hline.style_dotted, color=color.new(color.red,50)) hline(-50, linestyle=hline.style_dotted, color=color.new(color.green,70)) hline(-100, linestyle=hline.style_dotted, color=color.new(color.green,50)) // END OF FEAR AND GREED CALCULATIONS // Below are optional indicators which could be helpful, currently divergence lines and long range bollinger bands // DIVERGENCE LINES lbR = input(title='Pivot Lookback Right', defval=2) lbL = input(title='Pivot Lookback Left', defval=30) 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=false) plotBear = input(title='Plot Bearish', defval=true) plotHiddenBear = input(title='Plot Hidden Bearish', defval=false) bearColor = color.new(color.red,66) bullColor = color.new(color.green,66) hiddenBullColor = color.new(color.green, 80) hiddenBearColor = color.new(color.red, 80) textColor = color.white noneColor = color.new(color.white, 100) [macdline, _, _] = ta.macd(close, 12, 26, 9) P = (close - open) / open DI = 0.0 Spread = 0.0 H = 0.0 L = 0.0 if high > high[1] H := high H else H := high[1] H if low < low[1] L := low L else L := low[1] L Spread := H - L Spread := math.avg(Spread, 10) if Spread == 0 Spread := 1 Spread K = 3 * close / Spread P *= K BP = 1.0 SP = 1.0 if close > open BP := volume SP := volume / P SP else BP := volume / P SP := volume SP if math.abs(BP) > math.abs(SP) DI := 100 * SP / BP DI else DI := 100 * BP / SP DI DI := ta.ema(DI, 10) ad = close == high and close == low or high == low ? 0 : (2 * close - low - high) / (high - low) * volume cmf = math.sum(ad, 20) / math.sum(volume, 20) * 100 osc = Final 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 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, transp=0) oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) 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, transp=0) oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) 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, transp=0) oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) 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, transp=0) // BOLLINGER BANDS bblength = input.int(2000, minval=1, title="Bollinger Band Length") src = Final mult = input.float(2.0, minval=0.001, maxval=50, title="Bollinger Band Std Dev") basis = ta.sma(src, bblength) dev = mult * ta.stdev(src, bblength) upper = basis + dev lower = basis - dev plot(basis, "Basis", color=color.new(#FF6D00,50)) p1 = plot(upper, "Upper", color=color.new(#2962FF,50)) p2 = plot(lower, "Lower", color=color.new(#2962FF,50))
Average Total Price From Bottom
https://www.tradingview.com/script/IBcsj6sl-Average-Total-Price-From-Bottom/
OrionAlgo
https://www.tradingview.com/u/OrionAlgo/
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/ // © OrionAlgo //@version=5 indicator("Average Total Price From Bottom", max_bars_back=4999, overlay=true) time1 = input.time(timestamp("18 Jan 2015 00:00 +0000"), "Bottom1") time2 = input.time(timestamp("9 Jan 2019 00:00 +0000"), "Bottom2") time3 = input.time(timestamp("16 Dec 2024 00:00 +0000"), "Bottom3") //update this later when the bottom is found from the 2021 bullrun time4 = input.time(timestamp("16 Dec 2028 00:00 +0000"), "Bottom4") //update this later when the bottom is found 2 bullruns later _c0 = timestamp(2009, 01, 01, 00, 00) c0_start = time >= _c0 _c1 = time1 c1_start = time >= _c1 _c2 = time2 c2_start = time >= _c2 _c3 = time3 c3_start = time >= _c3 _c4 = time4 c4_start = time >= _c4 ma1 = 0.0 if c0_start count0 = ta.cum(1+1==2 ? 1 : 0) ma1 := ta.sma( close,math.round(count0)) if c1_start ma1 := 0.0 else ma1 := 0.0 ma2 = 0.0 if c1_start count1 = ta.cum(1+1==2 ? 1 : 0) ma2 := ta.sma( close,math.round(count1)) if c2_start ma2 := 0.0 else ma2 := 0.0 ma3 = 0.0 if c2_start count2 = ta.cum(1+1==2 ? 1 : 0) ma3 := ta.sma( close,math.round(count2)) if c3_start ma3 := 0.0 else ma3 := 0.0 ma4 = 0.0 if c3_start count3 = ta.cum(1+1==2 ? 1 : 0) ma4 := ta.sma( close,math.round(count3)) if c4_start ma4 := 0.0 else ma4 := 0.0 // count1 = ta.cum(1+1==2 ? 1 : 0) // ma1 = ta.sma( close,math.round(count0)) plot(ma1, color=color.green) plot(ma2, color=color.green) plot(ma3, color=color.green) plot(ma4, color=color.green)
Fear and Greed Index Candlesticks
https://www.tradingview.com/script/G6kgr6jJ-Fear-and-Greed-Index-Candlesticks/
barnabygraham
https://www.tradingview.com/u/barnabygraham/
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/ // © barnabygraham // 1 to 7 are the original variables which this indicator is based upon. I've added others to add range, diversification and to improve the greed signals so that they (are more likely to) occur before downward moves. //@version=5 indicator("Fear and Greed Index Candlesticks", overlay=false, timeframe="D", timeframe_gaps=true) length=input(1, "Length (Smoothing)") LengthSMA=input(125,"Length of SMAs") GreedCeiling = input(100,"Greed Ceiling") GreedFloor = input(0,"Greed Floor") FearCeiling = input(0,"Fear Ceiling") FearFloor = input(-100,"Fear Floor") // 1. Advancers minus decliners - the original index uses NYSE 52 week high/lows. That's now variable #14. ADD = request.security('ADD', "D", close) ADD2 = ADD/30 ADDma= ta.ema(ADD2,5) ADDavg=((ADD2*2)+ADDma)/3 ADD3 = ADDavg > 100 ? 100 : ADDavg < -100 ? -100 : ADDavg //plot(ADD3) // 2. Volume Breadth - VOLD VOLD = request.security('VOLD', 'D', hlc3) VOLD2 = VOLD/20000000 VOLDma= ta.ema(VOLD2,5) VOLDavg=((VOLD2*2)+VOLDma)/3 VOLD3 = VOLDavg > 100 ? 100 : VOLDavg < -100 ? -100 : VOLDavg //plot(VOLD3) // 3. Market momentum - SPY vs simple moving average SPY = request.security('SPY', 'D', close) Spy125sma = ta.sma(SPY,LengthSMA) momentum = ((SPY/Spy125sma)-0.95)*400 momo = momentum > 100 ? 100 : momentum < -100 ? -100 : momentum //plot(momo) // 4. Put to Call ratio - Ticker 'PC' occasionally doesn't work - (this may be the cause if the script breaks) if so, and you want results now, you can replace PC with PCSP or any other PUT:CALL ratio symbol of your choice. PC = request.security('PC', 'D', close) PC2 = ((PC*100)-100)*-1.5 PC3 = PC2 > 100 ? 100 : PC2 < -100 ? 100 : PC2 PC4 = na(PC3) ? 0 : PC3 //plot(PC4) // 5. Safe haven demand; stocks vs bonds TLT = request.security('TLT','D',close) TLTma = ((-TLT/ta.sma(-TLT,LengthSMA))*-800)+800 TLT2 = na(TLTma) ? 0 : TLTma SvB = (TLT2 + momentum)/2 //plot(SvB) // 6. HYG vs TLT, high yeild vs low yeild HYG2 = request.security('HYG','D',close) HYG = na(HYG2) ? 0 : HYG2 HYGma = ((HYG/ta.sma(HYG,LengthSMA))*800)-800 HTG2 = na(HYGma) ? 0 : HYGma HvL = HTG2+TLT2 > 100 ? 100 : HTG2+TLT2 < -100 ? -100 : HTG2+TLT2 //(HvL) // 7. VIX - Volatility VIX = request.security('VIX', 'D', close) VIX2=(((VIX-10)*5)-100)*-1 VIX3 = VIX2 > 100 ? 100 : VIX2 < -100 ? -100 : VIX2 //plot(VIX3) // 8. Risk Sentiment - XBI vs XLP; Biotech vs staples XBI = request.security('XBI','D',close) XLP = request.security('XLP','D',close) xlp50sma = ta.sma(XLP,LengthSMA) xlpmomentum = ((XLP/xlp50sma)-0.95)*400 xlpmomo2 = xlpmomentum > 100 ? 100 : xlpmomentum < -100 ? -100 : xlpmomentum XBI50sma = ta.sma(XBI,LengthSMA) XBImomentum = ((XBI/XBI50sma)-0.95)*400 XBImomo = XBImomentum > 100 ? 100 : XBImomentum < -100 ? -100 : XBImomentum XVIvsXLP = XBImomo-xlpmomo2 //plot(XVIvsXLP) // 9. VUG vs VTV; growth vs value VUG = request.security('VUG','D',close) VTV = request.security('VTV','D',close) GvV = (ta.roc(VTV,30)+ta.roc(VUG,30))*5 GvVz= GvV > 100 ? 100 : GvV < -100 ? -100 : GvV GvVzFin=na(GvVz) ? 0 : GvVz //plot(GvVzFin) // 10. DXY rate of change DXY = request.security('DXY', 'D', close) DXYROC=ta.roc(DXY,100)*-5 DXYz = DXYROC > 100 ? 100 : DXYROC < -100 ? -100 : DXYROC //plot(DXYz) // 11. Aussie Dollar rate of change AUDUSD = request.security('AUDUSD','D',close) AUDROC = ta.roc(AUDUSD,69)*5 AUDz = AUDROC > 100 ? 100 : AUDROC < -100 ? -100 : AUDROC //plot(AUDz) // 12. SPY / VIX 10-day correlation - Early greed signals - (I felt this indicator was lacking appropriate greed signals before adding these) SPYVIXa=ta.correlation(SPY,VIX,10) SPYVIX10=(((SPYVIXa)*69)+60) SPYVIXa10=SPYVIX10 > 100 ? 100 : SPYVIX10 < -100 ? -100 : SPYVIX10 //plot(SPYVIXa10) // 13. SPY / VIX 20-day correlation - Early greed signals - (I felt this indicator was lacking appropriate greed signals before adding these) SPYVIXb=ta.correlation(SPY,VIX,20) SPYVIX20=(((SPYVIXb)*69)+60) SPYVIXb20=SPYVIX20 > 100 ? 100 : SPYVIX20 < -100 ? -100 : SPYVIX20 //plot(SPYVIXb20) // 14. NYSE 52 week highs vs 52 week lows HIGN = request.security('HIGN','D',close) LOWN = request.security('LOWN','D',close) HIGNSMA = ta.sma(HIGN,1000) LOWNSMA = ta.sma(LOWN,1000) HIGNr = (HIGN/HIGNSMA)*15 LOWNr = (LOWN/LOWNSMA)*-5 HighsAndLows=(HIGNr+LOWNr) HisLows=HighsAndLows > 100 ? 100 : HighsAndLows < -100 ? -100 : HighsAndLows // plot(HisLows) // 15. SPY Short Volume SSV = request.security('SPY_SHORT_VOLUME','D',close) SSVsma=ta.sma(SSV,LengthSMA) SSVf=(SSV/SSVsma) SSVf2 = na(SSVf) ? 0 : ((SSVf*-30)+30) SSVf3=SSVf2 > 1 ? SSVf2*5 : SSVf2 < -100 ? -100 : SSVf2 //plot(SSVf3) // 16. % of stocks above/below moving averages Per5MA = request.security('MMFD','D',close) Per20MA = request.security('MMTW','D',close) Per50MA = request.security('MMFI','D',close) Per100MA= request.security('MMOH','D',close) Per150MA= request.security('MMOF','D',close) Per200MA= request.security('MMTH','D',close) PerAverage=(Per5MA+Per20MA+Per50MA+Per100MA+Per150MA+Per200MA)/6 PerFin=na(PerAverage) ? 0 : (PerAverage*2)-100 //plot(PerFin) // 17. McClellan Oscillator ai = request.security('ADVN','D',close) di = request.security('DECN','D',close) rana=1000 * (ai-di)/(ai+di) e1=ta.ema(rana, 19) e2=ta.ema(rana, 39) mo=e1-e2 mcclellan = mo > 100 ? 100 : mo < -100 ? -100 : mo //plot(mcclellan) // // 18. this is just an idea for now and may be better to use GS or some other large investment bank.... let me know if you have any ideas about this // IBKR = request.financial('NASDAQ:IBKR', 'TOTAL_LIABILITIES' ,'FQ', barmerge.gaps_on) // IBKRSMA = (ta.ema(IBKR,2)) // IBKRfin = IBKR/IBKRSMA // IBKRfin2=ta.highest((((IBKRfin)-1.01)*2000),10) // plot(IBKRfin2) subTotal = ((ADD3 + VOLD3 + momo + PC4 + SvB + HvL + VIX3 + XVIvsXLP + GvVzFin + DXYz + AUDz + SPYVIXa10 + SPYVIXb20 + HisLows + SSVf3 + PerFin + mcclellan) / 8) Total = subTotal > 100 ? 100 : subTotal < -100 ? -100 : subTotal Final = ta.ema(Total,length) //coloring method below FearGradient = color.from_gradient(Final, FearFloor, FearCeiling, #17CC00, color.new(#17CC00,100)) GreedGradient= color.from_gradient(Final, GreedFloor, GreedCeiling, color.new(#FF0000,100), #FF0000) barcolor(Final > 0 ? GreedGradient : FearGradient)
Pocket Pivots and standard SMA/EMA's
https://www.tradingview.com/script/MsQ8zBt7-Pocket-Pivots-and-standard-SMA-EMA-s/
felixlanglet
https://www.tradingview.com/u/felixlanglet/
192
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/ //© @path_to_profit (Twitter Handle) - Special Thanks to DavidOConnorSpain (Pocket Pivot Indicator), and MattDeLong (10-day Swingtrading system) //@version=4 //@version =3 study(title="Pocket Pivots, SMA/EMA, and Slingshot", shorttitle="Swing Trading Indicators", precision=0,overlay =true) myMaxVolume = volume greenDay = close>open redDay = open>close //EMA Inputs emasrc1 = input(high, title="EMA Source 1") esrc0 = emasrc1, elen0 = input(04, minval=1, title="EMA 1") emasrc2 = input(close, title="EMA Source 2") esrc1 = emasrc2, elen1 = input(06, minval=1, title="EMA 2") emasrc3 = input(close, title="EMA Source 3") esrc2 = emasrc3, elen2 = input(10, minval=1, title="EMA 3") emasrc4 = input(close, title="EMA Source 4") esrc3 = emasrc4, elen3 = input(12, minval=1, title="EMA 4") emasrc5 = input(close, title="EMA Source 5") esrc4 = emasrc5, elen4 = input(20, minval=1, title="EMA 5") ema1 = ema(esrc0, elen0) ema2 = ema(esrc1, elen1) ema3 = ema(esrc2, elen2) ema4 = ema(esrc3, elen3) ema5 = ema(esrc4, elen4) //SMA inputs len1 = input(10, minval=1, title="SMA 10") out1 = sma(close, len1) len2 = input(20, minval=1, title="SMA 20") out2 = sma(close, len2) len3 = input(50, minval=1, title="SMA 50") out3 = sma(close, len3) len4 = input(200, minval=1, title="SMA 200") out4 = sma(close, len4) // Plot SMA and EMA plot(out1, title="SMA 10", linewidth=1, color = color.green, editable=true, display=display.none) plot(out2, title="SMA 20", linewidth=1, color = color.red, editable=true, display=display.none) plot(out3, title="SMA 50", linewidth=1, color = color.gray, editable=true) plot(out4, title="SMA 200", linewidth=1, color = color.black, editable=true, display=display.none) plot(ema1, title="EMA 1", linewidth=2, color = color.green, editable=true) plot(ema2, title="EMA 2", linewidth=1, color = color.aqua, editable=true, display=display.none) plot(ema3, title="EMA 3", linewidth=1, color = #1de5ff, editable=true) plot(ema4, title="EMA 4", linewidth=1, color = #f57c00, editable=true, display=display.none) plot(ema5, title="EMA 5", linewidth=2, color = #d32f2f, editable=true) // Pocket pivot rules myVolume1 = volume[1] myVolume2 = volume[2] myVolume3 = volume[3] myVolume4 = volume[4] myVolume5 = volume[5] myVolume6 = volume[6] myVolume7 = volume[7] myVolume8 = volume[8] myVolume9 = volume[9] myVolume10 = volume[10] //make all upday volumes = 0 if close[1]>open[1] myVolume1= 0 if close[2]>open[2] myVolume2= 0 if close[3]>open[3] myVolume3= 0 if close[4]>open[4] myVolume4= 0 if close[5]>open[5] myVolume5= 0 if close[6]>open[6] myVolume6= 0 if close[7]>open[7] myVolume7= 0 if close[8]>open[8] myVolume8= 0 if close[9]>open[9] myVolume9= 0 if close[10]>open[10] myVolume10= 0 // if any down days have volumes greater then the current volume, then it's not a pocket pivot pocketPivot = myVolume1 < myMaxVolume and myVolume2 < myMaxVolume and myVolume3 < myMaxVolume and myVolume4 < myMaxVolume and myVolume5 < myMaxVolume and myVolume6 < myMaxVolume and myVolume7 < myMaxVolume and myVolume8 < myMaxVolume and myVolume9 < myMaxVolume and myVolume10 < myMaxVolume insideBar = (high < high[1]) and (low > low[1] and open > out3 and close > out3) sellSignal = crossunder(close, ema3) and ema3 > ema5 and ema5>out3 and high[1] > ema3 and close > out2 candleBelow = close < out3 //only show pocket pivots on up days pocketPivotDay = pocketPivot and greenDay barColour = (insideBar) ? color.green : na resCandle = (candleBelow) ? color.orange : na slingshot = close > ema1 and close[1] < ema1[1]+(ema1[1]/100*0.5) and close[2] < ema1[2]+(ema1[2]/100*0.5) and close[3] < ema1[3]+(ema1[3]/100*0.5) plotshape(slingshot? 1:na, style=shape.square, location=location.abovebar, color=#000000, size=size.auto, title="Slingshot", editable=true) plotshape(pocketPivotDay? 1:na, style=shape.circle, location=location.belowbar, color=#000000, size=size.auto, title="Pocket Pivot Day Color", editable=true) plotshape(sellSignal, style=shape.circle, location=location.belowbar, color=color.red, size=size.auto, title="Caution Signal Color", editable=true) //plotshape(sellSignal, style=shape.flag, location=location.abovebar, color=color.gray, size=size.small) barcolor(color=barColour, title="Inside day bar color", editable=true) barcolor(color=resCandle, title="Restriction Candles", editable=true) //--------------------------------------------------------- // Support and Resistance //---------------------------------------------------------- line_width = input(1, type = input.integer, title="Resistance line width") level_min_lengh = input(3, type = input.integer, title="Set minimum number of bars from level start to qualify a level") y = input("Black", "Line Color", options=["Red", "Lime", "Orange", "Teal", "Yellow", "White", "Black"]) line_extend = input(false, type = input.bool, title = "Extend line Right") ? extend.right : extend.none sr_tf = input("", type = input.resolution, title="SR Timeframe (Beta)") //color function colour(z) => z=="Red"?color.red:z=="Lime"?color.lime:z=="Orange"?color.orange:z=="Teal"? color.teal:z=="Yellow"?color.yellow:z=="Black"?color.black:color.white //Legacy RSI calc rsi_src = close, len = 9 up1 = rma(max(change(rsi_src), 0), len) down1 = rma(-min(change(rsi_src), 0), len) legacy_rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1)) //CMO based on HMA length = 1 src1 = hma(open, 7)[1] // legacy hma(5) calculation gives a resul with one candel shift, thus use hma()[1] src2 = hma(close, 12) momm1 = change(src1) momm2 = change(src2) f1(m, n) => m >= n ? m : 0.0 f2(m, n) => m >= n ? 0.0 : -m m1 = f1(momm1, momm2) m2 = f2(momm1, momm2) sm1 = sum(m1, length) sm2 = sum(m2, length) percent(nom, div) => 100 * nom / div cmo_new = percent(sm1-sm2, sm1+sm2) //Legacy Close Pivots calcs. len5 = 2 h = highest(len5) h1 = dev(h, len5) ? na : h hpivot = fixnan(h1) l = lowest(len5) l1 = dev(l, len5) ? na : l lpivot = fixnan(l1) //Calc Values rsi_new = rsi(close,5) lpivot_new = lpivot // use legacy pivots calculation as integrated pivotlow/pivothigh functions give very different result hpivot_new = hpivot sup = rsi_new < 25 and cmo_new > 50 and lpivot_new res = rsi_new > 75 and cmo_new < -50 and hpivot_new calcXup() => var xup = 0.0 xup := sup ? low : xup[1] calcXdown() => var xdown = 0.0 xdown := res ? high : xdown[1] //Lines drawing variables tf1 = security(syminfo.tickerid, sr_tf, calcXup(), lookahead=barmerge.lookahead_on) tf2 = security(syminfo.tickerid, sr_tf, calcXdown(), lookahead=barmerge.lookahead_on) //Plot Line of Least Resistance var tf2_line = line.new(0, 0, 0, 0) var tf2_bi_start = 0 var tf2_bi_end = 0 tf2_bi_start := change(tf2) ? bar_index : tf2_bi_start[1] tf2_bi_end := change(tf2) ? tf2_bi_start : bar_index if change(tf2) if (line.get_x2(tf2_line) - line.get_x1(tf2_line)) < level_min_lengh line.delete(tf2_line) tf2_line := line.new(tf2_bi_start, tf2, tf2_bi_end, tf2, color = colour(y), width = line_width, extend = line_extend, style = line.style_dotted) line.set_x2(tf2_line, tf2_bi_end) alertcondition(change(tf1) != 0 or change(tf2) != 0 , message = "New S/R line" ) //--------------------------------------------------------- // 3 Weeks Tight //---------------------------------------------------------- iThreshold = input(title = "% threshold between closes", type = input.float, minval = .5, defval = 1.0, step = .05) iShowIndicatorLine = input(title = "Horizontal indicator at tight areas?", type = input.bool, defval = true, group = "Visual Indicators") iIndicatorStyle = input(title = " ‎ ‎ ‎ ‎ ‎Style", type=input.string, options=["Solid", "Dotted", "Dashed", "Arrow Left", "Arrow Right", "Arrow Both"], defval="Solid", group = "Visual Indicators") iIndicatorLineThickness = input(title = " ‎ ‎ ‎ ‎ ‎Thickness", type = input.integer, minval = 1, maxval = 10, defval = 2, group = "Visual Indicators") iIndicatorLineColor = input(title = " ‎ ‎ ‎ ‎ ‎Color", type = input.color, defval = #5A98C6, group = "Visual Indicators") iOffset = input(title = " ‎ ‎ ‎ ‎ ‎Offset up/down", type = input.integer, minval = -5, maxval = 5, defval = 1, step = .1, group = "Visual Indicators") iShowVerticalBars = input(title = "Vertical band at tight areas?", type = input.bool, defval = true, group = "Visual Indicators") iShowBuyPrice = input(title = "Show buy price at tight area?", type = input.bool, defval = true, group = "Buy Price") iBuyPriceOffset = input(title = "Buy price offset up/down", type = input.integer, minval = 0, maxval = 15, defval = 5, step = .5, group = "Buy Price") iTextSizeOption = input(title = "Text size", type = input.string, options=["Normal", "Large", "Huge"], defval = "Normal", group = "Buy Price") // Only show content if on a weekly timeframe onWeeklyChart = timeframe.isweekly highestHigh = max(high, high[1], high[2]) //--------------------------------------------------------- // Calculate % change between closes //---------------------------------------------------------- percentChange1 = ((close - close[1]) / close[1]) * 100 percentChange2 = ((close[1] - close[2]) / close[2]) * 100 //--------------------------------------------------------- // 3 weeks tight if closes meet threshold //---------------------------------------------------------- threeWeeksTight = (abs(percentChange1) <= iThreshold) and (abs(percentChange2) <= iThreshold) lineStyle = (iIndicatorStyle == "Dotted") ? line.style_dotted : (iIndicatorStyle == "Dashed") ? line.style_dashed : (iIndicatorStyle == "Arrow Left") ? line.style_arrow_left : (iIndicatorStyle == "Arrow Right") ? line.style_arrow_right : (iIndicatorStyle == "Arrow Both") ? line.style_arrow_both : line.style_solid //--------------------------------------------------------- // Draw horizontal line above three weeks tight //---------------------------------------------------------- if (onWeeklyChart and threeWeeksTight and iShowIndicatorLine) line.new(bar_index[2], high + iOffset, bar_index, high + iOffset, style = lineStyle, width = iIndicatorLineThickness, color = iIndicatorLineColor) //--------------------------------------------------------- // Show vertical bar indicating tight area? //---------------------------------------------------------- bgcolor(onWeeklyChart and iShowVerticalBars and threeWeeksTight ? #5A98C6 : na, editable = false) bgcolor(onWeeklyChart and iShowVerticalBars and threeWeeksTight ? #5A98C6 : na, offset = -1, editable = false) bgcolor(onWeeklyChart and iShowVerticalBars and threeWeeksTight ? #5A98C6 : na, offset = -2, editable = false) //--------------------------------------------------------- // Optional alert when 3 weeks tight is detected //---------------------------------------------------------- alertcondition(threeWeeksTight, title="3 Weeks Tight", message="3 Weeks Tight pattern has been found.") //--------------------------------------------------------- // Round to specified number of decimal places //---------------------------------------------------------- fRound(_number, _decimals) => power = pow(10, _decimals) int(_number * power) / power //--------------------------------------------------------- // Label showing highest high of the tight range //---------------------------------------------------------- fontSize = (iTextSizeOption == "Normal") ? size.normal : (iTextSizeOption == "Large") ? size.large : size.huge var label labelID = label.new(x = na, y = na, textcolor = color.white, color = #15B72C, size = fontSize, tooltip = "Highest high of the tight area + ten cents.") if (onWeeklyChart and threeWeeksTight and iShowBuyPrice) // Notice the buy price is $.1 above the highest high, // the traditional CANSLIM entry to ensure push through resistance label.set_text(id = labelID, text = "Buy price: \n" + tostring(fRound(highestHigh + .1, 2))) label.set_x(id = labelID, x = bar_index) label.set_y(id = labelID, y = high + iBuyPriceOffset)
RVOL Relative Volume - Intraday
https://www.tradingview.com/script/tCblSVVi-RVOL-Relative-Volume-Intraday/
LonesomeTheBlue
https://www.tradingview.com/u/LonesomeTheBlue/
2,994
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LonesomeTheBlue var tooltip1 = "The more recent the data is, the more relevant it is. Longer period baselines have lower volumes. This creates too much noise when we generate our results." //@version=5 indicator("RVOL Relative Volume - Intraday", "RVOL", max_lines_count = 500, precision = 2) period = input.int(defval = 5, title = "Number of Days", minval = 1, maxval = 55, tooltip = tooltip1) // Chart time frame must be ">=1min" and less than 1Day to run the script if not timeframe.isintraday or timeframe.isseconds runtime.error("Chart time frame must be less than 1 Day and greater/equal 1 minute") hline(0.0, linestyle = hline.style_solid) hline(0.5, linestyle = hline.style_dotted) hline(1.0, linestyle = hline.style_dashed) hline(1.5, linestyle = hline.style_dotted) hline(2.0, linestyle = hline.style_dashed) // get current bar time as hour/minute int hour_ = math.floor(time / 3600000) % 24 int minute_ = math.floor(time / 60000) % 60 // *24*60 => 1 day, *2 is used to make the day 48 hours because session start time may change sometimes and also it may start (say) at 17:00 and ends at 02:00 // this method is used to calculate exact rvol, other methods may give false results var rvols = array.new_float(24 * 60 * 2 * (period + 1), 0) // new session started? bool newday = ta.change(time('D')) != 0 // this is used to make the day 48 hours var plus24 = 0 if newday plus24 := 0 for x = 1 to 2880 array.shift(rvols) array.push(rvols, 0) // get bar time int ctime_ = hour_ * 60 + minute_ // calculate addition if ctime_ < ctime_[1] and not newday plus24 := 1440 // convert bar time to index (48 hours) int ctime = ctime_ + plus24 // draw vertical line at the beginning of the Session if newday line.new(x1 = bar_index, y1 = 0, x2 = bar_index, y2 = 1, color = color.gray, style = line.style_dashed, extend = extend.right) // keep the current cumulative volume at related element in the array array.set(rvols, period * 2880 + ctime, newday ? volume : array.get(rvols, period * 2880 + ctime[1]) + volume) // calculate relative volume relativeVolume()=> float hvol = 0//array.sum(array.slice(rvols, x * 2880 + ctime) for x = 0 to period - 1 svol = array.get(rvols, x * 2880 + ctime) // if it missing hour in last days, get sum from last hour(s) if svol == 0 for y = x * 2880 + ctime to x * 2880 svol := array.get(rvols, y) if svol != 0 break hvol += svol / period cvol = array.get(rvols, period * 2880 + ctime) rvol = hvol == 0 ? 0 : cvol / hvol RVOL = relativeVolume() // plot relative volume plot(RVOL, style = plot.style_columns, color = close >= open ? color.rgb(0, math.max(math.min(RVOL * 130, 255), 130), 0, 0) : color.rgb(math.max(math.min(RVOL * 130, 255), 130), 0, 0, 0))
Sessions Rainbow EST with overlaps
https://www.tradingview.com/script/V0wj4uwr-Sessions-Rainbow-EST-with-overlaps/
jlc3fx
https://www.tradingview.com/u/jlc3fx/
27
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jlc3fx //@version=5 indicator("Sessions Rainbow EST with overlaps", overlay=true) frankfurt = time(timeframe.period, "0200-0300") london = time(timeframe.period, "0300-0800") london_newyork = time(timeframe.period, "0800-1100") newyork = time(timeframe.period, "1100-1600") sidney = time(timeframe.period, "1600-1800") sidney_tokyo = time(timeframe.period, "1800-0000") tokyo = time(timeframe.period, "0000-0200") Sidney = na(sidney) ? na : color.new(#FF0000, 90) // Red Sidney_tokyo = na(sidney_tokyo) ? na : color.new(#FF7F00, 90) // Orange Tokyo = na(tokyo) ? na : color.new(#FFFF00, 90) // Yellow Frankfurt = na(frankfurt) ? na : color.new(#00FF00, 90) // Green London = na(london) ? na : color.new(#0000FF, 90) // Blue London_newyork = na(london_newyork) ? na : color.new(#4B0082, 90) // Indigo Newyork = na(newyork) ? na : color.new(#9400D3, 90) // Violet bgcolor(Frankfurt , title="Frankfurt") bgcolor(London , title="London") bgcolor(London_newyork, title="London NewYork") bgcolor(Newyork , title="NewYork") bgcolor(Sidney , title="Sidney") bgcolor(Sidney_tokyo , title="Sidney Tokyo") bgcolor(Tokyo , title="Tokyo")
Meu Script 44
https://www.tradingview.com/script/K3N0s8mg-Meu-Script-44/
jacobfabris
https://www.tradingview.com/u/jacobfabris/
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/ // © jacobfabris //@version=4 study("Meu Script 44",overlay = true) s1 = alma(close,17,0.786,3.236) s2 = alma(close,72,0.786,3.236) s3 = alma(close,305,0.786,3.236) s4 = alma(close,1292,0.786,3.236) plotshape(s1, style= shape.diamond, location = location.absolute , color = color.green, text = "17", show_last= 1) plotshape(s2, style= shape.diamond, location = location.absolute , color = color.yellow, text = "72", show_last= 1) plotshape(s3, style= shape.diamond, location = location.absolute , color = color.orange, text = "305", show_last= 1) plotshape(s4, style= shape.diamond, location = location.absolute , color = color.red, text = "1292", show_last= 1) p1 = plot(s1,transp=100) p2 = plot(s2,transp=100) p3 = plot(s3,transp=100) p4 = plot(s4,transp=100) fill( p1 , p2, color = color.green, transp=70) fill( p2 , p3, color = color.yellow, transp=70) fill( p3 , p4, color = color.red, transp=70)
Kzx PT mod v1.0 by RX-RAY
https://www.tradingview.com/script/c13XuoOS-kzx-pt-mod-v1-0-by-rx-ray/
RX-RAY
https://www.tradingview.com/u/RX-RAY/
93
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © K-zax + fair use RX-RAY MOD. //@version=4 study(title="Kzx PT mod v1.0 by RX-RAY", shorttitle="Kzx PT mod v1.0 by RX-RAY", overlay=true) //================================================================================================================================================== // // IMPUT // //================================================================================================================================================== // ENTRY ENTRY_SIDE = input(defval="Undefined", title="Position Side", options=["Undefined", "SHORT", "LONG"], group = "Entry") ENTRY_PRICE = input(defval=0.0, title="Price", type=input.float, minval=0, group = "Entry") BROKER_COM = input(defval=0.0, title="Broker comission, %", type=input.float, group = "Entry") ENTRY_AS_TIME = input(title="Entry Time", type=input.bool, defval=false, group = "Entry", inline = "Entry Time") ENTRY_TIME = input(defval = timestamp("03 Apr 2021 10:45 +0000"), title = "", type = input.time, group = "Entry", inline = "Entry Time") ENTRY_POS = input(defval = 0, title="POSITION", type=input.integer,minval=0, group = "Entry" ) // STOP LOSS AS_SL = input(title="Stop Loss", type=input.bool, defval=false, group = "Stop Loss", inline = "SL") SL_PRICE = input(defval=0.0, title="Price", type=input.float, minval=0, group = "Stop Loss", inline = "SL") // TAKE PROFIT AS_TP = input(title="Take Profit", type=input.bool, defval=false, group = "Take Profit", inline = "TP") TP_PRICE = input(defval=0.0, title="Price", type=input.float, minval=0, group = "Take Profit", inline = "TP") // DISPLAY OFFSET = input(defval=2, title="offset", type=input.integer, minval=2, group = "Display") LABEL_OFFSET = input(defval=2, title="Label offset", type=input.integer, minval=2, group = "Display") ENTRY_COLOR = input(title="Entry", type=input.color, defval=color.yellow) SL_COLOR = input(title="SL", type=input.color, defval=#cc141e) TP_COLOR = input(title="TP", type=input.color, defval=#2caa83) LOSS_COLOR = input(title="Loss", type=input.color, defval=#cc141e) GAIN_COLOR = input(title="Gain", type=input.color, defval=#2caa83) CRIT_COLOR = input(title="Critical gain", type=input.color, defval=color.yellow) BG_COLOR = input(title="Background", type=input.color, defval=#2d2d2e) LEVEL_WIDTH = input(defval=1, title="Level Line Width", type=input.integer, minval=1) STATUS_WIDTH = input(defval=2, title="Status Line Width", type=input.integer, minval=1) //================================================================================================================================================== // // INDICATOR // //================================================================================================================================================== // DISPLAY CONDITIONS var isShort = ENTRY_SIDE == "SHORT" ? true : false var isLong = ENTRY_SIDE == "LONG" ? true : false var isActive = (isShort or isLong) and ENTRY_PRICE > 0.0 ? true : false var slIsValid = SL_PRICE > 0 and ((isShort and SL_PRICE > ENTRY_PRICE) or (isLong and SL_PRICE < ENTRY_PRICE)) var slIsActive = isActive and AS_SL and slIsValid var tpIsValid = TP_PRICE > 0 and ((isShort and TP_PRICE < ENTRY_PRICE) or (isLong and TP_PRICE > ENTRY_PRICE)) var tpIsActive = isActive and AS_TP and tpIsValid // INDICATOR OFFSET timeOffset = time[1] - time[2] baseOffset = time + OFFSET * timeOffset //xLabel = baseOffset + (timeOffset * LABEL_OFFSET) xLabel = time + (OFFSET + LABEL_OFFSET) * timeOffset pnlStatus = 0 color pnlColor = na pnlPercent = 0.0 if (isActive) pnlStatus := (isShort and close < ENTRY_PRICE) or (isLong and close > ENTRY_PRICE) ? 1 : -1 pnlColor := pnlStatus == 1 ? GAIN_COLOR : LOSS_COLOR pnlPercent := pnlStatus * floor((abs((close / ENTRY_PRICE) - 1 )) * 10000) / 100 pnlCom = floor( ENTRY_POS * 1000 / 100 * BROKER_COM * 2 + 0.5) pnlPosSt = floor((ENTRY_PRICE - close) * ENTRY_POS * 1000 / close - pnlCom) pnlPosLg = floor((close - ENTRY_PRICE) * ENTRY_POS * 1000 / close - pnlCom) pnlPos = isShort ? pnlPosSt : isLong ? pnlPosLg : 0 pnlColorM = ( pnlColor == GAIN_COLOR and pnlPos < 0 ) ? CRIT_COLOR : pnlColor sideM = isShort ? "[S]" : "[L]" slPnlPercent = 0.0 if (slIsActive) slPnlPercent := floor(abs((SL_PRICE / ENTRY_PRICE) - 1 ) * -10000) / 100 tpPnlPercent = 0.0 if (tpIsActive) tpPnlPercent := floor(abs((TP_PRICE / ENTRY_PRICE) - 1 ) * 10000) / 100 //================================================================================================================================================== // // DISPLAY // //================================================================================================================================================== // BG var line bgLine = na if (isActive and (slIsActive or tpIsActive)) line.delete(bgLine) y1 = isLong and AS_SL ? SL_PRICE : isShort and AS_TP ? TP_PRICE : ENTRY_PRICE y2 = isShort and AS_SL ? SL_PRICE : isLong and AS_TP ? TP_PRICE : ENTRY_PRICE bgLine := line.new(x1 = baseOffset, y1 = y1, x2 = baseOffset, y2 = y2, xloc = xloc.bar_time, extend = extend.none, color = BG_COLOR, style = line.style_solid, width=STATUS_WIDTH) // SL var line slLine = na var label slLabel = na if (slIsActive) line.delete(slLine) label.delete(slLabel) slLine := line.new(x1 = time, y1=SL_PRICE, x2 = baseOffset, y2=SL_PRICE, xloc = xloc.bar_time, extend = extend.none, style = line.style_solid, color=SL_COLOR, width=LEVEL_WIDTH) slLabel := label.new(text = " "+tostring(SL_PRICE, "#.00")+' | '+tostring(slPnlPercent, "0.00")+' %', x = xLabel, y = SL_PRICE, textcolor= SL_COLOR, xloc = xloc.bar_time, style = label.style_none) // TP var line tpLine = na var label tpLabel = na if (tpIsActive) line.delete(tpLine) label.delete(tpLabel) tpLine := line.new(x1 = time, y1=TP_PRICE, x2 = baseOffset, y2=TP_PRICE, xloc = xloc.bar_time, extend = extend.none, style = line.style_solid, color=TP_COLOR, width=LEVEL_WIDTH) tpLabel := label.new(text = " "+tostring(TP_PRICE, "#.00")+' | '+tostring(tpPnlPercent, "0.00")+' % ', x = xLabel, y = TP_PRICE, textcolor= TP_COLOR, xloc = xloc.bar_time, style = label.style_none) // ENTRY var line entryLine = na var label entryLabel = na var line statusLine = na var label statusLabel = na if (isActive) line.delete(entryLine) label.delete(entryLabel) line.delete(statusLine) label.delete(statusLabel) x1 = ENTRY_AS_TIME and ENTRY_TIME < timenow ? ENTRY_TIME : time // Entry entryLine := line.new(x1 = x1, y1=ENTRY_PRICE, x2 = baseOffset, y2=ENTRY_PRICE, xloc = xloc.bar_time, extend = extend.none, style = line.style_solid, color=ENTRY_COLOR, width=LEVEL_WIDTH) entryLabel := label.new(text = ' ' +tostring(ENTRY_PRICE, "#.00") +' | '+tostring(pnlPercent, pnlPercent >= 0 ? " 0.00" : "0.00")+'% | '+tostring(ENTRY_POS)+' '+tostring(sideM)+' '+tostring(pnlPos, pnlPos >=0 ? " 0000" : "0000" )+' $', x = xLabel, y = ENTRY_PRICE, textcolor = pnlColorM , xloc = xloc.bar_time, style = label.style_none) // Status statusLine := line.new(x1 = baseOffset, y1 = ENTRY_PRICE, x2 = baseOffset, y2 = close, xloc = xloc.bar_time, extend = extend.none, color = pnlColor, style = line.style_solid, width=STATUS_WIDTH)
Median Convergence Divergence
https://www.tradingview.com/script/odyzZlzU-Median-Convergence-Divergence/
maksumit
https://www.tradingview.com/u/maksumit/
529
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © maksumit //@version=5 indicator("Median Convergence Divergence", "MCD", timeframe="", timeframe_gaps=true) //Inputs fast = input.int(5, "Fast Length", 1) slow = input.int(20, "Slow Length", 1) src = input.source(close, "Source") signal = input.int(10, "Signal Length", 1) //Median, Median Convergence Divergence, Signal and Histogram medianF = ta.median(src, fast) medianS = ta.median(src, slow) mcd = medianF - medianS mcds = ta.median(mcd, signal) hist = mcd - mcds //Plots plot(hist, "Histogram", style=plot.style_columns, color=hist<hist[1] and hist>0 ? color.green:hist>0 ? color.lime:hist>hist[1] ? color.maroon:color.red) plot(mcds, "Signal Line", color=color.orange, linewidth=2) plot(mcd, "MCD Line", color=color.blue, linewidth=2) hline(0, "Zero Line")
Cash Gaps on a Future/CFD-Chart
https://www.tradingview.com/script/qIB79unm/
mgruner
https://www.tradingview.com/u/mgruner/
53
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/ // © NgUTech // extended based on the original version by NgUTech // *****Purpose of the script is to polot the cash-index gaps into the future (or CFD) chart in order to fade gaps of the cash-index //@version=4 study(title="Mind the Gap GM", shorttitle="Gaps", overlay=true, max_bars_back=5000) //threshold set to zero to show all gaps threshold = input(title="Threshold Percentage", type=input.float, defval=0.000, minval=0, maxval=1, step=0.001) background_color = input(title="Background Color", type=input.color, defval=color.rgb(156, 39, 176, 80)) border_color = input(title="Border Color", type=input.color, defval=color.purple) border_width = input(title="Border Width", type=input.integer, defval=0, minval=0) max_box_length = input(title="Maximum Box Length (bars) - reduce this if getting an error about 'left' being too far or whatever", type=input.integer, defval=10000, minval=0) //the Symbol of the underlying cash index cashIndex = input(title="Cash-Index Symbol", type=input.string, defval="DAX") // current spread between the cash-index and the future/cfd Spread = input(title="Spread Cash-Future", type=input.integer, defval=10) var gap_top = array.new_float(0) var gap_bottom = array.new_float(0) var gap_bar = array.new_int(0) [CILow,CIHigh]=security(cashIndex,"D",[low, high]) [CIOpen,CIClose]=security(cashIndex,"D",[open, close]) gap_down = CIOpen < CIClose[1] gap_up = CIOpen > CIClose[1] if gap_down array.push(gap_top, CIClose[1]) array.push(gap_bottom, CIOpen[0]) array.push(gap_bar, bar_index - 1) if gap_up array.push(gap_top, CIOpen[0]) array.push(gap_bottom, CIClose[1]) array.push(gap_bar, bar_index - 1) num_removed = 0 size = array.size(gap_top) if size > 0 for i = 0 to size - 1 g_top = array.get(gap_top, i - num_removed) g_bottom = array.get(gap_bottom, i - num_removed) if CIHigh >= g_top and CILow < g_top array.set(gap_top, i - num_removed, CILow[0]) g_top := CILow[0] else if CIHigh > g_bottom and CILow <= g_bottom array.set(gap_bottom, i - num_removed, CIHigh[0]) g_bottom := CIHigh[0] else if CIHigh < g_top and CILow > g_bottom if CIClose[1] < g_bottom array.set(gap_bottom, i - num_removed, CIHigh[0]) g_bottom := CIHigh[0] else array.set(gap_top, i - num_removed, CILow[0]) g_top := CILow[0] if (g_top <= CIHigh and g_bottom >= CILow) or ((g_top - g_bottom)/g_bottom < threshold) or (((CILow[1] < g_bottom and CIHigh > g_top) or (CIHigh[1] > g_top and CILow < g_bottom)) and not ((gap_up or gap_down) and i == size - 1)) array.remove(gap_top, i - num_removed) array.remove(gap_bottom, i - num_removed) array.remove(gap_bar, i - num_removed) num_removed += 1 if barstate.islast if array.size(gap_top) > 0 for i = 0 to array.size(gap_top) - 1 if bar_index - array.get(gap_bar, i) < max_box_length box.new(left=array.get(gap_bar, i), top=array.get(gap_top, i) - Spread, right=bar_index, bottom=array.get(gap_bottom, i) - Spread , border_color=border_color, border_width=border_width, extend=extend.right, xloc=xloc.bar_index, bgcolor=background_color)//border_style, extend, xloc
Kitti-Playbook Fibonacci retracement GAGE Click Start
https://www.tradingview.com/script/Jf5kDCnd-Kitti-Playbook-Fibonacci-retracement-GAGE-Click-Start/
Kittimasak_S
https://www.tradingview.com/u/Kittimasak_S/
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/ // © Kittimasak_S //@version=5 indicator("Kitti-Playbook Fibonacci retracement GAGE Click Start R0.1",overlay=true) // Date Apr 13 2023R0.1 // 1) Addition Setting TEXT size menu for display Fibonacci Value and currency // 2) Addition Unit of Currency for display Fibonacci Value and currency // 3) Debug for small digit currency display for 2 digit to Mintick // Date Jan 9 2022 DEBUG Miss operation for Minimum line Line Calculation // Date Jan 1 2022 // OVERVIEW :Kitti-Playbook Fibonacci retracement GAGE R0.00 // Easy for visualize Fibonacci retracement level // CONCEPTS // 0)Point and Click on chart to point Origin // 1)Calculate Minimum Line from Origin point // 2)Calculate Maximum Line from New Low // 3)Calculation Fibo scale // a) Fibonacci Retracement of 61.8% form Maximum level , Defaultf Suorce = close // b) Fibonacci Retracement of 78.6% form Maximum level . Defaultf Suorce = close // c) Fibonacci Retracement of 88.7% form Maximum level // d) Fibonacci Retracement of 94.2% form Maximum level // 4)Information Display // GAGE Scale Number from origin point // Highest Lowest Value from origin point LabelSW= input.bool(title="Show Fibonacci ", defval=true) LabelSW1= input.bool(title="Show Lowest - Highes level ", defval=false) LabelSW2= input.bool(title="Show Lowest - Highes label ", defval=false) Front0=input.string(size.normal,"Fibonacci Text Size",options= [ size.tiny, size.small, size.normal, size.large, size.huge], group='Fibinacci Display Setting') // // ==> 1)Minimum Line = Lowest level of Source form start // 0)Point and Click on chart to point Origin startCalculationDate = input.time(timestamp("1 Dec 2021"), "Origin point by Point then CLICK on chart", confirm=true) // 1)Calculate Minimum Line from Origin point i_aSource=input.source(close, "Source Min",group="Fibo Source",inline= "A") Low_calc() => var srcLowArray = array.new_float(na) var srcHighArray = array.new_float(na) var srcSurArray = array.new_float(na) if startCalculationDate <= time array.push(srcLowArray, low) // LL Line array.push(srcHighArray, high) // HH Line array.push(srcSurArray, i_aSource) else array.clear(srcLowArray) array.clear(srcHighArray) array.clear(srcSurArray) [array.min(srcLowArray),array.max(srcHighArray),array.min(srcSurArray),array.max(srcSurArray) ] [Low_Line,High_Line,aMin0,bMax0a] = Low_calc() float x=na x :=aMin0 if x > x[1] x := x[1] else x := x aMin = x //---------- Check and count Minimum Points HL=i_aSource>aMin[1] and i_aSource[1]==aMin HLC=HL==true?1:0 Count_HL=ta.cum(HLC) //Count Minimum Points BSLL=ta.barssince(HL) *0.001 //plot(BSLL) // 2)Calculate Maximum Line from New Low i_bstart= 0 i_bend= 1 i_bSource=input.source(close, "Source Max",group="Fibo Source",inline= "A") b = array.new_float(0) for i = i_bstart to i_bend array.push(b, i_bSource[i]) bMax0 = math.round_to_mintick(array.max(b)) float y=na //y :=bMax0 y :=bMax0 // Confirm New Low for Set New HHV if y < y[1] and BSLL > 0 y := y[1] else y := y bMax = y P_Low_Line = LabelSW1 ? Low_Line : na P_High_Line = LabelSW1 ? High_Line : na plot(P_Low_Line, "Lower Low",color=color.new(color.green,50) ,linewidth=1) plot(P_High_Line, "High High", color=color.new(color.green,50),linewidth=1) // 3)Calculation Fibo scale // a) Fibonacci Retracement of 61.8% form Maximum level , Defaultf Suorce = close // b) Fibonacci Retracement of 78.6% form Maximum level . Defaultf Suorce = close // c) Fibonacci Retracement of 88.7% form Maximum level // d) Fibonacci Retracement of 94.2% form Maximum level Range=math.round_to_mintick(bMax-aMin) L618=LabelSW ? math.round_to_mintick(bMax-Range*0.618) :na L786=LabelSW ? math.round_to_mintick(bMax-Range*0.786) :na L887=LabelSW ? math.round_to_mintick(bMax-Range*0.887) :na L942=LabelSW ? math.round_to_mintick(bMax-Range*0.942) :na P_aMin = LabelSW ? aMin :na P_bMax = LabelSW ? bMax :na bMax_Col= startCalculationDate <= time ? color.new(color.yellow,50) : na plot(P_aMin,"Min 0%",color=color.new(color.red,50)) plot(P_bMax,"Max 100%",color=bMax_Col) // Plot Color_Line=color.new(#888888,50) L6 =plot(L618 , "61.8", color=Color_Line) L7=plot(L786 , "78.6", color=Color_Line) L8=plot(L887 , "88.7", color=Color_Line) L9=plot(L942,"94.2", color=Color_Line) i_ColRangeH = input.color(color.new(color.orange,90), "Waiting Zone") i_ColRangeL = input.color(color.new(color.blue,70), "Action Zone") ColorFill=color.from_gradient(close,aMin+Range*.1,bMax-0.5*Range,i_ColRangeL,i_ColRangeH) fill(L6,L9,color=ColorFill ) // 4)Information Display // GAGE Scale Number from origin point // Highest Lowest Value from origin point bc=#88888888 styleUpDwn= label.style_none ylocatPrice = yloc.price //------------ Max ,61.8 78.6 88.7 94.2 min ) lMax = label.new(bar_index, bMax, text= "0.00% = " +str.tostring(bMax ) + " "+syminfo.currency , color=bc, style= styleUpDwn, textcolor=color.new(#888888,20),size=Front0 , yloc=ylocatPrice ) label.delete(LabelSW? lMax[1] : lMax) l618 = label.new(bar_index, L618, text= "61.8% = " +str.tostring(L618 )+ " "+syminfo.currency, color=bc, style= styleUpDwn, textcolor=color.new(#888888,20), size=Front0 ,yloc=ylocatPrice ) label.delete(LabelSW? l618[1] : l618) l786 = label.new(bar_index, L786, text= "78.6% = " +str.tostring(L786 )+ " "+syminfo.currency, color=bc, style= styleUpDwn, textcolor=color.new(#888888,20), size=Front0 ,yloc=ylocatPrice ) label.delete(LabelSW? l786[1] : l786) l887 = label.new(bar_index, L887, text= "88.7% = " +str.tostring(L887 )+ " "+syminfo.currency, color=bc, style= styleUpDwn, textcolor=color.new(#888888,20), size=Front0 ,yloc=ylocatPrice ) label.delete(LabelSW? l887[1] : l887) l942 = label.new(bar_index, L942, text= "94.2% = " +str.tostring(L942 )+ " "+syminfo.currency, color=bc, style= styleUpDwn, textcolor=color.new(#888888,20), size=Front0 ,yloc=ylocatPrice ) label.delete(LabelSW? l942[1] : l942) laMin = label.new(bar_index, aMin, text= " 100% = " +str.tostring(math.round_to_mintick(aMin))+ " "+syminfo.currency, color=bc, style= styleUpDwn, textcolor=color.new(#888888,20), size=Front0 ,yloc=ylocatPrice ) label.delete(LabelSW? laMin[1] : laMin) label.delete(LabelSW? laMin[1] : laMin) // --------------------- Highest Lowest label --------------------------------- LLV = label.new(bar_index, P_Low_Line , text= "Lowest = " +str.tostring(math.round_to_mintick(P_Low_Line ))+ " "+syminfo.currency, color=bc, style= styleUpDwn, textcolor=color.new(#888888,20), size=Front0 ,yloc=ylocatPrice ) label.delete(LabelSW2? LLV[1] : LLV) HHV = label.new(bar_index, P_High_Line , text= "Highest = " +str.tostring(math.round_to_mintick(High_Line ))+ " "+syminfo.currency, color=bc, style= styleUpDwn, textcolor=color.new(#888888,20), size=Front0 ,yloc=ylocatPrice ) label.delete(LabelSW2? HHV[1] : HHV) /////////////////////////// END //////////////////////////////////////
rv_iv_vrp
https://www.tradingview.com/script/8SovCBDc-rv-iv-vrp/
voided
https://www.tradingview.com/u/voided/
170
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © voided //@version=5 indicator("rv_iv_vrp") // inputs sym = input.string("SPX", "symbol", options = [ "SPX", "NDX", "RUT", "DJX", "TLT", "FXI", "EFA", "EEM", "EWZ", "USO", "GC1!", "GDX", "SLV", "FXE", "AAPL", "AMZN", "GOOG", "GS", "IBM" ]) iv_sym = sym == "SPX" ? "VIX" : sym == "NDX" ? "VXN" : sym == "RUT" ? "RVX" : sym == "DJX" ? "VXD" : sym == "TLT" ? "VXTLT" : sym == "FXI" ? "VXFXI" : sym == "EFA" ? "VXEFA" : sym == "EEM" ? "VXEEM" : sym == "EWZ" ? "VXEWZ" : sym == "USO" ? "OVX" : sym == "GC1!" ? "GVZ" : sym == "GDX" ? "VXGDX" : sym == "SLV" ? "VXSLV" : sym == "FXE" ? "EVZ" : sym == "AAPL" ? "VXAPL" : sym == "AMZN" ? "VXAZN" : sym == "GOOG" ? "VXGOG" : sym == "GS" ? "VXGS" : sym == "IBM" ? "VXIBM" : na start = input.time(timestamp("1 Jan 1900"), "start") end = input.time(timestamp("1 Jan 2100"), "end") // securities ul = request.security(sym, "D", close) iv = request.security(iv_sym, "D", close) / 100 // volatility squared_returns = math.pow(math.log(ul / ul[1]), 2) smoothed_returns = ta.ema(squared_returns, 20) rv = math.sqrt(smoothed_returns * 252) vrp = iv - rv // data collection var float[] ivs = array.new_float() var float[] rvs = array.new_float() var float[] vrps = array.new_float() in_range = time >= start and time < end if in_range array.push(ivs, iv) array.push(rvs, rv) array.push(vrps, vrp) in_clr = color.new(color.gray, 98) bgcolor(in_range ? in_clr : na) // output current_color = rv >= iv ? color.red : color.blue plot(iv, color = color.new(color.gray, 85)) plot(rv, color = current_color) if barstate.islast // median and percentile array.sort(ivs) iv_pct = array.indexof(ivs, iv) / array.size(ivs) array.sort(rvs) rv_pct = array.indexof(rvs, rv) / array.size(rvs) array.sort(vrps) vrp_pct = array.indexof(vrps, vrp) / array.size(vrps) iv_med = array.median(ivs) rv_med = array.median(rvs) vrp_med = array.median(vrps) // colors and formatting iv_lbl_clr = color.new(iv > iv_med ? color.red : color.blue, 70) iv_data_clr = color.new(iv > iv_med ? color.red : color.blue, 70) rv_lbl_clr = color.new(current_color, 70) rv_data_clr = color.new(current_color, 90) vrp_lbl_clr = color.new(vrp > vrp_med ? color.red : color.blue, 70) vrp_data_clr = color.new(vrp > vrp_med ? color.red : color.blue, 90) med_lbl_clr = color.new(color.fuchsia, 70) med_data_clr = color.new(color.fuchsia, 90) fmt = "#.###" // table t = table.new(position.middle_right, 2, 9) table.cell(t, 0, 0, "iv", bgcolor = iv_lbl_clr) table.cell(t, 1, 0, str.tostring(iv, fmt), bgcolor = iv_data_clr) table.cell(t, 0, 1, "iv %", bgcolor = iv_lbl_clr) table.cell(t, 1, 1, str.tostring(iv_pct, fmt), bgcolor = iv_data_clr) table.cell(t, 0, 2, "iv median", bgcolor = med_lbl_clr) table.cell(t, 1, 2, str.tostring(iv_med, fmt), bgcolor = med_data_clr) table.cell(t, 0, 3, "rv", bgcolor = rv_lbl_clr) table.cell(t, 1, 3, str.tostring(rv, fmt), bgcolor = rv_data_clr) table.cell(t, 0, 4, "rv %", bgcolor = rv_lbl_clr) table.cell(t, 1, 4, str.tostring(rv_pct, fmt), bgcolor = rv_data_clr) table.cell(t, 0, 5, "rv median", bgcolor = med_lbl_clr) table.cell(t, 1, 5, str.tostring(rv_med, fmt), bgcolor = med_data_clr) table.cell(t, 0, 6, "vrp", bgcolor = vrp_lbl_clr) table.cell(t, 1, 6, str.tostring(vrp, fmt), bgcolor = vrp_data_clr) table.cell(t, 0, 7, "vrp %", bgcolor = vrp_lbl_clr) table.cell(t, 1, 7, str.tostring(vrp_pct, fmt), bgcolor = vrp_data_clr) table.cell(t, 0, 8, "vrp median", bgcolor = med_lbl_clr) table.cell(t, 1, 8, str.tostring(vrp_med, fmt), bgcolor = med_data_clr) // iv/rv median line.new(x1 = time_close - bar_index * (24 * 60 * 60 * 1000), y1 = iv_med, x2 = time_close, y2 = iv_med, color = color.new(color.fuchsia, 70), xloc = xloc.bar_time) line.new(x1 = time_close - bar_index * (24 * 60 * 60 * 1000), y1 = rv_med, x2 = time_close, y2 = rv_med, color = color.fuchsia, xloc = xloc.bar_time)
Signal Table - AutoFib - SMA - EMA - RSI - ATR - Vol
https://www.tradingview.com/script/mhl1Fgp1/
only_fibonacci
https://www.tradingview.com/u/only_fibonacci/
3,727
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © only_fibonacci //@version=5 indicator("Multicator Table",overlay=true) dil = input.string(defval = "EN", title = "Language" , options = ["EN", "TR"]) yaziRenk = input.color(defval = color.black, title = "Text Color") en = dil == "EN" tr = dil == "TR" fibUst = en ? "Top ( " : "Tepe ( " fibAlt = en ? "Bottom ( " : "Dip ( " mobilGoster = input.bool(false,"Is mobile ?") tabloGoster = input.bool(true,"Show Desktop Table ?") tabloYonu = input.string(defval = "Sağ Üst", title = "Tablo Yönü", options=["Sağ Üst","Sağ Alt","Sağ Orta","Orta Alt","Orta Sol"]) tabloBuyukluk = input.string(defval = "Küçük", title = "Tablo Boyutu", options = ["Küçük","Büyük","Orta"]) fibonacciGoster=input.bool(false,"Show Fibonacci Retracement", group = "Fibonacci") fibonacciExtendRight = input.bool(defval = true,title = "Fibonacci Extend Right", group = "Fibonacci" , inline = "FG") fibShowData = input.bool(defval = true,title = "Fibonacci Show Data", group = "Fibonacci" , inline = "FG") uzunluk=input.int(233, minval=8, title="Fibonacci Distance", group = "Fibonacci") fibTepe = ta.highest(uzunluk) fibDip = ta.lowest(uzunluk) fibColor = input.color(defval = color.black, title = "Fibonacci Color", group = "Fibonacci") tepeyeUzaklik = math.abs(ta.highestbars(uzunluk)) dipeUzaklik = math.abs(ta.lowestbars(uzunluk)) yon = switch tabloYonu "Sağ Üst" => position.top_right "Sağ Alt" => position.bottom_right "Sağ Orta" => position.middle_right "Orta Alt" => position.bottom_center "Orta Sol" => position.bottom_left buyuk = switch tabloBuyukluk "Küçük" => size.small "Büyük" => size.large "Orta" => size.normal var table mobiletablo = table.new(position.bottom_right,2,6,border_width=4,border_color=color.gray, frame_color=color.gray, frame_width=4) var table tablo = table.new(yon,6,6,border_width=4,border_color=color.gray, frame_color=color.gray, frame_width=4) fib1 = input.int(defval = 618, title = "Fib Level", group = "Fibonacci", maxval = 1618, tooltip = "Max : 1618") fib2 = input.int(defval = 382, title = "Fib Level", group = "Fibonacci", maxval = 1618, tooltip = "Max : 1618") fib3 = input.int(defval = 786, title = "Fib Level", group = "Fibonacci", maxval = 1618, tooltip = "Max : 1618") // a_allLabels = label.all // if array.size(a_allLabels) > 0 // for i = 0 to array.size(a_allLabels) - 1 // label.delete(array.get(a_allLabels, i)) if barstate.islast and fibonacciGoster fib618=dipeUzaklik>tepeyeUzaklik ? fibTepe-((fibTepe-fibDip)*fib1/1000) : fibDip+((fibTepe-fibDip)*fib1/1000) fib50=dipeUzaklik>tepeyeUzaklik ? fibTepe-((fibTepe-fibDip)*500/1000) : fibDip+((fibTepe-fibDip)*500/1000) fib382=dipeUzaklik>tepeyeUzaklik ? fibTepe-((fibTepe-fibDip)*fib2/1000) : fibDip+((fibTepe-fibDip)*fib2/1000) fib786=dipeUzaklik>tepeyeUzaklik ? fibTepe-((fibTepe-fibDip)*fib3/1000) : fibDip+((fibTepe-fibDip)*fib3/1000) line.new(bar_index - tepeyeUzaklik,fibTepe, bar_index+50,fibTepe, color = fibColor, width = 1, extend = fibonacciExtendRight ? extend.right : extend.none) line.new(bar_index - dipeUzaklik,fibDip, bar_index+50,fibDip, color = fibColor, width = 1, extend = fibonacciExtendRight ? extend.right : extend.none) line.new(bar_index + 10, fib382,bar_index+50, fib382,color = fibColor,style = line.style_dashed, extend = fibonacciExtendRight ? extend.right : extend.none) line.new(bar_index + 10, fib50,bar_index+50, fib50,color = fibColor,style = line.style_dashed, extend = fibonacciExtendRight ? extend.right : extend.none) line.new(bar_index + 10, fib618,bar_index+50, fib618,color = fibColor,style = line.style_dashed, extend = fibonacciExtendRight ? extend.right : extend.none) line.new(bar_index + 10, fib786,bar_index+50, fib786,color = fibColor,style = line.style_dashed, extend = fibonacciExtendRight ? extend.right : extend.none) if fibShowData label.new(bar_index + 55, fibTepe,fibUst+str.tostring(math.round_to_mintick(fibTepe))+" )", color = color.gray, style = label.style_none, textcolor = yaziRenk ) label.new(bar_index + 55, fibDip,fibAlt+str.tostring(math.round_to_mintick(fibDip))+" )", color = color.gray, style = label.style_none, textcolor = yaziRenk) label.new(bar_index + 55, fib382,str.tostring(fib2/1000)+" ( "+str.tostring(math.round_to_mintick(fib382))+" )", color = color.gray, style = label.style_none, textcolor = yaziRenk) label.new(bar_index + 55, fib618,str.tostring(fib1/1000)+" ( "+str.tostring(math.round_to_mintick(fib618))+" )", color = color.gray, style = label.style_none, textcolor = yaziRenk) label.new(bar_index + 55, fib50,"% 50 ( "+str.tostring(math.round_to_mintick(fib50))+" )", color = color.gray, style = label.style_none, textcolor = yaziRenk) label.new(bar_index + 55, fib786,str.tostring(fib3/1000)+" ( "+str.tostring(math.round_to_mintick(fib786))+" )", color = color.gray, style = label.style_none, textcolor = yaziRenk) ///////////////////////////////////// ema1=input.int(defval=50, title="EMA 1", group = "MA", inline = "E1") ema1Show = input.bool(defval = false, group = "MA", inline = "E1", title = "") ema1Color = input.color(defval = color.black, title = "EMA1 COLOR",group = "MA") ema2=input.int(defval=100, title="EMA 2", group = "MA",inline = "E23") ema2Show = input.bool(defval = false, group = "MA", inline = "E2", title = "") ema2Color = input.color(defval = color.black, title = "EMA2 COLOR",group = "MA") ema3=input.int(defval=200, title="EMA 3", group = "MA",inline = "E3") ema3Show = input.bool(defval = false, group = "MA", inline = "E3", title = "") ema3Color = input.color(defval = color.black, title = "EMA3 COLOR",group = "MA") sma1 = input.int(defval=50, title="SMA 1", group = "MA",inline = "S1") sma1Show = input.bool(defval = false, group = "MA", inline = "S1", title = "") sma1Color = input.color(defval = color.black, title = "SMA1 COLOR",group = "MA") sma2= input.int(defval=100, title="SMA 2", group = "MA",inline = "S2") sma2Show = input.bool(defval = false, group = "MA", inline = "S2", title = "") sma2Color = input.color(defval = color.black, title = "SMA2 COLOR",group = "MA") sma3 = input.int(defval=200, title="SMA 3", group = "MA",inline = "S3") sma3Show = input.bool(defval = false, group = "MA", inline = "S3", title = "") sma3Color = input.color(defval = color.black, title = "SMA3 COLOR",group = "MA") ema50 = ta.ema(close,ema1) ema100 = ta.ema(close,ema2) ema200 = ta.ema(close,ema3) sma50 = ta.sma(close,sma1) sma100 = ta.sma(close,sma2) sma200 = ta.sma(close,sma3) hacim = volume acilis = open kapanis = close fark = (ta.change(close)/close[1])*100 plot(ema1Show ? ema50 : na, color = ema1Color,title = "EMA1") plot(ema2Show ? ema100 : na, color = ema2Color,title ="EMA2") plot(ema3Show ? ema200 : na, color = ema3Color,title ="EMA3") plot(sma1Show ? sma50 : na, color = sma1Color,title ="SMA1") plot(sma2Show ? sma100 : na, color = sma2Color,title ="SMA2") plot(sma3Show ? sma200 : na, color = sma3Color,title ="SMA3") len = 300 max = ta.lowest(len) min = max/2 textColor = input.color(defval = color.white, title = "TEXT COLOR") // min = ta.lowest(len) rsiPeriod = input.int(defval = 14, title = "RSI Period", inline = "RSI", group = "RSI") rsiShow = input.bool(defval = true, title = "", inline = "RSI", group = "RSI") rsiColor = input.color(defval = color.purple, title = "RSI COLOR", group = "RSI") rsi = ta.rsi(close,rsiPeriod) rsiMaPeriod = input.int(defval = 10, title = "RSI MA Period", group = "RSI") rsiMa = ta.sma(rsi,rsiMaPeriod) atrPeriod = input.int(defval = 14, title = "ATR Period", inline = "ATR", group = "ATR") atrShow = input.bool(defval = true, title = "", inline = "ATR", group = "ATR") atrColor = input.color(defval = color.red, title = "ATR COLOR", group = "ATR") atr = ta.atr(atrPeriod) momPeriod = input.int(defval = 14, title = "MOM Period", inline = "MOM", group = "MOM") momShow = input.bool(defval = true, title = "", inline = "MOM", group = "MOM") momColor = input.color(defval = color.orange, title = "MOM COLOR", group = "MOM") mom = ta.mom(close,momPeriod) lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50, inline = "ADX", group = "ADX") adxShow = input.bool(defval = true, title = "", inline = "ADX", group = "ADX") [diplus, diminus, adx] = ta.dmi(17, lensig) adxColor = input.color(defval = color.green, title = "ADX COLOR", group = "ADX") ml = input.int(defval = 12, title = "Macd Line", inline = "MACD", group = "MACD") sl = input.int(defval = 26, title = "signal Line", group = "MACD") hl = input.int(defval = 9, title = "Hist Line", group = "MACD") macdShow = input.bool(defval = true, title = "", inline = "MACD", group = "MACD") [macdLine, signalLine, histLine] = ta.macd(close, ml, sl, hl) macdLineColor = input.color(defval = color.blue, title = "MACD LINE COLOR", group = "MACD") macdSignalColor =input.color(defval = color.orange, title = "MACD SIGNAL COLOR", group = "MACD") start = input(0.02, group = "P.SAR", inline = "SAR") sarShow = input.bool(defval = true, title = "", inline = "SAR", group = "P.SAR") increment = input(0.02, group = "P.SAR") maximum = input(0.2, "Max Value", group = "P.SAR") out = ta.sar(start, increment, maximum) plot(sarShow ? out : na, "ParabolicSAR", style=plot.style_cross, color=#2962FF) length = input.int(20, minval=1,group = "BB", inline = "BB") bbShow = input.bool(defval = true, title = "", inline = "BB", group = "BB") maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],group = "BB") src = input(close, title="Source",group = "BB") mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev",group = "BB") 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) basis = ma(src, length, maType) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev offset = input.int(0, "Offset", minval = -500, maxval = 500,group = "BB") plot(bbShow ? basis : na, "Basis", color=#FF6D00, offset = offset) p1 = plot(bbShow ? upper : na, "Upper", color=#2962FF, offset = offset) p2 = plot(bbShow ? lower : na, "Lower", color=#2962FF, offset = offset) fill( p1 , p2 , title = "Background", color=bbShow ? color.rgb(33, 150, 243, 90) : na) conversionPeriods = input.int(9, minval=1, title="Conversion Line Length",group = "ICHIMOKU", inline = "ICHIMOKU") ichShow = input.bool(defval = true, group = "ICHIMOKU", inline = "ICHIMOKU", title = "") basePeriods = input.int(26, minval=1, title="Base Line Length",group = "ICHIMOKU") laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length",group = "ICHIMOKU") displacement = input.int(26, minval=1, title="Lagging Span",group = "ICHIMOKU") donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = math.avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) plot(ichShow ? conversionLine : na, color=#2962FF, title="Conversion Line") plot(ichShow ? baseLine : na, color=#B71C1C, title="Base Line") plot(ichShow ? close : na, offset = -displacement + 1, color=#43A047, title="Lagging Span") p1i = plot(ichShow ? leadLine1 : na, offset = displacement - 1, color=#A5D6A7, title="Leading Span A") p2i = plot(ichShow ? leadLine2 : na, offset = displacement - 1, color=#EF9A9A, title="Leading Span B") plot(ichShow ? (leadLine1 > leadLine2 ? leadLine1 : leadLine2) : na, offset = displacement - 1, title = "Kumo Cloud Upper Line", display = display.none) plot(ichShow ? (leadLine1 < leadLine2 ? leadLine1 : leadLine2) : na, offset = displacement - 1, title = "Kumo Cloud Lower Line", display = display.none) fill(p1i, p2i, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, ichShow ? 90 : 0) : color.rgb(244, 67, 54, ichShow ? 90 : 0)) lengthGroupTitle = "LENGTH LEFT / RIGHT" colorGroupTitle = "Text Color / Label Color" pivotShow = input.bool(defval = true, title = "PIVOT SHOW", group = lengthGroupTitle) leftLenH = input.int(title="Pivot High", defval=10, minval=1, inline="Pivot High", group=lengthGroupTitle) rightLenH = input.int(title="/", defval=10, minval=1, inline="Pivot High", group=lengthGroupTitle) textColorH = input(title="Pivot High", defval=color.black, inline="Pivot High", group=colorGroupTitle) labelColorH = input(title="", defval=color.white, inline="Pivot High", group=colorGroupTitle) leftLenL = input.int(title="Pivot Low", defval=10, minval=1, inline="Pivot Low", group=lengthGroupTitle) rightLenL = input.int(title="/", defval=10, minval=1, inline="Pivot Low", group=lengthGroupTitle) textColorL = input(title="Pivot Low", defval=color.black, inline="Pivot Low", group=colorGroupTitle) labelColorL = input(title="", defval=color.white, inline="Pivot Low", group=colorGroupTitle) ph = ta.pivothigh(leftLenH, rightLenH) pl = ta.pivotlow(leftLenL, rightLenL) drawLabel(_offset, _pivot, _style, _color, _textColor) => if not na(_pivot) label.new(bar_index[_offset], _pivot, str.tostring(_pivot, format.mintick), style=_style, color=_color, textcolor=_textColor) if pivotShow drawLabel(rightLenH, ph, label.style_label_down, labelColorH, textColorH) drawLabel(rightLenL, pl, label.style_label_up, labelColorL, textColorL) scale(data)=> dataMax = ta.highest(data,len) dataMin = ta.lowest(data,len) scaleof = (data - dataMin) / (dataMax-dataMin) * (max - min) + min last = 50 if rsiShow rS = label.new(bar_index, scale(rsi), text = "RSI : " + str.tostring(math.round_to_mintick(rsi)), textcolor = textColor, color = rsiColor ) label.delete(rS[1]) plot(rsiShow ? scale(rsi) : na, show_last = last, offset = 0, color = rsiColor) plot(rsiShow ?scale(rsiMa) : na, show_last = last, offset = 0, color = color.black) if atrShow aS = label.new(bar_index - last, scale(atr), text = "ATR : " + str.tostring(math.round_to_mintick(atr)), textcolor = textColor, color = atrColor) label.delete(aS[1]) plot(atrShow ? scale(atr) : na, show_last = last, offset = -1 * last, color = atrColor) if momShow mS = label.new(bar_index - last*2, scale(mom), text = "MOM : " + str.tostring(math.round_to_mintick(mom)), textcolor = textColor, color = momColor) label.delete(mS[1]) plot(momShow ? scale(mom) : na, show_last = last, offset = -2 * last, color = momColor) if adxShow adS = label.new(bar_index - last*3, scale(adx), text = "ADX : " + str.tostring(math.round_to_mintick(adx)), textcolor = textColor, color = adxColor) label.delete(adS[1]) plot(adxShow ? scale(adx) : na, show_last = last, offset = -3 * last, color = adxColor) if macdShow mcS = label.new(bar_index - last*4 - last/2, math.max(scale(macdLine)[last/2],scale(signalLine)[last/2]), text = "MACD" , textcolor = textColor, color = macdLineColor) label.delete(mcS[1]) plot(macdShow ? scale(macdLine) : na, show_last = last, offset = -4 * last, color = macdLineColor) plot(macdShow ? scale(signalLine) : na, show_last = last, offset = -4 * last, color = macdSignalColor) if barstate.islast and mobilGoster==false and tabloGoster g1="Open Price" g2="Close Price" g3="Change Percent" g4="RSI" g5="ATR" g6="Volume" i1="SMA"+str.tostring(sma1) i2="SMA"+str.tostring(sma2) i3="SMA"+str.tostring(sma3) i4="EMA"+str.tostring(ema1) i5="EMA"+str.tostring(ema2) i6="EMA"+str.tostring(ema3) text7=str.tostring(math.round_to_mintick(sma50)) text8=str.tostring(math.round_to_mintick(sma100)) text9=str.tostring(math.round_to_mintick(sma200)) text10=str.tostring(math.round_to_mintick(ema50)) text11=str.tostring(math.round_to_mintick(ema100)) text12=str.tostring(math.round_to_mintick(ema200)) text1 = str.tostring(acilis) text2 = str.tostring(kapanis) text3 = str.tostring(math.round_to_mintick(fark)) +" %" text4 = str.tostring(math.round_to_mintick(rsi)) text5=str.tostring(math.round_to_mintick(atr)) text6=str.tostring(hacim) table.cell(tablo,0,0,bgcolor=color.black,text_color=color.white, text=g1, text_size = buyuk) table.cell(tablo,1,0,bgcolor=color.black,text_color=color.white, text=g2, text_size = buyuk) table.cell(tablo,2,0,bgcolor=color.black,text_color=color.white, text=g3, text_size = buyuk) table.cell(tablo,3,0,bgcolor=color.black,text_color=color.white, text=g4, text_size = buyuk) table.cell(tablo,4,0,bgcolor=color.black,text_color=color.white, text=g5, text_size = buyuk) table.cell(tablo,5,0,bgcolor=color.black,text_color=color.white, text=g6, text_size = buyuk) table.cell(tablo,0,1,bgcolor=color.black,text_color=color.white, text=text1, text_size = buyuk) table.cell(tablo,1,1,bgcolor=color.black,text_color=color.white, text=text2, text_size = buyuk) table.cell(tablo,2,1,bgcolor=fark>0?color.green:color.red,text_color=color.white, text=text3, text_size = buyuk) table.cell(tablo,3,1,bgcolor=rsi>70?color.green:rsi<30?color.red:color.teal,text_color=color.white, text=text4, text_size = buyuk) table.cell(tablo,4,1,bgcolor=color.black,text_color=color.white, text=text5, text_size = buyuk) table.cell(tablo,5,1,bgcolor=color.black,text_color=color.white, text=text6, text_size = buyuk) table.cell(tablo,0,2,bgcolor=color.gray,text_color=color.white, text=i1, text_size = buyuk) table.cell(tablo,1,2,bgcolor=color.gray,text_color=color.white, text=i2, text_size = buyuk) table.cell(tablo,2,2,bgcolor=color.gray,text_color=color.white, text=i3, text_size = buyuk) table.cell(tablo,3,2,bgcolor=color.gray,text_color=color.white, text=i4, text_size = buyuk) table.cell(tablo,4,2,bgcolor=color.gray,text_color=color.white, text=i5, text_size = buyuk) table.cell(tablo,5,2,bgcolor=color.gray,text_color=color.white, text=i6, text_size = buyuk) table.cell(tablo,0,3,bgcolor=sma50>close?color.red:color.green,text_color=color.white, text=text7, text_size = buyuk) table.cell(tablo,1,3,bgcolor=sma100>close?color.red:color.green,text_color=color.white, text=text8, text_size = buyuk) table.cell(tablo,2,3,bgcolor=sma200>close?color.red:color.green,text_color=color.white, text=text9, text_size = buyuk) table.cell(tablo,3,3,bgcolor=ema50>close?color.red:color.green,text_color=color.white, text=text10, text_size = buyuk) table.cell(tablo,4,3,bgcolor=ema100>close?color.red:color.green,text_color=color.white, text=text11, text_size = buyuk) table.cell(tablo,5,3,bgcolor=ema200>close?color.red:color.green,text_color=color.white, text=text12, text_size = buyuk) if barstate.islast and mobilGoster==true and tabloGoster==false g1="Open Price" g2="Close Price" g3="Change Percent" g4="RSI" g5="ATR" g6="Volume" text1 = str.tostring(acilis) text2 = str.tostring(kapanis) text3 = str.tostring(math.round_to_mintick(fark)) +" %" text4 = str.tostring(math.round_to_mintick(rsi)) text5=str.tostring(math.round_to_mintick(atr)) text6=str.tostring(hacim) table.cell(mobiletablo,0,0,bgcolor=color.black,text_color=color.white, text=g1, text_size = buyuk) table.cell(mobiletablo,0,1,bgcolor=color.black,text_color=color.white, text=g2, text_size = buyuk) table.cell(mobiletablo,0,2,bgcolor=color.black,text_color=color.white, text=g3, text_size = buyuk) table.cell(mobiletablo,0,3,bgcolor=color.black,text_color=color.white, text=g4, text_size = buyuk) table.cell(mobiletablo,0,4,bgcolor=color.black,text_color=color.white, text=g5, text_size = buyuk) table.cell(mobiletablo,0,5,bgcolor=color.black,text_color=color.white, text=g6, text_size = buyuk) table.cell(mobiletablo,1,0,bgcolor=color.black,text_color=color.white, text=text1, text_size = buyuk) table.cell(mobiletablo,1,1,bgcolor=color.black,text_color=color.white, text=text2, text_size = buyuk) table.cell(mobiletablo,1,2,bgcolor=color.black,text_color=color.white, text=text3, text_size = buyuk) table.cell(mobiletablo,1,3,bgcolor=rsi>70?color.green:rsi<30?color.red:color.teal,text_color=color.white, text=text4, text_size = buyuk) table.cell(mobiletablo,1,4,bgcolor=color.black,text_color=color.white, text=text5, text_size = buyuk) table.cell(mobiletablo,1,5,bgcolor=color.black,text_color=color.white, text=text6, text_size = buyuk)
Adaptive Trend Cipher loxx]
https://www.tradingview.com/script/a7062wqw-Adaptive-Trend-Cipher-loxx/
loxx
https://www.tradingview.com/u/loxx/
160
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © loxx //@version=5 indicator('Adaptive Trend Cipher [Loxx]', shorttitle = "ATC [Loxx]", overlay = true, max_bars_back = 5000) selector = input.string("Band-pass", title='Dominant Cycle Type', options = ["Autocorrelation", "Instantaneous", "Hilbert", "Band-pass", "Dual Differentiator"], group = "Trend Core Settings") corr_src = input.source(close, title='Trend Correlation Source', group = "Trend Core Settings") cycle_mult = input.float(100.0, minval = 1, title = "Dominant Cycle Length (%)", group = "Trend Core Settings")/100 auto_src = input.source(close, title='Auto Source', group = "Autocorrelation") auto_min = input.int(8, minval = 1, title='Auto Min Length', group = "Autocorrelation") auto_max = input.int(48, minval = 1, title='Auto Max Length', group = "Autocorrelation") auto_avg = input.int(3, minval = 1, title='Auto Average Length', group = "Autocorrelation") hilbert_src = input.source(hl2, title='Hilbert Source', group = "Regular Hilbert Period") hilbert_len = input.int(7, title='Hilbert Length', minval=1, group = "Regular Hilbert Period") hilbert_alpha = input.float(0.07, title = "Hilbert Alpha", step = 0.01, group = "Regular Hilbert Period") instant_src = input.source(hl2, title='Instant Source', group = "Instantaneous") instant_min_len = input.int(8, title='Instant Min Length', minval=1, group = "Instantaneous") instant_max_len = input.int(48, title='Instant Max Length', minval=1, group = "Instantaneous") bp_period = input.int(20, "Band-pass Period", minval = 1, group = "Band-pass") Bandwidth = input.float(0.70, "Band-pass Width", step = 0.1, group = "Band-pass") LPPeriod = input(20, title='LP Period', group = "Hilbert Dual Differentiator") min_len_input = input.int(8, title='Min Length', group = "Hilbert Dual Differentiator") max_len_input = input.int(48, title='Max Length', group = "Hilbert Dual Differentiator") _hilber_dual(len_in, min_len, max_len, mult) => alpha1 = 0.00 HP = 0.00 a1 = 0.00 b1 = 0.00 c1 = 0.00 c2 = 0.00 c3 = 0.00 Filt = 0.00 QFilt = 0.00 Real = 0.00 Quad = 0.00 Imag = 0.00 IPeak = 0.00 QPeak = 0.00 IDot = 0.00 QDot = 0.00 Period = 0.00 DomCycle = 0.00 alpha1 := (math.cos(0.707 * 2 * math.pi / max_len) + math.sin(0.707 * 2 * math.pi / max_len) - 1) / math.cos(0.707 * 2 * math.pi / max_len) HP := (1 - alpha1 / 2) * (1 - alpha1 / 2) * (close - 2 * close[1] + close[2]) + 2 * (1 - alpha1) * nz(HP[1]) - (1 - alpha1) * (1 - alpha1) * nz(HP[2]) a1 := math.exp(-math.sqrt(2) * math.pi / LPPeriod) b1 := 2 * a1 * math.cos(math.sqrt(2) * math.pi / LPPeriod) c2 := b1 c3 := -a1 * a1 c1 := 1 - c2 - c3 Filt := c1 * (HP + nz(HP[1])) / 2 + c2 * nz(Filt[1]) + c3 * nz(Filt[2]) IPeak := 0.991 * nz(IPeak[1]) IPeak := math.abs(Filt) > IPeak ? math.abs(Filt) : IPeak Real := Filt / IPeak Quad := Real - nz(Real[1]) QPeak := 0.991 * nz(QPeak[1]) QPeak := math.abs(Quad) > QPeak ? math.abs(Quad) : QPeak Imag := Quad / QPeak IDot := Real - nz(Real[1]) QDot := Imag - nz(Imag[1]) Period := Real * QDot - Imag * IDot != 0 ? 2 * math.pi * (Real * Real + Imag * Imag) / (-Real * QDot + Imag * IDot) : Period Period := math.min(math.max(Period, min_len), max_len) DomCycle := c1 * (Period + nz(Period[1])) / 2 + c2 * nz(DomCycle[1]) + c3 * nz(DomCycle[2]) out = DomCycle * mult out _corrrelation(x, y, len) => lenMinusOne = len - 1 meanx = 0.0, meany = 0.0 for i=0.0 to lenMinusOne meanx := meanx + nz(x[i]) meany := meany + nz(y[i]) meanx := meanx / len meany := meany / len sumxy=0.0, sumx=0.0, sumy=0.0 for i=0 to lenMinusOne sumxy := sumxy + (nz(x[i]) - meanx) * (nz(y[i]) - meany) sumx := sumx + math.pow(nz(x[i]) - meanx, 2) sumy := sumy + math.pow(nz(y[i]) - meany, 2) sumxy / math.sqrt(sumy * sumx) _cycleit(src, len, len_of_cycle, alpha) => instPeriod = 0.0 smooth = (src + 2 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 6 cycle = 0.0 cycle := bar_index < 7 ? (src - 2 * nz(src[1]) + nz(src[2])) / 4 : (1 - .5*alpha)*(1 - .5*alpha)*(smooth - 2*smooth[1] + smooth[2]) + 2*(1 - alpha)*cycle[1] - (1 - alpha)*(1 - alpha)*cycle[2] q1 = (0.0962 * cycle + 0.5769 * nz(cycle[2]) - 0.5769 * nz(cycle[4]) - 0.0962 * nz(cycle[6])) * (0.5 + 0.08 * nz(instPeriod[1])) i1 = nz(cycle[3]) deltaPhase = q1 != 0 and nz(q1[1]) != 0 ? (i1 / q1 - nz(i1[1]) / nz(q1[1])) / (1 + i1 * nz(i1[1]) / (q1 * nz(q1[1]))) : 0 deltaPhase := math.min(math.max(deltaPhase, 0.1), 1.1) medianDelta = ta.percentile_nearest_rank(deltaPhase, len, 50) dc = medianDelta != 0 ? math.pi*2 / medianDelta + 0.5 : 15 instPeriod := 0.33 * dc + 0.67 * nz(instPeriod[1]) period = 0.0 period := 0.15 * instPeriod + 0.85 * nz(period[1]) number = math.round(math.floor(len_of_cycle*ta.wma(period, 4))) number _f_hp(_src, max_len) => var 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, _len) => var s = math.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(src, min_len, max_len, ave_len, mult) => var c = 2 * math.pi var s = math.sqrt(2) avglen = ave_len 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 = avglen == 0 ? lag : avglen 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) dominantcycle = 0.0 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 peakpwr >= 0.25 and nz(array.get(pwr, period)) >= 0.25 spx += period * nz(array.get(pwr, period)) sp += nz(array.get(pwr, period)) if sp != 0 dominantcycle := spx / sp if sp < 0.25 dominantcycle := dominantcycle[1] if dominantcycle < 1 dominantcycle := 1 dom_in = math.min(math.max(dominantcycle, min_len), max_len) dom_out = dom_in * mult dom_out _instant_cycle(src, llen, hlen, mult) => v1 = src - nz(src[llen]) ip = 0.0 ip := 1.25 * (nz(v1[4]) - 0.635 * nz(v1[2])) + 0.635 * nz(ip[3]) qu = 0.0 qu := nz(v1[2]) - 0.338 * v1 + 0.338 * nz(qu[2]) phase = math.abs(ip + nz(ip[1])) > 0 ? math.atan(math.abs((qu + nz(qu[1])) / (ip + nz(ip[1])))) * 180 / math.pi : 0 phase := ip < 0 and qu > 0 ? 180 - phase : phase phase := ip < 0 and qu < 0 ? 180 + phase : phase phase := ip > 0 and qu < 0 ? 360 - phase : phase dPhase = nz(phase[1]) - phase dPhase := nz(phase[1]) < 90 and phase > 270 ? 360 + nz(phase[1]) - phase : dPhase dPhase := math.max(math.min(60, dPhase), 1) instPeriod = 0.0 v4 = 0.0 for i = 0 to hlen by 1 v4 += nz(dPhase[i]) if v4 > 360 and instPeriod == 0 instPeriod := i instPeriod dcPeriod = 0.0 dcPeriod := 0.25 * instPeriod + 0.75 * nz(dcPeriod[1]) dom_in = math.min(math.max(dcPeriod, llen), hlen) dom_out = dom_in * mult dom_out _bpDom(len, bpw, mult) => HP = 0.0 BP = 0.0 Peak = 0.0 Real = 0.0 counter = 0.0 DC = 0.0 alpha2 = (math.cos(0.25 * bpw * 2 * math.pi / len) + math.sin(0.25 * bpw * 2 * math.pi / len) - 1) / math.cos(0.25 * bpw * 2 * math.pi / len) HP := (1 + alpha2 / 2) * (close - nz(close[1])) + (1 - alpha2) * nz(HP[1]) beta1 = math.cos(2 * math.pi / len) gamma1 = 1 / math.cos(2 * math.pi * bpw / len) alpha1 = gamma1 - math.sqrt(gamma1 * gamma1 - 1) BP := 0.5 * (1 - alpha1) * (HP - nz(HP[2])) + beta1 * (1 + alpha1) * nz(BP[1]) - alpha1 * nz(BP[2]) BP := bar_index == 1 or bar_index == 2 ? 0 : BP Peak := 0.991 * Peak Peak := math.abs(BP) > Peak ? math.abs(BP) : Peak Real := Peak != 0 ? BP / Peak : Real DC := nz(DC[1]) DC := DC < 6 ? 6 : DC counter := counter[1] + 1 if ta.crossover(Real, 0) or ta.crossunder(Real, 0) DC := 2 * counter if 2 * counter > 1.25 * nz(DC[1]) DC := 1.25 * DC[1] if 2 * counter < 0.8 * nz(DC[1]) DC := 0.8 * nz(DC[1]) counter := 0 temp_out = mult * DC temp_out _corr_period(type) => int out = 0 if type == "Autocorrelation" auto = _auto_dom(auto_src, auto_min, auto_max, auto_avg, cycle_mult) out := math.floor(auto) < 1 ? 1 : math.floor(auto) if type == "Instantaneous" instant = _instant_cycle(instant_src, instant_min_len, instant_max_len, cycle_mult) out := math.floor(instant) < 1 ? 1 : math.floor(instant) if type == "Hilbert" hilbert = _cycleit(hilbert_src, hilbert_len, cycle_mult, hilbert_alpha) out := math.floor(hilbert) < 1 ? 1 : math.floor(hilbert) if type == "Band-pass" band = _bpDom(bp_period, Bandwidth, cycle_mult) out := math.floor(band) < 1 ? 1 : math.floor(band) if type == "Dual Differentiator" hilbert_dd = _hilber_dual(LPPeriod, min_len_input, max_len_input, cycle_mult) out := math.floor(hilbert_dd) < 1 ? 1 : math.floor(hilbert_dd) out corr_period = _corr_period(selector) correlate = _corrrelation(corr_src, bar_index, corr_period) colorCorrelate = correlate > 0.95 ? #FFF300 : correlate > 0.9 ? #80ff5f : correlate > 0.8 ? #58ff2e : correlate > 0.6 ? #33fc00 : correlate > 0.4 ? #29cc00 : correlate > 0.2 ? #1f9b00 : correlate > 0.0 ? #156a00 : correlate < -0.95 ? #FF0EF3 : correlate < -0.9 ? #ff2e57 : correlate < -0.8 ? #fc0031 : correlate < -0.6 ? #cc0028 : correlate < -0.4 ? #9b001e : correlate < -0.2 ? #6a0014 : #6a0014 color_out = color.new(colorCorrelate, 0) barcolor(color_out)
Initial Balance
https://www.tradingview.com/script/6yofFVAv-Initial-Balance/
noop-noop
https://www.tradingview.com/u/noop-noop/
745
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © noop42 //@version=5 indicator("Initial Balance", shorttitle="Initial Balance", overlay=true, max_bars_back=5000) // Options ib_session = input.session("0930-1030", title="Calculation period for the initial balance", group="Calculation period") show_extra_levels = input.bool(true, "Show extra levels (IBH x2 & IBL x2)", group="Information") show_intermediate_levels = input.bool(true, "Show intermediate levels (50%)", group="Information") show_ib_calculation_area = input.bool(false, "Initial balance calculation period coloration", group="Information") show_labels = input.bool(true, "Show labels", group="Information") fill_ib_areas = input.bool(true, "Colour IB areas", group="Information") only_current_levels = input.bool(true, "Only display the current IB Levels", group="Information") only_current_zone = input.bool(false, "Only display the current IB calculation area", group="Information") show_delta_analytics = input.bool(true, "Display IB delta analytics", group="Information") label_size = input.string("Small", title="Label Size", options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group="Drawings") lvl_width = input.int(1, "Daily price level width", group="Drawings") high_col = input.color(color.green, "Initial balance high levels color", group="Drawings") low_col = input.color(color.red, "Initial balance low levels color", group="Drawings") middle_col = input.color(#ffa726, "50% initial balance color", group="Drawings") extend_level = input.string("Right", title="Extend current levels", options=["Right", "Left", "Both", "None"], group="Drawings") main_levels_style = input.string("Solid" , "Main levels line style", options=["Solid", "Dashed", "Dotted"], group="Drawings") ext_levels_style = input.string("Dashed" , "Extended levels line style", options=["Solid", "Dashed", "Dotted"], group="Drawings") int_levels_style = input.string("Dotted" , "Intermediate levels line style", options=["Solid", "Dashed", "Dotted"], group="Drawings") fill_ib_color= input.color(#b8851faa, "IB area background color", group="Drawings") ext = extend_level == "Right" ? extend.right : extend_level == "Left" ? extend.left : extend_level == "Both" ? extend.both : extend.none var delta_history = array.new_float(20) inSession(sess) => na(time(timeframe.period, sess)) == false get_line_style(s) => s == "Solid" ? line.style_solid : s == "Dotted" ? line.style_dotted : line.style_dashed get_levels(n) => h = high[1] l = low[1] for i=1 to n if low[i] < l l := low[i] if high[i] > h h := high[i] [h, l, (h+l)/2] var line ibh = na var line ibl = na var line ibm = na var line ib_plus = na var line ib_minus = na var line ib_plus2 = na var line ib_minus2 = na var line ibm_plus = na var line ibm_minus = na var label labelh = na var label labell = na var label labelm = na var label label_plus = na var label label_minus = na var label label_plus2 = na var label label_minus2 = na var label labelm_plus = na var label labelm_minus = na var box ib_area = na labelSize = (label_size == "Huge") ? size.huge : (label_size == "Large") ? size.large : (label_size == "Small") ? size.small : (label_size == "Tiny") ? size.tiny : (label_size == "Auto") ? size.auto : size.normal var offset = 0 ins = inSession(ib_session) bgcolor(show_ib_calculation_area and ins ? #673ab730 : na, title="IB calculation zone") var float ib_delta = na if ins offset += 1 if ins[1] and not ins [h, l, m] = get_levels(offset) ib_delta := h - l if array.size(delta_history) >= 20 array.shift(delta_history) array.push(delta_history, ib_delta) line.set_extend(ibh, extend.none) line.set_extend(ibl, extend.none) if show_intermediate_levels line.set_extend(ibm, extend.none) if show_extra_levels line.set_extend(ib_plus, extend.none) line.set_extend(ib_minus, extend.none) line.set_extend(ib_plus2, extend.none) line.set_extend(ib_minus2, extend.none) if show_intermediate_levels line.set_extend(ibm_plus, extend.none) line.set_extend(ibm_minus, extend.none) if show_labels if only_current_levels label.delete(labelh) label.delete(labell) label.delete(labelm) label.delete(label_plus) label.delete(label_minus) label.delete(label_plus2) label.delete(label_minus2) label.delete(labelm_plus) label.delete(labelm_minus) labelh := label.new(bar_index[offset], h, text="IBH 100%: "+str.tostring(h), style=label.style_none, textcolor=high_col, size=labelSize) labell := label.new(bar_index[offset], l, text="IBL 0%: "+str.tostring(l), style=label.style_none, textcolor=low_col, size=labelSize) if show_intermediate_levels labelm := label.new(bar_index[offset], m, text="IBM 50%: "+str.tostring(m)+"\nIBΔ: "+str.tostring(h - l), style=label.style_none, textcolor=middle_col, size=labelSize) if show_extra_levels label_plus := label.new(bar_index[offset], h + ib_delta, text="IBH x2 - "+str.tostring(h + ib_delta), style=label.style_none, textcolor=high_col, size=labelSize) label_minus := label.new(bar_index[offset], l - ib_delta, text="IBL x2: "+str.tostring(l - ib_delta), style=label.style_none, textcolor=low_col, size=labelSize) label_plus2 := label.new(bar_index[offset], h + (ib_delta*2), text="IBH x3 - "+str.tostring(h + (ib_delta*2)), style=label.style_none, textcolor=high_col, size=labelSize) label_minus2 := label.new(bar_index[offset], l - (ib_delta*2), text="IBL x3: "+str.tostring(l - (ib_delta*2)), style=label.style_none, textcolor=low_col, size=labelSize) if fill_ib_areas if only_current_zone box.delete(ib_area) ib_area := box.new(bar_index[offset], h, bar_index, l, bgcolor=fill_ib_color, border_color=#00000000)//, extend=ext) if only_current_levels line.delete(ibh) line.delete(ibl) line.delete(ibm) line.delete(ib_plus) line.delete(ib_minus) line.delete(ib_plus2) line.delete(ib_minus2) line.delete(ibm_plus) line.delete(ibm_minus) ibh := line.new(bar_index[offset], h, bar_index, h, color=high_col, extend=ext, width=lvl_width, style=get_line_style(main_levels_style)) ibl := line.new(bar_index[offset], l, bar_index, l, color=low_col, extend=ext, width=lvl_width, style=get_line_style(main_levels_style)) if show_intermediate_levels ibm := line.new(bar_index[offset], m, bar_index, m, color=middle_col, style=get_line_style(int_levels_style), extend=ext, width=lvl_width) if show_extra_levels ib_plus := line.new(bar_index[offset], h + ib_delta, bar_index, h + ib_delta, color=high_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width) ib_minus := line.new(bar_index[offset], l - ib_delta, bar_index, l - ib_delta, color=low_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width) ib_plus2 := line.new(bar_index[offset], h + (ib_delta*2), bar_index, h + (ib_delta *2), color=high_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width) ib_minus2 := line.new(bar_index[offset], l - (ib_delta*2), bar_index, l - (ib_delta*2), color=low_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width) if show_intermediate_levels ibm_plus := line.new(bar_index[offset], h + (ib_delta/2), bar_index, h + (ib_delta/2), color=middle_col, style=get_line_style(int_levels_style), extend=ext, width=lvl_width) ibm_minus := line.new(bar_index[offset], l - (ib_delta/2), bar_index, l - (ib_delta/2), color=middle_col, style=get_line_style(int_levels_style), extend=ext, width=lvl_width) offset := 0 if (not ins) and (not ins[1]) line.set_x2(ibh, bar_index) line.set_x2(ibl, bar_index) if show_intermediate_levels line.set_x2(ibm, bar_index) if show_extra_levels line.set_x2(ib_plus, bar_index) line.set_x2(ib_minus, bar_index) line.set_x2(ib_plus2, bar_index) line.set_x2(ib_minus2, bar_index) if show_intermediate_levels line.set_x2(ibm_plus, bar_index) line.set_x2(ibm_minus, bar_index) var table ib_analytics = table.new(position.bottom_left, 2, 6) ib_sentiment() => h = array.max(delta_history) l = array.min(delta_history) a = array.avg(delta_history) h_comp = ib_delta > h ? ib_delta - h : (ib_delta - h) * -1 l_comp = ib_delta > l ? ib_delta - l : (ib_delta - l) * -1 a_comp = ib_delta > a ? ib_delta - a : (ib_delta - a) * -1 (h_comp < l_comp and h_comp < a_comp) ? "Huge" : (l_comp < h_comp and l_comp < a_comp) ? "Small" : "Medium" if show_delta_analytics table.cell(ib_analytics, 0, 0, "IB Delta", bgcolor=color.black, text_color=color.white) table.cell(ib_analytics, 0, 1, "20D MAX", bgcolor=color.black, text_color=color.white) table.cell(ib_analytics, 1, 1, str.tostring(array.max(delta_history), "#.####"), bgcolor=color.black, text_color=high_col) table.cell(ib_analytics, 0, 2, "20D AVG", bgcolor=color.black, text_color=color.white) table.cell(ib_analytics, 1, 2, str.tostring(array.avg(delta_history), "#.####"), bgcolor=color.black, text_color=middle_col) table.cell(ib_analytics, 0, 3, "20D MIN", bgcolor=color.black, text_color=color.white) table.cell(ib_analytics, 1, 3, str.tostring(array.min(delta_history), "#.####"), bgcolor=color.black, text_color=low_col) table.cell(ib_analytics, 0, 4, "Today", bgcolor=color.black, text_color=color.white) table.cell(ib_analytics, 1, 4, str.tostring(ib_delta), bgcolor=color.black, text_color=color.blue) table.cell(ib_analytics, 0, 5, "Status", bgcolor=color.black, text_color=color.white) table.cell(ib_analytics, 1, 5, ib_sentiment() , bgcolor=color.black, text_color=color.white)
Relative Volume Strength Index (MZ RVSI)
https://www.tradingview.com/script/75kQ1ySs-Relative-Volume-Strength-Index-MZ-RVSI/
MightyZinger
https://www.tradingview.com/u/MightyZinger/
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/ // © MightyZinger //@version=4 study(shorttitle="MZ RVSI",title="Relative Volume Strength Index (MZ RVSI)", overlay=false) uha =input(true, title="Use Heikin Ashi Candles") chartResolution = input("",type=input.resolution, title="Chart Resolution") // Use only Heikinashi Candles for all calculations haclose = uha ? security(heikinashi(syminfo.tickerid), chartResolution, close) : security(syminfo.tickerid, chartResolution, close) haopen = uha ? security(heikinashi(syminfo.tickerid), chartResolution, open) : security(syminfo.tickerid, chartResolution, open) hahigh = uha ? security(heikinashi(syminfo.tickerid), chartResolution, high) : security(syminfo.tickerid, chartResolution, high) halow = uha ?security(heikinashi(syminfo.tickerid), chartResolution, low) : security(syminfo.tickerid, chartResolution, low) vol = security(syminfo.tickerid, chartResolution, volume) // Oscillator Types Input osc1 = "TFS Volume Oscillator" osc2 = "On Balance Volume" osc3 = "Klinger Volume Oscillator" osc4 = "Cumulative Volume Oscillator" osc5 = "Volume Zone Oscillator" osctype = input(title="Volume Oscillator Type", type=input.string, group="Indicator Parameters", defval = osc2, options=[osc1, osc2, osc3, osc4, osc5]) volLen = input(30, minval=1,title="Volume Length", group="Indicator Parameters") rvsiLen = input(14, minval=1,title="RVSI Period", group="Indicator Parameters") vBrk = input(50, minval=1,title="RVSI Break point", group="Indicator Parameters") //Slope calculation to determine whether Volume is in trend, or in consolidation or choppy, or might about to change current trend slopePeriod = input(34, title="Slope Period", group="Slope Parameters") slopeInRange = input(25, title="Slope Initial Range", group="Slope Parameters") flat = input(17, title="Consolidation area is when slope below:", group="Slope Parameters") calcslope(_ma,src,slope_period,range)=> pi = atan(1) * 4 highestHigh = highest(slope_period) lowestLow = lowest(slope_period) slope_range = range / (highestHigh - lowestLow) * lowestLow dt = (_ma[2] - _ma) / src * slope_range c = sqrt(1 + dt * dt) xAngle = round(180 * acos(1 / c) / pi) maAngle = iff(dt > 0, -xAngle, xAngle) maAngle // Dynamic coloring function to detect trend dynColor(_flat, upPara, dnPara, slp, col_1, col_2, col_3, col_4, col_r) => col = color.green if slp > _flat and upPara col := col_1 if slp > _flat and not upPara col := col_2 if slp <= _flat and slp > -flat col := col_r if slp <= -_flat and dnPara col := col_3 if slp <= -_flat and not dnPara col := col_4 col ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Volume Oscillator Functions ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Volume Zone Oscillator zone(_src, _type, _len) => vp = _src > _src[1] ? _type : _src < _src[1] ? -_type : _src == _src[1] ? 0 : 0 z = 100 * (ema(vp, _len) / ema(_type, _len)) vzo(vol_src, _close) => float result = 0 zLen = input(21, "VZO Length", minval=1, group="Volume Zone Oscillator Parameters") result := zone(_close, vol_src, zLen) result // Cumulative Volume Oscillator _rate(cond, tw, bw, body) => ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) ret := nz(ret) == 0 ? 0.5 : ret ret cvo(vol_src, _open, _high, _low, _close) => float result = 0 ema1len = input(defval = 8, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters") ema2len = input(defval = 21, title = "EMA 1 Length", minval = 1, group="Cumulative Volume Oscillator Parameters") obvl = "On Balance Volume" cvdo = "Cumulative Volume Delta" pvlt = "Price Volume Trend" cvtype = input(defval = pvlt, options = [obvl, cvdo, pvlt], group="Cumulative Volume Oscillator Parameters") tw = _high - max(_open, _close) bw = min(_open, _close) - _low body = abs(_close - _open) deltaup = vol_src * _rate(_open <= _close , tw, bw, body) deltadown = vol_src * _rate(_open > _close , tw, bw, body) delta = _close >= _open ? deltaup : -deltadown cumdelta = cum(delta) float ctl = na ctl := cumdelta cv = cvtype == obvl ? obv : cvtype == cvdo ? ctl : pvt ema1 = ema(cv,ema1len) ema2 = ema(cv,ema2len) result := ema1 - ema2 result // Volume Oscillator function vol_osc(type, vol_src, vol_Len, _open, _high, _low, _close) => float result = 0 if type=="TFS Volume Oscillator" nVolAccum = sum(iff(_close > _open, vol_src, iff(_close < _open, -vol_src, 0)) ,vol_Len) result := nVolAccum / vol_Len if type=="On Balance Volume" result := cum(sign(change(_close)) * vol_src) if type=="Klinger Volume Oscillator" FastX = input(34, minval=1,title="Volume Fast Length", group="KVO Parameters") SlowX = input(55, minval=1,title="Volume Slow Length", group="KVO Parameters") xTrend = iff(_close > _close[1], vol * 100, -vol * 100) xFast = ema(xTrend, FastX) xSlow = ema(xTrend, SlowX) result := xFast - xSlow if type=="Cumulative Volume Oscillator" result := cvo(vol_src, _open, _high, _low, _close) if type=="Volume Zone Oscillator" result := vzo(vol_src, _close) result ///////////////////////////////////////////////////////////////////// // MA of Volume Oscillator Source volMA = hma(vol_osc(osctype,vol,volLen,haopen,hahigh,halow,haclose) , rvsiLen) // RSI of Volume Oscillator Data rsivol = rsi(volMA, rvsiLen) rvsi = hma(rsivol, rvsiLen) // RVSI IndicatorPlot TopBand = input(80, step=0.01, title="Top Band", group="Indicator Plot Parameters") LowBand = input(20, step=0.01, title="Low Band", group="Indicator Plot Parameters") MidBand = input(50, step=0.01, title="Middle Band", group="Indicator Plot Parameters") hline(TopBand, color=color.red,linestyle=hline.style_dotted, linewidth=2) hline(LowBand, color=color.green, linestyle=hline.style_dotted, linewidth=2) hline(MidBand, color=color.lime, linestyle=hline.style_dotted, linewidth=1) volBrkUp = rvsi > vBrk volBrkDn = rvsi < vBrk slope = calcslope(rvsi, rsivol, slopePeriod, slopeInRange) // Slope Calculations rvsi_col = dynColor(flat, volBrkUp, volBrkDn, slope, color.lime, color.fuchsia, color.red, color.gray, color.yellow) plot(rvsi, "MZ RVSI", rvsi_col, 4) hline(0, "0", color.green, linewidth=1) hline(100, "100", color.red, linewidth=1) hline(125, "125", color.gray, linewidth=1) plotchar(rvsi, "MZ RVSI", "", location.top, color.yellow)
Slope Adaptive Moving Average (MZ SAMA)
https://www.tradingview.com/script/Ies7Tygo-Slope-Adaptive-Moving-Average-MZ-SAMA/
MightyZinger
https://www.tradingview.com/u/MightyZinger/
738
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MightyZinger //@version=5 indicator('Slope Adaptive Moving Average (MZ SAMA)', shorttitle='MZ SAMA', overlay=true) ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// MZ SAMA ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// chartResolution = input.timeframe('', title='Chart Resolution') src = input.source(close, 'Source') // Length Inputs string grp_1 = 'SAMA Length Inputs' length = input(200, title='Adaptive MA Length', group = grp_1) // To check for Highest and Lowest value within provided period majLength = input(14, title='Major Length', group = grp_1) // For Major alpha calculations to detect recent price changes minLength = input(6, title='Minor Length', group = grp_1) // For Minor alpha calculations to detect recent price changes // Slope Inputs string grp_2 = 'Slope and Dynamic Coloring Parameters' slopePeriod = input.int(34, title='Slope Period', group = grp_2) slopeInRange = input.int(25, title='Slope Initial Range', group = grp_2) flat = input.int(17, title='Consolidation area is when slope below:', group = grp_2) bull_col = input.color(color.green, 'Bull Color  ', inline='dyn_col', group = grp_2) bear_col = input.color(color.red, 'Bear Color  ', inline='dyn_col', group = grp_2) conc_col = input.color(color.yellow, 'Reversal/Consolidation/Choppiness Color  ', inline='dyn_col', group = grp_2) showSignals = input.bool(true, title='Show Signals on Chart', group='Plot Parameters') //Slope calculation Function to check trend strength i.e. consolidating, choppy, or near reversal calcslope(_ma, src, slope_period, range_1) => pi = math.atan(1) * 4 highestHigh = ta.highest(slope_period) lowestLow = ta.lowest(slope_period) slope_range = range_1 / (highestHigh - lowestLow) * lowestLow dt = (_ma[2] - _ma) / src * slope_range c = math.sqrt(1 + dt * dt) xAngle = math.round(180 * math.acos(1 / c) / pi) maAngle = dt > 0 ? -xAngle : xAngle maAngle //MA coloring function to mark market dynamics dynColor(_flat, slp, col_1, col_2, col_r) => var col = color.new(na,0) // Slope supporting bullish uprtrend color col := slp > _flat ? col_1: // Slope supporting bearish downtrend color slp <= -_flat ? col_2: // Reversal/Consolidation/Choppiness color slp <= _flat and slp > -_flat ? col_r : col_r col //AMA Calculations ama(src,length,minLength,majLength)=> minAlpha = 2 / (minLength + 1) majAlpha = 2 / (majLength + 1) hh = ta.highest(length + 1) ll = ta.lowest(length + 1) mult = hh - ll != 0 ? math.abs(2 * src - ll - hh) / (hh - ll) : 0 final = mult * (minAlpha - majAlpha) + majAlpha final_alpha = math.pow(final, 2) // Final Alpha calculated from Minor and Major length along with considering Multiplication factor calculated using Highest / Lowest value within provided AMA overall length var _ama = float(na) _ama := (src - nz(_ama[1])) * final_alpha + nz(_ama[1]) _ama // SAMA Definition sama = request.security(syminfo.tickerid, chartResolution, ama(src,length,minLength,majLength)) // Slope Calculation for Dynamic Coloring slope = calcslope(sama, src, slopePeriod, slopeInRange) // SAMA Dynamic Coloring from slope sama_col = request.security(syminfo.tickerid, chartResolution, dynColor(flat, slope, bull_col, bear_col, conc_col)) // SAMA Plot plot(sama, 'MZ SAMA', sama_col, 4) // BUY & SELL CONDITIONS AND ALERTS _up = sama_col == bull_col _downn = sama_col == bear_col _chop = sama_col == conc_col buy = _up and not _up[1] sell = _downn and not _downn[1] chop_zone = _chop and not _chop[1] _signal() => var sig = 0 if buy and sig <= 0 sig := 1 if sell and sig >= 0 sig := -1 sig sig = _signal() longsignal = sig == 1 and (sig != 1)[1] shortsignal = sig == -1 and (sig != -1)[1] // Plotting Signals on Chart atrOver = 1 * ta.atr(5) // Atr to place alert shape on chart plotshape(showSignals and longsignal ? (sama - atrOver) : na , style=shape.triangleup, color=color.new(color.green, 30), location=location.absolute, text='Buy', size=size.small) plotshape(showSignals and shortsignal ? (sama + atrOver): na , style=shape.triangledown, color=color.new(color.red, 30), location=location.absolute, text='Sell', size=size.small) // Signals Alerts alertcondition(longsignal, "Buy", "Go Long" ) alertcondition(shortsignal, "Sell", "Go Short") alertcondition(chop_zone, "Chop Zone", "Possible Reversal/Consolidation/Choppiness") if longsignal alert("Buy at" + str.tostring(close), alert.freq_once_per_bar_close) if shortsignal alert("Sell at" + str.tostring(close), alert.freq_once_per_bar_close)
TFS Volume Oscillator Noise Filtered
https://www.tradingview.com/script/eSVRUwCf-TFS-Volume-Oscillator-Noise-Filtered/
MightyZinger
https://www.tradingview.com/u/MightyZinger/
193
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/ // © MightyZinger //@version=4 study(title="TFS Volume Oscillator Noise Filtered", shorttitle="MZ TFS") uha =input(true, title="Use Heikin Ashi Candles") chartResolution = input("",type=input.resolution, title="Chart Resolution") // Use only Heikinashi Candles for all calculations haclose = uha ? security(heikinashi(syminfo.tickerid), chartResolution, close) : security(syminfo.tickerid, chartResolution, close) haopen = uha ? security(heikinashi(syminfo.tickerid), chartResolution, open) : security(syminfo.tickerid, chartResolution, open) hahigh = uha ? security(heikinashi(syminfo.tickerid), chartResolution, high) : security(syminfo.tickerid, chartResolution, high) halow = uha ?security(heikinashi(syminfo.tickerid), chartResolution, low) : security(syminfo.tickerid, chartResolution, low) vol = security(syminfo.tickerid, chartResolution, volume) volLen = input(30, minval=1,title="Volume Length", group="Indicator Parameters") volMAlen = input(14, minval=1,title="Volume MA Length", group="Indicator Parameters") volMAtype = input(title="Volume MA Type", type=input.string, group="Indicator Parameters", defval="HMA", options=["LRC","HMA"]) nVolAccum = sum(iff(haclose > haopen, vol, iff(haclose < haopen, -vol, 0)) ,volLen) nRes = nVolAccum / volLen volMA = iff(volMAtype=="HMA", hma(nRes , volMAlen), linreg(nRes , volMAlen,0)) //Oscillator Plot hline(0, color=color.red, linestyle=hline.style_dotted) col_grow_above = input(#08FF08, "Above   Grow", group="Histogram", inline="Above") col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above") col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below") col_fall_below = input(#E10600, "Fall", group="Histogram", inline="Below") hist_col = (nRes>=0 ? (nRes[1] < nRes ? col_grow_above : col_fall_above) : (nRes[1] < nRes ? col_grow_below : col_fall_below)) plot(nRes, title="Histogram", style=plot.style_columns, color=hist_col) // MA Coloring bullColor = color.from_gradient(volMA, 50, 80, color.new(#f1fd6d, 70), color.new(#f1fd6d, 0)) bearColor = color.from_gradient(volMA, 20, 50, color.new(#485cff, 0), color.new(#485cff, 70)) volMAcol = volMA > 0 ? bullColor : bearColor plot(volMA, "Signal", color = volMAcol, linewidth=2) // ---Bar Color--- show_color_bar = input(title='Color Bars', defval=true) barcolor(show_color_bar ? hist_col : na)