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
AMASling - All Moving Average Sling Shot
https://www.tradingview.com/script/b6xaJlaf-AMASling-All-Moving-Average-Sling-Shot/
EltAlt
https://www.tradingview.com/u/EltAlt/
68
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © EltAlt //@version=5 // ----------------------------------------------------------------------------- // // Title: AMASling - All Moving Average Sling Shot // Authors: @EltAlt // Revision: v1.00 // Date: 20-May-2022 // // Description // ============================================================================= // This indicator modifies the SlingShot System by Chris Moody to allow it to be based on 'any' Fast and Slow moving average pair. // Open Long / Close Long / Open Short / Close Short alerts can be generated for automated bot trading based on the SlingShot strategy: // • Conservative Entry = Fast MA above Slow MA, and previous bar close below Fast MA, and current price above Fast MA // • Conservative Entry = Fast MA below Slow MA, and previous bar close above Fast MA, and current price below Fast MA // • Aggressive Entry = Fast MA above Slow MA, and price below Fast MA // • Aggressive Exit = Fast MA below Slow MA, and price above Fast MA // // Entries and exits can also be made based on moving average crossovers, I initially put this in to make it easy to compare to a more // standard strategy, but upon backtesting combining crossovers with the SlingShot appeared to produce better results on some charts. // Alerts can also be filtered to allow long deals only when the fast moving average is above the slow moving average (uptrend) and // short deals only when the fast moving average is below the slow moving averages (downtrend). // // If you have a strategy that can buy based on External Indicators you can use the 'Backtest Signal' which plots the values set in // the 'Long / Short Signals' section. // // The Fast, Slow and Signal Moving Averages can be set to: // • Simple Moving Average (SMA) // • Exponential Moving Average (EMA) // • Weighted Moving Average (WMA) // • Volume-Weighted Moving Average (VWMA) // • Hull Moving Average (HMA) // • Exponentially Weighted Moving Average (RMA) (SMMA) // • Linear regression curve Moving Average (LSMA) // • Double EMA (DEMA) // • Double SMA (DSMA) // • Double WMA (DWMA) // • Double RMA (DRMA) // • Triple EMA (TEMA) // • Triple SMA (TSMA) // • Triple WMA (TWMA) // • Triple RMA (TRMA) // • Symmetrically Weighted Moving Average (SWMA) ** length does not apply ** // • Arnaud Legoux Moving Average (ALMA) // • Variable Index Dynamic Average (VIDYA) // • Fractal Adaptive Moving Average (FRAMA) // // 'Backtest Signal' and 'Deal State' are plotted to display.none, so change the Style Settings for the chart if you need to see them // for testing. // // ============================================================================= // // I would gladly accept any suggestions to improve the script. // If you encounter any problems please share them with me. // // Thanks to ChrisMoody for "CM Sling Shot System" which gave me the basis. // // Changlog // ============================================================================= // // 1.00 • Initial release // // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // // // ============ "AMASling - All Moving Average Sling Shot" indicator(title='AMASling - All Moving Average Sling Shot', shorttitle='AMASling', overlay = true, timeframe='', timeframe_gaps=true) // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // ============ Inputs MATip = 'Simple Moving Average (SMA)\nExponential Moving Average (EMA)\nWeighted Moving Average (WMA)\nVolume-Weighted Moving Average (VWMA)\nHull Moving Average (HMA)\nExponentially Weighted Moving Average (RMA) (SMMA)\nLinear regression curve Moving Average (LSMA)\nDouble EMA (DEMA)\nDouble SMA (DSMA)\nDouble WMA (DWMA)\nDouble RMA (DRMA)\nTriple EMA (TEMA)\nTriple SMA (TSMA)\nTriple WMA (TWMA)\nTriple RMA (TRMA)\nSymmetrically Weighted Moving Average (SWMA)\n** length does not apply to SWMA **\nArnaud Legoux Moving Average (ALMA)\nVariable Index Dynamic Average (VIDYA)\nFractal Adaptive Moving Average (FRAMA)' FastType = input.string('EMA', title='Fast Moving Average Type', group='Moving Averages', options=['EMA', 'SMA', 'WMA', 'VWMA', 'HMA', 'RMA', 'LSMA', 'Double EMA', 'Double SMA', 'Double WMA', 'Double RMA', 'Triple EMA', 'Triple SMA', 'Triple WMA', 'Triple RMA', 'SWMA', 'ALMA', 'VIDYA', 'FRAMA'], tooltip = MATip) FastSource = input (defval = close, title='Fast Source', inline='Fast', group='Moving Averages') FastLength = input.int (38, title='Fast Length', inline='Fast', group='Moving Averages', minval=2, maxval=1000) SlowType = input.string ('EMA', title='Slow Moving Average Type', group='Moving Averages', options=['EMA', 'SMA', 'WMA', 'VWMA', 'HMA', 'RMA', 'LSMA', 'Double EMA', 'Double SMA', 'Double WMA', 'Double RMA', 'Triple EMA', 'Triple SMA', 'Triple WMA', 'Triple RMA', 'SWMA', 'ALMA', 'VIDYA', 'FRAMA'], tooltip = MATip) SlowSource = input (defval = close, title='Slow Source', inline='Slow', group='Moving Averages') SlowLength = input.int (62, title='Slow Length', inline='Slow', group='Moving Averages', minval=2, maxval=1000) longUptrendOnly = input.bool (true, inline='1', group='Filters', title='Long Only in Uptrend') shortDowntrendOnly = input.bool (true, inline='1', group='Filters', title='Short Only in Downtrend') signalTip = 'Here you can set the signals that will enable backtester to open and close deals.\nIf the backtester you are using can only work with long OR short deals you may need to save diffent chart layouts for longs and shorts.\nIf \'Generate Close Signals for Long / Short Positions\' is not selected only the \'Open Long\' and \'Close Long\' settings will plot.' generateClose = input.bool (false, inline='0', group='Long / Short Signals', title='Generate Close Signals for Long / Short Positions', tooltip = signalTip) longOpenSignal = input.int (1, inline='1', group='Long / Short Signals', title='Open Long = ') longCloseSignal = input.int (2, inline='1', group='Long / Short Signals', title='Close Long = ') shortOpenSignal = input.int (-1, inline='2', group='Long / Short Signals', title='Open Short = ') shortCloseSignal = input.int (-2, inline='2', group='Long / Short Signals', title='Close Short = ') slingshotTip = 'SlingShot entries are based on CM_SlingShotSystem by Chris Moody. To replicate the SlingShot method exactly set:\nLong Only in Uptrend\nShort Only in Downtrend\nFast MA = EMA close 38\nSlow MA = EMA close 62\nSignal Length = 1\n' slingSigsTip = 'Buy Agressive Entry = Fast MA above Slow MA, and price below Fast MA\nSell Agressive Exit = Fast MA below Slow MA, and price above Fast MA\nBuy Conservative Entry = Fast MA above Slow MA, and previous bar close below Fast MA, and current price above Fast MA\nSell Conservative Entry = Fast MA below Slow MA, and previous bar close above Fast MA, and current price below Fast MA' aggFilterTip = 'Aggressive signals are often repeated for a few bars, this will show only the first of a cluster of aggressive signals.' buySlingConLong = input.bool (false, inline='1', group='Buy / Sell SlingShot System', title='Buy Conservative SlingShot Entry', tooltip = slingSigsTip) sellSlingConShort = input.bool (false, inline='1', group='Buy / Sell SlingShot System', title='Sell Conservative SlingShot Entry') buySlingAggLong = input.bool (false, inline='2', group='Buy / Sell SlingShot System', title='Buy Aggressive SlingShot Entry', tooltip = slingshotTip) sellSlingAggShort = input.bool (false, inline='2', group='Buy / Sell SlingShot System', title='Sell Aggressive SlingShot Exit') filterAggReps = input.bool (false, inline='3', group='Buy / Sell SlingShot System', title='First Aggressive Signal Only', tooltip = aggFilterTip) crossoverTip = 'Generate buy signals when the fast moving average crosses up on the slow moving average, or sell signals when the fast moving average crosses down on the slow moving average.\nThis is the same as the histogram crossing zero.' buyCrossover = input.bool (true, inline='1', group='Buy / Sell Moving Averages', title='Buy Moving Average Crossover', tooltip = crossoverTip) sellCrossunder = input.bool (true, inline='1', group='Buy / Sell Moving Averages', title='Sell Moving Average Crossunder') almaTip = 'Only required if ALMA is used as one of the moving averages.' offset_alma = input (0.85, title='ALMA Offset', inline='1', group='Alma', tooltip = almaTip) sigma_alma = input.float (6, title='ALMA Sigma', inline='1', group='Alma') framaTip = 'Only required if FRAMA is used as one of the moving averages.' FC = input.int(1, minval=1, title='FRAMA lower shift limit (FC)', inline='1', group='Frama', tooltip = framaTip) SC = input.int(198, minval=1, title='FRAMA upper shift limit (SC)', inline='1', group='Frama') alertsTip = 'By default SlingShot Conservative signals are 25% brighter than other signals.' plotAlerts = input.bool (true, inline='1', group='Plot Options', title='Plot Alerts', tooltip = alertsTip) plotMA = input.bool (true, inline='1', group='Plot Options', title='Plot Moving Averages') // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // ============ Functions getCMO(src, length) => mom = ta.change(src) upSum = math.sum(math.max(mom, 0), length) downSum = math.sum(-math.min(mom, 0), length) out = (upSum - downSum) / (upSum + downSum) out vidya(src, length) => alpha = 2 / (length + 1) cmo = math.abs(getCMO(src, length)) vidya = 0.0 vidya := src * alpha * cmo + nz(vidya[1]) * (1 - alpha * cmo) vidya frama(x, y, z, v) => // x = source , y = length , z = FC , v = SC HL = (ta.highest(high, y) - ta.lowest(low, y)) / y HL1 = (ta.highest(high, y / 2) - ta.lowest(low, y / 2)) / (y / 2) HL2 = (ta.highest(high, y / 2)[y / 2] - ta.lowest(low, y / 2)[y / 2]) / (y / 2) D = (math.log(HL1 + HL2) - math.log(HL)) / math.log(2) dim = HL1 > 0 and HL2 > 0 and HL > 0 ? D : nz(D[1]) w = math.log(2 / (v + 1)) alpha = math.exp(w * (dim - 1)) alpha1 = alpha > 1 ? 1 : alpha < 0.01 ? 0.01 : alpha oldN = (2 - alpha1) / alpha1 newN = (v - z) * (oldN - 1) / (v - 1) + z newalpha = 2 / (newN + 1) newalpha1 = newalpha < 2 / (v + 1) ? 2 / (v + 1) : newalpha > 1 ? 1 : newalpha frama = 0.0 frama := (1 - newalpha1) * nz(frama[1]) + newalpha1 * x frama calcMA(_type, _src, _length) => switch _type 'EMA' => ta.ema(_src, _length) 'SMA' => ta.sma(_src, _length) 'WMA' => ta.wma(_src, _length) 'VWMA' => ta.vwma(_src, _length) 'HMA' => ta.hma(_src, _length) 'RMA' => ta.rma(_src, _length) 'LSMA' => ta.linreg(_src, _length, 0) 'Double EMA' => 2 * ta.ema(_src, _length) - ta.ema(ta.ema(_src, _length), _length) 'Double SMA' => 2 * ta.sma(_src, _length) - ta.sma(ta.sma(_src, _length), _length) 'Double WMA' => 2 * ta.wma(_src, _length) - ta.wma(ta.wma(_src, _length), _length) 'Double RMA' => 2 * ta.rma(_src, _length) - ta.rma(ta.rma(_src, _length), _length) 'Triple EMA' => 3 * (ta.ema(_src, _length) - ta.ema(ta.ema(_src, _length), _length)) + ta.ema(ta.ema(ta.ema(_src, _length), _length), _length) 'Triple SMA' => 3 * (ta.sma(_src, _length) - ta.sma(ta.sma(_src, _length), _length)) + ta.sma(ta.sma(ta.sma(_src, _length), _length), _length) 'Triple WMA' => 3 * (ta.wma(_src, _length) - ta.wma(ta.wma(_src, _length), _length)) + ta.wma(ta.wma(ta.wma(_src, _length), _length), _length) 'Triple RMA' => 3 * (ta.rma(_src, _length) - ta.rma(ta.rma(_src, _length), _length)) + ta.rma(ta.rma(ta.rma(_src, _length), _length), _length) 'SWMA' => ta.swma(_src) // No Length for SWMA 'ALMA' => ta.alma(_src, _length, offset_alma, sigma_alma) 'VIDYA' => vidya(_src, _length) 'FRAMA' => frama(_src, _length, FC, SC) // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // ============ Calculations MA_fast = calcMA(FastType, FastSource, FastLength) MA_slow = calcMA(SlowType, SlowSource, SlowLength) uptrend = MA_fast > MA_slow crossover = ta.crossover(MA_fast, MA_slow) crossunder = ta.crossunder(MA_fast, MA_slow) // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // ============ Logic // ------------ SlingShot bool slingAggLong = MA_fast > MA_slow and close < MA_fast bool slingAggShort = MA_fast < MA_slow and close > MA_fast bool slingConLong = MA_fast > MA_slow and close[1] < MA_fast and close > MA_fast bool slingConShort = MA_fast < MA_slow and close[1] > MA_fast and close < MA_fast // ------------ Order Logic var int dealstate = 0 bool openLong = false bool closeLong = false bool openShort = false bool closeShort = false backtestBuy = (buyCrossover and crossover) or (buySlingConLong and slingConLong) or (buySlingAggLong and slingAggLong and not (slingAggLong[1] and filterAggReps)) backtestSell = (sellCrossunder and crossunder) or (sellSlingConShort and slingConShort) or (sellSlingAggShort and slingAggShort and not (slingAggShort[1] and filterAggReps)) if backtestBuy and not backtestSell if uptrend or not longUptrendOnly if generateClose and dealstate == -1 closeShort := true dealstate := 0 else openLong := true dealstate := 1 else if generateClose and dealstate == -1 closeShort := true dealstate := 0 if backtestSell and not backtestBuy if not uptrend or not shortDowntrendOnly if generateClose and dealstate <= 0 openShort := true dealstate := -1 else closeLong := true dealstate := 0 else if generateClose and dealstate == 1 closeLong := true dealstate := 0 // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // ============ Plot plotFast = plot(plotMA ? MA_fast : na, title= 'Fast Moving Average', color = color.lime )//MA_fast > MA_slow ? color.lime : MA_fast < MA_slow ? color.red : color.yellow) plotSlow = plot(plotMA ? MA_slow : na, title= 'Slow Moving Average', color = color.red)//MA_fast > MA_slow ? color.lime : MA_fast < MA_slow ? color.red : color.yellow) fill(plotFast, plotSlow, color=color.new(color.silver, 75)) plot(closeShort ? shortCloseSignal : openLong ? longOpenSignal : closeLong ? longCloseSignal : openShort ? shortOpenSignal : 0, 'Backtest Signal', color=openLong or closeShort ? color.lime : openShort or closeLong? color.red : color.gray, display=display.none) plot(dealstate, title='Deal State', display=display.none, color = (dealstate > 0 ? color.lime : dealstate < 0 ? color.red : color.gray)) // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // ============ Alerts alertcondition (openLong, title='AMASling Open Long!', message='Buy signal, put your JSON here to open longs or start bots.') alertcondition (openShort, title='AMASling Open Short!', message='Sell signal, put your JSON here to open shorts or stop bots.') alertcondition (closeShort, title='AMASling Close Short!', message='Buy signal, put your JSON here to close shorts or start bots.') alertcondition (closeLong, title='AMASling Close Long!', message='Sell signal, put your JSON here to close longs or stop bots.') plotshape (plotAlerts ? openLong : na, style=shape.triangleup, color=slingConLong ? color.lime : color.new(color.lime, 50), location=location.bottom, size=size.tiny, title='Open Long') plotshape (plotAlerts ? closeShort : na, style=shape.square, color=slingConLong ? color.red : color.new(color.red, 50), location=location.bottom, size=size.tiny, title='Close Short') plotshape (plotAlerts ? openShort : na, style=shape.triangledown, color=slingConShort ? color.red : color.new(color.red, 50), location=location.bottom, size=size.tiny, title='Open Short') plotshape (plotAlerts ? closeLong : na, style=shape.square, color=slingConShort ? color.lime : color.new(color.lime, 50), location=location.bottom, size=size.tiny, title='Close Long')
EMA Price Distance Tracker
https://www.tradingview.com/script/etREth7l-EMA-Price-Distance-Tracker/
jordanfray
https://www.tradingview.com/u/jordanfray/
92
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jordanfray //@version=5 indicator(title="EMA Price Distance Tracker", overlay=true) // Indenting Classs indent_1 = " " indent_2 = "  " indent_3 = "   " indent_4 = "    " indent_5 = "     " indent_6 = "      " indent_7 = "       " indent_8 = "        " indent_9 = "         " indent_10 = "          " // Group Titles group_one_title = "EMA Settings" group_two_title = "EMA Distance Settings" // Colors blue = color.new(#00A5FF,0) green = color.new(#2DBD85,0) gray_80 = color.new(#7F7F7F,80) gray_60 = color.new(#7F7F7F,60) gray_40 = color.new(#7F7F7F,40) white = color.new(#ffffff,0) // Strategy Settings EMAtimeframe = input.timeframe(defval="", title="Timeframe", group=group_one_title) EMAlength = input.int(defval=200, minval=1, title="Length", group=group_one_title) EMAtype = input.string(defval="EMA", options = ["EMA", "SMA", "RMA", "WMA"], title="Type", group=group_one_title) EMAsource = input.source(defval=close, title="Source", group=group_one_title) low_level = input.int(defval=10, title="Low EMA Distance", group=group_two_title) mid_level = input.int(defval=20, title="Medium EMA Distance", group=group_two_title) high_level = input.int(defval=30, title="High EMA Distance", group=group_two_title) // Calulate EMA EMA = switch EMAtype "EMA" => ta.ema(EMAsource, EMAlength) "SMA" => ta.sma(EMAsource, EMAlength) "RMA" => ta.rma(EMAsource, EMAlength) "WMA" => ta.wma(EMAsource, EMAlength) => na EMA_ = EMAtimeframe == timeframe.period ? EMA : request.security(syminfo.ticker, EMAtimeframe, EMA[1], lookahead = barmerge.lookahead_on) // EMA Distance Settings hline(0, title="Zero Line", color=white, linestyle=hline.style_solid) hline(low_level, title="Low Level Line",color=gray_80, linestyle=hline.style_solid) hline(mid_level, title="Mid Level Line",color=gray_60, linestyle=hline.style_solid) hline(high_level, title="High Level Line",color=gray_40, linestyle=hline.style_solid) // Calculate Price's Distance from EMA distance_from_EMA = ((close - EMA_)/close)*100 if distance_from_EMA < 0 distance_from_EMA := distance_from_EMA * -1 plot(distance_from_EMA, title="Distance from EMA", color=blue, linewidth=2)
Pivoting Pivot
https://www.tradingview.com/script/2MvmxhkV-Pivoting-Pivot/
OztheWoz
https://www.tradingview.com/u/OztheWoz/
55
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © OztheWoz // Pivoting pivots. Thank you to @fikira for the help with ideas on how to code this! //@version=5 indicator("Pivoting Pivot", overlay=true) p_left = input.int(2, "Pivot Left") p_right = input.int(2, "Pivot Right") lg_left = input.int(2, "LG Left") lg_right = input.int(2, "LG Right") _xyval(_cond, _ysrc, _xsrc) => x = ta.valuewhen(_cond, _xsrc, 0) y = ta.valuewhen(_cond, _ysrc, 0) [x, y] _clearIntArray(_array, oversize) => size = array.size(_array) if size > oversize (array.pop(_array)) ph = ta.pivothigh(high, p_left, p_right) pl = ta.pivotlow (low, p_left, p_right) p_since = ta.barssince(ph or pl) [ph_x, ph_y] = _xyval(not na(ph), high[p_right], bar_index[p_right]) [pl_x, pl_y] = _xyval(not na(pl), low[p_right], bar_index[p_right]) // barcolor(ph ? color.yellow : pl ? color.white : na, offset=-2) _getLG(int _left, int _right) => lg_Hpivot = false lg_Lpivot = false if barstate.isconfirmed var pTime_array = array.new_int() switch (ph and not pl) => array.unshift(pTime_array, ph_x) (pl and not ph) => array.unshift(pTime_array, pl_x) (pl and ph) => array.unshift(pTime_array, pl_x) _clearIntArray(pTime_array, 2) p_curr = array.get(pTime_array, array.size(pTime_array) > 0 ? 0 : na) p_last = array.get(pTime_array, array.size(pTime_array) > 1 ? 1 : na) lg_Hpivot := (math.abs(p_curr - p_last) >= _left+1) and (p_since >= _right) and (ph[_right]) lg_Lpivot := (math.abs(p_curr - p_last) >= _left+1) and (p_since >= _right) and (pl[_right]) [lg_Hpivot, lg_Lpivot] [lg_H, lg_L] = _getLG(lg_left, lg_right) barcolor(lg_H ? color.blue : lg_L ? color.navy : na, offset=-(p_right + lg_right))
Moving Average Convergence Divergence with Rate of Change
https://www.tradingview.com/script/mfVtTk2X-Moving-Average-Convergence-Divergence-with-Rate-of-Change/
Bhangerang
https://www.tradingview.com/u/Bhangerang/
39
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Bhangerang //@version=5 indicator(title="Moving Average Convergence Divergence with Rate of Change", shorttitle="MACD with Rate of Change", timeframe="", timeframe_gaps=true) // Getting inputs 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.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) // Calculating fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) macd = fast_ma - slow_ma signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length) hist = macd - signal bool rate_increasing = math.abs(hist[1]-hist[2]) < math.abs(hist-hist[1]) ? true : false // Plot colors col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD") col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal") col_grow_above_rate_increase = input(#00332a, "Above   Grow Rate Increase", group="Histogram", inline="Above and Increasing") col_fall_above_rate_increase = input(#B2DFDB, "Fall Rate Increase", group="Histogram", inline="Above and Increasing") col_grow_below_rate_increase = input(#FFCDD2, "Below Grow Rate Increase", group="Histogram", inline="Below and Increasing") col_fall_below_rate_increase = input(#801922, "Fall Rate Increase", group="Histogram", inline="Below and Increasing") col_grow_above_rate_decrease = input(#056656, "Above   Grow Rate Decrease", group="Histogram", inline="Above and Decreasing") col_fall_above_rate_decrease = input(#42bda8, "Fall Rate Decrease", group="Histogram", inline="Above and Decreasing") col_grow_below_rate_decrease = input(#f77c80, "Below Grow Rate Decrease", group="Histogram", inline="Below and Decreasing") col_fall_below_rate_decrease = input(#f23645, "Fall Rate Decrease", group="Histogram", inline="Below and Decreasing") plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? (rate_increasing ? col_grow_above_rate_increase : col_grow_above_rate_decrease) : (rate_increasing ? col_fall_above_rate_increase : col_fall_above_rate_decrease)) : (hist[1] < hist ? (rate_increasing ? col_grow_below_rate_increase : col_grow_below_rate_decrease) : (rate_increasing ? col_fall_below_rate_increase : col_fall_below_rate_decrease)))) plot(macd, title="MACD", color=col_macd) plot(signal, title="Signal", color=col_signal)
Signal generator
https://www.tradingview.com/script/xBRGQTy0-Signal-generator/
RobertD7723
https://www.tradingview.com/u/RobertD7723/
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/ // © RobertD7723 // This script generates signals to test Jackrabbit Relay. // DO NOT USE IT FOR LIVE TRADING. // YOU WILL LOOSE ALL YOUR MONEY IF YOU DO. //@version=5 indicator('Tester', overlay=true) // Functrions var label lblStats = na fprint(labl, _txt, _y, _color, _offsetLabels) => label _lbl = labl _t = int(time + (time - time[1]) * _offsetLabels) if barstate.islast if na(_lbl) // Only create label once. _lbl := label.new(_t, _y, _txt, xloc.bar_time, yloc.price, #00000000, label.style_none, _color, size.normal,textalign=text.align_left) // Fudge return type of `if` block so compiler doesn't complain (thx midtownsk8rguy for the trick). _lbl else // Rather than delete and recreate the label on every realtime bar update, update the label's information; it's more efficient. label.set_xy(_lbl, _t, _y) label.set_text(_lbl, _txt) label.set_textcolor(_lbl, _color) label.set_textalign(_lbl,text.align_left) _lbl // Do we want to test DCA functionality testDCA=input.string(defval="No",options=["Yes","No"],title="Test DCA") TakeProfit=input.float(defval=1.0,minval=0.0,title="Take Profit")/100 colStats=input.color(defval=#0000ff,title="Stats Color") // Define nweeded data points/variables from the chart. // This is done to prevent updates during the analysis section. so=open sc=close // For keeping track of the average for DCA analysis var sum=0.0 var count=0 // For DSR testing. Total buys (tb) and trade cycles/total sells (tc) var lp=0.0 var tb=0 var tc=0 // Analysis section BuySignal = so > sc SellSignal = sc > so // The DCA logic as follows: // First purchase of Trade Cycle, last price = closng price // Rest of trade cycle rewquires price to be less then last purchase if BuySignal tb+=1 if testDCA=="Yes" if count==0 lp:=sc sum+=sc count+=1 else if sc<lp lp:=sc sum+=sc count+=1 else BuySignal:=false // Figure out average and take profit average=sum/count tp=average+(average*TakeProfit) if SellSignal if testDCA=="Yes" and count>0 if sc>tp tc+=1 sum:=0.0 count:=0 else SellSignal:=false else tc+=1 sum:=0.0 count:=0 // Display statistics firstBarTime = ta.valuewhen(bar_index == 1, time, 0) lastBarTime = timenow timeStart = firstBarTime timeEnd = lastBarTime timeElapsedDays = (timeEnd - timeStart) / 86400000 txt="Time elapsed: " + str.tostring(timeElapsedDays,"0.00") + " days" if testDCA=="Yes" txt:=txt+"\nTrade Cycles: "+str.tostring(tc) +"\nTotal Buys: "+str.tostring(tb) else txt:=txt+"\nTotal Sells: "+str.tostring(tc) +"\nTotal Buys: "+str.tostring(tb) ls=fprint(lblStats,txt,sc,colStats,0) lblStats:=ls // Handle alerts and display markers alertcondition(BuySignal, 'BUY ASSET', 'Below buy zone') alertcondition(SellSignal, 'SELL ASSET', 'Above sell zone') plotshape(BuySignal, style=shape.triangleup, location=location.bottom, color=color.new(#000000, 0), size=size.tiny, title='Buy') plotshape(SellSignal, style=shape.triangledown, location=location.top, color=color.new(#000000, 0), size=size.tiny, title='Sell')
PhinkTrade Risk Manager Essentials
https://www.tradingview.com/script/MYyrALvU-PhinkTrade-Risk-Manager-Essentials/
PhinkTrade
https://www.tradingview.com/u/PhinkTrade/
106
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © PhinkTrade 2022 //@version=5 indicator('PhinkTrade Risk Manager Essentials v.2.2', shorttitle = 'Risk Manager Essentials v.2.2 [PhinkTrade]', overlay=true) //////////////////////////////////// //Start settings entry1_defVal = 0.0 entry2_defVal = 0.0 entry3_defVal = 0.0 stopLoss_defVal = 0.0 target1_defVal = 0.0 target2_defVal = 0.0 target3_defVal = 0.0 currentEquity_defVal = 1000 percentRisk_defVal = 1 showMinimumIdealTarget_defVal = true displayAverageTarget_defVal = false displayAverageEntry_defVal = false chartCurrencyPrecision_defVal = "2" baseCurrencyPrecision_defVal = "4" pricePrecision_defVal = "2" labelSizeSetting_defVal = 'Normal' labelPositionReference_defVal = 'Auto' //'Latest Bar Date / Time', 'Journal Date / Time' //////////////////////////////////// // Inputs // Prices Settings entry1 = input.price(title='Entry 1', group='Entries', defval=entry1_defVal, inline='entries 1', confirm=true, tooltip='Define your entry price. You can also define 2 more entries in \'Settings\' window.') entry2 = input.price(title='Entry 2', group='Entries', defval=entry2_defVal, inline='entries 1') entry3 = input.price(title='Entry 3', group='Entries', defval=entry3_defVal, inline='entries 1') stopLoss = input.price(title='Stop Loss', defval=stopLoss_defVal, group='Risk', confirm=true, tooltip='Define your stop loss price.') target1 = input.price(title='Target 1', group='Targets', defval=target1_defVal, inline='targets 1', confirm=true, tooltip='Define your target price. You can also define 2 more targets (or no target at all - set all to 0) in \'Settings\' window.') target2 = input.price(title='Target 2', group='Targets', defval=target2_defVal, inline='targets 1') target3 = input.price(title='Target 3', group='Targets', defval=target3_defVal, inline='targets 1') // Base Settings currentEquity = input.float(title='Starting Capital (in chart currency)', defval=currentEquity_defVal, group='Base Settings', confirm=true, minval=0.00000001, tooltip="Your starting capital for this trade. Must be set in order for position size to be calculated.\n\n\'Chart currency\' is the one usually displayed at the top right corner, over the scale bar (e.g. USD in a BTCUSD chart).\n\nRecommended: update it before every trade, so your risk amount remains under control. This is the main point of this indicator, after all! 😉") percentRisk = input.float(title='Risk (as % of Starting Capital)', defval=percentRisk_defVal, minval=0, maxval=100, group='Risk', confirm=true, tooltip='Define how much of your starting capital you are willing to lose if this trade gets stopped out (in % terms).') / 100 // Journal Settings tradeDateTime = input.time(title='Trade Date / Time', defval=0, group='Journal', inline='Journal', tooltip='Date and time of the trade. Labels Position Reference setting can use this information to display labels near the date/time defined here.') //timestamp('01 Jan 2021 00:00 +0000') // Display Settings showMinimumIdealTarget = input.bool(title='Display Minimum Recommended Target (3:1 Return/Risk Best Practice)', defval=showMinimumIdealTarget_defVal, group='Display Settings') displayAverageTarget = input.bool(title='Display Average Target', defval=displayAverageTarget_defVal, group='Display Settings') displayAverageEntry = input.bool(title='Display Average Entry', defval=displayAverageEntry_defVal, group='Display Settings') chartCurrencyPrecision = input.string(title='Chart Currency Precision', defval=chartCurrencyPrecision_defVal, options=['0','1','2','3','4','5','6','7','8'], group='Display Settings') baseCurrencyPrecision = input.string(title='Base Currency / Asset Precision', defval=baseCurrencyPrecision_defVal, options=['0','1','2','3','4','5','6','7','8'], group='Display Settings') pricePrecision = input.string(title='Price Precision', defval=pricePrecision_defVal, options=['0','1','2','3','4','5','6','7','8'], group='Display Settings') labelSizeSetting = input.string(title='Labels Size', defval=labelSizeSetting_defVal, options=['Tiny', 'Small', 'Normal', 'Large'], group='Display Settings') labelPositionReference = input.string(title='Labels Position Reference', options=['Auto','Latest Bar Date / Time', 'Journal Date / Time'], defval=labelPositionReference_defVal, group='Display Settings', tooltip='Choose to display labels near the latest bar (real-time), near the date / time defined in Journal settings, above, or automatically (default; if no custom trade date is set, labels will be displayed near the latest bar; otherwise, near the chosen date).') labelOffsetToTheRight = input.int(title='Labels offset (to the right)', defval=10, group='Display Settings', tooltip='Use to reposition labels farther or closer to reference date / time chosen above.') secondaryLabelsOffsetToTheRight = input.int(title='Secondary labels offset (to the right)', defval=10, group='Display Settings', tooltip='Use to reposition secondary labels (Minimum Recommended Target, Average Entry and Average Target) farther or closer to reference date / time chosen above.') longEntriesLabelsBgColor = input.color(title='Long Entries Labels Backg. Color', defval=color.green, group='Display Settings', inline='Colors 1') longEntriesLabelsTxtColor = input.color(title='Long Entries Labels Text Color', defval=color.white, group='Display Settings', inline='Colors 1') shortEntriesLabelsBgColor = input.color(title='Short Entries Labels Backg. Color', defval=color.red, group='Display Settings', inline='Colors 2') shortEntriesLabelsTxtColor = input.color(title='Short Entries Labels Text Color', defval=color.white, group='Display Settings', inline='Colors 2') longStopLabelBgColor = input.color(title='Long Stop Label Backg. Color', defval=color.red, group='Display Settings', inline='Colors 3') longStopLabelTxtColor = input.color(title='Long Stop Label Text Color', defval=color.white, group='Display Settings', inline='Colors 3') shortStopsLabelsBgColor = input.color(title='Short Stop Label Backg. Color', defval=color.green, group='Display Settings', inline='Colors 4') shortStopsLabelsTxtColor = input.color(title='Short Stop Label Text Color', defval=color.white, group='Display Settings', inline='Colors 4') longTargetsLabelsBgColor = input.color(title='Long Targets Labels Backg. Color', defval=color.red, group='Display Settings', inline='Colors 5') longTargetsLabelsTxtColor = input.color(title='Long Targets Labels Text Color', defval=color.white, group='Display Settings', inline='Colors 5') shortTargetsLabelsBgColor = input.color(title='Short Targets Labels Backg. Color', defval=color.green, group='Display Settings', inline='Colors 6') shortTargetsLabelsTxtColor = input.color(title='Short Targets Labels Text Color', defval=color.white, group='Display Settings', inline='Colors 6') minimumLongTargetsLabelsBgColor = input.color(title='Minimum Long Target Label Backg. Color', defval=#F5F5F5, group='Display Settings', inline='Colors 7') minimumLongTargetsLabelsTxtColor = input.color(title='Minimum Long Target Label Text Color', defval=color.red, group='Display Settings', inline='Colors 7') minimumShortTargetsLabelsBgColor = input.color(title='Minimum Short Target Label Backg. Color', defval=#F5F5F5, group='Display Settings', inline='Colors 8') minimumShortTargetsLabelsTxtColor = input.color(title='Minimum Short Target Label Text Color', defval=color.green, group='Display Settings', inline='Colors 8') //////////////////////////////////// //Functions getFormattingString(precision) => formattingString = "" if precision == 0 formattingString := "#" else if precision > 0 formattingString := "#." for i = 1 to precision formattingString := formattingString + "#" formattingString targetForReturnRiskRatio(maxRisk, avgEntry, orderSize, rrRatio, tradeSide) => target = 0.0 entryValue = orderSize * avgEntry / syminfo.mintick * syminfo.pointvalue * syminfo.mintick if true if tradeSide == 'Long' target := (syminfo.mintick * ((rrRatio * maxRisk) / (syminfo.pointvalue * syminfo.mintick)) + avgEntry * orderSize) / orderSize target else target := (syminfo.mintick * ((rrRatio * maxRisk) / (syminfo.pointvalue * syminfo.mintick)) + avgEntry * orderSize) / orderSize target target expectedResultIfFullyExecuted(target, avgEntry, orderSize, tradeSide) => netResult = 0.0 entryValue = orderSize * avgEntry / syminfo.mintick * syminfo.pointvalue * syminfo.mintick takeProfitValue = orderSize * target / syminfo.mintick * syminfo.pointvalue * syminfo.mintick grossResult = takeProfitValue - entryValue netResult := grossResult netResult returnOverRisk(expectedReturn, allowedRisk) => returnRatio = expectedReturn / allowedRisk returnRatio //////////////////////////////////// // Init Vars maxRisk = currentEquity * percentRisk entries = array.new_float(0, na) if entry1 != 0.0 array.push(entries, entry1) if entry2 != 0.0 array.push(entries, entry2) if entry3 != 0.0 array.push(entries, entry3) avgEntry = array.avg(entries) tradeSide = avgEntry >= stopLoss ? 'Long' : 'Short' targets = array.new_float(0, na) if target1 != 0.0 array.push(targets, target1) if target2 != 0.0 array.push(targets, target2) if target3 != 0.0 array.push(targets, target3) avgTarget = array.avg(targets) // Minimum Ideal Target (based on 3:1 best practice) minimalIdealReturnRiskRatio = 3 targetsOrderSizesInBaseCurrency = array.new_float(0, na) maxAllowedPositionSizeInBaseCurrency = 0.0 effectiveMaxAllowedPositionSizeInBaseCurrency = 0.0 averageEntrySizeInBaseCurrency = 0.0 effectiveAverageEntrySizeInBaseCurrency = 0.0 entrySize1InBaseCurrency = 0.0 entrySize2InBaseCurrency = 0.0 entrySize3InBaseCurrency = 0.0 positionSize = 0.0 entrySize1 = 0.0 entrySize2 = 0.0 entrySize3 = 0.0 averageEntrySize = 0.0 averageTakeProfitSizeInBaseCurrency = 0.0 targetSize1InBaseCurrency = 0.0 targetSize2InBaseCurrency = 0.0 targetSize3InBaseCurrency = 0.0 targetSize1 = 0.0 targetSize2 = 0.0 targetSize3 = 0.0 rawAverageTargetSizeInBaseCurrency = 0.0 chartCurrencyFormattingString = getFormattingString(str.tonumber(chartCurrencyPrecision)) baseCurrencyFormattingString = getFormattingString(str.tonumber(baseCurrencyPrecision)) priceFormattingString = getFormattingString(str.tonumber(pricePrecision)) //////////////////////////////////// // Main Calcs //Calculate Max Allowed Position Size maxAllowedPositionSizeInBaseCurrency := maxRisk / ((avgEntry - stopLoss) / syminfo.mintick * syminfo.pointvalue * syminfo.mintick) // Calculate Individual Entry Sizes, considering initial / raw Max Position Size, in Base Currency, being equally divided between number of entries averageEntrySizeInBaseCurrency := float(maxAllowedPositionSizeInBaseCurrency / array.size(entries)) // even distribution between entries (shall be changed in future releases to support uneven distributions) // Set entry orders sizes for further calculations entrySize1InBaseCurrency := entry1 != 0.0 ? averageEntrySizeInBaseCurrency : 0.0 entrySize2InBaseCurrency := entry2 != 0.0 ? averageEntrySizeInBaseCurrency : 0.0 entrySize3InBaseCurrency := entry3 != 0.0 ? averageEntrySizeInBaseCurrency : 0.0 effectiveMaxAllowedPositionSizeInBaseCurrency := entrySize1InBaseCurrency + entrySize2InBaseCurrency + entrySize3InBaseCurrency effectiveAverageEntrySizeInBaseCurrency := effectiveMaxAllowedPositionSizeInBaseCurrency / array.size(entries) averageTakeProfitSizeInBaseCurrency := float(averageEntrySizeInBaseCurrency * array.size(entries) / array.size(targets)) targetSize1InBaseCurrency := target1 != 0.0 ? averageTakeProfitSizeInBaseCurrency : 0.0 targetSize2InBaseCurrency := target2 != 0.0 ? averageTakeProfitSizeInBaseCurrency : 0.0 targetSize3InBaseCurrency := target3 != 0.0 ? averageTakeProfitSizeInBaseCurrency : 0.0 // Set Display Variables positionSize := effectiveMaxAllowedPositionSizeInBaseCurrency averageEntrySize := effectiveAverageEntrySizeInBaseCurrency entrySize1 := entry1 != 0.0 ? entrySize1InBaseCurrency : 0.0 entrySize2 := entry2 != 0.0 ? entrySize2InBaseCurrency : 0.0 entrySize3 := entry3 != 0.0 ? entrySize3InBaseCurrency : 0.0 targetSize1 := target1 != 0.0 ? targetSize1InBaseCurrency : 0.0 targetSize2 := target2 != 0.0 ? targetSize2InBaseCurrency : 0.0 targetSize3 := target3 != 0.0 ? targetSize3InBaseCurrency : 0.0 currencyToDisplay = syminfo.basecurrency //Adjust position size given chosen precision (to avoid a wrong total position size given rounding on average size) precisionAdjustedPositionSize = array.size(entries) * str.tonumber(str.tostring(math.abs(averageEntrySize), baseCurrencyFormattingString)) // Results and Return : Risk Ratios Calcs minimumIdealTarget = targetForReturnRiskRatio(maxRisk, avgEntry, effectiveMaxAllowedPositionSizeInBaseCurrency, minimalIdealReturnRiskRatio, tradeSide) minimumIdealTargetExpectedGainIfFullyExecuted = expectedResultIfFullyExecuted(minimumIdealTarget, avgEntry, effectiveMaxAllowedPositionSizeInBaseCurrency, tradeSide) // Targets Calculations // Target 1 target1ExpectedGain = expectedResultIfFullyExecuted(target1, avgEntry, targetSize1InBaseCurrency, tradeSide) target1ReturnOverRisk = returnOverRisk(target1ExpectedGain, maxRisk) // Target 2 target2ExpectedGain = expectedResultIfFullyExecuted(target2, avgEntry, targetSize2InBaseCurrency, tradeSide) target2ReturnOverRisk = returnOverRisk(target2ExpectedGain, maxRisk) // Target 3 target3ExpectedGain = expectedResultIfFullyExecuted(target3, avgEntry, targetSize3InBaseCurrency, tradeSide) target3ReturnOverRisk = returnOverRisk(target3ExpectedGain, maxRisk) // Average Target avgTargetExpectedGain = expectedResultIfFullyExecuted(avgTarget, avgEntry, effectiveMaxAllowedPositionSizeInBaseCurrency, tradeSide) avgTargetReturnOverRisk = returnOverRisk(avgTargetExpectedGain, maxRisk) // All data produced at this point // Moving to Presentation / Plotting //////////////////////////////////// // PLOTTINGS //Labels Positioning and Style labelXPosition = ((labelPositionReference == 'Auto') and tradeDateTime == 0) or labelPositionReference == 'Latest Bar Date / Time' ? time + labelOffsetToTheRight * (time - time[1]) : tradeDateTime + labelOffsetToTheRight * (time - time[1]) secondaryLabelXPosition = ((labelPositionReference == 'Auto') and tradeDateTime == 0) or labelPositionReference == 'Latest Bar Date / Time' ? time + secondaryLabelsOffsetToTheRight * (time - time[1]) : tradeDateTime + secondaryLabelsOffsetToTheRight * (time - time[1]) labelStyle = label.style_label_left labelSize = labelSizeSetting == 'Small' ? size.small : labelSizeSetting == 'Tiny' ? size.tiny : labelSizeSetting == 'Normal' ? size.normal : labelSizeSetting == 'Large' ? size.large : size.small // Primary Labels // Entries entry1LabelString = 'Entry 1: ' + (tradeSide == 'Long' ? 'Buy ' : 'Sell ') + str.tostring(math.abs(entrySize1), baseCurrencyFormattingString) + ' ' + currencyToDisplay + ' at ' + str.tostring(entry1, priceFormattingString) entry1TooltipString = entry1LabelString entry1Label = entry1 > 0.0 ? label.new(x=labelXPosition, y=entry1, text=entry1LabelString, color=tradeSide == 'Long' ? longEntriesLabelsBgColor : shortEntriesLabelsBgColor, textcolor=tradeSide == 'Long' ? longEntriesLabelsTxtColor : shortEntriesLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=entry1TooltipString) : na label.delete(entry1Label[1]) entry2LabelString = 'Entry 2: ' + (tradeSide == 'Long' ? 'Buy ' : 'Sell ') + str.tostring(math.abs(entrySize2), baseCurrencyFormattingString) + ' ' + currencyToDisplay + ' at ' + str.tostring(entry2, priceFormattingString) entry2TooltipString = entry2LabelString entry2Label = entry2 > 0.0 ? label.new(x=labelXPosition, y=entry2, text=entry2LabelString, color=tradeSide == 'Long' ? longEntriesLabelsBgColor : shortEntriesLabelsBgColor, textcolor=tradeSide == 'Long' ? longEntriesLabelsTxtColor : shortEntriesLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=entry2TooltipString) : na label.delete(entry2Label[1]) entry3LabelString = 'Entry 3: ' + (tradeSide == 'Long' ? 'Buy ' : 'Sell ') + str.tostring(math.abs(entrySize3), baseCurrencyFormattingString) + ' ' + currencyToDisplay + ' at ' + str.tostring(entry3, priceFormattingString) entry3TooltipString = entry3LabelString entry3Label = entry3 > 0.0 ? label.new(x=labelXPosition, y=entry3, text=entry3LabelString, color=tradeSide == 'Long' ? longEntriesLabelsBgColor : shortEntriesLabelsBgColor, textcolor=tradeSide == 'Long' ? longEntriesLabelsTxtColor : shortEntriesLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=entry3TooltipString) : na label.delete(entry3Label[1]) // Stop Loss stopLossLabelString = 'Stop Loss: ' + (tradeSide == 'Long' ? 'Sell ' : 'Buy ') + str.tostring(math.abs(precisionAdjustedPositionSize)) + ' ' + currencyToDisplay + ' at ' + str.tostring(stopLoss, priceFormattingString) + ' (Gross Risk: ' + str.tostring(maxRisk, chartCurrencyFormattingString) + ' ' + syminfo.currency + ')' stopLossTooltipString = stopLossLabelString stopLossLabel = stopLoss > 0.0 ? label.new(x=labelXPosition, y=stopLoss, text=stopLossLabelString, color=tradeSide == 'Long' ? longStopLabelBgColor : shortStopsLabelsBgColor, textcolor=tradeSide == 'Long' ? longStopLabelTxtColor : shortStopsLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=stopLossTooltipString) : na label.delete(stopLossLabel[1]) // Targets target1BuySellLabelString = (tradeSide == 'Long' ? 'Sell ' : 'Buy ') + str.tostring(math.abs(targetSize1), baseCurrencyFormattingString) + ' ' + currencyToDisplay target1LabelString = 'Target 1: ' + target1BuySellLabelString + ' at ' + str.tostring(target1, priceFormattingString) + ' (Gross Return: ' + str.tostring(target1ExpectedGain, chartCurrencyFormattingString) + ' ' + syminfo.currency + '; ' + str.tostring(target1ReturnOverRisk, '#.##') + ':1 R/R)' target1TooltipString = target1LabelString + '. Return if fully executed at entry and target.' intendedTargetLabel = target1 > 0.0 ? label.new(x=labelXPosition, y=target1, text=target1LabelString, color=tradeSide == 'Long' ? longTargetsLabelsBgColor : shortTargetsLabelsBgColor, textcolor=tradeSide == 'Long' ? longTargetsLabelsTxtColor : shortTargetsLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=target1TooltipString) : na label.delete(intendedTargetLabel[1]) target2BuySellLabelString = (tradeSide == 'Long' ? 'Sell ' : 'Buy ') + str.tostring(math.abs(targetSize2), baseCurrencyFormattingString) + ' ' + currencyToDisplay target2LabelString = 'Target 2: ' + target2BuySellLabelString + ' at ' + str.tostring(target2, priceFormattingString) + ' (Gross return: ' + str.tostring(target2ExpectedGain, chartCurrencyFormattingString) + ' ' + syminfo.currency + '; ' + str.tostring(target2ReturnOverRisk, '#.##') + ':1 R/R)' target2TooltipString = target2LabelString + '. Return if fully executed at entry and target.' target2Label = target2 > 0.0 ? label.new(x=labelXPosition, y=target2, text=target2LabelString, color=tradeSide == 'Long' ? longTargetsLabelsBgColor : shortTargetsLabelsBgColor, textcolor=tradeSide == 'Long' ? longTargetsLabelsTxtColor : shortTargetsLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=target2TooltipString) : na label.delete(target2Label[1]) target3BuySellLabelString = (tradeSide == 'Long' ? 'Sell ' : 'Buy ') + str.tostring(math.abs(targetSize3), baseCurrencyFormattingString) + ' ' + currencyToDisplay target3LabelString = 'Target 3: ' + target3BuySellLabelString + ' at ' + str.tostring(target3, priceFormattingString) + ' (Gross return: ' + str.tostring(target3ExpectedGain, chartCurrencyFormattingString) + ' ' + syminfo.currency + '; ' + str.tostring(target3ReturnOverRisk, '#.##') + ':1 R/R)' target3TooltipString = target3LabelString + '. Return if fully executed at entry and target.' target3Label = target3 > 0.0 ? label.new(x=labelXPosition, y=target3, text=target3LabelString, color=tradeSide == 'Long' ? longTargetsLabelsBgColor : shortTargetsLabelsBgColor, textcolor=tradeSide == 'Long' ? longTargetsLabelsTxtColor : shortTargetsLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=target3TooltipString) : na label.delete(target3Label[1]) // Secondary Labels // Minimum Ideal Target minimumIdealTargetBuySellLabelString = (tradeSide == 'Long' ? 'Sell ' : 'Buy ') + str.tostring(math.abs(positionSize), baseCurrencyFormattingString) + ' ' + currencyToDisplay minimumIdealTargetLabelString = 'Minimum Recommended Target: ' + minimumIdealTargetBuySellLabelString + ' at ' + str.tostring(minimumIdealTarget, priceFormattingString) + ' (Gross return: ' + str.tostring(minimumIdealTargetExpectedGainIfFullyExecuted, chartCurrencyFormattingString) + ' ' + syminfo.currency + '; ' + str.tostring(minimalIdealReturnRiskRatio, '#.##') + ':1 R/R)' minimumIdealTargetTooltipString = minimumIdealTargetLabelString + '. Return if fully executed at entry and target.' minimumIdealTargetLabel = showMinimumIdealTarget and minimumIdealTarget > 0.0 ? label.new(x=secondaryLabelXPosition, y=minimumIdealTarget, text=minimumIdealTargetLabelString, color=tradeSide == 'Long' ? minimumLongTargetsLabelsBgColor : minimumShortTargetsLabelsBgColor, textcolor=tradeSide == 'Long' ? minimumLongTargetsLabelsTxtColor : minimumShortTargetsLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=minimumIdealTargetTooltipString) : na label.delete(minimumIdealTargetLabel[1]) // Average Entry avgEntryBuySellLabelString = (tradeSide == 'Long' ? 'Long ' : 'Short ') + str.tostring(math.abs(positionSize), baseCurrencyFormattingString) + ' ' + currencyToDisplay avgEntryLabelString = 'Average Entry: ' + avgEntryBuySellLabelString + ' at ' + str.tostring(avgEntry, priceFormattingString) avgEntryTooltipString = avgEntryLabelString avgEntryLabel = avgEntry > 0.0 and displayAverageEntry and array.size(entries) > 1 ? label.new(x=secondaryLabelXPosition, y=avgEntry, text=avgEntryLabelString, color=tradeSide == 'Long' ? longEntriesLabelsBgColor : shortEntriesLabelsBgColor, textcolor=tradeSide == 'Long' ? longEntriesLabelsTxtColor : shortEntriesLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=avgEntryTooltipString) : na label.delete(avgEntryLabel[1]) // Average Target avgTargetBuySellLabelString = (tradeSide == 'Long' ? 'Sell ' : 'Buy ') + str.tostring(math.abs(positionSize), baseCurrencyFormattingString) + ' ' + currencyToDisplay avgTargetLabelString = 'Average Target: ' + avgTargetBuySellLabelString + ' at ' + str.tostring(avgTarget, priceFormattingString) + ' (Gross return: ' + str.tostring(avgTargetExpectedGain, chartCurrencyFormattingString) + ' ' + syminfo.currency + '; ' + str.tostring(avgTargetReturnOverRisk, '#.##') + ':1 R/R)' avgTargetTooltipString = avgTargetLabelString + '. Return if fully executed at entry and target.' avgTargetLabel = avgTarget > 0.0 and displayAverageTarget and array.size(targets) > 1 ? label.new(x=secondaryLabelXPosition, y=avgTarget, text=avgTargetLabelString, color=tradeSide == 'Long' ? longTargetsLabelsBgColor : shortTargetsLabelsBgColor, textcolor=tradeSide == 'Long' ? longTargetsLabelsTxtColor : shortTargetsLabelsTxtColor, style=labelStyle, xloc=xloc.bar_time, size=labelSize, tooltip=avgTargetTooltipString) : na label.delete(avgTargetLabel[1])
Fibonacci Timing Pattern
https://www.tradingview.com/script/QS2r0eNp-Fibonacci-Timing-Pattern/
Sofien-Kaabar
https://www.tradingview.com/u/Sofien-Kaabar/
522
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Sofien-Kaabar //@version = 5 indicator("Fibonacci Timing Pattern", overlay = true) // FB Buy Setup FB_Buy = close < close[3] and close < close[5] and close[1] < close[4] and close[1] < close[6] and close[2] < close[5] and close[2] < close[7] and close[3] < close[6] and close[3] < close[8] and close[4] < close[7] and close[4] < close[9] and close[5] < close[8] and close[5] < close[10] and close[6] < close[9] and close[6] < close[11] and close[7] < close[10] and close[7] < close[12] and close[8] > close[11] if FB_Buy == true and FB_Buy[1] == true FB_Buy == false // FB Sell Setup FB_Sell = close > close[3] and close > close[5] and close[1] > close[4] and close[1] > close[6] and close[2] > close[5] and close[2] > close[7] and close[3] > close[6] and close[3] > close[8] and close[4] > close[7] and close[4] > close[9] and close[5] > close[8] and close[5] > close[10] and close[6] > close[9] and close[6] > close[11] and close[7] > close[10] and close[7] > close[12] and close[8] < close[11] if FB_Sell == true and FB_Sell[1] == true FB_Sell == false plotshape(FB_Buy, style = shape.triangleup, color = color.green, location = location.belowbar, size = size.small) plotshape(FB_Sell, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.small)
High/Low/Open/Close Daily, Weekly, Monthly Line
https://www.tradingview.com/script/1ycX9iOJ-High-Low-Open-Close-Daily-Weekly-Monthly-Line/
goofoffgoose
https://www.tradingview.com/u/goofoffgoose/
865
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © goofoffgoose //@version=5 // For My pal Jittery // // This indicator draws a line on the Daily, Weekly, and Monthly bar at the High, Low, Open and Close of each bar as price // tends to react when revisiting these areas. // Each set of bars has an optional identifying label with its own color set that can be shown with or without the lines // price value, and has drop down menues for size and style of each set of labels. // Each set of lines has inputs for line/text color, line width and style. // I recommend going into Chart Settings/Status Line and turning off indicator arguments OR moving the script to the top // of the indicator list to avoid obstructed chart view with this indicators arguments. When script allows, I will update it to hide them. //New and Improved menu with vertical and horizontal offsets indicator("High/Low/Open/Close Daily, Weekly, Monthly Line", shorttitle= "D/W/M HLOC", overlay=true) t = ticker.new(syminfo.prefix, syminfo.ticker) ///////// Label input options and colors ////////// ////// Daily line and label options //// // Show Lines and colors show_dhloc = input.bool(defval=true, title="Show Daily Lines?", group="Daily High, Low, Open and Close Lines", inline="Daily Line") show_dh = input.bool(defval=true, title="-", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") dhcolor = input(color.rgb(133, 245, 86, 30), title="High", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") show_dl = input.bool(defval=true, title="-", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") dlcolor = input(color.rgb(246, 135, 135, 30), title="Low", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") show_do = input.bool(defval=true, title="-", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") docolor = input(color.rgb(120, 167, 241, 30), title="Open", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") show_dc = input.bool(defval=true, title="-", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") dccolor = input(color.rgb(246, 221, 96, 30), title="Close", group="Daily High, Low, Open and Close Lines", inline="Daily Select Line") // Line style and size dLineWidth = input.int(1, title="Line Width -  ", minval=1, group="Daily High, Low, Open and Close Lines", inline="Daily Line Style") dLineStyleOption = input.string(defval="solid (─)",title="  Line Style - ", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group="Daily High, Low, Open and Close Lines", inline="Daily Line Style") dLineStyle = (dLineStyleOption == "dotted (┈)") ? line.style_dotted : (dLineStyleOption == "dashed (╌)") ? line.style_dashed : (dLineStyleOption == "arrow left (←)") ? line.style_arrow_left : (dLineStyleOption == "arrow right (→)") ? line.style_arrow_right : (dLineStyleOption == "arrows both (↔)") ? line.style_arrow_both : line.style_solid // Daily label options // Show labels and colors show_dhlocLabel = input(defval=true, title="Show Daily Labels?", group="Daily Label Options", inline="Daily") show_dVal = input.bool(defval=true, title="Show Daily Line Value?", group="Daily Label Options", inline="Daily") dHighLblClr = input(color.rgb(00,153,00,80), title= "High Color", inline="daily label colors") dLowLblClr = input(color.rgb(204,00,00,80), title= "Low Color", inline="daily label colors") dOpenLblClr = input(color.rgb(00,102,204,80), title= "Open Color", inline="daily label colors") dCloseLblClr = input(color.rgb(255,153,51,80), title= "Close Color", inline="daily label colors") // Size and style drop down dSizeOption = input.string(defval="Normal", title="Label Size -  ", options = ["Auto","Huge","Large","Normal","Small","Tiny"], inline="Daily options") dStyleOption = input.string(title="   Label Style -", options=["Triangle up (▲)", "Triangle down (▼)", "Label up (⬆)", "Label down (⬇)", "Plus (+)", "Text Outline", "None"], defval="Text Outline", inline="Daily options") dLabelStyle = (dStyleOption == "Triangle up (▲)") ? label.style_triangleup : (dStyleOption == "Triangle down (▼)") ? label.style_triangledown : (dStyleOption == "Label up (⬆)") ? label.style_label_up : (dStyleOption == "Label down (⬇)") ? label.style_label_down : (dStyleOption == "Plus (+)") ? label.style_cross: (dStyleOption == "Text Outline") ? label.style_text_outline: (dStyleOption == "None") ? label.style_none : label.style_label_down dLabelSize = (dSizeOption == "Huge") ? size.huge : (dSizeOption == "Large") ? size.large : (dSizeOption == "Small") ? size.small : (dSizeOption == "Tiny") ? size.tiny : (dSizeOption == "Auto") ? size.auto : size.normal dLblHOffset = input.int(20, title="Horizontal Offset  ", inline="Daily offsets") dLblVOffset = input(3.05, title= " Vertical Offset ", inline="Daily offsets") ////// Weekly line and label options //// // Show Lines and colors show_whloc = input.bool(defval=true, title="Show Weekly Lines?", group="Weekly High, Low, Open and Close Lines", inline="Weekly Line") show_wh = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") whcolor = input(color.rgb(133, 245, 86, 30), title="High", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") show_wl = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") wlcolor = input(color.rgb(246, 135, 135, 30), title="Low", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") show_wo = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") wocolor = input(color.rgb(120, 167, 241, 30), title="Open", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") show_wc = input.bool(defval=true, title="-", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") wccolor = input(color.rgb(246, 221, 96, 30), title="Close", group="Weekly High, Low, Open and Close Lines", inline="Weekly Select Line") // Line style and size wLineWidth = input.int(1, title="Line Width -  ", minval=1, group="Weekly High, Low, Open and Close Lines", inline="Weekly Line Style") wLineStyleOption = input.string(defval="solid (─)",title="  Line Style - ", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group="Weekly High, Low, Open and Close Lines", inline="Weekly Line Style") wLineStyle = (wLineStyleOption == "dotted (┈)") ? line.style_dotted : (wLineStyleOption == "dashed (╌)") ? line.style_dashed : (wLineStyleOption == "arrow left (←)") ? line.style_arrow_left : (wLineStyleOption == "arrow right (→)") ? line.style_arrow_right : (wLineStyleOption == "arrows both (↔)") ? line.style_arrow_both : line.style_solid // Weekly label options // Show labels and colors show_whlocLabel = input(defval=true, title="Show Weekly Labels?", group="Weekly Label Options", inline="Weekly") show_wVal = input.bool(defval=true, title="Show Weekly Line Value?", group="Weekly Label Options", inline="Weekly") wHighLblClr = input(color.rgb(00,153,00,80), title= "High Color", inline="weekly label colors") wLowLblClr = input(color.rgb(204,00,00,80), title= "Low Color", inline="weekly label colors") wOpenLblClr = input(color.rgb(00,102,204,80), title= "Open Color", inline="weekly label colors") wCloseLblClr = input(color.rgb(255,153,51,80), title= "Close Color", inline="weekly label colors") // Size and style drop down wSizeOption = input.string(defval="Normal", title="Label Size -  ", options = ["Auto","Huge","Large","Normal","Small","Tiny"], inline="Weekly options") wStyleOption = input.string(title="   Label Style -", options=["Triangle up (▲)", "Triangle down (▼)", "Label up (⬆)", "Label down (⬇)", "Plus (+)", "Text Outline", "None"], defval="Text Outline", inline= "Weekly options") wLabelStyle = (wStyleOption == "Triangle up (▲)") ? label.style_triangleup : (wStyleOption == "Triangle down (▼)") ? label.style_triangledown : (wStyleOption == "Label up (⬆)") ? label.style_label_up : (wStyleOption == "Label down (⬇)") ? label.style_label_down : (wStyleOption == "Plus (+)") ? label.style_cross: (wStyleOption == "Text Outline") ? label.style_text_outline: (wStyleOption == "None") ? label.style_none : label.style_label_down wLabelSize = (wSizeOption == "Huge") ? size.huge : (wSizeOption == "Large") ? size.large : (wSizeOption == "Small") ? size.small : (wSizeOption == "Tiny") ? size.tiny : (wSizeOption == "Auto") ? size.auto : size.normal wLblHOffset = input.int(40, title="Horizontal Offset  ", inline="Weekly offsets") wLblVOffset = input(3.05, title= " Vertical Offset ", inline="Weekly offsets") ////// Monthly line and label options //// // Show Lines and colors show_mhloc = input.bool(defval=true, title="Show Monthly Lines?", group="Monthly High, Low, Open and Close Lines", inline="Monthly Line") show_mh = input.bool(defval=true, title="-", group="Monthly High, Low, Open and Close Lines", inline="Select Line") mhcolor = input(color.rgb(133, 245, 86, 30), title="High", group="Monthly High, Low, Open and Close Lines", inline="Select Line") show_ml = input.bool(defval=true, title="-",group="Monthly High, Low, Open and Close Lines", inline="Select Line") mlcolor = input(color.rgb(246, 135, 135, 30), title="Low", group="Monthly High, Low, Open and Close Lines", inline="Select Line") show_mo = input.bool(defval=true, title="-", group="Monthly High, Low, Open and Close Lines", inline="Select Line") mocolor = input(color.rgb(120, 167, 241, 30), title="Open", group="Monthly High, Low, Open and Close Lines", inline="Select Line") show_mc = input.bool(defval=true, title="-", group="Monthly High, Low, Open and Close Lines", inline="Select Line") mccolor = input(color.rgb(246, 221, 96, 30), title="Close", group="Monthly High, Low, Open and Close Lines", inline="Select Line") // Line style and size mLineWidth = input.int(1, title="Line Width -  ", minval=1, group="Monthly High, Low, Open and Close Lines", inline="Monthly Line Style") mLineStyleOption = input.string(defval="solid (─)",title="  Line Style - ", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group="Monthly High, Low, Open and Close Lines", inline="Monthly Line Style") mLineStyle = (mLineStyleOption == "dotted (┈)") ? line.style_dotted : (mLineStyleOption == "dashed (╌)") ? line.style_dashed : (mLineStyleOption == "arrow left (←)") ? line.style_arrow_left : (mLineStyleOption == "arrow right (→)") ? line.style_arrow_right : (mLineStyleOption == "arrows both (↔)") ? line.style_arrow_both : line.style_solid // Monthly label options // Show labels and colors show_mhlocLabel = input(defval=true, title="Show Monthly Labels?", group="Monthly Label Options", inline="Monthly") show_mVal = input.bool(defval=true, title="Show Monthly Line Value?", group="Monthly Label Options", inline="Monthly") mHighLblClr = input(color.rgb(00,153,00,80), title= "High Color", inline="monthly label colors") mLowLblClr = input(color.rgb(204,00,00,80), title= "Low Color", inline="monthly label colors") mOpenLblClr = input(color.rgb(00,102,204,80), title= "Open Color", inline="monthly label colors") mCloseLblClr = input(color.rgb(255,153,51,80), title= "Close Color", inline="monthly label colors") // Size and style drop down mSizeOption = input.string(defval="Normal", title="Label Size -  ", options = ["Auto","Huge","Large","Normal","Small","Tiny"], inline="Monthly Options") mStyleOption = input.string(title="   Label Style -", options=["Triangle up (▲)", "Triangle down (▼)", "Label up (⬆)", "Label down (⬇)", "Plus (+)", "Text Outline", "None"], defval="Text Outline", inline="Monthly Options") mLabelStyle = (mStyleOption == "Triangle up (▲)") ? label.style_triangleup : (mStyleOption == "Triangle down (▼)") ? label.style_triangledown : (mStyleOption == "Label up (⬆)") ? label.style_label_up : (mStyleOption == "Label down (⬇)") ? label.style_label_down : (mStyleOption == "Plus (+)") ? label.style_cross: (mStyleOption == "Text Outline") ? label.style_text_outline: (mStyleOption == "None") ? label.style_none : label.style_label_down mLabelSize = (mSizeOption == "Huge") ? size.huge : (mSizeOption == "Large") ? size.large : (mSizeOption == "Small") ? size.small : (mSizeOption == "Tiny") ? size.tiny : (mSizeOption == "Auto") ? size.auto : size.normal mLblHOffset = input.int(50, title="Horizontal Offset  ", inline="Monthly offsets") mLblVOffset = input(3.05, title= " Vertical Offset ", inline="Monthly offsets") ////////HLOC Lines and Label Plots/////// // Daily HLOC // Call daily data dhigh = request.security(t, 'D', high[1]) dlow = request.security(t, 'D', low[1]) dopen = request.security(t, 'D', open[1]) dclose = request.security(t, 'D', close[1]) // Line Conditions if (show_dhloc) if (show_dh) dh_line = line.new(x1=bar_index-1, y1=dhigh, color=dhcolor, x2=bar_index, y2=dhigh, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) line.delete(dh_line[1]) if (show_dl) dl_line = line.new(x1=bar_index-1, y1=dlow, color=dlcolor, x2=bar_index, y2=dlow, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) line.delete(dl_line[1]) if (show_do) do_line = line.new(x1=bar_index-1, y1=dopen, color=docolor, x2=bar_index, y2=dopen, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) line.delete(do_line[1]) if (show_dc) dc_line = line.new(x1=bar_index-1, y1=dclose, color=dccolor, x2=bar_index, y2=dclose, xloc=xloc.bar_index, style=dLineStyle, width=dLineWidth , extend=extend.both) line.delete(dc_line[1]) // Daily Labels // // Label Value String dHigh = str.tostring(dhigh, format.mintick) dhValNa = " " string dhVal = if show_dVal dHigh else dhValNa dLow = str.tostring(dlow, format.mintick) dlValNa = " " string dlVal = if show_dVal dLow else dlValNa dOpen = str.tostring(dopen, format.mintick) doValNa = " " string doVal = if show_dVal dOpen else doValNa dClose = str.tostring(dclose, format.mintick) dcValNa = " " string dcVal = if show_dVal dClose else dcValNa // Label Conditions if (show_dhlocLabel) and (show_dhloc) if (show_dh) dHighLabel = label.new(x=bar_index-1, y=dhigh, xloc=xloc.bar_index[0], color=(dHighLblClr), textcolor=dhcolor, style=dLabelStyle) label.set_text(id=dHighLabel, text=" Daily High "+ str.tostring(dhVal)) label.set_size(dHighLabel,dLabelSize) label.set_y(dHighLabel, dhigh + dLblVOffset) label.set_x(dHighLabel, label.get_x(dHighLabel) + dLblHOffset) label.delete(dHighLabel[1]) if (show_dl) dlowLabel = label.new(x=bar_index-1, y=dlow, xloc=xloc.bar_index[0], color=(dLowLblClr), textcolor=dlcolor, style=dLabelStyle) label.set_text(id=dlowLabel, text=" Daily Low "+ str.tostring(dlVal)) label.set_size(dlowLabel,dLabelSize) label.set_y(dlowLabel, dlow - dLblVOffset) label.set_x(dlowLabel, label.get_x(dlowLabel) + dLblHOffset) label.delete(dlowLabel[1]) if (show_do) dopenLabel = label.new(x=bar_index-1, y=dopen, xloc=xloc.bar_index[0], color=(dOpenLblClr), textcolor=docolor, style=dLabelStyle) label.set_text(id=dopenLabel, text=" Daily Open "+ str.tostring(doVal)) label.set_size(dopenLabel,dLabelSize) label.set_y(dopenLabel, dopen + dLblVOffset) label.set_x(dopenLabel, label.get_x(dopenLabel) + dLblHOffset) label.delete(dopenLabel[1]) if (show_dc) dcloseLabel = label.new(x=bar_index-1, y=dclose, xloc=xloc.bar_index[0], color=(dCloseLblClr), textcolor=dccolor, style=dLabelStyle) label.set_text(id=dcloseLabel, text=" Daily Close "+ str.tostring(dcVal)) label.set_size(dcloseLabel,dLabelSize) label.set_y(dcloseLabel, dclose - dLblVOffset) label.set_x(dcloseLabel, label.get_x(dcloseLabel) + dLblHOffset) label.delete(dcloseLabel[1]) // Weekly HLOC // Call weekly data whigh = request.security(t, 'W', high[1]) wlow = request.security(t, 'W', low[1]) wopen = request.security(t, 'W', open[1]) wclose = request.security(t, 'W', close[1]) // Line Condition if (show_whloc) if (show_wh) wh_line = line.new(x1=bar_index-1, y1=whigh, color=whcolor, x2=bar_index, y2=whigh, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth , extend=extend.both) line.delete(wh_line[1]) if (show_wl) wl_line = line.new(x1=bar_index-1, y1=wlow, color=wlcolor, x2=bar_index, y2=wlow, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth , extend=extend.both) line.delete(wl_line[1]) if (show_wo) wo_line = line.new(x1=bar_index-1, y1=wopen, color=wocolor, x2=bar_index, y2=wopen, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth , extend=extend.both) line.delete(wo_line[1]) if (show_wc) wc_line = line.new(x1=bar_index-1, y1=wclose, color=wccolor, x2=bar_index, y2=wclose, xloc=xloc.bar_index, style=wLineStyle, width=wLineWidth , extend=extend.both) line.delete(wc_line[1]) // Weekly Labels// // Label Value String wHigh = str.tostring(whigh, format.mintick) whValNa = " " string whVal = if show_wVal wHigh else whValNa wLow = str.tostring(wlow, format.mintick) wlValNa = " " string wlVal = if show_wVal wLow else wlValNa wOpen = str.tostring(wopen, format.mintick) woValNa = " " string woVal = if show_wVal wOpen else woValNa wClose = str.tostring(wclose, format.mintick) wcValNa = " " string wcVal = if show_wVal wClose else wcValNa // Label Conditions if (show_whlocLabel) and (show_whloc) if (show_wh) wHighLabel = label.new(x=bar_index-1, y=whigh, xloc=xloc.bar_index[0], color=(wHighLblClr), textcolor=whcolor, style=wLabelStyle) label.set_text(id=wHighLabel, text=" Weekly High "+ str.tostring(whVal)) label.set_size(wHighLabel,wLabelSize) label.set_y(wHighLabel, whigh + wLblVOffset) label.set_x(wHighLabel, label.get_x(wHighLabel) + wLblHOffset) label.delete(wHighLabel[1]) if (show_wl) wlowLabel = label.new(x=bar_index-1, y=wlow, xloc=xloc.bar_index[0], color=(wLowLblClr), textcolor=wlcolor, style=wLabelStyle) label.set_text(id=wlowLabel, text=" Weekly Low "+ str.tostring(wlVal)) label.set_size(wlowLabel,wLabelSize) label.set_y(wlowLabel, wlow - wLblVOffset) label.set_x(wlowLabel, label.get_x(wlowLabel) + wLblHOffset) label.delete(wlowLabel[1]) if (show_wo) wopenLabel = label.new(x=bar_index-1, y=wopen, xloc=xloc.bar_index[0], color=(wOpenLblClr), textcolor=wocolor, style=wLabelStyle) label.set_text(id=wopenLabel, text=" Weekly Open "+ str.tostring(woVal)) label.set_size(wopenLabel,wLabelSize) label.set_y(wopenLabel, wopen + wLblVOffset) label.set_x(wopenLabel, label.get_x(wopenLabel) + wLblHOffset) label.delete(wopenLabel[1]) if (show_wc) wcloseLabel = label.new(x=bar_index-1, y=wclose, xloc=xloc.bar_index[0], color=(wCloseLblClr), textcolor=wccolor, style=wLabelStyle) label.set_text(id=wcloseLabel, text=" Weekly Close "+ str.tostring(wcVal)) label.set_size(wcloseLabel,wLabelSize) label.set_y(wcloseLabel, wclose - wLblVOffset) label.set_x(wcloseLabel, label.get_x(wcloseLabel) + wLblHOffset) label.delete(wcloseLabel[1]) // Monthly HLOC // // Call monthly data mhigh = request.security(t, 'M', high[1]) mlow = request.security(t, 'M', low[1]) mopen = request.security(t, 'M', open[1]) mclose = request.security(t, 'M', close[1]) // Line Condition if (show_mhloc) if (show_mh) mh_line = line.new(x1=bar_index-1, y1=mhigh, color=mhcolor, x2=bar_index, y2=mhigh, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) line.delete(mh_line[1]) if (show_ml) ml_line = line.new(x1=bar_index-1, y1=mlow, color=mlcolor, x2=bar_index, y2=mlow, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) line.delete(ml_line[1]) if (show_mo) mo_line = line.new(x1=bar_index-1, y1=mopen, color=mocolor, x2=bar_index, y2=mopen, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) line.delete(mo_line[1]) if (show_mc) mc_line = line.new(x1=bar_index-1, y1=mclose, color=mccolor, x2=bar_index, y2=mclose, xloc=xloc.bar_index, style=mLineStyle, width=mLineWidth , extend=extend.both) line.delete(mc_line[1]) // Monthly Labels // // Label Value String mHigh = str.tostring(mhigh, format.mintick) mhValNa = " " string mhVal = if show_mVal mHigh else mhValNa mLow = str.tostring(mlow, format.mintick) mlValNa = " " string mlVal = if show_mVal mLow else mlValNa mOpen = str.tostring(mopen, format.mintick) moValNa = " " string moVal = if show_mVal mOpen else moValNa mClose = str.tostring(mclose, format.mintick) mcValNa = " " string mcVal = if show_mVal mClose else mcValNa // Label Condition if (show_mhlocLabel) and (show_mhloc) if (show_mh) mHighLabel = label.new(x=bar_index-1, y=mhigh, xloc=xloc.bar_index[0], color=(mHighLblClr), textcolor=mhcolor, style=mLabelStyle) label.set_text(id=mHighLabel, text=" Monthly High "+ str.tostring(mhVal)) label.set_size(mHighLabel,mLabelSize) label.set_y(mHighLabel, mhigh + mLblVOffset) label.set_x(mHighLabel, label.get_x(mHighLabel) + mLblHOffset) label.delete(mHighLabel[1]) if (show_ml) mlowLabel = label.new(x=bar_index-1, y=mlow, xloc=xloc.bar_index[0], color=(mLowLblClr), textcolor=mlcolor, style=mLabelStyle) label.set_text(id=mlowLabel, text=" Monthly Low "+ str.tostring(mlVal)) label.set_size(mlowLabel,mLabelSize) label.set_y(mlowLabel, mlow - mLblVOffset) label.set_x(mlowLabel, label.get_x(mlowLabel) + mLblHOffset) label.delete(mlowLabel[1]) if (show_mo) mopenLabel = label.new(x=bar_index-1, y=mopen, xloc=xloc.bar_index[0], color=(mOpenLblClr), textcolor=mocolor, style=mLabelStyle) label.set_text(id=mopenLabel, text=" Monthly Open "+ str.tostring(moVal)) label.set_size(mopenLabel,mLabelSize) label.set_y(mopenLabel, mopen + mLblVOffset) label.set_x(mopenLabel, label.get_x(mopenLabel) + mLblHOffset) label.delete(mopenLabel[1]) if (show_mc) mcloseLabel = label.new(x=bar_index-1, y=mclose, xloc=xloc.bar_index[0], color=(mCloseLblClr), textcolor=mccolor, style=mLabelStyle) label.set_text(id=mcloseLabel, text=" Monthly Close "+ str.tostring(mcVal)) label.set_size(mcloseLabel,mLabelSize) label.set_y(mcloseLabel, mclose - mLblVOffset) label.set_x(mcloseLabel, label.get_x(mcloseLabel) + mLblHOffset) label.delete(mcloseLabel[1])
RSI MA Cross
https://www.tradingview.com/script/r4vJai9D-RSI-MA-Cross/
PtGambler
https://www.tradingview.com/u/PtGambler/
176
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © PtGambler // Building onto standard RSI indicator with RSI MA crossover signals and added alert conditions //@version=5 indicator(title="RSI MA Cross", shorttitle="RSI-X[Pt]", format=format.price, precision=2, timeframe="", timeframe_gaps=true) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) len = input.int(14, minval=1, title="RSI Length", group="RSI Settings") src = input.source(close, "Source", group="RSI Settings") show_smooth = input.bool(true, title="Use smoothed RSI instead", group="RSI Settings") len2 = input.int(10, title="Smooth period", group="RSI Settings") col1 = input.color(color.purple, "Color", group = "RSI Settings") upper_band = input.int(70, "Upper Band (Overbought level)", minval = 0, maxval = 100, group="RSI Settings") lower_band = input.int(30, "Lower Band (Oversold level)", minval = 0, maxval = 100, group="RSI Settings") maType = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") malen = input.int(100, title="MA Length", group="MA Settings") show_X = input.bool(true, title="Show RSI cross overs", group="MA Settings") col2 = input.color(color.yellow, "Color", group = "MA Settings") show_trend = input.bool(true, "Show Trend color", inline = "trend", group = "Extra Settings") bull_col = input.color(color.green, "↑", inline = "trend", group = "Extra Settings") bear_col = input.color(color.red, "↓", inline = "trend", group = "Extra Settings") transp = input.int(90, "Transp.",minval = 0, maxval = 100, inline = "trend", group = "Extra Settings") OSOB_cross_only = input.bool(false, "Shows crossover signals only in OB / OS region", group = "Extra Settings") up = ta.rma(math.max(ta.change(src), 0), len) down = ta.rma(-math.min(ta.change(src), 0), len) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) rsiSM = ta.sma(rsi,len2) rsiMA = ma(rsi, malen, maType) bullX = show_smooth ? ta.crossover(rsiSM, rsiMA) : ta.crossover(rsi, rsiMA) bearX = show_smooth ? ta.crossunder(rsiSM, rsiMA) : ta.crossunder(rsi, rsiMA) bullX := OSOB_cross_only ? bullX and rsiMA < lower_band : bullX bearX := OSOB_cross_only ? bearX and rsiMA > upper_band : bearX plotshape(show_X and bullX, style=shape.triangleup, location=location.bottom, color=color.green, title="Cross Up", size = size.tiny) plotshape(show_X and bearX, style=shape.triangledown, location=location.top, color=color.red, title="Cross Down", size = size.tiny) p1 = plot(show_smooth ? rsiSM : rsi, "RSI", color=color.purple, linewidth=3) p2 = plot(rsiMA, "RSI-based MA", color=color.yellow, linewidth=2) trend_color = show_smooth ? (rsiSM > rsiMA ? bull_col : bear_col) : (rsi > rsiMA ? bull_col : bear_col) fill(p1,p2, color = show_trend ? color.new(trend_color,transp) : na) rsiUpperBand = hline(upper_band, "RSI Upper Band", color=#787B86) hline(50, "RSI Middle Band", color=color.new(color.white, 50)) rsiLowerBand = hline(lower_band, "RSI Lower Band", color=#787B86) fill(rsiUpperBand, rsiLowerBand, color=color.new(color.gray,90), title="RSI Background Fill") alertcondition(bullX, title='Bullish Crossover', message='RSI Cross, Bullish Signal') alertcondition(bearX, title='Bearish Crossover', message='RSI Cross, Bearish Signal')
TIG's Market Internals Clouds Indicator v2.0
https://www.tradingview.com/script/pfXNTcMH-TIG-s-Market-Internals-Clouds-Indicator-v2-0/
TIG_That-Indicator-Guy
https://www.tradingview.com/u/TIG_That-Indicator-Guy/
216
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © That Indicator Guy (TIG) // @version = 5 // Blank title so we can overwrite with whatever we're using indicator(title=" ", overlay=false) ///////////////////////////////////////////////// // SET UP ///////////////////////////////////////////////// // User inputs var oGroup0 = "WELCOME TO TIG'S MARKET INTERNALS CLOUD INDICATOR!" oInternal = input.string("VIX", "Use Built-In Market Internal?     ", options = ["ADD", "TICK", "TRIN", "VIX", "VOLD"], group = oGroup0) oCustomInternal = input.string("", "(or Custom Market Internal?)", group = oGroup0, tooltip = "leave blank to use built-in internal") var oGroup1 = "FAST CLOUD            EMA                   LINE WIDTH" oFastCloudShort_Length = input.int(3, "Super Fast Line ", minval = 1, inline = "11", group = oGroup1) oFastCloudShortThickness = input.int(1, " ", options = [1, 2, 3, 4, 5], inline = "11", group = oGroup1) oFastCloudLong_Length = input.int(30, "Fast Line       ", minval = 1, inline = "12", group = oGroup1) oFastCloudLongThickness = input.int(3, " ", options = [1, 2, 3, 4, 5], inline = "12", group = oGroup1) var oGroup2 = "FAST CLOUD         SHOW         UPTRENDING   DOWNTRENDING" oShowFastCloudLines = input.string("Yes please!", "Lines           ", options = ["Yes please!", "No thanks!", "Dots for the win!"], inline = "21", group = oGroup2) oFastLineColorGreen = input.color(color.rgb(64,255,64,0), " ", inline = "21", group = oGroup2) oFastLineColorRed = input.color(color.rgb(255, 64, 64, 0), " ", inline = "21", group = oGroup2) oShowFastCloud = input.string("Yes please!", "Cloud           ", options = ["Yes please!", "No thanks!"], inline = "22", group = oGroup2) oFastCloudColorGreen = input.color(color.rgb(0, 255, 0, 70), " ", inline = "22", group = oGroup2) oFastCloudColorRed = input.color(color.rgb(255, 0, 0, 60), " ", inline = "22", group = oGroup2) var oGroup3 = "SLOW CLOUD            EMA                   LINE WIDTH" oSlowCloudShort_Length = input.int(150, "Slow Line       ", minval = 1, inline = "31", group = oGroup3) oSlowCloudShortThickness = input.int(1, " ", options = [1, 2, 3, 4, 5], inline = "31", group = oGroup3) oSlowCloudLong_Length = input.int(600, "Super Slow Line ", minval = 1, inline = "32", group = oGroup3) oSlowCloudLongThickness = input.int(1, " ", options = [1, 2, 3, 4, 5], inline = "32", group = oGroup3) var oGroup4 = "SLOW CLOUD         SHOW         UPTRENDING   DOWNTRENDING" oShowSlowCloudLines = input.string("No thanks!", "Lines           ", options = ["Yes please!", "No thanks!", "Dots for the win!"], inline = "41", group = oGroup4) oSlowLineColorGreen = input.color(color.rgb(64, 255, 64, 50), " ", inline = "41", group = oGroup4) oSlowLineColorRed = input.color(color.rgb(255, 64, 64, 50), " ", inline = "41", group = oGroup4) oShowSlowCloud = input.string("Yes please!", "Cloud           ", options = ["Yes please!", "No thanks!"], inline = "42", group = oGroup4) oSlowCloudColorGreen = input.color(color.rgb(0, 255, 0, 80), " ", inline = "42", group = oGroup4) oSlowCloudColorRed = input.color(color.rgb(255, 0, 0, 70), " ", inline = "42", group = oGroup4) var oGroup5 = "OTHER RANDOM STUFF" oTextColor = input.color(color.rgb(128, 128, 128, 0), "                                Text Color", inline = "51", group = oGroup5) oShowLevelLines = input.bool(true, "Show Level Lines?", inline = "52", group = oGroup5) oLevelLinesColor = input.color(color.rgb(128, 128, 128, 0), "If so, Level Lines Color", inline = "52", group = oGroup5) oTickLine1 = input.int(-350, "TICK Lines    ", inline = "53", group = oGroup5) oTickLine2 = input.int( 0, "", inline = "53", group = oGroup5) oTickLine3 = input.int( 350, "", inline = "53", group = oGroup5) oTrinLine1 = input.float(0.6, "TRIN Lines    ", inline = "54", group = oGroup5) oTrinLine2 = input.float(1.8, "", inline = "54", group = oGroup5) oCustomLine1 = input.float(0, "Custom Lines  ", inline = "55", group = oGroup5) oCustomLine2 = input.float(0, "", inline = "55", group = oGroup5) oCustomLine3 = input.float(0, "", inline = "55", group = oGroup5) var oGroup6 = "THIS IS AN EXPERIMENTAL FEATURE - USE AT OWN RISK :)" oShowCorrT = input.string("No thanks!", "Show Correlation between Internal and Price Action?", options = ["Let's give it a whirl", "No thanks!"], inline = "61", group = oGroup6) oShowCorr = oShowCorrT == "No thanks!" ? false : true oLookback = input.int(30, "Correlaton lookback length (bars)                 ", minval = 2, inline = "62", group = oGroup6) // Other Intial Variables oColorNone = color.rgb(0, 0, 0, 255) var oBarCount = 0 var oFastSpx = 0.0 var oSpxArray = array.new_float(oLookback) var oFastArray = array.new_float(oLookback) ///////////////////////////////////////////////// // DO SOME CALCULATIONS ///////////////////////////////////////////////// // Intialize for a new session oCashSession = time(timeframe.period, "0930-1600", "America/New_York") oNewSession = (oCashSession and not(oCashSession[1])) or (oCashSession and (dayofweek != dayofweek[1])) oShow = (oCashSession and not(oNewSession)) if oNewSession oBarCount := 0 array.clear(oSpxArray) array.clear(oFastArray) oBarCount += 1 ///////////////////////////////////////////////// // MARKET DATA ///////////////////////////////////////////////// // Main Internal oReading = request.security(oInternal, timeframe.period, close) oCustomReading = request.security(oCustomInternal, timeframe.period, close) oReading := oCustomInternal != "" ? oCustomReading : oReading oAdvancingIssues = request.security("ADVN.NY", timeframe.period, close) oDecliningIssues = request.security("DECL.NY", timeframe.period, close) oUpVolume = request.security("UPVOL.NY", timeframe.period, close) oDownVolume = request.security("DNVOL.NY", timeframe.period, close) if oInternal == "TRIN" oReading := (oAdvancingIssues / oDecliningIssues) / (oUpVolume / oDownVolume) if oInternal == "VOLD" oReading := oReading / 1000000 ///////////////////////////////////////////////// // EMA LINES AND CLOUDS ///////////////////////////////////////////////// // EMA calculations var oFastCloudShort = 0.0 var oFastCloudLong = 0.0 var oSlowCloudShort = 0.0 var oSlowCloudLong = 0.0 oFastShortMulti = (2 / (math.min(oBarCount, oFastCloudShort_Length) + 1)) oFastLongMulti = (2 / (math.min(oBarCount, oFastCloudLong_Length) + 1)) oSlowShortMulti = (1.6 / (math.min(oBarCount, oSlowCloudShort_Length) + 1)) oSlowLongMulti = (1.2 / (math.min(oBarCount, oSlowCloudLong_Length) + 1)) oFastCloudShort := oBarCount == 1 ? oReading : oReading * oFastShortMulti + oFastCloudShort[1] * (1 - oFastShortMulti) oFastCloudLong := oBarCount == 1 ? oReading : oReading * oFastLongMulti + oFastCloudLong[1] * (1 - oFastLongMulti) oSlowCloudShort := oBarCount == 1 ? oReading : oReading * oSlowShortMulti + oSlowCloudShort[1] * (1 - oSlowShortMulti) oSlowCloudLong := oBarCount == 1 ? oReading : oReading * oSlowLongMulti + oSlowCloudLong[1] * (1 - oSlowLongMulti) oFastCloudShort_Color = oShowFastCloudLines == "No thanks!" or oBarCount == 1 ? oColorNone : oFastCloudShort > oFastCloudShort[1] ? oFastLineColorGreen : oFastLineColorRed oFastCloudLong_Color = oShowFastCloudLines == "No thanks!" or oBarCount == 1 ? oColorNone : oFastCloudLong > oFastCloudLong[1] ? oFastLineColorGreen : oFastLineColorRed oSlowCloudShort_Color = oShowSlowCloudLines == "No thanks!" or oBarCount == 1 ? oColorNone : oSlowCloudShort > oSlowCloudShort[1] ? oSlowLineColorGreen : oSlowLineColorRed oSlowCloudLong_Color = oShowSlowCloudLines == "No thanks!" or oBarCount == 1 ? oColorNone : oSlowCloudLong > oSlowCloudLong[1] ? oSlowLineColorGreen : oSlowLineColorRed // Plot the lines and the clouds oFastCloudShort_Plot = plot(oFastCloudShort, linewidth = oFastCloudShortThickness, color = oFastCloudShort_Color, style = oShowFastCloudLines == "Dots for the win!" ? plot.style_circles : plot.style_line) oFastCloudLong_Plot = plot(oFastCloudLong, linewidth = oFastCloudLongThickness, color = oFastCloudLong_Color, style = oShowFastCloudLines == "Dots for the win!" ? plot.style_circles : plot.style_line) fill(oFastCloudShort_Plot, oFastCloudLong_Plot, color = oShowFastCloud == "No thanks!" or oBarCount == 1 ? oColorNone : oFastCloudShort < oFastCloudLong ? oFastCloudColorRed : oFastCloudColorGreen) oSlowCloudShort_Plot = plot(oSlowCloudShort, linewidth = oSlowCloudShortThickness, color = oSlowCloudShort_Color, style = oShowSlowCloudLines == "Dots for the win!" ? plot.style_circles : plot.style_line) oSlowCloudLong_Plot = plot(oSlowCloudLong, linewidth = oSlowCloudLongThickness, color = oSlowCloudLong_Color, style = oShowSlowCloudLines == "Dots for the win!" ? plot.style_circles : plot.style_line) fill(oSlowCloudShort_Plot, oSlowCloudLong_Plot, color = oShowSlowCloud == "No thanks!" or oBarCount == 1 ? oColorNone : oSlowCloudShort < oSlowCloudLong ? oSlowCloudColorRed : oSlowCloudColorGreen) ///////////////////////////////////////////////// // OTHER DISPLAY STUFF ///////////////////////////////////////////////// // Study Title oStudyTitle = oCustomInternal !="" ? oCustomInternal : oInternal var table oTable2 = table.new(position.top_left, 1, 1) table.cell(oTable2, 0, 0, " " + oStudyTitle +" Cloud", text_color = oTextColor, text_halign = text.align_left) // Format the current value oDisplayValue = "" if oInternal == "ADD" or oInternal == "TICK" or oInternal == "VOLD" oDisplayValue := str.format("{0, number, #}", oReading) if oInternal == "TRIN" or oInternal == "VIX" oDisplayValue := str.format("{0, number, #.##}", oReading) if oInternal == "VOLD" oDisplayValue := oDisplayValue +"m" // Display it in a box var table oTable1 = table.new(position.bottom_right, 2, 1) oAccuracy = oInternal == "TRIN" or oInternal == "VIX" ? 3 : 0 table.cell(oTable1, 0, 0, oDisplayValue, text_color = oTextColor) oCellColor = oFastCloudShort_Color == oFastLineColorGreen ? oFastCloudColorGreen : oFastCloudColorRed table.cell(oTable1, 1, 0, " ", bgcolor = oCellColor) // Plot some reference lines oLevel0 = 0.0 oLevel1 = 0.0 oLevel2 = 0.0 if oInternal == "VIX" and oCustomInternal == "" or not(oShowLevelLines) oLevel0 := oReading oLevel1 := oReading oLevel2 := oReading oLevelLinesColor := oColorNone if oInternal == "TICK" oLevel0 := oTickLine1 oLevel1 := oTickLine2 oLevel2 := oTickLine3 if oInternal == "TRIN" oLevel0 := oTrinLine1 oLevel1 := oTrinLine2 oLevel2 := oTrinLine2 if oCustomInternal != "" and oShowLevelLines oLevel0 := oCustomLine1 oLevel1 := oCustomLine2 oLevel2 := oCustomLine3 plot(oLevel0, color = oLevelLinesColor) plot(oLevel1, color = oLevelLinesColor) plot(oLevel2, color = oLevelLinesColor) ///////////////////////////////////////////////// // CORRELATION - THE GOOD STUFF ///////////////////////////////////////////////// oSpx = close oFastSpx := oBarCount == 1 ? oSpx : oSpx * oFastLongMulti + oSpx[1] * (1 - oFastLongMulti) if oBarCount > oLookback array.shift(oSpxArray) array.shift(oFastArray) array.push(oSpxArray, oFastSpx) array.push(oFastArray, oFastCloudLong) oCorrelation = array.covariance(oSpxArray, oFastArray) / (array.stdev(oSpxArray) * array.stdev(oFastArray)) oPearsons = oCorrelation * oCorrelation var table oTable3 = table.new(position.top_right, 1, 2) table.cell(oTable3, 0, 0, str.format("{0, number, #}", oLookback) + "-bar PC", text_color = oShowCorr ? oTextColor : oColorNone, text_halign = text.align_right) table.cell(oTable3, 0, 1, str.format("{0, number, #.##}", oPearsons), text_color = oShowCorr ? oTextColor : oColorNone, text_halign = text.align_right)
BTC Spot/Futures Volume Ratio
https://www.tradingview.com/script/uF3K4pHZ/
wzkkzw12345
https://www.tradingview.com/u/wzkkzw12345/
26
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/ // © wzkkzw12345 //@version=4 study(title="Spot/Futures") length = input(14 , title="EMA length") res = timeframe.period spot_volume = security("BINANCE:BTCUSDT", res, volume) + security("BINANCE:BTCBUSD", res, volume)+security("OKEX:BTCUSDT",res, volume)+security("OKEX:BTCUSDC",res, volume)+security("FTX:BTCUSDT",res, volume/hlc3)+security("FTX:BTCUSD",res, volume/hlc3) futures_volume = security("BINANCE:BTCUSDTPERP", res, volume)+ security("BINANCE:BTCBUSDPERP", res, volume) + security("BINANCE:BTCPERP", res, volume/hlc3)*100+security("OKEX:BTCPERP", res, volume/hlc3)*100+security("OKEX:BTCUSDTPERP", res, volume/hlc3)+security("FTX:BTCPERP",res, volume/hlc3) //spot_ema = ema(spot_volume, length) //futures_ema = ema(futures_volume, length) ratio_ema = ema(spot_volume/futures_volume* (spot_volume+futures_volume),length) //plot(spot_ema,color=color.new(color.green,30)) //plot(futures_ema,color=color.new(color.green,30)) //plot(spot_ema/futures_ema,color=color.new(color.green,30)) plot(ratio_ema /ema(spot_volume+futures_volume, length),color=color.new(color.green,30))
Trend Indicator (dow trending) - Fontiramisu
https://www.tradingview.com/script/lg53lsqe-Trend-Indicator-dow-trending-Fontiramisu/
Fontiramisu
https://www.tradingview.com/u/Fontiramisu/
68
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Author : @Fontiramisu // Pivot Calculation Pivot is from ©ZenAndTheArtOfTrading / PineScriptMastery.com // Trend interpretation is from @Fontiramisu // @version=5 indicator("Trend Indicator - Fontiramisu", overlay=true) import Fontiramisu/fontilab/1 as fontLib // ------------------------------------- Possibility to Use Other Timeframe ----------------------------------------------------------------- // oneHourClose = request.security(syminfo.tickerid, "60", close[1], barmerge.gaps_off, barmerge.lookahead_on) // oneHourHigh = request.security(syminfo.tickerid, "60", high[1], barmerge.gaps_off, barmerge.lookahead_on) // oneHourLow = request.security(syminfo.tickerid, "60", low[1], barmerge.gaps_off, barmerge.lookahead_on) // ------------------------------------- Input Vars ------------------------------------------------------------------------------------------ // Get user input var devTooltip = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot." var devTooltipUtSup = "For UT Sup - Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot." var depthTooltip = "The minimum number of bars that will be taken into account when analyzing pivots." var depthUtSupTooltip = "For UT Sup - The minimum number of bars that will be taken into account when analyzing pivots." thresholdMultiplier = input.float(title="Deviation", defval=2.5, minval=0, tooltip=devTooltip, group="CUR. UT") thresholdMultiplierUtSup = input.float(title="Deviation", defval=2.5, minval=0, tooltip=devTooltip, group="UT SUP") depth = input.int(title="Depth", defval=10, minval=1, tooltip=depthTooltip, group="CUR. UT") depthUtSup = input.int(title="Depth", defval=100, minval=1, tooltip=depthTooltip, group="UT SUP") deleteLastLine = input.bool(title="Delete Trend Lines", defval=true, group="CUR. UT") deleteLastLineUtSup = input.bool(title="Delete Trend Lines Ut Sup", defval=true, group="UT SUP") isDrawBounds = input.bool(title="Draw Trend Bounds", defval=true, group="CUR. UT") isDrawBoundsUtSup = input.bool(title="Draw Trend Bounds Ut Sup", defval=true, group="UT SUP") breakingLineColor = input.color(title="Breaking Line Color", defval=color.silver, group="CUR. UT") breakingLineColorUtSup = input.color(title="Breaking Line Color Ut Sup", defval=color.gray, group="UT SUP") // ------------------------------------- Current UT - Calculate Pivots - Trend From Pivots ----------------------------------------------------------------------------- // --- Find Dev Pivots --- // Prepare pivot variables var line lineLast = na var int iLast = 0 // Index last var int iPrev = 0 // Index previous var float pLast = 0 // Price last var float pLastHigh = 0 // Price last var float pLastLow = 0 // Price last var isHighLast = false // If false then the last pivot was a pivot low // Get pivot information from dev pivot finding function [dupLineLast, dupIsHighLast, dupIPrev, dupILast, dupPLast, dupPLastHigh, dupPLastLow] = fontLib.getDeviationPivots(thresholdMultiplier, depth, lineLast, isHighLast, iLast, pLast, deleteLastLine, close, high, low) // fontLib.getDeviationPivots(thresholdMultiplier, depth, isHighLast, iLast, pLast, close, high, low) if not na(dupIsHighLast) lineLast := dupLineLast isHighLast := dupIsHighLast iPrev := dupIPrev iLast := dupILast pLast := dupPLast pLastHigh := dupPLastHigh pLastLow := dupPLastLow // --- Find Trend Pivots --- // - Init Vars and Inputs - // Input var trendPrecision = input.float(0.01, title="trend precision", tooltip="% move out of bound needed to validate a trend", group="CUR. UT") // Create Array to store the pivots var trendBarIndexes = array.new_int(0) var trendPrices = array.new_float(0) var trendPricesIsHigh = array.new_bool(0) // Create inter Array to store hesitating moves var interBarIndexes = array.new_int(0) var interPrices = array.new_float(0) var interPricesIsHigh = array.new_bool(0) // // Variable to store trend state var bool isTrendUp = na // Is trend up or down var bool isTrendHesitate = na // Is trend hesitate [dupTrendBarIndexes, dupTrendPrices, dupTrendPricesIsHigh, dupInterBarIndexes, dupInterPrices, dupInterPricesIsHigh, dupIsTrendHesitate, dupIsTrendUp] = fontLib.getTrendPivots(trendBarIndexes, trendPrices, trendPricesIsHigh, interBarIndexes, interPrices, interPricesIsHigh, isTrendHesitate, isTrendUp, trendPrecision, pLast, iLast, isHighLast) if not na(dupTrendPrices) trendBarIndexes := dupTrendBarIndexes trendPrices := dupTrendPrices trendPricesIsHigh := dupTrendPricesIsHigh interBarIndexes := dupInterBarIndexes interPrices := dupInterPrices interPricesIsHigh := dupInterPricesIsHigh isTrendHesitate := dupIsTrendHesitate isTrendUp := dupIsTrendUp // ------------------------------------- UT Sup - Calculate Pivots - Trend From Pivots ----------------------------------------------------------------------------- // --- Find Dev Pivots --- var line lineLastUtSup = na var int iLastUtSup = 0 // Index last var int iPrevUtSup = 0 // Index previous var float pLastLowUtSup = 0 // Price last var float pLastHighUtSup = 0 // Price last var float pLastUtSup = 0 // Price last var isHighLastUtSup = false // If false then the last pivot was a pivot low // Get pivot information from dev pivot finding function [dupLineLastUtSup, dupIsHighLastUtSup, dupIPrevUtSup, dupILastUtSup, dupPLastUtSup, dupPLastLowUtSup, dupPLastHighUtSup] = // fontLib.getDeviationPivots(thresholdMultiplierUtSup, depthUtSup, lineLastUtSup, isHighLastUtSup, iLastUtSup, pLastUtSup, deleteLastLineUtSup, oneHourCloseUtSup, oneHourHighUtSup, oneHourLowUtSup) fontLib.getDeviationPivots(thresholdMultiplierUtSup, depthUtSup, lineLastUtSup, isHighLastUtSup, iLastUtSup, pLastUtSup, deleteLastLineUtSup, close, high, low) // fontLib.getDeviationPivots(thresholdMultiplierUtSup, depthUtSup, isHighLastUtSup, iLastUtSup, pLastUtSup, close, high, low) if not na(dupIsHighLastUtSup) lineLastUtSup := dupLineLastUtSup isHighLastUtSup := dupIsHighLastUtSup iPrevUtSup := dupIPrevUtSup iLastUtSup := dupILastUtSup pLastUtSup := dupPLastUtSup pLastLowUtSup := dupPLastLowUtSup pLastHighUtSup := dupPLastHighUtSup // --- Find Trend Pivots --- // Input var trendPrecisionUtSup = input.float(0.01, title="trend precision", tooltip="% move out of bound needed to validate a trend", group="UT SUP") // Create Array to store the pivots var trendBarIndexesUtSup = array.new_int(0) var trendPricesUtSup = array.new_float(0) var trendPricesIsHighUtSup = array.new_bool(0) // Create inter Array to store hesitating moves var interBarIndexesUtSup = array.new_int(0) var interPricesUtSup = array.new_float(0) var interPricesIsHighUtSup = array.new_bool(0) // Variable to store trend state var bool isTrendUpUtSup = na // Is trend up or down var bool isTrendHesitateUtSup = na // Is trend hesitate [dupTrendBarIndexesUtSup, dupTrendPricesUtSup, dupTrendPricesIsHighUtSup, dupInterBarIndexesUtSup, dupInterPricesUtSup, dupInterPricesIsHighUtSup, dupIsTrendHesitateUtSup, dupIsTrendUpUtSup] = fontLib.getTrendPivots(trendBarIndexesUtSup, trendPricesUtSup, trendPricesIsHighUtSup, interBarIndexesUtSup, interPricesUtSup, interPricesIsHighUtSup, isTrendHesitateUtSup, isTrendUpUtSup, trendPrecisionUtSup, pLastUtSup, iLastUtSup, isHighLastUtSup) if not na(dupTrendPricesUtSup) trendBarIndexesUtSup := dupTrendBarIndexesUtSup trendPricesUtSup := dupTrendPricesUtSup trendPricesIsHighUtSup := dupTrendPricesIsHighUtSup interBarIndexesUtSup := dupInterBarIndexesUtSup interPricesUtSup := dupInterPricesUtSup interPricesIsHighUtSup := dupInterPricesIsHighUtSup isTrendHesitateUtSup := dupIsTrendHesitateUtSup isTrendUpUtSup := dupIsTrendUpUtSup // ------------------------------------- Do Some Drawings------------------------------------------------------------------------------------------ // -- Draw boundlines UT SUP -- if isDrawBounds // Get starting and ending high/low price of the current pivot line startIndex = fontLib.getElIntArrayFromEnd(trendBarIndexes, 1) startPrice = fontLib.getElFloatArrayFromEnd(trendPrices, 1) endIndex = fontLib.getElIntArrayFromEnd(trendBarIndexes, 0) endPrice = fontLib.getElFloatArrayFromEnd(trendPrices, 0) breakingPivotIndex = fontLib.getElIntArrayFromEnd(trendBarIndexes, 2) breakingPivotPrice = fontLib.getElFloatArrayFromEnd(trendPrices, 2) // Draw boundlines fontLib.drawBoundLines(startIndex, startPrice, endIndex, endPrice, breakingPivotIndex , breakingPivotPrice, isTrendUp, breakingLineColor) // -- Draw boundlines UT SUP -- if isDrawBoundsUtSup // Get starting and ending high/low price of the current pivot line startIndexUtSup = fontLib.getElIntArrayFromEnd(trendBarIndexesUtSup, 1) startPriceUtSup = fontLib.getElFloatArrayFromEnd(trendPricesUtSup, 1) endIndexUtSup = fontLib.getElIntArrayFromEnd(trendBarIndexesUtSup, 0) endPriceUtSup = fontLib.getElFloatArrayFromEnd(trendPricesUtSup, 0) breakingPivotIndexUtSup = fontLib.getElIntArrayFromEnd(trendBarIndexesUtSup, 2) breakingPivotPriceUtSup = fontLib.getElFloatArrayFromEnd(trendPricesUtSup, 2) // Draw boundlines fontLib.drawBoundLines(startIndexUtSup, startPriceUtSup, endIndexUtSup, endPriceUtSup, breakingPivotIndexUtSup, breakingPivotPriceUtSup, isTrendUpUtSup, breakingLineColorUtSup) // -- bgcolor -- // Inputs bgcolorChange = input.bool(title=" Show Color Trend", defval=false, group="Drawings") offsetBG = -(depth / 2) bgcolor(bgcolorChange ? isTrendHesitate ? na : isTrendUp ? color.new(color.green,88) : color.new(color.red,88) : na, offset=offsetBG) // -- Display Trend and hesitate -- show_table = input(true, "Show table with stats", group = "Drawings") if show_table var table ATHtable = table.new(position.bottom_right, 10, 10, frame_color = color.gray, bgcolor = color.gray, border_width = 1, frame_width = 1, border_color = color.white) table.cell(ATHtable, 0, 0, text="Trend (D" + str.tostring(depth) + ")", bgcolor = isTrendUp ? color.green : color.red, tooltip="Green if pivot trend Up, red if down, for depth " + str.tostring(depth)) table.cell(ATHtable, 0, 1, text="Hesit. (D" + str.tostring(depth) + ")", bgcolor = isTrendHesitate ? color.orange : color.black, tooltip="Orange if pivot trend hesitate, for depth " + str.tostring(depth)) table.cell(ATHtable, 0, 2, text="Trend (D" + str.tostring(depthUtSup) + ")", bgcolor = dupIsTrendUpUtSup ? color.green : color.red, tooltip="Green if pivot trend up, red if down for depth " + str.tostring(depthUtSup)) table.cell(ATHtable, 0, 3, text="Hesit. (D" + str.tostring(depthUtSup) + ")", bgcolor = isTrendHesitateUtSup ? color.orange : color.black, tooltip="Orange if pivot trend hesitate, for depth " + str.tostring(depthUtSup)) // ]
Big Moves Indicator
https://www.tradingview.com/script/oSfnywuz-Big-Moves-Indicator/
bhnmzm
https://www.tradingview.com/u/bhnmzm/
285
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © bhnmzm //@version=5 indicator("Big Moves Indicator", overlay=true) // Input variables default_percentage = input.float(5, minval=0, maxval=100, title="Default Control Percentage (%)", tooltip="Will be applied only if specific control percentages for the timeframe are not set.", display = display.none) max_displayed_moves = input.int(10, "Maximum number of moves to display", minval = 0, maxval = 100, display = display.none) var group="Use Timeframe-Specific Control Percentage" bool tf_1_enabled = input.bool(false, title = "", inline="01", group=group, display = display.none) string tf_1 = input.timeframe(defval = "", title = "Timeframe: ", inline="01", group=group, display = display.none) float tf_1_per = input.float(0, minval=0, maxval=100, title="Percentage: ", inline="01", group=group, display = display.none) bool tf_2_enabled = input.bool(false, title = "", inline="02", group=group, display = display.none) string tf_2 = input.timeframe(defval = "", title = "Timeframe: ", inline="02", group=group, display = display.none) float tf_2_per = input.float(0, minval=0, maxval=100, title="Percentage: ", inline="02", group=group, display = display.none) bool tf_3_enabled = input.bool(false, title = "", inline="03", group=group, display = display.none) string tf_3 = input.timeframe(defval = "", title = "Timeframe: ", inline="03", group=group, display = display.none) float tf_3_per = input.float(0, minval=0, maxval=100, title="Percentage: ", inline="03", group=group, display = display.none) bool tf_4_enabled = input.bool(false, title = "", inline="04", group=group, display = display.none) string tf_4 = input.timeframe(defval = "", title = "Timeframe: ", inline="04", group=group, display = display.none) float tf_4_per = input.float(0, minval=0, maxval=100, title="Percentage: ", inline="04", group=group, display = display.none) bool tf_5_enabled = input.bool(false, title = "", inline="05", group=group, display = display.none) string tf_5 = input.timeframe(defval = "", title = "Timeframe: ", inline="05", group=group, display = display.none) float tf_5_per = input.float(0, minval=0, maxval=100, title="Percentage: ", inline="05", group=group, display = display.none) var label_ids = array.new_label(max_displayed_moves) // Timeframe-specific control percentages float current_tf_in_mins = timeframe.in_seconds() / 60 float tf_1_mins = not na(tf_1) ? timeframe.in_seconds(tf_1) / 60 : na float tf_2_mins = not na(tf_2) ? timeframe.in_seconds(tf_2) / 60 : na float tf_3_mins = not na(tf_3) ? timeframe.in_seconds(tf_3) / 60 : na float tf_4_mins = not na(tf_4) ? timeframe.in_seconds(tf_4) / 60 : na float tf_5_mins = not na(tf_5) ? timeframe.in_seconds(tf_5) / 60 : na // Get the selected control percentage based on the timeframe getPercentage() => if tf_1_enabled and tf_1_mins == current_tf_in_mins tf_1_per else if tf_2_enabled and tf_2_mins == current_tf_in_mins tf_2_per else if tf_3_enabled and tf_3_mins == current_tf_in_mins tf_3_per else if tf_4_enabled and tf_4_mins == current_tf_in_mins tf_4_per else if tf_5_enabled and tf_5_mins == current_tf_in_mins tf_5_per else default_percentage // Indicator calculations pre_close = close[1] is_red = close <= open height = high - low move = height / pre_close * 100 active_percentage = getPercentage() is_big_move = move > active_percentage // Plotting if is_big_move lbl = label.new(is_big_move ? bar_index : na, is_red ? high : low, style=is_red ? label.style_label_down : label.style_label_up, text = str.tostring(move, "##.##") + "%") // add new label to the queue array.push(label_ids, lbl) // remove oldest label label.delete(array.shift(label_ids)) // Alerts alertcondition(is_big_move and is_red, "Big Falling Move", "Big falling move") alertcondition(is_big_move and not is_red, "Big Rising Move", "Big rising move")
Lunch-Break
https://www.tradingview.com/script/qW0pqS4J-Lunch-Break/
totta
https://www.tradingview.com/u/totta/
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/ // © Se7en777 //@version=5 indicator("Lunch-Break", overlay=true) //version = 1.0.0 lunch1 = time(timeframe.period, "1200-1300", "America/New_York") lunch2 = time(timeframe.period, "1200-1300", "Europe/London") lunch3 = time(timeframe.period, "1200-1300", "Asia/Tokyo") bgcolor(lunch1 ? #ff525215 : na, title = "Lunch NYSE") bgcolor(lunch2 ? #ff525215 : na, title = "Lunch London") bgcolor(lunch3 ? #ff525215 : na, title = "Lunch Tokyo")
No Active Bar
https://www.tradingview.com/script/StebsWdf-No-Active-Bar/
NeoDaNomad
https://www.tradingview.com/u/NeoDaNomad/
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/ // © NeoDaNomad //@version=5 indicator("No Active Bar", 'N.A.B.', overlay=true) barcolor(color.rgb(0,0,0), offset=-1 ) //plot(bar_index, color=color.rgb(0,0,0) plot(barstate.isconfirmed ? high : na, color=input.color(color.rgb(0,0,0)), style=plot.style_stepline, linewidth=1) plot(barstate.isconfirmed ? low : na, color=input.color(color.new(color.orange, 50)), style=plot.style_stepline, linewidth=1)
Bitcoin OnChain & Other Metrics
https://www.tradingview.com/script/TbEIcooa-Bitcoin-OnChain-Other-Metrics/
LucasVivien
https://www.tradingview.com/u/LucasVivien/
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/ // © LucasVivien //@version=5 indicator("Bitcoin OnChain & Other Metrics", shorttitle="BTC Metrics", overlay=false, precision=1) //============================================================================== //============================== USER INPUT ================================ //============================================================================== c_MKPRU = input.color( defval=#ff3333, inline="1", group="", title="") u_MKPRU = input.bool(title="Bitcoin Market Price USD" , defval=true , inline="1", group="", tooltip="Average USD market price across major bitcoin exchanges.") c_TRVOU = input.color( defval=#ff6633, inline="2", group="", title="") u_TRVOU = input.bool(title="USD Exchange Trade Volume" , defval=false , inline="2", group="", tooltip="The total USD value of trading volume on major bitcoin exchanges.") c_DIFF = input.color( defval=#ff9933, inline="3", group="", title="") u_DIFF = input.bool(title="Difficulty" , defval=false , inline="3", group="", tooltip="A relative measure of how difficult it is to find a new block. The difficulty is adjusted periodically as a function of how much hashing power has been deployed by the network of miners.") c_MWNUS = input.color( defval=#ffcc33, inline="4", group="", title="") u_MWNUS = input.bool(title="My Wallet Number of Users" , defval=false , inline="4", group="", tooltip="Number of wallets hosts using Blockchain.com Service.") c_AVBLS = input.color( defval=#ffff33, inline="5", group="", title="") u_AVBLS = input.bool(title="Average Block Size" , defval=false , inline="5", group="", tooltip="The average block size in MB.") c_BLCHS = input.color( defval=#ccff33, inline="6", group="", title="") u_BLCHS = input.bool(title="API.blockchain Size" , defval=false , inline="6", group="", tooltip="The total size of all block headers and transactions. Not including database indexes.") c_ATRCT = input.color( defval=#99ff33, inline="7", group="", title="") u_ATRCT = input.bool(title="Median Transaction Confirmation Time" , defval=false , inline="7", group="", tooltip="The median time for a transaction to be accepted into a mined block and added to the public ledger (note: only includes transactions with miner fees).") c_MIREV = input.color( defval=#66ff33, inline="8", group="", title="") u_MIREV = input.bool(title="Miners Revenue" , defval=false , inline="8", group="", tooltip="Total value of coinbase block rewards and transaction fees paid to miners.") c_HRATE = input.color( defval=#33ff33, inline="9", group="", title="") u_HRATE = input.bool(title="Hash Rate" , defval=false , inline="9", group="", tooltip="The estimated number of tera hashes per second (trillions of hashes per second) the Bitcoin network is performing.") c_CPTRA = input.color( defval=#33ff66, inline="10", group="", title="") u_CPTRA = input.bool(title="Cost Per Transaction" , defval=false , inline="10", group="", tooltip="A chart showing miners revenue divided by the number of transactions.") c_CPTRV = input.color( defval=#33ff99, inline="11", group="", title="") u_CPTRV = input.bool(title="Cost % of Transaction Volume" , defval=false , inline="11", group="", tooltip="A chart showing miners revenue as percentage of the transaction volume.") c_ETRVU = input.color( defval=#33ffcc, inline="12", group="", title="") u_ETRVU = input.bool(title="Estimated Transaction Volume USD" , defval=false , inline="12", group="", tooltip="The Estimated Transaction Value in USD value.") c_ETRAV = input.color( defval=#33ffff, inline="13", group="", title="") u_ETRAV = input.bool(title="Estimated Transaction Volume" , defval=false , inline="13", group="", tooltip="The total estimated value of transactions on the Bitcoin blockchain (does not include coins returned to sender as change).") c_TOUTV = input.color( defval=#33ccff, inline="14", group="", title="") u_TOUTV = input.bool(title="Total Output Volume" , defval=false , inline="14", group="", tooltip="The total value of all transaction outputs per day (includes coins returned to the sender as change).") c_NTRBL = input.color( defval=#3399ff, inline="15", group="", title="") u_NTRBL = input.bool(title="Number of Transaction per Block" , defval=false , inline="15", group="", tooltip="The average number of transactions per block.") c_NADDU = input.color( defval=#3366ff, inline="16", group="", title="") u_NADDU = input.bool(title="Number of Unique Bitcoin Addresses Used" , defval=false , inline="16", group="", tooltip="The total number of unique addresses used on the Bitcoin blockchain.") c_NTREP = input.color( defval=#3333ff, inline="17", group="", title="") u_NTREP = input.bool(title="Number of Transac. Excl. Popular Addresses" , defval=false , inline="17", group="", tooltip="The total number of Bitcoin transactions, excluding those involving any of the network's 100 most popular addresses.") c_NTRAT = input.color( defval=#6633ff, inline="18", group="", title="") u_NTRAT = input.bool(title="Total Number of Transactions" , defval=false , inline="18", group="", tooltip="Total Number of transactions") c_NTRAN = input.color( defval=#9933ff, inline="19", group="", title="") u_NTRAN = input.bool(title="Number of Transactions" , defval=false , inline="19", group="", tooltip="The number of daily confirmed Bitcoin transactions.") c_TRFUS = input.color( defval=#cc33ff, inline="20", group="", title="") u_TRFUS = input.bool(title="Total Transaction Fees USD" , defval=false , inline="20", group="", tooltip="The total value of all transaction fees paid to miners (not including the coinbase value of block rewards).") c_TRFEE = input.color( defval=#ff33ff, inline="21", group="", title="") u_TRFEE = input.bool(title="Total Transaction Fees" , defval=false , inline="21", group="", tooltip="The total value of all transaction fees paid to miners (not including the coinbase value of block rewards).") c_MKTCP = input.color( defval=#ff33cc, inline="22", group="", title="") u_MKTCP = input.bool(title="Market Capitalization" , defval=false , inline="22", group="", tooltip="The total USD value of bitcoin supply in circulation, as calculated by the daily average market price across major exchanges.") c_TOTBC = input.color( defval=#ff3399, inline="23", group="", title="") u_TOTBC = input.bool(title="Total Bitcoins" , defval=false , inline="23", group="", tooltip="The total number of bitcoins that have already been mined; in other words, the current supply of bitcoins on the network.") c_MWNTD = input.color( defval=#ff3366, inline="24", group="", title="") u_MWNTD = input.bool(title="My Wallet Number of Transaction Per Day" , defval=false , inline="24", group="", tooltip="Number of transactions made by My Wallet Users per day.") c_MWTRV = input.color( defval=#ff3333, inline="25", group="", title="") u_MWTRV = input.bool(title="My Wallet Transaction Volume" , defval=false , inline="25", group="", tooltip="24hr Transaction Volume of our web wallet service.") //============================================================================== //=============================== GET DATA ================================= //============================================================================== req_MKPRU = request.quandl("BCHAIN/MKPRU", barmerge.gaps_off, 0) req_TRVOU = request.quandl("BCHAIN/TRVOU", barmerge.gaps_off, 0) req_DIFF = request.quandl("BCHAIN/DIFF" , barmerge.gaps_off, 0) req_MWNUS = request.quandl("BCHAIN/MWNUS", barmerge.gaps_off, 0) req_AVBLS = request.quandl("BCHAIN/AVBLS", barmerge.gaps_off, 0) req_BLCHS = request.quandl("BCHAIN/BLCHS", barmerge.gaps_off, 0) req_ATRCT = request.quandl("BCHAIN/ATRCT", barmerge.gaps_off, 0) req_MIREV = request.quandl("BCHAIN/MIREV", barmerge.gaps_off, 0) req_HRATE = request.quandl("BCHAIN/HRATE", barmerge.gaps_off, 0) req_CPTRA = request.quandl("BCHAIN/CPTRA", barmerge.gaps_off, 0) req_CPTRV = request.quandl("BCHAIN/CPTRV", barmerge.gaps_off, 0) req_ETRVU = request.quandl("BCHAIN/ETRVU", barmerge.gaps_off, 0) req_ETRAV = request.quandl("BCHAIN/ETRAV", barmerge.gaps_off, 0) req_TOUTV = request.quandl("BCHAIN/TOUTV", barmerge.gaps_off, 0) req_NTRBL = request.quandl("BCHAIN/NTRBL", barmerge.gaps_off, 0) req_NADDU = request.quandl("BCHAIN/NADDU", barmerge.gaps_off, 0) req_NTREP = request.quandl("BCHAIN/NTREP", barmerge.gaps_off, 0) req_NTRAT = request.quandl("BCHAIN/NTRAT", barmerge.gaps_off, 0) req_NTRAN = request.quandl("BCHAIN/NTRAN", barmerge.gaps_off, 0) req_TRFUS = request.quandl("BCHAIN/TRFUS", barmerge.gaps_off, 0) req_TRFEE = request.quandl("BCHAIN/TRFEE", barmerge.gaps_off, 0) req_MKTCP = request.quandl("BCHAIN/MKTCP", barmerge.gaps_off, 0) req_TOTBC = request.quandl("BCHAIN/TOTBC", barmerge.gaps_off, 0) req_MWNTD = request.quandl("BCHAIN/MWNTD", barmerge.gaps_off, 0) req_MWTRV = request.quandl("BCHAIN/MWTRV", barmerge.gaps_off, 0) //============================================================================== //================================= PLOTS ================================== //============================================================================== plot(u_MKPRU ? req_MKPRU : na, title="", color=c_MKPRU, style=plot.style_linebr) plot(u_TRVOU ? req_TRVOU : na, title="", color=c_TRVOU, style=plot.style_linebr) plot(u_DIFF ? req_DIFF : na, title="", color=c_DIFF , style=plot.style_linebr) plot(u_MWNUS ? req_MWNUS : na, title="", color=c_MWNUS, style=plot.style_linebr) plot(u_AVBLS ? req_AVBLS : na, title="", color=c_AVBLS, style=plot.style_linebr) plot(u_BLCHS ? req_BLCHS : na, title="", color=c_BLCHS, style=plot.style_linebr) plot(u_ATRCT ? req_ATRCT : na, title="", color=c_ATRCT, style=plot.style_linebr) plot(u_MIREV ? req_MIREV : na, title="", color=c_MIREV, style=plot.style_linebr) plot(u_HRATE ? req_HRATE : na, title="", color=c_HRATE, style=plot.style_linebr) plot(u_CPTRA ? req_CPTRA : na, title="", color=c_CPTRA, style=plot.style_linebr) plot(u_CPTRV ? req_CPTRV : na, title="", color=c_CPTRV, style=plot.style_linebr) plot(u_TRVOU ? req_TRVOU : na, title="", color=c_TRVOU, style=plot.style_linebr) plot(u_ETRVU ? req_ETRVU : na, title="", color=c_ETRVU, style=plot.style_linebr) plot(u_ETRAV ? req_ETRAV : na, title="", color=c_ETRAV, style=plot.style_linebr) plot(u_TOUTV ? req_TOUTV : na, title="", color=c_TOUTV, style=plot.style_linebr) plot(u_NTRBL ? req_NTRBL : na, title="", color=c_NTRBL, style=plot.style_linebr) plot(u_NADDU ? req_NADDU : na, title="", color=c_NADDU, style=plot.style_linebr) plot(u_NTREP ? req_NTREP : na, title="", color=c_NTREP, style=plot.style_linebr) plot(u_NTRAT ? req_NTRAT : na, title="", color=c_NTRAT, style=plot.style_linebr) plot(u_NTRAN ? req_NTRAN : na, title="", color=c_NTRAN, style=plot.style_linebr) plot(u_TRFUS ? req_TRFUS : na, title="", color=c_TRFUS, style=plot.style_linebr) plot(u_TRFEE ? req_TRFEE : na, title="", color=c_TRFEE, style=plot.style_linebr) plot(u_MKTCP ? req_MKTCP : na, title="", color=c_MKTCP, style=plot.style_linebr) plot(u_TOTBC ? req_TOTBC : na, title="", color=c_TOTBC, style=plot.style_linebr) plot(u_MWNTD ? req_MWNTD : na, title="", color=c_MWNTD, style=plot.style_linebr) plot(u_MWTRV ? req_MWTRV : na, title="", color=c_MWTRV, style=plot.style_linebr)
Kros-Candles
https://www.tradingview.com/script/WEeGpg7r-Kros-Candles/
kemaltkn
https://www.tradingview.com/u/kemaltkn/
30
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © kemaltkn //@version=5 indicator(title="Kros-Candles", overlay = true,shorttitle="Kros Candles") ShowMarket = input.bool(group='Market-Table', title='Show Market Table ?', defval=false, inline='showtable') BarRange() => high - low BodyRange() => math.abs(close - open) rangeOfBar = BarRange() rangeOfBody = BodyRange() isUp = close > open isDown = close <= open KrosCandle = 0.93 <= rangeOfBody / rangeOfBar PumpColor = input.color(group='Bars', title='Pump Bar Color', defval= color.lime , inline='pump') DumpColor = input.color(group='Bars', title='Dump Bar Color', defval=color.red, inline='dump') CandleColor = KrosCandle and isUp ? PumpColor : KrosCandle and isDown ? DumpColor : na , barcolor(CandleColor) plotshape(KrosCandle,style=shape.triangledown,size=size.small, location=location.abovebar, color=color.silver,title="FullBodyCandle") //----------------------------------------- //Table Btc_dom1 = request.security('CRYPTOCAP:BTC.D' ,"D" ,expression = open) Btc_dom2 = request.security('CRYPTOCAP:BTC.D' ,"D" ,expression = close) Change = (Btc_dom2 - Btc_dom2[1]) / Btc_dom2[1] * 100 TotalOp = request.security('CRYPTOCAP:TOTAL' ,"D" ,expression = open) TotalClose = request.security('CRYPTOCAP:TOTAL' ,"D" ,expression = close) Change1 = (TotalClose - TotalClose[1]) / TotalClose[1] * 100 Total2Op = request.security('CRYPTOCAP:TOTAL2' ,"D" ,expression = open) Total2Close = request.security('CRYPTOCAP:TOTAL2' ,"D" ,expression = close) Change2 = (Total2Close - Total2Close[1]) / Total2Close[1] * 100 Dom_Text = Btc_dom1 > Btc_dom2 ? color.red : Btc_dom1 < Btc_dom2 ? color.green : na Total_Text = TotalOp > TotalClose ? color.red : TotalOp < TotalClose ? color.green :na Total2_Text = Total2Op > Total2Close ? color.red : Total2Op < Total2Close ? color.green :na if barstate.islast and ShowMarket var infoTable = table.new(position = position.top_right, columns = 2, rows = 3, bgcolor = color.rgb(93, 96, 107, 70), border_width = 1) table.cell(table_id = infoTable, column = 0, row = 2, text = "BTC.D : ",text_color=color.rgb(31, 188, 211, 0),text_halign=text.align_left) table.cell(table_id = infoTable, column = 1, row = 2, text = "" + str.tostring(Change,"#.##"),text_color=Dom_Text,text_halign=text.align_center ) table.cell(table_id = infoTable, column = 0, row = 0, text = "TOTAL : ",text_color=color.rgb(31, 188, 211, 0),text_halign=text.align_left) table.cell(table_id = infoTable, column = 1, row = 0, text = str.tostring(Change1,"#.##"),text_color=Total_Text,text_halign=text.align_center) table.cell(table_id = infoTable, column = 0, row = 1, text = "TOTAL2 : ",text_color=color.rgb(31, 188, 211, 0),text_halign=text.align_left) table.cell(table_id = infoTable, column = 1, row = 1, text = str.tostring(Change2,"#.##"),text_color=Total_Text,text_halign=text.align_center) //----------------------------------------- //Emas threeEmaLength = 50 fourEmaLength = 200 showEmas = input.bool(group='EMAs', title='Show EMAs?', defval=false, inline='showemas') threeEmaColor = input.color(group='EMAs', title='50', defval=color.rgb(31, 188, 211, 0), inline='emacolors') fourEmaColor = input.color(group='EMAs', title='200', defval=color.rgb(255, 255, 255, 0), inline='emacolors') threeEma = ta.ema(close, threeEmaLength) plot(showEmas ? threeEma : na, color=threeEmaColor, title='50 Ema') fourEma = ta.ema(close, fourEmaLength) plot(showEmas ? fourEma : na, color=fourEmaColor, title='200 Ema') //-----------------------------------------
Baseline (BL)
https://www.tradingview.com/script/IarKgYFQ-Baseline-BL/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
115
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at // https://mozilla.org/MPL/2.0/ // © peacefulLizard50262 //@version=5 indicator("Baseline", overlay = true) baseline(float _source = close, simple string _period = "D", string _user = "true", string _custom, bool _manual = false, float _mInput = na) => //can any one explain why I HAD to use a string for my _user "bool" ?? string self = syminfo.tickerid bool live = barstate.isrealtime period = _user == "false" ? _period : _user == "true" ? _custom : "D" float baseline = request.security(self, period, _source[live ? 1 :0])[live ? 0 : 1] result = _manual == false ? baseline : _mInput period = input.timeframe("D", "Anchor Period") custom_toggle = input.bool(false, "Custom Anchor", inline = "toggle") toggle = str.tostring(custom_toggle) custom_input = input.int(5, "", inline = "toggle") custom = str.format("{0,number,integer}", custom_input) manual_toggle = input.bool(false, "Manual Anchor", inline = "manual") manual_value = input.float(0.0, "", inline = "manual") source = input.source(close, "Source                 ") float baseline = baseline(source, period, toggle, custom, manual_toggle, manual_value) colour_toggle = input.bool(true, "Color Candle", inline = "colour") colour = baseline < source ? color.new(#26a69a, 0) : color.new(#ef5350, 0) colour_enable = colour_toggle == true ? colour : na colour_tog_bg = input.bool(false, "Color Background", inline = "colour") colour_bg = baseline < source ? color.new(#26a69a, 90) : color.new(#ef5350, 90) colour_fill = colour_tog_bg == true ? colour_bg : na barcolor(colour_enable) price = plot(source, "source", color.new(color.white, 100), style = plot.style_stepline) baseline_plot = plot(baseline, "baseline", colour, style = plot.style_stepline) fill(price, baseline_plot, colour_fill)
NVT Ratio: Onchain
https://www.tradingview.com/script/KDGS40fj-NVT-Ratio-Onchain/
cryptoonchain
https://www.tradingview.com/u/cryptoonchain/
55
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MJShahsavar //@version=5 indicator("NVT Ratio: Onchain") R = input.symbol("BTC_MARKETCAP", "Symbol") r = request.security(R, 'D', close) S=input.symbol("BTC_TOTALVOLUMEUSD", "Symbol") s = request.security(S, 'D', close) C= r/s plot (C, color = color.blue, linewidth=1)
[_ParkF]MA_Package
https://www.tradingview.com/script/tza6UjM2/
ParkF
https://www.tradingview.com/u/ParkF/
102
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ParkF //@version=5 indicator("[_ParkF]MA_Package", overlay=true) // Function src = input.source(close, 'Source', group='_____Moving Average Setting') 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) // Input switch1 = input.bool(true, 'ON / OFF', group='_____MA1') maType1 = input.string("SMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="_____MA1") len_1 = input.int( 10, 'Length', inline='MA1', group='_____MA1') col_1 = input.color(color.new(#ff0000, 0), '', inline='MA1', group='_____MA1') width1 = input.int(2, 'Width', inline='MA1', group='_____MA1') switch2 = input.bool(true, 'ON / OFF', group='_____MA2') maType2 = input.string("SMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="_____MA2") len_2 = input.int( 20, 'Length', inline='MA2', group='_____MA2') col_2 = input.color(color.new(#ff9800, 0), '', inline='MA2', group='_____MA2') width2 = input.int(2, 'Width', inline='MA2', group='_____MA2') switch3 = input.bool(true, 'ON / OFF', group='_____MA3') maType3 = input.string("SMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="_____MA3") len_3 = input.int( 60, 'Length', inline='MA3', group='_____MA3') col_3 = input.color(color.new(#ffe500, 0), '', inline='MA3', group='_____MA3') width3 = input.int(3, 'Width', inline='MA3', group='_____MA3') switch4 = input.bool(true, 'ON / OFF', group='_____MA4') maType4 = input.string("SMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="_____MA4") len_4 = input.int(100, 'Length', inline='MA4', group='_____MA4') col_4 = input.color(color.new(#4caf50, 0), '', inline='MA4', group='_____MA4') width4 = input.int(2, 'Width', inline='MA4', group='_____MA4') switch5 = input.bool(true, 'ON / OFF', group='_____MA5') maType5 = input.string("SMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="_____MA5") len_5 = input.int(200, 'Length', inline='MA5', group='_____MA5') col_5 = input.color(color.new(#2962ff, 0), '', inline='MA5', group='_____MA5') width5 = input.int(2, 'Width', inline='MA5', group='_____MA5') switch6 = input.bool(true, 'ON / OFF', group='_____MA6') maType6 = input.string("SMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="_____MA6") len_6 = input.int(300, 'Length', inline='MA6', group='_____MA6') col_6 = input.color(color.new(#9c27b0, 0), '', inline='MA6', group='_____MA6') width6 = input.int(2, 'Width', inline='MA6', group='_____MA6') // Get Moving Average ma1 = ma(src, len_1, maType1) ma2 = ma(src, len_2, maType2) ma3 = ma(src, len_3, maType3) ma4 = ma(src, len_4, maType4) ma5 = ma(src, len_5, maType5) ma6 = ma(src, len_6, maType6) // Plot plot(switch1 ? ma1 : na, 'MA(5)', color=col_1, linewidth=width1, editable=false) plot(switch2 ? ma2 : na, 'MA(10)', color=col_2, linewidth=width2, editable=false) plot(switch3 ? ma3 : na, 'MA(20)', color=col_3, linewidth=width3, editable=false) plot(switch4 ? ma4 : na, 'MA(60)', color=col_4, linewidth=width4, editable=false) plot(switch5 ? ma5 : na, 'MA(120)', color=col_5, linewidth=width5, editable=false) plot(switch6 ? ma6 : na, 'MA(240)', color=col_6, linewidth=width6, editable=false) // Prdictive Monvig Average PreMA_width = input(2, 'Width', group='_____Predictv MA') // Function tf = timeframe.period sym = syminfo.tickerid // Predivtive MA1 p_ma1_1 = request.security(sym, tf, (ma(src, len_1-1, maType1) * (len_1 - 1) + src * 1) / len_1) p_ma1_2 = request.security(sym, tf, (ma(src, len_1-2, maType1) * (len_1 - 2) + src * 2) / len_1) p_ma1_3 = request.security(sym, tf, (ma(src, len_1-3, maType1) * (len_1 - 3) + src * 3) / len_1) p_ma1_4 = request.security(sym, tf, (ma(src, len_1-4, maType1) * (len_1 - 4) + src * 4) / len_1) plot(switch1 ? p_ma1_1 : na, title='pMA1_1', color=col_1, style=plot.style_circles, linewidth=PreMA_width, offset=+1, show_last=1, editable=false) plot(switch1 ? p_ma1_2 : na, title='pMA1_2', color=col_1, style=plot.style_circles, linewidth=PreMA_width, offset=+2, show_last=1, editable=false) plot(switch1 ? p_ma1_3 : na, title='pMA1-3', color=col_1, style=plot.style_circles, linewidth=PreMA_width, offset=+3, show_last=1, editable=false) plot(switch1 ? p_ma1_4 : na, title='pMA1-4', color=col_1, style=plot.style_circles, linewidth=PreMA_width, offset=+4, show_last=1, editable=false) // Predivtive MA2 p_ma2_1 = request.security(sym, tf, (ma(src, len_2-1, maType2) * (len_2 - 1) + src * 1) / len_2) p_ma2_2 = request.security(sym, tf, (ma(src, len_2-2, maType2) * (len_2 - 2) + src * 2) / len_2) p_ma2_3 = request.security(sym, tf, (ma(src, len_2-3, maType2) * (len_2 - 3) + src * 3) / len_2) p_ma2_4 = request.security(sym, tf, (ma(src, len_2-4, maType2) * (len_2 - 4) + src * 4) / len_2) plot(switch2 ? p_ma2_1 : na, title='pMA2-1', color=col_2, style=plot.style_circles, linewidth=PreMA_width, offset=+1, show_last=1, editable=false) plot(switch2 ? p_ma2_2 : na, title='pMA2-2', color=col_2, style=plot.style_circles, linewidth=PreMA_width, offset=+2, show_last=1, editable=false) plot(switch2 ? p_ma2_3 : na, title='pMA2-3', color=col_2, style=plot.style_circles, linewidth=PreMA_width, offset=+3, show_last=1, editable=false) plot(switch2 ? p_ma2_4 : na, title='pMA2-4', color=col_2, style=plot.style_circles, linewidth=PreMA_width, offset=+4, show_last=1, editable=false) // Predivtive MA3 p_ma3_1 = request.security(sym, tf, (ma(src, len_3-1, maType3) * (len_3 - 1) + src * 1) / len_3) p_ma3_2 = request.security(sym, tf, (ma(src, len_3-2, maType3) * (len_3 - 2) + src * 2) / len_3) p_ma3_3 = request.security(sym, tf, (ma(src, len_3-3, maType3) * (len_3 - 3) + src * 3) / len_3) p_ma3_4 = request.security(sym, tf, (ma(src, len_3-4, maType3) * (len_3 - 4) + src * 4) / len_3) plot(switch3 ? p_ma3_1 : na, title='pMA3-1', color=col_3, style=plot.style_circles, linewidth=PreMA_width, offset=+1, show_last=1, editable=false) plot(switch3 ? p_ma3_2 : na, title='pMA3-2', color=col_3, style=plot.style_circles, linewidth=PreMA_width, offset=+2, show_last=1, editable=false) plot(switch3 ? p_ma3_3 : na, title='pMA3-3', color=col_3, style=plot.style_circles, linewidth=PreMA_width, offset=+3, show_last=1, editable=false) plot(switch3 ? p_ma3_4 : na, title='pMA3-4', color=col_3, style=plot.style_circles, linewidth=PreMA_width, offset=+4, show_last=1, editable=false) // Predivtive MA4 p_ma4_1 = request.security(sym, tf, (ma(src, len_4-1, maType4) * (len_4 - 1) + src * 1) / len_4) p_ma4_2 = request.security(sym, tf, (ma(src, len_4-2, maType4) * (len_4 - 2) + src * 2) / len_4) p_ma4_3 = request.security(sym, tf, (ma(src, len_4-3, maType4) * (len_4 - 3) + src * 3) / len_4) p_ma4_4 = request.security(sym, tf, (ma(src, len_4-4, maType4) * (len_4 - 4) + src * 4) / len_4) plot(switch4 ? p_ma4_1 : na, title='pMA4-1', color=col_4, style=plot.style_circles, linewidth=PreMA_width, offset=+1, show_last=1, editable=false) plot(switch4 ? p_ma4_2 : na, title='pMA4-2', color=col_4, style=plot.style_circles, linewidth=PreMA_width, offset=+2, show_last=1, editable=false) plot(switch4 ? p_ma4_3 : na, title='pMA4-3', color=col_4, style=plot.style_circles, linewidth=PreMA_width, offset=+3, show_last=1, editable=false) plot(switch4 ? p_ma4_4 : na, title='pMA4-4', color=col_4, style=plot.style_circles, linewidth=PreMA_width, offset=+4, show_last=1, editable=false) // Predivtive MA5 p_ma5_1 = request.security(sym, tf, (ma(src, len_5-1, maType5) * (len_5 - 1) + src * 1) / len_5) p_ma5_2 = request.security(sym, tf, (ma(src, len_5-2, maType5) * (len_5 - 2) + src * 2) / len_5) p_ma5_3 = request.security(sym, tf, (ma(src, len_5-3, maType5) * (len_5 - 3) + src * 3) / len_5) p_ma5_4 = request.security(sym, tf, (ma(src, len_5-4, maType5) * (len_5 - 4) + src * 4) / len_5) plot(switch5 ? p_ma5_1 : na, title='pMA5-1', color=col_5, style=plot.style_circles, linewidth=PreMA_width, offset=+1, show_last=1, editable=false) plot(switch5 ? p_ma5_2 : na, title='pMA5-2', color=col_5, style=plot.style_circles, linewidth=PreMA_width, offset=+2, show_last=1, editable=false) plot(switch5 ? p_ma5_3 : na, title='pMA5-3', color=col_5, style=plot.style_circles, linewidth=PreMA_width, offset=+3, show_last=1, editable=false) plot(switch5 ? p_ma5_4 : na, title='pMA5-4', color=col_5, style=plot.style_circles, linewidth=PreMA_width, offset=+4, show_last=1, editable=false) // Predivtive MA6 p_ma6_1 = request.security(sym, tf, (ma(src, len_6-1, maType6) * (len_6 - 1) + src * 1) / len_6) p_ma6_2 = request.security(sym, tf, (ma(src, len_6-2, maType6) * (len_6 - 2) + src * 2) / len_6) p_ma6_3 = request.security(sym, tf, (ma(src, len_6-3, maType6) * (len_6 - 3) + src * 3) / len_6) p_ma6_4 = request.security(sym, tf, (ma(src, len_6-4, maType6) * (len_6 - 4) + src * 4) / len_6) plot(switch6 ? p_ma6_1 : na, title='pMA6-1', color=col_6, style=plot.style_circles, linewidth=PreMA_width, offset=+1, show_last=1, editable=false) plot(switch6 ? p_ma6_2 : na, title='pMA6-2', color=col_6, style=plot.style_circles, linewidth=PreMA_width, offset=+2, show_last=1, editable=false) plot(switch6 ? p_ma6_3 : na, title='pMA6-3', color=col_6, style=plot.style_circles, linewidth=PreMA_width, offset=+3, show_last=1, editable=false) plot(switch6 ? p_ma6_4 : na, title='pMA6-4', color=col_6, style=plot.style_circles, linewidth=PreMA_width, offset=+4, show_last=1, editable=false)
Heikin-Ashi Candle Color
https://www.tradingview.com/script/MP7Qy6V5-Heikin-Ashi-Candle-Color/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
48
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © peacefulLizard50262 //@version=5 indicator("Heiken-Ashi Color", overlay = true) candel_bool = input.bool(true, "Enable Heiken-Ashi Candle Color") ha_close = candel_bool == true ? (open + high + low + close) / 4 : close ha_open = float(na) ha_open := candel_bool == true ? na(ha_open[1]) ? (open + close) / 2 : (nz(ha_open[1]) + nz(ha_close[1])) / 2 : open ha_high = candel_bool == true ? math.max(high, math.max(ha_open, ha_close)) : high ha_low = candel_bool == true ? math.min(low, math.min(ha_open, ha_close)) : low ha_color = candel_bool == true ? ha_close > ha_open ? color.new(#26a69a, 0) : color.new(#ef5350, 0) : close >= open ? color.new(#26a69a, 0) : color.new(#ef5350, 0) barcolor(ha_color)
Noski - Rob Hoffman_Inventory Retracement Bar
https://www.tradingview.com/script/khxEdmoy-Noski-Rob-Hoffman-Inventory-Retracement-Bar/
noski1
https://www.tradingview.com/u/noski1/
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/ // © noski1 //@version=5 indicator(title='Noski - Rob Hoffman_Inventory Retracement Bar', shorttitle='Noski HM', precision=2, overlay=true) // Inputs z = input.int(45, title='Inventory Retracement Percentage %', maxval=100, group="IRB") src = input(title='Source', defval=close, group="Angle of EMA") guide_pos = input.float(title='Guides Position', defval=45, group="Angle of EMA") guide_neg = input(title='Guides Position', defval=-45, group="Angle of EMA") price2bar_ratio = input(title='Price To Bar Ratio', defval=20.0, group="Angle of EMA") threshold = input(title='Threshold', defval=1.0, group="Angle of EMA") smal = input(title='Average angle over how many bars', defval=20, group="Angle of EMA") emafilter = input.int(title="EMA length", defval=20, group= "EMA") // Strategy Settings var g_strategy = "Strategy Settings" stopMultiplier = input.float(title="Stop Loss ATR", defval=1.0, group=g_strategy, tooltip="Stop loss multiplier (x ATR)") rr = input.float(title="R:R", defval=1.0, group=g_strategy, tooltip="Risk:Reward profile") // Filter Settings var g_filter = "Filter Settings" atrMinFilterSize = input.float(title=">= ATR Filter", defval=0.0, minval=0.0, group=g_filter, tooltip="Minimum size of entry candle compared to ATR") atrMaxFilterSize = input.float(title="<= ATR Filter", defval=3.0, minval=0.0, group=g_filter, tooltip="Maximum size of entry candle compared to ATR") // -------------------------------------------------------------------------------- //------- IRB--------// // -------------------------------------------------------------------------------- // Candle Range a = math.abs(high - low) // Candle Body b = math.abs(close - open) // Percent to Decimal c = z / 100 // Range Verification rv = b < c * a // Price Level for Retracement x = low + c * a y = high - c * a // IRB Buy/Sell Filter irbb = rv == 1 and high > y and close < y and open < y //triangle down irbs = rv == 1 and low < x and close > x and open > x //triangle up // Line Definition li = irbb ? y : irbs ? x : (x + y) / 2 // -------------------------------------------------------------------------------- // EMA Angle Functions // -------------------------------------------------------------------------------- ema = ta.ema(close, emafilter) get_slope(ema, price2bar_ratio) => 180.0 / (2 * math.asin(1)) * math.atan(ta.change(ema) / price2bar_ratio) // Logic slope = get_slope(ema, price2bar_ratio) rise = false rise := slope - slope[1] > threshold ? true : slope - slope[1] < -threshold ? false : nz(rise[1]) prefall = false prefall := not rise or slope - slope[1] > 0 ? false : rise and slope - slope[1] < 0 ? true : nz(prefall[1]) prerise = false prerise := rise or slope - slope[1] < 0 ? false : not rise and slope - slope[1] > 0 ? true : nz(prerise[1]) sma = ta.sma(slope, smal) atr = ta.atr(14) // Angle Buy Sell Filter emapos = sma > guide_pos emaneg = sma < guide_neg // -------------------------------------------------------------------------------- // ATR Settings // -------------------------------------------------------------------------------- // Check ATR filter atrMinFilter = high - low >= (atrMinFilterSize * atr) or atrMinFilterSize == 0.0 atrMaxFilter = high - low <= (atrMaxFilterSize * atr) or atrMaxFilterSize == 0.0 atrFilter = atrMinFilter and atrMaxFilter and not na(atr) // Calculate long stops & targets longStop = low - (atr * stopMultiplier) longStopDistance = close - longStop longTarget = high + (longStopDistance * rr) // Calculate short stops & targets shortStop = high + (atr * stopMultiplier) shortStopDistance = shortStop - close shortTarget = low - (shortStopDistance * rr) var int inTrade = 0 // -------------------------------------------------------------------------------- // Combined Buy and Sell signals // -------------------------------------------------------------------------------- buy = irbb and emapos and atrFilter and barstate.isconfirmed and inTrade == 0 sell = irbs and emaneg and atrFilter and barstate.isconfirmed and inTrade == 0 // Save stops & targets var float t_stop = na var float t_target = na if (buy or sell) and inTrade == 0 t_stop := buy ? longStop : shortStop t_target := buy ? longTarget : shortTarget inTrade := buy ? 1 : -1 // Check if long stop or target is hit if inTrade == 1 if high >= t_target or low <= t_stop inTrade := 0 // Check if short stop or target is hit if inTrade == -1 if high >= t_stop or low <= t_target inTrade := 0 // Plot Statement plotshape(buy, style=shape.triangleup, location=location.abovebar, color=color.new(color.green, 0), text = "Long", title='Long IRB', textcolor = color.green) plotshape(sell, style=shape.triangledown, location=location.belowbar, color=color.new(color.red, 0), text = "Short", title='Short IRB', textcolor = color.red) bgcolor(sma > guide_pos ? color.new(color.green, 85) : na) // highlighting bg when ema angle > 45 bgcolor(sma < guide_neg ? color.new(color.red, 85) : na) plot(inTrade != 0 ? t_stop : na, style=plot.style_linebr, color=color.red, title="Trade Stop") plot(inTrade != 0 ? t_target : na, style=plot.style_linebr, color=color.green, title="Trade Target") plot(ema, title="EMA", color=color.yellow, linewidth=2) // Trigger alerts alertcondition(buy, "Buy") alertcondition(sell, "Sell")
Triangle line
https://www.tradingview.com/script/XeVAIQuz/
nicoakim
https://www.tradingview.com/u/nicoakim/
300
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © nicoakim //@version=5 indicator("Triangle Line",overlay=true) res1 = input.timeframe(title='Resolution Trendline', defval='') ln = input.int(10, minval=5, title='Length of Trend') bars = input(100, 'Bars offset') color col = input.color(color.yellow) /////////////////////////////////////////////// reqsymbol(resolusi,value) => request.security(syminfo.tickerid,resolusi,value) dt = time - time[1] /////////////////////////////////////////////// pivothigh() => hprice = 0.0 swh = ta.pivothigh(high, ln, ln) hprice := not na(swh) ? swh : hprice[1] hprice pivothightime() => var int hprice = na swh = ta.pivothigh(high, ln, ln) hprice := not na(swh) ? time[ln] : hprice[1] hprice pivotlow() => lprice = 0.0 swl = ta.pivotlow(low, ln, ln) lprice := not na(swl) ? swl : lprice[1] lprice pivotlowtime() => var int lprice = na swl = ta.pivotlow(low, ln,ln) lprice := not na(swl) ? time[ln] : lprice lprice /////////////////////////////////////////////// storevalueint(value2) => var int storei = na if value2 != value2[1] storei := value2[1] storei storevaluefloat(value) => var float store = na if value != value[1] store := value[1] store /////////////////////////////////////////////// geting(x1,x2,y1,y2,ts) => m = (y1 - y2) / (x1 - x2) b = y1 - m * x1 Y = m * ts + b Y ////////////////////////////////////////i/j////// abc(resolusi) => xs1 = storevalueint( reqsymbol(res1,pivotlowtime())) ys1 = storevaluefloat( reqsymbol(res1,pivotlow())) xs2 = reqsymbol(res1,pivotlowtime()) ys2 = reqsymbol(res1,pivotlow()) xr1 = storevalueint( reqsymbol(res1,pivothightime())) yr1 = storevaluefloat( reqsymbol(res1,pivothigh())) xr2 = reqsymbol(res1,pivothightime()) yr2 = reqsymbol(res1,pivothigh()) breakout = ta.crossover(close,geting(xr1,xr2,yr1,yr2,time)) breakdown= ta.crossunder(close, geting(xs1,xs2,ys1,ys2,time)) var line s = line.new(na, na, na, na, xloc.bar_time, extend.none, color.new(color.yellow,99), line.style_solid, 1) var line r = line.new(na, na, na, na, xloc.bar_time, extend.none, color.new(color.yellow,99), line.style_solid, 1) var line sx = line.new(na, na, na, na, xloc.bar_time, extend.none, color.new(color.yellow,99), line.style_dashed, 1) var line rx = line.new(na, na, na, na, xloc.bar_time, extend.none, color.new(color.yellow,99), line.style_dashed, 1) if ys1 < ys2 and yr1 > yr2 line.set_xy1(s, xs1, ys1) line.set_xy2(s, time+bars*dt,ys1) line.set_xy1(r, xr1, yr1) line.set_xy2(r, time+bars*dt,yr1) line.set_xy1(sx, xs1, ys1) line.set_xy2(sx, time +bars*dt,geting(xs1,xs2,ys1,ys2,time + bars * dt)) line.set_xy1(rx, xr1, yr1) line.set_xy2(rx, time +bars *dt,geting(xr1,xr2,yr1,yr2,time + bars *dt)) linefill.new(sx,rx,color=color.new(col,80)) abc(res1)
3 EMAs with Visible ANGLE
https://www.tradingview.com/script/GGERiJUj-3-EMAs-with-Visible-ANGLE/
Papadaulat
https://www.tradingview.com/u/Papadaulat/
76
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/ // © Papadaulat //@version=4 //Format 1st EMA study("3 EMAs with Visible ANGLE", overlay = true) len1 = input(5, minval=1, title="1st EMA Length", group = "1st EMA ------") res1 = input(title="Resolution", type=input.resolution, defval="") src1 = input(close, title="Source") dev1 = input(0.00, minval=-5, title="Deviation %", step=0.05) offset1 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500) turnon1 = input(true, title="Turn on/off 1st Ema") allowRepainting1 = input(true, "Allow Repainting?") //Format 2ndt EMA len2 = input(18, minval=1, title="2nd EMA Length", group = "2nd EMA ------") res2 = input(title="Resolution", type=input.resolution, defval="") src2 = input(close, title="Source") dev2 = input(0.00, minval=-5, title="Deviation %",step=0.05) offset2 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500) turnon2 = input(true, title="Turn on/off 2nd Ema") allowRepainting2 = input(true, "Allow Repainting?") //Format 3rd EMA len3 = input(44, minval=1, title="3rd EMA Length", group = "3rd EMA ------") res3 = input(title="Resolution", type=input.resolution, defval="") src3 = input(close, title="Source") dev3 = input(0.00, minval=-5, title="Deviation %",step=0.05) offset3 = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500) turnon3 = input(true, title="Turn on/off 3rd Ema") allowRepainting3 = input(true, "Allow Repainting?") extend = input(30, minval=0, title="Lines Extension Value", group = "Extension Lines ------") extendonoff1 = input(true, title="Turn on/off 1st Line Extension") extendonoff2 = input(true, title="Turn on/off 2nd Line Extension") extendonoff3 = input(true, title="Turn on/off 3rd Line Extension") //------------------------------------------------------------------------------------------------------------------// factorm1 = 1 - dev1/100 factorm2 = 1 - dev2/100 factorm3 = 1 - dev3/100 maa = ema(src1, len1) MA1 = allowRepainting1 ? security(syminfo.tickerid, res1, maa) : security(syminfo.tickerid, res1, maa[1], barmerge.lookahead_on) ma1 = MA1 * factorm1 mab = ema(src2, len2) MA2 = allowRepainting2 ? security(syminfo.tickerid, res2, mab) : security(syminfo.tickerid, res2, mab[1], barmerge.lookahead_on) ma2 = MA2 * factorm2 mac = ema(src3, len3) MA3 = allowRepainting3 ? security(syminfo.tickerid, res3, mac) : security(syminfo.tickerid, res3, mac[1], barmerge.lookahead_on) ma3 = MA3 * factorm3 //------------------------------------------------------------------------------------------------------------------------// plot(turnon1 ? ma1 : na, color=color.fuchsia, offset=offset1) plot(turnon2 ? ma2 : na, color=color.blue, offset=offset2) plot(turnon3 ? ma3 : na, color=color.orange, offset=offset3) //------------------------------------------------------------------------------------------------------------------------// f_y_given_x(_x1, _y1, _x2, _y2, _new_x) => _m = (_y2 - _y1) / (_x2 - _x1) _b = _y1 - _m * _x1 _new_y = _m * _new_x + _b _new_y var ma_line1 = line.new(x1 = na, y1 = na, x2 = na, y2 = na, color = color.fuchsia, extend = extend.none, style=line.style_dashed) var ma_line2 = line.new(x1 = na, y1 = na, x2 = na, y2 = na, color = color.blue, extend = extend.none, style=line.style_dashed) var ma_line3 = line.new(x1 = na, y1 = na, x2 = na, y2 = na, color = color.orange, extend = extend.none, style=line.style_dashed) x1 = bar_index - 1 y1 = ma1[1] x2 = bar_index y2 = ma1 x3 = bar_index + extend y3 = f_y_given_x(x1, y1, x2, y2, x3) line.set_xy1(extendonoff1 ? ma_line1 : na, x = x1, y = y1) line.set_xy2(extendonoff1 ? ma_line1 : na, x = x3, y = y3) y22 = ma2[1] y33 = ma2 y44 = f_y_given_x(x1, y22, x2, y33, x3) line.set_xy1(extendonoff2 ? ma_line2 : na, x = x1, y = y22) line.set_xy2(extendonoff2 ? ma_line2 : na, x = x3, y = y44) y55 = ma3[1] y66 = ma3 y77 = f_y_given_x(x1, y55, x2, y66, x3) line.set_xy1(extendonoff3 ? ma_line3 :na, x = x1, y = y55) line.set_xy2(extendonoff3 ? ma_line3 : na, x = x3, y = y77)
Hayden's Advanced Relative Strength Index (RSI)
https://www.tradingview.com/script/R5lNnNRk-Hayden-s-Advanced-Relative-Strength-Index-RSI/
BarefootJoey
https://www.tradingview.com/u/BarefootJoey/
681
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Editor: © BarefootJoey // Authors: © dgtrd, LazyBear, LonesomeTheBlue, Koalafied_3, iFuSiiOnzZ, jmgneves, // Dicargo_Beam, balipour, whentotrade, Kent_RichProFit_93, chrism665, // mmoiwgg, TradingView, and a couple of authors that need identification. // //@version=5 indicator("Hayden's Advanced Relative Strength Index (RSI)",'Hayden\'s RSI',overlay=false, max_bars_back = 4999) // Groups grbfjt= "🦶 BarefootJoey Theme 🦶" grrsi='📈 Relative Strength Index 📈' grppl='🔖 Price Pivot Labels 🔖' grtl="📐 Trend Lines 📐" grsx="🧰 Stochastic [X] 🧰" grhts='🚦 Hayden Triple Trend State 🚦' grdv='🔀 Divergences 🔀' grrtpl="💱 RSI-to-Price Labels 💱" grtk="🎰 Tickers 🎰" // ----------------------- 🦶 BarefootJoey Theme ---------------------------- // // Gradient Bull/Bear brightgreen = #00ff0a green=color.green darkgreen = #1b5e20 brightred = #ff1100 red=color.red darkred = #801922 // Other yellow = #ffe500 fuchsia = #da00ff blue = #0006ff aqua = #00ffef gray=color.gray grayishgreen=#a5d6a7 grayishred=#faa1a4 // Default Variables pi=3.141592653589793238462643383279502884197169399375105820974944592307816406286 // ---------------------------------- RSI ------------------------------------// // Code Author: © Dicargo_Beam // Inputs src = input.source(close, "Source", group=grrsi) //, tooltip="" len = input(14, 'RSI Length', group=grrsi, tooltip="RSI = The indexed ratio of the average UP closes to the average DOWN closes over 'length' periods."+ "\nThe RSI formula requires at least 10 times 'length' time intervals to stabilize the RSI value. So if length = 14 bars, then we need 140 bars of prior data for the RSI value to be of use."+ "\nChart #17 (Page 71) suggests that using a 9-period RSI along with a 9-period stochastic is a method to identify strong multiple divergences indicating strong contra-trend retracements or possible trend reversals.") ad = input(false, 'Length-Volatility Adjusted?', group=grrsi, tooltip="(Page 8) You might check this box when you want to use RSI length other than 14 (default). As length becomes larger, the RSI value oscillates less vigorously. As length becomes smaller, the oscillations of the indicator become more pronounced. This feature changes the RSI by applying the appropriate function expression so that the RSI with a period value of 56 (=14*4) in a 15-minute time frame has the same value as the RSI with a period value of 14 in a 60-minute time frame.") cdob = input.string('Candle', title='Candle or Bar or Line?', options=['Candle', 'Bar', 'Line'], group=grrsi) uc = input(brightgreen, 'Bullish Color', group=grrsi, tooltip="(Page 56) 10 Lies That Traders Believe = Whenever the RSI is above 50, it is a bullish indication.") dc = input(brightred, 'Bearish Color', group=grrsi, tooltip="(Page 56) 10 Lies That Traders Believe = Whenever the RSI is below 50, it's a bearish indication.") // Calculations _rsi(src, len) => u = math.max(src - src[1], 0) d = math.max(src[1] - src, 0) rs = ta.rma(u, len) / ta.rma(d, len) res = 100 - 100 / (1 + rs) res _rma(src, length) => a = 1 / length sum = 0.0 sum := na(sum[1]) ? ta.sma(src, length) : a * src + (1 - a) * nz(sum[1]) sum u = math.max(src - src[1], 0) d = math.max(src[1] - src, 0) a = 1 / len ruh = a * math.max(high - close[1], 0) + (1 - a) * ta.rma(u, len)[1] rdh = (1 - a) * ta.rma(d, len)[1] rul = (1 - a) * ta.rma(u, len)[1] rdl = a * math.max(close[1] - low, 0) + (1 - a) * ta.rma(d, len)[1] function(rsi, len) => f = -math.pow(math.abs(math.abs(rsi - 50) - 50), 1 + math.pow(len / 14, 0.618) - 1) / math.pow(50, math.pow(len / 14, 0.618) - 1) + 50 rsiadvanced = if rsi > 50 f + 50 else -f + 50 rsiadvanced rsiha = 100 - 100 / (1 + ruh / rdh) rsila = 100 - 100 / (1 + rul / rdl) rsia = ta.rsi(src, len) rsih = if ad function(rsiha, len) else rsiha rsil = if ad function(rsila, len) else rsila rsi = if ad function(rsia, len) else rsia col = ta.change(rsi) > 0 ? uc : dc colc = if cdob == 'Candle' col colb = if cdob == 'Bar' col cold = if cdob == 'Line' col // Plots plotcandle(rsi[1], rsih, rsil, rsi, color=colc, wickcolor=colc, bordercolor=color.new(#000000,0), title='RSI Candles', editable=false) plotbar(rsi[1], rsih, rsil, rsi, color=colb, title='RSI Bars', editable=false) plot(rsi, title='RSI Line', color=cold, editable=false) // ----------------------------- Decimals ----------------------------------- // len_rsi=len targetsrc=src targetrsi = rsi price_by_rsi(level) => x1 = (len_rsi - 1) * (ta.rma(math.max(nz(targetsrc[1], targetsrc) - targetsrc, 0), len_rsi) * level / (100 - level) - ta.rma(math.max(targetsrc - nz(targetsrc[1], targetsrc), 0), len_rsi)) x1 >= 0 ? targetsrc + x1 : targetsrc + x1 * (100 - level) / level showperc = input(defval=true, title='Show Percentage & Price Change Labels?', group=grppl, tooltip="Hover over labels for additional info.") pricedecimals= input.int(defval=2, title='Price Decimals', minval=0, maxval=10, group=grppl, tooltip="This Price Decimals setting also applies to all other Price labels/data") percentdecimals= input.int(defval=2, title='% Decimals', minval=0, maxval=10, group=grppl, tooltip="This % Decimals setting also applies to all other Percent labels/data") truncateprice(number, pricedecimals) => factor = math.pow(10, pricedecimals) int(number * factor) / factor percenttruncate(number, percentdecimals) => factor = math.pow(10, percentdecimals) int(number * factor) / factor percent(n1, n2) => ((n1 - n2) / n2) * 100 // ----------------------------- Trend Lines -------------------------------- // // Possible error with higher timeframes calculating incorrect slope & angle due to BarefootJoey calculations // Code author: © LonesomeTheBlue n = bar_index showtl = input(false, "Show Trend Lines?", group=grtl, tooltip="(Page 48) The most common pattern is the triangle formation, which often indicates a pending explosive move. However, there is often a false breakout before the real move!") prd = input.int(defval=8, title='Pivot Point Period', minval=5, maxval=50, group=grtl) PPnum = input.int(defval=3, title='Number of Pivot Point to check', minval=2, maxval=3, group=grtl) trendstyle = input.string(defval='.....', title='Trend Line Style', options=['.....', '-----'], group=grtl) float ph = na float pl = na ph := ta.pivothigh(rsi, prd, prd) pl := ta.pivotlow(rsi, prd, prd) getloc(bar_i) => _ret = bar_index + prd - bar_i _ret t1pos = ta.valuewhen(ph, bar_index, 0) t1val = nz(rsi[getloc(t1pos)]) t2pos = ta.valuewhen(ph, bar_index, 1) t2val = nz(rsi[getloc(t2pos)]) t3pos = ta.valuewhen(ph, bar_index, 2) t3val = nz(rsi[getloc(t3pos)]) b1pos = ta.valuewhen(pl, bar_index, 0) b1val = nz(rsi[getloc(b1pos)]) b2pos = ta.valuewhen(pl, bar_index, 1) b2val = nz(rsi[getloc(b2pos)]) b3pos = ta.valuewhen(pl, bar_index, 2) b3val = nz(rsi[getloc(b3pos)]) getloval(l1, l2) => _ret1 = l1 == 1 ? b1val : l1 == 2 ? b2val : l1 == 3 ? b3val : 0 _ret2 = l2 == 1 ? b1val : l2 == 2 ? b2val : l2 == 3 ? b3val : 0 [_ret1, _ret2] getlopos(l1, l2) => _ret1 = l1 == 1 ? b1pos : l1 == 2 ? b2pos : l1 == 3 ? b3pos : 0 _ret2 = l2 == 1 ? b1pos : l2 == 2 ? b2pos : l2 == 3 ? b3pos : 0 [_ret1, _ret2] gethival(l1, l2) => _ret1 = l1 == 1 ? t1val : l1 == 2 ? t2val : l1 == 3 ? t3val : 0 _ret2 = l2 == 1 ? t1val : l2 == 2 ? t2val : l2 == 3 ? t3val : 0 [_ret1, _ret2] gethipos(l1, l2) => _ret1 = l1 == 1 ? t1pos : l1 == 2 ? t2pos : l1 == 3 ? t3pos : 0 _ret2 = l2 == 1 ? t1pos : l2 == 2 ? t2pos : l2 == 3 ? t3pos : 0 [_ret1, _ret2] var line l1 = na var label l1a = na var line l2 = na var label l2a = na var line l3 = na var label l3a = na var line t1 = na var label t1a = na var line t2 = na var label t2a = na var line t3 = na var label t3a = na line.delete(l1) label.delete(l1a[1]) line.delete(l2) label.delete(l2a[1]) line.delete(l3) label.delete(l3a[1]) line.delete(t1) label.delete(t1a[1]) line.delete(t2) label.delete(t2a[1]) line.delete(t3) label.delete(t3a[1]) countlinelo = 0 countlinehi = 0 for p1 = 1 to PPnum - 1 by 1 uv1 = 0.0 uv2 = 0.0 up1 = 0 up2 = 0 for p2 = PPnum to p1 + 1 by 1 [val1, val2] = getloval(p1, p2) [pos1, pos2] = getlopos(p1, p2) if val1 > val2 diff = (val1 - val2) / (pos1 - pos2) hline = val2 + diff lloc = bar_index lval = src valid = true for x = pos2 + 1 - prd to bar_index by 1 if nz(rsi[getloc(x + prd)]) < hline valid := false valid lloc := x lval := hline hline += diff hline if valid uv1 := hline uv2 := val2 up1 := lloc up2 := pos2 break dv1 = 0.0 dv2 = 0.0 dp1 = 0 dp2 = 0 for p2 = PPnum to p1 + 1 by 1 [val1, val2] = gethival(p1, p2) [pos1, pos2] = gethipos(p1, p2) if val1 < val2 diff = (val2 - val1) / (pos1 - pos2) hline = val2 - diff lloc = bar_index lval = rsi valid = true for x = pos2 + 1 - prd to bar_index by 1 if nz(rsi[getloc(x + prd)]) > hline valid := false break lloc := x lval := hline hline -= diff hline if valid dv1 := hline dv2 := val2 dp1 := lloc dp2 := pos2 break if up1 != 0 and up2 != 0 and showtl countlinelo += 1 l1 := countlinelo == 1 ? line.new(up2 - prd, uv2, up1, uv1, color=green, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : l1 l2 := countlinelo == 2 ? line.new(up2 - prd, uv2, up1, uv1, color=green, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : l2 l3 := countlinelo == 3 ? line.new(up2 - prd, uv2, up1, uv1, color=green, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : l3 l3 if dp1 != 0 and dp2 != 0 and showtl countlinehi += 1 t1 := countlinehi == 1 ? line.new(dp2 - prd, dv2, dp1, dv1, color=red, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : t1 t2 := countlinehi == 2 ? line.new(dp2 - prd, dv2, dp1, dv1, color=red, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : t2 t3 := countlinehi == 3 ? line.new(dp2 - prd, dv2, dp1, dv1, color=red, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : t3 t3 // ----------------------------- 45 WMA/EMA --------------------------------- // // Code by: © Tradingview r45ma = input.string('WMA', title='RSI 45 WMA or EMA?', options=['WMA', 'EMA'], group=grrsi, tooltip='There is some inconsistency in the book due to charts (Appendix C) citing use of a 45 EMA on RSI, and text (page 107 & 108) citing use of a 45 WMA on RSI; take your pick.') rwma=ta.wma(rsi,45) rema=ta.ema(rsi,45) r45maout= r45ma == 'WMA' ? rwma : rema rwmacol= r45maout>r45maout[1] ? green : red rwmacolv= r45maout>r45maout[1] ? brightgreen : brightred rwmafill=plot(r45maout, 'RSI 45 WMA/EMA', color.new(rwmacol, 0)) // ------------------------------ 9 SMA ------------------------------------- // // Code by: © Tradingview rsma=ta.sma(rsi,9) rsmacol=rsma>rsma[1] ? green : red rsmacolv=rsma>rsma[1] ? brightgreen : brightred rsmafill=plot(rsma, 'RSI 9 SMA', color=color.new(rsmacol, 50)) // ---------------------- Stochastic of X Signals --------------------------- // // Idea by: © dgtrd // Code by: © Tradingview built-in scripts (unless otherwise noted) showstoch=input(true, "Show Stochastic [X]?", group=grsx) indi = input.string(defval='RSI', title='[X]=', group=grsx, options=['Price/Source','Volume','RSI', 'scRSI', 'CCI', 'OBV', 'Momentum', 'MFI', 'ROSI', 'Slope', 'TSI', 'RVI', 'CMO', 'CMF', 'CO', 'AO', 'DPO', 'ROC', 'SMIeO', 'UO', 'W%R', 'PPO', 'HAO','RMI'], tooltip='CMF, OBV, MFI, CO, and Volume will not generate signals on assets that have no volume, like $DJI and other indexes.\nChart #17 (Page 71) suggests that using a 9-period RSI along with a 9-period stochastic is a method that can be used to identify strong multiple divergences indicating strong contra-trend retracements or possible trend reversals.') Src = input(defval=close, title='Source', group=grsx) rsilen = input.int(defval= 14, title='RSI Length', minval=1, group=grsx) domcycle = input.int(20, minval=10, title='scRSI Dominant Cycle Length', group=grsx) ccilen = input.int(defval=20, title='CCI Length', minval=1, group=grsx) momlen = input.int(defval=10, title='Momentum Length', minval=1, group=grsx) mfilen = input.int(defval=14, title='MFI Length', minval=1, group=grsx) rosilen=input.int(defval=14, title="ROSI Length", group=grsx) rocP=input.int(defval=3, title="ROSI Rate of Change", group=grsx) slopelen=input.int(defval=14, title="Slope Length", group=grsx) SlopePeriod = input.int(1,title="Slope Period", group=grsx) r=input(25, title="TSI Smoothing 1", group=grsx) s=input(13, title="TSI Smoothing 2", group=grsx) rvilen=input.int(defval=14, title="RVI Length", group=grsx) rvi_dev_len = input(10, title="RVI Std. Dev. Length", group=grsx) cmolen=input.int(defval=9, title="Chande Momentum Osc Length", group=grsx) cmflength = input.int(20, "Chaikin Money Flow Length", minval=1, group=grsx) choshort = input.int(3, minval=1, title="Chaikin Money Osc (CO) Fast Length", group=grsx) cholong = input.int(10, minval=1, title="Chaikin Money Osc (CO) Slow Length", group=grsx) dperiod_ = input.int(21, title="DPO Length", minval=1, group=grsx) isCentered = input(false, title="DPO Centered?", group=grsx) rlength = input.int(9, "Rate of Change Length", minval=1, group=grsx) slonglen = input.int(20, minval=1, title="SMIeO Long Length", group=grsx) sshortlen = input.int(5, minval=1, title="SMIeO Short Length", group=grsx) ssiglen = input.int(5, minval=1, title="SMIeO Signal Line Length", group=grsx) ulength1 = input.int(7, minval=1, title = "Ultimate Osc Fast Length", group=grsx) ulength2 = input.int(14, minval=1, title = "Ultimate Osc Middle Length", group=grsx) ulength3 = input.int(28, minval=1, title = "Ultimate Osc Slow Length", group=grsx) plength = input(title="William's % R Length", defval=14, group=grsx) pshortlen=input.int(10, "PPO Short Length", minval=1, group=grsx) plonglen=input.int(21, "PPO Long Length", minval=1, group=grsx) pexp = input(false, "PPO Exponential?", group=grsx) bbd_src = input.source(hlc3,"Heikin Ashi Osc Source", group=grsx, tooltip='Recommended setting: hlc3') bbd_avg = input.int(5,'Heikin Ashi Osc Moving Average =', minval=1, group=grsx) rlen = input.int(minval=1,defval=14,title="Relative Momentum Index Length", group=grsx) // Different 'one-liner' Oscillator Calculations Rsi = ta.rsi(Src, rsilen) Cci = ta.cci(Src, ccilen) Mom = Src - Src[momlen] // ta.cci(Src, momlen) Mfi = ta.mfi(Src, mfilen) Rosi = ta.roc(ta.rsi(Src,rosilen),rocP) ao = ta.sma(hl2,5) - ta.sma(hl2,34) Chosc = ta.ema(ta.accdist, choshort) - ta.ema(ta.accdist, cholong) // ROC source = Src roc = 100 * (source - source[rlength])/source[rlength] // PPO esma(source, length)=> ps = ta.sma(source, length) pe = ta.ema(source, length) pexp ? pe : ps pshort = esma(Src, pshortlen) plong = esma(Src, plonglen) po = (pshort - plong)/plong*100 // W % R _pr(length) => pmax = ta.highest(plength) pmin = ta.lowest(plength) 100 * (Src - pmax) / (pmax - pmin) percentR = _pr(plength) // SMIO serg = ta.tsi(close, sshortlen, slonglen) ssig = ta.ema(serg, ssiglen) sosc = serg - ssig // UO average(ubp, utr_, ulength) => math.sum(ubp, ulength) / math.sum(utr_, ulength) uhigh_ = math.max(high, close[1]) ulow_ = math.min(low, close[1]) ubp = close - ulow_ utr_ = uhigh_ - ulow_ avg7 = average(ubp, utr_, ulength1) avg14 = average(ubp, utr_, ulength2) avg28 = average(ubp, utr_, ulength3) uout = 100 * (4*avg7 + 2*avg14 + avg28)/7 // DPO barsback = dperiod_/2 + 1 ma = ta.sma(close, dperiod_) dpo = isCentered ? close[barsback] - ma : close - ma[barsback] // Slope SMAs= ta.sma(Src, slopelen) Slope = (SMAs - SMAs[SlopePeriod]) / SlopePeriod // TSI m=Src-Src[1] Tsi=100*(ta.ema(ta.ema(m,r),s)/ta.ema(ta.ema(math.abs(m), r),s)) // RVI rvi_dev = ta.stdev(Src, rvi_dev_len) upper = ta.ema(ta.change(Src) <= 0 ? 0 : rvi_dev, rvilen) lower = ta.ema(ta.change(Src) > 0 ? 0 : rvi_dev, rvilen) Rvi = upper / (upper + lower) * 100 // CMO momm = ta.change(Src) f1(m) => m >= 0.0 ? m : 0.0 f2(m) => m >= 0.0 ? 0.0 : -m m1 = f1(momm) m2 = f2(momm) sm1 = math.sum(m1, cmolen) sm2 = math.sum(m2, cmolen) percentCMO(nom, div) => 100 * nom / div chandeMO = percentCMO(sm1-sm2, sm1+sm2) // CMF var cumVol = 0. cumVol += nz(volume) ad1 = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume Cmf = math.sum(ad1, cmflength) / math.sum(volume, cmflength) // Smoothed Cyclic RSI // Code by: © whentotrade crsi = 0.0 cyclelen = domcycle / 2 vibration = 10 leveling = 10.0 cyclicmemory = domcycle * 2 torque = 2.0 / (vibration + 1) phasingLag = (vibration - 1) / 2.0 up = ta.rma(math.max(ta.change(Src), 0), cyclelen) down = ta.rma(-math.min(ta.change(Src), 0), cyclelen) vrsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down) crsi := torque * (2 * vrsi - vrsi[phasingLag]) + (1 - torque) * nz(crsi[1]) lmax = -999999.0 lmin = 999999.0 for i = 0 to cyclicmemory - 1 by 1 if nz(crsi[i], -999999.0) > lmax lmax := nz(crsi[i]) lmax else if nz(crsi[i], 999999.0) < lmin lmin := nz(crsi[i]) lmin mstep = (lmax - lmin) / 100 aperc = leveling / 100 db = 0.0 for steps = 0 to 100 by 1 testvalue = lmin + mstep * steps above = 0 below = 0 for m = 0 to cyclicmemory - 1 by 1 below += (crsi[m] < testvalue ? 1 : 0) below ratio = below / cyclicmemory if ratio >= aperc db := testvalue break else continue ubs = 0.0 for steps = 0 to 100 by 1 testvalue = lmax - mstep * steps above = 0 for m = 0 to cyclicmemory - 1 by 1 above += (crsi[m] >= testvalue ? 1 : 0) above ratio = above / cyclicmemory if ratio >= aperc ubs := testvalue break else continue // Heikin Ashi Oscillator // Code by: © Kent_RichProFit_93 Y(X, N, M) => alpha = M / N S2 = 0.0 S2 := nz(S2[1]) - nz(X[N]) + X M2 = 0.0 M2 := na(X[N]) ? na : S2 / N A2 = 0.0 A2 := na(A2[1]) ? M2 : alpha * X + (1 - alpha) * nz(A2[1]) A2 bbd_raw = Y(bbd_src, 5, 1) - Y(bbd_src, 13, 1) bbd = (bbd_raw - Y(bbd_raw, 3, 1)) * 100 // RMI // Code by: © chrism665 rmisrc = Src rmi(src, len) => up = math.sum(math.max(ta.change(src), 0), len) down = math.sum(-math.min(ta.change(src), 0), len) rmi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down) rmi rmiout = rmi(rmisrc,rlen) // Which plot to display? indiout = indi=='HAO'? bbd : indi == 'RSI' ? Rsi : indi == 'scRSI' ? crsi : indi == 'CCI' ? Cci : indi == 'Momentum' ? Mom : indi == 'MFI' ? Mfi : indi == 'ROSI' ? Rosi : indi == 'Slope' ? Slope : indi == 'TSI' ? Tsi : indi == 'RVI' ? Rvi : indi == 'CMO' ? chandeMO : indi == 'CMF' ? Cmf : indi == 'CO' ? Chosc : indi == 'AO' ? ao : indi == 'DPO' ? dpo : indi == 'ROC' ? roc : indi == 'SMIeO' ? sosc : indi == 'UO' ? uout : indi == 'W%R' ? percentR : indi == 'PPO' ? po : indi == 'Price/Source' ? Src : indi == 'Volume' ? volume : indi == 'RMI' ? rmiout : ta.obv // Stochastic of X smoothKr = input.int(3, "Stochastic [X] K Length", minval=1, group=grsx) smoothDr = input.int(3, "Stochastic [X] D Length", minval=1, group=grsx) lengthStoch = input.int(14, "Stochastic [X] Length", minval=1, group=grsx) stochtransp = input.int(70, "Stochastic [X] Transparency", minval=0, maxval=100, group=grsx) rsi1 = indiout kr = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothKr) dr = ta.sma(kr, smoothDr) fkr=plot(showstoch?kr:na, title="Stochastich [X] K Line", color=color.new(color.blue, stochtransp), display=display.none) fdr=plot(showstoch?dr:na, title="Stochastich [X] D Line", color=color.new(color.orange, stochtransp), display=display.none) fillcol=kr>dr ? color.blue : color.orange fill(fkr,fdr, color=showstoch?color.new(fillcol, stochtransp):na) plot(ta.cross(kr, dr) and showstoch ? dr : na, title="Stochastic [X] K-D Crosses", color = color.new(ta.crossover(kr,dr)?color.blue:color.orange,0) , style = plot.style_circles, linewidth = 1, display=display.none) // ------------------------- Trend State ------------------------------------ // // Code Author: © Koalafied_3 showtrend = input(true, title='Show Hayden triple trend state H-line fill?',group=grhts, tooltip ="Check this box if you want to see the Bull, Bear, or Chop trend state background according to Hayden.\n(Page 56) 10 Lies That Traders Believe = The RSI is unable to indicate trend direction, because it's only a momentum indicator.") showbc = input(true, title='Show Hayden triple trend state Chart Bar Color?',group=grhts) ts1 = input.float(defval=67, title="Precise Bullish RSI Crossover 66 to 68", minval=66, maxval=68, step=0.001, group=grhts, tooltip="End of chop. Popular: 66, 66.666, or 67") ts2 = input.float(defval=33, title="Precise Bearish RSI Crossunder 32 to 34", minval=32, maxval=34, step=0.001, group=grhts, tooltip="End of chop. Popular: 34, 33.333, or 33") ts1a = input.float(defval=61, title="Precise Bullish RSI Crossover 60 to 62", minval=60, maxval=62, step=0.001, group=grhts, tooltip="End of bearish trend. Popular: 61, 60.618, 60.5, or 60") ts2a = input.float(defval=39, title="Precise Bearish RSI Crossunder 38 to 40", minval=38, maxval=40, step=0.001, group=grhts, tooltip="End of bullish trend. Popular: 39, 39.5, 39.618, or 40") // Trend State var state = 0 if ta.crossover(rsi, ts1) state := 1 state if ta.crossunder(rsi, ts2) state := 2 state if state == 1 and ta.crossunder(rsi, ts2a) state := 3 state if state == 2 and ta.crossover(rsi, ts1a) state := 3 state state := state // ------------------- Hayden & Fibonacci H Lines --------------------------- // hundred=hline(100, title="100 H-Line", color=color.new(uc,70), editable=true, display=display.none) eighty=hline(85.41, color=color.new(uc,70), editable=false) seventysix=hline(76.30, color=color.new(uc,70), editable=false) sixtysix=hline(ts1, color=color.new(uc,70), editable=false) sixty=hline(ts1a, color=color.new(gray,50), editable=false) fifty=hline(50, color=color.new(gray,50), editable=false) fourty=hline(ts2a, color=color.new(gray,50), editable=false) thirtythree=hline(ts2, color=color.new(brightred,70), editable=false) twentythree=hline(23.61, color=color.new(brightred,70), editable=false) twenty=hline(14.59, color=color.new(brightred,70), editable=false) zero=hline(0, title="0 H-Line", color=color.new(brightred,70), editable=true, display=display.none) fill(sixty,sixtysix, color=showtrend and state == 3 ? color.new(red,80) : na) fill(thirtythree,fourty, color=showtrend and state == 3 ? color.new(green,80) : na) fill(fifty, hundred, color=showtrend and state == 1 ? color.new(green,80) : na) fill(fifty, zero, color=showtrend and state == 2 ? color.new(red,80) : na) fill(fifty, sixty, color=showtrend and state == 2 ? color.new(darkred,80) : na) fill(fifty, fourty, color=showtrend and state == 1 ? color.new(darkgreen,80) : na) //---------------------------- RSI Divergences ------------------------------ // // Code Author: Currently unknown. This divergence code is all over TradingView and // Im not sure who the original author is. Please help identify the // author if you know who it is. lbR = input(title="Pivot Lookback Right", defval=3, group='🔀 Divergences 🔀', tooltip="(Page 68) The price that generated the divergence often becomes a key number used to identify temporary support or resistance.") lbL = input(title="Pivot Lookback Left", defval=3, group='🔀 Divergences 🔀') rangeUpper = input(title="Max of Lookback Range", defval=100, group='🔀 Divergences 🔀') rangeLower = input(title="Min of Lookback Range", defval=3, group='🔀 Divergences 🔀') plotBull = input(title="Plot Bullish", defval=false, group='🔀 Divergences 🔀', tooltip="(Page 65) Valid bullish divergences only occur in bear markets. \n(Page 56) 10 Lies That Traders Believe = A bullish divergence is an indication that a downtrend is about to end. \n(Page 47) Going long when a bullish divergence makes its appearance is a certain way to make small profits and generate large losses!") plotHiddenBull = input(title="Plot Hidden Bullish", defval=false, group='🔀 Divergences 🔀', tooltip="(Page 82) An Uptrend is indicated when the chart shows Hidden bullish divergence.") plotBear = input(title="Plot Bearish", defval=false, group='🔀 Divergences 🔀', tooltip="(Page 65) Valid bearish divergences only occur in bull markets. \n(Page 56) 10 Lies That Traders Believe = A bearish divergence is an indication that an uptrend is about to end.") plotHiddenBear = input(title="Plot Hidden Bearish", defval=false, group='🔀 Divergences 🔀', tooltip="(Page 82) A Downtrend is indicated when the chart shows Hidden bearish divergence.") bearColor = red bullColor = green hiddenBullColor = color.new(green, 50) hiddenBearColor = color.new(red, 50) noneColor = color.new(color.white, 100) osc = rsi plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true _inRange(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper // Regular Bullish // Osc: Higher Low oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Lower Low priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1) bullCond = plotBull and priceLL and oscHL and plFound and (state==2 or state==3)// Hayden trend state filter page 72 plot(plFound ? osc[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=1, editable=false, color=(bullCond ? bullColor : noneColor)) // Hidden Bullish // Osc: Lower Low oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Higher Low priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1) hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound and (state==1 or state==3)// Hayden trend state filter page 72 plot(plFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish", linewidth=2, editable=false, color=(hiddenBullCond ? hiddenBullColor : noneColor)) // Regular Bearish // Osc: Lower High oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Higher High priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1) bearCond = plotBear and priceHH and oscLH and phFound and (state==1 or state==3)// Hayden trend state filter page 72 plot(phFound ? osc[lbR] : na, offset=-lbR, title="Regular Bearish", linewidth=1, editable=false, color=(bearCond ? bearColor : noneColor)) // Hidden Bearish // Osc: Higher High oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Lower High priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1) hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound and (state==2 or state==3)// Hayden trend state filter page 72 plot(phFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish", linewidth=2, editable=false, color=(hiddenBearCond ? hiddenBearColor : noneColor)) // ------------------ RSI Price & Percentage Change Pivots ------------------ // // Code Author: © mmoiwgg // Pivot Lookback pppsize = input.string(size.small, "RSI Price & Percentage Change Pivots Label Size", [size.tiny, size.small, size.normal], group=grppl) leftbars = input.int(5, minval=1, title='Bars to the left', group=grppl) rightbars = input.int(5, minval=1, title='Bars to the right', group=grppl) // Pivot Prices phigh = ta.pivothigh(high, leftbars, rightbars) plow = ta.pivotlow(low, leftbars, rightbars) // Pivot RSI rsiphigh = ta.pivothigh(rsi, leftbars, rightbars) rsiplow = ta.pivotlow(rsi, leftbars, rightbars) //Pivot % //Inputs zigperiod = input(defval=8, title='ZigZag Period', group=grppl, tooltip="The higher the number, the fewer the labels") showline = input(defval=false, title='Show Zig Lines?', group=grppl) zigstyle = input.string(defval='-----', title='Zig Zag Line Style', options=['.....', '-----'], group=grppl) upcolor = input(defval=green, title='Bullish Color', group=grppl) downcolor = input(defval=red, title='Bearish Color', group=grppl) zigwidth = 1 elen = 5 esrc = close out = ta.ema(esrc, elen) //Float float highs = ta.highestbars(rsi, zigperiod) == 0 ? rsi : na float lows = ta.lowestbars(rsi, zigperiod) == 0 ? rsi : na //Variables var dir1 = 0 iff_1 = lows and na(highs) ? -1 : dir1 dir1 := highs and na(lows) ? 1 : iff_1 var max_array_size = 10 var ziggyzags = array.new_float(0) add_to_zigzag(pointer, value, bindex) => array.unshift(pointer, bindex) array.unshift(pointer, value) if array.size(pointer) > max_array_size array.pop(pointer) array.pop(pointer) update_zigzag(pointer, value, bindex, dir) => if array.size(pointer) == 0 add_to_zigzag(pointer, value, bindex) else if dir == 1 and value > array.get(pointer, 0) or dir == -1 and value < array.get(pointer, 0) array.set(pointer, 0, value) array.set(pointer, 1, bindex) 0. dir1changed = ta.change(dir1) if highs or lows if dir1changed add_to_zigzag(ziggyzags, dir1 == 1 ? highs : lows, bar_index) else update_zigzag(ziggyzags, dir1 == 1 ? highs : lows, bar_index, dir1) // Retrace Targets: (A-C)+B, see book page 75: "We can also calculate the upside target by obtaining the difference between points "B" and "Ref' rtt=(ta.valuewhen(highs or lows,close,2) - ta.valuewhen(highs or lows,close,0)) + ta.valuewhen(highs or lows,close,1) // Stop Loss: Calculated as the high for the leftbars variable ('Bars to the left' setting) lsl = ta.lowest(low,leftbars) ssl = ta.highest(high,leftbars) // Risk Reward Ratio rrri = (percent(rtt, ta.valuewhen(highs or lows,close,0)))/(percent(highs?ssl:lsl, ta.valuewhen(highs or lows,close,0))) rrr = math.abs(rrri) if array.size(ziggyzags) >= 6 var line zzline1 = na var label zzlabel1 = na float val = array.get(ziggyzags, 0) int point = math.round(array.get(ziggyzags, 1)) if ta.change(val) or ta.change(point) float val1 = array.get(ziggyzags, 2) int point1 = math.round(array.get(ziggyzags, 3)) plabel = "RSI ∆y " + str.tostring(truncateprice(val-val1, pricedecimals)) + ", " + str.tostring(percenttruncate(percent(val, val1),percentdecimals)) + ' %' // Change in X + "\n⏱ ∆x " + str.tostring(point - point1) + " bars" // RSI + "\n📍 RSI " + str.tostring(percenttruncate(rsi,percentdecimals)) // Targets + "\n🎯 " + str.tostring(rtt) + ", " + str.tostring(percenttruncate(percent(rtt, ta.valuewhen(highs or lows,close,0)),percentdecimals)) + " %" // Stop + "\n🛑 " + str.tostring(highs?ssl:lsl) + ", " + str.tostring(percenttruncate(percent(highs?ssl:lsl, ta.valuewhen(highs or lows,close,0)),percentdecimals)) + " %" // Reward:Risk Ratio + "\nReward : Risk = " + str.tostring(percenttruncate(rrr, percentdecimals)) + " : 1 "// + (rrr>2 and rrr<3 ? "✅" : rrr>3 ? "💰" : "⛔" ) // useful easteregg if you follow a >2:1 Reward:Risk ratio if ta.change(val1) == 0 and ta.change(point1) == 0 line.delete(zzline1) label.delete(zzlabel1) if showline zzline1 := line.new(x1=point, x2=point1, y1=val, y2=val1, color=dir1 == 1 ? upcolor : downcolor, width=zigwidth, style=zigstyle == '-----' ? line.style_dashed : line.style_dotted) zzline1 labelcol = dir1 == 1 ? array.get(ziggyzags, 0) > out ? upcolor : downcolor : array.get(ziggyzags, 0) < out ? downcolor : upcolor if showperc zzlabel1 := label.new(x=point, y=val, text=str.tostring(truncateprice(close,pricedecimals)), size=pppsize, color=color.new(labelcol, 100), textcolor=dir1 == 1 ? downcolor : upcolor, style=dir1 == 1 ? label.style_label_down : label.style_label_up, tooltip=plabel) zzlabel1 // ------------------------- RSI Price Targets ------------------------------ // // Code Author: © jmgneves showrtp = input(true, "Show RSI-to-Price Labels?", group=grrtpl, tooltip="Hover over labels for additional info.") rtpoffset =input(5, title="RSI-to-Price Label Horizontal Offset", group=grrtpl, tooltip ="(Page 56) 10 Lies That Traders Believe = It is not possible to use the RSI to set price objectives.") rtpsize = input.string(size.small, "RSI-to-Price Label Size", [size.tiny, size.small, size.normal], group=grrtpl) // [BFJ] Fib variables fr1 = 0 fr3 = 14.59 fr5 = 23.61 fr7 = ts2 fr9 = ts2a fr11 = 50 fr13 = ts1a fr16 = ts1 fr18 = 76.3 fr20 = 85.41 fr21 = 100 // Number of Decimals for Labels truncatepercent(number, percentdecimals) => factor = math.pow(10, percentdecimals) int(number * factor) / factor // RSI to Price Labels var label la0 = na if showrtp la0 := label.new(n + rtpoffset,fr3, str.tostring(truncateprice(price_by_rsi(fr3), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=state == 2 ? dc : na, tooltip="📍 RSI " + str.tostring(fr3) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr3)-close, pricedecimals))+'\n~1 : 6') label.delete(la0[1]) var label la1c = na if showrtp la1c := label.new(n + rtpoffset,fr5, str.tostring(truncateprice(price_by_rsi(fr5), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=state == 2 ? dc : na, tooltip="📍 RSI " + str.tostring(fr5) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr5)-close, pricedecimals))+'\n~1 : 3') label.delete(la1c[1]) var label la1b = na if showrtp la1b := label.new(n + rtpoffset,fr7, str.tostring(truncateprice(price_by_rsi(fr7), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor= state == 2 ? dc : state == 3 ? uc : na, tooltip="📍 RSI " + str.tostring(fr7) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr7)-close, pricedecimals))+'\n1 : 2') label.delete(la1b[1]) var label la2 = na if showrtp la2 := label.new(n + rtpoffset,fr9,str.tostring(truncateprice(price_by_rsi(fr9), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=state == 1 or state == 3? uc : state == 2 ? dc : na, tooltip="📍 RSI " + str.tostring(fr9) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr9)-close, pricedecimals))+'\n~1 : 1.618') label.delete(la2[1]) var label la3 = na if showrtp la3 := label.new(n + rtpoffset,fr11, str.tostring(truncateprice(price_by_rsi(fr11), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=rsi > 50 ? uc : dc, tooltip="📍 RSI " + str.tostring(fr11) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr11)-close, pricedecimals))+'\n1 : 1') label.delete(la3[1]) var label la4 = na if showrtp la4 := label.new(n + rtpoffset,fr13,str.tostring(truncateprice(price_by_rsi(fr13), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=state == 2 or state == 3 ? dc : state == 1 ? uc : na, tooltip="📍 RSI " + str.tostring(fr13) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr13)-close, pricedecimals))+'\n~1.618 : 1') label.delete(la4[1]) var label la4b = na if showrtp la4b := label.new(n + rtpoffset,fr16, str.tostring(truncateprice(price_by_rsi(fr16), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=state == 1 ? uc :state == 3 ? dc : na, tooltip="📍 RSI " + str.tostring(fr16) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr16)-close, pricedecimals))+'\n2 : 1') label.delete(la4b[1]) var label la5b = na if showrtp la5b := label.new(n + rtpoffset,fr18, str.tostring(truncateprice(price_by_rsi(fr18), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=state == 1 ? uc : na, tooltip="📍 RSI " + str.tostring(fr18) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr18)-close, pricedecimals))+'\n~3 : 1') label.delete(la5b[1]) var label la6 = na if showrtp la6 := label.new(n + rtpoffset,fr20, str.tostring(truncateprice(price_by_rsi(fr20), pricedecimals)), color=color.new(color.white, 100), style=label.style_none, size=rtpsize, textcolor=state == 1 ? uc : na, tooltip="📍 RSI " + str.tostring(fr20) + "\n∆y " + str.tostring(truncateprice(price_by_rsi(fr20)-close, pricedecimals))+'\n~6 : 1') label.delete(la6[1]) // ------------------------ Advanced Data Ticker ---------------------------- // showticker=input(true, "Show Tickers?", group=grtk) datatype = input.string('RSI MA Price', title='Ticker 1 Data Source?', options=['RSI to Price', "RSI MA Price", 'Trend End', 'Trend State', 'ADX & DI+/-', "Watermark", "Volatility", "None"], group=grtk) datatype2 = input.string('RSI to Price', title='Ticker 2 Data Source?', options=['RSI to Price', "RSI MA Price", 'Trend End', 'Trend State', 'ADX & DI+/-', "Watermark", "Volatility", "None"], group=grtk) // Emoji Rating erating= (r45maout>r45maout[1] and rsma>rsma[1])?" 🚀 ": (r45maout<r45maout[1] and rsma<rsma[1])?" 💀 ":" 🪓 " // RSI to Price Target Inputs obLevel1 = input.float(80, title='RSI to Price Target 1', minval=1, maxval=99, group=grtk, tooltip="Table #8 Fibonacci Bullish RSI Levels: 61.8, 66.67, 76.30, 85.42, 90.98, 94.43\n(Page 56) 10 Lies That Traders Believe = The RSI will generally 'top out' somewhere around the 70 level.") osLevel1 = input.float(20, title='RSI to Price Target 2', minval=1, maxval=99, group=grtk, tooltip="Table #8 Fibonacci Bearish RSI Levels: 38.2, 33.33, 23.61, 14.59, 9.02, 5.57\n(Page 56) 10 Lies That Traders Believe = The RSI will generally 'bottom out' somewhere around the 30 level.") // Functional Math and RSI Targets // Code Author: @ LazyBear ep = 2 * 14 - 1 auc = ta.ema(math.max(src - src[1], 0), ep) adc = ta.ema(math.max(src[1] - src, 0), ep) x1 = (14 - 1) * (adc * obLevel1 / (100 - obLevel1) - auc) longrsitarget = x1 >= 0 ? src + x1 : src + x1 * (100 - obLevel1) / obLevel1 x2 = (14 - 1) * (adc * osLevel1 / (100 - osLevel1) - auc) shortrsitarget = x2 >= 0 ? src + x2 : src + x2 * (100 - osLevel1) / osLevel1 // Text tickerstateob=(str.tostring(obLevel1) + " 🎯 = " + str.tostring(truncateprice(longrsitarget,pricedecimals))) tickerstateos=(str.tostring(osLevel1) + " 🎯 = " + str.tostring(truncateprice(shortrsitarget,pricedecimals))) // Plots roblcol=input.color(aqua, title="RSI to Price Target 1 Color", group=grtk) roslcol=input.color(fuchsia, title="RSI to Price Target 2 Color", group=grtk) // Shape Plots plotshape(obLevel1, title="User-defined RSI to Price Target 1", location=location.absolute, style=shape.cross, color=datatype=="RSI to Price" or datatype2=="RSI to Price" ?color.new(roblcol, 0):na, show_last=1) plotshape(osLevel1, title="User-defined RSI to Price Target 2", location=location.absolute, style=shape.cross, color=datatype=="RSI to Price" or datatype2=="RSI to Price" ?color.new(roslcol, 0):na, show_last=1) // RSI MA Price Targets lstop2=r45maout sstop2=rsma // RWMA Math // Code Author: @ LazyBear x122 = (14 - 1) * (adc * lstop2 / (100 - lstop2) - auc) rwmatarget = x122 >= 0 ? src + x122 : src + x122 * (100 - lstop2) / lstop2 // RSMA Math // Code Author: @ LazyBear x132 = (14 - 1) * (adc * sstop2 / (100 - sstop2) - auc) rsmatarget = x132 >= 0 ? src + x132 : src + x132 * (100 - sstop2) / sstop2 // Text tickerstaterwma=("45 "+ (r45ma == 'WMA' ? "WMA" : "EMA") + " = " + str.tostring(truncateprice(rwmatarget, pricedecimals))) + " " + erating tickerstatersma=("9 SMA = " + str.tostring(truncateprice(rsmatarget, pricedecimals))) // Text Color rwmatcol2=rwmacolv rsmatcol2=rsmacolv // Trend Ends Text tickerstateendbull=("🐮 Bullish above " + str.tostring(truncateprice(price_by_rsi(fr9),pricedecimals))) tickerstateendbear=("🐻 Bearish below " + str.tostring(truncateprice(price_by_rsi(fr13),pricedecimals))) tickerstateendbullchop=("Bullish above " + str.tostring(truncateprice(price_by_rsi(fr16),pricedecimals))) tickerstateendbearchop=("🪓 Bearish below " + str.tostring(truncateprice(price_by_rsi(fr7),pricedecimals))) // Trend State Text bulltrend=rsi>r45maout and rsi>rsma and state==1 tickerstatebulltrend=("📈 Bullish " + (bulltrend?"Trend 🚀":"Chop 🪓")) beartrend=rsi<r45maout and rsi<rsma and state==2 tickerstatebeartrend=("📉 Bearish " + (beartrend?"Trend 💀":"Chop 🪓")) chopbear=state==3 and rsi<r45maout tickerstatechoptrend=("🪓 Chop with " + (chopbear?"Bearish 💀":"Bullish 🚀") + " Sentiment") trendstatedisplay=state==1?tickerstatebulltrend:state==2?tickerstatebeartrend:state==3?tickerstatechoptrend:na // Trend State Text Color tstextcol=state==1 and bulltrend ?brightgreen : state==1 and not bulltrend?green : state==2 and beartrend ? brightred : state==2 and not beartrend ? red : state==3 and chopbear ? red : state==3 and not chopbear ? green : na // ADX & DI Data // Code Author: Currently unknown. Please help identify the author if you know who it is. [_, _, adx1] = ta.dmi(17, 4) adxlen = 14 dilen = 14 dirmov(len) => up = ta.change(high) down = -ta.change(low) truerange = ta.rma(ta.tr, len) plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, len) / truerange) minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, len) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) adx adxHigh(dilen, adxlen) => [plus, minus] = dirmov(dilen) plus adxLow(dilen, adxlen) => [plus, minus] = dirmov(dilen) minus sig = adx(dilen, adxlen) sigHigh = adxHigh(dilen, adxlen) sigLow = adxLow(dilen, adxlen) sigTop = sigHigh>sigLow?sigHigh:sigLow // Text adxtext ='ADX ' + str.tostring(truncatepercent(adx1, percentdecimals)) + (adx1>adx1[1] ? ' & 📈' : ' & 📉') + (adx1<25?' 💤':adx1>25 and adx1<50 ?' 💪':adx1>50 and adx1<75 ?' 🔥':adx1>75 and adx1<100 ?' 🚀':'') ditext ='DI ' + str.tostring(truncatepercent(sigTop, percentdecimals)) + (sigTop>sigTop[1] and sigHigh>sigLow? ' & 📈 🐮' : sigTop<sigTop[1] and sigHigh>sigLow ? ' & 📉 🪓': sigTop>sigTop[1] and sigHigh<sigLow ? ' & 📈 🐻' : sigTop<sigTop[1] and sigHigh<sigLow ? ' & 📉 🪓':na) // Text Color adxtextcol = color.new( sigHigh > sigLow and adx1 < 25 ? green: sigHigh > sigLow and adx1 > 25 ? brightgreen: sigHigh < sigLow and adx1 > 25 ? brightred: sigHigh < sigLow and adx1 < 25 ? red: gray, 0) ditextcol = color.new( sigHigh > sigLow and sigTop<sigTop[1] ? green: sigHigh > sigLow and sigTop>sigTop[1] ? brightgreen: sigHigh < sigLow and sigTop>sigTop[1] ? brightred: sigHigh < sigLow and sigTop<sigTop[1] ? red: gray, 0) // Volatility lowvolcol = input.color(color.rgb(250,237,56,1), "Low Volatility Gradient Color", group=grtk) highvolcol = input.color(color.rgb(255,37,174,1), "High Volatility Gradient Color", group=grtk) f_volatility() => atr = ta.atr(14) stdAtr = 2*ta.stdev(atr,20) smaAtr = ta.sma(atr,20) topAtrDev = smaAtr+stdAtr bottomAtrDev = smaAtr-stdAtr calcDev = (atr-bottomAtrDev)/(topAtrDev-bottomAtrDev) percentVol = (40*calcDev+30) volatility = f_volatility() volatilitydir = volatility>volatility[1]?" & 📈":" & 📉" volemoji = volatility > 0 and volatility < 20 ? "😴" : volatility > 20 and volatility < 40 ? " 😐" : volatility > 40 and volatility < 60 ? " 😬" : volatility > 60 and volatility < 80 ? " 😮" : volatility > 80 and volatility < 100 ? " 😵" : " 🤯" voltxt = "Volatility = " + str.tostring(truncatepercent(volatility, percentdecimals)) + " %" + volemoji + volatilitydir volcol = color.from_gradient(volatility,25,75,lowvolcol,highvolcol) // Dual Ticker Display // Code Author: © dgtrd // Watermark tooltips (hover) q1 = "Look first / Then leap." q2 = "TradeStation™ Charting by Omega Research and Epsilon Charting" q3 = "Made w/ ❤ by © 🦶 BarefootJoey" // Watermark Displays str1 = "₸⩒ TradingView" str2 = "TradeStation™" str3 = "🦶 BarefootJoey" showwatermark = input(true, 'Show Watermark?', group=grtk, tooltip="Hover over watermark for additional info.") wmstring = input.string("TradingView", title="Watermark Display Text", options=["BarefootJoey", "TradeStation", "TradingView", "Custom"], group=grtk) watermark = input("Your name", title="Custom Trader WaterMark Text", group=grtk, tooltip="Emojis allowed!") WMtxtcol = input(gray, title="WaterMark Text Color", group=grtk) Ttransp = input(20, title="Ticker Text Transparency", group=grtk) // Show which watermark & tooltip whichwm = wmstring == "BarefootJoey" ? str3 :wmstring =="TradeStation"? str2 : wmstring == "TradingView" ? str1 : watermark whichtt = wmstring == "TradeStation" ? q2 : wmstring == "TradingView"? q1 : q3 position = input.string(position.top_center, "Ticker 1 Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left], group=grtk) size = input.string(size.small, "Ticker 1 Size", [size.tiny, size.small, size.normal, size.large, size.huge], group=grtk) var table Ticker = na Ticker := table.new(position, 2, 1) if barstate.islast and showticker table.cell(Ticker, 0, 0, text = datatype=="RSI to Price"?tickerstateob:datatype=="RSI MA Price"?tickerstaterwma:datatype=="Trend End" and state ==1?tickerstateendbull:datatype=="Trend End" and state ==3?tickerstateendbullchop:datatype=="ADX & DI+/-"?adxtext:datatype=="Watermark"?whichwm:na, text_size = size, text_color = color.new(datatype=="RSI to Price"?roblcol:datatype=="RSI MA Price"?rwmatcol2:datatype=="Trend End" and (state==3 or state==1)?green:datatype=="ADX & DI+/-"?adxtextcol:gray,Ttransp), tooltip=datatype=="Watermark"?whichtt:na) table.cell(Ticker, 1, 0, text = datatype=="RSI to Price"?tickerstateos:datatype=="RSI MA Price"?tickerstatersma:datatype=="Trend End" and state ==2?tickerstateendbear:datatype=="Trend End" and state ==3?tickerstateendbearchop:datatype=="ADX & DI+/-"?ditext:datatype=="Trend State"?trendstatedisplay:datatype=="Volatility"?voltxt:na, text_size = size, text_color = color.new(datatype=="RSI to Price"?roslcol:datatype=="RSI MA Price"?rsmatcol2:datatype=="Trend End" and (state==3 or state==2)?red:datatype=="ADX & DI+/-"?ditextcol:datatype=="Trend State"?tstextcol:datatype=="Volatility" ? volcol :gray,Ttransp)) position2 = input.string(position.bottom_center, "Ticker 2 Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left], group=grtk) size2 = input.string(size.small, "Ticker 2 Size", [size.tiny, size.small, size.normal, size.large, size.huge], group=grtk) var table Ticker2 = na Ticker2 := table.new(position2, 2, 1) if barstate.islast and showticker table.cell(Ticker2, 0, 0, text = datatype2=="RSI to Price"?tickerstateob:datatype2=="RSI MA Price"?tickerstaterwma:datatype2=="Trend End" and state ==1?tickerstateendbull:datatype2=="Trend End" and state ==3?tickerstateendbullchop:datatype2=="ADX & DI+/-"?adxtext:datatype2=="Watermark"?whichwm:na, text_size = size2, text_color = color.new(datatype2=="RSI to Price"?roblcol:datatype2=="RSI MA Price"?rwmatcol2:datatype2=="Trend End" and (state==3 or state==1)?green:datatype2=="ADX & DI+/-"?adxtextcol:gray,Ttransp), tooltip = datatype=="Watermark"?whichtt:na) table.cell(Ticker2, 1, 0, text = datatype2=="RSI to Price"?tickerstateos:datatype2=="RSI MA Price"?tickerstatersma:datatype2=="Trend End" and state ==2?tickerstateendbear:datatype2=="Trend End" and state ==3?tickerstateendbearchop:datatype2=="ADX & DI+/-"?ditext:datatype2=="Trend State"?trendstatedisplay:datatype=="Volatility"?voltxt:na, text_size = size2, text_color = color.new(datatype2=="RSI to Price"?roslcol:datatype2=="RSI MA Price"?rsmatcol2:datatype2=="Trend End" and (state==3 or state==2)?red:datatype2=="ADX & DI+/-"?ditextcol:datatype2=="Trend State"?tstextcol:datatype=="Volatility" ? volcol :gray,Ttransp)) //-----------------3 State RSI Gradient Bar Color on Chart--------------------// cbullu = input(brightgreen, "Chart BarColor: Bull Run", group=grhts) cbulld = input(darkgreen, "Chart BarColor: Bull Pullback", group=grhts) cbearu = input(brightred, "Chart BarColor: Bear Run", group=grhts) cbeard = input(darkred, "Chart BarColor: Bear Pullback", group=grhts) cbearc = input(brightgreen, "Chart BarColor: Bull Chop", group=grhts) // old version alt: green cbullc = input(brightred, "Chart BarColor: Bear Chop", group=grhts) // old version alt: red barcolor(state==1 and rsi>50?cbullu: state==1 and rsi<50?cbulld: state==2 and rsi<50 ?cbearu: state==2 and rsi>50 ?cbeard:color.new(color.from_gradient(rsi, ts2, ts1, cbearu, cbullu),0),title="Chart Bar Color", display = showbc ? display.all : display.none, editable=false) // EoS. Made w/ ❤ by © 🦶BarefootJoey
NVM Ratio: Onchain
https://www.tradingview.com/script/dmC2B0eb-NVM-Ratio-Onchain/
cryptoonchain
https://www.tradingview.com/u/cryptoonchain/
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/ // © MJShahsavar //@version=5 indicator("NVM Ratio: Onchain") R = input.symbol("BTC_MARKETCAP", "Symbol") r = request.security(R, 'D', close) S=input.symbol("BTC_ACTIVEADDRESSES", "Symbol") s = request.security(S, 'D', close) A= math.log10 (r) b= s*s B= math.log10 (b) C= A/B plot (C, color = color.blue, linewidth=1)
village trader
https://www.tradingview.com/script/NZ6lvuUG-village-trader/
villagetraderbro
https://www.tradingview.com/u/villagetraderbro/
52
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/ // © villagetraderbro //@version=4 study (title="village trader", shorttitle="VT", overlay=true) src = close EMA7 = ema(src, 6) SMA7 = sma(src, 50) EMA21 = ema(src, 14) SMA21 = sma(src, 100) EMA50 = ema(src, 26) SMA50 = sma(src, 200) plot( EMA7, color=color.green, style=plot.style_line, title="7EMA", linewidth=1) plot( SMA7, color=color.yellow, style=plot.style_line, title="7SMA", linewidth=2) plot( EMA21, color=color.blue, style=plot.style_line, title="21EMA", linewidth=1) plot( SMA21, color=color.orange, style=plot.style_line, title="21SMA", linewidth=2) plot( EMA50, color=color.red, style=plot.style_line, title="50EMA", linewidth=1) plot( SMA50, color=color.black, style=plot.style_line, title="50SMA", linewidth=2)
TRENDLINE V1
https://www.tradingview.com/script/lYIxejV9/
nicoakim
https://www.tradingview.com/u/nicoakim/
162
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © nicoakim //@version=5 indicator("TRENDLINE V2",overlay=true) res1 = input.timeframe(title='Resolution Trendline', defval='') ln = input.int(10, minval=5, title='Length of Trend') bars = input(100, 'Bars offset') /////////////////////////////////////////////// reqsymbol2(resolusi,value) => request.security(syminfo.tickerid,resolusi,value) dt = time - time[1] /////////////////////////////////////////////// f_round(_val, _decimals) => // Rounds _val to _decimals places. _p = math.pow(10, _decimals) math.round(math.abs(_val) * _p) / _p * math.sign(_val) pivothigh() => hprice = 0.0 swh = ta.pivothigh(high, ln, ln) hprice := not na(swh) ? swh : hprice[1] hprice pivothightime() => var int hprice = na swh = ta.pivothigh(high, ln, ln) hprice := not na(swh) ? time[ln] : hprice[1] hprice pivotlow() => lprice = 0.0 swl = ta.pivotlow(low, ln, ln) lprice := not na(swl) ? swl : lprice[1] lprice pivotlowtime() => var int lprice = na swl = ta.pivotlow(low, ln,ln) lprice := not na(swl) ? time[ln] : lprice lprice /////////////////////////////////////////////// storevalueint(value2) => var int storei = na if value2 != value2[1] storei := value2[1] storei storevaluefloat(value) => var float store = na if value != value[1] store := value[1] store /////////////////////////////////////////////// geting(x1,x2,y1,y2,ts) => m = (y2 - y1) / (x2 - x1) b = y1 - m * x1 Y = m * ts + b Y /////////////////////////////////////////////// fibcalc(hi,lo,out) => maxr = hi minr = lo ranr = maxr - minr plussatu6 = maxr - 1.618 * ranr satu = maxr nol7 = maxr - 0.236 * ranr nol6 = maxr - 0.382 * ranr nol5 = maxr - 0.50 * ranr nol3 = minr + 0.382 * ranr nol2 = minr + 0.236 * ranr nol = minr minsatu6 = minr + 1.618 * ranr out == 1 ? satu : out == 0.7 ? nol7 : out == 0.6 ? nol6 : out == 0.5 ? nol5 : out == 0.3 ? nol3 : out == 0.2 ? nol2 : out == -1.6 ? minsatu6 : out == 1.6 ? plussatu6 : nol trend(resolusi,out) => var linefill[] filline = array.new_linefill() var line[] upline = array.new_line() var line[] downline = array.new_line() var line[] satu = array.new_line() var line[] nol7 = array.new_line() var line[] nol6 = array.new_line() var line[] nol5 = array.new_line() var line[] nol3 = array.new_line() var line[] nol2 = array.new_line() var line[] nol = array.new_line() xs1 = storevalueint( reqsymbol2(res1,pivotlowtime())) ys1 = storevaluefloat( reqsymbol2(res1,pivotlow())) xs2 = reqsymbol2(res1,pivotlowtime()) ys2 = reqsymbol2(res1,pivotlow()) xs3 = storevalueint(xs1) ys3 = storevaluefloat(ys1) xr1 = storevalueint( reqsymbol2(res1,pivothightime())) yr1 = storevaluefloat( reqsymbol2(res1,pivothigh())) xr2 = reqsymbol2(res1,pivothightime()) yr2 = reqsymbol2(res1,pivothigh()) xr3 = storevalueint(xr1) yr3 = storevaluefloat(yr1) bear= yr2<yr1 and yr1 < yr3 bear2= ys2<ys1 and ys1 < ys3 bull= yr2>yr1 and yr1 > yr3 bull2= ys2>ys1 and ys1 > ys3 var float bul = na bul := bull and bull2 ? 1 : 2 var float ber = na ber := bear and bear2 ? 1 : 2 var int akhir = na var float highi = na var float lowi = na //////////////////////////suport///////////////////////////////// if bul != bul[1] and bul == 1 highi := yr2 lowi := ys3 array.unshift(downline,line.new(xs3,ys3, time +bars *dt,geting(xs3,xs2,ys3,ys2,time + bars *dt),xloc=xloc.bar_time,color=color.green)) if ber != ber[1] and ber == 1 highi := yr3 lowi := ys2 array.unshift(upline,line.new(xr3,yr3, time +bars *dt,geting(xr3,xr2,yr3,yr2,time + bars *dt),xloc=xloc.bar_time,color=color.red)) out == "h" ? highi : lowi hh=trend(res1,"h") ll=trend(res1,"l") one=plot(fibcalc(hh,ll,1),color=color.new(color.red,80)) one7=plot(fibcalc(hh,ll,0.7),color=na) one6=plot(fibcalc(hh,ll,0.6),color=color.green) one5=plot(fibcalc(hh,ll,0.5),color=color.yellow,style=plot.style_circles) one3=plot(fibcalc(hh,ll,0.3),color=color.red) one2=plot(fibcalc(hh,ll,0.2),color=na) nol=plot(fibcalc(hh,ll,0),color=na) satu6=plot(fibcalc(hh,ll,1.6),color=na) minsatu6=plot(fibcalc(hh,ll,-1.6),color=na) fill(one,one7,color=color.new(color.red,80)) fill(one7,one6,color=color.new(#9c27b0,80)) fill(one6,one5,color=color.new(color.green,80)) fill(one5,one3,color=color.new(#f44336,80)) fill(one3,one2,color=color.new(color.blue,80)) fill(one2,nol,color=color.new(#787b86,80)) fill(minsatu6,one,color=color.new(color.lime,80)) fill(satu6,nol,color=color.new(color.maroon,80)) if time[1] !=time l1=label.new(time+5*dt,fibcalc(hh,ll,1),text="(100%) " + str.tostring(f_round(fibcalc(hh,ll,1),2)),xloc=xloc.bar_time,textcolor=color.white,style=label.style_label_center,size=size.tiny,color=na) l2=label.new(time+5*dt,fibcalc(hh,ll,0.7),text="(70%) " + str.tostring(f_round(fibcalc(hh,ll,0.7),2)),xloc=xloc.bar_time,textcolor=color.white,style=label.style_label_center,size=size.tiny,color=na) l3=label.new(time+5*dt,fibcalc(hh,ll,0.6),text="(60%) " + str.tostring(f_round(fibcalc(hh,ll,0.6),2)),xloc=xloc.bar_time,textcolor=color.white,style=label.style_label_center,size=size.tiny,color=na) l4=label.new(time+5*dt,fibcalc(hh,ll,0.5),text="(50%) " + str.tostring(f_round(fibcalc(hh,ll,0.5),2)),xloc=xloc.bar_time,textcolor=color.white,style=label.style_label_center,size=size.tiny,color=na) l5=label.new(time+5*dt,fibcalc(hh,ll,0.3),text="(30%) " + str.tostring(f_round(fibcalc(hh,ll,0.3),2)),xloc=xloc.bar_time,textcolor=color.white,style=label.style_label_center,size=size.tiny,color=na) l6=label.new(time+5*dt,fibcalc(hh,ll,0.2),text="(20%) " + str.tostring(f_round(fibcalc(hh,ll,0.2),2)),xloc=xloc.bar_time,textcolor=color.white,style=label.style_label_center,size=size.tiny,color=na) l7=label.new(time+5*dt,fibcalc(hh,ll,0),text="(0%) " + str.tostring(f_round(fibcalc(hh,ll,0),2)),xloc=xloc.bar_time,textcolor=color.white,style=label.style_label_center,size=size.tiny,color=na) label.delete(l1[1]) label.delete(l2[1]) label.delete(l3[1]) label.delete(l4[1]) label.delete(l5[1]) label.delete(l6[1]) label.delete(l7[1])
Consecutive positive/negative candles
https://www.tradingview.com/script/2EEGL1rG-Consecutive-positive-negative-candles/
fbaghyari
https://www.tradingview.com/u/fbaghyari/
68
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © fbaghyari //@version=5 indicator("Consecutive positive/negative candles") period = input.int(10, "sma period") var negative = 0 var positive = 0 var maxPositive = 0 var maxNegative = 0 if close<close[1] negative := negative - 1 else negative := 0 if close>close[1] positive := positive + 1 else positive := 0 if negative <= maxNegative maxNegative := negative if positive >= maxPositive maxPositive := positive nSMA = ta.sma(negative, period) pSMA = ta.sma(positive, period) plot(positive,title="Positive candles" ,color=color.green, style=plot.style_histogram) plot(negative,title="Negative candles" ,color=color.red, style=plot.style_histogram) plot(nSMA, title="Negative sma" ,color=color.orange) plot(pSMA, title="positive sma" ,color=color.blue) plot(maxPositive, "max consecutive positive", color=color.blue) plot(maxNegative, "max consecutive negative", color=color.orange)
[_ParkF]HeikinAshi
https://www.tradingview.com/script/KWdVpm8m/
ParkF
https://www.tradingview.com/u/ParkF/
78
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ParkF //@version=5 indicator("[_ParkF]HeikinAshi", overlay=true) // Input ha_fill = input.bool(true, 'Fill', group='_____HeikinAshi') Location = input.float(1, 'Location', minval=1, step=0.1, group='_____HeikinAshi') bull_col = input.color(color.new(#ffffff, 35), 'Bull', inline='CANDLE', group='_____HeikinAshi') bear_col = input.color(color.new(#9598a1, 35), 'Bear', inline='CANDLE', group='_____HeikinAshi') // Get Heiken-Ashi tickerid = syminfo.tickerid tf = timeframe.period haOpen = request.security(ticker.heikinashi(tickerid), tf, open * Location) haHigh = request.security(ticker.heikinashi(tickerid), tf, high * Location) haLow = request.security(ticker.heikinashi(tickerid), tf, low * Location) haClose = request.security(ticker.heikinashi(tickerid), tf, close * Location) // Color trend_col = haClose > haOpen ? bull_col : bear_col // Plot plotcandle(haOpen, haHigh, haLow, haClose, title='Heikin-Ashi', color=trend_col, wickcolor=trend_col, bordercolor=trend_col, editable=false) candleOpen = plot(ha_fill ? haOpen : na, title='OpenCandle' , color=haOpen < haClose ? bull_col : bear_col, editable=false) candleClose = plot(ha_fill ? haClose : na, title='CloseCandle', color=haOpen > haClose ? bull_col : bear_col, editable=false) fill(candleOpen, candleClose, color=haOpen < haClose ? bull_col : bear_col, editable=false)
CashDataPloter
https://www.tradingview.com/script/9CxvRzmh-CashDataPloter/
WillamFletcher
https://www.tradingview.com/u/WillamFletcher/
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/ // © WillamFletcher //@version=5 indicator(title = "CashDataPloter", overlay = true,format=format.price, precision=2, max_lines_count = 500, max_labels_count = 500) StartTimeOnOff = input.bool(false,title="Custom start ", group="Date") StartTime = input.time(defval = timestamp("1 mar 2022 12:00"),title = "custom end " ) //StartTime2 = input.time(defval = timestamp("1 feb 2022 12:00"),title = "custom start " ) linewidth = input.int(defval=2, title= "Width : ") upcolor = input.color(title = "UpColor", defval = color.white,group="color") dncolor = input.color(title = "DownColor", defval = color.white,group="color") concolor = input.color(title = "ConnectionColor", defval = color.white,group ="color") cashdataperiod_daily = input.string("1D", title="Daily", options=["1D","2D","3D"]) cashdataperiod_weekly = input.string("1W", title="Weekly", options=["1W", "2W"]) cashdataperiod_monthly = input.string("1M", title="Monthly", options=["1M", "2M","3M","6M"]) cashdataperiod_yearly = input.string("12M", title="Yearly", options=["12M"]) cashdataperiod_minute = input.string("5", title="Minute", options=["5","10","15" , "30" ]) cashdataperiod_hourly = input.string("60", title="Hourly", options=["60","120", "180" ]) //Declare Variables var float _highPrice = na var float _lowPrice = na var int _highTime = na var int _lowTime = na var int _sessionStart = na var int _sessionMid = na var int _barNum = na var line MainLine = na var line ConnectLine = na var string bar = na var string TF = na var int bars = na var int mainlinecounter= 0 if timeframe.period == "1" bar:= cashdataperiod_minute TF:="1Min" else if timeframe.period == "3" bar:= cashdataperiod_minute TF:="3Min" else if timeframe.period == "5" bar:= cashdataperiod_minute TF:="5Min" else if timeframe.period == "15" bar:= cashdataperiod_hourly TF:="15Min" else if timeframe.period == "30" bar := cashdataperiod_hourly TF:="30Min" else if timeframe.period == "45" bar := cashdataperiod_hourly TF:="45Min" else if timeframe.period == "60" bar:= cashdataperiod_daily TF:= "1H" else if timeframe.period == "120" bar:= cashdataperiod_daily TF:= "2H" else if timeframe.period == "180" bar:= cashdataperiod_daily TF:= "3H" else if timeframe.period == "240" bar := cashdataperiod_weekly TF:= "4H" else if timeframe.period == "D" bar:=cashdataperiod_monthly TF:="D" else if timeframe.period == "W" bar:=cashdataperiod_monthly TF:= "W" else if timeframe.period == "M" bar:=cashdataperiod_yearly TF:="M" NewSession = ta.change(time(bar)) > 0 //and ( StartTime2 <= time ) if ( StartTimeOnOff ) ? StartTime>=time : ( timenow >= time ) if NewSession _highPrice := high _lowPrice := low _highTime := bar_index _lowTime := bar_index _sessionStart := bar_index _sessionMid := bar_index MainLine := line.new(x1 = _sessionStart,y1 = _highPrice,x2 = _sessionMid, y2 =_lowPrice,xloc=xloc.bar_index, extend = extend.none, color = color.black, style = line.style_solid, width = linewidth) ConnectLine := line.new(x1=line.get_x2(MainLine[1]),y1=line.get_y2(MainLine[1]),x2= _sessionStart,y2= _lowPrice,xloc=xloc.bar_index, extend = extend.none, color = concolor, style = line.style_solid, width = linewidth) _barNum := 0 mainlinecounter:=mainlinecounter+1 else _barNum := _barNum[1] + 1 barCount = ta.valuewhen(NewSession , _barNum[1],0) delta = (barCount - barCount%2)/2 _sessionMid := _sessionStart + delta if ( StartTimeOnOff ) ? StartTime>=time : ( timenow >= time ) if high > _highPrice _highPrice := high _highTime := bar_index if low < _lowPrice _lowPrice := low _lowTime := bar_index if _highTime <= _lowTime line.set_xy1(id = MainLine, x = _sessionStart, y = _highPrice ) line.set_xy2(id = MainLine, x = _sessionMid, y = _lowPrice ) line.set_color(id = MainLine, color = dncolor) else line.set_xy1(id = MainLine, x = _sessionStart, y = _lowPrice ) line.set_xy2(id = MainLine, x = _sessionMid, y = _highPrice ) line.set_color(id = MainLine, color = upcolor) line.set_xy2(id=ConnectLine, x=line.get_x1(MainLine[0]), y=line.get_y1(MainLine[0])) line.set_color(id=ConnectLine, color=concolor) bar:=bar=="60"?"H":bar=="120"?"2H":bar=="180"?"3H":bar if barstate.islast var table atrDisplay = table.new(position.top_right, 5, 5, bgcolor = color.red, frame_width = 1, frame_color = color.white , border_color= color.white , border_width=1) table.cell(atrDisplay, 0, 0, "Symbol :", text_color = color.white,bgcolor=#636161,width=8,height=3.5 ) table.cell(atrDisplay, 1, 0, syminfo.ticker, text_color= color.white , bgcolor=#8c0e0e,width=4,height=3.5) table.cell(atrDisplay, 0, 2, "CashData TF :", text_color = color.white,bgcolor=#636161,width=8,height=3.5 ) table.cell(atrDisplay, 1, 2, bar, text_color= color.white , bgcolor=#8c0e0e,width=4,height=3.5) table.cell(atrDisplay, 0, 1, "Base TF : ", text_color = color.white,bgcolor=#636161, height=3.5 , width=8) table.cell(atrDisplay, 1, 1, TF, text_color = color.white,bgcolor=#8c0e0e,width=4,height=3.5) table.cell(atrDisplay, 0, 3, "Current price : ", text_color = color.white,bgcolor=#636161,width=8,height=3.5 ) table.cell(atrDisplay, 1, 3, str.tostring(close,'#.####'), text_color= color.white , bgcolor=#8c0e0e,width=4,height=3.5) table.cell(atrDisplay, 0, 4, " Monowaves :", text_color = color.white,bgcolor=#636161,width=8,height=3.5 ) table.cell(atrDisplay, 1, 4, str.tostring(mainlinecounter-1), text_color= color.white , bgcolor=#8c0e0e,width=4,height=3.5)
RSI BGCOLOR indicator
https://www.tradingview.com/script/g8oV9N0y-RSI-BGCOLOR-indicator/
Maboko
https://www.tradingview.com/u/Maboko/
40
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Maboko //@version=5 indicator("RSI BGCOLOR indicator", overlay=true) //User Inputs rsilen = input.int(title="RSI Lenght", defval=14) rsiob = input.int(title="RSI Bullish",defval=51) rsios = input.int(title="RSI Bearish",defval=49) //Get RSI value rsi = ta.rsi(close, rsilen) //RSI Conditions rsilong = rsi > rsiob rsishort = rsi < rsios rsi50 = rsi <= rsiob and rsi >= rsios //Plot RSI background direction bgcolor(rsilong? color.new(color.green,85) : na) bgcolor(rsishort? color.new(color.red,85) : na) bgcolor(rsi50? color.new(color.black,85) : na)
MarginRockets 5 Mins Ultimate Scalp v1
https://www.tradingview.com/script/colhzfgH-MarginRockets-5-Mins-Ultimate-Scalp-v1/
ahmedashraf20999
https://www.tradingview.com/u/ahmedashraf20999/
63
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/ // © ahmedashraf20999 //@version=4 study("5 Mins Complex alert", overlay =true) len = input(14) th = input(20) TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1]))) DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0 DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0 SmoothedTrueRange = 0.0 SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange SmoothedDirectionalMovementPlus = 0.0 SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus SmoothedDirectionalMovementMinus = 0.0 SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100 DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100 DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100 ADX = sma(DX, len) //plot(DIPlus, color=color.green, title="DI+") //plot(DIMinus, color=color.red, title="DI-") //plot(ADX, color=color.navy, title="ADX") //hline(th, color=color.black) //-------------- // Define Variables ema200 = ema(close, 200) vwma20 = vwma (close,20) volumeaverage = sma(volume, 30) volumetrue = volume > volumeaverage Long_signal = close > ema200 and volumetrue and ADX >20 and DIPlus > DIMinus and close > open Short_signal = close < ema200 and volumetrue and ADX >20 and DIMinus > DIPlus and open > close // Plot Decision plotshape (Long_signal,style=shape.arrowup,color=color.green) plotshape (Short_signal,style=shape.arrowdown,color = color.red) plot(series=ema200, color=color.blue, linewidth=2) plot(series=vwma20, color=color.yellow, linewidth=1) //Alert Setup alertcondition(Long_signal,title = "Long Signal", message = "Long Ya Basha") alertcondition(Short_signal,title = "Short Signal",message = "Short Ya Basha")
MTF Stochastic, A version
https://www.tradingview.com/script/1StZCcFd-MTF-Stochastic-A-version/
A3Sh
https://www.tradingview.com/u/A3Sh/
153
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // @version=5 // @ A3Sh // Multi Time Frame Stochastic based on the formula RSI MTF created by PeterO // https://www.tradingview.com/script/JwWWwZOD-RSI-MTF-by-PeterO/ // Like the security based Non Repainting MTF scripts, it has a delay compared to the build in version. // Simple MTF Stoch script that can be used as trend indicator or filter in your scripts. // Additional functions to plot the Up and Down trend, Buy and Sell Signals and the Overbought and Oversold areas. indicator(title='MTF Stochastic', shorttitle='MTF Stoch') // Inputs periodK = input.int(14, group='MTF Stochastic Settings', title='K', minval=1) periodD = input.int(3, group='MTF Stochastic Settings', title='D', minval=1) smoothK = input.int(3, group='MTF Stochastic Settings', title='Smooth', minval=1) upper = input.int(80, group='MTF Stochastic Settings', title='Overbought Limit') lower = input.int(20, group='MTF Stochastic Settings', title='Oversold Limit') mtf_ = input.int(8, group='MTF Stochastic Settings', title='Higher TimeFrame Multiplier', tooltip='Multiplies the current timeframe by specified value') pud = input.bool(true, group='Plot Options', title='Plot Up and Down Trends') poo = input.bool(true, group='Plot Options', title='Plot Overbought and Oversold Areas') pbs = input.bool(true, group='Plot Options', title='Plot Buy and Sell Signals') // MTF Stoch Calcualation stoch_mtfK(source, mtf, len) => k = ta.sma(ta.stoch(source, high, low, periodK * mtf), smoothK * mtf) stoch_mtfD(source, mtf, len) => k = ta.sma(ta.stoch(source, high, low, periodK * mtf), smoothK * mtf) d = ta.sma(k, periodD * mtf) mtfK = stoch_mtfK(close, mtf_, periodK) mtfD = stoch_mtfD(close, mtf_, periodK) // Plots // Stoch up and down trend plots trendChange = ta.change(mtfD) trendColor = trendChange > 0 ? color.new(color.blue,80) : color.new(color.red,80) plot(pud ? upper : na, title='Background Up/Down Trends', color=trendColor, style = plot.style_areabr, histbase=lower) // Stoch K and D line plots plot(mtfK, title="%K", color=#2962FF) plot(mtfD, title="%D", color=#FF6D00) // The dashed horizontal lines and the fill. h0 = hline(upper, title= 'Upper Band', color=#606060) h1 = hline(lower, title= 'Lower Band', color=#606060) fill(h0, h1, title='Background', color=color.new(#9915FF, 95)) // Overbought and oversold plots plot1 = plot(mtfK, title='PlotforFill_1', color= color.new(color.black,100)) plot2 = plot(upper, title='PlotforFill_2', color= color.new(color.black,100)) plot3 = plot(lower, title='PlotforFill_3', color= color.new(color.black,100)) fill(plot1, plot2, title='Oversold Area', color= poo and mtfK > upper ? color.new(color.red, 50) : na) fill(plot1, plot3, title='Overbought Area', color= poo and mtfK < lower ? color.new(color.blue, 50) : na) // Buy and Sell signal plots crossUp = mtfK[1] < mtfD[1] and mtfK[1] < lower[1] and mtfK > mtfD ? 1 : 0 crossDn = mtfK[1] > mtfD[1] and mtfK[1] > upper[1] and mtfK < mtfD ? 1 : 0 bgcolor(pbs and crossUp ? color.new(color.blue,0) : na, title = 'Buy Signal') bgcolor(pbs and crossDn ? color.new(color.red ,0) : na, title = 'Sell Signal')
[_ParkF]Mini Chart(BB)
https://www.tradingview.com/script/4VVUntAg/
ParkF
https://www.tradingview.com/u/ParkF/
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/ // © ParkF //@version=5 indicator('[_ParkF]Mini Chart(BB)', overlay=true) // MINI LINE CHART // input barcount = input.int(50, 'Length', inline='SETTING', group='_____MINI LINE CHART') width1 = input(2, 'Width', inline='SETTING', group='_____MINI LINE CHART') line_col = input.color(color.new(#000000, 0), 'Color', inline='COLOR', group='_____MINI LINE CHART') cross_bb20_col = input.color(color.new(#0c3299, 0), 'Color', inline='COLOR', group='_____MINI LINE CHART') cross_bb120_col = input.color(color.new(#ffe500, 0), 'Color', inline='COLOR', group='_____MINI LINE CHART') // func line_show = true src = close offset = barcount+5[barcount] // plot plot(line_show ? src : na, title='Line', offset=offset, color=line_col, linewidth=width1, show_last=barcount, editable=false) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // BOLLINGER BANDS mult = input.float(1.0, 'Deviation', group='_____BOLLINGER BANDS') len1 = input(20, 'Length', group='_____BB 20') width2 = input(1, 'Width', inline='BASIS20', group='_____BB 20') basis_col1 = input.color(color.new(#f57c00, 0), 'Color', inline='BASIS20', group='_____BB 20') width3 = input(3, 'Width', inline='BAND20', group='_____BB 20') band_col1 = input.color(color.new(#089981, 50), 'Color', inline='BAND20', group='_____BB 20') len2 = input(120, 'Length', group='_____BB 120') width4 = input(1, 'Width', inline='BASIS120', group='_____BB 120') basis_col2 = input.color(color.new(#787b86, 0), 'Color', inline='BASIS120', group='_____BB 120') width5 = input(4, 'Width', inline='BAND120', group='_____BB 120') band_col2 = input.color(color.new(#5d606b, 55), 'Color', inline='BAND120', group='_____BB 120') // func dev1 = mult * ta.stdev(src, len1) dev2 = mult * ta.stdev(src, len2) basis1 = ta.sma(src, len1) basis2 = ta.sma(src, len2) upper1 = basis1 + dev1 upper2 = basis2 + dev2 lower1 = basis1 - dev1 lower2 = basis2 - dev2 // plot plot(basis1, "20 BB Basis", style=plot.style_line, color=basis_col1, offset=offset, show_last=barcount, linewidth=width2, editable=false) plot(upper1, "20 BB Upper", style=plot.style_line, color=band_col1, offset=offset, show_last=barcount, linewidth=width3, editable=false) plot(lower1, "20 BB Lower", style=plot.style_line, color=band_col1, offset=offset, show_last=barcount, linewidth=width3, editable=false) plot(basis2, "120 BB Basis", style=plot.style_line, color=basis_col2, offset=offset, show_last=barcount, linewidth=width4, editable=false) plot(upper2, "120 BB Upper", style=plot.style_line, color=band_col2, offset=offset, show_last=barcount, linewidth=width5, editable=false) plot(lower2, "120 BB Lower", style=plot.style_line, color=band_col2, offset=offset, show_last=barcount, linewidth=width5, editable=false) // cross mark crossbb20 = line_show == true and (ta.cross(src, basis1) or ta.cross(src, upper1) or ta.cross(src, lower1)) crossbb120 = line_show == true and (ta.cross(src, basis2) or ta.cross(src, upper2) or ta.cross(src, lower2)) plotshape(crossbb20 ? src : na, title='Line Cross 20', style=shape.circle, location=location.absolute, color=cross_bb20_col, offset=offset, size=size.tiny, show_last=barcount, editable=false) plotshape(crossbb120 ? src : na, title='Line Cross 120', style=shape.circle, location=location.absolute, color=cross_bb120_col, offset=offset, size=size.tiny, show_last=barcount, editable=false) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // PREDICTIVE //input p_width = input(1, 'Width', group='_____Predictive') pbasis_col1 = input.color(color.new(#f57c00, 0), 'Color', inline='PBASIS20', group='_____Predictive') pband_col1 = input.color(color.new(#089981, 0), 'Color', inline='PBASIS20', group='_____Predictive') pbasis_col2 = input.color(color.new(#787b86, 0), 'Color', inline='PBASIS120', group='_____Predictive') pband_col2 = input.color(color.new(#5d606b, 0), 'Color', inline='PBASIS120', group='_____Predictive') tf = timeframe.period sym = syminfo.tickerid pbb20_1 = request.security(sym, tf, (ta.sma(src, len1 -1) * (len1 - 1) + src * 1) / len1) pbb20_2 = request.security(sym, tf, (ta.sma(src, len1 -2) * (len1 - 2) + src * 2) / len1) pbb20_3 = request.security(sym, tf, (ta.sma(src, len1 -3) * (len1 - 3) + src * 3) / len1) pbb20_u1 = pbb20_1 + request.security(sym, tf, (ta.stdev(src, len1))) * mult pbb20_u2 = pbb20_2 + request.security(sym, tf, (ta.stdev(src, len1))) * mult pbb20_u3 = pbb20_3 + request.security(sym, tf, (ta.stdev(src, len1))) * mult pbb20_l1 = pbb20_1 - request.security(sym, tf, (ta.stdev(src, len1))) * mult pbb20_l2 = pbb20_2 - request.security(sym, tf, (ta.stdev(src, len1))) * mult pbb20_l3 = pbb20_3 - request.security(sym, tf, (ta.stdev(src, len1))) * mult pbb120_1 = request.security(sym, tf, (ta.sma(src, len2 -1) * (len2 - 1) + src * 1) / len2) pbb120_2 = request.security(sym, tf, (ta.sma(src, len2 -2) * (len2 - 2) + src * 2) / len2) pbb120_3 = request.security(sym, tf, (ta.sma(src, len2 -3) * (len2 - 3) + src * 3) / len2) pbb120_u1 = pbb120_1 + request.security(sym, tf, (ta.stdev(src, len2))) * mult pbb120_u2 = pbb120_2 + request.security(sym, tf, (ta.stdev(src, len2))) * mult pbb120_u3 = pbb120_3 + request.security(sym, tf, (ta.stdev(src, len2))) * mult pbb120_l1 = pbb120_1 - request.security(sym, tf, (ta.stdev(src, len2))) * mult pbb120_l2 = pbb120_2 - request.security(sym, tf, (ta.stdev(src, len2))) * mult pbb120_l3 = pbb120_3 - request.security(sym, tf, (ta.stdev(src, len2))) * mult // plot plot(pbb20_1, title='PBB_20 Base1', color=pbasis_col1, style=plot.style_circles, linewidth=p_width, offset=offset+1, show_last=1, editable=false) plot(pbb20_2, title='PBB_20 Base2', color=pbasis_col1, style=plot.style_circles, linewidth=p_width, offset=offset+2 , show_last=1, editable=false) plot(pbb20_3, title='PBB_20 Base3', color=pbasis_col1, style=plot.style_circles, linewidth=p_width, offset=offset+3, show_last=1, editable=false) plot(pbb20_u1, title='PBB_20 Upper1', color=pband_col1, style=plot.style_circles, linewidth=p_width, offset=offset+1, show_last=1, editable=false) plot(pbb20_u2, title='PBB_20 Upper2', color=pband_col1, style=plot.style_circles, linewidth=p_width, offset=offset+2, show_last=1, editable=false) plot(pbb20_u3, title='PBB_20 Upper3', color=pband_col1, style=plot.style_circles, linewidth=p_width, offset=offset+3, show_last=1, editable=false) plot(pbb20_l1, title='PBB_20 Lower1', color=pband_col1, style=plot.style_circles, linewidth=p_width, offset=offset+1, show_last=1, editable=false) plot(pbb20_l2, title='PBB_20 Lower2', color=pband_col1, style=plot.style_circles, linewidth=p_width, offset=offset+2, show_last=1, editable=false) plot(pbb20_l3, title='PBB_20 Lower3', color=pband_col1, style=plot.style_circles, linewidth=p_width, offset=offset+3, show_last=1, editable=false) plot(pbb120_1, title='PBB_120 Base1', color=pbasis_col2, style=plot.style_circles, linewidth=p_width, offset=offset+1, show_last=1, editable=false) plot(pbb120_2, title='PBB_120 Base2', color=pbasis_col2, style=plot.style_circles, linewidth=p_width, offset=offset+2 , show_last=1, editable=false) plot(pbb120_3, title='PBB_120 Base3', color=pbasis_col2, style=plot.style_circles, linewidth=p_width, offset=offset+3, show_last=1, editable=false) plot(pbb120_u1, title='PBB_120 Upper1', color=pband_col2, style=plot.style_circles, linewidth=p_width, offset=offset+1, show_last=1, editable=false) plot(pbb120_u2, title='PBB_120 Upper2', color=pband_col2, style=plot.style_circles, linewidth=p_width, offset=offset+2, show_last=1, editable=false) plot(pbb120_u3, title='PBB_120 Upper3', color=pband_col2, style=plot.style_circles, linewidth=p_width, offset=offset+3, show_last=1, editable=false) plot(pbb120_l1, title='PBB_120 Lower1', color=pband_col2, style=plot.style_circles, linewidth=p_width, offset=offset+1, show_last=1, editable=false) plot(pbb120_l2, title='PBB_120 Lower2', color=pband_col2, style=plot.style_circles, linewidth=p_width, offset=offset+2, show_last=1, editable=false) plot(pbb120_l3, title='PBB_120 Lower3', color=pband_col2, style=plot.style_circles, linewidth=p_width, offset=offset+3, show_last=1, editable=false)
ATR with MA
https://www.tradingview.com/script/DYWRVstZ-ATR-with-MA/
bjr117
https://www.tradingview.com/u/bjr117/
102
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © bjr117 //@version=5 indicator(title = "ATR with MA", shorttitle = "ATRMA", overlay = false) //============================================================================== // Function: Calculate a given type of moving average //============================================================================== get_ma_out(type, src, len, alma_offset, alma_sigma, kama_fastLength, kama_slowLength, vama_vol_len, vama_do_smth, vama_smth, mf_beta, mf_feedback, mf_z, eit_alpha) => float baseline = 0.0 if type == 'SMA | Simple MA' baseline := ta.sma(src, len) else if type == 'EMA | Exponential MA' baseline := ta.ema(src, len) else if type == 'DEMA | Double Exponential MA' e = ta.ema(src, len) baseline := 2 * e - ta.ema(e, len) else if type == 'TEMA | Triple Exponential MA' e = ta.ema(src, len) baseline := 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len) else if type == 'TMA | Triangular MA' // by everget baseline := ta.sma(ta.sma(src, math.ceil(len / 2)), math.floor(len / 2) + 1) else if type == 'WMA | Weighted MA' baseline := ta.wma(src, len) else if type == 'VWMA | Volume-Weighted MA' baseline := ta.vwma(src, len) else if type == 'SMMA | Smoothed MA' w = ta.wma(src, len) baseline := na(w[1]) ? ta.sma(src, len) : (w[1] * (len - 1) + src) / len else if type == 'RMA | Rolling MA' baseline := ta.rma(src, len) else if type == 'HMA | Hull MA' baseline := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len))) else if type == 'LSMA | Least Squares MA' baseline := ta.linreg(src, len, 0) else if type == 'Kijun' //Kijun-sen kijun = math.avg(ta.lowest(len), ta.highest(len)) baseline := kijun else if type == 'MD | McGinley Dynamic' mg = 0.0 mg := na(mg[1]) ? ta.ema(src, len) : mg[1] + (src - mg[1]) / (len * math.pow(src / mg[1], 4)) baseline := mg else if type == 'JMA | Jurik MA' // by everget DEMAe1 = ta.ema(src, len) DEMAe2 = ta.ema(DEMAe1, len) baseline := 2 * DEMAe1 - DEMAe2 else if type == 'ALMA | Arnaud Legoux MA' baseline := ta.alma(src, len, alma_offset, alma_sigma) else if type == 'VAR | Vector Autoregression MA' valpha = 2 / (len+1) vud1 = (src > src[1]) ? (src - src[1]) : 0 vdd1 = (src < src[1]) ? (src[1] - src) : 0 vUD = math.sum(vud1, 9) vDD = math.sum(vdd1, 9) vCMO = nz( (vUD - vDD) / (vUD + vDD) ) baseline := nz(valpha * math.abs(vCMO) * src) + (1 - valpha * math.abs(vCMO)) * nz(baseline[1]) else if type == 'WWMA | Welles Wilder MA (aka Rolling MA)' baseline := nz(baseline[1]) + (src - nz(baseline[1])) / len else if type == 'ZLEMA | Zero-Lag Exponential MA' // by HPotter xLag = (len) / 2 xEMAData = (src + (src - src[xLag])) baseline := ta.ema(xEMAData, len) else if type == 'AHMA | Ahrens Moving Average' // by everget baseline := nz(baseline[1]) + (src - (nz(baseline[1]) + nz(baseline[len])) / 2) / len else if type == 'EVWMA | Elastic Volume Weighted MA' volumeSum = math.sum(volume, len) baseline := ( (volumeSum - volume) * nz(baseline[1]) + volume * src ) / volumeSum else if type == 'SWMA | Sine Weighted MA' // by everget sum = 0.0 weightSum = 0.0 for i = 0 to len - 1 weight = math.sin(i * math.pi / (len + 1)) sum := sum + nz(src[i]) * weight weightSum := weightSum + weight baseline := sum / weightSum else if type == 'LMA | Leo MA' baseline := 2 * ta.wma(src, len) - ta.sma(src, len) else if type == 'VIDYA | Variable Index Dynamic Average' // by KivancOzbilgic mom = ta.change(src) upSum = math.sum(math.max(mom, 0), len) downSum = math.sum(-math.min(mom, 0), len) out = (upSum - downSum) / (upSum + downSum) cmo = math.abs(out) alpha = 2 / (len + 1) baseline := src * alpha * cmo + nz(baseline[1]) * (1 - alpha * cmo) else if type == 'FRAMA | Fractal Adaptive MA' length2 = math.floor(len / 2) hh2 = ta.highest(length2) ll2 = ta.lowest(length2) N1 = (hh2 - ll2) / length2 N2 = (hh2[length2] - ll2[length2]) / length2 N3 = (ta.highest(len) - ta.lowest(len)) / len D = (math.log(N1 + N2) - math.log(N3)) / math.log(2) factor = math.exp(-4.6 * (D - 1)) baseline := factor * src + (1 - factor) * nz(baseline[1]) else if type == 'VMA | Variable MA' // by LazyBear k = 1.0/len pdm = math.max((src - src[1]), 0) mdm = math.max((src[1] - src), 0) pdmS = float(0.0) mdmS = float(0.0) pdmS := ((1 - k)*nz(pdmS[1]) + k*pdm) mdmS := ((1 - k)*nz(mdmS[1]) + k*mdm) s = pdmS + mdmS pdi = pdmS/s mdi = mdmS/s pdiS = float(0.0) mdiS = float(0.0) pdiS := ((1 - k)*nz(pdiS[1]) + k*pdi) mdiS := ((1 - k)*nz(mdiS[1]) + k*mdi) d = math.abs(pdiS - mdiS) s1 = pdiS + mdiS iS = float(0.0) iS := ((1 - k)*nz(iS[1]) + k*d/s1) hhv = ta.highest(iS, len) llv = ta.lowest(iS, len) d1 = hhv - llv vI = (iS - llv)/d1 baseline := (1 - k*vI)*nz(baseline[1]) + k*vI*src else if type == 'GMMA | Geometric Mean MA' lmean = math.log(src) smean = math.sum(lmean, len) baseline := math.exp(smean / len) else if type == 'CMA | Corrective MA' // by everget sma = ta.sma(src, len) baseline := sma v1 = ta.variance(src, len) v2 = math.pow(nz(baseline[1], baseline) - baseline, 2) v3 = v1 == 0 or v2 == 0 ? 1 : v2 / (v1 + v2) var tolerance = math.pow(10, -5) float err = 1 // Gain Factor float kPrev = 1 float k = 1 for i = 0 to 5000 by 1 if err > tolerance k := v3 * kPrev * (2 - kPrev) err := kPrev - k kPrev := k kPrev baseline := nz(baseline[1], src) + k * (sma - nz(baseline[1], src)) else if type == 'MM | Moving Median' // by everget baseline := ta.percentile_nearest_rank(src, len, 50) else if type == 'QMA | Quick MA' // by everget peak = len / 3 num = 0.0 denom = 0.0 for i = 1 to len + 1 mult = 0.0 if i <= peak mult := i / peak else mult := (len + 1 - i) / (len + 1 - peak) num := num + src[i - 1] * mult denom := denom + mult baseline := (denom != 0.0) ? (num / denom) : src else if type == 'KAMA | Kaufman Adaptive MA' // by everget mom = math.abs(ta.change(src, len)) volatility = math.sum(math.abs(ta.change(src)), len) // Efficiency Ratio er = volatility != 0 ? mom / volatility : 0 fastAlpha = 2 / (kama_fastLength + 1) slowAlpha = 2 / (kama_slowLength + 1) alpha = math.pow(er * (fastAlpha - slowAlpha) + slowAlpha, 2) baseline := alpha * src + (1 - alpha) * nz(baseline[1], src) else if type == 'VAMA | Volatility Adjusted MA' // by Joris Duyck (JD) mid = ta.ema(src, len) dev = src - mid vol_up = ta.highest(dev, vama_vol_len) vol_down = ta.lowest(dev, vama_vol_len) vama = mid + math.avg(vol_up, vol_down) baseline := vama_do_smth ? ta.wma(vama, vama_smth) : vama else if type == 'Modular Filter' // by alexgrover //---- b = 0.0, c = 0.0, os = 0.0, ts = 0.0 //---- alpha = 2/(len+1) a = mf_feedback ? mf_z*src + (1-mf_z)*nz(baseline[1],src) : src //---- b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a) c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a) os := a == b ? 1 : a == c ? 0 : os[1] //---- upper = mf_beta*b+(1-mf_beta)*c lower = mf_beta*c+(1-mf_beta)*b baseline := os*upper+(1-os)*lower else if type == 'EIT | Ehlers Instantaneous Trendline' // by Franklin Moormann (cheatcountry) baseline := bar_index < 7 ? (src + (2 * nz(src[1])) + nz(src[2])) / 4 : ((eit_alpha - (math.pow(eit_alpha, 2) / 4)) * src) + (0.5 * math.pow(eit_alpha, 2) * nz(src[1])) - ((eit_alpha - (0.75 * math.pow(eit_alpha, 2))) * nz(src[2])) + (2 * (1 - eit_alpha) * nz(baseline[1])) - (math.pow(1 - eit_alpha, 2) * nz(baseline[2])) else if type == 'ESD | Ehlers Simple Decycler' // by everget // High-pass Filter alphaArg = 2 * math.pi / (len * math.sqrt(2)) alpha = 0.0 alpha := math.cos(alphaArg) != 0 ? (math.cos(alphaArg) + math.sin(alphaArg) - 1) / math.cos(alphaArg) : nz(alpha[1]) hp = 0.0 hp := math.pow(1 - (alpha / 2), 2) * (src - 2 * nz(src[1]) + nz(src[2])) + 2 * (1 - alpha) * nz(hp[1]) - math.pow(1 - alpha, 2) * nz(hp[2]) baseline := src - hp baseline //============================================================================== //============================================================================== // Inputs //============================================================================== // Main inputs for ATR atr_length = input.int(14, title = "ATR Length", minval = 1, group = 'ATR Settings', inline = 'ATR Settings') atr_smth_type = input.string('RMA | Rolling MA', 'ATR Smoothing', options = [ 'EMA | Exponential MA', 'SMA | Simple MA', 'WMA | Weighted MA', 'DEMA | Double Exponential MA', 'TEMA | Triple Exponential MA', 'TMA | Triangular MA', 'VWMA | Volume-Weighted MA', 'SMMA | Smoothed MA', 'HMA | Hull MA', 'LSMA | Least Squares MA', 'Kijun', 'MD | McGinley Dynamic', 'RMA | Rolling MA', 'JMA | Jurik MA', 'ALMA | Arnaud Legoux MA', 'VAR | Vector Autoregression MA', 'WWMA | Welles Wilder MA', 'ZLEMA | Zero-Lag Exponential MA', 'AHMA | Ahrens Moving Average', 'EVWMA | Elastic Volume Weighted MA', 'SWMA | Sine Weighted MA', 'LMA | Leo MA', 'VIDYA | Variable Index Dynamic Average', 'FRAMA | Fractal Adaptive MA', 'VMA | Variable MA', 'GMMA | Geometric Mean MA', 'CMA | Corrective MA', 'MM | Moving Median', 'QMA | Quick MA', 'KAMA | Kaufman Adaptive MA', 'VAMA | Volatility Adjusted MA', 'Modular Filter', 'EIT | Ehlers Instantaneous Trendline', 'ESD | Ehlers Simple Decycler' ], group = 'ATR Settings', inline = 'ATR Settings') // Main inputs for Moving Average atr_ma_length = input.int(20, title = "MA Length", minval = 2, group = 'ATR MA Settings', inline = 'ATR Settings') atr_ma_type = input.string('SMA | Simple MA', 'MA Type', options = [ 'EMA | Exponential MA', 'SMA | Simple MA', 'WMA | Weighted MA', 'DEMA | Double Exponential MA', 'TEMA | Triple Exponential MA', 'TMA | Triangular MA', 'VWMA | Volume-Weighted MA', 'SMMA | Smoothed MA', 'HMA | Hull MA', 'LSMA | Least Squares MA', 'Kijun', 'MD | McGinley Dynamic', 'RMA | Rolling MA', 'JMA | Jurik MA', 'ALMA | Arnaud Legoux MA', 'VAR | Vector Autoregression MA', 'WWMA | Welles Wilder MA', 'ZLEMA | Zero-Lag Exponential MA', 'AHMA | Ahrens Moving Average', 'EVWMA | Elastic Volume Weighted MA', 'SWMA | Sine Weighted MA', 'LMA | Leo MA', 'VIDYA | Variable Index Dynamic Average', 'FRAMA | Fractal Adaptive MA', 'VMA | Variable MA', 'GMMA | Geometric Mean MA', 'CMA | Corrective MA', 'MM | Moving Median', 'QMA | Quick MA', 'KAMA | Kaufman Adaptive MA', 'VAMA | Volatility Adjusted MA', 'Modular Filter', 'EIT | Ehlers Instantaneous Trendline', 'ESD | Ehlers Simple Decycler' ], group = 'ATR MA Settings', inline = 'ATR Settings') // Specific smoothing settings for ATR atr_smth_alma_offset = input.float(title = "Offset (ATR)", defval = 0.85, step = 0.05, group = 'ALMA Settings', inline = 'ALMA Offset') atr_smth_alma_sigma = input.int(title = 'Sigma (ATR)', defval = 6, group = 'ALMA Settings', inline = 'ALMA Sigma') atr_smth_kama_fastLength = input(title = 'Fast EMA Length (ATR)', defval=2, group = 'KAMA Settings', inline = 'KAMA Fast EMA Length') atr_smth_kama_slowLength = input(title = 'Slow EMA Length (ATR)', defval=30, group = 'KAMA Settings', inline = 'KAMA Slow EMA Length') atr_smth_vama_vol_len = input.int(title = 'Volatality Length (ATR)', defval = 51, group = 'VAMA Settings', inline = 'VAMA Volatility Length') atr_smth_vama_do_smth = input.bool(title = 'Do Smoothing? (ATR)', defval = false, group = 'VAMA Settings', inline = 'VAMA Do Smoothing?') atr_smth_vama_smth = input.int(title = 'Smoothing length (ATR)', defval = 5, minval = 1, group = 'VAMA Settings', inline = 'VAMA Smoothing length') atr_smth_mf_beta = input.float(title = 'Beta (ATR)', defval = 0.8, step = 0.1, minval = 0, maxval=1, group = 'Modular Filter Settings', inline = 'MF Beta') atr_smth_mf_feedback = input.bool(title = 'Feedback? (ATR)', defval = false, group = 'Modular Filter Settings', inline = 'MF Feedback?') atr_smth_mf_z = input.float(title = 'Feedback Weighting (ATR)', defval = 0.5, step = 0.1, minval = 0, maxval = 1, group = 'Modular Filter Settings', inline = 'MF Feedback Weighting') atr_smth_eit_alpha = input.float(title = 'Alpha (ATR)', defval = 0.07, step = 0.01, minval = 0.0, group = 'Ehlers Instantaneous Trendline Settings', inline = 'EIT Alpha') // Specific smoothing settings for Moving Average atr_ma_alma_offset = input.float(title = "Offset (MA)", defval = 0.85, step = 0.05, group = 'ALMA Settings', inline = 'ALMA Offset') atr_ma_alma_sigma = input.int(title = 'Sigma (MA)', defval = 6, group = 'ALMA Settings', inline = 'ALMA Sigma') atr_ma_kama_fastLength = input(title = 'Fast EMA Length (MA)', defval=2, group = 'KAMA Settings', inline = 'KAMA Fast EMA Length') atr_ma_kama_slowLength = input(title = 'Slow EMA Length (MA)', defval=30, group = 'KAMA Settings', inline = 'KAMA Slow EMA Length') atr_ma_vama_vol_len = input.int(title = 'Volatality Length (MA)', defval = 51, group = 'VAMA Settings', inline = 'VAMA Volatility Length') atr_ma_vama_do_smth = input.bool(title = 'Do Smoothing? (MA)', defval = false, group = 'VAMA Settings', inline = 'VAMA Do Smoothing?') atr_ma_vama_smth = input.int(title = 'Smoothing length (MA)', defval = 5, minval = 1, group = 'VAMA Settings', inline = 'VAMA Smoothing length') atr_ma_mf_beta = input.float(title = 'Beta (MA)', defval = 0.8, step = 0.1, minval = 0, maxval=1, group = 'Modular Filter Settings', inline = 'MF Beta') atr_ma_mf_feedback = input.bool(title = 'Feedback? (MA)', defval = false, group = 'Modular Filter Settings', inline = 'MF Feedback?') atr_ma_mf_z = input.float(title = 'Feedback Weighting (MA)', defval = 0.5, step = 0.1, minval = 0, maxval = 1, group = 'Modular Filter Settings', inline = 'MF Feedback Weighting') atr_ma_eit_alpha = input.float(title = 'Alpha (MA)', defval = 0.07, step = 0.01, minval = 0.0, group = 'Ehlers Instantaneous Trendline Settings', inline = 'EIT Alpha') //============================================================================== //============================================================================== // Calculate ATR and ATR MA //============================================================================== atr = get_ma_out(atr_smth_type, ta.tr(true), atr_length, atr_smth_alma_offset, atr_smth_alma_sigma, atr_smth_kama_fastLength, atr_smth_kama_slowLength, atr_smth_vama_vol_len, atr_smth_vama_do_smth, atr_smth_vama_smth, atr_smth_mf_beta, atr_smth_mf_feedback, atr_smth_mf_z, atr_smth_eit_alpha) atr_ma = get_ma_out(atr_ma_type, atr, atr_ma_length, atr_ma_alma_offset, atr_ma_alma_sigma, atr_ma_kama_fastLength, atr_ma_kama_slowLength, atr_ma_vama_vol_len, atr_ma_vama_do_smth, atr_ma_vama_smth, atr_ma_mf_beta, atr_ma_mf_feedback, atr_ma_mf_z, atr_ma_eit_alpha) //============================================================================== //============================================================================== // Plot ATR and ATR MA //============================================================================== atr_plot = plot(atr, title = "ATR", color = color.new(#000000, 0), linewidth = 2) atr_ma_plot = plot(atr_ma, title = "ATR MA", color = color.new(#000000, 70)) fillColor = atr > atr_ma ? color.blue : color.red fill(atr_plot, atr_ma_plot, title = "ATR Fill", color = color.new(fillColor, 70)) //==============================================================================
volatility_24h
https://www.tradingview.com/script/ZaRKTSIw-volatility-24h/
federalTacos24740
https://www.tradingview.com/u/federalTacos24740/
9
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © federalTacos24740 //@version=5 indicator("volatility_1m_close", timeframe='1',overlay=true) arr = array.new_float(1440) for i = 0 to 1439 roc=math.log(close[i]/close[i+1]) array.push(arr, roc) sd = array.stdev(arr) vol=100*sd*math.sqrt(1440) plot(vol)
Lowry Upside % Volume
https://www.tradingview.com/script/DzG4WcvF-Lowry-Upside-Volume/
BullRiderCapital
https://www.tradingview.com/u/BullRiderCapital/
275
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/ // © BullRiderCapital //@version=4 study(title = "Lowry Upside % Volume", shorttitle="Upside % Vol", precision=2) sym(s) => security(s, "D", close) // Calculation // Get total volume or the sum of Upside Volume and Downside Volume // Divide Upside Volume by total volume to get Upside % Volume divide = (sym("USI:UPVOL.NY")) / (sym("USI:TVOL.NY")) barColor = divide >= .90 ? #7CFC00 : divide >= .80 ? #7FFFD4 : divide <= .10 ? #FF0000 : #194859 plot(divide, "Lowry Vol Alert", barColor, style=plot.style_columns)
Rally HTF Candle (Candlestick Analysis) Guaranteed Winners
https://www.tradingview.com/script/aKOawPus-Rally-HTF-Candle-Candlestick-Analysis-Guaranteed-Winners/
LuxTradeVenture
https://www.tradingview.com/u/LuxTradeVenture/
176
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MINTYFRESH97 //@version=5 indicator("Rally D/6h Candle" ,overlay=true ) //user input var g_ema = "EMA Filter" emaLength = input.int(title="EMA Length", defval=100, tooltip="Length of the EMA filter", group=g_ema) useEmaFilter = input.bool(title="Use EMA Filter?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema) // Get EMA filter ema = ta.ema(close, emaLength) emaFilterLong = not useEmaFilter or close > ema emaFilterShort = not useEmaFilter or close < ema //////rallycandledaily //swing high/low filter swingHigh = high == ta.highest(high,5) or high[1] == ta.highest(high,5) RallieCandle = (close[2] > close[3]) and (close[1] > close[2]) and (close < close[1]) and emaFilterShort and swingHigh and timeframe.isdaily ///////rallycandle6h //swing high/low filter swingHighx = high == ta.highest(high,8) or high[1] == ta.highest(high,8) RallieCandle6h = (close[3] > close[4]) and (close[2] > close[23]) and (close < close[1]) and emaFilterShort and swingHigh // Plot our candle patterns plotshape(RallieCandle, style=shape.xcross,size=size.tiny, color=color.red, text="R",location=location.abovebar) barcolor (RallieCandle ? color.purple :na) alertcondition(RallieCandle, "RallieCandle", "RallieCandle detected for {{ticker}}") // Plot our candle patterns plotshape(RallieCandle6h, style=shape.xcross,size=size.tiny, color=color.red, text="R",location=location.abovebar) barcolor (RallieCandle6h ? color.purple :na) alertcondition(RallieCandle6h, "RallieCandle", "RallieCandle detected for {{ticker}}")
BTC Active1Y holders: Onchain
https://www.tradingview.com/script/vcodKkqd-BTC-Active1Y-holders-Onchain/
cryptoonchain
https://www.tradingview.com/u/cryptoonchain/
81
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MJShahsavar //@version=5 indicator("BTC Active1Y holders: Onchain", timeframe = "W") //@version=5 R = input.symbol("BTC_ACTIVE1Y", "Symbol") r = request.security(R, 'M', close) M = ta.rsi(r, 14) h1=hline (90) h2= hline (10) h3= hline (50) h4= hline (120) h5 = hline (140) hashColor = M >= 85 ? color.blue : M <= 20 ? color.red : color.maroon fill (h5, h4, hashColor) plot (M, "hashColor" , M >= 90 ? color.blue : M <= 10 ? color.red : color.maroon, linewidth=1)
HSRL - historical support resistance lines
https://www.tradingview.com/script/IFx4raq7-HSRL-historical-support-resistance-lines/
spiritualhealer117
https://www.tradingview.com/u/spiritualhealer117/
43
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/ // © spiritualhealer117 //@version=4 study("HSRL") length = input(title="Length", type=input.integer, defval=150) resistanceChange = (highest(close,length)-highest(close,length)[length])/highest(close,length)[length] supportChange = (lowest(close,length)-lowest(close,length)[length])/lowest(close,length)[length] HSRL = resistanceChange-supportChange line1=plot(resistanceChange,color=color.green) line2=plot(supportChange,color=color.red) fill(line1,line2,color=resistanceChange>supportChange?(resistanceChange>0?color.new(color.green,50):color.new(color.red,50)):(resistanceChange>0?color.new(color.yellow,25):color.new(color.yellow,50)))
Vix FIX / Stochastic Weights Strategy
https://www.tradingview.com/script/QfgPbWOr-Vix-FIX-Stochastic-Weights-Strategy/
OsMar21
https://www.tradingview.com/u/OsMar21/
245
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © OsMar21 //@version=5 indicator('Vix FIX / Stochastic Weights Strategy', 'VixFIX / StochWeights Strategy', overlay=false) show_StochW = input.bool(true, "Show Stochastic Weights") show_exit = input.bool(true, "Show Signal: OverBought [Stochastic Crossover]") alert_Stoch = input.bool(false, '◁ Alert: OverBought [Stochastic Crossover]') enableStoch = input.bool(true, "Enable Stochastic") smoothStochK = input.int(3, "Stochastic K MA Length", minval=1) lengthStoch = input.int(14, "Stochastic Lookback Length", minval=1) enableRSI = input.bool(false, "Enable RSI") rsiLength = input.int(14, "RSI Lookback Length", minval=1) enableStochRSI = input.bool(true, "Enable Stochastic RSI") smoothStochRSIK = input.int(3, "Stochastic RSI K MA Length", minval=1) lengthStochRSI = input.int(14, "Stochastic RSI - Stochastic Lookback Length", minval=1) rsiLengthInStochRSI = input.int(14, "Stochastic RSI - RSI Lookback Length", minval=1) enableStochVOL = input.bool(false, "Enable Stochastic VOL [BigBitsIO]") smoothStochVOLK = input.int(3, "Stochastic VOL K MA Length", minval=1) lengthStochVOL = input.int(14, "Stochastic VOL Lookback Length", minval=1) superStochVOLFastSmoothLength = input.int(6, "Stochastic VOL Super Fast Smoothing Length", minval=1) enableStochPC = input.bool(false, "Enable Stochastic PC [BigBitsIO]") smoothStochPCK = input.int(3, "Stochastic PC K MA Length", minval=1) lengthStochPC = input.int(8, "Stochastic PC Lookback Length", minval=1) superStochPCFastSmoothLength = input.int(4, "Stochastic PC Super Fast Smoothing Length", minval=1) smoothD = input.int(3, "Stochastic D Length (only applies to weighted K)", minval=1) sbcFilt = input.bool(true, 'Show Signal For Filtered Entry [▲ FE ]', group='Williams Vix Fix') // Use FILTERED Criteria sbcAggr = input.bool(true, 'Show Signal For AGGRESSIVE Filtered Entry [▲ AE ]', group='Williams Vix Fix') // Use FILTERED Criteria alert_AE = input.bool(false, '◁ Alert: [AGGRESSIVE Entry]', inline='AlertVF', group='Williams Vix Fix') alert_FE = input.bool(false, '◁ Alert: [Filtered Entry]', inline='AlertVF', group='Williams Vix Fix') pd = input.int(22, 'LookBack Period Standard Deviation High', group='Williams Vix Fix') bbl = input.int(20, 'Bolinger Band Length', group='Williams Vix Fix') mult = input.float(2.0, 'Bollinger Band Standard Devaition Up', minval=1, maxval=5, group='Williams Vix Fix') lb = input.int(50, 'Look Back Period Percentile High', group='Williams Vix Fix') ph = input.float(.85, 'Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%', group='Williams Vix Fix') ltLB = input.int(40, minval=25, maxval=99, title='Long-Term Look Back Current Bar Has To Close Below This Value OR Medium Term--Default=40', group='Williams Vix Fix') mtLB = input.int(14, minval=10, maxval=20, title='Medium-Term Look Back Current Bar Has To Close Below This Value OR Long Term--Default=14', group='Williams Vix Fix') str = input.int(3, minval=1, maxval=9, title='Entry Price Action Strength--Close > X Bars Back---Default=3', group='Williams Vix Fix') show_StochCCI = input.bool(false, "Show StochCCI", inline="show_scci", group="Ehlers Stochastic CCI") show_dots = input.bool(false, "Show Circle on Cross", inline="show_scci", group="Ehlers Stochastic CCI") color_change = input.bool(true, "Color Change", inline="show_scci", group="Ehlers Stochastic CCI") RSI_Length = input.int(8, "Length: RSI", minval=1, inline="len", group="Ehlers Stochastic CCI") Stoc_Length = input.int(8, "Stoch", minval=1, inline="len", group="Ehlers Stochastic CCI") WMA_Length = input.int(5, "WMA", minval=1, inline="len", group="Ehlers Stochastic CCI") alert_StochCCI = input.bool(false, "◁ Alert: [Buy / Sell]", group="Ehlers Stochastic CCI") //_____________________________________________________________________________________________ // Based on "MStochastic Weights - Basic [BigBitsIO]" - Author: @BigBitsIO // https://www.tradingview.com/script/DOgvQOPh-Stochastic-Weights-Basic-BigBitsIO/ //_____________________________________________________________________________________________ int Weights = 0 float WeightedTotal = 0 float percentChange = 0 float SPC = 0 float StochPC = 0 if(enableStochPC) percentChange := ((close - open) / open) * 100 SPC := ta.sma(percentChange, superStochPCFastSmoothLength) StochPC := ta.sma(ta.stoch(SPC, SPC, SPC, lengthStochPC), smoothStochPCK) Weights := Weights + 1 WeightedTotal := WeightedTotal + StochPC float Stoch = 0 if(enableStoch) Stoch := ta.sma(ta.stoch(close, high, low, lengthStoch), smoothStochK) Weights := Weights + 1 WeightedTotal := WeightedTotal + Stoch float RSIInStochRSI = 0 float StochRSI = 0 if(enableStochRSI) RSIInStochRSI := ta.rsi(close, rsiLengthInStochRSI) StochRSI := ta.sma(ta.stoch(RSIInStochRSI, RSIInStochRSI, RSIInStochRSI, lengthStochRSI), smoothStochRSIK) Weights := Weights + 1 WeightedTotal := WeightedTotal + StochRSI float RSI = 0 if(enableRSI) RSI := ta.rsi(close, rsiLength) Weights := Weights + 1 WeightedTotal := WeightedTotal + RSI float VOLInStochVOL = 0 float SVOL = 0 float StochVOL = 0 if(enableStochVOL) VOLInStochVOL := close >= open ? volume : volume * -1 SVOL := ta.sma(VOLInStochVOL, superStochVOLFastSmoothLength) StochVOL := ta.sma(ta.stoch(SVOL, SVOL, SVOL, lengthStochVOL), smoothStochVOLK) Weights := Weights + 1 WeightedTotal := WeightedTotal + StochVOL k = WeightedTotal / Weights d = ta.sma(k, smoothD) plot(show_StochW ? k : na, color=color.aqua, title="K (Weighted)", linewidth=2) plot(show_StochW ? d : na, color=color.orange, title="D", linewidth=2) h0 = hline(80, "Overbought Level") h1 = hline(20, "Oversold Level") fill(h0, h1, color=color.new(color.purple, 80)) //_____________________________________________________________________________________________ // Based on "Matrix Series and Vix Fix with VWAP CCI and QQE Signals" // Author: @ChrisMoody and @OskarGallard // https://www.tradingview.com/script/n8l5QqjD/ //_____________________________________________________________________________________________ // Williams Vix Fix Formula wvf = (ta.highest(close, pd) - low) / ta.highest(close, pd) * 100 sDev = mult * ta.stdev(wvf, bbl) midLine = ta.sma(wvf, bbl) lowerBand = midLine - sDev upperBand = midLine + sDev rangeHigh = ta.highest(wvf, lb) * ph // Filtered Criteria upRange = low > low[1] and close > high[1] upRange_Aggr = close > close[1] and close > open[1] // Filtered Criteria filtered = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and wvf < upperBand and wvf < rangeHigh filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and not(wvf < upperBand and wvf < rangeHigh) // Alerts Criteria alert1 = wvf >= upperBand or wvf >= rangeHigh ? 1 : 0 alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and wvf < upperBand and wvf < rangeHigh ? 1 : 0 cond_FE = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered alert3 = cond_FE ? 1 : 0 cond_AE = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr alert4 = cond_AE ? 1 : 0 color_VF = alert1 ? color.new(color.lime, 60) : alert2 ? color.new(color.teal, 60) : color.new(color.silver, 80) plotshape(sbcAggr and alert4 ? alert4 : na, title='Aggressive Entry', color=color.new(#80FF00, 0), style=shape.triangleup, location=location.bottom, text='AE', textcolor=color.new(#80FF00, 0)) bgcolor(sbcAggr and alert4 ? color.new(#80FF00, 80) : na, title='Aggressive Entry') plotshape(sbcFilt and alert3 ? alert3 : na, title='Filtered Entry', color=color.new(#15FF00, 0), style=shape.triangleup, location=location.bottom, text='FE', textcolor=color.new(#15FF00, 0)) bgcolor(sbcFilt and alert3 ? color.new(#15FF00, 80) : na, title='Filtered Entry') if alert_AE and cond_AE alert('Symbol = (' + syminfo.tickerid + ') \n TimeFrame = (' + timeframe.period + ') \n Current Price (' + str.tostring(close) + ') \n Aggressive Entry [VixFix].-', alert.freq_once_per_bar_close) if alert_FE and cond_FE alert('Symbol = (' + syminfo.tickerid + ') \n TimeFrame = (' + timeframe.period + ') \n Current Price (' + str.tostring(close) + ') \n Filtered Entry [VixFix].-', alert.freq_once_per_bar_close) isOverBought = ta.crossunder(k, d) and d > 80 plotshape(show_exit and isOverBought, title='Stochastic Crossover', color=color.new(#FF8080, 0), style=shape.triangledown, location=location.top, text='S', textcolor=color.new(#FF8080, 0)) bgcolor(show_exit and isOverBought ? color.new(#FF0015, 65) : na, title='Stochastic Crossover') if alert_Stoch and isOverBought alert('Symbol = (' + syminfo.tickerid + ') \n TimeFrame = (' + timeframe.period + ') \n Current Price (' + str.tostring(close) + ') \n Exit [Stochastic Crossover].-', alert.freq_once_per_bar_close) //_____________________________________________________________________________________________ // Based on "Ehlrers StochCCI" - Author: @glaz // https://www.tradingview.com/script/OC5yz8CP-Ehlrers-StochCCI/ //_____________________________________________________________________________________________ // A variation of Ehlers Stochastic RSI Value1 = ta.cci(hlc3, RSI_Length) - ta.lowest(ta.cci(hlc3, RSI_Length), Stoc_Length) Value2 = ta.highest(ta.cci(close, RSI_Length), Stoc_Length) - ta.lowest(ta.cci(close, RSI_Length), Stoc_Length) Value3 = nz(Value1/Value2) Value4 = ta.wma(Value3, WMA_Length)*100 //2 * (ta.wma(Value3, WMA_Length) - 0.5) Trigger = Value4[1] cross_UP = ta.crossover(Value4, Trigger) and Value4 < 50 cross_DN = ta.crossunder(Value4, Trigger) and Value4 > 50 col = color_change ? Value4 > Value4[1] ? #00FF90 : #FF006E : #00FF90 plot(show_StochCCI ? Value4 : na, "StochCCI", color=col) plot(show_StochCCI ? Trigger : na, "Trigger", color=color.yellow) plot(show_dots and cross_UP ? Trigger : na, title="Buy's Dots", color=color.new(#00FF90, 40), style=plot.style_circles, linewidth=5) plot(show_dots and cross_DN ? Trigger : na, title="Sell's Dots", color=color.new(#FF006E, 30), style=plot.style_circles, linewidth=5) if alert_StochCCI and cross_UP alert('Symbol = (' + syminfo.tickerid + ') \n TimeFrame = (' + timeframe.period + ') \n Current Price (' + str.tostring(close) + ') \n Buy [StochCCI].-', alert.freq_once_per_bar_close) if alert_StochCCI and cross_DN alert('Symbol = (' + syminfo.tickerid + ') \n TimeFrame = (' + timeframe.period + ') \n Current Price (' + str.tostring(close) + ') \n Sell [StochCCI].-', alert.freq_once_per_bar_close)
Congestion Zone
https://www.tradingview.com/script/Eo36qGtD-Congestion-Zone/
HLongTran
https://www.tradingview.com/u/HLongTran/
405
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/ // © HLong Tran //@version=4 study("Congestion Zone", overlay = true, max_boxes_count = 500) ZoneColor = input(defval = color.new(color.orange, 70), title = "Color") var aCZ = array.new_float(0) congestionCondtion = close >= low[1] and close <= high[1] and open >= low[1] and open <= high[1] if ( congestionCondtion == true ) array.push(aCZ, open) array.push(aCZ, close) else if( array.size(aCZ) < 6 ) array.clear(aCZ) if( array.size(aCZ) >= 6 and congestionCondtion == false ) float maxCZ = array.max(aCZ) float minCZ = array.min(aCZ) box.new(bar_index - (array.size(aCZ) / 2), maxCZ, bar_index - 1, minCZ, bgcolor = ZoneColor, border_color = na) array.clear(aCZ)
Solar Seasons
https://www.tradingview.com/script/BMaWNiWV-Solar-Seasons/
jtonka
https://www.tradingview.com/u/jtonka/
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/ // © jamiedubauskas //@version=5 indicator(title = "Seasons", shorttitle = "Seasons", overlay = true) show_summer = input.bool(title = "Summer", defval = true) show_spring = input.bool(title = "Spring", defval = true) show_winter = input.bool(title = "Winter", defval = true) show_fall = input.bool(title = "Fall", defval = true) current_hemisphere = input.string(title = "Current Hemisphere", options = ["Northern", "Southern"], defval = "Northern") month = (dayofmonth < 21 and month > 1) ? month-1 : month is_summer = current_hemisphere == "Northern" ? month >= 6 and month <= 8 : month == 12 or month == 1 or month == 2 is_spring = current_hemisphere == "Northern" ? month >= 3 and month <= 5 : month >= 9 and month <= 11 is_fall = current_hemisphere == "Northern" ? month >= 9 and month <= 11 : month >= 3 and month <= 5 is_winter = current_hemisphere == "Northern" ? month == 12 or month == 1 or month == 2 : month >= 6 and month <= 8 // plotting the instances of summmer bgcolor(is_summer and show_summer ? color.new(color.yellow, 75) : na) bgcolor(is_spring and show_spring ? color.new(color.blue, 75) : na) bgcolor(is_fall and show_fall ? color.new(color.orange, 75) : na) bgcolor(is_winter and show_winter ? color.new(color.white, 75) : na)
Ratio For Harmonic Points
https://www.tradingview.com/script/Rw1kblYq-Ratio-For-Harmonic-Points/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
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/ // © RozaniGhani-RG //@version=5 indicator('Ratio For Harmonic Points', shorttitle = 'RFHP') // 0. Inputs // 1. Arrays and variables // 2. Switch // 3. Custom functions // 4. Delete drawings // 5. Construct // ————————————————————————————————————————————————————————————————————————————— 0. Inputs { G1 = 'Animal' point = input.string( 'B = XA', 'Point', options = ['B = XA', 'C = AB', 'D = BC', 'D = XA', 'Stop Loss']) show = input.bool(true, 'Show D = XA labels') b_abat = input.bool(true, '  Alt Bat 1.130 XA', group = G1, inline ='0') b_bat = input.bool(true, '      Bat 0.886 XA', group = G1, inline ='0') b_crab = input.bool(true, '   Crab 1.618 XA', group = G1, inline ='1') b_gart = input.bool(true, '   Gartley 0.786 XA', group = G1, inline ='1') b_bfly = input.bool(true, 'Butterfly 1.270 XA', group = G1, inline ='2') b_dcrab = input.bool(true, 'Deep Crab 1.618 XA', group = G1, inline ='2') // } // ————————————————————————————————————————————————————————————————————————————— 1. Arrays and variables { p0 = math.rphi p1 = math.phi p2 = math.rphi + 2 p3 = math.rphi + 3 arr_bool = array.new_bool(6) box[] box_bxa = array.new_box(6), box[] box_cab = array.new_box(6), box[] box_dbc = array.new_box(6) line_dxa = array.new_line(6), line_sl = array.new_line(6) label_dxa = array.new_label(6), label_sl = array.new_label(6) array_label = array.new_label(6) label_bxa_min = array.new_label(6), label_bxa_max = array.new_label(6) label_cab_min = array.new_label(6), label_cab_max = array.new_label(6) label_dbc_min = array.new_label(6), label_dbc_max = array.new_label(6) animal = array.from('ALT BAT', 'BAT', 'CRAB', 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB') bar_label = array.from( 95, 85, 75, 65, 55, 45) box_left = array.from( 100, 90, 80, 70, 60, 50) box_right = array.from( 90, 80, 70, 60, 50, 40) bxa_min = array.from( .371, .382, .382, .599, .762, .886) bxa_max = array.from( .382, .5 , .618, .637, .81 , .913) dbc_min = array.from(2. , p1, p2, 1.130, p1, 2. ) dbc_max = array.from( p3, p2, p3, p1, 2.24 , p3) dxa = array.from(1.13 , .886, p1, .786, 1.27 , p1) sl = array.from(1.27 , 1.130, 2. , 1. , 1.414, 2. ) var ratioTable = table.new(position.top_center, 1, 2, border_width = 1) var int _left = na, var int _right = na var float _top = na, var float _bottom = na var int _x = na var float _y = na, var float _y1 = na, var float _y2 = na var string _text = na array.set(arr_bool, 0, b_abat) array.set(arr_bool, 1, b_bat) array.set(arr_bool, 2, b_crab) array.set(arr_bool, 3, b_gart) array.set(arr_bool, 4, b_bfly) array.set(arr_bool, 5, b_dcrab) // } // ————————————————————————————————————————————————————————————————————————————— 2. Switch { col = switch point 'B = XA' => color.red 'C = AB' => color.red 'D = BC' => color.blue 'D = XA' => color.blue 'Stop Loss' => color.blue // } // ————————————————————————————————————————————————————————————————————————————— 3. Custom functions { f_delete_box(_id) => for x = 0 to array.size(_id) - 1 box.delete(array.get(_id, x)) f_delete_label(_id) => for x = 0 to array.size(_id) - 1 label.delete(array.get(_id, x)) // } // ————————————————————————————————————————————————————————————————————————————— 4. Delete drawings { f_delete_box(box_bxa) f_delete_label(array_label) // } // ————————————————————————————————————————————————————————————————————————————— 5. Construct { if barstate.islast table.cell(ratioTable, 0, 0, 'Ratio For Harmonic Points', bgcolor = color.new(color.blue, 100), text_color = color.blue) table.cell(ratioTable, 0, 1, point, bgcolor = color.new(color.blue, 100), text_color = color.blue) for x = 0 to 5 if array.get(arr_bool, x) _x := bar_index[array.get(bar_label, x)] _text := show ? array.get(animal, x) + str.tostring(array.get(dxa, x), '\n 0.000 XA') : array.get(animal, x) array.set(array_label, x, label.new(_x, 0, _text, color = col, style = label.style_label_center, textcolor = color.white)) if point == 'B = XA' _left := bar_index[array.get(box_left, x)] _top := array.get(bxa_max, x) _right := bar_index[array.get(box_right, x)] _bottom := array.get(bxa_min, x) _x := bar_index[array.get(bar_label, x)] _y1 := array.get(bxa_min, x) _y2 := array.get(bxa_max, x) array.set(box_bxa, x, box.new(_left, _top, _right, _bottom, border_color = color.black, bgcolor = col)) array.set(label_bxa_min, x, label.new(_x, _y1, str.tostring(_y1, '0.000'), color = color.new(color.blue, 100), style = label.style_label_up, textcolor = col)) array.set(label_bxa_max, x, label.new(_x, _y2, str.tostring(_y2, '0.000'), color = color.new(color.blue, 100), style = label.style_label_down, textcolor = col)) else if point == 'C = AB' _left := bar_index[array.get(box_left, x)] _right := bar_index[array.get(box_right, x)] _x := bar_index[array.get(bar_label, x)] _y1 := array.get(bxa_min, x) _y2 := array.get(bxa_max, x) array.set(box_bxa, x, box.new(_left, 0.886, _right, 0.382, border_color = color.black, bgcolor = col)) array.set(label_cab_min, x, label.new(_x, 0.382, '0.382', color = color.new(color.blue, 100), style = label.style_label_up, textcolor = col)) array.set(label_cab_max, x, label.new(_x, 0.886, '0.886', color = color.new(color.blue, 100), style = label.style_label_down, textcolor = col)) else if point == 'D = BC' _left := bar_index[array.get(box_left, x)] _top := array.get(dbc_max, x) _right := bar_index[array.get(box_right, x)] _bottom := array.get(dbc_min, x) _x := bar_index[array.get(bar_label, x)] _y1 := array.get(dbc_min, x) _y2 := array.get(dbc_max, x) array.set(box_bxa, x, box.new(_left, _top, _right, _bottom, border_color = color.black, bgcolor = col)) array.set(label_dbc_min, x, label.new(_x, _y1, str.tostring(_y1, '0.000'), color = color.new(color.blue, 100), style = label.style_label_up, textcolor = col)) array.set(label_dbc_max, x, label.new(_x, _y2, str.tostring(_y2, '0.000'), color = color.new(color.blue, 100), style = label.style_label_down, textcolor = col)) else if point == 'D = XA' _left := bar_index[array.get(box_left, x)] _right := bar_index[array.get(box_right, x)] _x := bar_index[array.get(bar_label, x)] _y := array.get(dxa, x) array.set(line_dxa, x, line.new(_left, _y, _right, _y, color = col)) array.set(label_dxa, x, label.new(_x, _y, str.tostring(_y, '0.000'), color = color.new(color.blue, 100), style = label.style_label_down, textcolor = col)) label.set_color( array.get(array_label, 1), color.red) label.set_color( array.get(array_label, 3), color.red) label.set_textcolor(array.get(label_dxa, 1), color.red) label.set_textcolor(array.get(label_dxa, 3), color.red) line.set_color( array.get(line_dxa, 1), color.red) line.set_color( array.get(line_dxa, 3), color.red) if point == 'Stop Loss' _left := bar_index[array.get(box_left, x)] _right := bar_index[array.get(box_right, x)] _x := bar_index[array.get(bar_label, x)] _y := array.get(sl, x) array.set(line_sl, x, line.new(_left, _y, _right, _y, color = col)) array.set(label_sl, x, label.new(_x, _y, str.tostring(_y, '0.000'), color = color.new(color.blue, 100), style = label.style_label_up, textcolor = col)) hline(point == 'B = XA' ? 1.2 : na, 'B = XA', color.new(color.blue, 100)) hline(point == 'C = AB' ? 1.2 : na, 'C = AB', color.new(color.blue, 100)) hline(point == 'D = BC' ? 4.0 : na, 'D = BC', color.new(color.blue, 100)) hline(point == 'D = XA' ? 2.5 : na, 'D = XA', color.new(color.blue, 100)) hline(point == 'Stop Loss' ? 2.5 : na, 'Stop Loss', color.new(color.blue, 100)) // }
Normal Distribution Outliers for volume (NDO indicator)
https://www.tradingview.com/script/Wm85hYLA-Normal-Distribution-Outliers-for-volume-NDO-indicator/
spiritualhealer117
https://www.tradingview.com/u/spiritualhealer117/
97
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © spiritualhealer117 //@version=5 indicator("NDO") length = input(14, "Length") use_sv = input.bool(false,"Use Short Volume") bool overwriteSymbolInput = input.bool(false, "Other symbol", inline = "OS", group = "Short Volume") string tickerInput = input.symbol("", "", inline = "OS", group = "Short Volume") string symbolOnly = str.substring(tickerInput, str.pos(tickerInput, ":") + 1) string userSymbol = overwriteSymbolInput ? symbolOnly : syminfo.ticker string shortVolumeTicker = str.format("FINRA:{0}_SHORT_VOLUME", userSymbol) [shortVolume, shortVolumeMa] = request.security(shortVolumeTicker, "D", [close, ta.sma(close, length)], ignore_invalid_symbol = true) var string[] validPrefixes = array.from("BATS", "NASDAQ", "NYSE", "AMEX") src = shortVolume moving_average = ta.ema(src,length) standard_deviation = ta.stdev(src,length) src2 = volume moving_average2 = ta.ema(src2,length) standard_deviation2 = ta.stdev(src2, length) standardized_volume = (src-moving_average)/standard_deviation standardized_volume2 = (src2-moving_average2)/standard_deviation2 clor = standardized_volume > 3 ? color.green : standardized_volume > 2 ? color.yellow : standardized_volume >1 ? color.orange : color.red color2=standardized_volume2 > 3 ? color.green : standardized_volume2 > 2 ? color.yellow : standardized_volume2 >1 ? color.orange : color.red //Volume - short volume, if gap is massive then its a whale selling off or buying in, while short volume disagrees plot(use_sv?standardized_volume:standardized_volume2,color=use_sv?clor:color2, title="NDO",style=plot.style_columns) hline(-1) hline(0) hline(1) hline(2) hline(3)
Double Ichimoku Cloud with drop-down selectable lookback periods
https://www.tradingview.com/script/fCd9YWiJ-Double-Ichimoku-Cloud-with-drop-down-selectable-lookback-periods/
Ronbo83
https://www.tradingview.com/u/Ronbo83/
54
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/ // © lockeyj provided much of the original code. Many other coders inspired my modications. Thanks everyone. // Edit: Ronbo //@version=4 study(title="IL", overlay=true) // Input options showkumoborder = input(true , "Show Kumu Border?") showLagging = input(true , "Show Chikou Span?") bar = input(title="Allow Bar Color Change?", type=input.bool, defval=false) ichisettings = input("9-26-52-26", "Ichimoku Settings", input.string , options=["7-22-44-22", "8-24-48-24", "9-26-52-26", "10-30-60-30"]) tslen(ichisettings) => if ichisettings == "7-22-44-22" 7 else if ichisettings == "8-24-48-24" 8 else if ichisettings == "9-26-52-26" 9 else 10 kslen(ichisettings) => if ichisettings == "7-22-44-22" 22 else if ichisettings == "8-24-48-24" 24 else if ichisettings == "9-26-52-26" 26 else 30 sslen(ichisettings) => if ichisettings == "7-22-44-22" 44 else if ichisettings == "8-24-48-24" 48 else if ichisettings == "9-26-52-26" 52 else 60 shift(ichisettings) => if ichisettings == "7-22-44-22" 22 else if ichisettings == "8-24-48-24" 24 else if ichisettings == "9-26-52-26" 26 else 30 // Ichimoku Cloud #1 conversionLine1 = avg(lowest(tslen(ichisettings)), highest(tslen(ichisettings))) baseLine1 = avg(lowest(kslen(ichisettings)), highest(kslen(ichisettings))) leadLine1_1 = avg(conversionLine1, baseLine1) leadLine2_1 = avg(lowest(sslen(ichisettings)), highest(sslen(ichisettings))) // Ichimoku Cloud #2 conversionLine2 = avg(lowest(2*tslen(ichisettings)), highest(2*tslen(ichisettings))) baseLine2 = avg(lowest(2*kslen(ichisettings)), highest(2*kslen(ichisettings))) leadLine1_2 = avg(conversionLine2, baseLine2) leadLine2_2 = avg(lowest(2*sslen(ichisettings)), highest(2*sslen(ichisettings))) chikoucolor1 = iff(close[shift(ichisettings)] > ohlc4, color.red, color.green) p1_1 = plot(leadLine1_1, offset = shift(ichisettings), color=color.new(color.gray,32), title="K#1L1") p2_1 = plot(leadLine2_1, offset = shift(ichisettings), color=color.new(color.gray,32), title="K#1L2") fill(p1_1, p2_1, color = leadLine1_1 > leadLine2_1 ? color.new(color.green,68) : color.new(color.red,68)) p1_2 = plot(leadLine1_2, offset = shift(ichisettings), color=color.new(color.gray,32), title="K#2L2") p2_2 = plot(leadLine2_2, offset = shift(ichisettings), color=color.new(color.gray,32), title="K#2L2") fill(p1_2, p2_2, color = leadLine1_2 > leadLine2_2 ? color.new(color.green,68) : color.new(color.red,68)) plot(showLagging ? ohlc4 : na, offset = -shift(ichisettings), color=chikoucolor1, title="Chikou Span") // Cloud Borders kumomax = max(leadLine1_1,leadLine2_1,leadLine1_2,leadLine2_2) kumomin = min(leadLine1_1,leadLine2_1,leadLine1_2,leadLine2_2) plot(showkumoborder and kumomax ? kumomax : na, title = 'K Max', style=plot.style_line, linewidth=2, offset = shift(ichisettings), color=color.new(color.black,38)) plot(showkumoborder and kumomin ? kumomin : na, title = 'K Min', style=plot.style_line, linewidth=2, offset = shift(ichisettings), color=color.new(color.black,38)) //Colors bgcolor = close > kumomax[shift(ichisettings)] ? #2BFF00 : #B5000F barcolor(bar ? bgcolor : na)
Determine Consecutive Candles
https://www.tradingview.com/script/hCdhp2Kx-Determine-Consecutive-Candles/
SolCollector
https://www.tradingview.com/u/SolCollector/
45
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SolCollector // BS Computer Science // This simple script allows the user to show when (and for how many) consecutive // black or white candles had been experienced by an asset. Can be applied to // all time frames. This script now has the ability to recognize runs of: // higher highs, lower highs, higher lows, and lower lows, and will properly // display alerts for each of these cases. // // To keep this script simple, it will not feature the usual ASCII-art that has // been present in my other scripts. This was a simple experiment inspired by // something I had found on Twitter regarding Bitcoin experiencing its first // 7th weekly black candle throughout the entirety that it has been trading // (apply this script to INDEX:BTCUSD using following parameters: offset - true, // Number of Candles - 7, Black or White - "Black"). //@version=5 indicator("Determine Consecutive Candles", overlay = true) // INPUT LIST: // enableAlert - (onRun/Break) Allows this script to recognize when runs have // occured/when they break and displays a message to the user when // conditions set by the inputs below are met. // indOffset - Determines which index to begin counting at for runs (either // 0 or 1). // showCPlots - Checkbox to show a visual representation of the values that // are used for logic checks in this script (see tooltip). // onClose - Determines if this script will be applied to the currently // closing candle (false) or most recently closed candle (true). // minCandles - The minimum number of candles to needed for consecutive-ness. // blackOrWhite - Shows runs of black, white, or both candle types on input // given by the user (may also be turned off). // HLBool(s) - Boolean switches for showing runs of higher highs, lower highs, // higher lows, and lower lows (uses minCandles). // i_enableAlertOnRun = input.bool(defval = true, title = "Enable Alerts on Runs", tooltip = "Allows alerts to be fired when runs that exceed the specified " + "minimum number of candles.*\n\n*This must be turned on *prior* to enabling" + " the alert through TradingView.", group = "ALERT SETTINGS") i_enableAlertOnBreak = input.bool(defval = false, title = "Enable Alerts on " + "Broken runs", tooltip = "Fires an alert when a prior run that has exceeded " + "The specified number of candles has ended.*\n\n*This must be turned on " + "*prior* to enabling the alert through TradingView.", group = "ALERT SETTINGS") i_indOffset = input.int(defval = 1, title = "Default Index Starting Value", minval = 0, maxval = 1, tooltip = "Sets the first value that will be used for " + "counting runs.\n\nDefault Value: 1st candle in a run will be '1'.", group = "BEHAVIOR SETTINGS") i_showCounterPlots = input.bool(defval = false, title = "Show Counter Plots", tooltip = "[Diagnostic tools]:\n\nShows a plot of the active counter variables " + "used to determine the number of candles that have occurred in a run of " + "Black or White candles. To properly view this, I recommend moving the " + "indicator to a separate pane above or below before enabling.", group = "BEHAVIOR SETTINGS") i_onClose = input.bool(defval = false, title = "Identify On Close", tooltip = "Identifies on most recent close if true; current candle otherwise.", group = "BEHAVIOR SETTINGS") i_minCandles = input.int(defval = 7, title = "Min Number of Candles", minval = 2, maxval = 100, tooltip = "Minimum number of candles needed to backtest for " + "consecutive candles.", group = "BEHAVIOR SETTINGS") i_blackOrWhite = input.string(defval = "Black", title = "Candle Type Setting", options = ["Black", "White", "Both", "OFF"], tooltip = "Selects which candle type(s) to look for with this script.", group = "BEHAVIOR SETTINGS") // Bool Switches for HL Detection i_HHBool = input.bool(defval = false, title = "HH", group = "BEHAVIOR SETTINGS", inline = "HL SWITCHES") i_LHBool = input.bool(defval = false, title = "LH", group = "BEHAVIOR SETTINGS", inline = "HL SWITCHES") i_HLBool = input.bool(defval = false, title = "HL", group = "BEHAVIOR SETTINGS", inline = "HL SWITCHES") i_LLBool = input.bool(defval = false, title = "LL", tooltip = "HL Detection Switches:\n\nHH - Higher High\nLH - Lower High\nHL - " + "Higher Low\nLL - Lower Low", group = "BEHAVIOR SETTINGS", inline = "HL SWITCHES") // GetOrdinal is a string function that will return the proper ordinal indicator // associated with the parameter given to it. // // Ex: [value returned is outside parenthesis in each case] // // _val == 10 -> (10)th _val == 21 -> (21)st // _val == 11 -> (11)th _val == 31 -> (31)st // _val == 12 -> (12)th _val == 32 -> (32)nd // _val == 13 -> (13)th _val == 33 -> (33)rd // _val == 20 -> (20)th // // @param: // _val - integer value to grab oridnal indictor for. // // @return: // string - one of the following: "st", "nd", "rd", or "th" // // This function accounts for the special cases of 11th, 12th, and 13th // f_getOrdinal(int _val) => pos = _val % 10 // Eleventh, Twelfth, Thirteenth restriction (also % 100 may be overkill // but I believe it's necessary) ETT = (_val % 100) - 10 bool ETTRestrict = ETT == 1 or ETT == 2 or ETT == 3 if ETTRestrict "th" else pos == 1 ? "st" : pos == 2 ? "nd" : pos == 3 ? "rd" : "th" // Global variable offset using i_onClose logic OFFSET = i_onClose ? 1 : 0 // Boolean condition on if the current (or prior) candle is black or white bool blackOrWhite = close[OFFSET] - open[OFFSET] < 0 bool currHighLower = high[OFFSET] < high[OFFSET + 1] bool currLowHigher = low[OFFSET] > low[OFFSET + 1] // Counting vars var BWcount = 0 var higherHigh = i_indOffset var lowerHigh = i_indOffset var higherLow = i_indOffset var lowerLow = i_indOffset BWFlip = (blackOrWhite and not blackOrWhite[1]) or (blackOrWhite[1] and not blackOrWhite) // Black and White consecutive candle counting logic if BWFlip and i_indOffset != 1 BWcount := 0 else if blackOrWhite // reset to -1 if previous was a white candle run if BWcount >= 0 and (blackOrWhite[1] or i_indOffset == 1) BWcount := -1 else BWcount := BWcount - 1 else // reset to 1 if previous was a black candle run if BWcount <= 0 and (not blackOrWhite[1] or i_indOffset == 1) BWcount := 1 else BWcount := BWcount + 1 // Count higher highs/lower highs if currHighLower lowerHigh := lowerHigh + 1 higherHigh := i_indOffset else lowerHigh := i_indOffset higherHigh := higherHigh + 1 // Count higher lows/lower lows if currLowHigher higherLow := higherLow + 1 lowerLow := i_indOffset else higherLow := i_indOffset lowerLow := lowerLow + 1 // Get total number of consecutive candles for each (needs to be unsigned). absCount = math.abs(BWcount) // Get runs isBlackRun = BWcount < 0 isWhiteRun = not isBlackRun HHRun = higherHigh >= i_minCandles LHRun = lowerHigh >= i_minCandles HLRun = higherLow >= i_minCandles LLRun = lowerLow >= i_minCandles // Show if count exceeds i_minCandle # and if it is the specified type of run showBW = absCount >= i_minCandles and (i_blackOrWhite == "Black" ? isBlackRun : i_blackOrWhite == "White" ? isWhiteRun : i_blackOrWhite == "Both") showHH = HHRun and i_HHBool showLH = LHRun and i_LHBool showHL = HLRun and i_HLBool showLL = LLRun and i_LLBool // String formatting, will properly display ordinal indicator for the number of // candles on labels + candle type. BWstrBeg = f_getOrdinal(absCount) highVal = higherHigh > lowerHigh ? higherHigh : - lowerHigh lowVal = higherLow > lowerLow ? higherLow : - lowerLow HVAbs = math.abs(highVal) LVAbs = math.abs(lowVal) highStrBeg = f_getOrdinal(HVAbs) lowStrBeg = f_getOrdinal(LVAbs) string builtBWString = str.tostring(absCount) + BWstrBeg + " consecutive " + (blackOrWhite ? "black" : "white") + " candle." string builtHighString = str.tostring(HVAbs) + highStrBeg + (highVal > 0 ? " higher high." : " lower high.") string builtLowString = str.tostring(LVAbs) + lowStrBeg + (lowVal > 0 ? " higher low." : " lower low.") // Create a new label for each specific run. label generateBWLabel = showBW ? (label.new(x = bar_index[OFFSET], y = isBlackRun ? low[OFFSET] : high[OFFSET], text = builtBWString, style = isBlackRun ? label.style_label_up : label.style_label_down, textalign = text.align_center, color = color.white)) : na label generateHHLabel = showHH ? (label.new(x = bar_index[OFFSET], y = high[OFFSET], text = builtHighString, style = label.style_label_down, textalign = text.align_center, color = color.white)) : na label generateLHLabel = showLH ? (label.new(x = bar_index[OFFSET], y = high[OFFSET], text = builtHighString, style = label.style_label_down, textalign = text.align_center, color = color.white)) : na label generateHLLabel = showHL ? (label.new(x = bar_index[OFFSET], y = low[OFFSET], text = builtLowString, style = label.style_label_up, textalign = text.align_center, color = color.white)) : na label generateLLLabel = showLL ? (label.new(x = bar_index[OFFSET], y = low[OFFSET], text = builtLowString, style = label.style_label_up, textalign = text.align_center, color = color.white)) : na // Delete the previous labels so there are no overlaps if showBW and not na(generateBWLabel[1]) label.delete(generateBWLabel[1]) if showHH and not na(generateHHLabel[1]) label.delete(generateHHLabel[1]) if showLH and not na(generateLHLabel[1]) label.delete(generateLHLabel[1]) if showHL and not na(generateHLLabel[1]) label.delete(generateHLLabel[1]) if showLL and not na(generateLLLabel[1]) label.delete(generateLLLabel[1]) string MSTRSTR = "A run of " // Generate alert strings for each case (runs/breaks) string builtBWRunAlertString = MSTRSTR + str.tostring(absCount) + " consecutive " + (blackOrWhite ? "black" : "white") + " candles has been found." string builtBWBreakAlertString = MSTRSTR + str.tostring(absCount[1]) + " consecutive " + (blackOrWhite[1] ? "black" : "white") + " candles has just been broken." string builtHighRunAlertString = MSTRSTR + str.tostring(HVAbs) + (highVal > 0 ? " high" : " low") + "er highs has been found." string builtHighBreakAlertString = MSTRSTR + str.tostring(HVAbs[1]) + (highVal[1] > 0 ? " high" : " low") + "er highs has ended." string builtLowRunAlertString = MSTRSTR + str.tostring(LVAbs) + (lowVal > 0 ? " high" : " low") + "er lows has been found." string builtLowBreakAlertString = MSTRSTR + str.tostring(LVAbs[1]) + (lowVal[1] > 0 ? " high" : " low") + "er lows has ended." bool showHigh = showHH or showLH bool showLow = showHL or showLL alertFreq = i_onClose ? alert.freq_once_per_bar : alert.freq_once_per_bar_close // Black and White candle alerts if showBW and i_enableAlertOnRun alert(builtBWRunAlertString, alertFreq) if not showBW and showBW[1] and i_enableAlertOnBreak alert(builtBWBreakAlertString, alertFreq) // High/Low switch alerts // Note: This handles breaks where higher highs are detected immediately and // a candle with a lower high is detected after the close. Where as lower // highs are detected after the candle close, and a higher high is detected // immediately. The same applies to the lows. if showHigh and i_enableAlertOnRun if HHRun alert(builtHighRunAlertString) else alert(builtHighRunAlertString, alertFreq) if not showHigh and showHigh[1] and i_enableAlertOnBreak if HHRun[1] alert(builtHighBreakAlertString, alert.freq_once_per_bar_close) else alert(builtHighBreakAlertString) if showLow and i_enableAlertOnRun if LLRun alert(builtLowRunAlertString) else alert(builtLowRunAlertString, alertFreq) if not showLow and showLow[1] and i_enableAlertOnBreak if LLRun[1] alert(builtLowBreakAlertString, alert.freq_once_per_bar_close) else alert(builtLowBreakAlertString) // Delete labels for plot view labelList = label.all if i_showCounterPlots and not array.size(labelList) == 0 for i = 0 to array.size(labelList) - 1 label.delete(array.get(labelList, i)) // Optional Plots plot(i_showCounterPlots and i_blackOrWhite != "OFF" ? BWcount : na, title = "BWCount", color = color.red) plot(i_showCounterPlots and i_HHBool ? higherHigh : na, title = "Higher High", color = color.orange) plot(i_showCounterPlots and i_LHBool ? lowerHigh : na, title = "Lower High", color = color.yellow) plot(i_showCounterPlots and i_HLBool ? higherLow : na, title = "Higher Low", color = color.green) plot(i_showCounterPlots and i_LLBool ? lowerLow : na, title = "Lower Low", color = color.blue)
Root mean squared error range (RMSER)
https://www.tradingview.com/script/7mgzkEPy-Root-mean-squared-error-range-RMSER/
spiritualhealer117
https://www.tradingview.com/u/spiritualhealer117/
27
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © spiritualhealer117 //@version=4 study("RMSE") length = input(14, "Length") src = input(title="Source", type=input.source, defval=close) rmse = sqrt(sum(pow(sma(src, length)-src,2)/length,length)) top = sma(src + 2 * rmse,length) bottom = sma(src -2 * rmse, length) plot(top) plot(bottom)
EWMA Implied Volatility based on Historical Volatility
https://www.tradingview.com/script/DzZqd5dn-EWMA-Implied-Volatility-based-on-Historical-Volatility/
exlux99
https://www.tradingview.com/u/exlux99/
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/ // © exlux99 //@version=5 indicator("EWMA Implied Volatility", overlay=true) // Exponentially Weighted Volatility ewma_function(source, length, annual_volatility) => var lambda = (length - 1) / (length + 1) squared = math.pow(source, 2) float variance = na variance := lambda * nz(variance[1], squared) + (1.0 - lambda) * squared annual_volatility * math.sqrt(variance) close_daily = request.security(syminfo.tickerid, "D", close) close_weekly = request.security(syminfo.tickerid, "W", close) close_monthly = request.security(syminfo.tickerid, "M", close) logarithm_daily = math.log(close_daily / close_daily[1]) logarithm_weekly = math.log(close_weekly / close_weekly[1]) logarithm_monthly = math.log(close_monthly / close_monthly[1]) var sqrt_daily = math.sqrt(252) * 100 var sqrt_weekly = math.sqrt(52) * 100 var sqrt_monthly = math.sqrt(12) * 100 yearly_volatility = ewma_function(logarithm_daily, 21, sqrt_daily)/100 daily_volatility = (yearly_volatility / math.sqrt(252) ) weekly_volatility = (yearly_volatility / math.sqrt(52) ) monthly_volatility = (yearly_volatility / math.sqrt(12) ) //////////////////////////////////////////////////////////////////////////// posInput = input.string(title='Position', defval='Middle Right', options=['Bottom Left', 'Bottom Right', 'Top Left', 'Top Right', 'Middle Right']) var pos = posInput == 'Bottom Left' ? position.bottom_left : posInput == 'Bottom Right' ? position.bottom_right : posInput == 'Top Left' ? position.top_left : posInput == 'Top Right' ? position.top_right : posInput == 'Middle Right' ? position.middle_right: na var table table_vol = table.new(pos, 15, 15, border_width=1) table_fillCell(_table, _column, _row, _value, _timeframe, _c_color) => _transp = 70 _cellText = str.tostring(_value, '#.### %') table.cell(_table, _column, _row, _cellText, bgcolor=color.new(_c_color, _transp), text_color=_c_color, width=5) //table.cell_set_text_size(table_atr, 0, 2, text) if barstate.islast table.cell(table_vol, 0, 0, 'EWMA Volatility', text_color=color.white, text_size=size.normal, bgcolor=color.purple) table.cell(table_vol, 0, 4, 'Yearly Volatility', text_color=color.white, text_size=size.normal, bgcolor=color.aqua) table.cell(table_vol, 0, 1, 'Daily Volatility', text_color=color.white, text_size=size.normal, bgcolor=color.green) table.cell(table_vol, 0, 2, 'Weekly Volatility', text_color=color.white, text_size=size.normal, bgcolor=color.blue) table.cell(table_vol, 0, 3, 'Monthly Volatility', text_color=color.white, text_size=size.normal, bgcolor=color.orange) table_fillCell(table_vol, 1, 4, yearly_volatility , 'Text', color.white) table_fillCell(table_vol, 1, 1, daily_volatility , 'Text', color.white) table_fillCell(table_vol, 1, 2, weekly_volatility, 'Text', color.white) table_fillCell(table_vol, 1, 3, monthly_volatility, 'Text', color.white)
Leg/Base & GAP Candles
https://www.tradingview.com/script/3DKhHjiP-Leg-Base-GAP-Candles/
ankurjpr
https://www.tradingview.com/u/ankurjpr/
95
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/ // © india TradeLegend By AnkurMaheshwari //@version=4 study(title="Leg/Base & GAP Candles",overlay=true) //Leg and Base Candle Input var legThreshold = input(title="Leg Candle Close-Open to Low-High Range Ratio Between 0 to 1", type=input.float, minval = 0.01, maxval = 0.99, defval=0.75) var baseThreshold = input(title="Base Candle Body to Range Ratio 0 to 1", type=input.float, minval = 0.01, maxval = 0.99, defval=0.5) var allowLegCandleColorChange = input(title="Colour Change on Leg Candles",type=input.bool, defval = true) var allowBaseCandleColorChange = input(title="Colour Change on Base Candles",type=input.bool, defval = false) var labelAllow = input(title="Label Close Price? ",type=input.bool, defval = false) var redrawCandle = input(title="Redraw all intraday candles?",type=input.bool, defval = false) //MINUTE & HOUR LegCandle and Base Candle boolean based on previous values //legCandle = iff(float((abs(close-iff(hour(time)==9 and minute(time)==15,close[1],open))/(high-low)))>=float(legThreshold) and timeframe.isminutes and allowLegCandleColorChange,1,0) //baseCandle = iff(float((abs(close-iff(hour(time)==9 and minute(time)==15,close[1],open))/(high-low)))<=float(baseThreshold) and timeframe.isminutes and allowBaseCandleColorChange,1,0) legCandle = iff(timeframe.isminutes, float((abs(close-iff(hour(time)==9 and minute(time)==15,close[1],open))/(high-low)))>=float(legThreshold) and allowLegCandleColorChange?1:0, float((abs(close-close[1])/(high-low)))>=float(legThreshold) and allowLegCandleColorChange?1:0) baseCandle = iff(timeframe.isminutes, float((abs(close-iff(hour(time)==9 and minute(time)==15,close[1],open))/(high-low)))<=float(baseThreshold) and allowBaseCandleColorChange?1:0, float((abs(close-close[1])/(high-low)))<=float(baseThreshold) and allowBaseCandleColorChange?1:0) firstCandle = iff(hour(time)==9 and minute(time)==15,1,0) //Leg Candles and Base Candles Bar Colour changes barcolor(legCandle and firstCandle==0 ? close >= iff(timeframe.isminutes,hour(time)==9 and minute(time)==15?close[1]:open,close[1]) ? color.yellow : color.fuchsia : na, title="Leg Candle Color Marking") barcolor(baseCandle and firstCandle==0 ? close >= iff(timeframe.isminutes,hour(time)==9 and minute(time)==15?close[1]:open,close[1]) ? color.black : color.black : na, title="Base Candle Color Marking") //barcolor(legCandle ? close >= iff(hour(time)==9 and minute(time)==15,close[1],open) ? color.yellow : color.fuchsia : na, title="Leg Candle Color Marking") //barcolor(baseCandle ? close >= iff(hour(time)==9 and minute(time)==15,close[1],open) ? color.black : color.black : na, title="Base Candle Color Marking") //Shaping on Leg candles plotshape(legCandle ? close < iff(timeframe.isminutes,hour(time)==9 and minute(time)==15?close[1]:open,close[1]) ? 1:0:0, style=shape.arrowdown, color = color.purple, location = location.top) plotshape(legCandle ? close > iff(timeframe.isminutes,hour(time)==9 and minute(time)==15?close[1]:open,close[1]) ? 1:0:0, style=shape.arrowup, color = color.yellow, location = location.top) //Minute Redraw Candle on the Basis of Previous Close //Only NSE 9:15 candle redraw intraday //plotcandle(iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday,close[1],na), iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday,high,na), iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday,low,na), iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday,close,na), color = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.teal:color.red), wickcolor = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.black:color.black), bordercolor = color.black, title="Minute/Hourly Redraw Candle") plotcandle(iff(timeframe.isintraday and redrawCandle,close[1],na), iff(timeframe.isintraday and redrawCandle,high,na), iff(timeframe.isintraday and redrawCandle,low,na), iff(timeframe.isintraday and redrawCandle,close,na), color = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.teal:color.red), wickcolor = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.black:color.black), bordercolor = color.black, title="Minute/Hourly Redraw Candle") if (barstate.islast and labelAllow and redrawCandle) l = label.new(bar_index, high, text=tostring(close)) label.delete(l[1]) if(close<open) label.set_y(l,low) label.set_style(l,label.style_label_up) plotcandle(iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday and not redrawCandle,close[1],na), iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday and not redrawCandle,high,na), iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday and not redrawCandle,low,na), iff(hour(time)==9 and minute(time)==15 and timeframe.isintraday and not redrawCandle,close,na), color = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.teal:color.red), wickcolor = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.black:color.black), bordercolor = color.black, title="Minute/Hourly Redraw Candle") //Daily Weekly Monthly Redraw Candles on the Basis of Previous Close plotcandle(iff(timeframe.isdwm,close[1],na), iff(timeframe.isdwm,high,na), iff(timeframe.isdwm,low,na), iff(timeframe.isdwm,close,na), color = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.teal:color.red), wickcolor = iff(legCandle,close[1]<=close?color.yellow:color.fuchsia,close[1]<=close?color.teal:color.red), bordercolor = color.black,title="Daily, Weekly, Monthly Redraw Candle") //plotchar(baseCandle,text=tostring(float((high-low)/close)),char="x") //if(float((abs(close-iff(hour(time)==9 and minute(time)==15,close[1],open))/(high-low)))<=float(0.5)?float((high-low)/close)<float(0.003)?1:1:0) // label.new(bar_index, high, tostring(float((high-low)/close)), yloc = yloc.abovebar, color = color.red, textcolor = color.black)
Infiten's Regressive Trend Channel
https://www.tradingview.com/script/CYpNDA8B-Infiten-s-Regressive-Trend-Channel/
spiritualhealer117
https://www.tradingview.com/u/spiritualhealer117/
153
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/ // © spiritualhealer117 //@version=4 study("Regression Estimates") len = input(title="Extreme Length", type=input.integer, defval=14) len2 = input(title="Regression Length", type=input.integer, defval=14) offset = input(title="Plot Offset", type=input.integer,defval=0) low_forecast = linreg(lowest(low,len),len2,0) high_forecast = linreg(highest(high,len),len2,0) mid_forecast = linreg(sma((close+open)/2,len),len2,0) plot(low_forecast, offset=offset, color=color.red, style=plot.style_circles) plot(high_forecast, offset=offset, color=color.green, style=plot.style_circles) plot(mid_forecast, offset=offset, color=color.gray, style=plot.style_circles) plotcandle(close, high_forecast, low_forecast, mid_forecast, title = 'LRE', color = mid_forecast < close ? color.green : color.red, wickcolor = color.black)
MACD Scalper Analysis
https://www.tradingview.com/script/JkGxP1xr-MACD-Scalper-Analysis/
exlux99
https://www.tradingview.com/u/exlux99/
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/ // © exlux99 //@version=5 indicator(title="MACD Scalper Analysis") heikinashi_close = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) // Getting inputs 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.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) // Calculating fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) macd = fast_ma - slow_ma signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length) hist = macd - signal plot(macd, color=color.white) plot(signal) ema200 = ta.ema(close,200) // plot(ema200) long = close > ema200 and ta.crossover(macd,signal) short = close < ema200 and ta.crossover(macd,signal) var int contador_positiv_long = 0 var int contador_negativ_long = 0 var int contador_positiv_short = 0 var int contador_negativ_short = 0 var float average_bull_movement_long = 0 var float average_bear_movement_long = 0 var float average_bear_movement_short =0 var float average_bull_movement_short=0 if(long[1]) if(close >open) contador_positiv_long := contador_positiv_long+1 //count_bull_long:=count_bull_long+1 average_bull_movement_long:=average_bull_movement_long+((close-open)/open) if(long[1]) if( close <open) contador_negativ_long := contador_negativ_long+1 //count_bear_long:=count_bear_long+1 average_bear_movement_long:=average_bear_movement_long+((open-close)/close) if(short[1]) if(close<open) contador_positiv_short := contador_positiv_short+1 //count_bear_short:=count_bear_short+1 average_bear_movement_short:=average_bear_movement_short+((open-close)/close) if(short[1]) if(close>open) contador_negativ_short := contador_negativ_short+1 //count_bull_short:=count_bull_short+1 average_bull_movement_short:=average_bull_movement_short+((close-open)/open) plotshape(long[1] and close>open? close : na, style=shape.xcross, color=color.green, location= location.bottom) plotshape(long[1] and close<open ? close : na, style=shape.square, color=color.white, location= location.bottom) plotshape(short[1] and close <open ? close : na, style=shape.xcross, color=color.red, location = location.top) plotshape(short[1] and close > open ? close : na, style=shape.square, color=color.blue, location=location.top) //////////////////////////////////////////////////////////////////////////// posInput = input.string(title='Position', defval='Middle Right', options=['Bottom Left', 'Bottom Right', 'Top Left', 'Top Right', 'Middle Right']) var pos = posInput == 'Bottom Left' ? position.bottom_left : posInput == 'Bottom Right' ? position.bottom_right : posInput == 'Top Left' ? position.top_left : posInput == 'Top Right' ? position.top_right : posInput == 'Middle Right' ? position.middle_right: na var table table_macd = table.new(pos, 15, 15, border_width=1) table_fillCell(_table, _column, _row, _value, _timeframe, _c_color) => _transp = 70 _cellText = str.tostring(_value, '#.###') table.cell(_table, _column, _row, _cellText, bgcolor=color.new(_c_color, _transp), text_color=_c_color, width=5) //table.cell_set_text_size(table_atr, 0, 2, text) if barstate.islast table.cell(table_macd, 0, 0, 'MACD Scalper Analysis', text_color=color.white, text_size=size.normal, bgcolor=color.purple) table.cell(table_macd, 0, 1, 'Long Positiv', text_color=color.white, text_size=size.normal, bgcolor=color.green) table.cell(table_macd, 0, 2, 'Long Negativ', text_color=color.white, text_size=size.normal, bgcolor=color.red) table.cell(table_macd, 0, 3, 'Short Positiv', text_color=color.white, text_size=size.normal, bgcolor=color.green) table.cell(table_macd, 0, 4, 'Short Negativ', text_color=color.white, text_size=size.normal, bgcolor=color.red) table_fillCell(table_macd, 1, 1, contador_positiv_long, 'Text', color.white) table_fillCell(table_macd, 1, 2, contador_negativ_long, 'Text', color.white) table_fillCell(table_macd, 1, 3, contador_positiv_short, 'Text', color.white) table_fillCell(table_macd, 1, 4, contador_negativ_short, 'Text', color.white) table.cell(table_macd, 2, 1, 'Average Movement Long Positiv', text_color=color.white, text_size=size.normal, bgcolor=color.green) table.cell(table_macd, 2, 2, 'Average Movement Long Negativ', text_color=color.white, text_size=size.normal, bgcolor=color.red) table.cell(table_macd, 2, 3, 'Average Movement Short Positiv', text_color=color.white, text_size=size.normal, bgcolor=color.green) table.cell(table_macd, 2, 4, 'Average Movement Short Negativ', text_color=color.white, text_size=size.normal, bgcolor=color.red) table_fillCell(table_macd, 3, 1, average_bull_movement_long/contador_positiv_long*100, 'Text', color.white) table_fillCell(table_macd, 3, 2, average_bear_movement_long/contador_negativ_long*100, 'Text', color.white) table_fillCell(table_macd, 3, 3, average_bear_movement_short/contador_positiv_short*100, 'Text', color.white) table_fillCell(table_macd, 3, 4, average_bull_movement_short/contador_negativ_short*100, 'Text', color.white) table.cell(table_macd, 4, 1, 'Total Long Positiv', text_color=color.white, text_size=size.normal, bgcolor=color.green) table.cell(table_macd, 4, 2, 'Total Long Negativ', text_color=color.white, text_size=size.normal, bgcolor=color.red) table.cell(table_macd, 4, 3, 'Total Short Positiv', text_color=color.white, text_size=size.normal, bgcolor=color.green) table.cell(table_macd, 4, 4, 'Total Short Negativ', text_color=color.white, text_size=size.normal, bgcolor=color.red) table_fillCell(table_macd, 5, 1, (average_bull_movement_long/contador_positiv_long*100)*contador_positiv_long, 'Text', color.white) table_fillCell(table_macd, 5, 2, (average_bear_movement_long/contador_negativ_long*100)*contador_negativ_long*(-1), 'Text', color.white) table_fillCell(table_macd, 5, 3, (average_bear_movement_short/contador_positiv_short*100)*contador_positiv_short, 'Text', color.white) table_fillCell(table_macd, 5, 4, (average_bull_movement_short/contador_negativ_short*100)*contador_negativ_short*(-1), 'Text', color.white)
MME MTF CCI
https://www.tradingview.com/script/IT5ffQsR-MME-MTF-CCI/
mme_trades
https://www.tradingview.com/u/mme_trades/
92
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mme_trades //@version=5 //This indicator will draw the following //CCI- 8 of 5 minutes or Current Timeframe //CCI-34 of 5 minutes or Current Timeframe //CCI-34 of 30 minutes or appropriate HTF indicator('MME MTF CCI v1.1', shorttitle='MTF CCI v1.1', overlay=false) group_cci = "CCI Settings" len = 8 //input(8, title='Length', group=group_cci) len2 = 34 //input(34, title='Length', group=group_cci) src = input(hlc3, title='CCI Source', group=group_cci) show_CCI8_5m = input(true, title='Show CCI 8 CTF', group=group_cci) show_CCI34_5m = input(true, title='Show CCI 34 CTF', group=group_cci) show_CCI34_30m = input(true, title='Show CCI 34 HTF', group=group_cci) show_labels = input(true, title='Show labels', group=group_cci) htf_auto = timeframe.period == '1' ? '5' : timeframe.period == '3' ? '5' : timeframe.period == '5' ? '30' : timeframe.period == '10' ? '30' : timeframe.period == '15' ? '30' : timeframe.period == '25' ? 'D' : timeframe.period == '30' ? 'D' : timeframe.period == '45' ? 'D' : timeframe.period == '60' ? 'D' : timeframe.period == '75' ? 'D' : timeframe.period == '120' ? 'D' : timeframe.period == '180' ? 'D' : timeframe.period == '240' ? 'D' : timeframe.period == 'D' ? 'W' : timeframe.period == 'W' ? 'M' : timeframe.period == 'M' ? '3M' : '30' cci8_5m = ta.cci(src, len) cci34_5m = ta.cci(src, len2) cci34_30m = request.security(syminfo.tickerid, htf_auto, ta.cci(src, len2)) CCI8_5m_str = str.format("{0,number,integer}", cci8_5m) CCI34_5m_str = str.format("{0,number,integer}", cci34_5m) CCI34_30m_str = str.format("{0,number,integer}", cci34_30m) plot(show_CCI8_5m ? cci8_5m : na, color=color.new(color.orange,0), linewidth=1, title=' 8 CTF') plot(show_CCI34_5m ? cci34_5m : na, color=color.new(color.blue,0), linewidth=2, title='34 CTF') plot(show_CCI34_30m ? cci34_30m : na, color=color.new(color.red,0), linewidth=3, title='34 HTF') if show_CCI8_5m and show_labels cci8_5m_l = label.new(bar_index + 3, cci8_5m, text="CCI 8 "+timeframe.period, color=color.white, textcolor=color.orange, size=size.small, style=label.style_none) label.delete(cci8_5m_l[1]) if show_CCI34_5m and show_labels cci34_5m_l = label.new(bar_index + 3, cci34_5m, text="CCI 34 "+timeframe.period, color=color.white, textcolor=color.blue, size=size.small, style=label.style_none) label.delete(cci34_5m_l[1]) if show_CCI34_30m and show_labels cci34_30m_l = label.new(bar_index + 3, cci34_30m, text="CCI 34 "+ htf_auto, color=color.white, textcolor=color.red, size=size.small, style=label.style_none) label.delete(cci34_30m_l[1]) band1 = plot(135, title='135', style=plot.style_circles, linewidth=1, color=color.new(color.red, 50), display=display.none,editable=false) band2 = plot(100, title='100', style=plot.style_circles, linewidth=1, color=color.new(color.lime, 50), display=display.none,editable=false) band3 = plot(60, title='60', style=plot.style_circles, linewidth=1, color=color.new(color.green, 50), display=display.none,editable=false) band4 = plot(0, title='0', style=plot.style_line, linewidth=0, color=color.new(color.gray, 50), display=display.none,editable=false) band5 = plot(-60, title='-60', style=plot.style_circles, linewidth=1, color=color.new(color.green, 50), display=display.none,editable=false) band6 = plot(-100, title='-100', style=plot.style_circles, linewidth=1, color=color.new(color.lime, 50), display=display.none,editable=false) band7 = plot(-135, title='-135', style=plot.style_circles, linewidth=1, color=color.new(color.red, 50), display=display.none,editable=false) fill(band1, band2, color=color.new(color.fuchsia, 90), editable=false) fill(band3, band4, color=color.new(color.gray, 95), editable=false) fill(band4, band5, color=color.new(color.gray, 85), editable=false) fill(band6, band7, color=color.new(color.fuchsia, 90), editable=false)
ATH ATL ATX Finder
https://www.tradingview.com/script/X5KI6JTD-ATH-ATL-ATX-Finder/
AlfaVisioner
https://www.tradingview.com/u/AlfaVisioner/
84
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © AlfaVisioner //@version=5 indicator("ATH ATL ATX Finder", overlay=true) in_src=hlc3 //input.source(hlc3, title="Data source", group="General") in_use_initial_time=input.bool(defval=true, title="Start from date below", group="Period") in_initial_time=input.time(defval=timestamp("01 JAN 2021"), title="Date", group="Period") in_panel_alignment=input.string(defval="Top", options=["Top", "Bottom"], title ="Panel alignment", group="View") in_show_labels=input.bool(defval=true, title="Show labels", group="View") // Time filter time_is_ok = not in_use_initial_time or time > in_initial_time // Counters var candles = 0 var average_price_total = 0.00 var ath = -1e10 var atl = 1e10 new_ath_found = false new_atl_found = false if time_is_ok if high > ath ath := high new_ath_found := true if low < atl atl := low new_atl_found := true // Output //-- Colors color_atx_label = color.green color_atl_label = color.red color_price_label = #b5c7fd color_table = color.new(color.green,50) color_envelope = color.purple //-- Time bgcolor(not time_is_ok? color.new(color.red, 80) : na) //-- Labels if in_show_labels and new_ath_found ath_label=label.new(bar_index, high, text='ATH', style=label.style_label_down, color=color_atx_label) label.delete(ath_label[1]) if in_show_labels and new_atl_found atl_label=label.new(bar_index, low, text='ATL', style=label.style_label_up, color=color_atl_label) label.delete(atl_label[1]) //--Math- safe_div(a, b)=> result = (b != 0) ? a / b : 0 panel_alignment = switch in_panel_alignment 'Top' => position.top_right 'Bottom' => position.bottom_right result_table = table.new(panel_alignment, columns=1, rows=5, bgcolor=#00000000) if barstate.islast atx = safe_div(ath, atl) x_to_ath = safe_div(ath, in_src) t_from_atl = safe_div(in_src, atl) ath_text = 'ATH: ' + str.tostring(ath, format.mintick) atl_text = 'ATL: ' + str.tostring(atl, format.mintick) atx_text = 'ATX: ' + str.tostring(atx,"#.##") x_to_ath_text = 'X to ATH: ' + str.tostring(x_to_ath, "#.##") t_from_atl_text = 'X from ATL: ' + str.tostring(t_from_atl, "#.##") table.cell(table_id=result_table, column=0, row=0, text=ath_text, height=0, text_color=color.black, text_halign=text.align_left, text_valign= text.align_center, bgcolor=color_table) table.cell(table_id=result_table, column=0, row=1, text=atl_text, height=0, text_color=color.black, text_halign=text.align_left, text_valign= text.align_center, bgcolor=color_table) table.cell(table_id=result_table, column=0, row=2, text=atx_text, height=0, text_color=color.black, text_halign=text.align_left, text_valign= text.align_center, bgcolor=color_table) table.cell(table_id=result_table, column=0, row=3, text=x_to_ath_text, height=0, text_color=color.black, text_halign=text.align_left, text_valign= text.align_center, bgcolor=color_table) table.cell(table_id=result_table, column=0, row=4, text=t_from_atl_text, height=0, text_color=color.black, text_halign=text.align_left, text_valign= text.align_center, bgcolor=color_table)
[HELPER] Math Constant Helper
https://www.tradingview.com/script/RuKHbhWf-HELPER-Math-Constant-Helper/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
8
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RozaniGhani-RG //@version=5 indicator('[HELPER] Math Constant Helper', shorttitle = 'HMCH') // 0. Tooltips // 1. Inputs for table // 3. New array // 4. Construct // ————————————————————————————————————————————————————————————————————————————— 0. Tooltips { T0 = 'Small font size recommended for mobile app or multiple layout' T1 = 'Tick to hide' // } // ————————————————————————————————————————————————————————————————————————————— 1. Inputs for table { i_s_font = input.string('normal', 'Font size', tooltip = T0, options = ['tiny', 'small', 'normal', 'large', 'huge']) i_s_Y = input.string('top', 'Table Position', inline = '0', options = ['top', 'middle', 'bottom']) i_s_X = input.string('right', '', inline = '0', options = ['left', 'center', 'right']) i_c_text = input.color(color.black, 'Text') i_c_bg = input.color(color.white, 'Background') i_c_border = input.color(color.black, 'Border') // } // ————————————————————————————————————————————————————————————————————————————— 2. Inputs for array { i_b_e = input.bool(true, 'Euler', inline ='1', group = 'math') i_b_pi = input.bool(true, 'Archimedes', inline ='2', group = 'math') i_b_phi = input.bool(true, 'Golden Ratio', inline ='3', group = 'math') i_b_rphi = input.bool(true, 'Golden Ratio Conjugate', inline ='4', group = 'math') // } // ————————————————————————————————————————————————————————————————————————————— 3. New array { table[] arr_table = array.new_table() arr_bool = array.new_bool(4) math_name = array.from( 'Euler', 'Archimedes', 'Golden Ratio', 'Golden Ratio Conjugate') math_short_name = array.from( 'e', 'pi', 'phi', 'rphi') math_constant = array.from( math.e, math.pi, math.phi, math.rphi) math_string = array.from('math.e', 'math.pi', 'math.phi', 'math.rphi') array.push(arr_table, table.new(position = i_s_Y + '_' + i_s_X, rows = 12, columns = 5, frame_color = i_c_border, frame_width = 1, border_color = i_c_border, border_width = 1)) array.set(arr_bool, 0, i_b_e) array.set(arr_bool, 1, i_b_pi) array.set(arr_bool, 2, i_b_phi) array.set(arr_bool, 3, i_b_rphi) // } // ————————————————————————————————————————————————————————————————————————————— 4. Construct { if barstate.islast table.cell(array.get(arr_table, 0), 0, 0, 'Name', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) table.cell(array.get(arr_table, 0), 1, 0, 'Short Name', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) table.cell(array.get(arr_table, 0), 2, 0, 'Constant', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) table.cell(array.get(arr_table, 0), 3, 0, 'Value', text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) for _row = 0 to 3 if array.get(arr_bool, _row) table.cell(array.get(arr_table, 0), 0, _row + 1, array.get( math_name, _row), text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) table.cell(array.get(arr_table, 0), 1, _row + 1, array.get(math_short_name, _row), text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) table.cell(array.get(arr_table, 0), 2, _row + 1, array.get( math_string, _row), text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) table.cell(array.get(arr_table, 0), 3, _row + 1, str.tostring(array.get( math_constant, _row), '0.000'), text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg) // }
TASC 2022.06 Ehlers Loops
https://www.tradingview.com/script/5WXLRdaQ-TASC-2022-06-Ehlers-Loops/
PineCodersTASC
https://www.tradingview.com/u/PineCodersTASC/
642
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © PineCodersTASC // TASC Issue: June 2022 - Vol. 40, Issue 7 // Article: Ehlers Loops // Article By: John F. Ehlers // Language: TradingView's Pine Script v5 // Provided By: PineCoders, for tradingview.com //@version=5 indicator("TASC 2022.06 Ehlers Loops", "ELs", precision=3, max_lines_count=300, max_labels_count=300, max_boxes_count=300) // Crocker chart constants: string _B0_ = '✸', _B1_ = '✜', _B2_ = '◉', _B3_= '・', _B4_ = 'x' string _LS0_ = 'dashed', _LS1_ = 'dotted', _LS2_ = 'solid' _lineStyleHelper(style)=> switch style 'dashed' => line.style_dashed 'dotted' => line.style_dotted 'solid' => line.style_solid color c_devbox_border = color.rgb( 250, 250, 100, 60) color c_devbox_bg = #00000020 int i_barScale = 100 source = input.source(close, "Source") mode = input.string(defval='Oscillators', options=['Oscillators', 'Scatter Plot'], title = 'Output mode') periodLP = input.int( 20, "Low-Pass Period", minval= 7) periodHP = input.int(125, "High-Pass Period", minval=20) periodRMS = input.int( 80, "RMS Period", step=10) // Crocker graph inputs: string ig_graph = 'Scatterplot Options:' i_depth = input.int( 20, title = 'Scatter Plot Timespan', group=ig_graph) i_col_devbox = input.color( #ffffa080, title = 'Box Color', group=ig_graph) i_bul0 = input.string( defval=_B2_, title = 'Symbol', options=[_B0_, _B1_, _B2_, _B3_, _B4_], group=ig_graph) i_col0 = input.color( color.red, title = 'Symbol Color', group=ig_graph) i_size = input.string( size.small, title = 'Symbol Size', options=[size.small, size.normal, size.large, size.huge], group = ig_graph) i_ls0 = _lineStyleHelper(input.string(defval=_LS0_, options=[_LS0_, _LS1_, _LS2_], title='Line', group=ig_graph)) //== 2 Pole Butterworth Highpass Filter ==// butterworthHP(float Series, float Period) => var float ALPHA = math.pi * math.sqrt(2.0) / Period var float BETA = math.exp(-ALPHA ) var float COEF2 = -math.pow(BETA, 2) var float COEF1 = math.cos( ALPHA ) * 2.0 * BETA var float COEF0 = (1.0 + COEF1 - COEF2) * 0.25 float tmp = nz(Series[1], Series) float whiten = Series + nz(Series[2], tmp) - 2.0 * tmp float smooth = na, smooth := COEF0 * whiten + COEF1 * nz(smooth[1]) + COEF2 * nz(smooth[2]) //===== 2 Pole Super Smoother Filter =====// superSmoother(float Series, float Period) => var float ALPHA = math.pi * math.sqrt(2.0) / Period var float BETA = math.exp(-ALPHA ) var float COEF2 = -math.pow(BETA, 2) var float COEF1 = math.cos( ALPHA ) * 2.0 * BETA var float COEF0 = 1.0 - COEF1 - COEF2 float sma2 = math.avg(Series, nz(Series[1], Series)) float smooth = na, smooth := COEF0 * sma2 + COEF1 * nz(smooth[1]) + COEF2 * nz(smooth[2]) //===== Faster Root Mean Square =====// fastRMS(float Series, float Period) => if Period < 1 runtime.error("Err: fastRMS(Period=) is less than 1") var float COEF0 = 2.0 / (Period + 1) var float COEF1 = 1.0 - COEF0 float pow = math.pow(Series, 2) float ema = na, ema := COEF0 * pow + COEF1 * nz(ema[1], pow) nz(Series / math.sqrt(ema)) //==== Normalized Roofing Filter for Price ====// float HP = butterworthHP(source, periodHP ) float Price = superSmoother( HP, periodLP ) float PriceRMS = fastRMS( Price, periodRMS) //=== Normalized Roofing Filter for Volume ==// float VolHP = butterworthHP(volume, periodHP ) float Vol = superSmoother( VolHP, periodLP ) float VolRMS = fastRMS( Vol, periodRMS) //=== Output/Visualization ==// bool isOsc = mode=='Oscillators' // Option 1: Visalize the data as two separate oscillator time series plot(isOsc?PriceRMS:na, "Area", #0077FF40, style=plot.style_area) plot(isOsc?PriceRMS:na, "PRMS", #0077FF, 2) plot( isOsc?VolRMS:na, "VRMS", #FF7700) hline( 2.0, "2σ", #FF0000CC) hline( 1.0, "1σ", #FF000055, hline.style_dotted, 2) hline( 0.0, "Zero", #808080) hline( -1.0, "-1σ", #00FF0055, hline.style_dotted, 2) hline( -2.0, "-2σ", #00FF00CC) // Option 2: Visualize the data as a scatterplot (Crocker chart) // @function Draws deviation boxes DrawDeviationBox (int deviations, color bgcolor, int bar_scale=100) => int halfWidth = int(deviations * bar_scale) if halfWidth > 500 runtime.error('Width must be less than 500.') if barstate.islast var Box = box.new( bar_index, deviations, bar_index, -deviations, border_color=bgcolor, border_style=line.style_dotted, bgcolor=color.new(bgcolor, 96), text_size=size.small, text=str.tostring(deviations) + ' deviations', text_color=bgcolor, text_valign=text.align_bottom) box.set_left( Box, bar_index - halfWidth) box.set_right(Box, bar_index + halfWidth) // // @function Draws the labels DrawDeviationBoxLabels (color text_color=#ffffa080, color bg_color=#00000020, int bar_scale=100, string size=size.small) => int right = bar_index + 3 * bar_scale int left = bar_index - 3 * bar_scale var label l_top_right = label.new(right, 3.0, 'Up Price | Up Volume' , color=bg_color, style=label.style_label_down, textcolor=text_color, size=size) var label l_bot_right = label.new(right, -3.0, 'Down Price | Up Volume' , color=bg_color, style=label.style_label_up , textcolor=text_color, size=size) var label l_top_left = label.new(left , 3.0, 'Up Price | Down Volume' , color=bg_color, style=label.style_label_down, textcolor=text_color, size=size) var label l_bot_left = label.new(left , -3.0, 'Down Price | Down Volume', color=bg_color, style=label.style_label_up , textcolor=text_color, size=size) label.set_x(l_top_right, right) label.set_x(l_bot_right, right) label.set_x(l_top_left, left) label.set_x(l_bot_left, left) // // @function Helper method to draw the symbol data over the cartesian space, where 1 unit == 1 deviation. DrawCrockerSegment ( string symbol, float vol, float price, int depth=5, color tcolor=color.blue, string style=line.style_dashed, string bullet='⦿', string size=size.small, int bar_scale=100 ) => // // var _Li = array.new<line>(depth) var _La = array.new<label>(depth+1) float _sump = 0.0 float _sumv = 0.0 if bar_index > depth for _i = depth to 0 float _cv = vol[_i+1] float _cp = price[_i+1] if _i < depth int _x1 = bar_index + math.min(500, int(_sumv * bar_scale)) int _x2 = bar_index + math.min(500, int(_cv * bar_scale)) // line _line = line.new( x1=_x1, y1=_sump, x2=_x2, y2=_cp, color=tcolor, style=style, width=1//math.max(1, int((_i / depth) * 5.0)) ) label _lab = label.new( x=_x2, y=_cp, text=bullet, color=color.rgb(0,0,0,99), style=label.style_label_center, textcolor=tcolor, size=size) // line.delete(array.get(_Li, _i)) array.set(_Li, _i, _line) label.delete(array.get(_La, _i+1)) array.set(_La, _i+1, _lab) if _i == depth-1 label.delete(array.get(_La, 0)) label _lab1 = label.new( x=_x1, y=_sump, text=symbol, color=color.rgb(0,0,0,60), style=label.style_label_center, textcolor=tcolor, size=size.small) array.set(_La, 0, _lab1) _sump := _cp _sumv := _cv // if not isOsc DrawDeviationBox(3, i_col_devbox, i_barScale) DrawDeviationBox(2, i_col_devbox, i_barScale) DrawDeviationBox(1, i_col_devbox, i_barScale) DrawDeviationBoxLabels(c_devbox_border, c_devbox_bg, i_barScale, size.small) DrawCrockerSegment(array.get(str.split(syminfo.tickerid, ':'), 1), VolRMS, PriceRMS, i_depth, i_col0, i_ls0, i_bul0, i_size, i_barScale)
alsat-direncler
https://www.tradingview.com/script/gpZqXuyE/
edosutcu
https://www.tradingview.com/u/edosutcu/
185
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/ // © LonesomeTheBlue //@version=4 study("alsat-direncler", "edosutcu", overlay = true, max_bars_back = 501) prd = input(defval = 10, title="Pivot Period", minval = 4, maxval = 30, group = "Settings 🔨", tooltip="Used while calculating Pivot Points, checks left&right bars") ppsrc = input(defval = 'High/Low', title="Source", options = ['High/Low', 'Close/Open'], group = "Settings 🔨", tooltip="Source for Pivot Points") ChannelW = input(defval = 5, title = "Maximum Channel Width %", minval = 1, maxval = 8, group = "Settings 🔨", tooltip="Calculated using Highest/Lowest levels in 300 bars") minstrength = input(defval = 1, title = "Minimum Strength", minval = 1, group = "Settings 🔨", tooltip = "Channel must contain at least 2 Pivot Points") maxnumsr = input(defval = 6, title = "Maximum Number of S/R", minval = 1, maxval = 10, group = "Settings 🔨", tooltip = "Maximum number of Support/Resistance Channels to Show") - 1 loopback = input(defval = 290, title = "Loopback Period", minval = 100, maxval = 400, group = "Settings 🔨", tooltip="While calculating S/R levels it checks Pivots in Loopback Period") res_col = input(defval = color.new(color.red, 75), title = "Resistance Color", group = "Colors 🟡🟢🟣") sup_col = input(defval = color.new(color.lime, 75), title = "Support Color", group = "Colors 🟡🟢🟣") inch_col = input(defval = color.new(color.gray, 75), title = "Color When Price in Channel", group = "Colors 🟡🟢🟣") showpp = input(defval = false, title = "Show Pivot Points", group = "Extras ⏶⏷") showsrbroken = input(defval = false, title = "Show Broken Support/Resistance", group = "Extras ⏶⏷") showthema1en = input(defval = false, title = "MA 1", inline = "ma1") showthema1len = input(defval = 50, title = "", inline = "ma1") showthema1type = input(defval = "SMA", title = "", options = ["SMA", "EMA"], inline = "ma1") showthema2en = input(defval = false, title = "MA 2", inline = "ma2") showthema2len = input(defval = 200, title = "", inline = "ma2") showthema2type = input(defval = "SMA", title = "", options = ["SMA", "EMA"], inline = "ma2") ma1 = showthema1en ? (showthema1type == "SMA" ? sma(close, showthema1len) : ema(close, showthema1len)) : na ma2 = showthema2en ? (showthema2type == "SMA" ? sma(close, showthema2len) : ema(close, showthema2len)) : na plot(ma1, color = not na(ma1) ? color.blue : na) plot(ma2, color = not na(ma2) ? color.red : na) // get Pivot High/low float src1 = ppsrc == 'High/Low' ? high : max(close, open) float src2 = ppsrc == 'High/Low' ? low: min(close, open) float ph = pivothigh(src1, prd, prd) float pl = pivotlow(src2, prd, prd) // draw Pivot points plotshape(ph and showpp, text = "H", style = shape.labeldown, color = na, textcolor = color.red, location = location.abovebar, offset = -prd) plotshape(pl and showpp, text = "L", style = shape.labelup, color = na, textcolor = color.lime, location = location.belowbar, offset = -prd) //calculate maximum S/R channel width prdhighest = highest(300) prdlowest = lowest(300) cwidth = (prdhighest - prdlowest) * ChannelW / 100 // get/keep Pivot levels var pivotvals= array.new_float(0) var pivotlocs= array.new_float(0) if ph or pl array.unshift(pivotvals, ph ? ph : pl) array.unshift(pivotlocs, bar_index) for x = array.size(pivotvals) - 1 to 0 if bar_index - array.get(pivotlocs, x) > loopback // remove old pivot points array.pop(pivotvals) array.pop(pivotlocs) continue break //find/create SR channel of a pivot point get_sr_vals(ind)=> float lo = array.get(pivotvals, ind) float hi = lo int numpp = 0 for y = 0 to array.size(pivotvals) - 1 float cpp = array.get(pivotvals, y) float wdth = cpp <= hi ? hi - cpp : cpp - lo if wdth <= cwidth // fits the max channel width? if cpp <= hi lo := min(lo, cpp) else hi := max(hi, cpp) numpp := numpp + 20 // each pivot point added as 20 [hi, lo, numpp] // keep old SR channels and calculate/sort new channels if we met new pivot point var suportresistance = array.new_float(20, 0) // min/max levels changeit(x, y)=> tmp = array.get(suportresistance, y * 2) array.set(suportresistance, y * 2, array.get(suportresistance, x * 2)) array.set(suportresistance, x * 2, tmp) tmp := array.get(suportresistance, y * 2 + 1) array.set(suportresistance, y * 2 + 1, array.get(suportresistance, x * 2 + 1)) array.set(suportresistance, x * 2 + 1, tmp) if ph or pl supres = array.new_float(0) // number of pivot, strength, min/max levels stren = array.new_float(10, 0) // get levels and strengs for x = 0 to array.size(pivotvals) - 1 [hi, lo, strength] = get_sr_vals(x) array.push(supres, strength) array.push(supres, hi) array.push(supres, lo) // add each HL to strengh for x = 0 to array.size(pivotvals) - 1 h = array.get(supres, x * 3 + 1) l = array.get(supres, x * 3 + 2) s = 0 for y = 0 to loopback if (high[y] <= h and high[y] >= l) or (low[y] <= h and low[y] >= l) s := s + 1 array.set(supres, x * 3, array.get(supres, x * 3) + s) //reset SR levels array.fill(suportresistance, 0) // get strongest SRs src = 0 for x = 0 to array.size(pivotvals) - 1 stv = -1. // value stl = -1 // location for y = 0 to array.size(pivotvals) - 1 if array.get(supres, y * 3) > stv and array.get(supres, y * 3) >= minstrength * 20 stv := array.get(supres, y * 3) stl := y if stl >= 0 //get sr level hh = array.get(supres, stl * 3 + 1) ll = array.get(supres, stl * 3 + 2) array.set(suportresistance, src * 2, hh) array.set(suportresistance, src * 2 + 1, ll) array.set(stren, src, array.get(supres, stl * 3)) // make included pivot points' strength zero for y = 0 to array.size(pivotvals) - 1 if (array.get(supres, y * 3 + 1) <= hh and array.get(supres, y * 3 + 1) >= ll) or (array.get(supres, y * 3 + 2) <= hh and array.get(supres, y * 3 + 2) >= ll) array.set(supres, y * 3, -1) src += 1 if src >= 10 break for x = 0 to 8 for y = x + 1 to 9 if array.get(stren, y) > array.get(stren, x) tmp = array.get(stren, y) array.set(stren, y, array.get(stren, x)) changeit(x, y) get_level(ind)=> float ret = na if ind < array.size(suportresistance) if array.get(suportresistance, ind) != 0 ret := array.get(suportresistance, ind) ret get_color(ind)=> color ret = na if ind < array.size(suportresistance) if array.get(suportresistance, ind) != 0 ret := array.get(suportresistance, ind) > close and array.get(suportresistance, ind + 1) > close ? res_col : array.get(suportresistance, ind) < close and array.get(suportresistance, ind + 1) < close ? sup_col : inch_col ret var srchannels = array.new_box(10) for x = 0 to min(9, maxnumsr) box.delete(array.get(srchannels, x)) srcol = get_color(x * 2) if not na(srcol) array.set(srchannels, x, box.new(left = bar_index, top = get_level(x * 2), right = bar_index + 1, bottom = get_level(x * 2 + 1), border_color = srcol, border_width = 1, extend = extend.both, bgcolor = srcol)) resistancebroken = false supportbroken = false // check if it's not in a channel not_in_a_channel = true for x = 0 to min(9, maxnumsr) if close <= array.get(suportresistance, x * 2) and close >= array.get(suportresistance, x * 2 + 1) not_in_a_channel := false // if price is not in a channel then check broken ones if not_in_a_channel for x = 0 to min(9, maxnumsr) if close[1] <= array.get(suportresistance, x * 2) and close > array.get(suportresistance, x * 2) resistancebroken := true if close[1] >= array.get(suportresistance, x * 2 + 1) and close < array.get(suportresistance, x * 2 + 1) supportbroken := true alertcondition(resistancebroken, title = "Resistance Broken", message = "Resistance Broken") alertcondition(supportbroken, title = "Support Broken", message = "Support Broken") plotshape(showsrbroken and resistancebroken, style = shape.triangleup, location = location.belowbar, color = color.new(color.lime, 0), size = size.tiny) plotshape(showsrbroken and supportbroken, style = shape.triangledown, location = location.abovebar, color = color.new(color.red, 0), size = size.tiny) //@version=4 //Original Script > @DonovanWall // Actual Version > @guikroth ////////////////////////////////////////////////////////////////////////// // Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters ////////////////////////////////////////////////////////////////////////// // Source src = input(defval=close, title="Source") // Sampling Period // Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters per = input(defval=100, minval=1, title="Sampling Period") // Range Multiplier mult = input(defval=3.0, minval=0.1, title="Range Multiplier") // Smooth Average Range smoothrng(x, t, m) => wper = t * 2 - 1 avrng = ema(abs(x - x[1]), t) smoothrng = ema(avrng, wper) * m smoothrng smrng = smoothrng(src, per, mult) // Range Filter rngfilt(x, r) => rngfilt = x rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r rngfilt filt = rngfilt(src, smrng) // Filter Direction upward = 0.0 upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) downward = 0.0 downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) // Target Bands hband = filt + smrng lband = filt - smrng // Colors filtcolor = upward > 0 ? color.lime : downward > 0 ? color.red : color.orange barcolor = src > filt and src > src[1] and upward > 0 ? color.lime : src > filt and src < src[1] and upward > 0 ? color.green : src < filt and src < src[1] and downward > 0 ? color.red : src < filt and src > src[1] and downward > 0 ? color.maroon : color.orange filtplot = plot(filt, color=filtcolor, linewidth=3, title="Range Filter") // Target hbandplot = plot(hband, color=color.aqua, transp=100, title="High Target") lbandplot = plot(lband, color=color.fuchsia, transp=100, title="Low Target") // Fills fill(hbandplot, filtplot, color=color.aqua, title="High Target Range") fill(lbandplot, filtplot, color=color.fuchsia, title="Low Target Range") // Bar Color barcolor(barcolor) // Break Outs longCond = bool(na) shortCond = bool(na) longCond := src > filt and src > src[1] and upward > 0 or src > filt and src < src[1] and upward > 0 shortCond := src < filt and src < src[1] and downward > 0 or src < filt and src > src[1] and downward > 0 CondIni = 0 CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] longCondition = longCond and CondIni[1] == -1 shortCondition = shortCond and CondIni[1] == 1 //Alerts plotshape(longCondition, title="Buy Signal", text="BUY", textcolor=color.white, style=shape.labelup, size=size.normal, location=location.belowbar, color=color.green, transp=0) plotshape(shortCondition, title="Sell Signal", text="SELL", textcolor=color.white, style=shape.labeldown, size=size.normal, location=location.abovebar, color=color.red, transp=0) alertcondition(longCondition, title="Buy Alert", message="BUY") alertcondition(shortCondition, title="Sell Alert", message="SELL") //For use like Strategy, //1. Change the word "study" for "strategy" at the top //2. Remove the "//" below //strategy.entry( id = "Long", long = true, when = longCondition ) //strategy.close( id = "Long", when = shortCondition )
Pullback Candles (Candlestick Analysis) Guaranteed Winners!!!!
https://www.tradingview.com/script/qb0OGnPK-Pullback-Candles-Candlestick-Analysis-Guaranteed-Winners/
LuxTradeVenture
https://www.tradingview.com/u/LuxTradeVenture/
2,103
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MINTYFRESH97 //@version=5 //@version=5 indicator("Pullback Candle " ,overlay=true ) //swing high/low filter swingHigh = high == ta.highest(high,10) or high[1] == ta.highest(high,10) swingLow = low == ta.lowest(low,6) or low[1] ==ta.lowest(low,6) //user input var g_ema = "EMA Filter" emaLength = input.int(title="EMA Length", defval=50, tooltip="Length of the EMA filter", group=g_ema) useEmaFilter = input.bool(title="Use EMA Filter?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema) // Get EMA filter ema = ta.ema(close, emaLength) emaFilterLong = not useEmaFilter or close > ema emaFilterShort = not useEmaFilter or close < ema //DETECT MARUBUZO pullBack = (close[2] < close[3]) and (close[2] < close[3]) and (close[1] < close[2]) and (close > close[1]) and emaFilterLong and swingLow // Plot our candle patterns plotshape(pullBack, style=shape.xcross,size=size.tiny, color=color.green, text="PB",location=location.belowbar) alertcondition(pullBack, "Pullback Candle ", "Pullback Candle detected for {{ticker}}") barcolor(pullBack ? color.green :na)
CB-BINANCE basis
https://www.tradingview.com/script/G17n62OH/
youngpimpy
https://www.tradingview.com/u/youngpimpy/
4
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © youngpimpy //@version=5 indicator(' CB-BINANCE basis', overlay=false) //Uses candle closes for difference so best accuracy on lower timeframes premium = request.security('COINBASE:BTCUSD', timeframe.period, close) - request.security('BINANCE:BTCUSDT', timeframe.period, close) premiumPercent = premium / close * 100 plot(premiumPercent, color=premiumPercent >= 0 ? color.blue : color.red) plot(0, color=color.new(color.black, 0))
season
https://www.tradingview.com/script/lWrYdIH1-season/
voided
https://www.tradingview.com/u/voided/
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/ // © voided //@version=5 indicator("season", overlay = true) type = input.string("month", options = [ "month", "weekofyear", "dayofmonth", "dayofweek", "hour", "minute"]) labels = input.bool(false, "labels") start = input(1, "start") end = input(3, "end") delta = end - start + 1 src = type == "month" ? month : type == "weekofyear" ? weekofyear : type == "dayofmonth" ? dayofmonth : type == "dayofweek" ? dayofweek : type == "hour" ? hour : type == "minute" ? minute : na highlight = color.new(color.red, 90) none = color.new(color.white, 100) on = src >= start and src <= end bgcolor(on ? highlight : none) var sea_sampling = array.new_float() var pop_sampling = array.new_float() ret = math.log(close / close[1]) if src == end sea_rets = array.new_float() for i = 0 to delta array.push(sea_rets, ret[i]) array.push(sea_sampling, array.avg(sea_rets)) if labels label.new(bar_index, high * 1.5, text = str.tostring(ret * 100, "#.##") + "%", style = label.style_none) else pop_rets = array.new_float() for i = 0 to delta array.push(pop_rets, ret[i]) array.push(pop_sampling, array.avg(pop_rets)) if barstate.islast fmt = "#.##" t = table.new(position.middle_right, 3, 12, bgcolor = color.white) sea_avg = array.avg(sea_sampling) pop_avg = array.avg(pop_sampling) sea_std = array.stdev(sea_sampling) pop_std = array.stdev(pop_sampling) sea_size = array.size(sea_sampling) pop_size = array.size(pop_sampling) z = (sea_avg - pop_avg) / (sea_std / math.sqrt(sea_size)) p05 = z >= -2 and z <= 2 ? color.red : color.green p01 = z >= -2.575829 and z <= 2.575829 ? color.red : color.green lbl_clr = color.new(color.blue, 80) table.cell(t, 0, 0, bgcolor = lbl_clr) table.cell(t, 1, 0, "season", bgcolor = lbl_clr) table.cell(t, 2, 0, "population", bgcolor = lbl_clr) table.cell(t, 0, 1, "samples", bgcolor = lbl_clr) table.cell(t, 1, 1, str.tostring(sea_size, fmt)) table.cell(t, 2, 1, str.tostring(pop_size, fmt)) table.cell(t, 0, 2, "mean", bgcolor = lbl_clr) table.cell(t, 1, 2, str.tostring(sea_avg * 100, fmt) + "%") table.cell(t, 2, 2, str.tostring(pop_avg * 100, fmt) + "%") table.cell(t, 0, 3, "median", bgcolor = lbl_clr) table.cell(t, 1, 3, str.tostring(array.median(sea_sampling) * 100, fmt) + "%") table.cell(t, 2, 3, str.tostring(array.median(pop_sampling) * 100, fmt) + "%") table.cell(t, 0, 4, "stdev", bgcolor = lbl_clr) table.cell(t, 1, 4, str.tostring(sea_std * 100, fmt) + "%") table.cell(t, 2, 4, str.tostring(pop_std * 100, fmt) + "%") table.cell(t, 0, 5, "1%", bgcolor = lbl_clr) table.cell(t, 1, 5, str.tostring(array.percentile_nearest_rank(sea_sampling, 1) * 100, fmt) + "%") table.cell(t, 2, 5, str.tostring(array.percentile_nearest_rank(pop_sampling, 1) * 100, fmt) + "%") table.cell(t, 0, 6, "5%", bgcolor = lbl_clr) table.cell(t, 1, 6, str.tostring(array.percentile_nearest_rank(sea_sampling, 5) * 100, fmt) + "%") table.cell(t, 2, 6, str.tostring(array.percentile_nearest_rank(pop_sampling, 5) * 100, fmt) + "%") table.cell(t, 0, 7, "95%", bgcolor = lbl_clr) table.cell(t, 1, 7, str.tostring(array.percentile_nearest_rank(sea_sampling, 95) * 100, fmt) + "%") table.cell(t, 2, 7, str.tostring(array.percentile_nearest_rank(pop_sampling, 95) * 100, fmt) + "%") table.cell(t, 0, 8, "99%", bgcolor = lbl_clr) table.cell(t, 1, 8, str.tostring(array.percentile_nearest_rank(sea_sampling, 99) * 100, fmt) + "%") table.cell(t, 2, 8, str.tostring(array.percentile_nearest_rank(pop_sampling, 99) * 100, fmt) + "%") table.cell(t, 0, 9, "z-test", bgcolor = lbl_clr) table.cell(t, 1, 9, str.tostring(z, fmt)) table.cell(t, 2, 9) table.cell(t, 0, 10, "significant (p = 0.05)", bgcolor = lbl_clr) table.cell(t, 1, 10, bgcolor = p05) table.cell(t, 2, 10, bgcolor = p05) table.cell(t, 0, 11, "significant (p = 0.01)", bgcolor = lbl_clr) table.cell(t, 1, 11, bgcolor = p01) table.cell(t, 2, 11, bgcolor = p01)
Price delta
https://www.tradingview.com/script/4BnSvXtG-Price-delta/
Crypto-Hamster
https://www.tradingview.com/u/Crypto-Hamster/
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/ // © Crypto-Hamster //@version=5 indicator(title="Price delta") Length = input.int(14, minval=1) Source = input.source(close) TestMA = ta.sma(close, Length) Delta = (Source[0] - Source[1])/Source[1] * 100 DeltaRatio = (close - TestMA) * 100 / close plot(Delta, color=color.white, title="Delta") plot(DeltaRatio, color=color.lime, title="Delta")
TRADEMASTER 2.35
https://www.tradingview.com/script/JTwuel3A-TRADEMASTER-2-35/
marketsoldier
https://www.tradingview.com/u/marketsoldier/
183
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/ // © maheshpatil //////i copied the code and made it as per mine not my orignal code and rights reseved to admin@ TRADEMASTER EDUTECH //@version=4 study(title="TRADEMASTER 2.35", shorttitle=" TRADEMASTER 2.35 ", overlay=true) up15on = input(true, title="15 Minute Opening Range High") down15on = input(true, title="15 Minute Opening Range Low") is_newbar(res) => change(time(res)) != 0 adopt(r, s) => security(syminfo.tickerid, r, s) //high_range = valuewhen(is_newbar('D'),high,0) //low_range = valuewhen(is_newbar('D'),low,0) high_rangeL = valuewhen(is_newbar('D'),high,0) low_rangeL = valuewhen(is_newbar('D'),low,0) diff = (high_rangeL-low_rangeL)/2.35 up15 = plot(up15on ? adopt('15', high_rangeL): na, color = #009900, linewidth=1,style=plot.style_line) down15 = plot(down15on ? adopt('15', low_rangeL): na, color = #ff0000, linewidth=1,style=plot.style_line) diffup15 = plot(up15on ? adopt('15', (high_rangeL+diff)): na, color = #009900, linewidth=1,style=plot.style_line) diffdown15 = plot(down15on ? adopt('15', (low_rangeL-diff)): na, color = #ff0000, linewidth=1,style=plot.style_line)
Yearly Percentage Returns
https://www.tradingview.com/script/X1gZMTl7-Yearly-Percentage-Returns/
Botnet101
https://www.tradingview.com/u/Botnet101/
229
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Botnet101 //@version=5 indicator(title="Yearly Percentage Returns", overlay=false, precision=2, format=format.percent, max_labels_count=500) // Inputs //{ show_separator = input.bool (defval=true , title="Enable Separator", group='Separator Settings', inline='Separator') color_separator = input.color (defval=color.new(color.yellow , 80) , title="" , group='Separator Settings', inline='Separator') show_line1 = input.bool (defval=false , title="Line 1", group='Lines Settings', inline='Line 1') value_line1 = input.float (defval=0 , title="" , group='Lines Settings', inline='Line 1') color_line1 = input.color (defval=color.new(color.white , 70) , title="" , group='Lines Settings', inline='Line 1') style_line1 = input.string(defval="Dashed", options=["Dashed", "Dotted", "Solid"], title="" , group='Lines Settings', inline='Line 1') show_line2 = input.bool (defval=false , title="Line 2", group='Lines Settings', inline='Line 2') value_line2 = input.float (defval=0 , title="" , group='Lines Settings', inline='Line 2') color_line2 = input.color (defval=color.new(color.white , 70) , title="" , group='Lines Settings', inline='Line 2') style_line2 = input.string(defval="Dashed", options=["Dashed", "Dotted", "Solid"], title="" , group='Lines Settings', inline='Line 2') show_line3 = input.bool (defval=false , title="Line 3", group='Lines Settings', inline='Line 3') value_line3 = input.float (defval=0 , title="" , group='Lines Settings', inline='Line 3') color_line3 = input.color (defval=color.new(color.white , 70) , title="" , group='Lines Settings', inline='Line 3') style_line3 = input.string(defval="Dashed", options=["Dashed", "Dotted", "Solid"], title="" , group='Lines Settings', inline='Line 3') show_line4 = input.bool (defval=false , title="Line 4", group='Lines Settings', inline='Line 4') value_line4 = input.float (defval=0 , title="" , group='Lines Settings', inline='Line 4') color_line4 = input.color (defval=color.new(color.white , 70) , title="" , group='Lines Settings', inline='Line 4') style_line4 = input.string(defval="Dashed", options=["Dashed", "Dotted", "Solid"], title="" , group='Lines Settings', inline='Line 4') show_line5 = input.bool (defval=false , title="Line 5", group='Lines Settings', inline='Line 5') value_line5 = input.float (defval=0 , title="" , group='Lines Settings', inline='Line 5') color_line5 = input.color (defval=color.new(color.white , 70) , title="" , group='Lines Settings', inline='Line 5') style_line5 = input.string(defval="Dashed", options=["Dashed", "Dotted", "Solid"], title="" , group='Lines Settings', inline='Line 5') input_table_enable = input.bool (defval=true , title="Enable Table", group="Table Settings") input_table_size = input.string(defval="Small" , title="Size" , group="Table Settings", options=["Auto", "Tiny", "Small", "Normal", "Large", "Huge"]) input_table_position = input.string(defval="Top Right", title="Position" , group="Table Settings", options=["Top Left", "Top Right", "Bottom Left", "Bottom Right"]) input_table_direction = input.string(defval="Vertical" , title="Direction" , group="Table Settings", options=["Vertical", "Horizontal"]) input_sort_order = input.string(defval="Ascending", title="Sort By" , group="Table Settings", options=["Ascending", "Descending"]) //} table_size = switch input_table_size "Auto" => size.auto "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large "Huge" => size.huge table_position = switch input_table_position "Top Left" => position.top_left "Top Right" => position.top_right "Bottom Left" => position.bottom_left "Bottom Right" => position.bottom_right GetLineStyle (line_style) => switch line_style "Dashed" => hline.style_dashed "Dotted" => hline.style_dotted "Solid" => hline.style_solid GetOpen (timeframe) => request.security(syminfo.tickerid, timeframe, close[1], lookahead=barmerge.lookahead_on) var float[] yearly_returns = array.new_float(0) var int[] year_array = array.new_int(0) var float yearly_openPrice = 0.0 var table returns_table = table(na) // Plot Yearly return //{ // Check if it is a new year bool isNewYear = year(time) != year(time[1]) // Get the Yearly Opening price yearly_openPrice := GetOpen('12M') // Calculate the yearly return float yearly_return = 100 * (close - yearly_openPrice) / yearly_openPrice color plot_color = yearly_return > 0 ? color.green : color.red plot(yearly_return, title="Yearly Returns", style=plot.style_areabr, color=color.new(plot_color, 30)) // Show Background color color separator_col = show_separator and isNewYear ? color_separator : na bgcolor(separator_col, title="Year separator", editable=false) //} // Plot current and previous yearly return Labels //{ label past_return_label = na label current_return_label = na if (isNewYear) // Only push non-NaN values to array bool isNaN = na(yearly_return[1]) if (not isNaN) past_return_label := label.new(bar_index[1], yearly_return[1], str.tostring(yearly_return[1], format.percent), textcolor=color.white, color=plot_color[1]) label.set_style(past_return_label, yearly_return[1] > 0 ? label.style_label_down : label.style_label_up) array.push(yearly_returns, yearly_return[1]) array.push(year_array , year-1 ) label.delete(past_return_label[1]) // Plot current year returns if (barstate.islast) current_return_label := label.new(bar_index, yearly_return, str.tostring(yearly_return, format.percent), textcolor=color.white, color=plot_color) label.set_style(current_return_label, yearly_return > 0 ? label.style_label_down : label.style_label_up) array.push(yearly_returns, yearly_return) array.push(year_array , year ) label.delete(current_return_label[1]) //} // Plot Horizontal lines //{ hline(show_line1 ? value_line1 : na, title="Line 1", color=color_line1, linestyle=GetLineStyle(style_line1), editable=false) hline(show_line2 ? value_line2 : na, title="Line 2", color=color_line2, linestyle=GetLineStyle(style_line2), editable=false) hline(show_line3 ? value_line3 : na, title="Line 3", color=color_line3, linestyle=GetLineStyle(style_line3), editable=false) hline(show_line4 ? value_line4 : na, title="Line 4", color=color_line4, linestyle=GetLineStyle(style_line4), editable=false) hline(show_line5 ? value_line5 : na, title="Line 5", color=color_line5, linestyle=GetLineStyle(style_line5), editable=false) //} // Plot Table //{ InsertCell (id, int col_index, int row_index, string _text, color _colour=#aaaaaa) => table.cell(table_id=id, column=col_index, row=row_index, text=_text, text_size=table_size, bgcolor=_colour) if (barstate.islast and input_table_enable and array.size(yearly_returns) > 0) int _header_size = 2 int _returns_size = array.size(yearly_returns) + 1 _table = switch input_table_direction "Vertical" => array.from(_header_size , _returns_size) "Horizontal" => array.from(_returns_size, _header_size) int _column_size = array.get(_table, 0) int _rows_size = array.get(_table, 1) returns_table := table.new(table_position, columns=_column_size, rows=_rows_size, border_width=1) // Insert headers to table if input_table_direction == "Vertical" InsertCell(returns_table, 0, 0, "Year" ) InsertCell(returns_table, 1, 0, "% Returns") else InsertCell(returns_table, 0, 0, "Year" ) InsertCell(returns_table, 0, 1, "% Returns") // Insert data to table for i=0 to array.size(yearly_returns) - 1 color col = array.get(yearly_returns, i) > 0 ? color.green : color.red string _year = str.tostring(array.get(year_array , i) ) string _returns = str.tostring(array.get(yearly_returns, i), format.percent) if input_table_direction == "Vertical" int _row_pos = input_sort_order == "Descending" ? _rows_size - i - 1 : i + 1 InsertCell(returns_table, 0 ,_row_pos, _year ) InsertCell(returns_table, 1 ,_row_pos, _returns, _colour=col) else int _column_pos = input_sort_order == "Descending" ? _column_size - i - 1 : i + 1 InsertCell(returns_table, _column_pos, 0, _year ) InsertCell(returns_table, _column_pos, 1, _returns, _colour=col) //}
Awesome Oscillator Plus
https://www.tradingview.com/script/GovhteZ5/
OskarGallard
https://www.tradingview.com/u/OskarGallard/
494
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © OskarGallard //@version=5 indicator(title="Awesome Oscillator Plus", shorttitle="AO [+]", timeframe="", timeframe_gaps=true) // Input - Awesome Oscillator { group_ao = "Awesome Oscillator" show_ao = input.bool(true, "Show AO", inline="inputAO", group = group_ao) type_osc = input.string("SMA", "MA Type", inline="inputAO", group = group_ao, options=["JMA", "NWMA", "VAMA", "SMA", "EMA", "WMA", "DWMA", "Wild", "LSMA", "ALMA", "VWMA", "DVWMA", "HMA", "COVWMA", "FRAMA", "KAMA", "Zero Lag", "RMA", "DEMA", "TEMA", "Median"]) ao_src = input.source(hl2, "   Source", inline="inputAO", group = group_ao) show_sig = input.bool(false, "Show Signal", inline="signal", group = group_ao) type_sig = input.string("NWMA", "MA Type", inline="signal", group = group_ao, options=["JMA", "NWMA", "VAMA", "SMA", "EMA", "WMA", "DWMA", "Wild", "LSMA", "ALMA", "VWMA", "DVWMA", "HMA", "COVWMA", "FRAMA", "KAMA", "Zero Lag", "RMA", "DEMA", "TEMA", "Median"]) len_sig = input.int(15, "Length", 1, inline="signal", group = group_ao) show_saucer_bull = input.bool(true, "Bullrish Saucer   ", inline="saucer", group = group_ao) show_saucer_bear = input.bool(true, "Bearish Saucer", inline="saucer", group = group_ao) len_HL = input.int(150, "Highest/Lowest Period", 5, inline="HL", group = group_ao) show_Highest = input.bool(false, "Show Highest ", inline="HL", group = group_ao) show_Lowest = input.bool(false, "Show Lowest", inline="HL", group = group_ao) // VAMA factor factor = input.float(0.67, "Factor (if VAMA)", minval = 0.01, step = 0.1, group = group_ao) // JMA phaseJ = input.int(50, "Phase (if JMA)", group = group_ao) powerJ = input.int(2, "Power (if JMA)", group = group_ao) // Volume Type voltype = input.string("Default", "Volume Type (if VWMA)", options=["Default", "Tick"], group = group_ao) // LSMA Offset loff = input.int(0, "Offset (if LSMA)", minval=0, group = group_ao) // ALMA Offset and Sigma offs = input.float(0.85, "Offset (if ALMA)", step=0.01, minval=0, group = group_ao) sigma = input.int(6, "Sigma (if ALMA)", minval=0, group = group_ao) // FRAMA Coefficient w = input.float(-4.6, "Coefficient (if FRAMA)", group = group_ao) // KAMA Smoothing Constant fastK = input.float(0.666, "Smoothing Constant Fast End (if KAMA)", step=0.001, group = group_ao) slowK = input.float(0.0645, "Smoothing Constant Slow End (if KAMA)", step=0.0001, group = group_ao) // } // Types of moving averages{ // JMA - Jurik Moving Average of @everget jma(src, length, power, phase) => phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5 beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2) alpha = math.pow(beta, power) Jma = 0.0 e0 = 0.0 e0 := (1 - alpha) * src + alpha * nz(e0[1]) e1 = 0.0 e1 := (src - e0) * (1 - beta) + beta * nz(e1[1]) e2 = 0.0 e2 := (e0 + phaseRatio * e1 - nz(Jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1]) Jma := e2 + nz(Jma[1]) Jma // KAMA - Kaufman's Adaptive Moving Average kama(x, t)=> dist = math.abs(x[0] - x[1]) signal_x = math.abs(x - x[t]) noise = math.sum(dist, t) effr = noise!=0 ? signal_x/noise : 1 sc = math.pow(effr*(fastK - slowK) + slowK,2) KAma = x KAma := nz(KAma[1]) + sc*(x - nz(KAma[1])) KAma // COVWMA - Coefficient of Variation Weighted Moving Average of @DonovanWall covwma(a, b) => cov = ta.stdev(a, b) / ta.sma(a, b) cw = a*cov covwma = math.sum(cw, b) / math.sum(cov, b) // FRAMA - Fractal Adaptive Moving Average of @DonovanWall frama(a, b) => frama = 0.0 n3 = (ta.highest(high, b) - ta.lowest(low, b))/b hd2 = ta.highest(high, b/2) ld2 = ta.lowest(low, b/2) n2 = (hd2 - ld2)/(b/2) n1 = (hd2[b/2] - ld2[b/2])/(b/2) dim = (n1 > 0) and (n2 > 0) and (n3 > 0) ? (math.log(n1 + n2) - math.log(n3))/math.log(2) : 0 alpha = math.exp(w*(dim - 1)) sc = (alpha < 0.01 ? 0.01 : (alpha > 1 ? 1 : alpha)) frama := ta.cum(1)<=2*b ? a : (a*sc) + nz(frama[1])*(1 - sc) frama // ZLEMA: Zero Lag zema(_src, _len) => alpha = (_len - 1) / 2 zlema0 = _src + _src - _src[alpha] zlemaF = ta.ema(zlema0, _len) zlemaF // VWMA VWMA(x, t) => tick = syminfo.mintick rng = close - open tickrng = tick tickrng := math.abs(rng) < tick ? nz(tickrng[1]) : rng tickvol = math.abs(tickrng) / tick vol = voltype == "Default" ? (volume == na ? tickvol : volume) : tickvol vmp = x * vol VWMA = math.sum(vmp, t) / math.sum(vol, t) VWMA // VAMA - Volume Adjusted Moving Average of @allanster vama(_src,_len,_fct,_rul,_nvb) => // vama(source,length,factor,rule,sample) tvb = 0, tvb := _nvb == 0 ? nz(tvb[1]) + 1 : _nvb // total volume bars used in sample tvs = _nvb == 0 ? ta.cum(volume) : math.sum(volume, _nvb) // total volume in sample v2i = volume / ((tvs / tvb) * _fct) // ratio of volume to increments of volume wtd = _src*v2i // weighted prices nmb = 1 // initialize number of bars summed back wtdSumB = 0.0 // initialize weighted prices summed back v2iSumB = 0.0 // initialize ratio of volume to increments of volume summed back for i = 1 to _len * 10 // set artificial cap for strict to VAMA length * 10 to help reduce edge case timeout errors strict = _rul ? false : i == _len // strict rule N bars' v2i ratios >= vama length, else <= vama length wtdSumB := wtdSumB + nz(wtd[i-1]) // increment number of bars' weighted prices summed back v2iSumB := v2iSumB + nz(v2i[i-1]) // increment number of bars' v2i's summed back if v2iSumB >= _len or strict // if chosen rule met break // break (exit loop) nmb := nmb + 1 // increment number of bars summed back counter nmb // number of bars summed back to fulfill volume requirements or vama length wtdSumB // number of bars' weighted prices summed back v2iSumB // number of bars' v2i's summed back vama = (wtdSumB - (v2iSumB - _len) * _src[nmb]) / _len // volume adjusted moving average // New WMA NWMA(_src, _n1) => fast = int(_n1 / 2) lambda = _n1 / fast alpha = lambda * (_n1 - 1) / (_n1 - lambda) ma1 = ta.wma(_src, _n1) ma2 = ta.wma(ma1, fast) nwma = (1 + alpha) * ma1 - alpha * ma2 // Function to know the type of MA ma(MAType, MASource, MAPeriod) => if MAPeriod > 0 if MAType == "SMA" ta.sma(MASource, MAPeriod) else if MAType == "LSMA" ta.linreg(MASource, MAPeriod, loff) else if MAType == "EMA" ta.ema(MASource, MAPeriod) else if MAType == "WMA" ta.wma(MASource, MAPeriod) else if MAType == "RMA" ta.rma(MASource, MAPeriod) else if MAType == "HMA" ta.hma(MASource, MAPeriod) else if MAType == "DEMA" e = ta.ema(MASource, MAPeriod) 2 * e - ta.ema(e, MAPeriod) else if MAType == "TEMA" e = ta.ema(MASource, MAPeriod) 3 * (e - ta.ema(e, MAPeriod)) + ta.ema(ta.ema(e, MAPeriod), MAPeriod) else if MAType == "Median" ta.median(MASource, MAPeriod) else if MAType == "VWMA" VWMA(MASource, MAPeriod) else if MAType == "ALMA" ta.alma(MASource, MAPeriod, offs, sigma) else if MAType == "KAMA" kama(MASource, MAPeriod) else if MAType == "Wild" wild = MASource wild := nz(wild[1]) + (MASource - nz(wild[1])) / MAPeriod else if MAType == "JMA" jma(MASource, MAPeriod, powerJ, phaseJ) else if MAType == "DWMA" // Double Weighted Moving Average ta.wma(ta.wma(MASource, MAPeriod), MAPeriod) else if MAType == "DVWMA" // Double Volume-Weighted Moving Average ta.vwma(ta.vwma(MASource, MAPeriod), MAPeriod) else if MAType == "COVWMA" covwma(MASource, MAPeriod) else if MAType == "FRAMA" frama(MASource, MAPeriod) else if MAType == "Zero Lag" zema(MASource, MAPeriod) else if MAType == "VAMA" vama(MASource, MAPeriod, factor, true, 0) else if MAType == "NWMA" NWMA(MASource, MAPeriod) // } // Input - Moving Average Convergence Divergence{ group_macd = "Moving Average Convergence Divergence" tip_macd = "This factor is used to increase the size of the graph.-" show_macd = input.bool(true, "Show MACD Line", inline="show", group = group_macd) show_cross = input.bool(true, "Show Crossovers", inline="show", group = group_macd) show_barC = input.bool(false, "Show color bars", inline="show", group = group_macd) show_hist = input.bool(false, "Show MACD Histogram", inline="line2", group = group_macd) exp_factor = input.float(5.5, "Expansion Factor", 1, 10, inline="line2", group = group_macd, tooltip = tip_macd) macd_src = input.source(close, "Source", group = group_macd) macd_fast = input.int(13, "Fast MA Length", 1, group = group_macd) macd_slow = input.int(21, "Slow MA Length", 2, group = group_macd) macd_sig = input.int(8, "Signal Length", 1, group = group_macd) // } // Input - Divergences{ group_divergences = "Divergences For Awesome Oscillator" plotBull = input.bool(true, "Plot Bullish   ", inline="bull", group=group_divergences) plotHiddenBull = input.bool(false, "Plot Hidden Bullish", inline="bull", group=group_divergences) plotBear = input.bool(true, "Plot Bearish   ", inline="bear", group=group_divergences) plotHiddenBear = input.bool(false, "Plot Hidden Bearish", inline="bear", group=group_divergences) lbR = input.int(5, "Pivot Lookback Right", group=group_divergences) lbL = input.int(5, "Pivot Lookback Left", group=group_divergences) rangeUpper = input.int(60, "Max of Lookback Range", group=group_divergences) rangeLower = input.int(5, "Min of Lookback Range", group=group_divergences) // } // MACD - Moving Average Convergence Divergence{ [macd_line, macd_signal, macd_hist] = ta.macd(macd_src, macd_fast, macd_slow, macd_sig) cross_up = macd_line < 0 and ta.crossover(macd_line, macd_signal) cross_dn = macd_line > 0 and ta.crossunder(macd_line, macd_signal) // } // AO - Awesome Oscillator { ma_fast = ma(type_osc, ao_src, 5) ma_slow = ma(type_osc, ao_src, 34) ao = ma_fast - ma_slow signal_ao = ma(type_sig, ao, len_sig) diff = ao - ao[1] forma_v = math.abs(ao[2]) > math.abs(ao[1]) highest_55 = ta.highest(ao, len_HL) lowest_55 = ta.lowest(ao, len_HL) ao_Highest = ao > 0 and ao >= highest_55 ao_Lowest = ao < 0 and ao <= lowest_55 bullish_saucer = ao[2] > 0 and ao[1] > 0 and diff[3] < 0 and diff[2] < 0 and forma_v and ta.crossover(diff, 0) bearish_saucer = ao[2] < 0 and ao[1] < 0 and diff[3] > 0 and diff[2] > 0 and forma_v and ta.crossunder(diff, 0) // } // Plots - AO { rojo = color.new(#FF6347, 0) // #96000E verde = color.new(#32CD32, 0) // #00963D plot(show_ao ? ao : na, "Awesome Oscillator", diff <= 0 ? rojo : verde, 3, plot.style_histogram) plot(show_Highest and ao_Highest ? ao : na, "AO Highest", #4774FF, 2, plot.style_circles) plot(show_Lowest and ao_Lowest ? ao : na, "AO Lowest", #4774FF, 2, plot.style_circles) plot(show_sig ? signal_ao : na, "AO Signal", color.silver) plotshape(show_saucer_bull and bullish_saucer, color=verde, style=shape.triangleup, title="Bullish saucer", location=location.bottom) plotshape(show_saucer_bear and bearish_saucer, color=rojo, style=shape.triangledown, title="Bearish saucer", location=location.top) bgcolor(show_saucer_bull and bullish_saucer ? color.new(verde, 85) : na, title="Bullish saucer") bgcolor(show_saucer_bear and bearish_saucer ? color.new(rojo, 85) : na, title="Bearish saucer") // } // Plots - MACD { cian = color.new(#38F5E9, 0) cian_oscuro = color.new(#1C7A74, 0) pink = color.new(#F7709D, 0) pink_oscuro = color.new(#7B384E, 0) color_hist = macd_hist > 0 ? color.new(cian, 80) : color.new(pink, 80) color_up = macd_line > macd_signal ? cian : cian_oscuro color_dn = macd_line < macd_signal ? pink : pink_oscuro color_macd = macd_line > 0 ? color_up : color_dn color_bar = macd_line > 0 ? color_up : color_dn macd_exp = macd_line * exp_factor hist_exp = macd_hist * exp_factor * 2 plot(show_hist ? hist_exp : na, "MACD Histogram", color_hist, 1, plot.style_columns) plot(show_macd ? macd_exp : na, "MACD Line", color_macd, 2) plot(show_cross and cross_up ? macd_exp : na, "MACD Cross Up", color.new(cian, 55), 5, plot.style_circles) plot(show_cross and cross_dn ? macd_exp : na, "MACD Cross Down", color.new(pink, 55), 5, plot.style_circles) barcolor(show_barC ? color_bar : na, title = "MACD Color Bars") // } // Divergences { osc = show_ao ? ao : na bearColor = rojo bullColor = verde hiddenBullColor = color.new(bullColor, 80) hiddenBearColor = color.new(bearColor, 80) textColor = color.white textColor2 = #000000 noneColor = color.new(color.white, 100) plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true _inRange(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Lower Low priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1) bullCond = plotBull and priceLL and oscHL and plFound plot( plFound ? osc[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=2, color=(bullCond ? bullColor : noneColor) ) plotshape( bullCond ? osc[lbR] : na, offset=-lbR, title="Regular Bullish Label", text="R", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor2 ) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Higher Low priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1) hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound plot( plFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond ? hiddenBullColor : noneColor) ) plotshape( hiddenBullCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish Label", text="H", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor2 ) //------------------------------------------------------------------------------ // Regular Bearish // Osc: Lower High oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Higher High priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1) bearCond = plotBear and priceHH and oscLH and phFound plot( phFound ? osc[lbR] : na, offset=-lbR, title="Regular Bearish", linewidth=2, color=(bearCond ? bearColor : noneColor) ) plotshape( bearCond ? osc[lbR] : na, offset=-lbR, title="Regular Bearish Label", text="R", style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor ) //------------------------------------------------------------------------------ // Hidden Bearish // Osc: Higher High oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Lower High priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1) hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound plot( phFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond ? hiddenBearColor : noneColor) ) plotshape( hiddenBearCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish Label", text="H", style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor ) // } // Alerts { alertcondition(barstate.islast ? cross_up[1] : cross_up, title="MACD Long", message="MACD: Probable Long\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") alertcondition(barstate.islast ? cross_up[1] : cross_dn, title="MACD Short", message="MACD: Probable Short\n{{exchange}}:{{ticker}}->\nPrice = {{close}},\nTime = {{time}}") alertcondition(bullish_saucer, title="AO - Bullish Saucer", message="AO: Probable Long\n A red bar, followed by a smaller red bar, followed by a green bar indicates a Bullish Saucer.-") alertcondition(bearish_saucer, title="AO - Bearish Saucer", message="AO: Probable Short\n A green bar, followed by a samller green bar, followed a red bar indicates a Bearish Saucer.-") // }
Lal Online
https://www.tradingview.com/script/LsNytH59-Lal-Online/
adidasanlal
https://www.tradingview.com/u/adidasanlal/
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/ // © adidasanlal //@version=5 indicator('Lal Online', shorttitle='Lal Online', overlay=true) getSeries(e, timeFrame) => request.security(syminfo.tickerid, timeFrame, e, lookahead=barmerge.lookahead_on) //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| //Supertrend-1 Begins Periods = input(title='ATR Period-1', defval=10) src = input(hl2, title='Source') Multiplier = input.float(title='ATR Multiplier-1', step=0.1, defval=3.0) changeATR = input(title='Change ATR Calculation Method ?', defval=false) showsignals = input(title='Show Buy/Sell Signals ?', defval=true) highlighting = input(title='Highlighter On/Off ?', defval=true) atr2 = ta.sma(ta.tr, Periods) atr = changeATR ? ta.atr(Periods) : atr2 up = src - Multiplier * atr up1 = nz(up[1], up) up := close[1] > up1 ? math.max(up, up1) : up dn = src + Multiplier * atr dn1 = nz(dn[1], dn) dn := close[1] < dn1 ? math.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.new(color.green, 0)) 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, 0)) plotshape(buySignal and showsignals ? up : na, title='Buy', text='', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0)) dnPlot = plot(trend == 1 ? na : dn, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0)) 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, 0)) plotshape(sellSignal and showsignals ? dn : na, title='Sell', text='', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0)) mPlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0) longFillColor = highlighting ? trend == 1 ? color.green : color.white : color.white shortFillColor = highlighting ? trend == -1 ? color.red : color.white : color.white fill(mPlot, upPlot, color=color.new(color.green,90)) fill(mPlot, dnPlot, color=color.new(color.red,90)) changeCond = trend != trend[1] //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // RoundToHundreds() rounds the close price to 100 strikes RoundToHundreds(value) => math.round(value / 100.0) * 100 // Calculate and Strike Price CallStrike = close[0] PutStrike = close[0] //Find Call option Strike STdown= trend==-1 ? label.new(bar_index, na, 'Down Trend : BUY PUT ' + '( Strike ' + str.tostring(RoundToHundreds(PutStrike)) + ' or above)', color=#DC250C, textcolor=color.white, size=size.large, style=label.style_label_down, yloc=yloc.abovebar) : na label.delete(STdown[1]) //Find Put Option Strike STup= trend==1 ? label.new(bar_index, na, 'Up Trend : BUY CALL ' + '( Strike ' + str.tostring(RoundToHundreds(CallStrike)) + ' or below)', color=#18C522, textcolor=color.white, size=size.large, style=label.style_label_down, yloc=yloc.abovebar) : na label.delete(STup[1])
MACD in BANDS
https://www.tradingview.com/script/hrau0NNE/
NhanTam
https://www.tradingview.com/u/NhanTam/
22
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © NhanTam // @version=5 indicator(title='MACD BAND by NhanTam', shorttitle='MACD B', precision=3, timeframe='', timeframe_gaps=true) // Getting inputs fast_length = input.int(12, 'Fast Length', minval=6, maxval=19, tooltip='Default 12') slow_length = input.int(26, 'Slow Length', minval=19, maxval=39, tooltip='Default 26') src = input.source(close, 'Source') signal_length = input.int(9, 'Signal Smoothing', minval=1, maxval=50) ma_source = input.string('EMA', 'Oscillator MA Type', options=['SMA', 'EMA', 'WMA', 'RMA', 'HMA', 'ALMA', 'VWMA'], tooltip='Normally uses EMA') ma_signal = input.string('EMA', 'Signal Line MA Type', options=['SMA', 'EMA', 'WMA', 'RMA', 'HMA', 'ALMA', 'VWMA'], tooltip='Normally uses EMA') // Input color col_macd = input.color(#2962FF, 'MACD Line', group='Histogram', inline='1') showMACD = input.bool(true, 'Show', group='Histogram', inline='1') col_sign = input.color(#FF6D00, 'Signal Line:', group='Histogram', inline='2') showMACDSignal = input.bool(true, 'Show', group='Histogram', inline='2') col_grow_above = input.color(#26A69A, 'Above grow', group='Histogram', inline='3') col_fall_above = input.color(#B2DFDB, 'Fall', group='Histogram', inline='3') col_grow_below = input.color(#FFCDD2, 'Below grow', group='Histogram', inline='4') col_fall_below = input.color(#FF5252, 'Fall', group='Histogram', inline='4') showMACDHistogram = input.bool(true, 'Show Histogram', group='Histogram') histo_trans = input.int(30, 'Hist transparent', minval=0, maxval=100, group='Histogram', tooltip='Histogram transparency, Default 30') lowcolumn = input.int(10, 'Columns Low', minval=2, maxval=20, group='Histogram', tooltip='Default 10. Min = 2, max = 20. The larger the number, the lower the Histogram height.') lowline = input.int(5, 'Line Low', minval=2, maxval=20, group='Histogram', tooltip='Default 5. Min = 2, max = 20. The larger the number, the lower the height of the MACD line and the Signal line.') // MACD Calculating shortMA = ma_source == 'SMA' ? ta.sma(src, fast_length) : ma_source == 'EMA' ? ta.ema(src, fast_length) : ma_source == 'WMA' ? ta.wma(src, fast_length) : ma_source == 'RMA' ? ta.rma(src, fast_length) : ma_source == 'HMA' ? ta.hma(src, fast_length) : ma_source == 'ALMA' ? ta.alma(src, fast_length, 0.85, 6) : ma_source == 'VWMA' ? ta.vwma(src, fast_length) : ta.ema(src, fast_length) longMA = ma_source == 'SMA' ? ta.sma(src, slow_length) : ma_source == 'EMA' ? ta.ema(src, slow_length) : ma_source == 'WMA' ? ta.wma(src, slow_length) : ma_source == 'RMA' ? ta.rma(src, slow_length) : ma_source == 'HMA' ? ta.hma(src, slow_length) : ma_source == 'VWMA' ? ta.vwma(src, slow_length) : ma_source == 'ALMA' ? ta.alma(src, slow_length, 0.85, 6) : ta.ema(src, slow_length) macdLine = shortMA - longMA signalLine = ma_signal == 'SMA' ? ta.sma(macdLine, signal_length) : ma_signal == 'EMA' ? ta.ema(macdLine, signal_length) : ma_signal == 'WMA' ? ta.wma(macdLine, signal_length) : ma_signal == 'RMA' ? ta.rma(macdLine, signal_length) : ma_signal == 'HMA' ? ta.hma(macdLine, signal_length) : ma_source == 'VWMA' ? ta.vwma(macdLine, signal_length) : ma_signal == 'ALMA' ? ta.alma(macdLine, signal_length, 0.85, 6) : ta.ema(macdLine, signal_length) hist = macdLine - signalLine // Re-Calculating MACD midline = 50 sd_hist = ta.stdev(hist, 500) basis_hist = ta.ema(hist, 500) up_hist = basis_hist + sd_hist * lowcolumn dn_hist = basis_hist - sd_hist * lowcolumn re_hist = (hist - dn_hist) / (up_hist - dn_hist) * 100 sd_sig = ta.stdev(signalLine, 500) basis_sig = ta.ema(signalLine, 500) up_sig = basis_sig + sd_sig * lowline dn_sig = basis_sig - sd_sig * lowline rescaled_sig = (signalLine - dn_sig) / (up_sig - dn_sig) * 100 sd_mac = ta.stdev(macdLine, 500) basis_mac = ta.ema(macdLine, 500) up_mac = basis_mac + sd_mac * lowline dn_mac = basis_mac - sd_mac * lowline rescaled_mac = (macdLine - dn_mac) / (up_mac - dn_mac) * 100 // Plot histLineCol = hist >= 0 ? hist[1] < hist ? color.new(col_grow_above,histo_trans) : color.new(col_fall_above,histo_trans) : hist[1] < hist ? color.new(col_grow_below,histo_trans) : color.new(col_fall_below,histo_trans) plot(showMACD ? rescaled_mac : na, title='MACD', color=col_macd, style=plot.style_line, linewidth=1, histbase=midline) plot(showMACDSignal ? rescaled_sig : na, title='Signal', color=col_sign, style=plot.style_line, linewidth=1, histbase=midline) plot(showMACDHistogram ? re_hist : na, title='Histogram', color=histLineCol, style=plot.style_columns, linewidth=1, histbase=midline) band1 = hline(70, 'Upper Band', color=#787B86) bandm = hline(50, 'Middle Band', color=color.new(#787B86, 50)) band0 = hline(30, 'Lower Band', color=#787B86) fill(band1, band0, color=color.new(#7e575e, 95), title='Background')
Education: INDEX
https://www.tradingview.com/script/TUeC9XDq-Education-INDEX/
fikira
https://www.tradingview.com/u/fikira/
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/ // © fikira //@version=5 indicator("Education: INDEX", overlay=true) // ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // | Hi, this is my index page where educative articles are sorted by date | // | | // | From time to time I will add educative scripts/idea's in here, or update scripts and add more information | // | They will be added in the comments / Release Notes (see above) | // | Since these are not sorted, it can be messy to try and find something | // | | // | ––-> This is where this 'script' comes in place | // | | // | 1) -> FIRST find your subject of interest | // | 2) -> Check for the date (and title) at the right (UTC time) | // | 3) -> Go back to the comment / Release Notes section, find the date | // | 4) -> Then you'll find the link of the concerning script | // | | // | EXAMPLE: You wish to find more information about 'var' | // | | // | • Search BELOW for 'var' | // | • -> 🔸 var -> '22 Aug 28 explaining Pine Script keywords :'var' and 'nz' | // | • -> Go to the comment / Release Notes section ABOVE and search | // | -> '22 Aug 28 explaining Pine Script keywords :'var' and 'nz' | // | • -> click on the link | // | | // ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– // // //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– //| //| //|🔻 //| | //| 🔷 Ticker //| | | //| | 🔸 combined/calculated tickers -> 2022 May 14 - Working with combined calculated tickers coding tool //| | //| 🔷 Keywords //| | | //| | 🔸 nz – – – -> 2022 Aug 28 - explaining Pine Script keywords :'var' and 'nz' //| | | //| | 🔸 var – – – -> 2022 Aug 28 - explaining Pine Script keywords :'var' and 'nz' //| | | //| | 🔸 request.security_lower_tf -> 2022 June 04 - Educational LTF -> HTF volume delta //| | 2022 June 08 - LTF -> HTF volume delta Up/Down //| | //| 🔷 Techniques/Language //| | | //| | //| 🔷 Plot/Displaying //| | | //| | 🔸 chart.left_visible_bar_time -> 2022 July 18 - chart visible bar time //| | | chart.right_visible_bar_time -{ placing label.new() at 'top/bottom' or 'right/left' of visible chart } //| | | 2022 Aug 28 - Debug tool - table //| | | //| | 🔸 input.time -> 2022 July 18 - switches [experimental / tools] //| | -{ using input.time() as tool for switching between settings without opening settings } //| 🔷 Debugging //| | //| 🔸 plotting values – – -> 2022 Aug 28 - Debug tool - table //|🔺 //| //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– if barstate.islastconfirmedhistory var table = table.new(position = position.middle_center, columns = 1, rows = 1, bgcolor = color.new(color.blue, 100), border_width = 1) table.cell(table_id = table, column = 0, row = 0, text = "INDEX", text_size = size.huge, text_color=color.new(color.blue, 25))
UST tracker
https://www.tradingview.com/script/WmGcWT5h-UST-tracker/
ExamTheCavalier44
https://www.tradingview.com/u/ExamTheCavalier44/
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/ // © ExamTheCavalier44 //@version=5 indicator("UST tracker", overlay = false) BIN = request.security("BINANCE:USTUSDT","3", close) FTX = request.security("FTX:USTUSD","3", close) KRA = request.security("KRAKEN:USTUSD","3", close) LUNA = request.security("FTX:LUNAUSD","3", close) LUNA1 = request.security("FTX:LUNAUSD","3", close[5]) AVG=(BIN+FTX+KRA)/3 LUNAkoef=LUNA1/LUNA //vytvořeno pro UST:PERP PERP= close plot(AVG/PERP/LUNAkoef, style=plot.style_histogram, histbase=1,color=(AVG/PERP>1?color.lime:color.red)) //plot (BIN, color=color.yellow) //plot(FTX, color=color.blue) //plot(KRA, color=color.purple)
Fractal Break Imbalance / Fair Value Gap (FVG) / Liquidity Void
https://www.tradingview.com/script/q67i2j7X-Fractal-Break-Imbalance-Fair-Value-Gap-FVG-Liquidity-Void/
geneclash
https://www.tradingview.com/u/geneclash/
2,355
study
5
MPL-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("Fractal Break Imbalance / Fair Value Gap (FVG) / Liquidity Void", format=format.price, precision=0, overlay=true) showFractals = input(false,title="Show Fractals?",group="Fractals") showBrekout = input(false,title="Show Market Structure Breakouts?",group="Fractals") breakType = input.string("Body",title="Fractal Break Type:",options=["Wick+Body","Body"],group="Fractals") n = input.int(title="Periods", defval=2, minval=2,group="Fractals") lineStyle= input.string(line.style_dotted,title="Line Style:",options=[line.style_dotted,line.style_dashed,line.style_solid],group="Fractals") upClr = input.color(color.teal,title="Up/Down Line Colors:",inline="b_1",group="Fractals") downClr = input.color(color.maroon,title="-",inline="b_1",group="Fractals") showImbalance = input(true,title="Show Breakout Imbalances",group="Imbalance") showOtherImbalance = input(true,title="Show Other Imbalances",group="Imbalance") hideFilled = input(false,title="Hide Filled Gaps",group="Imbalance") imbGreenClr = input.color(color.new(color.green,65),title="Up:",inline="i_1",group="Imbalance") imbRedClr = input.color(color.new(color.red,65),title="Down:",inline="i_1",group="Imbalance") imbRestClr = input.color(color.new(color.yellow,65), title="Other:",inline="i_1",group="Imbalance") showBoxes = input(false,title="Show OrderBlocks?",group="OrderBlock") changeColor = input(false,title="Change OrderBlock Colors?",group="OrderBlock") transGreenClr = input.color(color.new(color.green,80),title="Bg:",inline="a_1",group="OrderBlock") greenClr = input.color(color.new(color.green,0),title="Border:",inline="a_1",group="OrderBlock") transRedClr = input.color(color.new(color.red,80),title="Bg:",inline="b_1",group="OrderBlock") redClr = input.color(color.new(color.red,0),title="Border:",inline="b_1",group="OrderBlock") //Fractals{ // UpFractal bool upflagDownFrontier = true bool upflagUpFrontier0 = true bool upflagUpFrontier1 = true bool upflagUpFrontier2 = true bool upflagUpFrontier3 = true bool upflagUpFrontier4 = true for i = 1 to n upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n]) upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n]) upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n]) upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n]) upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n]) upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n]) flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4 upFractal = (upflagDownFrontier and flagUpFrontier) //DownFractal bool downflagDownFrontier = true bool downflagUpFrontier0 = true bool downflagUpFrontier1 = true bool downflagUpFrontier2 = true bool downflagUpFrontier3 = true bool downflagUpFrontier4 = true for i = 1 to n downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n]) downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n]) downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n]) downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n]) downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n]) downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n]) flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4 downFractal = (downflagDownFrontier and flagDownFrontier) //} var float topValue = na, var float bottomValue = na var int lastRedIndex = na, var float lastRedLow = na, var float lastRedHigh = na var int lastGreenIndex = na, var float lastGreenLow = na, var float lastGreenHigh = na var line topLine = na, var line bottomLine = na var box demandBox = na, var box supplyBox = na var box imbalanceBox = na var bool checkUpImbalance = false var bool checkDownImbalance = false var topBreakBlock = false, var bottomBreakBlock = false var isLongBreak = false, var isShortBreak = false var arrBoxes = array.new_box(0) var arrImbBoxes = array.new_box(0) topBreakCheckSource = breakType == "Wick+Body" ? high : close bottomBreakCheckSource = breakType == "Wick+Body" ? low : close //IMBALANCE //Data L1 = low H3 = high[2] H1 = high L3 = low[2] FVGUp = H3 < L1 ? 1 : 0 plotFVGU = FVGUp ? H3 : na plotFVGUL = FVGUp ? L1 : na FVGDown = L3 > H1 ? 1 : 0 plotFVGD = FVGDown ? L3 : na plotFVGH = FVGDown ? H1 : na if FVGUp and showOtherImbalance and checkUpImbalance == false imbalanceBox := box.new(bar_index-2, plotFVGU,bar_index,plotFVGUL, bgcolor=imbRestClr, border_color=imbRestClr) array.push(arrImbBoxes,imbalanceBox) if FVGDown and showOtherImbalance and checkDownImbalance == false imbalanceBox := box.new(bar_index-2, plotFVGH,bar_index,plotFVGD, bgcolor=imbRestClr, border_color=imbRestClr) array.push(arrImbBoxes,imbalanceBox) //Last red check if close < open lastRedIndex := bar_index lastRedLow := low lastRedHigh := high //Last green check if close > open lastGreenIndex := bar_index lastGreenLow := low lastGreenHigh := high //Check Imbalance if checkUpImbalance checkUpImbalance := false imbTop = low imbBottom = high[2] if imbTop > imbBottom and showImbalance imbalanceBox := box.new(bar_index-2, imbTop,bar_index,imbBottom, bgcolor=imbGreenClr, border_color=imbGreenClr) array.push(arrImbBoxes,imbalanceBox) alert("Bullish Imbalance Detected!",freq=alert.freq_once_per_bar_close) if checkDownImbalance checkDownImbalance := false imbTop = low[2] imbBottom = high if imbTop > imbBottom and showImbalance imbalanceBox := box.new(bar_index-2, imbTop,bar_index,imbBottom, bgcolor=imbRedClr, border_color=imbRedClr) array.push(arrImbBoxes,imbalanceBox) alert("Bearish Imbalance Detected!",freq=alert.freq_once_per_bar_close) //Top break if ta.crossover(topBreakCheckSource,topValue) and topBreakBlock == false topBreakBlock := true isLongBreak := true checkUpImbalance := true if showBrekout line.set_x2(topLine,bar_index) if showBoxes demandBox := box.new(lastRedIndex-1, lastRedHigh,lastRedIndex+1,lastRedLow, bgcolor=transGreenClr, border_color=greenClr) array.push(arrBoxes,demandBox) //Bottom break if ta.crossunder(bottomBreakCheckSource,bottomValue) and bottomBreakBlock == false bottomBreakBlock := true isShortBreak := true checkDownImbalance := true if showBrekout line.set_x2(bottomLine,bar_index) if showBoxes supplyBox := box.new(lastGreenIndex-1, lastGreenHigh,lastGreenIndex+1,lastGreenLow, bgcolor=transRedClr, border_color=redClr) array.push(arrBoxes,supplyBox) //New up fractal if upFractal topBreakBlock := false isLongBreak := false topValue := high[n] if showBrekout topLine := line.new(bar_index[n],topValue,bar_index,topValue, color=upClr, style=lineStyle, width=2) if isLongBreak[1] == false line.delete(topLine[1]) //New down fractal if downFractal bottomBreakBlock := false isShortBreak := false bottomValue := low[n] if showBrekout bottomLine := line.new(bar_index[n],bottomValue,bar_index,bottomValue, color=downClr, style=lineStyle, width=2) if isShortBreak[1] == false line.delete(bottomLine[1]) //Imbalance Box Update activeImbBoxes = arrImbBoxes if array.size(activeImbBoxes) > 0 and hideFilled for i = 0 to array.size(activeImbBoxes) - 1 bVal = box.get_bottom(array.get(activeImbBoxes, i)) tVal = box.get_top(array.get(activeImbBoxes, i)) if open > tVal and low < tVal box.delete(array.get(activeImbBoxes, i)) if open < bVal and high > bVal box.delete(array.get(activeImbBoxes, i)) //OB Box state update activeBoxes = arrBoxes if array.size(activeBoxes) > 0 and changeColor for i = 0 to array.size(activeBoxes) - 1 bVal = box.get_bottom(array.get(activeBoxes, i)) tVal = box.get_top(array.get(activeBoxes, i)) if close < bVal box.set_bgcolor(array.get(activeBoxes, i),transRedClr) box.set_border_color(array.get(activeBoxes, i),redClr) if close > tVal box.set_bgcolor(array.get(activeBoxes, i),transGreenClr) box.set_border_color(array.get(activeBoxes, i),greenClr) //PLOTS plotshape(showFractals ? downFractal : na,style=shape.triangleup, location=location.belowbar, offset=-n, color=color.new(color.gray,80), size = size.tiny) plotshape(showFractals ? upFractal : na, style=shape.triangledown, location=location.abovebar, offset=-n, color=color.new(color.gray,80), size = size.tiny)
Pivot Points (Channel | Fib | Support/Resistances)
https://www.tradingview.com/script/oCkT2YJd-Pivot-Points-Channel-Fib-Support-Resistances/
atolelole
https://www.tradingview.com/u/atolelole/
620
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © atolelole //@version=5 indicator("Pivot Channel", overlay = true, max_bars_back = 500, max_lines_count = 500, max_labels_count = 500) i_pivothigh_len = input.int(21, "Pivot high length(left, right)", group="Pivot points", inline="phb") i_pivothigh_n = input.int(5 , "Max pivot points" , group="Pivot points", inline="phb") i_pivotlow_len = input.int(21, "Pivot low length(left, right)", group="Pivot points", inline="plb") i_pivotlow_n = input.int(5 , "Max pivot points" , group="Pivot points", inline="plb") i_drawpivots = input.bool(true, "Draw pivot points" , group="Pivot points") i_hsource_test = input.source(close, "Pivot high test source" , group="Pivot points", tooltip = "Series that is tested for a high pivot point, if yes takes price from Pivot high source") i_hsource = input.source(high, "Pivot high source" , group="Pivot points") i_lsource_test = input.source(close, "Pivot low test source" , group="Pivot points", tooltip = "Series that is tested for a low pivot point, if yes takes price from Pivot low source") i_lsource = input.source(low, "Pivot low source" , group="Pivot points") i_trend_old_method = input.bool(false, "Use old method to find channel lines", group="Trends") i_htrend_style = input.string(line.style_dashed, "High trend line style", options=[line.style_dotted, line.style_dashed, line.style_solid, line.style_arrow_both, line.style_arrow_left, line.style_arrow_right], group="Trends", inline="htr") i_htrend_width = input.int(2, "High trend line width", group="Trends", inline="htr") i_ltrend_style = input.string(line.style_dashed, "Low trend line style" , options=[line.style_dotted, line.style_dashed, line.style_solid, line.style_arrow_both, line.style_arrow_left, line.style_arrow_right], group="Trends", inline="ltr") i_ltrend_width = input.int(2, "Low trend line width" , group="Trends", inline="ltr") i_trend_extlen = input.int(5, "Right channel extension length", group="Trends") i_hcolor = input.color(color.new(#99d31b, 0), "High color", group="Colors", inline="clr") i_lcolor = input.color(color.new(#FA5032, 0), "Low color" , group="Colors", inline="clr") i_drawheatmap = input.bool(false, "Enable" , group = "Heatmap") i_minrsi_len = input.int(2 , "Min RSI length" , group = "Heatmap", tooltip = "for step = 0 to 10 : rsi = step * (max - min) / 10") i_maxrsi_len = input.int(22, "Max RSI length" , group = "Heatmap", tooltip = "for step = 0 to 10 : rsi = step * (max - min) / 10") i_grid_x = input.int(100, "Number of horizontal grid segments", group = "Heatmap", tooltip = "X axis resolution, if > 45 first cells start to get deleted") i_drawfibs = input.bool(true , "Enable" , group = "Fibs", inline="fiblines") i_drawfibs_extended = input.bool(false, "Draw fib lines > 1.618", group = "Fibs", inline="fiblines") i_fibline_widths = input.int(1, "Fib line widths" , group="Fibs") i_fibline_styles = input.string(line.style_dotted, "Fib lines style", options=[line.style_dotted, line.style_dashed, line.style_solid, line.style_arrow_both, line.style_arrow_left, line.style_arrow_right], group="Fibs") i_alerts_enabled = input.bool(false, "Enable", group="Alerts", inline="alrt", tooltip = "WIP, alarms dont trigger so just a label for now") i_alerts_high_trend_trigger_pct = input.float(0.15, "High trend % trigger", group="Alerts", step=0.1, minval = 0.0, maxval = 1.0) i_alerts_low_trend_trigger_pct = input.float(0.15, "Low trend % trigger" , group="Alerts", step=0.1, minval = 0.0, maxval = 1.0) i_alerts_draw_alert_zones = input.bool(false, "Draw alert zones", group="Alerts", inline="alrt") i_alerts_fill_alert_zones = input.bool(false, "Fill alert zones", group="Alerts", inline="alrt") get_color(rsi) => clr = color.white if rsi >= 0 and rsi <= 25 clr := color.from_gradient(rsi, 0 , 25 , color.rgb(69, 13, 85, 40), color.rgb(64, 70, 137 , 40)) if rsi > 25 and rsi <= 50 clr := color.from_gradient(rsi, 25, 50 , color.rgb(57, 87, 141, 40), color.rgb(35, 139, 140, 40)) if rsi > 50 and rsi <= 75 clr := color.from_gradient(rsi, 50, 75 , color.rgb(30, 150, 138, 40), color.rgb(85, 199, 103, 40)) if rsi > 75 and rsi <= 100 clr := color.from_gradient(rsi, 75, 100, color.rgb(115, 208, 85, 40), color.rgb(253, 230, 36, 40)) clr get_avg_rsi(source, start_index, len) => avg = 0.0 for i = start_index to start_index + len avg += source[i] avg / len interp(l, h, s) => l + (h - l) * s //PIVOT POINTS type PivotPoint float price int index var high_pivots = array.new<PivotPoint>() var low_pivots = array.new<PivotPoint>() ph = ta.pivothigh(i_hsource_test, i_pivothigh_len, i_pivothigh_len) if ph if array.size(high_pivots) >= i_pivothigh_n array.shift(high_pivots) array.push(high_pivots, PivotPoint.new(i_hsource[i_pivothigh_len], bar_index[i_pivothigh_len])) pl = ta.pivotlow(i_lsource_test, i_pivotlow_len, i_pivotlow_len) if pl if array.size(low_pivots) >= i_pivotlow_n array.shift(low_pivots) array.push(low_pivots, PivotPoint.new(i_lsource[i_pivotlow_len], bar_index[i_pivotlow_len])) //FIND HIGH AND LOW TREND LINE var low_trend = line(na) var high_trend = line(na) var labels = array.new_label() while array.size(labels) > 0 label.delete(array.shift(labels)) if array.size(high_pivots) > 1 if i_drawpivots for pivot in high_pivots array.push(labels, label.new(pivot.index, pivot.price, "", style=label.style_label_down, size=size.tiny, color=color.new(#99d31b, 70))) tmp = array.new_line() for i = 0 to array.size(high_pivots) - 1 for j = i to array.size(high_pivots) - 1 if i != j PivotPoint pp0 = array.get(high_pivots, i) PivotPoint pp1 = array.get(high_pivots, j) array.push(tmp, line.new(pp0.index, pp0.price, pp1.index, pp1.price, color=i_hcolor, width = 1, style = line.style_dashed)) best_ind = int(na) if i_trend_old_method min_val = 10000000.0 for i = 0 to array.size(tmp) - 1 lp = line.get_price(array.get(tmp, i), bar_index) if lp > high if min_val > math.abs(lp - close) min_val := math.abs(lp - close) best_ind := i else best_cnt = 0 for i = 0 to array.size(tmp) - 1 trend = array.get(tmp, i) cnt = 0 for pivot in high_pivots if line.get_price(trend, pivot.index) >= pivot.price cnt += 1 if cnt > best_cnt best_cnt := cnt best_ind := i if cnt == best_cnt if line.get_price(array.get(tmp, best_ind), bar_index + 1) > line.get_price(trend, bar_index + 1) and line.get_price(trend, bar_index + 1) > i_hsource best_cnt := cnt best_ind := i if not na(best_ind) line.delete(high_trend) high_trend := array.get(tmp, best_ind) array.remove(tmp, best_ind) while array.size(tmp) > 0 line.delete(array.shift(tmp)) if array.size(low_pivots) > 1 if i_drawpivots for pivot in low_pivots array.push(labels, label.new(pivot.index, pivot.price, "", style=label.style_label_up, size=size.tiny, color=color.new(#FA5032, 70))) tmp = array.new_line() for i = 0 to array.size(low_pivots) - 1 for j = i to array.size(low_pivots) - 1 if i != j PivotPoint pp0 = array.get(low_pivots, i) PivotPoint pp1 = array.get(low_pivots, j) array.push(tmp, line.new(pp0.index, pp0.price, pp1.index, pp1.price, color=i_lcolor, width = 1, style = line.style_dashed)) best_ind = int(na) if i_trend_old_method min_val = 100000.0 for i = 0 to array.size(tmp) - 1 lp = line.get_price(array.get(tmp, i), bar_index) if lp < low if min_val > math.abs(lp - close) min_val := math.abs(lp - close) best_ind := i else best_cnt = 0 for i = 0 to array.size(tmp) - 1 trend = array.get(tmp, i) cnt = 0 for pivot in low_pivots if line.get_price(trend, pivot.index) <= pivot.price cnt += 1 if cnt > best_cnt best_cnt := cnt best_ind := i if cnt == best_cnt if line.get_price(array.get(tmp, best_ind), bar_index + 1) < line.get_price(trend, bar_index + 1) and line.get_price(trend, bar_index + 1) < i_lsource best_cnt := cnt best_ind := i if not na(best_ind) line.delete(low_trend) low_trend := array.get(tmp, best_ind) array.remove(tmp, best_ind) while array.size(tmp) > 0 line.delete(array.shift(tmp)) if not na(low_trend) and not na(high_trend) for l in labels if label.get_x(l) == line.get_x1(low_trend) or label.get_x(l) == line.get_x2(low_trend) label.set_color(l, color.new(#FA5032, 0)) line.set_y2(low_trend, line.get_price(low_trend, bar_index + i_trend_extlen)) line.set_x2(low_trend, bar_index + i_trend_extlen) line.set_width(low_trend, i_ltrend_width) line.set_style(low_trend, i_ltrend_style) if line.get_x1(high_trend) > line.get_x1(low_trend) line.set_y1(high_trend, line.get_price(high_trend, line.get_x1(low_trend))) line.set_x1(high_trend, line.get_x1(low_trend)) for l in labels if label.get_x(l) == line.get_x1(high_trend) or label.get_x(l) == line.get_x2(high_trend) label.set_color(l, color.new(#99d31b, 0)) line.set_y2(high_trend, line.get_price(high_trend, bar_index + i_trend_extlen)) line.set_x2(high_trend, bar_index + i_trend_extlen) line.set_width(high_trend, i_htrend_width) line.set_style(high_trend, i_htrend_style) if line.get_x1(low_trend) > line.get_x1(high_trend) line.set_y1(low_trend, line.get_price(low_trend, line.get_x1(high_trend))) line.set_x1(low_trend, line.get_x1(high_trend)) //you can now use high and low trend line //if not na(high_trend) // ...code... //HEATMAP var fills = array.new_linefill() var lines = array.new_line() while array.size(fills) > 0 linefill.delete(array.shift(fills)) while array.size(lines) > 0 line.delete(array.shift(lines)) rsi0 = ta.rsi(close, i_minrsi_len + 0 * (i_maxrsi_len - i_minrsi_len) / 10) rsi1 = ta.rsi(close, i_minrsi_len + 1 * (i_maxrsi_len - i_minrsi_len) / 10) rsi2 = ta.rsi(close, i_minrsi_len + 2 * (i_maxrsi_len - i_minrsi_len) / 10) rsi3 = ta.rsi(close, i_minrsi_len + 3 * (i_maxrsi_len - i_minrsi_len) / 10) rsi4 = ta.rsi(close, i_minrsi_len + 4 * (i_maxrsi_len - i_minrsi_len) / 10) rsi5 = ta.rsi(close, i_minrsi_len + 5 * (i_maxrsi_len - i_minrsi_len) / 10) rsi6 = ta.rsi(close, i_minrsi_len + 6 * (i_maxrsi_len - i_minrsi_len) / 10) rsi7 = ta.rsi(close, i_minrsi_len + 7 * (i_maxrsi_len - i_minrsi_len) / 10) rsi8 = ta.rsi(close, i_minrsi_len + 8 * (i_maxrsi_len - i_minrsi_len) / 10) rsi9 = ta.rsi(close, i_minrsi_len + 9 * (i_maxrsi_len - i_minrsi_len) / 10) rsi10 = ta.rsi(close, i_minrsi_len + 10 * (i_maxrsi_len - i_minrsi_len) / 10) if not na(high_trend) and not na(low_trend) and barstate.islast and i_drawheatmap X = i_grid_x //horizontal grid segments OK to change (limited by max_line_count? or something) (max 45 at 500) Y = 10 //vertical grid segments do NOT change or add rsi11 and so on with other relevant code for x = 0 to X - 1 by 1 for y = 0 to Y x0 = int(line.get_x1(low_trend) + x * (bar_index - line.get_x1(low_trend)) / X) y0 = line.get_price(low_trend, x0) + y * (line.get_price(high_trend, x0) - line.get_price(low_trend, x0)) / Y x1 = int(line.get_x1(high_trend) + (x + 1) * (bar_index - line.get_x1(high_trend)) / X) y1 = line.get_price(low_trend, x1) + y * (line.get_price(high_trend, x1) - line.get_price(low_trend, x1)) / Y array.push(lines, line.new(x0, y0, x1, y1, color=na)) if array.size(lines) > 1 and y != 0 l0 = array.get(lines, array.size(lines) - 2) l1 = array.get(lines, array.size(lines) - 1) if y == 1 array.push(fills, linefill.new(l0, l1, get_color(rsi0[bar_index - x1 + int((x1 - x0) / 2)]))) //get_color(get_avg_rsi(rsi0, bar_index - x1, x1 - x0)) //not working great so lets just take the middle if y == 2 array.push(fills, linefill.new(l0, l1, get_color(rsi1[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 3 array.push(fills, linefill.new(l0, l1, get_color(rsi2[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 4 array.push(fills, linefill.new(l0, l1, get_color(rsi3[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 5 array.push(fills, linefill.new(l0, l1, get_color(rsi4[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 6 array.push(fills, linefill.new(l0, l1, get_color(rsi5[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 7 array.push(fills, linefill.new(l0, l1, get_color(rsi6[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 8 array.push(fills, linefill.new(l0, l1, get_color(rsi7[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 9 array.push(fills, linefill.new(l0, l1, get_color(rsi8[bar_index - x1 + int((x1 - x0) / 2)]))) if y == 10 array.push(fills, linefill.new(l0, l1, get_color(rsi9[bar_index - x1 + int((x1 - x0) / 2)]))) //FIBONACI var fibs = array.new_line() while array.size(fibs) > 0 line.delete(array.shift(fibs)) if not na(high_trend) and not na(low_trend) and barstate.islast and i_drawfibs left = line.get_x1(low_trend) right = bar_index + i_trend_extlen left_val = interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , -0.618) right_val = interp(line.get_price(low_trend, right), line.get_price(high_trend, right), -0.618) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 0.236) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 0.236) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 0.382) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 0.382) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 0.5) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 0.5) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 0.618) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 0.618) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 0.75) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 0.75) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 1.618) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 1.618) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) if i_drawfibs_extended left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 2.618) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 2.618) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 3.618) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 3.618) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) left_val := interp(line.get_price(low_trend, left) , line.get_price(high_trend, left) , 4.236) right_val := interp(line.get_price(low_trend, right), line.get_price(high_trend, right), 4.236) array.push(fibs, line.new(left, left_val, right, right_val, style=i_fibline_styles, width=i_fibline_widths, color=color.from_gradient(right_val, line.get_price(low_trend, right), line.get_price(high_trend, right), i_lcolor , i_hcolor))) //ALERTS var line alert_zone_low = line(na) var line alert_zone_high = line(na) var linefill alert_zone_low_linefill = linefill(na) var linefill alert_zone_high_linefill = linefill(na) var label alert_label = label(na) if not na(low_trend) and not na(high_trend) and barstate.islast and i_alerts_enabled clp = line.get_price(low_trend, bar_index) chp = line.get_price(high_trend, bar_index) ldiff = (close - clp) / (chp - clp) hdiff = (chp - close) / (chp - clp) label.delete(alert_label) if ldiff <= i_alerts_low_trend_trigger_pct and ldiff > 0.0 alert_label := label.new(bar_index + 3, close, str.tostring(ldiff, "buy #.##%"), style=label.style_label_left) alert("Possible bounce incoming " + syminfo.ticker, alert.freq_once_per_bar) else if hdiff <= i_alerts_high_trend_trigger_pct and hdiff > 0.0 alert_label := label.new(bar_index + 3, close, str.tostring(hdiff, "sell #.##%"), style=label.style_label_left) alert("Possible drop incoming " + syminfo.ticker, alert.freq_once_per_bar) if i_alerts_draw_alert_zones line.delete(alert_zone_low) line.delete(alert_zone_high) x0 = bar_index y0 = clp + (chp - clp) * i_alerts_low_trend_trigger_pct x1 = bar_index + i_trend_extlen y1 = line.get_price(low_trend, x1) + (line.get_price(high_trend, x1) - line.get_price(low_trend, x1)) * i_alerts_low_trend_trigger_pct alert_zone_low := line.new(x0, y0, x1, y1, color=i_lcolor) if i_alerts_fill_alert_zones linefill.delete(alert_zone_low_linefill) alert_zone_low_linefill := linefill.new(low_trend, alert_zone_low, color.new(i_lcolor, 70)) x0 := bar_index y0 := clp + (chp - clp) * (1.0 - i_alerts_high_trend_trigger_pct) x1 := bar_index + i_trend_extlen y1 := line.get_price(low_trend, x1) + (line.get_price(high_trend, x1) - line.get_price(low_trend, x1)) * (1.0 - i_alerts_high_trend_trigger_pct) alert_zone_high := line.new(x0, y0, x1, y1, color=i_hcolor) if i_alerts_fill_alert_zones linefill.delete(alert_zone_high_linefill) alert_zone_high_linefill := linefill.new(high_trend, alert_zone_high, color.new(i_hcolor, 70))
Trend Master
https://www.tradingview.com/script/th8aHOjk-Trend-Master/
sadmansamee
https://www.tradingview.com/u/sadmansamee/
349
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © sadmansamee //@version=5 // Created By Sadman Samee // indicator(title='Trend Master V1.3') // Instructions:- // Works on all TimeFrame but gives more accuracey 4H, 1D. // Buy when green big dot appears at the bottom. // Sell when red big dot appears at the bottom. // Red/green dot at the top line appears when three trend meter is aligned and this is a good confirmation. // Any red/green dot below horizontal bars are trend signal. Buy/Sell Signals from Trend Indicator like Chandelier Exit, WaveTrend, QQE, Parabolic SAR // Big red/green got at the bottom appears whenever there's a good confirmation from trend meter and a buy/sell signal comes from any trend signals. // Alert:- // 01 Buy Signal = Strong Buy Signal // 02 Sell Signal = Strong Sell Signal // 03 Buy Signal = Strong Buy Signal // 04 Sell Signal = Strong Sell Signal // Thanks to https://www.tradingview.com/u/everget and https://www.tradingview.com/u/Lij_MC for their work. // and other authors // Trend Meter: https://www.tradingview.com/script/Ciurp4Qn-Trend-Meter/ // Alphatrend: https://www.tradingview.com/script/o50NYLAZ-AlphaTrend/ // Chandelier Exit: www.tradingview.com/script/AqXxNS7j-Chandelier-Exit/]Chandelier Exit[/url], // WaveTrend // QQE Signals: www.tradingview.com/script/7R6ZxyZu-QQE-signals/]QQE Signals[/url], // Parabolic Sar: www.tradingview.com/script/MddD4giy-Parabolic-SAR/]Parabolic Sar[/url] // Technical Ratings: https://www.tradingview.com/v/Jdw7wW2g/ // Donchian Trend Ribbon: https://www.tradingview.com/script/PxLqmP8o-Donchian-Trend-Ribbon/ // Neural Network: https://www.tradingview.com/v/HCfdtUut/ ShowTrendBar = true var string TM = 'Trend Meters' BuySellPolicy = input.string(title='Select Buy/Sell policy',group = 'Generel',defval='Slow Buy and Fast Sell(Bear/SideWays)', options=['Fast Buy and Fast Sell(Bull/Bear)', 'Fast Buy and Slow Sell(Bull)','Slow Buy and Fast Sell(Bear/SideWays)', 'Slow Buy and Slow Sell']) BuyColor = input.color(#1fb622, 'Positive Color', group = 'Generel') SellColor = input.color(color.red, 'Negative Color', group = 'Generel') WeakColor = input.color(color.yellow, 'Weak Color', group = 'Generel') NeutralColor = input.color(color.gray, 'Neutral Color', group = 'Generel') DisabledColor = input.color(#f0f0f0, 'Disabled Color', group = 'Generel') MSBarCE = 'Trend Filter' // input(title= "1 - Chandelier Exit", defval = "Trend Filter", options = ["N/A", "Trend Filter", "Filter X", "Filter X + Trend Filter"]) MSBar1 = 'Trend Filter' // input(title= "2 - Wave Trend Signals", defval = "Trend Filter", options = ["N/A", "Trend Filter", "Filter X", "Filter X + Trend Filter"]) MSBar2 = 'Trend Filter' // input(title= "2 - Wave Trend Signals", defval = "Filter X", options = ["N/A", "Trend Filter", "Filter X", "Filter X + Trend Filter"]) TrendBar1 = input.string(title='2 - Trend Meter 1', group = TM, defval='MACD Crossover - Fast - 8, 21, 5', options=['MACD Crossover - 12, 26, 9', 'MACD Crossover - Fast - 8, 21, 5', 'Mom Dad Cross (Top Dog Trading)', 'RSI Signal Line Cross - RSI 13, Sig 21', 'RSI 13: > or < 50', 'RSI 5: > or < 50', 'Trend Candles', 'N/A']) // "MA Crossover", "DAD Direction (Top Dog Trading)", TrendBar2 = input.string(title='3 - Trend Meter 2', group = TM,defval='RSI 13: > or < 50', options=['MACD Crossover - 12, 26, 9', 'MACD Crossover - Fast - 8, 21, 5', 'Mom Dad Cross (Top Dog Trading)', 'RSI Signal Line Cross - RSI 13, Sig 21', 'RSI 13: > or < 50', 'RSI 5: > or < 50', 'Trend Candles', 'N/A']) // "MA Crossover", "DAD Direction (Top Dog Trading)", TrendBar3 = input.string(title='4 - Trend Meter 3', group = TM,defval='RSI 5: > or < 50', options=['MACD Crossover - 12, 26, 9', 'MACD Crossover - Fast - 8, 21, 5', 'Mom Dad Cross (Top Dog Trading)', 'RSI Signal Line Cross - RSI 13, Sig 21', 'RSI 13: > or < 50', 'RSI 5: > or < 50', 'Trend Candles', 'N/A']) // "MA Crossover", "DAD Direction (Top Dog Trading)", TrendBar4 = input.string(title='5 - Trend Bar 1', group = TM,defval='MA Crossover', options=['MA Crossover', 'MA Direction - Fast MA - TB1', 'MA Direction - Slow MA - TB1', 'N/A']) // "MACD Crossover - 12, 26 9", "MACD Crossover - Fast - 8, 21, 5", "DAD Direction (Top Dog Trading)", TrendBar5 = input.string(title='6 - Trend Bar 2', group = TM,defval='MA Crossover', options=['MA Crossover', 'MA Direction - Fast MA - TB2', 'MA Direction - Slow MA - TB2', 'N/A']) // "MACD Crossover - 12, 26 9", "MACD Crossover - Fast - 8, 21, 5", "DAD Direction (Top Dog Trading)", ////////////////Signals - Wave Trend///////////////////////////////////////////////////////////////////////////////////////////////// // Wave Trend - RSI RSIMC = ta.rsi(close, 14) // Wave Trend ap = hlc3 n1 = 9 n2 = 12 esa = ta.ema(ap, n1) de = ta.ema(math.abs(ap - esa), n1) ci = (ap - esa) / (0.015 * de) tci = ta.ema(ci, n2) wt1 = tci wt2 = ta.sma(wt1, 3) // Wave Trend - Overbought & Oversold lines obLevel2 = 60 obLevel = 50 osLevel = -50 osLevel2 = -60 // Wave Trend - Conditions WTCross = ta.cross(wt1, wt2) WTCrossUp = wt2 - wt1 <= 0 WTCrossDown = wt2 - wt1 >= 0 WTOverSold = wt2 <= osLevel2 WTOverBought = wt2 >= obLevel2 // MA Inputs MA1_Type = input.string(title='Trend Bar 1 - Fast MA - Type', group = TM,defval='EMA', options=['EMA', 'SMA']) MA1_Length = input.int(5, title='Trend Bar 1 - Fast MA - Length', group = TM,minval=1) MA2_Type = input.string(title='Trend Bar 1 - Slow MA - Type', group = TM,defval='EMA', options=['EMA', 'SMA']) MA2_Length = input.int(11, title='Trend Bar 1 - Slow MA - Length', minval=1) MA3_Type = input.string(title='Trend Bar 2 - Fast MA - Type', group = TM,defval='EMA', options=['EMA', 'SMA']) MA3_Length = input.int(13, title='Trend Bar 2 - Fast MA - Length', minval=1) MA4_Type = input.string(title='Trend Bar 2 - Slow MA - Type', group = TM,defval='SMA', options=['EMA', 'SMA']) MA4_Length = input.int(36, title='Trend Bar 2 - Slow MA - Length', minval=1) // MA Calculations MA1 = if MA1_Type == 'SMA' ta.sma(close, MA1_Length) else ta.ema(close, MA1_Length) MA2 = if MA2_Type == 'SMA' ta.sma(close, MA2_Length) else ta.ema(close, MA2_Length) MA3 = if MA3_Type == 'SMA' ta.sma(close, MA3_Length) else ta.ema(close, MA3_Length) MA4 = if MA4_Type == 'SMA' ta.sma(close, MA4_Length) else ta.ema(close, MA4_Length) // MA Crossover Condition MACrossover1 = MA1 > MA2 ? 1 : 0 MACrossover2 = MA3 > MA4 ? 1 : 0 // MA Direction Condition MA1Direction = MA1 > MA1[1] ? 1 : 0 MA2Direction = MA2 > MA2[1] ? 1 : 0 MA3Direction = MA3 > MA3[1] ? 1 : 0 MA4Direction = MA4 > MA4[1] ? 1 : 0 // MA Direction Change Condition MA1PositiveDirectionChange = MA1Direction and not MA1Direction[1] ? 1 : 0 MA2PositiveDirectionChange = MA2Direction and not MA2Direction[1] ? 1 : 0 MA3PositiveDirectionChange = MA3Direction and not MA3Direction[1] ? 1 : 0 MA4PositiveDirectionChange = MA4Direction and not MA4Direction[1] ? 1 : 0 MA1NegativeDirectionChange = not MA1Direction and MA1Direction[1] ? 1 : 0 MA2NegativeDirectionChange = not MA2Direction and MA2Direction[1] ? 1 : 0 MA3NegativeDirectionChange = not MA3Direction and MA3Direction[1] ? 1 : 0 MA4NegativeDirectionChange = not MA4Direction and MA4Direction[1] ? 1 : 0 // MACD and MOM & DAD - Top Dog Trading // Standard MACD Calculations MACDfastMA = 12 MACDslowMA = 26 MACDsignalSmooth = 9 MACDLine = ta.ema(close, MACDfastMA) - ta.ema(close, MACDslowMA) SignalLine = ta.ema(MACDLine, MACDsignalSmooth) MACDHistogram = MACDLine - SignalLine // MACD- Background Color Change Condition MACDHistogramCross = MACDHistogram > 0 ? 1 : 0 MACDLineOverZero = MACDLine > 0 ? 1 : 0 MACDLineOverZeroandHistogramCross = MACDHistogramCross and MACDLineOverZero ? 1 : 0 MACDLineUnderZeroandHistogramCross = not MACDHistogramCross and not MACDLineOverZero ? 1 : 0 // Fast MACD Calculations FastMACDfastMA = 8 FastMACDslowMA = 21 FastMACDsignalSmooth = 5 FastMACDLine = ta.ema(close, FastMACDfastMA) - ta.ema(close, FastMACDslowMA) FastSignalLine = ta.ema(FastMACDLine, FastMACDsignalSmooth) FastMACDHistogram = FastMACDLine - FastSignalLine // Fast MACD- Background Color Change Condition FastMACDHistogramCross = FastMACDHistogram > 0 ? 1 : 0 FastMACDLineOverZero = FastMACDLine > 0 ? 1 : 0 FastMACDLineOverZeroandHistogramCross = FastMACDHistogramCross and FastMACDLineOverZero ? 1 : 0 FastMACDLineUnderZeroandHistogramCross = not FastMACDHistogramCross and not FastMACDLineOverZero ? 1 : 0 // Top Dog Trading - Mom Dad Calculations TopDog_Fast_MA = 5 TopDog_Slow_MA = 20 TopDog_Sig = 30 TopDogMom = ta.ema(close, TopDog_Fast_MA) - ta.ema(close, TopDog_Slow_MA) TopDogDad = ta.ema(TopDogMom, TopDog_Sig) // Top Dog Dad - Background Color Change Condition TopDogDadDirection = TopDogDad > TopDogDad[1] ? 1 : 0 TopDogMomOverDad = TopDogMom > TopDogDad ? 1 : 0 TopDogMomOverZero = TopDogMom > 0 ? 1 : 0 TopDogDadDirectandMomOverZero = TopDogDadDirection and TopDogMomOverZero ? 1 : 0 TopDogDadDirectandMomUnderZero = not TopDogDadDirection and not TopDogMomOverZero ? 1 : 0 ////// Trend Barmeter Calculations ////// // UCS_Trend / Trend Candles Trend Barmeter Calculations //UCS_Trend by ucsgears copy Trend Candles //Interpretation of TTM Trend bars. It is really close to the actual. haclose = ohlc4 haopen = 0.0 haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2 ccolor = haclose - haopen > 0 ? 1 : 0 inside6 = haopen <= math.max(haopen[6], haclose[6]) and haopen >= math.min(haopen[6], haclose[6]) and haclose <= math.max(haopen[6], haclose[6]) and haclose >= math.min(haopen[6], haclose[6]) ? 1 : 0 inside5 = haopen <= math.max(haopen[5], haclose[5]) and haopen >= math.min(haopen[5], haclose[5]) and haclose <= math.max(haopen[5], haclose[5]) and haclose >= math.min(haopen[5], haclose[5]) ? 1 : 0 inside4 = haopen <= math.max(haopen[4], haclose[4]) and haopen >= math.min(haopen[4], haclose[4]) and haclose <= math.max(haopen[4], haclose[4]) and haclose >= math.min(haopen[4], haclose[4]) ? 1 : 0 inside3 = haopen <= math.max(haopen[3], haclose[3]) and haopen >= math.min(haopen[3], haclose[3]) and haclose <= math.max(haopen[3], haclose[3]) and haclose >= math.min(haopen[3], haclose[3]) ? 1 : 0 inside2 = haopen <= math.max(haopen[2], haclose[2]) and haopen >= math.min(haopen[2], haclose[2]) and haclose <= math.max(haopen[2], haclose[2]) and haclose >= math.min(haopen[2], haclose[2]) ? 1 : 0 inside1 = haopen <= math.max(haopen[1], haclose[1]) and haopen >= math.min(haopen[1], haclose[1]) and haclose <= math.max(haopen[1], haclose[1]) and haclose >= math.min(haopen[1], haclose[1]) ? 1 : 0 colorvalue = inside6 ? ccolor[6] : inside5 ? ccolor[5] : inside4 ? ccolor[4] : inside3 ? ccolor[3] : inside2 ? ccolor[2] : inside1 ? ccolor[1] : ccolor TrendBarTrend_Candle_Color = colorvalue ? BuyColor : SellColor TrendBarTrend_Candle = colorvalue ? 1 : 0 // RSI 5 Trend Barmeter Calculations RSI5 = ta.rsi(close, 5) RSI5Above50 = RSI5 > 50 ? 1 : 0 RSI5Color = RSI5Above50 ? BuyColor : SellColor TrendBarRSI5Color = RSI5Above50 ? BuyColor : SellColor // RSI 5 Trend Barmeter Calculations RSI13 = ta.rsi(close, 13) // Linear Regression Calculation For RSI Signal Line SignalLineLength1 = 21 x = bar_index y = RSI13 x_ = ta.sma(x, SignalLineLength1) y_ = ta.sma(y, SignalLineLength1) mx = ta.stdev(x, SignalLineLength1) my = ta.stdev(y, SignalLineLength1) c = ta.correlation(x, y, SignalLineLength1) slope = c * (my / mx) inter = y_ - slope * x_ LinReg1 = x * slope + inter RSISigDirection = LinReg1 > LinReg1[1] ? 1 : 0 RSISigCross = RSI13 > LinReg1 ? 1 : 0 RSI13Above50 = RSI13 > 50 ? 1 : 0 // Trend Barmeter Color Calculation RSI13Color = RSI13Above50 ? BuyColor : SellColor TrendBarRSI13Color = RSI13Above50 ? BuyColor : SellColor TrendBarRSISigCrossColor = RSISigCross ? BuyColor : SellColor TrendBarMACDColor = MACDHistogramCross ? BuyColor : SellColor TrendBarFastMACDColor = FastMACDHistogramCross ? BuyColor : SellColor TrendBarMACrossColor = MACrossover1 ? BuyColor : SellColor TrendBarMomOverDadColor = TopDogMomOverDad ? BuyColor : SellColor TrendBarDadDirectionColor = TopDogDadDirection ? BuyColor : SellColor TrendBar1Result = TrendBar1 == 'MA Crossover' ? MACrossover1 : TrendBar1 == 'MACD Crossover - 12, 26, 9' ? MACDHistogramCross : TrendBar1 == 'MACD Crossover - Fast - 8, 21, 5' ? FastMACDHistogramCross : TrendBar1 == 'Mom Dad Cross (Top Dog Trading)' ? TopDogMomOverDad : TrendBar1 == 'DAD Direction (Top Dog Trading)' ? TopDogDadDirection : TrendBar1 == 'RSI Signal Line Cross - RSI 13, Sig 21' ? RSISigCross : TrendBar1 == 'RSI 5: > or < 50' ? RSI5Above50 : TrendBar1 == 'RSI 13: > or < 50' ? RSI13Above50 : TrendBar1 == 'Trend Candles' ? TrendBarTrend_Candle : na TrendBar2Result = TrendBar2 == 'MA Crossover' ? MACrossover1 : TrendBar2 == 'MACD Crossover - 12, 26, 9' ? MACDHistogramCross : TrendBar2 == 'MACD Crossover - Fast - 8, 21, 5' ? FastMACDHistogramCross : TrendBar2 == 'Mom Dad Cross (Top Dog Trading)' ? TopDogMomOverDad : TrendBar2 == 'DAD Direction (Top Dog Trading)' ? TopDogDadDirection : TrendBar2 == 'RSI Signal Line Cross - RSI 13, Sig 21' ? RSISigCross : TrendBar2 == 'RSI 5: > or < 50' ? RSI5Above50 : TrendBar2 == 'RSI 13: > or < 50' ? RSI13Above50 : TrendBar2 == 'Trend Candles' ? TrendBarTrend_Candle : na TrendBar3Result = TrendBar3 == 'MA Crossover' ? MACrossover1 : TrendBar3 == 'MACD Crossover - 12, 26, 9' ? MACDHistogramCross : TrendBar3 == 'MACD Crossover - Fast - 8, 21, 5' ? FastMACDHistogramCross : TrendBar3 == 'Mom Dad Cross (Top Dog Trading)' ? TopDogMomOverDad : TrendBar3 == 'DAD Direction (Top Dog Trading)' ? TopDogDadDirection : TrendBar3 == 'RSI Signal Line Cross - RSI 13, Sig 21' ? RSISigCross : TrendBar3 == 'RSI 5: > or < 50' ? RSI5Above50 : TrendBar3 == 'RSI 13: > or < 50' ? RSI13Above50 : TrendBar3 == 'Trend Candles' ? TrendBarTrend_Candle : na TrendBars2Positive = TrendBar1Result and TrendBar2Result or TrendBar1Result and TrendBar3Result or TrendBar2Result and TrendBar3Result ? 1 : 0 TrendBars2Negative = not TrendBar1Result and not TrendBar2Result or not TrendBar1Result and not TrendBar3Result or not TrendBar2Result and not TrendBar3Result ? 1 : 0 TrendBars3Positive = TrendBar1Result and TrendBar2Result and TrendBar3Result ? 1 : 0 TrendBars3Negative = not TrendBar1Result and not TrendBar2Result and not TrendBar3Result ? 1 : 0 // Signal Filters FilterXUp = FastMACDHistogramCross and ta.ema(close, 15) > ta.ema(close, 15)[1] FilterXDown = not FastMACDHistogramCross and ta.ema(close, 15) < ta.ema(close, 15)[1] TrendFilterPlus = ta.ema(close, 15) > ta.ema(close, 20) and ta.ema(close, 20) > ta.ema(close, 30) and ta.ema(close, 30) > ta.ema(close, 40) and ta.ema(close, 40) > ta.ema(close, 50) ? 1 : 0 TrendFilterMinus = ta.ema(close, 15) < ta.ema(close, 20) and ta.ema(close, 20) < ta.ema(close, 30) and ta.ema(close, 30) < ta.ema(close, 40) and ta.ema(close, 40) < ta.ema(close, 50) ? 1 : 0 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// BackgroundColorChangePositive = TrendBars3Positive and not TrendBars3Positive[1] BackgroundColorChangeNegative = TrendBars3Negative and not TrendBars3Negative[1] // Trend Barmeter Color Assignments TrendBar1Color = TrendBar1 == 'N/A' ? na : TrendBar1 == 'MACD Crossover - 12, 26, 9' ? TrendBarMACDColor : TrendBar1 == 'MACD Crossover - Fast - 8, 21, 5' ? TrendBarFastMACDColor : TrendBar1 == 'Mom Dad Cross (Top Dog Trading)' ? TrendBarMomOverDadColor : TrendBar1 == 'DAD Direction (Top Dog Trading)' ? TrendBarDadDirectionColor : TrendBar1 == 'RSI Signal Line Cross - RSI 13, Sig 21' ? TrendBarRSISigCrossColor : TrendBar1 == 'RSI 5: > or < 50' ? TrendBarRSI5Color : TrendBar1 == 'RSI 13: > or < 50' ? TrendBarRSI13Color : TrendBar1 == 'Trend Candles' ? TrendBarTrend_Candle_Color : TrendBar1 == 'MA Crossover' ? TrendBarMACrossColor : na TrendBar2Color = TrendBar2 == 'N/A' ? na : TrendBar2 == 'MACD Crossover - 12, 26, 9' ? TrendBarMACDColor : TrendBar2 == 'MACD Crossover - Fast - 8, 21, 5' ? TrendBarFastMACDColor : TrendBar2 == 'Mom Dad Cross (Top Dog Trading)' ? TrendBarMomOverDadColor : TrendBar2 == 'DAD Direction (Top Dog Trading)' ? TrendBarDadDirectionColor : TrendBar2 == 'RSI Signal Line Cross - RSI 13, Sig 21' ? TrendBarRSISigCrossColor : TrendBar2 == 'RSI 5: > or < 50' ? TrendBarRSI5Color : TrendBar2 == 'RSI 13: > or < 50' ? TrendBarRSI13Color : TrendBar2 == 'Trend Candles' ? TrendBarTrend_Candle_Color : TrendBar2 == 'MA Crossover' ? TrendBarMACrossColor : na TrendBar3Color = TrendBar3 == 'N/A' ? na : TrendBar3 == 'MACD Crossover - 12, 26, 9' ? TrendBarMACDColor : TrendBar3 == 'MACD Crossover - Fast - 8, 21, 5' ? TrendBarFastMACDColor : TrendBar3 == 'Mom Dad Cross (Top Dog Trading)' ? TrendBarMomOverDadColor : TrendBar3 == 'DAD Direction (Top Dog Trading)' ? TrendBarDadDirectionColor : TrendBar3 == 'RSI Signal Line Cross - RSI 13, Sig 21' ? TrendBarRSISigCrossColor : TrendBar3 == 'RSI 5: > or < 50' ? TrendBarRSI5Color : TrendBar3 == 'RSI 13: > or < 50' ? TrendBarRSI13Color : TrendBar3 == 'Trend Candles' ? TrendBarTrend_Candle_Color : TrendBar3 == 'MA Crossover' ? TrendBarMACrossColor : na CrossoverType2 = TrendBar4 == 'DAD Direction (Top Dog Trading)' ? TopDogDadDirection : TrendBar4 == 'MACD Crossover' ? MACDHistogramCross : TrendBar4 == 'MA Direction - Fast MA - TB1' ? MA1Direction : TrendBar4 == 'MA Direction - Slow MA - TB1' ? MA2Direction : MACrossover1 color_1 = color.new(BuyColor, 15) color_2 = color.new(SellColor, 20) TrendBar4Color1 = TrendBar4 == 'N/A' ? na : CrossoverType2 ? color_1 : color_2 CrossoverType3 = TrendBar5 == 'DAD Direction (Top Dog Trading)' ? TopDogDadDirection : TrendBar5 == 'MACD Crossover' ? MACDHistogramCross : TrendBar5 == 'MA Direction - Fast MA - TB2' ? MA3Direction : TrendBar5 == 'MA Direction - Slow MA - TB2' ? MA4Direction : MACrossover2 color_3 = color.new(BuyColor, 15) color_4 = color.new(SellColor, 20) TrendBar5Color1 = TrendBar5 == 'N/A' ? na : CrossoverType3 ? color_3 : color_4 alertcondition(BackgroundColorChangePositive, title='3 TMs Turn Green', message='All 3 Trend Meters Turn Green - Trend Meter') alertcondition(BackgroundColorChangeNegative, title='3 TMs Turn Red', message='All 3 Trend Meters Turn Red - Trend Meter') alertcondition(BackgroundColorChangePositive or BackgroundColorChangeNegative, title='3 TMs Change Color', message='All 3 Trend Meters Change Color - Trend Meter') RapidColorChangePositive = TrendBars3Positive and (TrendBars3Negative[1] or TrendBars3Negative[2]) RapidColorChangeNegative = TrendBars3Negative and (TrendBars3Positive[1] or TrendBars3Positive[2]) alertcondition(RapidColorChangePositive, title='3 TMs Rapid Change Red to Green', message='3 Trend Meters Rapid Change Red to Green - Trend Meter') alertcondition(RapidColorChangeNegative, title='3 TMs Rapid Change Green to Red', message='3 Trend Meters Rapid Change Green to Red - Trend Meter') alertcondition(RapidColorChangePositive or RapidColorChangeNegative, title='3 TMs Rapid Color Change', message='3 Trend Meters Rapid Color Change - Trend Meter') MaxValueMACrossUp = ta.crossover(ta.ema(close, 5), ta.ema(close, 11)) MaxValueMACrossDown = ta.crossunder(ta.ema(close, 5), ta.ema(close, 11)) TB1MACrossUp = ta.crossover(MA1, MA2) TB1MACrossDown = ta.crossunder(MA1, MA2) alertcondition(TB1MACrossUp, title='TB1 Fast MA X Above Slow MA', message='Trend Bar 1 - Fast MA X Above Slow MA - Trend Meter') alertcondition(TB1MACrossDown, title='TB1 Fast MA X Below Slow MA', message='Trend Bar 1 - Fast MA X Below Slow MA - Trend Meter') alertcondition(TB1MACrossUp or TB1MACrossDown, title='TB1 MAs X', message='Color Change - Trend Bar 1 - MAs Crossing - Trend Meter') TB2MACrossUp = ta.crossover(MA3, MA4) TB2MACrossDown = ta.crossunder(MA3, MA4) alertcondition(TB2MACrossUp, title='TB2 Fast MA X Above Slow MA', message='Trend Bar 2 - Fast MA X Above Slow MA - Trend Meter') alertcondition(TB2MACrossDown, title='TB2 Fast MA X Below Slow MA', message='Trend Bar 2 - Fast MA X Below Slow MA - Trend Meter') alertcondition(TB2MACrossUp or TB2MACrossDown, title='TB2 MAs X', message='Color Change - Trend Bar 2 - MAs Crossing - Trend Meter') TB1Green = MA1 > MA2 TB1Red = MA1 < MA2 TB2Green = MA3 > MA4 TB2Red = MA3 < MA4 alertcondition(BackgroundColorChangePositive and TB1Green, title='3 TMs Turn Green with TB 1', message='All 3 Trend Meters Turn Green with TB 1 - Trend Meter') alertcondition(BackgroundColorChangeNegative and TB1Red, title='3 TMs Turn Red with TB 1', message='All 3 Trend Meters Turn Red with TB 1 - Trend Meter') alertcondition(BackgroundColorChangePositive and TB1Green or BackgroundColorChangeNegative and TB1Red, title='3 TMs Change Color with TB 1', message='All 3 Trend Meters Change Color with TB 1 - Trend Meter') alertcondition(BackgroundColorChangePositive and TB2Green, title='3 TMs Turn Green with TB 2', message='All 3 Trend Meters Turn Green with TB 2 - Trend Meter') alertcondition(BackgroundColorChangeNegative and TB2Red, title='3 TMs Turn Red with TB 2', message='All 3 Trend Meters Turn Red with TB 2 - Trend Meter') alertcondition(BackgroundColorChangePositive and TB2Green or BackgroundColorChangeNegative and TB2Red, title='3 TMs Change Color with TB 2', message='All 3 Trend Meters Change Color with TB 2 - Trend Meter') alertcondition(BackgroundColorChangePositive and TB1Green and TB2Green, title='3 TMs Turn Green with TBs 1+2', message='All 3 Trend Meters Turn Green with Trend Bar 1+2 - Trend Meter') alertcondition(BackgroundColorChangeNegative and TB1Red and TB2Red, title='3 TMs Turn Red with TBs 1+2', message='All 3 Trend Meters Turn Red with Trend Bar 1+2 - Trend Meter') alertcondition(BackgroundColorChangePositive and TB1Green and TB2Green or BackgroundColorChangeNegative and TB1Red and TB2Red, title='3 TMs Change Color with TBs1+2', message='All 3 Trend Meters Change Color with Trend Bar 1+2 - Trend Meter') //Trend Meter END ////////////////Chaikin Money Flow STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// cmfLength = input(title='CMF length', defval=20,group = 'Chaikin Moneyflow') ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume mf = math.sum(ad, cmfLength) / math.sum(volume, cmfLength) cmfPositive = mf >= 0.05 cmfNeutral = mf < 0.05 and mf > -0.05 cmfNegative = mf <= -0.05 MSBarCMFColor = cmfPositive ? color.new(BuyColor, 15) : cmfNeutral ? color.new(NeutralColor, 20) : color.new(SellColor, 20) ////////////////Chaikin Money Flow Exit End ///////////////////////////////////////////////////////////////////////////////////////////////// ////////////////Signals - KDJ STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// ilong = input(9, title="KDJ period",group = 'KDJ') isig = input(3, title="KDJ signal",group = 'KDJ') bcwsma(s, l, m) => _bcwsma = float(na) _s = s _l = l _m = m _bcwsma := (_m * _s + (_l - _m) * nz(_bcwsma[1])) / _l _bcwsma //c = close h = ta.highest(high, ilong) l = ta.lowest(low, ilong) RSV = 100 * ((close - l) / (h - l)) pK = bcwsma(RSV, isig, 1) pD = bcwsma(pK, isig, 1) pJ = 3 * pK - 2 * pD KDJ = math.avg(pD, pJ, pK) MSBarKDJPositiveTrendSignal = pJ>pD MSBarKDJNegativeTrendSignal = pJ<pD MSBarKDJColor = MSBarKDJPositiveTrendSignal ? color.new(BuyColor, 15) : MSBarKDJNegativeTrendSignal ? color.new(SellColor, 20) : na ////////////////Signals - KDJ ENDS ///////////////////////////////////////////////////////////////////////////////////////////////// ////////////////Signals - Chandelier Exit STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// atrLength = input(title='ATR Period', defval=1,group = 'Chandelier Exit') ceMult = input.float(title='ATR Multiplier', step=0.1, defval=1.85,group = 'Chandelier Exit') ceUseClose = input(title='Use Close Price for Extremums ?', defval=false,group = 'Chandelier Exit') atr = ceMult * ta.atr(atrLength) ceLongStop = (ceUseClose ? ta.highest(close, atrLength) : ta.highest(atrLength)) - atr ceLongStopPrev = nz(ceLongStop[1], ceLongStop) ceLongStop := close[1] > ceLongStopPrev ? math.max(ceLongStop, ceLongStopPrev) : ceLongStop ceShortStop = (ceUseClose ? ta.lowest(close, atrLength) : ta.lowest(atrLength)) + atr ceShortStopPrev = nz(ceShortStop[1], ceShortStop) ceShortStop := close[1] < ceShortStopPrev ? math.min(ceShortStop, ceShortStopPrev) : ceShortStop var int ceDir = 1 ceDir := close > ceShortStopPrev ? 1 : close < ceLongStopPrev ? -1 : ceDir ceBuySignal = ceDir == 1 and ceDir[1] == -1 ceSellSignal = ceDir == -1 and ceDir[1] == 1 ceChangeCond = ceDir != ceDir[1] //Without filtering MSBarCEPositiveTrendSignal = ceBuySignal MSBarCENegativeTrendSignal = ceSellSignal MSBarCEColor = MSBarCEPositiveTrendSignal ? BuyColor : MSBarCENegativeTrendSignal ? SellColor : color.new(DisabledColor,90) ////////////////Signals - Chandelier Exit Ends///////////////////////////////////////////////////////////////////////////////////////////////// ////////////////Signals - WaveTrend STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// MSBar1PositiveWaveTrendSignal = MSBar1 == 'Filter X' ? FilterXUp and WTCross and WTCrossUp : MSBar1 == 'Trend Filter' ? TrendFilterPlus and WTCross and WTCrossUp : MSBar1 == 'Filter X + Trend Filter' ? FilterXUp and TrendFilterPlus and WTCross and WTCrossUp : WTCross and WTCrossUp MSBar1NegativeWaveTrendSignal = MSBar1 == 'Filter X' ? FilterXDown and WTCross and WTCrossDown : MSBar1 == 'Trend Filter' ? TrendFilterMinus and WTCross and WTCrossDown : MSBar1 == 'Filter X + Trend Filter' ? FilterXDown and TrendFilterMinus and WTCross and WTCrossDown : WTCross and WTCrossDown MSBar2PositiveWaveTrendSignal = MSBar2 == 'Filter X' ? FilterXUp and WTCross and WTCrossUp : MSBar2 == 'Trend Filter' ? TrendFilterPlus and WTCross and WTCrossUp : MSBar2 == 'Filter X + Trend Filter' ? FilterXUp and TrendFilterPlus and WTCross and WTCrossUp : WTCross and WTCrossUp MSBar2NegativeWaveTrendSignal = MSBar2 == 'Filter X' ? FilterXDown and WTCross and WTCrossDown : MSBar2 == 'Trend Filter' ? TrendFilterMinus and WTCross and WTCrossDown : MSBar2 == 'Filter X + Trend Filter' ? FilterXDown and TrendFilterMinus and WTCross and WTCrossDown : WTCross and WTCrossDown MSBar1Color = MSBar1PositiveWaveTrendSignal ? BuyColor : MSBar1NegativeWaveTrendSignal ? SellColor : color.new(DisabledColor,90) MSBar2Color = BackgroundColorChangePositive ? BuyColor : BackgroundColorChangeNegative ? SellColor : color.new(DisabledColor,90) ////////////////Signals - WaveTrend ENDS ///////////////////////////////////////////////////////////////////////////////////////////////// ////////////////Signals - QQE STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// RSI_Period = input(14, title='RSI Length',group = 'QQE') SF = input(5, title='RSI Smoothing',group = 'QQE') QQE = input(4.238, title='Fast QQE Factor',group = 'QQE') ThreshHold = input(10, title='Thresh-hold',group = 'QQE') qqrSrc = close Wilders_Period = RSI_Period * 2 - 1 Rsi = ta.rsi(qqrSrc, RSI_Period) RsiMa = ta.ema(Rsi, SF) AtrRsi = math.abs(RsiMa[1] - RsiMa) MaAtrRsi = ta.ema(AtrRsi, Wilders_Period) dar = ta.ema(MaAtrRsi, Wilders_Period) * QQE qqeLongband = 0.0 qqeShortband = 0.0 qqeTrend = 0 DeltaFastAtrRsi = dar RSIndex = RsiMa qqeNewshortband = RSIndex + DeltaFastAtrRsi qqeNewlongband = RSIndex - DeltaFastAtrRsi qqeLongband := RSIndex[1] > qqeLongband[1] and RSIndex > qqeLongband[1] ? math.max(qqeLongband[1], qqeNewlongband) : qqeNewlongband qqeShortband := RSIndex[1] < qqeShortband[1] and RSIndex < qqeShortband[1] ? math.min(qqeShortband[1], qqeNewshortband) : qqeNewshortband cross_1 = ta.cross(qqeLongband[1], RSIndex) qqeTrend := ta.cross(RSIndex, qqeShortband[1]) ? 1 : cross_1 ? -1 : nz(qqeTrend[1], 1) FastAtrRsiTL = qqeTrend == 1 ? qqeLongband : qqeShortband // Find all the QQE Crosses QQExlong = 0 QQExlong := nz(QQExlong[1]) QQExshort = 0 QQExshort := nz(QQExshort[1]) QQExlong := FastAtrRsiTL < RSIndex ? QQExlong + 1 : 0 QQExshort := FastAtrRsiTL > RSIndex ? QQExshort + 1 : 0 //Conditions qqeLong = QQExlong == 1 ? FastAtrRsiTL[1] - 50 : na qqeShort = QQExshort == 1 ? FastAtrRsiTL[1] - 50 : na MSBarQQEPositiveTrendSignal = qqeLong MSBarQQENegativeTrendSignal = qqeShort MSBarQQEColor = MSBarQQEPositiveTrendSignal ? BuyColor : MSBarQQENegativeTrendSignal ? SellColor : color.new(DisabledColor,90) ////////////////Signals - QQE ENDS ///////////////////////////////////////////////////////////////////////////////////////////////// ////////////////Signals - PSAR STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// psStart = input.float(title='Start', step=0.001, defval=0.02,group = 'Parabolic SAR') psIncrement = input.float(title='Increment', step=0.001, defval=0.02,group = 'Parabolic SAR') psMaximum = input.float(title='Maximum', step=0.01, defval=0.2,group = 'Parabolic SAR') psWidth = input.int(title='Point Width', minval=1, defval=2,group = 'Parabolic SAR') psar = ta.sar(psStart, psIncrement, psMaximum) psDir = psar < close ? 1 : -1 psBuySignal = psDir == 1 and psDir[1] == -1 psSellSignal = psDir == -1 and psDir[1] == 1 MSBarPSPositiveTrendSignal = psBuySignal MSBarPSNegativeTrendSignal = psSellSignal MSBarPSColor = MSBarPSPositiveTrendSignal ? BuyColor : MSBarPSNegativeTrendSignal ? SellColor : color.new(DisabledColor,90) changeCond = psDir != psDir[1] ////////////////Signals - PSAR ENDS ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////// Technical Ratings ENDS ///////////////////////////////////////////////////////////////////////////////////////////////// // ———————————————————— Constants, global arrays and inputs { var string TR = 'Technical Ratings' // ————— Input `options` selections. var string RT1 = 'MAs and Oscillators' var string RT2 = 'MAs' var string RT3 = 'Oscillators' var string ON = 'On' var string OFF = 'Off' var string TD0 = 'None' var string TD1 = 'Longs' var string TD2 = 'Shorts' var string TD3 = 'Longs and Shorts' var string PS1 = 'Columns' var string PS2 = 'Histogram' var string PS3 = 'Area' var string PS4 = 'Line' // Levels determining "Strong Buy/Sell" and "Buy/Sell" ratings. var float LEVEL_STRONG = 0.5 var float LEVEL_WEAK = 0.1 // Color constants. var color C_AQUA = #0080FFff var color C_BLACK = #000000ff var color C_BLUE = #013BCAff var color C_CORAL = #FF8080ff var color C_GOLD = #CCCC00ff var color C_GRAY = #808080ff var color C_GREEN = #008000ff var color C_LIME = #00FF00ff var color C_MAROON = #800000ff var color C_ORANGE = #FF8000ff var color C_PINK = #FF0080ff var color C_RED = #FF0000ff var color C_VIOLET = #AA00FFff var color C_YELLOW = #FFFF00ff var color C_WHITE = #FFFFFFff var color C_NEUTRAL = #434650 // ————— Global arrays // Array holding values for the 3 ratings in this order: All, MAs, Osc. var float[] ratings = array.new_float(3) // Array holding the text used as a legend in the displayed results. var string[] TEXTS = array.from('All', 'MAs', 'Osc') // Array holding the index into `ratings` and `texts` arrays determined by which rating user chooses to display. var int[] indices = array.new_int(3) // ————— Inputs string i_tf = ''//input.timeframe('', 'Higher timeframe for technical rating', group=TR, tooltip='When using a higher timeframe, values do not repaint, which means that only values from COMPLETED timeframes are displayed. This provides late, more reliable values, and also ensures the indicator behaves in realtime the same way it does on historical bars.') bool i_repaint = false//input.string(OFF, 'Repainting', options=[ON, OFF], group=TR, tooltip='This only controls the repainting of the displayed signal when NOT using a higher timeframe. Alerts never repaint, regardless of this setting. This means you can display repainting calculations but still have non-repainting markers and alerts.') == ON string i_calcs = input.string(RT1, 'Rating uses', group=TR, options=[RT2, RT3, RT1]) float i_weightMAs = input.int(50, 'Weight of MAs (%)', minval=0, maxval=100, step=10, group=TR, tooltip='Determines the respective weight of MAs and Oscillators when both are used to calculate the overall rating. Equal weight for MAs and Oscillators is 50%. If you use 60% for MAs, then Oscillators weigh in at 40% of the overall rating.') / 100 string i_plotStyle = PS1 //input.string(PS1, 'Plot style', inline='10', options=[PS1, PS2, PS3, PS4]) int i_plotWidth = 1 //input.int(1, '', inline='10', minval=1, maxval=50, tooltip='Width for styles other than \'Columns\'.') color i_c_01 = BuyColor //input.color(C_LIME, 'Bull  ', inline='11', tooltip='Pick only one. These are preset colors, but you can modify anyone of them.') bool i_01 = true //input.bool(true, '', inline='11') color i_c_02 = C_GOLD //input.color(C_GOLD, '', inline='11') bool i_02 = false //input.bool(false, '', inline='11') color i_c_03 = C_WHITE //input.color(C_WHITE, '', inline='11') bool i_03 = false //input.bool(false, '', inline='11') color i_c_04 = SellColor //input.color(C_PINK, 'Bear   ', inline='12', tooltip='Pick only one. These are preset colors, but you can modify anyone of them.') bool i_04 = true//input.bool(true, '', inline='12') color i_c_05 = C_VIOLET//input.color(C_VIOLET, '', inline='12') bool i_05 = false//input.bool(false, '', inline='12') color i_c_06 = C_BLUE//input.color(C_BLUE, '', inline='12') bool i_06 = false //input.bool(false, '', inline='12') color i_c_neutral = color.new(NeutralColor, 20) //input.color(C_NEUTRAL, 'Neutral', inline='13') //var string GP1 = 'Alert Markers (non-repainting)' string i_markerDir = TD3 //input.string(TD0, 'Direction', options=[TD0, TD1, TD2, TD3], group=GP1, tooltip='Markers only become active when you select a direction here. Your marker setup defines the conditions that will trigger an alert configured on the indicator.') bool i_markerAlt = ON == ON and i_markerDir == TD3 //input.string(ON, 'Alternate Longs & Shorts', options=[ON, OFF], group=GP1, tooltip='If both Longs and Shorts are displayed, shows only the first marker in a given direction. This prevents triggering successive markers in the same direction. Has no effect when only long or only short markers are displayed.') == ON and i_markerDir == TD3 float i_levelUp = LEVEL_STRONG //input.float(LEVEL_STRONG, 'Longs Level', minval=0, maxval=1, step=0.05, group=GP1, tooltip='The level that must be breached upward to trigger a long.\n\'Buy\' state corresponds to 0.1\n\'Strong Buy\' state corresponds to 0.5\n\nUse zero if you do not want triggers on this condition.') float i_levelDn = -LEVEL_STRONG //input.float(-LEVEL_STRONG, 'Shorts Level', minval=-1, maxval=0, step=0.05, group=GP1, tooltip='The level that must be breached downward to trigger a short.\n\'Sell\' state corresponds to -0.1\n\'Strong Sell\' state corresponds to -0.5\n\nUse zero if you do not want triggers on this condition.') float i_gradLevel = 0 //input.int(0, 'Cumulative adv./decl.', minval=0, maxval=5, step=1, group=GP1, tooltip='The number of cumulative advances or declines in the signal (capped to 5). The maximum of 5 corresponds to the brightest color for the signal.\n\nUse zero if you do not want triggers on this condition.') // Determine base bull/bear colors as per user selection. var color i_c_bull = i_01 ? i_c_01 : i_02 ? i_c_02 : i_03 ? i_c_03 : i_c_01 var color i_c_bear = i_04 ? i_c_04 : i_05 ? i_c_05 : i_06 ? i_c_06 : i_c_04 var bool doLongs = i_markerDir == TD1 or i_markerDir == TD3 var bool doShorts = i_markerDir == TD2 or i_markerDir == TD3 int plotStyle = i_plotStyle == PS1 ? 5 : i_plotStyle == PS2 ? 1 : i_plotStyle == PS3 ? 4 : 0 // } // ———————————————————— Functions { // RATINGS CALCULATION METHOD: // Individual ratings are one of four values: // • +1 for bull bias. // • 0 for neutral. // • -1 for bear bias. // • na when no value can be determined yet. // The average of all non-na values within each of the MAs and Oscillators groups determines the group's rating. // The overall rating is the average of the two group ratings. // ————— Helper functions. f_rising(_src) => ta.rising(_src, 1) f_falling(_src) => ta.falling(_src, 1) f_trendUp() => close > ta.ema(close, 50) f_trendDn() => close < ta.ema(close, 50) f_notNa(_src) => not na(_src) and not na(_src[1]) // ————— Function returning `_color` with `_transp` transparency. f_colorNew(_color, _transp) => _r = color.r(_color) _g = color.g(_color) _b = color.b(_color) color _return = color.rgb(_r, _g, _b, _transp) _return // ————— General MA rating (+1/0/-1) calculated using position of `_src` price with regards to `_ma`. f_ratingMa(_ma, _src) => math.sign(_src - _ma) // ————— Converts bull/bear conditions into a +1/0/-1 value corresponding to a bull/neutral/bear bias. f_ratingBullBear(_bullCond, _bearCond) => na(_bullCond) or na(_bearCond) ? na : _bullCond ? 1 : _bearCond ? -1 : 0 // ————— Ichimoku rating. f_donchian(_p) => math.avg(ta.lowest(_p), ta.highest(_p)) f_ratingIchimoku() => float _conversion = f_donchian(9) float _base = f_donchian(26) float _lead1 = math.avg(_conversion, _base) float _lead2 = f_donchian(52) float _return = f_ratingBullBear(_lead1 > _lead2 and close > _lead1 and close < _base and close[1] < _conversion and close > _conversion, _lead2 > _lead1 and close < _lead2 and close > _base and close[1] > _conversion and close < _conversion) if not(na(_lead1) or na(_lead2) or na(close) or na(close[1]) or na(_base) or na(_conversion)) _return else float(na) // ————— RSI rating. f_ratingRsi() => float _rsi = ta.rsi(close, 14) float _return = f_ratingBullBear(_rsi < 30 and f_falling(_rsi), _rsi > 70 and f_rising(_rsi)) _return := f_notNa(_rsi) ? _return : na _return // ————— Stochastic rating. f_ratingStoch() => float _k = ta.sma(ta.stoch(close, high, low, 14), 3) float _d = ta.sma(_k, 3) float _return = f_ratingBullBear(_k < 20 and _d < 20 and _k > _d and _k[1] < _d[1], _k > 80 and _d > 80 and _k < _d and _k[1] > _d[1]) _return := f_notNa(_k) and f_notNa(_d) ? _return : na _return // ————— CCI rating. f_ratingCci() => float _cci = ta.cci(close, 20) float _return = f_ratingBullBear(_cci < -100 and f_rising(_cci), _cci > 100 and f_falling(_cci)) _return := f_notNa(_cci) ? _return : na _return // ————— ADX rating. f_ratingAdx() => [_diPlus, _diMinus, _adx] = ta.dmi(14, 14) float _return = f_ratingBullBear(_adx > 20 and _diPlus[1] < _diMinus[1] and _diPlus > _diMinus, _adx > 20 and _diPlus[1] > _diMinus[1] and _diPlus < _diMinus) _return := f_notNa(_diPlus) and f_notNa(_diMinus) and not na(_adx) ? _return : na _return // ————— Awesome Oscillator rating. f_ratingAo() => float _ao = ta.sma(hl2, 5) - ta.sma(hl2, 34) bool _aoXUp = ta.crossover(_ao, 0) bool _aoXDn = ta.crossunder(_ao, 0) float _return = f_ratingBullBear(_aoXUp or _ao > 0 and _ao[1] > 0 and f_rising(_ao), _aoXDn or _ao < 0 and _ao[1] < 0 and f_falling(_ao)) _return := f_notNa(_ao) ? _return : na _return // ————— Momentum rating. f_ratingMom() => float _mom = close - close[10] float _return = f_ratingBullBear(f_rising(_mom), f_falling(_mom)) _return := f_notNa(_mom) ? _return : na _return // ————— MACD rating. f_ratingMacd() => [_macd, _signal, _] = ta.macd(close, 12, 26, 9) float _return = f_ratingBullBear(_macd > _signal, _macd < _signal) _return := not na(_macd) and not na(_signal) ? _return : na _return // ————— Stoch RSI rating. f_ratingStochRsi() => float _rsi = ta.rsi(close, 14) float _k = ta.sma(ta.stoch(_rsi, _rsi, _rsi, 14), 3) float _d = ta.sma(_k, 3) float _return = f_ratingBullBear(f_trendDn() and _k < 20 and _d < 20 and _k > _d and _k[1] < _d[1], f_trendUp() and _k > 80 and _d > 80 and _k < _d and _k[1] > _d[1]) _return := f_notNa(_k) and f_notNa(_d) and not na(f_trendDn()) and not na(f_trendUp()) ? _return : na _return // ————— Williams %R rating. f_ratingWpr() => float _wpr = ta.wpr(14) float _return = f_ratingBullBear(_wpr < -80 and f_rising(_wpr), _wpr > -20 and f_falling(_wpr)) _return := f_notNa(_wpr) ? _return : na _return // ————— Bull Bear Power rating. f_ratingBbp() => float _powerBull = high - ta.ema(close, 13) float _powerBear = low - ta.ema(close, 13) float _return = f_ratingBullBear(f_trendUp() and _powerBear < 0 and f_rising(_powerBear), f_trendDn() and _powerBull > 0 and f_falling(_powerBull)) _return := f_notNa(_powerBull) and f_notNa(_powerBear) and not na(f_trendDn()) and not na(f_trendUp()) ? _return : na _return // ————— Ultimate Oscillator rating. f_ratingUo() => var int _pFast = 7 var int _pMid = 14 var int _pLong = 28 float _tl = close[1] < low ? close[1] : low float _uo = na float _v1 = math.sum(ta.tr, _pFast) float _v2 = math.sum(ta.tr, _pMid) float _v3 = math.sum(ta.tr, _pLong) float _v4 = math.sum(close - _tl, _pFast) float _v5 = math.sum(close - _tl, _pMid) float _v6 = math.sum(close - _tl, _pLong) if _v1 != 0 and _v2 != 0 and _v3 != 0 float _p0 = _pLong / _pFast float _p1 = _pLong / _pMid float _v7 = _v4 / _v1 * _p0 float _v8 = _v5 / _v2 * _p1 float _v9 = _v6 / _v3 _uo := 100 * (_v7 + _v8 + _v9) / (_p0 + _p1 + 1) _uo float _return = f_ratingBullBear(_uo > 70, _uo < 30) _return := not na(_uo) ? _return : na _return // ————— Function that calculates the ratings for the three groups: All, MAs, Oscillators. f_ratings(_offset) => // int _offset: offset of values returned. Required to control repainting. Can be 0 or 1. // Dependencies: `f_ratingMa()`, `f_ratingIchimoku()`, and one function for each of the oscillators. // Array holding the calculated ratings for MAs group, then for Oscillators. var float[] _ratings = array.new_float(0) // Calculate MAs rating. array.clear(_ratings) array.push(_ratings, f_ratingMa(ta.sma(close, 10), close)) array.push(_ratings, f_ratingMa(ta.sma(close, 20), close)) array.push(_ratings, f_ratingMa(ta.sma(close, 30), close)) array.push(_ratings, f_ratingMa(ta.sma(close, 50), close)) array.push(_ratings, f_ratingMa(ta.sma(close, 100), close)) array.push(_ratings, f_ratingMa(ta.sma(close, 200), close)) array.push(_ratings, f_ratingMa(ta.ema(close, 10), close)) array.push(_ratings, f_ratingMa(ta.ema(close, 20), close)) array.push(_ratings, f_ratingMa(ta.ema(close, 30), close)) array.push(_ratings, f_ratingMa(ta.ema(close, 50), close)) array.push(_ratings, f_ratingMa(ta.ema(close, 100), close)) array.push(_ratings, f_ratingMa(ta.ema(close, 200), close)) array.push(_ratings, f_ratingMa(ta.hma(close, 9), close)) array.push(_ratings, f_ratingMa(ta.vwma(close, 20), close)) array.push(_ratings, f_ratingIchimoku()) float _ratingMas = array.avg(_ratings) // Calculate Oscillators rating. array.clear(_ratings) array.push(_ratings, f_ratingRsi()) array.push(_ratings, f_ratingStoch()) array.push(_ratings, f_ratingCci()) array.push(_ratings, f_ratingAdx()) array.push(_ratings, f_ratingAo()) array.push(_ratings, f_ratingMom()) array.push(_ratings, f_ratingMacd()) array.push(_ratings, f_ratingStochRsi()) array.push(_ratings, f_ratingWpr()) array.push(_ratings, f_ratingBbp()) array.push(_ratings, f_ratingUo()) float _ratingOsc = array.avg(_ratings) // Calculate weighed average of the two groups: MAs and Oscillators. float _ratingTot = nz(_ratingMas * i_weightMAs) + nz(_ratingOsc * (1. - i_weightMAs)) [_ratingTot[_offset], _ratingMas[_offset], _ratingOsc[_offset]] // ————— Function returning the index to be used in arrays `ratings` and `texts` to get values and legends in the correct order when printing results. f_idx(_pos) => // int _pos: line number (0-2) for which we need the index into our `ratings` and `texts` arrays. // Dependency: `indices` array containing the vertical order of appearance of the current ratings. int _return = array.get(indices, _pos) _return // ————— Function that orders the `indices` array such that its elements represent the indices into arrays `ratings` and `texts`, // which `f_idx()` will then use to fetch the proper values and legends for each of the three lines in the results. // The order used is derived from the "Rating uses" user selection. User's choice always appears on line 1, with the remaining ones on lines 2 and 3. f_orderSignals(_userSelection) => // string _userSelection: user choice of which rating group to display. // Dependencies: `indices` array, `RTx` constants. if _userSelection == RT2 array.set(indices, 0, 1) array.set(indices, 1, 2) array.set(indices, 2, 0) else if _userSelection == RT3 array.set(indices, 0, 2) array.set(indices, 1, 1) array.set(indices, 2, 0) else array.set(indices, 0, 0) array.set(indices, 1, 1) array.set(indices, 2, 2) // ————— Function counting the number of consecutive ups and downs for `_src`. f_countRising(_src) => // float _src: value of ratings to color. var int _cnt = 0 float _chg = ta.change(math.abs(_src)) if _src == 0 _cnt := 0 _cnt else if _chg > 0 _cnt := math.min(5, _cnt + 1) _cnt else if _chg < 0 _cnt := math.max(1, _cnt - 1) _cnt int _return = _src > 0 ? _cnt : -_cnt _return f_c_signal(_gradient) => // int _gradient: gradient level (+5 to -5) from which to derive a color. color _color = _gradient > 0 ? i_c_bull : _gradient < 0 ? i_c_bear : i_c_neutral float _transp = 100 - math.abs(_gradient) * 20 _transp := _transp == 80 ? 75 : _transp color _return = _color == i_c_neutral ? _color : f_colorNew(_color, _transp) _return // ————— Function returning the color used to display a state string in the results. f_c_colorFromRating(_rating) => // float _rating: rating from which to derive a color. color _return = if _rating > LEVEL_STRONG f_colorNew(i_c_bull, 00) else if _rating > LEVEL_WEAK f_colorNew(i_c_bull, 25) else if _rating < -LEVEL_STRONG f_colorNew(i_c_bear, 00) else if _rating < -LEVEL_WEAK f_colorNew(i_c_bear, 25) else i_c_neutral _return // ————— Function returning a string corresponding to the state of a `_rating`. f_textFromRating(_rating) => // float _rating: rating from which to derive a string. string _return = if _rating > LEVEL_STRONG 'Strong Buy' else if _rating > LEVEL_WEAK 'Buy' else if _rating < -LEVEL_STRONG 'Strong Sell' else if _rating < -LEVEL_WEAK 'Sell' else 'Neutral' _return // ————— Function that prints one line at a time in rating results to the right of the last bar. f_print(_txt, _lineNo, _txtColor) => // string _txt : text of the line. // int _lineNo : number of the line (0-2). // color _txtColor: color of the text. var _lbl = label.new(bar_index, 0, '', xloc.bar_index, yloc.price, color(na), label.style_label_left, color.white, textalign=text.align_left) // Create dynamic prefix and suffix containing the appropriate qty of newlines before and after the line, to place it in the correct vertical position. string[] _returnsPrefix = array.new_string(math.max(0, _lineNo - 1), '\n') string[] _returnsSuffix = array.new_string(math.max(0, 4 - _lineNo), '\n') string _prefix = array.join(_returnsPrefix, '') string _suffix = array.join(_returnsSuffix, '') // Update label. if barstate.islast label.set_x(_lbl, bar_index) label.set_text(_lbl, _prefix + _txt + _suffix) label.set_textcolor(_lbl, _txtColor) // ————— Function that triggers alert with `_txt` message when `_cond` is true. // Note that while we call `alert()` with `alert.freq_all`, the moment when alerts will trigger is controlled in the triggering conditions. f_alert(_txt) => alert(_txt, alert.freq_once_per_bar) // ————— Converts current chart timeframe into a float minutes value. f_tfInMinutes() => float _return = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) _return // ————— Returns resolution of _res string timeframe in minutes. f_tfInMinutesFrom(_tf) => // _tf: string timeframe (in `timeframe.period` string format) to convert in float minutes. // Dependency: f_tfInMinutes() float _return = request.security(syminfo.tickerid, _tf, f_tfInMinutes()) _return // } // ———————————————————— Calculations { // ————— Set text of results legends and determine their order from user-selected group of ratings. if barstate.isfirst f_orderSignals(i_calcs) // ————— Calculate ratings. // Determine if HTF is used. var bool htfUsed = i_tf != '' // If HTF is used, ensure chart TF < HTF. bool chartTfIsTooHigh = htfUsed and f_tfInMinutes() >= f_tfInMinutesFrom(i_tf) // Fetch ratings, adjusting series offset with HTF (which never repaints) and user-selected repaint settings (when no HTF is used). Two-stage offsetting is required because `f_ratings()` returns a tuple. int idx1 = htfUsed and barstate.isrealtime ? 1 : 0 int idx2 = i_repaint and not htfUsed or htfUsed and barstate.isrealtime ? 0 : 1 [ratingTot_, ratingMas_, ratingOsc_] = request.security(syminfo.tickerid, i_tf, f_ratings(idx1)) float ratingTot = ratingTot_[idx2] float ratingMas = ratingMas_[idx2] float ratingOsc = ratingOsc_[idx2] // ————— Place ratings in known order. array.set(ratings, 0, ratingTot) array.set(ratings, 1, ratingMas) array.set(ratings, 2, ratingOsc) // User-selected ratings group to display as the signal and whose state always appears on the first line of results. float userRating = array.get(ratings, f_idx(0)) // } // ———————————————————— Plots { // ————— Build signal color. bool condBuy = userRating > LEVEL_WEAK bool condSell = userRating < -LEVEL_WEAK bool condNeutral = not condBuy and not condSell float valsBuy = condBuy ? userRating : 0 float valsSell = condSell ? userRating : 0 int risingBuys = f_countRising(valsBuy) int fallingSells = f_countRising(valsSell) int gradientLvl = condBuy ? risingBuys : condSell ? fallingSells : 0 color c_signal = f_c_signal(gradientLvl) // ————— Print text corresponding to the rating on last bar, with user-selected group always on the first line. // Legends and rating states are printed separately so they align vertically. // Indices into `ratings` and `texts` arrays corresponding to the order in which they need to be displayed, given user selection of which group to use as the main signal. var int idxOfLine1 = f_idx(0) var int idxOfLine2 = f_idx(1) var int idxOfLine3 = f_idx(2) // Display label to the right of last bar. var string COLUMN_PADDING = ' ' if barstate.islast f_print(COLUMN_PADDING + array.get(TEXTS, idxOfLine1) + ': ' + f_textFromRating(array.get(ratings, idxOfLine1)), 1, f_c_colorFromRating(array.get(ratings, idxOfLine1))) f_print(COLUMN_PADDING + array.get(TEXTS, idxOfLine2) + ': ' + f_textFromRating(array.get(ratings, idxOfLine2)), 2, f_c_colorFromRating(array.get(ratings, idxOfLine2))) f_print(COLUMN_PADDING + array.get(TEXTS, idxOfLine3) + ': ' + f_textFromRating(array.get(ratings, idxOfLine3)), 3, f_c_colorFromRating(array.get(ratings, idxOfLine3))) // ———————————————————— Alerts and markers. { // ————— Alerts. // The triggering conditions can only be met in such a way that they never repaint. // If no HTF is used and no-repainting is required, we wait for the bar to close. Otherwise we can trigger at the bar's open because the signal is non-repainting signal. int ensureNoRepaintIdx = not htfUsed and i_repaint ? 1 : 0 bool xUp = i_levelUp != 0 and ta.crossover(userRating, i_levelUp) bool xDn = i_levelDn != 0 and ta.crossunder(userRating, i_levelDn) bool gUp = i_gradLevel != 0 and gradientLvl == i_gradLevel and gradientLvl[1] < i_gradLevel bool gDn = i_gradLevel != 0 and gradientLvl == -i_gradLevel and gradientLvl[1] > -i_gradLevel //////////////// Technical Ratings ENDS ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////// Volatility STARTS///////////////////////////////////////////////////////////////////////////////////////////////// Volatility_Group = "Volatility" //Volatility Calculation volatilityCalculation = ta.tr(true) * 100 / math.abs(low) //Resolution 1 volatilityPercentageRes1 = input.timeframe(defval='1D', title='Volatility Resolution 1', inline='Volatility 1 Inline', group=Volatility_Group) volatilityPercentSec1 = request.security(syminfo.tickerid, volatilityPercentageRes1, volatilityCalculation) volatilityConvertToLive1 = volatilityPercentSec1 - volatilityCalculation volatilityDetector1 = volatilityCalculation + volatilityConvertToLive1 volatilityDetector1Condition = volatilityDetector1 //Resolution 2 volatilityPercentageRes2 = input.timeframe(defval='1W', title='Volatility Resolution 2', inline='Volatility 2 Inline', group=Volatility_Group) volatilityPercentSec2 = request.security(syminfo.tickerid, volatilityPercentageRes2, volatilityCalculation) volatilityConvertToLive2 = volatilityPercentSec2 - volatilityCalculation volatilityDetector2 = volatilityCalculation + volatilityConvertToLive2 volatilityDetector2Condition = volatilityDetector2 //Resolution 3 volatilityPercentageRes3 = input.timeframe(defval='1M', title='Volatility Resolution 3', inline='Volatility 3 Inline', group=Volatility_Group) volatilityPercentSec3 = request.security(syminfo.tickerid, volatilityPercentageRes3, volatilityCalculation) volatilityConvertToLive3 = volatilityPercentSec3 - volatilityCalculation volatilityDetector3 = volatilityCalculation + volatilityConvertToLive3 volatilityDetector3Condition = volatilityDetector3 Volatility = "Volatility (" + str.tostring(volatilityPercentageRes1) + "): " + str.tostring(volatilityDetector1Condition, '#.##') + "%" + " (" + str.tostring(volatilityPercentageRes2) + "): " + str.tostring(volatilityDetector2Condition, '#.##') + "%" + " (" + str.tostring(volatilityPercentageRes3) + "): " + str.tostring(volatilityDetector3Condition, '#.##') + "%" if barstate.islast if chartTfIsTooHigh f_print(COLUMN_PADDING + 'Chart\'s timeframe must be smaller than ' + i_tf, 4, color.red) // Rating states. f_print(COLUMN_PADDING + Volatility, 4, color.teal) //////////////// Volatility ENDS///////////////////////////////////////////////////////////////////////////////////////////////// //////////////// Donchin Channel Ribbon ///////////////////////////////////////////////////////////////////////////////////////////////// dlen = input.int(defval=20, title='Donchian Channel Period', minval=10,group= "Donchian Trend Ribbon") dchannel(len) => float hh = ta.highest(len) float ll = ta.lowest(len) int trend = 0 trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1]) trend dchannelalt(len, maintrend) => float hh = ta.highest(len) float ll = ta.lowest(len) int trend = 0 trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1]) maintrend == 1 ? trend == 1 ? color.new(BuyColor, 15) : color.new(BuyColor, 15) : maintrend == -1 ? trend == -1 ? color.new(SellColor, 20) : color.new(SellColor, 20) : na maintrend = dchannel(dlen) dcColor = dchannelalt(dlen - 1, maintrend) //////////////// Donchin Channel Ribbon ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////// Alpha Trend ///////////////////////////////////////////////////////////////////////////////////////////////// coeff = input.float(1, 'Multiplier', step=0.1,group = 'Alpha Trend') AP = input(14, 'Common Period',group = 'Alpha Trend') ATR = ta.sma(ta.tr, AP) src = input(close) novolumedata = input(title='Change calculation (no volume data)?', defval=false,group = 'Alpha Trend') atUpT = low - ATR * coeff atDownT = high + ATR * coeff AlphaTrend = 0.0 AlphaTrend := (novolumedata ? ta.rsi(src, AP) >= 50 : ta.mfi(hlc3, AP) >= 50) ? atUpT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : atUpT : atDownT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : atDownT ATStrongBuySell = false ATWeakBuySell = false BARAtColor = color.gray if AlphaTrend > AlphaTrend[2] BARAtColor := color.new(BuyColor, 15) ATStrongBuySell := true else BARAtColor := color.new(SellColor, 20) ATStrongBuySell := false if AlphaTrend[1] > AlphaTrend[3] BARAtColor := NeutralColor //color.new(color.gray, 15) ATWeakBuySell := true else BARAtColor = color.yellow ATWeakBuySell := false //////////////// Alpha Trend ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////// Half Trend ///////////////////////////////////////////////////////////////////////////////////////////////// amplitude = input(title='Amplitude', defval=2) channelDeviation = input(title='Channel Deviation', defval=2) showArrows = input(title='Show Arrows', defval=true) showChannels = input(title='Show Channels', defval=true) var int halftrend = 0 var int nextTrend = 0 var float maxLowPrice = nz(low[1], low) var float minHighPrice = nz(high[1], high) var float htup = 0.0 var float htdown = 0.0 float atrHigh = 0.0 float atrLow = 0.0 float arrowUp = na float arrowDown = na atr2 = ta.atr(100) / 2 dev = channelDeviation * atr2 highPrice = high[math.abs(ta.highestbars(amplitude))] lowPrice = low[math.abs(ta.lowestbars(amplitude))] highma = ta.sma(high, amplitude) lowma = ta.sma(low, amplitude) if nextTrend == 1 maxLowPrice := math.max(lowPrice, maxLowPrice) if highma < maxLowPrice and close < nz(low[1], low) halftrend := 1 nextTrend := 0 minHighPrice := highPrice minHighPrice else minHighPrice := math.min(highPrice, minHighPrice) if lowma > minHighPrice and close > nz(high[1], high) halftrend := 0 nextTrend := 1 maxLowPrice := lowPrice maxLowPrice if halftrend == 0 if not na(halftrend[1]) and halftrend[1] != 0 htup := na(htdown[1]) ? htdown : htdown[1] arrowUp := htup - atr2 arrowUp else htup := na(htup[1]) ? maxLowPrice : math.max(maxLowPrice, htup[1]) htup atrHigh := htup + dev atrLow := htup - dev atrLow else if not na(halftrend[1]) and halftrend[1] != 1 htdown := na(htup[1]) ? htup : htup[1] arrowDown := htdown + atr2 arrowDown else htdown := na(htdown[1]) ? minHighPrice : math.min(minHighPrice, htdown[1]) htdown atrHigh := htdown + dev atrLow := htdown - dev atrLow ht = halftrend == 0 ? htup : htdown htBuySignal = not na(arrowUp) and halftrend == 0 and halftrend[1] == 1 htSellSignal = not na(arrowDown) and halftrend == 1 and halftrend[1] == 0 //////////////// Half Trend ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////// Neural Network ///////////////////////////////////////////////////////////////////////////////////////////////// NeuralNetwork = 'Neural Network' price = close//plot(close, title='Close Line', color=color.new(color.blue, 0), display=display.none) //////////////////////////////////////////////////////////////////////////////// //TREND INDICATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //Trend EMA tttradetrend = 'Only place BUY or SELL orders with the direction of the Trend EMA.' tradetrendoption = input.bool(false, title='Only Tade with Trend', tooltip=tttradetrend,group=NeuralNetwork) len111 = input.int(defval=200, minval=0, maxval=2000, title='Trend EMA Length',group=NeuralNetwork) src111 = close out111 = ta.ema(src111, len111) //ma111 = plot(out111, title='EMA 200', linewidth=2, color=color.new(color.blue, 0), offset=0) mabuy = out111 > out111[1] masell = out111 < out111[1] //5 EMAs//////////////////////////////////////////////////////////////////////// len1 = 9 src1 = close out1 = ta.ema(src1, len1) ema1color = out1 > out1[1] ? #00bcd4 : #e91e63 //ema1 = plot(out1, title='EMA 9', linewidth=3, color=color.new(ema1color, 50), offset=0, display=display.none) //fill(price, ema1, title='EMA 9 Fill', color=color.new(ema1color, 90), editable=true) len2 = 21 src2 = close out2 = ta.ema(src2, len2) ema2color = out2 > out2[1] ? #00bcd4 : #e91e63 //ema2 = plot(out2, title='EMA 21', linewidth=3, color=color.new(ema2color, 50), offset=0, display=display.none) //fill(price, ema2, title='EMA 21 Fill', color=color.new(ema2color, 90), editable=true) len3 = 55 src3 = close out3 = ta.ema(src3, len3) ema3color = out3 > out3[1] ? #00bcd4 : #e91e63 //ema3 = plot(out3, title='EMA 55', linewidth=3, color=color.new(ema3color, 50), offset=0, display=display.none) //fill(price, ema3, title='EMA 55 Fill', color=color.new(ema3color, 90), editable=true) len4 = 100 src4 = close out4 = ta.ema(src4, len4) ema4color = out4 > out4[1] ? #00bcd4 : #e91e63 //ema4 = plot(out4, title='EMA 100', linewidth=3, color=color.new(ema4color, 50), offset=0, display=display.none) //fill(price, ema4, title='EMA 100 Fill', color=color.new(ema4color, 90), editable=true) len5 = 200 src5 = close out5 = ta.ema(src5, len5) ema5color = out5 > out5[1] ? #00bcd4 : #e91e63 //ema5 = plot(out5, title='EMA 200', linewidth=3, color=color.new(ema5color, 50), offset=0, display=display.none) //fill(price, ema5, title='EMA 200 Fill', color=color.new(ema5color, 90), editable=true) //Supertrend//////////////////////////////////////////////////////////////////// atrPeriod = 10 factor = 3 [supertrend, direction] = ta.supertrend(factor, atrPeriod) //bodyMiddle = plot((open + close) / 2, display=display.none, title='Body Middle Line') uptrend = direction < 0 and direction[1] > 0[1] ? supertrend : na downtrend = direction > 0 and direction[1] < 0[1] ? supertrend : na //fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false) //fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false) //bullishsupertrend = supertrend < close and supertrend[1] > close //plotshape(uptrend, style=shape.labelup, color=color.green, location=location.belowbar, size=size.large) //HMA/////////////////////////////////////////////////////////////////////////// len6 = 100 src6 = close hma = ta.wma(2 * ta.wma(src6, len6 / 2) - ta.wma(src6, len6), math.floor(math.sqrt(len6))) //hmacolor = close > hma ? #00bcd4 : #e91e63 //plot(hma, title='HMA Line', color=color.new(hmacolor, 25), linewidth=5) //Parabolic SAR///////////////////////////////////////////////////////////////// start = 0.02 increment = 0.01 maximum = 0.2 psarN = ta.sar(start, increment, maximum) //plot(psar, "ParabolicSAR", style=plot.style_circles, color=#ffffff) //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //MOMENTUM INCIDATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //RSI Divergence//////////////////////////////////////////////////////////////// len11 = 14 src11 = close lbR11 = 2 lbL11 = 6 rangeUpper11 = 60 rangeLower11 = 5 plotBull11 = true plotHiddenBull11 = false plotBear11 = true plotHiddenBear11 = false bearColor11 = color.red bullColor11 = color.green hiddenBullColor11 = color.new(color.green, 80) hiddenBearColor11 = color.new(color.red, 80) textColor11 = color.white noneColor11 = color.new(color.white, 100) osc11 = ta.rsi(src11, len11) //plot(osc11, title="RSI", linewidth=2, color=#2962FF) //hline(50, title="Middle Line", color=#787B86, linestyle=hline.style_dotted) //obLevel11 = hline(70, title="Overbought", color=#787B86, linestyle=hline.style_dotted) //osLevel11 = hline(30, title="Oversold", color=#787B86, linestyle=hline.style_dotted) //fill(obLevel11, osLevel11, title="Background", color=color.rgb(33, 150, 243, 90)) plFound11 = na(ta.pivotlow(osc11, lbL11, lbR11)) ? false : true phFound11 = na(ta.pivothigh(osc11, lbL11, lbR11)) ? false : true _inRange11(cond) => bars11 = ta.barssince(cond == true) rangeLower11 <= bars11 and bars11 <= rangeUpper11 //Regular Bullish Divergence //Osc: Higher Low oscHL11 = osc11[lbR11] > ta.valuewhen(plFound11, osc11[lbR11], 1) and _inRange11(plFound11[1]) //Price: Lower Low priceLL11 = low[lbR11] < ta.valuewhen(plFound11, low[lbR11], 1) bullCond11 = plotBull11 and priceLL11 and oscHL11 and plFound11 //plot(plFound11 ? osc11[lbR11] : na, offset=-lbR11, title="Regular Bullish", linewidth=2, color=(bullCond11 ? bullColor11 : noneColor11)) //plotshape(bullCond11 ? osc11[lbR11] : na, offset=-lbR11, title="Regular Bullish Label", text=" Bull ", style=shape.labelup, location=location.absolute, color=bullColor11, textcolor=textColor11) //Hidden Bullish Divergence //Osc: Lower Low oscLL11 = osc11[lbR11] < ta.valuewhen(plFound11, osc11[lbR11], 1) and _inRange11(plFound11[1]) //Price: Higher Low priceHL11 = low[lbR11] > ta.valuewhen(plFound11, low[lbR11], 1) hiddenBullCond11 = plotHiddenBull11 and priceHL11 and oscLL11 and plFound11 //plot(plFound11 ? osc11[lbR11] : na, offset=-lbR11, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond11 ? hiddenBullColor11 : noneColor11)) //plotshape(hiddenBullCond11 ? osc11[lbR11] : na, offset=-lbR11, title="Hidden Bullish Label", text=" H Bull ", style=shape.labelup, location=location.absolute, color=bullColor11, textcolor=textColor11) //Regular Bearish Divergence //Osc: Lower High oscLH11 = osc11[lbR11] < ta.valuewhen(phFound11, osc11[lbR11], 1) and _inRange11(phFound11[1]) //Price: Higher High priceHH11 = high[lbR11] > ta.valuewhen(phFound11, high[lbR11], 1) bearCond11 = plotBear11 and priceHH11 and oscLH11 and phFound11 //plot(phFound11 ? osc11[lbR11] : na, offset=-lbR11, title="Regular Bearish", linewidth=2, color=(bearCond11 ? bearColor11 : noneColor11)) //plotshape(bearCond11 ? osc11[lbR11] : na, offset=-lbR11, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=bearColor11, textcolor=textColor11) //Hidden Bearish Divergence //Osc: Higher High oscHH11 = osc11[lbR11] > ta.valuewhen(phFound11, osc11[lbR11], 1) and _inRange11(phFound11[1]) // Price: Lower High priceLH11 = high[lbR11] < ta.valuewhen(phFound11, high[lbR11], 1) hiddenBearCond11 = plotHiddenBear11 and priceLH11 and oscHH11 and phFound11 //plot(phFound11 ? osc11[lbR11] : na, offset=-lbR11, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond11 ? hiddenBearColor11 : noneColor11)) //plotshape(hiddenBearCond11 ? osc11[lbR11] : na, offset=-lbR11, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=bearColor11, textcolor=textColor11) //MACD Divergence/////////////////////////////////////////////////////////////// fast_length12 = 12 slow_length12 = 26 src12 = close signal_length12 = 9 sma_source12 = 'EMA' sma_signal12 = 'EMA' //Plot colors col_macd12 = #2962FF col_signal12 = #FF6D00 col_grow_above12 = #26A69A col_fall_above12 = #B2DFDB col_grow_below12 = #FFCDD2 col_fall_below12 = #FF5252 //Calculating fast_ma12 = sma_source12 == 'SMA' ? ta.sma(src12, fast_length12) : ta.ema(src12, fast_length12) slow_ma12 = sma_source12 == 'SMA' ? ta.sma(src12, slow_length12) : ta.ema(src12, slow_length12) macd = fast_ma12 - slow_ma12 signal = sma_signal12 == 'SMA' ? ta.sma(macd, signal_length12) : ta.ema(macd, signal_length12) hist = macd - signal //plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above12 : col_fall_above12) : (hist[1] < hist ? col_grow_below12 : col_fall_below12))) //plot(macd, title="MACD", color=col_macd12) //plot(signal, title="Signal", color=col_signal12) donttouchzero12 = true lbR12 = 2 lbL12 = 6 rangeUpper12 = 60 rangeLower12 = 5 plotBull12 = true plotHiddenBull12 = false plotBear12 = true plotHiddenBear12 = false bearColor12 = color.red bullColor12 = color.green hiddenBullColor12 = color.new(color.green, 80) hiddenBearColor12 = color.new(color.red, 80) textColor12 = color.white noneColor12 = color.new(color.white, 100) osc12 = macd plFound12 = na(ta.pivotlow(osc12, lbL12, lbR12)) ? false : true phFound12 = na(ta.pivothigh(osc12, lbL12, lbR12)) ? false : true _inRange12(cond) => bars12 = ta.barssince(cond == true) rangeLower12 <= bars12 and bars12 <= rangeUpper12 //Regular Bullish Divergence //Osc: Higher Low oscHL12 = osc12[lbR12] > ta.valuewhen(plFound12, osc12[lbR12], 1) and _inRange12(plFound12[1]) and osc12[lbR12] < 0 // Price: Lower Low priceLL12 = low[lbR12] < ta.valuewhen(plFound12, low[lbR12], 1) priceHHZero12 = ta.highest(osc12, lbL12 + lbR12 + 5) //plot(priceHHZero,title="priceHHZero",color=color.green) blowzero12 = donttouchzero12 ? priceHHZero12 < 0 : true bullCond12 = plotBull12 and priceLL12 and oscHL12 and plFound12 and blowzero12 //plot(plFound12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bullish", linewidth=2, color=(bullCond12 ? bullColor12 : noneColor12)) //plotshape(bullCond12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bullish Label", text=" Bull ", style=shape.labelup, location=location.absolute, color=bullColor12, textcolor=textColor12) //Hidden Bullish Divergence //Osc: Lower Low oscLL12 = osc12[lbR12] < ta.valuewhen(plFound12, osc12[lbR12], 1) and _inRange12(plFound12[1]) //Price: Higher Low priceHL12 = low[lbR12] > ta.valuewhen(plFound12, low[lbR12], 1) hiddenBullCond12 = plotHiddenBull12 and priceHL12 and oscLL12 and plFound12 //plot(plFound12 ? osc12[lbR12] : na, offset=-lbR12, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond12 ? hiddenBullColor12 : noneColor12)) //plotshape(hiddenBullCond12 ? osc12[lbR12] : na, offset=-lbR12, title="Hidden Bullish Label", text=" H Bull ", style=shape.labelup, location=location.absolute, color=bullColor12, textcolor=textColor12) //Regular Bearish Divergence //Osc: Lower High oscLH12 = osc12[lbR12] < ta.valuewhen(phFound12, osc12[lbR12], 1) and _inRange12(phFound12[1]) and osc12[lbR12] > 0 priceLLZero12 = ta.lowest(osc12, lbL12 + lbR12 + 5) //plot(priceLLZero,title="priceLLZero", color=color.red) bearzero12 = donttouchzero12 ? priceLLZero12 > 0 : true //Price: Higher High priceHH12 = high[lbR12] > ta.valuewhen(phFound12, high[lbR12], 1) bearCond12 = plotBear12 and priceHH12 and oscLH12 and phFound12 and bearzero12 //plot(phFound12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bearish", linewidth=2, color=(bearCond12 ? bearColor12 : noneColor12)) //plotshape(bearCond12 ? osc12[lbR12] : na, offset=-lbR12, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=bearColor12, textcolor=textColor12) //Hidden Bearish Divergence //Osc: Higher High oscHH12 = osc12[lbR12] > ta.valuewhen(phFound12, osc12[lbR12], 1) and _inRange12(phFound12[1]) //Price: Lower High priceLH12 = high[lbR12] < ta.valuewhen(phFound12, high[lbR12], 1) hiddenBearCond12 = plotHiddenBear12 and priceLH12 and oscHH12 and phFound12 //plot(phFound12 ? osc12[lbR12] : na, offset=-lbR12, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond12 ? hiddenBearColor12 : noneColor12)) //plotshape(hiddenBearCond12 ? osc12[lbR12] : na, offset=-lbR12, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=bearColor12, textcolor=textColor12) //Wave Trend Divergence///////////////////////////////////////////////////////// n1W = 9 n2W = 12 apW = hlc3 esaW = ta.ema(ap, n1W) d1W = ta.ema(math.abs(apW - esaW), n1W) ciW = (apW - esaW) / (0.015 * d1W) tciW = ta.ema(ciW, n2W) hlineW = 0 wt1W = tciW wt2W = ta.sma(wt1W, 4) //plot(hline, color=color.gray) //plot(wt1, color=color.white) //plot(wt2, color=color.blue) //Divergence lbR13 = 2 lbL13 = 6 rangeUpper13 = 60 rangeLower13 = 5 plotBull13 = true plotHiddenBull13 = false plotBear13 = true plotHiddenBear13 = false bearColor13 = color.red bullColor13 = color.green hiddenBullColor13 = color.green hiddenBearColor13 = color.red textColor13 = color.white noneColor13 = color.new(color.white, 100) k13 = wt1 d13 = wt2 osc13 = k13 plFound13 = na(ta.pivotlow(osc13, lbL13, lbR13)) ? false : true phFound13 = na(ta.pivothigh(osc13, lbL13, lbR13)) ? false : true _inRange13(cond) => bars13 = ta.barssince(cond == true) rangeLower13 <= bars13 and bars13 <= rangeUpper13 //Regular Bullish //Osc: Higher Low oscHL13 = osc13[lbR13] > ta.valuewhen(plFound13, osc13[lbR13], 1) and _inRange13(plFound13[1]) //Price: Lower Low priceLL13 = low[lbR13] < ta.valuewhen(plFound13, low[lbR13], 1) bullCond13 = plotBull13 and priceLL13 and oscHL13 and plFound13 //plot(plFound13 ? osc13[lbR13] : na, offset=-lbR13, title="Regular Bullish", linewidth=2, color=(bullCond13 ? bullColor13 : noneColor13)) //plotshape(bullCond13 ? osc13[lbR13] : na, offset=-lbR13, title="Regular Bullish Label", text=" Bull ", style=shape.labelup, location=location.absolute, color=bullColor13, textcolor=textColor13) //Hidden Bullish //Osc: Lower Low oscLL13 = osc13[lbR13] < ta.valuewhen(plFound13, osc13[lbR13], 1) and _inRange13(plFound13[1]) //Price: Higher Low priceHL13 = low[lbR13] > ta.valuewhen(plFound13, low[lbR13], 1) hiddenBullCond13 = plotHiddenBull13 and priceHL13 and oscLL13 and plFound13 //plot(plFound13 ? osc13[lbR13] : na, offset=-lbR13, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond13 ? hiddenBullColor13 : noneColor13)) //plotshape(hiddenBullCond13 ? osc13[lbR13] : na, offset=-lbR13, title="Hidden Bullish Label", text=" H Bull ", style=shape.labelup, location=location.absolute, color=bullColor13, textcolor=textColor13) //Regular Bearish //Osc: Lower High oscLH13 = osc13[lbR13] < ta.valuewhen(phFound13, osc13[lbR13], 1) and _inRange13(phFound13[1]) //Price: Higher High priceHH13 = high[lbR13] > ta.valuewhen(phFound13, high[lbR13], 1) bearCond13 = plotBear13 and priceHH13 and oscLH13 and phFound13 //plot(phFound13 ? osc13[lbR13] : na, offset=-lbR13, title="Regular Bearish", linewidth=2, color=(bearCond13 ? bearColor13 : noneColor13)) //plotshape(bearCond13 ? osc13[lbR13] : na, offset=-lbR13, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=bearColor13, textcolor=textColor13) //Hidden Bearish //Osc: Higher High oscHH13 = osc13[lbR13] > ta.valuewhen(phFound13, osc13[lbR13], 1) and _inRange13(phFound13[1]) //Price: Lower High priceLH13 = high[lbR13] < ta.valuewhen(phFound13, high[lbR13], 1) hiddenBearCond13 = plotHiddenBear13 and priceLH13 and oscHH13 and phFound13 //plot(phFound13 ? osc13[lbR13] : na, offset=-lbR13, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond13 ? hiddenBearColor13 : noneColor13)) //plotshape(hiddenBearCond13 ? osc13[lbR13] : na, offset=-lbR13, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=bearColor13, textcolor=textColor13) //Stochastic Divergence///////////////////////////////////////////////////////// periodK14 = 14 smoothK14 = 3 periodD14 = 3 k14 = ta.sma(ta.stoch(close, high, low, periodK14), smoothK14) d14 = ta.sma(k14, periodD14) //plot(k14, title="%K", color=#2962FF) //plot(d14, title="%D", color=#FF6D00) //h0 = hline(80, "Upper Band", color=#787B86) //h1 = hline(20, "Lower Band", color=#787B86) //fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background") //Divergence lbR14 = 2 lbL14 = 6 rangeUpper14 = 60 rangeLower14 = 5 plotBull14 = true plotHiddenBull14 = false plotBear14 = true plotHiddenBear14 = false bearColor14 = color.red bullColor14 = color.green hiddenBullColor14 = color.green hiddenBearColor14 = color.red textColor14 = color.white noneColor14 = color.new(color.white, 100) osc14 = k14 plFound14 = na(ta.pivotlow(osc14, lbL14, lbR14)) ? false : true phFound14 = na(ta.pivothigh(osc14, lbL14, lbR14)) ? false : true _inRange14(cond) => bars14 = ta.barssince(cond == true) rangeLower14 <= bars14 and bars14 <= rangeUpper14 //Regular Bullish //Osc: Higher Low oscHL14 = osc14[lbR14] > ta.valuewhen(plFound14, osc14[lbR14], 1) and _inRange14(plFound14[1]) //Price: Lower Low priceLL14 = low[lbR14] < ta.valuewhen(plFound14, low[lbR14], 1) bullCond14 = plotBull14 and priceLL14 and oscHL14 and plFound14 //plot(plFound14 ? osc14[lbR14] : na, offset=-lbR14, title="Regular Bullish", linewidth=2, color=(bullCond14 ? bullColor14 : noneColor14)) //plotshape(bullCond14 ? osc14[lbR14] : na, offset=-lbR14, title="Regular Bullish Label", text=" Bull ", style=shape.labelup, location=location.absolute, color=bullColor14, textcolor=textColor14) //Hidden Bullish //Osc: Lower Low oscLL14 = osc14[lbR14] < ta.valuewhen(plFound14, osc14[lbR14], 1) and _inRange14(plFound14[1]) //Price: Higher Low priceHL14 = low[lbR14] > ta.valuewhen(plFound14, low[lbR14], 1) hiddenBullCond14 = plotHiddenBull14 and priceHL14 and oscLL14 and plFound14 //plot(plFound14 ? osc14[lbR14] : na, offset=-lbR14, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond14 ? hiddenBullColor14 : noneColor14)) //plotshape(hiddenBullCond14 ? osc14[lbR14] : na, offset=-lbR14, title="Hidden Bullish Label", text=" H Bull ", style=shape.labelup, location=location.absolute, color=bullColor14, textcolor=textColor14) //Regular Bearish //Osc: Lower High oscLH14 = osc14[lbR14] < ta.valuewhen(phFound14, osc14[lbR14], 1) and _inRange14(phFound14[1]) //Price: Higher High priceHH14 = high[lbR14] > ta.valuewhen(phFound14, high[lbR14], 1) bearCond14 = plotBear14 and priceHH14 and oscLH14 and phFound14 //plot(phFound14 ? osc14[lbR14] : na, offset=-lbR14, title="Regular Bearish", linewidth=2, color=(bearCond14 ? bearColor14 : noneColor14)) //plotshape(bearCond14 ? osc14[lbR14] : na, offset=-lbR14, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=bearColor14, textcolor=textColor14) //Hidden Bearish //Osc: Higher High oscHH14 = osc14[lbR14] > ta.valuewhen(phFound14, osc14[lbR14], 1) and _inRange14(phFound14[1]) //Price: Lower High priceLH14 = high[lbR14] < ta.valuewhen(phFound14, high[lbR14], 1) hiddenBearCond14 = plotHiddenBear14 and priceLH14 and oscHH14 and phFound14 //plot(phFound14 ? osc14[lbR14] : na, offset=-lbR14, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond14 ? hiddenBearColor14 : noneColor14)) //plotshape(hiddenBearCond14 ? osc14[lbR14] : na, offset=-lbR14, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=bearColor14, textcolor=textColor14) //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //VOLATILITY INDICATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //Bollinger Bands/////////////////////////////////////////////////////////////// length1 = 20 src7 = close mult1 = 2.0 basis = ta.sma(src7, length1) devW = mult1 * ta.stdev(src7, length1) upper = basis + devW lower = basis - devW offset = 0 //plot(basis, "Basis", color=#FF6D00, offset = offset) //p1 = plot(upper, "Upper", color=#2962FF, offset = 0) //p2 = plot(lower, "Lower", color=#2962FF, offset = 0) //fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95)) //Average True Range ///////////////////////////////////////////////// length2 = 1 mult2 = 1.85 showLabels = true useClose = false highlightState = false atrN = mult2 * ta.atr(length2) longStop = (useClose ? ta.highest(close, length2) : ta.highest(length2)) - atrN longStopPrev = nz(longStop[1], longStop) longStop := close[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop shortStop = (useClose ? ta.lowest(close, length2) : ta.lowest(length2)) + atrN shortStopPrev = nz(shortStop[1], shortStop) shortStop := close[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop var int dirN = 1 dirN := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dirN var color longColor = color.green var color shortColor = color.red buySignal = dirN == 1 and dirN[1] == -1 //plotshape(buySignal and showLabels ? longStop : na, title="Gold Buy", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=longColor, textcolor=color.new(color.white, 0)) sellSignal = dirN == -1 and dirN[1] == 1 //plotshape(sellSignal and showLabels ? shortStop : na, title="Gold Sell", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.new(color.white, 0)) //Relative Volatility Index Divergence////////////////////////////////////////// length15 = 12 src15 = close len15 = 14 stddev15 = ta.stdev(src15, length15) upper15 = ta.ema(ta.change(src15) <= 0 ? 0 : stddev15, len15) lower15 = ta.ema(ta.change(src15) > 0 ? 0 : stddev15, len15) rvi = upper15 / (upper15 + lower15) * 100 //h0 = hline(80, "Upper Band", color=#787B86) //h1 = hline(20, "Lower Band", color=#787B86) //fill(h0, h1, color=color.rgb(126, 87, 194, 90), title="Background") //plot(rvi15, title="RVI", color=#7E57C2, offset = offset) //Divergence lbR15 = 2 lbL15 = 6 rangeUpper15 = 60 rangeLower15 = 5 plotBull15 = true plotHiddenBull15 = false plotBear15 = true plotHiddenBear15 = false bearColor15 = color.red bullColor15 = color.green hiddenBullColor15 = color.green hiddenBearColor15 = color.red textColor15 = color.white noneColor15 = color.new(color.white, 100) d15 = rvi osc15 = d15 plFound15 = na(ta.pivotlow(osc15, lbL15, lbR15)) ? false : true phFound15 = na(ta.pivothigh(osc15, lbL15, lbR15)) ? false : true _inRange15(cond) => bars15 = ta.barssince(cond == true) rangeLower15 <= bars15 and bars15 <= rangeUpper15 //Regular Bullish //Osc: Higher Low oscHL15 = osc15[lbR15] > ta.valuewhen(plFound15, osc15[lbR15], 1) and _inRange15(plFound15[1]) //Price: Lower Low priceLL15 = low[lbR15] < ta.valuewhen(plFound15, low[lbR15], 1) bullCond15 = plotBull15 and priceLL15 and oscHL15 and plFound15 //plot(plFound15 ? osc15[lbR15] : na, offset=-lbR15, title="Regular Bullish", linewidth=2, color=(bullCond15 ? bullColor15 : noneColor15)) //plotshape(bullCond15 ? osc15[lbR15] : na, offset=-lbR15, title="Regular Bullish Label", text=" Bull ", style=shape.labelup, location=location.absolute, color=bullColor15, textcolor=textColor15) //Hidden Bullish //Osc: Lower Low oscLL15 = osc15[lbR15] < ta.valuewhen(plFound15, osc15[lbR15], 1) and _inRange15(plFound15[1]) //Price: Higher Low priceHL15 = low[lbR15] > ta.valuewhen(plFound15, low[lbR15], 1) hiddenBullCond15 = plotHiddenBull15 and priceHL15 and oscLL15 and plFound15 //plot(plFound15 ? osc15[lbR15] : na, offset=-lbR15, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond15 ? hiddenBullColor15 : noneColor15)) //plotshape(hiddenBullCond15 ? osc15[lbR15] : na, offset=-lbR15, title="Hidden Bullish Label", text=" H Bull ", style=shape.labelup, location=location.absolute, color=bullColor15, textcolor=textColor15) //Regular Bearish //Osc: Lower High oscLH15 = osc15[lbR15] < ta.valuewhen(phFound15, osc15[lbR15], 1) and _inRange15(phFound15[1]) //Price: Higher High priceHH15 = high[lbR15] > ta.valuewhen(phFound15, high[lbR15], 1) bearCond15 = plotBear15 and priceHH15 and oscLH15 and phFound15 //plot(phFound15 ? osc15[lbR15] : na, offset=-lbR15, title="Regular Bearish", linewidth=2, color=(bearCond15 ? bearColor15 : noneColor15)) //plotshape(bearCond15 ? osc15[lbR15] : na, offset=-lbR15, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=bearColor15, textcolor=textColor15) //Hidden Bearish //Osc: Higher High oscHH15 = osc15[lbR15] > ta.valuewhen(phFound15, osc15[lbR15], 1) and _inRange15(phFound15[1]) //Price: Lower High priceLH15 = high[lbR15] < ta.valuewhen(phFound15, high[lbR15], 1) hiddenBearCond15 = plotHiddenBear15 and priceLH15 and oscHH15 and phFound15 //plot(phFound15 ? osc15[lbR15] : na, offset=-lbR15, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond15 ? hiddenBearColor15 : noneColor15)) //plotshape(hiddenBearCond15 ? osc15[lbR15] : na, offset=-lbR15, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=bearColor15, textcolor=textColor15) //Support and Resistance//////////////////////////////////////////////////////// left16 = 200 right16 = 20 quick_right16 = 5 src16 = 'Close' pivothigh_1 = ta.pivothigh(close, left16, right16) pivothigh_2 = ta.pivothigh(high, left16, right16) pivot_high16 = src16 == 'Close' ? pivothigh_1 : pivothigh_2 pivotlow_1 = ta.pivotlow(close, left16, right16) pivotlow_2 = ta.pivotlow(low, left16, right16) pivot_lows16 = src16 == 'Close' ? pivotlow_1 : pivotlow_2 pivothigh_3 = ta.pivothigh(close, left16, quick_right16) pivothigh_4 = ta.pivothigh(high, left16, quick_right16) quick_pivot_high16 = src16 == 'Close' ? pivothigh_3 : pivothigh_4 pivotlow_3 = ta.pivotlow(close, left16, quick_right16) pivotlow_4 = ta.pivotlow(low, left16, quick_right16) quick_pivot_lows16 = src16 == 'Close' ? pivotlow_3 : pivotlow_4 valuewhen_1 = ta.valuewhen(quick_pivot_high16, close[quick_right16], 0) valuewhen_2 = ta.valuewhen(quick_pivot_high16, high[quick_right16], 0) level1 = src16 == 'Close' ? valuewhen_1 : valuewhen_2 valuewhen_3 = ta.valuewhen(quick_pivot_lows16, close[quick_right16], 0) valuewhen_4 = ta.valuewhen(quick_pivot_lows16, low[quick_right16], 0) level2 = src16 == 'Close' ? valuewhen_3 : valuewhen_4 valuewhen_5 = ta.valuewhen(pivot_high16, close[right16], 0) valuewhen_6 = ta.valuewhen(pivot_high16, high[right16], 0) level3 = src16 == 'Close' ? valuewhen_5 : valuewhen_6 valuewhen_7 = ta.valuewhen(pivot_lows16, close[right16], 0) valuewhen_8 = ta.valuewhen(pivot_lows16, low[right16], 0) level4 = src16 == 'Close' ? valuewhen_7 : valuewhen_8 valuewhen_9 = ta.valuewhen(pivot_high16, close[right16], 1) valuewhen_10 = ta.valuewhen(pivot_high16, high[right16], 1) level5 = src16 == 'Close' ? valuewhen_9 : valuewhen_10 valuewhen_11 = ta.valuewhen(pivot_lows16, close[right16], 1) valuewhen_12 = ta.valuewhen(pivot_lows16, low[right16], 1) level6 = src16 == 'Close' ? valuewhen_11 : valuewhen_12 valuewhen_13 = ta.valuewhen(pivot_high16, close[right16], 2) valuewhen_14 = ta.valuewhen(pivot_high16, high[right16], 2) level7 = src16 == 'Close' ? valuewhen_13 : valuewhen_14 valuewhen_15 = ta.valuewhen(pivot_lows16, close[right16], 2) valuewhen_16 = ta.valuewhen(pivot_lows16, low[right16], 2) level8 = src16 == 'Close' ? valuewhen_15 : valuewhen_16 level1_col = close >= level1 ? color.green : color.red level2_col = close >= level2 ? color.green : color.red level3_col = close >= level3 ? color.green : color.red level4_col = close >= level4 ? color.green : color.red level5_col = close >= level5 ? color.green : color.red level6_col = close >= level6 ? color.green : color.red level7_col = close >= level7 ? color.green : color.red level8_col = close >= level8 ? color.green : color.red length17 = 9 src17 = close hma17 = ta.wma(2 * ta.wma(src17, length17 / 2) - ta.wma(src17, length17), math.floor(math.sqrt(length17))) buy1 = hma17 > level1 and hma17[1] < level1[1] and close > close[2] buy2 = hma17 > level2 and hma17[1] < level2[1] and close > close[2] buy3 = hma17 > level3 and hma17[1] < level3[1] and close > close[2] buy4 = hma17 > level4 and hma17[1] < level4[1] and close > close[2] buy5 = hma17 > level5 and hma17[1] < level5[1] and close > close[2] buy6 = hma17 > level6 and hma17[1] < level6[1] and close > close[2] buy7 = hma17 > level7 and hma17[1] < level7[1] and close > close[2] buy8 = hma17 > level8 and hma17[1] < level8[1] and close > close[2] sell1 = hma17 < level1 and hma17[1] > level1[1] and close < close[2] sell2 = hma17 < level2 and hma17[1] > level2[1] and close < close[2] sell3 = hma17 < level3 and hma17[1] > level3[1] and close < close[2] sell4 = hma17 < level4 and hma17[1] > level4[1] and close < close[2] sell5 = hma17 < level5 and hma17[1] > level5[1] and close < close[2] sell6 = hma17 < level6 and hma17[1] > level6[1] and close < close[2] sell7 = hma17 < level7 and hma17[1] > level7[1] and close < close[2] sell8 = hma17 < level8 and hma17[1] > level8[1] and close < close[2] //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //VOLUME INDICATORS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //OBV Divergence//////////////////////////////////////////////////////////////// len18 = 20 src18 = close lbR18 = 2 lbL18 = 6 rangeUpper18 = 60 rangeLower18 = 5 plotBull18 = true plotHiddenBull18 = false plotBear18 = true plotHiddenBear18 = false bearColor18 = color.red bullColor18 = color.green hiddenBullColor18 = color.green hiddenBearColor18 = color.new(color.red, 80) textColor18 = color.white noneColor18 = color.new(color.white, 100) csrc = ta.change(src18) obv1(src18) => ta.cum(ta.change(src18) > 0 ? volume : csrc < 0 ? -volume : 0 * volume) os = obv1(src18) obv_osc = os - ta.ema(os, len18) obc_color = obv_osc > 0 ? color.green : color.red //plot(obv_osc, color=obc_color, style=plot.style_line,title="OBV-Points", linewidth=2) //plot(obv_osc, color=color.silver, transp=70, title="OBV", style=plot.style_area) //hline(0) plFound18 = na(ta.pivotlow(obv_osc, lbL18, lbR18)) ? false : true phFound18 = na(ta.pivothigh(obv_osc, lbL18, lbR18)) ? false : true _inRange(cond) => bars = ta.barssince(cond == true) rangeLower18 <= bars and bars <= rangeUpper18 // Regular Bullish // Osc: Higher Low oscHL18 = obv_osc[lbR18] > ta.valuewhen(plFound18, obv_osc[lbR18], 1) and _inRange(plFound18[1]) // Price: Lower Low priceLL18 = low[lbR18] < ta.valuewhen(plFound18, low[lbR18], 1) bullCond18 = plotBull18 and priceLL18 and oscHL18 and plFound18 //plot(plFound18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Regular Bullish",linewidth=2,color=(bullCond18 ? bullColor18 : noneColor18)) //plotshape(bullCond18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Regular Bullish Label",text=" Bull ",style=shape.labelup,location=location.absolute,color=bullColor18,textcolor=textColor18) // Hidden Bullish // Osc: Lower Low oscLL18 = obv_osc[lbR18] < ta.valuewhen(plFound18, obv_osc[lbR18], 1) and _inRange(plFound18[1]) // Price: Higher Low priceHL18 = low[lbR18] > ta.valuewhen(plFound18, low[lbR18], 1) hiddenBullCond18 = plotHiddenBull18 and priceHL18 and oscLL18 and plFound18 //plot(plFound18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Hidden Bullish",linewidth=2,color=(hiddenBullCond18 ? hiddenBullColor18 : noneColor18)) //plotshape(hiddenBullCond18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Hidden Bullish Label",text=" H Bull ",style=shape.labelup,location=location.absolute,color=bullColor18,textcolor=textColor18) // Regular Bearish // Osc: Lower High oscLH18 = obv_osc[lbR18] < ta.valuewhen(phFound18, obv_osc[lbR18], 1) and _inRange(phFound18[1]) // Price: Higher High priceHH18 = high[lbR18] > ta.valuewhen(phFound18, high[lbR18], 1) bearCond18 = plotBear18 and priceHH18 and oscLH18 and phFound18 //plot(phFound18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Regular Bearish",linewidth=2,color=(bearCond18 ? bearColor18 : noneColor18)) //plotshape(bearCond18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Regular Bearish Label",text=" Bear ",style=shape.labeldown,location=location.absolute,color=bearColor18,textcolor=textColor18) // Hidden Bearish // Osc: Higher High oscHH18 = obv_osc[lbR18] > ta.valuewhen(phFound18, obv_osc[lbR18], 1) and _inRange(phFound18[1]) // Price: Lower High priceLH18 = high[lbR18] < ta.valuewhen(phFound18, high[lbR18], 1) hiddenBearCond18 = plotHiddenBear18 and priceLH18 and oscHH18 and phFound18 //plot(phFound18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Hidden Bearish",linewidth=2,color=(hiddenBearCond18 ? hiddenBearColor18 : noneColor18)) //plotshape(hiddenBearCond18 ? obv_osc[lbR18] : na,offset=-lbR18,title="Hidden Bearish Label",text=" H Bear ",style=shape.labeldown,location=location.absolute,color=bearColor18,textcolor=textColor18) //Chaikin Money Flow//////////////////////////////////////////////////////////// length19 = 50 ad19 = close == high and close == low or high == low ? 0 : (2 * close - low - high) / (high - low) * volume cmf = math.sum(ad19, length19) / math.sum(volume, length19) //plot(cmf, color=#43A047, title="MF") //hline(0, color=#787B86, title="Zero", linestyle=hline.style_dashed) //VWAP////////////////////////////////////////////////////////////////////////// computeVWAP(src20, isNewPeriod, stDevMultiplier) => var float sumSrcVol = na var float sumVol = na var float sumSrcSrcVol = na sumSrcVol := isNewPeriod ? src20 * volume : src20 * volume + sumSrcVol[1] sumVol := isNewPeriod ? volume : volume + sumVol[1] // sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation sumSrcSrcVol := isNewPeriod ? volume * math.pow(src20, 2) : volume * math.pow(src20, 2) + sumSrcSrcVol[1] _vwap = sumSrcVol / sumVol variance = sumSrcSrcVol / sumVol - math.pow(_vwap, 2) variance := variance < 0 ? 0 : variance stDev = math.sqrt(variance) lowerBand20 = _vwap - stDev * stDevMultiplier upperBand20 = _vwap + stDev * stDevMultiplier [_vwap, lowerBand20, upperBand20] hideonDWM = false var anchor = 'Session' src20 = hlc3 offset20 = 0 showBands = true stdevMult = 1.0 timeChange(period) => ta.change(time(period)) new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on) new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on) new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on) tcD = timeChange('D') tcW = timeChange('W') tcM = timeChange('M') tc3M = timeChange('3M') tc12M = timeChange('12M') isNewPeriod = anchor == 'Earnings' ? new_earnings : anchor == 'Dividends' ? new_dividends : anchor == 'Splits' ? new_split : na(src20[1]) ? true : anchor == 'Session' ? tcD : anchor == 'Week' ? tcW : anchor == 'Month' ? tcM : anchor == 'Quarter' ? tc3M : anchor == 'Year' ? tc12M : anchor == 'Decade' ? tc12M and year % 10 == 0 : anchor == 'Century' ? tc12M and year % 100 == 0 : false float vwapValue = na float std = na float upperBandValue = na float lowerBandValue = na if not(hideonDWM and timeframe.isdwm) [_vwap, bottom, top] = computeVWAP(src20, isNewPeriod, stdevMult) vwapValue := _vwap upperBandValue := showBands ? top : na lowerBandValue := showBands ? bottom : na lowerBandValue //plot(vwapValue, title="VWAP", color=#2962FF, offset=offset) //upperBand20 = plot(upperBandValue, title="Upper Band", color=color.green, offset=offset) //lowerBand20 = plot(lowerBandValue, title="Lower Band", color=color.green, offset=offset) //fill(upperBand20, lowerBand20, title="Bands Fill", color= showBands ? color.new(color.green, 95) : na) //Candle Patterns/////////////////////////////////////////////////////////////// //Bullish Engulfing C_DownTrend = true C_UpTrend = true var trendRule1 = 'SMA50' var trendRule2 = 'SMA50, SMA200' var trendRule = trendRule1 if trendRule == trendRule1 priceAvg = ta.sma(close, 50) C_DownTrend := close < priceAvg C_UpTrend := close > priceAvg C_UpTrend if trendRule == trendRule2 sma200 = ta.sma(close, 200) sma50 = ta.sma(close, 50) C_DownTrend := close < sma50 and sma50 < sma200 C_UpTrend := close > sma50 and sma50 > sma200 C_UpTrend C_Len = 14 // ema depth for bodyAvg C_ShadowPercent = 5.0 // size of shadows C_ShadowEqualsPercent = 100.0 C_DojiBodyPercent = 5.0 C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body C_BodyHi = math.max(close, open) C_BodyLo = math.min(close, open) C_Body = C_BodyHi - C_BodyLo C_BodyAvg = ta.ema(C_Body, C_Len) C_SmallBody = C_Body < C_BodyAvg C_LongBody = C_Body > C_BodyAvg C_UpShadow = high - C_BodyHi C_DnShadow = C_BodyLo - low C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body C_WhiteBody = open < close C_BlackBody = open > close C_Range = high - low C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo C_BodyMiddle = C_Body / 2 + C_BodyLo C_ShadowEquals = C_UpShadow == C_DnShadow or math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100 < C_ShadowEqualsPercent and math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100 < C_ShadowEqualsPercent C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 C_Doji = C_IsDojiBody and C_ShadowEquals patternLabelPosLow = low - ta.atr(30) * 0.6 patternLabelPosHigh = high + ta.atr(30) * 0.6 label_color_bullish = color.blue C_EngulfingBullishNumberOfCandles = 2 C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and C_SmallBody[1] and close >= open[1] and open <= close[1] and (close > open[1] or open < close[1]) if C_EngulfingBullish var ttBullishEngulfing = 'Engulfing\nAt the end of a given downward trend, there will most likely be a reversal pattern. To distinguish the first day, this candlestick pattern uses a small body, followed by a day where the candle body fully overtakes the body from the day before, and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to completely overtake the range (high to low), rather only the open and the close.' ttBullishEngulfing //label.new(bar_index, patternLabelPosLow, text="BE", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishEngulfing) //bgcolor(highest(C_EngulfingBullish?1:0, C_EngulfingBullishNumberOfCandles)!=0 ? color.blue : na, offset=-(C_EngulfingBullishNumberOfCandles-1)) //Bearish Engulfing label_color_bearish = color.red C_EngulfingBearishNumberOfCandles = 2 C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and C_SmallBody[1] and close <= open[1] and open >= close[1] and (close < open[1] or open > close[1]) if C_EngulfingBearish var ttBearishEngulfing = 'Engulfing\nAt the end of a given uptrend, a reversal pattern will most likely appear. During the first day, this candlestick pattern uses a small body. It is then followed by a day where the candle body fully overtakes the body from the day before it and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to fully overtake the range (high to low), rather only the open and the close.' ttBearishEngulfing //label.new(bar_index, patternLabelPosHigh, text="BE", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEngulfing) //bgcolor(highest(C_EngulfingBearish?1:0, C_EngulfingBearishNumberOfCandles)!=0 ? color.red : na, offset=-(C_EngulfingBearishNumberOfCandles-1)) //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //SIGNAL SCORES▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //Alternate Signals Option alternatesignals = input(title='Alternate Signals', defval=true) //Position Options longpositions = input(title='Long Positions', defval=false) shortpositions = input(title='Short Positions', defval=false) //Stop Loss Warning Option stoplosspercent = input.float(title='Stop Loss Warning (%)', defval=-2.5, minval=-50, maxval=0, step=.1) / 100 //Score Requirements stronglongscore = input.int(defval=10, minval=0, maxval=1000, title='Required Strong LONG Score') strongshortscore = input.int(defval=10, minval=0, maxval=1000, title='Required Strong SHORT Score') weaklongscore = input.int(defval=8, minval=0, maxval=1000, title='Required Weak LONG Score') weakshortscore = input.int(defval=8, minval=0, maxval=1000, title='Required Weak SHORT Score') //Trend Indicator Signals/////////////////////////////////////////////////////// //EMA Signals emadirectionimportance = input.int(defval=2, minval=0, maxval=100, title='EMA Trend Direction Importance') emadirectionup = out5 < close ? emadirectionimportance : 0 emadirectionupstatus = emadirectionup ? 'EMA Trend Direction Up' : na emadirectiondown = out5 > close ? emadirectionimportance : 0 emadirectiondownstatus = emadirectiondown ? 'EMA Trend Direction Down' : na emapushpullimportance = input.int(defval=1, minval=0, maxval=100, title='EMA Pressure Importance') emapushup = out2 > out2[1] and out3 < out3[1] ? emapushpullimportance : 0 emapushupstatus = emapushup ? 'EMA Pushing Up' : na emapulldown = out2 < out2[1] and out3 > out3[1] ? emapushpullimportance : 0 emapulldownstatus = emapulldown ? 'EMA Pulling Down' : na //Super Trend Signals supertrenddirimportance = input.int(defval=2, minval=0, maxval=100, title='SuperTrend Direction Importance') supertrendup = direction < 0 ? supertrenddirimportance : 0 supertrendupstatus = supertrendup ? 'SuperTrend Direction Up' : na supertrenddown = direction > 0 ? supertrenddirimportance : 0 supertrenddownstatus = supertrenddown ? 'SuperTrend Direction Down' : na supertrendrevimportance = input.int(defval=4, minval=0, maxval=100, title='SuperTrend Reversal Importance') supertrendrevup = direction < 0 and direction[1] > 0[1] ? supertrendrevimportance : 0 supertrendrevupstatus = supertrendrevup ? 'SuperTrend Reversed Up' : na supertrendrevdown = direction > 0 and direction[1] < 0[1] ? supertrendrevimportance : 0 supertrendrevdownstatus = supertrendrevdown ? 'SuperTrend Reversed Down' : na //Parabolic SAR Signals psardirimportance = input.int(defval=0, minval=0, maxval=100, title='Parabolic SAR Direction Importance') psardirup = psar < close ? psardirimportance : 0 psardirupstatus = psardirup ? 'PSAR Direction Up' : na psardirdown = psar > close ? psardirimportance : 0 psardirdownstatus = psardirdown ? 'PSAR Direction Down' : na psarrevimportance = input.int(defval=3, minval=0, maxval=100, title='Parabolic SAR Reversal Importance') psarrevup = psar < close and psar[1] > close[1] ? psarrevimportance : 0 psarrevupstatus = psarrevup ? 'PSAR Reversed Up' : na psarrevdown = psar > close and psar[1] < close ? psarrevimportance : 0 psarrevdownstatus = psarrevdown ? 'PSAR Reversed Down' : na //HMA Signals hmacloseposimportance = input.int(defval=1, minval=0, maxval=100, title='HMA Trend Direction Importance') hmacloseposup = hma < close and hma[1] ? hmacloseposimportance : 0 hmacloseposupstatus = hmacloseposup ? 'Price Crossed Over HMA' : na hmacloseposdown = hma > close ? hmacloseposimportance : 0 hmacloseposdownstatus = hmacloseposdown ? 'Price Crossed Under HMA' : na hmapivotimportance = input.int(defval=4, minval=0, maxval=100, title='HMA Pivot Importance') hmapivotup = hma > hma[1] and hma[1] < hma[2] ? hmapivotimportance : 0 hmapivotupstatus = hmapivotup ? 'HMA Pivot Up' : na hmapivotdown = hma < hma[1] and hma[1] > hma[2] ? hmapivotimportance : 0 hmapivotdownstatus = hmapivotdown ? 'HMA Pivot Down' : na //Momentum Indicator Signals//////////////////////////////////////////////////// //RSI Signals rsidivimportance = input.int(defval=4, minval=0, maxval=100, title='RSI Divergence Importance') rsidivup = bullCond11 or bullCond11[1] or bullCond11[2] ? rsidivimportance : 0 rsidivupstatus = rsidivup ? 'Bullish RSI Divergence' : na rsidivdown = bearCond11 or bearCond11[1] or bearCond11[2] ? rsidivimportance : 0 rsidivdownstatus = rsidivdown ? 'Bearish RSI Divergence' : na rsilevelimportance = input.int(defval=0, minval=0, maxval=100, title='RSI Level Importance') rsioversold = osc11 < 30 ? rsilevelimportance : 0 rsioversoldstatus = rsioversold ? 'RSI Oversold' : na rsioverbought = osc11 > 70 ? rsilevelimportance : 0 rsioverboughtstatus = rsioverbought ? 'RSI Overbought' : na rsidirectionimportance = input.int(defval=1, minval=0, maxval=100, title='RSI Cross 50-Line Importance') rsicrossup = osc11 > 50 and osc11[1] < 50 or osc11 > 50 and osc11[2] < 50 ? rsidirectionimportance : 0 rsicrossupstatus = rsicrossup ? 'RSI Crossed 50-Line Up' : na rsicrossdown = osc11 < 50 and osc11[1] > 50 or osc11 < 50 and osc11[2] > 50 ? rsidirectionimportance : 0 rsicrossdownstatus = rsicrossdown ? 'RSI Crossed 50-Line Down' : na //MACD Signals macddivimportance = input.int(defval=2, minval=0, maxval=100, title='MACD Divergence Importance') macddivup = bullCond12 or bullCond12[1] or bullCond12[2] ? macddivimportance : 0 macddivupstatus = macddivup ? 'Bullish MACD Divergence' : na macddivdown = bearCond12 or bearCond12[1] or bearCond12[2] ? macddivimportance : 0 macddivdownstatus = macddivdown ? 'Bearish MACD Divergence' : na histpivotimportance = input.int(defval=1, minval=0, maxval=100, title='MACD Histogram Pivot Importance') histpivotup = hist > hist[1] and hist[1] < hist[2] and hist < 0 ? histpivotimportance : 0 histpivotupstatus = histpivotup ? 'MACD Histogram Pivot Up' : na histpivotdown = hist < hist[1] and hist[1] > hist[2] and hist > 0 ? histpivotimportance : 0 histpivotdownstatus = histpivotdown ? 'MACD Histogram Pivot Down' : na macdcrosssignalimportance = input.int(defval=1, minval=0, maxval=100, title='MACD Cross Signal Importance') macdcrosssignalup = macd > signal and macd[1] < signal[1] and signal < 0 ? macdcrosssignalimportance : 0 macdcrosssignalupstatus = macdcrosssignalup ? 'MACD Crossed Signal Up' : na macdcrosssignaldown = macd < signal and macd[1] > signal[1] and signal > 0 ? macdcrosssignalimportance : 0 macdcrosssignaldownstatus = macdcrosssignaldown ? 'MACD Crossed Signal Down' : na //WaveTrend Signals wtdivimportance = input.int(defval=1, minval=0, maxval=100, title='WaveTrend Divergence Importance') wtdivup = bullCond13 or bullCond13[1] or bullCond13[2] ? wtdivimportance : 0 wtdivupstatus = wtdivup ? 'Bullish WaveTrend Divergence' : na wtdivdown = bearCond13 or bearCond13[1] or bearCond13[2] ? wtdivimportance : 0 wtdivdownstatus = wtdivdown ? 'Bearish WaveTrend Divergence' : na wtcrosssignalimportance = input.int(defval=4, minval=0, maxval=100, title='WaveTrend Cross Signal Importance') wtcrosssignalup = wt1 > wt2 and wt1[1] < wt2[1] and wt2 < -10 ? wtcrosssignalimportance : 0 wtcrosssignalupstatus = wtcrosssignalup ? 'WaveTrend Crossed Signal Up' : na wtcrosssignaldown = wt1 < wt2 and wt1[1] > wt2[1] and wt2 > 10 ? wtcrosssignalimportance : 0 wtcrosssignaldownstatus = wtcrosssignaldown ? 'WaveTrend Crossed Signal Down' : na //Stochastic Signals sdivimportance = input.int(defval=1, minval=0, maxval=100, title='Stochastic Divergence Importance') sdivup = bullCond14 or bullCond14[1] or bullCond14[2] ? sdivimportance : 0 sdivupstatus = sdivup ? 'Bullish Stoch Divergence' : na sdivdown = bearCond14 or bearCond14[1] or bearCond14[2] ? sdivimportance : 0 sdivdownstatus = sdivdown ? 'Bearish Stoch Divergence' : na scrosssignalimportance = input.int(defval=1, minval=0, maxval=100, title='Stoch Cross Signal Importance') scrosssignalup = k14 > d14 and k14[1] < d14[1] ? scrosssignalimportance : 0 scrosssignalupstatus = scrosssignalup ? 'Stoch Crossed Signal Up' : na scrosssignaldown = k14 < d14 and k14[1] > d14[1] ? scrosssignalimportance : 0 scrosssignaldownstatus = scrosssignaldown ? 'Stoch Crossed Signal Down' : na //Volatility Indicators///////////////////////////////////////////////////////// //Bollinger Bands Signals bbcontimportance = input.int(defval=2, minval=0, maxval=100, title='BollingerBands Contact Importance') bbcontup = close < lower ? bbcontimportance : 0 bbcontupstatus = bbcontup ? 'Price Contacted Lower BB' : na bbcontdown = open > upper ? bbcontimportance : 0 bbcontdownstatus = bbcontdown ? 'Price Contacted Upper BB' : na //Average True Range Signals atrrevimportance = input.int(defval=1, minval=0, maxval=100, title='ATR Reversal Importance') atrrevup = buySignal ? atrrevimportance : 0 atrrevupstatus = atrrevup ? 'ATR Reversed Up' : na atrrevdown = sellSignal ? atrrevimportance : 0 atrrevdownstatus = atrrevdown ? 'ATR Reversed Down' : na //Relative Volatility Index Signals rviposimportance = input.int(defval=3, minval=0, maxval=100, title='RVI Position Importance') rviposup = rvi > 25 and rvi[1] < 40 ? rviposimportance : 0 rviposupstatus = rviposup ? 'RVI Volatility Increasing' : na rviposdown = rvi < 75 and rvi[1] > 60 ? rviposimportance : 0 rviposdownstatus = rviposdown ? 'RVI Volatility Decreasing' : na rvidivimportance = input.int(defval=4, minval=0, maxval=100, title='RVI Divergence Importance') rvidivup = bullCond15 or bullCond15[1] or bullCond15[2] ? rvidivimportance : 0 rvidivupstatus = rvidivup ? 'Bullish RVI Divergence' : na rvidivdown = bearCond15 or bearCond15[1] or bearCond15[2] ? rvidivimportance : 0 rvidivdownstatus = rvidivdown ? 'Bearish RVI Divergence' : na //Support and Resistance Signals srcrossimportance = input.int(defval=0, minval=0, maxval=100, title='Support/Resistance Cross Importance') srcrossup = buy1 or buy2 or buy3 or buy4 or buy5 or buy6 or buy7 or buy8 ? srcrossimportance : 0 srcrossupstatus = srcrossup ? 'Crossed Key Level Up' : na srcrossdown = sell1 or sell2 or sell3 or sell4 or sell5 or sell6 or sell7 or sell8 ? srcrossimportance : 0 srcrossdownstatus = srcrossdown ? 'Crossed Key Level Down' : na //Volume Indicator Signals////////////////////////////////////////////////////// //On Balance Volume Divergence Signals obvdivimportance = input.int(defval=0, minval=0, maxval=100, title='OBV Divergence Importance') obvdivup = bullCond18 or bullCond18[1] or bullCond18[2] ? obvdivimportance : 0 obvdivupstatus = obvdivup ? 'Bullish OBV Divergence' : na obvdivdown = bearCond18 or bearCond18[1] or bearCond18[2] ? obvdivimportance : 0 obvdivdownstatus = obvdivdown ? 'Bearish OBV Divergence' : na //Chaikin Money Flow Signals cmfcrossimportance = input.int(defval=1, minval=0, maxval=100, title='CMF Cross 50-Line Importance') cmfcrossup = cmf > 0 and cmf[1] < 0 ? cmfcrossimportance : 0 cmfcrossupstatus = cmfcrossup ? 'CMF Crossed 50-Line Up' : na cmfcrossdown = cmf < 0 and cmf[1] > 0 ? cmfcrossimportance : 0 cmfcrossdownstatus = cmfcrossdown ? 'CMF Crossed 50-Line Down' : na cmflevimportance = input.int(defval=0, minval=0, maxval=100, title='CMF Level Importance') cmflevup = cmf > 0 ? cmflevimportance : 0 cmflevupstatus = cmflevup ? 'CMF Level Up' : na cmflevdown = cmf < 0 ? cmflevimportance : 0 cmflevdownstatus = cmflevdown ? 'CMF Level Down' : na //VWAP Signals vwapcrossimportance = input.int(defval=0, minval=0, maxval=100, title='VWAP Cross HMA Importance') vwapcrossup = hma < vwapValue and hma[1] > vwapValue[1] ? vwapcrossimportance : 0 vwapcrossupstatus = vwapcrossup ? 'VWAP Crossed Above HMA' : na vwapcrossdown = hma > vwapValue and hma[1] < vwapValue[1] ? vwapcrossimportance : 0 vwapcrossdownstatus = vwapcrossdown ? 'VWAP Crossed Below HMA' : na vwaptrendimportance = input.int(defval=0, minval=0, maxval=100, title='VWAP Trend Importance') vwaptrendup = out2 > vwapValue ? vwaptrendimportance : 0 vwaptrendupstatus = vwaptrendup ? 'VWAP Up Trend' : na vwaptrenddown = out2 < vwapValue ? vwaptrendimportance : 0 vwaptrenddownstatus = vwaptrenddown ? 'VWAP Down Trend' : na //Candle Patterns Signals engulfingcandleimportance = input.int(defval=1, minval=0, maxval=100, title='Engulfing Candle Importance') bulleng = C_EngulfingBullish ? engulfingcandleimportance : 0 bullengstatus = bulleng ? 'Bullish Engulfing Candle' : na beareng = C_EngulfingBearish ? engulfingcandleimportance : 0 bearengstatus = beareng ? 'Bearish Engulfing Candle' : na //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //COLLECT SIGNALS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //Classify Entries stronglongentrysignal = emadirectionup + emapushup + supertrendup + supertrendrevup + psardirup + psarrevup + hmacloseposup + hmapivotup + rsidivup + rsioversold + rsicrossup + macddivup + histpivotup + macdcrosssignalup + wtdivup + wtcrosssignalup + sdivup + scrosssignalup + bbcontup + atrrevup + rviposup + rvidivup + srcrossup + obvdivup + cmfcrossup + cmflevup + vwapcrossup + vwaptrendup + bulleng >= stronglongscore strongshortentrysignal = emadirectiondown + emapulldown + supertrenddown + supertrendrevdown + psardirdown + psarrevdown + hmacloseposdown + hmapivotdown + rsidivdown + rsioverbought + rsicrossdown + macddivdown + histpivotdown + macdcrosssignaldown + wtdivdown + wtcrosssignaldown + sdivdown + scrosssignaldown + bbcontdown + atrrevdown + rviposdown + rvidivdown + srcrossdown + obvdivdown + cmfcrossdown + cmflevdown + vwapcrossdown + vwaptrenddown + beareng >= strongshortscore weaklongentrysignal = emadirectionup + emapushup + supertrendup + supertrendrevup + psardirup + psarrevup + hmacloseposup + hmapivotup + rsidivup + rsioversold + rsicrossup + macddivup + histpivotup + macdcrosssignalup + wtdivup + wtcrosssignalup + sdivup + scrosssignalup + bbcontup + atrrevup + rviposup + rvidivup + srcrossup + obvdivup + cmfcrossup + cmflevup + vwapcrossup + vwaptrendup + bulleng >= weaklongscore weakshortentrysignal = emadirectiondown + emapulldown + supertrenddown + supertrendrevdown + psardirdown + psarrevdown + hmacloseposdown + hmapivotdown + rsidivdown + rsioverbought + rsicrossdown + macddivdown + histpivotdown + macdcrosssignaldown + wtdivdown + wtcrosssignaldown + sdivdown + scrosssignaldown + bbcontdown + atrrevdown + rviposdown + rvidivdown + srcrossdown + obvdivdown + cmfcrossdown + cmflevdown + vwapcrossdown + vwaptrenddown + beareng >= weakshortscore //Alternate Entry Signals var pos = 0 if stronglongentrysignal and pos <= 0 pos := 1 pos if strongshortentrysignal and pos >= 0 pos := -1 pos longentry = pos == 1 and (pos != 1)[1] shortentry = pos == -1 and (pos != -1)[1] alternatelong = alternatesignals ? longentry : stronglongentrysignal alternateshort = alternatesignals ? shortentry : strongshortentrysignal NUBuySignal = tradetrendoption ? alternatelong and mabuy and longpositions : alternatelong and longpositions NUSellSignal = tradetrendoption ? alternateshort and masell and shortpositions : alternateshort and shortpositions MSBarNUColor = NUBuySignal ? BuyColor : NUSellSignal ? SellColor : color.new(DisabledColor,90) //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //PLOT SIGNALS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //CHANGED //plotshape(tradetrendoption ? alternatelong and mabuy : alternatelong, title='Strong Long Label', style=shape.labelup, location=location.belowbar, color=color.new(#00bcd4, 0), text='𝐋𝐎𝐍𝐆', textcolor=color.new(color.white, 0), size=size.small) //plotshape(tradetrendoption ? alternateshort and masell : alternateshort, title='Strong Short Label', style=shape.labeldown, location=location.abovebar, color=color.new(#e91e63, 0), text='𝐒𝐇𝐎𝐑𝐓', textcolor=color.new(color.white, 0), size=size.small) //plotshape(weaklongentrysignal, title='Weak Long Triangle', style=shape.triangleup, location=location.belowbar, color=color.new(#00bcd4, 50), size=size.tiny) //plotshape(weakshortentrysignal, title='Weak Short Triangle', style=shape.triangledown, location=location.abovebar, color=color.new(#e91e63, 50), size=size.tiny) //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //PLOT STATUS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //var table statuswindow = table.new(position.top_right, 100, 100, border_width=2) //Trend Status////////////////////////////////////////////////////////////////// //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //STOP LOSS WARNINGS▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //Stop Loss Criteria //longstoploss = strategy.position_avg_price * (1 + stoplosspercent) //shortstoploss = strategy.position_avg_price * (1 - stoplosspercent) //printstoplong = longstoploss > close and longstoploss[1] < close[1] and strategy.position_size > 0 //printstopshort = shortstoploss < close and shortstoploss[1] > close[1] and strategy.position_size < 0 //Stop Loss Lines //plot(strategy.position_size > 0 ? longstoploss : na, style=plot.style_line, color=color.new(color.yellow, 50), linewidth=1, title='Stop Long Line', display=display.none) //plot(strategy.position_size < 0 ? shortstoploss : na, style=plot.style_line, color=color.new(color.yellow, 50), linewidth=1, title='Stop Short Line', display=display.none) //Stop Loss Labels //plotshape(printstoplong, title='Stop Long Label', style=shape.labelup, location=location.belowbar, color=color.new(color.yellow, 0), text='𝐒𝐓𝐎𝐏', textcolor=color.new(color.black, 0), size=size.tiny) //plotshape(printstopshort, title='Stop Short Label', style=shape.labeldown, location=location.abovebar, color=color.new(color.yellow, 0), text='𝐒𝐓𝐎𝐏', textcolor=color.new(color.black, 0), size=size.tiny) //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //STRATEGY TESTER▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼ //Long // if tradetrendoption ? alternatelong and mabuy and longpositions : alternatelong and longpositions // strategy.entry('longposition', strategy.long, comment='Long Entry') // if (shortentry or printstoplong) and longpositions // strategy.close('longposition', comment='Long Exit') // //Short // if tradetrendoption ? alternateshort and masell and shortpositions : alternateshort and shortpositions // strategy.entry('shortposition', strategy.short, comment=' Short Entry') // if (longentry or printstopshort) and shortpositions // strategy.close('shortposition', comment='Short Exit') //Alerts // ttbuystring = 'Input your custom alert message here. In the Alert settings, choose "Neural Network" and "Alert() functionc calls only"\nIf you\'re using a 3Commas Bot, make sure to format your message correctly with forward slashes in front of each quotation, you can find videos about how to do this on YouTube. Or ask 3Commas support about how to format the message for PineScript.' // ttsellstring = 'Input your custom alert message here. In the Alert settings, choose "Neural Network" and "Alert() functionc calls only"\nIf you\'re using a 3Commas Bot, make sure to format your message correctly with forward slashes in front of each quotation, you can find videos about how to do this on YouTube. Or ask 3Commas support about how to format the message for PineScript.' // ttstopstring = 'Input your custom alert message here. In the Alert settings, choose "Neural Network" and "Alert() functionc calls only"\nIf you\'re using a 3Commas Bot, make sure to format your message correctly with forward slashes in front of each quotation, you can find videos about how to do this on YouTube. Or ask 3Commas support about how to format the message for PineScript.' // usebuyalert = input.bool(defval=true, title='Use BUY Alert', group='Alert Messages') // buystring = input.string(title='Buy Alert Message', defval='BUY', confirm=false, group='Alert Messages', tooltip=ttbuystring) // usesellalert = input.bool(defval=true, title='Use SELL Alert', group='Alert Messages') // sellstring = input.string(title='Sell Alert Message', defval='SELL', confirm=false, group='Alert Messages', tooltip=ttsellstring) // usestopalert = input.bool(defval=true, title='Use STOP Alert', group='Alert Messages') // stopstring = input.string(title='Stop Alert Message', defval='STOP', confirm=false, group='Alert Messages', tooltip=ttstopstring) // if longentry and longpositions and usebuyalert // alert(buystring, alert.freq_once_per_bar) // if shortentry and shortpositions and usesellalert // alert(sellstring, alert.freq_once_per_bar) // if printstoplong or printstopshort and usestopalert // alert(stopstring, alert.freq_once_per_bar) //END▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ //////////////////////////////////////////////////////////////////////////////// //////////////// Buy/Sell STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// buySellAnyPositive = MSBar1PositiveWaveTrendSignal or BackgroundColorChangePositive or MaxValueMACrossUp or MSBarCEPositiveTrendSignal or MSBarPSPositiveTrendSignal or MSBarQQEPositiveTrendSignal or htBuySignal or NUBuySignal buySellAnyNegative = MSBar1NegativeWaveTrendSignal or BackgroundColorChangeNegative or MaxValueMACrossDown or MSBarCENegativeTrendSignal or MSBarPSNegativeTrendSignal or MSBarQQENegativeTrendSignal or htSellSignal or NUSellSignal buySellAnyPositiveNegative = MSBar1PositiveWaveTrendSignal or MSBar1NegativeWaveTrendSignal or BackgroundColorChangePositive or BackgroundColorChangeNegative or MaxValueMACrossUp or MaxValueMACrossDown or MSBarCEPositiveTrendSignal or MSBarPSPositiveTrendSignal or MSBarQQEPositiveTrendSignal or MSBarCENegativeTrendSignal or MSBarPSNegativeTrendSignal or MSBarQQENegativeTrendSignal or NUSellSignal or NUBuySignal bool buySellStrongPositive = na bool buySellStrongNegative = na // FOR BULL: 2 then 1 // FOR BEAR or Side Ways: 3 then 1 //BULL: 2 BEAR: 2 if BuySellPolicy == 'Fast Buy and Fast Sell(Bull/Bear)' //if BuyTRating //Fast Buy buySellStrongPositive := (TrendBars3Positive and not condSell) and (NUBuySignal or MSBar1PositiveWaveTrendSignal or MSBarCEPositiveTrendSignal or MSBarPSPositiveTrendSignal or MSBarQQEPositiveTrendSignal or htBuySignal) and ((xUp or gUp) or MSBarKDJPositiveTrendSignal or cmfPositive) //if SellTRating //Fast Sell buySellStrongNegative := (TrendBars3Negative or MSBarKDJNegativeTrendSignal or not condBuy) and (NUSellSignal or MSBar1NegativeWaveTrendSignal or MSBarCENegativeTrendSignal or MSBarPSNegativeTrendSignal or MSBarQQENegativeTrendSignal or htSellSignal or (xDn or gDn) or (condSell and not TrendBars3Positive)) //BULL: 1 if BuySellPolicy == 'Fast Buy and Slow Sell(Bull)' //if BuyTRating //Fast Buy buySellStrongPositive := (TrendBars3Positive and not condSell) and (NUBuySignal or MSBar1PositiveWaveTrendSignal or MSBarCEPositiveTrendSignal or MSBarPSPositiveTrendSignal or MSBarQQEPositiveTrendSignal or htBuySignal) and ((xUp or gUp) or MSBarKDJPositiveTrendSignal or cmfPositive) //if SellTRating //Slow Sell buySellStrongNegative := (TrendBars3Negative and not condBuy) and (NUSellSignal or MSBar1NegativeWaveTrendSignal or MSBarCENegativeTrendSignal or MSBarPSNegativeTrendSignal or MSBarQQENegativeTrendSignal or htSellSignal or (xDn or gDn) or (condSell and not TrendBars3Positive)) //BEAR: 1 if BuySellPolicy == 'Slow Buy and Fast Sell(Bear/SideWays)' //if BuyTRating //Slow Buy buySellStrongPositive := (TrendBars3Positive or condBuy) and (NUBuySignal or MSBar1PositiveWaveTrendSignal or MSBarCEPositiveTrendSignal or MSBarPSPositiveTrendSignal or MSBarQQEPositiveTrendSignal or htBuySignal) //and ((xUp or gUp) or MSBarKDJPositiveTrendSignal or cmfPositive) //if SellTRating //Fast Sell buySellStrongNegative := (TrendBars3Negative or MSBarKDJNegativeTrendSignal or not condBuy) and (NUSellSignal or MSBar1NegativeWaveTrendSignal or MSBarCENegativeTrendSignal or MSBarPSNegativeTrendSignal or MSBarQQENegativeTrendSignal or htSellSignal or (xDn or gDn) or (condSell and not TrendBars3Positive)) //BULL: 2 BEAR: 3 if BuySellPolicy == 'Slow Buy and Slow Sell' //if BuyTRating //Slow Buy buySellStrongPositive := (TrendBars3Positive or condBuy) and (NUBuySignal or MSBar1PositiveWaveTrendSignal or MSBarCEPositiveTrendSignal or MSBarPSPositiveTrendSignal or MSBarQQEPositiveTrendSignal or htBuySignal) //and ((xUp or gUp) or MSBarKDJPositiveTrendSignal or cmfPositive) //if SellTRating //Slow Sell buySellStrongNegative := (TrendBars3Negative and not condBuy) and (NUSellSignal or MSBar1NegativeWaveTrendSignal or MSBarCENegativeTrendSignal or MSBarPSNegativeTrendSignal or MSBarQQENegativeTrendSignal or htSellSignal or (xDn or gDn) or (condSell and not TrendBars3Positive)) BarBuySellColor = color.gray var bool lastDirectionUp = na // Trigger alerts on user-selected conditions. bool triggerLong = (buySellStrongPositive and (na(lastDirectionUp) or not lastDirectionUp))[ensureNoRepaintIdx] bool triggerShort = (buySellStrongNegative and (na(lastDirectionUp) or lastDirectionUp))[ensureNoRepaintIdx] if triggerLong lastDirectionUp := true BarBuySellColor := BuyColor else if triggerShort lastDirectionUp := false BarBuySellColor := SellColor alertcondition(triggerLong, title='01 Buy Signal', message='Buy') alertcondition(triggerShort, title='02 Sell Signal', message='Sell') alertcondition(buySellAnyPositive, title='03 Positive Signals', message='Buy') alertcondition(buySellAnyNegative, title='04 Negative Signals', message='Sell') alertcondition(buySellAnyPositiveNegative, title='05 Positive/Negative Signal', message='Buy/Sell') //////////////// Buy/Sell Ends ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////// PLOTTING STARTS ///////////////////////////////////////////////////////////////////////////////////////////////// plot(ShowTrendBar ? 50 : na, title='Signals 1 - All 3 Trend Meters Now Align', style=plot.style_circles, color=MSBar2Color, linewidth=2, transp=1) // Trend Barmeter Plots plot(ShowTrendBar ? 43 : na, title='2 - Trend Meter', style=plot.style_circles, color=TrendBar1Color, linewidth=2, transp=1) plot(ShowTrendBar ? 37.5 : na, title='3 - Trend Meter', style=plot.style_circles, color=TrendBar2Color, linewidth=2, transp=1) plot(ShowTrendBar ? 31 : na, title='4 - Trend Meter', style=plot.style_circles, color=TrendBar3Color, linewidth=2, transp=1) plot(ShowTrendBar and not(TrendBar5 == 'N/A') ? 24.5 : na, title='5 - Trend Bar 1 - Thin Line', style=plot.style_line, color=TrendBar4Color1, linewidth=4, transp=1) plot(ShowTrendBar and not(TrendBar4 == 'N/A') ? 18.5 : na, title='6 - Trend Bar 2 - Thin Line', style=plot.style_line, color=TrendBar5Color1, linewidth=4, transp=1) plot(ShowTrendBar ? 13 : na, title='8 - Trend Bar 3 - AlphaTrend', style=plot.style_line, color=BARAtColor, linewidth=4, transp=1) plot(ShowTrendBar ? 8 : na, title='7 - Trend Bar 3 - Donchin Channel', style=plot.style_line, color=dcColor, linewidth=4, transp=1) plot(0, title='7 - Trend Bar 3 - Technical Ratings', style=plot.style_line, color=c_signal, linewidth=7, transp=1) // Momentum Setup Plots plot(ShowTrendBar ? -8 : na, title='Signals 9 - Chandelier Exit', style=plot.style_circles, color=MSBarCEColor, linewidth=2, transp=1) plot(ShowTrendBar ? -16 : na, title='Signals 10 - Wave Trend Signals', style=plot.style_circles, color=MSBar1Color, linewidth=2, transp=1) plot(ShowTrendBar ? -22 : na, title='Signals 11 - QQE', style=plot.style_circles, color=MSBarQQEColor, linewidth=2, transp=1) plot(ShowTrendBar ? -29 : na, title='Signals 12 - Nural Network', style=plot.style_circles, color=MSBarNUColor, linewidth=2, transp=1) plot((triggerLong or triggerShort) ? -36 : na, title='Signals 13 - Buy Sell', style=plot.style_circles, color=BarBuySellColor, linewidth=3, transp=1) //////////////// PLOTTING ENDS ///////////////////////////////////////////////////////////////////////////////////////////////// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Heikin_Ashi_Homma
https://www.tradingview.com/script/VnwOvbfF-Heikin-Ashi-Homma/
jacobfabris
https://www.tradingview.com/u/jacobfabris/
48
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jacobfabris //@version=5 indicator("Heikin_Ashi_Homma",overlay=false) abre = request.security(ticker.heikinashi(syminfo.tickerid),timeframe.period,open) pico = request.security(ticker.heikinashi(syminfo.tickerid),timeframe.period,high) fundo = request.security(ticker.heikinashi(syminfo.tickerid),timeframe.period,low) cor = close > abre ? color.green : color.red plotcandle(abre,pico,fundo,close,color=cor) period1 = input(defval = 8) period2 = input(defval = 34) period3 = input(defval = 144) weigth_close = input.float(defval = 0.8) weigth_open = input.float(defval = 0.2) spot = (close*weigth_close+abre*weigth_open) m1 = ta.ema(spot,period1) m2 = ta.ema(spot,period2) m3 = ta.ema(spot,period3) plot(m1,color=color.aqua,linewidth=2) plot(m2,color=color.blue,linewidth=2) plot(m3,color=color.navy,linewidth=2)
Forex Lot Size Calculator [AKCHOOO]
https://www.tradingview.com/script/Go0H4ZDO-Forex-Lot-Size-Calculator-AKCHOOO/
akchooo
https://www.tradingview.com/u/akchooo/
209
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © akchooo //credits - source adapted from @hanabil //@version=5 indicator("Lot Size Calculator", max_bars_back=2000, overlay=true) tst(x)=> str.tostring(x) var int dec = str.length(str.tostring(syminfo.mintick))-2 trc(number) => factor = math.pow(10, dec) int(number * factor) / factor trc_(number) => factor = math.pow(10, 0) int(number * factor) / factor // ------------------------- // Price gr1 = 'Stop Loss' sl = input.price(20, 'Ticks' , group=gr1, inline='2') partial = input.price(25, 'Percentage of First Partial [%]' , group=gr1, inline='3') round = input(3, 'Round Lot Size to Which Decimal' , group=gr1, inline='4') slpartial1 = partial/100 slpartial2 = 1-slpartial1 // RISK MANAGER gr11 = 'Risk Manager' equity = input(100000, 'Equity', group=gr11) riskInp = input(0.500, title='Risk % of Equity' , group=gr11) risk = riskInp balance = equity riskCurr = risk*balance/100 slRangeL = sl st = slRangeL/syminfo.mintick pzfull = riskCurr/slRangeL pzpartial1 = pzfull*slpartial1 pzpartial2 = pzfull*slpartial2 pz = math.round(pzfull,round) pz1 = math.round(pzpartial1,round) pz2 = math.round(pzpartial2,round) // ---------------- // Smart Table // -------- gr10 = 'Table' tabPosI = input.string('Top', 'Table Position', ['Top', 'Middle', 'Bot'], group=gr10) tabCol = input.color(color.new(color.black, 35), 'Table Color', inline='1', group=gr10) tabCol2 = input.color(color.new(color.gray, 35), 'Highlight Lot Color', inline='1', group=gr10) textCol = input.color(color.white, 'Text', inline='1', group=gr10) textSizeI = input.string('Small', 'Text Size', ['Small', 'Tiny', 'Normal'], group=gr10) textSize = textSizeI=='Small'? size.small : textSizeI=='Tiny'? size.tiny : size.normal tabPos = tabPosI=='Top'? position.top_right : tabPosI=='Bot'? position.bottom_right : position.middle_right var smartTable = table.new(tabPos, 50, 50, color.new(color.black,100), color.black, 1, color.black,1) table.cell(smartTable, 0, 0, 'Equity [$]' , text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 0, 1, 'Risk [%]' , text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 0, 2, 'Risk [$]' , text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 0, 3, 'Stoploss [Ticks]' , text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 0, 5, 'Full Lot Size' , text_color=textCol, text_size=textSize, bgcolor=tabCol2) table.cell(smartTable, 0, 6, 'Partial Lot Size' , text_color=textCol, text_size=textSize, bgcolor=tabCol2) table.cell(smartTable, 0, 7, 'Remainder Lot Size' , text_color=textCol, text_size=textSize, bgcolor=tabCol2) table.cell(smartTable, 1, 0, tst(equity) , text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 1, 1, tst(risk) , text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 1, 2, tst(riskCurr) , text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 1, 3, tst(trc(sl)), text_color=textCol, text_size=textSize, bgcolor=tabCol) table.cell(smartTable, 1, 5, tst(trc(pz)), text_color=textCol, text_size=textSize, bgcolor=tabCol2) table.cell(smartTable, 1, 6, tst(trc(pz1)), text_color=textCol, text_size=textSize, bgcolor=tabCol2) table.cell(smartTable, 1, 7, tst(trc(pz2)), text_color=textCol, text_size=textSize, bgcolor=tabCol2)
ScalpiusTrend
https://www.tradingview.com/script/UwUPNQFL-ScalpiusTrend/
westofpluto
https://www.tradingview.com/u/westofpluto/
96
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © westofpluto //@version=5 // // Updated Dec 13, 2022 to allow immediate reversal to pending trade in opposite direction // indicator(title="ScalpiusTrend", shorttitle="SPTRND", format=format.price, precision=4, timeframe="", timeframe_gaps=true) OPTHIST="Histogram" OPTLINE="Line" showPending = input.bool(false,"Pending Bars") useReverse = input.bool(true,"Let trend reverse to pending") // // COMPUTE BOLLINGER BANDS INTERNALLY // source = close length = 20 mult = 2.0 basis = ta.sma(source, length) dev = mult * ta.stdev(source, length) upperBBValue = basis + dev lowerBBValue = basis - dev NO_UPTREND = 0, UPTREND_PENDING = 1, UPTREND_CONFIRMED = 2 NO_DOWNTREND = 0, DOWNTREND_PENDING = 1, DOWNTREND_CONFIRMED = 2 DOWN = -1, NONE=0, UP=1 ID_TRENDMODEON = 0 ID_TRENDDIRECTION = 0 ID_UPTRENDMODESTATE = 1 ID_DOWNTRENDMODESTATE = 2 ID_PENDINGCANDLECOUNT = 3 ID_TRENDHIGH = 0 ID_TRENDLOW = 1 ID_TRENDCLOSE = 2 var trendMode = false var trendDirection = NONE var upTrendModeState = NO_UPTREND var downTrendModeState = NO_DOWNTREND var pendingCandleCount = 0 var trendHigh = 0.0 var trendLow = 1.0e+20 var trendClose = 0.0 global_bool = array.new_bool(1) array.set(global_bool,ID_TRENDMODEON,trendMode) global_int = array.new_int(4) array.set(global_int,ID_TRENDDIRECTION,trendDirection) array.set(global_int,ID_UPTRENDMODESTATE,upTrendModeState) array.set(global_int,ID_DOWNTRENDMODESTATE,downTrendModeState) array.set(global_int,ID_PENDINGCANDLECOUNT,pendingCandleCount) global_float = array.new_float(3) array.set(global_float,ID_TRENDHIGH,trendHigh) array.set(global_float,ID_TRENDLOW,trendLow) array.set(global_float,ID_TRENDCLOSE,trendClose) isUptrendReversed() => if (useReverse == true and low <= lowerBBValue) true else false isDowntrendReversed() => if (useReverse == true and high >= upperBBValue) true else false isUptrendEnded() => if (low <= lowerBBValue) true else if (array.get(global_int,ID_PENDINGCANDLECOUNT) >= 20) true else if (high > array.get(global_float,ID_TRENDHIGH)) array.set(global_int,ID_PENDINGCANDLECOUNT,0) false isDowntrendEnded() => if (high >= upperBBValue) true else if (array.get(global_int,ID_PENDINGCANDLECOUNT) >= 20) true else if (low < array.get(global_float,ID_TRENDLOW)) array.set(global_int,ID_PENDINGCANDLECOUNT,0) false checkForTrendMode() => if (high >= upperBBValue and low <= lowerBBValue) array.set(global_int,ID_TRENDDIRECTION,NONE) array.set(global_int,ID_UPTRENDMODESTATE,NO_UPTREND) array.set(global_int,ID_DOWNTRENDMODESTATE,NO_DOWNTREND) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_bool,ID_TRENDMODEON,false) else if (not array.get(global_bool,ID_TRENDMODEON)) if array.get(global_int,ID_UPTRENDMODESTATE) == NO_UPTREND if (high >= upperBBValue) array.set(global_int,ID_UPTRENDMODESTATE,UPTREND_PENDING) array.set(global_float,ID_TRENDHIGH,high) array.set(global_float,ID_TRENDCLOSE,close) array.set(global_int,ID_PENDINGCANDLECOUNT,0) else if (array.get(global_int,ID_UPTRENDMODESTATE) == UPTREND_PENDING) array.set(global_int,ID_PENDINGCANDLECOUNT,array.get(global_int,ID_PENDINGCANDLECOUNT) + 1) if isUptrendEnded() array.set(global_int,ID_UPTRENDMODESTATE,NO_UPTREND) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_bool,ID_TRENDMODEON,false) array.set(global_int,ID_TRENDDIRECTION,NONE) if (high > array.get(global_float,ID_TRENDHIGH) and close > array.get(global_float,ID_TRENDCLOSE)) array.set(global_int,ID_UPTRENDMODESTATE,UPTREND_CONFIRMED) array.set(global_bool,ID_TRENDMODEON,true) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_int,ID_TRENDDIRECTION,UP) if array.get(global_int,ID_DOWNTRENDMODESTATE) == NO_DOWNTREND if (low <= lowerBBValue) array.set(global_int,ID_DOWNTRENDMODESTATE,DOWNTREND_PENDING) array.set(global_float,ID_TRENDLOW,low) array.set(global_float,ID_TRENDCLOSE,close) array.set(global_int,ID_PENDINGCANDLECOUNT,0) else if (array.get(global_int,ID_DOWNTRENDMODESTATE) == DOWNTREND_PENDING) array.set(global_int,ID_PENDINGCANDLECOUNT,array.get(global_int,ID_PENDINGCANDLECOUNT) + 1) if isDowntrendEnded() array.set(global_int,ID_DOWNTRENDMODESTATE,NO_DOWNTREND) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_bool,ID_TRENDMODEON,false) array.set(global_int,ID_TRENDDIRECTION,NONE) if (low < array.get(global_float,ID_TRENDLOW) and close < array.get(global_float,ID_TRENDCLOSE)) array.set(global_int,ID_DOWNTRENDMODESTATE,DOWNTREND_CONFIRMED) array.set(global_bool,ID_TRENDMODEON,true) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_int,ID_TRENDDIRECTION,DOWN) else if (array.get(global_int,ID_UPTRENDMODESTATE) == UPTREND_CONFIRMED) if isUptrendReversed() array.set(global_int,ID_UPTRENDMODESTATE,NO_UPTREND) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_bool,ID_TRENDMODEON,false) array.set(global_int,ID_TRENDDIRECTION,NONE) array.set(global_int,ID_DOWNTRENDMODESTATE,DOWNTREND_PENDING) array.set(global_float,ID_TRENDLOW,low) array.set(global_float,ID_TRENDCLOSE,close) array.set(global_int,ID_PENDINGCANDLECOUNT,0) else if isUptrendEnded() array.set(global_int,ID_UPTRENDMODESTATE,NO_UPTREND) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_bool,ID_TRENDMODEON,false) array.set(global_int,ID_TRENDDIRECTION,NONE) else if (high > array.get(global_float,ID_TRENDHIGH)) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_float,ID_TRENDHIGH,high) else array.set(global_int,ID_PENDINGCANDLECOUNT,array.get(global_int,ID_PENDINGCANDLECOUNT) + 1) if (array.get(global_int,ID_DOWNTRENDMODESTATE) == DOWNTREND_CONFIRMED) if isDowntrendReversed() array.set(global_int,ID_DOWNTRENDMODESTATE,NO_DOWNTREND) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_bool,ID_TRENDMODEON,false) array.set(global_int,ID_TRENDDIRECTION,NONE) array.set(global_int,ID_UPTRENDMODESTATE,UPTREND_PENDING) array.set(global_float,ID_TRENDHIGH,high) array.set(global_float,ID_TRENDCLOSE,close) array.set(global_int,ID_PENDINGCANDLECOUNT,0) else if isDowntrendEnded() array.set(global_int,ID_DOWNTRENDMODESTATE,NO_DOWNTREND) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_bool,ID_TRENDMODEON,false) array.set(global_int,ID_TRENDDIRECTION,NONE) else if (low < array.get(global_float,ID_TRENDLOW)) array.set(global_int,ID_PENDINGCANDLECOUNT,0) array.set(global_float,ID_TRENDLOW,low) else array.set(global_int,ID_PENDINGCANDLECOUNT,array.get(global_int,ID_PENDINGCANDLECOUNT) + 1) checkForTrendMode() // // Save the vars for next bar // trendMode := array.get(global_bool,ID_TRENDMODEON) trendDirection := array.get(global_int,ID_TRENDDIRECTION) upTrendModeState := array.get(global_int,ID_UPTRENDMODESTATE) downTrendModeState := array.get(global_int,ID_DOWNTRENDMODESTATE) pendingCandleCount := array.get(global_int,ID_PENDINGCANDLECOUNT) trendHigh := array.get(global_float,ID_TRENDHIGH) trendLow := array.get(global_float,ID_TRENDLOW) trendClose := array.get(global_float,ID_TRENDCLOSE) float trendDetail = 0 c=#000000 if upTrendModeState == UPTREND_PENDING trendDetail := 0.35 c := #004000 else if upTrendModeState == UPTREND_CONFIRMED trendDetail := 1.0 c := #00C000 else if downTrendModeState == DOWNTREND_PENDING trendDetail := -0.35 c := #400000 else if downTrendModeState == DOWNTREND_CONFIRMED trendDetail := -1.0 c := #C00000 zeroLine = 0.0 plot(zeroLine, color=#800000, title="TREND") plot(showPending ? na : trendDirection, style=plot.style_histogram, color=c, title="TREND", linewidth=3) plot(showPending ? trendDetail : na, color=c, title="TREND", style=plot.style_histogram,linewidth=3)
JxModi Camarilla
https://www.tradingview.com/script/26rwJMQF-JxModi-Camarilla/
jxmodi
https://www.tradingview.com/u/jxmodi/
117
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/ // © jxmodi //@version=4 study("JxModi Camarilla", overlay = true) mode =input(title = "HTF Method", defval = 'User Defined', options=['Auto', 'User Defined']) HTFm = input('D', title = "Time Frame (if HTF Method=User Defined)", type=input.resolution) showlast = input(title = "Show Only Last Period", defval = false) showlabels = input(title = "Show Labels", defval = true) lstyle = input(title = "Line Style", options = ['Solid', 'Circles', 'Cross'], defval ='Solid') //auto higher time frame HTFo =timeframe.period == '1' ? '30' : timeframe.period == '3' ? '60' : timeframe.period == '5' ? '240' : timeframe.period == '15' ? 'D' : timeframe.period == '30' ? 'D' : timeframe.period == '45' ? 'D' : timeframe.period == '60' ? 'D' : timeframe.period == '120' ? 'D' : timeframe.period == '180' ? 'D' : timeframe.period == '240' ? 'D' : timeframe.period == 'D' ? 'W' : '5W' HTF = mode == 'Auto' ? HTFo : HTFm highhtf = security(syminfo.tickerid, HTF, high[1], lookahead = barmerge.lookahead_on) lowhtf = security(syminfo.tickerid, HTF, low[1], lookahead = barmerge.lookahead_on) closehtf = security(syminfo.tickerid, HTF, close[1], lookahead = barmerge.lookahead_on) RANGE = highhtf - lowhtf // is this last bar for HTF? islast = showlast ? security(syminfo.tickerid, HTF, barstate.islast, lookahead = true) : true // Line Style linestyle = lstyle == 'Solid' ? plot.style_stepline : lstyle == 'Circle' ? plot.style_circles : plot.style_cross H5 = (highhtf / lowhtf) * closehtf H4 = closehtf + RANGE * 1.1/2 H3 = closehtf + RANGE * 1.1/4 H2 = closehtf + RANGE * 1.1/6 H1 = closehtf + RANGE * 1.1/12 L1 = closehtf - RANGE * 1.1/12 L2 = closehtf - RANGE * 1.1/6 L3 = closehtf - RANGE * 1.1/4 L4 = closehtf - RANGE * 1.1/2 L5 = closehtf - (H5 - closehtf) plot(islast ? H5 : na, title = "H5", color = color.navy, linewidth = 1, style = linestyle, transp = 0) plot(islast ? H4 : na, title = "H4", color = color.teal, linewidth = 3, style = linestyle, transp = 0) plot(islast ? H3 : na, title = "H3", color = color.red, linewidth = 1, style = linestyle, transp = 0) plot(islast ? L3 : na, title = "L3", color = color.red, linewidth = 1, style = linestyle, transp = 0) plot(islast ? L4 : na, title = "L4", color = color.teal, linewidth = 3, style = linestyle, transp = 0) plot(islast ? L5 : na, title = "L5", color = color.navy, linewidth = 1, style = linestyle, transp = 0) // Label for S/R chper = time - time[1] chper := change(chper) > 0 ? chper[1] : chper Round_it(valu)=> a = 0 num = syminfo.mintick s = valu if na(s) s := syminfo.mintick if num < 1 for i = 1 to 20 num := num * 10 if num > 1 break a := a +1 for x = 1 to a s := s * 10 s := round(s) for x = 1 to a s := s / 10 s := s < syminfo.mintick ? syminfo.mintick : s s // Labels if showlabels var label s3label = na, var label s4label = na, var label s5label = na var label r3label = na, var label r4label = na, var label r5label = na label.delete(s3label), label.delete(s4label), label.delete(s5label) label.delete(r3label), label.delete(r4label), label.delete(r5label) s3label := label.new(x = time + chper * 20, y = L3, text = "L3= " + tostring(Round_it(L3)), color = color.lime, textcolor=color.black, style=label.style_labelup, xloc = xloc.bar_time, yloc=yloc.price) s4label := label.new(x = time + chper * 20, y = L4, text = "L4= " + tostring(Round_it(L4)), color = color.blue, textcolor=color.yellow, style=label.style_labelup, xloc = xloc.bar_time, yloc=yloc.price) s5label := label.new(x = time + chper * 20, y = L5, text = "L5= " + tostring(Round_it(L5)), color = color.navy, textcolor=color.white, style=label.style_labelup, xloc = xloc.bar_time, yloc=yloc.price) r3label := label.new(x = time + chper * 20, y = H3, text = "H3= " + tostring(Round_it(H3)), color = color.orange, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price) r4label := label.new(x = time + chper * 20, y = H4, text = "H4= " + tostring(Round_it(H4)), color = color.red, textcolor=color.white, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price) r5label := label.new(x = time + chper * 20, y = H5, text = "H5= " + tostring(Round_it(H5)), color = color.maroon, textcolor=color.yellow, style=label.style_labeldown, xloc = xloc.bar_time, yloc=yloc.price) //EMA 9/20/50/200", overlay=true //Input Menus Input1 = input(4, "First EMA") Input2 = input(20, "Second EMA") Input3 = input(50, "Third EMA") Input4 = input(200, "Fourth EMA") shortest = ema(close, Input1) short = ema(close, Input2) longer = ema(close, Input3) longest = ema(close, Input4) typicalPrice = (high + low + close) / 3 typicalPriceVolume = typicalPrice * volume plot(shortest,"First EMA", color.green, transp=0) plot(short, "Second EMA", color.orange, transp=0) plot(longer, "Third EMA", color.red, transp=0) plot(longest,"Fourth EMA", color.maroon, transp=0) // VWAP price = input(type=input.source, defval=hlc3, title="VWAP Source") enable_vwap = input(true, title="Enable VWAP") vwapResolution = input(title = "VWAP Resolution", defval = "", type=input.resolution) vwapFunction = vwap(price) vwapSecurity = security(syminfo.tickerid, vwapResolution, vwapFunction) plot(enable_vwap ? vwapSecurity : na, title="VWAP", color=color.black, linewidth=2, transp=0, editable=true) // All TimeFrames
Greedy MA & Greedy Bollinger Bands
https://www.tradingview.com/script/4He5yOEx-Greedy-MA-Greedy-Bollinger-Bands/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
49
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © peacefulLizard50262 //ema/1/700/325/1/2/1/325(700)/175/dstd/gdstd //ema/1/14/28/1/2/14/28/20/gdstd/gdstd //ema/-10/20/2/2/2/14/10/20/rstd/rstd //color themes for each preset //@version=5 indicator("All Your Averaged r Belong to Us", "Moving Average Mod", overlay = true) //, max_bars_back = 700) donchian(src, int len) => math.avg(ta.lowest(src, len), ta.highest(src, len)) stdev(float src, float avg, float dev = 2, int len = 20, bool pol = true) => stdev = dev * ta.stdev(src, len) out = pol == true ? avg + stdev : avg - stdev gstdv(float src, float avg, float dev = 2, int len = 20, bool pol = false) => float result = na lsrc = math.log(src) stdev = dev * ta.stdev(lsrc, len) lavg = math.log(avg) out = pol == true ? lavg + stdev : lavg - stdev result := math.exp(out) result rstdv(float avg, int len = 10, float dev = 2, bool pol = true) => out = pol == true ? avg + ta.atr(len) * dev : avg - ta.atr(len) * dev dstdv(float src, float avg, float dev = 2, int len = 20, int don_len, int min, int max, bool pol = true) => deviation = array.new_float(na) stdev = 0.0 for i = min to max by 1 array.push(deviation, donchian(dev * ta.stdev(src, i), don_len)) stdev := array.sum(deviation)/((max-min)+1) result = pol == true ? avg + stdev : avg - stdev gstdd(float src, float avg, float dev = 2, int len = 20, int don_len, int min, int max, bool pol = true) => float result = na deviation = array.new_float(na) stdev = 0.0 lsrc = math.log(src) for i = min to max by 1 array.push(deviation, donchian(dev * ta.stdev(lsrc, i), don_len)) stdev := array.sum(deviation)/((max-min)+1) lavg = math.log(avg) out = pol == true ? lavg + stdev : lavg - stdev result := math.exp(out) result std(string sel = "std", float src, float avg, float dev = 2, len, int don_len, int min = 1, bool pol = true) => result = switch sel "std" => stdev(src, avg, dev, len, pol) "gstd" => gstdv(src, avg, dev, len, pol) "rstd" => rstdv(avg, len, dev, pol) "dstd" => dstdv(src, avg, dev, len, don_len, min, len, pol) "gdstd" => gstdd(src, avg, dev, len, don_len, min, len, pol) =>stdev(src, avg, dev, len, pol) result ema(src, int len) => alpha = 2 / (len + 1) sum = 0.0 sum := na(sum[1]) ? src : alpha * src + (1 - alpha) * nz(sum[1]) tma(src, int len) => ema1 = ema(src, len) ema2 = ema(ema1, len) ema3 = ema(ema2, len) tma = 3 * (ema1 - ema2) + ema3 average(src, int len = 10, string sel = 'sma') => sel == "ema" ? ema(src, len) : sel == "sma" ? ta.sma(src, len) : sel == "tma" ? tma(src, len) : na deep(source, int min, int max, int length, string select) => result = array.new_float(na) for i = min to max by 1 array.push(result, donchian(average(source, i, select), length)) array.sum(result)/((max-min)+1) band_enable = input.bool(true) source = input.source(close) select = input.string("tma", "select ma", ["sma","ema","tma"]) min_length = input.int(1) max_length = input.int(700) donchain_length = input.int(325) smooth = input.int(1) deviation = input.float(2) deviation_min_lookback = input.int(1) deviation_lookback = input.int(325) deviation_doncian = input.int(175) band_top = input.string("dstd", "top type", ["std","gstd","rstd","dstd","gdstd"]) band_bot = input.string("gdstd", "bot type", ["std","gstd","rstd","dstd","gdstd"]) deep = deep(source, min_length, max_length, donchain_length, select) out = ta.sma(deep, smooth) deviation_src = ta.sma(source, smooth) top = std(band_top, deviation_src, out, deviation, deviation_lookback, deviation_doncian, deviation_min_lookback, true) bot = std(band_bot, deviation_src, out, deviation, deviation_lookback, deviation_doncian, deviation_min_lookback, false) topnew = top > 0 ? top : na botnew = bot > 0 ? bot : na outnew = out > 0 ? out : na topen = band_enable == true ? topnew : na boten = band_enable == true ? botnew : na center = plot(outnew, color = color.new(color.orange, 0)) High = plot(topen, linewidth = 2) Low = plot(boten, linewidth = 2)
Multiple MAs + No Trend Zone + ATR Widget
https://www.tradingview.com/script/9jzFDLcx-Multiple-MAs-No-Trend-Zone-ATR-Widget/
ForexStoryteller
https://www.tradingview.com/u/ForexStoryteller/
83
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © xAverageJoex //@version=5 indicator(title="Multiple MAs + Trend/No-Trend Channel + ATR Widget", shorttitle="Mx MAs + TNTC + ATR", overlay=true) // ----- Globals string group1 = "- MA# -- Length ---------------- Type ---------------------- Source" string group2 = "------------- ATR Widget Settings -------------" string group3 = "------------- Hoffman Candle Recognition -------------" string group4 = "------------- Standard Candles Recognition -------------" // ----- FUNCTIONS ma(source, length, type) => type == "SMA" ? ta.sma(source, length) : type == "EMA" ? ta.ema(source, length) : type == "SMMA (RMA)" ? ta.rma(source, length) : type == "WMA" ? ta.wma(source, length) : type == "VWMA" ? ta.vwma(source, length) : na //-------------------------------------*********************************-------------------------------------// //-------------------------------------*********************************-------------------------------------// // ----- Moving Averages // -- MA#1 ma1_length = input.int(3 , "MA 1" , inline="MA #1", minval=1, group = group1) ma1_type = input.string("SMA" , "" , inline="MA #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma1_source = input(close , "" , inline="MA #1", group = group1) //ma1_color = input(#0000FF, "" , inline="MA #1", group = group1) ma1 = ma(ma1_source, ma1_length, ma1_type) plot(ma1, title="MA #1", linewidth = 1, color = #0000FF) // -- MA #2 ma2_length = input.int(5 , "MA 2" , inline="MA #2", minval=1, group = group1) ma2_type = input.string("SMA" , "" , inline="MA #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma2_source = input(close , "" , inline="MA #2", group = group1) //ma2_color = input(#143374, "" , inline="MA #2", group = group1) ma2 = ma(ma2_source, ma2_length, ma2_type) plot(ma2, title="MA #2", linewidth = 2, color = #143374) // -- MA #3 ma3_length = input.int(18 , "MA 3" , inline="MA #3", minval=1, group = group1) ma3_type = input.string("EMA" , "" , inline="MA #3", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma3_source = input(close , "" , inline="MA #3", group = group1) //ma3_color = input(#C8C8C8, "" , inline="MA #3", group = group1) ma3 = ma(ma3_source, ma3_length, ma3_type) plot(ma3, title="MA #3", linewidth = 1, color = #C8C8C8) // -- MA #4 ma4_length = input.int(20 , " MA 4" , inline="MA #4", minval=1, group = group1) ma4_type = input.string("EMA" , "" , inline="MA #4", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma4_source = input(close , "" , inline="MA #4", group = group1) //ma4_color = input(#00FF00, "" , inline="MA #4", group = group1) ma4 = ma(ma4_source, ma4_length, ma4_type) plot(ma4, title="MA #4", linewidth = 2, color = #00FF00) // -- MA #5 ma5_length = input.int(50 , "MA 5" , inline="MA #5", minval=1, group = group1) ma5_type = input.string("SMA" , "" , inline="MA #5", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma5_source = input(close , "" , inline="MA #5", group = group1) //ma5_color = input(#FFFF00, "" , inline="MA #5", group = group1) ma5 = ma(ma5_source, ma5_length, ma5_type) plot(ma5, title="MA #5", linewidth = 3, color = #FFFF00) // -- MA #6 ma6_length = input.int(89 , "MA 6" , inline="MA #6", minval=1, group = group1) ma6_type = input.string("SMA" , "" , inline="MA #6", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma6_source = input(close , "" , inline="MA #6", group = group1) //ma6_color = input(#FF4500, "" , inline="MA #6", group = group1) ma6 = ma(ma6_source, ma6_length, ma6_type) plot(ma6, title="MA #6", linewidth = 3, color = #FF4500, style=plot.style_circles) // -- MA #7 ma7_length = input.int(144 , "MA 7" , inline="MA #7", minval=1, group = group1) ma7_type = input.string("EMA" , "" , inline="MA #7", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma7_source = input(close , "" , inline="MA #7", group = group1) //ma7_color = input(#FF00FF, "" , inline="MA #7", group = group1) ma7 = ma(ma7_source, ma7_length, ma7_type) plot(ma7, title="MA #7", linewidth = 2, color = #FF00FF, style=plot.style_circles) // -- MA #8 ma8_length = input.int(200 , "MA 8" , inline="MA #8", minval=1, group = group1) ma8_type = input.string("SMA" , "" , inline="MA #8", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma8_source = input(close , "" , inline="MA #8", group = group1) //ma8_color = input(#00FFFF, "" , inline="MA #8", group = group1) ma8 = ma(ma8_source, ma8_length, ma8_type) plot(ma8, title="MA #8", linewidth = 2, color = #00FFFF, style=plot.style_circles) // -- MA #9 ma9_length = input.int(250 , "MA 9" , inline="MA #9", minval=1, group = group1) ma9_type = input.string("SMA" , "" , inline="MA #9", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma9_source = input(close , "" , inline="MA #9", group = group1) //ma9_color = input(#AAAAAA, "" , inline="MA #9", group = group1) ma9 = ma(ma9_source, ma9_length, ma9_type) plot(ma9, title="MA #9", linewidth = 2, color = #AAAAAA, style=plot.style_circles, display=display.none) // -- MA #10 ma10_length = input.int(255 , "MA 10" , inline="MA #10", minval=1, group = group1) ma10_type = input.string("SMA" , "" , inline="MA #10", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma10_source = input(close , "" , inline="MA #10", group = group1) //ma10_color = input(#20B2AA, "" , inline="MA #10", group = group1) ma10 = ma(ma10_source, ma10_length, ma10_type) plot(ma10, title="MA #10", linewidth = 3, color = #20B2AA, style=plot.style_circles, display=display.none) // -- MA #11 ma11_length = input.int(260 , "MA 11" , inline="MA #11", minval=1, group = group1) ma11_type = input.string("SMA" , "" , inline="MA #11", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma11_source = input(close , "" , inline="MA #11", group = group1) //ma11_color = input(#F0F0FF, "" , inline="MA #11", group = group1) ma11 = ma(ma11_source, ma11_length, ma11_type) plot(ma11, title="MA #11", linewidth = 3, color = #F0F0FF, style=plot.style_circles, display=display.none) // -- MA #12 ma12_length = input.int(265 , "MA 12" , inline="MA #12", minval=1, group = group1) ma12_type = input.string("SMA" , "" , inline="MA #12", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = group1) ma12_source = input(close , "" , inline="MA #12", group = group1) //ma12_color = input(#0FFF0F, "" , inline="MA #12", group = group1) ma12 = ma(ma12_source, ma12_length, ma12_type) plot(ma12, title="MA #12", linewidth = 3, color = #0FFF0F, style=plot.style_circles, display=display.none) //-------------------------------------*********************************-------------------------------------// //-------------------------------------*********************************-------------------------------------// // ----- ATR Widget atrShow = input.bool(defval = true, title = "Show ATR Widget?", tooltip = "Show a readable ATR number on the chart?", group = group2, inline = "MTF7") atrPeriod = input.int(defval = 14, minval = 2, step = 1, title = "Period", tooltip = "The period for the ATR value calculation", group = group2, inline = "MTF7") atrStyle = input.string(defval = "Forex Pips = 0.0001", options = ["Forex Pips = 0.0001", "Forex Pips/Stock/ETF/Indicies = 0.01"], title="ATR Style", group=group2, tooltip = "If you see some strange numbers in the readout, it may be because of this. Adjust for what you trade (0.0001 for pips, or 0.01 for everything else.)") int atrStyleSet = switch atrStyle "Forex Pips = 0.0001" => 1 "Forex Pips/Stock/ETF/Indicies = 0.01" => 2 atrTS = input.string(defval = "Normal", options = ["Tiny", "Small", "Normal", "Large", "Huge"], title="Widget Size", group=group2, tooltip = "Adjust the size of the text, which will change the size of the widget, great for multiple charts or mobile viewing.") string widgetSize = switch atrTS "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large "Huge" => size.huge tableRowStr = input.string(defval = "Column", title = "Display Style", options = ["Row", "Column"], tooltip = "Row or Column Orientation?", group = group2) string tableRow = switch tableRowStr "Row" => "true" "Column" => "false" tableLocation = input.string(defval="Bottom Right", options=["Top Right", "Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center", "Top Left", "Middle Left", "Bottom Left"], title="ATR Widget Location", group=group2, tooltip = "Where to place the ATR Widget in the pane.") atrSLSet = input.bool(defval = true, title = "Calculate Stop?", group = "------------- Stops & Targets -------------", inline = "MTF8") atrMultiple1 = input.float(defval = 2, minval = 0.1, step = 0.1, title = " SL - ATR Multiplier", group="------------- Stops & Targets -------------", tooltip = "Use this for quick calculations on the ATR automatically. For setting ATR based Stop Loss", inline = "MTF8") atrTPSet = input.bool(defval = true, title = "Calculate Take Profit?", group = "------------- Stops & Targets -------------", inline = "MTF9") atrMultiple2 = input.float(defval = 3, minval = 0.1, step = 0.1, title = "TP - ATR Multiplier", tooltip = "Use this for quick calculations on the ATR automatically. For setting ATR based Profit Target", group="------------- Stops & Targets -------------", inline = "MTF9") string tablePos = switch tableLocation "Top Right" => position.top_right "Middle Right" => position.middle_right "Bottom Right" => position.bottom_right "Top Center" => position.top_center "Middle Center" => position.middle_center "Bottom Center" => position.bottom_center "Top Left" => position.top_left "Middle Left" => position.middle_left "Bottom Left" => position.bottom_left atr1 = ta.atr(atrPeriod) float atr = 0 if atrStyleSet == 1 atr1 := (atr1 + 0.000005) * 100000 atr := int(atr1) / 10 else atr1 := (atr1 + 0.005) * 100 atr := int(atr1) / 100 atrSL = atr * atrMultiple1 atrTP = atr * atrMultiple2 //-------------------------------------*********************************-------------------------------------// //-------------------------------------*********************************-------------------------------------// // ----- ATR TABLE PLOTTING tColor = input.color(color.white, title = "Text", group = "------------- ATR Widget Colors -------------", inline = "MTF10") bgColor = input.color(color.black, title = "Background", group = "------------- ATR Widget Colors -------------", inline = "MTF10") frColor = input.color(color.yellow, title = "Frame", group = "------------- ATR Widget Colors -------------", inline = "MTF10") frameSize = input.int(defval = 3, minval = 0, step = 1, title = "Border Frame Size", tooltip = "How wide will the border be around the widget? (In pixels, set to 0 to make it disappear)", group = "------------- ATR Widget Colors -------------") if tableRow == "true" var table ATRTable = table.new(tablePos, 3, 1, frame_width = frameSize, frame_color = frColor) string tx1 = "ATR - " + str.tostring (atr) string tx2 = "SL (" + str.tostring(atrMultiple1) + "x) =" + str.tostring (atrSL) string tx3 = "TP (" + str.tostring(atrMultiple2) + "x) =" + str.tostring (atrTP) if atrShow == true table.cell(ATRTable, 0, 0, tx1, bgcolor = bgColor, text_color=tColor, text_size = widgetSize) if atrSLSet == true and atrShow == true table.cell(ATRTable, 1, 0, tx2, bgcolor = bgColor, text_color=tColor, text_size = widgetSize) if atrTPSet == true and atrShow == true table.cell(ATRTable, 2, 0, tx3, bgcolor = bgColor, text_color=tColor, text_size = widgetSize) else var table ATRTable = table.new(tablePos, 1, 3, frame_width = frameSize, frame_color = frColor) string tx1 = "ATR - " + str.tostring (atr) string tx2 = "SL (" + str.tostring(atrMultiple1) + "x) =" + str.tostring (atrSL) string tx3 = "TP (" + str.tostring(atrMultiple2) + "x) =" + str.tostring (atrTP) if atrShow == true table.cell(ATRTable, 0, 0, tx1, bgcolor = bgColor, text_color=tColor, text_size = widgetSize) if atrSLSet == true and atrShow == true table.cell(ATRTable, 0, 1, tx2, bgcolor = bgColor, text_color=tColor, text_size = widgetSize) if atrTPSet == true and atrShow == true table.cell(ATRTable, 0, 2, tx3, bgcolor = bgColor, text_color=tColor, text_size = widgetSize) //-------------------------------------*********************************-------------------------------------// //-------------------------------------*********************************-------------------------------------// // ----- Candle Pattern Recognition // ----- Hoffman IRB - Inventory Retracement Bars from @UCSGEARS "Rob Hoffman's Inventory Retracement Bar" irbShow = input.bool(true, title = "Hoffman Inventory Retracement Bar/Candles", group = group3) rz = input.int(45, title="Inventory Retracement Percentage %", maxval=100, tooltip = "Hoffman Inventory Retracement Bar (Hoffman IRB for short) Default is 45%, but Rob says even 40 is ok sometimes... Use your own judgement :) Check the Styles tab for 'Hoffman IRB' title settings", group = group3) // Candle Range rba = math.abs(high - low) // Candle Body rbb = math.abs(close - open) // Percent to Decimal rbc = rz/100 // Range Verification rv = rbb < rbc*rba // Price Level for Retracement rx = low + (rbc * rba) ry = high - (rbc * rba) rsl = rv == 1 and high > ry and close < ry and open < ry rss = rv == 1 and low < rx and close > rx and open > rx // Plot Statement plotshape(irbShow ? rsl : na , style=shape.triangleup, location=location.abovebar, color = color.green, title = "Hoffman IRB - Long Bar") plotshape(irbShow ? rss : na, style=shape.triangledown, location=location.belowbar, color = color.red, title = "Hoffman IRB - Short Bar") // Line Definition rli = rsl ? ry : rss ? rx : (rx+ry)/2 plot(rli, style = plot.style_line, color = color.blue, title = "Hoffman IRB - Inventory Bar Retracement Price Line", display = display.none) //-------------------------------------*********************************-------------------------------------// //-------------------------------------*********************************-------------------------------------// // START ----- *All Candlestick Patterns* Source : C_DownTrend = true C_UpTrend = true var trendRule1 = "SMA50" var trendRule2 = "SMA50, SMA200" var trendRule = input.string(trendRule1, "Detect Trend Based On", options=[trendRule1, trendRule2, "No detection"], group = group4) if trendRule == trendRule1 priceAvg = ta.sma(close, 50) C_DownTrend := close < priceAvg C_UpTrend := close > priceAvg if trendRule == trendRule2 sma200 = ta.sma(close, 200) sma50 = ta.sma(close, 50) C_DownTrend := close < sma50 and sma50 < sma200 C_UpTrend := close > sma50 and sma50 > sma200 C_Len = 14 // ta.ema depth for bodyAvg C_ShadowPercent = 5.0 // size of shadows C_ShadowEqualsPercent = 100.0 C_DojiBodyPercent = 5.0 C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body C_BodyHi = math.max(close, open) C_BodyLo = math.min(close, open) C_Body = C_BodyHi - C_BodyLo C_BodyAvg = ta.ema(C_Body, C_Len) C_SmallBody = C_Body < C_BodyAvg C_LongBody = C_Body > C_BodyAvg C_UpShadow = high - C_BodyHi C_DnShadow = C_BodyLo - low C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body C_WhiteBody = open < close C_BlackBody = open > close C_Range = high-low C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo C_BodyMiddle = C_Body / 2 + C_BodyLo C_ShadowEquals = C_UpShadow == C_DnShadow or (math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100 C_Doji = C_IsDojiBody and C_ShadowEquals patternLabelPosLow = low - (ta.atr(30) * 0.6) patternLabelPosHigh = high + (ta.atr(30) * 0.6) label_color_bullish = input(color.blue, "Label Color Bullish") label_color_bearish = input(color.red, "Label Color Bearish") label_color_neutral = input(color.gray, "Label Color Neutral") CandleType = input.string(title = "Pattern Type", defval="Both", options=["Bullish", "Bearish", "Both"]) AbandonedBabyInput = input(title = "Abandoned Baby" ,defval=false) DarkCloudCoverInput = input(title = "Dark Cloud Cover" ,defval=false) DojiInput = input(title = "Doji" ,defval=false) DojiStarInput = input(title = "Doji Star" ,defval=false) DownsideTasukiGapInput = input(title = "Downside Tasuki Gap" ,defval=false) DragonflyDojiInput = input(title = "Dragonfly Doji" ,defval=false) EngulfingInput = input(title = "Engulfing" ,defval=true) EveningDojiStarInput = input(title = "Evening Doji Star" ,defval=false) EveningStarInput = input(title = "Evening Star" ,defval=false) FallingThreeMethodsInput = input(title = "Falling Three Methods" ,defval=false) FallingWindowInput = input(title = "Falling Window" ,defval=false) GravestoneDojiInput = input(title = "Gravestone Doji" ,defval=false) HammerInput = input(title = "Hammer" ,defval=true) HangingManInput = input(title = "Hanging Man" ,defval=false) HaramiCrossInput = input(title = "Harami Cross" ,defval=false) HaramiInput = input(title = "Harami" ,defval=false) InvertedHammerInput = input(title = "Inverted Hammer" ,defval=true) KickingInput = input(title = "Kicking" ,defval=false) LongLowerShadowInput = input(title = "Long Lower Shadow" ,defval=false) LongUpperShadowInput = input(title = "Long Upper Shadow" ,defval=false) MarubozuBlackInput = input(title = "Marubozu Black" ,defval=false) MarubozuWhiteInput = input(title = "Marubozu White" ,defval=false) MorningDojiStarInput = input(title = "Morning Doji Star" ,defval=false) MorningStarInput = input(title = "Morning Star" ,defval=false) OnNeckInput = input(title = "On Neck" ,defval=false) PiercingInput = input(title = "Piercing" ,defval=false) RisingThreeMethodsInput = input(title = "Rising Three Methods" ,defval=false) RisingWindowInput = input(title = "Rising Window" ,defval=false) ShootingStarInput = input(title = "Shooting Star" ,defval=false) SpinningTopBlackInput = input(title = "Spinning Top Black" ,defval=false) SpinningTopWhiteInput = input(title = "Spinning Top White" ,defval=false) ThreeBlackCrowsInput = input(title = "Three Black Crows" ,defval=false) ThreeWhiteSoldiersInput = input(title = "Three White Soldiers" ,defval=false) TriStarInput = input(title = "Tri-Star" ,defval=false) TweezerBottomInput = input(title = "Tweezer Bottom" ,defval=false) TweezerTopInput = input(title = "Tweezer Top" ,defval=false) UpsideTasukiGapInput = input(title = "Upside Tasuki Gap" ,defval=false) C_OnNeckBearishNumberOfCandles = 2 C_OnNeckBearish = false if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_WhiteBody and open < close[1] and C_SmallBody and C_Range!=0 and math.abs(close-low[1])<=C_BodyAvg*0.05 C_OnNeckBearish := true alertcondition(C_OnNeckBearish, title = "On Neck – Bearish", message = "New On Neck – Bearish pattern detected") if C_OnNeckBearish and OnNeckInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishOnNeck = "On Neck\nOn Neck is a two-line continuation pattern found in a downtrend. The first candle is long and red, the second candle is short and has a green body. The closing price of the second candle is close or equal to the first candle's low price. The pattern hints at a continuation of a downtrend, and penetrating the low of the green candlestick is sometimes considered a confirmation. " label.new(bar_index, patternLabelPosHigh, text="ON", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishOnNeck) C_RisingWindowBullishNumberOfCandles = 2 C_RisingWindowBullish = false if C_UpTrend[1] and (C_Range!=0 and C_Range[1]!=0) and low > high[1] C_RisingWindowBullish := true alertcondition(C_RisingWindowBullish, title = "Rising Window – Bullish", message = "New Rising Window – Bullish pattern detected") if C_RisingWindowBullish and RisingWindowInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishRisingWindow = "Rising Window\nRising Window is a two-candle bullish continuation pattern that forms during an uptrend. Both candles in the pattern can be of any type with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's high and the second candle's low. That gap (window) between two bars signifies support against the selling pressure." label.new(bar_index, patternLabelPosLow, text="RW", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishRisingWindow) C_FallingWindowBearishNumberOfCandles = 2 C_FallingWindowBearish = false if C_DownTrend[1] and (C_Range!=0 and C_Range[1]!=0) and high < low[1] C_FallingWindowBearish := true alertcondition(C_FallingWindowBearish, title = "Falling Window – Bearish", message = "New Falling Window – Bearish pattern detected") if C_FallingWindowBearish and FallingWindowInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishFallingWindow = "Falling Window\nFalling Window is a two-candle bearish continuation pattern that forms during a downtrend. Both candles in the pattern can be of any type, with the exception of the Four-Price Doji. The most important characteristic of the pattern is a price gap between the first candle's low and the second candle's high. The existence of this gap (window) means that the bearish trend is expected to continue." label.new(bar_index, patternLabelPosHigh, text="FW", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingWindow) C_FallingThreeMethodsBearishNumberOfCandles = 5 C_FallingThreeMethodsBearish = false if C_DownTrend[4] and (C_LongBody[4] and C_BlackBody[4]) and (C_SmallBody[3] and C_WhiteBody[3] and open[3]>low[4] and close[3]<high[4]) and (C_SmallBody[2] and C_WhiteBody[2] and open[2]>low[4] and close[2]<high[4]) and (C_SmallBody[1] and C_WhiteBody[1] and open[1]>low[4] and close[1]<high[4]) and (C_LongBody and C_BlackBody and close<close[4]) C_FallingThreeMethodsBearish := true alertcondition(C_FallingThreeMethodsBearish, title = "Falling Three Methods – Bearish", message = "New Falling Three Methods – Bearish pattern detected") if C_FallingThreeMethodsBearish and FallingThreeMethodsInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishFallingThreeMethods = "Falling Three Methods\nFalling Three Methods is a five-candle bearish pattern that signifies a continuation of an existing downtrend. The first candle is long and red, followed by three short green candles with bodies inside the range of the first candle. The last candle is also red and long and it closes below the close of the first candle. This decisive fifth strongly bearish candle hints that bulls could not reverse the prior downtrend and that bears have regained control of the market." label.new(bar_index, patternLabelPosHigh, text="FTM", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishFallingThreeMethods) C_RisingThreeMethodsBullishNumberOfCandles = 5 C_RisingThreeMethodsBullish = false if C_UpTrend[4] and (C_LongBody[4] and C_WhiteBody[4]) and (C_SmallBody[3] and C_BlackBody[3] and open[3]<high[4] and close[3]>low[4]) and (C_SmallBody[2] and C_BlackBody[2] and open[2]<high[4] and close[2]>low[4]) and (C_SmallBody[1] and C_BlackBody[1] and open[1]<high[4] and close[1]>low[4]) and (C_LongBody and C_WhiteBody and close>close[4]) C_RisingThreeMethodsBullish := true alertcondition(C_RisingThreeMethodsBullish, title = "Rising Three Methods – Bullish", message = "New Rising Three Methods – Bullish pattern detected") if C_RisingThreeMethodsBullish and RisingThreeMethodsInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishRisingThreeMethods = "Rising Three Methods\nRising Three Methods is a five-candle bullish pattern that signifies a continuation of an existing uptrend. The first candle is long and green, followed by three short red candles with bodies inside the range of the first candle. The last candle is also green and long and it closes above the close of the first candle. This decisive fifth strongly bullish candle hints that bears could not reverse the prior uptrend and that bulls have regained control of the market." label.new(bar_index, patternLabelPosLow, text="RTM", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishRisingThreeMethods) C_TweezerTopBearishNumberOfCandles = 2 C_TweezerTopBearish = false if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and math.abs(high-high[1]) <= C_BodyAvg*0.05 and C_WhiteBody[1] and C_BlackBody and C_LongBody[1] C_TweezerTopBearish := true alertcondition(C_TweezerTopBearish, title = "Tweezer Top – Bearish", message = "New Tweezer Top – Bearish pattern detected") if C_TweezerTopBearish and TweezerTopInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishTweezerTop = "Tweezer Top\nTweezer Top is a two-candle pattern that signifies a potential bearish reversal. The pattern is found during an uptrend. The first candle is long and green, the second candle is red, and its high is nearly identical to the high of the previous candle. The virtually identical highs, together with the inverted directions, hint that bears might be taking over the market." label.new(bar_index, patternLabelPosHigh, text="TT", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishTweezerTop) C_TweezerBottomBullishNumberOfCandles = 2 C_TweezerBottomBullish = false if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and math.abs(low-low[1]) <= C_BodyAvg*0.05 and C_BlackBody[1] and C_WhiteBody and C_LongBody[1] C_TweezerBottomBullish := true alertcondition(C_TweezerBottomBullish, title = "Tweezer Bottom – Bullish", message = "New Tweezer Bottom – Bullish pattern detected") if C_TweezerBottomBullish and TweezerBottomInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishTweezerBottom = "Tweezer Bottom\nTweezer Bottom is a two-candle pattern that signifies a potential bullish reversal. The pattern is found during a downtrend. The first candle is long and red, the second candle is green, its lows nearly identical to the low of the previous candle. The virtually identical lows together with the inverted directions hint that bulls might be taking over the market." label.new(bar_index, patternLabelPosLow, text="TB", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishTweezerBottom) C_DarkCloudCoverBearishNumberOfCandles = 2 C_DarkCloudCoverBearish = false if (C_UpTrend[1] and C_WhiteBody[1] and C_LongBody[1]) and (C_BlackBody and open >= high[1] and close < C_BodyMiddle[1] and close > open[1]) C_DarkCloudCoverBearish := true alertcondition(C_DarkCloudCoverBearish, title = "Dark Cloud Cover – Bearish", message = "New Dark Cloud Cover – Bearish pattern detected") if C_DarkCloudCoverBearish and DarkCloudCoverInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishDarkCloudCover = "Dark Cloud Cover\nDark Cloud Cover is a two-candle bearish reversal candlestick pattern found in an uptrend. The first candle is green and has a larger than average body. The second candle is red and opens above the high of the prior candle, creating a gap, and then closes below the midpoint of the first candle. The pattern shows a possible shift in the momentum from the upside to the downside, indicating that a reversal might happen soon." label.new(bar_index, patternLabelPosHigh, text="DCC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDarkCloudCover) C_DownsideTasukiGapBearishNumberOfCandles = 3 C_DownsideTasukiGapBearish = false if C_LongBody[2] and C_SmallBody[1] and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_BlackBody[1] and C_WhiteBody and C_BodyHi <= C_BodyLo[2] and C_BodyHi >= C_BodyHi[1] C_DownsideTasukiGapBearish := true alertcondition(C_DownsideTasukiGapBearish, title = "Downside Tasuki Gap – Bearish", message = "New Downside Tasuki Gap – Bearish pattern detected") if C_DownsideTasukiGapBearish and DownsideTasukiGapInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishDownsideTasukiGap = "Downside Tasuki Gap\nDownside Tasuki Gap is a three-candle pattern found in a downtrend that usually hints at the continuation of the downtrend. The first candle is long and red, followed by a smaller red candle with its opening price that gaps below the body of the previous candle. The third candle is green and it closes inside the gap created by the first two candles, unable to close it fully. The bull’s inability to close that gap hints that the downtrend might continue." label.new(bar_index, patternLabelPosHigh, text="DTG", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDownsideTasukiGap) C_UpsideTasukiGapBullishNumberOfCandles = 3 C_UpsideTasukiGapBullish = false if C_LongBody[2] and C_SmallBody[1] and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_WhiteBody[1] and C_BlackBody and C_BodyLo >= C_BodyHi[2] and C_BodyLo <= C_BodyLo[1] C_UpsideTasukiGapBullish := true alertcondition(C_UpsideTasukiGapBullish, title = "Upside Tasuki Gap – Bullish", message = "New Upside Tasuki Gap – Bullish pattern detected") if C_UpsideTasukiGapBullish and UpsideTasukiGapInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishUpsideTasukiGap = "Upside Tasuki Gap\nUpside Tasuki Gap is a three-candle pattern found in an uptrend that usually hints at the continuation of the uptrend. The first candle is long and green, followed by a smaller green candle with its opening price that gaps above the body of the previous candle. The third candle is red and it closes inside the gap created by the first two candles, unable to close it fully. The bear’s inability to close the gap hints that the uptrend might continue." label.new(bar_index, patternLabelPosLow, text="UTG", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishUpsideTasukiGap) C_EveningDojiStarBearishNumberOfCandles = 3 C_EveningDojiStarBearish = false if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi C_EveningDojiStarBearish := true alertcondition(C_EveningDojiStarBearish, title = "Evening Doji Star – Bearish", message = "New Evening Doji Star – Bearish pattern detected") if C_EveningDojiStarBearish and EveningDojiStarInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishEveningDojiStar = "Evening Doji Star\nThis candlestick pattern is a variation of the Evening Star pattern. It is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gap and a Doji candle and concludes with a downward close. The close would be below the first day’s midpoint. It is more bearish than the regular evening star pattern because of the existence of the Doji." label.new(bar_index, patternLabelPosHigh, text="EDS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEveningDojiStar) C_DojiStarBearishNumberOfCandles = 2 C_DojiStarBearish = false if C_UpTrend and C_WhiteBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyLo > C_BodyHi[1] C_DojiStarBearish := true alertcondition(C_DojiStarBearish, title = "Doji Star – Bearish", message = "New Doji Star – Bearish pattern detected") if C_DojiStarBearish and DojiStarInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishDojiStar = "Doji Star\nThis is a bearish reversal candlestick pattern that is found in an uptrend and consists of two candles. First comes a long green candle, followed by a Doji candle (except 4-Price Doji) that opens above the body of the first one, creating a gap. It is considered a reversal signal with confirmation during the next trading day." label.new(bar_index, patternLabelPosHigh, text="DS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishDojiStar) C_DojiStarBullishNumberOfCandles = 2 C_DojiStarBullish = false if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyHi < C_BodyLo[1] C_DojiStarBullish := true alertcondition(C_DojiStarBullish, title = "Doji Star – Bullish", message = "New Doji Star – Bullish pattern detected") if C_DojiStarBullish and DojiStarInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishDojiStar = "Doji Star\nThis is a bullish reversal candlestick pattern that is found in a downtrend and consists of two candles. First comes a long red candle, followed by a Doji candle (except 4-Price Doji) that opens below the body of the first one, creating a gap. It is considered a reversal signal with confirmation during the next trading day." label.new(bar_index, patternLabelPosLow, text="DS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishDojiStar) C_MorningDojiStarBullishNumberOfCandles = 3 C_MorningDojiStarBullish = false if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo C_MorningDojiStarBullish := true alertcondition(C_MorningDojiStarBullish, title = "Morning Doji Star – Bullish", message = "New Morning Doji Star – Bullish pattern detected") if C_MorningDojiStarBullish and MorningDojiStarInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishMorningDojiStar = "Morning Doji Star\nThis candlestick pattern is a variation of the Morning Star pattern. A three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a Doji that gaps down on the open. After that comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day. It is more bullish than the regular morning star pattern because of the existence of the Doji." label.new(bar_index, patternLabelPosLow, text="MDS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMorningDojiStar) C_PiercingBullishNumberOfCandles = 2 C_PiercingBullish = false if (C_DownTrend[1] and C_BlackBody[1] and C_LongBody[1]) and (C_WhiteBody and open <= low[1] and close > C_BodyMiddle[1] and close < open[1]) C_PiercingBullish := true alertcondition(C_PiercingBullish, title = "Piercing – Bullish", message = "New Piercing – Bullish pattern detected") if C_PiercingBullish and PiercingInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishPiercing = "Piercing\nPiercing is a two-candle bullish reversal candlestick pattern found in a downtrend. The first candle is red and has a larger than average body. The second candle is green and opens below the low of the prior candle, creating a gap, and then closes above the midpoint of the first candle. The pattern shows a possible shift in the momentum from the downside to the upside, indicating that a reversal might happen soon." label.new(bar_index, patternLabelPosLow, text="P", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishPiercing) C_HammerBullishNumberOfCandles = 1 C_HammerBullish = false if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow if C_DownTrend C_HammerBullish := true alertcondition(C_HammerBullish, title = "Hammer – Bullish", message = "New Hammer – Bullish pattern detected") if C_HammerBullish and HammerInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishHammer = "Hammer\nHammer candlesticks form when a security moves lower after the open, but continues to rally into close above the intraday low. The candlestick that you are left with will look like a square attached to a long stick-like figure. This candlestick is called a Hammer if it happens to form during a decline." label.new(bar_index, patternLabelPosLow, text="H", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHammer) C_HangingManBearishNumberOfCandles = 1 C_HangingManBearish = false if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow if C_UpTrend C_HangingManBearish := true alertcondition(C_HangingManBearish, title = "Hanging Man – Bearish", message = "New Hanging Man – Bearish pattern detected") if C_HangingManBearish and HangingManInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishHangingMan = "Hanging Man\nWhen a specified security notably moves lower after the open, but continues to rally to close above the intraday low, a Hanging Man candlestick will form. The candlestick will resemble a square, attached to a long stick-like figure. It is referred to as a Hanging Man if the candlestick forms during an advance." label.new(bar_index, patternLabelPosHigh, text="HM", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHangingMan) C_ShootingStarBearishNumberOfCandles = 1 C_ShootingStarBearish = false if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow if C_UpTrend C_ShootingStarBearish := true alertcondition(C_ShootingStarBearish, title = "Shooting Star – Bearish", message = "New Shooting Star – Bearish pattern detected") if C_ShootingStarBearish and ShootingStarInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishShootingStar = "Shooting Star\nThis single day pattern can appear during an uptrend and opens high, while it closes near its open. It trades much higher as well. It is bearish in nature, but looks like an Inverted Hammer." label.new(bar_index, patternLabelPosHigh, text="SS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishShootingStar) C_InvertedHammerBullishNumberOfCandles = 1 C_InvertedHammerBullish = false if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow if C_DownTrend C_InvertedHammerBullish := true alertcondition(C_InvertedHammerBullish, title = "Inverted Hammer – Bullish", message = "New Inverted Hammer – Bullish pattern detected") if C_InvertedHammerBullish and InvertedHammerInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishInvertedHammer = "Inverted Hammer\nIf in a downtrend, then the open is lower. When it eventually trades higher, but closes near its open, it will look like an inverted version of the Hammer Candlestick. This is a one-day bullish reversal pattern." label.new(bar_index, patternLabelPosLow, text="IH", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishInvertedHammer) C_MorningStarBullishNumberOfCandles = 3 C_MorningStarBullish = false if C_LongBody[2] and C_SmallBody[1] and C_LongBody if C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo C_MorningStarBullish := true alertcondition(C_MorningStarBullish, title = "Morning Star – Bullish", message = "New Morning Star – Bullish pattern detected") if C_MorningStarBullish and MorningStarInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishMorningStar = "Morning Star\nA three-day bullish reversal pattern, which consists of three candlesticks will look something like this: The first being a long-bodied red candle that extends the current downtrend. Next comes a short, middle candle that gaps down on the open. After comes a long-bodied green candle, which gaps up on the open and closes above the midpoint of the body of the first day." label.new(bar_index, patternLabelPosLow, text="MS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMorningStar) C_EveningStarBearishNumberOfCandles = 3 C_EveningStarBearish = false if C_LongBody[2] and C_SmallBody[1] and C_LongBody if C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi C_EveningStarBearish := true alertcondition(C_EveningStarBearish, title = "Evening Star – Bearish", message = "New Evening Star – Bearish pattern detected") if C_EveningStarBearish and EveningStarInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishEveningStar = "Evening Star\nThis candlestick pattern is bearish and continues an uptrend with a long-bodied, green candle day. It is then followed by a gapped and small-bodied candle day, and concludes with a downward close. The close would be below the first day’s midpoint." label.new(bar_index, patternLabelPosHigh, text="ES", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEveningStar) C_MarubozuWhiteBullishNumberOfCandles = 1 C_MarubozuShadowPercentWhite = 5.0 C_MarubozuWhiteBullish = C_WhiteBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_WhiteBody alertcondition(C_MarubozuWhiteBullish, title = "Marubozu White – Bullish", message = "New Marubozu White – Bullish pattern detected") if C_MarubozuWhiteBullish and MarubozuWhiteInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishMarubozuWhite = "Marubozu White\nA Marubozu White Candle is a candlestick that does not have a shadow that extends from its candle body at either the open or the close. Marubozu is Japanese for “close-cropped” or “close-cut.” Other sources may call it a Bald or Shaven Head Candle." label.new(bar_index, patternLabelPosLow, text="MW", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishMarubozuWhite) C_MarubozuBlackBearishNumberOfCandles = 1 C_MarubozuShadowPercentBearish = 5.0 C_MarubozuBlackBearish = C_BlackBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_DnShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_BlackBody alertcondition(C_MarubozuBlackBearish, title = "Marubozu Black – Bearish", message = "New Marubozu Black – Bearish pattern detected") if C_MarubozuBlackBearish and MarubozuBlackInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishMarubozuBlack = "Marubozu Black\nThis is a candlestick that has no shadow, which extends from the red-bodied candle at the open, the close, or even at both. In Japanese, the name means “close-cropped” or “close-cut.” The candlestick can also be referred to as Bald or Shaven Head." label.new(bar_index, patternLabelPosHigh, text="MB", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishMarubozuBlack) C_DojiNumberOfCandles = 1 C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne, title = "Doji", message = "New Doji pattern detected") if C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne and DojiInput var ttDoji = "Doji\nWhen the open and close of a security are essentially equal to each other, a doji candle forms. The length of both upper and lower shadows may vary, causing the candlestick you are left with to either resemble a cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-seller indecision in a tug-of-war of sorts. As price moves either above or below the opening level during the session, the close is either at or near the opening level." label.new(bar_index, patternLabelPosLow, text="D", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttDoji) C_GravestoneDojiBearishNumberOfCandles = 1 C_GravestoneDojiBearish = C_IsDojiBody and C_DnShadow <= C_Body alertcondition(C_GravestoneDojiBearish, title = "Gravestone Doji – Bearish", message = "New Gravestone Doji – Bearish pattern detected") if C_GravestoneDojiBearish and GravestoneDojiInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishGravestoneDoji = "Gravestone Doji\nWhen a doji is at or is close to the day’s low point, a doji line will develop." label.new(bar_index, patternLabelPosHigh, text="GD", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishGravestoneDoji) C_DragonflyDojiBullishNumberOfCandles = 1 C_DragonflyDojiBullish = C_IsDojiBody and C_UpShadow <= C_Body alertcondition(C_DragonflyDojiBullish, title = "Dragonfly Doji – Bullish", message = "New Dragonfly Doji – Bullish pattern detected") if C_DragonflyDojiBullish and DragonflyDojiInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishDragonflyDoji = "Dragonfly Doji\nSimilar to other Doji days, this particular Doji also regularly appears at pivotal market moments. This is a specific Doji where both the open and close price are at the high of a given day." label.new(bar_index, patternLabelPosLow, text="DD", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishDragonflyDoji) C_HaramiCrossBullishNumberOfCandles = 2 C_HaramiCrossBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiCrossBullish, title = "Harami Cross – Bullish", message = "New Harami Cross – Bullish pattern detected") if C_HaramiCrossBullish and HaramiCrossInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishHaramiCross = "Harami Cross\nThis candlestick pattern is a variation of the Harami Bullish pattern. It is found during a downtrend. The two-day candlestick pattern consists of a Doji candle that is entirely encompassed within the body of what was once a red-bodied candle." label.new(bar_index, patternLabelPosLow, text="HC", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHaramiCross) C_HaramiCrossBearishNumberOfCandles = 2 C_HaramiCrossBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiCrossBearish, title = "Harami Cross – Bearish", message = "New Harami Cross – Bearish pattern detected") if C_HaramiCrossBearish and HaramiCrossInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishHaramiCross = "Harami Cross\nThis candlestick pattern is a variation of the Harami Bearish pattern. It is found during an uptrend. This is a two-day candlestick pattern with a Doji candle that is entirely encompassed within the body that was once a green-bodied candle. The Doji shows that some indecision has entered the minds of sellers, and the pattern hints that the trend might reverse." label.new(bar_index, patternLabelPosHigh, text="HC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHaramiCross) C_HaramiBullishNumberOfCandles = 2 C_HaramiBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_WhiteBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiBullish, title = "Harami – Bullish", message = "New Harami – Bullish pattern detected") if C_HaramiBullish and HaramiInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishHarami = "Harami\nThis two-day candlestick pattern consists of a small-bodied green candle that is entirely encompassed within the body of what was once a red-bodied candle." label.new(bar_index, patternLabelPosLow, text="BH", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishHarami) C_HaramiBearishNumberOfCandles = 2 C_HaramiBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_BlackBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] alertcondition(C_HaramiBearish, title = "Harami – Bearish", message = "New Harami – Bearish pattern detected") if C_HaramiBearish and HaramiInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishHarami = "Harami\nThis is a two-day candlestick pattern with a small, red-bodied candle that is entirely encompassed within the body that was once a green-bodied candle." label.new(bar_index, patternLabelPosHigh, text="BH", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishHarami) C_LongLowerShadowBullishNumberOfCandles = 1 C_LongLowerShadowPercent = 75.0 C_LongLowerShadowBullish = C_DnShadow > C_Range/100*C_LongLowerShadowPercent alertcondition(C_LongLowerShadowBullish, title = "Long Lower Shadow – Bullish", message = "New Long Lower Shadow – Bullish pattern detected") if C_LongLowerShadowBullish and LongLowerShadowInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishLongLowerShadow = "Long Lower Shadow\nTo indicate seller domination of the first part of a session, candlesticks will present with long lower shadows and short upper shadows, consequently lowering prices." label.new(bar_index, patternLabelPosLow, text="LLS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishLongLowerShadow) C_LongUpperShadowBearishNumberOfCandles = 1 C_LongShadowPercent = 75.0 C_LongUpperShadowBearish = C_UpShadow > C_Range/100*C_LongShadowPercent alertcondition(C_LongUpperShadowBearish, title = "Long Upper Shadow – Bearish", message = "New Long Upper Shadow – Bearish pattern detected") if C_LongUpperShadowBearish and LongUpperShadowInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishLongUpperShadow = "Long Upper Shadow\nTo indicate buyer domination of the first part of a session, candlesticks will present with long upper shadows, as well as short lower shadows, consequently raising bidding prices." label.new(bar_index, patternLabelPosHigh, text="LUS", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishLongUpperShadow) C_SpinningTopWhiteNumberOfCandles = 1 C_SpinningTopWhitePercent = 34.0 C_IsSpinningTopWhite = C_DnShadow >= C_Range / 100 * C_SpinningTopWhitePercent and C_UpShadow >= C_Range / 100 * C_SpinningTopWhitePercent and not C_IsDojiBody C_SpinningTopWhite = C_IsSpinningTopWhite and C_WhiteBody alertcondition(C_SpinningTopWhite, title = "Spinning Top White", message = "New Spinning Top White pattern detected") if C_SpinningTopWhite and SpinningTopWhiteInput var ttSpinningTopWhite = "Spinning Top White\nWhite spinning tops are candlestick lines that are small, green-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision between buyer and seller." label.new(bar_index, patternLabelPosLow, text="STW", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttSpinningTopWhite) C_SpinningTopBlackNumberOfCandles = 1 C_SpinningTopBlackPercent = 34.0 C_IsSpinningTop = C_DnShadow >= C_Range / 100 * C_SpinningTopBlackPercent and C_UpShadow >= C_Range / 100 * C_SpinningTopBlackPercent and not C_IsDojiBody C_SpinningTopBlack = C_IsSpinningTop and C_BlackBody alertcondition(C_SpinningTopBlack, title = "Spinning Top Black", message = "New Spinning Top Black pattern detected") if C_SpinningTopBlack and SpinningTopBlackInput var ttSpinningTopBlack = "Spinning Top Black\nBlack spinning tops are candlestick lines that are small, red-bodied, and possess shadows (upper and lower) that end up exceeding the length of candle bodies. They often signal indecision." label.new(bar_index, patternLabelPosLow, text="STB", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttSpinningTopBlack) C_ThreeWhiteSoldiersBullishNumberOfCandles = 3 C_3WSld_ShadowPercent = 5.0 C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow C_ThreeWhiteSoldiersBullish = false if C_LongBody and C_LongBody[1] and C_LongBody[2] if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2] C_ThreeWhiteSoldiersBullish := close > close[1] and close[1] > close[2] and open < close[1] and open > open[1] and open[1] < close[2] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2] alertcondition(C_ThreeWhiteSoldiersBullish, title = "Three White Soldiers – Bullish", message = "New Three White Soldiers – Bullish pattern detected") if C_ThreeWhiteSoldiersBullish and ThreeWhiteSoldiersInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishThreeWhiteSoldiers = "Three White Soldiers\nThis bullish reversal pattern is made up of three long-bodied, green candles in immediate succession. Each one opens within the body before it and the close is near to the daily high." label.new(bar_index, patternLabelPosLow, text="3WS", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishThreeWhiteSoldiers) C_ThreeBlackCrowsBearishNumberOfCandles = 3 C_3BCrw_ShadowPercent = 5.0 C_3BCrw_HaveNotDnShadow = C_Range * C_3BCrw_ShadowPercent / 100 > C_DnShadow C_ThreeBlackCrowsBearish = false if C_LongBody and C_LongBody[1] and C_LongBody[2] if C_BlackBody and C_BlackBody[1] and C_BlackBody[2] C_ThreeBlackCrowsBearish := close < close[1] and close[1] < close[2] and open > close[1] and open < open[1] and open[1] > close[2] and open[1] < open[2] and C_3BCrw_HaveNotDnShadow and C_3BCrw_HaveNotDnShadow[1] and C_3BCrw_HaveNotDnShadow[2] alertcondition(C_ThreeBlackCrowsBearish, title = "Three Black Crows – Bearish", message = "New Three Black Crows – Bearish pattern detected") if C_ThreeBlackCrowsBearish and ThreeBlackCrowsInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishThreeBlackCrows = "Three Black Crows\nThis is a bearish reversal pattern that consists of three long, red-bodied candles in immediate succession. For each of these candles, each day opens within the body of the day before and closes either at or near its low." label.new(bar_index, patternLabelPosHigh, text="3BC", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishThreeBlackCrows) C_EngulfingBullishNumberOfCandles = 2 C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and C_SmallBody[1] and close >= open[1] and open <= close[1] and ( close > open[1] or open < close[1] ) alertcondition(C_EngulfingBullish, title = "Engulfing – Bullish", message = "New Engulfing – Bullish pattern detected") if C_EngulfingBullish and EngulfingInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishEngulfing = "Engulfing\nAt the end of a given downward trend, there will most likely be a reversal pattern. To distinguish the first day, this candlestick pattern uses a small body, followed by a day where the candle body fully overtakes the body from the day before, and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to completely overtake the range (high to low), rather only the open and the close." label.new(bar_index, patternLabelPosLow, text="BE", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishEngulfing) C_EngulfingBearishNumberOfCandles = 2 C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and C_SmallBody[1] and close <= open[1] and open >= close[1] and ( close < open[1] or open > close[1] ) alertcondition(C_EngulfingBearish, title = "Engulfing – Bearish", message = "New Engulfing – Bearish pattern detected") if C_EngulfingBearish and EngulfingInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishEngulfing = "Engulfing\nAt the end of a given uptrend, a reversal pattern will most likely appear. During the first day, this candlestick pattern uses a small body. It is then followed by a day where the candle body fully overtakes the body from the day before it and closes in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to fully overtake the range (high to low), rather only the open and the close." label.new(bar_index, patternLabelPosHigh, text="BE", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEngulfing) C_AbandonedBabyBullishNumberOfCandles = 3 C_AbandonedBabyBullish = C_DownTrend[2] and C_BlackBody[2] and C_IsDojiBody[1] and low[2] > high[1] and C_WhiteBody and high[1] < low alertcondition(C_AbandonedBabyBullish, title = "Abandoned Baby – Bullish", message = "New Abandoned Baby – Bullish pattern detected") if C_AbandonedBabyBullish and AbandonedBabyInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishAbandonedBaby = "Abandoned Baby\nThis candlestick pattern is quite rare as far as reversal patterns go. The first of the pattern is a large down candle. Next comes a doji candle that gaps below the candle before it. The doji candle is then followed by another candle that opens even higher and swiftly moves to the upside." label.new(bar_index, patternLabelPosLow, text="AB", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishAbandonedBaby) C_AbandonedBabyBearishNumberOfCandles = 3 C_AbandonedBabyBearish = C_UpTrend[2] and C_WhiteBody[2] and C_IsDojiBody[1] and high[2] < low[1] and C_BlackBody and low[1] > high alertcondition(C_AbandonedBabyBearish, title = "Abandoned Baby – Bearish", message = "New Abandoned Baby – Bearish pattern detected") if C_AbandonedBabyBearish and AbandonedBabyInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishAbandonedBaby = "Abandoned Baby\nA bearish abandoned baby is a specific candlestick pattern that often signals a downward reversal trend in terms of security price. It is formed when a gap appears between the lowest price of a doji-like candle and the candlestick of the day before. The earlier candlestick is green, tall, and has small shadows. The doji candle is also tailed by a gap between its lowest price point and the highest price point of the candle that comes next, which is red, tall and also has small shadows. The doji candle shadows must completely gap either below or above the shadows of the first and third day in order to have the abandoned baby pattern effect." label.new(bar_index, patternLabelPosHigh, text="AB", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishAbandonedBaby) C_TriStarBullishNumberOfCandles = 3 C_3DojisBullish = C_Doji[2] and C_Doji[1] and C_Doji C_BodyGapUpBullish = C_BodyHi[1] < C_BodyLo C_BodyGapDnBullish = C_BodyLo[1] > C_BodyHi C_TriStarBullish = C_3DojisBullish and C_DownTrend[2] and C_BodyGapDnBullish[1] and C_BodyGapUpBullish alertcondition(C_TriStarBullish, title = "Tri-Star – Bullish", message = "New Tri-Star – Bullish pattern detected") if C_TriStarBullish and TriStarInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishTriStar = "Tri-Star\nA bullish TriStar candlestick pattern can form when three doji candlesticks materialize in immediate succession at the tail-end of an extended downtrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." label.new(bar_index, patternLabelPosLow, text="3S", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishTriStar) C_TriStarBearishNumberOfCandles = 3 C_3Dojis = C_Doji[2] and C_Doji[1] and C_Doji C_BodyGapUp = C_BodyHi[1] < C_BodyLo C_BodyGapDn = C_BodyLo[1] > C_BodyHi C_TriStarBearish = C_3Dojis and C_UpTrend[2] and C_BodyGapUp[1] and C_BodyGapDn alertcondition(C_TriStarBearish, title = "Tri-Star – Bearish", message = "New Tri-Star – Bearish pattern detected") if C_TriStarBearish and TriStarInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishTriStar = "Tri-Star\nThis particular pattern can form when three doji candlesticks appear in immediate succession at the end of an extended uptrend. The first doji candle marks indecision between bull and bear. The second doji gaps in the direction of the leading trend. The third changes the attitude of the market once the candlestick opens in the direction opposite to the trend. Each doji candle has a shadow, all comparatively shallow, which signify an interim cutback in volatility." label.new(bar_index, patternLabelPosHigh, text="3S", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishTriStar) C_KickingBullishNumberOfCandles = 2 C_MarubozuShadowPercent = 5.0 C_Marubozu = C_LongBody and C_UpShadow <= C_MarubozuShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuShadowPercent/100*C_Body C_MarubozuWhiteBullishKicking = C_Marubozu and C_WhiteBody C_MarubozuBlackBullish = C_Marubozu and C_BlackBody C_KickingBullish = C_MarubozuBlackBullish[1] and C_MarubozuWhiteBullishKicking and high[1] < low alertcondition(C_KickingBullish, title = "Kicking – Bullish", message = "New Kicking – Bullish pattern detected") if C_KickingBullish and KickingInput and (("Bullish" == CandleType) or CandleType == "Both") var ttBullishKicking = "Kicking\nThe first day candlestick is a bearish marubozu candlestick with next to no upper or lower shadow and where the price opens at the day’s high and closes at the day’s low. The second day is a bullish marubozu pattern, with next to no upper or lower shadow and where the price opens at the day’s low and closes at the day’s high. Additionally, the second day gaps up extensively and opens above the opening price of the day before. This gap or window, as the Japanese call it, lies between day one and day two’s bullish candlesticks." label.new(bar_index, patternLabelPosLow, text="K", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishKicking) C_KickingBearishNumberOfCandles = 2 C_MarubozuBullishShadowPercent = 5.0 C_MarubozuBearishKicking = C_LongBody and C_UpShadow <= C_MarubozuBullishShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuBullishShadowPercent/100*C_Body C_MarubozuWhiteBearish = C_MarubozuBearishKicking and C_WhiteBody C_MarubozuBlackBearishKicking = C_MarubozuBearishKicking and C_BlackBody C_KickingBearish = C_MarubozuWhiteBearish[1] and C_MarubozuBlackBearishKicking and low[1] > high alertcondition(C_KickingBearish, title = "Kicking – Bearish", message = "New Kicking – Bearish pattern detected") if C_KickingBearish and KickingInput and (("Bearish" == CandleType) or CandleType == "Both") var ttBearishKicking = "Kicking\nA bearish kicking pattern will occur, subsequently signaling a reversal for a new downtrend. The first day candlestick is a bullish marubozu. The second day gaps down extensively and opens below the opening price of the day before. There is a gap between day one and two’s bearish candlesticks." label.new(bar_index, patternLabelPosHigh, text="K", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishKicking) var ttAllCandlestickPatterns = "All Candlestick Patterns\n" label.new(bar_index, patternLabelPosLow, text="Collection", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttAllCandlestickPatterns) // END ----- *All Candlestick Patterns* Source //-------------------------------------*********************************-------------------------------------// //-------------------------------------*********************************-------------------------------------// // ----- Trend/No-Trend Channel also from @UCSGEARS "Hoffman Overlay" lenNTZ = input.int(35, minval=1, step = 1, tooltip = "Default = 35", title="Trend/No-Trend Channel Length", group="------------- Trend/No-Trend Channel -------------") devNTZ = input.float(0.5, minval=0.1, step=.05, tooltip = "Default = 0.5... When Moving Averages & price action are in this zone, & it is flat, it usually indicates sideways movement. If thre is a trend, price may occasionally use this as a channel.", title = "Trend/No-Trend Channel Deviation", group="------------- Trend/No-Trend Channel -------------", inline = "MTF6") NTZa = ta.ema(close,lenNTZ) NTZrsima = ta.rma(ta.tr,lenNTZ) // Calculate Deviation NTZaUp = NTZa + NTZrsima*devNTZ NTZaLo = NTZa - NTZrsima*devNTZ plot(NTZa, title = "Trend/No-Trend Channel - Mid Line", linewidth = 1, color = #3CB371, style = plot.style_circles) p1 = plot(NTZaUp, title = "Trend/No-Trend Channel - Upper Line", color = #3CB371, display = display.none) p2 = plot(NTZaLo, title = "Trend/No-Trend Channel - Lower Line", color = #3CB371, display = display.none) fill(p1, p2, title = "Trend/No-Trend Channel - Background", color=color.rgb(33, 150, 243, 90))
ATH Levels V3
https://www.tradingview.com/script/CgQDLocB-ATH-Levels-V3/
daytask
https://www.tradingview.com/u/daytask/
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/ // © daytask // // // V2 features // - hide/show level lines // - configurable lookback period whe nsearching for highest high // - configurable rightmargin for last bar (before displaying level info) // - only shows levels with a pot size % set // // V3 features (9th May 2020) // - Hide the ATH level enabling zooming into lower levels with higher resolution //@version=4 study("ATH Levels", overlay=true) potSize = input(defval=1000,title="Pot size", type=input.float, minval = 1) LookbackPeriod = input(defval = 365, title = "Days to Lookback") RightMargin = input(defval = 10, title = "Margin from last bar") ShowLines = input(defval = true, title = "Show level lines") HideATH = input(defval = false, title = "Hide ATH level") percPotLevel1 = input(defval=0, title="Level 1 pot %", type=input.float, minval = 0, maxval=100) percPotLevel2 = input(defval=0, title="Level 2 pot %", type=input.float, minval = 0, maxval=100) percPotLevel3 = input(defval=10, title="Level 3 pot %", type=input.float, minval = 0, maxval=100) percPotLevel4 = input(defval=20, title="Level 4 pot %", type=input.float, minval = 0, maxval=100) percPotLevel5 = input(defval=25, title="Level 5 pot %", type=input.float, minval = 0, maxval=100) percPotLevel6 = input(defval=30, title="Level 6 pot %", type=input.float, minval = 0, maxval=100) percPotLevel7 = input(defval=10, title="Level 7 pot %", type=input.float, minval = 0, maxval=100) percPotLevel8 = input(defval=5, title="Level 8 pot %", type=input.float, minval = 0, maxval=100) // everything is rendered in ms, and we determine the size of thos ms in the candle width (in time) var lastCandleSpacing = RightMargin var lineLength = 30 var levelColors = array.new_color(8) var c_fillColor = #24a06a array.set(levelColors, 0, color.new(c_fillColor, 40)) array.set(levelColors, 1, color.new(c_fillColor, 35)) array.set(levelColors, 2, color.new(c_fillColor, 30)) array.set(levelColors, 3, color.new(c_fillColor, 25)) array.set(levelColors, 4, color.new(c_fillColor, 20)) array.set(levelColors, 5, color.new(c_fillColor, 10)) array.set(levelColors, 6, color.new(c_fillColor, 5)) array.set(levelColors, 7, color.new(c_fillColor, 0)) timePerCandle = time[0] - time[1] highestHigh = highest(close, LookbackPeriod) leftMarginPosition = time[0] + (timePerCandle * lastCandleSpacing) lineEndRight = leftMarginPosition + (timePerCandle * lineLength) ath = highestHigh[0] LEVEL1 = 0.9 LEVEL2 = 0.8 LEVEL3 = 0.7 LEVEL4 = 0.6 LEVEL5 = 0.5 LEVEL6 = 0.4 LEVEL7 = 0.3 LEVEL8 = 0.2 AthLevelValue(n) => ath*n LevelPercOffset(LEVEL) => (1-LEVEL)*100 AthLine(LEVEL, value) => var line ln = na line.delete(ln) if value > 0 level = AthLevelValue(LEVEL) ln:=line.new(x1=leftMarginPosition , y1=level, x2=lineEndRight , y2=level, xloc=xloc.bar_time, color=c_fillColor, style=line.style_dashed, extend=extend.none) AthLabel(LEVEL, percPotLevel, labelColor) => var label lb = na label.delete(lb) if percPotLevel > 0 level = AthLevelValue(LEVEL) potValueLevel = potSize * (percPotLevel / 100) // labelColor = level < close[0] ? colorLevelAbovePrice :colorLevelUnderPrice lb:=label.new(x=leftMarginPosition, y=level, text="ATH -"+tostring(LevelPercOffset(LEVEL))+"% = "+tostring(level)+"\n"+tostring(percPotLevel)+"% Pot size = $"+tostring(potValueLevel), color=labelColor, textcolor=color.white, style=label.style_label_lower_left, xloc=xloc.bar_time, textalign=text.align_left) // now we render the levels off the latest highest high (only do this on the last bar) if barstate.islast // Draw lines (if has settings % value) if ShowLines athLine = line.new(x1=leftMarginPosition , y1=ath, x2=lineEndRight , y2=ath, xloc=xloc.bar_time, style=line.style_dashed, extend=extend.none, color=c_fillColor) AthLine(LEVEL1, percPotLevel1) AthLine(LEVEL2, percPotLevel2) AthLine(LEVEL3, percPotLevel3) AthLine(LEVEL4, percPotLevel4) AthLine(LEVEL5, percPotLevel5) AthLine(LEVEL6, percPotLevel6) AthLine(LEVEL7, percPotLevel7) AthLine(LEVEL8, percPotLevel8) // Draw labels if HideATH == false label.new(x=leftMarginPosition, y=ath, text="ATH = "+tostring(ath)+", Total pot = $"+tostring(potSize), color=color.gray, textcolor=color.white, style=label.style_label_lower_left, xloc=xloc.bar_time, textalign=text.align_left) AthLabel(LEVEL1, percPotLevel1, array.get(levelColors, 0)) AthLabel(LEVEL2, percPotLevel2, array.get(levelColors, 1)) AthLabel(LEVEL3, percPotLevel3, array.get(levelColors, 2)) AthLabel(LEVEL4, percPotLevel4, array.get(levelColors, 3)) AthLabel(LEVEL5, percPotLevel5, array.get(levelColors, 4)) AthLabel(LEVEL6, percPotLevel6, array.get(levelColors, 5)) AthLabel(LEVEL7, percPotLevel7, array.get(levelColors, 6)) AthLabel(LEVEL8, percPotLevel8, array.get(levelColors, 7))
ALL Ticker ID information
https://www.tradingview.com/script/eq3fVKjb-all-ticker-id-information/
pavbuy
https://www.tradingview.com/u/pavbuy/
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/ // © pavbuy //@version=5 indicator(title = " ALL Ticker ID information", shorttitle = "Ticker ID", overlay = true) //Функция printTable выводит значения инструмента на график printTable(txtLeft, txtRight) => var table t = table.new(position.middle_right, 2, 1) table.cell(t, 0, 0, txtLeft, bgcolor = color.yellow, text_halign = text.align_right) table.cell(t, 1, 0, txtRight, bgcolor = color.yellow, text_halign = text.align_left) nl = "\n" left = "syminfo.basecurrency: " + nl + "syminfo.currency: " + nl + "syminfo.description: " + nl + "syminfo.mintick: " + nl + "syminfo.pointvalue: " + nl + "syminfo.prefix: " + nl + "syminfo.root: " + nl + "syminfo.session: " + nl + "syminfo.ticker: " + nl + "syminfo.tickerid: " + nl + "syminfo.timezone: " + nl + "syminfo.type: " right = syminfo.basecurrency + nl + //Базовая валюта символа. Для символа 'BTCUSD' возвращает 'BTC'. syminfo.currency + nl + //Валюта для текущего символа. Возвращает код валюты: 'USD', 'EUR' и т. д. syminfo.description + nl + //Описание текущего символа. str.tostring(syminfo.mintick) + nl + //Строковое представление аргумента - Мин. тиковое значение для текущего инструмента. str.tostring(syminfo.pointvalue) + nl + //Строковое представление аргумента - Значение пункта для текущего инструмента. syminfo.prefix + nl + //Префикс текущего имени инструмента (т.е. для 'CME_EOD:TICKER' префикс 'CME_EOD'). syminfo.root + nl + //Корень для таких деривативов, как фьючерсные контракты. Для других инструментов возвращает то же значение, что и syminfo.ticker. syminfo.session + nl + //Тип сессии графика главной серии. Возможные значения: session.regular, session.extended. syminfo.ticker + nl + //Имя инструмента без префикса биржи, например, 'MSFT'. syminfo.tickerid + nl + //Имя инструмента с префиксом биржи, например, 'BATS:MSFT', 'NASDAQ:MSFT'. syminfo.timezone + nl + //Часовой пояс биржи графика главной серии. Возможные значения можно найти в timestamp. syminfo.type //Тип текущего символа. Возможные значения: stock, futures, index, forex, crypto, fund, dr. printTable(left, right) // Пример Реализация доступа до другого инструмента // T = "BITFINEX:"+str.tostring(syminfo.basecurrency)+"USDT" T = "BITFINEX:"+str.tostring(syminfo.basecurrency)+"USD" S = "SHORTS" L = "LONGS" shorts = request.security(T+S, timeframe.period, close, ignore_invalid_symbol=true) longs = request.security(T+L, timeframe.period, close, ignore_invalid_symbol=true) // Обработка ошибки resolve error pine script if barstate.isrealtime if na(shorts) and na(longs) label label1 = label.new(bar_index, high, text='Ошибка в значении идикатора. Такой валюты нет!', color=color.green, textcolor=color.white, style=label.style_label_down, yloc=yloc.price, size=size.small) // label.delete(label1[1]) else label label0 = label.new(bar_index, high, text=str.tostring(T+S+L), color=color.green, textcolor=color.white, style=label.style_label_down, yloc=yloc.price, size=size.small) // label.delete(label0[1])
Jurik MA [lastguru]
https://www.tradingview.com/script/ofu6hRfu-Jurik-MA-lastguru/
lastguru
https://www.tradingview.com/u/lastguru/
90
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © lastguru, 2022. All right reserved //@version=5 indicator("Jurik MA by lastguru", "JMA [lastguru]", overlay=true) import lastguru/CommonFilters/2 as cf //////////// // Inputs // //////////// src = input(close, title="Source", inline="1") Length = input.int(title="Length", defval=7) Phase = input.int(title="Phase", defval=50) float out = cf.jma(src, Length, Phase) ////////////// // Plotting // ////////////// plot(out, "JMA", color=color.yellow, linewidth=2)
NSE Bank Nifty - Arms Index (TRIN)
https://www.tradingview.com/script/vToiKdfp-NSE-Bank-Nifty-Arms-Index-TRIN/
Sharad_Gaikwad
https://www.tradingview.com/u/Sharad_Gaikwad/
59
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Sharad_Gaikwad //@version=5 indicator("NSE Bank Nifty - Arms Index (TRIN)", overlay=false) tab = table.new(position=position.top_center, columns=7, rows=20,frame_color = color.yellow, frame_width = 1) msg(int row, int col, string msg_str, clr=color.blue) => table.cell(table_id=tab, column=col, row=row, text=msg_str, text_color=clr) t(_val) => ret_val = str.tostring(_val) method = input.string(title = 'Calculation method', defval='SAME-DAY', options = ['SAME-DAY', 'PREVIOUS-DAY'], tooltip = 'Used to derive advancing and declining stocks. SAME-DAY = uses days close - days open. PREVIOUS-DAY = uses days close - previous days close') plot_avg_trin = input.bool(title = 'Plot Average TRIN', defval = true) avg_len = input.int(title = 'Length for Average TRIN', defval = 10) plot_trin = input.bool(title = 'Plot TRIN', defval = false) plot_AD_price_line = input.bool(title = 'Plot AD Price line', defval = false) plot_AD_volume_line = input.bool(title = 'Plot AD Volume line', defval = false) overbought_band = input(title = 'Overbought above', defval = 3.00) oversold_band = input(title = 'Oversold below', defval = 0.5) // varip float s1_wtg = 27.8 / 100 // varip float s2_wtg = 22.62 / 100 // varip float s3_wtg = 11.61 / 100 // varip float s4_wtg = 11.52 / 100 // varip float s5_wtg = 11.45 / 100 // varip float s6_wtg = 5.91 / 100 // varip float s7_wtg = 2.33 / 100 // varip float s8_wtg = 1.75 / 100 // varip float s9_wtg = 1.7 / 100 // varip float s10_wtg = 1.54 / 100 // varip float s11_wtg = 1.13 / 100 // varip float s12_wtg = 0.65 / 100 no_of_stocks = 12 s1 = input('NSE:HDFCBANK') s2 = input('NSE:ICICIBANK') s3 = input('NSE:KOTAKBANK') s4 = input('NSE:AXISBANK') s5 = input('NSE:SBIN') s6 = input('NSE:INDUSINDBK') s7 = input('NSE:AUBANK') s8 = input('NSE:BANDHANBNK') s9 = input('NSE:FEDERALBNK') s10 = input('NSE:IDFCFIRSTB') s11 = input('NSE:PNB') s12 = input('NSE:RBLBANK') // var adv_stocks = int(0) // var dec_stocks = int(0) // var adv_volume = float(0) // var dec_volume= float(0) adv_stocks = int(0) dec_stocks = int(0) adv_volume = float(0) dec_volume= float(0) [s1_open, s1_close, s1_volume] = request.security(s1, timeframe.period, [open, close, volume]) [s2_open, s2_close, s2_volume] = request.security(s2, timeframe.period, [open, close, volume]) [s3_open, s3_close, s3_volume] = request.security(s3, timeframe.period, [open, close, volume]) [s4_open, s4_close, s4_volume] = request.security(s4, timeframe.period, [open, close, volume]) [s5_open, s5_close, s5_volume] = request.security(s5, timeframe.period, [open, close, volume]) [s6_open, s6_close, s6_volume] = request.security(s6, timeframe.period, [open, close, volume]) [s7_open, s7_close, s7_volume] = request.security(s7, timeframe.period, [open, close, volume]) [s8_open, s8_close, s8_volume] = request.security(s8, timeframe.period, [open, close, volume]) [s9_open, s9_close, s9_volume] = request.security(s9, timeframe.period, [open, close, volume]) [s10_open, s10_close, s10_volume] = request.security(s10, timeframe.period, [open, close, volume]) [s11_open, s11_close, s11_volume] = request.security(s11, timeframe.period, [open, close, volume]) [s12_open, s12_close, s12_volume] = request.security(s12, timeframe.period, [open, close, volume]) s1_adv = method == 'SAME-DAY' ? s1_close >= s1_open : s1_close >= s1_close[1] s2_adv = method == 'SAME-DAY' ? s2_close >= s2_open : s2_close >= s2_close[1] s3_adv = method == 'SAME-DAY' ? s3_close >= s3_open : s3_close >= s3_close[1] s4_adv = method == 'SAME-DAY' ? s4_close >= s4_open : s4_close >= s4_close[1] s5_adv = method == 'SAME-DAY' ? s5_close >= s5_open : s5_close >= s5_close[1] s6_adv = method == 'SAME-DAY' ? s6_close >= s6_open : s6_close >= s6_close[1] s7_adv = method == 'SAME-DAY' ? s7_close >= s7_open : s7_close >= s7_close[1] s8_adv = method == 'SAME-DAY' ? s8_close >= s8_open : s8_close >= s8_close[1] s9_adv = method == 'SAME-DAY' ? s9_close >= s9_open : s9_close >= s9_close[1] s10_adv = method == 'SAME-DAY' ? s10_close >= s10_open : s10_close >= s10_close[1] s11_adv = method == 'SAME-DAY' ? s11_close >= s11_open : s11_close >= s11_close[1] s12_adv = method == 'SAME-DAY' ? s12_close >= s12_open : s12_close >= s12_close[1] s1_dec = method == 'SAME-DAY' ? s1_close < s1_open : s1_close < s1_close[1] s2_dec = method == 'SAME-DAY' ? s2_close < s2_open : s2_close < s2_close[1] s3_dec = method == 'SAME-DAY' ? s3_close < s3_open : s3_close < s3_close[1] s4_dec = method == 'SAME-DAY' ? s4_close < s4_open : s4_close < s4_close[1] s5_dec = method == 'SAME-DAY' ? s5_close < s5_open : s5_close < s5_close[1] s6_dec = method == 'SAME-DAY' ? s6_close < s6_open : s6_close < s6_close[1] s7_dec = method == 'SAME-DAY' ? s7_close < s7_open : s7_close < s7_close[1] s8_dec = method == 'SAME-DAY' ? s8_close < s8_open : s8_close < s8_close[1] s9_dec = method == 'SAME-DAY' ? s9_close < s9_open : s9_close < s9_close[1] s10_dec = method == 'SAME-DAY' ? s10_close < s10_open : s10_close < s10_close[1] s11_dec = method == 'SAME-DAY' ? s11_close < s11_open : s11_close < s11_close[1] s12_dec = method == 'SAME-DAY' ? s12_close < s12_open : s12_close < s12_close[1] //adv_stocks := 0 adv_stocks := s1_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s2_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s3_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s4_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s5_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s6_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s7_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s8_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s9_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s10_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s11_adv ? adv_stocks + 1 : adv_stocks adv_stocks := s12_adv ? adv_stocks + 1 : adv_stocks //dec_stocks := 0 dec_stocks := s1_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s2_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s3_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s4_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s5_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s6_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s7_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s8_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s9_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s10_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s11_dec ? dec_stocks + 1 : dec_stocks dec_stocks := s12_dec ? dec_stocks + 1 : dec_stocks //adv_volume := 0 adv_volume := s1_adv ? adv_volume + s1_volume : adv_volume adv_volume := s2_adv ? adv_volume + s2_volume : adv_volume adv_volume := s3_adv ? adv_volume + s3_volume : adv_volume adv_volume := s4_adv ? adv_volume + s4_volume : adv_volume adv_volume := s5_adv ? adv_volume + s5_volume : adv_volume adv_volume := s6_adv ? adv_volume + s6_volume : adv_volume adv_volume := s7_adv ? adv_volume + s7_volume : adv_volume adv_volume := s8_adv ? adv_volume + s8_volume : adv_volume adv_volume := s9_adv ? adv_volume + s9_volume : adv_volume adv_volume := s10_adv ? adv_volume + s10_volume : adv_volume adv_volume := s11_adv ? adv_volume + s11_volume : adv_volume adv_volume := s12_adv ? adv_volume + s12_volume : adv_volume //dec_volume := 0 dec_volume := s1_dec ? dec_volume + s1_volume : dec_volume dec_volume := s2_dec ? dec_volume + s2_volume : dec_volume dec_volume := s3_dec ? dec_volume + s3_volume : dec_volume dec_volume := s4_dec ? dec_volume + s4_volume : dec_volume dec_volume := s5_dec ? dec_volume + s4_volume : dec_volume dec_volume := s6_dec ? dec_volume + s6_volume : dec_volume dec_volume := s7_dec ? dec_volume + s7_volume : dec_volume dec_volume := s8_dec ? dec_volume + s8_volume : dec_volume dec_volume := s9_dec ? dec_volume + s9_volume : dec_volume dec_volume := s10_dec ? dec_volume + s10_volume : dec_volume dec_volume := s11_dec ? dec_volume + s11_volume : dec_volume dec_volume := s12_dec ? dec_volume + s12_volume : dec_volume trin = (nz(adv_stocks, 1) / nz(dec_stocks, 1)) / (nz(adv_volume, 1) / nz(dec_volume, 1)) avg_trin = ta.sma(trin, avg_len) plot(plot_trin ? trin : na, color = color.blue) plot(plot_avg_trin ? avg_trin : na, color = color.purple) plot(plot_AD_price_line ? adv_stocks : na, color = color.green) plot(plot_AD_price_line ? dec_stocks : na, color = color.red) plot(plot_AD_volume_line ? adv_volume : na, color = color.green) plot(plot_AD_volume_line ? dec_volume : na, color = color.red) hline(price = 1, title = 'Line at 1', color = color.gray, linestyle=hline.style_dashed) hline(price = overbought_band, title = 'Top Line', color = color.gray, linestyle=hline.style_dashed) hline(price = oversold_band, title = 'Low Line', color = color.gray, linestyle=hline.style_dashed)
ICT Index Futures Session Lines
https://www.tradingview.com/script/CMYepDcm-ICT-Index-Futures-Session-Lines/
geneclash
https://www.tradingview.com/u/geneclash/
488
study
5
MPL-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("ICT Index Futures Session Lines",overlay=true,max_lines_count=500) //INPUTS i_tz = input.string('America/New_York', title='Timezone: ', tooltip='e.g. \'America/New_York\', \'Asia/Tokyo\', \'GMT-4\', \'GMT+9\'...', group='Session') sessionFiveRange = input.session(title='H/L/O Range: ', defval='0000-0830', inline='e', group='Session') sessionOneRange = input.session(title='Open of Day: ', defval='0830-0831', inline='a', group='Session') sessionTwoRange = input.session(title='NY Lunch: ', defval='1200-1300', inline='b', group='Session') sessionThreeRange = input.session(title='Algorithm: ', defval='1330-1331', inline='c', group='Session') sessionFourRange = input.session(title='End of Day: ', defval='1630-1631', inline='d', group='Session') colorOne = input.color(color.new(color.black,65),title="Open of Day:",inline="s_1",group="Style") lineStyleOne = input.string(title="-", defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid],inline="s_1",group="Style") colorTwo = input.color(color.new(color.black,65),title="Ny Lunch:",inline="s_2",group="Style") colorTwoFill = input.color(color.new(color.orange,90),title="-",inline="s_2",group="Style") lineStyleTwo = input.string(title="-", defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid],inline="s_2",group="Style") colorThree = input.color(color.new(color.purple,65),title="Algorithm:",inline="s_3",group="Style") lineStyleThree = input.string(title="-", defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid],inline="s_3",group="Style") colorFour = input.color(color.new(color.black,65),title="End of Day:",inline="s_4",group="Style") lineStyleFour = input.string(title="-", defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid],inline="s_4",group="Style") colorFiveHL = input.color(color.new(color.black,65),title="H/L:",inline="s_5",group="Style") colorFiveOpen = input.color(color.new(color.orange,0),title="Open:",inline="s_5",group="Style") activeFive = input.color(color.new(color.yellow,95),title="-",inline="s_5",group="Style") passiveFive = input.color(color.new(color.gray,95),title="/",inline="s_5",group="Style") lineStyleFive = input.string(title="-", defval=line.style_solid, options=[line.style_dotted, line.style_dashed, line.style_solid],inline="s_5",group="Style") //Sessions in_session_one = time(timeframe.period, sessionOneRange,i_tz) sessionOneActive = in_session_one and timeframe.multiplier <= 30 in_session_two = time(timeframe.period, sessionTwoRange,i_tz) sessionTwoActive = in_session_two and timeframe.multiplier <= 30 in_session_three = time(timeframe.period, sessionThreeRange,i_tz) sessionThreeActive = in_session_three and timeframe.multiplier <= 30 in_session_four = time(timeframe.period, sessionFourRange,i_tz) sessionFourActive = in_session_four and timeframe.multiplier <= 30 in_session_five = time(timeframe.period, sessionFiveRange,i_tz) sessionFiveActive = in_session_five and timeframe.multiplier <= 30 f_resInMinutes() => _resInMinutes = timeframe.multiplier * ( timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) barHour = hour(time,i_tz) barMin = minute(time,i_tz) checkLastBar(sessionRange)=> splitSessionOne = str.split(sessionRange,'') hour1 = array.get(splitSessionOne,5) hour2 = array.get(splitSessionOne,6) hourSessionOne = str.tonumber(hour1+hour2) min1 = array.get(splitSessionOne,7) min2 = array.get(splitSessionOne,8) minSessionOne = str.tonumber(min1+min2) if hourSessionOne == 0 hourSessionOne := 24 if minSessionOne == 0 minSessionOne := 60 hourSessionOne := hourSessionOne -1 _islastBarSession = (barHour == hourSessionOne) and (barMin >= minSessionOne - f_resInMinutes()) islastBarSession = _islastBarSession and _islastBarSession[1] == false islastBarSessionFive = checkLastBar(sessionFiveRange) var float highVal = na, var float lowVal = na, var float openVal = na var line hLine = na, var line lLine = na, var line oLine = na var line tempHLine = na, var line tempLLine = na var linefill fill1 = na if sessionFiveActive if sessionFiveActive[1] == false openVal := open if high >= nz(highVal, 0) highVal := high else highVal := highVal if low <= nz(lowVal, high) lowVal := low else lowVal := lowVal else highVal := na lowVal := na openVal := na startIndexH = ta.valuewhen(na(highVal[1]) and highVal, bar_index, 0) startIndexL = ta.valuewhen(na(lowVal[1]) and lowVal, bar_index, 0) //Plot H/L lines if sessionFiveActive oLine := line.new(startIndexH, openVal, bar_index, openVal, color=colorFiveOpen, width=1, style=lineStyleFive) tempHLine := line.new(startIndexH, highVal, bar_index, highVal, color=colorFiveHL, width=1, style=lineStyleFive) tempLLine := line.new(startIndexL, lowVal, bar_index, lowVal, color=colorFiveHL, width=1, style=lineStyleFive) fill1 := linefill.new(tempHLine, tempLLine, activeFive) linefill.delete(fill1[1]) line.delete(tempHLine[1]), line.delete(tempLLine[1]) if islastBarSessionFive hLine := line.new(startIndexH, highVal, bar_index, highVal, color=colorFiveHL, width=1, style=lineStyleFive) lLine := line.new(startIndexL, lowVal, bar_index, lowVal, color=colorFiveHL, width=1, style=lineStyleFive) linefill.new(hLine, lLine, passiveFive) var line openLine = na if sessionOneActive and sessionOneActive[1] == false openLine := line.new(bar_index,high,bar_index,low,extend=extend.both,color=colorOne, style=lineStyleOne) var line lunchOpen = na, var line lunchClose = na if sessionTwoActive and sessionTwoActive[1] == false lunchOpen := line.new(bar_index,high,bar_index,low,extend=extend.both,color=colorTwo , style=lineStyleTwo) if sessionTwoActive==false and sessionTwoActive[1] lunchClose := line.new(bar_index,high,bar_index,low,extend=extend.both,color=colorTwo, style=lineStyleTwo) linefill.new(lunchOpen, lunchClose, colorTwoFill) var line algoLine = na if sessionThreeActive and sessionThreeActive[1] == false algoLine := line.new(bar_index,high,bar_index,low,extend=extend.both,color=colorThree, style=lineStyleThree) var line endLine = na if sessionFourActive and sessionFourActive[1] == false endLine := line.new(bar_index,high,bar_index,low,extend=extend.both,color=colorFour, style=lineStyleFour)
Standard Deviation Channels (ThinkorSwim identical)
https://www.tradingview.com/script/Mvyufvyg-Standard-Deviation-Channels-ThinkorSwim-identical/
SUNNY29081975
https://www.tradingview.com/u/SUNNY29081975/
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/ // © SUNNY29081975 //@version=5 indicator("StandardDevChannel" , overlay=true) price = input(close, "price") deviations = input(2.0, "deviations") fullRange = input(false, "fullRange") length = input(21, "length") uppercolor = input(color.yellow, "Upper line") middlecolor = input(color.yellow, "Middle line") lowercolor = input(color.yellow, "Lower line") //-- change this variable to the miximum number of bars you want to cover. must be bigger then length --// //-- even if full range is off. max_bars_back=1560 //----------------------------------------------------------------------------// max_bars_back(price, max_bars_back) Sqr(x) => x*x newlength = fullRange ? max_bars_back : length InertiaAll (y, n) => var x = 0 x := x + 1 a = (n * math.sum(x * y, n) - math.sum(x, n) * math.sum(y, n) ) / ( n * math.sum(Sqr(x), n) - Sqr(math.sum(x, n))) b = (math.sum(Sqr(x), n) * math.sum(y, n) - math.sum(x, n) * math.sum(x * y, n) ) / ( n * math.sum(Sqr(x), n) - Sqr(math.sum(x, n))) InertiaTS = a * x + b [InertiaTS, x, a, b] [regression, x1, a1, b1] = InertiaAll(price, newlength) stdDeviation = ta.stdev(price, newlength) var UpperLine = line.new(0, low, 0, low, color=uppercolor, extend=extend.right) //regression + deviations * stdDeviation; var MiddleLine = line.new(0, low, 0, low, color=uppercolor, extend=extend.right) //regression; var LowerLine = line.new(0, low, 0, low, color=uppercolor, extend=extend.right) // regression - deviations * stdDeviation; if barstate.islast line.set_xy1(UpperLine, last_bar_index - newlength + 1, a1*x1[newlength - 1] +b1 + deviations * stdDeviation) line.set_xy2(UpperLine, last_bar_index, a1*x1 +b1 + deviations * stdDeviation) line.set_xy1(MiddleLine, last_bar_index - newlength + 1, a1*x1[newlength - 1] +b1) line.set_xy2(MiddleLine, last_bar_index, a1*x1 +b1) line.set_xy1(LowerLine, last_bar_index - newlength + 1, a1*x1[newlength - 1] +b1 - deviations * stdDeviation) line.set_xy2(LowerLine, last_bar_index, a1*x1 +b1 - deviations * stdDeviation)
Stochastic ATR Volatility Oscillator
https://www.tradingview.com/script/jMJ1O8dr/
spacekadet17
https://www.tradingview.com/u/spacekadet17/
41
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © spacekadet17 // @version=5 // NOTES: As x, k and d use; // 21-10-3 for 1 Hour candles // 5-4-2 for 4 Hour candles // 21-21-3 for 1 Day candles // Yellow plot is the main oscillator. Orange plot, and hlines at 20, 50 and 80 can be used as signal lines. // I personally use hlines as the signal in 1H as it's the best timeframe for the indicator. // If you are in a long position, sell when yellow plot crosses 80 or 50 line downwards; // and buy when the line crosses 20, 50 or 75 upwards while you are not in a trade. indicator(title="Stochastic ATR Volatility Oscillator", shorttitle="SATRVO", format=format.price, precision=2, timeframe="", timeframe_gaps=true, overlay = false) x = input.int(21,"Length") k = input.int(10," k Length") d = input.int(3," d Length") //percent change of candles / neutral pcAtrn = ( ( low[1]>high ? low[1]: high ) / ( low>high[1] ? high[1] : low ) - 1 ) * 100 //percent change of candles / + or - considered pcAtr = close>open ? ( ( close[1]>high ? close[1]: high ) / ( low>close[1] ? close[1] : low ) - 1 ) * 100 : ( ( low>close[1] ? close[1] : low ) / ( close[1]>high ? close[1]: high ) - 1 ) * 100 //stochastic atr volatilty oscilator smaorema = input.float(0.1, "0(sma) to 1(ema) slider") sigma = input.float(2, "sigma of atr average") avgPcAtr = ta.alma(pcAtr,x,smaorema,sigma) stoatr = ta.stoch(avgPcAtr,avgPcAtr,avgPcAtr,k) //smoothened oscilators stoatr3 = ta.ema(ta.ema(stoatr,d),d) stoatr3sig = ta.ema(stoatr3,d) //plots plot(stoatr3,color = color.yellow) plot(stoatr3sig,color = color.orange) // signal lines h0 = plot(80, "Upper Band", color=color.red) h1 = plot(20, "Lower Band", color=color.green) h2 = plot(50, "Mid Band", color=color.orange) fill(h0, h1, color=color.rgb(150, 150, 150, 95), title="Background")
NoBrain Breakout
https://www.tradingview.com/script/K6qXjbZL-NoBrain-Breakout/
jxmodi
https://www.tradingview.com/u/jxmodi/
146
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/ // © jxmodi //@version=4 study("NoBrarin Breakout", overlay = true, shorttitle="NB",precision=1) //******************LOGICS************************** //cenral pivot range pivot = (high + low + close) /3 //Central Povit BC = (high + low) / 2 //Below Central povit TC = (pivot - BC) + pivot //Top Central povot //3 support levels S1 = (pivot * 2) - high S2 = pivot - (high - low) S3 = low - 2 * (high - pivot) //3 resistance levels R1 = (pivot * 2) - low R2 = pivot + (high - low) R3 = high + 2 * (pivot-low) //Checkbox inputs CPRPlot = input(title = "Plot CPR?", type=input.bool, defval=false) DayS1R1 = input(title = "Plot Daiy S1/R1?", type=input.bool, defval=false) DayS2R2 = input(title = "Plot Daiy S2/R2?", type=input.bool, defval=false) DayS3R3 = input(title = "Plot Daiy S3/R3?", type=input.bool, defval=false) WeeklyPivotInclude = input(title = "Plot Weekly Pivot?", type=input.bool, defval=false) WeeklyS1R1 = input(title = "Plot weekly S1/R1?", type=input.bool, defval=false) WeeklyS2R2 = input(title = "Plot weekly S2/R2?", type=input.bool, defval=false) WeeklyS3R3 = input(title = "Plot weekly S3/R3?", type=input.bool, defval=false) MonthlyPivotInclude = input(title = "Plot Montly Pivot?", type=input.bool, defval=false) MonthlyS1R1 = input(title = "Plot Monthly S1/R1?", type=input.bool, defval=true) MonthlyS2R2 = input(title = "Plot Monthly S2/R2?", type=input.bool, defval=false) MonthlyS3R3 = input(title = "Plot Montly S3/R3?", type=input.bool, defval=false) //******************DAYWISE CPR & PIVOTS************************** // Getting daywise CPR DayPivot = security(syminfo.tickerid, "D", pivot[1], barmerge.gaps_off, barmerge.lookahead_on) DayBC = security(syminfo.tickerid, "D", BC[1], barmerge.gaps_off, barmerge.lookahead_on) DayTC = security(syminfo.tickerid, "D", TC[1], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks daywse for CPR CPColour = DayPivot != DayPivot[1] ? na : color.white BCColour = DayBC != DayBC[1] ? na : color.gray TCColour = DayTC != DayTC[1] ? na : color.gray //Plotting daywise CPR plot(DayPivot, title = "CP" , color = CPColour, style = plot.style_linebr, linewidth =2) plot(CPRPlot ? DayBC : na , title = "BC" , color = BCColour, style = plot.style_line, linewidth =1) plot(CPRPlot ? DayTC : na , title = "TC" , color = TCColour, style = plot.style_line, linewidth =1) // Getting daywise Support levels DayS1 = security(syminfo.tickerid, "D", S1[1], barmerge.gaps_off, barmerge.lookahead_on) DayS2 = security(syminfo.tickerid, "D", S2[1], barmerge.gaps_off, barmerge.lookahead_on) DayS3 = security(syminfo.tickerid, "D", S3[1], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for daywise Support levels DayS1Color =DayS1 != DayS1[1] ? na : color.green DayS2Color =DayS2 != DayS2[1] ? na : color.green DayS3Color =DayS3 != DayS3[1] ? na : color.green //Plotting daywise Support levels plot(DayS1R1 ? DayS1 : na, title = "D-S1" , color = DayS1Color, style = plot.style_line, linewidth =1) plot(DayS2R2 ? DayS2 : na, title = "D-S2" , color = DayS2Color, style = plot.style_line, linewidth =1) plot(DayS3R3 ? DayS3 : na, title = "D-S3" , color = DayS3Color, style = plot.style_line, linewidth =1) // Getting daywise Resistance levels DayR1 = security(syminfo.tickerid, "D", R1[1], barmerge.gaps_off, barmerge.lookahead_on) DayR2 = security(syminfo.tickerid, "D", R2[1], barmerge.gaps_off, barmerge.lookahead_on) DayR3 = security(syminfo.tickerid, "D", R3[1], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for daywise Support levels DayR1Color =DayR1 != DayR1[1] ? na : color.red DayR2Color =DayR2 != DayR2[1] ? na : color.red DayR3Color =DayR3 != DayR3[1] ? na : color.red //Plotting daywise Resistance levels plot(DayS1R1 ? DayR1 : na, title = "D-R1" , color = DayR1Color, style = plot.style_line, linewidth =1) plot(DayS2R2 ? DayR2 : na, title = "D-R2" , color = DayR2Color, style = plot.style_line, linewidth =1) plot(DayS3R3 ? DayR3 : na, title = "D-R3" , color = DayR3Color, style = plot.style_line, linewidth =1) //******************WEEKLY PIVOTS************************** // Getting Weely Pivot WPivot = security(syminfo.tickerid, "W", pivot[1], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for Weely Pivot WeeklyPivotColor =WPivot != WPivot[1] ? na : color.blue //Plotting Weely Pivot plot(WeeklyPivotInclude ? WPivot:na, title = "W-P" , color = WeeklyPivotColor, style = plot.style_circles, linewidth =1) // Getting Weely Support levels WS1 = security(syminfo.tickerid, "W", S1[1],barmerge.gaps_off, barmerge.lookahead_on) WS2 = security(syminfo.tickerid, "W", S2[1],barmerge.gaps_off, barmerge.lookahead_on) WS3 = security(syminfo.tickerid, "W", S3[1],barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for weekly Support levels WS1Color =WS1 != WS1[1] ? na : color.green WS2Color =WS2 != WS2[1] ? na : color.green WS3Color =WS3 != WS3[1] ? na : color.green //Plotting Weely Support levels plot(WeeklyS1R1 ? WS1 : na, title = "W-S1" , color = WS1Color, style = plot.style_cross, linewidth =1) plot(WeeklyS2R2 ? WS2 : na, title = "W-S2" , color = WS2Color, style = plot.style_cross, linewidth =1) plot(WeeklyS3R3 ? WS3 : na, title = "W-S3" , color = WS3Color, style = plot.style_cross, linewidth =1) // Getting Weely Resistance levels WR1 = security(syminfo.tickerid, "W", R1[1], barmerge.gaps_off, barmerge.lookahead_on) WR2 = security(syminfo.tickerid, "W", R2[1], barmerge.gaps_off, barmerge.lookahead_on) WR3 = security(syminfo.tickerid, "W", R3[1], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for weekly Resistance levels WR1Color = WR1 != WR1[1] ? na : color.red WR2Color = WR2 != WR2[1] ? na : color.red WR3Color = WR3 != WR3[1] ? na : color.red //Plotting Weely Resistance levels plot(WeeklyS1R1 ? WR1 : na , title = "W-R1" , color = WR1Color, style = plot.style_cross, linewidth =1) plot(WeeklyS2R2 ? WR2 : na , title = "W-R2" , color = WR2Color, style = plot.style_cross, linewidth =1) plot(WeeklyS3R3 ? WR3 : na , title = "W-R3" , color = WR3Color, style = plot.style_cross, linewidth =1) //******************MONTHLY PIVOTS************************** // Getting Monhly Pivot MPivot = security(syminfo.tickerid, "M", pivot[1],barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for Monthly Support levels MonthlyPivotColor =MPivot != MPivot[1] ? na : color.blue //Plotting Monhly Pivot plot(MonthlyPivotInclude? MPivot:na, title = " M-P" , color = MonthlyPivotColor, style = plot.style_line, linewidth =1) // Getting Monhly Support levels MS1 = security(syminfo.tickerid, "M", S1[1],barmerge.gaps_off, barmerge.lookahead_on) MS2 = security(syminfo.tickerid, "M", S2[1],barmerge.gaps_off, barmerge.lookahead_on) MS3 = security(syminfo.tickerid, "M", S3[1],barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for Montly Support levels MS1Color =MS1 != MS1[1] ? na : color.green MS2Color =MS2 != MS2[1] ? na : color.green MS3Color =MS3 != MS3[1] ? na : color.green //Plotting Monhly Support levels plot(MonthlyS1R1 ? MS1 : na, title = "M-S1" , color = MS1Color, style = plot.style_stepline, linewidth =2) plot(MonthlyS2R2 ? MS2 : na, title = "M-S2" , color = MS2Color, style = plot.style_circles, linewidth =1) plot(MonthlyS3R3 ? MS3 : na, title = "M-S3" , color = MS3Color, style = plot.style_circles, linewidth =1) // Getting Monhly Resistance levels MR1 = security(syminfo.tickerid, "M", R1[1],barmerge.gaps_off, barmerge.lookahead_on) MR2 = security(syminfo.tickerid, "M", R2[1],barmerge.gaps_off, barmerge.lookahead_on) MR3 = security(syminfo.tickerid, "M", R3[1],barmerge.gaps_off, barmerge.lookahead_on) MR1Color =MR1 != MR1[1] ? na : color.teal MR2Color =MR2 != MR2[1] ? na : color.red MR3Color =MR3 != MR3[1] ? na : color.red //Plotting Monhly Resistance levels plot(MonthlyS1R1 ? MR1 : na , title = "M-R1", color = MR1Color, style = plot.style_stepline , linewidth =2) plot(MonthlyS2R2 ? MR2 : na , title = "M-R2" , color = MR2Color, style = plot.style_circles, linewidth =1) plot(MonthlyS3R3 ? MR3 : na, title = "M-R3" , color = MR3Color, style = plot.style_circles, linewidth =1) //*****************************INDICATORs************************** //SMA PlotSMA = input(title = "Plot SMA?", type=input.bool, defval=false) SMALength = input(title="SMA Length", type=input.integer, defval=44) SMASource = input(title="SMA Source", type=input.source, defval=close) SMAvg = sma (SMASource, SMALength) plot(PlotSMA ? SMAvg : na, color= color.orange, title="SMA") //EMA PlotEMA = input(title = "Plot EMA?", type=input.bool, defval=false) EMALength = input(title="EMA Length", type=input.integer, defval=48) EMASource = input(title="EMA Source", type=input.source, defval=close) EMAvg = ema (EMASource, EMALength) plot(PlotEMA ? EMAvg : na, color= color.red, title="EMA") //VWAP PlotVWAP = input(title = "Plot VWAP?", type=input.bool, defval=false) VWAPSource = input(title="VWAP Source", type=input.source, defval=close) VWAPrice = vwap (VWAPSource) plot(PlotVWAP ? VWAPrice : na, color= color.teal, title="VWAP") //SuperTrend PlotSTrend = input(title = "Plot Super Trend?", type=input.bool, defval=true) InputFactor=input(2.7, minval=1,maxval = 100, title="Factor") InputLength=input(13, minval=1,maxval = 100, title="Lenght") BasicUpperBand=hl2-(InputFactor*atr(InputLength)) BasicLowerBand=hl2+(InputFactor*atr(InputLength)) FinalUpperBand=0.0 FinalLowerBand=0.0 FinalUpperBand:=close[1]>FinalUpperBand[1]? max(BasicUpperBand,FinalUpperBand[1]) : BasicUpperBand FinalLowerBand:=close[1]<FinalLowerBand[1]? min(BasicLowerBand,FinalLowerBand[1]) : BasicLowerBand IsTrend=0.0 IsTrend:= close > FinalLowerBand[1] ? 1: close< FinalUpperBand[1]? -1: nz(IsTrend[1],1) STrendline = IsTrend==1? FinalUpperBand: FinalLowerBand linecolor = IsTrend == 1 ? color.green : color.red Plotline = (PlotSTrend? STrendline: na) plot(Plotline, color = linecolor , style = plot.style_linebr , linewidth = 1,title = "SuperTrend") PlotShapeUp = cross(close,STrendline) and close>STrendline PlotShapeDown = cross(STrendline,close) and close<STrendline plotshape(PlotSTrend? PlotShapeUp: na, "Up Arrow", shape.arrowup,location.belowbar,color.green,0,0) plotshape(PlotSTrend? PlotShapeDown: na , "Down Arrow", shape.arrowdown , location.abovebar, color.red,0,0) //Pivot Points Standard", "Pivots", overlay=true, max_lines_count=500, max_labels_count=500 AUTO = "Auto" DAILY = "Daily" WEEKLY = "Weekly" MONTHLY = "Monthly" QUARTERLY = "Quarterly" YEARLY = "Yearly" BIYEARLY = "Biyearly" TRIYEARLY = "Triyearly" QUINQUENNIALLY = "Quinquennially" DECENNIALLY = "Decennially" TRADITIONAL = "Traditional" FIBONACCI = "Fibonacci" WOODIE = "Woodie" CLASSIC = "Classic" DEMARK = "DM" CAMARILLA = "Camarilla" kind = input(title="Pivots Type", defval="Camarilla", options=[TRADITIONAL, FIBONACCI, WOODIE, CLASSIC, DEMARK, CAMARILLA]) pivot_time_frame = input(title="Pivots Timeframe", defval=DAILY, options=[AUTO, DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY, BIYEARLY, TRIYEARLY, QUINQUENNIALLY, DECENNIALLY]) look_back = input(title="Number of Pivots Back", type=input.integer, defval=15, minval=1, maxval=5000) is_daily_based = input(title="Use Daily-based Values", type=input.bool, defval=true, tooltip = "When this option is unchecked, Pivot Points will use intraday data while calculating on intraday charts. If Extended Hours are displayed on the chart, they will be taken into account during the pivot level calculation. If intraday OHLC values are different from daily-based values (normal for stocks), the pivot levels will also differ.") show_labels = input(title="Show Labels", type=input.bool, defval=true, inline = "labels") position_labels = input("Left", "", options = ["Left", "Right"], inline = "labels") var DEF_COLOR = #FB8C00 var arr_time = array.new_int() var p = array.new_float() p_show = input(false, "P‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏", inline = "P") p_color = input(DEF_COLOR, "", inline = "P") var r1 = array.new_float() var s1 = array.new_float() s1r1_show = input(false, "S1/R1", inline = "S1/R1") s1r1_color = input(DEF_COLOR, "", inline = "S1/R1") var r2 = array.new_float() var s2 = array.new_float() s2r2_show = input(false, "S2/R2", inline = "S2/R2") s2r2_color = input(DEF_COLOR, "", inline = "S2/R2") var r3 = array.new_float() var s3 = array.new_float() s3r3_show = input(false, "S3/R3", inline = "S3/R3") s3r3_color = input(DEF_COLOR, "", inline = "S3/R3") var r4 = array.new_float() var s4 = array.new_float() s4r4_show = input(true, "S4/R4", inline = "S4/R4") s4r4_color = input(DEF_COLOR, "", inline = "S4/R4") var r5 = array.new_float() var s5 = array.new_float() s5r5_show = input(false, "S5/R5", inline = "S5/R5") s5r5_color = input(DEF_COLOR, "", inline = "S5/R5") pivotX_open = float(na) pivotX_open := nz(pivotX_open[1],open) pivotX_high = float(na) pivotX_high := nz(pivotX_high[1],high) pivotX_low = float(na) pivotX_low := nz(pivotX_low[1],low) pivotX_prev_open = float(na) pivotX_prev_open := nz(pivotX_prev_open[1]) pivotX_prev_high = float(na) pivotX_prev_high := nz(pivotX_prev_high[1]) pivotX_prev_low = float(na) pivotX_prev_low := nz(pivotX_prev_low[1]) pivotX_prev_close = float(na) pivotX_prev_close := nz(pivotX_prev_close[1]) get_pivot_resolution() => resolution = "M" if pivot_time_frame == AUTO if timeframe.isintraday resolution := timeframe.multiplier <= 15 ? "D" : "W" else if timeframe.isweekly or timeframe.ismonthly resolution := "12M" else if pivot_time_frame == DAILY resolution := "D" else if pivot_time_frame == WEEKLY resolution := "W" else if pivot_time_frame == MONTHLY resolution := "M" else if pivot_time_frame == QUARTERLY resolution := "3M" else if pivot_time_frame == YEARLY or pivot_time_frame == BIYEARLY or pivot_time_frame == TRIYEARLY or pivot_time_frame == QUINQUENNIALLY or pivot_time_frame == DECENNIALLY resolution := "12M" resolution var lines = array.new_line() var labels = array.new_label() draw_line(i, pivot, col) => if array.size(arr_time) > 1 array.push(lines, line.new(array.get(arr_time, i), array.get(pivot, i), array.get(arr_time, i + 1), array.get(pivot, i), color=col, xloc=xloc.bar_time)) draw_label(i, y, txt, txt_color) => if show_labels offset = '‏ ‏ ‏ ‏ ‏' labels_align_str_left= position_labels == "Left" ? txt + offset : offset + txt x = position_labels == "Left" ? array.get(arr_time, i) : array.get(arr_time, i + 1) array.push(labels, label.new(x = x, y=y, text=labels_align_str_left, textcolor=txt_color, style=label.style_label_center, color=#00000000, xloc=xloc.bar_time)) traditional() => pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3 array.push(p, pivotX_Median) array.push(r1, pivotX_Median * 2 - pivotX_prev_low) array.push(s1, pivotX_Median * 2 - pivotX_prev_high) array.push(r2, pivotX_Median + 1 * (pivotX_prev_high - pivotX_prev_low)) array.push(s2, pivotX_Median - 1 * (pivotX_prev_high - pivotX_prev_low)) array.push(r3, pivotX_Median * 2 + (pivotX_prev_high - 2 * pivotX_prev_low)) array.push(s3, pivotX_Median * 2 - (2 * pivotX_prev_high - pivotX_prev_low)) array.push(r4, pivotX_Median * 3 + (pivotX_prev_high - 3 * pivotX_prev_low)) array.push(s4, pivotX_Median * 3 - (3 * pivotX_prev_high - pivotX_prev_low)) array.push(r5, pivotX_Median * 4 + (pivotX_prev_high - 4 * pivotX_prev_low)) array.push(s5, pivotX_Median * 4 - (4 * pivotX_prev_high - pivotX_prev_low)) fibonacci() => pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3 pivot_range = pivotX_prev_high - pivotX_prev_low array.push(p, pivotX_Median) array.push(r1, pivotX_Median + 0.382 * pivot_range) array.push(s1, pivotX_Median - 0.382 * pivot_range) array.push(r2, pivotX_Median + 0.618 * pivot_range) array.push(s2, pivotX_Median - 0.618 * pivot_range) array.push(r3, pivotX_Median + 1 * pivot_range) array.push(s3, pivotX_Median - 1 * pivot_range) woodie() => pivotX_Woodie_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_open * 2)/4 pivot_range = pivotX_prev_high - pivotX_prev_low array.push(p, pivotX_Woodie_Median) array.push(r1, pivotX_Woodie_Median * 2 - pivotX_prev_low) array.push(s1, pivotX_Woodie_Median * 2 - pivotX_prev_high) array.push(r2, pivotX_Woodie_Median + 1 * pivot_range) array.push(s2, pivotX_Woodie_Median - 1 * pivot_range) pivot_point_r3 = pivotX_prev_high + 2 * (pivotX_Woodie_Median - pivotX_prev_low) pivot_point_s3 = pivotX_prev_low - 2 * (pivotX_prev_high - pivotX_Woodie_Median) array.push(r3, pivot_point_r3) array.push(s3, pivot_point_s3) array.push(r4, pivot_point_r3 + pivot_range) array.push(s4, pivot_point_s3 - pivot_range) classic() => pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close)/3 pivot_range = pivotX_prev_high - pivotX_prev_low array.push(p, pivotX_Median) array.push(r1, pivotX_Median * 2 - pivotX_prev_low) array.push(s1, pivotX_Median * 2 - pivotX_prev_high) array.push(r2, pivotX_Median + 1 * pivot_range) array.push(s2, pivotX_Median - 1 * pivot_range) array.push(r3, pivotX_Median + 2 * pivot_range) array.push(s3, pivotX_Median - 2 * pivot_range) array.push(r4, pivotX_Median + 3 * pivot_range) array.push(s4, pivotX_Median - 3 * pivot_range) demark() => pivotX_Demark_X = pivotX_prev_high + pivotX_prev_low * 2 + pivotX_prev_close if pivotX_prev_close == pivotX_prev_open pivotX_Demark_X := pivotX_prev_high + pivotX_prev_low + pivotX_prev_close * 2 if pivotX_prev_close > pivotX_prev_open pivotX_Demark_X := pivotX_prev_high * 2 + pivotX_prev_low + pivotX_prev_close array.push(p, pivotX_Demark_X / 4) array.push(r1, pivotX_Demark_X / 2 - pivotX_prev_low) array.push(s1, pivotX_Demark_X / 2 - pivotX_prev_high) camarilla() => pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3 pivot_range = pivotX_prev_high - pivotX_prev_low array.push(p, pivotX_Median) array.push(r1, pivotX_prev_close + pivot_range * 1.1 / 12.0) array.push(s1, pivotX_prev_close - pivot_range * 1.1 / 12.0) array.push(r2, pivotX_prev_close + pivot_range * 1.1 / 6.0) array.push(s2, pivotX_prev_close - pivot_range * 1.1 / 6.0) array.push(r3, pivotX_prev_close + pivot_range * 1.1 / 4.0) array.push(s3, pivotX_prev_close - pivot_range * 1.1 / 4.0) array.push(r4, pivotX_prev_close + pivot_range * 1.1 / 2.0) array.push(s4, pivotX_prev_close - pivot_range * 1.1 / 2.0) resolution = get_pivot_resolution() [sec_open, sec_high, sec_low, sec_close] = security(syminfo.tickerid, resolution, [open, high, low, close], lookahead = barmerge.lookahead_on) sec_open_gaps_on = security(syminfo.tickerid, resolution, open, gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on) var number_of_years = 0 is_change_years = false var custom_years_resolution = pivot_time_frame == BIYEARLY or pivot_time_frame == TRIYEARLY or pivot_time_frame == QUINQUENNIALLY or pivot_time_frame == DECENNIALLY if custom_years_resolution and change(time(resolution)) number_of_years += 1 if pivot_time_frame == BIYEARLY and number_of_years % 2 == 0 is_change_years := true number_of_years := 0 else if pivot_time_frame == TRIYEARLY and number_of_years % 3 == 0 is_change_years := true number_of_years := 0 else if pivot_time_frame == QUINQUENNIALLY and number_of_years % 5 == 0 is_change_years := true number_of_years := 0 else if pivot_time_frame == DECENNIALLY and number_of_years % 10 == 0 is_change_years := true number_of_years := 0 var is_change = false var uses_current_bar = timeframe.isintraday and kind == WOODIE var change_time = int(na) is_time_change = (change(time(resolution)) and not custom_years_resolution) or is_change_years if is_time_change change_time := time if (not uses_current_bar and is_time_change) or (uses_current_bar and not na(sec_open_gaps_on)) if is_daily_based pivotX_prev_open := sec_open[1] pivotX_prev_high := sec_high[1] pivotX_prev_low := sec_low[1] pivotX_prev_close := sec_close[1] pivotX_open := sec_open pivotX_high := sec_high pivotX_low := sec_low else pivotX_prev_high := pivotX_high pivotX_prev_low := pivotX_low pivotX_prev_open := pivotX_open pivotX_open := open pivotX_high := high pivotX_low := low pivotX_prev_close := close[1] if barstate.islast and not is_change and array.size(arr_time) > 0 array.set(arr_time, array.size(arr_time) - 1, change_time) else array.push(arr_time, change_time) if kind == TRADITIONAL traditional() else if kind == FIBONACCI fibonacci() else if kind == WOODIE woodie() else if kind == CLASSIC classic() else if kind == DEMARK demark() else if kind == CAMARILLA camarilla() if array.size(arr_time) > look_back if array.size(arr_time) > 0 array.shift(arr_time) if array.size(p) > 0 and p_show array.shift(p) if array.size(r1) > 0 and s1r1_show array.shift(r1) if array.size(s1) > 0 and s1r1_show array.shift(s1) if array.size(r2) > 0 and s2r2_show array.shift(r2) if array.size(s2) > 0 and s2r2_show array.shift(s2) if array.size(r3) > 0 and s3r3_show array.shift(r3) if array.size(s3) > 0 and s3r3_show array.shift(s3) if array.size(r4) > 0 and s4r4_show array.shift(r4) if array.size(s4) > 0 and s4r4_show array.shift(s4) if array.size(r5) > 0 and s5r5_show array.shift(r5) if array.size(s5) > 0 and s5r5_show array.shift(s5) is_change := true else if is_daily_based pivotX_high := max(pivotX_high, sec_high) pivotX_low := min(pivotX_low, sec_low) else pivotX_high := max(pivotX_high, high) pivotX_low := min(pivotX_low, low) if barstate.islast and array.size(arr_time) > 0 and is_change is_change := false if array.size(arr_time) > 2 and custom_years_resolution last_pivot_time = array.get(arr_time, array.size(arr_time) - 1) prev_pivot_time = array.get(arr_time, array.size(arr_time) - 2) estimate_pivot_time = last_pivot_time - prev_pivot_time array.push(arr_time, last_pivot_time + estimate_pivot_time) else array.push(arr_time, time_close(resolution)) for i = 0 to array.size(lines) - 1 if array.size(lines) > 0 line.delete(array.shift(lines)) if array.size(lines) > 0 label.delete(array.shift(labels)) for i = 0 to array.size(arr_time) - 2 if array.size(p) > 0 and p_show draw_line(i, p, p_color) draw_label(i, array.get(p, i), "P", p_color) if array.size(r1) > 0 and s1r1_show draw_line(i, r1, s1r1_color) draw_label(i, array.get(r1, i), "R1", s1r1_color) if array.size(s1) > 0 and s1r1_show draw_line(i, s1, s1r1_color) draw_label(i, array.get(s1, i), "S1", s1r1_color) if array.size(r2) > 0 and s2r2_show draw_line(i, r2, s2r2_color) draw_label(i, array.get(r2, i), "R2", s2r2_color) if array.size(s2) > 0 and s2r2_show draw_line(i, s2, s2r2_color) draw_label(i, array.get(s2, i), "S2", s2r2_color) if array.size(r3) > 0 and s3r3_show draw_line(i, r3, s3r3_color) draw_label(i, array.get(r3, i), "R3", s3r3_color) if array.size(s3) > 0 and s3r3_show draw_line(i, s3, s3r3_color) draw_label(i, array.get(s3, i), "S3", s3r3_color) if array.size(r4) > 0 and s4r4_show draw_line(i, r4, s4r4_color) draw_label(i, array.get(r4, i), "R4", s4r4_color) if array.size(s4) > 0 and s4r4_show draw_line(i, s4, s4r4_color) draw_label(i, array.get(s4, i), "S4", s4r4_color) if array.size(r5) > 0 and s5r5_show draw_line(i, r5, s5r5_color) draw_label(i, array.get(r5, i), "R5", s5r5_color) if array.size(s5) > 0 and s5r5_show draw_line(i, s5, s5r5_color) draw_label(i, array.get(s5, i), "S5", s5r5_color)
Heiken Ashi Smoothed Net Volume
https://www.tradingview.com/script/yLP4Vbsy-Heiken-Ashi-Smoothed-Net-Volume/
mdenson
https://www.tradingview.com/u/mdenson/
150
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/ // © mdenson //@version=4 //Modified Volume net histogram by RafaelZioni study("Heiken Ashi Smoothed Net Volume") //================================================================== //Heiken Ashi Candle Calculations hkClose = (open + high + low + close) / 4 hkOpen = float(na) hkOpen := na(hkOpen[1]) ? (open + close) / 2 : (nz(hkOpen[1]) + nz(hkClose[1])) / 2 hkHigh = max(high, max(hkOpen, hkClose)) hkLow = min(low, min(hkOpen, hkClose)) hkHl2 = (hkOpen + hkClose)/2 volumeHA = security(heikinashi(syminfo.tickerid), timeframe.period, volume) //=================================================================== //volume Net Histogram calculations topwick = iff(hkOpen<hkClose, hkHigh - hkClose, hkHigh - hkOpen) bottomwick = iff(hkOpen<hkClose, hkOpen-hkLow, hkClose-hkLow) body = iff(hkOpen<hkClose, hkClose-hkOpen, hkOpen-hkClose) ohcl4 = (hkHigh+hkLow+hkOpen+hkClose)/4 fractionup = iff( hkOpen<hkClose, (topwick + bottomwick + 2*body)/(2*topwick + 2*bottomwick + 2*body), (topwick + bottomwick)/(2*topwick + 2*bottomwick + 2*body) ) fractiondown = iff( hkOpen<hkClose, (topwick + bottomwick)/(2*topwick + 2*bottomwick + 2*body), (topwick + bottomwick + 2*body)/(2*topwick + 2*bottomwick + 2*body) ) volumeup = volume * fractionup * ohcl4 volumedown = volume * fractiondown * ohcl4 netvolume = volumeup - volumedown lengthMA =input(25, title="length") netplot = linreg(netvolume, lengthMA, -lengthMA) lineColor = netplot > 0 ? color.green : color.red v = plot(netplot, title=" volume netflow", color=lineColor,style=plot.style_histogram, linewidth=3, transp=0) plot(0)
CRYPTO MARKET SESSION ANALYZER INDICATOR
https://www.tradingview.com/script/6WSoxyvy-CRYPTO-MARKET-SESSION-ANALYZER-INDICATOR/
thequantscience
https://www.tradingview.com/u/thequantscience/
87
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © thequantscience // @version=5 indicator(" Crypto Market Session Analyzer - The Quant Science ™ ", overlay = true) /////////////////////////////// Code by The Quant Science ® //////////////////////////////////// // -------------------------------- Crypto Market Session -------------------------------------- // HOW IT WORKS: Easy track crypto market session. // -------------------------------------------------------------------------------------------- // SETTING: Setting the session hours for your UTC and launch the script. // -------------------------------------------------------------------------------------------- // Update release 1.00 (11/15/2022) /////////////////////////////// STARTING ALGORITHM BACKTEST //////////////////////////////////// // ########################################################################################## // ########################################################################################## asia_session = input.session( defval = "2200-0900", title = "Asia session: ", group = " ############# ASIA SESSION ############# ", tooltip = "Adjust hours on your UTC.") euro_session = input.session( defval = "0900-1700", title = "Euro session: ", group = " ############# EURO SESSION ############# ", tooltip = "Adjust hours on your UTC.") america_session = input.session( defval = "1500-2200", title = "Usa session: ", group = " ############# USA SESSION ############# ", tooltip = "Adjust hours on your UTC.") // ########################################################################################## AsiaSession(sessionTimes) => not na(time(timeframe.period, sessionTimes)) asia = AsiaSession(asia_session) EuroSession(sessionTimes) => not na(time(timeframe.period, sessionTimes)) euro = EuroSession(euro_session) AmericaSession(sessionTimes) => not na(time(timeframe.period, sessionTimes)) usa = AmericaSession(america_session) // ############################################################################################ bgcolor(asia ? color.new(color.blue, 90) : na) bgcolor(euro ? color.new(color.purple, 90) : na) bgcolor(usa ? color.new(color.aqua, 90) : na) // ######################################################################################################### var tb = table.new(position.bottom_left, 1, 1, bgcolor = color.new(color.blue, 90)) if barstate.isfirst table.cell(tb, 0, 0, 'Developed by The Quant Science™' ,text_size = size.normal ,text_color = color.new(color.blue, 20)) // ############################################################################################
DrawingOBForSMC
https://www.tradingview.com/script/Tn3bH0zq-DrawingOBForSMC/
datnt141
https://www.tradingview.com/u/datnt141/
372
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © datnt141 //@version=5 indicator("SMC",overlay=true,max_boxes_count=50,max_lines_count=150) draw_structure = input(defval=true, title='Show MiS',group="Control panel") draw_supply = input(defval=true, title='Show Supply',group="Control panel") draw_demand = input(defval=true, title='Show Demand',group="Control panel") var box[] supply_zones = array.new_box() var box[] demand_zones = array.new_box() var line[] move_ups = array.new_line() var line[] move_downs = array.new_line() get_supply()=> imb = low[2]-high[0] if imb>0 prev_imb = low[3]-high[1] if prev_imb>0 sup_box = box.new(left=bar_index[2],top=high[1],right=bar_index[0],bottom=low[2]) box.set_bgcolor(sup_box, color=color.new(color.red,90)) box.set_border_color(sup_box, color=color.new(color.gray,90)) array.push(supply_zones,sup_box) else sup_box = box.new(left=bar_index[2],top=high[2],right=bar_index[0],bottom=low[2]) box.set_bgcolor(sup_box, color=color.new(color.red,90)) box.set_border_color(sup_box, color=color.new(color.gray,90)) array.push(supply_zones,sup_box) //Modify boxes// if array.size(supply_zones)>0 for i=array.size(supply_zones)-1 to 0 sup_box = array.get(supply_zones,i) top = box.get_top(sup_box) if high>=top array.remove(supply_zones,i) else box.set_right(array.get(supply_zones,i),bar_index+1) supply_zones get_demand() => imb = low[0]-high[2] if imb>0 prev_imb = low[1]-high[3] if prev_imb>0 dm_box = box.new(left=bar_index[2],top=high[2],right=bar_index[0],bottom=low[1]) box.set_bgcolor(dm_box, color=color.new(color.blue,80)) box.set_border_color(dm_box, color=color.new(color.gray,80)) array.push(demand_zones,dm_box) else dm_box = box.new(left=bar_index[2],top=high[2],right=bar_index[0],bottom=low[2]) box.set_bgcolor(dm_box, color=color.new(color.blue,80)) box.set_border_color(dm_box, color=color.new(color.gray,80)) array.push(demand_zones,dm_box) //Modify boxes// if array.size(demand_zones)>0 for i=array.size(demand_zones)-1 to 0 dm_box = array.get(demand_zones,i) bottom = box.get_bottom(dm_box) if low<=bottom array.remove(demand_zones,i) else box.set_right(array.get(demand_zones,i),bar_index+1) demand_zones //Drawing choch points// get_move_up() => move_up = high[0]>high[1] and low[0]>low[1] if array.size(move_ups)>0 most_recent_move = array.get(move_ups,array.size(move_ups)-1) x2=line.get_x2(most_recent_move) y2=line.get_y2(most_recent_move) if x2==bar_index-1 if high>=y2 line.set_x2(most_recent_move,bar_index) line.set_y2(most_recent_move,high) else if move_up == true if low[2]<low[1] up_move = line.new(x1=bar_index-2,y1=low[2],x2=bar_index,y2=high,color=color.new(color.white,10)) line.set_style(up_move,line.style_dashed) array.push(move_ups,up_move) else up_move = line.new(x1=bar_index-1,y1=low[1],x2=bar_index,y2=high,color=color.new(color.white,10)) line.set_style(up_move,line.style_dashed) array.push(move_ups,up_move) else if move_up == true if low[2]<low[1] up_move = line.new(x1=bar_index-2,y1=low[2],x2=bar_index,y2=high,color=color.new(color.white,10)) line.set_style(up_move,line.style_dashed) array.push(move_ups,up_move) else up_move = line.new(x1=bar_index-1,y1=low[1],x2=bar_index,y2=high,color=color.new(color.white,10)) line.set_style(up_move,line.style_dashed) array.push(move_ups,up_move) get_move_down() => move_down = low[0]<low[1] and high[0]<high[1] if array.size(move_downs)>0 most_recent_move = array.get(move_downs,array.size(move_downs)-1) x2=line.get_x2(most_recent_move) y2=line.get_y2(most_recent_move) if x2==bar_index-1 if low<=y2 line.set_x2(most_recent_move,bar_index) line.set_y2(most_recent_move,low) else if move_down == true if high[2]>high[1] down_move = line.new(x1=bar_index-2,y1=high[2],x2=bar_index,y2=low,color=color.new(color.yellow,10)) line.set_style(down_move,line.style_dashed) array.push(move_downs,down_move) else down_move = line.new(x1=bar_index-1,y1=high[1],x2=bar_index,y2=low,color=color.new(color.yellow,10)) line.set_style(down_move,line.style_dashed) array.push(move_downs,down_move) else if move_down == true if high[2]>high[1] down_move = line.new(x1=bar_index-2,y1=high[2],x2=bar_index,y2=low,color=color.new(color.yellow,10)) line.set_style(down_move,line.style_dashed) array.push(move_downs,down_move) else down_move = line.new(x1=bar_index-1,y1=high[1],x2=bar_index,y2=low,color=color.new(color.yellow,10)) line.set_style(down_move,line.style_dashed) array.push(move_downs,down_move) //Main script// if draw_supply get_supply() if draw_demand get_demand() if draw_structure get_move_up() get_move_down() //End of script//
Price Color Alert V2
https://www.tradingview.com/script/NUkaSdLa-Price-Color-Alert-V2/
Cryton52
https://www.tradingview.com/u/Cryton52/
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/ // © Cryton //@version=4 study("Price Color Alert", shorttitle="PCA", format = format.price, overlay=true) RedPrice = close < open GreenPrice = close > open alertcondition(RedPrice, 'Red Price') alertcondition(GreenPrice, 'Green Price')
ENVELOPE RSI - Buy Sell Signals
https://www.tradingview.com/script/nVvltKvo-ENVELOPE-RSI-Buy-Sell-Signals/
Saleh_Toodarvari
https://www.tradingview.com/u/Saleh_Toodarvari/
2,641
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Saleh_Toodarvari //@version=5 indicator(title="ENVELOPE - RSI - Buy Sell Signals", shorttitle="ENVELOPE - RSI", overlay=true) //_________________Envelope_________________ len = input.int(8, title="Envelope Length", minval=1, group="Envelope Settings") percent = input(0.22,title="Envelope Percent", group="Envelope Settings") src = input(hl2, title="Envelope Source", group="Envelope Settings") exponential = input(false) basis = exponential ? ta.ema(src, len) : ta.sma(src, len) k = percent/100.0 upper = basis * (1 + k) lower = basis * (1 - k) plot(basis, "Basis", color=#ED7300) u = plot(upper, "Upper", color=#FF2424) l = plot(lower, "Lower", color=#24FF24) fill(u, l, color=color.rgb(33, 150, 243, 95), title="Background") cross_buy=ta.crossover(close,lower) cross_sell=ta.crossunder(close,upper) // _________________RSI_________________ rsiLengthInput = input.int(8, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(hl2, "RSI Source", group="RSI Settings") up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput) down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) Overbought_RSI = input.price(title="RSI OverBought Limit(Recommended: 70-85)", defval=80, group="RSI Settings") Oversold_RSI = input.price(title="RSI OverSold Limit(Recommended: 20-30)", defval=25, group="RSI Settings") condition_buy= rsi<Oversold_RSI and (ta.cross(low,lower) or ta.cross(close,lower) or ta.cross(high,lower) or ta.cross(open,lower)) condition_sell= rsi>Overbought_RSI and (ta.cross(low,upper) or ta.cross(close,upper) or ta.cross(high,upper) or ta.cross(open,upper)) plotshape(cross_sell ? condition_sell:na, title="Sell Label", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white) sell_sig=plot(cross_sell ? high:na,color=color.new(#000000,100)) plotshape(cross_buy ? condition_buy:na, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white) buy_sig=plot(cross_buy ? ohlc4:na,color=color.new(#000000,100)) tpColor = if(cross_sell[1] or cross_sell[2] or cross_buy[1] or cross_buy[2]) color.new(#1DBC60, 30) else color.new(#000000,100) slColor = if(cross_sell[1] or cross_sell[2] or cross_buy[1] or cross_buy[2]) color.new(#F74A58, 30) else color.new(#000000,100) //_________________TP&SL_________________ TP_Percent = input.float(0.15, "TP %") SL_Percent = input.float(0.15, "SL %") tp= if condition_sell ohlc4-ohlc4*(TP_Percent/100) else if condition_buy ohlc4+ohlc4*(TP_Percent/100) sl= if condition_sell ohlc4+ohlc4*(SL_Percent/100) else if condition_buy ohlc4-ohlc4*(SL_Percent/100) tp_sig=plot(tp,color=color.new(#000000,100),title="tp") sl_sig=plot(sl,color=color.new(#000000,100),title="tp") lower_plot=plot(lower,color=color.new(#000000,100)) fill(sell_sig,tp_sig, color=tpColor) fill(buy_sig,tp_sig, color=tpColor) fill(buy_sig,sl_sig, color=slColor) fill(sell_sig,sl_sig, color=slColor) //_________________alerts_________________ alertConditionBuy=cross_buy and condition_buy alertConditionSell=cross_sell and condition_sell alertcondition(alertConditionBuy, title='Envelope RSI Buy signal!', message='Buy signal') alertcondition(alertConditionSell, title='Envelope RSI Sell signal!', message='Sell signal')
Close Over/Under Level
https://www.tradingview.com/script/Qm6i6Pa7-Close-Over-Under-Level/
ddctv
https://www.tradingview.com/u/ddctv/
195
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ddctv //@version=5 indicator("Close Over/Under Level", overlay=true) // Inputs closeAboveLevel = input(0.0) closeBelowLevel = input(0.0) plotLines = input(true) // Logic closedAbove = closeAboveLevel > 0 and close[1] > closeAboveLevel closedBelow = closeBelowLevel > 0 and close[1] < closeBelowLevel // Plots plot( closeAboveLevel > 0 and plotLines ? closeAboveLevel : na, color = color.new(color.red,50), style=plot.style_circles, offset=-1 ) plot( closeBelowLevel > 0 and plotLines ? closeBelowLevel : na, color = color.new(color.blue,50), style=plot.style_circles, offset=-1 ) // Alerts alertcondition(closedAbove, title="Close Over", message="{{ticker}} closed above {{plot_0}}.") alertcondition(closedBelow, title="Close Under", message="{{ticker}} closed below {{plot_1}}.")
ChillLax Percent Up and Down
https://www.tradingview.com/script/2iFPNQev-ChillLax-Percent-Up-and-Down/
chilllaxtrader
https://www.tradingview.com/u/chilllaxtrader/
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/ // © chilllaxtrader //@version=5 // mark the point when a stock is up or down more than 5% (default) from the previous close. indicator(title='ChillLax Percent Up or Down', shorttitle='ChillLax Percent Up or Down', overlay=true) percentup = input(defval=5, title='percentage up') percentdown = input(defval=5, title='percentage down') upday = (close - close[1]) / close[1] * 100 >= percentup downday = (close - close[1]) / close[1] * 100 <= -percentdown plotshape(upday, style=shape.triangleup, location=location.belowbar, size=size.normal, color=color.new(color.blue, 0)) plotshape(downday, style=shape.triangledown, location=location.abovebar, size=size.normal, color=color.new(color.red, 0))
Highlight Trading Window (Simple Hours / Time of Day Filter)
https://www.tradingview.com/script/3BmID7aW-Highlight-Trading-Window-Simple-Hours-Time-of-Day-Filter/
ddctv
https://www.tradingview.com/u/ddctv/
389
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ddctv //@version=5 indicator("Highlight Trading Window (Simple Hours / Time of Day Filter)", overlay=true) ////////////////////////////// // LIMIT TIME OF DAY WINDOW // ////////////////////////////// transparency = 90 // input.int(title="Time Filter background transparency", defval=95) gmtSelect = input.string(title="Select Local Time Zone", defval="GMT-8", options=["GMT-12","GMT-11","GMT-10","GMT-9","GMT-8","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","GMT+14"], confirm=true, group="Limit Time of Day Window") // === INPUT TIME RANGE === betweenTime = input.session('0700-0900', title = "Time Filter", group="Limit Time of Day Window") // '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) ? na : color.new(color.green,transparency))
U.S. Futures Price Limits
https://www.tradingview.com/script/oH1OAPsr-U-S-Futures-Price-Limits/
theGary
https://www.tradingview.com/u/theGary/
55
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © theGary //@version=5 indicator("Psych. Levels", overlay = true, max_boxes_count = 500) // inputs var group1_singlesle_box = array.new_box(50, na) var group1_tens_box = array.new_box(50, na) var group1_hundreds_box = array.new_box(50, na) var group1_thousands_box = array.new_box(50, na) group1_singles = input.bool(false, title = "Zone 1", group = 'Group 1', inline = '1') group1_singlescolor = input.color(color.new(color.white, 80), title = '', group = 'Group 1', inline = '1') group1_tens = input.bool(true, title = "Zone 2", group = 'Group 1', inline = '2') group1_tenscolor = input.color(color.new(color.white, 90), title = '', group = 'Group 1', inline = '2') group1_hundreds = input.bool(false, title = "Zone 3", group = 'Group 1', inline = '3') group1_hundredscolor = input.color(color.new(color.white, 93), title = '', group = 'Group 1', inline = '3') group1_thousands = input.bool(false, title = "Zone 4", group = 'Group 1', inline = '4') group1_thousandscolor = input.color(color.new(color.white, 97), title = '', group = 'Group 1', inline = '4') // extract price length len = str.length(str.tostring(math.round(close,0))) priceString = str.tostring(close[1]) decimalPosition = str.pos(priceString, ".") splitPriceString = str.split(priceString, ".") beforeDecimalLength = str.length(array.first(splitPriceString)) afterDecimalLength = str.length(array.last(splitPriceString)) totalLength = beforeDecimalLength + afterDecimalLength if barstate.islastconfirmedhistory label.new(bar_index+20, close[1], text=str.tostring(beforeDecimalLength)) // set rounding var float rounding_singles = na var float rounding_tens = na var float rounding_hundreds = na var float rounding_thousands = na var float baseline_singles = na var float baseline_tens = na var float baseline_hundreds = na var float baseline_thousands = na barcolor(beforeDecimalLength <= 1 ? color.yellow : na) if barstate.isconfirmed if beforeDecimalLength <= 1 rounding_singles := afterDecimalLength == 5 ? 10 : afterDecimalLength == 4 ? 1 : afterDecimalLength >= 3 ? 0.1 : 0.01 rounding_tens := afterDecimalLength == 5 ? 100 : afterDecimalLength == 4 ? 10 : afterDecimalLength >= 3 ? 1 : 0.1 rounding_hundreds := afterDecimalLength == 5 ? 1000 : afterDecimalLength == 4 ? 100 : afterDecimalLength >= 3 ? 10 : 1 rounding_thousands := afterDecimalLength == 5 ? 10000 : afterDecimalLength == 4 ? 1000 : afterDecimalLength >= 3 ? 100 : 10 baseline_singles := math.round( close / rounding_singles) * rounding_singles baseline_tens := math.round( close / rounding_tens) * rounding_tens baseline_hundreds := math.round( close / rounding_hundreds) * rounding_hundreds baseline_thousands := math.round( close / rounding_thousands) * rounding_thousands else rounding_singles := beforeDecimalLength == 5 ? 10 : beforeDecimalLength == 4 ? 1 : beforeDecimalLength >= 3 ? 0.1 : 0.01 rounding_tens := beforeDecimalLength == 5 ? 100 : beforeDecimalLength == 4 ? 10 : beforeDecimalLength >= 3 ? 1 : 0.1 rounding_hundreds := beforeDecimalLength == 5 ? 1000 : beforeDecimalLength == 4 ? 100 : beforeDecimalLength >= 3 ? 10 : 1 rounding_thousands := beforeDecimalLength == 5 ? 10000 : beforeDecimalLength == 4 ? 1000 : beforeDecimalLength >= 3 ? 100 : 10 baseline_singles := math.round( close / rounding_singles) * rounding_singles baseline_tens := math.round( close / rounding_tens) * rounding_tens baseline_hundreds := math.round( close / rounding_hundreds) * rounding_hundreds baseline_thousands := math.round( close / rounding_thousands) * rounding_thousands if barstate.islastconfirmedhistory log.info("Zone 1= " + str.tostring(rounding_singles)) log.info("Zone 2= " + str.tostring(rounding_tens)) log.info("Zone 3= " + str.tostring(rounding_hundreds)) log.info("Zone 4= " + str.tostring(rounding_thousands)) plot(baseline_singles) f_draw_box(boxes, baseline, round, mult_top, mult_bottom, color) => array_size = array.size(boxes) if array_size > 0 for i = 0 to array_size- 1 box.delete(array.get(boxes, i)) array.clear(boxes) for i = 0 to 49 array.unshift(boxes, box.new(left = time[1], top = baseline+(i*round) + (round/10*mult_top), right = time, bottom = baseline+(i*round) + (round/10*mult_bottom), extend = extend.both, xloc = xloc.bar_time, bgcolor = color, border_color = color.new(color.white, 100))) array.unshift(boxes, box.new(left = time[1], top = baseline-((i+1)*round) + (round/10*mult_top), right = time, bottom = baseline-((i+1)*round) + (round/10*mult_bottom), extend = extend.both, xloc = xloc.bar_time, bgcolor = color, border_color = color.new(color.white, 100))) // draw levels if barstate.islastconfirmedhistory or (barstate.islast and barstate.isconfirmed) if group1_singles f_draw_box(group1_singlesle_box, baseline_singles, rounding_singles, 1, 0, group1_singlescolor) if group1_tens f_draw_box(group1_tens_box, baseline_tens, rounding_tens, 1, 0, group1_tenscolor) if group1_hundreds f_draw_box(group1_hundreds_box, baseline_hundreds, rounding_hundreds, 1, 0, group1_hundredscolor) if group1_thousands f_draw_box(group1_thousands_box, baseline_thousands, rounding_thousands, 1, 0, group1_thousandscolor)
오일선
https://www.tradingview.com/script/eH09RO90/
bass83110
https://www.tradingview.com/u/bass83110/
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/ // © bass83110 //@version=5 indicator("내 스크립트") plot(close)
Rolling VWAP with Standard Deviations
https://www.tradingview.com/script/ZzE3Wd0S-Rolling-VWAP-with-Standard-Deviations/
xcessivegee
https://www.tradingview.com/u/xcessivegee/
141
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © TradingView //@version=5 indicator("Rolling VWAP with Standard Deviations", "RVWAP + StdDev", true) import PineCoders/ConditionalAverages/1 as pc // ———————————————————— Constants and Inputs { int MS_IN_MIN = 60 * 1000 int MS_IN_HOUR = MS_IN_MIN * 60 int MS_IN_DAY = MS_IN_HOUR * 24 var string TT_WINDOW = "By default, the time period used to calculate the RVWAP automatically adjusts with the chart's timeframe. Check this to use a fixed-size time period instead, which you define with the following three values." var string TT_MINBARS = "The minimum number of last values to keep in the moving window, even if these values are outside the time period. This avoids situations where a large time gap between two bars would cause the time window to be empty." var string TT_STDEV = "The multiplier for the standard deviation bands offset above and below the RVWAP. Example: 1.0 is 100% of the offset value. \n\nNOTE: A value of 0.0 will hide the bands." float srcInput = input.source(hlc3, "Source", tooltip = "The source used to calculate the VWAP. The default is the average of the high, low and close prices.") var string GRP2 = '═══════════   Time Period   ═══════════' bool fixedTfInput = input.bool(false, "Use a fixed time period", group = GRP2, tooltip = TT_WINDOW) int daysInput = input.int(1, "Days", minval = 0, maxval = 90, group = GRP2) * MS_IN_DAY int hoursInput = input.int(0, "Hours", minval = 0, maxval = 23, group = GRP2) * MS_IN_HOUR int minsInput = input.int(0, "Minutes", minval = 0, maxval = 59, group = GRP2) * MS_IN_MIN bool tableInput = input.bool(true, "Show time period", group = GRP2, tooltip = "Displays the time period of the rolling window.") string textSizeInput = input.string("large", "Text size", group = GRP2, options = ["tiny", "small", "normal", "large", "huge", "auto"]) string tableYposInput = input.string("bottom", "Position     ", inline = "21", group = GRP2, options = ["top", "middle", "bottom"]) string tableXposInput = input.string("right", "", inline = "21", group = GRP2, options = ["left", "center", "right"]) var string GRP4 = '════════  Minimum Window Size  ════════' int minBarsInput = input.int(10, "Bars", group = GRP4, tooltip = TT_MINBARS) // } // ———————————————————— Functions { timeStep() => // @function Determines a time period from the chart's timeframe. // @returns (int) A value of time in milliseconds that is appropriate for the current chart timeframe. To be used in the RVWAP calculation. int tfInMs = timeframe.in_seconds() * 1000 float step = switch tfInMs <= MS_IN_MIN => MS_IN_HOUR tfInMs <= MS_IN_MIN * 5 => MS_IN_HOUR * 4 tfInMs <= MS_IN_HOUR => MS_IN_DAY * 1 tfInMs <= MS_IN_HOUR * 4 => MS_IN_DAY * 3 tfInMs <= MS_IN_HOUR * 12 => MS_IN_DAY * 7 tfInMs <= MS_IN_DAY => MS_IN_DAY * 30.4375 tfInMs <= MS_IN_DAY * 7 => MS_IN_DAY * 90 => MS_IN_DAY * 365 int result = int(step) tfString(int timeInMs) => // @function Produces a string corresponding to the input time in days, hours, and minutes. // @param (series int) A time value in milliseconds to be converted to a string variable. // @returns (string) A string variable reflecting the amount of time from the input time. int s = timeInMs / 1000 int m = s / 60 int h = m / 60 int tm = math.floor(m % 60) int th = math.floor(h % 24) int d = math.floor(h / 24) string result = switch d == 30 and th == 10 and tm == 30 => "1M" d == 7 and th == 0 and tm == 0 => "1W" => string dStr = d ? str.tostring(d) + "D " : "" string hStr = th ? str.tostring(th) + "H " : "" string mStr = tm ? str.tostring(tm) + "min" : "" dStr + hStr + mStr // } // ———————————————————— Calculations and Plots { // Stop the indicator on charts with no volume. if barstate.islast and ta.cum(nz(volume)) == 0 runtime.error("No volume is provided by the data vendor.") // RVWAP + stdev bands var int timeInMs = fixedTfInput ? minsInput + hoursInput + daysInput : timeStep() float sumSrcVol = pc.totalForTimeWhen(srcInput * volume, timeInMs, true, minBarsInput) float sumVol = pc.totalForTimeWhen(volume, timeInMs, true, minBarsInput) float sumSrcSrcVol = pc.totalForTimeWhen(volume * math.pow(srcInput, 2), timeInMs, true, minBarsInput) float rollingVWAP = sumSrcVol / sumVol float variance = sumSrcSrcVol / sumVol - math.pow(rollingVWAP, 2) variance := variance < 0 ? 0 : variance float stDev = math.sqrt(variance) r1 = plot(rollingVWAP, "Rolling VWAP", color.purple) n2 = plot(rollingVWAP - stDev * 1, "Lower 1", color.new(color.green, 90)) n3 = plot(rollingVWAP - stDev * 1.5, "1.5", color.new(color.green, 85)) n4 = plot(rollingVWAP - stDev * 2, "2", color.new(color.green, 80)) n5 = plot(rollingVWAP - stDev * 2.5, "2.5", color.new(color.green, 75)) n6 = plot(rollingVWAP - stDev * 3, "3", color.new(color.green, 70)) p2 = plot(rollingVWAP + stDev * 1, "Upper 1", color.new(color.red, 90)) p3 = plot(rollingVWAP + stDev * 1.5, "1.5", color.new(color.red, 85)) p4 = plot(rollingVWAP + stDev * 2, "2", color.new(color.red, 80)) p5 = plot(rollingVWAP + stDev * 2.5, "2.5", color.new(color.red, 75)) p6 = plot(rollingVWAP + stDev * 3, "3", color.new(color.red, 70)) fill(r1, p2, color.new(color.red, 97), "Mid Lower Fill") fill(r1, n2, color.new(color.green, 97), "Mid Upper Fill") fill(p2, p3, color.new(color.red, 95), "-1 Fill") fill(p3, p4, color.new(color.red, 90), "-1.5 Fill") fill(p4, p5, color.new(color.red, 85), "-2 Fill") fill(p5, p6, color.new(color.red, 80), "-2.5 Fill") fill(n2, n3, color.new(color.green, 95), "-1 Fill") fill(n3, n4, color.new(color.green, 90), "-1.5 Fill") fill(n4, n5, color.new(color.green, 85), "-2 Fill") fill(n5, n6, color.new(color.green, 80), "-2.5 Fill") // Display of time period. var table tfDisplay = table.new(tableYposInput + "_" + tableXposInput, 1, 1) if tableInput table.cell(tfDisplay, 0, 0, tfString(timeInMs), bgcolor = na, text_color = color.gray, text_size = textSizeInput) // }
Market Bias (CEREBR)
https://www.tradingview.com/script/mSAccJBe-Market-Bias-CEREBR/
Professeur_X
https://www.tradingview.com/u/Professeur_X/
879
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Professeur_X //@version=5 indicator(title='Market Bias (CEREBR)', shorttitle='Market Bias', overlay=true) //#region -----> INPUTS, FUCNTIONS // FUNCTIONS //@function This function forces the current timeframe on inputs that shouldn't take lower timeframes FORCE_CTF(str_tf) => i_tf_sec = timeframe.in_seconds(str_tf) ctf_sec = timeframe.in_seconds('') // Returns the CTF if the passed timeframe is lower i_tf_sec < ctf_sec ? '' : str_tf // // INPUTS ha_htf = FORCE_CTF(input.timeframe('', 'Timeframe', tooltip="This timeframe must be equal to or greater than the chart's timeframe", group="HA Market Bias")) ha_len = input(100, 'Period', group="HA Market Bias") ha_len2 = input(100, 'Smoothing', group="HA Market Bias") show_ha = input.bool(true, "Show HA Candles", inline='ha/mb display', group='Display Settings') show_mb = input.bool(true, "Show Market Bias", inline='ha/mb display', group='Display Settings') col_bull = input.color(color.lime, 'Color: Bullish', inline='bull/bear color', group='Display Settings', display=display.none) col_bear = input.color(color.red, 'Bearish', inline='bull/bear color', group='Display Settings', display=display.none) // These add an offset during data importation to avoid lookahead bias indexHighTF = timeframe.in_seconds(ha_htf) == timeframe.in_seconds('') ? 0 : barstate.isrealtime ? 1 : 0 indexCurrTF = timeframe.in_seconds(ha_htf) == timeframe.in_seconds('') ? 0 : barstate.isrealtime ? 0 : 1 //@function Handles the import of data from other timeframes, while preventing repainting //@param _resolution (str) : This is the timeframe to import data from. //@param _expression (float | int) : This is the data to be imported f_no_repaint_request(string _resolution, _expression) => request.security(syminfo.tickerid, _resolution, _expression[indexHighTF])[indexCurrTF] //#endregion //#region -----> CALCULATIONS // Smoothen the OHLC values o = ta.ema(open, ha_len) c = ta.ema(close, ha_len) h = ta.ema(high, ha_len) l = ta.ema(low, ha_len) // Calculate the Heikin Ashi OHLC values from it haclose = f_no_repaint_request(ha_htf, (o + h + l + c) / 4) xhaopen = f_no_repaint_request(ha_htf, (o + c) / 2) haopen = na(xhaopen[1]) ? (o + c) / 2 : (xhaopen[1] + haclose[1]) / 2 hahigh = math.max(h, math.max(haopen, haclose)) halow = math.min(l, math.min(haopen, haclose)) // Smoothen the Heiken Ashi Candles o2 = f_no_repaint_request(ha_htf, ta.ema(haopen, ha_len2)) c2 = f_no_repaint_request(ha_htf, ta.ema(haclose, ha_len2)) h2 = f_no_repaint_request(ha_htf, ta.ema(hahigh, ha_len2)) l2 = f_no_repaint_request(ha_htf, ta.ema(halow, ha_len2)) ha_avg = (h2 + l2) / 2 //TODO: Publish the Oscillator version of the indicator // Oscillator { osc_len = input.int(7, "Oscillator Period", group="HA Market Bias") osc_bias = 100 * (c2 - o2) osc_smooth = ta.ema(osc_bias, osc_len) sigcolor = switch (osc_bias > 0) and (osc_bias >= osc_smooth) => color.new(col_bull, 35) (osc_bias > 0) and (osc_bias < osc_smooth) => color.new(col_bull, 75) (osc_bias < 0) and (osc_bias <= osc_smooth) => color.new(col_bear, 35) (osc_bias < 0) and (osc_bias > osc_smooth) => color.new(col_bear, 75) => color(na) // } //#endregion //#region -----> PLOTS, ALERTS { // Plots p_h = plot(h2, "Bias High", color=color(na), display=display.data_window, editable=false) p_l = plot(l2, "Bias Low", color=color(na), display=display.data_window, editable=false) p_avg = plot(ha_avg, "Bias Avergae", color=color(na), display=display.data_window, editable=false) fill(p_l, p_h, show_mb ? sigcolor : na) col = o2 > c2 ? col_bear : col_bull plotcandle(o2, h2, l2, c2, title='heikin smoothed', color=col, display=show_ha ? display.pane : display.data_window, editable=false) // Alerts // Bullish Trend Switch (Bearish -> Bullish) alertcondition(ta.change(ta.change(math.sign(osc_bias)) > 0), 'Bullish Trend Switch (Bearish -> Bullish)', '{{exchange}}:{{ticker}}: Trend is now Bullish.') // Bullish Trend Strengthens alertcondition(osc_bias > 0 and ta.change(math.sign(osc_bias - osc_smooth)) > 0, 'Bullish Trend Strengthens', '{{exchange}}:{{ticker}}: Bullish Trend is now Stronger.') // Bullish Trend Weakens alertcondition(osc_bias > 0 and ta.change(math.sign(osc_bias - osc_smooth)) < 0, 'Bullish Trend Weakens', '{{exchange}}:{{ticker}}: Bullish Trend is now Weaker.') // Bearish Trend Switch (Bullish -> Bearish) alertcondition(ta.change(ta.change(math.sign(osc_bias)) < 0), 'Bearish Trend Switch (Bullish -> Bearish)', '{{exchange}}:{{ticker}}: Trend is now Bearish.') // Bearish Trend Strengthens alertcondition(osc_bias < 0 and ta.change(math.sign(osc_bias - osc_smooth)) < 0, 'Bearish Trend Strengthens', '{{exchange}}:{{ticker}}: Bearish Trend is now Stronger.') // Bearish Trend Weakens alertcondition(osc_bias < 0 and ta.change(math.sign(osc_bias - osc_smooth)) > 0, 'Bearish Trend Weakens', '{{exchange}}:{{ticker}}: Bearish Trend is now Weaker.') //#endregion // CUSTOM ALERTS : To enable this functionality, Select and uncomment (Cmd (or Ctrl) + /) the following code block, starting from the next line. // // { // use_custom_alerts = input.bool(false, 'Use Custom Alert Messages', group='Alert Messages', display=display.none) // i_alert_bull_trend_switch = input.text_area('New Bullish Trend', 'Bullish Trend Switch', group='Alert Messages', display=display.none) // i_alert_bull_trend_strengthen = input.text_area('New Strong Bullish Trend', 'Bullish Trend Strengthens', group='Alert Messages', display=display.none) // i_alert_bull_trend_weaken = input.text_area('New Weak Bullish Trend', 'Bullish Trend Weakens', group='Alert Messages', display=display.none) // i_alert_bear_trend_switch = input.text_area('New Bearish Trend', 'Bearish Trend Switch', group='Alert Messages', display=display.none) // i_alert_bear_trend_strengthen = input.text_area('New Strong Bearish Trend', 'Bearish Trend Strengthens', group='Alert Messages', display=display.none) // i_alert_bear_trend_weaken = input.text_area('New Weak Bearish Trend', 'Bearish Trend Weakens', group='Alert Messages', display=display.none) // // Bullish Trend Switch (Bearish -> Bullish) // if (ta.change(ta.change(math.sign(osc_bias)) > 0)) // alert(i_alert_bull_trend_switch, alert.freq_once_per_bar) // // Bullish Trend Strengthens // if (osc_bias > 0 and ta.change(math.sign(osc_bias - osc_smooth)) > 0) // alert(i_alert_bull_trend_strengthen, alert.freq_once_per_bar) // // Bullish Trend Weakens // if (osc_bias > 0 and ta.change(math.sign(osc_bias - osc_smooth)) < 0) // alert(i_alert_bull_trend_weaken, alert.freq_once_per_bar) // // Bearish Trend Switch (Bullish -> Bearish) // if (ta.change(ta.change(math.sign(osc_bias)) < 0)) // alert(i_alert_bear_trend_switch, alert.freq_once_per_bar) // // Bearish Trend Strengthens // if (osc_bias < 0 and ta.change(math.sign(osc_bias - osc_smooth)) < 0) // alert(i_alert_bear_trend_strengthen, alert.freq_once_per_bar) // // Bearish Trend Weakens // if (osc_bias < 0 and ta.change(math.sign(osc_bias - osc_smooth)) > 0) // alert(i_alert_bear_trend_weaken, alert.freq_once_per_bar) // // }
Vegas+200+Big Vol by RSU
https://www.tradingview.com/script/aJ5xadIl/
rsu9
https://www.tradingview.com/u/rsu9/
208
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rsu9111 //@version=5 indicator(title="Vegas+200+Big Vol by RSU",shorttitle="Vegas200BV[RSU]",overlay=true) ema144=ta.sma(ta.ema(close,144),5) ema169=ta.sma(ta.ema(close,169),5) ema288=ta.sma(ta.ema(close,288),5) ema338=ta.sma(ta.ema(close,338),5) ema576=ta.sma(ta.ema(close,576),5) ema676=ta.sma(ta.ema(close,676),5) color1=color.new(color.orange,90) color2=color.new(color.red,90) color3=color.new(color.lime,95) color4=color.new(color.gray,90) ema200=ta.sma(ta.ema(close,200),5) ma200=ta.sma(close,200) plot(ema200,color=ta.change(ema200) > 0 ? color.green : color.red,linewidth=2,title="EMA200") plot(ma200,color = bar_index % 3 == 0 and not barstate.islast ? ta.change(ma200) > 0 ? color.green : color.red:color.new(color.blue,100),linewidth=2,title="MA200") plotchar(ta.crossover(ema144,ema169),location=location.belowbar,size=size.normal,title="144 crossover 169",char='✌️') l144=plot(ema144,color=color1,title="144") l169=plot(ema169,color=color1,title="169") l288=plot(ema288,color=color3,title="288") l338=plot(ema338,color=color3,title="338") l576=plot(timeframe.isdaily?ema576:na,color=color4,title="576") l676=plot(timeframe.isdaily?ema676:na,color=color4,title="676") fill(l144,l169,color=ema144>ema169 and ema144>=ema144[1]?color1:color2,title="144,169 channel") fill(l288,l338,color=ema288>ema338 and ema288>=ema288[1]?color3:color4,title="288,338 channel") //Big Vol BOX boxcolor1=color.new(color.yellow, 80) var boxindex=0 avg = ta.sma(volume,60) std = ta.stdev(volume,60) condition = (volume-avg) > 4*std if condition boxcolor=boxcolor1 myBox = box.new(left=bar_index, top=high,border_color=boxcolor,right=bar_index+20, bottom=low,bgcolor=boxcolor)
wnG - VWAP MOD
https://www.tradingview.com/script/YZpZp4uC-wnG-VWAP-MOD/
wingoutoulouse
https://www.tradingview.com/u/wingoutoulouse/
88
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © wingoutoulouse //@version=5 indicator(title="wnG - VWAP", shorttitle="wnG - VWAP [p]", overlay=true) // Inputs //ATR_vs_TR = input.bool(true,title="Progressive Daily TR ?") Period = input.string("D",title="Period", options=["240", "D", "W", "M"]) vwap_src = input.source(hlc3, title="Source") ATR_vs_TR = input.string("Progressive Daily",title="ATR Type", options=["Progressive Daily", "24 Hours rolling ATR"]) vwap_show = input.bool(true, title='Show VWAP ?', inline="line 0") band_show = input.bool(true, title='Show BAND ?', inline="line 0") vwap1 = input.float(title='VWAP 1', defval=1, step=0.5, inline="line 1") vwap2 = input.float(title='VWAP 2', defval=-1, step=0.5, inline="line 1") vwap3 = input.float(title='VWAP 3', defval=2, step=0.5, inline="line 2") vwap4 = input.float(title='VWAP 4', defval=-2, step=0.5, inline="line 2") vwap5 = input.float(title='VWAP 5', defval=3, step=0.5, inline="line 3") vwap6 = input.float(title='VWAP 6', defval=-3, step=0.5, inline="line 3") start = request.security(syminfo.tickerid, "D", time,lookahead=barmerge.lookahead_on) newSession = start > start[1] ? 1 : 0 vwapsum = 0.0 volumesum = 0.0 vwapsum := newSession[1] ? vwap_src * volume : vwapsum[1] + vwap_src * volume volumesum := newSession[1] ? volume : volumesum[1] + volume //vwap_now = barstate.isconfirmed ? vwapsum/volumesum : na vwap_now = vwapsum/volumesum actual_TF = timeframe.in_seconds(timeframe.period)/60 length_ATR = 1440 / actual_TF size_ATR = ta.atr(length_ATR) var start_index = 0 start_index := newSession ? bar_index : start_index[1] length_TR = bar_index - start_index == 0 ? 1440 / actual_TF : bar_index - start_index true_range = ta.tr(true) true_range_sum = 0.0 for i = 0 to length_TR-1 true_range_sum += true_range[i] average_true_range = true_range_sum / length_TR vwap_1 = ATR_vs_TR == "Progressive Daily" ? vwap_now + average_true_range * vwap1 : vwap_now + size_ATR * vwap1 vwap_2 = ATR_vs_TR == "Progressive Daily" ? vwap_now + average_true_range * vwap2 : vwap_now + size_ATR * vwap2 vwap_3 = ATR_vs_TR == "Progressive Daily" ? vwap_now + average_true_range * vwap3 : vwap_now + size_ATR * vwap3 vwap_4 = ATR_vs_TR == "Progressive Daily" ? vwap_now + average_true_range * vwap4 : vwap_now + size_ATR * vwap4 vwap_5 = ATR_vs_TR == "Progressive Daily" ? vwap_now + average_true_range * vwap5 : vwap_now + size_ATR * vwap5 vwap_6 = ATR_vs_TR == "Progressive Daily" ? vwap_now + average_true_range * vwap6 : vwap_now + size_ATR * vwap6 plot(vwap_show ? vwap_now : na, color=color.white, title='VWAP',linewidth=2) plot_vwap1 = plot(band_show ? vwap_1 : na, color=color.gray, title='VWAP 1', linewidth=1) plot_vwap2 = plot(band_show ? vwap_2 : na, color=color.gray, title='VWAP 2', linewidth=1) plot_vwap3 = plot(band_show ? vwap_3 : na, color=color.gray, title='VWAP 3', linewidth=1) plot_vwap4 = plot(band_show ? vwap_4 : na, color=color.gray, title='VWAP 4', linewidth=1) plot_vwap5 = plot(band_show ? vwap_5 : na, color=color.gray, title='VWAP 5', linewidth=1) plot_vwap6 = plot(band_show ? vwap_6 : na, color=color.gray, title='VWAP 6', linewidth=1) fill(plot_vwap4, plot_vwap6, color=color.new(color.lime,80)) fill(plot_vwap3, plot_vwap5, color=color.new(color.red,80))