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
DOW Theory Price Action Multi-Time Frame
https://www.tradingview.com/script/mX5C48KH-DOW-Theory-Price-Action-Multi-Time-Frame/
Mohit_Kakkar08
https://www.tradingview.com/u/Mohit_Kakkar08/
242
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Mohit_Kakkar08 // This code is written on the basis of Dow theory candlesticks rules by Mohit Kakkar. Disclaimer - Publisher is not responsible for any financial loss or any false signal. //@version=5 indicator("DOW Theory Price Action Multi-Time Frame", overlay=true) tableposition=input.string("top_right",title="Table position", options=["top_left", "top_center", "top_right", "middle_left", "middle_center", "middle_right", "bottom_left", "bottom_center", "bottom_right"]) tabpos= tableposition== "top_left"? position.top_left:tableposition== "top_center"?position.top_center : tableposition== "top_right"? position.top_right : tableposition== "middle_left"? position.middle_left : tableposition== "middle_center"? position.middle_center : tableposition== "middle_right"? position.middle_right : tableposition== "bottom_left"? position.bottom_left : tableposition== "bottom_center"? position.bottom_center: tableposition== "bottom_right"? position.bottom_right: position.top_right oneSet = input.timeframe(defval='60', title='First Timeframe', group='Higher Timeframe Levels', tooltip='Allows you to set different time frames for timeframe continuity.') twoSet = input.timeframe(defval='D', title='Second Timeframe', group='Higher Timeframe Levels') threeSet = input.timeframe(defval='W', title='Third Timeframe', group='Higher Timeframe Levels') fourSet = input.timeframe(defval='M', title='Fourth Timeframe', group='Higher Timeframe Levels') f_Strat() => U = (high >= high[1]) and (low >= low[1]) and close>high[1] D = (high <= high[1]) and (low <= low[1]) and close<low[1] UX = U[1] and not D DX = D[1] and not U UVX = (U[1] or UX[1]) and not U and not D DVX = (D[1] or DX[1]) and not U and not D OC = (high>high[1]) and (low<low[1]) UC= (U[1] or UX[1] or UVX[1] ) and close>low[1] and close>close[1] and not (D[1] or DX[1] or DVX[1] or OC[1]) DC= (D[1] or DX[1] or DVX[1] ) and close<high[1] and close<close[1] and not (U[1] or UX[1] or UVX[1] or OC[1]) UD = UC[1] and not D DD = DC[1] and not U UE = close>low[1] and not (U or UX or UVX or UC or UD or D or DX or DVX or DC or DD) and ((U[1] or UX[1] or UVX[1] or UC[1] or UD[1])) DE = close<high[1] and not (U or UX or UVX or UC or UD or D or DX or DVX or DC or DD or UE) [U, D, UX, DX, UVX, DVX, OC, UC, DC, UD, DD, UE, DE] [U0, D0, UX0, DX0, UVX0, DVX0, OC0, UC0, DC0, UD0, DD0, UE0, DE0 ] = request.security(syminfo.ticker, oneSet, f_Strat()) [U1, D1, UX1, DX1, UVX1, DVX1, OC1, UC1, DC1, UD1, DD1, UE1, DE1] = request.security(syminfo.ticker, twoSet, f_Strat()) [U2, D2, UX2, DX2, UVX2, DVX2, OC2, UC2, DC2, UD2, DD2, UE2, DE2] = request.security(syminfo.ticker, threeSet, f_Strat()) [U3, D3, UX3, DX3, UVX3, DVX3, OC3, UC3, DC3, UD3, DD3, UE3, DE3] = request.security(syminfo.ticker, fourSet, f_Strat()) // == TABLE PLOTTING == var table trendTable = table.new(tabpos, 5, 2, border_width=2) upColor = color.rgb(38, 166, 154) downColor = color.rgb(240, 83, 80) tfColor = color.new(#999999, 0) show_table4 = input(true, "Show MTF Price Action Table?") // Check to ensure boxes are all higher timeframe than the chart to remove glyph and gray out box if that's the case tfInMinutes(simple string tf = "") => float chartTf = 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) float result = tf == "" ? chartTf : request.security(syminfo.tickerid, tf, chartTf) float chartTFInMinutes = tfInMinutes() bool TF1Check = tfInMinutes(oneSet) < chartTFInMinutes bool TF2Check = tfInMinutes(twoSet) < chartTFInMinutes bool TF3Check = tfInMinutes(threeSet) < chartTFInMinutes bool TF4Check = tfInMinutes(fourSet) < chartTFInMinutes // Define glyphs glyph1 = TF1Check ? na : (U0 or UX0 or UVX0 or UC0 or UD0 or UE0 ) ? 'β–² ': (D0 or DX0 or DVX0 or DC0 or DD0 or DE0) ? 'β–Ό ' : na glyph2 = TF2Check ? na : (U1 or UX1 or UVX1 or UC1 or UD1 or UE1) ? 'β–² ': (D1 or DX1 or DVX1 or DC1 or DD1 or DE1) ? 'β–Ό ' : na glyph3 = TF3Check ? na : (U2 or UX2 or UVX2 or UC2 or UD2 or UE2) ? 'β–² ': (D2 or DX2 or DVX2 or DC2 or DD2 or DE2) ? 'β–Ό ' : na glyph4 = TF4Check ? na : (U3 or UX3 or UVX3 or UC3 or UD3 or UE3) ? 'β–² ': (D3 or DX3 or DVX3 or DC3 or DD3 or DE3) ? 'β–Ό ' : na f_fillCell(_column, _row, _cellText, _c_color) => table.cell(trendTable, _column, _row, _cellText, bgcolor=color.new(_c_color, 70), text_color=_c_color, width=3) if barstate.islast and show_table4 f_fillCell(0, 0, glyph1 + oneSet, TF1Check ? tfColor : (U0 or UX0 or UVX0 or UC0 or UD0 or UE0 ) ? upColor : downColor) f_fillCell(1, 0, glyph2 + twoSet, TF2Check ? tfColor : (U1 or UX1 or UVX1 or UC1 or UD1 or UE1) ? upColor : downColor) f_fillCell(2, 0, glyph3 + threeSet, TF3Check ? tfColor : (U2 or UX2 or UVX2 or UC2 or UD2 or UE2) ? upColor : downColor) f_fillCell(3, 0, glyph4 + fourSet, TF4Check ? tfColor : (U3 or UX3 or UVX3 or UC3 or UD3 or UE3) ? upColor : downColor) U = (high >= high[1]) and (low >= low[1]) and close>high[1] D = (high <= high[1]) and (low <= low[1]) and close<low[1] UX = U[1] and not D DX = D[1] and not U UVX = (U[1] or UX[1]) and not U and not D DVX = (D[1] or DX[1]) and not U and not D OC = (high>high[1]) and (low<low[1]) UC= (U[1] or UX[1] or UVX[1] ) and close>low[1] and close>close[1] and not (D[1] or DX[1] or DVX[1] or OC[1]) DC= (D[1] or DX[1] or DVX[1] ) and close<high[1] and close<close[1] and not (U[1] or UX[1] or UVX[1] or OC[1]) UD = UC[1] and not D DD = DC[1] and not U UE = close>low[1] and not (U or UX or UVX or UC or UD or D or DX or DVX or DC or DD) and ((U[1] or UX[1] or UVX[1] or UC[1] or UD[1])) DE = close<high[1] and not (U or UX or UVX or UC or UD or D or DX or DVX or DC or DD or UE) uptrend = (U or UX or UVX or UC or UD or UE) downtrend = (D or DX or DVX or DC or DD or DE) plotshape(UE, title='Uptrend', text='U', textcolor=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny) plotshape(DE, title='Downtrend', text='D', textcolor=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(UD, title='Uptrend', text='U', textcolor=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny) plotshape(DD, title='Downtrend', text='D', textcolor=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(U, title='Uptrend', text='U', textcolor=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny) plotshape(D, title='Downtrend', text='D', textcolor=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(UC, title='Uptrend', text='U', textcolor=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny) plotshape(DC, title='Downtrend', text='D', textcolor=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(UX, title='Uptrend', text='U', textcolor=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny) plotshape(DX, title='Downtrend', text='D', textcolor=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(UVX, title='Uptrend', text='U' , textcolor=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny) plotshape(DVX, title='Downtrend', text='D' , textcolor=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(OC, title='Outside Candle', text='OC' , textcolor=color.new(color.orange, 0), style=shape.diamond, location=location.abovebar, color=color.new(color.orange, 0), size=size.tiny) length = input.int(3, title="Trailing SL", minval=2) lower = ta.lowest(length) -ta.atr(length)/5 upper = ta.highest(length) +ta.atr(length)/5 u = plot(downtrend ? upper : na, "Short SL", color=color.red, style = plot.style_linebr ) l = plot(uptrend ? lower :na , "Long SL", color=color.green, style = plot.style_linebr )
Percent Research
https://www.tradingview.com/script/R3j5Z3tA-Percent-Research/
shaaah10
https://www.tradingview.com/u/shaaah10/
99
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© shaaah10 //@version=5 indicator("Percent Research", overlay = false) inputPrice = input.float(defval = 5, minval = 0, title = "Price") inputUp = input.float(defval = 20, minval = 0, title="Change % Up") inputDown = input.float(defval = -20, maxval = 0, title = "Change % Down") inputInterval = input(defval = 5, title = "Change Interval") valueCalc = close/close[inputInterval] valueVolume = input.float(defval = 100000, title = "Volume") intervalVolume = input(defval = 3, title = "Volume Interval") minVolume = ta.lowest(volume, intervalVolume) valColor = if ((valueCalc >= (inputUp/100)+1) and (minVolume >= valueVolume) and (close >= inputPrice)) color.green else if ((valueCalc <= (inputDown/100)+1) and (minVolume >= valueVolume) and (close >= inputPrice)) color.red else na plot(series=1, style=plot.style_area, color=valColor)
Session High and Low Indicator
https://www.tradingview.com/script/42RkeEA5-Session-High-and-Low-Indicator/
benjaminbarch
https://www.tradingview.com/u/benjaminbarch/
129
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© benjaminbarch //@version=5 indicator("Session High and Low Indicator", shorttitle="H/L", overlay=true) // --- WHAT THIS INDICATOR DOES - DESCRIPTION --- { // Looks at the ATR for the last 2 candles and compares it with the ATR for the last 14 // If the ATR(2) / ATR(14) is under our threshold, then calculate H/L // Plots a Green line for the Pre-Market High // Plots a Red line for the Pre-Market Low // Quick spikes are ignored in the PM High/Low Calculation // AlertConditions for when the Price Close breaks above or below the pre-market channel // -- END DESCRIPTION } // --- INPUTS --- { //Let user adjust how tight to peaks and valleys to mark pre-market high and low thresholdAtrPercent = input.float(title="ATR threshold %", defval=300, step=10, minval=1, maxval=10000, tooltip="Compares ATR(2) with ATR(14), Threshold must be under this number. The larger the number, the tighter to price action the PM Lines stick to. A lower number in this setting will allow quick price ation to blow over") PreMarketSession = input.session(title="Premarket Time", defval="0400-0930") // --- END INPUTS } // --- VARIABLES AND DECLARATIONS --- { //establish new function to simplify things isInSession(_sess) => not na(time(timeframe.period, _sess)) //Set variables var float PMcalculatedHigh = na // The ending results of the calculated session. only plotted outside of calculated session. In other words this is the variable to ise for alerting during regular trading hour alerts only var float PMcalculatedLow = na atr2 = ta.atr(2) atr14 = ta.atr(14) BullFlag = false BearFlag = false CurrentAtrPercent = 0.0 // --- END VARIABLES } // --- GET PRE-MARKET H/L --- { CurrentAtrPercent := (atr2 / atr14) * 100 if isInSession(PreMarketSession) and (not isInSession(PreMarketSession)[1]) // If this is the first bar of pre-market PMcalculatedHigh := na //reset variables PMcalculatedLow := na if isInSession(PreMarketSession) if (na(PMcalculatedHigh) and CurrentAtrPercent <= thresholdAtrPercent) or (CurrentAtrPercent <= thresholdAtrPercent and close > PMcalculatedHigh)//If we don't have a Calculated PM High yet or our current high is higher, update the calcuated highest PMcalculatedHigh := close > open ? close : open //store the higher of either the open or the close if (na(PMcalculatedLow) and CurrentAtrPercent <= thresholdAtrPercent) or (CurrentAtrPercent <= thresholdAtrPercent and close < PMcalculatedLow) PMcalculatedLow := close < open ? close : open else // We are not In PM Session, so check if we have broken the channel BullFlag := (close > PMcalculatedHigh) ? true : false BearFlag := (close < PMcalculatedLow) ? true : false // --- END GET PRE-MARKET H/L} // --- PLOTS AND ALERTS --- { //plot the calculated Pre-Market High/Low Lines plot(PMcalculatedHigh, title="Calculated PM High Line", color=color.new(color.green, 50), style=plot.style_linebr) plot(PMcalculatedLow, title="Calculated PM Low Line", color=color.new(color.red, 50), style=plot.style_linebr) // Alerts for Breaking out of channel alertcondition(BullFlag, title="Bull Signal", message="Price breaking above pre-market channel") alertcondition(BearFlag, title="Bear Signal", message="Price breaking below pre-market channel") // --- END PLOTS }
Gedhusek UltraTrend
https://www.tradingview.com/script/hpf1d8ce-Gedhusek-UltraTrend/
Gedhusek
https://www.tradingview.com/u/Gedhusek/
86
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© gedhusek1 //@version=5 indicator("Gedhusek UltraTrend",overlay = true) firstPeriod = input.int(125,"First Period") secondPeriod = input.int(225,"Second Period") thirdPeriod = input.int(325,"Third Period") AtrPeriod = input.int(6,"ATR Period") float firstMa = ta.sma(open,firstPeriod) float secondMa = ta.sma(open,secondPeriod) float thirdMa = ta.sma(open,thirdPeriod) float AtrValue = ta.atr(AtrPeriod) GreenShade(value) => value >= 15 ? #00b300: value >12 ? #00cc00 :value > 10 ? #00e600: value >8 ? #00ff00 :value > 6? #1aff1a: value > 4 ? #33ff33 :#4dff4d RedShade(value) => value >= 15 ? #b30000 : value > 12 ? #cc0000 : value > 10 ? #e60000 : value > 8 ? color.rgb(221, 59, 59) : value > 6? #ff1a1a : value > 4 ? #ff3333 :#ff3333 TrendFunction(int period, float value, float atr) => float multiplier = 0.5 float shiftValue = value[period] float strength = 0 string returnTrend = "None" float difference = value-shiftValue strength := math.abs(difference)/atr if(difference>atr*multiplier) returnTrend := "BULL" else if(difference<(atr*-1)*multiplier) returnTrend :="BEAR" [returnTrend,strength] plottingLine = secondMa string currentTrend = "None" color plotColor = color.gray [firstTrend,firstStr] = TrendFunction(firstPeriod,firstMa,AtrValue) [secondTrend,secondStr] = TrendFunction(secondPeriod,secondMa,AtrValue) [thirdTrend,thirdStr] = TrendFunction(thirdPeriod,thirdMa,AtrValue) float sumofStrength = (firstStr+secondStr+thirdStr)/3 if(firstTrend == "BEAR" and secondTrend=="BEAR" and thirdTrend=="BEAR" and high<secondMa) currentTrend := "BEAR" else if(firstTrend == "BULL" and secondTrend=="BULL" and thirdTrend=="BULL" and low>secondMa) currentTrend := "BULL" if(currentTrend=="BULL") plotColor := GreenShade(sumofStrength) if(currentTrend=="BEAR") plotColor := RedShade(sumofStrength) plotcandle(open,high,low,close,color = plotColor,wickcolor = plotColor,bordercolor=plotColor) plot(plottingLine,"Trend Line",color = plotColor,linewidth = 3)
Simple OHLC Custom Range Interactive
https://www.tradingview.com/script/DKKO1VnS-Simple-OHLC-Custom-Range-Interactive/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
121
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© RozaniGhani-RG //@version=5 indicator('Simple OHLC Custom Range Interactive', 'SO_CRI',true) // 0. Imports // 1. Inputs // 2. Variables / Array Initializations // 3. Custom Functions // 4. Variables / Array Setups // 5. Constructs // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” 0. Imports { import RozaniGhani-RG/PriceTimeInteractive/2 as pti import RozaniGhani-RG/DeleteArrayObject/1 as obj import RozaniGhani-RG/HarmonicSwitches/1 as sw // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” 1. Inputs { int i_ts = timestamp( '2022-12') int i_t = input.time( i_ts, 'Point', confirm = true) i_s_price = input.string('Simple', 'Price Name', options = ['Simple', 'Full']) i_extend = input.string( 'None', 'Extend lines', options = [ 'Right', 'Left', 'Both', 'None']) G1 = 'HELPER' T1 = '1) Tick to show table\n2) Small font size recommended for mobile app or multiple layout' T2 = 'Table must be tick before change table position' i_b_price = input.bool( false, 'Show Price on axis', group = G1) i_b_table = input.bool( true, 'Show Table |', group = G1, inline = 'Table1') i_s_font = input.string('normal', 'Font size', group = G1, inline = 'Table1', options = ['tiny', 'small', 'normal', 'large', 'huge'], tooltip = T1) i_s_Y = input.string('bottom', 'Table Position', group = G1, inline = 'Table2', options = [ 'top', 'middle', 'bottom']) i_s_X = input.string( 'left', '', group = G1, inline = 'Table2', options = ['left', 'center', 'right'], tooltip = T2) // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” 2. Variables / Array Initializations { [O, H, L, C] = pti.ohlc_time(i_t) float_OHLC = array.from(O, H, L, C) var line_OHLC = array.new_line(4), obj.delete(line_OHLC) var fill_OHLC = array.new_linefill(4), obj.delete(fill_OHLC) bool_price = array.new_bool(3) col_price = array.from(color.teal, color.red, color.blue) var color col = na var string str = na var label label_OHLC = na, label.delete(label_OHLC) var linefill fill = na, linefill.delete(fill) var TBL = table.new(i_s_Y + '_' + i_s_X, 5, 4, border_width = 1) [str_O, str_H, str_L, str_C] = switch i_s_price // [ str_O, str_H, str_L, str_C] 'Simple' => [ 'O', 'H', 'L', 'C'] 'Full' => ['OPEN', 'HIGH', 'LOW', 'CLOSE'] extend = switch i_extend 'Right' => extend.right 'Left' => extend.left 'Both' => extend.both 'None' => extend.none // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” 3. Custom Functions { 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) f_row(int _row, string _str, float _float, color _col) => table.cell(TBL, 3, _row, _str, text_size = i_s_font, bgcolor = _col) table.cell(TBL, 4, _row, str.tostring(_float, '#.000'), text_size = i_s_font, bgcolor = _col) // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” 4. Variables / Array Setups { array.set(bool_price, 0 , C > O) array.set(bool_price, 1 , C < O) array.set(bool_price, 2 , C == O) if array.includes(bool_price, true) col := array.get( col_price, array.indexof(bool_price, array.includes(bool_price, true))) array.set(line_OHLC, 0, line.new(i_t, array.get(float_OHLC, 0), int(i_t + f_resInMinutes() * 60 * 1000 * 14), array.get(float_OHLC, 0), xloc.bar_time, extend, col, line.style_dotted)) array.set(line_OHLC, 1, line.new(i_t, array.get(float_OHLC, 1), int(i_t + f_resInMinutes() * 60 * 1000 * 14), array.get(float_OHLC, 1), xloc.bar_time, extend, color.new(col, 100), line.style_dotted)) array.set(line_OHLC, 2, line.new(i_t, array.get(float_OHLC, 2), int(i_t + f_resInMinutes() * 60 * 1000 * 14), array.get(float_OHLC, 2), xloc.bar_time, extend, color.new(col, 100), line.style_dotted)) array.set(line_OHLC, 3, line.new(i_t, array.get(float_OHLC, 3), int(i_t + f_resInMinutes() * 60 * 1000 * 14), array.get(float_OHLC, 3), xloc.bar_time, extend, col, line.style_dotted)) str := 'O : ' + str.tostring(O, '#.000') + '\nH : ' + str.tostring(H, '#.000') + '\nL : ' + str.tostring(L, '#.000') + '\nC : ' + str.tostring(C, '#.000') fill := linefill.new(array.get(line_OHLC, 1), array.get(line_OHLC, 2), color.new(col, 80)) label_OHLC := label.new(i_t, L - (ta.atr(30) * 0.6), '', xloc = xloc.bar_time, color = col, style = label.style_label_up, tooltip = str) // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” 5. Constructs { if barstate.islast and i_b_table // Candle Construct table.cell( TBL, 0, 0, '|', text_size = i_s_font, bgcolor = color.new(color.blue, 100), text_color = col) table.cell( TBL, 0, 1, '|', text_size = i_s_font, bgcolor = color.new(color.blue, 100), text_color = color.new(color.blue, 100)) table.cell( TBL, 0, 3, '|', text_size = i_s_font, bgcolor = color.new(color.blue, 100), text_color = col) table.cell( TBL, 1, 1, ' ', text_size = i_s_font, bgcolor = col) table.cell( TBL, 2, 1, '|', text_size = i_s_font, bgcolor = color.new(color.blue, 100), text_color = color.new(color.blue, 100)) table.merge_cells(TBL, 0, 0, 2, 0) table.merge_cells(TBL, 0, 1, 0, 2) table.merge_cells(TBL, 0, 3, 2, 3) table.merge_cells(TBL, 1, 1, 1, 2) table.merge_cells(TBL, 2, 1, 2, 2) // Candle values f_row(0, str_H, H, col) f_row(3, str_L, L, col) if C > O f_row(1, str_C, C, col) f_row(2, str_O, O, col) else f_row(1, str_O, O, col) f_row(2, str_C, C, col) // Show Price on axis plot(time == i_t and i_b_price ? O : na, 'O', col) plot(time == i_t and i_b_price ? H : na, 'H', col) plot(time == i_t and i_b_price ? L : na, 'L', col) plot(time == i_t and i_b_price ? C : na, 'C', col) // }
Visible Range
https://www.tradingview.com/script/vbXLRm4n-Visible-Range/
kaigouthro
https://www.tradingview.com/u/kaigouthro/
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/ // Β© kaigouthro import kaigouthro/hsvColor/11 as h import kaigouthro/calc/5 import kaigouthro/font/4 //@version=5 indicator("Visible Range",'Range View',true) //input distances var int _d1 = input.int(5, 'Bar Distance for Viewing ', 5,50,5) var int _d2 = input.int(20, 'Second Bar Distance Mult.', 20,50,1) * _d1 // set line var line _highvisible = na var line _current = na var line _lowvisible = na var line _rangeline = na var line _highdist = na var line _lowdist = na var line _midpoint = na var label _rangeline_lb = na var label _highdist_lb = na var label _lowdist_lb = na var linefill _midfill = na // create lines to fill if barstate.isfirst _highvisible := line.new (chart.left_visible_bar_time,close,chart.right_visible_bar_time,close, xloc.bar_time ,extend.left, #88888888,line.style_dotted,1) _lowvisible := line.new (chart.left_visible_bar_time,close,chart.right_visible_bar_time,close, xloc.bar_time ,extend.left, #88888888,line.style_dotted,1) _current := line.new (last_bar_index[10],close,last_bar_index,close , xloc.bar_index ,extend.right, #88888888,line.style_dotted,1) _midpoint := line.new (last_bar_index[10],close,last_bar_index,close , xloc.bar_index ,extend.none, #88888888,line.style_dotted,1) _rangeline := line.new (last_bar_index[10],close,last_bar_index,close ) _highdist := line.new (last_bar_index[10],close,last_bar_index,close ) _lowdist := line.new (last_bar_index[10],close,last_bar_index,close ) _rangeline_lb := label.new (last_bar_index ,close, '',size = size.normal ) _highdist_lb := label.new (last_bar_index ,close, '',size = size.small ) _lowdist_lb := label.new (last_bar_index ,close, '',size = size.small ) _midfill := linefill.new(_current,_midpoint,#00000000) // force update value each calc var _newalc = -1 _newalc *= -1 //get and set values if ta.change(_newalc) and (time > chart.left_visible_bar_time) varip _highest = close varip _lowest = close _lefttime = chart.left_visible_bar_time _righttime = chart.right_visible_bar_time _close = close _highest := time >= _lefttime ? math.max(_highest , high ) : close _lowest := time >= _lefttime ? math.min(_lowest , low ) : close _avg = math.avg ( _highest , _lowest ) line.set_xy2 ( _current , last_bar_index - _d1 , _close ) line.set_xy1 ( _current , last_bar_index - _d2 , _close ) line.set_xy2 ( _midpoint , last_bar_index - _d1 , _avg ) line.set_xy1 ( _midpoint , last_bar_index - _d2 , _avg ) line.set_xy1 ( _highvisible , _lefttime , _highest ) line.set_xy2 ( _highvisible , _righttime , _highest ) line.set_xy1 ( _lowvisible , _lefttime , _lowest ) line.set_xy2 ( _lowvisible , _righttime , _lowest ) line.set_xy1 ( _rangeline , last_bar_index - _d2 , _highest ) line.set_xy2 ( _rangeline , last_bar_index - _d2 , _lowest ) line.set_xy1 ( _highdist , last_bar_index - _d1 , _close ) line.set_xy2 ( _highdist , last_bar_index - _d1 , _highest ) line.set_xy1 ( _lowdist , last_bar_index - _d1 , _close ) line.set_xy2 ( _lowdist , last_bar_index - _d1 , _lowest ) label.set_xy ( _lowdist_lb , last_bar_index - _d1 , math.avg(_close, _lowest )) _range = (_highest / _lowest - 1 ) _lowdif = (_close / _lowest - 1 ) _highdif = (_close / _highest - 1 ) _colrangeline = h.hsv(calc.percentOfDistance(_close - _avg , _lowest - _avg , _highest - _avg ) * 120 , .8,1,1) _collowdist = h.hsv(calc.percentOfDistance(_close , _lowest , _highest ) * 120 , .8,1,1) _colhighdist = h.hsv(calc.percentOfDistance(_close , _highest , _lowest ) * 120 , .8,1,1) linefill.set_color( _midfill, color.new(_avg > _close ? _colhighdist : _collowdist,90)) label.set_text ( _lowdist_lb , font.uni(str.format('{0,number,#.##} % ', 100 * (_close / _lowest - 1 ) ), 15)) label.set_color ( _lowdist_lb , _collowdist ) line.set_color ( _lowdist , _collowdist ) label.set_xy ( _rangeline_lb , last_bar_index - _d2 , math.avg(_highest, _lowest )) label.set_text ( _rangeline_lb , font.uni(str.format('{0,number,#.##} % from avg \n {1,number,#.##} % Range', 100 * (_close / _avg - 1 ), 100 * (_highest / _lowest - 1 ) ), 15)) label.set_color ( _rangeline_lb , _colrangeline ) line.set_color ( _rangeline , _colrangeline ) label.set_xy ( _highdist_lb , last_bar_index - _d1 , math.avg(_close, _highest )) label.set_text ( _highdist_lb , font.uni(str.format('{0,number,#.##} %', 100 * (_close / _highest - 1 ) ), 15)) label.set_color ( _highdist_lb , _colhighdist ) line.set_color ( _highdist , _colhighdist )
Buy and Sell Indicator
https://www.tradingview.com/script/zdwzwVky-Buy-and-Sell-Indicator/
Shauryam_or
https://www.tradingview.com/u/Shauryam_or/
511
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Shauryam_or //@version=05 indicator(title="High and low" ,overlay=true) h = input.int(09 , "Hour" , minval=0, maxval=23, inline='hm',group="Select Time for Signal") m = input.int(15, ": Min", minval=0, maxval=59, inline='hm',group="Select Time for Signal") //select Gmt time gmt=input.string("Asia/Kolkata",title="Gmt",options=["America/New_York","America/Los_Angeles","America/Chicago","America/Phoenix","America/Toronto" ,"America/Vancouver","America/Argentina/Buenos_Aires","America/El_Salvador","America/Sao_Paulo","America/Bogota" ,"Europe/Moscow" ,"Europe/Athens" ,"Europe/Berlin","Europe/London" ,"Europe/Madrid" ,"Europe/Paris" ,"Europe/Warsaw", "Australia/Sydney","Australia/Brisbane","Australia/Adelaide","Australia/ACT" ,"Asia/Almaty" ,"Asia/Ashkhabad" ,"Asia/Tokyo" ,"Asia/Taipei" ,"Asia/Singapore" ,"Asia/Shanghai" ,"Asia/Seoul" ,"Asia/Tehran" ,"Asia/Dubai" ,"Asia/Kolkata" ,"Asia/Hong_Kong" ,"Asia/Bangkok" ,"Pacific/Auckland","Pacific/Chatham","Pacific/Fakaofo" ,"Pacific/Honolulu" ],group="Select Time for Signal",inline="hm") select_gmt=gmt=="America/New_York"? "GMT-4:00":gmt=="America/Los_Angeles"? "GMT-7:00":gmt=="America/Chicago"? "GMT-5:00":gmt=="America/Phoenix"?"GMT-7:00": gmt=="America/Toronto"?"GMT-4:00":gmt=="America/Vancouver"?"GMT-7:00": gmt=="America/Argentina/Buenos_Aires"?"GMT-3:00": gmt=="America/El_Salvador" ?"GMT-6:00": gmt=="America/Sao_Paulo"?"GMT-3:00": gmt=="America/Bogota"?"GMT-5:00":gmt=="Europe/Moscow"?"GMT+3:00": gmt=="Europe/Athens"?"GMT+3:00": gmt=="Europe/Berlin" ?"GMT+2:00": gmt=="Europe/London"?"GMT+1:00": gmt=="Europe/Madrid"?"GMT+2:00": gmt=="Europe/Paris"?"GMT+2:00":gmt=="Europe/Warsaw"?"GMT+2:00": gmt=="Australia/Sydney"?"GMT+11:00":gmt=="Australia/Brisbane"?"GMT+10:00":gmt=="Australia/Adelaide"?"GMT+10:30":gmt=="Australia/ACT"?"GMT+9:30": gmt=="Asia/Almaty"?"GMT+6:00":gmt=="Asia/Ashkhabad"?"GMT+5:00":gmt=="Asia/Tokyo"?"GMT+9:00":gmt=="Asia/Taipei"?"GMT+8:00":gmt=="Asia/Singapore"?"GMT+8:00": gmt=="Asia/Shanghai"?"GMT+8:00":gmt=="Asia/Seoul"?"GMT+9:00":gmt=="Asia/Tehran" ?"GMT+3:30":gmt=="Asia/Dubai" ?"GMT+4:00":gmt=="Asia/Kolkata"?"GMT+5:30": gmt=="Asia/Hong_Kong"?"GMT+8:00":gmt=="Asia/Bangkok"?"GMT+7:00":gmt=="Pacific/Auckland"?"GMT+13:00":gmt=="Pacific/Chatham"?"GMT+13:45":gmt=="Pacific/Fakaofo" ?"GMT+13:00": gmt=="Pacific/Honolulu"?"GMT-10:00": na // Highlights the first bar of the new day. isNewDay = timeframe.change("1D") bgcolor(isNewDay ? color.new(color.green, 80) : na) var s_high = 0.0 var s_low = 0.0 if (hour(time,select_gmt) ==h and minute(time,select_gmt) == m) s_high:=high s_low:=low plot(s_high,style = plot.style_cross,color=color.green) plot(s_low,style = plot.style_cross,color=color.red) long_entry=ta.crossover(close,s_high) short_entry=ta.crossunder(close,s_low) //// Β© fikira logic for buy if new trade is less thn previous trade and opposite for sell var float priceL = close var float priceS = close if long_entry if close < priceL priceL := close if short_entry if close > priceS priceS := close buy_cond = long_entry and close < priceL[1] sell_cond = short_entry and close > priceS[1] plotshape(buy_cond,title = "Buy Cond",style=shape.labelup,location=location.belowbar,color=color.green,textcolor = color.white,text="long") plotshape(sell_cond,title = "Sell Cond",style=shape.labeldown,location=location.abovebar,color=color.red,textcolor = color.white,text="short")
Darvas box
https://www.tradingview.com/script/EfgGtIXp-Darvas-box/
danilogalisteu
https://www.tradingview.com/u/danilogalisteu/
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/ // Β© danilogalisteu //@version=5 indicator("Darvas box", overlay=true) show_labels = input.bool(false, "Show labels for box top and bottom") // Reference: https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/C-D/DarvasBox // Logic changed to transition to state 5 after one higher low only box_state = 1 high_value = high low_value = ta.lowest(4) if box_state[1] == 1 and high < high_value[1] box_state := 2 high_value := high_value[1] if box_state[1] == 2 and high < high_value[1] box_state := 3 high_value := high_value[1] if box_state[1] == 3 and high < high_value[1] if low > low_value[1] box_state := 5 low_value := low_value[1] else box_state := 4 high_value := high_value[1] if box_state[1] == 4 and high < high_value[1] if low > low_value[1] box_state := 5 low_value := low_value[1] else box_state := 4 high_value := high_value[1] if box_state[1] == 5 and high <= high_value[1] and low >= low_value[1] box_state := 5 high_value := high_value[1] low_value := low_value[1] draw_box(left, top, right, bottom, color) => box = box.new(left, top, right, bottom) box.set_border_color(box, color) box.set_bgcolor(box, color.rgb(color.r(color), color.g(color), color.b(color), 95)) box // draw and redraw box state_active = 5 box_active = box_state == state_active box_start = ta.barssince(box_state == 1) b = box(na) l_up = label(na) l_dn = label(na) end_box = false end_box_dir = 0 box_color = color.yellow if box_active if box_active[1] box.delete(b[1]) if show_labels label.delete(l_up[1]) label.delete(l_dn[1]) b := draw_box(bar_index-box_start, high_value, bar_index, low_value, box_color) if show_labels l_up := label.new(bar_index-2, high_value[1], str.tostring(high_value[1]), yloc=yloc.price, color=color.green, style=label.style_label_down) l_dn := label.new(bar_index-2, low_value[1], str.tostring(low_value[1]), yloc=yloc.price, color=color.red, style=label.style_label_up) else if box_active[1] end_box := true end_box_dir := high > box.get_top(b[1]) ? 1 : low < box.get_bottom(b[1]) ? -1 : 0 box_color := end_box_dir == 1 ? color.green : end_box_dir == -1 ? color.red : color.yellow box.set_border_color(b[1], box_color) box.set_bgcolor(b[1], color.rgb(color.r(box_color), color.g(box_color), color.b(box_color), 95)) box_break_up = end_box_dir == 1 box_break_dn = end_box_dir == -1 // show values as soon as box is active plot(box_active ? high_value : na, "Box top", style=plot.style_linebr, color=color.green, display=display.all-display.pane) plot(box_active ? low_value : na, "Box bottom", style=plot.style_linebr, color=color.red, display=display.all-display.pane) // show arrows for breakout / breakdown plotshape(box_break_up ? high_value[1]+0.1*(high_value-low_value)[1] : na, style=shape.arrowup, color=color.green, offset=-1, location=location.absolute, display=display.pane) plotshape(box_break_dn ? low_value[1]-0.1*(high_value-low_value)[1] : na, style=shape.arrowdown, color=color.red, offset=-1, location=location.absolute, display=display.pane) // alerts alertcondition(end_box, title='DB break', message='Darvas box break!') alertcondition(box_break_up, title='DB breakout', message='Darvas box breakout!') alertcondition(box_break_dn, title='DB breakdown', message='Darvas box breakdown!')
Pivot Pattern Boundaries [cajole]
https://www.tradingview.com/script/hsEFLsr7-Pivot-Pattern-Boundaries-cajole/
cajole
https://www.tradingview.com/u/cajole/
158
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© cajole //@version=5 // hat tip to 'Liquidity by makuchaku & eFe', daughter of 'Pivots MTF [LucF]' for the basic architecture. indicator("Pivot Pattern Boundaries [cajole]", shorttitle='Pivot boundaries', overlay = true, max_lines_count=500) i_prd = input.int(3, minval=1, title="Pivot Period", inline='pvt') i_ATRtol = input.float(0.125, minval=0, maxval=1, inline='pvt', title="Tolerance [ATR]", tooltip="Fraction of ATR used to define when 2 prices are equal. ATR calculated over 'expiry' window.") i_labelPvts= input.bool(false, title="Label every pivot", group='Plot', inline='pvt') i_levelPersist= input.bool(false, title="Let levels persist after crossing", group='Plot', inline='pvt') i_showLines= input.bool(defval=true, title='Show lines:', group='Plot', inline='col') i_pvtTopColor = input.color(defval=color.new(color.fuchsia, 30), title='Resistance', group='Plot', inline='col') i_pvtBtmColor = input.color(defval=color.new(color.fuchsia, 30), title='Support', group='Plot', inline='col') i_showTol = input.bool(defval=true, title='Shade tolerance', group='Plot', inline='col') i_minTouches = input.int(defval=2, title='Min. touches', group='Plot', inline='tch') i_minLength = input.int(defval=25, title='Min. length', tooltip='Lines shorter than this will be hidden.', group='Plot', inline='tch') i_expiry = input.int(defval=200, title='Level expiry', tooltip='Max. no. of bars to search for min. touches before giving up', group='Plot', inline='tch') i_pvtStyle = input.string(defval=line.style_solid, title='Line style', group='Plot', inline='lines', options=[line.style_solid, line.style_dotted, line.style_dashed, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both]) i_pvtLThick = input.int(defval=2, title='Pivot line thickness', group='Plot', inline='lines') i_maxHiLines = input.int(defval=50, title='Max. resistance lines', minval=1, maxval=500, group='Plot') i_maxLoLines = input.int(defval=50, title='Max. support lines', minval=1, maxval=500, group='Plot') // Transform inputs //tol = i_tolPct/100 * ta.median(close, 200) // Resolution below which 2 prices / pivots considered the same. //tol = i_tolPct/100 * (ta.highest(high, 50) - ta.lowest(low, 50)) // Resolution below which 2 prices / pivots considered the same. tol = i_ATRtol * ta.atr(i_expiry) // Resolution below which 2 prices / pivots considered the same. // FUNCTIONS _levelCurrentlyActive(_level, _linesD, _linesU, _touchesX) => // Check all lines in array _lines for y1 == y2 == _level. _levelFound = 0 if array.size(_linesU) > 0 for i = 0 to array.size(_linesU)-1 by 1 _touchX = array.get(_touchesX, i) _lineD = array.get(_linesD, i) _lineU = array.get(_linesU, i) _levelD = line.get_y1(_lineD) _levelU = line.get_y1(_lineU) if (bar_index - _touchX) < i_expiry _lvl = (_levelD + _levelU) / 2 _tol = tol*2 if (math.abs(_level - _lvl) <= _tol or math.abs(_level - _lvl) <= _tol) _levelFound := 1 break _levelFound // Given a _touches array identifying # touches of each line // a _linesUP array identifying UPPER BOUND price pivots, // a _linesDN array identifying LOWER BOUND price pivots, // a _touchesY array identifying bar_index of each last touch // a _touchesY array identifying level of each line (midpt of _lines._level, for convenience and labelling)', // update the _lines array for the current bar. // OR // delete the line if it has persisted with only 1 touch for too long (defined by i_expiry). _controlLine(_linesU, _linesD, _touches, _touchesX, _touchesY, _colour, tol, highOrLow) => isPH = highOrLow > 0 // boundaries get treated differently below isPL = highOrLow < 0 // boundaries get treated differently beloww if array.size(_linesU) > 0 for i = array.size(_linesU)-1 to 0 by 1 _lineU = array.get(_linesU, i) _lineD = array.get(_linesD, i) _NtouchPrevX = array.get(_touchesX, i) _NtouchPrev = array.get(_touches , i) _levelU = line.get_y1(_lineU) _levelD = line.get_y1(_lineD) _x1 = line.get_x1(_lineU) _x2 = line.get_x2(_lineU) // line update expired? if (bar_index - _NtouchPrevX) > i_expiry or barstate.islast // delete if no boundary developed if (_NtouchPrev < i_minTouches) or (_x2 - _x1) < i_minLength line.delete(_lineU) line.delete(_lineD) array.remove(_linesU, i) array.remove(_linesD, i) array.remove(_touches, i) array.remove(_touchesX, i) array.remove(_touchesY, i) // here is an opportunity to label Ntouches... else line.set_x2(_lineD, _NtouchPrevX) // pull bar back to the last touch line.set_x2(_lineU, _NtouchPrevX) // pull bar back to the last touch if i_labelPvts label.new(_x2, _levelD, str.tostring(_NtouchPrev), style=label.style_none, yloc=yloc.abovebar, size=size.small) continue // line already crossed? (if so, then prev. iteration of this code did not update _x2) _levelAlreadyCrossed = (bar_index > _x2) if _levelAlreadyCrossed // and (_x2 - _x1) > i_minLength) continue // HERE I COULD PROGRAM A 1.25H RULE / EXPLORE THE TRUE BREAKOUT LEVELS. // price crossed over high pivot? mul = 2 // 2 because the uncertainty applies both to the pivot and to the current bar _xOver = (low < (_levelD - tol*mul) and high > (_levelU + tol*mul) and high[1] < (_levelD - tol*mul)) or (high[1] < (_levelU + tol*mul) and low > (_levelU + tol*mul)) // price crossed under low pivot? _xUnder = (high > (_levelU + tol*mul) and low < (_levelD - tol*mul) and low[1] > (_levelU + tol*mul)) or (low[1] < (_levelD - tol*mul) and high > (_levelU + tol*mul)) // adjust active lines if i_levelPersist or not (_xOver or _xUnder) line.set_x2(_lineD, bar_index + 1) // stretch line over to the next bar line.set_x2(_lineU, bar_index + 1) // stretch line over to the next bar // future feature: move lines to average of pivots FIRST NEED TO SWITCH TO PIVOT BASED TRIGGER OF THE CODE // line.set_y1(_lineD, (_levelD + pvt) / 2) // needs to handle hi/lo // line.set_y2(_lineD, bar_index + 1) // line.set_y1(_lineU, // line.set_y2(_lineU, // line touched? _touched = (math.abs(high - _levelD) <= tol or math.abs(high - _levelU) <= tol) or (math.abs( low - _levelD) <= tol or math.abs( low - _levelU) <= tol) _Ntouch = _touched ? _NtouchPrev + 1 : _NtouchPrev if _touched and not (_xOver or _xUnder) array.set(_touchesX, i, bar_index) array.set(_touches , i, _NtouchPrev + 1) if i_showTol // visualize the tolerance of 'touches' linefill.new(_lineU, _lineD, _colour) 1 else // show only the inner line [THE LOGIC THAT WORKS HERE IS BACKWARDS? BUG?] line.set_color(_lineU, isPH ? _colour : color.new(color.white, 100)) line.set_color(_lineD, isPL ? _colour : color.new(color.white, 100)) 1 // PREP var line[] loLinesDN = array.new_line() // up and down lines, for linefill() var line[] loLinesUP = array.new_line() var line[] hiLinesDN = array.new_line() var line[] hiLinesUP = array.new_line() var int[] loTouches = array.new_int() // # of times price touched this level var int[] hiTouches = array.new_int() var float[] loTouchesY = array.new_float() // Y position of pivot touches var float[] hiTouchesY = array.new_float() var int[] loTouchesX = array.new_int() // bar_index of last touches var int[] hiTouchesX = array.new_int() // CALCULATIONS pl = ta.pivotlow( i_prd, i_prd) ph = ta.pivothigh(i_prd, i_prd) // define pivots as rounded to the nearest 'tol' and tick ph := math.round_to_mintick( math.ceil(ph / tol) * tol) pl := math.round_to_mintick(math.floor( pl / tol) * tol) plotshape(i_labelPvts ? pl : na, text="L", style=shape.labeldown, color=na, textcolor=color.new(i_pvtBtmColor,0), location=location.belowbar, offset = -i_prd) plotshape(i_labelPvts ? ph : na, text="H", style=shape.labeldown, color=na, textcolor=color.new(i_pvtTopColor,0), location=location.abovebar, offset = -i_prd) // Add pivot low to lines, if new if pl plu = pl + tol pld = pl - tol if not _levelCurrentlyActive(pl, loLinesDN, loLinesUP, loTouchesX) _loLineUP = line.new(x1=bar_index[i_prd], y1=plu, x2=bar_index, y2=plu, xloc=xloc.bar_index, color=i_pvtBtmColor, style=i_pvtStyle, width=i_pvtLThick) _loLineDN = line.new(x1=bar_index[i_prd], y1=pld, x2=bar_index, y2=pld, xloc=xloc.bar_index, color=i_pvtBtmColor, style=i_pvtStyle, width=i_pvtLThick) if array.size(loLinesUP) >= i_maxLoLines line.delete(array.shift(loLinesDN)) line.delete(array.shift(loLinesUP)) array.shift(loTouches) array.shift(loTouchesX) array.shift(loTouchesY) array.push(loLinesDN, _loLineUP) array.push(loLinesUP, _loLineDN) array.push(loTouches, 1) array.push(loTouchesY, pl) array.push(loTouchesX, bar_index) // Add pivot high to lines, if new if ph phu = ph + tol phd = ph - tol if not _levelCurrentlyActive(ph, hiLinesDN, hiLinesUP, hiTouchesX) _hiLineUP = line.new(x1=bar_index[i_prd], y1=phu, x2=bar_index, y2=phu, xloc=xloc.bar_index, color=i_pvtTopColor, style=i_pvtStyle, width=i_pvtLThick) _hiLineDN = line.new(x1=bar_index[i_prd], y1=phd, x2=bar_index, y2=phd, xloc=xloc.bar_index, color=i_pvtTopColor, style=i_pvtStyle, width=i_pvtLThick) if array.size(hiLinesUP) >= i_maxHiLines line.delete(array.shift(hiLinesUP)) line.delete(array.shift(hiLinesDN)) array.shift(hiTouches) array.shift(hiTouchesX) array.shift(hiTouchesY) array.push(hiLinesUP, _hiLineUP) array.push(hiLinesDN, _hiLineDN) array.push(hiTouches, 1) array.push(hiTouchesY, ph) array.push(hiTouchesX, bar_index) _controlLine(loLinesUP, loLinesDN, loTouches, loTouchesX, loTouchesY, i_pvtBtmColor, tol, -1) _controlLine(hiLinesUP, hiLinesDN, hiTouches, hiTouchesX, hiTouchesY, i_pvtTopColor, tol, 1) if barstate.islast 1 // combine neighbouring lines? // remove very short pivots inside longer ones // todo -- add a summary of the bars if 0 var table t = table.new(position.top_right, 1, 5, frame_color=color.black) table.cell(t, 0, 0, " ", bgcolor = color.new(color.white, 70), text_color=color.red, text_halign = text.align_right, text_size=size.small) table.cell(t, 0, 1, array.join(hiTouchesY, ", "), bgcolor = color.new(color.white, 70), text_color=color.new(i_pvtTopColor, 0), text_halign = text.align_right, text_size=size.small) table.cell(t, 0, 2, array.join(hiTouches, ', '), bgcolor = color.new(color.white, 70), text_color=color.new(i_pvtTopColor, 0), text_halign = text.align_right, text_size=size.small) table.cell(t, 0, 3, array.join(loTouchesY, ", "), bgcolor = color.new(color.white, 70), text_color=color.new(i_pvtBtmColor, 0), text_halign = text.align_right, text_size=size.small) table.cell(t, 0, 4, array.join(loTouches, ', '), bgcolor = color.new(color.white, 70), text_color=color.new(i_pvtBtmColor, 0), text_halign = text.align_right, text_size=size.small)
Order Block Detector [LuxAlgo]
https://www.tradingview.com/script/KvGhxGxY-Order-Block-Detector-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
8,684
study
5
CC-BY-NC-SA-4.0
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // Β© LuxAlgo //@version=5 indicator("Order Block Detector [LuxAlgo]" , overlay = true , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ length = input.int(5, 'Volume Pivot Length' , minval = 1) bull_ext_last = input.int(3, 'Bullish OB ' , minval = 1 , inline = 'bull') bg_bull_css = input.color(color.new(#169400, 80), '' , inline = 'bull') bull_css = input.color(#169400, '' , inline = 'bull') bull_avg_css = input.color(color.new(#9598a1, 37), '' , inline = 'bull') bear_ext_last = input.int(3, 'Bearish OB' , minval = 1 , inline = 'bear') bg_bear_css = input.color(color.new(#ff1100, 80), '' , inline = 'bear') bear_css = input.color(#ff1100, '' , inline = 'bear') bear_avg_css = input.color(color.new(#9598a1, 37), '' , inline = 'bear') line_style = input.string('⎯⎯⎯', 'Average Line Style' , options = ['⎯⎯⎯', '----', 'Β·Β·Β·Β·']) line_width = input.int(1, 'Average Line Width' , minval = 1) mitigation = input.string('Wick', 'Mitigation Methods' , options = ['Wick', 'Close']) //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ //Line Style function get_line_style(style) => out = switch style '⎯⎯⎯' => line.style_solid '----' => line.style_dashed 'Β·Β·Β·Β·' => line.style_dotted //Function to get order block coordinates get_coordinates(condition, top, btm, ob_val)=> var ob_top = array.new_float(0) var ob_btm = array.new_float(0) var ob_avg = array.new_float(0) var ob_left = array.new_int(0) float ob = na //Append coordinates to arrays if condition avg = math.avg(top, btm) array.unshift(ob_top, top) array.unshift(ob_btm, btm) array.unshift(ob_avg, avg) array.unshift(ob_left, time[length]) ob := ob_val [ob_top, ob_btm, ob_avg, ob_left, ob] //Function to remove mitigated order blocks from coordinate arrays remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=> mitigated = false target_array = bull ? ob_btm : ob_top for element in target_array idx = array.indexof(target_array, element) if (bull ? target < element : target > element) mitigated := true array.remove(ob_top, idx) array.remove(ob_btm, idx) array.remove(ob_avg, idx) array.remove(ob_left, idx) mitigated //Function to set order blocks set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=> var ob_box = array.new_box(0) var ob_lvl = array.new_line(0) //Fill arrays with boxes/lines if barstate.isfirst for i = 0 to ext_last-1 array.unshift(ob_box, box.new(na,na,na,na , xloc = xloc.bar_time , extend= extend.right , bgcolor = bg_css , border_color = color.new(border_css, 70))) array.unshift(ob_lvl, line.new(na,na,na,na , xloc = xloc.bar_time , extend = extend.right , color = lvl_css , style = get_line_style(line_style) , width = line_width)) //Set order blocks if barstate.islast if array.size(ob_top) > 0 for i = 0 to math.min(ext_last-1, array.size(ob_top)-1) get_box = array.get(ob_box, i) get_lvl = array.get(ob_lvl, i) box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i)) box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i)) line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i)) line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i)) //-----------------------------------------------------------------------------} //Global elements //-----------------------------------------------------------------------------{ var os = 0 var target_bull = 0. var target_bear = 0. n = bar_index upper = ta.highest(length) lower = ta.lowest(length) if mitigation == 'Close' target_bull := ta.lowest(close, length) target_bear := ta.highest(close, length) else target_bull := lower target_bear := upper os := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1] phv = ta.pivothigh(volume, length, length) //-----------------------------------------------------------------------------} //Get bullish/bearish order blocks coordinates //-----------------------------------------------------------------------------{ [bull_top , bull_btm , bull_avg , bull_left , bull_ob] = get_coordinates(phv and os == 1, hl2[length], low[length], low[length]) [bear_top , bear_btm , bear_avg , bear_left , bear_ob] = get_coordinates(phv and os == 0, high[length], hl2[length], high[length]) //-----------------------------------------------------------------------------} //Remove mitigated order blocks //-----------------------------------------------------------------------------{ mitigated_bull = remove_mitigated(bull_top , bull_btm , bull_left , bull_avg , target_bull , true) mitigated_bear = remove_mitigated(bear_top , bear_btm , bear_left , bear_avg , target_bear , false) //-----------------------------------------------------------------------------} //Display order blocks //-----------------------------------------------------------------------------{ //Set bullish order blocks set_order_blocks(bull_top , bull_btm , bull_left , bull_avg , bull_ext_last , bg_bull_css , bull_css , bull_avg_css) //Set bearish order blocks set_order_blocks(bear_top , bear_btm , bear_left , bear_avg , bear_ext_last , bg_bear_css , bear_css , bear_avg_css) //Show detected order blocks plot(bull_ob, 'Bull OB', bull_css, 2, plot.style_linebr , offset = -length , display = display.none) plot(bear_ob, 'Bear OB', bear_css, 2, plot.style_linebr , offset = -length , display = display.none) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ alertcondition(bull_ob, 'Bullish OB Formed', 'Bullish order block detected') alertcondition(bear_ob, 'Bearish OB Formed', 'bearish order block detected') alertcondition(mitigated_bull, 'Bullish OB Mitigated', 'Bullish order block mitigated') alertcondition(mitigated_bear, 'Bearish OB Mitigated', 'bearish order block mitigated') //-----------------------------------------------------------------------------}
Custom OBV Oscillator
https://www.tradingview.com/script/xEa7W9Cv-Custom-OBV-Oscillator/
jsalemfinancial
https://www.tradingview.com/u/jsalemfinancial/
51
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© jsalemfinancial //@version=5 indicator(title="Custom OBV Oscillator", shorttitle="OBVO", precision=2) lookback_len = input.int(defval=20, title="Lookback Period") fast_len = input.int(defval=3, title="Fast Period") obvo(src) => ta.cum(ta.change(src) > 0 ? volume : -volume) os = obvo(close) - obvo(close)[lookback_len] obv_osc = os + ta.ema(os, fast_len) obv_color = if obv_osc > 0 #b1d930 else #d12e41 hline(0, color= color.gray) plot(obv_osc, color= obv_color, style= plot.style_histogram, linewidth = 2, title="OBV") plot(ta.sma(obv_osc, 10), color= color.red) plot(ta.sma(obv_osc, 20), color= color.blue)
ICT NY Futures Indices Session Model - YT New York Mentorship
https://www.tradingview.com/script/oGxTJNqB-ICT-NY-Futures-Indices-Session-Model-YT-New-York-Mentorship/
Shanxia
https://www.tradingview.com/u/Shanxia/
373
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Shanxia //@version=5 indicator("ICT NY Model", "ICT NY", overlay=true, max_lines_count=500) ////////// INPUTS \\\\\\\\\\ i_d4 = input.string ("GMT-4", "Timezone", options=["GMT+0", "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-1", "GMT-2", "GMT-3","GMT-4","GMT-5","GMT-6","GMT-7","GMT-8","GMT-9","GMT-10","GMT-11","GMT-12"]) s1 = input.session ("0830-0931:1234567", "", inline="i1") s2 = input.session ("0930-1131:1234567", "", inline="i2") s3 = input.session ("1330-1501:1234567", "", inline="i3") s4 = input.session ("1500-1601:1234567", "", inline="i4") c1 = input.color (color.new(color.silver, 85), "", inline="i1") c2 = input.color (color.new(color.silver, 92), "", inline="i2") c3 = input.color (color.new(color.aqua, 92), "", inline="i3") c4 = input.color (color.new(color.aqua, 85), "", inline="i4") i_bool1 = input.bool (true, "NY 00.00am", group="Opens (Local Time)", inline="1") i_bool2 = input.bool (true, "NY 8.30am ", group="Opens (Local Time)", inline="2") i_bool3 = input.bool (true, "NY 9.30am ", group="Opens (Local Time)", inline="3") i_bool4 = input.bool (true, "London Open", group="Opens (Local Time)", inline="4") i_linecol1 = input.color (#d40c0c, "", group="Opens (Local Time)", inline="1") i_txtcol = input.color (#676767, "Text color", group="Opens (Local Time)", inline="1") i_linecol2 = input.color (#fbc02d, "", group="Opens (Local Time)", inline="2") i_llh = input.bool (true, "London H/L", group="Opens (Local Time)", inline="2") i_lonhl = input.color (#a2a2a2, "", group="Opens (Local Time)", inline="2") i_linecol3 = input.color (#00cd88, "", group="Opens (Local Time)", inline="3") i_linecol4 = input.color (#008fff, "", group="Opens (Local Time)", inline="4") lonr = input.session ("0300-0700:1234567", "London") i_linewidth = input.int (1, "Linewidth", 0, 5, inline="in0") i_vstyle = input.string ("Dashed", "Style", options=["Solid", "Dotted", "Dashed"], inline="in1") i_linestyle = input.string ("Solid", " ", options=["Solid", "Dotted", "Dashed"], inline="in1") i_dev = input.bool (false, 'Deviations', inline='x1') i_devno = input.int (2 , "", minval=1, inline='x1') ////////// VARIABLES \\\\\\\\\\ ny830 = time("1", s1, i_d4) ny930 = time("1", s2, i_d4) ny130 = time("1", s3, i_d4) ny300 = time("1", s4, i_d4) i_time = '0000-0001:1234567' i_time2 = '0830-0831:1234567' i_time3 = '0930-0931:1234567' i_time4 = '0800-0801:1234567' linestyle = i_linestyle == "Solid" ? line.style_solid : i_linestyle == "Dotted" ? line.style_dotted : line.style_dashed vstyle = i_vstyle == "Solid" ? line.style_solid : i_vstyle == "Dotted" ? line.style_dotted : line.style_dashed ////////// FUNCTION DECLARATIONS \\\\\\\\\\ in_session(sess) => not na(time(timeframe.period, sess, i_d4)) start_time(sess) => int startTime = na startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1] startTime is_new_session(res, sess) => t = time(res, sess, i_d4) na(t[1]) and not na(t) or t[1] < t _hline(StartTime, EndTime, Price, Color, Style, Width) => return_1 = line.new(StartTime, Price, EndTime, Price, xloc=xloc.bar_time, extend=extend.none, color=Color, style=Style, width=Width) f_vline(a, f, b, d, e, sess) => var line fl1 = na var line fl2 = na var linefill lf1 = na st_vl = timestamp(i_d4, year, month, sess, a, f, 00) en_vl = timestamp(i_d4, year, month, sess, b, e, 00) fl1 := line.new(st_vl, high, st_vl, low, xloc.bar_time, extend.both, color.new(color.white, 100), line.style_solid, 1) line.delete(fl1[1]) fl2 := line.new(en_vl, high, en_vl, low, xloc.bar_time, extend.both, color.new(color.white, 100), line.style_solid, 1) line.delete(fl2[1]) lf1 := linefill.new(fl1, fl2, d) linefill.delete(lf1[1]) for i = 0 to 100 if time > line.get_x1(fl2[i]) line.delete(fl2[i]) line.delete(fl1[i]) openline(sess, timezone, col, txt, st, boo) => _open = request.security(syminfo.tickerid, "1", open, barmerge.gaps_on, barmerge.lookahead_on) nymid= time("1", sess, timezone) var openprice = 0.0 var label lb = na var line lne = na if nymid if not nymid[1] openprice := _open else openprice := math.max(_open, openprice) if openprice != openprice[1] and boo if barstate.isconfirmed line.set_x2(lne, nymid) line.set_extend(lne, extend.none) lne := line.new(nymid, openprice, nymid + 86400000 , openprice, xloc.bar_time, extend.none, col, st, i_linewidth) lb := label.new(nymid + 86400000, openprice, txt, xloc.bar_time, yloc.price, na, label.style_none, i_txtcol) lrange(kz, bdcol, col1)=> sesh = is_new_session('1440', kz) float kzlow = na float kzhigh = na bline = line(na) bline2 = line(na) lab1 = label(na) lab2 = label(na) kzstart = start_time(kz) + 19800000 labst = start_time(kz) + 46800000 kzlow := sesh ? low : in_session(kz) ? math.min(low, kzlow[1]) : na kzhigh := sesh ? high : in_session(kz) ? math.max(high, kzhigh[1]) : na devdiff = kzhigh[1] - kzlow[1] if in_session(kz) if in_session(kz)[1] line.delete(bline[1]) line.delete(bline2[1]) if low < kzlow kzlow := low kzlow if high > kzhigh kzhigh := high kzhigh bline := line.new(kzstart, kzhigh, kzstart + 27000000, kzhigh, xloc.bar_time, extend.none, bdcol, line.style_solid, 4) bline bline2 := line.new(kzstart, kzlow, kzstart + 27000000, kzlow, xloc.bar_time, extend.none, bdcol, line.style_solid, 4) bline2 lab1 := label.new(labst, kzhigh, "L β€’ High", xloc.bar_time, yloc.price, color.new(#ffffff, 100), label.style_label_down, i_txtcol) label.delete(lab1[1]) lab2 := label.new(labst, kzlow, "L β€’ Low", xloc.bar_time, yloc.price, color.new(#ffffff, 100), label.style_label_up, i_txtcol) label.delete(lab2[1]) tz = time - time[1] if i_dev and not in_session(kz) and in_session(kz)[1] for s = 1 to i_devno by 1 _hline(kzstart, kzstart + 27000000, kzhigh[1] + devdiff * s, col1, line.style_solid, 3) _hline(kzstart, kzstart + 27000000, kzlow[1] - devdiff * s, col1, line.style_solid, 3) hf(x, a, b, c) => y = line(na) z = line(na) lf = linefill(na) st = start_time(b) if in_session(b) y := line.new(st, high, st, low, xloc.bar_time, extend.both, color.new(#ffffff, 100)) z := line.new(st + c , high, st + c , low, xloc.bar_time, extend.both, color.new(#ffffff, 100)) lf := linefill.new(z, y, a) line.delete(y[1]) line.delete(z[1]) linefill.delete(lf[1]) ////////// FUNCTIONS \\\\\\\\\\ if timeframe.isintraday and timeframe.multiplier <= 30 openline(i_time, i_d4, i_linecol1, "00.00", vstyle, i_bool1) openline(i_time2, i_d4, i_linecol2, "08.30", linestyle, i_bool2) openline(i_time3, i_d4, i_linecol3, "09.30", linestyle, i_bool3) openline(i_time4, "GMT+1", i_linecol4, "London", linestyle, i_bool4) if i_llh lrange(lonr, i_lonhl, i_lonhl) hf(ny830, c1, s1, 3600000) hf(ny930, c2, s2, 7200000) hf(ny130, c3, s3, 5400000) hf(ny300, c4, s4, 3600000) f_vline(08, 30, 09, c1, 30, dayofmonth) f_vline(09, 30, 11, c2, 30, dayofmonth) f_vline(13, 30, 15, c3, 00, dayofmonth) f_vline(15, 00, 16, c4, 00, dayofmonth) f_vline(08, 30, 09, c1, 30, dayofmonth + 1) f_vline(09, 30, 11, c2, 30, dayofmonth + 1) f_vline(13, 30, 15, c3, 00, dayofmonth + 1) f_vline(15, 00, 16, c4, 00, dayofmonth + 1)
RSI Divergence
https://www.tradingview.com/script/hfVa19WB/
faytterro
https://www.tradingview.com/u/faytterro/
904
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© faytterro //@version=5 indicator("RSI Divergence", overlay = false, max_lines_count = 500)//, overlay=true)//, scale = scale.none) rsilen=input.int(14, title="rsi length") rsisrc=input(close, title="source") x=ta.rsi(rsisrc,rsilen) len=input.int(25, title="RSI Divergence length", maxval=500) src=close extrapolation=0 //zoom=input.int(0, title="zoom", maxval=27, minval=-27) //hline(300-zoom*10, color=color.rgb(54, 58, 69, 100)) //hline(10, color=color.rgb(54, 58, 69, 100)) // for ax+b xo=0.0 yo=0.0 xyo=0.0 xxo=0.0 for i=0 to len-1 xo:= xo + i/(len) yo:= yo + x[len-1-i]/(len) xyo:= xyo + i*x[len-1-i]/(len) xxo:= xxo + i*i/(len) dnm=ta.lowest(low,200) dizi=array.new_float(len*2+1+extrapolation) linedizi=array.new_line() a=(xo*yo-xyo)/(xo*xo-xxo) b=yo-a*xo for i=0 to len-1+extrapolation array.set(dizi,i,a*i+b) //// for src // for ax+b xo2=0.0 yo2=0.0 xyo2=0.0 xxo2=0.0 for i=0 to len-1 xo2:= xo2 + i/(len) yo2:= yo2 + src[len-1-i]/(len) xyo2:= xyo2 + i*src[len-1-i]/(len) xxo2:= xxo2 + i*i/(len) dizi2=array.new_float(len*2+1+extrapolation) linedizi2=array.new_line() a2=(xo2*yo2-xyo2)/(xo2*xo2-xxo2) b2=yo2-a*xo2 for i=0 to len-1+extrapolation array.set(dizi2,i,a2*i+b2) ttk=((array.get(dizi,0)<array.get(dizi,1)) and (array.get(dizi2,0)>array.get(dizi2,1)))? 1 : ((array.get(dizi,0)>array.get(dizi,1)) and (array.get(dizi2,0)<array.get(dizi2,1)))? -1 : 0 cg=((array.get(dizi,0)<array.get(dizi,1)) and (array.get(dizi2,0)>array.get(dizi2,1)))// and ta.highest(ttk[1],len/2)<1) cr=((array.get(dizi,0)>array.get(dizi,1)) and (array.get(dizi2,0)<array.get(dizi2,1)))// and ta.lowest(ttk[1],len/2)>-1) bgcolor(color=(cg and ta.highest(ttk[1],len/2)<1)? color.rgb(76, 175, 79, 50) : (cr and ta.lowest(ttk[1],len/2)>-1)? color.rgb(255, 82, 82, 50) : na, offset=0, display=display.none) plot(x, color = color.rgb(200, 87, 194)) // for ax+b xo3=0.0 yo3=0.0 xyo3=0.0 xxo3=0.0 for i=0 to len-1 xo3:= xo3 + i/(len) yo3:= yo3 + x[len-1-i+(ta.barssince(cg))]/(len) xyo3:= xyo3 + i*x[len-1-i+(ta.barssince(cg))]/(len) xxo3:= xxo3 + i*i/(len) dizi3=array.new_float(len*2+1+extrapolation) linedizi3=array.new_line() a3=(xo3*yo3-xyo3)/(xo3*xo3-xxo3) b3=yo3-a3*xo3 for i=0 to len-1+extrapolation array.set(dizi3,i,a3*i+b3) // for ax+b xo4=0.0 yo4=0.0 xyo4=0.0 xxo4=0.0 for i=0 to len-1 xo4:= xo4 + i/(len) yo4:= yo4 + x[len-1-i+(ta.barssince(cr))]/(len) xyo4:= xyo4 + i*x[len-1-i+(ta.barssince(cr))]/(len) xxo4:= xxo4 + i*i/(len) dizi4=array.new_float(len*2+1+extrapolation) linedizi4=array.new_line() a4=(xo4*yo4-xyo4)/(xo4*xo4-xxo4) b4=yo4-a4*xo4 for i=0 to len-1+extrapolation array.set(dizi4,i,a4*i+b4) prp = input.int(0, "previous positive divergences", minval = 0) prn = input.int(0, "previous negative divergences", minval = 0) line=line.new((ta.valuewhen(cg, bar_index,prp)-len), ta.valuewhen(cg,array.get(dizi3,0),prp), ta.valuewhen(cg, bar_index,prp), ta.valuewhen(cg,array.get(dizi3,len-1),prp), color=color.rgb(0,255,0), width=2) line2=line.new((ta.valuewhen(cr, bar_index,prn)-len), ta.valuewhen(cr,array.get(dizi4,0),prn), ta.valuewhen(cr, bar_index,prn), ta.valuewhen(cr,array.get(dizi4,len-1),prn), color=color.rgb(255, 0, 0, 0), width=2) line.delete(line[1]) line.delete(line2[1]) alertcondition(cg, title = "RSI Buy") alertcondition(cr, title = "RSI Sell") hline(50, color = color.new(#787B86, 50)) rs=hline(30) rss=hline(70) fill(rs, rss, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
Position Sizing Calculator
https://www.tradingview.com/script/kg7Yq4fg-Position-Sizing-Calculator/
sosacur01
https://www.tradingview.com/u/sosacur01/
54
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© sosacur01 //@version=5 indicator("Position Sizing Calculator", overlay=true) //Table Inputs Equity = input.float(defval=10000, title="Total Equity", group="Position Sizing") i_pctStop = input.float(defval=2, title="% of Equity at Risk", step=.5, group="Position Sizing")/100 sl_price = input.float(defval=0, title="Stop Loss Price", group="Position Sizing") entry_price = input.float(defval=0, title="Entry Price", group="Position Sizing") //Table Values positionSize = (Equity * i_pctStop) / (math.abs(entry_price - sl_price)) open_pl = (close - entry_price) / entry_price * 100 //table var table myTable = table.new(position.bottom_right, 1, 8, border_width = 1) if barstate.islast text1 = "Total Equity\n" + str.tostring(Equity) text2 = "% of Equity at Risk\n" + str.tostring(i_pctStop*100) text3 = "Stop Loss Price\n" + str.tostring(sl_price) text4 = "Entry Price\n" + str.tostring(entry_price) text5 = "Price\n" + str.tostring(close) text6 = "Position Size #\n" + str.tostring(positionSize) text7 = "Open PL\n" + str.tostring(open_pl) table.cell(myTable, 0, 1, text=text1, bgcolor = color.black, text_color = color.white) table.cell(myTable, 0, 2, text=text2, bgcolor = color.black, text_color = color.white) table.cell(myTable, 0, 3, text=text3, bgcolor = color.black, text_color = color.white) table.cell(myTable, 0, 4, text=text4, bgcolor = color.black, text_color = color.white) table.cell(myTable, 0, 5, text=text5, bgcolor = color.black, text_color = color.white) table.cell(myTable, 0, 6, text=text6, bgcolor = color.black, text_color = color.white) table.cell(myTable, 0, 7, text=text7, bgcolor = color.black, text_color = color.white)
dmn's ICT Toolkit
https://www.tradingview.com/script/nStgl5A9-dmn-s-ICT-Toolkit/
fxdmn
https://www.tradingview.com/u/fxdmn/
1,012
study
5
MPL-2.0
// This source code is subjectsubject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© fxdmn // @version=5 indicator(title="dmn's ICT Toolkit", shorttitle="dmn's ICT Toolkit", overlay=true, max_lines_count=500, max_boxes_count=500) // β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•— // β–ˆβ–ˆβ•”β•β•β•β•β•β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ // β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β•šβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ // β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘ // β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘ // β•šβ•β• β•šβ•β• β•šβ•β•β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•šβ•β• β•šβ•β•β•β• //{ Constants var CBDR_SESSION = "1400-2000" var FLOUT_SESSION = "1500-2400" var ASIA_SESSION = "2000-2400" var TRUEDAY_SESSION = "0000-0100" var SUNDAY_SESSION = "1700-1701:1" var DAILY_OPEN_SESSION = "1700-1704" var GMT_OPEN_SESSION = "1900-1901" var FOUR_OPEN_SESSION = "0400-0401" var LONDON_OPEN_KILLZONE_SESSION = "0200-0500" var NY_OPEN_KILLZONE_SESSION = "0700-0900" var LONDON_CLOSE_KILLZONE_SESSION = "1030-1200" var ASIAN_OPEN_KILLZONE_SESSION = "2000-2200" var NY_LUNCH_SESSION = "1200-1300" var CBDR_LABEL_NAME = "CBDR" var FLOUT_LABEL_NAME = "Flout" var ASIA_LABEL_NAME = "AR" var NEW_YORK_MIDNIGHT_LABEL_TEXT = "NY Midnight Open" var NEW_YORK_MIDNIGHT_LABEL_SHORT = "NYM" var GMT_LABEL_TEXT = "GMT Midnight Open" var GMT_LABEL_SHORT = "GMT" var FOUR_OPEN_LABEL_TEXT = "4am Open" var FOUR_OPEN_LABEL_SHORT = "4am" var DAILY_OPEN_LABEL_TEXT = "Daily Open" var DAILY_OPEN_LABEL_SHORT = "DO" var PDH_LABEL_TEXT = "Previous Day High" var PDH_LABEL_SHORT = "PDH" var PDL_LABEL_TEXT = "Previous Day Low" var PDL_LABEL_SHORT = "PDL" var PMH_LABEL_TEXT = "Previous Month High" var PMH_LABEL_SHORT = "PMH" var PML_LABEL_TEXT = "Previous Month Low" var PML_LABEL_SHORT = "PML" var PWH_LABEL_TEXT = "Previous Week High" var PWH_LABEL_SHORT = "PWH" var PWL_LABEL_TEXT = "Previous Week Low" var PWL_LABEL_SHORT = "PWL" var TT_KILLZONE_OLD = "Original look of the killzones (note: text labels unavailable)" var TT_AUTO_TZ = "Overrides the manual option and sets the timezone automatically." var TT_ADR_LOOKBACK_INPUT = "Number of closed candles used to calculate the ADR" var TT_SESSION_ZONE_INPUT = "Change if not displaying New York midnight correctly" var TT_TABLE_LOC_INPUT = "Shows x days average daily range, current daily range, CBDR range and Asian range" var TT_ADR_DYNAMIC_TEXT = "Colors the ADR box information dynamically based on the ranges. Readable using most sensible background colors. Disabling this option will make the text black or white depending on percieved brighness of the background color" var TT_TIMEFRAME_INPUT = "The default 1 hour should provide the most accurate projections" var TT_WEEKDAY_OFFSET_INPUT = "Set this to position the weekday text where you want it during the day" var DECIMALS = int(math.log10(1/syminfo.mintick)) // get number of decimals of the ticker var PIP = math.pow(10, DECIMALS-1) // get the pip position of the ticker //END CONSTANTS} //{ Inputs sessionZoneInput = input.string('GMT-5', title='New York Time Zone', tooltip=TT_SESSION_ZONE_INPUT, options=['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'], inline="tz") sessionZoneAutoToggleInput = input.bool(true, "Automatic", TT_AUTO_TZ, inline="tz") //{ ADR inputs adrLookbackInput = input.int(5, "ADR Lookback", 1, tooltip=TT_ADR_LOOKBACK_INPUT) tableToggleInput = input.bool(true, "Stats box", "", inline="table2") tableDynamicTextInputToggle = input.bool(true, "Dynamic Text Color", TT_ADR_DYNAMIC_TEXT, inline="table2") tableBgInput = input.color(color.new(#ffffff, 5), "", inline="table") tableLocInput = input.string("Top Right", "", ["Top Left", "Bottom Left", "Top Right", "Bottom Right", "Top Center", "Bottom Center"], TT_TABLE_LOC_INPUT, inline="table") tableOrientationInput = input.string("Vertical", "", ["Horizontal", "Vertical"], inline="table") //} useWicksToggleInput = input.string("Bodies", "Range calculation source", ["Bodies", "Wicks"]) timeframeInput = input.timeframe("60", "Range calculation timeframe", tooltip=TT_TIMEFRAME_INPUT) //{ CBDR Box inputs cbdrBoxColorInput = input.color(color.new(color.green, 85), "", group="CBDR", inline="CBDR_show") cbdrBoxToggleInput = input.bool(true,"Box", group="CBDR", inline="CBDR_show") cbdrHistoryInput = input.bool(true, "History", group="CBDR", inline="CBDR_show") cbdrBorderColorInput = input.color(color.green, "", group="CBDR", inline="CBDR_border") cbdrBorderSizeInput = input.int(1, "Border", minval=0, maxval=3, group="CBDR", inline="CBDR_border") cbdrBorderTypeInput = input.string("Dotted", "", options=['Solid', 'Dotted', 'Dashed'],group="CBDR", inline="CBDR_border") cbdrLabelColorInput = input.color(color.green, "", group="CBDR", inline="CBDR_label") cbdrRangeToggleInput = input.bool(true,"Pips", group="CBDR", inline="CBDR_label") cbdrNameToggleInput = input.bool(false,"Name", group="CBDR", inline="CBDR_label") cbdrProjectionColorInput = input.color(color.green, "", group="CBDR", inline="CBDR_ext") cbdrProjectionToggleInput = input.bool(false, "Std. Deviations", group="CBDR", inline="CBDR_ext") cbdrProjectionHistoryInput = input.bool(false, "History", group="CBDR", inline="CBDR_ext") cbdrLineWidthInput = input.int(1, "Std. dev. Line Width", minval=1, maxval=3, group="CBDR", inline="CBDR_ext2") cbdrLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="CBDR", inline="CBDR_ext2") //} //{ Flout Box inputs floutBoxColorInput = input.color(color.rgb(76, 122, 175, 85), "", group="flout", inline="flout_show") floutToggleInput = input.bool(false,"Box", group="flout", inline="flout_show") floutHistoryToggleInput = input.bool(true, "History", group="flout", inline="flout_show") floutBorderColorInput = input.color(color.rgb(76, 122, 175), "", group="flout", inline="flout_border") floutBorderSizeInput = input.int(1, "Border", minval=0, maxval=3, group="flout", inline="flout_border") floutBorderTypeInput = input.string("Dotted", "", options=['Solid', 'Dotted', 'Dashed'],group="flout", inline="flout_border") floutLabelColorInput = input.color(color.rgb(76, 122, 175), "", group="flout", inline="flout_label") floutRangeToggleInput = input.bool(true,"Pips", group="flout", inline="flout_label") floutNameToggleInput = input.bool(false,"Name", group="flout", inline="flout_label") floutProjectionColorInput = input.color(color.rgb(76, 122, 175), "", group="flout", inline="floutExt") floutProjectionToggleInput = input.bool(false, "Std. Deviations", group="flout", inline="floutExt") floutProjectionHistoryInput = input.bool(false, "History", group="flout", inline="floutExt") floutLineWidthInput = input.int(1, "Std. dev. Line Width", minval=1, maxval=3, group="flout", inline="floutExt2") floutLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="flout", inline="floutExt2") //} //{ Asia Box inputs asiaBoxColorInput = input.color(color.new(color.purple, 85), "", group="AR", inline="asia_show") asiaToggleInput = input.bool(true,"Box", group="AR", inline="asia_show") asiaHistoryInput = input.bool(true, "History", group="AR", inline="asia_show") asiaBorderColorInput = input.color(color.purple, "", group="AR", inline="AR_border") asiaBorderSizeInput = input.int(1, "Border", minval=0, maxval=3,group="AR", inline="AR_border") asiaBorderTypeInput = input.string("Dotted", "", options=['Solid', 'Dotted', 'Dashed'],group="AR", inline="AR_border") asiaLabelColorInput = input.color(color.purple, "", group="AR", inline="asia_label") asiaRangeToggleInput = input.bool(true,"Pips", group="AR", inline="asia_label") asiaNameToggleInput = input.bool(false,"Name", group="AR", inline="asia_label") asiaProjectionColorInput = input.color(color.purple, "", group="AR", inline="asiaExt") asiaProjectionToggle = input.bool(false, "Std. Deviations", group="AR", inline="asiaExt") asiaProjectionHistoryInput = input.bool(false, "History", group="AR", inline="asiaExt") asiaLineWidthInput = input.int(1, "Std. dev. Line Width", minval=1, maxval=3, group="AR", inline="asiaExt2") asiaLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="AR", inline="asiaExt2") //END Asia Box inputs} //{ Trueday inputs levelLabelsShortFormatInput = input.bool(false, "Short format Name Labels", group="Levels and Lines", inline="trueDay3") staticLabelColorInput = input.bool(false, "Colored", group="Levels and Lines", inline="trueDay3") truedayColorInput = input.color(color.new(#838383, 18), "", group="Levels and Lines", inline="trueDay") truedayToggleInput = input.bool(true,"True Day", group="Levels and Lines", inline="trueDay") sundayLineToggleInput = input.bool(true,"Sunday Line", group="Levels and Lines", inline="trueDay") truedayHistoryToggleInput = input.bool(true, "History", group="Levels and Lines", inline="trueDay") truedayWidthInput = input.int(1, "", 1, 3, group="Levels and Lines", inline="trueDay2") truedayLineStyleInput = input.string("Dashed", "", options=['Solid', 'Dotted', 'Dashed'],group="Levels and Lines", inline="trueDay2") midnightColorInput = input.color(color.new(#ffcb3b, 5), "", group="Levels and Lines", inline="midnight") midnightToggleInput = input.bool(true,"Midnight", group="Levels and Lines", inline="midnight") midnightHistoryToggleInput = input.bool(true, "History", group="Levels and Lines", inline="midnight") midnightLabelToggleInput = input.bool(false, "Name", group="Levels and Lines", inline="midnight") midnightWidthInput = input.int(2, "", 1, 3, group="Levels and Lines", inline="midnight2") midnightLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="Levels and Lines", inline="midnight2") dailyOpenColorInput = input.color(color.new(#e75845, 5), "", group="Levels and Lines", inline="daily") dailyOpenToggleInput = input.bool(false,"Daily Open", inline="daily", group="Levels and Lines") dailyOpenHistoryToggleInput = input.bool(true, "History", group="Levels and Lines", inline="daily") dailyOpenLabelToggleInput = input.bool(false, "Name", group="Levels and Lines", inline="daily") dailyOpenWidthInput = input.int(2, "", 1, 3, group="Levels and Lines", inline="daily2") dailyOpenLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="Levels and Lines", inline="daily2") gmtOpenColorInput = input.color(color.new(#45c1e7, 5), "", group="Levels and Lines", inline="gmt") gmtOpenToggleInput = input.bool(false,"GMT Midnight", group="Levels and Lines", inline="gmt") gmtOpenHistoryToggleInput = input.bool(true, "History", group="Levels and Lines", inline="gmt") gmtOpenLabelToggleInput = input.bool(false, "Name", group="Levels and Lines", inline="gmt") gmtOpenWidthInput = input.int(2, "", 1, 3, group="Levels and Lines", inline="gmt2") gmtOpenLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="Levels and Lines", inline="gmt2") fourOpenColorInput = input.color(color.new(#3c49ff, 5), "", group="Levels and Lines", inline="four") fourOpenToggleInput = input.bool(false,"4am ", group="Levels and Lines", inline="four") fourOpenHistoryToggleInput = input.bool(true, "History", group="Levels and Lines", inline="four") fourOpenLabelToggleInput = input.bool(false, "Name", group="Levels and Lines", inline="four") fourOpenWidthInput = input.int(2, "", 1, 3, group="Levels and Lines", inline="four2") fourOpenLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="Levels and Lines", inline="four2") //} //{ HTF Levels pdhColorInput = input.color(color.new(#663cff, 5), "", "Note: This is the previous true day high, not the actual chart's previous daily high", group="HTF Levels", inline="pdh") pdhToggleInput = input.bool(false,"PDH ", group="HTF Levels", inline="pdh") pdhHistoryToggleInput = input.bool(false, "History", group="HTF Levels", inline="pdh") pdhLabelToggleInput = input.bool(true, "Name", group="HTF Levels", inline="pdh") pdhWidthInput = input.int(2, "", 1, 3, group="HTF Levels", inline="pdh2") pdhLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="HTF Levels", inline="pdh2") var TT_PDL = "Note: This is the previous true day low, not the actual chart's previous daily low" pdlColorInput = input.color(color.new(#663cff, 5), "", TT_PDL, group="HTF Levels", inline="pdl") pdlToggleInput = input.bool(false,"PDL ", group="HTF Levels", inline="pdl") pdlHistoryToggleInput = input.bool(false, "History", group="HTF Levels", inline="pdl") pdlLabelToggleInput = input.bool(true, "Name", group="HTF Levels", inline="pdl") pdlWidthInput = input.int(2, "", 1, 3, group="HTF Levels", inline="pdl2") pdlLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="HTF Levels", inline="pdl2") pmhColorInput = input.color(color.new(#663cff, 5), "", group="HTF Levels", inline="pmh") pmhToggleInput = input.bool(false,"PMH ", group="HTF Levels", inline="pmh") pmhHistoryToggleInput = input.bool(false, "History", group="HTF Levels", inline="pmh") pmhLabelToggleInput = input.bool(true, "Name", group="HTF Levels", inline="pmh") pmhWidthInput = input.int(2, "", 1, 3, group="HTF Levels", inline="pmh2") pmhLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="HTF Levels", inline="pmh2") pmlColorInput = input.color(color.new(#663cff, 5), "", group="HTF Levels", inline="pml") pmlToggleInput = input.bool(false,"PML ", group="HTF Levels", inline="pml") pmlHistoryToggleInput = input.bool(false, "History", group="HTF Levels", inline="pml") pmlLabelToggleInput = input.bool(true, "Name", group="HTF Levels", inline="pml") pmlWidthInput = input.int(2, "", 1, 3, group="HTF Levels", inline="pml2") pmlLineStyleInput = input.string("Solid", "", options=['Solid', 'Dotted', 'Dashed'],group="HTF Levels", inline="pml2") // END HTF Levels} //{ Killzone inputs killzoneLineWidthInput = input.float(2, "Size", 0.1, 20, 0.1, group="Killzones", inline="kzToggle") killzoneToggleInput = input.bool(true, "Killzones", group="Killzones", inline="kzToggle") killzoneOldStyleToggleInput = input.bool(false, "Old style", group="Killzones", inline="kzToggle", tooltip=TT_KILLZONE_OLD) killzoneYoffsetInput = input.int(4, "Y-offset", 1, 200 , tooltip="Higher value = closer to price", group="Killzones", inline="kzToggle2") killzoneHistoryToggleInput = input.bool(true, "History", group="Killzones", inline="kzToggle2") killzoneTextToggleInput = input.bool(true, "Text Labels", group="Killzones", inline="kzToggle2") killzoneLondonOpenColorInput = input.color(color.new(#515cbb, 5), "", group="Killzones", inline="kzLO") killzoneLondonOpenSessionInput = input.session(LONDON_OPEN_KILLZONE_SESSION, "", group="Killzones", inline="kzLO") killzoneLondonOpenToggleInput = input.bool(true, "London", group="Killzones", inline="kzLO") killzoneNyColorInput = input.color(color.new(#f3c547, 5), "", group="Killzones", inline="kzNY") killzoneNyOpenSessionInput = input.session(NY_OPEN_KILLZONE_SESSION, "", group="Killzones", inline="kzNY") killzoneNyToggleInput = input.bool(true, "New York", group="Killzones", inline="kzNY") killzoneLondonCloseColorInput = input.color(color.new(#515cbb, 5), "", group="Killzones", inline="kzLC") killzoneLondonCloseSessionInput = input.session(LONDON_CLOSE_KILLZONE_SESSION, "", group="Killzones", inline="kzLC") killzoneLondonCloseToggleInput = input.bool(true, "London Close", group="Killzones", inline="kzLC") killzoneAsianOpenColorInput = input.color(color.purple, "", group="Killzones", inline="kzAO") killzoneAsianOpenSessionInput = input.session(ASIAN_OPEN_KILLZONE_SESSION, "", group="Killzones", inline="kzAO") killzoneAsianOpenToggleInput = input.bool(true, "Asian Open", group="Killzones", inline="kzAO") killzoneNyLunchColorInput = input.color(color.red, "", group="Killzones", inline="kzNyL") killzoneNyLunchSessionInput = input.session(NY_LUNCH_SESSION, "", group="Killzones", inline="kzNyL") killzoneNyLunchToggleInput = input.bool(false, "New York Lunch", group="Killzones", inline="kzNyL") //} //{ Weekday input weekdaysColorInput = input.color(color.gray, "", group="weekdays", inline="weekdays") weekdaysLocationInput = input.string("Bottom", "", ["Top", "Bottom"], group="weekdays", inline="weekdays") weekdaysToggleInput = input.bool(true, "Weekdays", group="weekdays", inline="weekdays") weekdaysShortFormatToggleInput = input.bool(false, "Short format", group="weekdays", inline="weekdays") weekdayOffsetInput = input.int(0, "Horizontal position offset", tooltip=TT_WEEKDAY_OFFSET_INPUT) //END Weekday input} //{ Session Times input cbdrSessionInput = input.session(CBDR_SESSION, "CBDR", group="Session Times Customization") floutSessionInput = input.session(FLOUT_SESSION, "Flout", group="Session Times Customization") asiaSessionInput = input.session(ASIA_SESSION, "Asian Range", group="Session Times Customization") stdvNumLinesInput = input.int(4, "Standard Deviations", 1, 10, group="Session Times Customization") //} //END Inputs} //{ Functions hours(int h, int m=0) => //@function Returns UNIX time a certain number hours from now. //@param h (int) number of hours //@param m (int) (optional) number of minutes time+(3600000*h)+(60000*m) stringToHour(s) => //@function Converts session input strings to integers for using with the hours() function //@param s session string //@return (int) hours part of the session string input parameter math.round(str.tonumber(str.substring(s, 0, 2))) stringToMinutes(s) => //@function Converts session input strings to integers for using with the hours() function //@param s session string //@return (int) minutes part of the session string input parameter math.round(str.tonumber(str.substring(s, 2, 4))) averageRange(h, l, n) => //@function Calculate the average range in pips of a number of bars //@param h = high, l = low, n = number of bars r = 0.0 for i = 1 to n r += h[i]-l[i] PIP*r/n addLines(a, x1, x2, y, c, n, s, w) => //@function Adds horizonal lines to a line array //@param a = array id, x1 & x2 = x coordinates, y = y coordinate, c = color, n = number of lines for i=0 to n-1 array.push(a, line.new(x1, y, x2, y, xloc=xloc.bar_time, color=c, style=s, width=w)) delLines(a) => //@function Delete all lines in a line array //@param a = line array if array.size(a) > 0 for i=0 to array.size(a)-1 line.delete(array.get(a, i)) setLineArrayY(a, y, spacing, m) => //@function moves all lines in a line array and space them based on a range, starting at y, m=1 for upward spacing, -1 for downward //@param a = line array, y = y coordinate to start from, spacing = distance between lines, m = upward or downward spacing (+/-1) for [i, l] in a float step=(i+1) * spacing * m line.set_y1(l, y+step) line.set_y2(l, y+step) lineset_y(l, y) => //@function Makes a line horizontal at a location //@param l = line id, y = y coordinate line.set_y1(l, y) line.set_y2(l, y) inSession(sessionTime, sessionTimeZone=syminfo.timezone) => //@function Checks if a session is active //@param SessionTime = session start and end, sessionTimeZone = optional timezone parameter not na(time(timeframe.period, sessionTime, sessionTimeZone)) getBrightness(color c) => //@function Calculates percieved brightness of a color //@param c (color) //@returns (float) brightness of c between 0 and 255 r = color.r(c) g = color.g(c) b = color.b(c) math.sqrt(r*r*0.241 + g*g*0.691 + b*b*0.068) blackOrWhiteText(c) => if getBrightness(c) > 130 color.black else color.white getLineStyle(s) => switch(s) "Solid" => line.style_solid "Dotted" => line.style_dotted "Dashed" => line.style_dashed //END Functions} var useWicks = useWicksToggleInput == "Bodies" ? false : true var sessionZone = sessionZoneAutoToggleInput ? "America/New_York" : sessionZoneInput //{ CBDR vars var cbdrHighPrice = 0.0 var cbdrLowPrice = 0.0 var cbdrRange = 0.0 var box cbdrBox = na var cbdrBorderStyle = getLineStyle(cbdrBorderTypeInput) var label cbdrLabel = na var cbdrLabelText = cbdrNameToggleInput and cbdrRangeToggleInput ? CBDR_LABEL_NAME + ": " : cbdrNameToggleInput ? CBDR_LABEL_NAME : "" var array<line> cbdrLinesHi = array.new<line>() var array<line> cbdrLinesLo = array.new<line>() var cbdrLineStyle = getLineStyle(cbdrLineStyleInput) var cbdrLineWidth = cbdrLineWidthInput //END CBDR vars} //{ Flout vars var floutHighPrice = 0.0 var floutLowPrice = 0.0 var floutRange = 0.0 var box floutBox = na var floutBorderStyle = getLineStyle(floutBorderTypeInput) var label floutLabel = na var floutLabelText = floutNameToggleInput and floutRangeToggleInput ? FLOUT_LABEL_NAME + ": " : floutNameToggleInput ? FLOUT_LABEL_NAME : "" var line floutLineMid = na var array<line> floutLinesHi = array.new<line>() var array<line> floutLinesLo = array.new<line>() var floutLineStyle = getLineStyle(floutLineStyleInput) var floutLineWidth = floutLineWidthInput //END Flout vars} //{ Asian vars var asiaHighPrice = 0.0 var asiaLowPrice = 0.0 var asiaRange = 0.0 var box asiaBox = na var asiaBorderStyle = getLineStyle(asiaBorderTypeInput) var label asiaLabel = na var asiaLabelText = asiaNameToggleInput and asiaRangeToggleInput ? ASIA_LABEL_NAME + ": " : asiaNameToggleInput ? ASIA_LABEL_NAME : "" var array<line> asiaLinesHi = array.new<line>() var array<line> asiaLinesLo = array.new<line>() var asiaLineStyle = getLineStyle(asiaLineStyleInput) var asiaLineWidth = asiaLineWidthInput //END Asian vars} //{ Trueday vars var killzoneHighPrice = 0.0 var killzoneLowPrice = 0.0 var line kzLoLine1 = na var line kzLoLine2 = na var line kzNYLine1 = na var line kzNYLine2 = na var line kzLCLine1 = na var line kzLCLine2 = na var line kzAOLine1 = na var line kzAOLine2 = na var line kzNyLLine1 = na var line kzNyLLine2 = na var box kzLoBox1 = na var box kzLoBox2 = na var box kzNyBox1 = na var box kzNyBox2 = na var box kzLcBox1 = na var box kzLcBox2 = na var box kzAoBox1 = na var box kzAoBox2 = na var box kzNyLBox1 = na var box kzNyLBox2 = na var line dailyOpenLine = na var line fourOpenLine = na var line gmtOpenLine = na var line midnightLine = na var line truedayLine = na var line pdhLine = na var line pdlLine = na var line pmhLine = na var line pmlLine = na var label dailyOpenLabel = na var label fourOpenLabel = na var label gmtOpenLabel = na var label midnightLabel = na var label pdhLabel = na var label pdlLabel = na var label pmhLabel = na var label pmlLabel = na var levelsLabelTextSize = size.small var color dailyOpenLabelColor = dailyOpenColorInput var color fourOpenLabelColor = fourOpenColorInput var color gmtOpenLabelColor = gmtOpenColorInput var color midnightLabelColor = midnightColorInput var color pdhLabelColor = pdhColorInput var color pdlLabelColor = pdlColorInput var color pmhLabelColor = pmhColorInput var color pmlLabelColor = pmlColorInput var dailyOpenStyle = getLineStyle(dailyOpenLineStyleInput) var fourOpenStyle = getLineStyle(fourOpenLineStyleInput) var gmtOpenStyle = getLineStyle(gmtOpenLineStyleInput) var midnightStyle = getLineStyle(midnightLineStyleInput) var truedayStyle = getLineStyle(truedayLineStyleInput) var pdhStyle = getLineStyle(pdhLineStyleInput) var pdlStyle = getLineStyle(pdlLineStyleInput) var pmhStyle = getLineStyle(pmhLineStyleInput) var pmlStyle = getLineStyle(pmlLineStyleInput) var tdHigh = high var tdLow = low var float ptdHigh = na var float ptdLow = na var int tdLowX = na var int tdHighX = na var int ptdHighX = na var int ptdLowX = na //END Trueday vars} //{ Killzone vars var LONDON_OPEN_KILLZONE_START = str.substring(killzoneLondonOpenSessionInput, 0, 4) var LONDON_OPEN_KILLZONE_END = str.substring(killzoneLondonOpenSessionInput, 5, 9) var NY_OPEN_KILLZONE_START = str.substring(killzoneNyOpenSessionInput, 0, 4) var NY_OPEN_KILLZONE_END = str.substring(killzoneNyOpenSessionInput, 5, 9) var LONDON_CLOSE_KILLZONE_START = str.substring(killzoneLondonCloseSessionInput, 0, 4) var LONDON_CLOSE_KILLZONE_END = str.substring(killzoneLondonCloseSessionInput, 5, 9) var ASIAN_OPEN_KILLZONE_START = str.substring(killzoneAsianOpenSessionInput, 0, 4) var ASIAN_OPEN_KILLZONE_END = str.substring(killzoneAsianOpenSessionInput, 5, 9) var ASIAN_RANGE_START = str.substring(ASIA_SESSION, 0,4) var NY_LUNCH_START = str.substring(killzoneNyLunchSessionInput, 0, 4) var NY_LUNCH_END = str.substring(killzoneNyLunchSessionInput, 5, 9) //END Killzone vars} //{ Weekday vars var weekdaysLocation = weekdaysLocationInput == "Top" ? location.top : location.bottom var invisible = color.rgb(0,0,0,100) var weekdayCondition = weekdaysToggleInput and timeframe.isintraday and timeframe.multiplier <= 60 var weekdayOffset = weekdayOffsetInput/timeframe.multiplier //END Weekday vars} //{ Calculation Timeframe [tfOpen, tfClose, tfHigh, tfLow] = request.security(syminfo.tickerid, timeframeInput, [open, close, high, low], lookahead=barmerge.lookahead_on) //[pdhigh, pdLow] = request.security(syminfo.tickerid, "D", [high[1], low[1]], lookahead=barmerge.lookahead_on) [pmHigh, pmLow] = request.security(syminfo.tickerid, "M", [high[1], low[1]], lookahead=barmerge.lookahead_on) //END Calculation Timeframe} //{ Colorize static Labels if not staticLabelColorInput var color c = getBrightness(chart.bg_color) >130 ? color.black : color.white gmtOpenLabelColor := c fourOpenLabelColor := c dailyOpenLabelColor := c midnightLabelColor := c pdhLabelColor := c pdlLabelColor := c pmhLabelColor := c pmlLabelColor := c //} END Colorize static Labels //{ Session Start checks inCbdrSession = inSession(cbdrSessionInput, sessionZone) and timeframe.isintraday cbdrStart = inCbdrSession and not inCbdrSession[1] inFloutSession = inSession(floutSessionInput, sessionZone) and timeframe.isintraday floutStart = inFloutSession and not inFloutSession[1] inasiaSession = inSession(asiaSessionInput, sessionZone) and timeframe.isintraday asiaStart = inasiaSession and not inasiaSession[1] intruedaySession = inSession(TRUEDAY_SESSION, sessionZone) and timeframe.isintraday truedayStart = intruedaySession and not intruedaySession[1] insundaySession = inSession(SUNDAY_SESSION, sessionZone) and timeframe.isintraday sundayStart = insundaySession and not insundaySession[1] indailyOpenSession = inSession(DAILY_OPEN_SESSION, sessionZone) and timeframe.isintraday dailyOpenStart = indailyOpenSession and not indailyOpenSession[1] ingmtOpenSession = inSession(GMT_OPEN_SESSION, sessionZone) and timeframe.isintraday gmtOpenStart = ingmtOpenSession and not ingmtOpenSession[1] infourOpenSession = inSession(FOUR_OPEN_SESSION, sessionZone) and timeframe.isintraday fourOpenStart = infourOpenSession and not infourOpenSession[1] inkzLOSession = inSession(killzoneLondonOpenSessionInput, sessionZone) and timeframe.isintraday kzLOStart = inkzLOSession and not inkzLOSession[1] inkzNySession = inSession(killzoneNyOpenSessionInput, sessionZone) and timeframe.isintraday kzNyStart = inkzNySession and not inkzNySession[1] inkzLcSession = inSession(killzoneLondonCloseSessionInput, sessionZone) and timeframe.isintraday kzLcStart = inkzLcSession and not inkzLcSession[1] inkzAoSession = inSession(killzoneAsianOpenSessionInput, sessionZone) and timeframe.isintraday kzAoStart = inkzAoSession and not inkzAoSession[1] inKzNyLunchSession = inSession(killzoneNyLunchSessionInput, sessionZone) and timeframe.isintraday kzNyLunchStart = inKzNyLunchSession and not inKzNyLunchSession[1] if cbdrStart //are we at the start of a CBDR? if not cbdrHistoryInput //is CBDR history off? box.delete(cbdrBox) // label.delete(cbdrLabel) //then delete previous boxes and labels if not cbdrProjectionHistoryInput or not cbdrHistoryInput //is CBDR Projection history off OR CBDR history off? delLines(cbdrLinesHi) // delLines(cbdrLinesLo) //then delete previous CBDR projections array.clear(cbdrLinesHi) // array.clear(cbdrLinesLo) //Clean up the CBDR Line arrays cbdrHighPrice := tfOpen // cbdrLowPrice := tfOpen //Set the initial high and low of the CBDR cbdrRange := 0.0 // asiaRange := 0.0 //Reset the range of the CBDR and Asian Range else if inCbdrSession //are we in the CBDR session? if useWicks cbdrHighPrice := math.max(cbdrHighPrice, tfHigh) cbdrLowPrice := math.min(cbdrLowPrice, tfLow) else cbdrHighPrice := math.max(cbdrHighPrice, math.max(tfOpen,tfClose)) // cbdrLowPrice := math.min(cbdrLowPrice, math.min(tfOpen, tfClose)) //check for new high and low cbdrRange := (PIP*(cbdrHighPrice-cbdrLowPrice)) //calculate the CBDR and convert to pips if floutStart if not floutHistoryToggleInput //is flout history off? box.delete(floutBox) // label.delete(floutLabel) //then delete previous boxes and labels if not floutProjectionHistoryInput or not floutHistoryToggleInput //is flout Projection history off OR flout history off? line.delete(floutLineMid) delLines(floutLinesHi) // delLines(floutLinesLo) //then delete previous flout projections array.clear(floutLinesHi) // array.clear(floutLinesLo) //Clean up the flout Line arrays floutHighPrice := tfOpen // floutLowPrice := tfOpen //reset flout high and low else if inFloutSession //are we already in the flout? if useWicks floutHighPrice := math.max(floutHighPrice, tfHigh) //check for new flout high floutLowPrice := math.min(floutLowPrice, tfLow) //check for new flout low else floutHighPrice := math.max(floutHighPrice, math.max(tfOpen,tfClose)) floutLowPrice := math.min(floutLowPrice, math.min(tfOpen, tfClose)) floutRange := PIP*(floutHighPrice-floutLowPrice) //calculate current flout range and convert to pips if asiaStart //are we at the start of a new asian range? if not asiaHistoryInput //is asian range history off? box.delete(asiaBox) // label.delete(asiaLabel) //then delete previous boxes and labels if not asiaProjectionHistoryInput or not asiaHistoryInput //is asian range projection history off OR asian range history off? delLines(asiaLinesHi) // delLines(asiaLinesLo) //then delete previous asian range projections array.clear(asiaLinesHi) // array.clear(asiaLinesLo) //Clean up the asian Line arrays asiaHighPrice := tfOpen // asiaLowPrice := tfOpen //reset asian range high and low else if inasiaSession //are we already in the asian range? if useWicks asiaHighPrice := math.max(asiaHighPrice, tfHigh) //check for new asian range high asiaLowPrice := math.min(asiaLowPrice, tfLow) //check for new asian range low else asiaHighPrice := math.max(asiaHighPrice, math.max(tfOpen, tfClose)) asiaLowPrice := math.min(asiaLowPrice, math.min(tfOpen, tfClose)) asiaRange := (PIP*(asiaHighPrice-asiaLowPrice)) //calculate current asian range and convert to pips if dailyOpenStart label.delete(pmhLabel) label.delete(pmlLabel) if not pmhHistoryToggleInput line.delete(pmhLine) if pmhToggleInput pmhLine := line.new(time, pmHigh, dayofweek(time) == 6 ? hours(72) : hours(24), pmHigh, xloc=xloc.bar_time, color=pmhColorInput, style=pmhStyle, width=pmhWidthInput) if pmhLabelToggleInput pmhLabel := label.new(dayofweek(time) == 6 ? hours(72) : hours(24), pmHigh, levelLabelsShortFormatInput ? PMH_LABEL_SHORT : PMH_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, pmhLabelColor, levelsLabelTextSize) if not pmlHistoryToggleInput line.delete(pmlLine) if pmlToggleInput pmlLine := line.new(time, pmLow, dayofweek(time) == 6 ? hours(72) : hours(24), pmLow, xloc=xloc.bar_time, color=pmlColorInput, style=pmlStyle, width=pmlWidthInput) if pmlLabelToggleInput pmlLabel := label.new(dayofweek(time) == 6 ? hours(72) : hours(24), pmLow, levelLabelsShortFormatInput ? PML_LABEL_SHORT : PML_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, pmlLabelColor, levelsLabelTextSize) if not dailyOpenHistoryToggleInput line.delete(dailyOpenLine) label.delete(dailyOpenLabel) if dailyOpenToggleInput dailyOpenLine := line.new(time, open, dayofweek(time) == 6 ? hours(72) : hours(24), open, xloc=xloc.bar_time, color=dailyOpenColorInput, style=dailyOpenStyle, width=dailyOpenWidthInput) if dailyOpenLabelToggleInput dailyOpenLabel := label.new(dayofweek(time) == 6 ? hours(72) : hours(24), open, levelLabelsShortFormatInput ? DAILY_OPEN_LABEL_SHORT : DAILY_OPEN_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, dailyOpenLabelColor, levelsLabelTextSize) if fourOpenStart if not fourOpenHistoryToggleInput line.delete(fourOpenLine) label.delete(fourOpenLabel) if fourOpenToggleInput fourOpenLine := line.new(time, open, dayofweek(time) == 6 ? hours(72) : hours(24), open, xloc=xloc.bar_time, color=fourOpenColorInput, style=fourOpenStyle, width=fourOpenWidthInput) if fourOpenLabelToggleInput fourOpenLabel := label.new(dayofweek(time) == 6 ? hours(72) : hours(24), open, levelLabelsShortFormatInput ? FOUR_OPEN_LABEL_SHORT : FOUR_OPEN_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, fourOpenLabelColor, levelsLabelTextSize) if gmtOpenStart if not gmtOpenHistoryToggleInput line.delete(gmtOpenLine) label.delete(gmtOpenLabel) if gmtOpenToggleInput gmtOpenLine := line.new(time, open, dayofweek(time) == 6 ? hours(72) : hours(24), open, xloc=xloc.bar_time, color=gmtOpenColorInput, style=gmtOpenStyle, width=gmtOpenWidthInput) if gmtOpenLabelToggleInput gmtOpenLabel := label.new(dayofweek(time) == 6 ? hours(72) : hours(24), open, levelLabelsShortFormatInput ? GMT_LABEL_SHORT : GMT_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, gmtOpenLabelColor, levelsLabelTextSize) //{ True day Start} if truedayStart //New True Day ptdHigh := tdHigh //Save high, low and x coordinates to previous day's variables before resetting ptdLow := tdLow tdHigh := high // reset true day high tdLow := low // reset true day low ptdHighX := tdHighX ptdLowX := tdLowX tdLowX := time tdHighX := time _s = dayofweek == dayofweek.friday ? hours(54) : hours(6) _h = dayofweek == dayofweek.friday ? hours(72) : hours(24) if not pdhHistoryToggleInput label.delete(pdhLabel) line.delete(pdhLine) if pdhToggleInput pdhLine := line.new(ptdHighX, ptdHigh, _h, ptdHigh, xloc=xloc.bar_time, color=pdhColorInput, style=pdhStyle, width=pdhWidthInput) if pdhLabelToggleInput pdhLabel := label.new(_h, ptdHigh, levelLabelsShortFormatInput ? PDH_LABEL_SHORT : PDH_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, pdhLabelColor, levelsLabelTextSize) if not pdlHistoryToggleInput label.delete(pdlLabel) line.delete(pdlLine) if pdlToggleInput pdlLine := line.new(ptdLowX, ptdLow, _h, ptdLow, xloc=xloc.bar_time, color=pdlColorInput, style=pdlStyle, width=pdlWidthInput) if pdlLabelToggleInput pdlLabel := label.new(_h, ptdLow, levelLabelsShortFormatInput ? PDL_LABEL_SHORT : PDL_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, pdlLabelColor, levelsLabelTextSize) if not midnightHistoryToggleInput // is midnight level history off? line.delete(midnightLine) // delete old midnight level lines label.delete(midnightLabel) // delete old midnight level labels if not truedayHistoryToggleInput // is true day vertical line history off? line.delete(truedayLine) // delete old true day vertical lines if not killzoneHistoryToggleInput // is killzone history off? if killzoneOldStyleToggleInput // is old style killzone display on? line.delete(kzLoLine1) // line.delete(kzLoLine2) // line.delete(kzLCLine1) // line.delete(kzLCLine2) // line.delete(kzNYLine1) // line.delete(kzNYLine2) // then delete previous killzone lines line.delete(kzAOLine1) // line.delete(kzAOLine2) // line.delete(kzNyLLine1) // line.delete(kzNyLLine2) // else // is new style killzone boxes in use? box.delete(kzLoBox1) // box.delete(kzLoBox2) // box.delete(kzNyBox1) // box.delete(kzNyBox2) // box.delete(kzLcBox1) // box.delete(kzLcBox2) // then delete previous killzone boxes box.delete(kzAoBox1) // box.delete(kzAoBox2) // box.delete(kzNyLBox1) // box.delete(kzNyLBox2) // killzoneHighPrice := high // reset killzone high killzoneLowPrice := low // reset killzone low if killzoneToggleInput //are killzones enabled? if killzoneLondonOpenToggleInput // is london killzone enabled? if killzoneOldStyleToggleInput kzLoLine1 := line.new(hours(stringToHour(LONDON_OPEN_KILLZONE_START), stringToMinutes(LONDON_OPEN_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(LONDON_OPEN_KILLZONE_END), stringToMinutes(LONDON_OPEN_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, color=killzoneLondonOpenColorInput, style=line.style_solid, width=math.round(killzoneLineWidthInput)) kzLoLine2 := line.copy(kzLoLine1) //draw london open killzone lines from it's start to end else kzLoBox1 := box.new(hours(stringToHour(LONDON_OPEN_KILLZONE_START), stringToMinutes(LONDON_OPEN_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(LONDON_OPEN_KILLZONE_END), stringToMinutes(LONDON_OPEN_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, bgcolor=killzoneLondonOpenColorInput, border_width=0) kzLoBox2 := box.copy(kzLoBox1) if killzoneNyToggleInput //is new york killzone enabled? if killzoneOldStyleToggleInput kzNYLine1 := line.new(hours(stringToHour(NY_OPEN_KILLZONE_START), stringToMinutes(NY_OPEN_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(NY_OPEN_KILLZONE_END), stringToMinutes(NY_OPEN_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, color=killzoneNyColorInput, style=line.style_solid, width=math.round(killzoneLineWidthInput)) kzNYLine2 := line.copy(kzNYLine1) //draw new york open killzone lines from it's start to end else kzNyBox1 := box.new(hours(stringToHour(NY_OPEN_KILLZONE_START), stringToMinutes(NY_OPEN_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(NY_OPEN_KILLZONE_END), stringToMinutes(NY_OPEN_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, bgcolor=killzoneNyColorInput, border_width=0) kzNyBox2 := box.copy(kzNyBox1) if killzoneLondonCloseToggleInput //is london close killzone enabled? if killzoneOldStyleToggleInput kzLCLine1 := line.new(hours(stringToHour(LONDON_CLOSE_KILLZONE_START), stringToMinutes(LONDON_CLOSE_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(LONDON_CLOSE_KILLZONE_END), stringToMinutes(LONDON_CLOSE_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, color=killzoneLondonCloseColorInput, style=line.style_solid, width=math.round(killzoneLineWidthInput)) kzLCLine2 := line.copy(kzLCLine1) //draw london close killzone lines from it's start to end else kzLcBox1 := box.new(hours(stringToHour(LONDON_CLOSE_KILLZONE_START), stringToMinutes(LONDON_CLOSE_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(LONDON_CLOSE_KILLZONE_END), stringToMinutes(LONDON_CLOSE_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, bgcolor=killzoneLondonCloseColorInput, border_width=0) kzLcBox2 := box.copy(kzLcBox1) if killzoneAsianOpenToggleInput //is asian killzone enabled? if killzoneOldStyleToggleInput kzAOLine1 := line.new(hours(stringToHour(ASIAN_OPEN_KILLZONE_START), stringToMinutes(ASIAN_OPEN_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(ASIAN_OPEN_KILLZONE_END), stringToMinutes(ASIAN_OPEN_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, color=killzoneAsianOpenColorInput, style=line.style_solid, width=math.round(killzoneLineWidthInput)) kzAOLine2 := line.copy(kzAOLine1) //draw asian open killzone lines from it's start to end else kzAoBox1 := box.new(hours(stringToHour(ASIAN_OPEN_KILLZONE_START), stringToMinutes(ASIAN_OPEN_KILLZONE_START)), killzoneHighPrice, hours(stringToHour(ASIAN_OPEN_KILLZONE_END), stringToMinutes(ASIAN_OPEN_KILLZONE_END)), killzoneHighPrice, xloc=xloc.bar_time, bgcolor=killzoneAsianOpenColorInput, border_width=0, text_color=blackOrWhiteText(killzoneAsianOpenColorInput)) kzAoBox2 := box.copy(kzAoBox1) if killzoneNyLunchToggleInput //is asian killzone enabled? if killzoneOldStyleToggleInput kzNyLLine1 := line.new(hours(stringToHour(NY_LUNCH_START), stringToMinutes(NY_LUNCH_START)), killzoneHighPrice, hours(stringToHour(NY_LUNCH_END), stringToMinutes(NY_LUNCH_END)), killzoneHighPrice, xloc=xloc.bar_time, color=killzoneNyLunchColorInput, style=line.style_solid, width=math.round(killzoneLineWidthInput)) kzNyLLine2 := line.copy(kzNyLLine1) else kzNyLBox1 := box.new(hours(stringToHour(NY_LUNCH_START), stringToMinutes(NY_LUNCH_START)), killzoneHighPrice, hours(stringToHour(NY_LUNCH_END), stringToMinutes(NY_LUNCH_END)), killzoneHighPrice, xloc=xloc.bar_time, bgcolor=killzoneNyLunchColorInput, border_width=0) kzNyLBox2 := box.copy(kzNyLBox1) if killzoneTextToggleInput c = blackOrWhiteText(killzoneLondonOpenColorInput) box.set_text(kzLoBox1, "LONDON OPEN KZ") box.set_text(kzLoBox2, "LONDON OPEN KZ") box.set_text_color(kzLoBox1, c) box.set_text_color(kzLoBox2, c) c := blackOrWhiteText(killzoneNyColorInput) box.set_text(kzNyBox1, "NEW YORK KZ") box.set_text(kzNyBox2, "NEW YORK KZ") box.set_text_color(kzNyBox1, c) box.set_text_color(kzNyBox2, c) c := blackOrWhiteText(killzoneLondonCloseColorInput) box.set_text(kzLcBox1, "LONDON CLOSE KZ") box.set_text_color(kzLcBox1, c ) box.set_text(kzLcBox2, "LONDON CLOSE KZ") box.set_text_color(kzLcBox2, c) c := blackOrWhiteText(killzoneAsianOpenColorInput) box.set_text(kzAoBox1, "ASIAN OPEN KZ") box.set_text(kzAoBox2, "ASIAN OPEN KZ") box.set_text_color(kzAoBox1, c) box.set_text_color(kzAoBox2, c) c := blackOrWhiteText(killzoneNyLunchColorInput) box.set_text(kzNyLBox1, "NEW YORK LUNCH") box.set_text(kzNyLBox2, "NEW YORK LUNCH") box.set_text_color(kzNyLBox1, c) box.set_text_color(kzNyLBox2, c) if midnightToggleInput //is true day open line enabled? midnightLine := line.new(time, open, dayofweek(time) == 6 ? hours(72) : hours(24), open, xloc=xloc.bar_time, color=midnightColorInput, style=midnightStyle, width=midnightWidthInput) if midnightLabelToggleInput midnightLabel := label.new(dayofweek(time) == 6 ? hours(72) : hours(24), open, levelLabelsShortFormatInput ? NEW_YORK_MIDNIGHT_LABEL_SHORT : NEW_YORK_MIDNIGHT_LABEL_TEXT, xloc.bar_time, yloc.price, invisible, label.style_none, midnightLabelColor, levelsLabelTextSize) if truedayToggleInput //draw the true day vertical line if enabled truedayLine := line.new(time, open, time, open+1, xloc=xloc.bar_time, extend=extend.both, color=truedayColorInput, style=truedayStyle, width=truedayWidthInput) //END True day start} if high > tdHigh // check for new high tdHigh := high // set new high tdHighX := time // set new high's x position if low < tdLow // check for new low tdLow := low // set new low tdLowX := time // set new low's x position //{ Sunday Start if sundayStart if not truedayHistoryToggleInput line.delete(truedayLine) if sundayLineToggleInput truedayLine := line.new(time, open, time, open+1, xloc=xloc.bar_time, extend=extend.both, color=truedayColorInput, style=truedayStyle, width=truedayWidthInput) //END Sunday Start} //END Session checks} //{ Draw stuff if cbdrStart and cbdrBoxToggleInput cbdrBox := box.new(bar_index, na, na, na, cbdrBorderColorInput, cbdrBorderSizeInput, cbdrBorderStyle, bgcolor=cbdrBoxColorInput) cbdrLabel := label.new(bar_index, high, "", style=label.style_none, textcolor=cbdrLabelColorInput, textalign=text.align_center) if cbdrProjectionToggleInput s = dayofweek == dayofweek.friday ? hours(54) : hours(6) h = dayofweek == dayofweek.friday ? hours(72) : hours(24) addLines(cbdrLinesHi, s, h, open, cbdrProjectionColorInput, stdvNumLinesInput, cbdrLineStyle, cbdrLineWidth) addLines(cbdrLinesLo, s, h, open, cbdrProjectionColorInput, stdvNumLinesInput, cbdrLineStyle, cbdrLineWidth) if floutStart and floutToggleInput floutBox := box.new(bar_index, na, na, na, floutBorderColorInput, floutBorderSizeInput, floutBorderStyle, bgcolor=floutBoxColorInput) floutLabel := label.new(bar_index, high, "", xloc.bar_time, style=label.style_none, textcolor=floutLabelColorInput, textalign=text.align_center) if floutProjectionToggleInput s = dayofweek == dayofweek.friday ? hours(57) : hours(9) h = dayofweek == dayofweek.friday ? hours(71) : hours(23) floutLineMid :=line.new(s, high, h, high, xloc.bar_time, color=floutProjectionColorInput, style=line.style_dashed, width=1) addLines(floutLinesHi, s, h, open, floutProjectionColorInput, stdvNumLinesInput, floutLineStyle, floutLineWidth) addLines(floutLinesLo, s, h, open, floutProjectionColorInput, stdvNumLinesInput, floutLineStyle, floutLineWidth) if asiaStart and asiaToggleInput asiaBox := box.new(bar_index, na, na, na, asiaBorderColorInput, asiaBorderSizeInput, asiaBorderStyle, bgcolor=asiaBoxColorInput) asiaLabel := label.new(bar_index, high, "", style=label.style_none, textcolor=asiaLabelColorInput, textalign=text.align_left) if asiaProjectionToggle s =hours(4) // length of asian range session in hours h =hours(18) // hours until next asian rage session addLines(asiaLinesHi, s, h, high, asiaProjectionColorInput, stdvNumLinesInput, asiaLineStyle, asiaLineWidth) addLines(asiaLinesLo, s, h, high, asiaProjectionColorInput, stdvNumLinesInput, asiaLineStyle, asiaLineWidth) //END Draw stuff} //{ Update drawn stuff that changes with price if inCbdrSession and cbdrBoxToggleInput true_cbdr = cbdrHighPrice-cbdrLowPrice box.set_top(cbdrBox, cbdrHighPrice) box.set_bottom(cbdrBox, cbdrLowPrice) box.set_right(cbdrBox, bar_index + 1) label.set_text(cbdrLabel, cbdrRangeToggleInput ? cbdrLabelText + str.tostring(cbdrRange) : cbdrLabelText) label.set_x(cbdrLabel, bar_index) label.set_y(cbdrLabel, cbdrHighPrice) setLineArrayY(cbdrLinesHi, cbdrHighPrice, true_cbdr, 1) setLineArrayY(cbdrLinesLo, cbdrLowPrice, true_cbdr, -1) if inFloutSession and floutToggleInput true_flout = (floutHighPrice-floutLowPrice)/2 box.set_top(floutBox, floutHighPrice) box.set_bottom(floutBox, floutLowPrice) box.set_right(floutBox, bar_index + 1) label.set_text(floutLabel, floutRangeToggleInput ? floutLabelText + str.tostring(floutRange) : floutLabelText) label.set_x(floutLabel, hours(-1)) label.set_y(floutLabel, floutHighPrice) lineset_y(floutLineMid, floutHighPrice-true_flout) setLineArrayY(floutLinesHi, floutHighPrice, true_flout, 1) setLineArrayY(floutLinesLo, floutLowPrice, true_flout, -1) if inasiaSession and asiaToggleInput true_asia = asiaHighPrice-asiaLowPrice box.set_top(asiaBox, asiaHighPrice) box.set_bottom(asiaBox, asiaLowPrice) box.set_right(asiaBox, bar_index + 1) label.set_text(asiaLabel, asiaRangeToggleInput ? asiaLabelText + str.tostring(asiaRange) : asiaLabelText) label.set_x(asiaLabel, bar_index-1) label.set_y(asiaLabel, asiaHighPrice) setLineArrayY(asiaLinesHi, asiaHighPrice, true_asia, 1) setLineArrayY(asiaLinesLo, asiaLowPrice, true_asia, -1) //END Update drawn stuff} //{ Killzone lines killzoneHighPrice := math.max(killzoneHighPrice, high) killzoneLowPrice := math.min(killzoneLowPrice, low) scaleModifier = DECIMALS == 0 ? 10 : 1 kzUpperBoxTop = killzoneHighPrice+(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput + killzoneLineWidthInput/PIP/scaleModifier kzUpperBoxBottom = killzoneHighPrice+(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput kzLowerBoxTop = killzoneLowPrice-(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput kzLowerBoxBottom = killzoneLowPrice-(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput - killzoneLineWidthInput/PIP/scaleModifier if killzoneOldStyleToggleInput lineset_y(kzLoLine1, killzoneHighPrice+(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzLoLine2, killzoneLowPrice-(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzNYLine1, killzoneHighPrice+(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzNYLine2, killzoneLowPrice-(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzLCLine1, killzoneHighPrice+(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzLCLine2, killzoneLowPrice-(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzAOLine1, killzoneHighPrice+(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzAOLine2, killzoneLowPrice-(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzNyLLine1, killzoneHighPrice+(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) lineset_y(kzNyLLine2, killzoneLowPrice-(killzoneHighPrice-killzoneLowPrice)/killzoneYoffsetInput) else box.set_top(kzLoBox1, kzUpperBoxTop) box.set_bottom(kzLoBox1, kzUpperBoxBottom) box.set_top(kzLoBox2, kzLowerBoxTop) box.set_bottom(kzLoBox2, kzLowerBoxBottom) box.set_top(kzNyBox1, kzUpperBoxTop) box.set_bottom(kzNyBox1, kzUpperBoxBottom) box.set_top(kzNyBox2, kzLowerBoxTop) box.set_bottom(kzNyBox2, kzLowerBoxBottom) box.set_top(kzLcBox1, kzUpperBoxTop) box.set_bottom(kzLcBox1, kzUpperBoxBottom) box.set_top(kzLcBox2, kzLowerBoxTop) box.set_bottom(kzLcBox2, kzLowerBoxBottom) box.set_top(kzAoBox1, kzUpperBoxTop) box.set_bottom(kzAoBox1, kzUpperBoxBottom) box.set_top(kzAoBox2, kzLowerBoxTop) box.set_bottom(kzAoBox2, kzLowerBoxBottom) box.set_top(kzNyLBox1, kzUpperBoxTop) box.set_bottom(kzNyLBox1, kzUpperBoxBottom) box.set_top(kzNyLBox2, kzLowerBoxTop) box.set_bottom(kzNyLBox2, kzLowerBoxBottom) //END Killzone lines} //{ ADR Table averageDailyRangeRounded = math.round(request.security(syminfo.tickerid, "1D", averageRange(high, low, adrLookbackInput)),1) //set average daily range for the past 'adrLookbackInput' number of days and round it [currentDailyLow, currentDailyHigh] = request.security(syminfo.tickerid, "1D", [low, high]) //get current daily high and low currentDailyRangeRounded = math.round(PIP*(currentDailyHigh-currentDailyLow),1) //set current daily range and round it if tableToggleInput tablePosition = tableLocInput == "Top Left" ? position.top_left : tableLocInput == "Bottom Left" ? position.bottom_left : tableLocInput == "Top Right" ? position.top_right : tableLocInput == "Top Center" ? position.top_center : tableLocInput == "Bottom Center" ? position.bottom_center : position.bottom_right adrTable = table.new(tablePosition, tableOrientationInput == "Vertical" ? 2 : 4, tableOrientationInput == "Vertical" ? 4 : 1, tableBgInput, border_width = 1) bgBrightness = getBrightness(tableBgInput) //color staticTextColor = bgBrightness > 130 ? color.black : color.white color staticTextColor = blackOrWhiteText(tableBgInput) color dynamicGreen = staticTextColor color dynamicRed = staticTextColor color dynamicOrange = staticTextColor color currentDailyRangeColor = staticTextColor if tableDynamicTextInputToggle dynamicGreen := bgBrightness > 130 ? color.green : color.rgb(0, 255, 0) dynamicRed := bgBrightness > 130 ? color.rgb(155, 0, 0) : color.rgb(255, 0, 0) dynamicOrange := bgBrightness > 130 ? color.rgb(255, 152, 0) : color.rgb(255, 200, 0) currentDailyRangeColor := currentDailyRangeRounded/averageDailyRangeRounded < 0.5 ? dynamicGreen : currentDailyRangeRounded/averageDailyRangeRounded < 1.0 ? dynamicOrange : dynamicRed if tableOrientationInput == "Vertical" and barstate.islast table.cell(adrTable, 0, 0, str.tostring(adrLookbackInput) + "ADR:", text_color=staticTextColor, text_halign = text.align_right, text_size=size.small) table.cell(adrTable, 1, 0, str.tostring(averageDailyRangeRounded), text_color=staticTextColor, text_halign = text.align_left, text_size=size.small) table.cell(adrTable, 0, 1, "CDR:", text_color=currentDailyRangeColor, text_halign = text.align_right, text_size=size.small) table.cell(adrTable, 1, 1, str.tostring(currentDailyRangeRounded), text_color=currentDailyRangeColor, text_halign = text.align_left, text_size=size.small) table.cell(adrTable, 0, 2, "CBDR:", text_color=cbdrRange <= 40 ? dynamicGreen : dynamicRed, text_halign = text.align_right, text_size=size.small) table.cell(adrTable, 1, 2, str.tostring(cbdrRange), text_color=cbdrRange <= 40 ? dynamicGreen : dynamicRed, text_halign = text.align_left, text_size=size.small) table.cell(adrTable, 0, 3, "AR:", text_color=asiaRange <= 40 ? dynamicGreen : dynamicRed, text_halign = text.align_right, text_size=size.small) table.cell(adrTable, 1, 3, asiaRange == 0.0 ? "n/a" : str.tostring(asiaRange), text_color=asiaRange <= 40 ? dynamicGreen : dynamicRed, text_halign = text.align_left, text_size=size.small) else if barstate.islast table.cell(adrTable, 0, 0, str.tostring(adrLookbackInput) + "ADR: " + str.tostring(averageDailyRangeRounded), text_color=staticTextColor, text_halign = text.align_right, text_size=size.small) table.cell(adrTable, 1, 0, "CDR: " + str.tostring(currentDailyRangeRounded), text_color=currentDailyRangeColor, text_halign = text.align_right, text_size=size.small) table.cell(adrTable, 2, 0, "CBDR: " + str.tostring(cbdrRange), text_color=cbdrRange <= 40 ? dynamicGreen : dynamicRed, text_halign = text.align_right, text_size=size.small) table.cell(adrTable, 3, 0, "AR: " + (asiaRange == 0.0 ? "n/a" : str.tostring(asiaRange)), text_color=asiaRange <= 40 ? dynamicGreen : dynamicRed, text_halign = text.align_right, text_size=size.small) //END ADR Table } //{ Plot Weekdays weekdaysShortFormat = weekdayCondition and weekdaysShortFormatToggleInput plotshape(weekdaysShortFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.monday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Mon", offset=weekdayOffset) plotshape(weekdaysShortFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.tuesday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Tue", offset=weekdayOffset) plotshape(weekdaysShortFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.wednesday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Wed", offset=weekdayOffset) plotshape(weekdaysShortFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.thursday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Thu", offset=weekdayOffset) plotshape(weekdaysShortFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.friday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Fri/Sun", offset=weekdayOffset) plotshape(weekdaysShortFormat and hour == 19 and minute == 30 and dayofweek == dayofweek.sunday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Sun", offset=weekdayOffset) weekdaysLongFormat = weekdayCondition and not weekdaysShortFormatToggleInput plotshape(weekdaysLongFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.monday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Monday", offset=weekdayOffset) plotshape(weekdaysLongFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.tuesday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Tuesday", offset=weekdayOffset) plotshape(weekdaysLongFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.wednesday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Wednesday", offset=weekdayOffset) plotshape(weekdaysLongFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.thursday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Thursday", offset=weekdayOffset) plotshape(weekdaysLongFormat and hour == 12 and minute == 0 and dayofweek == dayofweek.friday, "", color=invisible, textcolor=weekdaysColorInput, location=weekdaysLocation, text="Friday/Sunday", offset=weekdayOffset) // END Plot Weekdays } //{ DEBUGGING //debugTable = table.new(position.bottom_center, 1, 1, tableBgInput, border_width = 1) //debugText = str.tostring(killzoneLineWidthInput/PIP) + " pip:" + str.tostring(PIP) + " dec: " + str.tostring(DECIMALS) //table.cell(debugTable, 0, 0, debugText, text_halign = text.align_left) //}
Custom Candle Body Width
https://www.tradingview.com/script/dS5sYgCs-Custom-Candle-Body-Width/
a_dema
https://www.tradingview.com/u/a_dema/
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/ // Β© a_dema //@version=5 indicator(title="Custom Candle Body Width", shorttitle="CCBW", overlay=true, max_lines_count=500) candleBodyColor_Up = input.color(defval=color.new(color.green, 0), title="Color Up", group="Candle Body", inline="010") candleBodyColor_Dn = input.color(defval=color.new(color.red, 0), title="Down", group="Candle Body", inline="010") candleBodyWidth = input.int(defval=6, title="Fixed Width (pixels)", minval=1, maxval=500, group="Candle Body", inline="020") mintickRangeDivisor = input.int(defval=10, title="Minimum tick division", minval=1 , tooltip="Without this, the candle bodies for same open/close candles do not display at all.\n\nIf a symbol moves in 0.01 ticks, and a 10 value is specified here, this will plot a 0.001 range body." , group="Candle Body", inline="040") barCount = input.int(defval=100, title="Bar Count (1-500)", minval=1, maxval=500, group="Range/Scope" , tooltip="The number of bars this indicator will apply to.\n\nThe more bars, the more processing this indicator needs to do. Size appropriately." , inline="060") candleBodyColor_Other = input.bool(defval=false, title="Enabled?" , tooltip="In lieu of no TV function to read the current bar color, this indicator can reference another indicator's color value (if implemented).\n\nRefer to sample code in comments. Very similar code to that of barcolor()." , group="Source Body Color From Other Indicator", inline="070") candleBodyColor_Source = input.source(defval=close, title="Source" , tooltip="Referenced plot must be in RGBT format (3 digits each, 0-padded)\n\nFor example fuchsia @ 75% transparency would be 224064251075.\n\nRefer to sample code in comments." , group="Source Body Color From Other Indicator", inline="080") barcolor(color=bar_index > last_bar_index - barCount ? color.new(color.white, 100) : na, display=display.all) // ***************************************************************************************************** // Sample code to generate a float series for the RGBT value, and plot to data-window-only (not visible on chart) // Copy/paste the below into the other indicator, uncomment (obviously!), and adjust as needed // // Populate color series with up/down bar logic // color barcolor_series = close >= open ? color.new(color.fuchsia, 77) : color.new(color.orange, 88) // // Build string of RGBT values (3 digits each, 0-padded) and convert to float // float barcolor_rgbt = str.tonumber(str.tostring(color.r(barcolor_series), "000") // + str.tostring(color.g(barcolor_series), "000") // + str.tostring(color.b(barcolor_series), "000") // + str.tostring(color.t(barcolor_series), "000")) // plot(barcolor_rgbt, title="Barcolor RGBT", display=display.data_window) // ***************************************************************************************************** int rgb_t = na int rgb_b = na int rgb_g = na int rgb_r = na if candleBodyColor_Other rgb_t := int( ( candleBodyColor_Source/1000 - int(candleBodyColor_Source/1000) ) * 1000) rgb_b := int( ( candleBodyColor_Source/1000000 - int(candleBodyColor_Source/1000000) ) * 1000) rgb_g := int( ( candleBodyColor_Source/1000000000 - int(candleBodyColor_Source/1000000000) ) * 1000) rgb_r := int( ( candleBodyColor_Source/1000000000000 - int(candleBodyColor_Source/1000000000000) ) * 1000) if bar_index > last_bar_index - barCount line.new(x1=time , y1=close == open ? open - syminfo.mintick / mintickRangeDivisor : open , x2=time , y2=close == open ? close + syminfo.mintick / mintickRangeDivisor : close , xloc=xloc.bar_time , extend=extend.none , color=candleBodyColor_Other == false ? close >= open ? candleBodyColor_Up : candleBodyColor_Dn : color.rgb(rgb_r, rgb_g, rgb_b, rgb_t) , style=line.style_solid , width=candleBodyWidth) plot(candleBodyColor_Other ? candleBodyColor_Source : na, display=display.data_window)
Democratic Fibonacci Moving Averages
https://www.tradingview.com/script/WZE4w91h-Democratic-Fibonacci-Moving-Averages/
LeafAlgo
https://www.tradingview.com/u/LeafAlgo/
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/ // Β© LeafAlgo //@version=5 indicator("Democratic Fibonacci MAs", overlay=true) src = input.source(ohlc4, 'Source') // Fib MA cfib_ma_3 = ta.ema(src, 3) plot(cfib_ma_3, title='Fib. MA (3)', color=color.white, linewidth=2) cfib_ma_5 = ta.ema(src, 5) plot(cfib_ma_5, title='Fib. MA (5)') cfib_ma_8 = ta.ema(src, 8) plot(cfib_ma_8, title='Fib. MA (8)') cfib_ma_13 = ta.ema(src, 13) plot(cfib_ma_13, title='Fib. MA (13)') cfib_ma_21 = ta.ema(src, 21) plot(cfib_ma_21, title='Fib. MA (21)') cfib_ma_34 = ta.ema(src, 34) plot(cfib_ma_34, title='Fib. MA (34)') cfib_ma_55 = ta.ema(src, 55) plot(cfib_ma_55, title='Fib. MA (55)') cfib_ma_89 = ta.ema(src, 89) plot(cfib_ma_89, title='Fib. MA (89)') cfib_ma_144 = ta.ema(src, 144) plot(cfib_ma_144, title='Fib. MA (144)') cfib_ma_233 = ta.ema(src, 233) plot(cfib_ma_233, title='Fib. MA (233)', color=color.white, linewidth=2) fib_ohlc4 = (cfib_ma_3 + cfib_ma_5 + cfib_ma_8 + cfib_ma_13 + cfib_ma_21 + cfib_ma_34 + cfib_ma_55 + cfib_ma_89 + cfib_ma_144 + cfib_ma_233) / 10 plot(fib_ohlc4, 'DFMA', color=(fib_ohlc4 > cfib_ma_233) ? color.lime : color.red, linewidth=4) var string GP2 = 'Display' string tableYposInput = input.string("bottom", "Panel position", inline = "11", options = ["top", "middle", "bottom"], group = GP2) string tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"], group = GP2) color bullColorInput = input.color(color.new(color.green, 20), "Bull", inline = "12", group = GP2) color bearColorInput = input.color(color.new(color.red, 20), "Bear", inline = "12", group = GP2) color neutColorInput = input.color(color.new(color.gray, 20), "Neutral", inline = "12", group = GP2) var table panel = table.new(tableYposInput + "_" + tableXposInput, 2, 12) if barstate.islast table.cell(panel, 0, 0, 'Fib. Number', bgcolor = neutColorInput, text_color = color.black) table.cell(panel, 1, 0, 'MA Value', bgcolor = neutColorInput, text_color = color.black) bgc1 = close > cfib_ma_3 ? open < cfib_ma_3 ? neutColorInput : bullColorInput : open > cfib_ma_3 ? neutColorInput : bearColorInput table.cell(panel, 0, 1, str.tostring(3), bgcolor = bgc1, text_color = color.black) table.cell(panel, 1, 1, str.tostring(cfib_ma_3, format.mintick), bgcolor = bgc1, text_color = color.black) bgc2 = close > cfib_ma_5 ? open < cfib_ma_5 ? neutColorInput : bullColorInput : open > cfib_ma_5 ? neutColorInput : bearColorInput table.cell(panel, 0, 2, str.tostring(5), bgcolor = bgc2, text_color = color.black) table.cell(panel, 1, 2, str.tostring(cfib_ma_5, format.mintick), bgcolor = bgc2, text_color = color.black) bgc3 = close > cfib_ma_8 ? open < cfib_ma_8 ? neutColorInput : bullColorInput : open > cfib_ma_8 ? neutColorInput : bearColorInput table.cell(panel, 0, 3, str.tostring(8), bgcolor = bgc3, text_color = color.black) table.cell(panel, 1, 3, str.tostring(cfib_ma_8, format.mintick), bgcolor = bgc3, text_color = color.black) bgc4 = close > cfib_ma_13 ? open < cfib_ma_13 ? neutColorInput : bullColorInput : open > cfib_ma_13 ? neutColorInput : bearColorInput table.cell(panel, 0, 4, str.tostring(13), bgcolor = bgc4, text_color = color.black) table.cell(panel, 1, 4, str.tostring(cfib_ma_13, format.mintick), bgcolor = bgc4, text_color = color.black) bgc5 = close > cfib_ma_21 ? open < cfib_ma_21 ? neutColorInput : bullColorInput : open > cfib_ma_21 ? neutColorInput : bearColorInput table.cell(panel, 0, 5, str.tostring(21), bgcolor = bgc5, text_color = color.black) table.cell(panel, 1, 5, str.tostring(cfib_ma_21, format.mintick), bgcolor = bgc5, text_color = color.black) bgc6 = close > cfib_ma_34 ? open < cfib_ma_34 ? neutColorInput : bullColorInput : open > cfib_ma_34 ? neutColorInput : bearColorInput table.cell(panel, 0, 6, str.tostring(34), bgcolor = bgc6, text_color = color.black) table.cell(panel, 1, 6, str.tostring(cfib_ma_34, format.mintick), bgcolor = bgc6, text_color = color.black) bgc7 = close > cfib_ma_55 ? open < cfib_ma_55 ? neutColorInput : bullColorInput : open > cfib_ma_55 ? neutColorInput : bearColorInput table.cell(panel, 0, 7, str.tostring(55), bgcolor = bgc7, text_color = color.black) table.cell(panel, 1, 7, str.tostring(cfib_ma_55, format.mintick), bgcolor = bgc7, text_color = color.black) bgc8 = close > cfib_ma_89 ? open < cfib_ma_89 ? neutColorInput : bullColorInput : open > cfib_ma_89 ? neutColorInput : bearColorInput table.cell(panel, 0, 8, str.tostring(89), bgcolor = bgc8, text_color = color.black) table.cell(panel, 1, 8, str.tostring(cfib_ma_89, format.mintick), bgcolor = bgc8, text_color = color.black) bgc9 = close > cfib_ma_144 ? open < cfib_ma_144 ? neutColorInput : bullColorInput : open > cfib_ma_144 ? neutColorInput : bearColorInput table.cell(panel, 0, 9, str.tostring(144), bgcolor = bgc9, text_color = color.black) table.cell(panel, 1, 9, str.tostring(cfib_ma_144, format.mintick), bgcolor = bgc9, text_color = color.black) bgc10 = close > cfib_ma_233 ? open < cfib_ma_233 ? neutColorInput : bullColorInput : open > cfib_ma_233 ? neutColorInput : bearColorInput table.cell(panel, 0, 10, str.tostring(233), bgcolor = bgc10, text_color = color.black) table.cell(panel, 1, 10, str.tostring(cfib_ma_233, format.mintick), bgcolor = bgc10, text_color = color.black) bgc11 = close > fib_ohlc4 ? open < fib_ohlc4 ? neutColorInput : bullColorInput : open > fib_ohlc4 ? neutColorInput : bearColorInput table.cell(panel, 0, 11, 'DFMA', bgcolor = bgc11, text_color = color.black) table.cell(panel, 1, 11, str.tostring(fib_ohlc4, format.mintick), bgcolor = bgc11, text_color = color.black)
Dynamic Highest Lowest Moving Average
https://www.tradingview.com/script/MHOCeh2K-Dynamic-Highest-Lowest-Moving-Average/
EsIstTurnt
https://www.tradingview.com/u/EsIstTurnt/
24
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© EsIstTurnt //@version=5 indicator("Dynamic Highest Lowest Moving Average",shorttitle='DHLMA',overlay=true) import TradingView/ta/4 as m /////////////Beginning, Get Inputs string high_oscillator = input.string("Decline", "HH's Length Curve Shape (< > <> ><)", options = ["Incline", "Decline", "Peak", "Trough"]) string low_oscillator = input.string("Decline", "LL's Length Curve Shape (< > <> ><)", options = ["Incline", "Decline", "Peak", "Trough"]) string curve = input.string("LRC", "Output Average Type ", options = ["EMA","WMA","LRC","DEMA","TEMA","TRIMA","FRAMA","NONE"]) var float mult = input.float (0.236,'Length Multiplier') var bool avg_include_price = input.bool(false,'Include Price in the Averaging of the Highest/Lowest ') var int included_price_offset = input.int(0,'Offset of the Price to Include in Averaging') var int smoothlen = input.int(12,'Smooth Length') var int ratiolen = input.int(12,'RSI of Ratio Length') var int min = input.int(16 ,'Minimum length ',maxval = 16,minval = 4) var int maxHigh = input.int(128,'Maximum HH length ',maxval = 1024,minval = 32) var int maxLow = input.int(128,'Maximum LL length ',maxval = 1024,minval = 32) var int coefHigh = input.int(40) var int coefLow = input.int(40) var int hlen = maxHigh var int llen = maxLow //Logic Selection, (<) (>) (<>) (><) x1 =high_oscillator == "Incline"? 1 :high_oscillator == "Decline"?20:high_oscillator == "Peak"?1 :high_oscillator == "Trough"?10:na x2 =high_oscillator == "Incline"? 2 :high_oscillator == "Decline"?19:high_oscillator == "Peak"?2 :high_oscillator == "Trough"?9 :na x3 =high_oscillator == "Incline"? 3 :high_oscillator == "Decline"?18:high_oscillator == "Peak"?3 :high_oscillator == "Trough"?8 :na x4 =high_oscillator == "Incline"? 4 :high_oscillator == "Decline"?17:high_oscillator == "Peak"?4 :high_oscillator == "Trough"?7 :na x5 =high_oscillator == "Incline"? 5 :high_oscillator == "Decline"?16:high_oscillator == "Peak"?5 :high_oscillator == "Trough"?6 :na x6 =high_oscillator == "Incline"? 6 :high_oscillator == "Decline"?15:high_oscillator == "Peak"?6 :high_oscillator == "Trough"?5 :na x7 =high_oscillator == "Incline"? 7 :high_oscillator == "Decline"?14:high_oscillator == "Peak"?7 :high_oscillator == "Trough"?4 :na x8 =high_oscillator == "Incline"? 8 :high_oscillator == "Decline"?13:high_oscillator == "Peak"?8 :high_oscillator == "Trough"?3 :na x9 =high_oscillator == "Incline"? 9 :high_oscillator == "Decline"?12:high_oscillator == "Peak"?9 :high_oscillator == "Trough"?2 :na x10 =high_oscillator == "Incline"? 10 :high_oscillator == "Decline"?11:high_oscillator == "Peak"?10:high_oscillator == "Trough"?1 :na x11 =high_oscillator == "Incline"? 11 :high_oscillator == "Decline"?10:high_oscillator == "Peak"?10:high_oscillator == "Trough"?1 :na x12 =high_oscillator == "Incline"? 12 :high_oscillator == "Decline"? 9:high_oscillator == "Peak"?9 :high_oscillator == "Trough"?2 :na x13 =high_oscillator == "Incline"? 13 :high_oscillator == "Decline"? 8:high_oscillator == "Peak"?8 :high_oscillator == "Trough"?3 :na x14 =high_oscillator == "Incline"? 14 :high_oscillator == "Decline"? 7:high_oscillator == "Peak"?7 :high_oscillator == "Trough"?4 :na x15 =high_oscillator == "Incline"? 15 :high_oscillator == "Decline"? 6:high_oscillator == "Peak"?6 :high_oscillator == "Trough"?5 :na x16 =high_oscillator == "Incline"? 16 :high_oscillator == "Decline"? 5:high_oscillator == "Peak"?5 :high_oscillator == "Trough"?6 :na x17 =high_oscillator == "Incline"? 17 :high_oscillator == "Decline"? 4:high_oscillator == "Peak"?4 :high_oscillator == "Trough"?7 :na x18 =high_oscillator == "Incline"? 18 :high_oscillator == "Decline"? 3:high_oscillator == "Peak"?3 :high_oscillator == "Trough"?8 :na x19 =high_oscillator == "Incline"? 19 :high_oscillator == "Decline"? 2:high_oscillator == "Peak"?2 :high_oscillator == "Trough"?9 :na x20 =high_oscillator == "Incline"? 20 :high_oscillator == "Decline"? 1:high_oscillator == "Peak"?1 :high_oscillator == "Trough"?10:na y1 =low_oscillator == "Incline"? 1 :low_oscillator == "Decline"?20:low_oscillator == "Peak"?1 :low_oscillator == "Trough"?10:na y2 =low_oscillator == "Incline"? 2 :low_oscillator == "Decline"?19:low_oscillator == "Peak"?2 :low_oscillator == "Trough"?9 :na y3 =low_oscillator == "Incline"? 3 :low_oscillator == "Decline"?18:low_oscillator == "Peak"?3 :low_oscillator == "Trough"?8 :na y4 =low_oscillator == "Incline"? 4 :low_oscillator == "Decline"?17:low_oscillator == "Peak"?4 :low_oscillator == "Trough"?7 :na y5 =low_oscillator == "Incline"? 5 :low_oscillator == "Decline"?16:low_oscillator == "Peak"?5 :low_oscillator == "Trough"?6 :na y6 =low_oscillator == "Incline"? 6 :low_oscillator == "Decline"?15:low_oscillator == "Peak"?6 :low_oscillator == "Trough"?5 :na y7 =low_oscillator == "Incline"? 7 :low_oscillator == "Decline"?14:low_oscillator == "Peak"?7 :low_oscillator == "Trough"?4 :na y8 =low_oscillator == "Incline"? 8 :low_oscillator == "Decline"?13:low_oscillator == "Peak"?8 :low_oscillator == "Trough"?3 :na y9 =low_oscillator == "Incline"? 9 :low_oscillator == "Decline"?12:low_oscillator == "Peak"?9 :low_oscillator == "Trough"?2 :na y10 =low_oscillator == "Incline"? 10 :low_oscillator == "Decline"?11:low_oscillator == "Peak"?10:low_oscillator == "Trough"?1 :na y11 =low_oscillator == "Incline"? 11 :low_oscillator == "Decline"?10:low_oscillator == "Peak"?10:low_oscillator == "Trough"?1 :na y12 =low_oscillator == "Incline"? 12 :low_oscillator == "Decline"? 9:low_oscillator == "Peak"?9 :low_oscillator == "Trough"?2 :na y13 =low_oscillator == "Incline"? 13 :low_oscillator == "Decline"? 8:low_oscillator == "Peak"?8 :low_oscillator == "Trough"?3 :na y14 =low_oscillator == "Incline"? 14 :low_oscillator == "Decline"? 7:low_oscillator == "Peak"?7 :low_oscillator == "Trough"?4 :na y15 =low_oscillator == "Incline"? 15 :low_oscillator == "Decline"? 6:low_oscillator == "Peak"?6 :low_oscillator == "Trough"?5 :na y16 =low_oscillator == "Incline"? 16 :low_oscillator == "Decline"? 5:low_oscillator == "Peak"?5 :low_oscillator == "Trough"?6 :na y17 =low_oscillator == "Incline"? 17 :low_oscillator == "Decline"? 4:low_oscillator == "Peak"?4 :low_oscillator == "Trough"?7 :na y18 =low_oscillator == "Incline"? 18 :low_oscillator == "Decline"? 3:low_oscillator == "Peak"?3 :low_oscillator == "Trough"?8 :na y19 =low_oscillator == "Incline"? 19 :low_oscillator == "Decline"? 2:low_oscillator == "Peak"?2 :low_oscillator == "Trough"?9 :na y20 =low_oscillator == "Incline"? 20 :low_oscillator == "Decline"? 1:low_oscillator == "Peak"?1 :low_oscillator == "Trough"?10:na //Get Distance from current price to highest high and lowest low, using the maximum length input difh=ta.highest(high,maxHigh) - close difl=close - ta.lowest(low,maxLow) //Then get the RSI value of the the ratio for each ratio1=ta.rsi(difh/difl,ratiolen) ratio2=ta.rsi(difl/difh,ratiolen) //Get the difference of the max high/low lengths and the minimum length, divide by the coefficient to get how far apart each step will be rangeh=(maxHigh-min) / coefHigh rangel=(maxLow-min) / coefLow // Set the length variables according to the value of the ratios. From the Maximum subtract the c hlen:=math.round(math.max(ratio2<=30?min :ratio2<=32?maxHigh-((x1 /mult)*rangeh) :ratio2<=34?maxHigh-((x2 /mult)*rangeh) :ratio2<=36?maxHigh-((x3 /mult)*rangeh) :ratio2<=38?maxHigh-((x4 /mult)*rangeh) :ratio2<=40?maxHigh-((x5 /mult)*rangeh) :ratio2<=42?maxHigh-((x6 /mult)*rangeh) :ratio2<=44?maxHigh-((x7 /mult)*rangeh) :ratio2<=46?maxHigh-((x8 /mult)*rangeh) :ratio2<=48?maxHigh-((x9 /mult)*rangeh) :ratio2<=50?maxHigh-((x10/mult)*rangeh) :ratio2<=52?maxHigh-((x11/mult)*rangeh) :ratio2<=54?maxHigh-((x12/mult)*rangeh) :ratio2<=56?maxHigh-((x13/mult)*rangeh) :ratio2<=58?maxHigh-((x14/mult)*rangeh) :ratio2<=60?maxHigh-((x15/mult)*rangeh) :ratio2<=62?maxHigh-((x16/mult)*rangeh) :ratio2<=64?maxHigh-((x17/mult)*rangeh) :ratio2<=66?maxHigh-((x18/mult)*rangeh) :ratio2<=68?maxHigh-((x19/mult)*rangeh) :ratio2<=70?maxHigh-((x20/mult)*rangeh) :maxHigh,min)) llen:=math.round(math.max(ratio1<=30?min :ratio1<=32?maxLow-((y1 /mult)*rangel) :ratio1<=34?maxLow-((y2 /mult)*rangel) :ratio1<=36?maxLow-((y3 /mult)*rangel) :ratio1<=38?maxLow-((y4 /mult)*rangel) :ratio1<=40?maxLow-((y5 /mult)*rangel) :ratio1<=42?maxLow-((y6 /mult)*rangel) :ratio1<=44?maxLow-((y7 /mult)*rangel) :ratio1<=46?maxLow-((y8 /mult)*rangel) :ratio1<=48?maxLow-((y9 /mult)*rangel) :ratio1<=50?maxLow-((y10/mult)*rangel) :ratio1<=52?maxLow-((y11/mult)*rangel) :ratio1<=54?maxLow-((y12/mult)*rangel) :ratio1<=56?maxLow-((y13/mult)*rangel) :ratio1<=58?maxLow-((y14/mult)*rangel) :ratio1<=60?maxLow-((y15/mult)*rangel) :ratio1<=62?maxLow-((y16/mult)*rangel) :ratio1<=64?maxLow-((y17/mult)*rangel) :ratio1<=66?maxLow-((y18/mult)*rangel) :ratio1<=68?maxLow-((y19/mult)*rangel) :ratio1<=70?maxLow-((y20/mult)*rangel) :maxLow,min)) //Now, Average the highest high and lowest low using their respective dynamic lengths from above. Then get a SWMA of the LRC of the value. (basically a base level of smoothing) hl=avg_include_price?ta.swma(ta.linreg(math.avg(ta.highest(high,hlen),ta.lowest(low,llen),hl2[included_price_offset]),math.round(math.avg(hlen,llen)),0)):ta.swma(ta.linreg(math.avg(ta.highest(high,hlen),ta.lowest(low,llen)),math.round(math.avg(hlen,llen)),0)) ////Final Filter using moving averages that allow the use of dynamic lengths float avg = switch curve 'LRC' => ta.ema(ta.linreg (hl,math.round(math.avg(hlen,llen)),0),smoothlen) "EMA" => ta.ema(m.ema2 (hl,math.round(math.avg(hlen,llen))),smoothlen) 'WMA' => ta.ema(ta.wma (hl,math.round(math.avg(hlen,llen))),smoothlen) 'DEMA' => ta.ema(m.dema2 (hl,math.round(math.avg(hlen,llen))),smoothlen) 'TEMA' => ta.ema(m.tema2 (hl,math.round(math.avg(hlen,llen))),smoothlen) 'TRIMA' => ta.ema(m.trima2 (hl,math.round(math.avg(hlen,llen))),smoothlen) 'FRAMA' => ta.ema(m.frama (hl,math.round(math.avg(hlen,llen))),smoothlen) 'NONE' => ta.ema(hl,smoothlen) // Default used when the three first cases do not match. => ta.ema(ta.linreg(hl,math.round(math.avg(hlen,llen)),0),smoothlen) //Plot it! plot(avg) //plot(hl)
BTC Indicator By Megalodon Trading
https://www.tradingview.com/script/4GOuUVBR-BTC-Indicator-By-Megalodon-Trading/
MegalodonTrading
https://www.tradingview.com/u/MegalodonTrading/
2,096
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/ // Β© MegalodonTrading //@version=4 study("BTC Indicator By Megalodon Trading", max_bars_back=366, overlay=false) buy_below = input(defval = -61.8 , title = "Buy Below Initial Trigger", minval = -100, maxval = 100) sell_above = input(defval = -38.2 , title = "Sell Above Initial Trigger", minval = -100, maxval = 100) calculate_fib()=> fib_price_close = nz(close) fib_gradual_increase_sum = 0.0 fib_average_count = 0 fib_price_high = nz(high) fib_price_low = nz(low) fib_counter_for_reduction_of_total_value1=0.0 return_fib = 0.0 fib_value_color_increase_sum = 0.0 fib_gradual_increase_average_total = 0.0 for i=365 to 7 //Going in term of every 7 days starting at 30 days look back to fib_lookback_days = (i-1) if(fib_lookback_days<bar_index) fib_average_count := fib_average_count + 1 fib_maximum = highest(fib_price_high, fib_lookback_days) fib_minumum = lowest(fib_price_low,fib_lookback_days) max_min_difference = fib_maximum - fib_minumum fib_price_of_sell_618 = (fib_maximum - (max_min_difference * 0.382)) fib_price_of_buy_618 = (fib_maximum - (max_min_difference * 0.618)) fib_value = fib_price_close >= ( fib_maximum - (0.382) * max_min_difference) ? 1 : fib_price_close <= ( fib_maximum - (0.618/100) * max_min_difference) ? -1 : 0 //+ if in the sell zone -if in the buy zone fib_gradual_increase_average = fib_value == 1 ?(((((fib_price_close - fib_price_of_sell_618 ) / max_min_difference * 100 ) * 2617.801) + 100000) / 2) : fib_value == -1 ? (((((fib_price_of_buy_618 - fib_price_close) / max_min_difference * 100) * -2617.801) + 100000) / 2) : 50000 fib_gradual_increase_sum := fib_gradual_increase_sum + fib_gradual_increase_average fib_average_total = fib_gradual_increase_sum / (fib_average_count* 1000) fib_new = (100 - fib_average_total) * -1 total_daily = security(syminfo.tickerid,"", calculate_fib()) color_new = total_daily <= buy_below ? color.new(color.green,78) : total_daily >= sell_above ? color.new(color.red,78) : color.new(color.gray,100) plot(total_daily) bgcolor(color_new)
Liquidity Candles
https://www.tradingview.com/script/Uvv5kzQP-Liquidity-Candles/
UnknownUnicorn36161431
https://www.tradingview.com/u/UnknownUnicorn36161431/
350
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© zathruswriter //@version=5 indicator( "Liquidity Candles", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back = 4500 ) liq_line_color = input.color( color.black, "Liquidity Line", inline="liq" ) liq_line_style = input.string( line.style_solid, "", options = [ line.style_solid, line.style_dashed, line.style_dotted ], inline="liq" ) liq_line_width = input.int( 2, "", inline="liq" ) liq_color_by_type = input.bool( false, "Color liquidity lines by break type (red/green)" ) i_show_potentials = input.bool( false, "Mark Potential Breakout Candles" ) i_show_liq_labels = input.bool( false, "Show Liquidity Labels" ) size = input.float( 0.07, "Big Candle Minimum Size", minval = 0.01, step = 0.1, inline = "candlesize" ) percentage = input.bool( true, "Percentage", inline = "candlesize", tooltip = "In order to prevent calculating liquidity sweeps on very small candles, you can say how big a candle should be at least to consider it for the sweep calculation. This setting affects both, candles where a potential place for the sweep occurs (marked with red/green diamonds) and the candles where the sweep actually occurs (i.e. where the red/green sweep line ends)." ) min_pullback = input.float( 30, "Minimum Pullback %", step = 1, tooltip = "How much should a candle body retrace from its high point (green candles) or low point (red candles) in order to be considered for a liquidity sweep calculation." ) var pullback_type = "" var pullback_level = 0.0 var pullback_index = 0 transparentcolor = color.new( color.white, 100 ) s_( txt ) => str.tostring( txt ) f_debug_label( txt ) => label.new(bar_index, high, str.tostring( txt ), color = color.lime, textcolor = color.black) f_debug_label_down( txt ) => label.new(bar_index, low, str.tostring( txt ), color = color.lime, textcolor = color.black, style = label.style_label_up) // reset pullback level and type if we've closed above/below the pullback we are waiting for if ( pullback_type == "up" and ( close > pullback_level or open > pullback_level ) ) or ( pullback_type == "down" and ( close < pullback_level or open < pullback_level ) ) pullback_type := "" pullback_level := 0.0 pullback_index := 0 // check for liquidity sweep bearish_pullback = false bullish_pullback = false if barstate.isconfirmed and ( ( pullback_type == "up" and high > pullback_level and close <= pullback_level and open <= pullback_level ) or ( pullback_type == "down" and low < pullback_level and close >= pullback_level and open >= pullback_level ) ) line.new( pullback_index, pullback_level, bar_index, pullback_level, color = ( liq_color_by_type ? ( pullback_type == "up" ? color.red : color.green ) : liq_line_color ), style = liq_line_style, width = liq_line_width ) if i_show_liq_labels label.new( pullback_index, pullback_level, "X", color = transparentcolor, textcolor = ( liq_color_by_type ? ( pullback_type == "up" ? color.red : color.green ) : liq_line_color ), style = pullback_type == "up" ? label.style_label_down : label.style_label_up ) if pullback_type == "up" bearish_pullback := true else bullish_pullback := true // reset variables, since we already found a pullback pullback_type := "" pullback_level := 0.0 pullback_index := 0 show_up_shape = false show_down_shape = false candle_size = percentage ? close * size / 100 : size pullback_value = ( ( high - low ) / 100 ) * min_pullback if ( close > open and close < high - pullback_value and high - low >= candle_size ) or ( close < open and close > low + pullback_value and high - low >= candle_size ) if close > open pullback_type := "up" pullback_level := high pullback_index := bar_index show_up_shape := true else pullback_type := "down" pullback_level := low pullback_index := bar_index show_down_shape := true plotshape( show_up_shape and i_show_potentials ? show_up_shape : na, "Potential Liquidity Sweep Candle Up", shape.diamond, location.abovebar, color.red, size = size.tiny ) plotshape( show_down_shape and i_show_potentials ? show_down_shape : na, "Potential Liquidity Sweep Candle Down", shape.diamond, location.belowbar, color.green, size = size.tiny )
Profitunity - Beginner [TC]
https://www.tradingview.com/script/CMu4dGgs-Profitunity-Beginner-TC/
Skyrex
https://www.tradingview.com/u/Skyrex/
295
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© SkyRockSignals //@version=5 indicator("Profitunity - Beginner [TC]", overlay = true) //INPUTS show11and33 = input.string(defval = 'No', title ='Show (11) and (33) bars?', options = ['Yes', 'No']) show22 = input.string(defval = 'No', title ='Show (22) bars?', options = ['Yes', 'No']) show32and12 = input.string(defval = 'No', title ='Show (32) and (12) bars?', options = ['Yes', 'No']) show23and21 = input.string(defval = 'No', title ='Show (23) and (21) bars?', options = ['Yes', 'No']) show31and13 = input.string(defval = 'No', title ='Show (13) and (31) bars?', options = ['Yes', 'No']) //SHOW BARS TYPES doshow11and33 = show11and33 == 'Yes' ? true : false doshow22 = show22 == 'Yes' ? true : false doshow32and12 = show32and12 == 'Yes' ? true : false doshow23and21 = show23and21 == 'Yes' ? true : false doshow31and13 = show31and13 == 'Yes' ? true : false //BARS TYPE DEFINITION bar11 = close > high - (high - low)/3 and open > high - (high - low)/3 bar22 = close < high - (high - low)/3 and close > high - (2*(high - low))/3 and open < high - (high - low)/3 and open > high - (2*(high - low))/3 bar33 = close < high - (2*(high - low))/3 and open < high - 2*(high - low)/3 bar13 = open > high - (high - low)/3 and close < high - (2*(high - low))/3 bar31 = open < high - (2*(high - low))/3 and close > high - (high - low)/3 bar21 = open < high - (high - low)/3 and open > high - (2*(high - low))/3 and close > high - (high - low)/3 bar32 = open < high - (2*(high - low))/3 and close < high - (high - low)/3 and close > high - (2*(high - low))/3 bar23 = open < high - (high - low)/3 and open > high - (2*(high - low))/3 and close < high - (2*(high - low))/3 bar12 = open > high - (high - low)/3 and close < high - (high - low)/3 and close > high - (2*(high - low))/3 //TREND MARKERS downtrend_marker = (high + low)/2 < low[1] uptrend_marker = (high + low)/2 > high[1] //TOTAL VOLUME usdt_total_volume = nz(request.security("BINANCE:BTCUSDT", "D", volume))+nz(request.security("KUCOIN:BTCUSDT", "D", volume))+nz(request.security("BINGX:BTCUSDT", "D", volume))+nz(request.security("OKX:BTCUSDT", "D", volume))+nz(request.security("HUOBI:BTCUSDT", "D", volume))+nz(request.security("FTX:BTCUSDT", "D", volume/close))+nz(request.security("COINBASE:BTCUSDT", "D", volume))+nz(request.security("PHEMEX:BTCUSDT", "D", volume))+nz(request.security("BINANCEUS:BTCUSDT", "D", volume))+nz(request.security("BITGET:BTCUSDT", "D", volume))+nz(request.security("BITTREX:BTCUSDT", "D", volume))+nz(request.security("GATEIO:BTCUSDT", "D", volume))+nz(request.security("POLONIEX:BTCUSDT", "D", volume))+nz(request.security("MEXC:BTCUSDT", "D", volume))+nz(request.security("BITSTAMP:BTCUSDT", "D", volume))+nz(request.security("KRAKEN:BTCUSDT", "D", volume))+nz(request.security("OKCOIN:BTCUSDT", "D", volume))+nz(request.security("CURRENCYCOM:BTCUSDT", "D", volume))+nz(request.security("WHITEBIT:BTCUSDT", "D", volume))+nz(request.security("ASCENDEX:BTCUSDT", "D", volume))+nz(request.security("TIMEX:BTCUSDT", "D", volume))+nz(request.security("UPBIT:BTCUSDT", "D", volume))+nz(request.security("EXMO:BTCUSDT", "D", volume))+nz(request.security("DELTA:BTCUSDT", "D", volume))+nz(request.security("WOONETWORK:BTCUSDT", "D", volume)) usdc_total_volume = nz(request.security("BINANCE:BTCUSDC", "D", volume))+nz(request.security("KUCOIN:BTCUSDC", "D", volume))+nz(request.security("BITSTAMP:BTCUSDC", "D", volume))+nz(request.security("COINBASE:BTCUSDC", "D", volume))+nz(request.security("KRAKEN:BTCUSDC", "D", volume))+nz(request.security("POLONIEX:BTCUSDC", "D", volume))+nz(request.security("BITTREX:BTCUSDC", "D", volume))+nz(request.security("BINGX:BTCUSDC", "D", volume))+nz(request.security("OKX:BTCUSDC", "D", volume))+nz(request.security("HUOBI:BTCUSDC", "D", volume))+nz(request.security("PHEMEX:BTCUSDC", "D", volume))+nz(request.security("BINANCEUS:BTCUSDC", "D", volume))+nz(request.security("BITGET:BTCUSDC", "D", volume))+nz(request.security("WHITEBIT:BTCUSDC", "D", volume))+nz(request.security("WOONETWORK:BTCUSDC", "D", volume)) total_volume = usdt_total_volume + usdc_total_volume //MFI AND PROFITUNITY WINDOWS MFI = (high - low)/volume squat = MFI < MFI[1] and volume > volume[1] green = MFI > MFI[1] and volume > volume[1] fade = MFI < MFI[1] and volume < volume[1] fake = MFI > MFI[1] and volume < volume[1] //PLOT THE UPTREND BAR LABELS plotshape(uptrend_marker and doshow11and33 and bar11?true: na,text="11",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow22 and bar22?true: na,text="22",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow11and33 and bar33?true: na,text="33",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow31and13 and bar13?true: na,text="13",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow31and13 and bar31?true: na,text="31",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow23and21 and bar21?true: na,text="21",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow32and12 and bar32?true: na,text="32",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow23and21 and bar23?true: na,text="23",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(uptrend_marker and doshow32and12 and bar12?true: na,text="12",size=size.tiny,offset=0,color=color.green,textcolor=color.white,style=shape.labelup,location=location.belowbar) //PLOT THE DOWNTREND BAR LABELS plotshape(downtrend_marker and doshow11and33 and bar11?true: na,text="11",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow22 and bar22?true: na,text="22",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow11and33 and bar33?true: na,text="33",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow31and13 and bar13?true: na,text="13",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow31and13 and bar31?true: na,text="31",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow23and21 and bar21?true: na,text="21",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow32and12 and bar32?true: na,text="32",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow23and21 and bar23?true: na,text="23",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(downtrend_marker and doshow32and12 and bar12?true: na,text="12",size=size.tiny,offset=0,color=color.red,textcolor=color.white,style=shape.labelup,location=location.belowbar) //PLOT NO TREND BAR LABELS plotshape(not(uptrend_marker or downtrend_marker) and doshow11and33 and bar11?true: na,text="11",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow22 and bar22?true: na,text="22",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow11and33 and bar33?true: na,text="33",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow31and13 and bar13?true: na,text="13",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow31and13 and bar31?true: na,text="31",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow23and21 and bar21?true: na,text="21",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow32and12 and bar32?true: na,text="32",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow23and21 and bar23?true: na,text="23",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) plotshape(not(uptrend_marker or downtrend_marker) and doshow32and12 and bar12?true: na,text="12",size=size.tiny,offset=0,color=color.blue,textcolor=color.white,style=shape.labelup,location=location.belowbar) //BARS COLORING ACCORDING TO SQUAT, GREEN, FASE AND FAKE barcolor(green? color.green : na) barcolor(squat?color.red : na) //barcolor(fade?color.yellow: na) //barcolor(fake?color.blue: na) //SIGNALS plotshape(downtrend_marker and squat and bar13?true: na,text="STRONG LONG",size=size.tiny, offset=0,color=color.green,textcolor=color.green,style=shape.triangleup,location=location.belowbar) plotshape(uptrend_marker and squat and bar31?true: na,text="STRONG SHORT",size=size.tiny, offset=0,color=color.red,textcolor=color.red,style=shape.triangledown,location=location.abovebar) //plotshape(squat and bar11?true: na,text="LONG",size=size.tiny, offset=0,color=color.green,textcolor=color.green,style=shape.triangleup,location=location.belowbar) //plotshape(squat and bar33?true: na,text="SHORT",size=size.tiny, offset=0,color=color.red,textcolor=color.red,style=shape.triangledown,location=location.abovebar)
Divergence Strength Oscillator
https://www.tradingview.com/script/mZaka7ks-Divergence-Strength-Oscillator/
reees
https://www.tradingview.com/u/reees/
693
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© reees //@version=5 indicator("Divergence Strength Oscillator","DivStrOsc",max_bars_back=500) import reees/TA/69 as t import reees/Utilities/4 as u //----------------------------------------- // inputs //----------------------------------------- var ppLength = input.int(4,"Previous pivot bars before/after",minval=1,group="Divergence Params",tooltip="Min # bars before and after a previous pivot high/low to consider it valid for divergence check") var cpLengthBefore = input.int(4,"Next (divergent) pivot bars before",minval=1,group="Divergence Params",tooltip="Min # leading bars before the next (divergent) pivot high/low to consider it valid for divergence check") var cpLengthAfter=0 var lbBars = input.int(50,"Lookback bars",minval=1,maxval=100,group="Divergence Params",inline="lb") var lbPivs = input.int(2,"Lookback pivots",minval=1,group="Divergence Params",inline="lb",tooltip="# of bars or # of pivot highs/lows to look back across, whichever comes first") var w_reg = input.float(1.0,"Regular divergence weight",step=.1,minval=0.0,group="Divergence Params",inline="degreg") var w_hid = input.float(1.0,"Hidden divergence weight",step=.1,minval=0.0,group="Divergence Params",inline="degreg",tooltip="Value/weight of regular divergence versus hidden divergence (applies to all indicators)") var w_p = input.float(0.5,"Ξ” price weight",step=.1,minval=0.0,group="Divergence Params",inline="degprice") var w_i = input.float(1.5,"Ξ” indicator weight",step=.1,minval=0.0,group="Divergence Params",inline="degprice",tooltip="Value/weight of change in price versus change in indicator value (applies to all indicators)") bullPsource = input.source(low,"Bullish divergence price source",group="Divergence Params",tooltip="Used for indicators only when appropriate. If the selected source is not technically feasible or otherwise offends the spirit of an indicator, the indicator's natural source will be used instead.") bearPsource = input.source(high,"Bearish divergence price source",group="Divergence Params",tooltip="Used for indicators only when appropriate. If the selected source is not technically feasible or otherwise offends the spirit of an indicator, the indicator's natural source will be used instead.") // var iRsi = input.bool(true,"RSI", group="Indicator", inline="ind_rsi") var w_rsi = input.float(1.1,"Weight",step=.1,minval=0.0,group="Indicator",inline="ind_rsi",tooltip="Relative Strength Index (RSI)\n\nWeight: Weight of RSI divergence in total divergence strength calculation.") var iObv = input.bool(true,"OBV", group="Indicator", inline="ind_obv") var w_obv = input.float(0.8,"Weight",step=.1,minval=0.0,group="Indicator",inline="ind_obv",tooltip="On Balance Volume (OBV)\n\nWeight: Weight of OBV divergence in total divergence strength calculation.") var iMacd = input.bool(true,"MACD", group="Indicator", inline="ind_macd") var w_macd = input.float(.9,"Weight",step=.1,minval=0.0,group="Indicator",inline="ind_macd",tooltip="Moving Average Convergence/Divergence (MACD)\n\nWeight: Weight of MACD divergence in total divergence strength calculation.") var iStoch = input.bool(true,"STOCH", group="Indicator", inline="ind_stoch") var w_stoch = input.float(0.9,"Weight",step=.1,minval=0.0,group="Indicator",inline="ind_stoch",tooltip="Stochastic (STOCH)\n\nWeight: Weight of STOCH divergence in total divergence strength calculation.") var iCci = input.bool(true,"CCI", group="Indicator", inline="ind_cci") var w_cci = input.float(1.0,"Weight",step=.1,minval=0.0,group="Indicator",inline="ind_cci",tooltip="Commodity Channel Index (CCI)\n\nWeight: Weight of CCI divergence in total divergence strength calculation.") var iMfi = input.bool(true,"MFI", group="Indicator", inline="ind_mfi") var w_mfi = input.float(1.0,"Weight",step=.1,minval=0.0,group="Indicator",inline="ind_mfi",tooltip="Money Flow Index (MFI)\n\nWeight: Weight of MFI divergence in total divergence strength calculation.") var iAo = input.bool(true,"AO", group="Indicator", inline="ind_ao") var w_ao = input.float(1.0,"Weight",step=.1,minval=0.0,group="Indicator",inline="ind_ao",tooltip="Awesome Oscillator (AO)\n\nWeight: Weight of AO divergence in total divergence strength calculation.") // var a_on = input.bool(true, "Alert", inline="alert", group="Alerts") // var a_above = input.float(5.0, "for values above", step=.1, inline="alert", group="Alerts") var bearSwitch = true var bullSwitch = true var netDiv = 0.0 var max = 7.0 var min = -7.0 //----------------------------------------- // Main //----------------------------------------- bearTotalDeg = 0.0 // total degree of divergence across all indicators bullTotalDeg = 0.0 // RSI if iRsi if bearSwitch i_bear = ta.rsi(bearPsource, 14) [f,d,_,_,_,_,_] = t.div_bear(bearPsource,i_bear,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_rsi if f bearTotalDeg += d if bullSwitch i_bull = ta.rsi(bullPsource, 14) [f,d,_,_,_,_,_] = t.div_bull(bullPsource,i_bull,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_rsi if f bullTotalDeg += d // OBV if iObv if bearSwitch i_bear = ta.obv [f,d,_,_,_,_,_] = t.div_bear(bearPsource,i_bear,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_obv if f bearTotalDeg += d if bullSwitch i_bull = ta.obv [f,d,_,_,_,_,_] = t.div_bull(bullPsource,i_bull,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_obv if f bullTotalDeg += d // MACD if iMacd if bearSwitch [_,_,i_bear] = ta.macd(bearPsource,12,26,9) [f,d,_,_,_,_,_] = t.div_bear(bearPsource,i_bear,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_macd if f bearTotalDeg += d if bullSwitch [_,_,i_bull] = ta.macd(bullPsource,12,26,9) [f,d,_,_,_,_,_] = t.div_bull(bullPsource,i_bull,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_macd if f bullTotalDeg += d // STOCH if iStoch if bearSwitch i_bear = ta.stoch(close, high, low, 14) [f,d,_,_,_,_,_] = t.div_bear(bearPsource,i_bear,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_stoch if f bearTotalDeg += d if bullSwitch i_bull = ta.stoch(close, high, low, 14) [f,d,_,_,_,_,_] = t.div_bull(bullPsource,i_bull,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_stoch if f bullTotalDeg += d // CCI if iCci if bearSwitch i_bear = ta.cci(bearPsource,20) [f,d,_,_,_,_,_] = t.div_bear(bearPsource,i_bear,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_cci if f bearTotalDeg += d if bullSwitch i_bull = ta.cci(bullPsource,20) [f,d,_,_,_,_,_] = t.div_bull(bullPsource,i_bull,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_cci if f bullTotalDeg += d // MFI if iMfi if bearSwitch i_bear = ta.mfi(bearPsource,14) [f,d,_,_,_,_,_] = t.div_bear(bearPsource,i_bear,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_mfi if f bearTotalDeg += d if bullSwitch i_bull = ta.mfi(bullPsource,14) [f,d,_,_,_,_,_] = t.div_bull(bullPsource,i_bull,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_mfi if f bullTotalDeg += d // AO if iAo if bearSwitch i_bear = ta.sma(hl2,5) - ta.sma(hl2,34) [f,d,_,_,_,_,_] = t.div_bear(bearPsource,i_bear,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_ao if f bearTotalDeg += d if bullSwitch i_bull = ta.sma(hl2,5) - ta.sma(hl2,34) [f,d,_,_,_,_,_] = t.div_bull(bullPsource,i_bull,cpLengthAfter,cpLengthBefore,ppLength,lbBars,lbPivs,true,w_p,w_i,w_hid,w_reg) d := d*w_ao if f bullTotalDeg += d netDiv := if bullTotalDeg > bearTotalDeg // IF stronger bull divergence forming if netDiv >= 0 or na(netDiv) // IF current net divergence is already bullish bullTotalDeg // use latest bullish divergence strength value else // ELSE netDiv + bullTotalDeg // add bullish divergence strength value to current (bearish) net divergence else if bearTotalDeg > bullTotalDeg // ELSE IF stronger bear divergence forming if netDiv <= 0 or na(netDiv) // IF current net divergence is already bearish 0 - bearTotalDeg // use latest negative bearish divergence strength value else // ELSE netDiv - bearTotalDeg // subtract bearish divergence strength value from current (bullish) net divergence else //netDiv na //netDiv := netDiv + bullTotalDeg- bearTotalDeg // color / gradient vars if netDiv > max max := netDiv if netDiv < min min := netDiv clr = if netDiv == 0 color.gray else if netDiv > 0 color.green else color.red fillClr = if netDiv == 0 color.gray else if netDiv > 0 color.lime else color.red // Plot hline(4,"Bullish signal line") hline(-4,"Bearish signal line") zero = plot(0.0,"Zero line",color.new(color.gray,50)) valPlot = plot(netDiv,"Divergence strength",color.new(clr,50),style=plot.style_histogram) topVal = netDiv > 0 ? max : 0.0 botVal = netDiv > 0 ? 0.0 : min topClr = netDiv > 0 ? color.new(color.lime,0) : color.new(color.red,100) botClr = netDiv > 0 ? color.new(color.lime,100) : color.new(color.red,0) fill(zero,valPlot,topVal,botVal,topClr,botClr)
Trading Checklist
https://www.tradingview.com/script/fdpa4CyN/
FX365_Thailand
https://www.tradingview.com/u/FX365_Thailand/
126
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© FX365_Thailand //Revision history //v53.0 First release //v54.0 Fixed text size adjustment //v55.0 Improved criteria fields for easier text input //@version=5 indicator("Trading Checklist",shorttitle = "Trading Checklist", overlay = true) //User input cr1 = input.text_area(title="Criteria 1", defval="Enter your criteria here",group="Criteria", tooltip="If you do not need a criterion, then delete it. It will not be shown on the table.") cr2 = input.text_area(title="Criteria 2", defval="Enter your criteria here") cr3 = input.text_area(title="Criteria 3", defval="Enter your criteria here") cr4 = input.text_area(title="Criteria 4", defval="Enter your criteria here") cr5 = input.text_area(title="Criteria 5", defval="Enter your criteria here") cr6 = input.text_area(title="Criteria 6", defval="Enter your criteria here") cr7 = input.text_area(title="Criteria 7", defval="Enter your criteria here") cr8 = input.text_area(title="Criteria 8", defval="Enter your criteria here") cr9 = input.text_area(title="Criteria 9", defval="Enter your criteria here") cr10 = input.text_area(title="Criteria 10", defval="Enter your criteria here") Text_Pos = input.string(title="Check list location", defval = position.top_right, options = [position.top_right,position.top_left,position.middle_right,position.middle_left,position.bottom_right,position.bottom_left] ,group="Check List Setting") Header_bg_color = input.color(defval = color.black, title = "Table Color") Header_text_color = input.color(defval = color.white, title = "Table text Color") Column_width = input.int(defval=30, title="Column width", minval=5, maxval=50) // Text_Col = input.color(defval = color.black, title = "Cell text color") Text_size = input.string(defval = size.small, title = "Cell text font size", options = [size.tiny, size.small, size.normal, size.large]) //Draw table var table table = table.new(Text_Pos, 2, 11, border_width = 3, frame_width = 3) //Color when nothing entered color_blank=color.new(color.white,100) //Header table.cell(table, 0, 0, "# ", width = 5, text_color=Header_text_color, bgcolor=Header_bg_color,text_size=Text_size) table.cell(table, 1, 0, "Criteria", width = Column_width,text_color=Header_text_color,bgcolor=Header_bg_color,text_size=Text_size) //Items //# table.cell(table, 1, 1, cr1, width = Column_width,text_color=cr1 == "" ? color_blank : Header_text_color,bgcolor=cr1 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 2, cr2, width = Column_width,text_color=cr2 == "" ? color_blank : Header_text_color,bgcolor=cr2 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 3, cr3, width = Column_width,text_color=cr3 == "" ? color_blank : Header_text_color,bgcolor=cr3 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 4, cr4, width = Column_width,text_color=cr4 == "" ? color_blank : Header_text_color,bgcolor=cr4 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 5, cr5, width = Column_width,text_color=cr5 == "" ? color_blank : Header_text_color,bgcolor=cr5 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 6, cr6, width = Column_width,text_color=cr6 == "" ? color_blank : Header_text_color,bgcolor=cr6 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 7, cr7, width = Column_width,text_color=cr7 == "" ? color_blank : Header_text_color,bgcolor=cr7 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 8, cr8, width = Column_width,text_color=cr8 == "" ? color_blank : Header_text_color,bgcolor=cr8 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 9, cr9, width = Column_width,text_color=cr9 == "" ? color_blank : Header_text_color,bgcolor=cr9 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 1, 10, cr10, width = Column_width,text_color=cr10 == "" ? color_blank : Header_text_color,bgcolor=cr10 == "" ? color_blank : Header_bg_color,text_size=Text_size) //Criteria table.cell(table, 0, 1, "1", width = 5,text_color= cr1 == "" ? color_blank : Header_text_color,bgcolor=cr1 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 2, "2", width = 5,text_color= cr2 == "" ? color_blank : Header_text_color,bgcolor=cr2 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 3, "3", width = 5,text_color= cr3 == "" ? color_blank : Header_text_color,bgcolor=cr3 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 4, "4", width = 5,text_color= cr4 == "" ? color_blank : Header_text_color,bgcolor=cr4 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 5, "5", width = 5,text_color= cr5 == "" ? color_blank : Header_text_color,bgcolor=cr5 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 6, "6", width = 5,text_color= cr6 == "" ? color_blank : Header_text_color,bgcolor=cr6 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 7, "7", width = 5,text_color= cr7 == "" ? color_blank : Header_text_color,bgcolor=cr7 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 8, "8", width = 5,text_color= cr8 == "" ? color_blank : Header_text_color,bgcolor=cr8 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 9, "9", width = 5,text_color= cr9 == "" ? color_blank : Header_text_color,bgcolor=cr9 == "" ? color_blank : Header_bg_color,text_size=Text_size) table.cell(table, 0, 10, "10", width = 5,text_color= cr10 == "" ? color_blank : Header_text_color,bgcolor=cr10 == "" ? color_blank : Header_bg_color,text_size=Text_size)
[Mad] Active Line
https://www.tradingview.com/script/SBxdByX7-Mad-Active-Line/
djmad
https://www.tradingview.com/u/djmad/
211
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© djmad // ver = "v1.1" //@version=5 indicator(title="[Mad] Active Line "+ver, shorttitle = "[Mad] Active Line "+ver, overlay = true, max_bars_back=1000, max_labels_count=500, max_lines_count=500, max_boxes_count=500) /////////////////// // { Inputs var int Entryline_1_collisions = 0 var int Entryline_2_collisions = 0 all_colors = array.new_color(16, color.gray) all_thickness = array.new_int(16, 1) all_styles = array.new_string(16, line.style_dotted ) int OFFSET = 0//input.int(0,"OFFSET TIME")*1000000 bool ChartisLog = input.bool(false,'Chart-Setting is Logarithmic',group='Log-Chart',inline='1cd') float Entryline_1_Time_L = input.time(timestamp("2020-02-20"), "Entryline 1 A", inline="Entryline 1 Point Left", confirm = true,group='Line 1') +OFFSET float Entryline_1_Price_T = input.price(100, "Entryline 1 A", inline="Entryline 1 Point Left", confirm=true,group='Line 1') float Entryline_1_Time_R = input.time(timestamp("2020-02-19"), "Entryline 1 B", inline="Entryline 1 Point Right", confirm = true,group='Line 1') +OFFSET float Entryline_1_Price_B = input.price(100, "Entryline 1 B", inline="Entryline 1 Point Right", confirm=true,group='Line 1') array.set(all_colors, 0, input.color(color.rgb(255, 251, 0), title='',group='Line 1',inline='1aa')) array.set(all_thickness, 0, input.int(1,'- thickness',group='Line 1',inline='1aa')) array.set(all_styles, 0, input.string(line.style_solid,' style',group='Line 1',inline='1aa',options=[line.style_dotted,line.style_solid])) string Entryline_1_Ext_temp = input.string("extend right","extend line", options=["extend right","extend none","extend left","extend both"]) bool show_line_hori = input.bool(true,'Show horizontal line',group='Horizontal Line',inline='1cb') array.set(all_colors, 2, input.color(color.rgb(255, 251, 0), title='',group='Horizontal Line',inline='1cc')) array.set(all_thickness, 1, input.int(1,'- thickness',group='Horizontal Line',inline='1cc')) array.set(all_styles, 1, input.string(line.style_solid,' style',group='Horizontal Line',inline='1cc',options=[line.style_dotted,line.style_solid])) bool infotext_right = input.bool(true,'Show horizontal text',group='Horizontal Line',inline='1cd') int infotext_right_space = input.int(42,'- shifting',group='Horizontal Line',inline='1cd',step=3) bool show_line_vert = input.bool(true,'Show difference line',group='Difference Line',inline='1cd') array.set(all_colors, 3, input.color(color.rgb(255, 251, 0), title='',group='Difference Line',inline='1ce')) array.set(all_thickness, 2, input.int(1,'- thickness',group='Difference Line',inline='1ce')) array.set(all_styles, 2, input.string(line.style_dotted,' style',group='Difference Line',inline='1ce',options=[line.style_dotted,line.style_solid])) bool infotext_diff = input.bool(true,'Show difference text',group='Difference Line',inline='1cf') int infotext_diff_space = input.int(18,'- shifting',group='Difference Line',inline='1cf',step=3) string infotext_text = input.string("c= ",'Naming:',group='Difference Line',inline='1cf') bool show_markers = input.bool(true,'Show Dragpoints and Crosses',group='Dragpoints and Crosses') var infotext_size = input.string(size.normal, title='Label-Size', group='label settings', options=[size.tiny, size.small, size.normal, size.large, size.huge], inline='1da') array.set(all_colors, 1, input.color(color.white, title='- Textcolor',group='label settings', inline='1da')) int i_decimals = input.int(2,'decimals',group='label settings') bool debugtext_active = false//input.bool(false,'Debug Info',group='label settings') int alertnumber = input.int(1,'maximum alerts',group='alert settings') var float timeto = na // } /////////////////// // { Functions bool Alert_output = false roundTo(_value) => str.tostring(math.round(_value * math.pow(10, i_decimals)) / math.pow(10, i_decimals)) shifting(_value) => var string output = "" output := "" for i = 0 to _value by 3 output := output + " " float LOGICAL_OFFSET = 4 float COORD_OFFSET = 0.0001 fromLog(series float value) => float exponent = math.abs(value) float product = math.pow(10, exponent - LOGICAL_OFFSET) - COORD_OFFSET float result = exponent < 1e-8 ? 0 : value < 0 ? - product : product toLog(series float value) => float exponent = math.abs(value) float product = math.log10(exponent + COORD_OFFSET) + LOGICAL_OFFSET float result = exponent < 1e-8 ? 0 : value < 0 ? - product : product f_getbartime() => var int firstbartime = 0, var int lastbartime = 0 var bool locked1 = false var bool locked2 = false var bool locked3 = false var int counter = 0 var int difftime = 0 var int timeperbar = na if locked1 == false firstbartime := time counter := 0 locked1 := true if counter == 100 and locked2 == false lastbartime := time locked2 := true if locked3 == false and locked2 == true difftime := lastbartime - firstbartime timeperbar := difftime / counter locked3 := true if locked3 != true counter += 1 timeperbar f_calc_projection( float Entryline_Time_L, float Entryline_Price_T, float Entryline_Time_R, float Entryline_Price_B, float relevanttime, bool chartislog) => if chartislog fromLog(toLog(Entryline_Price_T) + (toLog(Entryline_Price_B) - toLog(Entryline_Price_T)) / (toLog(Entryline_Time_R/f_getbartime()) - toLog(Entryline_Time_L/f_getbartime())) * (toLog(relevanttime/f_getbartime()) - toLog(Entryline_Time_L/f_getbartime()))) else if not chartislog Entryline_Price_T + (Entryline_Price_B - Entryline_Price_T) / (Entryline_Time_R/f_getbartime() - Entryline_Time_L/f_getbartime()) * (relevanttime/f_getbartime() - (Entryline_Time_L/f_getbartime())) f_draw_diff_line( float Entryline_Time_L, float Entryline_Price_T, float Entryline_Time_R, float Entryline_Price_B, string Entryline_Ext, string Entryline_dir, string Entryline_type, int Entryline_amount, string Entryline_spikes, color [] colors, int [] all_thickness, string [] all_styles) => var float difference = 0 line Line_Vertical = na line Line_Horizontal = na label Label_diff1 = na label Label_diff2 = na label Label_diff3 = na bool Alertoutput = false if Entryline_Ext == extend.right or Entryline_Ext == extend.both or time < Entryline_Time_R if show_line_hori Line_Horizontal := line.new( bar_index[2], f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog), bar_index[1], f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog), xloc=xloc.bar_index, color=array.get(colors,2), extend=extend.right, style=array.get(all_styles,1), width=array.get(all_thickness,1)) if infotext_right Label_diff3 := label.new(timenow + (time - time[1]) * 1, f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog), shifting(infotext_right_space) + str.tostring(roundTo(f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog))), xloc=xloc.bar_time, textcolor=array.get(colors,1) , style=label.style_none, size=infotext_size) if show_line_vert Line_Vertical := line.new( time, close - 0.1*(close-f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog)) , time, f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog), xloc=xloc.bar_time, color=array.get(colors,3), extend=extend.none, style=array.get(all_styles,2), width=array.get(all_thickness,2)) if infotext_diff Label_diff1 := label.new(time,f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog), text= shifting(infotext_diff_space) + infotext_text + str.tostring(roundTo(f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog)-close))+"\n\n" , xloc=xloc.bar_time, style=label.style_none, color=array.get(colors,0), textcolor=array.get(colors,1), size=infotext_size) if show_markers Label_diff2 := label.new(time,f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog), text= "" , xloc=xloc.bar_time, style=label.style_xcross, color=array.get(colors,0), textcolor=array.get(colors,1), size=size.tiny) Alertoutput := ta.cross(f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,time,ChartisLog),0) line.delete(Line_Vertical[1]) line.delete(Line_Horizontal[1]) label.delete(Label_diff1[1]) label.delete(Label_diff2[1]) label.delete(Label_diff3[1]) Alertoutput f_draw_entry_line( float Entryline_Time_L, float Entryline_Price_T, float Entryline_Time_R, float Entryline_Price_B, string Entryline_Ext, string Entryline_dir, string Entryline_type, float Entryline_width, int Entryline_amount, color [] colors, int [] all_thickness, string [] all_styles) => var float difference = 0 var line Line_entryline_1 = na var line Line_entryline_2 = na var linefill Line_fill_E1_E2 = na var color_given = array.get(colors,0) Line_entryline_1 := line.new(math.floor(math.round(Entryline_Time_L,0)), Entryline_Price_T, math.floor(math.round(Entryline_Time_R,0)), f_calc_projection(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B,Entryline_Time_R,ChartisLog), xloc=xloc.bar_time, color=color_given, extend=Entryline_Ext, style=array.get(all_styles,0), width=array.get(all_thickness,0)) difference := close[math.floor(Entryline_Time_L)] - Entryline_Price_B line.delete(Line_entryline_1[1]) line.delete(Line_entryline_2[1]) linefill.delete(Line_fill_E1_E2[1]) if show_markers Label_linestats = label.new( math.floor(math.round(Entryline_Time_L,0)), Entryline_Price_T, "" , xloc=xloc.bar_time, style=label.style_xcross, color=color_given, textcolor=array.get(colors,1), size=size.tiny) label.delete(Label_linestats[1]) Label_line_endpoint = label.new(math.ceil(math.round(Entryline_Time_R,0)),Entryline_Price_B, text= "" , xloc=xloc.bar_time, style=label.style_xcross, color=color_given, textcolor=array.get(colors,1), size=size.tiny) label.delete(Label_line_endpoint[1]) f_draw_entry_line_complete( float Entryline_Time_L, float Entryline_Price_T, float Entryline_Time_R, float Entryline_Price_B, string Entryline_Ext, string Entryline_dir, string Entryline_type, float Entryline_width, int Entryline_amount, string Entryline_spikes, color [] colors, int [] all_thickness, string [] all_styles) => f_draw_entry_line(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B, Entryline_Ext, Entryline_dir, Entryline_type, Entryline_width, Entryline_amount, colors, all_thickness, all_styles) f_draw_diff_line(Entryline_Time_L, Entryline_Price_T, Entryline_Time_R, Entryline_Price_B, Entryline_Ext, Entryline_dir, Entryline_type, Entryline_amount, Entryline_spikes, colors, all_thickness, all_styles) // } /////////////////// //RUNTIME { /////////////////// Entryline_1_Ext = switch Entryline_1_Ext_temp "extend right" => extend.right "extend none" => extend.none "extend left" => extend.left "extend both" => extend.both => "" if time >= Entryline_1_Time_L - 150*f_getbartime() Alert_output := f_draw_entry_line_complete( Entryline_1_Time_L, Entryline_1_Price_T, Entryline_1_Time_R, Entryline_1_Price_B, Entryline_1_Ext, "disabled", "disabled", 0, 0, "close", all_colors, all_thickness, all_styles) /////////////////// //Alerts { /////////////////// var actual_alerts = 0 if not barstate.isrealtime actual_alerts := 0 if Alert_output and alertnumber > actual_alerts actual_alerts :=+ 1 alert("Active line is crossed @" + str.tostring(roundTo(close)) + " Nr.:" + str.tostring(actual_alerts))
Open Interest Profile (OI)- By Leviathan
https://www.tradingview.com/script/8XKZuAOF-Open-Interest-Profile-OI-By-Leviathan/
LeviathanCapital
https://www.tradingview.com/u/LeviathanCapital/
1,628
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Leviathan // Some elements of generating Profiles are inspired by @LonesomeTheBlue's volume profile script //@version=5 indicator("Open Interest Profile [Periodic] - By Leviathan", overlay=true, max_boxes_count=500, max_bars_back=1000) //========================== //Inputs //========================== sessionType = input.string('Weekly', 'Session / Lookback', options=['Tokyo','London','New York','Daily','Weekly', 'Monthly']) dispMode = input.string('Mode 3', 'OI Profile Mode', ['Mode 1', 'Mode 2', 'Mode 3'], group='Display') showVAb = input.bool(false, 'Show OI Value Area', group='Display') showSbox = input.bool(false, 'Show Session Box', group='Display') showProf = input.bool(true, 'Show Profile', group='Display') showCur = input.bool(true, 'Show Current Session', group='Display') showLabels = input.bool(false, 'Show Session Lables', group='Display') resolution = input.int(50, 'Resolution', minval=5, tooltip='The higher the value, the more refined of a profile, but less profiles shown on chart', group='Profile Settings') volType = input.string('Open Interest', 'Profile Data Type', options=['Open Interest'], group='Profile Settings') VAwid = input.int(60, 'OI Value Area %', minval=1, maxval=100, group='Profile Settings') smoothVol = input.bool(false, 'Smooth OI Data', tooltip='Useful for assets that have very large spikes in volume over large bars, helps create better profiles', group='Profile Settings') dataTf = '' bullCol = input.color(color.rgb(76, 175, 79, 50), 'OI Increase', group='Appearance') bearCol = input.color(color.rgb(255, 82, 82, 50), 'OI Decrease', group='Appearance') VAbCol = input.color(color.rgb(107, 159, 255, 90), 'Value Area Box', group='Appearance' ) boxWid = input.int(1, 'Session Box Thickness', group='Appearance') //========================== //Constants / Variable Declaration //========================== var int zoneStart = 0 var int tokyoStart = 0 var int londonStart = 0 var int nyStart = 0 int lookback = bar_index - zoneStart var activeZone = false // Defining arrays that store the information var vpGreen = array.new_float(resolution, 0) // Sum of volume on long bars var vpRed = array.new_float(resolution, 0) // Same thing but with red bars var zoneBounds = array.new_float(resolution, 0) // array that stores the highest value that can be in a zone //Values to store current intra bar data var float[] ltfOpen = array.new_float(0) var float[] ltfClose = array.new_float(0) var float[] ltfHigh = array.new_float(0) var float[] ltfLow = array.new_float(0) var float[] ltfVolume = array.new_float(0) //Getting OI Data string userSymbol = syminfo.prefix + ":" + syminfo.ticker string openInterestTicker = str.format("{0}_OI", userSymbol) string timeframe = syminfo.type == "futures" and timeframe.isintraday ? "1D" : timeframe.period deltaOi = request.security(openInterestTicker, timeframe, close-close[1], ignore_invalid_symbol = true) //Selecting what vol type to use vol() => out = smoothVol ? ta.ema(volume, 5) : volume if volType == 'Open Interest' out := deltaOi out //Getting intrabar intial data [dO, dC, dH, dL, dV] = request.security_lower_tf(syminfo.tickerid, dataTf, [open, close, high, low, vol()]) //========================== //Functions //========================== resetProfile(enable) => if enable array.fill(vpGreen, 0) array.fill(vpRed, 0) array.clear(ltfOpen) array.clear(ltfHigh) array.clear(ltfLow) array.clear(ltfClose) array.clear(ltfVolume) profHigh = ta.highest(high, lookback+1)[1] profLow = ta.lowest(low, lookback+1)[1] tr = ta.atr(1) atr = ta.atr(14) get_vol(y11, y12, y21, y22, height, vol) => nz(math.max(math.min(math.max(y11, y12), math.max(y21, y22)) - math.max(math.min(y11, y12), math.min(y21, y22)), 0) * vol / height) profileAdd(o, h, l, c, v, g, w) => //Array to store how much to distribute in each zone, on scale of 1 for full gap size to 0 zoneDist = array.new_float(resolution, 0) distSum = 0.0 // Going over each zone for i = 0 to array.size(vpGreen) - 1 // Checking to see if cur bar is in zone zoneTop = array.get(zoneBounds, i) zoneBot = zoneTop - g body_top = math.max(c, o) body_bot = math.min(c, o) itsgreen = c >= o topwick = h - body_top bottomwick = body_bot - l body = body_top - body_bot bodyvol = body * v / (2 * topwick + 2 * bottomwick + body) topwickvol = 2 * topwick * v / (2 * topwick + 2 * bottomwick + body) bottomwickvol = 2 * bottomwick * v / (2 * topwick + 2 * bottomwick + body) if volType == 'Volume' array.set(vpGreen, i, array.get(vpGreen, i) + (itsgreen ? get_vol(zoneBot, zoneTop, body_bot, body_top, body, bodyvol) : 0) + get_vol(zoneBot, zoneTop, body_top, h, topwick, topwickvol) / 2 + get_vol(zoneBot, zoneTop, body_bot, l, bottomwick, bottomwickvol) / 2) array.set(vpRed, i, array.get(vpRed, i) + (itsgreen ? 0 : get_vol(zoneBot, zoneTop, body_bot, body_top, body, bodyvol)) + get_vol(zoneBot, zoneTop, body_top, h, topwick, topwickvol) / 2 + get_vol(zoneBot, zoneTop, body_bot, l, bottomwick, bottomwickvol) / 2) else if volType == 'Open Interest' if v > 0 array.set(vpGreen, i, array.get(vpGreen, i) + get_vol(zoneBot, zoneTop, body_bot, body_top, body, v))// + get_vol(zoneBot, zoneTop, body_top, h, topwick, topwickvol) / 2 + get_vol(zoneBot, zoneTop, body_bot, l, bottomwick, bottomwickvol) / 2) if v < 0 array.set(vpRed, i, array.get(vpRed, i) + get_vol(zoneBot, zoneTop, body_bot, body_top, body, -v))// + get_vol(zoneBot, zoneTop, body_top, h, topwick, topwickvol) / 2 + get_vol(zoneBot, zoneTop, body_bot, l, bottomwick, bottomwickvol) / 2) calcSession(update) => array.fill(vpGreen, 0) array.fill(vpRed, 0) if bar_index > lookback and update gap = (profHigh - profLow) / resolution // Defining profile bounds for i = 0 to resolution - 1 array.set(zoneBounds, i, profHigh - gap * i) // Putting each bar inside zone into the volume profile array if array.size(ltfOpen) > 0 for j = 0 to array.size(ltfOpen) - 1 profileAdd(array.get(ltfOpen, j), array.get(ltfHigh, j), array.get(ltfLow, j), array.get(ltfClose, j), array.get(ltfVolume, j), gap, 1) pocLevel() => float maxVol = 0 int levelInd = 0 for i = 0 to array.size(vpRed) - 1 if array.get(vpRed, i) + array.get(vpGreen, i) > maxVol maxVol := array.get(vpRed, i) + array.get(vpGreen, i) levelInd := i float outLevel = na if levelInd != array.size(vpRed) - 1 outLevel := array.get(zoneBounds, levelInd) - (array.get(zoneBounds, levelInd) - array.get(zoneBounds, levelInd+1)) / 2 outLevel valueLevels(poc) => float gap = (profHigh - profLow) / resolution float volSum = array.sum(vpRed) + array.sum(vpGreen) float volCnt = 0 float vah = profHigh float val = profLow //Finding poc index int pocInd = 0 for i = 0 to array.size(zoneBounds)-2 if array.get(zoneBounds, i) >= poc and array.get(zoneBounds, i + 1) < poc pocInd := i volCnt += (array.get(vpRed, pocInd) + array.get(vpGreen, pocInd)) for i = 1 to array.size(vpRed) if pocInd + i >= 0 and pocInd + i < array.size(vpRed) volCnt += (array.get(vpRed, pocInd + i) + array.get(vpGreen, pocInd + i)) if volCnt >= volSum * (VAwid/100) break else val := array.get(zoneBounds, pocInd + i) - gap if pocInd - i >= 0 and pocInd - i < array.size(vpRed) volCnt += (array.get(vpRed, pocInd - i) + array.get(vpGreen, pocInd - i)) if volCnt >= volSum * (VAwid/100) break else vah := array.get(zoneBounds, pocInd - i) [val, vah] drawNewZone(update) => if bar_index > lookback and update and array.sum(vpGreen) + array.sum(vpRed) > 0 gap = (profHigh - profLow) / resolution float leftMax = bar_index[lookback] float rightMax = bar_index[int(lookback / 1.4)] float rightMaxVol = array.max(vpGreen)+array.max(vpRed) float buffer = gap / 10 if showLabels label.new((bar_index - 1 + int(leftMax))/2, profHigh, sessionType, color=color.rgb(0,0,0,100), textcolor=chart.fg_color) if showProf for i = 0 to array.size(vpRed) - 1 greenEnd = int(leftMax + (rightMax - leftMax) * (array.get(vpGreen, i) / rightMaxVol)) redEnd = int(greenEnd + (rightMax - leftMax) * (array.get(vpRed, i) / rightMaxVol)) if dispMode == 'Mode 2' box.new(int(leftMax), array.get(zoneBounds, i) - buffer, greenEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bullCol, border_width=0) box.new(greenEnd, array.get(zoneBounds, i) - buffer, redEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bearCol, border_width=0) else if dispMode == 'Mode 1' box.new(int(leftMax), array.get(zoneBounds, i) - buffer, greenEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bullCol, border_width=0) else box.new(int(leftMax), array.get(zoneBounds, i) - buffer, greenEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bullCol, border_width=0) box.new(int(leftMax)-redEnd+greenEnd, array.get(zoneBounds, i) - buffer, int(leftMax), array.get(zoneBounds, i) - gap + buffer, bgcolor=bearCol, border_width=0) poc = pocLevel() [val, vah] = valueLevels(poc) if showVAb box.new(int(leftMax), vah, bar_index-1, val, border_color=color.rgb(54, 58, 69, 100), bgcolor=VAbCol) if showSbox box.new(int(leftMax), profHigh, bar_index-1, profLow, chart.fg_color, boxWid, line.style_dashed, bgcolor=color.rgb(0,0,0,100)) //if update // resetProfile(true) drawCurZone(update, delete) => var line pocLine = na var line vahLine = na var line valLine = na var box outBox = na var label sessionLab = na var redBoxes = array.new_box(array.size(vpRed), na) var greenBoxes = array.new_box(array.size(vpRed), na) if bar_index > lookback and update and array.sum(vpGreen) + array.sum(vpRed) > 0 //Clearing the previous boxes and array if not na(pocLine) line.delete(pocLine) if not na(vahLine) line.delete(vahLine) if not na(valLine) line.delete(valLine) if not na(outBox) box.delete(outBox) if not na(sessionLab) label.delete(sessionLab) for i = 0 to array.size(redBoxes) - 1 if not na(array.get(redBoxes, i)) box.delete(array.get(redBoxes, i)) box.delete(array.get(greenBoxes, i)) gap = (profHigh - profLow) / resolution float leftMax = bar_index[lookback] float rightMax = bar_index[int(lookback / 1.4)] float rightMaxVol = array.max(vpGreen)+array.max(vpRed) float buffer = gap / 10 if showLabels sessionLab := label.new((bar_index - 1 + int(leftMax))/2, profHigh, sessionType, color=color.rgb(0,0,0,100), textcolor=chart.fg_color) if showProf for i = 0 to array.size(vpRed) - 1 greenEnd = int(leftMax + (rightMax - leftMax) * (array.get(vpGreen, i) / rightMaxVol)) redEnd = int(greenEnd + (rightMax - leftMax) * (array.get(vpRed, i) / rightMaxVol)) if dispMode == 'Mode 2' array.set(greenBoxes, i, box.new(int(leftMax), array.get(zoneBounds, i) - buffer, greenEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bullCol, border_width=0)) array.set(redBoxes, i, box.new(greenEnd, array.get(zoneBounds, i) - buffer, redEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bearCol, border_width=0)) else if dispMode == 'Mode 1' array.set(greenBoxes, i, box.new(int(leftMax), array.get(zoneBounds, i) - buffer, greenEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bullCol, border_width=0)) else array.set(greenBoxes, i, box.new(int(leftMax), array.get(zoneBounds, i) - buffer, greenEnd, array.get(zoneBounds, i) - gap + buffer, bgcolor=bullCol, border_width=0)) array.set(redBoxes, i, box.new(int(leftMax)-redEnd+greenEnd, array.get(zoneBounds, i) - buffer, int(leftMax), array.get(zoneBounds, i) - gap + buffer, bgcolor=bearCol, border_width=0)) poc = pocLevel() [val, vah] = valueLevels(poc) if showVAb box.new(int(leftMax), vah, bar_index-1, val, border_color=color.rgb(54, 58, 69, 100), bgcolor=VAbCol) if showSbox box.new(int(leftMax), profHigh, bar_index-1, profLow, chart.fg_color, boxWid, line.style_dashed, bgcolor=color.rgb(0,0,0,100)) if delete box.delete(outBox) line.delete(pocLine) line.delete(vahLine) line.delete(valLine) for i = 0 to array.size(greenBoxes)-1 box.delete(array.get(greenBoxes, i)) for i = 0 to array.size(redBoxes)-1 box.delete(array.get(redBoxes, i)) drawForexBox(startBar, title, top, bottom) => box.new(int(startBar), top, bar_index-1, bottom, chart.fg_color, 2, line.style_dashed, bgcolor=color.rgb(0,0,0,100)) if showLabels label.new((bar_index - 1 + int(startBar))/2, top, title, color=color.rgb(0,0,0,100), textcolor=chart.fg_color) combArray(arr1, arr2) => out = array.copy(arr1) if array.size(arr2) > 0 for i = 0 to array.size(arr2) - 1 array.push(out, array.get(arr2, i)) out updateIntra(o, h, l, c, v) => if array.size(o) > 0 for i = 0 to array.size(o) - 1 array.push(ltfOpen, array.get(o, i)) array.push(ltfHigh,array.get(h, i)) array.push(ltfLow,array.get(l, i)) array.push(ltfClose,array.get(c, i)) array.push(ltfVolume,array.get(v, i)) //========================== //Calculations //========================== //Detecting different start dates newDaily = dayofweek != dayofweek[1] newWeekly = (dayofweek != dayofweek[1] + 1) and (dayofweek != dayofweek[1]) newMonthly = (dayofmonth != dayofmonth[1] + 1) and (dayofmonth != dayofmonth[1]) utcHour = hour(time(timeframe.period, '0000-2400', 'GMT'), 'GMT') newTokyo = utcHour != utcHour[1] + 1 and utcHour != utcHour[1] endTokyo = utcHour >= 9 and utcHour[1] < 9 newLondon = utcHour >= 7 and utcHour[1] < 7 endLondon = utcHour >= 16 and utcHour[1] < 16 newNewYork = utcHour >= 13 and utcHour[1] < 13 endNewYork = utcHour >= 22 and utcHour[1] < 22 newSession = switch sessionType 'Tokyo' => newTokyo 'London' => newLondon 'New York' => newNewYork 'Daily' => newDaily 'Weekly' => newWeekly 'Monthly' => newMonthly => newDaily zoneEnd = switch sessionType 'Tokyo' => endTokyo 'London' => endLondon 'New York' => endNewYork 'Daily' => newDaily 'Weekly' => newWeekly 'Monthly' => newMonthly => newDaily isForex = sessionType == 'FX Session' //Re calculating and drawing zones calcSession((zoneEnd or (barstate.islast and showCur)) and not isForex) drawNewZone(zoneEnd and not isForex) drawCurZone(barstate.islast and not zoneEnd and showCur and activeZone and not isForex, zoneEnd) //Reseting profie at start of new zone resetProfile(newSession) //Updating data arrays updateIntra(dO, dH, dL, dC, dV) //Reseting zone start value if zoneEnd activeZone := false if newSession zoneStart := bar_index activeZone := true
Ticker vs Index
https://www.tradingview.com/script/XC4Qkvnu-Ticker-vs-Index/
Lantzwat
https://www.tradingview.com/u/Lantzwat/
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/ // Β© Lantzwat //@version=5 indicator("Ticker vs Index", "TvI") RefTickerId = input.symbol("SPX", title="Reference index", tooltip = "e.g. SPX/NDX/RUT/DWCPF or combinations of it") sma = input.int(20,"SMA") ref_close = request.security(RefTickerId, timeframe.period, close) pclose = ((close * 100) / close[1]) - 1 prefclose = ((ref_close * 100) / ref_close[1]) - 1 diff = ta.sma(pclose - prefclose,sma) div = 100 / (ta.highest(diff,250)-ta.lowest(diff,250)) diff := diff * div p0 = plot(0, color=color.new(color.white,90)) diffcolor = diff >= 0 ? color.blue : color.red pDiff = plot(diff, color = diffcolor) fill(p0,pDiff,color = color.new(diffcolor,60))
S&P 500 Quandl Data & Ratios
https://www.tradingview.com/script/xBFYNRfr-S-P-500-Quandl-Data-Ratios/
TradeAutomation
https://www.tradingview.com/u/TradeAutomation/
67
study
5
MPL-2.0
//This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 //Author Β© TradeAutomation indicator("S&P 500 Quandl Data & Ratios") // Pulls in S&P500 data using Quandl / Nasdaq Data Link // //S&P 500 Dividend Yield by Month. 12 month dividend per share/price. DIVYield = request.quandl("MULTPL/SP500_DIV_YIELD_MONTH", barmerge.gaps_on, 0) //S&P 500 PE Ratio by Month. Price to earnings ratio, based on trailing twelve month as reported earnings. PERatio = request.quandl("MULTPL/SP500_PE_RATIO_MONTH", barmerge.gaps_off, 0) //Cyclically Adjusted PE Ratio (CAPE Ratio), aka Shiller PE Ratio by Month. Price earnings ratio based on average inflation-adjusted earnings. CAPERatio = request.quandl("MULTPL/SHILLER_PE_RATIO_MONTH", barmerge.gaps_off, 0) //S&P 500 Earnings Yield by month. Earnings Yield = trailing 12 month earnings divided by index price (or inverse PE). Data after latest S&P report is estimated. EYield = request.quandl("MULTPL/SP500_EARNINGS_YIELD_MONTH", barmerge.gaps_on, 0) //S&P 500 price to book value ratio by quarter. PriceBook = request.quandl("MULTPL/SP500_PBV_RATIO_QUARTER", barmerge.gaps_on, 0) //S&P 500 Price to Sales Ratio by quarter (P/S or Price to Revenue). PriceSales = request.quandl("MULTPL/SP500_PSR_QUARTER", barmerge.gaps_on, 0) //S&P 500 level, Inflation Adjusted, by Month. RealSP500 = request.quandl("MULTPL/SP500_INFLADJ_MONTH", barmerge.gaps_on, 0) //S&P 500 sales by quarter. Trailing twelve month S&P 500 Sales Per Share (S&P 500 Revenue Per Share) non-inflation adjusted Sales = request.quandl("MULTPL/SP500_SALES_QUARTER", barmerge.gaps_on, 0) //S&P 500 Earnings Per Share. 12-month real earnings per share inflation adjusted EPS = request.quandl("MULTPL/SP500_EARNINGS_MONTH", barmerge.gaps_on, 0) // Indicator Inputs // DIVYieldInput = input.bool(false, "Dividend Yield", tooltip="Aqua - Plots S&P 500 Dividend Yield by Month. 12 month dividend per share/price.", group="Which metrics would you like to plot?") PERatioInput = input.bool(true, "Price Earnings Ratio", tooltip="Purple - Plots S&P 500 PE Ratio by Month. Price to earnings ratio, based on trailing twelve month as reported earnings.", group="Which metrics would you like to plot?") CAPERatioInput = input.bool(true, "CAPE/Shiller PE Ratio", tooltip="Green - Plots Cyclically Adjusted PE Ratio (CAPE Ratio), aka Shiller PE Ratio by Month. Price earnings ratio based on average inflation-adjusted earnings.", group="Which metrics would you like to plot?") EYieldInput = input.bool(false, "Earnings Yield", tooltip="Red - Plots S&P 500 Earnings Yield by month. Earnings Yield = trailing 12 month earnings divided by index price (or inverse PE). Data after latest S&P report is estimated.", group="Which metrics would you like to plot?") PriceBookInput = input.bool(false, "Price Book Ratio", tooltip="Gray - Plots S&P 500 price to book value ratio by quarter.", group="Which metrics would you like to plot?") PriceSalesInput = input.bool(false, "Price Sales Ratio", tooltip="Blue - Plots S&P 500 Price to Sales Ratio by quarter (P/S or Price to Revenue).", group="Which metrics would you like to plot?") RealSP500Input = input.bool(false, "Inflation Adjusted SP500", tooltip="Olive - Plots the S&P 500 level, Inflation Adjusted, by Month.", group="Which metrics would you like to plot?") SalesInput = input.bool(false, "Revenue Per Share", tooltip="Fuchsia - Plots Trailing twelve month S&P 500 Sales Per Share (S&P 500 Revenue Per Share) non-inflation adjusted.", group="Which metrics would you like to plot?") EPSInput = input.bool(false, "Earnings Per Share", tooltip="Orange - Plots S&P 500 Earnings Per Share (EPS). 12-month real earnings per share inflation adjusted", group="Which metrics would you like to plot?") LineWidth = input.int(1, "Line Width", group="Plot Settings") // Plotting // plot(DIVYieldInput==true ? DIVYield : na, title='DIVYield', linewidth=LineWidth, color=color.aqua) plot(PERatioInput==true ? PERatio : na, title='PERatio', linewidth=LineWidth, color=color.purple) plot(CAPERatioInput==true ? CAPERatio : na, title='CAPERatio', linewidth=LineWidth, color=color.green) plot(EYieldInput==true ? EYield : na, title='EYield', linewidth=LineWidth, color=color.red) plot(PriceBookInput==true ? PriceBook : na, title='PriceBook', linewidth=LineWidth, color=color.gray) plot(PriceSalesInput==true ? PriceSales : na, title='PriceSales', linewidth=LineWidth, color=color.blue) plot(RealSP500Input==true ? RealSP500 : na, title='RealSP500', linewidth=LineWidth, color=color.olive) plot(SalesInput==true ? Sales : na, title='Sales', linewidth=LineWidth, color=color.fuchsia) plot(EPSInput==true ? EPS : na, title='EPS', linewidth=LineWidth, color=color.orange)
MA Momentum
https://www.tradingview.com/script/6F1WPbvx-MA-Momentum/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
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/ // Β© peacefulLizard50262 //@version=5 indicator("Ma Momentum") one = input.int(13, "MA1") two = input.int(48, "MA2") three = input.int(48, "Smooth Line") smoothing = input.int(1, "Generall Smoothing") sma1 = ta.ema(close, one) sma2 = ta.ema(close, two) macd = ((sma1 + sma2) - (sma1[1] + sma2[1])) / 2 smooth = ta.sma(macd, three) plot(ta.ema(macd, smoothing), style = plot.style_columns, color = smooth > macd ? color.red : color.green) plot(smooth)
Enterprise Value on Earnings / FCF / FFO Band
https://www.tradingview.com/script/jlyQlZge/
Nagumo_Tetora
https://www.tradingview.com/u/Nagumo_Tetora/
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/ // Β© Nagumo_Tetora //Per Share Enterprise Value Superimposed onto Free Cash Flow / Operating Income (Earnings) / Adjusted Funds from Operations Rainbow Band //@version=5 indicator("EV Band", overlay = true) NetDebt = request.financial(syminfo.tickerid, "TOTAL_DEBT", "FY") - request.financial(syminfo.tickerid, "CASH_N_EQUIVALENTS", "FY") DilutedSharesOutstanding = request.financial(syminfo.tickerid, "DILUTED_SHARES_OUTSTANDING", "FQ") NDpS = NetDebt / DilutedSharesOutstanding //Net Debt per Share EVpS = NDpS + close //Enterprise Value per Share FreeCashFlow = request.financial(syminfo.tickerid, "FREE_CASH_FLOW", "FY") OperatingIncome = request.financial(syminfo.tickerid, "OPER_INCOME", "FY") OperatingCashflow = request.financial(syminfo.tickerid, "CASH_F_OPERATING_ACTIVITIES","FY") AdjustedFundsfromOperations = request.financial(syminfo.tickerid, "FUNDS_F_OPERATIONS", "FY") - request.financial(syminfo.tickerid, "UNUSUAL_EXPENSE_INC", "FY") * (1 - 0.25) CoreEarnings = request.financial(syminfo.tickerid, "NET_INCOME", "FY") - request.financial(syminfo.tickerid, "UNUSUAL_EXPENSE_INC", "FY") * (1 - 0.25) FCFpS = FreeCashFlow / DilutedSharesOutstanding //Free Cash Flow per Share OIpS = OperatingIncome / DilutedSharesOutstanding //Operating Income per Share OFpS = OperatingCashflow /DilutedSharesOutstanding //Cashflow from Operations per Share AFfOpS = AdjustedFundsfromOperations / DilutedSharesOutstanding //Adjusted Funds from Operations per Share CEpS = CoreEarnings / DilutedSharesOutstanding //Core Earnings per Share //Plot plot(EVpS, linewidth = 3, color = color.black) string i_icType = input.string("Free Cash Flow", "Band Type", options = ["Free Cash Flow", "Operating Income", "Cashflow from Operations", "Adjusted Funds from Operations", "Core Earnings"]) float BandMetric = switch i_icType "Free Cash Flow" => FCFpS "Operating Income" => OIpS "Cashflow from Operations" => OFpS "Adjusted Funds from Operations" => AFfOpS "Core Earnings" => CEpS BandMetric_00 = BandMetric * 5 BandMetric_01 = BandMetric * 10 BandMetric_02 = BandMetric * 15 BandMetric_03 = BandMetric * 20 BandMetric_04 = BandMetric * 25 BandMetric_05 = BandMetric * 30 Band_00 = plot(BandMetric_00, linewidth = 1, color = color.rgb(129, 129, 129, 33)) Band_01 = plot(BandMetric_01, linewidth = 1, color = color.rgb(129, 129, 129, 33)) Band_02 = plot(BandMetric_02, linewidth = 1, color = color.rgb(129, 129, 129, 33)) Band_03 = plot(BandMetric_03, linewidth = 1, color = color.rgb(129, 129, 129, 33)) Band_04 = plot(BandMetric_04, linewidth = 1, color = color.rgb(129, 129, 129, 33)) Band_05 = plot(BandMetric_05, linewidth = 1, color = color.rgb(129, 129, 129, 33)) fill(Band_00,Band_01,BandMetric_01,BandMetric_00,color.rgb(255, 0, 0, 33),color.rgb(128, 0, 255, 33)) fill(Band_01,Band_02,BandMetric_02,BandMetric_01,color.rgb(255, 255, 0, 33),color.rgb(255, 0, 0, 33)) fill(Band_02,Band_03,BandMetric_03,BandMetric_02,color.rgb(0, 255, 0, 33),color.rgb(255, 255, 0, 33)) fill(Band_03,Band_04,BandMetric_04,BandMetric_03,color.rgb(0, 255, 255, 33),color.rgb(0, 255, 0, 33)) fill(Band_04,Band_05,BandMetric_05,BandMetric_04,color.rgb(255, 255, 255),color.rgb(0, 255, 255, 33))
RSI Candle Color
https://www.tradingview.com/script/7kU9Me7k-RSI-Candle-Color/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
222
study
5
MPL-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("RSI Color", overlay = true, timeframe = '', timeframe_gaps = false) grad(src)=> color out = switch int(src) 0 => color.new(#1500FF , 20) 1 => color.new(#1709F6 , 20) 2 => color.new(#1912ED , 20) 3 => color.new(#1B1AE5 , 20) 4 => color.new(#1D23DC , 20) 5 => color.new(#1F2CD3 , 20) 6 => color.new(#2135CA , 20) 7 => color.new(#233EC1 , 20) 8 => color.new(#2446B9 , 20) 9 => color.new(#264FB0 , 20) 10 => color.new(#2858A7 , 20) 11 => color.new(#2A619E , 20) 12 => color.new(#2C6A95 , 20) 13 => color.new(#2E728D , 20) 14 => color.new(#307B84 , 20) 15 => color.new(#32847B , 20) 16 => color.new(#348D72 , 20) 17 => color.new(#36956A , 20) 18 => color.new(#389E61 , 20) 19 => color.new(#3AA758 , 20) 20 => color.new(#3CB04F , 20) 21 => color.new(#3EB946 , 20) 22 => color.new(#3FC13E , 20) 23 => color.new(#41CA35 , 20) 24 => color.new(#43D32C , 20) 25 => color.new(#45DC23 , 20) 26 => color.new(#47E51A , 20) 27 => color.new(#49ED12 , 20) 28 => color.new(#4BF609 , 20) 29 => color.new(#4DFF00 , 20) 30 => color.new(#53FF00 , 20) 31 => color.new(#59FF00 , 20) 32 => color.new(#5FFE00 , 20) 33 => color.new(#65FE00 , 20) 34 => color.new(#6BFE00 , 20) 35 => color.new(#71FE00 , 20) 36 => color.new(#77FD00 , 20) 37 => color.new(#7DFD00 , 20) 38 => color.new(#82FD00 , 20) 39 => color.new(#88FD00 , 20) 40 => color.new(#8EFC00 , 20) 41 => color.new(#94FC00 , 20) 42 => color.new(#9AFC00 , 20) 43 => color.new(#A0FB00 , 20) 44 => color.new(#A6FB00 , 20) 45 => color.new(#ACFB00 , 20) 46 => color.new(#B2FB00 , 20) 47 => color.new(#B8FA00 , 20) 48 => color.new(#BEFA00 , 20) 49 => color.new(#C4FA00 , 20) 50 => color.new(#CAF900 , 20) 51 => color.new(#D0F900 , 20) 52 => color.new(#D5F900 , 20) 53 => color.new(#DBF900 , 20) 54 => color.new(#E1F800 , 20) 55 => color.new(#E7F800 , 20) 56 => color.new(#EDF800 , 20) 57 => color.new(#F3F800 , 20) 58 => color.new(#F9F700 , 20) 59 => color.new(#FFF700 , 20) 60 => color.new(#FFEE00 , 20) 61 => color.new(#FFE600 , 20) 62 => color.new(#FFDE00 , 20) 63 => color.new(#FFD500 , 20) 64 => color.new(#FFCD00 , 20) 65 => color.new(#FFC500 , 20) 66 => color.new(#FFBD00 , 20) 67 => color.new(#FFB500 , 20) 68 => color.new(#FFAC00 , 20) 69 => color.new(#FFA400 , 20) 70 => color.new(#FF9C00 , 20) 71 => color.new(#FF9400 , 20) 72 => color.new(#FF8C00 , 20) 73 => color.new(#FF8300 , 20) 74 => color.new(#FF7B00 , 20) 75 => color.new(#FF7300 , 20) 76 => color.new(#FF6B00 , 20) 77 => color.new(#FF6200 , 20) 78 => color.new(#FF5A00 , 20) 79 => color.new(#FF5200 , 20) 80 => color.new(#FF4A00 , 20) 81 => color.new(#FF4200 , 20) 82 => color.new(#FF3900 , 20) 83 => color.new(#FF3100 , 20) 84 => color.new(#FF2900 , 20) 85 => color.new(#FF2100 , 20) 86 => color.new(#FF1900 , 20) 87 => color.new(#FF1000 , 20) 88 => color.new(#FF0800 , 20) 89 => color.new(#FF0000 , 20) 90 => color.new(#F60000 , 20) 91 => color.new(#DF0505 , 20) 92 => color.new(#C90909 , 20) 93 => color.new(#B20E0E , 20) 94 => color.new(#9B1313 , 20) 95 => color.new(#851717 , 20) 96 => color.new(#6E1C1C , 20) 97 => color.new(#572121 , 20) 98 => color.new(#412525 , 20) 99 => color.new(#2A2A2A , 20) 100 => color.new(#220027 , 20) out filter(float src, int len) => var float filter = na filter := ta.cum((src + (src[1] * 2) + (src[2] * 2) + src[3])/6) (filter - filter[len])/len rsi(src, len) => rsi = ta.rsi(filter(src, 1), len) f = -math.pow(math.abs(math.abs(rsi - 50) - 50), 1 + math.pow(len / 14, 0.618) - 1) / math.pow(50, math.pow(len / 14, 0.618) - 1) + 50 rsia = if rsi > 50 f + 50 else -f + 50 rsia length = input.int(8) rsi = rsi(close, length) barcolor(grad(rsi))
SPX_Strikes_OpcionSigma
https://www.tradingview.com/script/Y61DgkPz-SPX-Strikes-OpcionSigma/
fmontenegro16481
https://www.tradingview.com/u/fmontenegro16481/
51
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© fmontenegro16481 //@version=5 indicator("VIX_Strikes",overlay=true) A = math.sqrt(252)//Raiz Cuadrada de 252 B = request.security("SPX","1",close)//Precio del SPX al cierre C = request.security("VIX","1",close)//Precio del cierre del VIX en minuto Vol_D = C/A ME = B*(Vol_D/100) MS = B + ME MI = B - ME plot(MS[0],"Mov Superior",color.fuchsia,linewidth = 3) plot(MI,"Mov Inferior",color.fuchsia,linewidth = 3)
Visualizing Displacement [TFO]
https://www.tradingview.com/script/n6djFgQH-Visualizing-Displacement-TFO/
tradeforopp
https://www.tradingview.com/u/tradeforopp/
1,935
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© tradeforopp //@version=5 indicator("Visualizing Displacement [TFO]", "Displacement [TFO]", true) require_fvg = input.bool(true, "Require FVG") disp_type = input.string("Open to Close", "Displacement Type", options = ['Open to Close', 'High to Low']) std_len = input.int(100, minval = 1, title = "Displacement Length", tooltip = "How far back the script will look to determine the candle range standard deviation") std_x = input.int(4, minval = 0, title = "Displacement Strength") disp_color = input.color(color.yellow, "Bar Color") candle_range = disp_type == "Open to Close" ? math.abs(open - close) : high - low std = ta.stdev(candle_range, std_len) * std_x fvg = close[1] > open[1] ? high[2] < low[0] : low[2] > high[0] displacement = require_fvg ? candle_range[1] > std[1] and fvg : candle_range > std barcolor(displacement ? disp_color : na, offset = require_fvg ? -1 : na)
Higher High / Lower Low based on Heikin Ashi
https://www.tradingview.com/script/OajecSQC-Higher-High-Lower-Low-based-on-Heikin-Ashi/
UnknownUnicorn36161431
https://www.tradingview.com/u/UnknownUnicorn36161431/
168
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© zathruswriter //@version=5 indicator( "Higher High / Lower Low based on Heikin Ashi", overlay = true, max_labels_count = 500 ) candles_to_confirm_trend = input.int( 5, "HA Candles to Confirm Trend" ) candletype = input.string ("Candles", "Candle Type", options=["Hollow", "Bars", "Candles"], tooltip="Candle Type to be dispalyed. User will have to 'Mute' the main series bar using the πŸ‘ symbol next to ticker id.") ha_show = input.bool (true, "Show Heikin Ashi Candles Overlay") hide_candlesticks = input.bool( true, "Hollow candlesticks" ) BodyBull = input.color ( #26a69a, "", inline="a") BodyBear = input.color ( #ef5350, "", inline="a") BorderBull = input.color ( color.new( #26a69a, 50 ), "", inline="b") BorderBear = input.color ( color.new( #ef5350, 50 ), "", inline="b") WickBull = input.color ( color.new( #26a69a, 50 ), "", inline="c") WickBear = input.color ( color.new( #ef5350, 50 ), "", inline="c") // Optional Mathmatical Calcualtion to avoid the security function // hkClose = (open + high + low + close) / 4 // hkOpen = float(na) // hkOpen := na(hkOpen[1]) ? (open + close) / 2 : (nz(hkOpen[1]) + nz(hkClose[1])) / 2 // hkHigh = math.max(high, math.max(hkOpen, hkClose)) // hkLow = math.min(low, math.min(hkOpen, hkClose)) [hkOpen, hkHigh, hkLow, hkClose] = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, [open, high, low, close]) hollow = candletype == "Hollow" bars = candletype == "Bars" candle = candletype == "Candles" var prev_high = 0.0 var prev_high_index = 0 var prev_low = 0.0 var prev_low_index = 0 var ha_candle_counter = 0 var trend_candles_counter = 0 var current_trend = "" var long_term_trend = "" plotcandle( ha_show ? hkOpen : na, ha_show ? hkHigh : na, ha_show ? hkLow : na, ha_show ? hkClose : na, "Hollow Candles", hollow ? hkClose < hkOpen ? BodyBear : na : candle ? hkClose < hkOpen ? BodyBear : BodyBull : na, hollow or candle ? hkClose < hkOpen ? WickBear : WickBull : na, bordercolor = hollow or candle ? hkClose < hkOpen ? BorderBear : BorderBull : na) plotbar( ha_show ? hkOpen : na, ha_show ? hkHigh : na, ha_show ? hkLow : na, ha_show ? hkClose : na, "Bars", bars ? hkClose < hkOpen ? BodyBear : BodyBull : na) barcolor( hide_candlesticks ? color.new( color.white, 100 ) : na ) s_( txt ) => str.tostring( txt ) f_debug_label( txt ) => label.new(bar_index, high, str.tostring( txt ), color = color.lime, textcolor = color.black) f_debug_label_down( txt ) => label.new(bar_index, low, str.tostring( txt ), color = color.lime, textcolor = color.black, style = label.style_label_up) f_find_last_low() => start_at = barstate.isconfirmed ? 0 : 1 opposite_trend_candle_counter = 0 low_ = 0.0 idx = 0 for i = start_at to 100 // red Heikin Ashi if hkClose[ i ] < hkOpen[ i ] and opposite_trend_candle_counter >= 2 break else if hkClose[ i ] < hkOpen[ i ] and opposite_trend_candle_counter < 2 opposite_trend_candle_counter := opposite_trend_candle_counter + 1 if low_ == 0 or low[ i ] < low_ low_ := low[ i ] idx := i [ low_, idx ] f_find_last_high() => start_at = barstate.isconfirmed ? 0 : 1 opposite_trend_candle_counter = 0 high_ = 0.0 idx = 0 for i = start_at to 100 // green Heikin Ashi if hkClose[ i ] > hkOpen[ i ] and opposite_trend_candle_counter >= 2 break else if hkClose[ i ] > hkOpen[ i ] and opposite_trend_candle_counter < 2 opposite_trend_candle_counter := opposite_trend_candle_counter + 1 if high[ i ] > high_ high_ := high[ i ] idx := i [ high_, idx ] // if we just started, find the last high or low plot_hl = false plot_hh = false plot_eqh = false plot_ll = false plot_lh = false plot_eql = false first_run = false if prev_high == 0 or prev_low == 0 first_run := true if ( barstate.isconfirmed and hkClose > hkOpen ) or hkClose[ 1 ] > hkOpen[ 1 ] // previous Heikin Ashi was green, find the low [ l, li ] = f_find_last_low() prev_low := l prev_low_index := bar_index - li plot_ll := true current_trend := "bull" long_term_trend := "bull" else if ( barstate.isconfirmed and hkClose < hkOpen ) or hkClose[ 1 ] < hkOpen[ 1 ] // previous Heikin Ashi was red, find the high [ h, hi ] = f_find_last_high() prev_high := h prev_high_index := bar_index - hi plot_hh := true current_trend := "bear" long_term_trend := "bear" else // check if our trend has changed, in which case reset the counter trend = hkClose > hkOpen ? "bull" : "bear" if current_trend != trend ha_candle_counter := 1 current_trend := trend else ha_candle_counter := ha_candle_counter + 1 // check if our long-term trend has changed, i.e. if we have X HA candles confirmation of an opposite trend change_confirmed = false if long_term_trend != trend and ha_candle_counter >= candles_to_confirm_trend trend_candles_counter := 1 long_term_trend := trend change_confirmed := true else trend_candles_counter := trend_candles_counter + 1 // if we have same X heikin ashi candles in a row opposite to the long-term trend, the last highest high / lowest low is confirmed if change_confirmed if trend == "bear" // find the highest high from now until the previous high higher_high = 0.0 hi = 0 for i = bar_index to prev_low_index + 1 ix = bar_index - i if high[ ix ] > higher_high higher_high := high[ ix ] hi := i if higher_high > prev_high plot_hh := true else if higher_high < prev_high plot_lh := true else plot_eqh := true prev_high := higher_high prev_high_index := hi else if trend == "bull" // find the lowest low from now until the previous low lower_low = 0.0 li = 0 for i = bar_index to prev_high_index + 1 ix = bar_index - i if lower_low == 0 or low[ ix ] < lower_low lower_low := low[ ix ] li := i if lower_low < prev_low plot_ll := true else if lower_low > prev_low plot_hl := true else plot_eql := true prev_low := lower_low prev_low_index := li if plot_hh or plot_lh or plot_eqh label.new( prev_high_index, prev_high, ( plot_hh ? "HH" : plot_lh ? "LH" : "EQH" ), color = color.lime, textcolor = color.black, style = label.style_label_down ) if plot_ll or plot_hl or plot_eql label.new( prev_low_index, prev_low, ( plot_ll ? "LL" : plot_hl ? "HL" : "EQL" ), color = color.red, textcolor = color.white, style = label.style_label_up )
Relative Strength against Index
https://www.tradingview.com/script/5fKrWf2Q-Relative-Strength-against-Index/
Vollchaot
https://www.tradingview.com/u/Vollchaot/
50
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Vollchaot //@version=5 indicator("Relative Strength against Index", shorttitle = "RelStr") symbol = input.symbol("SPX", "Reference Index Symbol") ref_chgATR = request.security(symbol, timeframe.period, ta.change(ohlc4, 1)/ta.atr(11) ) self_chgATR = ta.change(ohlc4, 1) / ta.atr(11) self_number = 0 if ref_chgATR < -0.5 if ref_chgATR < -1 and self_chgATR < 2*ref_chgATR self_number := -1 if ref_chgATR < -1 and self_chgATR > 0.5*ref_chgATR self_number := 1 if self_chgATR > 2 self_number := 2 if self_chgATR >= 0.5 self_number := 1 if ref_chgATR > +0.5 if ref_chgATR > 1 and self_chgATR > 2*ref_chgATR self_number := 1 if ref_chgATR > 1 and self_chgATR < 0.5*ref_chgATR self_number := -1 if self_chgATR < -2 self_number := -2 if self_chgATR < -0.5 self_number := -1 plot(ta.cum(self_number))
Vector Scaler
https://www.tradingview.com/script/wVWqx2Vz-Vector-Scaler/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
42
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© peacefulLizard50262 //@version=5 indicator("VS") diff(_src, enable) => derivative = (_src - _src[2])/2 enable ? derivative : _src // Define the vector_scale() function vector_scale(sr, len, smo, diff, rsi, rsi_len) => // Calculate the average of the vector src = rsi ? ta.sma(diff(ta.rsi(close, rsi_len), diff), smo) : ta.sma(diff(sr, diff), smo) avg = rsi ? (diff ? 0 : 50) : (diff ? 0 : ta.sma(src, len)) // Calculate the magnitude of the vector magnitude = math.sqrt(math.pow(src - avg, 2) + math.pow(src[1] - avg[1], 2) + math.pow(src[2] - avg[2], 2)) // Normalize the vector normalizedVec = (src - avg) / magnitude // Smooth the normalized vector smoothedVec = (normalizedVec + 1) * 50 // Return the smoothed, normalized vector smoothedVec src = input.source(close, "Source") len = input.int(12, "Average Length") smo = input.int(3, "Smoothing", 1) rsi = input.bool(false, "RSI Mode") rsi_len = input.int(14, "RSI Length") dif = input.bool(false, "Delta Mode") out = vector_scale(src, len, smo, dif, rsi, rsi_len) lag = ta.sma(out, smo == 1 ? smo + 1 : smo == 3 ? 2 : smo > 3 ? int(smo/2) : smo) f = plot(out) s = plot(lag, color = color.orange) hline(50) top = hline(80) bot = hline(20) fill(top, bot, color.new(color.navy, 80))
Sigma Expected Movement [D/W/M]
https://www.tradingview.com/script/5bmBkxJO-Sigma-Expected-Movement-D-W-M/
seba34e
https://www.tradingview.com/u/seba34e/
130
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© seba34e //@version=5 indicator("Sigma Expected Movement [D/W/M]", overlay=true) period = input.string("DAY", title="Period", options = ["DAY", "WEEK", "MONTH"]) FirstDeviation = input.float (68, title = "First Deviation (%)") SecondDeviation = input.float (90, title = "Second Deviation (%)") roundIt = input.bool(false, title = "Round to Integer", inline = "Round") spread = input.int(5, title="", inline = "Round") tablePosition = input.string(title = 'Table Position', defval="Top right", options = ["Top right", "Top left", "Bottom right", "Bottom left"], tooltip='Position of the table') operableDays = 0 var yy1= 0.0 var table TheTable = table.new(tablePosition == "Top right" ? position.top_right : tablePosition == "Top left" ? position.top_left : tablePosition == "Bottom right" ? position.bottom_right : position.bottom_left, 2, 20, border_width=2) fill_Cell(_table, _column, _row, _title, _value, _bgcolor, _txtcolor) => _cellText = _title + '' + _value table.cell(_table, _column, _row, _cellText, bgcolor=_bgcolor, text_color=_txtcolor, text_halign=text.align_right) if period == "DAY" operableDays :=252 if period == "WEEK" operableDays :=52 if period == "MONTH" operableDays :=12 //Geting data previousClose = nz(request.security(syminfo.tickerid, "D", close[1])) vixClose = nz(request.security("TVC:VIX",timeframe.period, close)) raizCuadrada = math.sqrt(operableDays) d = vixClose / raizCuadrada ME = previousClose * (d / 100) ME_sup = previousClose + ME ME_inf = previousClose - ME ME_inv = previousClose RangoUp1 = ME_inv + ((ME_sup - ME_inv) * (FirstDeviation/100)) RangoDown1 = ME_inv + ((ME_inv - ME_sup) * (FirstDeviation/100)) RangoUp2 = ME_inv + ((ME_sup - ME_inv) * (SecondDeviation/100)) RangoDown2 = ME_inv + ((ME_inv - ME_sup) * (SecondDeviation/100)) if roundIt // round to integer (default 5) yy1 := ME_sup % spread if yy1 > spread / 2 ME_sup := ME_sup + (spread-yy1) else ME_sup := ME_sup - yy1 yy1 := ME_inf % spread if yy1 > spread / 2 ME_inf := ME_inf + (spread-yy1) else ME_inf := ME_inf - yy1 yy1 := RangoUp1 % spread if yy1 > spread / 2 RangoUp1 := RangoUp1 + (spread-yy1) else RangoUp1 := RangoUp1 - yy1 yy1 := RangoDown1 % spread if yy1 > spread / 2 RangoDown1 := RangoDown1 + (spread-yy1) else RangoDown1 := RangoDown1 - yy1 yy1 := RangoUp2 % spread if yy1 > spread / 2 RangoUp2 := RangoUp2 + (spread-yy1) else RangoUp2 := RangoUp2 - yy1 yy1 := RangoDown2 % spread if yy1 > spread / 2 RangoDown2 := RangoDown2 + (spread-yy1) else RangoDown2 := RangoDown2 - yy1 // Draw lines line_inf = line.new(bar_index,ME_inf,bar_index+10,ME_inf, color=color.purple, width = 2) line_sup = line.new(bar_index,ME_sup,bar_index+10,ME_sup, color=color.purple, width = 2) label_sup = label.new(bar_index,ME_sup, "EM+ " + str.tostring(ME_sup, "0.00"), style=label.style_label_down, textcolor = color.white) label_inf = label.new(bar_index,ME_inf, "EM- " + str.tostring(ME_inf, "0.00"), style=label.style_label_up, textcolor = color.white) line_sup1 = line.new(bar_index,RangoUp1,bar_index+10,RangoUp1, color=color.yellow, style=line.style_dashed, width = 1) line_inf1 = line.new(bar_index,RangoDown1,bar_index+10,RangoDown1, color=color.yellow,style=line.style_dashed, width = 1) label_firstSup = label.new(bar_index+10,RangoUp1,str.tostring(RangoUp1, "0.00"), style=label.style_none, textcolor = color.yellow) label_firstDown = label.new(bar_index+10,RangoDown1,str.tostring(RangoDown1, "0.00"), style=label.style_none, textcolor = color.yellow) line_sup2 = line.new(bar_index,RangoUp2,bar_index+10,RangoUp2, color=color.blue, style=line.style_dashed, width = 1) line_inf2 = line.new(bar_index,RangoDown2,bar_index+10,RangoDown2, color=color.blue, style=line.style_dashed, width = 1) label_secondSup = label.new(bar_index+10,RangoUp2,str.tostring(RangoUp2, "0.00"), style=label.style_none, textcolor = color.blue) label_secondDown = label.new(bar_index+10,RangoDown2,str.tostring(RangoDown2, "0.00"), style=label.style_none, textcolor = color.blue) line_previousClose = line.new(bar_index,previousClose,bar_index+10, previousClose, color=color.white, style=line.style_dashed, width = 1) label_previousClose = label.new(bar_index, previousClose, "Previous Close", style=label.style_none, textcolor = color.white) //Delete prevous lines line.delete(line_inf[1]) line.delete(line_sup[1]) line.delete(line_inf1[1]) line.delete(line_inf2[1]) line.delete(line_sup1[1]) line.delete(line_sup2[1]) line.delete(line_previousClose[1]) label.delete(label_sup[1]) label.delete(label_inf[1]) label.delete(label_firstSup[1]) label.delete(label_secondSup[1]) label.delete(label_firstDown[1]) label.delete(label_secondDown[1]) label.delete(label_previousClose[1]) // Shows Table if barstate.islast fill_Cell(TheTable, 0, 0, "", 'Period' , color.black, color.yellow) fill_Cell(TheTable, 1, 0, "", period , color.black, color.yellow) fill_Cell(TheTable, 0, 1, "", 'EM' , color.black, color.yellow) fill_Cell(TheTable, 1, 1, "", str.tostring(ME,"Β± 0.00") , color.black, color.yellow) fill_Cell(TheTable, 0, 2, "", 'Expected Movement UP' , color.black, color.yellow) fill_Cell(TheTable, 1, 2, "", str.tostring(ME_sup,"0.00") , color.black, color.yellow) fill_Cell(TheTable, 0, 3, "", 'Expected Movement DOWN' , color.black, color.yellow) fill_Cell(TheTable, 1, 3, "", str.tostring(ME_inf,"0.00") , color.black, color.yellow) fill_Cell(TheTable, 0, 4, "", 'VIX' , color.black, color.yellow) fill_Cell(TheTable, 1, 4, "", str.tostring(vixClose,"0.00") , color.black, color.yellow) fill_Cell(TheTable, 0, 5, "", 'Previous Close' , color.black, color.yellow) fill_Cell(TheTable, 1, 5, "", str.tostring(previousClose,"0.00") , color.black, color.yellow)
Multi Timeframe Support and Resistance [ABA Invest]
https://www.tradingview.com/script/kO82pg19-Multi-Timeframe-Support-and-Resistance-ABA-Invest/
abainvest
https://www.tradingview.com/u/abainvest/
606
study
5
CC-BY-NC-SA-4.0
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // Β© ABA Invest //@version = 5 indicator(title="Multi Timeframe Support and Resistance [ABA Invest]", shorttitle = "MTF SnR [ABA Invest]", overlay = true) // SnR Levels bars = input.int(15, title = "Pivot") tipe = input.string("Body", title = "Type", options = ["Wick", "Body"]) show_c = input.bool(true, title = "Current Timeframe", group = "Timeframes") show_5m = input.bool(false, title = "M5", group = "Timeframes") show_15m = input.bool(false, title = "M15", group = "Timeframes") show_30m = input.bool(false, title = "M30", group = "Timeframes") show_1h = input.bool(false, title = "H1", group = "Timeframes") show_4h = input.bool(false, title = "H4", group = "Timeframes") show_d = input.bool(false, title = "Daily", group = "Timeframes") show_w = input.bool(false, title = "Weekly", group = "Timeframes") pivot_high_5m = fixnan(request.security(syminfo.tickerid, "5", ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1])) pivot_high_15m = fixnan(request.security(syminfo.tickerid, "15", ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1])) pivot_high_30m = fixnan(request.security(syminfo.tickerid, "30", ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1])) pivot_high_1h = fixnan(request.security(syminfo.tickerid, "60", ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1])) pivot_high_4h = fixnan(request.security(syminfo.tickerid, "240", ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1])) pivot_high_d = fixnan(request.security(syminfo.tickerid, "D", ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1])) pivot_high_w = fixnan(request.security(syminfo.tickerid, "W", ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1])) pivot_high_c = fixnan(ta.pivothigh(tipe == "Wick" ? high : close, bars, bars)[1]) pivot_low_5m = fixnan(request.security(syminfo.tickerid, "5", ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1])) pivot_low_15m = fixnan(request.security(syminfo.tickerid, "15", ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1])) pivot_low_30m = fixnan(request.security(syminfo.tickerid, "30", ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1])) pivot_low_1h = fixnan(request.security(syminfo.tickerid, "60", ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1])) pivot_low_4h = fixnan(request.security(syminfo.tickerid, "240", ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1])) pivot_low_d = fixnan(request.security(syminfo.tickerid, "D", ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1])) pivot_low_w = fixnan(request.security(syminfo.tickerid, "W", ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1])) pivot_low_c = fixnan(ta.pivotlow(tipe == "Wick" ? low : close, bars, bars)[1]) resistance_high_5m = plot(show_5m ? pivot_high_5m : na, color=ta.change(pivot_high_5m) ? na : #00aeff, offset = -bars - 1, linewidth=2, title="Resistance M5") resistance_low_5m = plot(show_5m ? pivot_low_5m : na, color=ta.change(pivot_low_5m) ? na : #ffbf00, offset = -bars - 1, linewidth=2, title="Support M5") resistance_high_15m = plot(show_15m ? pivot_high_15m : na, color=ta.change(pivot_high_15m) ? na : #00aeffdd, offset = -bars - 1, linewidth=2, title="Resistance M15") resistance_low_15m = plot(show_15m ? pivot_low_15m : na, color=ta.change(pivot_low_15m) ? na : #ffbf00dd, offset = -bars - 1, linewidth=2, title="Support M15") resistance_high_30m = plot(show_30m ? pivot_high_30m : na, color=ta.change(pivot_high_30m) ? na : #00aeffbb, offset = -bars - 1, linewidth=2, title="Resistance M30") resistance_low_30m = plot(show_30m ? pivot_low_30m : na, color=ta.change(pivot_low_30m) ? na : #ffbf00bb, offset = -bars - 1, linewidth=2, title="Support M30") resistance_high_1h = plot(show_1h ? pivot_high_1h : na, color=ta.change(pivot_high_1h) ? na : #00aeff90, offset = -bars - 1, linewidth=2, title="Resistance H1") resistance_low_1h = plot(show_1h ? pivot_low_1h : na, color=ta.change(pivot_low_1h) ? na : #ffbf0090, offset = -bars - 1, linewidth=2, title="Support H1") resistance_high_4h = plot(show_4h ? pivot_high_4h : na, color=ta.change(pivot_high_4h) ? na : #00aeff70, offset = -bars - 1, linewidth=2, title="Resistance H4") resistance_low_4h = plot(show_4h ? pivot_low_4h : na, color=ta.change(pivot_low_4h) ? na : #ffbf0070, offset = -bars - 1, linewidth=2, title="Support H4") resistance_high_d = plot(show_d ? pivot_high_d : na, color=ta.change(pivot_high_d) ? na : #00aeff50, offset = -bars - 1, linewidth=2, title="Resistance Daily") resistance_low_d = plot(show_d ? pivot_low_d : na, color=ta.change(pivot_low_d) ? na : #ffbf0050, offset = -bars - 1, linewidth=2, title="Support Daily") resistance_high_w = plot(show_w ? pivot_high_w : na, color=ta.change(pivot_high_w) ? na : #00aeff30, offset = -bars - 1, linewidth=2, title="Resistance Weekly") resistance_low_w = plot(show_w ? pivot_low_w : na, color=ta.change(pivot_low_w) ? na : #ffbf0030, offset = -bars - 1, linewidth=2, title="Support Weekly") resistance_high_c = plot(show_c ? pivot_high_c : na, color=ta.change(pivot_high_c) ? na : #ff0040, offset = -bars - 1, linewidth=2, title="Resistance Current Timeframe") resistance_low_c = plot(show_c ? pivot_low_c : na, color=ta.change(pivot_low_c) ? na : #6aff00, offset = -bars - 1, linewidth=2, title="Support Current Timeframe") // Adaptive Moving Average plot_ama = input.bool(false, title = "Adaptive Moving Average") ama_length = input.int(15, title = "Line Length") amarc = close float ama = 0 hh = math.max(math.sign(ta.change(ta.highest(ama_length))),0) ll = math.max(math.sign(ta.change(ta.lowest(ama_length))*-1),0) tc = math.pow(ta.sma(hh or ll ? 1 : 0,ama_length),2) ama := nz(ama[1]+tc*(amarc-ama[1]),amarc) garis_ama = plot(plot_ama ? ama : na,"Adaptive Moving Average",#ffffff,2)
RSI Objective Lines
https://www.tradingview.com/script/tlYXydXK-RSI-Objective-Lines/
Sofien-Kaabar
https://www.tradingview.com/u/Sofien-Kaabar/
108
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Sofien-Kaabar //@version=5 indicator("RSI Objective Lines") lookback = input(defval = 200, title = 'Lookback') threshold = input(defval = 0.05, title = 'Threshold') rsi_high = ta.rsi(high, 14) rsi_low = ta.rsi(low, 14) // calculating the maximum range max_range = ta.highest(rsi_high, lookback) - ta.lowest(rsi_low, lookback) // support support = ta.lowest(rsi_low, lookback) + (max_range * threshold) // resistance resistance = ta.highest(rsi_high, lookback) - (max_range * threshold) plot(ta.rsi(close, 14)) plot(support, color = ta.rsi(close, 14) > support? color.green : na) plot(resistance, color = ta.rsi(close, 14) < resistance? color.red : na)
Outlier Detecting Cumulative Moving Average (ODCMA)
https://www.tradingview.com/script/GO0XuJCt-Outlier-Detecting-Cumulative-Moving-Average-ODCMA/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
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/ // Β© peacefulLizard50262 //@version=5 indicator("ODCMA", overlay = true) filter(float src, int len = 1) => var float filter = na filter := ta.cum((src + (src[1] * 2) + (src[2] * 2) + src[3])/6) len > 0 ? (filter - filter[len])/len : src normalize(float src, int len) => out = (src - ta.lowest(src, len)) / (ta.highest(src, len) - ta.lowest(src, len)) out outlier(series float source, int periods = 30, float max = 2, int length = 100, bool other = false) => float out = math.abs(((source - source[1])/math.sqrt((math.sum(math.pow(source - source[1], 2), periods) - math.pow(source - source[1], 2))/(periods - 2)))) float tr = open > close ? -normalize(high - low, length) : normalize(high - low, length) outlier_tr = tr > 0.5 ? true : tr < -0.5 ? true : false outlier = out >= max ? true : false other ? outlier_tr : outlier outlier_volume(series float source, int periods = 30, float max = 2, int length = 100, bool other = false) => volume_high = open < close ? volume : 0 volume_low = open > close ? -volume : 0 float out = math.abs(((source - source[1])/math.sqrt((math.sum(math.pow(source - source[1], 2), periods) - math.pow(source - source[1], 2))/(periods - 2)))) float tr = open > close ? -normalize(volume_high - volume_low, length) : normalize(volume_high - volume_low, length) outlier_tr = tr > 0.5 ? true : tr < -0.5 ? true : false outlier = out >= max other ? outlier_tr : outlier odma(float src = close, int len = 20, float max = 2, string swch = "Price", int length = 100, bool other = false, bool ext = na, int smoothing = 0) => // TODO: You will need an input string forisNewPeriod. var float rolling_length = na var float swma = na var bool outlier = na var bool outlier_vol = na outlier := outlier(src, len, max, length, other) outlier_vol := outlier(volume, len, max, length, false) outlier := outlier(src, len, max, length, other) outlier_swch = swch == "Price" ? outlier : swch == "Volume" ? outlier_vol : swch == "Price or Volume" ? outlier or outlier_vol : swch == "Price and Volume" ? outlier and outlier_vol : ext rolling_length := outlier_swch ? 1 : 1 + rolling_length[1] swma := outlier_swch ? math.avg(src, src[1]) : src + swma[1] result = ta.wma(ta.sma(swma / rolling_length, 2), 3) filter(result, smoothing) odvwap(float src = close, int len = 200, float max = 3, string swch = "Volume", int length = 100, bool other = false, bool ext = na, int smoothing = 0) => // TODO: You will need an input string forisNewPeriod. var float sumSrcVol = na var float sumVol = na var bool outlier = na var bool outlier_vol = na outlier_vol := outlier_volume(volume, len, max, length, other) outlier := outlier(src, len, max, length, other) outlier_swch = swch == "Price" ? outlier : swch == "Volume" ? outlier_vol : swch == "Price or Volume" ? outlier or outlier_vol : swch == "Price and Volume" ? outlier and outlier_vol : ext sumSrcVol := outlier_swch ? math.avg(src * volume, src[1] * volume[1]) : src * volume + sumSrcVol[1] sumVol := outlier_swch ? math.avg(volume, volume[1]) : volume + sumVol[1] result = sumSrcVol / sumVol filter(result, smoothing) src = input.source(close, "Source") smoothing = input.int(0, "Smoothing", 0) weight = input.bool(true, "Volume Weighting") swch = input.string("Price and Volume", "Outlier Detection", ["Price","Volume","Price or Volume","Price and Volume", "Pivot Point"]) len = input.int(30, "Outlier Length", 2) max = input.float(3, "Outlier Detection Level", 0) other = input.bool(false, "True Range Detection", "Enable to use true range instead of standard deviation") length = input.int(100, "True Range Normalization Length") leftLenH = input.int(10, "Pivot High", 1, inline="Pivot High", group= "Pivot Points") rightLenH = input.int(10, "/", 1, inline="Pivot High", group= "Pivot Points") leftLenL = input.int(10, "Pivot Low", 1, inline="Pivot Low", group= "Pivot Points") rightLenL = input.int(10, "/", 1, inline="Pivot Low", group= "Pivot Points") pivot = ta.pivothigh(leftLenH, rightLenH) or ta.pivotlow(leftLenL, rightLenL) ma() => switch weight true => odvwap(src, len, max, swch, length, other, pivot, smoothing) false => odma(src, len, max, swch, length, other, pivot, smoothing) plot(ma())
Daily Session Windows background highlight indicator
https://www.tradingview.com/script/7qMP6NVY-Daily-Session-Windows-background-highlight-indicator/
SacroMacro
https://www.tradingview.com/u/SacroMacro/
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/ // Β© SacroMacro //@version=5 indicator("Daily Session Windows", overlay=true) same_as_instrument = "Same as instrument" group = "Daily segments" gmtSelect = input.string(title="Reference time zone", defval=same_as_instrument, options=[same_as_instrument, "Pacific/Honolulu","America/Los_Angeles","America/Phoenix","America/Vancouver","America/El_Salvador","America/Bogota","America/Chicago","America/New_York","America/Toronto","America/Argentina/Buenos_Aires","America/Sao_Paulo" ,"Etc/UTC" ,"Europe/London" ,"Europe/Berlin" ,"Europe/Madrid" ,"Europe/Paris" ,"Europe/Warsaw" ,"Europe/Athens" ,"Europe/Moscow" ,"Asia/Tehran" ,"Asia/Dubai" ,"Asia/Ashkhabad" ,"Asia/Kolkata" ,"Asia/Almaty" ,"Asia/Bangkok" ,"Asia/Hong_Kong" ,"Asia/Shanghai" ,"Asia/Singapore" ,"Asia/Taipei" ,"Asia/Seoul" ,"Asia/Tokyo" ,"Australia/ACT" ,"Australia/Adelaide" ,"Australia/Brisbane" ,"Australia/Sydney" ,"Pacific/Auckland" ,"Pacific/Fakaofo" ,"Pacific/Chatham"], group=group, confirm=true) premarketColor = input.color(color.blue, "", group=group, confirm=true, inline="premarket") premarketTime = input.session('0830-0930', title = "Premarket", group=group, confirm=true, inline="premarket") coreColor = input.color(color.lime, "", group=group, confirm=true, inline="core") coreTime = input.session('0930-1630', title = "Core session", group=group, confirm=true, inline="core") lunchColor = input.color(color.yellow, "", group=group, confirm=true, inline="lunch") lunchTime = input.session('1200-1300', title = "Lunch hour", group=group, confirm=true, inline="lunch") extColor = input.color(color.blue, "", group=group, confirm=true, inline="ext") extTime = input.session('1630-2000', title = "Aftermarket", group=group, confirm=true, inline="ext") offEnabled = input.bool(defval=false, title="Market closed", tooltip="Enable to also highlight market-closed time", group=group, confirm=true, inline="closed") offColor = input.color(color.black, "", group=group, confirm=true, inline="closed") transparency = input.int(title="Trasparency (%)", defval=90, confirm=true, group=group, minval = 0, maxval = 100) weekdays = "Week days" on_mon = input.bool(defval=true, title="Monday", group=weekdays, confirm=true, inline="r1") on_tue = input.bool(defval=true, title="Tuesday", group=weekdays, confirm=true, inline="r1") on_wed = input.bool(defval=true, title="Wednesday", group=weekdays, confirm=true, inline="r1") on_thu = input.bool(defval=true, title="Thursday", group=weekdays, confirm=true, inline="r2") on_fri = input.bool(defval=true, title="Friday", group=weekdays, confirm=true, inline="r2") on_sat = input.bool(defval=false, title="Saturday", group=weekdays, confirm=true, inline="r2") on_sun = input.bool(defval=false, title="Sunday", group=weekdays, confirm=true) session_weekdays = ':' if on_sun session_weekdays := session_weekdays + "1" if on_mon session_weekdays := session_weekdays + "2" if on_tue session_weekdays := session_weekdays + "3" if on_wed session_weekdays := session_weekdays + "4" if on_thu session_weekdays := session_weekdays + "5" if on_fri session_weekdays := session_weekdays + "6" if on_sat session_weekdays := session_weekdays + "7" if gmtSelect == same_as_instrument gmtSelect := syminfo.timezone _premarketColor = color.new(premarketColor, transparency) _coreColor = color.new(coreColor, transparency) _lunchColor = color.new(lunchColor, transparency) _extColor = color.new(extColor, transparency) _offColor = color.new(offColor, 100) if offEnabled _offColor := color.new(offColor, transparency) theColor() => // return bgcolor for current timeframe _ret = _offColor if not na(time(timeframe.period, premarketTime+session_weekdays, gmtSelect)) _ret := _premarketColor if not na(time(timeframe.period, extTime+session_weekdays, gmtSelect)) _ret := _extColor if not na(time(timeframe.period, coreTime+session_weekdays, gmtSelect)) _ret := _coreColor if not na(time(timeframe.period, lunchTime+session_weekdays, gmtSelect)) _ret := _lunchColor _ret bgcolor(color = theColor())
Directional Sentiment Line
https://www.tradingview.com/script/TqT9WE4n-Directional-Sentiment-Line/
Steversteves
https://www.tradingview.com/u/Steversteves/
277
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // /$$$$$$ /$$ /$$ // /$$__ $$ | $$ | $$ //| $$ \__//$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$ //| $$$$$$|_ $$_/ /$$__ $$| $$ /$$//$$__ $$ /$$__ $$ /$$_____/|_ $$_/ /$$__ $$| $$ /$$//$$__ $$ /$$_____/ // \____ $$ | $$ | $$$$$$$$ \ $$/$$/| $$$$$$$$| $$ \__/| $$$$$$ | $$ | $$$$$$$$ \ $$/$$/| $$$$$$$$| $$$$$$ // /$$ \ $$ | $$ /$$| $$_____/ \ $$$/ | $$_____/| $$ \____ $$ | $$ /$$| $$_____/ \ $$$/ | $$_____/ \____ $$ //| $$$$$$/ | $$$$/| $$$$$$$ \ $/ | $$$$$$$| $$ /$$$$$$$/ | $$$$/| $$$$$$$ \ $/ | $$$$$$$ /$$$$$$$/ // \______/ \___/ \_______/ \_/ \_______/|__/ |_______/ \___/ \_______/ \_/ \_______/|_______/ // ___________________ // / \ // / _____ _____ \ // / / \ / \ \ // __/__/ \____/ \__\_____ //| ___________ ____| // \_________/ \_________/ // \ /////// / // \///////// // Β© Steversteves //@version=5 indicator("Directional Sentiment Line [SS]", shorttitle = "DSL [SS]", overlay=true, max_bars_back = 5000, max_labels_count = 500) // Groups g1 = "Settings" g2 = "Plots" lengthInput = input.int(75, "Length", minval = 2, group = g1) atr_len = input.int(500, "ATR Length", group = g1) learn = input.int(500, "Training Time for Buy/Sell", group = g1) hi_lo_plt = input.bool(false, "Plot Highest and Lowest Price", group = g2) plot_atr = input.bool(true, "Plot High and Low Target Boxes", group = g2) plot_cross = input.bool(true, "Plot Crossovers/Unders", group = g2) plot_signals = input.bool(true, "Plot Buy and Sell Signals", group = g2) // Determine variables hi = ta.sma(high, lengthInput) lo = ta.sma(low, lengthInput) cl = ta.sma(close, lengthInput) op = ta.sma(open, lengthInput) // Lowest vs highest lowest = ta.lowest(lo, lengthInput) highest = ta.highest(hi, lengthInput) // bools for ribbon bool closeabove = close >= cl bool closebelow = close <= cl bool highabove = high >= hi bool lowabove = low >= lo bool openabove = open >= op // bools for highest/lowest bool paabovehigh = close > highest bool pabelowlow = close < lowest bool middle = close >= lo and close <= hi // Colours color bull = color.green color bear = color.red color neutral = color.orange color standard = color.blue color fillcolorbull = color.new(color.lime, 75) color fillcolorbear = color.new(color.red, 75) color fillcolorneutral = color.new(color.gray, 75) // Determine Colour color hicolor = highabove ? bull : bear color locolor = lowabove ? bull : bear color opcolor = openabove ? bull : bear color clcolor = closeabove ? bull : bear color lowestcolor = pabelowlow ? neutral : standard color highestcolor = paabovehigh ? neutral : standard color fillfinal = closeabove ? fillcolorbull : closebelow ? fillcolorbear : middle ? fillcolorneutral : na //Ribbon Plots hir = plot(hi, color = hicolor) lor = plot(lo, color = locolor) //plot(cl, color = hicolor) //plot(op, color = hicolor) // Fills fill(hir, lor, color = fillfinal, editable=false) // Band Plots plot(hi_lo_plt ? lowest : na, "Lowest Target", color = lowestcolor, linewidth=3) plot(hi_lo_plt ? highest : na, "Highest Target", color = highestcolor, linewidth=3) // Expand Range bool crossunder = ta.crossunder(close, lo)[3] and close[2] <= lo[2] and close[1] < lo[1] and close < lo bool crossover = ta.crossover(close, hi)[3] and close[2] >= hi[2] and close[1] > hi[1] and close > hi bool above_dsl = high > hi bool below_dsl = low < lo hi_array = array.new<float>() hi_reference = array.new<float>() lo_array = array.new<float>() lo_reference = array.new<float>() hi_dif = high - hi lo_dif = lo - low for i = 0 to atr_len if above_dsl[i] array.push(hi_array, hi_dif[i]) if below_dsl[i] array.push(lo_array, lo_dif[i]) if crossover[i] array.push(hi_reference, hi[i]) if crossunder[i] array.push(lo_reference, lo[i]) hi_avg_from_array = array.avg(hi_array) hi_max = array.max(hi_array) lo_avg_from_array = array.avg(lo_array) lo_max = array.max(lo_array) var box lo_box = na var box hi_box = na if barstate.isconfirmed and plot_atr if crossover box.delete(hi_box), box.delete(lo_box) hi_box := box.new(bar_index[1], array.get(hi_reference, 0) + hi_max, bar_index, array.get(hi_reference, 0) + hi_avg_from_array, bgcolor = fillcolorbull, border_color = fillcolorbull, extend = extend.right) if crossunder box.delete(lo_box), box.delete(hi_box) lo_box := box.new(bar_index[1], array.get(lo_reference, 0) - lo_avg_from_array, bar_index, array.get(lo_reference, 0) - lo_max, bgcolor = fillcolorbear, border_color = fillcolorbear, extend = extend.right) // Plot crossovers / unders plotshape(plot_cross and crossover ? low : na, title="Up Arrow", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green) plotshape(plot_cross and crossunder ? high : na, title="Down Arrow", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red) // Max Distance hi_distance = math.sqrt(math.pow(close - hi,2)) lo_distance = math.sqrt(math.pow(lo - close,2)) hi_dist_array = array.new_float() lo_dist_array = array.new_float() for i = 0 to learn if above_dsl[i] array.push(hi_dist_array, hi_distance[i]) if below_dsl[i] array.push(lo_dist_array, lo_distance[i]) hi_dist_max = array.max(hi_dist_array) lo_dist_max = array.min(lo_dist_array) var int hi_counter = 0 var int lo_counter = 0 if above_dsl and hi_distance >= hi_dist_max and plot_signals hi_counter += 1 if hi_counter >= 5 label.new(bar_index, high, color = color.red, text = "Short") hi_counter := 0 if below_dsl and lo_distance <= lo_dist_max and plot_signals lo_counter += 1 if lo_counter >= 5 label.new(bar_index, low, text = "Long", color = color.lime, style = label.style_label_up) lo_counter := 0
Smooth Stochastic and RSI Combo
https://www.tradingview.com/script/9xyRcwEX-Smooth-Stochastic-and-RSI-Combo/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
155
study
5
MPL-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("Stochastic and RSI", "SRSI") rsi_length = input.int(14, "RSI Length") sto_length = input.int(14, "Stochastic Length") smoothing = input.int(9, "Smoothing") rsi = (ta.rsi(ta.wma(close, smoothing), rsi_length) / 100) * 100 sto = (ta.sma(ta.stoch(ta.wma(close, smoothing), ta.wma(high, smoothing), ta.wma(low, smoothing), sto_length), smoothing) / 100) * 100 // plotbar(rsi, math.max(rsi, sto), math.min(rsi, sto), sto, color = math.avg(rsi, sto) > math.avg(rsi[1], sto[1]) ? color.green : color.red) r = plot(rsi, "RSI", color.red) s = plot(sto, "Stochastic", color.green) // fill(r, s, color = math.avg(rsi, sto) > math.avg(rsi[1], sto[1]) ? color.green : color.red) hline(50) up = plot(75, color = color.gray) dn = plot(25, color = color.gray) fill(up, dn, color.new(color.blue, 95)) fill(up, r, color = rsi > 75 ? color.new(color.orange, 80) : na) fill(up, s, color = sto > 75 ? color.new(color.orange, 80) : na) fill(dn, r, color = rsi < 25 ? color.new(color.orange, 80) : na) fill(dn, s, color = sto < 25 ? color.new(color.purple, 80) : na)
Volume composition / quantifytools
https://www.tradingview.com/script/d4TDeuRU-Volume-composition-quantifytools/
quantifytools
https://www.tradingview.com/u/quantifytools/
3,061
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© quantifytools //@version=5 indicator("Volume composition", overlay=false, max_boxes_count=500, max_lines_count = 500, max_labels_count=500) // Inputs //Volume inputs groupVol = "Volume settings" i_smoothingType = input.string("SMA", "Volume moving average", options=["SMA", "EMA", "HMA", "RMA", "WMA"], group=groupVol, inline="ma") i_volSmaLength = input.int(20, "", group=groupVol, inline="ma") i_source = input.source(close, "Source for volume direction", group=groupVol, tooltip="E.g. current close > previous close = buy volume.") i_volThreshold = input.int(70, "High volume threshold %", maxval=100, minval=1, group=groupVol) i_volAThreshold = input.int(70, "High active volume threshold %", maxval=100, minval=1, group=groupVol) //Volume source inputs groupSource = "Volume source" i_symbolBool = input.bool(false, "Override chart volume with custom symbol volume", group=groupSource) i_symbolVolume = input.symbol("BTCUSDT", "Symbol for volume data", group=groupSource) //Timeframe inputs groupTf = "Timeframe settings" i_tf1 = input.timeframe("1", "LTF for charts <= 30 min", group=groupTf, tooltip="Choose which timeframes are used for volume data when viewed within a given timeframe bracket. E.g. volume data is pulled from 1 minute timeframe when viewing charts at or below 30 min. The lower the chosen timeframe, the more precision you get, but with the cost of less historical data.") i_tf2 = input.timeframe("5", "LTF for charts > 30 min & <= 3 hours", group=groupTf) i_tf3 = input.timeframe("15", "LTF for charts > 3 hours & <= 8 hours", group=groupTf) i_tf4 = input.timeframe("60", "LTF for charts > 8 hours & <= 1D", group=groupTf) i_tf5 = input.timeframe("120", "LTF for charts > 1D & <= 3D", group=groupTf) i_tf6 = input.timeframe("240", "LTF for charts > 3D", group=groupTf) //Visual inputs groupVisuals = "Visual settings" i_displayMode = input.bool(false, "Round percentage values to single numbers", group=groupVisuals, tooltip="Helps with visual clutter when zooming out. Rounded to closest value, e.g. 54% = 5, 56% = 6.") i_buyVolCol = input.color(color.teal, "Buy volume", group=groupVisuals, inline="buy") i_buyVolACol = input.color(color.green, "Active", group=groupVisuals, inline="buy") i_sellVolCol = input.color(color.maroon, "Sell volume", group=groupVisuals, inline="sell") i_sellVolACol = input.color(color.red, "Active", group=groupVisuals, inline="sell") i_totalVolCol = input.color(color.gray, "Total volume", group=groupVisuals, inline="total") //Anomaly inputs groupMultiCond = "Multi-condition highlights" i_multiCondition = input.bool(false, "Multi-condition highlights", group=groupMultiCond, inline="multicond") i_multiConditionCol = input.color(color.yellow, "", group=groupMultiCond, inline="multicond",tooltip = "Overrides individual anomaly highlights with instances where all selected anomalies occured simultaneously. Example: highlight on a wick down with buy volume threshold and active buy volume threshold exceeded.") i_candleFormation = input.string("Close β–²", "Candle formation", options=["Close β–²", "Close β–Ό", "Reversal β–²", "Reversal β–Ό", "Expansion β–²", "Expansion β–Ό"], group=groupMultiCond, inline="candle") i_candleFormationBool = input.bool(false, "", group=groupMultiCond, inline="candle") i_volMultiplier = input.float(1, "Volume multiplier", 0.05, 100, step=0.05, inline="volmult", group=groupMultiCond) i_volMultiplierBool = input.bool(false, "", group=groupMultiCond, inline="volmult") groupAnomaly = "Anomaly highlights" i_highlightDomBuyVol = input.bool(false, "Buy volume threshold exceeded", group=groupAnomaly, inline="buyvol") i_domBuyVolCol = input.color(color.teal, "", group=groupAnomaly, inline="buyvol", tooltip="Colorizes candles on your chart where selected volume anomaly has occured. Useful for gaining reference from the past to get an idea what to expect in the future. Note that context matters a lot.") i_highlightDomABuyVol = input.bool(false, "Active buy volume threshold exceeded", group=groupAnomaly, inline="buyvola") i_domABuyVolCol = input.color(color.green, "", group=groupAnomaly, inline="buyvola") i_highlightDomSellVol = input.bool(false, "Sell volume threshold exceeded", group=groupAnomaly, inline="sellvol") i_domSellVolCol = input.color(color.maroon, "", group=groupAnomaly, inline="sellvol") i_highlightDomASellVol = input.bool(false, "Active sell volume threshold exceeded", group=groupAnomaly, inline="sellvola") i_domASellVolCol = input.color(color.red, "", group=groupAnomaly, inline="sellvola") i_highlightDivergence = input.bool(false, "Passive-active volume divergence", group=groupAnomaly, inline="divergence") i_divergenceCol = input.color(color.fuchsia, "", group=groupAnomaly, inline="divergence") // LTF calculations //If bool is false, use chart symbol, else symbol defined via input menu volumeSource = i_symbolBool == false ? syminfo.tickerid : i_symbolVolume //Convert current timeframe into minutes currentTimeframe = timeframe.in_seconds(timeframe.period) / 60 //Dynamic timeframe logic dynTf = currentTimeframe <= 30 ? i_tf1 : currentTimeframe > 30 and currentTimeframe <= 180 ? i_tf2 : currentTimeframe > 180 and currentTimeframe <= 480 ? i_tf3 : currentTimeframe > 480 and currentTimeframe <= 1440 ? i_tf4 : currentTimeframe > 1440 and currentTimeframe <= 4320 ? i_tf5 : currentTimeframe > 4320 ? i_tf6 : na //Fetching LTF volume ltfStats() => buyVol = i_source >= i_source[1] ? volume : 0 sellVol = i_source < i_source[1] ? volume : 0 buyVolActive = i_source >= i_source[1] and volume > volume[1] ? volume : 0 sellVolActive = i_source < i_source[1] and volume > volume[1] ? volume : 0 [buyVol, sellVol, i_source, volume, buyVolActive, sellVolActive] [buyVol, sellVol, ltfSrc, ltfVolume, buyVolActive, sellVolActive] = request.security_lower_tf(volumeSource, dynTf, ltfStats()) // Arrays //Sums of sell volume, buy volume and active volumes totalSellVol = array.sum(sellVol) totalBuyVol = array.sum(buyVol) totalVol = totalSellVol + totalBuyVol totalSellVolA = array.sum(sellVolActive) totalBuyVolA = array.sum(buyVolActive) totalVolA = totalSellVolA + totalBuyVolA //Directional volume % of total volume and directional active volume % of total active volume buyVolPerc = (totalBuyVol / totalVol) sellVolPerc = (totalSellVol / totalVol) buyVolPercA = (totalBuyVolA / totalVolA) sellVolPercA = (totalSellVolA / totalVolA) //Defining high buy/sell volume highBuyVol = buyVolPerc * 100 >= i_volThreshold highSellVol = sellVolPerc * 100 >= i_volThreshold //Defining high active buy/sell volume highBuyVolA = buyVolPercA * 100 >= i_volAThreshold highSellVolA = sellVolPercA * 100 >= i_volAThreshold //Defining volume-active volume divergence ActiveVolDisagreement = (buyVolPercA > sellVolPercA and buyVolPerc < sellVolPerc) or (buyVolPercA < sellVolPercA and buyVolPerc > sellVolPerc) //Total volume MA smoothedValue(source, length) => i_smoothingType == "SMA" ? ta.sma(source, length) : i_smoothingType == "EMA" ? ta.ema(source, length) : i_smoothingType == "HMA" ? ta.hma(source, length) : i_smoothingType == "RMA" ? ta.rma(source, length) : ta.wma(source, length) volSma = smoothedValue(totalVol, i_volSmaLength) // Multi-condition highlights //Volume anomaly conditions highBuyVolStudy = i_multiCondition and i_highlightDomBuyVol ? highBuyVol : na(close) == false highBuyAVolStudy = i_multiCondition and i_highlightDomABuyVol ? highBuyVolA : na(close) == false highSellVolStudy = i_multiCondition and i_highlightDomSellVol ? highSellVol : na(close) == false highSellAVolStudy = i_multiCondition and i_highlightDomASellVol ? highSellVolA : na(close) == false volDivStudy = i_multiCondition and i_highlightDivergence ? ActiveVolDisagreement : na(close) == false //Additional conditions //Open and close position closePos = (close - low) / (high - low) openPos = (open - low) / (high - low) //Engulfings. Defined by higher high, lower low with a close at 60%/40% of bar range (0% being the very low, 100% being the very high) engulfingUp = high > high[1] and low < low[1] and closePos > 0.60 engulfingDown = high > high[1] and low < low[1] and closePos < 0.40 //Wicks. Defined by higher high, higher low or lower high, lower low with a close at 60%/40% and open at 40%/60% of bar range. wickUp = high < high[1] and low < low[1] and closePos > 0.60 and openPos > 0.40 wickDown = high > high[1] and low > low[1] and closePos < 0.40 and openPos < 0.60 //Expansions. Defined by higher high, higher low or lower high, lower low with a close at 70% of bar range and range 1.5x higher than previous. barRange = high - low expUp = high > high[1] and low > low[1] and closePos > 0.70 and barRange > (barRange[1] * 1.5) expDown = high < high[1] and low < low[1] and closePos < 0.30 and barRange > (barRange[1] * 1.5) //Specified price related condition candleFormStudy = i_multiCondition and i_candleFormation == "Close β–²" and i_candleFormationBool ? close > close[1] : i_multiCondition and i_candleFormation == "Close β–Ό" and i_candleFormationBool ? close < close[1] : i_multiCondition and i_candleFormation == "Reversal β–²" and i_candleFormationBool ? wickUp or engulfingUp : i_multiCondition and i_candleFormation == "Reversal β–Ό" and i_candleFormationBool ? wickDown or engulfingDown : i_multiCondition and i_candleFormation == "Expansion β–²" and i_candleFormationBool ? expUp : i_multiCondition and i_candleFormation == "Expansion β–Ό" and i_candleFormationBool ? expDown : na(close) == false //Volume multiplier condition volMultStudy = i_volMultiplierBool ? totalVol >= (volSma * i_volMultiplier) : na(close) == false //Spcified anomaly studiedAnomaly = highBuyVolStudy and highBuyAVolStudy and highSellVolStudy and highSellAVolStudy and volDivStudy and candleFormStudy and volMultStudy //No studies selected condition allStudiesNa = i_highlightDomBuyVol == false and i_highlightDomABuyVol == false and i_highlightDomSellVol == false and i_highlightDomASellVol == false and i_highlightDivergence == false and i_candleFormationBool == false and i_volMultiplierBool == false //Defining multi-condition anomaly multiCondAnomaly = i_multiCondition and studiedAnomaly and allStudiesNa == false //Initializing anomaly counter var int anomalyCount = 0 //If multi-condition anomaly found, add 1 to counter if multiCondAnomaly anomalyCount += 1 //Anomaly counter text for table countText = i_multiCondition and allStudiesNa == true ? "Matches: " + str.tostring(0) + "┃" : i_multiCondition and allStudiesNa == false ? "Matches: " + str.tostring(anomalyCount) + "┃" : "" // Plot related calculations //If rounded display mode is true, round percentages to single values, else percentage values with no decimals. roundedBuyVol = i_displayMode == true ? math.round(10 * buyVolPerc, 0) : math.round(buyVolPerc, 2) * 100 roundedSellVol = i_displayMode == true ? math.round(10 * sellVolPerc, 0) : math.round(sellVolPerc, 2) * 100 roundedBuyVolA = i_displayMode == true ? math.round(10 * buyVolPercA, 0) : math.round(buyVolPercA, 2) * 100 roundedSellVolA = i_displayMode == true ? math.round(10 * sellVolPercA, 0) : math.round(sellVolPercA, 2) * 100 //Dominant volume, dominant active volume and appropriate colors dominantVolPerc = totalBuyVol >= totalSellVol ? roundedBuyVol : roundedSellVol dominantVolAPerc = totalBuyVolA >= totalSellVolA ? roundedBuyVolA : roundedSellVolA dominantVolAbsolute = totalBuyVol >= totalSellVol ? totalBuyVol : totalSellVol dominantVolAAbsolute = totalBuyVolA >= totalSellVolA ? totalBuyVolA : totalSellVolA dominantVolCol = totalBuyVol >= totalSellVol ? i_buyVolCol : i_sellVolCol dominantVolACol = totalBuyVolA >= totalSellVolA ? i_buyVolACol : i_sellVolACol // Labels, lines, tables //If volume data is NA (holidays, weekends etc.), plot no text instead of NaN dataNotNa = na(totalVol) == false and totalVol > 0 aDataNotNa = na(totalVolA) == false and totalVolA > 0 //Label text for active volume direction and () to indicate divergences ActiveText = totalBuyVolA >= totalSellVolA and ActiveVolDisagreement == false ? "+" : totalBuyVolA >= totalSellVolA and ActiveVolDisagreement == true ? "(+)" : totalBuyVolA < totalSellVolA and ActiveVolDisagreement == false ? "-" : totalBuyVolA < totalSellVolA and ActiveVolDisagreement == true ? "(-)" : "" //Label text for indicating high active volume ActiveText2 = highBuyVolA or highSellVolA ? "β–²" : "" //Constructing text for labels labelText1 = dataNotNa ? "" + str.tostring(dominantVolPerc) : "" labelText2 = aDataNotNa ? ActiveText + "\n" + str.tostring(dominantVolAPerc) + "\n" + ActiveText2 : "" //Labels, dominant volume %, dominant active volume % and highlights (divergences, threshold exceeded) if applicable label.new(x=bar_index, y=0, xloc=xloc.bar_index, text=labelText1, style=label.style_label_center, color=color.new(color.white, 100), textcolor=dominantVolCol, size=size.normal) label.new(x=bar_index, y=0, xloc=xloc.bar_index, text=labelText2, style=label.style_label_up, color=color.new(color.white, 100), textcolor=dominantVolACol, size=size.normal) //Line to fill gap between current bar index and next bar index, where real-time volume columns are halfway plotted. line.new(bar_index, 0, bar_index+1, 0, xloc=xloc.bar_index, color=color.rgb(38, 38, 38), width=18) //Initializing table var settingsTable = table.new(position = position.top_right, columns = 50, rows = 50, bgcolor = color.new(#2d2d2d, 100), border_width = 1, border_color=color.new(color.black, 100)) //Populating table cell tableSymbol = volumeSource == i_symbolVolume ? i_symbolVolume : syminfo.ticker table.cell(table_id = settingsTable, column = 1, row = 0, text = countText + str.tostring(tableSymbol) + " / " + str.tostring(dynTf) , text_color=color.white) // Plots //Plots for volume columns, SMA and 0 line pTotalVol = plot(totalBuyVol + totalSellVol, title="Total volume", color=i_totalVolCol, style=plot.style_columns, display=display.all - display.status_line) pDomVol = plot(dominantVolAbsolute, title="Dominating volume", color=dominantVolCol, style=plot.style_columns, display=display.all - display.status_line) pDomVolA = plot(dominantVolAAbsolute, title="Dominating active volume", color=dominantVolACol, style=plot.style_columns, display=display.all - display.status_line) pSma = plot(volSma, title="Volume SMA", color=color.white, style=plot.style_line, linewidth=1, display=display.all - display.status_line) p0 = plot(0, title="0 line", color=color.rgb(38, 38, 38), linewidth=18, display=display.all - display.status_line) //Plots for high buy/sell volume plotshape(highBuyVol and barstate.isconfirmed ? totalBuyVol + totalSellVol : na, title="High buy volume threshold exceeded", style=shape.diamond, text="", color=i_buyVolCol, location=location.absolute, size=size.auto, textcolor=color.white, display=display.all - display.status_line) plotshape(highSellVol and barstate.isconfirmed ? totalBuyVol + totalSellVol : na, title="High sell volume threshold exceeded", style=shape.diamond, text="", color=i_sellVolCol, location=location.absolute, size=size.auto, textcolor=color.white, display=display.all - display.status_line) plotshape(multiCondAnomaly ? totalBuyVol + totalSellVol : na, title="Multi-condition anomaly", style=shape.xcross, text="", color=i_multiConditionCol, location=location.absolute, size=size.tiny, textcolor=color.white, display=display.all - display.status_line) //Bar highlighter highlightCond = i_highlightDomBuyVol and highBuyVol ? i_domBuyVolCol : i_highlightDomSellVol and highSellVol? i_domSellVolCol : i_highlightDomABuyVol and highBuyVolA ? i_domABuyVolCol : i_highlightDomASellVol and highSellVolA ? i_domASellVolCol : i_highlightDivergence and ActiveVolDisagreement ? i_divergenceCol : na barcolor(i_multiCondition == false ? highlightCond : multiCondAnomaly ? i_multiConditionCol : na) // Alerts //Individual alertcondition(highBuyVol and barstate.isconfirmed, "Buy volume threshold exceeded", "Buy volume threshold exceeded anomaly detected.") alertcondition(highSellVol and barstate.isconfirmed, "Sell volume threshold exceeded", "Sell volume threshold exceeded anomaly detected.") alertcondition(highBuyVolA and barstate.isconfirmed, "Active buy volume threshold exceeded", "Active buy volume threshold exceeded anomaly detected.") alertcondition(highSellVolA and barstate.isconfirmed, "Active sell volume threshold exceeded", "Active sell volume threshold exceeded anomaly detected.") alertcondition(ActiveVolDisagreement and barstate.isconfirmed, "Volume/active volume divergence", "Volume/active volume divergence anomaly detected.") alertcondition(multiCondAnomaly and barstate.isconfirmed, "Multi-condition anomaly", "Multi-condition anomaly detected.") //Grouped alertcondition((highBuyVol or highSellVol) and barstate.isconfirmed, "Buy volume or sell volume threshold exceeded", "Buy volume or sell volume threshold exceeded anomaly detected.") alertcondition((highBuyVolA or highSellVolA) and barstate.isconfirmed, "Active buy volume or active sell volume threshold exceeded", "Active buy volume or sell volume threshold exceeded anomaly detected.") alertcondition((highBuyVolA or highSellVolA or highBuyVol or highSellVol or ActiveVolDisagreement) and barstate.isconfirmed, "Any volume anomaly (any type of volume threshold exceeded or volume/active volume divergence)", "A volume anomaly (any type of volume threshold exceeded or volume/active volume divergence) detected.")
MMA V2 Indicator - Blast
https://www.tradingview.com/script/lR4KkIoU-MMA-V2-Indicator-Blast/
MalikMMA
https://www.tradingview.com/u/MalikMMA/
171
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© LonesomeTheBlue //@version=5 indicator('MMA V2 Indicator - Blast by Malik Muntazir Abbas', 'MMA', overlay=true) prd = input.int(defval=10, title='Pivot Period', minval=4, maxval=30, group='Setup') ppsrc = input.string(defval='High/Low', title='Source', options=['High/Low', 'Close/Open'], group='Setup') maxnumpp = input.int(defval=20, title=' Maximum Number of Pivot', minval=5, maxval=100, group='Setup') ChannelW = input.int(defval=10, title='Maximum Channel Width %', minval=1, group='Setup') maxnumsr = input.int(defval=5, title=' Maximum Number of S/R', minval=1, maxval=10, group='Setup') min_strength = input.int(defval=2, title=' Minimum Strength', minval=1, maxval=10, group='Setup') labelloc = input.int(defval=20, title='Label Location', group='Colors', tooltip='Positive numbers reference future bars, negative numbers reference histical bars') linestyle = input.string(defval='Dashed', title='Line Style', options=['Solid', 'Dotted', 'Dashed'], group='Colors') linewidth = input.int(defval=2, title='Line Width', minval=1, maxval=4, group='Colors') resistancecolor = input.color(defval=color.red, title='Resistance Color', group='Colors') supportcolor = input.color(defval=color.lime, title='Support Color', group='Colors') showpp = input(false, title='Show Point Points') float src1 = ppsrc == 'High/Low' ? high : math.max(close, open) float src2 = ppsrc == 'High/Low' ? low : math.min(close, open) float ph = ta.pivothigh(src1, prd, prd) float pl = ta.pivotlow(src2, prd, prd) plotshape(ph and showpp, text='H', style=shape.labeldown, color=na, textcolor=color.new(color.red, 0), location=location.abovebar, offset=-prd) plotshape(pl and showpp, text='L', style=shape.labelup, color=na, textcolor=color.new(color.lime, 0), location=location.belowbar, offset=-prd) Lstyle = linestyle == 'Dashed' ? line.style_dashed : linestyle == 'Solid' ? line.style_solid : line.style_dotted //calculate maximum S/R channel zone width prdhighest = ta.highest(300) prdlowest = ta.lowest(300) cwidth = (prdhighest - prdlowest) * ChannelW / 100 var pivotvals = array.new_float(0) if ph or pl array.unshift(pivotvals, ph ? ph : pl) if array.size(pivotvals) > maxnumpp // limit the array size array.pop(pivotvals) get_sr_vals(ind) => float lo = array.get(pivotvals, ind) float hi = lo int numpp = 0 for y = 0 to array.size(pivotvals) - 1 by 1 float cpp = array.get(pivotvals, y) float wdth = cpp <= lo ? hi - cpp : cpp - lo if wdth <= cwidth // fits the max channel width? lo := cpp <= lo ? cpp : lo hi := cpp > lo ? cpp : hi numpp += 1 numpp [hi, lo, numpp] var sr_up_level = array.new_float(0) var sr_dn_level = array.new_float(0) sr_strength = array.new_float(0) find_loc(strength) => ret = array.size(sr_strength) for i = ret > 0 ? array.size(sr_strength) - 1 : na to 0 by 1 if strength <= array.get(sr_strength, i) break ret := i ret ret check_sr(hi, lo, strength) => ret = true for i = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1 //included? if array.get(sr_up_level, i) >= lo and array.get(sr_up_level, i) <= hi or array.get(sr_dn_level, i) >= lo and array.get(sr_dn_level, i) <= hi if strength >= array.get(sr_strength, i) array.remove(sr_strength, i) array.remove(sr_up_level, i) array.remove(sr_dn_level, i) ret else ret := false ret break ret var sr_lines = array.new_line(11, na) var sr_labels = array.new_label(11, na) for x = 1 to 10 by 1 rate = 100 * (label.get_y(array.get(sr_labels, x)) - close) / close label.set_text(array.get(sr_labels, x), text=str.tostring(label.get_y(array.get(sr_labels, x))) + '(' + str.tostring(rate, '#.##') + '%)') label.set_x(array.get(sr_labels, x), x=bar_index + labelloc) label.set_color(array.get(sr_labels, x), color=label.get_y(array.get(sr_labels, x)) >= close ? color.red : color.lime) label.set_textcolor(array.get(sr_labels, x), textcolor=label.get_y(array.get(sr_labels, x)) >= close ? color.white : color.black) label.set_style(array.get(sr_labels, x), style=label.get_y(array.get(sr_labels, x)) >= close ? label.style_label_down : label.style_label_up) line.set_color(array.get(sr_lines, x), color=line.get_y1(array.get(sr_lines, x)) >= close ? resistancecolor : supportcolor) if ph or pl //because of new calculation, remove old S/R levels array.clear(sr_up_level) array.clear(sr_dn_level) array.clear(sr_strength) //find S/R zones for x = 0 to array.size(pivotvals) - 1 by 1 [hi, lo, strength] = get_sr_vals(x) if check_sr(hi, lo, strength) loc = find_loc(strength) // if strength is in first maxnumsr sr then insert it to the arrays if loc < maxnumsr and strength >= min_strength array.insert(sr_strength, loc, strength) array.insert(sr_up_level, loc, hi) array.insert(sr_dn_level, loc, lo) // keep size of the arrays = 5 if array.size(sr_strength) > maxnumsr array.pop(sr_strength) array.pop(sr_up_level) array.pop(sr_dn_level) for x = 1 to 10 by 1 line.delete(array.get(sr_lines, x)) label.delete(array.get(sr_labels, x)) for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1 float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2) rate = 100 * (mid - close) / close array.set(sr_labels, x + 1, label.new(x=bar_index + labelloc, y=mid, text=str.tostring(mid) + '(' + str.tostring(rate, '#.##') + '%)', color=mid >= close ? color.red : color.lime, textcolor=mid >= close ? color.white : color.black, style=mid >= close ? label.style_label_down : label.style_label_up)) array.set(sr_lines, x + 1, line.new(x1=bar_index, y1=mid, x2=bar_index - 1, y2=mid, extend=extend.both, color=mid >= close ? resistancecolor : supportcolor, style=Lstyle, width=linewidth)) f_crossed_over() => ret = false for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1 float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2) if close[1] <= mid and close > mid ret := true ret ret f_crossed_under() => ret = false for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1 float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2) if close[1] >= mid and close < mid ret := true ret ret alertcondition(f_crossed_over(), title='Resistance Broken', message='Resistance Broken') alertcondition(f_crossed_under(), title='Support Broken', message='Support Broken')
Ross Hook Pattern (Expo)
https://www.tradingview.com/script/4zfdkTUK-Ross-Hook-Pattern-Expo/
Zeiierman
https://www.tradingview.com/u/Zeiierman/
1,891
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Zeiierman //@version=5 indicator("Ross Hook Pattern (Expo)",overlay=true,max_bars_back=5000,max_labels_count=500,max_lines_count=500) // ~~ ToolTips { t1 = "Set the Ross Hook Period - A high value returns long-term patterns, and a low value returns short-term patterns" t2 = "Set the minimum distance between point 2 and point 3. A high value indicates a bigger price correction before the price takes off again. A low value indicates a shorter price correction before the price takes off again." t3 = "Show pattern break, set the size, and coloring" t4 = "Show the Ross Hook" t5 = "Show the Ross Hook pattern" t6 = "Enable the HH/HL/LL/LH labels" // ~~} // ~~ Inputs { prd = input.int(20, minval=1,title="Set Period",tooltip=t1) dst = input.int(20,minval=0, title="Set Hook Distance",tooltip=t2) showBreak = input.bool(true,"Show Break", inline="break") showHook = input.bool(true,"Show Hook",tooltip=t4) showPattern = input.bool(false,"Show Pattern",tooltip=t5) showPvts = input.bool(false,"Show Pivots",tooltip=t6) visuell = input.string("Diamond","",options=["Diamond","XCross","Cross","Flag","Square"],inline="break") colBull = input.color(color.new(#31be0c,0),"",inline="break") colBear = input.color(color.new(#df3d3d,0),"",inline="break") size = input.string(size.tiny,"",options=[size.tiny,size.small,size.normal,size.large,size.huge],inline="break",tooltip=t3) shape = switch visuell "Diamond" => label.style_diamond "XCross" => label.style_xcross "Cross" => label.style_cross "Flag" => label.style_flag "Square" => label.style_square // ~~ } // ~~ Arrays { var pvts = array.new<float>(5,0.0) var idx = array.new<int>(5,0) // ~~ } // ~~ Pivots { pvtHi = ta.pivothigh(high,prd,prd) pvtLo = ta.pivotlow(low,prd,prd) var pos = 0 if not na(pvtHi) and pos<=0 if showPvts label.new(bar_index-prd,high[prd],text=pvtHi>array.get(pvts,1)?"HH":"LH",style=label.style_label_down,color=color(na),textcolor=chart.fg_color) array.pop(pvts) array.pop(idx) array.unshift(pvts,high[prd]) array.unshift(idx,bar_index-prd) pos := 1 if not na(pvtLo) and pos>=0 if showPvts label.new(bar_index-prd,low[prd],text=pvtLo>array.get(pvts,1)?"HL":"LL",style=label.style_label_up,color=color(na),textcolor=chart.fg_color) array.pop(pvts) array.pop(idx) array.unshift(pvts,low[prd]) array.unshift(idx,bar_index-prd) pos := -1 // ~~ } // ~~ Identify RossHook Pattern & Alerts { var Hook = true if ta.crossover(high,array.get(pvts,1)) and Hook if array.get(pvts,0)<array.get(pvts,1) if array.get(pvts,1)>array.get(pvts,3) and array.get(pvts,0)>array.get(pvts,2) and array.get(pvts,2)>array.get(pvts,4) and array.get(pvts,3)>array.get(pvts,2) first = bar_index-array.get(idx,4) sec = bar_index-array.get(idx,3) if bar_index-array.get(idx,1)>=prd for i=first to sec if close[i]>array.get(pvts,2) and array.get(idx,2)-bar_index[i]>=dst if showPattern line.new(bar_index-i,array.get(pvts,2),array.get(idx,2),array.get(pvts,2),color=chart.fg_color,style=line.style_dashed) mid = math.round(math.avg(bar_index-i,array.get(idx,2))) label.new(mid,array.get(pvts,2),text="First Hook",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) Hook := true break else Hook := false if Hook if showBreak label.new(bar_index,high,style=shape,color=colBull,size=size) if showHook line.new(array.get(idx,3),array.get(pvts,3),bar_index,array.get(pvts,3),color=chart.fg_color,style=line.style_dashed) label.new(math.round(math.avg(bar_index,array.get(idx,3))),array.get(pvts,3),text="Ross Hook",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) if showPattern line.new(array.get(idx,1),array.get(pvts,1),bar_index,array.get(pvts,1),color=chart.fg_color,style=line.style_dashed) label.new(math.round(math.avg(bar_index,array.get(idx,1))),array.get(pvts,1),text="Second Hook",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) label.new(array.get(idx,4),array.get(pvts,4),text="1",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) label.new(array.get(idx,3),array.get(pvts,3),text="2",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) label.new(array.get(idx,2),array.get(pvts,2),text="3",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) for i=array.size(pvts)-2 to 2 line.new(array.get(idx,i),array.get(pvts,i),array.get(idx,i+1),array.get(pvts,i+1),color=chart.fg_color) alert("Bullish Ross Hook Pattern Identified on: "+syminfo.ticker,alert.freq_once_per_bar_close) Hook := false if ta.crossunder(low,array.get(pvts,1)) and Hook if array.get(pvts,0)>array.get(pvts,1) if array.get(pvts,1)<array.get(pvts,3) and array.get(pvts,0)<array.get(pvts,2) and array.get(pvts,2)<array.get(pvts,4) and array.get(pvts,3)<array.get(pvts,2) first = bar_index-array.get(idx,4) sec = bar_index-array.get(idx,3) if bar_index-array.get(idx,1)>=prd for i=first to sec if close[i]<array.get(pvts,2) and array.get(idx,2)-bar_index[i]>=dst if showPattern line.new(bar_index-i,array.get(pvts,2),array.get(idx,2),array.get(pvts,2),color=chart.fg_color,style=line.style_dashed) mid = math.round(math.avg(bar_index-i,array.get(idx,2))) label.new(mid,array.get(pvts,2),text="First Hook",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) Hook := true break else Hook := false if Hook if showBreak label.new(bar_index,low,style=shape,color=colBear,size=size) if showHook line.new(array.get(idx,3),array.get(pvts,3),bar_index,array.get(pvts,3),color=chart.fg_color,style=line.style_dashed) label.new(math.round(math.avg(bar_index,array.get(idx,3))),array.get(pvts,3),text="Ross Hook",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) if showPattern line.new(array.get(idx,1),array.get(pvts,1),bar_index,array.get(pvts,1),color=chart.fg_color,style=line.style_dashed) label.new(math.round(math.avg(bar_index,array.get(idx,1))),array.get(pvts,1),text="Second Hook",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) label.new(array.get(idx,4),array.get(pvts,4),text="1",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) label.new(array.get(idx,3),array.get(pvts,3),text="2",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) label.new(array.get(idx,2),array.get(pvts,2),text="3",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) for i=array.size(pvts)-2 to 2 line.new(array.get(idx,i),array.get(pvts,i),array.get(idx,i+1),array.get(pvts,i+1),color=chart.fg_color) alert("Bearish Ross Hook Pattern Identified on: "+syminfo.ticker,alert.freq_once_per_bar_close) Hook := false // ~~ } // ~~ Debugger only check break once { if ta.change(array.get(pvts,1)) Hook := true // ~~ }
Portfolio_Tracking_TR
https://www.tradingview.com/script/xtzzHhRp/
volkankocabas
https://www.tradingview.com/u/volkankocabas/
1,563
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © @volkankocabas_ //@version=5 indicator("Portfây Takip", shorttitle="Portfây Takip", overlay = true) //Tables On/Off dataTableOn = input.bool(true, title="Tablo Aç/Kapa", group="Info Table") //Table Positions bright = position.bottom_right bleft = position.bottom_left bcenter = position.bottom_center tright = position.top_right tleft = position.top_left tcenter = position.top_center mright = position.middle_right mleft = position.middle_left mcenter = position.middle_center tablePosition = input.string(tright, title="Tablo Yeri", options=[bright, bleft, bcenter, tright, tleft, tcenter, mright, mleft, mcenter], group="Info Table") //Ticker #1 ticker1On = input.bool(true, title="Aç/Kapa", group="Hisse #1") ticker1 = input.symbol("BIST_DLY:GARAN", title="Ticker", group="Hisse #1") ticker1OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #1") ticker1EntryPrice = input.float( 1,title="Maliyet", group="Hisse #1") ticker1Price = request.security(ticker1, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker1PriceClose = request.security(ticker1, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker1Pnl = ticker1Price > ticker1EntryPrice ? ((ticker1Price - ticker1EntryPrice) / ticker1EntryPrice) : ((ticker1EntryPrice - ticker1Price) / ticker1EntryPrice) ticker1PnlText = ticker1Price > ticker1EntryPrice ? str.tostring(ticker1Pnl*100, format.percent) : "-" +str.tostring(ticker1Pnl*100, format.percent) ticker1Value = ticker1Price * ticker1OrderSize ticker1ValueText = str.tostring(ticker1Value) + " TL" if not ticker1On ticker1OrderSize := 0.0 ticker1Value := 0.0 //Ticker #2 ticker2On = input.bool(true, title="Aç/Kapa", group="Hisse #2") ticker2 = input.symbol("BIST_DLY:EREGL", title="Ticker", group="Hisse #2") ticker2OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #2") ticker2EntryPrice = input.float(1, title="Maliyet", group="Hisse #2") ticker2Price = request.security(ticker2, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker2PriceClose = request.security(ticker2, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker2Pnl = ticker2Price > ticker2EntryPrice ? ((ticker2Price - ticker2EntryPrice) / ticker2EntryPrice) : ((ticker2EntryPrice - ticker2Price) / ticker2EntryPrice) ticker2PnlText = ticker2Price > ticker2EntryPrice ? str.tostring(ticker2Pnl*100, format.percent) : "-" +str.tostring(ticker2Pnl*100, format.percent) ticker2Value = ticker2Price * ticker2OrderSize ticker2ValueText = str.tostring(ticker2Value) + " TL" if not ticker2On ticker2OrderSize := 0.0 ticker2Value := 0.0 //Ticker #3 ticker3On = input.bool(true, title="Aç/Kapa", group="Hisse #3") ticker3 = input.symbol("BIST_DLY:PETKM", title="Ticker", group="Hisse #3") ticker3OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #3") ticker3EntryPrice = input.float(1, title="Maliyet", group="Hisse #3") ticker3Price = request.security(ticker3, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker3PriceClose = request.security(ticker3, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker3Pnl = ticker3Price > ticker3EntryPrice ? ((ticker3Price - ticker3EntryPrice) / ticker3EntryPrice) : ((ticker3EntryPrice - ticker3Price) / ticker3EntryPrice) ticker3PnlText = ticker3Price > ticker3EntryPrice ? str.tostring(ticker3Pnl*100, format.percent) : "-" +str.tostring(ticker3Pnl*100, format.percent) ticker3Value = ticker3Price * ticker3OrderSize ticker3ValueText = str.tostring(ticker3Value) + " TL" if not ticker3On ticker3OrderSize := 0.0 ticker3Value := 0.0 //Ticker #4 ticker4On = input.bool(true, title="Aç/Kapa", group="Hisse #4") ticker4 = input.symbol("BIST_DLY:KRDMD", title="Ticker", group="Hisse #4") ticker4OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #4") ticker4EntryPrice = input.float(1, title="Maliyet", group="Hisse #4") ticker4Price = request.security(ticker4, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker4PriceClose = request.security(ticker4, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker4Pnl = ticker4Price > ticker4EntryPrice ? ((ticker4Price - ticker4EntryPrice) / ticker4EntryPrice) : ((ticker4EntryPrice - ticker4Price) / ticker4EntryPrice) ticker4PnlText = ticker4Price > ticker4EntryPrice ? str.tostring(ticker4Pnl*100, format.percent) : "-" +str.tostring(ticker4Pnl*100, format.percent) ticker4Value = ticker4Price * ticker4OrderSize ticker4ValueText = str.tostring(ticker4Value) + " TL" if not ticker4On ticker4OrderSize := 0.0 ticker4Value := 0.0 //Ticker #5 ticker5On = input.bool(true, title="Aç/Kapa", group="Hisse #5") ticker5 = input.symbol("BIST_DLY:KOZAL", title="Ticker", group="Hisse #5") ticker5OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #5") ticker5EntryPrice = input.float(1, title="Maliyet", group="Hisse #5") ticker5Price = request.security(ticker5, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker5PriceClose = request.security(ticker5, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker5Pnl = ticker5Price > ticker5EntryPrice ? ((ticker5Price - ticker5EntryPrice) / ticker5EntryPrice) : ((ticker5EntryPrice - ticker5Price) / ticker5EntryPrice) ticker5PnlText = ticker5Price > ticker5EntryPrice ? str.tostring(ticker5Pnl*100, format.percent) : "-" +str.tostring(ticker5Pnl*100, format.percent) ticker5Value = ticker5Price * ticker5OrderSize ticker5ValueText = str.tostring(ticker5Value) + " TL" if not ticker5On ticker5OrderSize := 0.0 ticker5Value := 0.0 //Ticker #6 ticker6On = input.bool(true, title="Aç/Kapa", group="Hisse #6") ticker6 = input.symbol("BIST_DLY:SISE", title="Ticker", group="Hisse #6") ticker6OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #6") ticker6EntryPrice = input.float(1, title="Maliyet", group="Hisse #6") ticker6Price = request.security(ticker6, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker6PriceClose = request.security(ticker6, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker6Pnl = ticker6Price > ticker6EntryPrice ? ((ticker6Price - ticker6EntryPrice) / ticker6EntryPrice) : ((ticker6EntryPrice - ticker6Price) / ticker6EntryPrice) ticker6PnlText = ticker6Price > ticker6EntryPrice ? str.tostring(ticker6Pnl*100, format.percent) : "-" +str.tostring(ticker6Pnl*100, format.percent) ticker6Value = ticker6Price * ticker6OrderSize ticker6ValueText = str.tostring(ticker6Value) + " TL" if not ticker6On ticker6OrderSize := 0.0 ticker6Value := 0.0 //Ticker #7 ticker7On = input.bool(true, title="Aç/Kapa", group="Hisse #7") ticker7 = input.symbol("BIST_DLY:TUPRS", title="Ticker", group="Hisse #7") ticker7OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #7") ticker7EntryPrice = input.float(1, title="Maliyet", group="Hisse #7") ticker7Price = request.security(ticker7, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker7PriceClose = request.security(ticker7, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker7Pnl = ticker7Price > ticker7EntryPrice ? ((ticker7Price - ticker7EntryPrice) / ticker7EntryPrice) : ((ticker7EntryPrice - ticker7Price) / ticker7EntryPrice) ticker7PnlText = ticker7Price > ticker7EntryPrice ? str.tostring(ticker7Pnl*100, format.percent) : "-" +str.tostring(ticker7Pnl*100, format.percent) ticker7Value = ticker7Price * ticker7OrderSize ticker7ValueText = str.tostring(ticker7Value) + " TL" if not ticker7On ticker7OrderSize := 0.0 ticker7Value := 0.0 //Ticker #8 ticker8On = input.bool(true, title="Aç/Kapa", group="Hisse #8") ticker8 = input.symbol("BIST_DLY:THYAO", title="Ticker", group="Hisse #8") ticker8OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #8") ticker8EntryPrice = input.float(1, title="Maliyet", group="Hisse #8") ticker8Price = request.security(ticker8, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker8PriceClose = request.security(ticker8, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker8Pnl = ticker8Price > ticker8EntryPrice ? ((ticker8Price - ticker8EntryPrice) / ticker8EntryPrice) : ((ticker8EntryPrice - ticker8Price) / ticker8EntryPrice) ticker8PnlText = ticker8Price > ticker8EntryPrice ? str.tostring(ticker8Pnl*100, format.percent) : "-" +str.tostring(ticker8Pnl*100, format.percent) ticker8Value = ticker8Price * ticker8OrderSize ticker8ValueText = str.tostring(ticker8Value) + " TL" if not ticker8On ticker8OrderSize := 0.0 ticker8Value := 0.0 //Ticker #9 ticker9On = input.bool(true, title="Aç/Kapa", group="Hisse #9") ticker9 = input.symbol("BIST_DLY:FROTO", title="Ticker", group="Hisse #9") ticker9OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #9") ticker9EntryPrice = input.float(1, title="Maliyet", group="Hisse #9") ticker9Price = request.security(ticker9, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker9PriceClose = request.security(ticker9, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker9Pnl = ticker9Price > ticker9EntryPrice ? ((ticker9Price - ticker9EntryPrice) / ticker9EntryPrice) : ((ticker9EntryPrice - ticker9Price) / ticker9EntryPrice) ticker9PnlText = ticker9Price > ticker9EntryPrice ? str.tostring(ticker9Pnl*100, format.percent) : "-" +str.tostring(ticker9Pnl*100, format.percent) ticker9Value = ticker9Price * ticker9OrderSize ticker9ValueText = str.tostring(ticker9Value) + " TL" if not ticker9On ticker9OrderSize := 0.0 ticker9Value := 0.0 //Ticker #10 ticker10On = input.bool(true, title="Aç/Kapa", group="Hisse #10") ticker10 = input.symbol("BIST_DLY:AKBNK", title="Ticker", group="Hisse #10") ticker10OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #10") ticker10EntryPrice = input.float(1, title="Maliyet", group="Hisse #10") ticker10Price = request.security(ticker10, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker10PriceClose = request.security(ticker10, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker10Pnl = ticker10Price > ticker10EntryPrice ? ((ticker10Price - ticker10EntryPrice) / ticker10EntryPrice) : ((ticker10EntryPrice - ticker10Price) / ticker10EntryPrice) ticker10PnlText = ticker10Price > ticker10EntryPrice ? str.tostring(ticker10Pnl*100, format.percent) : "-" +str.tostring(ticker10Pnl*100, format.percent) ticker10Value = ticker10Price * ticker10OrderSize ticker10ValueText = str.tostring(ticker10Value) + " TL" if not ticker10On ticker10OrderSize := 0.0 ticker10Value := 0.0 //Ticker #11 ticker11On = input.bool(true, title="Aç/Kapa", group="Hisse #11") ticker11 = input.symbol("BIST_DLY:KCHOL", title="Ticker", group="PHisse #11") ticker11OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #11") ticker11EntryPrice = input.float(1, title="Maliyet", group="Hisse #11") ticker11Price = request.security(ticker11, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker11PriceClose = request.security(ticker11, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker11Pnl = ticker11Price > ticker11EntryPrice ? ((ticker11Price - ticker11EntryPrice) / ticker11EntryPrice) : ((ticker11EntryPrice - ticker11Price) / ticker11EntryPrice) ticker11PnlText = ticker11Price > ticker11EntryPrice ? str.tostring(ticker11Pnl*100, format.percent) : "-" +str.tostring(ticker11Pnl*100, format.percent) ticker11Value = ticker11Price * ticker11OrderSize ticker11ValueText = str.tostring(ticker11Value) + " TL" if not ticker11On ticker11OrderSize := 0.0 ticker11Value := 0.0 //Ticker #12 ticker12On = input.bool(true, title="Aç/Kapa", group="Hisse #12") ticker12 = input.symbol("BIST_DLY:DOHOL", title="Ticker", group="Hisse #12") ticker12OrderSize = input.float(100, title="# Hisse Sayısı", group="Hisse #12") ticker12EntryPrice = input.float(1, title="Maliyet", group="Hisse #12") ticker12Price = request.security(ticker12, "", close, barmerge.gaps_off, ignore_invalid_symbol=true) ticker12PriceClose = request.security(ticker12, "D", close[1], barmerge.gaps_off, ignore_invalid_symbol=true) ticker12Pnl = ticker12Price > ticker12EntryPrice ? ((ticker12Price - ticker12EntryPrice) / ticker12EntryPrice) : ((ticker12EntryPrice - ticker12Price) / ticker12EntryPrice) ticker12PnlText = ticker12Price > ticker12EntryPrice ? str.tostring(ticker12Pnl*100, format.percent) : "-" +str.tostring(ticker12Pnl*100, format.percent) ticker12Value = ticker12Price * ticker12OrderSize ticker12ValueText = str.tostring(ticker12Value) + " TL" if not ticker12On ticker12OrderSize := 0.0 ticker12Value := 0.0 //Change Background Color Of Cells For Positive/Negative Percentages ticker1Color = color.maroon ticker2Color = color.maroon ticker3Color = color.maroon ticker4Color = color.maroon ticker5Color = color.maroon ticker6Color = color.maroon ticker7Color = color.maroon ticker8Color = color.maroon ticker9Color = color.maroon ticker10Color = color.maroon ticker11Color = color.maroon ticker12Color = color.maroon ticker1ValueColor = color.maroon ticker2ValueColor = color.blue ticker3ValueColor = color.blue ticker4ValueColor = color.blue ticker5ValueColor = color.blue ticker6ValueColor = color.blue ticker7ValueColor = color.blue ticker8ValueColor = color.blue ticker9ValueColor = color.blue ticker10ValueColor = color.blue ticker11ValueColor = color.blue ticker12ValueColor = color.blue if ticker1Price > ticker1EntryPrice ticker1Color := color.green ticker1ValueColor := color.green else if ticker1Price < ticker1EntryPrice ticker1Color := color.red ticker1ValueColor := color.red if ticker2Price > ticker2EntryPrice ticker2Color := color.green ticker2ValueColor := color.green else if ticker2Price < ticker2EntryPrice ticker2Color := color.red ticker2ValueColor := color.red if ticker3Price > ticker3EntryPrice ticker3Color := color.green ticker3ValueColor := color.green else if ticker3Price < ticker3EntryPrice ticker3Color := color.red ticker3ValueColor := color.red if ticker4Price > ticker4EntryPrice ticker4Color := color.green ticker4ValueColor := color.green else if ticker4Price < ticker4EntryPrice ticker4Color := color.red ticker4ValueColor := color.red if ticker5Price > ticker5EntryPrice ticker5Color := color.green ticker5ValueColor := color.green else if ticker5Price < ticker5EntryPrice ticker5Color := color.red ticker5ValueColor := color.red if ticker6Price > ticker6EntryPrice ticker6Color := color.green ticker6ValueColor := color.green else if ticker6Price < ticker6EntryPrice ticker6Color := color.red ticker6ValueColor := color.red if ticker7Price > ticker7EntryPrice ticker7Color := color.green ticker7ValueColor := color.green else if ticker7Price < ticker7EntryPrice ticker7Color := color.red ticker7ValueColor := color.red if ticker8Price > ticker8EntryPrice ticker8Color := color.green ticker8ValueColor := color.green else if ticker8Price < ticker8EntryPrice ticker8Color := color.red ticker8ValueColor := color.red if ticker9Price > ticker9EntryPrice ticker9Color := color.green ticker9ValueColor := color.green else if ticker9Price < ticker9EntryPrice ticker9Color := color.red ticker9ValueColor := color.red if ticker10Price > ticker10EntryPrice ticker10Color := color.green ticker10ValueColor := color.green else if ticker10Price < ticker10EntryPrice ticker10Color := color.red ticker10ValueColor := color.red if ticker11Price > ticker11EntryPrice ticker11Color := color.green ticker11ValueColor := color.green else if ticker11Price < ticker11EntryPrice ticker11Color := color.red ticker11ValueColor := color.red if ticker12Price > ticker12EntryPrice ticker12Color := color.green ticker12ValueColor := color.green else if ticker12Price < ticker12EntryPrice ticker12Color := color.red ticker12ValueColor := color.red //Calculate Portfolio Percentages ticker1PortfolioPercent = ticker1Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker2PortfolioPercent = ticker2Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker3PortfolioPercent = ticker3Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker4PortfolioPercent = ticker4Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker5PortfolioPercent = ticker5Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker6PortfolioPercent = ticker6Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker7PortfolioPercent = ticker7Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker8PortfolioPercent = ticker8Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker9PortfolioPercent = ticker9Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker10PortfolioPercent = ticker10Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker11PortfolioPercent = ticker11Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker12PortfolioPercent = ticker12Value / (ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value) ticker1PortfolioPercentText = str.tostring(ticker1PortfolioPercent*100, format.percent) ticker2PortfolioPercentText = str.tostring(ticker2PortfolioPercent*100, format.percent) ticker3PortfolioPercentText = str.tostring(ticker3PortfolioPercent*100, format.percent) ticker4PortfolioPercentText = str.tostring(ticker4PortfolioPercent*100, format.percent) ticker5PortfolioPercentText = str.tostring(ticker5PortfolioPercent*100, format.percent) ticker6PortfolioPercentText = str.tostring(ticker6PortfolioPercent*100, format.percent) ticker7PortfolioPercentText = str.tostring(ticker7PortfolioPercent*100, format.percent) ticker8PortfolioPercentText = str.tostring(ticker8PortfolioPercent*100, format.percent) ticker9PortfolioPercentText = str.tostring(ticker9PortfolioPercent*100, format.percent) ticker10PortfolioPercentText = str.tostring(ticker10PortfolioPercent*100, format.percent) ticker11PortfolioPercentText = str.tostring(ticker11PortfolioPercent*100, format.percent) ticker12PortfolioPercentText = str.tostring(ticker12PortfolioPercent*100, format.percent) //Today % Gain Calculations ticker1TodayGain = ticker1Price >= ticker1PriceClose ? ((ticker1Price - ticker1PriceClose) / ticker1PriceClose) * 100 : ((ticker1PriceClose - ticker1Price) / ticker1PriceClose) * -100 ticker1TodayGainText = str.tostring(ticker1TodayGain, "#.##") + "%" ticker1TodayGainColor = ticker1Price > ticker1PriceClose ? color.green : ticker1Price < ticker1PriceClose ? color.red : color.blue ticker2TodayGain = ticker2Price >= ticker2PriceClose ? ((ticker2Price - ticker2PriceClose) / ticker2PriceClose) * 100 : ((ticker2PriceClose - ticker2Price) / ticker2PriceClose) * -100 ticker2TodayGainText = str.tostring(ticker2TodayGain, "#.##") + "%" ticker2TodayGainColor = ticker2Price > ticker2PriceClose ? color.green : ticker2Price < ticker2PriceClose ? color.red : color.blue ticker3TodayGain = ticker3Price >= ticker3PriceClose ? ((ticker3Price - ticker3PriceClose) / ticker3PriceClose) * 100 : ((ticker3PriceClose - ticker3Price) / ticker3PriceClose) * -100 ticker3TodayGainText = str.tostring(ticker3TodayGain, "#.##") + "%" ticker3TodayGainColor = ticker3Price > ticker3PriceClose ? color.green : ticker3Price < ticker3PriceClose ? color.red : color.blue ticker4TodayGain = ticker4Price >= ticker4PriceClose ? ((ticker4Price - ticker4PriceClose) / ticker4PriceClose) * 100 : ((ticker4PriceClose - ticker4Price) / ticker4PriceClose) * -100 ticker4TodayGainText = str.tostring(ticker4TodayGain, "#.##") + "%" ticker4TodayGainColor = ticker4Price > ticker4PriceClose ? color.green : ticker4Price < ticker4PriceClose ? color.red : color.blue ticker5TodayGain = ticker5Price >= ticker5PriceClose ? ((ticker5Price - ticker5PriceClose) / ticker5PriceClose) * 100 : ((ticker5PriceClose - ticker5Price) / ticker5PriceClose) * -100 ticker5TodayGainText = str.tostring(ticker5TodayGain, "#.##") + "%" ticker5TodayGainColor = ticker5Price > ticker5PriceClose ? color.green : ticker5Price < ticker5PriceClose ? color.red : color.blue ticker6TodayGain = ticker6Price >= ticker6PriceClose ? ((ticker6Price - ticker6PriceClose) / ticker6PriceClose) * 100 : ((ticker6PriceClose - ticker6Price) / ticker6PriceClose) * -100 ticker6TodayGainText = str.tostring(ticker6TodayGain, "#.##") + "%" ticker6TodayGainColor = ticker6Price > ticker6PriceClose ? color.green : ticker6Price < ticker6PriceClose ? color.red : color.blue ticker7TodayGain = ticker7Price >= ticker7PriceClose ? ((ticker7Price - ticker7PriceClose) / ticker7PriceClose) * 100 : ((ticker7PriceClose - ticker7Price) / ticker7PriceClose) * -100 ticker7TodayGainText = str.tostring(ticker7TodayGain, "#.##") + "%" ticker7TodayGainColor = ticker7Price > ticker7PriceClose ? color.green : ticker7Price < ticker7PriceClose ? color.red : color.blue ticker8TodayGain = ticker8Price >= ticker8PriceClose ? ((ticker8Price - ticker8PriceClose) / ticker8PriceClose) * 100 : ((ticker8PriceClose - ticker8Price) / ticker8PriceClose) * -100 ticker8TodayGainText = str.tostring(ticker8TodayGain, "#.##") + "%" ticker8TodayGainColor = ticker8Price > ticker8PriceClose ? color.green : ticker8Price < ticker8PriceClose ? color.red : color.blue ticker9TodayGain = ticker9Price >= ticker9PriceClose ? ((ticker9Price - ticker9PriceClose) / ticker9PriceClose) * 100 : ((ticker9PriceClose - ticker9Price) / ticker9PriceClose) * -100 ticker9TodayGainText = str.tostring(ticker9TodayGain, "#.##") + "%" ticker9TodayGainColor = ticker9Price > ticker9PriceClose ? color.green : ticker9Price < ticker9PriceClose ? color.red : color.blue ticker10TodayGain = ticker10Price >= ticker10PriceClose ? ((ticker10Price - ticker10PriceClose) / ticker10PriceClose) * 100 : ((ticker10PriceClose - ticker10Price) / ticker10PriceClose) * -100 ticker10TodayGainText = str.tostring(ticker10TodayGain, "#.##") + "%" ticker10TodayGainColor = ticker10Price > ticker10PriceClose ? color.green : ticker10Price < ticker10PriceClose ? color.red : color.blue ticker11TodayGain = ticker11Price >= ticker11PriceClose ? ((ticker11Price - ticker11PriceClose) / ticker11PriceClose) * 100 : ((ticker11PriceClose - ticker11Price) / ticker11PriceClose) * -100 ticker11TodayGainText = str.tostring(ticker11TodayGain, "#.##") + "%" ticker11TodayGainColor = ticker11Price > ticker11PriceClose ? color.green : ticker11Price < ticker11PriceClose ? color.red : color.blue ticker12TodayGain = ticker12Price >= ticker12PriceClose ? ((ticker12Price - ticker12PriceClose) / ticker12PriceClose) * 100 : ((ticker12PriceClose - ticker12Price) / ticker12PriceClose) * -100 ticker12TodayGainText = str.tostring(ticker12TodayGain, "#.##") + "%" ticker12TodayGainColor = ticker12Price > ticker12PriceClose ? color.green : ticker12Price < ticker12PriceClose ? color.red : color.blue //Overall Portfolio Calculations startingCapital = (ticker1OrderSize * ticker1EntryPrice) + (ticker2OrderSize * ticker2EntryPrice) + (ticker3OrderSize * ticker3EntryPrice) + (ticker4OrderSize * ticker4EntryPrice) + (ticker5OrderSize * ticker5EntryPrice) + (ticker6OrderSize * ticker6EntryPrice) + (ticker7OrderSize * ticker7EntryPrice) + (ticker8OrderSize * ticker8EntryPrice) + (ticker9OrderSize * ticker9EntryPrice) + (ticker10OrderSize * ticker10EntryPrice) + (ticker11OrderSize * ticker11EntryPrice) + (ticker12OrderSize * ticker12EntryPrice) startingCapitalText = str.tostring(startingCapital, "#.##") +" TL" currentCapital = ticker1Value + ticker2Value + ticker3Value + ticker4Value + ticker5Value + ticker6Value + ticker7Value + ticker8Value + ticker9Value + ticker10Value + ticker11Value + ticker12Value currentCapitalText = str.tostring(currentCapital, "#.##") + " TL" currentCapitalColor = currentCapital > startingCapital ? color.green : currentCapital < startingCapital ? color.red : color.blue overallProfitDollars = currentCapital >= startingCapital ? currentCapital - startingCapital : startingCapital - currentCapital overallProfitDollarsText = currentCapital >= startingCapital ? str.tostring(overallProfitDollars, "#.##") + " TL" : str.tostring(overallProfitDollars, "#.##") + " -TL" overallProfitDollarsColor = currentCapital > startingCapital ? color.green : currentCapital < startingCapital ? color.red : color.blue overallProfitPercent = currentCapital >= startingCapital ? ((currentCapital - startingCapital) / startingCapital) * 100 : ((startingCapital - currentCapital) / startingCapital) * 100 overallProfitPercentText = currentCapital >= startingCapital ? str.tostring(overallProfitPercent, "#.##") + "%" : "-" + str.tostring(overallProfitPercent, "#.##") + "%" overallProfitPercentColor = currentCapital > startingCapital ? color.green : currentCapital < startingCapital ? color.red : color.blue overallGainToday = (((ticker1Price - ticker1PriceClose) * ticker1OrderSize) - (ticker1PriceClose * ticker1OrderSize)) + (((ticker2Price - ticker2PriceClose) * ticker2OrderSize) - (ticker2PriceClose * ticker2OrderSize)) + (((ticker3Price - ticker3PriceClose) * ticker3OrderSize) - (ticker3PriceClose * ticker3OrderSize)) + (((ticker4Price - ticker4PriceClose) * ticker4OrderSize) - (ticker4PriceClose * ticker4OrderSize)) + (((ticker5Price - ticker5PriceClose) * ticker5OrderSize) - (ticker5PriceClose * ticker5OrderSize)) + (((ticker6Price - ticker6PriceClose) * ticker6OrderSize) - (ticker6PriceClose * ticker6OrderSize)) + (((ticker7Price - ticker7PriceClose) * ticker7OrderSize) - (ticker7PriceClose * ticker7OrderSize)) + (((ticker8Price - ticker8PriceClose) * ticker8OrderSize) - (ticker8PriceClose * ticker8OrderSize)) + (((ticker9Price - ticker9PriceClose) * ticker9OrderSize) - (ticker9PriceClose * ticker9OrderSize)) + (((ticker10Price - ticker10PriceClose) * ticker10OrderSize) - (ticker10PriceClose * ticker10OrderSize)) + (((ticker11Price - ticker11PriceClose) * ticker11OrderSize) - (ticker11PriceClose * ticker11OrderSize)) + (((ticker12Price - ticker12PriceClose) * ticker12OrderSize) - (ticker12PriceClose * ticker12OrderSize)) overallValueYesterday = (ticker1PriceClose * ticker1OrderSize) + (ticker2PriceClose * ticker2OrderSize) + (ticker3PriceClose * ticker3OrderSize) + (ticker4PriceClose * ticker4OrderSize) + (ticker5PriceClose * ticker5OrderSize) + (ticker6PriceClose * ticker6OrderSize) + (ticker7PriceClose * ticker7OrderSize) + (ticker8PriceClose * ticker8OrderSize) + (ticker9PriceClose * ticker9OrderSize) + (ticker10PriceClose * ticker10OrderSize) + (ticker11PriceClose * ticker11OrderSize) + (ticker12PriceClose * ticker12OrderSize) overallProfitTodayNumber = ((currentCapital - overallValueYesterday) / overallValueYesterday) * 100 overallProfitTodayText = str.tostring(overallProfitTodayNumber, "#.##") + "%" overallProfitTodayColor = overallProfitTodayNumber > 0 ? color.green : overallProfitTodayNumber < 0 ? color.red : color.blue //maliyet maliyet1=str.tostring(ticker1EntryPrice) maliyet2=str.tostring(ticker2EntryPrice) maliyet3=str.tostring(ticker3EntryPrice) maliyet4=str.tostring(ticker4EntryPrice) maliyet5=str.tostring(ticker5EntryPrice) maliyet6=str.tostring(ticker6EntryPrice) maliyet7=str.tostring(ticker7EntryPrice) maliyet8=str.tostring(ticker8EntryPrice) maliyet9=str.tostring(ticker9EntryPrice) maliyet10=str.tostring(ticker10EntryPrice) maliyet11=str.tostring(ticker11EntryPrice) maliyet12=str.tostring(ticker12EntryPrice) //Hisse adedi hisse1=str.tostring(ticker1OrderSize) hisse2=str.tostring(ticker2OrderSize) hisse3=str.tostring(ticker3OrderSize) hisse4=str.tostring(ticker4OrderSize) hisse5=str.tostring(ticker5OrderSize) hisse6=str.tostring(ticker6OrderSize) hisse7=str.tostring(ticker7OrderSize) hisse8=str.tostring(ticker8OrderSize) hisse9=str.tostring(ticker9OrderSize) hisse10=str.tostring(ticker10OrderSize) hisse11=str.tostring(ticker11OrderSize) hisse12=str.tostring(ticker12OrderSize) //Plot Data To Table dataTable = table.new(tablePosition, columns=10, rows=20, bgcolor=color.blue, frame_color=color.white, frame_width=1, border_color=color.white, border_width=1) if dataTableOn and barstate.islast table.cell(table_id=dataTable, column=0, row=0, text="Hisse Adı", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=1, row=0, text="Hisse Adedi", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=2, row=0, text="Maliyet", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=3+2, row=0, text="K/Z %", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=2+2, row=0, text="K/Z TL", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=1+2, row=0, text="Ağırlık", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=4+2, row=0, text="Bugün", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=0, row=1, text=ticker1On ? ticker1 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=1, text=ticker1On ? ticker1PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker1Color) table.cell(table_id=dataTable, column=2+2, row=1, text=ticker1On ? ticker1ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker1ValueColor) table.cell(table_id=dataTable, column=1+2, row=1, text=ticker1On ? ticker1PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=1, text=ticker1On ? ticker1TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker1TodayGainColor) table.cell(table_id=dataTable, column=0, row=2, text=ticker2On ? ticker2 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=2, text=ticker2On ? ticker2PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker2Color) table.cell(table_id=dataTable, column=2+2, row=2, text=ticker2On ? ticker2ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker2ValueColor) table.cell(table_id=dataTable, column=1+2, row=2, text=ticker2On ? ticker2PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=2, text=ticker2On ? ticker2TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker2TodayGainColor) table.cell(table_id=dataTable, column=0, row=3, text=ticker3On ? ticker3 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=3, text=ticker3On ? ticker3PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker3Color) table.cell(table_id=dataTable, column=2+2, row=3, text=ticker3On ? ticker3ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker3ValueColor) table.cell(table_id=dataTable, column=1+2, row=3, text=ticker3On ? ticker3PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=3, text=ticker3On ? ticker3TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker3TodayGainColor) table.cell(table_id=dataTable, column=0, row=4, text=ticker4On ? ticker4 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=4, text=ticker4On ? ticker4PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker4Color) table.cell(table_id=dataTable, column=2+2, row=4, text=ticker4On ? ticker4ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker4ValueColor) table.cell(table_id=dataTable, column=1+2, row=4, text=ticker4On ? ticker4PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=4, text=ticker4On ? ticker4TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker4TodayGainColor) table.cell(table_id=dataTable, column=0, row=5, text=ticker5On ? ticker5 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=5, text=ticker5On ? ticker5PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker5Color) table.cell(table_id=dataTable, column=2+2, row=5, text=ticker5On ? ticker5ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker5ValueColor) table.cell(table_id=dataTable, column=1+2, row=5, text=ticker5On ? ticker5PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=5, text=ticker5On ? ticker5TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker5TodayGainColor) table.cell(table_id=dataTable, column=0, row=6, text=ticker6On ? ticker6 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=6, text=ticker6On ? ticker6PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker6Color) table.cell(table_id=dataTable, column=2+2, row=6, text=ticker6On ? ticker6ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker6ValueColor) table.cell(table_id=dataTable, column=1+2, row=6, text=ticker6On ? ticker6PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=6, text=ticker6On ? ticker6TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker6TodayGainColor) table.cell(table_id=dataTable, column=0, row=7, text=ticker7On ? ticker7 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=7, text=ticker7On ? ticker7PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker7Color) table.cell(table_id=dataTable, column=2+2, row=7, text=ticker7On ? ticker7ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker7ValueColor) table.cell(table_id=dataTable, column=1+2, row=7, text=ticker7On ? ticker7PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=7, text=ticker7On ? ticker7TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker7TodayGainColor) table.cell(table_id=dataTable, column=0, row=8, text=ticker8On ? ticker8 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=8, text=ticker8On ? ticker8PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker8Color) table.cell(table_id=dataTable, column=2+2, row=8, text=ticker8On ? ticker8ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker8ValueColor) table.cell(table_id=dataTable, column=1+2, row=8, text=ticker8On ? ticker8PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=8, text=ticker8On ? ticker8TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker8TodayGainColor) table.cell(table_id=dataTable, column=0, row=9, text=ticker9On ? ticker9 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=9, text=ticker9On ? ticker9PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker9Color) table.cell(table_id=dataTable, column=2+2, row=9, text=ticker9On ? ticker9ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker9ValueColor) table.cell(table_id=dataTable, column=1+2, row=9, text=ticker9On ? ticker9PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=9, text=ticker9On ? ticker9TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker9TodayGainColor) table.cell(table_id=dataTable, column=0, row=10, text=ticker10On ? ticker10 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=10, text=ticker10On ? ticker10PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker10Color) table.cell(table_id=dataTable, column=2+2, row=10, text=ticker10On ? ticker10ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker10ValueColor) table.cell(table_id=dataTable, column=1+2, row=10, text=ticker10On ? ticker10PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=10, text=ticker10On ? ticker10TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker10TodayGainColor) table.cell(table_id=dataTable, column=0, row=11, text=ticker11On ? ticker11 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=11, text=ticker11On ? ticker11PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker11Color) table.cell(table_id=dataTable, column=2+2, row=11, text=ticker11On ? ticker11ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker11ValueColor) table.cell(table_id=dataTable, column=1+2, row=11, text=ticker11On ? ticker11PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=11, text=ticker11On ? ticker11TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker11TodayGainColor) table.cell(table_id=dataTable, column=0, row=12, text=ticker12On ? ticker12 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=3+2, row=12, text=ticker12On ? ticker12PnlText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker12Color) table.cell(table_id=dataTable, column=2+2, row=12, text=ticker12On ? ticker12ValueText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker12ValueColor) table.cell(table_id=dataTable, column=1+2, row=12, text=ticker12On ? ticker12PortfolioPercentText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=4+2, row=12, text=ticker12On ? ticker12TodayGainText : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=ticker12TodayGainColor) table.cell(table_id=dataTable, column=2, row=13, text="Toplam Yatırım", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=2, row=14, text=startingCapitalText, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center) table.cell(table_id=dataTable, column=1+2, row=13, text="Toplam Tutar", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=1+2, row=14, text=currentCapitalText, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=currentCapitalColor) table.cell(table_id=dataTable, column=2+2, row=13, text="Toplam K/Z TL", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=2+2, row=14, text=overallProfitDollarsText, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=overallProfitDollarsColor) table.cell(table_id=dataTable, column=3+2, row=13, text="Ort. K/Z %", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=3+2, row=14, text=overallProfitPercentText, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=overallProfitPercentColor) table.cell(table_id=dataTable, column=4+2, row=13, text="Bugün", height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.navy) table.cell(table_id=dataTable, column=4+2, row=14, text=overallProfitTodayText, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=overallProfitTodayColor) table.cell(table_id=dataTable, column=2, row=1, text=ticker1On ? maliyet1 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=2, text=ticker2On ? maliyet2 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=3, text=ticker3On ? maliyet3 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=4, text=ticker4On ? maliyet4 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=5, text=ticker5On ? maliyet5 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=6, text=ticker6On ? maliyet6 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=7, text=ticker7On ? maliyet7 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=8, text=ticker8On ? maliyet8 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=9, text=ticker9On ? maliyet9 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=10, text=ticker10On ? maliyet10 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=11, text=ticker11On ? maliyet11 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=2, row=12, text=ticker12On ? maliyet12 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=1, text=ticker1On ? hisse1 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=2, text=ticker2On ? hisse2 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=3, text=ticker3On ? hisse3 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=4, text=ticker4On ? hisse4 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=5, text=ticker5On ? hisse5 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=6, text=ticker6On ? hisse6 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=7, text=ticker7On ? hisse7 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=8, text=ticker8On ? hisse8 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=9, text=ticker9On ? hisse9 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=10, text=ticker10On ? hisse10 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=11, text=ticker11On ? hisse11 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue) table.cell(table_id=dataTable, column=1, row=12, text=ticker12On ? hisse12 : na, height=0, text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=color.blue)
Adaptive Fisherized KST
https://www.tradingview.com/script/Tn35FvN7-Adaptive-Fisherized-KST/
simwai
https://www.tradingview.com/u/simwai/
139
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© simwai //@version=5 indicator('Adaptive Fisherized KST', 'AF_KST', false) // -- Input -- string resolution = input.timeframe(defval='', title='Resolution', group='KST', inline='1') int min = input.int(defval=3, minval=2, title='Min Length', tooltip='Used for adaptive mode', group='KST', inline='2') int length = input.int(defval=100, minval=2, title='MA Length', group='KST', inline='2') int roc1Length = input.int(defval=5, minval=2, title='ROC Length 1', group='KST', inline='4') int roc2Length = input.int(defval=10, minval=2, title='ROC Length 2', group='KST', inline='4') int roc3Length = input.int(defval=15, minval=2, title='ROC Length 3', group='KST', inline='5') int roc4Length = input.int(defval=30, minval=2, title='ROC Length 4', group='KST', inline='5') bool isFisherized = input.bool(defval=true, title='Enable Inverse Fisher Transform', group='KST', inline='9') bool isFibWeightingEnabled = input.bool(title='Enable Fibonacci Weighting', defval=true, tooltip='Applied to the 4 ROCs used in KST calculation') string adaptiveMode = input.string(defval='Median', title='Choose Adaptive Mode', options=['None', 'Hilbert Transform', 'Inphase-Quadrature Transform', 'Median', 'Homodyne Discriminator'], tooltip='Just applied on KST MA', group='KST', inline='10') bool isHighlighted = input.bool(defval=true, title='Enable Positive/Negative Highlightning', group='KST', inline='11') string signalMode = input.string(defval='Zero Line', title='Choose Signal Mode', options=['Cross', 'Cross Filtered', 'Zero Line', 'None'], tooltip='Cross Filtered uses above/below zero line as filter', group='KST', inline='12') string kstMaType = input.string(defval='T3', title='Choose KST MA', options=['RMA', 'VWMA', 'KAMA', 'T3', 'JMA'], group='MA', inline='1') float t3Hot = input.float(title='T3 – Smoothing Factor (hot)', defval=0.7, step=0.1, minval=0.00001, group='MA', inline='2') string t3Type = input.string(title='T3 – Type', defval='T3 New', options=['T3 Normal', 'T3 New'], group='MA', inline='2') int jmaPhase = input.int(title='JMA – Phase', defval=50, minval=-100, maxval=100, tooltip='The phase is used to shift the input data before applying the smoothing algorithm. The phase shift can help to identify the turning points of the data.', group='MA', inline='3') int jmaPower = input.int(title='JMA – Power', defval=2, minval=2, tooltip='The power is used to adjust the sensitivity of the JMA to changes in the input data. Higher values of the power will make the JMA more sensitive to changes in the data.', group='MA', inline='3') bool isNetEnabled = input.bool(false, 'Enable NET', group='Smoothing', inline='1') int netLength = input.int(3, 'NET Length', minval=2, group='Smoothing', inline='1') bool isHannWindowEnabled = input.bool(false, 'Enable Hann Window', group='Smoothing', inline='2') int hannWindowLength = input.int(3, 'Hann Window Length', minval=2, group='Smoothing', inline='2') bool isHodrickPrescrottFilterEnabled = input.bool(true, 'Enable Hodrick Prescott Filter', group='Smoothing', inline='3') float hpLambda = input.float(defval=5000, title='Smoothing Factor (Lambda)', minval=1, group='Smoothing', inline='4') int hpLength = input.int(defval=300, title='Filter Length', minval=1, group='Smoothing', inline='4') string divergenceMode = input.string('None', title='Divergence Mode', options=['Regular', 'Hidden', 'Both', 'None'], group='Divergences', inline='1') bool isDivergencePlotEnabled = input.bool(false, title='Enable Divergence Lines Plot', group='Divergences', inline='2') int rangeUpper = input.int(title='Max Lookback Range', minval=1, defval=60, group='Divergences', inline='3') int rangeLower = input.int(title='Min Lookback Range', minval=1, defval=5, group='Divergences', inline='3') int lbR = input.int(title='Pivot Lookback Right', minval=2, defval=12, group='Divergences', inline='4') int lbL = input.int(title='Pivot Lookback Left', minval=2, defval=12, group='Divergences', inline='4') // -- Colors -- color superGreen = color.rgb(34, 255, 207) color superPurple = color.rgb(152, 105, 255) color lightPurple = color.rgb(193, 133, 243) color lightGray = color.rgb(214, 214, 214) color quickSilver = color.rgb(163, 163, 163) // Divergence colors color bullColor = lightPurple color bearColor = superPurple color hiddenBullColor = bullColor color hiddenBearColor = bearColor color noneColor = lightGray color textColor = color.white // -- Functions -- [src, _volume] = request.security(syminfo.tickerid, resolution, [close[1], volume[1]], barmerge.gaps_off, barmerge.lookahead_on) inRange(bool cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper // Apply normalization normalize(float _src, int _min, int _max) => var float _historicMin = 1.0 var float _historicMax = -1.0 _historicMin := math.min(nz(_src, _historicMin), _historicMin) _historicMax := math.max(nz(_src, _historicMax), _historicMax) _min + (_max - _min) * (_src - _historicMin) / math.max(_historicMax - _historicMin, 1) // Inverse Fisher Transformation (IFT) fisherize(float _value) => (math.exp(2 * _value) - 1) / (math.exp(2 * _value) + 1) // Convert length to alpha getAlpha(float kstLength) => 2 / (kstLength + 1) // Get dominant cyber cycle – Median – Credits to @blackcat1402 getMedianDc(float Price, float alpha=0.07, simple float CycPart=0.5) => Smooth = 0.00 Cycle = 0.00 Q1 = 0.00 I1 = 0.00 DeltaPhase = 0.00 MedianDelta = 0.00 DC = 0.00 InstPeriod = 0.00 Period = 0.00 I2 = 0.00 Q2 = 0.00 IntPeriod = 0 Smooth := (Price + 2 * nz(Price[1]) + 2 * nz(Price[2]) + nz(Price[3])) / 6 Cycle := (1 - .5 * alpha) * (1 - .5 * alpha) * (Smooth - 2 * nz(Smooth[1]) + nz(Smooth[2])) + 2 * (1 - alpha) * nz(Cycle[1]) - (1 - alpha) * (1 - alpha) * nz(Cycle[2]) Cycle := bar_index < 7 ? (Price - 2 * nz(Price[1]) + nz(Price[2])) / 4 : Cycle Q1 := (.0962 * Cycle + .5769 * nz(Cycle[2]) - .5769 * nz(Cycle[4]) - .0962 * nz(Cycle[6])) * (.5 + .08 * nz(InstPeriod[1])) I1 := nz(Cycle[3]) DeltaPhase := Q1 != 0 and nz(Q1[1]) != 0 ? (I1 / Q1 - nz(I1[1]) / nz(Q1[1])) / (1 + I1 * nz(I1[1]) / (Q1 * nz(Q1[1]))) : DeltaPhase DeltaPhase := DeltaPhase < 0.1 ? 0.1 : DeltaPhase DeltaPhase := DeltaPhase > 1.1 ? 1.1 : DeltaPhase MedianDelta := ta.median(DeltaPhase, 5) DC := MedianDelta == 0.00 ? 15.00 : 6.28318 / MedianDelta + .5 InstPeriod := .33 * DC + .67 * nz(InstPeriod[1]) Period := .15 * InstPeriod + .85 * nz(Period[1]) IntPeriod := math.round(Period * CycPart) < 1 ? 1 : math.round(Period * CycPart) IntPeriod // Get dominant cyber cycle – Inphase-Quadrature -- Credits to @DasanC getIqDc(float src, int min, int max) => PI = 3.14159265359 P = src - src[7] lenIQ = 0.0 lenC = 0.0 imult = 0.635 qmult = 0.338 inphase = 0.0 quadrature = 0.0 re = 0.0 im = 0.0 deltaIQ = 0.0 instIQ = 0.0 V = 0.0 inphase := 1.25 * (P[4] - imult * P[2]) + imult * nz(inphase[3]) quadrature := P[2] - qmult * P + qmult * nz(quadrature[2]) re := 0.2 * (inphase * inphase[1] + quadrature * quadrature[1]) + 0.8 * nz(re[1]) im := 0.2 * (inphase * quadrature[1] - inphase[1] * quadrature) + 0.8 * nz(im[1]) if re != 0.0 deltaIQ := math.atan(im / re) deltaIQ for i = 0 to max by 1 V += deltaIQ[i] if V > 2 * PI and instIQ == 0.0 instIQ := i instIQ if instIQ == 0.0 instIQ := nz(instIQ[1]) instIQ lenIQ := 0.25 * instIQ + 0.75 * nz(lenIQ[1], 1) length = lenIQ < min ? min : lenIQ math.round(length) // Get dominant cyber cycle – Hilbert Transform -- Credits to @DasanC getHtDc(float src) => Imult = .635 Qmult = .338 PI = 3.14159 InPhase = 0.0 Quadrature = 0.0 Phase = 0.0 DeltaPhase = 0.0 InstPeriod = 0.0 Period = 0.0 Value4 = 0.0 if bar_index > 5 // Detrend src Value3 = src - src[7] // Compute InPhase and Quadrature components InPhase := 1.25 * (Value3[4] - Imult * Value3[2]) + Imult * nz(InPhase[3]) Quadrature := Value3[2] - Qmult * Value3 + Qmult * nz(Quadrature[2]) // Use ArcTangent to compute the current phase if math.abs(InPhase + InPhase[1]) > 0 Phase := 180 / PI * math.atan(math.abs((Quadrature + Quadrature[1]) / (InPhase + InPhase[1]))) Phase // Resolve the ArcTangent ambiguity if InPhase < 0 and Quadrature > 0 Phase := 180 - Phase Phase if InPhase < 0 and Quadrature < 0 Phase := 180 + Phase Phase if InPhase > 0 and Quadrature < 0 Phase := 360 - Phase Phase // Compute a differential phase, resolve phase wraparound, and limit delta phase errors DeltaPhase := Phase[1] - Phase if Phase[1] < 90 and Phase > 270 DeltaPhase := 360 + Phase[1] - Phase DeltaPhase if DeltaPhase < 1 DeltaPhase := 1 DeltaPhase if DeltaPhase > 60 DeltaPhase := 60 DeltaPhase // Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous period. for i = 0 to 50 by 1 Value4 += DeltaPhase[i] if Value4 > 360 and InstPeriod == 0 InstPeriod := i InstPeriod // Resolve Instantaneous Period errors and smooth if InstPeriod == 0 nz(InstPeriod[1]) Period := .25 * InstPeriod + .75 * Period[1] math.round(Period) // Get Dominant Cyber Cycle - Homodyne Discriminator With Hilbert Dominant Cycle – Credits to @blackcat1402 getHdDc(float Price, int min, int max, simple float CycPart = 0.5) => Smooth = 0.00 Detrender = 0.00 I1 = 0.00 Q1 = 0.00 jI = 0.00 jQ = 0.00 I2 = 0.00 Q2 = 0.00 Re = 0.00 Im = 0.00 Period = 0.00 SmoothPeriod = 0.00 pi = 2 * math.asin(1) DomCycle = 0.0 // Hilbert Transform Smooth := bar_index > 7 ? (4 * Price + 3 * nz(Price[1]) + 2 * nz(Price[2]) + nz(Price[3])) / 10 : Smooth Detrender := bar_index > 7 ? (.0962 * Smooth + .5769 * nz(Smooth[2]) - .5769 * nz(Smooth[4]) - .0962 * nz(Smooth[6])) * (.075 * nz(Period[1]) + .54) : Detrender // Compute InPhase and Quadrature components Q1 := bar_index > 7 ? (.0962 * Detrender + .5769 * nz(Detrender[2]) - .5769 * nz(Detrender[4]) - .0962 * nz(Detrender[6])) * (.075 * nz(Period[1]) + .54) : Q1 I1 := bar_index > 7 ? nz(Detrender[3]) : I1 // Advance the phase of I1 and Q1 by 90 degrees jI := (.0962 * I1 + .5769 * nz(I1[2]) - .5769 * nz(I1[4]) - .0962 * nz(I1[6])) * (.075 * nz(Period[1]) + .54) jQ := (.0962 * Q1 + .5769 * nz(Q1[2]) - .5769 * nz(Q1[4]) - .0962 * nz(Q1[6])) * (.075 * nz(Period[1]) + .54) // Phasor addition for 3 bar averaging I2 := I1 - jQ Q2 := Q1 + jI // Smooth the I and Q components before applying the discriminator I2 := .2 * I2 + .8 * nz(I2[1]) Q2 := .2 * Q2 + .8 * nz(Q2[1]) // Homodyne Discriminator Re := I2 * nz(I2[1]) + Q2 * nz(Q2[1]) Im := I2 * nz(Q2[1]) - Q2 * nz(I2[1]) Re := .2 * Re + .8 * nz(Re[1]) Im := .2 * Im + .8 * nz(Im[1]) Period := Im != 0 and Re != 0 ? 2 * pi / math.atan(Im / Re) : Period Period := Period > 1.5 * nz(Period[1]) ? 1.5 * nz(Period[1]) : Period Period := Period < .67 * nz(Period[1]) ? .67 * nz(Period[1]) : Period Period := Period < min ? min : Period Period := Period > max ? max : Period Period := .2 * Period + .8 * nz(Period[1]) SmoothPeriod := .33 * Period + .67 * nz(SmoothPeriod[1]) DomCycle := math.ceil(CycPart * SmoothPeriod) < 1 ? 1 : math.ceil(CycPart * SmoothPeriod) // Limit dominant cycle DomCycle := DomCycle < min ? min : DomCycle > max ? max : DomCycle math.round(DomCycle) // Noise Elimination Technology (NET) – Credits to @blackcat1402 doNet(float _series, simple int _netLength, int _lowerBand=-1, int _upperBand=1) => var netX = array.new_float(102) var netY = array.new_float(102) num = 0.00 denom = 0.00 net = 0.00 trigger = 0.00 for count = 1 to _netLength array.set(netX, count, nz(_series[count - 1])) array.set(netY, count, -count) num := 0 for count = 2 to _netLength for k = 1 to count - 1 num := num - math.sign(nz(array.get(netX, count)) - nz(array.get(netX, k))) denom := 0.5 * _netLength * (_netLength - 1) net := num / denom trigger := 0.05 + 0.9 * nz(net[1]) trigger := normalize(trigger, _lowerBand, _upperBand) // Hann Window Smoothing – Credits to @cheatcountry doHannWindow(float _series, float _hannWindowLength) => sum = 0.0, coef = 0.0 for i = 1 to _hannWindowLength cosine = 1 - math.cos(2 * math.pi * i / (_hannWindowLength + 1)) sum := sum + (cosine * nz(_series[i - 1])) coef := coef + cosine h = coef != 0 ? sum / coef : 0 // Credits to @hajixde hodrickPrescottFilter(float src, float lambda, int length) => // Construct Arrays a = array.new_float(length, 0.0) b = array.new_float(length, 0.0) c = array.new_float(length, 0.0) d = array.new_float(length, 0.0) e = array.new_float(length, 0.0) f = array.new_float(length, 0.0) l1 = length - 1 l2 = length - 2 for i = 0 to l1 by 1 array.set(a, i, lambda * -4) array.set(b, i, src[i]) array.set(c, i, lambda * -4) array.set(d, i, lambda * 6 + 1) array.set(e, i, lambda) array.set(f, i, lambda) array.set(d, 0, lambda + 1.0) array.set(d, l1, lambda + 1.0) array.set(d, 1, lambda * 5.0 + 1.0) array.set(d, l2, lambda * 5.0 + 1.0) array.set(c, 0, lambda * -2.0) array.set(c, l2, lambda * -2.0) array.set(a, 0, lambda * -2.0) array.set(a, l2, lambda * -2.0) // Solve the optimization issue float r = array.get(a, 0) float s = array.get(a, 1) float t = array.get(e, 0) float xmult = 0.0 for i = 1 to l2 by 1 xmult := r / array.get(d, i - 1) array.set(d, i, array.get(d, i) - xmult * array.get(c, i - 1)) array.set(c, i, array.get(c, i) - xmult * array.get(f, i - 1)) array.set(b, i, array.get(b, i) - xmult * array.get(b, i - 1)) xmult := t / array.get(d, i - 1) r := s - xmult * array.get(c, i - 1) array.set(d, i + 1, array.get(d, i + 1) - xmult * array.get(f, i - 1)) array.set(b, i + 1, array.get(b, i + 1) - xmult * array.get(b, i - 1)) s := array.get(a, i + 1) t := array.get(e, i) t xmult := r / array.get(d, l2) array.set(d, l1, array.get(d, l1) - xmult * array.get(c, l2)) x = array.new_float(length, 0) array.set(x, l1, (array.get(b, l1) - xmult * array.get(b, l2)) / array.get(d, l1)) array.set(x, l2, (array.get(b, l2) - array.get(c, l2) * array.get(x, l1)) / array.get(d, l2)) for j = 0 to length - 3 by 1 i = length - 3 - j array.set(x, i, (array.get(b, i) - array.get(f, i) * array.get(x, i + 2) - array.get(c, i) * array.get(x, i + 1)) / array.get(d, i)) // Construct the output HP = array.get(x, 0) // Simple Moving Average (SMA) sma(float _src, int _period) => sum = 0.0 for i = 0 to _period - 1 sum := sum + _src[i] / _period sum // Standard Deviation isZero(val, eps) => math.abs(val) <= eps sum(fst, snd) => EPS = 1e-10 res = fst + snd if isZero(res, EPS) res := 0 else if not isZero(res, 1e-4) res := res else 15 stdev(src, length) => avg = sma(src, length) sumOfSquareDeviations = 0.0 for i = 0 to length - 1 sum = sum(src[i], - avg) sumOfSquareDeviations := sumOfSquareDeviations + sum * sum stdev = math.sqrt(sumOfSquareDeviations / length) // Measure of difference between the series and it's ma dev(float source, int length, float ma) => mean = sma(source, length) sum = 0.0 for i = 0 to length - 1 val = source[i] sum := sum + math.abs(val - mean) dev = sum/length // Smoothed Moving Average (SMMA) smma(float _src, int _period) => tmpSMA = sma(_src, _period) tmpVal = 0.0 tmpVal := na(tmpVal[1]) ? tmpSMA : (tmpVal[1] * (_period - 1) + _src) / _period // Kaufman's Adaptive Moving Average (KAMA) kama(float _src, int _period) => if (bar_index > _period) tmpVal = 0.0 tmpVal := nz(tmpVal[1]) + math.pow(((math.sum(math.abs(_src - _src[1]), _period) != 0) ? (math.abs(_src - _src[_period]) / math.sum(math.abs(_src - _src[1]), _period)) : 0) * (0.666 - 0.0645) + 0.0645, 2) * (_src - nz(tmpVal[1])) tmpVal // Rolling Moving Average (RMA) rma(float _src, int _period) => rmaAlpha = 1 / _period sum = 0.0 sum := na(sum[1]) ? sma(_src, _period) : rmaAlpha * _src + (1 - rmaAlpha) * nz(sum[1]) // Volume Weighted Moving Averga (VWMA) vwma(float _src, int _period) => sma(_src * _volume, _period) / sma(_volume, _period) // Jurik Moving Average (JMA) - Credits to @everget jma(float _src, int _length, int _phase=50, int _power=2) => 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]) // T3 - Credits to @loxx t3(float _src, float _length, float hot=1, string clean='T3')=> a = hot _c1 = -a * a * a _c2 = 3 * a * a + 3 * a * a * a _c3 = -6 * a * a - 3 * a - 3 * a * a * a _c4 = 1 + 3 * a + a * a * a + 3 * a * a alpha = 0. if (clean == 'T3 New') alpha := 2.0 / (2.0 + (_length - 1.0) / 2.0) else alpha := 2.0 / (1.0 + _length) _t30 = _src, _t31 = _src _t32 = _src, _t33 = _src _t34 = _src, _t35 = _src _t30 := nz(_t30[1]) + alpha * (_src - nz(_t30[1])) _t31 := nz(_t31[1]) + alpha * (_t30 - nz(_t31[1])) _t32 := nz(_t32[1]) + alpha * (_t31 - nz(_t32[1])) _t33 := nz(_t33[1]) + alpha * (_t32 - nz(_t33[1])) _t34 := nz(_t34[1]) + alpha * (_t33 - nz(_t34[1])) _t35 := nz(_t35[1]) + alpha * (_t34 - nz(_t35[1])) out = _c1 * _t35 + _c2 * _t34 + _c3 * _t33 + _c4 * _t32 out ma(float source, int length, string type) => float ma = switch type 'SMA' => sma(source, length) 'KAMA' => kama(source, length) 'VWMA' => vwma(source, length) 'RMA' => rma(source, length) 'T3' => t3(source, length, t3Hot, t3Type) 'JMA' => jma(source, length, jmaPhase, jmaPower) => source roc(float _src, float _length) => 100 * (_src - _src[_length]) / _src[_length] // -- KST Calculation -- int kstLength = switch adaptiveMode 'Hilbert Transform' => math.round(getHtDc(src) / 2) 'Inphase-Quadrature Transform' => math.round(getIqDc(src, min, length) / 2) 'Median' => getMedianDc(src, getAlpha(length)) 'Homodyne Discriminator' => math.round(getHdDc(src, min, length)) => length if (adaptiveMode != 'None') if (kstLength < min) kstLength := min roc1Length := kstLength roc2Length := math.round(kstLength * 1.5) roc3Length := kstLength * 2 roc4Length := kstLength * 3 if (isHodrickPrescrottFilterEnabled) src := hodrickPrescottFilter(src, hpLambda, hpLength) _volume := hodrickPrescottFilter(_volume, hpLambda, length) if (isHannWindowEnabled) src := doHannWindow(src, hannWindowLength) _volume := doHannWindow(src, hannWindowLength) float roc1 = roc(src, roc1Length) float roc2 = roc(src, roc2Length) float roc3 = roc(src, roc3Length) float roc4 = roc(src, roc4Length) float kst = isFibWeightingEnabled ? (0.236) * roc1 + (0.382 * roc2) + (0.50 * roc3) + (0.618) * roc4 : roc1 + (2 * roc2) + (3 * roc3) + (4 * roc4) float kstMa = ma(kst, kstLength, kstMaType) if (isFisherized) kst := fisherize(kst) kstMa := fisherize(kstMa) else kst := normalize(kst * 1000, -1, 1) kstMa := ma(kst, kstLength, kstMaType) if (isNetEnabled) kst := doNet(kstMa, netLength) bool rocLong = kst > 0 bool rocShort = kst < 0 topBand = plot(1, 'Top Band', color=color.new(lightGray, 50)) zeroLine = plot(0, 'Zero Line', color=color.new(lightGray, 50)) bottomBand = plot(-1, 'Bottom Band', color=color.new(lightGray, 50)) kstGradient = color.from_gradient(kst, bottom_value=-0.5, top_value=0.5, top_color=superGreen, bottom_color=superPurple) kstMaPlot = plot(kstMa, title='KST MA', color=kstGradient, linewidth=2) kstPlot = plot(kst, title='KST', color=kstGradient, linewidth=2) fill(kstPlot, kstMaPlot, color=kstGradient) fill(zeroLine, topBand, color=(isHighlighted and rocLong) ? color.new(color.rgb(34, 255, 207), 65) : na) fill(zeroLine, bottomBand, color=(isHighlighted and rocShort) ? color.new(color.rgb(152, 105, 255), 65) : na) // Signals var string openTrade = '' var string signalCache = '' bool enterLong = false bool enterShort = false bool exitLong = false bool exitShort = false if (signalMode == 'Cross') enterLong := ta.crossover(kst, kstMa) enterShort := ta.crossunder(kst, kstMa) if (signalMode == 'Cross Filtered') enterLong := ta.crossover(kst, kstMa) and rocLong enterShort := ta.crossunder(kst, kstMa) and rocShort exitLong := ta.crossunder(kst, kstMa) exitShort := ta.crossover(kst, kstMa) if (signalMode == 'Zero Line') enterLong := ta.crossover(kst, 0) enterShort := ta.crossunder(kst, 0) // Signal Cache // It shouldn't happen that multiple signals are executed in one instance // The cache tries to order the signals correctly if (signalMode == 'Cross Filtered') if (signalCache == 'long entry') signalCache := '' enterLong := true else if (signalCache == 'short entry') signalCache := '' enterShort := true if (openTrade == '') if (exitShort and (not enterLong)) exitShort := false if (exitLong and (not enterShort)) exitLong := false if (enterLong and exitShort) openTrade := 'long' exitShort := false else if (enterShort and exitLong) openTrade := 'short' exitLong := false else if (enterLong) openTrade := 'long' else if (enterShort) openTrade := 'short' else if (openTrade == 'long') if (exitShort) exitShort := false if (enterLong) enterLong := false if (enterShort and exitLong) enterShort := false signalCache := 'short entry' if (exitLong) openTrade := '' else if (openTrade == 'short') if (exitLong) exitLong := false if (enterShort) enterShort := false if (enterLong) enterShort := true if (enterLong and exitShort) enterLong := false signalCache := 'long entry' if (exitShort) openTrade := '' plotshape(enterLong ? -1.2 : na, title='BUY', style=shape.triangleup, color=superGreen, size=size.tiny, location=location.absolute) plotshape(enterShort ? 1.2 : na, title='SELL', style=shape.triangledown, color=superPurple, size=size.tiny, location=location.absolute) plotshape(exitLong ? -1.2 : na, title='BE', style=shape.circle, color=superGreen, size=size.tiny, location=location.absolute) plotshape(exitShort ? 1.2 : na, title='SE', style=shape.circle, color=superPurple, size=size.tiny, location=location.absolute) alertcondition(enterLong, title='ENTER LONG', message='KST – ENTER LONG') alertcondition(exitLong, title='EXIT LONG', message='KST – EXIT LONG') alertcondition(enterShort, title='ENTER SHORT', message='KST – ENTER SHORT') alertcondition(exitShort, title='EXIT SHORT', message='KST – EXIT SHORT') // -- Divergences – Credits to @tista -- [_high, _low] = request.security(syminfo.tickerid, resolution, [high[1], low[1]], barmerge.gaps_off, barmerge.lookahead_on) float top = na float bot = na top := ta.pivothigh(kst, lbL, lbR) bot := ta.pivotlow(kst, lbL, lbR) bool phFound = na(top) ? false : true bool plFound = na(bot) ? false : true // -- Regular Bullish -- // Osc: Higher Low bool kstHL = kst[lbR] > ta.valuewhen(plFound, kst[lbR], 1) and inRange(plFound[1]) // Price: Lower Low bool priceLL = _low[lbR] < ta.valuewhen(plFound, _low[lbR], 1) bool bullCond = priceLL and kstHL and plFound plot( (((divergenceMode == 'Regular') or (divergenceMode == 'Both')) and plFound and isDivergencePlotEnabled) ? kst[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=1, color=(bullCond ? bullColor : noneColor), editable = false) plotshape( (((divergenceMode == 'Regular') or (divergenceMode == 'Both')) and bullCond) ? kst[lbR] : na, offset=-lbR, title='Regular Bullish Label', text='R', style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor, editable = false) alertcondition(bullCond, title='Regular bullish divergence in KST found', message='KST – Regular Bullish Divergence') // -- Hidden Bullish Divergence -- // Osc: Lower Low bool kstLL = kst[lbR] < ta.valuewhen(plFound, kst[lbR], 1) and inRange(plFound[1]) // Price: Higher Low bool priceHL = _low[lbR] > ta.valuewhen(plFound, _low[lbR], 1) bool hiddenBullCond = priceHL and kstLL and plFound plot( (((divergenceMode == 'Hidden') or (divergenceMode == 'Both')) and plFound and isDivergencePlotEnabled) ? kst[lbR] : na, offset=-lbR, title='Hidden Bullish', linewidth=1, color=(hiddenBullCond ? hiddenBullColor : noneColor), editable = false) plotshape( (((divergenceMode == 'Hidden') or (divergenceMode == 'Both')) and hiddenBullCond) ? kst[lbR] : na, offset=-lbR, title='Hidden Bullish Label', text='H', style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor, editable = false) alertcondition(hiddenBullCond, title='Hidden bullish divergence in KST found', message='KST – Hidden Bullish Divergence') // -- Regular Bullish Divergence -- // Osc: Lower High bool kstLH = kst[lbR] < ta.valuewhen(phFound, kst[lbR], 1) and inRange(phFound[1]) // Price: Higher High bool priceHH = _high[lbR] > ta.valuewhen(phFound, _high[lbR], 1) bool bearCond = priceHH and kstLH and phFound plot( (((divergenceMode == 'Regular') or (divergenceMode == 'Both')) and phFound and isDivergencePlotEnabled) ? kst[lbR] : na, offset=-lbR, title='Regular Bearish', linewidth=1, color=(bearCond ? bearColor : noneColor), editable = false) plotshape( (((divergenceMode == 'Regular') or (divergenceMode == 'Both')) and bearCond) ? kst[lbR] : na, offset=-lbR, title='Regular Bearish Label', text='R', style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor, editable = false) alertcondition(bearCond, title='Regular bearish divergence in KST found', message='KST – Regular Bullish Divergence') // -- Hidden Bearish Divergence -- // Osc: Higher High bool kstHH = kst[lbR] > ta.valuewhen(phFound, kst[lbR], 1) and inRange(phFound[1]) // Price: Lower High bool priceLH = _high[lbR] < ta.valuewhen(phFound, _high[lbR], 1) bool hiddenBearCond = priceLH and kstHH and phFound plot( (((divergenceMode == 'Hidden') or (divergenceMode == 'Both')) and phFound and isDivergencePlotEnabled) ? kst[lbR] : na, offset=-lbR, title='Hidden Bearish', linewidth=1, color=(hiddenBearCond ? hiddenBearColor : noneColor), editable=false) plotshape( (((divergenceMode == 'Hidden') or (divergenceMode == 'Both')) and hiddenBearCond) ? kst[lbR] : na, offset=-lbR, title='Hidden Bearish Label', text='H', style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor, editable=false) alertcondition(hiddenBearCond, title='Hidden bearish divergence in KST found', message='KST – Hidden Bearish Divergence')
CVD Ichimoku(s)
https://www.tradingview.com/script/Y3ljh7v5-CVD-Ichimoku-s/
hakunamatata007
https://www.tradingview.com/u/hakunamatata007/
121
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© TradingView //@version=5 indicator("CVD Ichimoku(s)", "CVD Ichimoku(s)", format = format.volume) // CVD - Cumulative Volume Delta Candles // v3 2022.07.11 // This code was written using the recommendations from the Pine Scriptβ„’ User Manual's Style Guide: // https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html import PineCoders/Time/2 as timeLib // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Constants and Inputs { // β€”β€”β€”β€”β€” Constants int MS_IN_MIN = 60 * 1000 int MS_IN_HOUR = MS_IN_MIN * 60 int MS_IN_DAY = MS_IN_HOUR * 24 color WHITE = #ffffffff color GRAY = #808080ff color LIME = #00FF00ff color MAROON = #800000ff color ORANGE = #FF8000ff color PINK = #FF0080ff color TEAL = #008080ff color BG_DIV = color.new(ORANGE, 90) color BG_RESETS = color.new(GRAY, 90) color GRIS = color.new(GRAY, 50) color BLANC = color.new(WHITE, 50) string RST1 = "None" string RST2 = "On a stepped higher timeframe" string RST3 = "On a fixed higher timeframe" string RST4 = "At a fixed time" string RST5 = "At the beginning of the regular session" string RST6 = "At the first visible chart bar" string LTF1 = "Least precise, covering many chart bars" string LTF2 = "Less precise, covering some chart bars" string LTF3 = "More precise, covering less chart bars" string LTF4 = "Most precise, 1min intrabars" string TT_TOTVOL = "The 'Bodies' value is the transparency of the total volume candle bodies. Zero is opaque, 100 is transparent." string TT_RST_HTF = "This value only matters when '" + RST3 +"' is selected." string TT_RST_TIME = "Hour: 0-23\nMinute: 0-59\nThese values only matter when '" + RST4 +"' is selected. A reset will occur when the time is greater or equal to the bar's open time, and less than its close time." // β€”β€”β€”β€”β€” Inputs string GI = "Ichimokus" showSAnow = input(true, title='Senko A now', group = GI) show1r = input(true, title='Current TF - Ichimoku', group = GI) show2nd = input(true, title='Bigger TF - Ichimoku', group = GI) coef = input(6, title='Bigger TF Multiplier', group = GI) string GCVD = "Inputs CVD" string resetInput = input.string(RST1, "CVD Resets", inline = "00", options = [RST1, RST2, RST3, RST4, RST5, RST6], group = GCVD) string fixedTfInput = input.timeframe("D", "  Fixed higher timeframe:", tooltip = TT_RST_HTF, group = GCVD) int hourInput = input.int(9, "  Fixed time:  Hour", inline = "01", minval = 0, maxval = 23, group = GCVD) int minuteInput = input.int(30, "Minute", inline = "01", minval = 0, maxval = 59, tooltip = TT_RST_TIME, group = GCVD) string ltfModeInput = input.string(LTF2, "Intrabar precision", inline = "02", options = [LTF1, LTF2, LTF3, LTF4], group = GCVD) string GRP1 = "Visuals" color upColorInput = input.color(GRIS, "CVD candlesβ€ƒπŸ‘‘", inline = "11", group = GRP1) color dnColorInput = input.color(BLANC, "πŸ‘“", inline = "11", group = GRP1) bool colorDivBodiesInput = input.bool(false, "Color CVD bodies on divergences ", inline = "12", group = GRP1) color upDivColorInput = input.color(LIME, "πŸ‘‘", inline = "12", group = GRP1) color dnDivColorInput = input.color(PINK, "πŸ‘“", inline = "12", group = GRP1) bool showTotVolInput = input.bool(false, "Total volume candles borders", inline = "13", group = GRP1) color upTotVolColorInput = input.color(TEAL, "πŸ‘‘", inline = "13", group = GRP1) color dnTotVolColorInput = input.color(MAROON, "πŸ‘“", inline = "13", group = GRP1) int totVolBodyTranspInput = input.int(80, "bodies", inline = "13", group = GRP1, minval = 0, maxval = 100, tooltip = TT_TOTVOL) bool bgDivInput = input.bool(false, "Color background on divergences ", inline = "14", group = GRP1) color bgDivColorInput = input.color(BG_DIV, "", inline = "14", group = GRP1) bool bgResetInput = input.bool(true, "Color background on resets ", inline = "15", group = GRP1) color bgResetColorInput = input.color(BG_RESETS, "", inline = "15", group = GRP1) bool showInfoBoxInput = input.bool(false, "Show information box ", group = GRP1) string infoBoxSizeInput = input.string("small", "Size ", inline = "16", group = GRP1, options = ["tiny", "small", "normal", "large", "huge", "auto"]) string infoBoxYPosInput = input.string("bottom", "↕", inline = "16", group = GRP1, options = ["top", "middle", "bottom"]) string infoBoxXPosInput = input.string("left", "↔", inline = "16", group = GRP1, options = ["left", "center", "right"]) color infoBoxColorInput = input.color(color.gray, "", inline = "16", group = GRP1) color infoBoxTxtColorInput = input.color(color.white, "T", inline = "16", group = GRP1) // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Functions { // @function Determines if the volume for an intrabar is up or down. // @returns ([float, float]) A tuple of two values, one of which contains the bar's volume. `upVol` is the volume of up bars. `dnVol` is the volume of down bars. // Note that when this function is called with `request.security_lower_tf()` a tuple of float[] arrays will be returned by `request.security_lower_tf()`. upDnIntrabarVolumes() => float upVol = 0.0 float dnVol = 0.0 switch // Bar polarity can be determined. close > open => upVol += volume close < open => dnVol -= volume // If not, use price movement since last bar. close > nz(close[1]) => upVol += volume close < nz(close[1]) => dnVol -= volume // If not, use previously known polarity. nz(upVol[1]) > 0 => upVol += volume nz(dnVol[1]) < 0 => dnVol -= volume [upVol, dnVol] // @function Selects a HTF from the chart's TF. // @returns (simple string) A timeframe string. htfStep() => int tfInMs = timeframe.in_seconds() * 1000 string result = switch tfInMs < MS_IN_MIN => "60" tfInMs < MS_IN_HOUR * 3 => "D" tfInMs <= MS_IN_HOUR * 12 => "W" tfInMs < MS_IN_DAY * 7 => "M" => "12M" // @function Selects a LTF from the chart's TF. // @param precision (simple int) 1, 2, 3 or 4 for increasing quantities of intrabars. // @returns (simple string) A timeframe string. ltfStep(simple int precision = 2) => int tfInMs = timeframe.in_seconds() * 1000 bool coverAllChartBars = precision == 1 bool hiPrecision = precision == 3 bool mostIntrabars = precision == 4 string result = switch coverAllChartBars => timeLib.secondsToTfString(timeframe.in_seconds() / 4) mostIntrabars => "1" tfInMs < MS_IN_HOUR => hiPrecision ? "1" : "1" tfInMs < MS_IN_DAY => hiPrecision ? "1" : "15" tfInMs < MS_IN_DAY * 7 => hiPrecision ? "30" : "120" => hiPrecision ? "60" : "D" // @function Determines when a bar opens at a given time. // @param hours (series int) "Hour" part of the time we are looking for. // @param minutes (series int) "Minute" part of the time we are looking for. // @returns (series bool) `true` when the bar opens at `hours`:`minutes`, false otherwise. timeReset(int hours, int minutes) => int openTime = timestamp(year, month, dayofmonth, hours, minutes, 00) bool timeInBar = time <= openTime and time_close > openTime bool result = timeframe.isintraday and not timeInBar[1] and timeInBar // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Calculations { // Lower timeframe (LTF) used to mine intrabars. var int ltfPrecision = ltfModeInput == LTF1 ? 1 : ltfModeInput == LTF2 ? 2 : ltfModeInput == LTF3 ? 3 : 4 var string optimalLtf = ltfStep(ltfPrecision) // Get two arrays, one each for up and dn volumes. [upVolumes, dnVolumes] = request.security_lower_tf(syminfo.tickerid, optimalLtf, upDnIntrabarVolumes()) // Total up/dn volumes for intrabars. float totalUpVolume = nz(array.sum(upVolumes)) float totalDnVolume = nz(array.sum(dnVolumes)) float delta = totalUpVolume + totalDnVolume // Largest up/dn values in intrabars. float maxUpVolume = nz(array.max(upVolumes)) float maxDnVolume = nz(array.min(dnVolumes)) // Track cumulative volume. var float cvd = 0.0 [reset, resetDescription] = switch resetInput RST1 => [false, "No resets"] RST2 => [timeframe.change(htfStep()), "Resets every " + htfStep()] RST3 => [timeframe.change(fixedTfInput), "Resets every " + fixedTfInput] RST4 => [timeReset(hourInput, minuteInput), str.format("Resets at {0,number,00}:{1,number,00}", hourInput, minuteInput)] RST5 => [session.isfirstbar_regular, "Resets at the beginning of the session"] RST6 => [time == chart.left_visible_bar_time, "Resets at the beginning of visible bars"] if reset cvd := 0 // Build OHLC values for CVD candles. float cvdO = cvd float cvdH = cvdO + maxUpVolume float cvdL = cvdO + maxDnVolume float cvdC = cvdO + delta cvd += delta // Total volume level relative to CVD. float intrabarVolume = totalUpVolume - totalDnVolume float totalVolumeLevel = cvdO + (intrabarVolume * math.sign(delta)) // Qty of intrabars per chart bar and its average. int intrabars = array.size(upVolumes) int chartBarsCovered = int(ta.cum(math.sign(intrabars))) float avgIntrabars = ta.cum(intrabars) / chartBarsCovered // Detect errors. if resetInput == RST3 and timeframe.in_seconds(fixedTfInput) <= timeframe.in_seconds() runtime.error("The higher timeframe for resets must be greater than the chart's timeframe.") else if resetInput == RST4 and not timeframe.isintraday runtime.error("Resets at a fixed time work on intraday charts only.") else if ta.cum(intrabarVolume) == 0 and barstate.islast runtime.error("No volume is provided by the data vendor.") else if ta.cum(intrabars) == 0 and barstate.islast runtime.error("No intrabar information exists at the '" + optimalLtf + "' timeframe.") // Detect divergences between volume delta and the bar's polarity. bool divergence = delta != 0 and math.sign(delta) != math.sign(close - open) // } // β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Visuals { color candleColor = delta > 0 ? colorDivBodiesInput and divergence ? upDivColorInput : upColorInput : colorDivBodiesInput and divergence ? dnDivColorInput : dnColorInput color totVolCandleColor = delta > 0 ? upTotVolColorInput : dnTotVolColorInput // Display key values in indicator values and Data Window. plotchar(delta, "Volume delta for the bar", "", location.top, candleColor, display=display.none) plotchar(totalUpVolume, "Up volume for the bar", "", location.top, upColorInput, display=display.none) plotchar(totalDnVolume, "Dn volume for the bar", "", location.top, dnColorInput, display=display.none) plotchar(intrabarVolume, "Total intrabar volume", "", location.top, display=display.none) plotchar(na, "═════════════════", "", location.top, display=display.none) plotchar(cvdO, "CVD before this bar", "", location.top, display=display.none) plotchar(cvdC, "CVD after this bar", "", location.top, display=display.none) plotchar(maxUpVolume, "Max intrabar up volume", "", location.top, upColorInput, display=display.none) plotchar(maxDnVolume, "Max intrabar dn volume", "", location.top, dnColorInput, display=display.none) plotchar(intrabars, "Intrabars in this bar", "", location.top, display=display.none) plotchar(avgIntrabars, "Average intrabars", "", location.top, display=display.none) plotchar(chartBarsCovered, "Chart bars covered", "", location.top, display=display.none) plotchar(bar_index + 1, "Chart bars", "", location.top, size = size.tiny, display=display.none) plotchar(na, "═════════════════", "", location.top, display=display.none) // Total volume boxes. plotcandle(showTotVolInput ? cvdO : na, math.max(cvdO, totalVolumeLevel), math.min(cvdO, totalVolumeLevel), totalVolumeLevel, "CVD", color = color.new(totVolCandleColor, totVolBodyTranspInput), wickcolor = totVolCandleColor, bordercolor = totVolCandleColor) // CVD candles. plotcandle(cvdO, cvdH, cvdL, cvdC, "CVD", color = candleColor, wickcolor = candleColor, bordercolor = candleColor) // Zero line. hline(0, "Zero", GRAY, hline.style_dotted, display=display.none) // Background on resets and divergences. bgcolor(bgResetInput and reset ? bgResetColorInput : bgDivInput and divergence ? bgDivColorInput : na) // Display information box only once on the last historical bar, instead of on all realtime updates, as when `barstate.islast` is used. if showInfoBoxInput and barstate.islastconfirmedhistory var table infoBox = table.new(infoBoxYPosInput + "_" + infoBoxXPosInput, 1, 1) string txt = resetDescription + "\nUses intrabars at " + timeLib.formattedNoOfPeriods(timeframe.in_seconds(optimalLtf) * 1000) + "\nAvg intrabars per chart bar: " + str.tostring(avgIntrabars, "#.#") table.cell(infoBox, 0, 0, txt, text_color = infoBoxTxtColorInput, text_size = infoBoxSizeInput, bgcolor = infoBoxColorInput) // } //CVD Ichimoku cloud actual TF conversionPeriods = input.int(9, minval=1, title="Conversion Line Length") basePeriods = input.int(26, minval=1, title="Base Line Length") laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length") displacement = input.int(26, minval=1, title="Displacement") donchian(len) => math.avg(ta.lowest(cvd, len), ta.highest(cvd, len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = math.avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) plot(show1r?conversionLine:na, color=color.new(color.blue, 0), title="Conversion Line", display=display.none) plot(show1r?baseLine:na, color=color.new(color.purple, 0), title="Base Line", display=display.none) //plot(ctl, offset = -displacement + 1, color=color.new(color.maroon, 100), title="Lagging Span") p0 = plot(showSAnow?leadLine1:na, color= conversionLine > baseLine ? color.new(color.orange, 51) : color.new(color.orange, 49), linewidth=1, title="Now Span A") p1 = plot(show1r?leadLine1:na, offset = displacement - 1, color=color.new(color.white, 75), linewidth=2, display=display.none, title="Leading Span A") p2 = plot(show1r?leadLine2:na, offset = displacement - 1, color=color.new(color.white, 75), linewidth=2, display=display.none, title="Leading Span B") fill(p1, p2, color = leadLine1 > leadLine2 ? color.new(color.aqua, 80) : color.new(color.yellow, 80)) //CVD Ichimoku cloud bigger TF conversionPeriods2 = coef * conversionPeriods basePeriods2 = coef * basePeriods laggingSpan2Periods2 = coef * laggingSpan2Periods displacement2 = coef * displacement conversionLine2 = donchian(conversionPeriods2) baseLine2 = donchian(basePeriods2) leadLine12 = math.avg(conversionLine2, baseLine2) leadLine22 = donchian(laggingSpan2Periods2) plot(show2nd?conversionLine2:na, color=color.gray, linewidth=1, display=display.none, title="BTF Tenkan") plot(show2nd?baseLine2:na, color=color.gray, linewidth=1, display=display.none, title="BTF Kijun") plot(show2nd?close:na, offset = -displacement2 + 1, color=color.white, linewidth=1, display=display.none, title="BTF Chikou") p12 = plot(show2nd?leadLine12:na, offset = displacement2 - 1, color=color.new(color.gray, 75),linewidth=2, display=display.none, title="BTF Senko A") p22 = plot(show2nd?leadLine22:na, offset = displacement2 - 1, color=color.new(color.gray, 75), linewidth=2, display=display.none, title="BTF Senko B") fill(p12, p22, color = leadLine12 > leadLine22 ? color.new(color.gray, 85) : color.new(color.gray, 85)) //Hololooo
True Range Outlier Detector (TROD)
https://www.tradingview.com/script/8vfIItD6-True-Range-Outlier-Detector-TROD/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
58
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© peacefulLizard50262 //@version=5 indicator("TROD", explicit_plot_zorder = true) normalize(float src, int len) => out = (src - ta.lowest(src, len)) / (ta.highest(src, len) - ta.lowest(src, len)) out style = not input.bool(false, "Use Open Close instead of High Low") length = input.int(100) outlier_up = input.float(0.5, "Outlier High", step = 0.01) outlier_down = input.float(-0.5, "Outlier Low", step = 0.01) out = open > close ? -normalize(high - low, length) : normalize(high - low, length) other = (normalize(close - open, length) - 0.5) * 2 up = hline(outlier_up) dn = hline(outlier_down) fill(up, dn, color = color.new(color.navy, 80)) hline(1, color = color.new(color.green, 30), linestyle = hline.style_solid) hline(-1, color = color.new(color.red, 30), linestyle = hline.style_solid) plot(style ? out : other, color = (style ? out : other) > outlier_up ? color.green : (style ? out : other) < outlier_down ? color.red : color.blue, style = plot.style_columns)
Volume CVD and Open Interest
https://www.tradingview.com/script/esZMDlod-Volume-CVD-and-Open-Interest/
Texmoonbeam
https://www.tradingview.com/u/Texmoonbeam/
765
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Texmoonbeam //@version=5 indicator("Volume CVD and Open Interest", overlay = false, max_labels_count=500, max_lines_count=500, max_boxes_count=500, max_bars_back = 5000) ltf = input.timeframe(defval="1", title='Timeframe used to get Volume data', tooltip="This is the minute timeframe data volume is taken from. There is a maximum of 5000 bars of data, so on higher chart timeframes, you will need to use a higher volume source timeframe like m5, to be able to look back further, e.g there are 1440 minute candles in a daily candle") lookback = input.int(defval=500, title='Bars to look back', tooltip = "Only used to get the min/max for colour gradient") source = input.string(defval = "Up/Down Volume (Net)", title = "Source Data", options=["Volume", "Up/Down Volume (Net)", "Up Volume", "Down Volume", "Cumulative Volume", "Cumulative Volume EMA", "Open Interest"]) hot = input.color(defval=color.new(color.yellow,50), title='High') cold = input.color(defval=color.new(color.red,50), title='Low') oi = input.symbol("BTCUSDTPERP_OI", title = "Open Interest Ticker") oicalc = input.string(defval = "Close - Prev Close", title = "Open Interest Calculation", options=["Close - Prev Close", "Close - Open", "Close"], tooltip="As only a single value can be used, you can choose where this value comes from, either the Close value of OI, the Close - Open for that candle, or the Close - previous candle Close") ResolutionToSec(res)=> mins = res == "1" ? 1 : res == "3" ? 3 : res == "5" ? 5 : res == "10" ? 10 : res == "15" ? 15 : res == "30" ? 30 : res == "45" ? 45 : res == "60" ? 60 : res == "120" ? 120 : res == "180" ? 180 : res == "240" ? 240 : res == "D" or res == "1D" ? 1440 : res == "W" or res == "1W" ? 10080 : res == "M" or res == "1M" ? 43200 : res == "" ? int(str.tonumber(timeframe.period)) : str.substring(timeframe.period, 2, 3) == "S" ? int(str.tonumber(str.substring(timeframe.period, 0, 2)))/60 : int(str.tonumber(res)) ms = mins * 60 * 1000 bar = ResolutionToSec(timeframe.period) upAndDownVolume() => posVol = 0.0 negVol = 0.0 switch close > open => posVol += volume close < open => negVol -= volume close >= close[1] => posVol += volume close < close[1] => negVol -= volume [posVol, negVol] [upVol, downVol] = request.security_lower_tf(syminfo.tickerid, ltf, upAndDownVolume()) [oiOpen, oiHigh, oiLow, oiClose] = request.security(oi, timeframe.period, [open, high, low, close], ignore_invalid_symbol = true) var deltac = 0.0 var deltacema = 0.0 var color colD = na upVolume = array.sum(upVol) downVolume = array.sum(downVol) delta = upVolume + downVolume deltac:= 0 for v = 0 to 13 deltac := deltac + delta[v] deltacema := ta.ema(deltac, 14) deltahigh = ta.highest(delta, lookback) deltalow = ta.lowest(delta, lookback) upvolhigh = ta.highest(upVolume, lookback) upvollow = ta.lowest(upVolume, lookback) vollow = ta.lowest(volume, lookback) volhigh = ta.highest(volume, lookback) downvolhigh = ta.highest(downVolume, lookback) downvollow = ta.lowest(downVolume, lookback) deltachigh = ta.highest(deltac, lookback) deltaclow = ta.lowest(deltac, lookback) deltachighema = ta.highest(deltacema, lookback) deltaclowema = ta.lowest(deltacema, lookback) oival = oicalc == "Close - Prev Close" ? oiClose - oiClose[1] : oicalc == "Close - Open" ? oiClose - oiOpen : oiClose oihigh = ta.highest(oival, lookback) oilow = ta.lowest(oival, lookback) s = 0.0 sl = 0.0 sh = 0.0 if (source == "Volume") s := volume sl := vollow sh := volhigh if (source == "Up/Down Volume (Net)") s := delta sl := deltalow sh := deltahigh if (source == "Up Volume") s := upVolume sl := upvollow sh := upvolhigh if (source == "Down Volume") s := downVolume sl := downvollow sh := downvolhigh if (source == "Cumulative Volume") s := deltac sl := deltaclow sh := deltachigh if (source == "Cumulative Volume EMA") s := deltacema sl := deltaclowema sh := deltachighema if (source == "Open Interest") s := oival sl := oilow sh := oihigh col = color.from_gradient(s, sl, sh, cold, hot) plot(s, title="Source", style = plot.style_columns, color=col) // if (bar_index == last_bar_index) // label.new(x=bar_index, y=(oival)*1.01, text = str.tostring(oiClose)+ ' ' +str.tostring(oiClose[1])+' '+str.tostring(oiOpen)) //plot(delta, "V", style = plot.style_columns, color=col) //plotchar(delta, "delta", "β€”", location.absolute, color = col, size = size.small) //label.new(x=timenow, y=high, xloc = xloc.bar_time, text = str.tostring(deltahigh)) //for x = 0 to n //col = color.from_gradient(deltanorm, deltalow, detlahigh, color.yellow, color.red) //box.new(left=time, bottom=minp+(step*x), top=minp+(step)+(step*x), right=time+(bar), border_color = color.new(color.white, 100), bgcolor = col, xloc = xloc.bar_time) // if candle not pivot, store up / down price, add to box array, color as delta, when next candle is higher or lower, delete, otherwise extend // m = 76 // if (bar_index == last_bar_index) // nb = box.new(left=bar_index[m], top = open[m], right=last_bar_index, bottom=close[m], bgcolor = color.new(col[m],20), border_color = color.new(col[m],20))
10 MAs Alpha Indicator by Monty
https://www.tradingview.com/script/xoaiT3DQ-10-MAs-Alpha-Indicator-by-Monty/
MontyTheGuy
https://www.tradingview.com/u/MontyTheGuy/
51
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© MONTY //@version=5 indicator('10 MAs Alpha Indicator by Monty',shorttitle = "Alpha 10 MAs by Monty", overlay=true) showMAs = input.bool(title='Show All Moving Averages', defval=true, group='Moving Averages') ShowMA1 = input.bool(title='', defval=true, group='Moving Averages', inline="01") color MA1 = input.color(color.rgb(0, 255, 255, 0), group='Moving Averages', inline="01") MA_Period1 = input.int(title='', defval=20, minval=1, group='Moving Averages', inline="01") string MA1Period = str.tostring(MA_Period1) MA_Res1 = input.timeframe(title='', defval='', group='Moving Averages', inline="01") typeMA1 = input.string(title = "", defval = "SMA", options=["SMA", "EMA"], group='Moving Averages', inline="01") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA1Period := MA1Period + typeMA1 ShowMA2 = input.bool(title='', defval=true,group='Moving Averages', inline="02") color MA2 = input.color(color.rgb(0, 0, 255, 0), group='Moving Averages', inline="02") MA_Period2 = input.int(title='', defval=50, minval=1, group='Moving Averages', inline="02") string MA2Period = str.tostring(MA_Period2) MA_Res2 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="02") typeMA2 = input.string(title = "", defval = "SMA", options=["SMA", "EMA"], group='Moving Averages', inline="02") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA2Period := MA2Period + typeMA2 ShowMA3 = input.bool(title='', defval=true,group='Moving Averages', inline="03") color MA3 = input.color(color.rgb(0, 255, 0, 0), group='Moving Averages', inline="03") MA_Period3 = input.int(title='', defval=100, minval=1, group='Moving Averages', inline="03") string MA3Period = str.tostring(MA_Period3) MA_Res3 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="03") typeMA3 = input.string(title = "", defval = "SMA", options=["SMA", "EMA"], group='Moving Averages', inline="03") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA3Period := MA3Period + typeMA3 ShowMA4 = input.bool(title='', defval=true,group='Moving Averages', inline="04") color MA4 = input.color(color.rgb(0, 128, 0, 0), group='Moving Averages', inline="04") MA_Period4 = input.int(title='', defval=200, minval=1, group='Moving Averages', inline="04") string MA4Period = str.tostring(MA_Period4) MA_Res4 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="04") typeMA4 = input.string(title = "", defval = "SMA", options=["SMA", "EMA"], group='Moving Averages', inline="04") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA4Period := MA4Period + typeMA4 ShowMA5 = input.bool(title='', defval=false,group='Moving Averages', inline="05") color MA5 = input.color(color.rgb(128, 128, 0, 80), group='Moving Averages', inline="05") MA_Period5 = input.int(title='', defval=20, minval=1, group='Moving Averages', inline="05") string MA5Period = str.tostring(MA_Period5) MA_Res5 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="05") typeMA5 = input.string(title = "", defval = "EMA", options=["SMA", "EMA"], group='Moving Averages', inline="05") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA5Period := MA5Period + typeMA5 ShowMA6 = input.bool(title='', defval=false,group='Moving Averages', inline="06") color MA6 = input.color(color.rgb(128, 128, 0, 80), group='Moving Averages', inline="06") MA_Period6 = input.int(title='', defval=20, minval=1, group='Moving Averages', inline="06") string MA6Period = str.tostring(MA_Period6) MA_Res6 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="06") typeMA6 = input.string(title = "", defval = "EMA", options=["SMA", "EMA"], group='Moving Averages', inline="06") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA6Period := MA6Period + typeMA6 ShowMA7 = input.bool(title='', defval=false,group='Moving Averages', inline="07") color MA7 = input.color(color.rgb(128, 128, 0, 80), group='Moving Averages', inline="07") MA_Period7 = input.int(title='', defval=20, minval=1, group='Moving Averages', inline="07") string MA7Period = str.tostring(MA_Period7) MA_Res7 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="07") typeMA7 = input.string(title = "", defval = "EMA", options=["SMA", "EMA"], group='Moving Averages', inline="07") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA7Period := MA7Period + typeMA7 ShowMA8 = input.bool(title='', defval=false,group='Moving Averages', inline="08") color MA8 = input.color(color.rgb(128, 128, 0, 80), group='Moving Averages', inline="08") MA_Period8 = input.int(title='', defval=20, minval=1, group='Moving Averages', inline="08") string MA8Period = str.tostring(MA_Period8) MA_Res8 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="08") typeMA8 = input.string(title = "", defval = "EMA", options=["SMA", "EMA"], group='Moving Averages', inline="08") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA8Period := MA8Period + typeMA8 ShowMA9 = input.bool(title='', defval=false,group='Moving Averages', inline="09") color MA9 = input.color(color.rgb(128, 128, 0, 80), group='Moving Averages', inline="09") MA_Period9 = input.int(title='', defval=20, minval=1, group='Moving Averages', inline="09") string MA9Period = str.tostring(MA_Period9) MA_Res9 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="09") typeMA9 = input.string(title = "", defval = "EMA", options=["SMA", "EMA"], group='Moving Averages', inline="09") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA9Period := MA9Period + typeMA9 ShowMA10 = input.bool(title='', defval=false,group='Moving Averages', inline="10") color MA10 = input.color(color.rgb(128, 128, 0, 80), group='Moving Averages', inline="10") MA_Period10 = input.int(title='', defval=20, minval=1, group='Moving Averages', inline="10") string MA10Period = str.tostring(MA_Period10) MA_Res10 = input.timeframe(title=' ', defval='', group='Moving Averages', inline="10") typeMA10 = input.string(title = "", defval = "EMA", options=["SMA", "EMA"], group='Moving Averages', inline="10") //options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"] MA10Period := MA10Period + typeMA10 f_secureSecurity(_symbol, _res, _src) => // orignal code line request.security(_symbol, _res, _src[1], barmerge.gaps_on, lookahead=barmerge.lookahead_on) MA_Function1 = f_secureSecurity(syminfo.tickerid, MA_Res1, ta.sma( close, MA_Period1)) MA_Function2 = f_secureSecurity(syminfo.tickerid, MA_Res2, ta.sma( close, MA_Period2)) MA_Function3 = f_secureSecurity(syminfo.tickerid, MA_Res3, ta.sma( close, MA_Period3)) MA_Function4 = f_secureSecurity(syminfo.tickerid, MA_Res4, ta.sma( close, MA_Period4)) MA_Function5 = f_secureSecurity(syminfo.tickerid, MA_Res5, ta.sma( close, MA_Period5)) MA_Function6 = f_secureSecurity(syminfo.tickerid, MA_Res6, ta.sma( close, MA_Period6)) MA_Function7 = f_secureSecurity(syminfo.tickerid, MA_Res7, ta.sma( close, MA_Period7)) MA_Function8 = f_secureSecurity(syminfo.tickerid, MA_Res8, ta.sma( close, MA_Period8)) MA_Function9 = f_secureSecurity(syminfo.tickerid, MA_Res9, ta.sma( close, MA_Period9)) MA_Function10 = f_secureSecurity(syminfo.tickerid, MA_Res10, ta.sma( close, MA_Period10)) switch typeMA1 "SMA"=> MA_Function1 := f_secureSecurity(syminfo.tickerid, MA_Res1, ta.sma( close, MA_Period1)) "EMA"=> MA_Function1 := f_secureSecurity(syminfo.tickerid, MA_Res1, ta.ema( close, MA_Period1)) switch typeMA2 "SMA"=> MA_Function2 := f_secureSecurity(syminfo.tickerid, MA_Res2, ta.sma( close, MA_Period2)) "EMA"=> MA_Function2 := f_secureSecurity(syminfo.tickerid, MA_Res2, ta.ema( close, MA_Period2)) switch typeMA3 "SMA"=> MA_Function3 := f_secureSecurity(syminfo.tickerid, MA_Res3, ta.sma( close, MA_Period3)) "EMA"=> MA_Function3 := f_secureSecurity(syminfo.tickerid, MA_Res3, ta.ema( close, MA_Period3)) switch typeMA4 "SMA"=> MA_Function4 := f_secureSecurity(syminfo.tickerid, MA_Res4, ta.sma( close, MA_Period4)) "EMA"=> MA_Function4 := f_secureSecurity(syminfo.tickerid, MA_Res4, ta.ema( close, MA_Period4)) switch typeMA5 "SMA"=> MA_Function5 := f_secureSecurity(syminfo.tickerid, MA_Res5, ta.sma( close, MA_Period5)) "EMA"=> MA_Function5 := f_secureSecurity(syminfo.tickerid, MA_Res5, ta.ema( close, MA_Period5)) switch typeMA6 "SMA"=> MA_Function6 := f_secureSecurity(syminfo.tickerid, MA_Res6, ta.sma( close, MA_Period6)) "EMA"=> MA_Function6 := f_secureSecurity(syminfo.tickerid, MA_Res6, ta.ema( close, MA_Period6)) switch typeMA7 "SMA"=> MA_Function7 := f_secureSecurity(syminfo.tickerid, MA_Res7, ta.sma( close, MA_Period7)) "EMA"=> MA_Function7 := f_secureSecurity(syminfo.tickerid, MA_Res7, ta.ema( close, MA_Period7)) switch typeMA8 "SMA"=> MA_Function8 := f_secureSecurity(syminfo.tickerid, MA_Res8, ta.sma( close, MA_Period8)) "EMA"=> MA_Function8 := f_secureSecurity(syminfo.tickerid, MA_Res8, ta.ema( close, MA_Period8)) switch typeMA9 "SMA"=> MA_Function9 := f_secureSecurity(syminfo.tickerid, MA_Res9, ta.sma( close, MA_Period9)) "EMA"=> MA_Function9 := f_secureSecurity(syminfo.tickerid, MA_Res9, ta.ema( close, MA_Period9)) switch typeMA10 "SMA"=> MA_Function10 := f_secureSecurity(syminfo.tickerid, MA_Res10, ta.sma( close, MA_Period10)) "EMA"=> MA_Function10 := f_secureSecurity(syminfo.tickerid, MA_Res10, ta.ema( close, MA_Period10)) ma1_plot = plot(showMAs and ShowMA1 ? MA_Function1 : na, title='Moving Average 1', color=MA1 , style=plot.style_line, linewidth=1) var MA1Label = label.new(x = bar_index, y = MA_Function1, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA1, text = MA1Period) label.set_xy(showMAs and ShowMA1 ? (MA1Label) : na, x = bar_index, y = MA_Function1) ma2_plot = plot(showMAs and ShowMA2 ? MA_Function2 : na, title='Moving Average 2', color=MA2, style=plot.style_line, linewidth=1) var MA2Label = label.new(x = bar_index, y = MA_Function1, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA2, text = MA2Period) label.set_xy(showMAs and ShowMA2 ? (MA2Label) : na, x = bar_index, y = MA_Function2) ma3_plot = plot(showMAs and ShowMA3 ? MA_Function3 : na, title='Moving Average 3', color=MA3, style=plot.style_line, linewidth=1) var MA3Label = label.new(x = bar_index, y = MA_Function3, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA3, text = MA3Period) label.set_xy(showMAs and ShowMA3 ? (MA3Label) : na, x = bar_index, y = MA_Function3) ma4_plot = plot(showMAs and ShowMA4 ? MA_Function4 : na, title='Moving Average 4', color=MA4, style=plot.style_line, linewidth=1) var MA4Label = label.new(x = bar_index, y = MA_Function4, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA4, text = MA4Period) label.set_xy(showMAs and ShowMA4 ? (MA4Label) : na, x = bar_index, y = MA_Function4) ma5_plot = plot(showMAs and ShowMA5 ? MA_Function5 : na, title='Moving Average 5', color=MA5, style=plot.style_line, linewidth=1) var MA5Label = label.new(x = bar_index, y = MA_Function5, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA5, text = MA5Period) label.set_xy(showMAs and ShowMA5 ? (MA5Label) : na, x = bar_index, y = MA_Function5) ma6_plot = plot(showMAs and ShowMA6 ? MA_Function6 : na, title='Moving Average 6', color=MA6 , style=plot.style_line, linewidth=1) var MA6Label = label.new(x = bar_index, y = MA_Function6, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA6, text = MA6Period) label.set_xy(showMAs and ShowMA1 ? (MA1Label) : na, x = bar_index, y = MA_Function1) ma7_plot = plot(showMAs and ShowMA7 ? MA_Function7 : na, title='Moving Average 7', color=MA7, style=plot.style_line, linewidth=1) var MA7Label = label.new(x = bar_index, y = MA_Function7, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA7, text = MA7Period) label.set_xy(showMAs and ShowMA7 ? (MA7Label) : na, x = bar_index, y = MA_Function7) ma8_plot = plot(showMAs and ShowMA8 ? MA_Function8 : na, title='Moving Average 8', color=MA8, style=plot.style_line, linewidth=1) var MA8Label = label.new(x = bar_index, y = MA_Function8, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA8, text = MA8Period) label.set_xy(showMAs and ShowMA8 ? (MA8Label) : na, x = bar_index, y = MA_Function8) ma9_plot = plot(showMAs and ShowMA9 ? MA_Function9 : na, title='Moving Average 9', color=MA9, style=plot.style_line, linewidth=1) var MA9Label = label.new(x = bar_index, y = MA_Function9, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA9, text = MA9Period) label.set_xy(showMAs and ShowMA9 ? (MA9Label) : na, x = bar_index, y = MA_Function9) ma10_plot = plot(showMAs and ShowMA10 ? MA_Function10 : na, title='Moving Average 5', color=MA10, style=plot.style_line, linewidth=1) var MA10Label = label.new(x = bar_index, y = MA_Function10, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = MA10, text = MA10Period) label.set_xy(showMAs and ShowMA10 ? (MA10Label) : na, x = bar_index, y = MA_Function10) if (ShowMA1==false) label.delete(MA1Label) if (ShowMA2==false) label.delete(MA2Label) if (ShowMA3==false) label.delete(MA3Label) if (ShowMA4==false) label.delete(MA4Label) if (ShowMA5==false) label.delete(MA5Label) if (ShowMA6==false) label.delete(MA6Label) if (ShowMA7==false) label.delete(MA7Label) if (ShowMA8==false) label.delete(MA8Label) if (ShowMA9==false) label.delete(MA9Label) if (ShowMA10==false) label.delete(MA10Label)
Musashi_Katana
https://www.tradingview.com/script/pE9pBESi-Musashi-Katana/
Musashi-Alchemist
https://www.tradingview.com/u/Musashi-Alchemist/
93
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Musashi-Alchemist //@version=5 indicator(title='Musashi_Katana', format=format.price, overlay=true, max_bars_back=5000, max_lines_count=500, max_labels_count=500) //============================================================================== // === STRATEGY INPUTS === //============================================================================== //------------------------------------------------------------------------------ ama_0_bool = input.bool(false, title="AMA - Short Term  ", group='ADAPTATIVE MOVING AVERAGE - TREND STRATEGIES', inline='ama') ama_mid_bool = input.bool(true, title="AMA - Mid Term  ", group='ADAPTATIVE MOVING AVERAGE - TREND STRATEGIES', inline='ama') ama_3_bool = input.bool(false, title="AMA - Long Term  ", group='ADAPTATIVE MOVING AVERAGE - TREND STRATEGIES', inline='ama') //------------------------------------------------------------------------------ vwap_1w_bool = input.bool(false, title="VWAP - 1W      ", group='MULTI TIMEFRAME - TREND STRATEGIES', inline='vwap') vwap_1m_bool = input.bool(false, title="VWAP - 1M      ", group='MULTI TIMEFRAME - TREND STRATEGIES', inline='vwap') vwap_1y_bool = input.bool(false, title="VWAP - 1Y", group='MULTI TIMEFRAME - TREND STRATEGIES', inline='vwap') //------------------------------------------------------------------------------ ema_4h_bool = input.bool(false, title="EMA - 4H        ", group='MULTI TIMEFRAME - TREND STRATEGIES', inline='mtema') ema_daily_bool = input.bool(false, title="EMA - Daily     ", group='MULTI TIMEFRAME - TREND STRATEGIES', inline='mtema') ema_weekly_bool = input.bool(false, title="EMA - Weekly", group='MULTI TIMEFRAME - TREND STRATEGIES', inline='mtema') //------------------------------------------------------------------------------ ema_1_bool = input.bool(false, title="EMA 1   ", group='EMA - TREND STRATEGIES', inline='ema') ema_2_bool = input.bool(false, title="EMA 2   ", group='EMA - TREND STRATEGIES', inline='ema') ema_3_bool = input.bool(true, title="EMA 3   ", group='EMA - TREND STRATEGIES', inline='ema') ema_4_bool = input.bool(false, title="EMA 4   ", group='EMA - TREND STRATEGIES', inline='ema') ema_5_bool = input.bool(false, title="EMA 5   ", group='EMA - TREND STRATEGIES', inline='ema') //------------------------------------------------------------------------------ ssl_1_bool = input.bool(false, title="SSL 1 - Current TF  ", group='SSL - TREND STRATEGIES', inline='ssl_1') ssl_1_period = input.int(21, title="", group='SSL - TREND STRATEGIES', inline='ssl_1') ssl_2_bool = input.bool(false, title="SSL 2 - Multi TF    ", group='SSL - TREND STRATEGIES', inline='ssl_2') ssl_2_period = input.int(21, title="", group='SSL - TREND STRATEGIES', inline='ssl_2') ssl_2_tf = input.string('1D', title="TF", group='SSL - TREND STRATEGIES', inline='ssl_2') //------------------------------------------------------------------------------ ki_bool = input.bool(false, title="Kijun-Sen    ", group='BASELINE - KIJUN-SEN', inline='kijunsen_a') ki_Length = input.int(21, 'Length', minval=1, group='BASELINE - KIJUN-SEN', inline='kijunsen_a') ki_atr_bands_bool = input.bool(false, title="ATR Bands   ", group='BASELINE - KIJUN-SEN', inline='kijunsen_b') ki_atr_len = input.int(34, 'Length', minval=1, group='BASELINE - KIJUN-SEN', inline='kijunsen_b') ki_atr_multip = input.float(1, 'Multip', minval=1, group='BASELINE - KIJUN-SEN', inline='kijunsen_b') //------------------------------------------------------------------------------ ama_base_bool = input.bool(false, title="AMA", group='BASELINE - AMA', inline='ama_base_a') ama_base_length = input.int(title='', defval=55, group='BASELINE - AMA', inline='ama_base_a') ama_base_fastLength = input.int(title='Fast', defval=3, group='BASELINE - AMA', inline='ama_base_a') ama_base_slowLength = input.int(title='Slow', defval=13, group='BASELINE - AMA', inline='ama_base_a') ama_base_highlightMovements = true ama_base_src = close ama_base_atr_bands_bool = input.bool(false, title="ATR Bands    ", group='BASELINE - AMA', inline='ama_base_b') ama_base_atr_len = input.int(13, 'ATR Length', minval=1, group='BASELINE - AMA', inline='ama_base_b') ama_base_atr_multip = input.float(1, 'ATR Multip', group='BASELINE - AMA', inline='ama_base_b') //------------------------------------------------------------------------------ ama_0_length = input.int(title='AMA 0', defval=21, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_0') ama_0_fastLength = input.int(title='Fast', defval=2, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_0') ama_0_slowLength = input.int(title='Slow', defval=13, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_0') ama_0_highlightMovements = input.bool(title='', defval=true, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_0') ama_0_src = close //------------------------------------------------------------------------------ ama_1_length = input.int(title='AMA 1', defval=55, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_1') ama_1_fastLength = input.int(title='Fast', defval=5, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_1') ama_1_slowLength = input.int(title='Slow', defval=55, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_1') ama_1_highlightMovements = input.bool(title='', defval=true, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_1') ama_1_src = close //------------------------------------------------------------------------------ ama_2_length = input.int(title='AMA 2', defval=55, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_2') ama_2_fastLength = input.int(title='Fast', defval=7, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_2') ama_2_slowLength = input.int(title='Slow', defval=13, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_2') ama_2_highlightMovements = input.bool(title='', defval=true, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_2') ama_2_src = close //------------------------------------------------------------------------------ ama_3_length = input.int(title='AMA 3', defval=55, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_3') ama_3_fastLength = input.int(title='Fast', defval=13, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_3') ama_3_slowLength = input.int(title='Slow', defval=13, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_3') ama_3_highlightMovements = input.bool(title='', defval=true, group='AMA - ADAPTATIVE MOVING AVERAGE', inline='ama_3') ama_3_src = close //------------------------------------------------------------------------------ tf_4h_ema = input.timeframe('240', title = "EMA - Short Term", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_1') length_4h_ema_fast = input.int(21, title="Fast", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_1') length_4h_ema_slow = input.int(55, title="Slow", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_1') //------------------------------------------------------------------------------ tf_daily_ema = input.timeframe('D', title = "EMA - Mid Term ", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_2') length_daily_ema_fast = input.int(21, title="Fast", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_2') length_daily_ema_slow = input.int(55, title="Slow", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_2') //------------------------------------------------------------------------------ tf_weekly_ema = input.timeframe('W', title = "EMA - Long Term", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_3') length_weekly_ema_fast = input.int(21, title="Fast", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_3') length_weekly_ema_slow = input.int(55, title="Slow", group='MULTIME EMA - Exponential Moving Average', inline='emas_all_3') //------------------------------------------------------------------------------ //============================================================================== // === EMA SETUP === //============================================================================== //------------------------------------------------------------------------------ ema_4h_1 = ema_4h_bool ? request.security(syminfo.ticker, tf_4h_ema, ta.ema(close, length_4h_ema_fast)) : 0 ema_4h_2 = ema_4h_bool ? request.security(syminfo.ticker, tf_4h_ema, ta.ema(close, length_4h_ema_slow)) : 0 ema_daily_1 = ema_daily_bool ? request.security(syminfo.ticker, tf_daily_ema, ta.ema(close, length_daily_ema_fast)) : 0 ema_daily_2 = ema_daily_bool ? request.security(syminfo.ticker, tf_daily_ema, ta.ema(close, length_daily_ema_slow)) : 0 ema_weekly_1 = ema_weekly_bool ? request.security(syminfo.ticker, tf_weekly_ema, ta.ema(close, length_weekly_ema_fast)) : 0 ema_weekly_2 = ema_weekly_bool ? request.security(syminfo.ticker, tf_weekly_ema, ta.ema(close, length_weekly_ema_slow)) : 0 //------------------------------------------------------------------------------ plot(ema_4h_bool ? ema_4h_1 : na,"4H EMA Fast",color.new(#d1d4dc, 64),linewidth=1) plot(ema_4h_bool ? ema_4h_2 : na,"4H EMA Slow",color.new(#5b9cf6, 45),linewidth=1) plot(ema_daily_bool ? ema_daily_1 : na,"Daily EMA Fast",color.new(#a10b0b, 24),linewidth=2) plot(ema_daily_bool ? ema_daily_2 : na,"Daily EMA Slow",color.new(color.gray, 42),linewidth=2) plot(ema_weekly_bool ? ema_weekly_1 : na,"Weekly EMA Fast",color.new(#a10b0b, 65),linewidth=4) plot(ema_weekly_bool ? ema_weekly_2 : na,"Weekly EMA Slow",color.new(color.gray, 28),linewidth=4) //------------------------------------------------------------------------------ ema1_period = input.int(9, minval=1, title="EMA 1", group='EMA - Exponential Moving Average', inline='emas_all_1') ema2_period = input.int(21, minval=1, title="EMA 2", group='EMA - Exponential Moving Average', inline='emas_all_1') ema3_period = input.int(55, minval=1, title="EMA 3", group='EMA - Exponential Moving Average', inline='emas_all_1') ema4_period = input.int(144, minval=1, title="EMA 4", group='EMA - Exponential Moving Average', inline='emas_all_2') ema5_period = input.int(233, minval=1, title="EMA 5", group='EMA - Exponential Moving Average', inline='emas_all_2') //------------------------------------------------------------------------------ ema1 = ta.ema(close, ema1_period) ema2 = ta.ema(close, ema2_period) ema3 = ta.ema(close, ema3_period) ema4 = ta.ema(close, ema4_period) ema5 = ta.ema(close, ema5_period) //------------------------------------------------------------------------------ plot(ema_1_bool ? ema1 : na,"EMA 1",linewidth=2, color=color.new(#d1d4dc, 50)) plot(ema_2_bool ? ema2 : na,"EMA 2",linewidth=2, color=color.new(#a10b0b, 25)) plot(ema_3_bool ? ema3 : na,"EMA 3",linewidth=2, color=color.new(#e92727, 20)) plot(ema_4_bool ? ema4 : na,"EMA 4",linewidth=3, color=color.new(#9598a1, 30)) plot(ema_5_bool ? ema5 : na,"EMA 5",linewidth=3, color=color.new(#434651, 20)) //------------------------------------------------------------------------------ //============================================================================== // === AMA SETUP === //============================================================================== //------------------------------------------------------------------------------ // AMA 0 //------------------------------------------------------------------------------ ama_0 = 0.0 ama_0_Color = color.white //------------------------------------------------------------------------------ ama_0_fastAlpha = 2 / (ama_0_fastLength + 1) ama_0_slowAlpha = 2 / (ama_0_slowLength + 1) ama_0_hh = ta.highest(ama_0_length + 1) ama_0_ll = ta.lowest(ama_0_length + 1) ama_0_mltp = ama_0_hh - ama_0_ll != 0 ? math.abs(2 * ama_0_src - ama_0_ll - ama_0_hh) / (ama_0_hh - ama_0_ll) : 0 ama_0_ssc = ama_0_mltp * (ama_0_fastAlpha - ama_0_slowAlpha) + ama_0_slowAlpha ama_0 := nz(ama_0[1]) + math.pow(ama_0_ssc, 2) * (ama_0_src - nz(ama_0[1])) ama_0_Color := ama_0_highlightMovements ? ama_0 > ama_0[1] ? color.new(color.gray,20) : color.new(#f70007,20) : color.new(color.gray,20) plot((ama_0_bool) ? ama_0 : na, title='AMA 0', linewidth=2, color=ama_0_Color) //------------------------------------------------------------------------------ // AMA 1 //------------------------------------------------------------------------------ ama_1 = 0.0 ama_1_Color = color.white //------------------------------------------------------------------------------ ama_1_fastAlpha = 2 / (ama_1_fastLength + 1) ama_1_slowAlpha = 2 / (ama_1_slowLength + 1) ama_1_hh = ta.highest(ama_1_length + 1) ama_1_ll = ta.lowest(ama_1_length + 1) ama_1_mltp = ama_1_hh - ama_1_ll != 0 ? math.abs(2 * ama_1_src - ama_1_ll - ama_1_hh) / (ama_1_hh - ama_1_ll) : 0 ama_1_ssc = ama_1_mltp * (ama_1_fastAlpha - ama_1_slowAlpha) + ama_1_slowAlpha ama_1 := nz(ama_1[1]) + math.pow(ama_1_ssc, 2) * (ama_1_src - nz(ama_1[1])) ama_1_Color := ama_1_highlightMovements ? ama_1 > ama_1[1] ? color.new(color.gray,42) : color.new(#f70007,42) : color.new(color.gray,42) plot((ama_0_bool or ama_mid_bool) ? ama_1 : na, title='AMA 1', linewidth=2, color=ama_1_Color) // or ama_3_bool //------------------------------------------------------------------------------ // AMA 2 //------------------------------------------------------------------------------ ama_2 = 0.0 ama_2_Color = color.white //------------------------------------------------------------------------------ ama_2_fastAlpha = 2 / (ama_2_fastLength + 1) ama_2_slowAlpha = 2 / (ama_2_slowLength + 1) ama_2_hh = ta.highest(ama_2_length + 1) ama_2_ll = ta.lowest(ama_2_length + 1) ama_2_mltp = ama_2_hh - ama_2_ll != 0 ? math.abs(2 * ama_2_src - ama_2_ll - ama_2_hh) / (ama_2_hh - ama_2_ll) : 0 ama_2_ssc = ama_2_mltp * (ama_2_fastAlpha - ama_2_slowAlpha) + ama_2_slowAlpha ama_2 := nz(ama_2[1]) + math.pow(ama_2_ssc, 2) * (ama_2_src - nz(ama_2[1])) ama_2_Color := ama_2_highlightMovements ? ama_2 > ama_2[1] ? color.new(color.gray,50) : color.new(#f70007,50) : color.new(color.gray,50) plot((ama_3_bool or ama_mid_bool or ama_3_bool) ? ama_2 : na, title='AMA 2', linewidth=2, color=ama_2_Color) //------------------------------------------------------------------------------ // AMA 3 //------------------------------------------------------------------------------ ama_3_fastAlpha = 2 / (ama_3_fastLength + 1) ama_3_slowAlpha = 2 / (ama_3_slowLength + 1) ama_3_hh = ta.highest(ama_3_length + 1) ama_3_ll = ta.lowest(ama_3_length + 1) ama_3_mltp = ama_3_hh - ama_3_ll != 0 ? math.abs(2 * ama_3_src - ama_3_ll - ama_3_hh) / (ama_3_hh - ama_3_ll) : 0 ama_3_ssc = ama_3_mltp * (ama_3_fastAlpha - ama_3_slowAlpha) + ama_3_slowAlpha ama_3 = 0.0 ama_3 := nz(ama_3[1]) + math.pow(ama_3_ssc, 2) * (ama_3_src - nz(ama_3[1])) ama_3_Color = ama_3_highlightMovements ? ama_3 > ama_3[1] ? color.new(color.gray,50) : color.new(#f70007,50) : color.new(color.gray,50) plot(ama_3_bool? ama_3 : na, title='AMA 3', linewidth=2, color=ama_3_Color)// : color.new(color.gray,100)) //------------------------------------------------------------------------------ //============================================================================== //=== VWAP SETUP === //============================================================================== //------------------------------------------------------------------------------ startW = vwap_1w_bool ? request.security(syminfo.tickerid, 'W', time, lookahead=barmerge.lookahead_on) : 0 startM = vwap_1m_bool ? request.security(syminfo.tickerid, 'M', time, lookahead=barmerge.lookahead_on) : 0 startY = vwap_1y_bool ? request.security(syminfo.tickerid, '12M', time, lookahead=barmerge.lookahead_on) : 0 //------------------------------------------------------------------------------ change_1 = vwap_1w_bool ? ta.change(startW) : 0 newSessionW = change_1 ? 1 : 0 change_2 = vwap_1m_bool ? ta.change(startM) : 0 newSessionM = change_2 ? 1 : 0 change_3 = vwap_1y_bool ? ta.change(startY) : 0 newSessionY = change_3 ? 1 : 0 //------------------------------------------------------------------------------ getVWAP(newSession) => p = hlc3 * volume p := newSession ? hlc3 * volume : p[1] + hlc3 * volume vol = 0.0 vol := newSession ? volume : vol[1] + volume v = p / vol Sn = 0.0 Sn := newSession ? 0 : Sn[1] + volume * (hlc3 - v[1]) * (hlc3 - v) std = math.sqrt(Sn / vol) [v, std] //------------------------------------------------------------------------------ [vW, stdevW] = getVWAP(newSessionW) [vM, stdevM] = getVWAP(newSessionM) [vY, stdevY] = getVWAP(newSessionY) //------------------------------------------------------------------------------ vMplotW = plot(vwap_1w_bool? vW : na, title = "Weekly VWAP", color = color.new(#d1d4dc,12), linewidth = 1) vMplotM = plot(vwap_1m_bool? vM : na, title = "Monthly VWAP", color = color.new(#d1d4dc,12), linewidth = 1) vMplotY = plot(vwap_1y_bool? vY : na, title = "Yearly VWAP", color = color.new(#d1d4dc,12), linewidth = 2) //------------------------------------------------------------------------------ //============================================================================== //=== SSL CHANNEL SETUP === //============================================================================== //------------------------------------------------------------------------------ //SSL 2 CHANNEL SETUP //------------------------------------------------------------------------------ ssl_1_down = 0.0 ssl_1_up = 0.0 //------------------------------------------------------------------------------ ssl_1_smaHigh = ta.sma(high, ssl_1_period) ssl_1_smaLow = ta.sma(low, ssl_1_period) //------------------------------------------------------------------------------ Hlv_1 = 0 Hlv_1 := close > ssl_1_smaHigh ? 1 : close < ssl_1_smaLow ? -1 : Hlv_1[1] //------------------------------------------------------------------------------ ssl_1_down := Hlv_1 < 0 ? ssl_1_smaHigh : ssl_1_smaLow ssl_1_up := Hlv_1 < 0 ? ssl_1_smaLow : ssl_1_smaHigh //------------------------------------------------------------------------------ plot(ssl_1_bool ? ssl_1_down : na, title = "SSL DOWN", linewidth=2, color=color.new(#f57c00,10)) plot(ssl_1_bool ? ssl_1_up : na, title = "SSL UP", linewidth=2, color=color.new(#ffffff,10)) //------------------------------------------------------------------------------ //SSL 2 CHANNEL SETUP //------------------------------------------------------------------------------ ssl_2_down = 0.0 ssl_2_up = 0.0 //------------------------------------------------------------------------------ ssl_2_smaHigh = ssl_2_bool ? request.security(syminfo.ticker, ssl_2_tf, ta.sma(high, ssl_2_period)) : 0 ssl_2_smaLow = ssl_2_bool ? request.security(syminfo.ticker, ssl_2_tf, ta.sma(low, ssl_2_period)) : 0 //------------------------------------------------------------------------------ if ssl_2_bool //-------------------------------------------------------------------------- Hlv_2 = 0 Hlv_2 := close > ssl_2_smaHigh ? 1 : close < ssl_2_smaLow ? -1 : Hlv_2[1] //-------------------------------------------------------------------------- ssl_2_down := Hlv_2 < 0 ? ssl_2_smaHigh : ssl_2_smaLow ssl_2_up := Hlv_2 < 0 ? ssl_2_smaLow : ssl_2_smaHigh //------------------------------------------------------------------------------ plot(ssl_2_bool ? ssl_2_down : na, linewidth=3, title = "SSL DOWN", color=color.new(#f57c00,10)) plot(ssl_2_bool ? ssl_2_up : na, linewidth=3, title = "SSL UP", color=color.new(#ffffff,10)) //------------------------------------------------------------------------------ //============================================================================== // === KIJUN-SEN SETUP === //============================================================================== //------------------------------------------------------------------------------ ki_baseLine = 0.0 ki_up = 0.0 ki_down = 0.0 kjuncol = color.white //------------------------------------------------------------------------------ donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) //------------------------------------------------------------------------------ ki_atr = ta.atr(ki_atr_len) ki_baseLine := donchian(ki_Length) //------------------------------------------------------------------------------ ki_up := ki_baseLine + ki_atr_multip*ki_atr ki_down := ki_baseLine - ki_atr_multip*ki_atr //------------------------------------------------------------------------------ kjuncol := close > ki_baseLine ? color.new(color.gray,36) : close < ki_baseLine ? color.new(color.gray,36) : color.new(color.gray,36) //------------------------------------------------------------------------------ plot(ki_bool ? ki_baseLine : na, color=kjuncol, linewidth=2, title='Kijun-sen') plot(ki_bool and ki_atr_bands_bool ? ki_up : na, color=color.new(#e65100, 30), linewidth=1, title='Upper ATR') plot(ki_bool and ki_atr_bands_bool ? ki_down : na, color=color.new(#e65100, 30), linewidth=1, title='Lower ATR') //------------------------------------------------------------------------------ //============================================================================== // AMA BASE //============================================================================== //------------------------------------------------------------------------------ ama_base = 0.0 ama_base_up = 0.0 ama_base_down = 0.0 ama_base_Color = color.white //------------------------------------------------------------------------------ if ama_base_bool //-------------------------------------------------------------------------- ama_base_atr = ta.atr(ama_base_atr_len) ama_base_fastAlpha = 2 / (ama_base_fastLength + 1) ama_base_slowAlpha = 2 / (ama_base_slowLength + 1) ama_base_hh = ta.highest(ama_base_length + 1) ama_base_ll = ta.lowest(ama_base_length + 1) ama_base_mltp = ama_base_hh - ama_base_ll != 0 ? math.abs(2 * ama_base_src - ama_base_ll - ama_base_hh) / (ama_base_hh - ama_base_ll) : 0 ama_base_ssc = ama_base_mltp * (ama_base_fastAlpha - ama_base_slowAlpha) + ama_base_slowAlpha ama_base := nz(ama_base[1]) + math.pow(ama_base_ssc, 2) * (ama_base_src - nz(ama_base[1])) //-------------------------------------------------------------------------- ama_base_up := ama_base + ama_base_atr_multip*ama_base_atr ama_base_down := ama_base - ama_base_atr_multip*ama_base_atr //-------------------------------------------------------------------------- ama_base_Color := ama_base_highlightMovements ? ama_base > ama_base[1] ? color.new(color.gray,36) : color.new(color.gray,36) : color.new(color.gray,36) //------------------------------------------------------------------------------ plot((ama_base_bool) ? ama_base : na, title='AMA BASE', linewidth=2, color=ama_base_Color) plot((ama_base_bool and ama_base_atr_bands_bool) ? ama_base_up : na, title='Upper ATR', linewidth=1, color=color.new(#e65100, 30)) //color.new(#f70007,50) : color.new(color.gray,50) plot((ama_base_bool and ama_base_atr_bands_bool) ? ama_base_down : na, title='Lower ATR', linewidth=1, color=color.new(#e65100, 30)) //------------------------------------------------------------------------------
Cold MACD by Cryptom
https://www.tradingview.com/script/13HMrxnh-Cold-MACD-by-Cryptom/
cryptom515
https://www.tradingview.com/u/cryptom515/
198
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© cryptom515 //@version=5 indicator('Cold MACD by CrypTom', shorttitle="Cold MACD by CrypTom" , overlay=true) //Inputs src = input.source(title = "Source", defval=close) fa = input(12, title='Ma Length') sa = input(26, title='Slow Length') sig = input(9, title='Signal Peroid') barc = input(defval = false, title = "Show Candle Color") //Calculation ma = ta.ema(src, sa - fa) signal = ta.sma(ma, sig) //Plot-and-Fill p1 = plot(signal, color = ma > signal ? color.new(#5fed18, 35) : color.new(#ff0000, 35), style=plot.style_line, linewidth=1, title='Signal') p2 = plot(ma, color = ma > signal ? color.new(#5fed18, 35) : color.new(#ff0000, 35), style=plot.style_line, linewidth=1, title='MA') fill(p1, p2, color = ma > signal ? color.new(#5fed18, 35) : color.new(#ff0000, 35), title='Plots Background') //Bar-Color barcolor(barc ? (ma > signal ? color.new(#5fed18, 0) : color.new(#ff0000, 0)) : na, title='Plots Barcolor')
3 Bank Index
https://www.tradingview.com/script/k4vsFb62-3-Bank-Index/
Omran04
https://www.tradingview.com/u/Omran04/
19
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/ // Β© Omran04 //@version=4 study("3 Bank Index") rsi_period = input(title="RSI Period", defval=14, minval=2, maxval=500) pct_change(val_series) => ((val_series - val_series[1]) / val_series[1]) * 100 AXISBANK_close = security(symbol="NSE:AXISBANK", resolution=timeframe.period, expression=close) SBIN_close = security(symbol="NSE:SBIN", resolution=timeframe.period, expression=close) KOTAKBANK_close = security(symbol="NSE:KOTAKBANK", resolution=timeframe.period, expression=close) AXISBANK_rsi = rsi(AXISBANK_close, rsi_period) SBIN_rsi = rsi(SBIN_close, rsi_period) KOTAKBANK_rsi = rsi(KOTAKBANK_close, rsi_period) plot((AXISBANK_rsi + SBIN_rsi + KOTAKBANK_rsi) / 3) plot(50, color=color.gray) plot(70, color=color.red) plot(70, color=color.blue)
Displacement detector
https://www.tradingview.com/script/jxEEpcKg-Displacement-detector/
bkomoroczy
https://www.tradingview.com/u/bkomoroczy/
65
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© bkomoroczy //@version=5 indicator(title = "Displacement detector", overlay = true) ////inputs overlaySignals = input.bool(defval = true, title = "Overlay signals?", group = "display") bullishBarOverlayColor = input.color(defval = color.rgb(152, 245, 245), title = "Bullish Overlay", group = "display") bearishBarOverlayColor = input.color(defval = color.rgb(252, 202, 138), title = "Bearish Overlay", group = "display") minDisplacementRatio = input.float(defval = 0.514, title = "Minimum displacement (%)", step = 0.01, group = "detection parameters") / 100 maxBarsInDisplacement = input.int(defval = 12, title = "Max bars in displacement", step = 1, minval = 0, maxval = 12, group = "detection parameters") maxIrregularBars = input.int(defval = 2, title = "Max bars allowed to be irregular", step = 1, minval = 0, maxval = 12, group = "detection parameters") maxCountermove = input.float(defval = 0.06, title = "Max countermove of irregular bars(%)", step = 0.01, group = "detection parameters") / 100 //maxNumberOfDisplacements = input.int(defval = 10, title = "Max number of displacements", step = 1, minval = 0, maxval = 100, group = "detection parameters") ////create variables var displacementBoxes = array.new_box(0) ////follow displacement backward //functions displacement(myBarIndex) => close[myBarIndex] - open[myBarIndex] bullish(myBarIndex) => displacement(myBarIndex) > 0.0 bearish(myBarIndex) => displacement(myBarIndex) < 0.0 actualBullishness = bullish(0) actualBearishness = bearish(0) //barIndexToCompare = 1 //if actualBullishness // while bullish(barIndexToCompare) or (displacement(barIndexToCompare) >= -(close * maxCountermove)) // barIndexToCompare := barIndexToCompare + 1 //if actualBearishness // while bearish(barIndexToCompare) or (displacement(barIndexToCompare) <= (close * maxCountermove)) // barIndexToCompare := barIndexToCompare + 1 //minWickOfRange = ta.lowest(low, (barIndexToCompare - 1)) //lastBarOfDisplacement = barIndexToCompare - 1 // Try a new way to detect displacement: look for max and min for increasing ranges and detect inbetween which bars were the max and min bars. barIndexToCompare = 0 maxBarIndex = 0 minBarIndex = 0 maxWickOfRange = high minWickOfRange = low maxBodyOfRange = (open > close) ? open : close minBodyOfRange = (open < close) ? open : close maxChanged = true minChanged = true maxStop = false minStop = false IrregularityCounter = maxIrregularBars for i = 1 to maxBarsInDisplacement maxWickOfRange_i = high[i] maxBodyOfRange_i = (open[i] > close[i]) ? open[i] : close[i] // if ((maxWickOfRange_i > maxWickOfRange) or (maxBodyOfRange_i > maxBodyOfRange)) and (minChanged or maxChanged) if ((maxWickOfRange_i > maxWickOfRange)) and (IrregularityCounter > 0) and not maxStop maxBarIndex := i maxWickOfRange := maxWickOfRange_i maxBodyOfRange := maxBodyOfRange_i maxChanged := true else maxChanged := false IrregularityCounter := IrregularityCounter - 1 maxStop := (math.abs(displacement(0)) > (close * maxCountermove)) IrregularityCounter := maxIrregularBars for i = 1 to maxBarsInDisplacement minWickOfRange_i = low[i] minBodyOfRange_i = (open[i] < close[i]) ? open[i] : close[i] // if ((minWickOfRange_i < minWickOfRange) or (minBodyOfRange_i < minBodyOfRange)) and (minChanged or maxChanged) if ((minWickOfRange_i < minWickOfRange)) and (IrregularityCounter > 0) and not minStop minBarIndex := i minWickOfRange := minWickOfRange_i minBodyOfRange := minBodyOfRange_i minChanged := true else minChanged := false IrregularityCounter := IrregularityCounter - 1 minStop := (math.abs(displacement(0)) > (close * maxCountermove)) plot(maxBarIndex, title = "maxBarIndex", display = display.none) plot(minBarIndex, title = "minBarIndex", display = display.none) if minBarIndex != maxBarIndex actualBullishness := minBarIndex > maxBarIndex actualBearishness := maxBarIndex > minBarIndex freshDisplacement = false lastBarOfDisplacement = 0 if actualBullishness freshDisplacement := maxBarIndex == 0 lastBarOfDisplacement := minBarIndex if actualBearishness freshDisplacement := minBarIndex == 0 lastBarOfDisplacement := maxBarIndex //lastBarOfDisplacement := lastBarOfDisplacement > maxBarsInDisplacement-1 ? maxBarsInDisplacement-1 : lastBarOfDisplacement rangeLength = lastBarOfDisplacement + 1 //minWickOfRange = -1.0 //maxWickOfRange = -1.0 //if rangeLength > 0 // minWickOfRange := ta.lowest(low, rangeLength + 1) // maxWickOfRange := ta.highest(high, rangeLength + 1) displacementLength = maxWickOfRange - minWickOfRange //plot(lastBarOfDisplacement, display = display.none) //plot(barIndexToCompare, display = display.none) plot(displacementLength, title = "displacementLength", display = display.none) plot(rangeLength, title = "rangeLength", display = display.none) //Compare the max displacement to the limit And Alert in case requested displacementThreshold = close * minDisplacementRatio displacementFound = freshDisplacement and (math.abs(displacementLength) >= (displacementThreshold)) and maxBarsInDisplacement >= rangeLength plot(displacementThreshold, title = "displacementThreshold", display = display.none) //display //plot bullish displacement top plotshape(displacementFound and overlaySignals and actualBullishness, "bullish displacement top", shape.triangleup, location.abovebar, offset = 0, size = size.normal, color = bullishBarOverlayColor) //plot bullish displacement bottom plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 0, "bullish displacement bottom", shape.circle, location.belowbar, offset = -0, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 1, "bullish displacement bottom", shape.circle, location.belowbar, offset = -1, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 2, "bullish displacement bottom", shape.circle, location.belowbar, offset = -2, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 3, "bullish displacement bottom", shape.circle, location.belowbar, offset = -3, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 4, "bullish displacement bottom", shape.circle, location.belowbar, offset = -4, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 5, "bullish displacement bottom", shape.circle, location.belowbar, offset = -5, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 6, "bullish displacement bottom", shape.circle, location.belowbar, offset = -6, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 7, "bullish displacement bottom", shape.circle, location.belowbar, offset = -7, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 8, "bullish displacement bottom", shape.circle, location.belowbar, offset = -8, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 9, "bullish displacement bottom", shape.circle, location.belowbar, offset = -9, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 10, "bullish displacement bottom", shape.circle, location.belowbar, offset = -10, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 11, "bullish displacement bottom", shape.circle, location.belowbar, offset = -11, size = size.small, color = bullishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBullishness and lastBarOfDisplacement == 12, "bullish displacement bottom", shape.circle, location.belowbar, offset = -12, size = size.small, color = bullishBarOverlayColor) //plot bearish displacement bottom plotshape(displacementFound and overlaySignals and actualBearishness, "bearish displacement bottom", shape.triangledown, location.belowbar, offset = 0, size = size.normal, color = bearishBarOverlayColor) //plot bearish displacement top plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 0, "bearish displacement top", shape.circle, location.abovebar, offset = -0, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 1, "bearish displacement top", shape.circle, location.abovebar, offset = -1, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 2, "bearish displacement top", shape.circle, location.abovebar, offset = -2, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 3, "bearish displacement top", shape.circle, location.abovebar, offset = -3, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 4, "bearish displacement top", shape.circle, location.abovebar, offset = -4, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 5, "bearish displacement top", shape.circle, location.abovebar, offset = -5, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 6, "bearish displacement top", shape.circle, location.abovebar, offset = -6, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 7, "bearish displacement top", shape.circle, location.abovebar, offset = -7, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 8, "bearish displacement top", shape.circle, location.abovebar, offset = -8, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 9, "bearish displacement top", shape.circle, location.abovebar, offset = -9, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 10, "bearish displacement top", shape.circle, location.abovebar, offset = -10, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 11, "bearish displacement top", shape.circle, location.abovebar, offset = -11, size = size.small, color = bearishBarOverlayColor) plotshape(displacementFound and overlaySignals and actualBearishness and lastBarOfDisplacement == 12, "bearish displacement top", shape.circle, location.abovebar, offset = -12, size = size.small, color = bearishBarOverlayColor) //plotshape(displacementFound and overlaySignals and actualBearishness, "bearish displacement top", shape.circle, location.abovebar, offset = startOffset, size = size.small, color = bearishBarOverlayColor) if displacementFound and actualBullishness alert("bullish displacement") if displacementFound and actualBearishness alert("bearish displacement")
Bitcoin Miner Extreme Selling
https://www.tradingview.com/script/85B12yck-Bitcoin-Miner-Extreme-Selling/
SimpleCryptoLife
https://www.tradingview.com/u/SimpleCryptoLife/
183
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© SimpleCryptoLife //@version=5 indicator("Bitcoin Miner Extreme Selling", overlay=false, precision=4) // ABOUT // This script is for identifying extreme selling. Judging by the chart, Bitcoin miners often (not always) sell hard for two reasons: to take profit into parabolic price rises, or to stay solvent when the price is very low. // Extreme selling thus often coincides with long-term tops and bottoms in Bitcoin price. This can be a useful EXTRA data point when trying to time long-term Bitcoin spot or crypto equity investment (NOT advice, you remain responsible, etc). // The difference between selling measured in BTC and in USD gives a reasonable idea of whether miners are selling to make a profit or to stay solvent. // CREDITS // The idea for using the ratio of miner outflows to reserves comes from the "Bitcoin Miner Sell Pressure" script by the pioneering capriole_charles. // The two request.security calls are identical. Another similarity is that you have to sum the outflows to make it make sense. But it doesn't make much difference, it turns out from testing, to use an average of the reserves, so I didn't. All other code is different. // The script from capriole_charles uses Bollinger bands to highlight periods when sell pressure is high, uses a rolling 30-day sum, and only uses the BTC metrics. // My script uses a configurable 2-6 week rolling sum (there's nothing magical about one month), uses different calculations, and uses BTC, USD, and composite metrics. // INPUTS // Rolling Time Basis: Determines how much data is rolled up. At the lowest level, daily data is too volatile. If you choose, e.g., 1 week, then the indicator displays the relative selling on a weekly basis. Longer time periods, obviously, are smoother but delayed, while shorter time periods are more reactive. There is no "real" time period, only an explicit interpretation. // Show Data > Outflows: Displays the relative selling data, along with a long-term moving average. You might use this option if you want to compare the "real" heights of peaks across history. // Show Data > Delta (the default): Only the difference between the relative selling and the long-term moving average is displayed, along with an average of *that*. This is more signal and less noise. // Base Currency: Configure whether the calculations use BTC or USD as the metric. This setting doesn't use the BTC price at all; it switches the data requested from INTOTHEBLOCK. // If you choose Composite (the default), the script combines BTC and USD together in a relative way (you can't simply add them, as USD is a much bigger absolute value). // In Composite mode, the peaks are coloured red if BTC selling is higher than USD, which usually indicates forced selling, and green if USD is higher, which usually indicates profit-taking. This categorisation is not perfectly accurate but it is interesting insomuch as it is derived from block data and not Bitcoin price. // In BTC or USD mode, a gradient is used to give a rough visual idea of how far from the average the current value is, and to make it look pretty. // USAGE NOTES // Because of the long-term moving averages, the length of the chart does make a difference. I recommend running the script on the longest Bitcoin chart, ticker BLX. // To use it to compare selling with pivots in crypto equities, use a split chart: one BLX with the indicator applied, and one with the equity of your choice. Sync Interval, Crosshair, Time, and Date Range, but not Symbol. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // INPUTS // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // int in_timeBasisWeeks = input.int(title="Rolling Time Basis (weeks)", minval=1, maxval=6, defval=2, tooltip="The time period for which miner outflows are summed.") string in_showData = input.string(defval="Delta", title="Show Data", options=["Delta","Outflows"], tooltip="Outflows: Show the relative and average outflows. This is like the \"raw\" data. Delta: Show by how much the outflows are above the average \(and the average of that\). This is a bit more signal and less noise.") string in_baseCurrency = input.string(defval="Composite", title="Base Currency", options=["Composite","BTC","USD"]) // === Variables derived solely from inputs === int timeBasisDays = in_timeBasisWeeks * 7 bool showOutflows = in_showData == "Outflows", bool showDelta = in_showData == "Delta" bool showBTC = in_baseCurrency == "BTC", bool showUSD = in_baseCurrency == "USD", bool showComposite = in_baseCurrency == "Composite" // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // GET DATA // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // float minerOutflowsBTC = request.security("INTOTHEBLOCK:BTC_MINEROUTFLOWS","D",close) // Hardcoded to days. View this indicator on a chart at the daily interval. float minerReservesBTC = request.security("INTOTHEBLOCK:BTC_MINERRESERVES","D",close) float minerOutflowsUSD = request.security("INTOTHEBLOCK:BTC_MINEROUTFLOWSUSD","D",close) float minerReservesUSD = request.security("INTOTHEBLOCK:BTC_MINERRESERVESUSD","D",close) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // CALCULATIONS // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // f_ema(_source,_length) => _alpha = (2 / (_length + 1)), var float _ema = 0.0, _ema := na(_ema[1]) ? _source : _alpha * _source + (1 - _alpha) * nz(_ema[1]) // Function taken from the Pine docs for ema(). We can't use the built-in function because we want to change the length dynamically. f_delta(_outflows,_reserves,_timeBasisDays) => float _outflowsRelativeToReserves = ta.rma(_outflows,5)/_reserves // How much selling is there *relative* to the size of the reserves. Smoothed because the raw data is extremely volatile, and smoothing makes it easier to work with and doesn't affect the timing significantly. float _sumOutflowsRelative = math.sum(_outflowsRelativeToReserves,_timeBasisDays) // Sum the relative outflows over the time basis, because otherwise it doesn't form patterns. _sumOutflowsRelative := _sumOutflowsRelative/_timeBasisDays // Adjust the sum for the size of the time basis to normalise the size of the peaks for different inputs. var int _dynamicLength = 1, _dynamicLength := bar_index > 1 and bar_index < 200 ? bar_index : 200 // Increase the long-term average MA length up to 200, so that we can start processing as early as possible. float _outflowsAverage = f_ema(_source=_sumOutflowsRelative,_length=_dynamicLength) // Long-term average of relative outflows to use as a baseline. float _delta = _sumOutflowsRelative - _outflowsAverage // Is the current relative selling more than (positive) or less than (negative) the baseline. var float _deltaPositiveAverage = na float _deltaPositiveSource = _delta > 0 ? _delta : _deltaPositiveAverage // Modify the input conditionally so that we can call the function on every bar for consistency. _deltaPositiveAverage := f_ema(_source=_deltaPositiveSource,_length=_dynamicLength) [_sumOutflowsRelative,_outflowsAverage,_delta,_deltaPositiveAverage] [sumOutflowsRelativeBTC,outflowsAverageBTC,deltaBTC,deltaPositiveAverageBTC] = f_delta(minerOutflowsBTC,minerReservesBTC,timeBasisDays) [sumOutflowsRelativeUSD,outflowsAverageUSD,deltaUSD,deltaPositiveAverageUSD] = f_delta(minerOutflowsUSD,minerReservesUSD,timeBasisDays) // Create Composite delta. We don't create an average for the Composite Delta because it doesn't make sense. float ratioOutflowsAverageBTC = (sumOutflowsRelativeBTC/outflowsAverageBTC)-1 // What is the BTC outflow as a ratio of its average? Positive if above the average, negative if below. float sumOutflowsRelativeComposite = sumOutflowsRelativeUSD + (ratioOutflowsAverageBTC * outflowsAverageUSD) // Use the USD as a base and add/subtract proportional BTC outflows. Just adding them wouldn't work. float outflowsAverageComposite = outflowsAverageUSD // We can use the USD average because of using the USD values as a base and it is the EXACT SAME as calculating it separately. Assigning it here doesn't make coding sense but is just for clarity of reading. float deltaComposite = sumOutflowsRelativeComposite - outflowsAverageComposite // Simple now we've done all the other stuff. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // PLOTS // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // OUTFLOWS plot(series=showOutflows and showBTC ? sumOutflowsRelativeBTC : showOutflows and showUSD ? sumOutflowsRelativeUSD : showOutflows and showComposite ? sumOutflowsRelativeComposite : na, title="Relative outflows", linewidth=1, color=color.yellow) // Show outflows in the appropriate currency. plot(series=showOutflows and showBTC ? outflowsAverageBTC : showOutflows and showUSD ? outflowsAverageUSD : showOutflows and showComposite ? outflowsAverageComposite : na, title="Average outflows", color=color.red, linewidth=2) // Show the average // DELTA PLOT float deltaPositiveBTC = deltaBTC < 0 ? 0 : deltaBTC, float deltaPositiveUSD = deltaUSD < 0 ? 0 : deltaUSD, float deltaPositiveComposite = deltaComposite < 0 ? 0 : deltaComposite // Suppress plots under zero deltaPositivePlot = plot(series=showDelta and showBTC ? deltaPositiveBTC : showDelta and showUSD ? deltaPositiveUSD : showDelta and showComposite ? deltaPositiveComposite : na, title="Delta (selling > average)", color=color.new(color.white,50)) deltaPositiveAveragePlot = plot(series=showDelta and showBTC ? deltaPositiveAverageBTC : showDelta and showUSD ? deltaPositiveAverageUSD : na, title="Average of delta", color=color.red, linewidth=1) // DELTA FILL float zeroLineBTC = deltaBTC > 0 ? 0 : na, float zeroLineUSD = deltaUSD > 0 ? 0 : na, float zeroLineComposite = deltaComposite > 0 ? 0 : na zeroPlot = plot(series=showDelta and showBTC ? zeroLineBTC : showDelta and showUSD ? zeroLineUSD : showComposite ? zeroLineComposite : na, color=na, style=plot.style_linebr, title="Phantom plot for 0") float deltaOrAverageLowerBTC = math.min(deltaPositiveAverageBTC, deltaPositiveBTC), float deltaOrAverageLowerUSD = math.min(deltaPositiveAverageUSD, deltaPositiveUSD) deltaOrAverageLowerPlot = plot(series=showDelta and showBTC ? deltaOrAverageLowerBTC : showDelta and showUSD ? deltaOrAverageLowerUSD : na, style=plot.style_linebr, color=na, title="Phantom plot for fill 1") fill(zeroPlot,deltaOrAverageLowerPlot, title="Fill for lower part of delta", color=color.new(color.white,80)) float averageIfDeltaHigherBTC = deltaPositiveBTC > deltaPositiveAverageBTC ? deltaPositiveAverageBTC : na float averageIfDeltaHigherUSD = deltaPositiveUSD > deltaPositiveAverageUSD ? deltaPositiveAverageUSD : na averageIfDeltaHigherPlot = plot(series=showDelta and showBTC ? averageIfDeltaHigherBTC : showDelta and showUSD ? averageIfDeltaHigherUSD : na, style=plot.style_linebr, color=na, title="Phantom plot for fill 2") deltaPositiveAverageResolved = showBTC ? deltaPositiveAverageBTC : showUSD ? deltaPositiveAverageUSD : na averageIfDeltaHigherResolved = showBTC ? averageIfDeltaHigherBTC : showUSD ? averageIfDeltaHigherUSD : na fill(plot1=averageIfDeltaHigherPlot,plot2=deltaPositivePlot, title="Fill for upper part of delta", top_value=deltaPositiveAverageResolved*3, bottom_value=averageIfDeltaHigherResolved, top_color=color.yellow, bottom_color=color.red) // Make it look pretty // COMPOSITE DELTA FILL // Take a % of how much the positive delta is above the average. float ratioDeltaBTC = deltaBTC/deltaPositiveAverageBTC, float ratioDeltaUSD = deltaUSD/deltaPositiveAverageUSD, float ratioDeltaBTCPositive = ratioDeltaBTC < 1 ? 0 : ratioDeltaBTC >= 1 ? ratioDeltaBTC : na, float ratioDeltaUSDPositive = ratioDeltaUSD < 1 ? 0 : ratioDeltaUSD >= 1 ? ratioDeltaUSD : na // Not needed? float ratioDelta = ratioDeltaBTC - ratioDeltaUSD // Colour the composite Delta plot: If BTC % positive delta is higher, the gradient is red/yellow. If USD is higher, it's green-blue. zeroLineCompositeFixed = showComposite ? zeroLineComposite : na // So the fill scopes to only Composite zeroLineCompositeFixedPlot = plot(series=zeroLineCompositeFixed, color=na, title="Phantom Plot for Composite Zero Line") compositeFillColour = ratioDelta > 0.1 ? color.red : ratioDelta < 0.1 and ratioDelta > 0 ? color.new(color.red,50) : ratioDelta < -0 and ratioDelta > -0.1 ? color.new(color.green,50) : ratioDelta < -0.1 ? color.green : na fill(plot1=zeroLineCompositeFixedPlot,plot2=deltaPositivePlot, title="Fill for Composite delta", color=compositeFillColour) // =============== FIN ============== // // // // WAGMI ? wagyu : ramen // // // // ================================== //
Extension %
https://www.tradingview.com/script/4XJxXamd-Extension/
valpatrad
https://www.tradingview.com/u/valpatrad/
65
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© valpatrad //@version=5 indicator('Extension', '', true, max_boxes_count=500, max_labels_count=500) //////////////////////////// // // // Menu // // // //////////////////////////// ext = input.string('Gap', 'Extension', ['Candles', 'Gap']) mode = input.string('Percentage', 'Mode', ['Percentage', 'Price', 'Ticks']) th = input.float(2.5, 'ThresholdΒ Β Β Β Β Β Β +/-', 0, step=0.01) dir = input.string('All', 'Direction', ['All', 'Bearish', 'Bullish']) i_day = input.bool(false, 'Intraday Range', inline='Intraday') rng = input.session('0930-1000', '', inline='Intraday', tooltip='Time range to consider on intraday charts.') earns_only = input.bool(false, 'Earnings Only', tooltip='This will work on daily charts for stocks only.') //Gap g1 = input.string('High/Low', '', ['Open/Close', 'High/Low'], inline='Gap', group='Gap') g2 = input.string('High/Low', 'β€”', ['Open/Close', 'High/Low'], inline='Gap', group='Gap') //Candles candles = input.int(2, 'Candles', 1, group='Candles') input_p1 = input.string('Open', '', ['Open', 'High', 'Low', 'Close'], inline='Price', group='Candles') p1 = switch input_p1 'Open' => open 'High' => high 'Low' => low 'Close' => close input_p2 = input.string('Close', 'β€”', ['Open', 'High', 'Low', 'Close'], inline='Price', group='Candles') p2 = switch input_p2 'Open' => open 'High' => high 'Low' => low 'Close' => close box_limit = input.int(3, 'Box limit', 0, group='Candles', tooltip='Maximum number of candles to be framed by boxes. Set to zero to hide them.') //Label Style lcol_bull = input.color(#FFFFFF, 'Bullish ColorsΒ Β Β Β Β Β Β Β Β Β Β BKGD', group='Label', inline='Bullish') tcol_bull = input.color(#000000, 'Text', group='Label', inline='Bullish') lcol_bear = input.color(#FFFFFF, 'Bearish ColorsΒ Β Β Β Β Β Β Β Β Β BKGD', group='Label', inline='Bearish') tcol_bear = input.color(#000000, 'Text', group='Label', inline='Bearish') in_font = input.string('Default', 'Font', ['Default', 'Monospace'], group='Label') font = switch in_font 'Default' => font.family_default 'Monospace' => font.family_monospace input_size = input.string('Normal', 'Size', ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group='Label') size = switch input_size 'Auto' => size.auto 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal 'Large' => size.large 'Huge' => size.huge //Box Style box_bg = input.color(color.new(#FFFFFF, 95), 'Background', group='Box') box_col = input.color(color.new(#FFFFFF, 60), 'Border', group='Box') box_wd = input.int(1, 'Border width', 0, 4, group='Box') box_stl_input = input.string('Solid', 'Border style', ['Solid', 'Dotted', 'Dashed'], group='Box') box_stl = switch box_stl_input 'Solid' => line.style_solid 'Dotted' => line.style_dotted 'Dashed' => line.style_dashed ///////////////////////////// // // // Variables // // // ///////////////////////////// o = open h = high l = low c = close earns = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, ignore_invalid_symbol=true) _calc(a, b) => if mode == 'Percentage' (a-b)/b*100 else if mode == 'Price' (a-b) else syminfo.type == 'forex' ? ((a-b)/syminfo.mintick)/10 : (a-b)/syminfo.mintick _lab(lbl) => if not earns_only or (earns_only and earns and timeframe.isdaily) if (not i_day and timeframe.isintraday or timeframe.isdwm) or (i_day and timeframe.isintraday and time(timeframe.period, rng)) label.new(bar_index, lbl >= th and dir != 'Bearish' ? h : lbl <= -th and dir != 'Bullish' ? l : na, mode == 'Percentage' ? str.tostring(lbl, format.percent) : (mode == 'Price' and syminfo.type == 'forex') or (mode == 'Price' and syminfo.type == 'bond') ? str.tostring(lbl) : mode == 'Price' and syminfo.type == 'economic' ? str.tostring(lbl, format.volume) : mode == 'Price' ? str.tostring(lbl, '#.##') : str.tostring(lbl, syminfo.type == 'forex' ? '#.#' : '#'), color=lbl >= th ? lcol_bull : lcol_bear, style=lbl >= th ? label.style_label_down : label.style_label_up, textcolor=lbl >= th ? tcol_bull : tcol_bear, size=size, text_font_family=font) //////////////////////////// // // // Plot // // // //////////////////////////// //Price Extension if ext == 'Candles' cdl = _calc(p2, p1[candles-1]) _lab(cdl) if candles <= box_limit if cdl >= th and dir != 'Bearish' or cdl <= -th and dir != 'Bullish' if not earns_only or (earns_only and earns and timeframe.isdaily) if (not i_day and timeframe.isintraday or timeframe.isdwm) or (i_day and timeframe.isintraday and time(timeframe.period, rng)) box.new(bar_index[candles-1], p1[candles-1], bar_index, p2, box_col, box_wd, box_stl, bgcolor=box_bg) //Gap Extension if ext == 'Gap' gn = c >= o rd = c < o gn_1 = c[1] >= o[1] rd_1 = c[1] < o[1] gg_up = o > c[1] gr_dn = o < o[1] gr_up = c > c[1] gg_dn = c < o[1] if g1 == 'High/Low' and g2 == 'High/Low' h_l = _calc(l, h[1]) l_h = _calc(h, l[1]) if l > h[1] and h_l >= th _lab(h_l) if h < l[1] and l_h <= -th _lab(l_h) if g1 == 'Open/Close' and g2 == 'Open/Close' c_o = _calc(o, c[1]) o_o = _calc(o, o[1]) c_c = _calc(c, c[1]) o_c = _calc(c, o[1]) if gn_1 if rd and gr_dn and o_o <= -th _lab(o_o) if gn and gg_up and c_o >= th _lab(c_o) if gn and gg_dn and o_c <= -th _lab(o_c) if rd and gr_up and c_c >= th _lab(c_c) if rd_1 if gn and o > o[1] and o_o >= th _lab(o_o) if rd and o < c[1] and c_o <= -th _lab(c_o) if rd and c > o[1] and o_c >= th _lab(o_c) if gn and c < c[1] and c_c <= -th _lab(c_c) if g1 == 'High/Low' and g2 == 'Open/Close' h_o = _calc(o, h[1]) l_o = _calc(o, l[1]) h_c = _calc(c, h[1]) l_c = _calc(c, l[1]) if gn and gg_up and h_o >= th _lab(h_o) if rd and gr_dn and l_o <= -th _lab(l_o) if rd and gr_up and h_c >= th _lab(h_c) if gn and gg_dn and l_c <= -th _lab(l_c) if g1 == 'Open/Close' and g2 == 'High/Low' c_l = _calc(l, c[1]) o_h = _calc(h, o[1]) o_l = _calc(l, o[1]) c_h = _calc(h, c[1]) if gn_1 if l > c[1] and c_l >= th _lab(c_l) if h < o[1] and o_h <= -th _lab(o_h) if rd_1 if l > o[1] and o_l >= th _lab(o_l) if h < c[1] and c_h <= -th _lab(c_h)
Coin & market cap table
https://www.tradingview.com/script/Tma6VUVN-Coin-market-cap-table/
Streetcoin
https://www.tradingview.com/u/Streetcoin/
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/ // Β© Streetcoin //@version=5 indicator("BTC Dominance",shorttitle = "CMCT", precision = 12, overlay = true) //================================================\\ //---->Custom function. truncate number means <-----\\ // ---->to reduce or increase decimal numbers <------\\ //======================================================\\ truncate(_number, _decimalPlaces) => _factor = math.pow(10, _decimalPlaces) int(_number * _factor) / _factor //==================================\\ // getting the daily percentage change\\ //======================================\\ var g_length = "This table gives you a qucik overview of how the coin on the chart is doing. It gives you the monthly, weekly and daily percentage change as well as what is happening in the overall market without having to go through numerous charts." res = input.timeframe(title="Time Frame", defval= "D",group = g_length,tooltip = "This cell is designed to only display the candle information from the time frame and market you choose") res2 = input.timeframe(title="Time Frame Weekly", defval= "W", tooltip = "The week starts on a Monday. This information is last weeks data") res3 = input.timeframe(title="Time Frame Monthly", defval= "M", tooltip = " the month starts on the first of the month, so this data is the last calander months data.") market = input.symbol(title="market", defval ="CRYPTOCAP:Total", tooltip = " This is specifically for the crypto markets.") source = input.source(title="Source", defval=close) reference = input.symbol(title="Reference Market", defval="CRYPTOCAP:TOTAL2", tooltip = "This is the cryptocap total without Bitcoin hence Total2, Total3 removes Bitcoin and Etherium.") //===================================\\ //Get % change of reference data source\\ //=======================================\\ referenceData = request.security(reference, res, source[barstate.isconfirmed ? 1 : 0]) marketData = request.security(market, res, source[barstate.isconfirmed ? 1 : 0]) referenceChange = ((marketData[1] - referenceData[1]) / marketData[1]) * 100 referenceChange2 = ((marketData[2] - referenceData[2]) / marketData[2]) * 100 //==============================\\ // Define custom security function\\ //==================================\\ f_sec(_market,_res,_exp) => request.security(_market,res,_exp[barstate.isconfirmed ? 1 : 0]) f_sec1(_market,_res,_exp) => request.security(_market,res,_exp[barstate.isconfirmed ? 1 : 0]) f_sec2(_market,_res,_exp) => request.security(_market,res,_exp[barstate.isconfirmed ? 1 : 0]) f_sec3(_market,_res,_exp) => request.security(_market,res,_exp[barstate.isconfirmed ? 1 : 0]) f_sec4(_market,_res,_exp) => request.security(_market,res,_exp[barstate.isconfirmed ? 1 : 0]) f_sec5(_market,_res,_exp) => request.security(_market,res,_exp[barstate.isconfirmed ? 1 : 0]) //=============================================\\ // get the percentage of the daiy time frame only\\ //=================================================\\ currentChange = ta.change(close [1]- close[2]) / 100 mktchange = ta.change(close[1]) / close[2] * 100 rounding = ta.change(close[1] / 1000000000) rounding1 = ta.change(close[1] / 1000000) rounding2 = ta.change(close[1] / 1000) rounding3 = ta.change(close[1] / 1) morning = (close[1] / 1000000000000) //=============\\ // get percentage\\ //=================\\ percent = f_sec(market, res, mktchange) dpercent = f_sec1(syminfo.tickerid, res,mktchange) cmcChange = f_sec2(market, res, rounding) cmcOpen = f_sec(market, res, morning) baseData = f_sec4(reference, res, referenceChange) dataChange = f_sec5(reference, res, referenceChange2) //===========\\ // create table\\ //===============\\ var table mytable = table.new(position.top_right, 1, 7, border_width=1) //=========\\ // fill cells\\ //=============\\ if barstate.islast txt1 = 'Charts Daily\npercentage change\n' + str.tostring(truncate(dpercent, 2)) + '%' txt2 = "Todays BTC Dominance\n" + str.tostring(truncate(baseData, 2)) + "%\n Yesterdays BTC Dominance\n" + str.tostring(truncate(dataChange, 2)) + "%\nFrom CryptoCap" // txt3 = "BTC Dominance\nfrom yesterday\n" + str.tostring(truncate(dataChange, 2)) + "%" txt4 = 'Crypto Cap Total\n daily open\n $' + str.tostring(truncate(cmcOpen, 12)) + "00 T" txt5 = 'Crypto Cap Total\n daily dollar change \n $' + str.tostring(truncate(cmcChange, 3)) + " B" txt6 = "Crypto Cap Total daily\npercentage change\n" + str.tostring(truncate(percent, 2)) + '%' //==========================\\ //----> color my table <------\\ //==============================\\ table.cell(mytable, 0, 1, text=txt1, bgcolor=dpercent > 0 ? color.green : color.red, text_color=color.black) table.cell(mytable, 0, 2, text=txt2, bgcolor=baseData > dataChange ? color.green : color.red, text_color=color.white) // table.cell(mytable, 0, 3, text=txt3, bgcolor=percent > 0 ? color.green : color.red, text_color=color.white) table.cell(mytable, 0, 4, text=txt4, bgcolor=percent > 0 ? color.green : color.red, text_color=color.black) table.cell(mytable, 0, 5, text=txt5, bgcolor=percent > 0 ? color.green : color.red, text_color=color.white) table.cell(mytable, 0, 6, text=txt6, bgcolor=percent > 0 ? color.green : color.red, text_color=color.black) // Define custom security function f_sec6(_market,_res2,_exp) => request.security(_market,res2,_exp[barstate.isconfirmed ? 1 : 0]) f_sec7(_market,_res3,_exp) => request.security(_market,res3,_exp[barstate.isconfirmed ? 1 : 0]) f_sec8(_market,_res3,_exp) => request.security(_market,res3,_exp[barstate.isconfirmed ? 1 : 0]) f_sec9(_market,_res3,_exp) => request.security(_market,res3,_exp[barstate.isconfirmed ? 1 : 0]) f_sec10(_market,_res2,_exp) => request.security(_market,res2,_exp[barstate.isconfirmed ? 1 : 0]) f_sec11(_market,_res3,_exp) => request.security(_market,res2,_exp[barstate.isconfirmed ? 1 : 0]) //secuurity functions for table 2 dpercent1 = f_sec1(syminfo.tickerid, res2,mktchange) dpercent2 = f_sec6(syminfo.tickerid, res2,mktchange) cmcChange2 = f_sec6(syminfo.tickerid, res2,rounding) dpercent3 = f_sec7(syminfo.tickerid, res3,mktchange) cmcChange3 = f_sec8(syminfo.tickerid, res3,rounding1) cmcChange4 = f_sec9(syminfo.tickerid, res3,rounding2) cmcChange5 = f_sec10(syminfo.tickerid, res2,rounding3) cmcChange6 = f_sec11(syminfo.tickerid, res2,rounding1) // Create table var table myTable = table.new(position.bottom_right, 5, 2, border_width=1) // fill cells if barstate.islast txt1 = "Charts previous Weeks\npercentage change " + str.tostring(truncate(dpercent2, 2)) + "%"//\n The dollar change is\n$" + str.tostring(cmcChange5) + " M" txt2 = "Charts previous Months\npercentage change " + str.tostring(truncate(dpercent3, 2)) + "%"//\n The dollar change is\n$" + str.tostring(cmcChange4) + " M" //==========================\\ //----> color my table <------\\ //==============================\\ table.cell(myTable, 0, 1, text=txt1, bgcolor=dpercent2 > 0 ? color.green : color.red, text_color=color.black) table.cell(myTable, 1, 1, text=txt2, bgcolor=dpercent3 > 0 ? color.green : color.red, text_color=color.white) plot(na)
TSG's Binance Round NRs - only for BTC
https://www.tradingview.com/script/8BPMgIrr-TSG-s-Binance-Round-NRs-only-for-BTC/
TheSecretsOfTrading
https://www.tradingview.com/u/TheSecretsOfTrading/
16
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© TheSecretsOfTrading //@version=5 indicator("TSG's Binance Round NRs", overlay = true) check = input.int(20, "Candles to check") var label highlab = label.new(na, na, "", color = color.new(color.black, 99), textcolor = color.white) var label lowlab = label.new(na, na, "", style=label.style_label_up, color = color.new(color.black, 99), textcolor = color.white) bin_perp_highs = request.security("BTCUSDTPERP", timeframe.period, high) bin_perp_lows = request.security("BTCUSDTPERP", timeframe.period, low) highest = ta.highest( bin_perp_highs, check) lowest = ta.lowest( bin_perp_lows, check) if barstate.islast for i=0 to check if bin_perp_highs[i] == math.round(bin_perp_highs[i]) and bin_perp_highs[i] == highest label.set_x(highlab, bar_index-i) label.set_y(highlab, high[i]) label.set_text(highlab, str.tostring(bin_perp_highs[i])) break for i=0 to check if bin_perp_lows[i] == math.round(bin_perp_lows[i]) and bin_perp_lows[i] == lowest label.set_x(lowlab, bar_index-i) label.set_y(lowlab, low[i]) label.set_text(lowlab, str.tostring(bin_perp_lows[i])) break
Volume Chart
https://www.tradingview.com/script/kJgZm9hH-Volume-Chart/
veryfid
https://www.tradingview.com/u/veryfid/
295
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© veryfid //@version=5 indicator("Volume Chart") showbars = input.bool(false, "Show as bars?") vol = volume plotbar(volume, volume[1], volume, volume, title='Title', color = showbars and volume > volume[1] ? color.teal : showbars and volume < volume[1] ? color.red : na) plotcandle(volume[1], volume, volume, volume, title='Title', color = showbars ? color.new(color.black,100) : volume > volume[1] ? color.teal : color.red, bordercolor = color.new(color.black,100), wickcolor = (color.new(color.black,100)) )
convolution
https://www.tradingview.com/script/ZCDcMWdn-convolution/
palitoj_endthen
https://www.tradingview.com/u/palitoj_endthen/
64
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© palitoj_endthen //@version=5 indicator(title = 'John F. Ehlers - Convolution', shorttitle = 'convolution', overlay = false) // input src = input.source(defval = ohlc4, title = 'Source', group = 'Options', tooltip = 'Determines the source of input data', inline = 'f') apply_hp = input.bool(defval = false, title = 'High-Pass Filter', group = 'Options', tooltip = 'Determines whether to apply High-Pass filter', inline = 'f') // variable shortest_period = 40 longest_period = 80 alpha1 = 0.00 hp = 0.00 a1 = 0.00 b1 = 0.00 c1 = 0.00 c2 = 0.00 c3 = 0.00 filt = 0.00 x = 0.00 y = 0.00 sx = 0.00 sy = 0.00 sxx = 0.00 syy = 0.00 sxy = 0.00 // array var corr = array.new_float(50) var slope = array.new_float(50) var convolution = array.new_float(50) // convolution // high-pass filter cyclic components whose periods are shorter than 48 bars alpha1 := (math.cos(1.414*360/longest_period)+math.sin(1.414*360/longest_period)-1)/math.cos(1.414*360/longest_period) hp := (1-alpha1/2)*(1-alpha1/2)*(src-2*src[1]+src[2])+2*(1-alpha1)*nz(hp[1])-(1-alpha1)*(1-alpha1)*nz(hp[2]) // smooth with super smoother filter pi = 2*math.asin(1) a1 := math.exp(-1.414*pi/shortest_period) b1 := 2*a1*math.cos(1.414*180/shortest_period) c2 := b1 c3 := -a1*a1 c1 := 1-c2-c3 filt := c1*((apply_hp?hp:src)+(apply_hp?hp[1]:src[1]))/2+c2*nz(filt[1])+c3*nz(filt[2]) // convolution for i = 1 to 48 sx := 0.0 sy := 0.0 sxx := 0.0 syy := 0.0 sxy := 0.0 for ii = 1 to i x := filt[ii-1] y := filt[i-ii] sx := sx+x sy := sy+y sxx := sxx+x*x sxy := sxy+x*y syy := syy+y*y if (i*sxx-sx*sx)*(i*syy-sy*sy) > 0 array.set(corr, i, ((i*sxy-sx*sy) /math.sqrt((i*sxx-sx*sx)*(i*syy-sy*sy)))) array.set(slope, i, 1) if filt[.5*i] < filt array.set(slope, i, -1) array.set(convolution, i, (1+math.exp(3*nz(array.get(corr, i))))-1/(math.exp(3*nz(array.get(corr, i))-1))/2) // visualize as heatmap // color condition col(n)=> if array.get(slope, n) > 0 color.rgb((255*array.get(convolution, n)), 0, 0) else if array.get(slope, n) < 0 color.rgb(0, (255*array.get(convolution, n)), 0) // plot n = 0 n := 2 plot(n, title = 'n2', color = col(n), linewidth = 8) n := 3 plot(n, title = 'n3', color = col(n), linewidth = 8) n := 4 plot(n, title = 'n4', color = col(n), linewidth = 8) n := 6 plot(n, title = 'n6', color = col(n), linewidth = 8) n := 8 plot(n, title = 'n8', color = col(n), linewidth = 8) n := 10 plot(n, title = 'n10', color = col(n), linewidth = 8) n := 11 plot(n, title = 'n11', color = col(n), linewidth = 8) n := 12 plot(n, title = 'n12', color = col(n), linewidth = 8) n := 14 plot(n, title = 'n14', color = col(n), linewidth = 8) n := 16 plot(n, title = 'n16', color = col(n), linewidth = 8) n := 18 plot(n, title = 'n18', color = col(n), linewidth = 8) n := 20 plot(n, title = 'n20', color = col(n), linewidth = 8) n := 21 plot(n, title = 'n21', color = col(n), linewidth = 8) n := 22 plot(n, title = 'n22', color = col(n), linewidth = 8) n := 24 plot(n, title = 'n24', color = col(n), linewidth = 8) n := 26 plot(n, title = 'n26', color = col(n), linewidth = 8) n := 28 plot(n, title = 'n28', color = col(n), linewidth = 8) n := 30 plot(n, title = 'n30', color = col(n), linewidth = 8) n := 31 plot(n, title = 'n31', color = col(n), linewidth = 8) n := 32 plot(n, title = 'n32', color = col(n), linewidth = 8) n := 34 plot(n, title = 'n34', color = col(n), linewidth = 8) n := 36 plot(n, title = 'n36', color = col(n), linewidth = 8) n := 38 plot(n, title = 'n38', color = col(n), linewidth = 8) n := 40 plot(n, title = 'n40', color = col(n), linewidth = 8) n := 41 plot(n, title = 'n41', color = col(n), linewidth = 8) n := 42 plot(n, title = 'n42', color = col(n), linewidth = 8) n := 44 plot(n, title = 'n44', color = col(n), linewidth = 8) n := 46 plot(n, title = 'n46', color = col(n), linewidth = 8) n := 48 plot(n, title = 'n48', color = col(n), linewidth = 8)
[Antipanicos] Year-over-Year YoY Change
https://www.tradingview.com/script/Kt5lvK5J-antipanicos-year-over-year-yoy-change/
antipanicos
https://www.tradingview.com/u/antipanicos/
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/ // Β© antipanicos // ABOUT THE SCRIPT // Year-over-year growth compares a company's recent financial performance // with its numbers for the same month one year earlier. This is considered more informative // than a month-to-month comparison, which often reflects seasonal trends. //@version=5 indicator("[Antipanicos] Year-over-Year YoY Change", shorttitle = "YOY_AP") source = input.source(close, "Source") col_yoy = color.gray yoy_change = math.log(source[0]) - math.log(source[12]) plot(yoy_change, color=col_yoy)
Munich Guppy
https://www.tradingview.com/script/Vx37C9x9-Munich-Guppy/
CheatCode1
https://www.tradingview.com/u/CheatCode1/
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/ // Β© CheatCode1 //@version=5 indicator("Munich Guppy", overlay = true) //Dominant Momentum ALMA dsource = input.source(close, title='Source', group='Dominant ALMA') dperiod = input.int(title='Period', defval=130, group='Dominant ALMA') doffset = input.float(title='Offset', step=0.025, defval=0.775, group='Dominant ALMA') dsigma = input.float(title='Sigma', step=0.5, defval=4.5, group='Dominant ALMA') dalma = ta.alma(dsource, dperiod, doffset, dsigma) dalma_up_color = input.color(#66bb6a, '+Coc', group='Dominant ALMA', inline = '1') dalma_down_color = input.color(#ef5350, '-Coc', group='Dominant ALMA', inline = '1') dcolor = close[1] > dalma ? dalma_up_color : dalma_down_color ////ALMA Plots// plot(dalma, color=dcolor, style=plot.style_stepline, linewidth=2, title='Dominant Momentum MA', offset = 0) //MMV1 // Input value grouping //Variable Declerations V = input.int(200, 'MA 3', 1, 201, group = 'EMA\'s') e11 = input.int(21, 'EMA 1', 1, 100, group = 'EMA\'s') e12 = input.int(55, 'EMA 2', 1, 100, group = 'EMA\'s') e21 = ta.ema(close, e11) e55 = ta.ema(close, e12) eV = ta.ema(close, V) ec = dalma < e21 and close > e21 and dalma[1] < e21[1] and close[1] > e21[1] and dalma[2] < e21[2] and close[2] > e21[2] plot(e21, '21 White', e21 < dalma and dalma > close[1] ? color.red: e21 > dalma and dalma < close[1] ? color.green:color.white, 3, plot.style_line, offset = 0) plot(e55, '55 Purple', e55 < dalma ? color.purple: color.gray, 3, plot.style_line, offset =0 ) plot(eV, 'MA V Aqua', color.aqua, 2, offset = 0) er1 = e55 > dalma and e21 > dalma er2 = e55 < dalma and e21 < dalma er1C = er1[1] == true er2C = er2[1] == true bgcolor(er1C ? color.new(color.green, 80) : er2C ? color.new(color.red, 80): na, offset = 1) //
Heikin Ashi of Candle RSI
https://www.tradingview.com/script/dBUqXExY-Heikin-Ashi-of-Candle-RSI/
EW_T
https://www.tradingview.com/u/EW_T/
113
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© EW_T //@version=5 indicator("HAoCRSI") x = close/ta.rsi(close, 14) hline(70, color=color.gray) hline(50, color=color.gray, linestyle=hline.style_dotted ) hline(30, color=color.gray) openx = open/x highx = high/x lowx = low/x closex = close/x float o = na c = (openx + highx + lowx + closex) / 4 o := na(o[1]) ? (openx[1] + highx[1] + lowx[1] + closex[1]) / 4 : (o[1] + c[1]) / 2 h = math.max(highx, o, c) l = math.min(lowx, o, c) cancol = c > o ? color.green : color.red plotcandle(o, h, l, c, color = cancol, wickcolor = cancol , bordercolor = cancol )
Inverted Candle
https://www.tradingview.com/script/HI3YEL48-Inverted-Candle/
marcosberghahn
https://www.tradingview.com/u/marcosberghahn/
24
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© marcosberghahn //@version=5 indicator("Inverted Candle") paletteColor = close >= open ? color(#f23645AA) : color(#089981AA) plotcandle(1/open, 1/high, 1/low, 1/close, color=paletteColor, wickcolor=paletteColor, bordercolor=paletteColor) //plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display) β†’ void
Divergence and Pivot - Detector For Any Indicator
https://www.tradingview.com/script/KAxNDOnN-Divergence-and-Pivot-Detector-For-Any-Indicator/
HALDRO
https://www.tradingview.com/u/HALDRO/
436
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© HALDRO //@version=5 indicator('Divergence and Pivot - Detecter For Any Indicator', shorttitle = 'Detector') //------------------------------------------------------------------------------ // Inputs groupdiv = 'Divergence Detect' grouppiv = 'Pivot Detect' groupvis = 'Visual' src = input (close,'                                   Oscillator Source') pivothl = input.bool(true, 'Pivot Show ?' , group = grouppiv, inline = ' ') pivR = input.int (1, 'Pivot Lookback - Left / Right     ', group = grouppiv, inline = '2') pivL = input.int (21, ' ' , group = grouppiv, inline = '2') lbR = input.int (1, 'Divergence Lookback - Left / Right', group = groupdiv, inline = '1') lbL = input.int (16, ' ' , group = groupdiv, inline = '1') rangeUpper = input.int (100, 'Lookback Range - MAX / MIN        ', group = groupdiv, inline = '0') rangeLower = input.int (6, ' ' , group = groupdiv, inline = '0') plotBull = input.bool(true, 'Bullish' , group = groupdiv, inline = 'd') plotBear = input.bool(true, 'Bearish' , group = groupdiv, inline = 'd') plotHiddenBull = input.bool(true, 'Hidden Bullish' , group = groupdiv, inline = 'd') plotHiddenBear = input.bool(true, 'Hidden Bearish' , group = groupdiv, inline = 'd') plot(src == close ? na : src, 'Oscillator Source') // Visual bullColor = input.color(#00ff6d,'Bull' , group = groupvis, inline = 'c') bearColor = input.color(#ff0056,'Bear' , group = groupvis, inline = 'c') char1 = input('β€’', 'Char Div', group = groupvis, inline = 'c') char2 = input('β–ͺ', 'Char Pivot', group = groupvis, inline = 'c') // Pivot Detect PHCond = ta.pivothigh(src, pivL, pivR), h = +1.1 PLCond = ta.pivotlow (src, pivL, pivR), l = -0.9 // Check Panel var table panel = table.new(position = position.middle_center, columns = 2, rows = 1, bgcolor = #363A45, border_width = 1) if barstate.islast table.cell(panel, 1, 0, text=src == close ? str.tostring('Choose a source!') : na, text_color = #ffa726, bgcolor = #363A45) if src != close table.delete(panel) // Plot Pivot plotchar(pivothl and src != close ? PHCond * +h : na, title='Pivot High', char=char2, size=size.tiny, location=location.absolute, color=bearColor) plotchar(pivothl and src != close ? PLCond * -l : na, title='Pivot Low' , char=char2, size=size.tiny, location=location.absolute, color=bullColor) // Divergence Detect osc = src //------------------------------------------------------------------------------ plFound = na(ta.pivotlow(src, lbL, lbR)) ? false : true phFound = na(ta.pivothigh(src, 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]) and src != close // 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=1, color=bullCond ? #089981 : na) plotchar(bullCond ? osc[lbR] : na, offset=-lbR, title='Regular Bullish Label', char=char1, size=size.tiny, location=location.absolute, color=bullColor) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) and src != close // 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=1, color=hiddenBullCond ? #089981 : na) plotchar(hiddenBullCond ? osc[lbR] : na, offset=-lbR, title='Hidden Bullish Label', char=char1, size=size.tiny, location=location.absolute, color=bullColor) //------------------------------------------------------------------------------ // Regular Bearish // Osc: Lower High oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) and src != close // 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=1, color=bearCond ? #673ab7 : na) plotchar(bearCond ? osc[lbR] : na, offset=-lbR, title='Regular Bearish Label', char=char1, size=size.tiny, location=location.absolute, color=bearColor) //------------------------------------------------------------------------------ // Hidden Bearish // Osc: Higher High oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) and src != close // 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=1, color=hiddenBearCond ? #673ab7 : na) plotchar(hiddenBearCond ? osc[lbR] : na, offset=-lbR, title='Hidden Bearish Label', char=char1, size=size.tiny, location=location.absolute, color=bearColor) //------------------------------------------------------------------------------ alertcondition (bullCond, title = '~Alert Bull Divergence', message = 'Bull Diver') alertcondition (bearCond, title = '~Alert Bear Divergence', message = 'Bear Diver') alertcondition (hiddenBullCond, title = '~Alert Hidden Bull Divergence', message = 'Hidden Bull Diver') alertcondition (hiddenBearCond, title = '~Alert Hidden Bear Divergence', message = 'Hidden Bear Diver') alertcondition (PLCond, title = '~Alert Bull Pivot', message = 'Bull Pivot') alertcondition (PHCond, title = '~Alert Bear Pivot', message = 'Bear Pivot')
TICK Indicator
https://www.tradingview.com/script/d5c35Qft-TICK-Indicator/
viewer405
https://www.tradingview.com/u/viewer405/
256
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© viewer405 //@version=5 indicator(title="TICK Indicator", shorttitle="TICK") bullColor = #26a69a bearColor = #ef5350 timeInterval = input.timeframe("", title="Time Interval") style = input.string("bars", title="Candle Style", options=["bars", "line", "candles", "ratio", "cumulative"], tooltip="NOTE: If selecting 'ratio' or 'cumulative', the Threshold Lines and Moving Averages will cause the histogram to appear very small. Consider disabling both options if selecting 'ratio' or 'cumulative'.") default = input.string("USI:TICK", title="Default Advance Decline Index", options=["USI:TICK", "USI:TICKQ", "USI:TICKA", "USI:TICK.US", "USI:TICK.NY", "USI:TICK.NQ", "USI:TICK.DJ", "USI:TICK.AM"]) enableSummaryTable = input.bool(true, "Enable Summary Table") enableThresholds = input.bool(false, "Enable Threshold Lines") enableMA = input.bool(false, "Enable Moving Averages") ma1Length = input.int(10, "1st MA Length") ma2Length = input.int(20, "2nd MA Length") ma1Source = input.string("close", "1st MA Source", options=["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"]) ma2Source = input.string("close", "2nd MA Source", options=["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"]) ma1Type = input.string("ema", "1st MA Type", options=["ema", "sma"]) ma2Type = input.string("ema", "2nd MA Type", options=["ema", "sma"]) prefix = switch syminfo.prefix "NYSE" => "USI:TICK.NY" "NASDAQ" => "USI:TICK.NQ" "USI" => syminfo.ticker => "" type = switch syminfo.type "crypto" => "USI:TICKQ" // Crypto is behaving like tech sector, use NASDAQ. "economic" => "" "fund" => "" "cfd" => "" // (contract for difference) "dr" => "" // (depository receipt) "stock" => "USI:TICK.US" "index" => "" => "" index = switch syminfo.ticker "ES" => "USI:TICK" "SPY" => "USI:TICK" "SPX" => "USI:TICK" "NQ" => "USI:TICKQ" "QQQ" => "USI:TICKQ" "TQQQ" => "USI:TICKQ" "NASDAQ" => "USI:TICKQ" "YM" => "USI:TICK.DJ" "DJI" => "USI:TICK.DJ" => "" uIndex = switch syminfo.ticker "ES" => "USI:UPTKS.US" "SPY" => "USI:UPTKS.US" "SPX" => "USI:UPTKS.US" "NQ" => "USI:UPTKS.NQ" "QQQ" => "USI:UPTKS.NQ" "TQQQ" => "USI:UPTKS.NQ" "NASDAQ" => "USI:UPTKS.NQ" "YM" => "USI:UPTKS.DJ" "DJI" => "USI:UPTKS.DJ" => "" dIndex = switch syminfo.ticker "ES" => "USI:DNTKS.US" "SPY" => "USI:DNTKS.US" "SPX" => "USI:DNTKS.US" "NQ" => "USI:DNTKS.NQ" "QQQ" => "USI:DNTKS.NQ" "TQQQ" => "USI:DNTKS.NQ" "NASDAQ" => "USI:DNTKS.NQ" "YM" => "USI:DNTKS.DJ" "DJI" => "USI:DNTKS.DJ" => "" ticker = prefix != "" ? prefix : (type != "" ? type : (index != "" ? index : default)) // As of 2022, TradingView has not yet resolved data issues when querying daily // candlestick data for USI:TICK. Use 390 minutes instead of the daily. It // equates to 6 1/2 hours that the markets are open Monday to Friday. if timeframe.isdaily and (style == "candles" or style == "ratio") timeInterval := '390' uO = request.security(uIndex, timeInterval, open) uH = request.security(uIndex, timeInterval, high) uL = request.security(uIndex, timeInterval, low) uC = request.security(uIndex, timeInterval, close) dO = request.security(dIndex, timeInterval, open) dH = request.security(dIndex, timeInterval, high) dL = request.security(dIndex, timeInterval, low) dC = request.security(dIndex, timeInterval, close) ratio = uC > dC ? math.round(uC / dC, 2) : -math.round(dC / uC, 2) o = request.security(ticker, timeInterval, open) h = request.security(ticker, timeInterval, high) l = request.security(ticker, timeInterval, low) c = request.security(ticker, timeInterval, close) trigger = not na(time(timeframe.period, "0930-1000")) reset = trigger and not trigger[1] var cumulative = 0.0 cumulative := reset ? 0.0 : cumulative + c getMASourcePrice(source, o, h, l, c) => price = switch source "open" => o "high" => h "low" => l "close" => c "hl2" => (h + l) / 2 "hlc3" => (h + l + c) / 3 "ohlc4" => (o + h + l + c) / 4 => c price ma1Price = getMASourcePrice(ma1Source, o, h, l, c) ma2Price = getMASourcePrice(ma2Source, o, h, l, c) ma1 = ma1Type == "ema" ? ta.ema(ma1Price, ma1Length) : ta.sma(ma1Price, ma1Length) ma2 = ma2Type == "ema" ? ta.ema(ma2Price, ma2Length) : ta.sma(ma2Price, ma2Length) plot(ma1, "1st MA", display = enableMA ? display.all : display.none, color=color.fuchsia) plot(ma2, "2nd MA", display = enableMA ? display.all : display.none, color=color.aqua) if barstate.islast and enableSummaryTable table legend = table.new(position.top_right, 3, 4, bgcolor = color.gray, frame_width = 2) table.cell(legend, 0, 0, ticker + " " + str.tostring(c) + " | Ratio: " + str.tostring(ratio) + ":1") table.cell(legend, 0, 1, uIndex + " " + str.tostring(uC)) table.cell(legend, 0, 2, dIndex + " " + str.tostring(dC)) isBar = style == "bars" ? true : false isLine = style == "line" ? true : false isRatio = style == "ratio" ? true : false isCandle = style == "candles" ? true : false isCumulative = style == "cumulative" ? true : false plot(c, display=isLine ? display.all : display.none) plot(ratio, style = plot.style_columns, display = isRatio ? display.all : display.none) plot(cumulative, style = plot.style_columns, display = isCumulative ? display.all : display.none) plotbar(open=o, high=h, low=l, close=c, color=c < o ? bearColor : bullColor, display=isBar ? display.all : display.none) plotcandle(open=o, high=h, low=l, close=c, color=c < o ? bearColor : bullColor, bordercolor=na, display=isCandle ? display.all : display.none) hline(0, "Middle Band", color=color.new(#787B86, 50)) hline(500, "Upper Band +500", color=color.new(bullColor, 75), display=display.none) hline(-500, "Lower Band -500", color=color.new(bearColor, 75), display=display.none) hline(1000, "Upper Band +1000", color=color.new(bullColor, 50), display = enableThresholds ? display.all : display.none) hline(-1000, "Lower Band -1000", color=color.new(bearColor, 50), display = enableThresholds ? display.all : display.none) hline(1500, "Upper Band +1500", color=color.new(bullColor, 25), display=display.none) hline(-1500, "Lower Band -1500", color=color.new(bearColor, 25), display=display.none) hline(2000, "Upper Band +2000", color=color.new(bullColor, 0), display = enableThresholds ? display.all : display.none) hline(-2000, "Lower Band -2000", color=color.new(bearColor, 0), display = enableThresholds ? display.all : display.none)
TRIX With Moving Average - Didi's Needles setup
https://www.tradingview.com/script/bM9cysbx/
heeger
https://www.tradingview.com/u/heeger/
101
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© hgrams //@version=5 indicator("TRIX With Moving Average - Didi", "TRIX MA DIDI", format = format.price, timeframe = "",timeframe_gaps = true) // Inputs trixLen = input.int(9, title="TRIX Length", minval=1) maLen = input.int(4, title="Moving Average", minval=1) useEma = input.bool(false, title="Use Ema ?") useFill = input.bool(true, title = "Fill ?") // Inputs Colors colTrix = input.color(color.new(#5b9bf5, 0), "TRIX Color", group = "Colors Settings", inline = "Color Settings") colMa = input.color(color.new(#ffee58, 0), "MA Color", group = "Colors Settings", inline = "Color Settings") // Calculations trix = 10000 * ta.change(ta.ema(ta.ema(ta.ema(math.log(close), trixLen), trixLen), trixLen)) ema = ta.ema(trix, maLen) sma = ta.sma(trix, maLen) ma = useEma ? ema : sma // PLOTS hline(0, color=#000000, title="Zero Line", display = display.none) p1 = plot(trix, color = colTrix, title="TRIX") p2 = plot(ma, "MA Trix", color = colMa) plotshape(ta.cross(ma, trix) ? trix : na, title = "TRIX Cross MA", style = shape.cross, color = color.new(color.white, 10), location = location.absolute) color fillColor = na if useFill if ma fillColor := switch trix > ma => color.new(colTrix, 70) ma > trix => color.new(colMa, 70) fill(p1, p2, color.new(fillColor, 70))
Pair Viewer
https://www.tradingview.com/script/PcSrRoEe-Pair-Viewer/
elio27
https://www.tradingview.com/u/elio27/
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/ // Β© elio27 //@version=5 indicator("Pair Viewer", overlay=false, precision=8, max_lines_count=500) // Inputs sym1 = input.symbol(defval="", title="Ticker #1", confirm=true) sym2 = input.symbol(defval="", title="Ticker #2", confirm=true) view = input.string(defval="Candles", title="View as", options=["Candles", "HLOC Cloud"]) upColor = input.color(defval=#089981, title="Up color") downColor = input.color(defval=#F23645, title="Down color") // Main Process pair = str.format("{0}/{1}", sym1, sym2) // Formatting the pair as "Ticker1 / Ticker2" pairH = request.security(pair, timeframe.period, high) // High of Pair on current candle pairL = request.security(pair, timeframe.period, low) // Low of Pair on current candle pairO = request.security(pair, timeframe.period, open) // Open of Pair on current candle pairC = request.security(pair, timeframe.period, close) // Close of Pair on current candle barColor = pairC > pairO ? upColor : downColor // Color selection helper // Ouptut methods // Candle Visualization if view == "Candles" line.new(x1=bar_index, x2=bar_index, y1=pairO, y2=pairC, width=5, color = barColor) // Candle Body line.new(x1=bar_index, x2=bar_index, y1=pairL, y2=pairH, width=1, color = barColor) // Candle Wick // Cloud Visualization cloud = view == "HLOC Cloud" // Boolean simplification highLine = plot(cloud ? pairH : na, color=color.white, title="Cloud : High Line") lowLine = plot(cloud ? pairL : na, color=color.white, title="Cloud : Low Line") plot(pairC, color=cloud ? barColor : color.new(barColor,100), linewidth=2, title="Cloud : Close Line") fill(lowLine, highLine, color=color.new(barColor, 80), title="Cloud : Background Color") var output = line.new(x1=bar_index,x2=bar_index,y1=close,y2=close,color=color.red, style=line.style_dotted, extend=extend.right) line.set_color(output, barColor) line.set_x1(output, bar_index) line.set_x2(output, bar_index+1) line.set_y1(output, pairC) line.set_y2(output, pairC)
BTC TOTALVOLUME MOMENTUM: Onchain
https://www.tradingview.com/script/VzMoIkGg-BTC-TOTALVOLUME-MOMENTUM-Onchain/
cryptoonchain
https://www.tradingview.com/u/cryptoonchain/
31
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© MJShahsavar //@version=5 indicator("BTC TOTALVOLUME MOMENTUM: Onchain", timeframe = "D", overlay=true) R = input.symbol("BTC_TOTALVOLUME", "Symbol") src = request.security(R, 'D', close) D = ta.sma(src, 30) M = ta.sma(src, 365) plot (M, color= color.red , linewidth=1) plot (D, color= color.blue , linewidth=1)
Bollinger Bands Filled - Didi's Needles setup
https://www.tradingview.com/script/7gNrNBdT/
heeger
https://www.tradingview.com/u/heeger/
51
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© hgrams //@version=5 indicator(shorttitle="BB Didi", title="Bollinger Bands Didi", overlay=true, timeframe="", timeframe_gaps=true) // Inputs length = input.int(8, minval=1) src = input(close, title="Source") mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev") offset = input.int(0, "Offset", minval = -500, maxval = 500) useFill = input.bool(true, title = "Fill Bandes ?") // Calculations basis = ta.sma(src, length) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev // BB Condition bbOpenUp = upper > upper[1] and lower < lower[1] and basis > basis[1] bbOpenDown = upper > upper[1] and lower < lower[1] and basis < basis[1] bbParallelUp = upper > upper[1] and (lower > lower[1] or lower == lower[1]) bbParallelDown = (upper < upper[1] or upper == upper[1]) and lower < lower[1] bbClose = upper < upper[1] and lower > lower[1] // Colors Settings colBbOpenUp = input.color(color.new(#5b9bf5, 10), "BB Open Upper Color", group = "Color Setting", inline = "BB Colors") colBbOpenDown = input.color(color.new(#fff176, 10), "BB Open Lower Color", group = "Color Setting", inline = "BB Colors") colBbParallelUp = input.color(color.new(#5b9bf5, 30), "BB Parallel Upper", group = "Color Setting", inline = "BB Colors") colBbParallelDown = input.color(color.new(#fff176, 30), "BB Parallel Lower", group = "Color Setting", inline = "BB Colors") colBbClose = input.color(color.new(color.white, 70), "BB Close", group = "Color Setting", inline = "BB Colors") // Plots plot(basis, "Basis", bbOpenUp ? colBbOpenUp : bbOpenDown ? colBbOpenDown : bbParallelDown ? colBbParallelDown : bbParallelUp ? colBbParallelUp : colBbClose, offset = offset, display = display.none) p1 = plot(upper, "Upper", bbOpenUp ? colBbOpenUp : bbOpenDown ? colBbOpenDown : bbParallelDown ? colBbParallelDown : bbParallelUp ? colBbParallelUp : colBbClose, offset = offset) p2 = plot(lower, "Lower", bbOpenUp ? colBbOpenUp : bbOpenDown ? colBbOpenDown : bbParallelDown ? colBbParallelDown : bbParallelUp ? colBbParallelUp : colBbClose, offset = offset) color fillBandsColor = na if useFill fillBandsColor := switch bbParallelUp => color.new(colBbParallelUp, 90) bbParallelDown => color.new(colBbParallelDown, 90) bbOpenUp => color.new(colBbOpenUp, 80) bbOpenDown => color.new(colBbOpenDown, 80) bbClose => color.new(colBbClose, 98) fill(p1, p2, title = "Background", color = fillBandsColor, display = display.all)
[TK] Congestion pattern
https://www.tradingview.com/script/ReYzma04-TK-Congestion-pattern/
mentalRock19315
https://www.tradingview.com/u/mentalRock19315/
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/ // Β© mentalRock19315 //@version=5 indicator("[TK] Congestion pattern", overlay = true) nbbar = input.int(2,"Minimal number of bars for a congestion zone ?", minval=2, maxval=40) barcongestion = true baranalyse = 0 while barcongestion baranalyse := baranalyse + 1 if close[baranalyse-1] < high[baranalyse] and close[baranalyse-1] > low[baranalyse] // on a bien une congestion na else barcongestion := false baranalyse := baranalyse - 1 boxleft = bar_index-baranalyse boxright = bar_index if baranalyse >= nbbar max = high min = low for no = 1 to baranalyse if high[no] > max max := high[no] if low[no] < min min := low[no] box.new(left=boxleft, top=max, right=boxright, bottom=min, bgcolor = color.new(color.white,90), border_color=color.new(color.white,100))
Stochastic Buy Sell with EMA Trend
https://www.tradingview.com/script/jbMn4M7c-Stochastic-Buy-Sell-with-EMA-Trend/
RealTradingIndicator
https://www.tradingview.com/u/RealTradingIndicator/
259
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© RealTradingIndicator //@version=5 indicator(title="Stochastic Buy Sell with EMA Trend", shorttitle="Stochastic Buy Sell with EMA Trend",overlay= true) periodK = input.int(14, title="%K Length", minval=1) smoothK = input.int(1, title="%K Smoothing", minval=1) periodD = input.int(3, title="%D Smoothing", minval=1) OverBought = input(80) OverSold = input(20) k = ta.sma(ta.stoch(close, high, low, periodK), smoothK) d = ta.sma(k, periodD) co = ta.crossover(k,d) cu = ta.crossunder(k,d) ema_200 = ta.ema(close,200) buy = false sell = false if (not na(k) and not na(d)) if (co and k < OverSold) and close > ema_200 buy := true if (cu and k > OverBought) and close < ema_200 sell := true plotshape(buy, style=shape.labelup, location=location.belowbar,color=color.green,size=size.tiny,text="Buy",textcolor=color.white) plotshape(sell, style=shape.labeldown, location=location.abovebar,color=color.red,size=size.tiny,text="Sell",textcolor=color.white) plot(ema_200,"Ema 200")
heikin ashi calculation call with higher timeframe
https://www.tradingview.com/script/6qNeCKoE-heikin-ashi-calculation-call-with-higher-timeframe/
potatoshop
https://www.tradingview.com/u/potatoshop/
164
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© potatoshop //@version=5 indicator("heikin ashi calculation call with higher timeframe","Pre_Heikin", overlay = true) is_in_chart = time >= chart.left_visible_bar_time and chart.right_visible_bar_time >= time //Mathmatical Calcualtion to avoid the security function heikin(Open,High,Low,Close) => hClose = (Open + High + Low + Close) / 4 hOpen = float(na) hOpen := na(hOpen[1]) ? (Open + Close) / 2 : (nz(hOpen[1]) + nz(hClose[1])) / 2 hHigh = math.max(High, math.max(hOpen, hClose)) hLow = math.min(Low, math.min(hOpen, hClose)) [hOpen,hHigh,hLow,hClose] Check = input.bool(true, "Use Heikin Ashi?") interval = input.timeframe('60', "Resolution") interval_ = if str.endswith(interval,"D") str.tonumber(str.substring(interval,0,str.pos(interval,"D")))*24*60 else if str.endswith(interval,"W") str.tonumber(str.substring(interval,0,str.pos(interval,"W")))*24*60*7 else if str.endswith(interval,"M") str.tonumber(str.substring(interval,0,str.pos(interval,"M")))*24*60*30 else str.tonumber(interval) lookback = int(interval_/str.tonumber(timeframe.period)) // Global variables for previous value of Higher timeframe. _h_high = ta.highest(high,lookback)[1] , _h_low = ta.lowest(low,lookback)[1] var h_high = float(na) , var h_low = float(na) var HOpen = 0. , var HHigh = 0. ,var HLow = 0. , var HClose = 0. var hkOpen = float(na),var hkHigh= float(na),var hkLow= float(na),var hkClose = float(na) if timeframe.change(interval) HOpen := HClose[1], HClose := close[1], HHigh := _h_high, HLow := _h_low [hkOpen_,hkHigh_,hkLow_,hkClose_] = heikin(HOpen,HHigh,HLow,HClose) hkOpen := hkOpen_, hkHigh := hkHigh_, hkLow := hkLow_, hkClose := hkClose_ DEFAULT_COLOR_GROWTH = color.rgb(0, 150, 136, 80) DEFAULT_COLOR_FALL = color.rgb(244, 67, 54, 80) O = Check ? hkOpen : HOpen H = Check ? hkHigh : HHigh L = Check ? hkLow : HLow C = Check ? hkClose : HClose Color = C > O ? DEFAULT_COLOR_GROWTH : DEFAULT_COLOR_FALL check1 = input.bool(true,"Original Time View") OPEN = plot(O,"Pre_Open",color =Color, style=plot.style_stepline ,offset =check1? -lookback:0) HIGH = plot(H,"Pre_High",color =Color, style=plot.style_stepline ,offset =check1? -lookback:0) LOW = plot(L,"Pre_Low",color =Color, style=plot.style_stepline ,offset =check1? -lookback:0) CLOSE = plot(C,"Pre_CLose",color =Color, style=plot.style_stepline ,offset =check1? -lookback:0) fill(OPEN,CLOSE,color=Color) fill(HIGH,LOW,color=Color) is_new_period = timeframe.change(interval) TMR = ((H-L)/L)*100 // Total Moving Range Volatility = ((C-C[1])/C[1])*100 halflookback = int(lookback/2) if is_new_period and is_in_chart label.new(bar_index-halflookback, H,style=label.style_none, text=str.tostring(Volatility,format.percent),textcolor = color.rgb(243, 245, 247, 45),color = color.rgb(27, 134, 45, 100),tooltip="TMR: "+ str.tostring(TMR,format.percent)) if barstate.islast line.new(last_bar_index-lookback,H,last_bar_index+lookback,H, color=color.new(Color,50),width=1) line.new(last_bar_index-lookback,O,last_bar_index+lookback,O, color=color.new(Color,50),width=1) line.new(last_bar_index-lookback,C,last_bar_index+lookback,C, color=color.new(Color,50),width=1) line.new(last_bar_index-lookback,L,last_bar_index+lookback,L, color=color.new(Color,50),width=1)
Adaptive Fisherized CMO
https://www.tradingview.com/script/f9bz3PcY-Adaptive-Fisherized-CMO/
simwai
https://www.tradingview.com/u/simwai/
60
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© simwai //@version=5 indicator('Adaptive Fisherized CMO', 'AF_CMO', false) // -- Input -- string signalMode = input.string('MA', 'Choose Signal Mode', options=['Overbought/Oversold', 'Zero Line', 'MA', 'MA Overbought/Oversold', 'None'], group='General', inline='1') bool areAdditionalExitsEnabled = input.bool(true, 'Enable Additional Exits', tooltip='Exits on MA Cross', group='General', inline='2') bool isInnerBgEnabled = input.bool(true, 'Enable Inner Background Plot', tooltip='Between outer and inner band', group='General', inline='3') bool isOuterBgEnabled = input.bool(true, 'Enable Outer Background Plot', tooltip='Between outer band and CMO', group='General', inline='3') bool areColorsReversed = input.bool(false, 'Enable Oversold/Overbought Color Reversion', group='General', inline='4') bool isTrendFilterEnabled = input.bool(true, 'Enable KAMA Trend Filter', group='Trend Filter', inline='1') bool isTrendPlotEnabled = input.bool(false, 'Enable KAMA Trend Plot', group='Trend Filter', inline='1') string kamaTimeframe = input.timeframe('240', 'Choose Timeframe', group='Trend Filter', inline='2') int kamaLength = input.int(89, 'KAMA Length', group='Trend Filter', inline='3') int kamaLookback = input.int(3, 'KAMA Lookback', group='Trend Filter', inline='3') string resolution = input.timeframe(defval='', title='Resolution', group='CMO', inline='1') int min = input.int(defval=34, minval=2, title='Min Length', group='CMO', inline='2', tooltip='Used as min length for adaptive mode') int cmoLength = input.int(defval=100, minval=2, title='Length', group='CMO', inline='2', tooltip='Used as length for CMO or max length when adaptive mode is enabled') float lowerBandValue = input.float(-0.5, 'Lower Band', group='CMO', inline='3') float upperBandValue = input.float(0.5, 'Upper Band', group='CMO', inline='3') bool isFisherized = input.bool(defval=false, title='Enable Fisherization', group='CMO', inline='4') string adaptiveMode = input.string('Homodyne Discriminator', 'Choose Adaptive Mode', options=['Inphase-Quadrature Transform', 'Median', 'Homodyne Discriminator', 'None'], group='CMO', inline='5') bool isMaPlotEnabled = input.bool(true, 'Enable MA Plot', inline='1') string maType = input.string(defval='T3', title='Choose MA Type', options=['SMA', 'SMMA', 'T3', 'VWMA'], group='MA', inline='2') int maLength = input.int(13, title='Length', group='MA', inline='2') float t3Hot = input.float(title='T3 Smoothing Factor', defval=0.5, minval=0.00001, maxval=1, step=0.1, group='MA', inline='3', tooltip='Called hot in code') string t3Type = input.string(title='T3 Type', defval='Normal', options=['Normal', 'New'], group='MA', inline='3') bool isHannWindowPriceSmoothingEnabled = input.bool(true, 'Enable Hann Window Price Smoothing', group='Smoothing', inline='1') int hannWindowLength = input.int(3, 'Hann Window Length', minval=2, group='Smoothing', inline='2') bool isNetEnabled = input.bool(true, 'Enable NET', group='Smoothing', inline='3', tooltip='Ehlers Noise Elmimination Technique') int netLength = input.int(9, 'NET Length', minval=2, group='Smoothing', inline='4') // -- Colors -- color maximumYellowRed = color.rgb(255, 203, 98) // yellow color rajah = color.rgb(242, 166, 84) // orange color magicMint = color.rgb(171, 237, 198) color lightPurple = color.rgb(193, 133, 243) color languidLavender = color.rgb(232, 215, 255) color maximumBluePurple = color.rgb(181, 161, 226) color skyBlue = color.rgb(144, 226, 244) color lightGray = color.rgb(214, 214, 214) color quickSilver = color.rgb(163, 163, 163) color mediumAquamarine = color.rgb(104, 223, 153) color carrotOrange = color.rgb(239, 146, 46) color transpGray = color.new(lightGray, 50) color transpMagicMint = color.new(magicMint, 50) color transpRajah = color.new(rajah, 50) color transpMaximumYellowRed = color.new(maximumYellowRed, 50) // -- Global States -- [src, _volume] = request.security(syminfo.tickerid, resolution, [close[1], volume[1]], barmerge.gaps_off, barmerge.lookahead_on) float kamaClose = request.security(syminfo.tickerid, kamaTimeframe, close[1], barmerge.gaps_off, barmerge.lookahead_on) // -- Functions -- // Chande Momentum Oscillator (CMO) f1(m) => m >= 0.0 ? m : 0.0 f2(m) => m >= 0.0 ? 0.0 : -m percent(nom, div) => 100 * nom / div cmo(float _src, int _cmoLength) => if (bar_index > _cmoLength) float mommOut = ta.change(_src) float m1 = f1(mommOut) float m2 = f2(mommOut) float sm1 = math.sum(m1, _cmoLength) float sm2 = math.sum(m2, _cmoLength) float cmo = percent(sm1 - sm2, sm1 + sm2) // Apply normalization normalize(float _src, int _min, int _max) => var float _historicMin = 1.0 var float _historicMax = -1.0 _historicMin := math.min(nz(_src, _historicMin), _historicMin) _historicMax := math.max(nz(_src, _historicMax), _historicMax) _min + (_max - _min) * (_src - _historicMin) / math.max(_historicMax - _historicMin, 1) // Inverse Fisher Transformation (IFT) fisherize(float _value) => (math.exp(2 * _value) - 1) / (math.exp(2 * _value) + 1) // Convert length to alpha getAlpha(float _length) => 2 / (_length + 1) // Get dominant cyber cycle – Median – Credits to @blackcat1402 getMedianDc(float Price, float alpha=0.07, simple float CycPart=0.5) => Smooth = 0.00 Cycle = 0.00 Q1 = 0.00 I1 = 0.00 DeltaPhase = 0.00 MedianDelta = 0.00 DC = 0.00 InstPeriod = 0.00 Period = 0.00 I2 = 0.00 Q2 = 0.00 IntPeriod = 0 Smooth := (Price + 2 * nz(Price[1]) + 2 * nz(Price[2]) + nz(Price[3])) / 6 Cycle := (1 - .5 * alpha) * (1 - .5 * alpha) * (Smooth - 2 * nz(Smooth[1]) + nz(Smooth[2])) + 2 * (1 - alpha) * nz(Cycle[1]) - (1 - alpha) * (1 - alpha) * nz(Cycle[2]) Cycle := bar_index < 7 ? (Price - 2 * nz(Price[1]) + nz(Price[2])) / 4 : Cycle Q1 := (.0962 * Cycle + .5769 * nz(Cycle[2]) - .5769 * nz(Cycle[4]) - .0962 * nz(Cycle[6])) * (.5 + .08 * nz(InstPeriod[1])) I1 := nz(Cycle[3]) DeltaPhase := Q1 != 0 and nz(Q1[1]) != 0 ? (I1 / Q1 - nz(I1[1]) / nz(Q1[1])) / (1 + I1 * nz(I1[1]) / (Q1 * nz(Q1[1]))) : DeltaPhase DeltaPhase := DeltaPhase < 0.1 ? 0.1 : DeltaPhase DeltaPhase := DeltaPhase > 1.1 ? 1.1 : DeltaPhase MedianDelta := ta.median(DeltaPhase, 5) DC := MedianDelta == 0.00 ? 15.00 : 6.28318 / MedianDelta + .5 InstPeriod := .33 * DC + .67 * nz(InstPeriod[1]) Period := .15 * InstPeriod + .85 * nz(Period[1]) IntPeriod := math.round(Period * CycPart) < 1 ? 1 : math.round(Period * CycPart) IntPeriod // Get dominant cyber cycle – Inphase-Quadrature -- Credits to @DasanC getIQ(float src, int min, int max) => PI = 3.14159265359 P = src - src[7] lenIQ = 0.0 lenC = 0.0 imult = 0.635 qmult = 0.338 inphase = 0.0 quadrature = 0.0 re = 0.0 im = 0.0 deltaIQ = 0.0 instIQ = 0.0 V = 0.0 inphase := 1.25 * (P[4] - imult * P[2]) + imult * nz(inphase[3]) quadrature := P[2] - qmult * P + qmult * nz(quadrature[2]) re := 0.2 * (inphase * inphase[1] + quadrature * quadrature[1]) + 0.8 * nz(re[1]) im := 0.2 * (inphase * quadrature[1] - inphase[1] * quadrature) + 0.8 * nz(im[1]) if re != 0.0 deltaIQ := math.atan(im / re) deltaIQ for i = 0 to max by 1 V += deltaIQ[i] if V > 2 * PI and instIQ == 0.0 instIQ := i instIQ if instIQ == 0.0 instIQ := nz(instIQ[1]) instIQ lenIQ := 0.25 * instIQ + 0.75 * nz(lenIQ[1], 1) length = lenIQ < min ? min : lenIQ > max ? max : lenIQ math.round(length) // Get Dominant Cyber Cycle - Homodyne Discriminator With Hilbert Dominant Cycle – Credits to @blackcat1402 getHdDc(float Price, int min, int max, simple float CycPart = 0.5) => Smooth = 0.00 Detrender = 0.00 I1 = 0.00 Q1 = 0.00 jI = 0.00 jQ = 0.00 I2 = 0.00 Q2 = 0.00 Re = 0.00 Im = 0.00 Period = 0.00 SmoothPeriod = 0.00 pi = 2 * math.asin(1) DomCycle = 0.0 // Hilbert Transform Smooth := bar_index > 7 ? (4 * Price + 3 * nz(Price[1]) + 2 * nz(Price[2]) + nz(Price[3])) / 10 : Smooth Detrender := bar_index > 7 ? (.0962 * Smooth + .5769 * nz(Smooth[2]) - .5769 * nz(Smooth[4]) - .0962 * nz(Smooth[6])) * (.075 * nz(Period[1]) + .54) : Detrender // Compute InPhase and Quadrature components Q1 := bar_index > 7 ? (.0962 * Detrender + .5769 * nz(Detrender[2]) - .5769 * nz(Detrender[4]) - .0962 * nz(Detrender[6])) * (.075 * nz(Period[1]) + .54) : Q1 I1 := bar_index > 7 ? nz(Detrender[3]) : I1 // Advance the phase of I1 and Q1 by 90 degrees jI := (.0962 * I1 + .5769 * nz(I1[2]) - .5769 * nz(I1[4]) - .0962 * nz(I1[6])) * (.075 * nz(Period[1]) + .54) jQ := (.0962 * Q1 + .5769 * nz(Q1[2]) - .5769 * nz(Q1[4]) - .0962 * nz(Q1[6])) * (.075 * nz(Period[1]) + .54) // Phasor addition for 3 bar averaging I2 := I1 - jQ Q2 := Q1 + jI // Smooth the I and Q components before applying the discriminator I2 := .2 * I2 + .8 * nz(I2[1]) Q2 := .2 * Q2 + .8 * nz(Q2[1]) // Homodyne Discriminator Re := I2 * nz(I2[1]) + Q2 * nz(Q2[1]) Im := I2 * nz(Q2[1]) - Q2 * nz(I2[1]) Re := .2 * Re + .8 * nz(Re[1]) Im := .2 * Im + .8 * nz(Im[1]) Period := Im != 0 and Re != 0 ? 2 * pi / math.atan(Im / Re) : Period Period := Period > 1.5 * nz(Period[1]) ? 1.5 * nz(Period[1]) : Period Period := Period < .67 * nz(Period[1]) ? .67 * nz(Period[1]) : Period Period := Period < min ? min : Period Period := Period > max ? max : Period Period := .2 * Period + .8 * nz(Period[1]) SmoothPeriod := .33 * Period + .67 * nz(SmoothPeriod[1]) DomCycle := math.ceil(CycPart * SmoothPeriod) < 1 ? 1 : math.ceil(CycPart * SmoothPeriod) // Limit dominant cycle DomCycle := DomCycle < min ? min : DomCycle > max ? max : DomCycle math.round(DomCycle) // Noise Elimination Technology (NET) – Credits to @blackcat1402 doNet(float _series, simple int _smoothingLength, int _lowerBand=-1, int _upperBand=1) => var netX = array.new_float(102) var netY = array.new_float(102) num = 0.00 denom = 0.00 net = 0.00 trigger = 0.00 for count = 1 to _smoothingLength array.set(netX, count, nz(_series[count - 1])) array.set(netY, count, -count) num := 0 for count = 2 to _smoothingLength for k = 1 to count - 1 num := num - math.sign(nz(array.get(netX, count)) - nz(array.get(netX, k))) denom := 0.5 * _smoothingLength * (_smoothingLength - 1) net := num / denom trigger := 0.05 + 0.9 * nz(net[1]) trigger := normalize(trigger, _lowerBand, _upperBand) // Hann Window Smoothing – Credits to @cheatcountry doHannWindow(float _series, float _hannWindowLength) => sum = 0.0, coef = 0.0 for i = 1 to _hannWindowLength cosine = 1 - math.cos(2 * math.pi * i / (_hannWindowLength + 1)) sum := sum + (cosine * nz(_series[i - 1])) coef := coef + cosine h = coef != 0 ? sum / coef : 0 // T3 – Credits to @loxx t3(float _src, float _length, float hot=1, string clean='T3')=> a = hot _c1 = -a * a * a _c2 = 3 * a * a + 3 * a * a * a _c3 = -6 * a * a - 3 * a - 3 * a * a * a _c4 = 1 + 3 * a + a * a * a + 3 * a * a alpha = 0. if (clean == 'T3 New') alpha := 2.0 / (2.0 + (_length - 1.0) / 2.0) else alpha := 2.0 / (1.0 + _length) _t30 = _src, _t31 = _src _t32 = _src, _t33 = _src _t34 = _src, _t35 = _src _t30 := nz(_t30[1]) + alpha * (_src - nz(_t30[1])) _t31 := nz(_t31[1]) + alpha * (_t30 - nz(_t31[1])) _t32 := nz(_t32[1]) + alpha * (_t31 - nz(_t32[1])) _t33 := nz(_t33[1]) + alpha * (_t32 - nz(_t33[1])) _t34 := nz(_t34[1]) + alpha * (_t33 - nz(_t34[1])) _t35 := nz(_t35[1]) + alpha * (_t34 - nz(_t35[1])) out = _c1 * _t35 + _c2 * _t34 + _c3 * _t33 + _c4 * _t32 out // Simple Moving Average (SMA) sma(float _src, int _period) => sum = 0.0 for i = 0 to _period - 1 sum := sum + _src[i] / _period sum // Standard Deviation isZero(val, eps) => math.abs(val) <= eps sum(fst, snd) => EPS = 1e-10 res = fst + snd if isZero(res, EPS) res := 0 else if not isZero(res, 1e-4) res := res else 15 stdev(src, length) => avg = sma(src, length) sumOfSquareDeviations = 0.0 for i = 0 to length - 1 sum = sum(src[i], - avg) sumOfSquareDeviations := sumOfSquareDeviations + sum * sum stdev = math.sqrt(sumOfSquareDeviations / length) // Measure of difference between the series and it's ma dev(float source, int length, float ma) => mean = sma(source, length) sum = 0.0 for i = 0 to length - 1 val = source[i] sum := sum + math.abs(val - mean) dev = sum/length // Exponential Moving Average (EMA) ema(float _src, int _period) => alpha = 2 / (_period + 1) sum = 0.0 sum := na(sum[1]) ? sma(_src, _period) : alpha * _src + (1 - alpha) * nz(sum[1]) // Smoothed Moving Average (SMMA) smma(float _src, int _period) => tmpSMA = sma(_src, _period) tmpVal = 0.0 tmpVal := na(tmpVal[1]) ? tmpSMA : (tmpVal[1] * (_period - 1) + _src) / _period // Kaufman's Adaptive Moving Average (KAMA) kama(float _src, int _period) => if (bar_index > _period) tmpVal = 0.0 tmpVal := nz(tmpVal[1]) + math.pow(((math.sum(math.abs(_src - _src[1]), _period) != 0) ? (math.abs(_src - _src[_period]) / math.sum(math.abs(_src - _src[1]), _period)) : 0) * (0.666 - 0.0645) + 0.0645, 2) * (_src - nz(tmpVal[1])) tmpVal // Volume Weighted Moving Averga (VWMA) vwma(float _src, int _period) => sma(_src * _volume, _period) / sma(_volume, _period) ma(float source, int length, string type) => float ma = switch type 'SMA' => sma(source, length) 'EMA' => ema(source, length) 'SMMA' => smma(source, length) 'VWMA' => vwma(source, length) 'T3' => t3(source, length, t3Hot, t3Type) => source // -- CMO Calculation -- if (isHannWindowPriceSmoothingEnabled) src := doHannWindow(src, hannWindowLength) int _cmoLength = switch adaptiveMode 'Inphase-Quadrature Transform' => getIQ(src, min, cmoLength) 'Median' => getMedianDc(src, getAlpha(cmoLength)), 'Homodyne Discriminator' => getHdDc(src, min, cmoLength) => cmoLength if (_cmoLength > min and adaptiveMode != 'None') cmoLength := min float cmo = cmo(src, _cmoLength) float cmoMa = ma(cmo, maLength, maType) if (isFisherized) cmo := fisherize(cmo) cmoMa := fisherize(cmoMa) else cmo := normalize(cmo, -1, 1) cmoMa := normalize(cmoMa, -1, 1) if (isNetEnabled) cmo := doNet(cmo, netLength) cmoMa := doNet(cmoMa, netLength) bool cmoLong = cmo >= 0 bool cmoShort = cmo < 0 float upperLevel = upperBandValue float lowerLevel = lowerBandValue plot(isMaPlotEnabled ? cmoMa : na, 'CMO MA', skyBlue) topBand = plot(1, 'Top Band', color=transpGray) upperBand = plot(upperLevel, 'Upper Band', color=transpGray) zeroLine = plot(0, 'Zero Line', color=transpGray) lowerBand = plot(lowerLevel, 'Lower Band', color=transpGray) bottomBand = plot(-1, 'Bottom Band', color=transpGray) cmoPlot = plot(cmo, title='CMO', color=languidLavender) fill(zeroLine, upperBand, color=not isTrendPlotEnabled and isInnerBgEnabled ? ((cmo > 0) ? (areColorsReversed ? transpMagicMint : transpRajah) : na) : na) fill(upperBand, topBand, color=not isTrendPlotEnabled and isOuterBgEnabled ? (cmo >= upperLevel ? (areColorsReversed ? color.new(magicMint, 75) : color.new(rajah, 75)) : na) : na) fill(zeroLine, lowerBand, color=not isTrendPlotEnabled and isInnerBgEnabled ? ((cmo < 0) ? (areColorsReversed ? transpRajah : transpMagicMint) : na) : na) fill(lowerBand, bottomBand, color=not isTrendPlotEnabled and isOuterBgEnabled ? (cmo < lowerLevel ? (areColorsReversed ? color.new(rajah, 75) : color.new(magicMint, 75)) : na) : na) bool enterLong = false bool enterShort = false bool exitLong = false bool exitShort = false // KAMA Trend Detection float kama = kama(kamaClose, kamaLength) float trendSensitivity = syminfo.mintick / 5 bool isKamaSide = math.abs(kama[kamaLookback] - kama) < trendSensitivity bool isKamaUp = (not isKamaSide) and kama[kamaLookback] < kama bool isKamaDown = (not isKamaSide) and kama[kamaLookback] > kama fill(upperBand, zeroLine, isTrendPlotEnabled ? (isKamaSide ? color.new(maximumYellowRed, 50) : isKamaUp ? color.new(mediumAquamarine, 50) : isKamaDown ? maximumBluePurple : na) : na) fill(lowerBand, zeroLine, isTrendPlotEnabled ? (isKamaSide ? color.new(maximumYellowRed, 50) : isKamaDown ? color.new(maximumBluePurple, 50) : isKamaUp ? mediumAquamarine : na) : na) var string openTrade = '' var string signalCache = '' if (signalMode == 'Overbought/Oversold') enterLong := ta.crossover(cmo, lowerLevel) enterShort := ta.crossunder(cmo, upperLevel) exitLong := enterShort exitShort := enterLong if (signalMode == 'MA') enterLong := ta.crossover(cmo, cmoMa) enterShort := ta.crossunder(cmo, cmoMa) exitLong := enterShort exitShort := enterLong if (signalMode == 'Zero Line') enterLong := ta.crossover(cmo, 0) enterShort := ta.crossunder(cmo, 0) exitLong := enterShort exitShort := enterLong if (signalMode == 'MA Overbought/Oversold') enterLong := ta.crossover(cmo, cmoMa) and cmo < lowerLevel enterShort := ta.crossunder(cmo, cmoMa) and cmo > upperLevel exitLong := enterShort exitShort := enterLong exitLong := areAdditionalExitsEnabled and (exitLong or ta.cross(cmoMa, cmo)) exitShort := areAdditionalExitsEnabled and (exitShort or ta.cross(cmoMa, cmo)) // -- Signal Cache -- // It shouldn't happen that multiple signals are executed in one instance // The cache tries to order the signals correctly if (isTrendFilterEnabled) if (isKamaUp and enterShort) enterShort := false if (isKamaDown and enterLong) enterLong := false if (isKamaSide and (enterLong or enterShort)) enterShort := false enterLong := false if (openTrade == 'long' and isKamaDown) exitLong := true if (openTrade == 'short' and isKamaUp) exitShort := true if (signalCache == 'long entry') signalCache := '' enterLong := true else if (signalCache == 'short entry') signalCache := '' enterShort := true if (openTrade == '') if (exitShort and (not enterLong)) exitShort := false if (exitLong and (not enterShort)) exitLong := false if (enterLong and exitShort) openTrade := 'long' exitShort := false else if (enterShort and exitLong) openTrade := 'short' exitLong := false else if (enterLong) openTrade := 'long' else if (enterShort) openTrade := 'short' else if (openTrade == 'long') if (exitShort) exitShort := false if (enterLong) enterLong := false if (enterShort and not exitLong) exitLong := true signalCache := 'short entry' if (enterShort and exitLong) enterShort := false signalCache := 'short entry' if (exitLong) openTrade := '' else if (openTrade == 'short') if (exitLong) exitLong := false if (enterShort) enterShort := false if (enterLong and not exitShort) exitShort := true signalCache := 'long entry' if (enterLong and exitShort) enterLong := false signalCache := 'long entry' if (exitShort) openTrade := '' plotshape(enterLong ? -1.2 : na, title='BUY', style=shape.triangleup, color=magicMint, size=size.tiny, location=location.absolute) plotshape(enterShort ? 1.2 : na, title='SELL', style=shape.triangledown, color=rajah, size=size.tiny, location=location.absolute) plotshape(exitLong ? -1.2 : na, title='BE', style=shape.circle, color=mediumAquamarine, size=size.tiny, location=location.absolute) plotshape(exitShort ? 1.2 : na, title='SE', style=shape.circle, color=carrotOrange, size=size.tiny, location=location.absolute) alertcondition(enterLong, title='ENTER LONG', message='CMO – ENTER LONG') alertcondition(exitLong, title='EXIT LONG', message='CMO – EXIT LONG') alertcondition(enterShort, title='ENTER SHORT', message='CMO – ENTER SHORT') alertcondition(exitShort, title='EXIT SHORT', message='CMO – EXIT SHORT')
Opening Range, Initial Balance, Opening Price
https://www.tradingview.com/script/0nXvk5cU-Opening-Range-Initial-Balance-Opening-Price/
PtGambler
https://www.tradingview.com/u/PtGambler/
264
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© PtGambler //@version=5 indicator('Opening Range, Initial Balance, Opening Price', shorttitle="OR/IB/OP", overlay=true) tz_increment = input.int(-4, 'UTC (+/-)', tooltip = 'New York is -4') use_exchange = input(false, 'Use Exchange Timezone') OR_sess = input.session('0930-1000', title='Opening Range Session') OR_t = time(timeframe.period, OR_sess + ':1234567', use_exchange ? syminfo.timezone : "GMT" + str.tostring(tz_increment)) IB_sess = input.session('0930-1030', title='Initial Balance Session') IB_t = time(timeframe.period, IB_sess + ':1234567', use_exchange ? syminfo.timezone : "GMT" + str.tostring(tz_increment)) show_mid = input.bool(true,"Show Mid levels") chg_col = input.bool(true,"Level changes color", tooltip="Lines change color based on whether the closing price is above or below the line") OR_pos = input.int(5,"OR label position", step=5) IB_pos = input.int(10,"IB label position", step=5) OP_pos = input.int(10,"OP label position", step=5) var opening = 0.0 opening := OR_t and not(OR_t[1]) ? open : opening[1] OR_in_session = not na(OR_t) OR_is_first = OR_in_session and not OR_in_session[1] IB_in_session = not na(IB_t) IB_is_first = IB_in_session and not IB_in_session[1] OR_h = float(na) OR_l = float(na) if OR_is_first OR_h := high OR_l := low OR_l else OR_h := OR_h[1] OR_l := OR_l[1] OR_l if high > OR_h and OR_in_session OR_h := high OR_h if low < OR_l and OR_in_session OR_l := low OR_l OR_mid = (OR_h + OR_l) / 2 IB_h = float(na) IB_l = float(na) if IB_is_first IB_h := high IB_l := low IB_l else IB_h := IB_h[1] IB_l := IB_l[1] IB_l if high > IB_h and IB_in_session IB_h := high IB_h if low < IB_l and IB_in_session IB_l := low IB_l IB_mid = (IB_h + IB_l) / 2 OR_line_col(_src)=> chg_col and close > _src ? color.new(color.green,40) : chg_col and close < _src ? color.new(color.red,40) : color.new(color.yellow,60) IB_line_col(_src)=> chg_col and close > _src ? color.new(color.green,40) : chg_col and close < _src ? color.new(color.red,40) : color.new(color.yellow,60) plot(timeframe.isintraday ? opening : na, style=plot.style_circles, color= color.new(color.white,50), title='Opening price', linewidth=2) plotshape(timeframe.isintraday ? opening : na, style=shape.labeldown, location=location.absolute, color=na, textcolor=color.new(color.white,50),text="OP", offset = OP_pos, show_last = 1) plot(timeframe.isintraday ? OR_h : na, style=plot.style_circles, color= OR_in_session[1] or OR_in_session ? na : OR_line_col(OR_h), title='OR High', linewidth=2) plot(timeframe.isintraday ? OR_l : na, style=plot.style_circles, color= OR_in_session[1] or OR_in_session ? na : OR_line_col(OR_l), title='OR Low', linewidth=2) plot(show_mid and timeframe.isintraday ? OR_mid : na, style=plot.style_circles, color= OR_in_session[1] or OR_in_session ? na : OR_line_col(OR_mid), title='OR Low', linewidth=1) plotshape(timeframe.isintraday ? OR_h : na,style=shape.labeldown, location=location.absolute, color=na, textcolor=OR_in_session[1] or OR_in_session ? na : OR_line_col(OR_h),text="OR High", offset = OR_pos, show_last = 1) plotshape(timeframe.isintraday ? OR_l : na,style=shape.labeldown, location=location.absolute, color=na, textcolor=OR_in_session[1] or OR_in_session ? na : OR_line_col(OR_l),text="OR Low", offset = OR_pos, show_last = 1) plotshape(show_mid and timeframe.isintraday ? OR_mid : na,style=shape.labeldown, location=location.absolute, color=na, textcolor=OR_in_session[1] or OR_in_session ? na : OR_line_col(OR_mid),text="OR Mid", offset = OR_pos, show_last = 1) plot(timeframe.isintraday ? IB_h : na, style=plot.style_cross, color= IB_in_session[1] or IB_in_session ? na : IB_line_col(IB_h), title='IB High', linewidth=2) plot(timeframe.isintraday ? IB_l : na, style=plot.style_cross, color= IB_in_session[1] or IB_in_session ? na : IB_line_col(IB_l), title='IB Low', linewidth=2) plot(show_mid and timeframe.isintraday ? IB_mid : na, style=plot.style_cross, color= IB_in_session[1] or IB_in_session ? na : IB_line_col(IB_mid), title='IB Low', linewidth=1) plotshape(timeframe.isintraday ? IB_h : na,style=shape.labelup, location=location.absolute, color=na, textcolor=IB_in_session[1] or IB_in_session ? na : IB_line_col(IB_h),text="IB High", offset = IB_pos, show_last = 1) plotshape(timeframe.isintraday ? IB_l : na,style=shape.labelup, location=location.absolute, color=na, textcolor=IB_in_session[1] or IB_in_session ? na : IB_line_col(IB_l),text="IB Low", offset = IB_pos, show_last = 1) plotshape(show_mid and timeframe.isintraday ? IB_mid : na,style=shape.labelup, location=location.absolute, color=na, textcolor=IB_in_session[1] or IB_in_session ? na : IB_line_col(IB_mid),text="IB Mid", offset = IB_pos, show_last = 1)
Electrocardiogram Chart
https://www.tradingview.com/script/NbsWKxVu-Electrocardiogram-Chart/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
729
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("Electrocardiogram Chart", "ECG", overlay = true, max_lines_count=500, max_boxes_count = 100) numberOfBars = input.int(25, "Number Of Bars", minval=25, maxval=100, step=25) type HeartBeatCandle float _open float _first float _second float _close int _time color _lineColor color _borderColor color _bodyColor type HeartBeatCandleDrawing line _open_open line _open_first line _first_second line _second_close line _close_close box _envelope label _info getStrTime(int _time)=> _year = str.tostring(year(_time)) _month = str.tostring(month(_time)) _day = str.tostring(dayofmonth(_time)) _hour = str.tostring(hour(_time)) _minute = str.tostring(minute(_time)) _second = str.tostring(second(_time)) strTime = _year + '-' + _month + '-'+_day+ 'T' + _hour + ':' + _minute + ':' + _second strTime unshift(array<HeartBeatCandle> heartBeatCandles, HeartBeatCandle heartBeatCandle, simple int maxItems=100)=> array.unshift(heartBeatCandles, heartBeatCandle) if(array.size(heartBeatCandles) > maxItems) array.pop(heartBeatCandles) clear(array<HeartBeatCandleDrawing> heartBeatDrawings)=> size = array.size(heartBeatDrawings) for i=1 to size!=0? size : na drawing = array.pop(heartBeatDrawings) line.delete(drawing._open_open) line.delete(drawing._open_first) line.delete(drawing._first_second) line.delete(drawing._second_close) line.delete(drawing._close_close) box.delete(drawing._envelope) label.delete(drawing._info) maxItems = 100 [lo, lh, ll, lc, lv] = request.security_lower_tf(syminfo.tickerid, '1', [open, high, low, close, volume], true) var heartBeatCandles = array.new<HeartBeatCandle>() if(bar_index >= last_bar_index-maxItems) hIndices = array.sort_indices(lh, order.descending) highestIndex = array.size(hIndices) > 0? array.get(hIndices, 0) : na lIndices = array.sort_indices(ll, order.ascending) lowestIndex = array.size(lIndices) > 0? array.get(lIndices, 0) : na nOpen = array.size(hIndices) > 0? array.get(lo, 0) : na nClose = array.size(hIndices) > 0? array.get(lc, array.size(lc)-1) : na firstPeak = highestIndex <= lowestIndex? high : low secondPeak = highestIndex <= lowestIndex? low : high lineColor = highestIndex >= lowestIndex? color.green : color.red borderColor = close >= close[1]? color.green : color.red bodyColor = close >= open? color.green : color.red if(array.size(lo) > 0 and array.min(ll) == low and array.max(lh) == high) heartBeatCandle = HeartBeatCandle.new(nOpen, firstPeak, secondPeak, nClose, time, lineColor, borderColor, bodyColor) unshift(heartBeatCandles, heartBeatCandle, numberOfBars) var startBarIndex = 0 var heartBeatDrawings = array.new<HeartBeatCandleDrawing>() lowOffset = 2*(ta.highest(numberOfBars)[1] - ta.lowest(numberOfBars*5)[1]) bgcolor(color.new(color.aqua, 90), show_last = numberOfBars) clear(heartBeatDrawings) if(barstate.islast) endBar = bar_index for candle in heartBeatCandles boxEnd = endBar closeEndBar = boxEnd-1 closeStartBar = closeEndBar -1 secondPeakBar = closeStartBar -1 firstPeakBar = secondPeakBar -1 openEndBar = firstPeakBar -1 openStartBar = openEndBar -1 boxStart = openStartBar -1 endBar := boxStart - 1 cOpen = candle._open - lowOffset cFirstBar = candle._first - lowOffset cSecondBar = candle._second - lowOffset cClose = candle._close - lowOffset _open_open = line.new(openStartBar, cOpen, openEndBar, cOpen, color=candle._lineColor, style=line.style_solid, width=1) _open_first = line.new(openEndBar, cOpen, firstPeakBar, cFirstBar,color=candle._lineColor, style=line.style_solid, width=1) _first_second = line.new(firstPeakBar, cFirstBar, secondPeakBar, cSecondBar,color=candle._lineColor, style=line.style_solid, width=1) _second_close = line.new(secondPeakBar, cSecondBar, closeStartBar, cClose,color=candle._lineColor, style=line.style_solid, width=1) _close_close = line.new(closeStartBar, cClose, closeEndBar, cClose, color=candle._lineColor, style=line.style_solid, width=1) adj = 0.2*math.abs(cFirstBar-cSecondBar) _high = math.max(cFirstBar, cSecondBar) _low = math.min(cFirstBar, cSecondBar) boxHigh = _high+adj boxLow = _low-adj strInfo = str.tostring(array.from(candle._open, _high, _low, candle._close))+'\n'+str.format_time(candle._time, 'yyyy-MM-dd / hh:mm:ss', syminfo.timezone) _envelope = box.new(boxStart, boxHigh, boxEnd, boxLow, candle._borderColor, bgcolor=color.new(candle._bodyColor, 80)) //,text = strInfo, text_valign = text.align_bottom, text_color = color.yellow, text_size = size.tiny) _info = label.new((boxStart+boxEnd+1)/2, boxLow, yloc = yloc.price, style = label.style_none, tooltip = strInfo, text='   \n   \n   \n   \n   \n   \n   ', textalign = text.align_center) heartBeatDrawing = HeartBeatCandleDrawing.new(_open_open, _open_first, _first_second, _second_close, _close_close, _envelope, _info) array.push(heartBeatDrawings, heartBeatDrawing)
Didi's Needles setup screener
https://www.tradingview.com/script/XR3rBEhd/
heeger
https://www.tradingview.com/u/heeger/
441
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // @Heeger // Apenas um rapaz latino americano //@version=5 indicator('Didi Screener V1', overlay=true) //////////// // INPUTS // // MA Type \\ ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "RMA (SMMA)" => ta.rma(source, length) "HMA" => ta.hma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) // ADX (Code Original by Smollet) \\ adxlen = input(8, title="ADX Smoothing", group = "ADX Config", inline = "Adx") dilen = input(8, title="DI Length", group = "ADX Config", inline = "Adx") level = input(32, title = "Level", group = "ADX Config", inline = "Adx") maTypeInputDM = input.string("RMA (SMMA)", title="+DM -DM MA Settings", options=["SMA", "EMA", "RMA (SMMA)", "HMA", "WMA", "VWMA"], group="ADX MA Type") maTypeInputADX = input.string("WMA", title="ADX Smoothing Settings", options=["SMA", "EMA", "RMA (SMMA)", "HMA", "WMA", "VWMA"], group="ADX MA Type") // DIDI Index Inputs \\ ddfast = input.int(title="Fast average", defval=3, group="Didi index config") ddmedian = input.int(title="Normal average", defval=8, group="Didi index config") ddslow = input.int(title="Slow average", defval=20, group="Didi index config") maTypeInputDidi = input.string("SMA", title="MA Type", options=["SMA", "EMA", "RMA (SMMA)", "HMA", "WMA", "VWMA"], group="Didi index config") delta = input.int(3, title = "Delta t Needle", group = "Agulhada", tooltip = "Defina o delta tempo entre o alerta e confirmaΓ§Γ£o para considerar a agulhada.") deltaBJmin = input.float(0.02, step=0.01, title = "Delta BJMA Min", group = "Beijo da Mulher Aranha") deltaBJmax = input.float(0.05, step=0.01, title = "Delta BJMA Max", group = "Beijo da Mulher Aranha") // BB Inputs // length = input.int(8, minval=1, group = "Bollinger Bands", inline = "BB") src = input(close, title="Source", group = "Bollinger Bands", inline = "BB") mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev", group = "Bollinger Bands", inline = "BB") offset = input.int(0, "Offset", minval = -500, maxval = 500, group = "Bollinger Bands", inline = "BB") // Trix Inputs // trixLen = input.int(9, title="TRIX Length", minval=1, group = "Trix", inline = "trix") maLen = input.int(4, title="Moving Average", minval=1, group = "Trix", inline = "trix") useEma = input.bool(false, title="Use Ema ?", group = "Trix", inline = "trix") // Stoch // periodK = input.int(8, title="%K Length", minval=1, group = "Stoch", inline = "stoch") smoothK = input.int(3, title="%K Smoothing", minval=1, group = "Stoch", inline = "stoch") periodD = input.int(3, title="%D Smoothing", minval=1, group = "Stoch", inline = "stoch") // Table Inputs // col_width = input.float(5, title = "Column Width (%)", group = "Table Config") scr_numb = input.int(1, title = "Screen #", tooltip = '1 - rightmost screener', minval = 1, group = "Table Config") // Colors Inputs // bgLong1 = input.color(color.new(#2C4C78, 0), title = "Color Background Long 1", inline = "Color Background Long", group = "Color Background Long") bgLong2 = input.color(color.new(#376099, 0), title = "Color Background Long 2", inline = "Color Background Long", group = "Color Background Long") bgLong3 = input.color(color.new(#467ecc, 0), title = "Color Background Long 3", inline = "Color Background Long", group = "Color Background Long") bgLong4 = input.color(color.new(#4b8be6, 0), title = "Color Background Long 4", inline = "Color Background Long", group = "Color Background Long") bgLong5 = input.color(color.new(#519aff, 0), title = "Color Background Long 5", inline = "Color Background Long", group = "Color Background Long") bgShort1 = input.color(color.new(#776f29, 0), title = "Color Background Short 1", inline = "Color Background Short", group = "Color Background Short") bgShort2 = input.color(color.new(#918836, 0), title = "Color Background Short 2", inline = "Color Background Short", group = "Color Background Short") bgShort3 = input.color(color.new(#a89d36, 0), title = "Color Background Short 3", inline = "Color Background Short", group = "Color Background Short") bgShort4 = input.color(color.new(#c0b236, 0), title = "Color Background Short 4", inline = "Color Background Short", group = "Color Background Short") bgShort5 = input.color(color.new(#e2d240, 0), title = "Color Background Short 5", inline = "Color Background Short", group = "Color Background Short") bgCloseLong = input.color(#aa2b2b, title = "Color Background Close Long", inline = "Color Background Close Buy", group = "Color Background Close") bgCloseShort = input.color(#aa2b2b, title = "Color Background Close Short", inline = "Color Background Close Short", group = "Color Background Close") ///////////// // SYMBOLS // u01 = input.bool(true, title = "", group = 'Symbols', inline = 's01') u02 = input.bool(true, title = "", group = 'Symbols', inline = 's02') u03 = input.bool(true, title = "", group = 'Symbols', inline = 's03') u04 = input.bool(true, title = "", group = 'Symbols', inline = 's04') u05 = input.bool(true, title = "", group = 'Symbols', inline = 's05') u06 = input.bool(true, title = "", group = 'Symbols', inline = 's06') u07 = input.bool(true, title = "", group = 'Symbols', inline = 's07') u08 = input.bool(true, title = "", group = 'Symbols', inline = 's08') u09 = input.bool(true, title = "", group = 'Symbols', inline = 's09') u10 = input.bool(true, title = "", group = 'Symbols', inline = 's10') u11 = input.bool(true, title = "", group = 'Symbols', inline = 's11') u12 = input.bool(true, title = "", group = 'Symbols', inline = 's12') u13 = input.bool(true, title = "", group = 'Symbols', inline = 's13') u14 = input.bool(true, title = "", group = 'Symbols', inline = 's14') u15 = input.bool(true, title = "", group = 'Symbols', inline = 's15') u16 = input.bool(true, title = "", group = 'Symbols', inline = 's16') u17 = input.bool(true, title = "", group = 'Symbols', inline = 's17') u18 = input.bool(true, title = "", group = 'Symbols', inline = 's18') u19 = input.bool(true, title = "", group = 'Symbols', inline = 's19') u20 = input.bool(true, title = "", group = 'Symbols', inline = 's20') u21 = input.bool(true, title = "", group = 'Symbols', inline = 's21') u22 = input.bool(true, title = "", group = 'Symbols', inline = 's22') u23 = input.bool(true, title = "", group = 'Symbols', inline = 's23') u24 = input.bool(true, title = "", group = 'Symbols', inline = 's24') u25 = input.bool(true, title = "", group = 'Symbols', inline = 's25') u26 = input.bool(true, title = "", group = 'Symbols', inline = 's26') u27 = input.bool(true, title = "", group = 'Symbols', inline = 's27') u28 = input.bool(true, title = "", group = 'Symbols', inline = 's28') u29 = input.bool(true, title = "", group = 'Symbols', inline = 's29') u30 = input.bool(true, title = "", group = 'Symbols', inline = 's30') u31 = input.bool(true, title = "", group = 'Symbols', inline = 's31') u32 = input.bool(true, title = "", group = 'Symbols', inline = 's32') u33 = input.bool(true, title = "", group = 'Symbols', inline = 's33') u34 = input.bool(true, title = "", group = 'Symbols', inline = 's34') u35 = input.bool(true, title = "", group = 'Symbols', inline = 's35') u36 = input.bool(true, title = "", group = 'Symbols', inline = 's36') u37 = input.bool(true, title = "", group = 'Symbols', inline = 's37') u38 = input.bool(true, title = "", group = 'Symbols', inline = 's38') u39 = input.bool(true, title = "", group = 'Symbols', inline = 's39') u40 = input.bool(true, title = "", group = 'Symbols', inline = 's40') s01 = input.symbol("BMFBOVESPA:WDO1!", group = 'Symbols', inline = 's01') s02 = input.symbol("PEPPERSTONE:BTCUSD", group = 'Symbols', inline = 's02') s03 = input.symbol("TVC:GOLD", group = 'Symbols', inline = 's03') s04 = input.symbol("FX:EURUSD", group = 'Symbols', inline = 's04') s05 = input.symbol("FX:USDJPY", group = 'Symbols', inline = 's05') s06 = input.symbol("FX:GBPUSD", group = 'Symbols', inline = 's06') s07 = input.symbol("FX:USDCAD", group = 'Symbols', inline = 's07') s08 = input.symbol("FX:USDSEK", group = 'Symbols', inline = 's08') s09 = input.symbol("FX:USDCHF", group = 'Symbols', inline = 's09') s10 = input.symbol("FX:EURGBP", group = 'Symbols', inline = 's10') s11 = input.symbol("FX:GBPJPY", group = 'Symbols', inline = 's11') s12 = input.symbol("FX:GBPAUD", group = 'Symbols', inline = 's12') s13 = input.symbol("FX:AUDCAD", group = 'Symbols', inline = 's13') s14 = input.symbol("PEPPERSTONE:USDSGD", group = 'Symbols', inline = 's14') s15 = input.symbol("FX:NZDUSD", group = 'Symbols', inline = 's15') s16 = input.symbol("FX:AUDUSD", group = 'Symbols', inline = 's16') s17 = input.symbol("FX:EURAUD", group = 'Symbols', inline = 's17') s18 = input.symbol("FX:EURCAD", group = 'Symbols', inline = 's18') s19 = input.symbol("FX:EURCHF", group = 'Symbols', inline = 's19') s20 = input.symbol("FX:EURJPY", group = 'Symbols', inline = 's20') s21 = input.symbol("FX:EURNZD", group = 'Symbols', inline = 's21') s22 = input.symbol("FX:GBPCAD", group = 'Symbols', inline = 's22') s23 = input.symbol("FX:GBPCHF", group = 'Symbols', inline = 's23') s24 = input.symbol("FX:GBPNZD", group = 'Symbols', inline = 's24') s25 = input.symbol("FX:AUDCHF", group = 'Symbols', inline = 's25') s26 = input.symbol("FX:AUDNZD", group = 'Symbols', inline = 's26') s27 = input.symbol("FX:CADJPY", group = 'Symbols', inline = 's27') s28 = input.symbol("FX:CADCHF", group = 'Symbols', inline = 's28') s29 = input.symbol("FX:NZDCAD", group = 'Symbols', inline = 's29') s30 = input.symbol("FX:CHFJPY", group = 'Symbols', inline = 's30') s31 = input.symbol("FX:NZDCHF", group = 'Symbols', inline = 's31') s32 = input.symbol("FX:NZDJPY", group = 'Symbols', inline = 's32') s33 = input.symbol("FX:AUDJPY", group = 'Symbols', inline = 's33') s34 = input.symbol("FX:USDNOK", group = 'Symbols', inline = 's34') s35 = input.symbol("FOREXCOM:USDPLN", group = 'Symbols', inline = 's35') s36 = input.symbol("FX:USDMXN", group = 'Symbols', inline = 's36') s37 = input.symbol("FOREXCOM:EURMXN", group = 'Symbols', inline = 's37') s38 = input.symbol("FX:EURNOK", group = 'Symbols', inline = 's38') s39 = input.symbol("FOREXCOM:EURSGD", group = 'Symbols', inline = 's39') s40 = input.symbol("FOREXCOM:SGDJPY", group = 'Symbols', inline = 's40') ////////////////// // CALCULATIONS // // Get only prefix only_prefix(s) => array.get(str.split(s, ":"), 0) // Get only symbol only_symbol(s) => array.get(str.split(s, ":"), 1) // ADX CALCULATION // dirmov(len) => up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) truerange = ma(ta.tr, len, maTypeInputDM) plus = fixnan(100 * ma(plusDM, len, maTypeInputDM) / truerange) minus = fixnan(100 * ma(minusDM, len, maTypeInputDM) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus dx = 100* math.abs(plus - minus) / (sum == 0 ? 1 : sum) adx = ma(dx, adxlen, maTypeInputADX) adxxr = (adx+adx[adxlen])/2 [adx, dx, plus, minus, adxxr] [sig, dxx, diplus, diminus, adxr] = adx(dilen, adxlen) // DIDI INDEX CALCULATIONS \\ DidiSlow = (ma(close, ddslow, maTypeInputDidi) / ma(close, ddmedian, maTypeInputDidi) - 1) * 100 DidiFast = (ma(close, ddfast, maTypeInputDidi) / ma(close, ddmedian, maTypeInputDidi) - 1) * 100 DidiMedian = (close / ma(close, ddmedian, maTypeInputDidi) - 1) * 100 // BB CALCULATIONS // basis = ta.sma(src, length) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev // Trix Calculations // trix = 10000 * ta.change(ta.ema(ta.ema(ta.ema(math.log(close), trixLen), trixLen), trixLen)) ema = ta.ema(trix, maLen) sma = ta.sma(trix, maLen) maTrix = useEma ? ema : sma // Stoch Calculations // k = ta.sma(ta.stoch(close, high, low, periodK), smoothK) d = ta.sma(k, periodD) /////////// // PLOT // screener_func() => // ADX \\ adxTrendUp = diplus > diminus and sig >= sig[1] and sig < level and sig > diminus adxTrendUpStrong = diplus > diminus and sig >= sig[1] and sig >= level adxTrendUpFalling = diplus > diminus and sig < sig[1] and sig >= level adxTrendDown = diminus > diplus and sig > sig[1] and sig < level and sig > diplus adxTrendDownStrong = diminus > diplus and sig > sig[1] and sig >= level adxTrendDownFalling = diminus > diplus and sig <= sig[1] and sig >= level //ADX KICK adxKick = sig <= sig[1] and sig[1] >= sig[2] and sig >= level // Didi Index \\ // Alerts longaUp = DidiSlow > DidiSlow[1] longaNeutral = DidiSlow == DidiSlow[1] longaDown = DidiSlow < DidiSlow[1] curtaUp = DidiFast > DidiFast[1] curtaDown = DidiFast < DidiFast[1] alertaCompra = ta.crossover(DidiFast, 0) alertaVenda = ta.crossunder(DidiFast, 0) confirmaCompra = ta.crossunder(DidiSlow, 0) confirmaVenda = ta.crossover(DidiSlow, 0) alertVendaF = alertaVenda and DidiSlow < 0 and longaUp alertCompraF = alertaCompra and DidiSlow > 0 and longaDown alertVendaFC = DidiSlow < 0 and longaUp and DidiFast < 0 alertCompraFC = DidiSlow > 0 and longaDown and DidiFast < 0 // Fake long and short compraFalsa = alertaCompra and longaUp and DidiSlow > DidiFast vendaFalsa = alertaVenda and longaDown and DidiSlow < DidiFast // Needle conditions // Delta needles barAlertaCompra = ta.barssince(alertaCompra) barConfirmaCompra = ta.barssince(confirmaCompra) barAlertaVenda = ta.barssince(alertaVenda) barConfirmaVenda = ta.barssince(confirmaVenda) barNeedleCompra = barAlertaCompra + barConfirmaCompra + 1 barNeedleVenda = barAlertaVenda + barConfirmaVenda + 1 // Direction of needles didiComprado = DidiFast > 0 and DidiSlow < 0 didiVendido = DidiFast < 0 and DidiSlow > 0 // Needles agulhadaCompra = barNeedleCompra <= delta and barNeedleCompra >= 0 agulhadaVenda = barNeedleVenda <= delta and barNeedleVenda >= 0 // BJMA bjCompraMax = didiComprado and didiComprado[1] == true and curtaUp and longaDown and DidiFast <= deltaBJmax and (DidiSlow >= deltaBJmax - deltaBJmax * 2) bjCompraMin = didiComprado and didiComprado[1] == true and curtaUp and longaDown and DidiFast[1] <= deltaBJmin and (DidiSlow[1] >= deltaBJmin - deltaBJmin * 2) bjCompra = bjCompraMax and bjCompraMin bjVendaMax = didiVendido and didiVendido[1] == true and longaUp and curtaDown and DidiSlow <= deltaBJmax and (DidiFast >= deltaBJmax - deltaBJmax * 2) bjVendaMin = didiVendido and didiVendido[1] == true and longaUp and curtaDown and DidiSlow[1] <= deltaBJmin and (DidiFast[1] >= deltaBJmin - deltaBJmin * 2) bjVenda = bjVendaMax and bjVendaMin // Bollinger Bands \\ bbOpenUp = upper > upper[1] and lower < lower[1] and basis > basis[1] bbOpenDown = upper > upper[1] and lower < lower[1] and basis < basis[1] bbParallelUp = upper > upper[1] and (lower > lower[1] or lower == lower[1]) bbParallelDown = (upper < upper[1] or upper == upper[1]) and lower < lower[1] bbClose = upper <= upper[1] and lower >= lower[1] // Trix \\ trixUp = trix > maTrix trixDown = trix < maTrix // Stoch \\ stochDown = d > k stochUp = k > d // Sybmbol Screener \\ symbolDidi = switch (bbOpenUp or bbParallelUp) and (adxTrendUp or adxTrendUpStrong or adxTrendUpFalling) and agulhadaCompra and (agulhadaCompra[1] == false and didiComprado[1] == false) => "Needle Buy" (bbOpenDown or bbParallelDown) and (adxTrendDown or adxTrendDownStrong or adxTrendDownFalling) and agulhadaVenda and (agulhadaVenda[1] == false and didiVendido[1] == false) => "Needle Sell" (bbOpenUp or bbParallelUp) and (adxTrendUp or adxTrendUpStrong or adxTrendUpFalling) and bjCompra and (bjCompra[1] == false and agulhadaCompra[1] == false) => "BJMA Buy" (bbOpenDown or bbParallelDown) and (adxTrendDown or adxTrendDownStrong or adxTrendDownFalling) and bjVenda and (bjVenda[1] == false and agulhadaVenda[1] == false) => "BJMA Sell" (bbOpenUp or bbParallelUp) and (adxTrendUp or adxTrendUpStrong or adxTrendUpFalling) and (alertCompraF or alertCompraFC) => "Buy Alert" (bbOpenDown or bbParallelDown) and (adxTrendDown or adxTrendDownStrong or adxTrendDownFalling) and (alertVendaF or alertVendaFC) => "Sell Alert" (bbOpenUp or bbParallelUp) and (adxTrendUp or adxTrendUpStrong or adxTrendUpFalling) and didiComprado => "Bought" (bbOpenDown or bbParallelDown) and (adxTrendDown or adxTrendDownStrong or adxTrendDownFalling) and didiVendido => "Sold" bbClose and (adxKick or adxTrendUpFalling) and didiComprado and trixDown and stochDown => "Close Long" bbClose and (adxKick or adxTrendDownFalling) and didiVendido and trixUp and stochUp => "Close Short" (adxTrendDown or adxTrendDownStrong or adxTrendDownFalling) and (alertVendaF or alertVendaFC) => "Close Long - Sell Alert" (adxTrendUp or adxTrendUpStrong or adxTrendUpFalling) and (alertCompraF or alertCompraFC) => "Close Short - Buy Alert" vendaFalsa => "Fake Sell" compraFalsa => "Fake Buy" => "" // Didi Result Screener didi = switch // Alert alertCompraF => "Buy Alert" alertVendaF => "Sell Alert" // Needles agulhadaCompra => "Needle Buy" agulhadaVenda => "Needle Sell" // Side Didi didiComprado => "Bought" didiVendido => "Sold" // PF Didi vendaFalsa => "Fake Sell" compraFalsa =>"Fake Buy" => "" // Stoch Screener StochDidi = switch stochDown => "Sold" stochUp => "Bought" // Trix Screener trixdidi = switch trixUp => "Bought" trixDown => "Sold" // Bollinger Bands Screener bb = switch bbOpenUp => "Open Rising" bbOpenDown => "Open Falling" bbParallelUp => "Parallel Rising" bbParallelDown => "Parallel Falling" => "Close" // ADX Result Screener adxd = switch adxTrendUp => "Uptrend" adxTrendUpStrong => "Uptrend Strong" adxTrendUpFalling => "Uptrend Falling" adxTrendDown => "Downtrend" adxTrendDownStrong => "Downtrend Strong" adxTrendDownFalling => "Downtrend Falling" adxKick => "Kick ADX" [symbolDidi,adxd, didi, bb, trixdidi, StochDidi] // Security call [symboldidi01, adxd01, didi01, bb01, trixdidi01, stochDidi01] = request.security(s01, timeframe.period, screener_func()) [symboldidi02, adxd02, didi02, bb02, trixdidi02, stochDidi02] = request.security(s02, timeframe.period, screener_func()) [symboldidi03, adxd03, didi03, bb03, trixdidi03, stochDidi03] = request.security(s03, timeframe.period, screener_func()) [symboldidi04, adxd04, didi04, bb04, trixdidi04, stochDidi04] = request.security(s04, timeframe.period, screener_func()) [symboldidi05, adxd05, didi05, bb05, trixdidi05, stochDidi05] = request.security(s05, timeframe.period, screener_func()) [symboldidi06, adxd06, didi06, bb06, trixdidi06, stochDidi06] = request.security(s06, timeframe.period, screener_func()) [symboldidi07, adxd07, didi07, bb07, trixdidi07, stochDidi07] = request.security(s07, timeframe.period, screener_func()) [symboldidi08, adxd08, didi08, bb08, trixdidi08, stochDidi08] = request.security(s08, timeframe.period, screener_func()) [symboldidi09, adxd09, didi09, bb09, trixdidi09, stochDidi09] = request.security(s09, timeframe.period, screener_func()) [symboldidi10, adxd10, didi10, bb10, trixdidi10, stochDidi10] = request.security(s10, timeframe.period, screener_func()) [symboldidi11, adxd11, didi11, bb11, trixdidi11, stochDidi11] = request.security(s11, timeframe.period, screener_func()) [symboldidi12, adxd12, didi12, bb12, trixdidi12, stochDidi12] = request.security(s12, timeframe.period, screener_func()) [symboldidi13, adxd13, didi13, bb13, trixdidi13, stochDidi13] = request.security(s13, timeframe.period, screener_func()) [symboldidi14, adxd14, didi14, bb14, trixdidi14, stochDidi14] = request.security(s14, timeframe.period, screener_func()) [symboldidi15, adxd15, didi15, bb15, trixdidi15, stochDidi15] = request.security(s15, timeframe.period, screener_func()) [symboldidi16, adxd16, didi16, bb16, trixdidi16, stochDidi16] = request.security(s16, timeframe.period, screener_func()) [symboldidi17, adxd17, didi17, bb17, trixdidi17, stochDidi17] = request.security(s17, timeframe.period, screener_func()) [symboldidi18, adxd18, didi18, bb18, trixdidi18, stochDidi18] = request.security(s18, timeframe.period, screener_func()) [symboldidi19, adxd19, didi19, bb19, trixdidi19, stochDidi19] = request.security(s19, timeframe.period, screener_func()) [symboldidi20, adxd20, didi20, bb20, trixdidi20, stochDidi20] = request.security(s20, timeframe.period, screener_func()) [symboldidi21, adxd21, didi21, bb21, trixdidi21, stochDidi21] = request.security(s21, timeframe.period, screener_func()) [symboldidi22, adxd22, didi22, bb22, trixdidi22, stochDidi22] = request.security(s22, timeframe.period, screener_func()) [symboldidi23, adxd23, didi23, bb23, trixdidi23, stochDidi23] = request.security(s23, timeframe.period, screener_func()) [symboldidi24, adxd24, didi24, bb24, trixdidi24, stochDidi24] = request.security(s24, timeframe.period, screener_func()) [symboldidi25, adxd25, didi25, bb25, trixdidi25, stochDidi25] = request.security(s25, timeframe.period, screener_func()) [symboldidi26, adxd26, didi26, bb26, trixdidi26, stochDidi26] = request.security(s26, timeframe.period, screener_func()) [symboldidi27, adxd27, didi27, bb27, trixdidi27, stochDidi27] = request.security(s27, timeframe.period, screener_func()) [symboldidi28, adxd28, didi28, bb28, trixdidi28, stochDidi28] = request.security(s28, timeframe.period, screener_func()) [symboldidi29, adxd29, didi29, bb29, trixdidi29, stochDidi29] = request.security(s29, timeframe.period, screener_func()) [symboldidi30, adxd30, didi30, bb30, trixdidi30, stochDidi30] = request.security(s30, timeframe.period, screener_func()) [symboldidi31, adxd31, didi31, bb31, trixdidi31, stochDidi31] = request.security(s31, timeframe.period, screener_func()) [symboldidi32, adxd32, didi32, bb32, trixdidi32, stochDidi32] = request.security(s32, timeframe.period, screener_func()) [symboldidi33, adxd33, didi33, bb33, trixdidi33, stochDidi33] = request.security(s33, timeframe.period, screener_func()) [symboldidi34, adxd34, didi34, bb34, trixdidi34, stochDidi34] = request.security(s34, timeframe.period, screener_func()) [symboldidi35, adxd35, didi35, bb35, trixdidi35, stochDidi35] = request.security(s35, timeframe.period, screener_func()) [symboldidi36, adxd36, didi36, bb36, trixdidi36, stochDidi36] = request.security(s36, timeframe.period, screener_func()) [symboldidi37, adxd37, didi37, bb37, trixdidi37, stochDidi37] = request.security(s37, timeframe.period, screener_func()) [symboldidi38, adxd38, didi38, bb38, trixdidi38, stochDidi38] = request.security(s38, timeframe.period, screener_func()) [symboldidi39, adxd39, didi39, bb39, trixdidi39, stochDidi39] = request.security(s39, timeframe.period, screener_func()) [symboldidi40, adxd40, didi40, bb40, trixdidi40, stochDidi40] = request.security(s40, timeframe.period, screener_func()) //////////// // ARRAYS // p_arr = array.new_string(0) s_arr = array.new_string(0) u_arr = array.new_bool(0) rsi_arr = array.new_float(0) didi_arr = array.new_string(0) adxd_arr = array.new_string(0) bb_arr = array.new_string(0) trixdidi_arr = array.new_string(0) stocchdidi_arr = array.new_string(0) symboldidi_arr = array.new_string(0) // Add Prefix array.push(p_arr, only_prefix(s01)) array.push(p_arr, only_prefix(s02)) array.push(p_arr, only_prefix(s03)) array.push(p_arr, only_prefix(s04)) array.push(p_arr, only_prefix(s05)) array.push(p_arr, only_prefix(s06)) array.push(p_arr, only_prefix(s07)) array.push(p_arr, only_prefix(s08)) array.push(p_arr, only_prefix(s09)) array.push(p_arr, only_prefix(s10)) array.push(p_arr, only_prefix(s11)) array.push(p_arr, only_prefix(s12)) array.push(p_arr, only_prefix(s13)) array.push(p_arr, only_prefix(s14)) array.push(p_arr, only_prefix(s15)) array.push(p_arr, only_prefix(s16)) array.push(p_arr, only_prefix(s17)) array.push(p_arr, only_prefix(s18)) array.push(p_arr, only_prefix(s19)) array.push(p_arr, only_prefix(s20)) array.push(p_arr, only_prefix(s21)) array.push(p_arr, only_prefix(s22)) array.push(p_arr, only_prefix(s23)) array.push(p_arr, only_prefix(s24)) array.push(p_arr, only_prefix(s25)) array.push(p_arr, only_prefix(s26)) array.push(p_arr, only_prefix(s27)) array.push(p_arr, only_prefix(s28)) array.push(p_arr, only_prefix(s29)) array.push(p_arr, only_prefix(s30)) array.push(p_arr, only_prefix(s31)) array.push(p_arr, only_prefix(s32)) array.push(p_arr, only_prefix(s33)) array.push(p_arr, only_prefix(s34)) array.push(p_arr, only_prefix(s35)) array.push(p_arr, only_prefix(s36)) array.push(p_arr, only_prefix(s37)) array.push(p_arr, only_prefix(s38)) array.push(p_arr, only_prefix(s39)) array.push(p_arr, only_prefix(s40)) // Add Symbols array.push(s_arr, only_symbol(s01)) array.push(s_arr, only_symbol(s02)) array.push(s_arr, only_symbol(s03)) array.push(s_arr, only_symbol(s04)) array.push(s_arr, only_symbol(s05)) array.push(s_arr, only_symbol(s06)) array.push(s_arr, only_symbol(s07)) array.push(s_arr, only_symbol(s08)) array.push(s_arr, only_symbol(s09)) array.push(s_arr, only_symbol(s10)) array.push(s_arr, only_symbol(s11)) array.push(s_arr, only_symbol(s12)) array.push(s_arr, only_symbol(s13)) array.push(s_arr, only_symbol(s14)) array.push(s_arr, only_symbol(s15)) array.push(s_arr, only_symbol(s16)) array.push(s_arr, only_symbol(s17)) array.push(s_arr, only_symbol(s18)) array.push(s_arr, only_symbol(s19)) array.push(s_arr, only_symbol(s20)) array.push(s_arr, only_symbol(s21)) array.push(s_arr, only_symbol(s22)) array.push(s_arr, only_symbol(s23)) array.push(s_arr, only_symbol(s24)) array.push(s_arr, only_symbol(s25)) array.push(s_arr, only_symbol(s26)) array.push(s_arr, only_symbol(s27)) array.push(s_arr, only_symbol(s28)) array.push(s_arr, only_symbol(s29)) array.push(s_arr, only_symbol(s30)) array.push(s_arr, only_symbol(s31)) array.push(s_arr, only_symbol(s32)) array.push(s_arr, only_symbol(s33)) array.push(s_arr, only_symbol(s34)) array.push(s_arr, only_symbol(s35)) array.push(s_arr, only_symbol(s36)) array.push(s_arr, only_symbol(s37)) array.push(s_arr, only_symbol(s38)) array.push(s_arr, only_symbol(s39)) array.push(s_arr, only_symbol(s40)) // FLAGS array.push(u_arr, u01) array.push(u_arr, u02) array.push(u_arr, u03) array.push(u_arr, u04) array.push(u_arr, u05) array.push(u_arr, u06) array.push(u_arr, u07) array.push(u_arr, u08) array.push(u_arr, u09) array.push(u_arr, u10) array.push(u_arr, u11) array.push(u_arr, u12) array.push(u_arr, u13) array.push(u_arr, u14) array.push(u_arr, u15) array.push(u_arr, u16) array.push(u_arr, u17) array.push(u_arr, u18) array.push(u_arr, u19) array.push(u_arr, u20) array.push(u_arr, u21) array.push(u_arr, u22) array.push(u_arr, u23) array.push(u_arr, u24) array.push(u_arr, u25) array.push(u_arr, u26) array.push(u_arr, u27) array.push(u_arr, u28) array.push(u_arr, u29) array.push(u_arr, u30) array.push(u_arr, u31) array.push(u_arr, u32) array.push(u_arr, u33) array.push(u_arr, u34) array.push(u_arr, u35) array.push(u_arr, u36) array.push(u_arr, u37) array.push(u_arr, u38) array.push(u_arr, u39) array.push(u_arr, u40) // Symbol Color array.push(symboldidi_arr, symboldidi01) array.push(symboldidi_arr, symboldidi02) array.push(symboldidi_arr, symboldidi03) array.push(symboldidi_arr, symboldidi04) array.push(symboldidi_arr, symboldidi05) array.push(symboldidi_arr, symboldidi06) array.push(symboldidi_arr, symboldidi07) array.push(symboldidi_arr, symboldidi08) array.push(symboldidi_arr, symboldidi09) array.push(symboldidi_arr, symboldidi10) array.push(symboldidi_arr, symboldidi11) array.push(symboldidi_arr, symboldidi12) array.push(symboldidi_arr, symboldidi13) array.push(symboldidi_arr, symboldidi14) array.push(symboldidi_arr, symboldidi15) array.push(symboldidi_arr, symboldidi16) array.push(symboldidi_arr, symboldidi17) array.push(symboldidi_arr, symboldidi18) array.push(symboldidi_arr, symboldidi19) array.push(symboldidi_arr, symboldidi20) array.push(symboldidi_arr, symboldidi21) array.push(symboldidi_arr, symboldidi22) array.push(symboldidi_arr, symboldidi23) array.push(symboldidi_arr, symboldidi24) array.push(symboldidi_arr, symboldidi25) array.push(symboldidi_arr, symboldidi26) array.push(symboldidi_arr, symboldidi27) array.push(symboldidi_arr, symboldidi28) array.push(symboldidi_arr, symboldidi29) array.push(symboldidi_arr, symboldidi30) array.push(symboldidi_arr, symboldidi31) array.push(symboldidi_arr, symboldidi32) array.push(symboldidi_arr, symboldidi33) array.push(symboldidi_arr, symboldidi34) array.push(symboldidi_arr, symboldidi35) array.push(symboldidi_arr, symboldidi36) array.push(symboldidi_arr, symboldidi37) array.push(symboldidi_arr, symboldidi38) array.push(symboldidi_arr, symboldidi39) array.push(symboldidi_arr, symboldidi40) // ADX array.push(adxd_arr, adxd01) array.push(adxd_arr, adxd02) array.push(adxd_arr, adxd03) array.push(adxd_arr, adxd04) array.push(adxd_arr, adxd05) array.push(adxd_arr, adxd06) array.push(adxd_arr, adxd07) array.push(adxd_arr, adxd08) array.push(adxd_arr, adxd09) array.push(adxd_arr, adxd10) array.push(adxd_arr, adxd11) array.push(adxd_arr, adxd12) array.push(adxd_arr, adxd13) array.push(adxd_arr, adxd14) array.push(adxd_arr, adxd15) array.push(adxd_arr, adxd16) array.push(adxd_arr, adxd17) array.push(adxd_arr, adxd18) array.push(adxd_arr, adxd19) array.push(adxd_arr, adxd20) array.push(adxd_arr, adxd21) array.push(adxd_arr, adxd22) array.push(adxd_arr, adxd23) array.push(adxd_arr, adxd24) array.push(adxd_arr, adxd25) array.push(adxd_arr, adxd26) array.push(adxd_arr, adxd27) array.push(adxd_arr, adxd28) array.push(adxd_arr, adxd29) array.push(adxd_arr, adxd30) array.push(adxd_arr, adxd31) array.push(adxd_arr, adxd32) array.push(adxd_arr, adxd33) array.push(adxd_arr, adxd34) array.push(adxd_arr, adxd35) array.push(adxd_arr, adxd36) array.push(adxd_arr, adxd37) array.push(adxd_arr, adxd38) array.push(adxd_arr, adxd39) array.push(adxd_arr, adxd40) // Didi index array.push(didi_arr, didi01) array.push(didi_arr, didi02) array.push(didi_arr, didi03) array.push(didi_arr, didi04) array.push(didi_arr, didi05) array.push(didi_arr, didi06) array.push(didi_arr, didi07) array.push(didi_arr, didi08) array.push(didi_arr, didi09) array.push(didi_arr, didi10) array.push(didi_arr, didi11) array.push(didi_arr, didi12) array.push(didi_arr, didi13) array.push(didi_arr, didi14) array.push(didi_arr, didi15) array.push(didi_arr, didi16) array.push(didi_arr, didi17) array.push(didi_arr, didi18) array.push(didi_arr, didi19) array.push(didi_arr, didi20) array.push(didi_arr, didi21) array.push(didi_arr, didi22) array.push(didi_arr, didi23) array.push(didi_arr, didi24) array.push(didi_arr, didi25) array.push(didi_arr, didi26) array.push(didi_arr, didi27) array.push(didi_arr, didi28) array.push(didi_arr, didi29) array.push(didi_arr, didi30) array.push(didi_arr, didi31) array.push(didi_arr, didi32) array.push(didi_arr, didi33) array.push(didi_arr, didi34) array.push(didi_arr, didi35) array.push(didi_arr, didi36) array.push(didi_arr, didi37) array.push(didi_arr, didi38) array.push(didi_arr, didi39) array.push(didi_arr, didi40) // Bollinger Bands array.push(bb_arr, bb01) array.push(bb_arr, bb02) array.push(bb_arr, bb03) array.push(bb_arr, bb04) array.push(bb_arr, bb05) array.push(bb_arr, bb06) array.push(bb_arr, bb07) array.push(bb_arr, bb08) array.push(bb_arr, bb09) array.push(bb_arr, bb10) array.push(bb_arr, bb11) array.push(bb_arr, bb12) array.push(bb_arr, bb13) array.push(bb_arr, bb14) array.push(bb_arr, bb15) array.push(bb_arr, bb16) array.push(bb_arr, bb17) array.push(bb_arr, bb18) array.push(bb_arr, bb19) array.push(bb_arr, bb20) array.push(bb_arr, bb21) array.push(bb_arr, bb22) array.push(bb_arr, bb23) array.push(bb_arr, bb24) array.push(bb_arr, bb25) array.push(bb_arr, bb26) array.push(bb_arr, bb27) array.push(bb_arr, bb28) array.push(bb_arr, bb29) array.push(bb_arr, bb30) array.push(bb_arr, bb31) array.push(bb_arr, bb32) array.push(bb_arr, bb33) array.push(bb_arr, bb34) array.push(bb_arr, bb35) array.push(bb_arr, bb36) array.push(bb_arr, bb37) array.push(bb_arr, bb38) array.push(bb_arr, bb39) array.push(bb_arr, bb40) // Trix array.push(trixdidi_arr, trixdidi01) array.push(trixdidi_arr, trixdidi02) array.push(trixdidi_arr, trixdidi03) array.push(trixdidi_arr, trixdidi04) array.push(trixdidi_arr, trixdidi05) array.push(trixdidi_arr, trixdidi06) array.push(trixdidi_arr, trixdidi07) array.push(trixdidi_arr, trixdidi08) array.push(trixdidi_arr, trixdidi09) array.push(trixdidi_arr, trixdidi10) array.push(trixdidi_arr, trixdidi11) array.push(trixdidi_arr, trixdidi12) array.push(trixdidi_arr, trixdidi13) array.push(trixdidi_arr, trixdidi14) array.push(trixdidi_arr, trixdidi15) array.push(trixdidi_arr, trixdidi16) array.push(trixdidi_arr, trixdidi17) array.push(trixdidi_arr, trixdidi18) array.push(trixdidi_arr, trixdidi19) array.push(trixdidi_arr, trixdidi20) array.push(trixdidi_arr, trixdidi21) array.push(trixdidi_arr, trixdidi22) array.push(trixdidi_arr, trixdidi23) array.push(trixdidi_arr, trixdidi24) array.push(trixdidi_arr, trixdidi25) array.push(trixdidi_arr, trixdidi26) array.push(trixdidi_arr, trixdidi27) array.push(trixdidi_arr, trixdidi28) array.push(trixdidi_arr, trixdidi29) array.push(trixdidi_arr, trixdidi30) array.push(trixdidi_arr, trixdidi31) array.push(trixdidi_arr, trixdidi32) array.push(trixdidi_arr, trixdidi33) array.push(trixdidi_arr, trixdidi34) array.push(trixdidi_arr, trixdidi35) array.push(trixdidi_arr, trixdidi36) array.push(trixdidi_arr, trixdidi37) array.push(trixdidi_arr, trixdidi38) array.push(trixdidi_arr, trixdidi39) array.push(trixdidi_arr, trixdidi40) // Stoch array.push(stocchdidi_arr, stochDidi01) array.push(stocchdidi_arr, stochDidi02) array.push(stocchdidi_arr, stochDidi03) array.push(stocchdidi_arr, stochDidi04) array.push(stocchdidi_arr, stochDidi05) array.push(stocchdidi_arr, stochDidi06) array.push(stocchdidi_arr, stochDidi07) array.push(stocchdidi_arr, stochDidi08) array.push(stocchdidi_arr, stochDidi09) array.push(stocchdidi_arr, stochDidi10) array.push(stocchdidi_arr, stochDidi11) array.push(stocchdidi_arr, stochDidi12) array.push(stocchdidi_arr, stochDidi13) array.push(stocchdidi_arr, stochDidi14) array.push(stocchdidi_arr, stochDidi15) array.push(stocchdidi_arr, stochDidi16) array.push(stocchdidi_arr, stochDidi17) array.push(stocchdidi_arr, stochDidi18) array.push(stocchdidi_arr, stochDidi19) array.push(stocchdidi_arr, stochDidi20) array.push(stocchdidi_arr, stochDidi21) array.push(stocchdidi_arr, stochDidi22) array.push(stocchdidi_arr, stochDidi23) array.push(stocchdidi_arr, stochDidi24) array.push(stocchdidi_arr, stochDidi25) array.push(stocchdidi_arr, stochDidi26) array.push(stocchdidi_arr, stochDidi27) array.push(stocchdidi_arr, stochDidi28) array.push(stocchdidi_arr, stochDidi29) array.push(stocchdidi_arr, stochDidi30) array.push(stocchdidi_arr, stochDidi31) array.push(stocchdidi_arr, stochDidi32) array.push(stocchdidi_arr, stochDidi33) array.push(stocchdidi_arr, stochDidi34) array.push(stocchdidi_arr, stochDidi35) array.push(stocchdidi_arr, stochDidi36) array.push(stocchdidi_arr, stochDidi37) array.push(stocchdidi_arr, stochDidi38) array.push(stocchdidi_arr, stochDidi39) array.push(stocchdidi_arr, stochDidi40) /////////// // PLOTS // var tbl = table.new(position.bottom_right, 8, 41, frame_color=#151715, frame_width=1, border_width=1, border_color=color.new(color.white, 100)) if barstate.islast table.cell(tbl, 0, 0, 'Source', width = col_width, text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.normal) table.cell(tbl, 1, 0, 'Symbol', width = col_width, text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.normal) table.cell(tbl, 2, 0, 'ADX', width = col_width, text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.normal) table.cell(tbl, 3, 0, 'Didi', width = col_width, text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.normal) table.cell(tbl, 4, 0, 'BB', width = col_width, text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.normal) table.cell(tbl, 5, 0, 'Trix', width = col_width, text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.normal) table.cell(tbl, 6, 0, 'Stoch', width = col_width, text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.normal) if (scr_numb > 1) table.cell(tbl, 7, 0, '', width = col_width * 2 * (scr_numb - 1), text_halign = text.align_center, bgcolor = color.new(color.gray, 100), text_color = color.white, text_size = size.small) for i = 0 to 39 if array.get(u_arr, i) symboldidi_col = array.get(symboldidi_arr, i) == "Bought" ? bgLong1 : array.get(symboldidi_arr, i) == "Sold" ? bgShort1 : array.get(symboldidi_arr, i) == "Close Long" ? bgCloseLong : array.get(symboldidi_arr, i) == "Close Short" ? bgCloseShort : color.gray adxd_col = array.get(symboldidi_arr, i) == "Close Long" ? bgCloseLong : array.get(symboldidi_arr, i) == "Close Short" ? bgCloseShort : array.get(symboldidi_arr, i) == "Bought" ? bgLong1 : array.get(adxd_arr, i) == "Uptrend Strong" ? bgLong2 : array.get(adxd_arr, i) == "Uptrend" ? bgLong3 : array.get(adxd_arr, i) == "Uptrend Falling" ? bgLong4 : array.get(symboldidi_arr, i) == "Sold" ? bgShort1 : array.get(adxd_arr, i) == "Downtrend Strong" ? bgShort2 : array.get(adxd_arr, i) == "Downtrend" ? bgShort3 : array.get(adxd_arr, i) == "Downtrend Falling" ? bgShort4 : array.get(adxd_arr, i) == "Kick ADX" ? color.new(#aa2b2b, 0) : color.gray didi_col = array.get(symboldidi_arr, i) == "Bought" ? bgLong1 : array.get(symboldidi_arr, i) == "BJMA Buy" ? bgLong1 : array.get(symboldidi_arr, i) == "BJMA Sell" ? bgLong1 : array.get(didi_arr, i) == "Needle Buy" ? bgLong2 : array.get(didi_arr, i) == "Buy Alert" ? bgLong3 : array.get(didi_arr, i) == "Bought" ? bgLong5 : array.get(didi_arr, i) == "Fake Buy" ? bgLong4 : array.get(symboldidi_arr, i) == "Sold" ? bgShort1 : array.get(didi_arr, i) == "Sold" ? bgShort5 : array.get(didi_arr, i) == "Needle Sell" ? bgShort2 : array.get(didi_arr, i) == "Sell Alert" ? bgShort3 : array.get(didi_arr, i) == "Fake Sell" ? bgShort4 : color.gray bb_col = array.get(symboldidi_arr, i) == "Close Long" ? bgCloseLong : array.get(symboldidi_arr, i) == "Close Short" ? bgCloseShort : array.get(symboldidi_arr, i) == "Bought" ? bgLong1 : array.get(bb_arr, i) == "Open Rising" ? bgLong2 : array.get(bb_arr, i) == "Parallel Rising" ? bgLong3 : array.get(symboldidi_arr, i) == "Sold" ? bgShort1 : array.get(bb_arr, i) == "Open Falling" ? bgShort2 : array.get(bb_arr, i) == "Parallel Falling" ? bgShort3 : array.get(bb_arr, i) == "Close" ? color.new(#aa2b2b, 0) : color.gray trix_col = array.get(symboldidi_arr, i) == "Close Long" ? bgCloseLong : array.get(symboldidi_arr, i) == "Close Short" ? bgCloseShort : array.get(trixdidi_arr, i) == "Bought" ? bgLong3 : array.get(trixdidi_arr, i) == "Sold" ? bgShort3 : color.gray stoch_col = array.get(symboldidi_arr, i) == "Close Long" ? bgCloseLong : array.get(symboldidi_arr, i) == "Close Short" ? bgCloseShort : array.get(stocchdidi_arr, i) == "Bought" ? bgLong3 : array.get(stocchdidi_arr, i) == "Sold" ? bgShort3 : color.gray table.cell(tbl, 0, i + 1, array.get(p_arr, i), text_halign = text.align_center, bgcolor = color.gray, text_color = color.white, text_size = size.small) table.cell(tbl, 1, i + 1, array.get(s_arr, i), text_halign = text.align_center, bgcolor = symboldidi_col, text_color = color.white, text_size = size.small) table.cell(tbl, 2, i + 1, array.get(adxd_arr, i), text_halign = text.align_center, bgcolor = adxd_col, text_color = color.white, text_size = size.small) table.cell(tbl, 3, i + 1, array.get(didi_arr, i), text_halign = text.align_center, bgcolor = didi_col, text_color = color.white, text_size = size.small) table.cell(tbl, 4, i + 1, array.get(bb_arr, i), text_halign = text.align_center, bgcolor = bb_col, text_color = color.white, text_size = size.small) table.cell(tbl, 5, i + 1, array.get(trixdidi_arr, i), text_halign = text.align_center, bgcolor = trix_col, text_color = color.white, text_size = size.small) table.cell(tbl, 6, i + 1, array.get(stocchdidi_arr, i), text_halign = text.align_center, bgcolor = stoch_col, text_color = color.white, text_size = size.small)
Cosmic Markers Lite
https://www.tradingview.com/script/RNau1yK9-Cosmic-Markers-Lite/
cosmic_indicators
https://www.tradingview.com/u/cosmic_indicators/
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/ // Β© cosmic_indicators //@version=5 indicator('Cosmic Markers Lite', shorttitle='CM Lite', overlay=true) // -------------------------------------------------------------------------------- // Constants // -------------------------------------------------------------------------------- // Colors // ---------------------------------------- var blue_hex = #0d74ff var yellow_hex = #ffd900 // Periods // ---------------------------------------- len1 = 100 len2 = 250 len3 = 500 len4 = 750 len5 = 999 // -------------------------------------------------------------------------------- // Variables // -------------------------------------------------------------------------------- r_score = 0 s_score = 0 // -------------------------------------------------------------------------------- // Logic // -------------------------------------------------------------------------------- r_score += ta.highestbars(high, len1) == 0 ? 1 : 0 r_score += ta.highestbars(high, len2) == 0 ? 1 : 0 r_score += ta.highestbars(high, len3) == 0 ? 1 : 0 r_score += ta.highestbars(high, len4) == 0 ? 1 : 0 r_score += ta.highestbars(high, len5) == 0 ? 1 : 0 s_score += ta.lowestbars(low, len1) == 0 ? 1 : 0 s_score += ta.lowestbars(low, len2) == 0 ? 1 : 0 s_score += ta.lowestbars(low, len3) == 0 ? 1 : 0 s_score += ta.lowestbars(low, len4) == 0 ? 1 : 0 s_score += ta.lowestbars(low, len5) == 0 ? 1 : 0 // -------------------------------------------------------------------------------- // View // -------------------------------------------------------------------------------- // R // ---------------------------------------- plotshape(r_score == 1, style=shape.cross, location=location.abovebar, size=size.tiny, color=color.new(color.gray, 33)) plotshape(r_score == 2, style=shape.diamond, location=location.abovebar, size=size.tiny, color=color.new(color.gray, 20)) plotshape(r_score == 3, style=shape.diamond, location=location.abovebar, size=size.tiny, color=color.new(color.teal, 0)) plotshape(r_score == 4, style=shape.circle, location=location.abovebar, size=size.tiny, color=color.new(color.aqua, 10)) plotshape(r_score == 5, style=shape.circle, location=location.abovebar, size=size.tiny, color=color.new(blue_hex, 10)) // S // ---------------------------------------- plotshape(s_score == 1, style=shape.cross, location=location.belowbar, size=size.tiny, color=color.new(color.gray, 33)) plotshape(s_score == 2, style=shape.diamond, location=location.belowbar, size=size.tiny, color=color.new(color.gray, 15)) plotshape(s_score == 3, style=shape.diamond, location=location.belowbar, size=size.tiny, color=color.new(yellow_hex, 20)) plotshape(s_score == 4, style=shape.circle, location=location.belowbar, size=size.tiny, color=color.new(color.orange, 10)) plotshape(s_score == 5, style=shape.circle, location=location.belowbar, size=size.tiny, color=color.new(color.red, 10))
TheMas7er scalp (US equity) 5min [promuckaj]
https://www.tradingview.com/script/t81B3CEe-TheMas7er-scalp-US-equity-5min-promuckaj/
promuckaj
https://www.tradingview.com/u/promuckaj/
1,900
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© promuckaj //@version=5 indicator("DR/iDR TheMas7er scalp 5min [promuckaj]", shorttitle="DR/iDR TheMas7er scalp 5min [promuckaj]", overlay=true, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500) //v1.7 showMain = input(true,"Show main DR/iDR", group = "DR/iDR v1.7 by Promuckaj") TimeMain = input.session("0930-1030", "DR time range:", group = "DR/iDR v1.7 by Promuckaj", tooltip = "By default it is set to be used on 5min chart, so it means it is set to obtain last candle on 10:25. Consider this if you change time frame.") showEarly = input(true,"Show oDR/oiDR", group = "DR/iDR v1.7 by Promuckaj") TimeEarly = input.session("0300-0400", "oDR time range:", group = "DR/iDR v1.7 by Promuckaj",tooltip = "By default it is set to be used on 5min chart, so it means it is set to obtain last candle on 03:55. Consider this if you change time frame.") showADR = input(true,"Show aDR/aiDR", group = "DR/iDR v1.7 by Promuckaj") TimeADR = input.session("1930-2030", "aDR time range:", group = "DR/iDR v1.7 by Promuckaj",tooltip = "By default it is set to be used on 5min chart, so it means it is set to obtain last candle on 08:25 pm. Consider this if you change time frame.") showExtLines = input(true,"Show extended lines on session", group = "Customizations", tooltip = "Extended lines to the right will be visible till next DR sesion") showDRlabels = input(true,"Show DR labels", group = "Customizations") showDRtexts = input(true,"Show DR texts", group = "Customizations") mainColor = input.color(color.green,"High DR Color:", inline = "Main lines:", group = "Customizations") mainLebelTextCol = input.color(color.white,"Label Text color:", inline = "Main lines:", group = "Customizations") mainExtLinesStyle = input.string("Dashed","Ext. Style:", options=["Solid", "Dashed", "Dotted"],inline = "exMain lines:", group = "Customizations") mainExtLinesWidth = input.int(1,"Width:",inline = "exMain lines:", group = "Customizations") lmainColor = input.color(color.red,"Low DR Color:", inline = "lMain lines:", group = "Customizations") lmainLebelTextCol = input.color(color.white,"Label Text color:", inline = "lMain lines:", group = "Customizations") lmainExtLinesStyle = input.string("Dashed","Ext. Style:", options=["Solid", "Dashed", "Dotted"],inline = "lexMain lines:", group = "Customizations") lmainExtLinesWidth = input.int(1,"Width:",inline = "lexMain lines:", group = "Customizations") BoxiDR = input(false, "Apply box on iDR range instead on DR", group = "Customizations") BoxColor = input(color.rgb(0, 187, 212, 75),"Color of box", inline = "box", group = "Customizations") BoxColorDir = input(false, "Color box according to direction", inline = "box", group = "Customizations", tooltip = "This option will auto color the box according to open/close price of the range (green/red).") showFibo = input(true,"Show fibo levels according to DR (0.5 step)", tooltip = "It will be visible till next DR session",group = "Fibonacci levels") useDRforFibo = input(false, "Apply fibo levels to DR instead of iDR range") FiboColor = input(color.rgb(196, 196, 196),"Fibo lines Color:",inline = "Fibo lines:") FiboLineStyle = input.string("Solid","Style:", options=["Solid", "Dashed", "Dotted"],inline = "Fibo lines:") FiboLineWidth = input.int(1,"Width:",inline = "Fibo lines:") showBreaches = input(true,"Show labels for breaches of DR", group = "Breaches") BreachThreshold = input.float(0.0, "Threshold for breaches", group = "Breaches", tooltip = "This option will add threshold in % for breach of DR. It will affect breach alerts to.") BreachLabelColor1 = input.color(color.lime,"Colors:", inline = "breach color") BreachLabelColor2 = input.color(color.rgb(255, 0, 0),"", inline = "breach color") UseWick = input(false,"Use wick of candles for breaches the DR to") //Check TF for default values of ranges //DR if timeframe.period == "5" and TimeMain == "0930-1030" TimeMain := "0930-1025" if timeframe.period == "1" and TimeMain == "0930-1030" TimeMain := "0930-1029" if timeframe.period == "2" and TimeMain == "0930-1030" TimeMain := "0930-1028" if timeframe.period == "3" and TimeMain == "0930-1030" TimeMain := "0930-1027" if timeframe.period == "4" and TimeMain == "0930-1030" TimeMain := "0930-1026" if timeframe.period == "10" and TimeMain == "0930-1030" TimeMain := "0930-1020" if timeframe.period == "15" and TimeMain == "0930-1030" TimeMain := "0930-1015" if timeframe.period == "30" and TimeMain == "0930-1030" TimeMain := "0930-1000" //oDR if timeframe.period == "5" and TimeEarly == "0300-0400" TimeEarly := "0300-0355" if timeframe.period == "2" and TimeEarly == "0300-0400" TimeEarly := "0300-0358" if timeframe.period == "3" and TimeEarly == "0300-0400" TimeEarly := "0300-0357" if timeframe.period == "4" and TimeEarly == "0300-0400" TimeEarly := "0300-0356" if timeframe.period == "1" and TimeEarly == "0300-0400" TimeEarly := "0300-0359" if timeframe.period == "10" and TimeEarly == "0300-0400" TimeEarly := "0300-0350" if timeframe.period == "15" and TimeEarly == "0300-0400" TimeEarly := "0300-0345" if timeframe.period == "30" and TimeEarly == "0300-0400" TimeEarly := "0300-0330" //aDR if timeframe.period == "5" and TimeADR == "1930-2030" TimeADR := "1930-2025" if timeframe.period == "1" and TimeADR == "1930-2030" TimeADR := "1930-2029" if timeframe.period == "2" and TimeADR == "1930-2030" TimeADR := "1930-2028" if timeframe.period == "3" and TimeADR == "1930-2030" TimeADR := "1930-2027" if timeframe.period == "4" and TimeADR == "1930-2030" TimeADR := "1930-2026" if timeframe.period == "10" and TimeADR == "1930-2030" TimeADR := "1930-2020" if timeframe.period == "15" and TimeADR == "1930-2030" TimeADR := "1930-2015" if timeframe.period == "30" and TimeADR =="1930-2030" TimeADR := "1930-2000" ny = TimeMain + ":1234567" nye = TimeEarly + ":1234567" nya = TimeADR + ":1234567" mainLineS = line.style_solid if mainExtLinesStyle == "Solid" mainLineS := line.style_solid if mainExtLinesStyle == "Dashed" mainLineS := line.style_dashed if mainExtLinesStyle == "Dotted" mainLineS := line.style_dotted lmainLineS = line.style_solid if lmainExtLinesStyle == "Solid" lmainLineS := line.style_solid if lmainExtLinesStyle == "Dashed" lmainLineS := line.style_dashed if lmainExtLinesStyle == "Dotted" lmainLineS := line.style_dotted fibLineS = line.style_solid if FiboLineStyle == "Solid" fibLineS := line.style_solid if FiboLineStyle == "Dashed" fibLineS := line.style_dashed if FiboLineStyle == "Dotted" fibLineS := line.style_dotted is_newbar(sess) => t = time("D", sess, "America/New_York") na(t[1]) and not na(t) or t[1] < t is_session(sess) => not na(time(timeframe.period, sess, "America/New_York")) nyNewbar = is_newbar(ny) nySession = is_session(ny) nyeSession = is_session(nye) nyaSession = is_session(nya) var line DRhighE = na var line DRlowE = na var line IDRhighE = na var line IDRlowE = na var line eDRhighE = na var line eDRlowE = na var line eIDRhighE = na var line eIDRlowE = na var line Fibo05 = na var line Fibo15 = na var line Fibo2 = na var line Fibo25 = na var line Fibo3 = na var line Fibo35 = na var line Fibo4 = na var line Fibo45 = na var line Fibo5 = na var line Fibo55 = na var line Fibo6 = na var line FiboM05 = na var line FiboM1 = na var line FiboM15 = na var line FiboM2 = na var line FiboM25 = na var line FiboM3 = na var line FiboM35 = na var line FiboM4 = na var line FiboM45 = na var line FiboM5 = na var line FiboM55 = na var line FiboM6 = na var label Fibo05T = na var label Fibo15T = na var label Fibo2T = na var label Fibo25T = na var label Fibo3T = na var label Fibo35T = na var label Fibo4T = na var label Fibo45T = na var label Fibo5T = na var label Fibo55T = na var label Fibo6T = na var label FiboM05T = na var label FiboM1T = na var label FiboM15T = na var label FiboM2T = na var label FiboM25T = na var label FiboM3T = na var label FiboM35T = na var label FiboM4T = na var label FiboM45T = na var label FiboM5T = na var label FiboM55T = na var label FiboM6T = na var box drBox = na startBar = false endBar = false DRhighText = "" DRlowText = "" iDRhighText = "" iDRlowText = "" DRdirection = "UP" DRrangeL = "DR Range" iDRrangeL = "iDR Range" DRdirectionL = "DR Direction" DRcloseL = "DR close" DRopenL = "DR open" DRhighL = "DR high" DRlowL = "DR low" iDRhighL = "iDR high" iDRlowL = "iDR low" //Panel info showPanelInfo = input(true,"Show info panel",group="Panel with DR informations") showPanelRange = input(true,"Range", inline = "panel") showPanelDir = input(true,"Direction", inline = "panel") showPanelOC = input(true,"Open/Close", inline = "panel") showPanelHL = input(true,"High/Low", inline = "panel") showPanelBreach = input(true,"Breaches", inline = "panel") PanelColor1 = input.color(color.rgb(0, 0, 0),"Panel Color: ",inline="panel color") PanelColor2 = input.color(color.silver,"",inline="panel color") TextColor1 = input.color(color.rgb(255, 255, 255),"Text Color: ",inline="text color") TextColor2 = input.color(color.rgb(0, 0, 0),"",inline="text color") TablePos = input.string(title="Table Location", defval="Bottom Right",options=["Top Right", "Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center", "Top Left", "Middle Left", "Bottom Left"]) TableSize = input.string(title="Text Size", defval="Small",options=["Auto", "Normal", "Small", "Tiny"]) _tablePos= TablePos== "Top Right" ? position.top_right: TablePos== "Middle Right" ? position.middle_right: TablePos== "Bottom Right" ? position.bottom_right: TablePos== "Top Center" ? position.top_center: TablePos== "Middle Center"? position.middle_center: TablePos== "Bottom Center"? position.bottom_center: TablePos== "Top Left" ? position.top_left: TablePos== "Middle Left" ? position.middle_left:position.bottom_left panel_Pos= TablePos== "Top Right" ? position.top_right: TablePos== "Middle Right" ? position.middle_right: TablePos== "Bottom Right" ? position.bottom_right: TablePos== "Top Center" ? position.top_center: TablePos== "Middle Center"? position.middle_center: TablePos== "Bottom Center"? position.bottom_center: TablePos== "Top Left" ? position.top_left: TablePos== "Middle Left" ? position.middle_left:position.bottom_left panel_size= TableSize == "Auto" ? size.auto: TableSize == "Normal"? size.normal: TableSize == "Small"? size.small: size.tiny var table t = table.new(_tablePos, 2, 11, border_width = 1) //Alerts settings BreachAlert = input(true,"Sent alerts for breaches of DR", group = "Alerts settings", tooltip = "This will create alert message for every breaches of DR, it will include close price. All alert messages are developed as function call, so you just need to activate it as 'Any alert() function call'.") BreachBackAlert = input(true,"Sent alerts for breaches back to DR", tooltip = "This will create alert message for every breaches back to DR, it will include close price.") DRAlert = input(true, "Sent alert of DR range", inline = "dralert", tooltip = "This will sent all the data of DR range and values once DR is printed on the chart.") FiboAlerts = input(true, "+ fibo data", inline = "dralert", tooltip = " DR range alert include all values of DR range, once it is printed on the chart, but if this option is activated then fibo levels will be included in alert to.") //DR Calc if barstate.isconfirmed if nyeSession[1] == false and nyeSession and showEarly and nySession == false and nyaSession == false startBar := true else if nyeSession == false and nyeSession[1] and showEarly and nySession == false and nyaSession == false endBar := true DRhighText := "oDR high" DRlowText := "oDR low" iDRhighText := "oiDR high" iDRlowText := "oiDR low" DRrangeL := "oDR range" iDRrangeL := "oiDR Range" DRdirectionL := "oDR Direction" DRcloseL := "oDR close" DRopenL := "oDR open" DRhighL := "oDR high" DRlowL := "oDR low" iDRhighL := "oiDR high" iDRlowL := "oiDR low" if nySession[1] == false and nySession and showMain and nyeSession == false and nyaSession == false startBar := true else if nySession == false and nySession[1] and showMain and nyeSession == false and nyaSession == false endBar := true DRhighText := "DR high" DRlowText := "DR low" iDRhighText := "iDR high" iDRlowText := "iDR low" if nyaSession[1] == false and nyaSession and showADR and nySession == false and nyeSession == false startBar := true else if nyaSession == false and nyaSession[1] and showADR and nySession == false and nyeSession == false endBar := true DRhighText := "aDR high" DRlowText := "aDR low" iDRhighText := "aiDR high" iDRlowText := "aiDR low" DRrangeL := "aDR range" iDRrangeL := "aiDR Range" DRdirectionL := "aDR Direction" DRcloseL := "aDR close" DRopenL := "aDR open" DRhighL := "aDR high" DRlowL := "aDR low" iDRhighL := "aiDR high" iDRlowL := "aiDR low" FirstBar = ta.barssince(startBar) LastBar = ta.barssince(endBar)+1 var label StartingSessionLabel = na if startBar StartingSessionLabel := label.new(bar_index,high,text='',color=color.lime,style=label.style_circle,size = size.auto) if barstate.isconfirmed and endBar DRopen = open[FirstBar] DRclose = close HH = high LL = low HHidr = close LLidr = open if close > open HHidr := close LLidr := open else HHidr := open LLidr := close for i = 1 to FirstBar if high[i] > HH HH := high[i] if low[i] < LL LL := low[i] if close[i] > open[i] and close[i] > HHidr HHidr := close[i] if close[i] < open[i] and open[i] > HHidr HHidr := open[i] if close[i] > open[i] and open[i] < LLidr LLidr := open[i] if close[i] < open[i] and close[i] < LLidr LLidr := close[i] DRhigh = line.new(bar_index[FirstBar], HH,bar_index,HH,color=mainColor,style=line.style_solid,width=mainExtLinesWidth) DRlow = line.new(bar_index[FirstBar], LL,bar_index,LL,color=lmainColor,style=line.style_solid,width=lmainExtLinesWidth) IDRhigh = line.new(bar_index[FirstBar], HHidr,bar_index,HHidr,color=mainColor,style=line.style_dotted,width=mainExtLinesWidth) IDRlow = line.new(bar_index[FirstBar], LLidr,bar_index,LLidr,color=lmainColor,style=line.style_dotted,width=lmainExtLinesWidth) if showDRlabels DRhighLabel = label.new(bar_index[FirstBar],HH,text=DRhighText,size=size.small,color=mainColor,style=label.style_label_right,textcolor=mainLebelTextCol) DRlowLabel = label.new(bar_index[FirstBar],LL,text=DRlowText,size=size.small,color=lmainColor,style=label.style_label_right,textcolor=lmainLebelTextCol) if showDRlabels == false and showDRtexts DRhighLabelT = label.new(bar_index[FirstBar-5],HH,text=DRhighText,size=size.small,color=mainColor,style=label.style_none,textcolor=mainColor) DRlowLabelT = label.new(bar_index[FirstBar-5],LL,text=DRlowText,size=size.small,color=lmainColor,style=label.style_none,textcolor=lmainColor) if showDRtexts IDRhighLabel = label.new(bar_index[FirstBar+3],HHidr,text=iDRhighText,size=size.small,color=color.rgb(61, 61, 61),style=label.style_none,textcolor=mainColor) IDRlowLabel = label.new(bar_index[FirstBar+3],LLidr,text=iDRlowText,size=size.small,color=color.rgb(61, 61, 61),style=label.style_none,textcolor=lmainColor) if showExtLines DRhighE := line.new(bar_index[1], HH,bar_index,HH,extend = extend.right,color=mainColor,style=mainLineS,width=mainExtLinesWidth) DRlowE := line.new(bar_index[1], LL,bar_index,LL,extend = extend.right,color=lmainColor,style=lmainLineS,width=lmainExtLinesWidth) IDRhighE := line.new(bar_index[1], HHidr,bar_index,HHidr,extend = extend.right,color=mainColor,style=line.style_dotted,width=mainExtLinesWidth) IDRlowE := line.new(bar_index[1], LLidr,bar_index,LLidr,extend = extend.right,color=lmainColor,style=line.style_dotted,width=lmainExtLinesWidth) HfiboVal = HHidr LfiboVal = LLidr if useDRforFibo HfiboVal := HH LfiboVal := LL if showFibo Fibo05 := line.new(bar_index[1], (HfiboVal+LfiboVal)/2,bar_index,(HfiboVal+LfiboVal)/2,extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo15 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*0.5),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*0.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo2 := line.new(bar_index[1], HfiboVal + (HfiboVal-LfiboVal),bar_index,HfiboVal + (HfiboVal-LfiboVal),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo25 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*1.5),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*1.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo3 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*2),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*2),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo35 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*2.5),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*2.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo4 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*3),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*3),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo45 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*3.5),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*3.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo5 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*4),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*4),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo55 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*4.5),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*4.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) Fibo6 := line.new(bar_index[1], HfiboVal + ((HfiboVal-LfiboVal)*5),bar_index,HfiboVal + ((HfiboVal-LfiboVal)*5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM05 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*0.5),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*0.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM1 := line.new(bar_index[1], LfiboVal - (HfiboVal-LfiboVal),bar_index,LfiboVal - (HfiboVal-LfiboVal),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM15 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*1.5),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*1.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM2 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*2),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*2),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM25 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*2.5),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*2.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM3 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*3),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*3),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM35 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*3.5),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*3.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM4 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*4),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*4),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM45 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*4.5),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*4.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM5 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*5),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM55 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*5.5),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*5.5),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) FiboM6 := line.new(bar_index[1], LfiboVal - ((HfiboVal-LfiboVal)*6),bar_index,LfiboVal - ((HfiboVal-LfiboVal)*6),extend = extend.right,color=FiboColor,style=fibLineS,width=FiboLineWidth) fTextPos = bar_index[1] fTextXloc = xloc.bar_index //if FiboPosRight // fTextPos := time + 197 * (time - time[1]) // fTextXloc := xloc.bar_time Fibo05T := label.new(fTextPos, (HfiboVal+LfiboVal)/2, "0.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo15T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*0.5), "1.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo2T := label.new(fTextPos, HfiboVal + (HfiboVal-LfiboVal), "2", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo25T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*1.5), "2.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo3T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*2), "3", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo35T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*2.5), "3.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo4T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*3), "4", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo45T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*3.5), "4.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo5T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*4), "5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo55T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*4.5), "5.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) Fibo6T := label.new(fTextPos, HfiboVal + ((HfiboVal-LfiboVal)*5), "6", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM05T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*0.5), "-0.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM1T := label.new(fTextPos, LfiboVal - (HfiboVal-LfiboVal), "-1", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM15T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*1.5), "-1.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM2T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*2), "-2", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM25T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*2.5), "-2.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM3T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*3), "-3", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM35T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*3.5), "-3.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM4T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*4), "-4", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM45T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*4.5), "-4.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM5T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*5), "-5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM55T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*5.5), "-5.5", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) FiboM6T := label.new(fTextPos, LfiboVal - ((HfiboVal-LfiboVal)*6), "-6", xloc = fTextXloc, style = label.style_none,textcolor=FiboColor) DRperc = math.round((HH-LL)/(LL/100), 3) iDRperc = math.round((HHidr-LLidr)/(LLidr/100), 3) if DRopen > DRclose DRdirection := "DOWN" DRperc := math.round((HH-LL)/(HH/100), 3) iDRperc := math.round((HHidr-LLidr)/(HHidr/100), 3) if BoxColorDir if DRdirection == "UP" BoxColor := color.rgb(51, 148, 54, 75) else BoxColor := color.rgb(255, 66, 66, 75) if BoxiDR drBox := box.new(bar_index[FirstBar],HHidr,bar_index,LLidr,border_color = na,bgcolor = BoxColor) else drBox := box.new(bar_index[FirstBar],HH,bar_index,LL,border_color = na,bgcolor = BoxColor) if showPanelInfo if showPanelRange table.cell(t, 0, 0, DRrangeL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size,tooltip = "DR range") table.cell(t, 1, 0, str.tostring(DRperc) + " %", bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) if showPanelRange table.cell(t, 0, 1, iDRrangeL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 1, str.tostring(iDRperc) + " %", bgcolor = PanelColor2, text_size = panel_size, text_color =TextColor2) if showPanelDir table.cell(t, 0, 2, DRdirectionL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 2, DRdirection, bgcolor = PanelColor2, text_size = panel_size, text_color = DRdirection== "UP" ? color.rgb(51, 148, 54) : #ff0000) if showPanelOC table.cell(t, 0, 3, DRcloseL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 3, str.tostring(math.round(DRclose, 4)), bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) table.cell(t, 0, 4, DRopenL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 4, str.tostring(math.round(DRopen, 4)), bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) if showPanelHL table.cell(t, 0, 5, DRhighL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 5, str.tostring(math.round(HH, 4)), bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) table.cell(t, 0, 6, DRlowL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 6, str.tostring(math.round(LL, 4)), bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) if showPanelHL table.cell(t, 0, 7, iDRhighL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 7, str.tostring(math.round(HHidr, 4)), bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) table.cell(t, 0, 8, iDRlowL, bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 8, str.tostring(math.round(LLidr, 4)), bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) if DRAlert drMessage = DRhighText + ": " + str.tostring(math.round(HH, 4)) + " ; " + iDRhighText + ": " + str.tostring(math.round(HHidr, 4)) + " ; " + DRlowText + ": " + str.tostring(math.round(LL, 4)) + " ; " + iDRlowText + ": " + str.tostring(math.round(LLidr, 4)) + " ; " + DRrangeL + ": " + str.tostring(DRperc) + " % ; " + iDRrangeL + ": " + str.tostring(iDRperc) + " % ; " + DRopenL + ": " + str.tostring(math.round(DRopen, 4)) + " ; " + DRcloseL + ": " + str.tostring(math.round(DRclose, 4)) if FiboAlerts drMessage := drMessage + " ; 0.5 Fibo level: " + str.tostring((HfiboVal+LfiboVal)/2) + " ; Fibo levels UP: " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*0.5)) + " ; " + str.tostring(HfiboVal + (HfiboVal-LfiboVal)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*1.5)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*2)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*2.5)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*3)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*3.5)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*4)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*4.5)) + " ; " + str.tostring(HfiboVal + ((HfiboVal-LfiboVal)*5)) + " ; Fibo levels DOWN: " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*0.5)) + " ; " + str.tostring(LfiboVal - (HfiboVal-LfiboVal)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*1.5)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*2)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*2.5)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*3)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*3.5)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*4)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*4.5)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*5)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*5.5)) + " ; " + str.tostring(LfiboVal - ((HfiboVal-LfiboVal)*6)) dr_alert = drMessage alert(dr_alert,alert.freq_once_per_bar_close) //Clear if endBar label.delete(StartingSessionLabel[1]) if startBar //box.delete(drBox[1]) eDRhighE := line.copy(DRhighE[1]) eDRlowE := line.copy(DRlowE[1]) eIDRhighE := line.copy(IDRhighE[1]) eIDRlowE := line.copy(IDRlowE[1]) line.set_extend(eDRhighE,extend.none) line.set_extend(eDRlowE,extend.none) line.set_extend(eIDRhighE,extend.none) line.set_extend(eIDRlowE,extend.none) line.set_x2(eDRhighE,bar_index[1]) line.set_x2(eDRlowE,bar_index[1]) line.set_x2(eIDRhighE,bar_index[1]) line.set_x2(eIDRlowE,bar_index[1]) line.delete(DRhighE[1]) line.delete(DRlowE[1]) line.delete(IDRhighE[1]) line.delete(IDRlowE[1]) line.delete(Fibo05[1]) line.delete(Fibo15[1]) line.delete(Fibo2[1]) line.delete(Fibo25[1]) line.delete(Fibo3[1]) line.delete(Fibo35[1]) line.delete(Fibo4[1]) line.delete(Fibo45[1]) line.delete(Fibo5[1]) line.delete(Fibo55[1]) line.delete(Fibo6[1]) line.delete(FiboM05[1]) line.delete(FiboM1[1]) line.delete(FiboM15[1]) line.delete(FiboM2[1]) line.delete(FiboM25[1]) line.delete(FiboM3[1]) line.delete(FiboM35[1]) line.delete(FiboM4[1]) line.delete(FiboM45[1]) line.delete(FiboM5[1]) line.delete(FiboM55[1]) line.delete(FiboM6[1]) label.delete(Fibo05T[1]) label.delete(Fibo15T[1]) label.delete(Fibo2T[1]) label.delete(Fibo25T[1]) label.delete(Fibo3T[1]) label.delete(Fibo35T[1]) label.delete(Fibo4T[1]) label.delete(Fibo45T[1]) label.delete(Fibo5T[1]) label.delete(Fibo55T[1]) label.delete(Fibo6T[1]) label.delete(FiboM05T[1]) label.delete(FiboM1T[1]) label.delete(FiboM15T[1]) label.delete(FiboM2T[1]) label.delete(FiboM25T[1]) label.delete(FiboM3T[1]) label.delete(FiboM35T[1]) label.delete(FiboM4T[1]) label.delete(FiboM45T[1]) label.delete(FiboM5T[1]) label.delete(FiboM55T[1]) label.delete(FiboM6T[1]) //Breaches check UPLabel = false DOWNLabel = false BreachBackUP = false BreachBackDown = false BreachesUP = 0 BreachesDown = 0 BreachUPYes = "NO" BreachDownYes = "NO" if barstate.isconfirmed and nySession == false and nyaSession == false and nyeSession == false HHcheck = high[LastBar-1] LLcheck = low[LastBar-1] HHidrcheck = close[LastBar-1] LLidrcheck = open[LastBar-1] if close[LastBar-1] > open[LastBar-1] HHidrcheck := close[LastBar-1] LLidrcheck := open[LastBar-1] else HHidrcheck := open[LastBar-1] LLidrcheck := close[LastBar-1] for i = 0 to FirstBar-LastBar if high[LastBar+i] > HHcheck HHcheck := high[LastBar+i] if low[LastBar+i] < LLcheck LLcheck := low[LastBar+i] if close[LastBar+i] > open[LastBar+i] and close[LastBar+i] > HHidrcheck HHidrcheck := close[LastBar+i] if close[LastBar+i] < open[LastBar+i] and open[LastBar+i] > HHidrcheck HHidrcheck := open[LastBar+i] if close[LastBar+i] > open[LastBar+i] and open[LastBar+i] < LLidrcheck LLidrcheck := open[LastBar+i] if close[LastBar+i] < open[LastBar+i] and close[LastBar+i] < LLidrcheck LLidrcheck := close[LastBar+i] if UseWick if high > (HHcheck + ((HHcheck/100)*BreachThreshold)) and high[1] <= HHcheck UPLabel := true if low < (LLcheck - ((LLcheck/100)*BreachThreshold)) and low[1] >= LLcheck DOWNLabel := true else if close > (HHcheck + ((HHcheck/100)*BreachThreshold)) and close[1] <= HHcheck UPLabel := true if close < (LLcheck - ((LLcheck/100)*BreachThreshold)) and close[1] >= LLcheck DOWNLabel := true for i = 0 to LastBar if UseWick if high[i] > (HHcheck + ((HHcheck/100)*BreachThreshold)) and high[i+1] <= HHcheck BreachesUP := BreachesUP+1 if low[i] < (LLcheck - ((LLcheck/100)*BreachThreshold)) and low[i+1] >= LLcheck BreachesDown := BreachesDown+1 else if close[i] > (HHcheck + ((HHcheck/100)*BreachThreshold)) and close[i+1] <= HHcheck BreachesUP := BreachesUP+1 if close[i] < (LLcheck - ((LLcheck/100)*BreachThreshold)) and close[i+1] >= LLcheck BreachesDown := BreachesDown+1 if close < (HHcheck) and close[1] > HHcheck BreachBackUP := true if close > (LLcheck) and close[1] < LLcheck BreachBackDown := true plotshape(UPLabel and showBreaches ? close : na, title="Breach UP Label", text="", style=shape.triangleup, location=location.belowbar, color=BreachLabelColor1, textcolor=color.white) plotshape(DOWNLabel and showBreaches ? close : na, title="Breach DOWN Label", text="", style=shape.triangledown, location=location.abovebar, color=BreachLabelColor2, textcolor=color.white) if showPanelInfo and barstate.isconfirmed and showPanelBreach if BreachesUP > 0 BreachUPYes := "YES" if BreachesDown > 0 BreachDownYes := "YES" table.cell(t, 0, 9, "Breaches Up", bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 0, 10, "Breaches Down", bgcolor = PanelColor1, text_color = TextColor1, text_size = panel_size) table.cell(t, 1, 9, BreachUPYes + "(" + str.tostring(BreachesUP) + ")", bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) table.cell(t, 1, 10, BreachDownYes + "(" + str.tostring(BreachesDown) + ")", bgcolor = PanelColor2, text_size = panel_size, text_color = TextColor2) //---------Send breach alert to TV alarm sub-system----------------------------- BreachMessage = "Breach!! Close Price: " + str.tostring(close) BreachBackMessage = "Breach back!! Close Price: " + str.tostring(close) if UPLabel and BreachAlert BreachMessage := "Breach Up signal!! Close Price: " + str.tostring(close) up_alert = BreachMessage alert(up_alert,alert.freq_once_per_bar_close) if DOWNLabel and BreachAlert BreachMessage := "Breach Down signal!! Close Price: " + str.tostring(close) down_alert = BreachMessage alert(down_alert,alert.freq_once_per_bar_close) if BreachBackUP and BreachBackAlert BreachBackMessage := "Breach back from Up signal!! Close Price: " + str.tostring(close) upb_alert = BreachBackMessage alert(upb_alert,alert.freq_once_per_bar_close) if BreachBackDown and BreachBackAlert BreachBackMessage := "Breach back from Down signal!! Close Price: " + str.tostring(close) upd_alert = BreachBackMessage alert(upd_alert,alert.freq_once_per_bar_close) //------------------------------------------------------------------------------ //ADDITIONAL STUFF BY LuxAlgo // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // Β© LuxAlgo //All credits goes to LuxAlgo //------------OB---------------------------------------------------------------- //Settings //-----------------------------------------------------------------------------{ showLAOB = input(false,"Show order block finder by LuxAlgo",group = "ADDITIOANL - Order Block Finder by LuxAlgo") lalength = input.int(5, 'Volume Pivot Length', minval = 1) labull_ext_last = input.int(3, 'Bullish OB ', minval = 1, inline = 'bull') labg_bull_css = input.color(color.new(#64C4AC, 85), '', inline = 'bull') labull_css = input.color(#5db49e, '', inline = 'bull') labull_avg_css = input.color(color.new(#64C4AC, 15), '', inline = 'bull') labear_ext_last = input.int(3, 'Bearish OB', minval = 1, inline = 'bear') labg_bear_css = input.color(color.new(#506CD3, 85), '', inline = 'bear') labear_css = input.color(#4760bb, '', inline = 'bear') labear_avg_css = input.color(color.new(#506CD3, 15), '', inline = 'bear') laline_style = input.string('⎯⎯⎯', 'Average Line Style', options = ['⎯⎯⎯', '----', 'Β·Β·Β·Β·']) laline_width = input.int(1, 'Average Line Width', minval = 1) lamitigation = input.string('Wick', 'Mitigation Methods', options = ['Wick', 'Close']) //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ //Line Style function get_line_style(style) => out = switch style '⎯⎯⎯' => line.style_solid '----' => line.style_dashed 'Β·Β·Β·Β·' => line.style_dotted //Function to get order block coordinates get_coordinates(condition, top, btm, ob_val)=> var ob_top = array.new_float(0) var ob_btm = array.new_float(0) var ob_avg = array.new_float(0) var ob_left = array.new_int(0) float ob = na //Append coordinates to arrays if condition avg = math.avg(top, btm) array.unshift(ob_top, top) array.unshift(ob_btm, btm) array.unshift(ob_avg, avg) array.unshift(ob_left, time[lalength]) ob := ob_val [ob_top, ob_btm, ob_avg, ob_left, ob] //Function to remove mitigated order blocks from coordinate arrays remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=> mitigated = false target_array = bull ? ob_btm : ob_top for element in target_array obidx = array.indexof(target_array, element) if (bull ? target < element : target > element) mitigated := true array.remove(ob_top, obidx) array.remove(ob_btm, obidx) array.remove(ob_avg, obidx) array.remove(ob_left, obidx) mitigated //Function to set order blocks set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=> var ob_box = array.new_box(0) var ob_lvl = array.new_line(0) //Fill arrays with boxes/lines if barstate.isfirst and showLAOB for i = 0 to ext_last-1 array.unshift(ob_box, box.new(na,na,na,na, xloc = xloc.bar_time, extend= extend.right, bgcolor = bg_css, border_color = color.new(border_css, 70))) array.unshift(ob_lvl, line.new(na,na,na,na, xloc = xloc.bar_time, extend = extend.right, color = lvl_css, style = get_line_style(laline_style), width = laline_width)) //Set order blocks if barstate.islast and showLAOB if array.size(ob_top) > 0 for i = 0 to math.min(ext_last-1, array.size(ob_top)-1) get_box = array.get(ob_box, i) get_lvl = array.get(ob_lvl, i) box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i)) box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i)) line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i)) line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i)) //-----------------------------------------------------------------------------} //Global elements //-----------------------------------------------------------------------------{ var os = 0 var target_bull = 0. var target_bear = 0. n = bar_index upper = ta.highest(lalength) lower = ta.lowest(lalength) if lamitigation == 'Close' target_bull := ta.lowest(close, lalength) target_bear := ta.highest(close, lalength) else target_bull := lower target_bear := upper os := high[lalength] > upper ? 0 : low[lalength] < lower ? 1 : os[1] phv = ta.pivothigh(volume, lalength, lalength) //-----------------------------------------------------------------------------} //Get bullish/bearish order blocks coordinates //-----------------------------------------------------------------------------{ [bull_top, bull_btm, bull_avg, bull_left, bull_ob] = get_coordinates(phv and os == 1, hl2[lalength], low[lalength], low[lalength]) [bear_top, bear_btm, bear_avg, bear_left, bear_ob] = get_coordinates(phv and os == 0, high[lalength], hl2[lalength], high[lalength]) //-----------------------------------------------------------------------------} //Remove mitigated order blocks //-----------------------------------------------------------------------------{ mitigated_bull = remove_mitigated(bull_top, bull_btm, bull_left, bull_avg, target_bull, true) mitigated_bear = remove_mitigated(bear_top, bear_btm, bear_left, bear_avg, target_bear, false) //-----------------------------------------------------------------------------} //Display order blocks //-----------------------------------------------------------------------------{ //Set bullish order blocks set_order_blocks(bull_top, bull_btm, bull_left, bull_avg, labull_ext_last, labg_bull_css, labull_css, labull_avg_css) //Set bearish order blocks set_order_blocks(bear_top, bear_btm, bear_left, bear_avg, labear_ext_last, labg_bear_css, labear_css, labear_avg_css) //Show detected order blocks plot(showLAOB ? bull_ob : na, 'Bull OB', labull_css, 2, plot.style_linebr, offset = -lalength, display = display.none) plot(showLAOB ? bear_ob : na, 'Bear OB', labear_css, 2, plot.style_linebr, offset = -lalength, display = display.none) //------------------------------------------------------------------------------ //------------Fair Value Gap (FVG)---------------------------------------------- // atr settings ShowFVG = input(false,"Show FVG", group='ADDITIOANL - Fair Value Gap (FVG)') fvg_atrLength = input.int(28, 'ATR MA length', group = "General settings") fvg_atrMultiplier = input.float(1.5, 'ATR multiplier', group = "General settings") // box settings fvg_boxCount = input.int(5, 'Show last Boxes', minval=1, group='box') fvgupBoxColor = input.color(color.rgb(76, 175, 79, 70), 'Up color', group='box') fvgdownBoxColor = input.color(color.rgb(255, 82, 82, 70), 'Down color', group='box') fvg_shrinkBoxes = input(true, 'Shrink touched part of boxes', group='box') extendFVGboxes = input(true, "Extend boxes", group='box',inline = "extend") fvgNumbOfBars = input.int(20,"bars:", group='box', inline = "extend") showFVGlabel = input(true,"Show labels", group = "box", inline = "label") sizeFVGlabel = input.string("Normal",", size:", options = ["Normal","Small","Large","Tiny","Auto"], group = "box", inline = "label") fvgLsize = size.normal if sizeFVGlabel == "Small" fvgLsize := size.small if sizeFVGlabel == "Large" fvgLsize := size.large if sizeFVGlabel == "Tiny" fvgLsize := size.tiny if sizeFVGlabel == "Auto" fvgLsize := size.auto var fvgboxArray = array.new_box() fvg_isUpCandle(_index) => open[_index] <= close[_index] fvg_isFairValueGap() => bool fvgbearCondition = close[3] <= high[2] and close[1] <= close[2] and high < low[2] bool fvgbullCondition = close[3] >= low[2] and close[1] >= close[2] and low > high[2] fvgpriceDiff = high[1] - low[1] fvgatrValue = ta.atr(fvg_atrLength) bool fvgmiddleCandleVolatilityCondition = fvgpriceDiff > fvgatrValue * fvg_atrMultiplier bool fvgisUpCandle = fvg_isUpCandle(1) bool fvgisGapClosed = fvgisUpCandle ? high[2] >= low : low[2] <= high [fvgisGapClosed, fvgbearCondition, fvgbullCondition, fvgmiddleCandleVolatilityCondition] fvg_extendArray(_boxArray) => if array.size(_boxArray) > 0 and ShowFVG for i = array.size(_boxArray) - 1 to 0 by 1 boxToExtend = array.get(_boxArray, i) fvgbottom = box.get_bottom(boxToExtend) fvgtop = box.get_top(boxToExtend) fvgright = box.get_right(boxToExtend) box.set_right(array.get(_boxArray, i), extendFVGboxes ? bar_index + fvgNumbOfBars : bar_index) if showFVGlabel box.set_text(array.get(_boxArray, i),"FVG") box.set_text_color(array.get(_boxArray, i),color.silver) box.set_text_halign(array.get(_boxArray, i),text.align_right) box.set_text_size(array.get(_boxArray, i),fvgLsize) fvghasClosed = (open <= fvgbottom and high > fvgbottom and high >= fvgtop or open >= fvgtop and low < fvgtop and low <= fvgbottom) if fvg_shrinkBoxes and open >= fvgtop and low < fvgtop and low > fvgbottom and ShowFVG box.set_top(array.get(_boxArray, i), low) if fvg_shrinkBoxes and open <= fvgbottom and high > fvgbottom and high < fvgtop and ShowFVG box.set_bottom(array.get(_boxArray, i), high) if fvg_shrinkBoxes and fvghasClosed and ShowFVG box.delete(array.get(_boxArray, i)) array.remove(fvgboxArray, i) [fvgisGapClosed, fvgbearCondition, fvgbullCondition, fvgmiddleCandleVolatilityCondition] = fvg_isFairValueGap() bool fvgisFairValueGap = false fvgisFairValueGap := (fvgbearCondition or fvgbullCondition) and not fvgisGapClosed and fvgmiddleCandleVolatilityCondition and not fvgisFairValueGap[1] if fvgisFairValueGap and ShowFVG fvgisUpCandle = fvg_isUpCandle(1) fvgtop = fvgisUpCandle ? low : low[2] fvgbottom = fvgisUpCandle ? high[2] : high fvgBox = box.new(bar_index[1], fvgtop, bar_index, fvgbottom, bgcolor=fvgisUpCandle ? fvgupBoxColor : fvgdownBoxColor, border_style=line.style_dashed, border_color=fvgisUpCandle ? fvgupBoxColor : fvgdownBoxColor, xloc=xloc.bar_index) if array.size(fvgboxArray) >= fvg_boxCount box.delete(array.shift(fvgboxArray)) array.push(fvgboxArray, fvgBox) fvg_extendArray(fvgboxArray) //----------------------------------------------------------------------------------------------------
GIRISH indicator
https://www.tradingview.com/script/Vyt7b1n2-GIRISH-indicator/
email_analysts
https://www.tradingview.com/u/email_analysts/
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/ // Β© email_analysts //@version=5 indicator("GIRISH indicator") var cumVol = 0. cumVol += nz(volume) if barstate.islast and cumVol == 0 runtime.error("No volume is provided by the data vendor.") computeVWAP(src, isNewPeriod) => var float sumSrcVol = na var float sumVol = na var float sumSrcSrcVol = na sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1] sumVol := isNewPeriod ? volume : volume + sumVol[1] // sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation sumSrcSrcVol := isNewPeriod ? volume * math.pow(src, 2) : volume * math.pow(src, 2) + sumSrcSrcVol[1] _vwap = sumSrcVol / sumVol variance = sumSrcSrcVol / sumVol - math.pow(_vwap, 2) variance := variance < 0 ? 0 : variance stDev = math.sqrt(variance) [_vwap, stDev] hideonDWM = input(false, title="Hide VWAP on 1D or Above", group="VWAP Settings") var anchor = input.string(defval = "Session", title="Anchor Period", options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings") src1 = input(title = "Source", defval = hlc3, group="VWAP Settings") offset = input(0, title="Offset", group="VWAP Settings") timeChange(period) => ta.change(time(period)) new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) isNewPeriod = switch anchor "Earnings" => not na(new_earnings) "Dividends" => not na(new_dividends) "Splits" => not na(new_split) "Session" => timeChange("D") "Week" => timeChange("W") "Month" => timeChange("M") "Quarter" => timeChange("3M") "Year" => timeChange("12M") "Decade" => timeChange("12M") and year % 10 == 0 "Century" => timeChange("12M") and year % 100 == 0 => false isEsdAnchor = anchor == "Earnings" or anchor == "Dividends" or anchor == "Splits" if na(src1[1]) and not isEsdAnchor isNewPeriod := true float vw = na if not (hideonDWM and timeframe.isdwm) [_vwap, _stdev] = computeVWAP(src1, isNewPeriod) vw := _vwap bar = -(vw-close)*10000/close len6 = input.int(5, "GH Smooth", minval=1) bar1 = ta.ema(bar, len6) hlineup = hline(40, color=#ffffff) hlinemid = hline(0, color=#ffffff) hlinelow = hline(-40, color=#ffffff) plot(bar1, color = color.white, style=plot.style_line, linewidth = 1, title="GH") //////////////////////////////// len1 = input(title="OBV Length 1", defval = 3) len2 = input(title="OBV Length 2", defval = 21) ema1 = ta.ema(ta.obv, len1) ema2 = ta.ema(ta.obv, len2) obv=ema1-ema2 len3 = input(title="RSI Length 1", defval = 5) len4 = input(title="RSI Length 2", defval = 9) len5 = input(title="RSI Length 3", defval = 14) sh = ta.rsi(close, len3) sh9 = ta.rsi(close, len4) ln = ta.ema(sh9, len5) rsi = sh-ln backgroundColor = obv >0 and rsi > 0 and vw-close > close/500 ? color.rgb(51, 100, 52): obv >0 and rsi > 0 ? color.rgb(64, 161, 65): obv < 0 and rsi < 0 and close-vw > close/500 ? color.rgb(146, 44, 44): obv < 0 and rsi < 0 ? color.rgb(209, 110, 110, 25): na bgcolor(color=backgroundColor, transp=100)
x-Period ROI by USCG_Vet
https://www.tradingview.com/script/R4niMM4L-x-Period-ROI-by-USCG-Vet/
USCG_Vet
https://www.tradingview.com/u/USCG_Vet/
10
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Written by USCG_Vet; All credit to Trace Mayer. Notice, this indicator is for educational purposes only and is not financial advice. //@version=5 indicator(title='x-Day ROI by USCG_Vet', overlay=false) HiOrLow = input(title='high vs low vs avg', defval='high') nPeriods = input(title='Number of Periods', defval=365) n1 = high[1] // this is end period n365 = high[nPeriods] // this is begin period if HiOrLow == 'high' n1 := high[1] n1 else if HiOrLow == 'low' n1 := low[1] n1 else n1 := high[1] + low[1] / 2 n1 if HiOrLow == 'high' n365 := high[nPeriods] n365 else if HiOrLow == 'low' n365 := low[nPeriods] n365 else n365 := high[nPeriods] + low[nPeriods] / 2 n365 ROI = (n1 - n365) / n1 // calculate the ROI between end period and begin period topCol = color.orange plot(ROI, color=color.new(topCol, 0), linewidth=1)
Future Pivots CPR - All Timeframes
https://www.tradingview.com/script/6vwBWn34-Future-Pivots-CPR-All-Timeframes/
TonioVolcano
https://www.tradingview.com/u/TonioVolcano/
336
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© TonioVolcano //Simple idea that allows you to display tomorrow CPR based on the high, low and close of today session. Likewise, it works for higher timeframes taking into account the high, low, close of the period (e.g. weekly, monthly, year). Just be aware that -regardless of the timeframe- if the period is still in development, the indicator will constantly/ live update the values untill the period is closed!! This indicator is meant to be used when preparing for the next trading period. If you want to use it live, I'd suggest using the function of this indicator which allows to display only current/closed pivots- //Similar to other script I publiushed, this indicator lower timeframes (Daily and Weekly) will work with lower timeframe bars, this is the Minutes and Hour bars. Conversely, higher timeframe CPR/Pivots will work better with timeframes/charts from Daily and above. //@version=5 indicator('Future Pivots CPR - All Timeframes', shorttitle='Future Pivots', overlay=true) // User inputs tf1 = input.timeframe(defval='D', title='Timeframe', options=['D', 'W', 'M', '12M']) showToday = input(defval=false, title='Show today\'s CPR') showTomorrowCPR = input(defval=true, title='Show tomorrow\'s CPR') showHistoricalCPR = input(defval=false, title='Show historical CPR') showR3S3 = input(defval=false, title='Show R2-3 & S2-3') cprColor = input.color(defval = color.white, title = 'Color current CPR') cprColorY = input.color(defval = color.green, title = 'Color past/future CPR') // Defaults highs = high lows = low pivot = hlc3 top = hl2 // Location of label and Line for Current Pivots var cpb = 0 var ppb = 0 if tf1 == 'D' and hour < hour[1] ppb := cpb cpb := 1 cpb if tf1 == 'D' and hour >= hour[1] cpb := cpb + 1 cpb if tf1 == 'W' and dayofweek < dayofweek[1] ppb := cpb cpb := 1 cpb if tf1 == 'W' and dayofweek >= dayofweek[1] cpb := cpb + 1 cpb if tf1 == 'M' and dayofmonth < dayofmonth[1] ppb := cpb cpb := 1 cpb if tf1 == 'M' and dayofmonth >= dayofmonth[1] cpb := cpb + 1 cpb if tf1 == '12M' and month < month[1] ppb := cpb cpb := 1 cpb if tf1 == '12M' and month >= month[1] cpb := cpb + 1 cpb // Location of label for Tomorrow Pivots tomstart = time_close // Calculate Today's CPR calcclose = request.security(syminfo.tickerid, tf1, close[1], barmerge.gaps_off, barmerge.lookahead_on) calchigh = request.security(syminfo.tickerid, tf1, highs[1], barmerge.gaps_off, barmerge.lookahead_on) calclow = request.security(syminfo.tickerid, tf1, lows[1], barmerge.gaps_off, barmerge.lookahead_on) calcpivot = math.round(request.security(syminfo.tickerid, tf1, pivot[1], barmerge.gaps_off, barmerge.lookahead_on), 2) calcbott = math.round(request.security(syminfo.tickerid, tf1, top[1], barmerge.gaps_off, barmerge.lookahead_on), 2) calctop = math.round((calcpivot - calcbott) + calcpivot, 2) // Resistance Levels R1 = math.round((calcpivot * 2) - calclow, 2) R2 = math.round(calcpivot + (calchigh - calclow), 2) R3 = math.round(R1 + (calchigh - calclow), 2) // Support Levels S1 = math.round((calcpivot * 2) - calchigh, 2) S2 = math.round(calcpivot - (calchigh - calclow), 2) S3 = math.round(S1 - (calchigh - calclow), 2) // Plot Today's CPR if showToday if showR3S3 _r3 = line.new(bar_index[cpb], R3, bar_index, R3, xloc.bar_index, color=cprColor) line.delete(_r3[1]) _r2 = line.new(bar_index[cpb], R2, bar_index, R2, xloc.bar_index, color=cprColor) line.delete(_r2[1]) _r1 = line.new(bar_index[cpb], R1, bar_index, R1, xloc.bar_index, color=cprColor) line.delete(_r1[1]) _tc = line.new(bar_index[cpb], calctop, bar_index, calctop, xloc.bar_index, color=cprColor) line.delete(_tc[1]) _p = line.new(bar_index[cpb], calcpivot, bar_index, calcpivot, xloc.bar_index, color=cprColor) line.delete(_p[1]) _bc = line.new(bar_index[cpb], calcbott, bar_index, calcbott, xloc.bar_index, color=cprColor) line.delete(_bc[1]) _s1 = line.new(bar_index[cpb], S1, bar_index, S1, xloc.bar_index, color=cprColor) line.delete(_s1[1]) if showR3S3 _s2 = line.new(bar_index[cpb], S2, bar_index, S2, xloc.bar_index, color=cprColor) line.delete(_s2[1]) _s3 = line.new(bar_index[cpb], S3, bar_index, S3, xloc.bar_index, color=cprColor) line.delete(_s3[1]) // Plot Today's Labels if showToday if showR3S3 l_r3 = label.new(bar_index[cpb], R3, text='R3', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_r3[1]) l_r2 = label.new(bar_index[cpb], R2, text='R2', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_r2[1]) l_r1 = label.new(bar_index[cpb], R1, text='R1', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_r1[1]) l_tc = label.new(bar_index[cpb], calctop, text='__', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_tc[1]) l_p = label.new(bar_index[cpb], calcpivot, text='[P]', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_p[1]) l_bc = label.new(bar_index[cpb], calcbott, text='__', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_bc[1]) l_s1 = label.new(bar_index[cpb], S1, text='S1', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_s1[1]) if showR3S3 l_s2 = label.new(bar_index[cpb], S2, text='S2', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_s2[1]) l_s3 = label.new(bar_index[cpb], S3, text='S3', xloc=xloc.bar_index, textcolor=cprColor, style=label.style_none) label.delete(l_s3[1]) // Calculate Tomorrow's CPR Tcalchigh = request.security(syminfo.tickerid, tf1, highs[0], barmerge.gaps_off, barmerge.lookahead_on) Tcalclow = request.security(syminfo.tickerid, tf1, lows[0], barmerge.gaps_off, barmerge.lookahead_on) Tcalcpivot = math.round(request.security(syminfo.tickerid, tf1, pivot[0], barmerge.gaps_off, barmerge.lookahead_on), 2) Tcalcbott = math.round(request.security(syminfo.tickerid, tf1, top[0], barmerge.gaps_off, barmerge.lookahead_on), 2) Tcalctop = math.round((Tcalcpivot - Tcalcbott) + Tcalcpivot, 2) // Resistance Levels tR1 = math.round((Tcalcpivot * 2) - Tcalclow, 2) tR2 = math.round(Tcalcpivot + (Tcalchigh - Tcalclow), 2) tR3 = math.round(tR1 + (Tcalchigh - Tcalclow), 2) // Support Levels tS1 = math.round((Tcalcpivot * 2) - Tcalchigh, 2) tS2 = math.round(Tcalcpivot - (Tcalchigh - Tcalclow), 2) tS3 = math.round(tS1 - (Tcalchigh - Tcalclow), 2) // Plot Tomorrow's Labels if showTomorrowCPR if showR3S3 l_t_r3 = label.new(tomstart, tR3, text='R3', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(tR3))) label.delete(l_t_r3[1]) l_t_r2 = label.new(tomstart, tR2, text='R2', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(tR2))) label.delete(l_t_r2[1]) l_t_r1 = label.new(tomstart, tR1, text='R1', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(tR1))) label.delete(l_t_r1[1]) l_t_tc = label.new(tomstart, Tcalctop, text='__', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(Tcalctop))) label.delete(l_t_tc[1]) l_t_p = label.new(tomstart, Tcalcpivot, text='[P]', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(Tcalcpivot))) label.delete(l_t_p[1]) l_t_bc = label.new(tomstart, Tcalcbott, text='__', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(Tcalcbott))) label.delete(l_t_bc[1]) l_t_s1 = label.new(tomstart, tS1, text='S1', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(tS1))) label.delete(l_t_s1[1]) if showR3S3 l_t_s2 = label.new(tomstart, tS2, text='S2', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(tS2))) label.delete(l_t_s2[1]) l_t_s3 = label.new(tomstart, tS3, text='S3', xloc=xloc.bar_time, textcolor=cprColorY, style=label.style_none, tooltip=str.tostring(float(tS3))) label.delete(l_t_s3[1]) p_cprTC = plot(showHistoricalCPR ? calctop : na, title=' TC', color=cprColorY, style= plot.style_circles) p_cprP = plot(showHistoricalCPR ? calcpivot : na, title='[P]', color=cprColorY, style= plot.style_circles) p_cprBC = plot(showHistoricalCPR ? calcbott : na, title=' BC', color=cprColorY, style= plot.style_circles)
1-2-3 Pattern (Expo)
https://www.tradingview.com/script/mb9GOCMz-1-2-3-Pattern-Expo/
Zeiierman
https://www.tradingview.com/u/Zeiierman/
3,252
study
5
CC-BY-NC-SA-4.0
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // Β© Zeiierman //@version=5 indicator("1-2-3 Pattern (Expo)",overlay=true,max_bars_back=5000,max_labels_count=500,max_lines_count=500) // ~~ ToolTips { t1 = "Pivot period" t2 = "Show pattern break, set the size, and coloring" t3 = "Show the 1-2-3 Pattern" t4 = "Enable the HH/HL/LL/LH labels" // ~~} // ~~ Inputs { prd = input.int(10,title="Period",tooltip=t1) showBreak = input.bool(true,"Show Break", inline="break") showPattern = input.bool(true,"Show Pattern",tooltip=t3) showPvts = input.bool(false,"Show Pivots",tooltip=t4) visuell = input.string("Diamond","",options=["Diamond","XCross","Cross","Flag","Square"],inline="break") colBull = input.color(color.new(#31be0c,0),"",inline="break") colBear = input.color(color.new(#df3d3d,0),"",inline="break") size = input.string(size.tiny,"",options=[size.tiny,size.small,size.normal,size.large,size.huge],inline="break",tooltip=t2) shape = switch visuell "Diamond" => label.style_diamond "XCross" => label.style_xcross "Cross" => label.style_cross "Flag" => label.style_flag "Square" => label.style_square // ~~ } // ~~ Arrays { var pvts = array.new<float>(3,0.0) var idx = array.new<int>(3,0) // ~~ } // ~~ Pivots { pvtHi = ta.pivothigh(high,prd,prd) pvtLo = ta.pivotlow(low,prd,prd) var pos = 0 if not na(pvtHi) and pos<=0 if showPvts label.new(bar_index-prd,high[prd],text=pvtHi>array.get(pvts,1)?"HH":"LH",style=label.style_label_down,color=color(na),textcolor=chart.fg_color) array.pop(pvts) array.pop(idx) array.unshift(pvts,high[prd]) array.unshift(idx,bar_index-prd) pos := 1 if not na(pvtLo) and pos>=0 if showPvts label.new(bar_index-prd,low[prd],text=pvtLo>array.get(pvts,1)?"HL":"LL",style=label.style_label_up,color=color(na),textcolor=chart.fg_color) array.pop(pvts) array.pop(idx) array.unshift(pvts,low[prd]) array.unshift(idx,bar_index-prd) pos := -1 // ~~ } // ~~ Identify 1-2-3 Pattern & Alerts { var pattern = true if ta.crossover(high,array.get(pvts,1)) and pattern if array.get(pvts,0)>array.get(pvts,2) and array.get(pvts,0)<array.get(pvts,1) if showBreak label.new(bar_index,high,style=shape,color=colBull,size=size) line.new(array.get(idx,1),array.get(pvts,1),bar_index,array.get(pvts,1),color=chart.fg_color,style=line.style_dashed) if showPattern label.new(array.get(idx,2),array.get(pvts,2),text="1",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) label.new(array.get(idx,1),array.get(pvts,1),text="2",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) label.new(array.get(idx,0),array.get(pvts,0),text="3",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) line.new(array.get(idx,2),array.get(pvts,2),array.get(idx,1),array.get(pvts,1),color=chart.fg_color) line.new(array.get(idx,1),array.get(pvts,1),array.get(idx,0),array.get(pvts,0),color=chart.fg_color) alert("Bullish 1-2-3 Pattern Identified on: "+syminfo.ticker,alert.freq_once_per_bar_close) pattern := false if ta.crossunder(low,array.get(pvts,1)) and pattern if array.get(pvts,0)<array.get(pvts,2) and array.get(pvts,0)>array.get(pvts,1) if showBreak label.new(bar_index,low,style=shape,color=colBear,size=size) line.new(array.get(idx,1),array.get(pvts,1),bar_index,array.get(pvts,1),color=chart.fg_color,style=line.style_dashed) if showPattern label.new(array.get(idx,2),array.get(pvts,2),text="1",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) label.new(array.get(idx,1),array.get(pvts,1),text="2",color=color(na),textcolor=chart.fg_color,style=label.style_label_up) label.new(array.get(idx,0),array.get(pvts,0),text="3",color=color(na),textcolor=chart.fg_color,style=label.style_label_down) line.new(array.get(idx,2),array.get(pvts,2),array.get(idx,1),array.get(pvts,1),color=chart.fg_color) line.new(array.get(idx,1),array.get(pvts,1),array.get(idx,0),array.get(pvts,0),color=chart.fg_color) alert("Bearish 1-2-3 Pattern Identified on: "+syminfo.ticker,alert.freq_once_per_bar_close) pattern := false // ~~ } // ~~ Debugger only check break once { if ta.change(array.get(pvts,1)) pattern := true // ~~ }
Multi Pivots
https://www.tradingview.com/script/7PCETlD9-Multi-Pivots/
tyffy_2k
https://www.tradingview.com/u/tyffy_2k/
111
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© tyffy_2k //@version=5 indicator("Multi Pivots",overlay=true,max_lines_count=90) runCPR = input.bool(title='RCPR', defval=false, inline='1', group='CPR') showTomorrowCPR = input.bool(title='TCPR', defval=false, inline='1', group='CPR') showTodayCPR = input.bool(title='DCPR', defval=false, inline='2', group='CPR') showTodayRes = input.bool(title='DRES', defval=false, inline='2', group='CPR') showTodaySup = input.bool(title='DSUP', defval=false, inline='2', group='CPR') pzone = input.bool(title='PZone', defval=false, inline='2', group='CPR') showCamRes = input.bool(title='CAMH', defval=false, inline='1', group='CAMARILLAS') showCamSup = input.bool(title='CAML', defval=false, inline='1', group='CAMARILLAS') showadr = input.bool(title='ADR', defval=false, inline='1', group='CAMARILLAS') show_table = input(true, "Dash", inline='11' , group = 'Others') fibs = input.bool(false, title='Fibs', inline='11', group = 'Others') use_tp = input(false, "Signals" , inline='12') //disp_drangeh = input.bool(false, title='DRangeH', inline='1', group='Day Range') //disp_drangel = input.bool(false, title='DRangeL', inline='1', group='Day Range') AUTO = 'Auto' DAILY = 'Daily' WEEKLY = 'Weekly' MONTHLY = 'Monthly' QUARTERLY = 'Quarterly' YEARLY = 'Yearly' BIYEARLY = 'Biyearly' TRIYEARLY = 'Triyearly' QUINQUENNIAL = 'Quinquennial' //pivot_time_frame = input.string(title='Pivots Timeframe', defval=AUTO, options=[AUTO, DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY, BIYEARLY, TRIYEARLY, QUINQUENNIAL]) pivot_time_frame = AUTO get_pivot_resolution() => resolution = 'M' if pivot_time_frame == AUTO if timeframe.isintraday resolution := timeframe.multiplier <= 15 ? 'D' : 'W' resolution else if timeframe.isweekly or timeframe.ismonthly resolution := '12M' resolution else if pivot_time_frame == DAILY resolution := 'D' resolution else if pivot_time_frame == WEEKLY resolution := 'W' resolution else if pivot_time_frame == MONTHLY resolution := 'M' resolution else if pivot_time_frame == QUARTERLY resolution := '3M' resolution else if pivot_time_frame == YEARLY or pivot_time_frame == BIYEARLY or pivot_time_frame == TRIYEARLY or pivot_time_frame == QUINQUENNIAL resolution := '12M' resolution resolution resolution = get_pivot_resolution() //Day CPR // Function to calculate pivot CalculatePivot(_o,dailyHigh,dailyLow,dailyClose)=> cprpivot = (dailyHigh + dailyLow + dailyClose) / 3 //Central Povit cprBC = (dailyHigh + dailyLow) / 2 //Below Central povit cprTC = cprpivot - cprBC + cprpivot //Top Central povot //3 support levels S1 = cprpivot * 2 - dailyHigh S2 = cprpivot - (dailyHigh - dailyLow) S3 = dailyLow - 2 * (dailyHigh - cprpivot) S4 = S3 - (S1 - S2) S5 = S4 - (S2 - S3) //3 resistance levels R1 = cprpivot * 2 - dailyLow R2 = cprpivot + dailyHigh - dailyLow R3 = dailyHigh + 2 * (cprpivot - dailyLow) R4 = R3 + R2 - R1 R5 = R4 + R3 - R2 //[S1,S2,S3,S4,S5,cprBC,cprpivot,cprTC,R1,R2,R3,R4,R5,dailyHigh,dailyLow,dailyClose] //Fib levels FS1 = cprpivot - (dailyHigh - dailyLow) * 0.382 FS2 = cprpivot - (dailyHigh - dailyLow) * 0.618 FS3 = cprpivot - (dailyHigh - dailyLow) * 1 FR1 = cprpivot + (dailyHigh - dailyLow) * 0.382 FR2 = cprpivot + (dailyHigh - dailyLow) * 0.618 FR3 = cprpivot + (dailyHigh - dailyLow) * 1 [S1,S2,S3,S4,S5,cprBC,cprpivot,cprTC,R1,R2,R3,R4,R5,dailyHigh,dailyLow,dailyClose,FS1,FS2,FS3,FR1,FR2,FR3] //MTF pivots //[S1,S2,S3,S4,S5,cprBC,cprpivot,cprTC,R1,R2,R3,R4,R5,D_High,D_Low,D_Close] = request.security(syminfo.tickerid, resolution, CalculatePivot(open[1],high[1],low[1],close[1]), lookahead=barmerge.lookahead_on) [S1,S2,S3,S4,S5,cprBC,cprpivot,cprTC,R1,R2,R3,R4,R5,D_High,D_Low,D_Close,FS1,FS2,FS3,FR1,FR2,FR3] = request.security(syminfo.tickerid, resolution, CalculatePivot(open[1],high[1],low[1],close[1]), lookahead=barmerge.lookahead_on) [ws1,ws2,ws3,ws4,ws5,wbc,wvpivot,wtc,wr1,wr2,wr3,wr4,wr5,wH,wL,wC] = request.security(syminfo.tickerid, resolution, CalculatePivot(open[1],high[1],low[1],close[1]), lookahead=barmerge.lookahead_on) [ms1,ms2,ms3,ms4,ms5,mbc,mvpivot,mtc,mr1,mr2,mr3,mr4,mr5,mH,mL,mC] = request.security(syminfo.tickerid, resolution , CalculatePivot(open[1],high[1],low[1],close[1]), lookahead=barmerge.lookahead_on) [dws1,dws2,dws3,dws4,dws5,dwbc,dwvpivot,dwtc,dwr1,dwr2,dwr3,dwr4,dwr5,dwH,dwL,dwC] = request.security(syminfo.tickerid, 'W', CalculatePivot(open[1],high[1],low[1],close[1]), lookahead=barmerge.lookahead_on) [dms1,dms2,dms3,dms4,dms5,dmbc,dmvpivot,dmtc,dmr1,dmr2,dmr3,dmr4,dmr5,dmH,dmL,dmC] = request.security(syminfo.tickerid, '1M', CalculatePivot(open[1],high[1],low[1],close[1]), lookahead=barmerge.lookahead_on) [dhigh,dlow,dclose,dopen] = request.security(syminfo.tickerid, 'D', [high,low,close,open]) [sec_open, sec_high, sec_low, sec_close] = request.security(syminfo.tickerid, resolution, [open, high, low, close], lookahead=barmerge.lookahead_on) [dS1,dS2,dS3,dS4,dS5,dcprBC,dcprpivot,dcprTC,dR1,dR2,dR3,dR4,dR5,dD_High,dD_Low,dD_Close] = request.security(syminfo.tickerid, 'D', CalculatePivot(open[1],high[1],low[1],close[1]), lookahead=barmerge.lookahead_on) intday = timeframe.isintraday and timeframe.multiplier < 31 intday1 = timeframe.isintraday and timeframe.multiplier < 30 // Function returns 1 when starting with first bar of the day firstbar(resolution) => ch = 0 if resolution == 'Y' t = year(time('D')) ch := ta.change(t) != 0 ? 1 : 0 ch else t = time(resolution) ch := ta.change(t) != 0 ? 1 : 0 ch ch pp_res = resolution bars_sinse = 0 bars_sinse := firstbar(pp_res) ? 0 : bars_sinse[1] + 1 truncate(number, decimals) => factor = math.pow(10, decimals) int(number * factor) / factor off_mult = 5 //l_size = size.tiny l_size = size.small ll_offset = timenow + math.round(ta.change(time) * off_mult) lTransp = 30 cprColor = #6050DC DayS1Color = S1 != S1[1] ? na : #26a69a DayR1Color = R1 != R1[1] ? na : #e91e63 DHColor = D_High != D_High[1] ? na : color.yellow line_TC = line.new(bar_index[math.min(bars_sinse, 376)], showTodayCPR?cprTC :na, bar_index, showTodayCPR?cprTC :na, color=cprColor, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_TC[1]) line_Pivot = line.new(bar_index[math.min(bars_sinse, 376)], showTodayCPR?cprpivot :na, bar_index, showTodayCPR?cprpivot :na, color=cprColor, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_Pivot[1]) line_BC = line.new(bar_index[math.min(bars_sinse, 376)], showTodayCPR?cprBC :na, bar_index, showTodayCPR?cprBC :na, color=cprColor, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_BC[1]) line_R1 = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes?R1 :na, bar_index, showTodayRes?R1 :na, color=DayR1Color, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_R1[1]) line_R2 = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes?R2 :na, bar_index, showTodayRes?R2 :na, color=DayR1Color, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_R2[1]) line_R3 = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes?R3 :na, bar_index, showTodayRes?R3 :na, color=DayR1Color, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_R3[1]) line_DH = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes?D_High :na, bar_index, showTodayRes?D_High :na, color=DHColor, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_DH[1]) line_S1 = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup?S1 :na, bar_index, showTodaySup?S1 :na, color=DayS1Color, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_S1[1]) line_S2 = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup?S2 :na, bar_index, showTodaySup?S2 :na, color=DayS1Color, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_S2[1]) line_S3 = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup?S3 :na, bar_index, showTodaySup?S3 :na, color=DayS1Color, style = line.style_dotted,width=2, extend = extend.none) line.delete(line_S3[1]) line_DL = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup?D_Low :na, bar_index, showTodaySup?D_Low :na, color=DHColor, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_DL[1]) l_WPivot = line.new(bar_index[math.max(bars_sinse, 100)], showTodayCPR and intday ? dwvpivot : na, bar_index, showTodayCPR ? dwvpivot : na, color=color.new(color.purple,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) line.delete(l_WPivot[1]) //l_MPivot = line.new(bar_index[math.max(bars_sinse, 100)], showTodayCPR and intday ? dmvpivot : na, bar_index, showTodayCPR ? dmvpivot : na, color=color.new(color.green,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) //line.delete(l_MPivot[1]) //l_dws1 = line.new(bar_index[math.max(bars_sinse, 100)], showTodaySup and intday ? dws1 : na, bar_index, showTodayCPR ? dws1 : na, color=color.new(DayS1Color,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) //line.delete(l_dws1[1]) //l_dwr1 = line.new(bar_index[math.max(bars_sinse, 100)], showTodayRes and intday ? dwr1 : na, bar_index, showTodayCPR ? dwr1 : na, color=color.new(DayR1Color,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) //line.delete(l_dwr1[1]) //l_WHigh = line.new(bar_index[math.max(bars_sinse, 100)], showTodayRes and intday ? dwH : na, bar_index, showTodayCPR ? dwH : na, color=color.new(#F3E5AB,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) //line.delete(l_WHigh[1]) //l_WLow = line.new(bar_index[math.max(bars_sinse, 100)], showTodaySup and intday ? dwL : na, bar_index, showTodayCPR ? dwL : na, color=color.new(#F3E5AB,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) //line.delete(l_WLow[1]) //Pivot Zones _Index = syminfo.root R1val = (_Index =='BANKNIFTY') ? 36 : 17 R2val = ((R1 - R2) /5 + (R2 - R3) /5) /2 R3val = ((R3 - R2) /5)/2 line_R1top = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes and pzone?R1 + R1val :na, bar_index, showTodayRes and pzone?R1 + R1val :na, color=color.new(DayR1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_R1top[1]) line_R1bot = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes and pzone?R1 - R1val :na, bar_index, showTodayRes and pzone?R1 - R1val :na, color=color.new(DayR1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_R1bot[1]) line_R2top = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes and pzone?R2 + R2val :na, bar_index, showTodayRes and pzone?R2 + R2val :na, color=color.new(DayR1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_R2top[1]) line_R2bot = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes and pzone?R2 - R2val :na, bar_index, showTodayRes and pzone?R2 - R2val :na, color=color.new(DayR1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_R2bot[1]) line_R3top = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes and pzone?R3 + R3val :na, bar_index, showTodayRes and pzone?R3 + R3val :na, color=color.new(DayR1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_R3top[1]) line_R3bot = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes and pzone?R3 - R3val :na, bar_index, showTodayRes and pzone?R3 - R3val :na, color=color.new(DayR1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_R3bot[1]) linefill.new(line_R1top, line_R1bot, color.new(color.red, 80)) linefill.new(line_R2top, line_R2bot, color.new(color.red, 80)) linefill.new(line_R3top, line_R3bot, color.new(color.red, 80)) S1val = (_Index =='BANKNIFTY') ? 36 : 17 S2val = ((S1 - S2) /5 + (S2 - S3) /5) /2 S3val = ((S3-S2) /5)/2 line_S1top = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup and pzone?S1 + S1val :na, bar_index, showTodaySup and pzone?S1 + S1val :na, color=color.new(DayS1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_S1top[1]) line_S1bot = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup and pzone?S1 - S1val :na, bar_index, showTodaySup and pzone?S1 - S1val :na, color=color.new(DayS1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_S1bot[1]) line_S2top = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup and pzone?S2 + S2val :na, bar_index, showTodaySup and pzone?S2 + S2val :na, color=color.new(DayS1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_S1top[1]) line_S2bot = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup and pzone?S2 - S2val :na, bar_index, showTodaySup and pzone?S2 - S2val :na, color=color.new(DayS1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_S2bot[1]) line_S3top = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup and pzone?S3 + S3val :na, bar_index, showTodaySup and pzone?S3 + S3val :na, color=color.new(DayS1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_S3top[1]) line_S3bot = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup and pzone?S3 - S3val :na, bar_index, showTodaySup and pzone?S3 - S3val :na, color=color.new(DayS1Color,100), style = line.style_solid,width=2, extend = extend.none) line.delete(line_S3bot[1]) linefill.new(line_S1top, line_S1bot, color.new(color.green, 90)) linefill.new(line_S2top, line_S2bot, color.new(color.green, 90)) linefill.new(line_S3top, line_S3bot, color.new(color.green, 90)) //Pivot Zones //Fib Pivots line_FR1 = line.new(bar_index[math.min(bars_sinse, 376)], fibs ? FR1 : na, bar_index, fibs ? FR1 : na, color=DayR1Color, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_FR1[1]) line_FR2 = line.new(bar_index[math.min(bars_sinse, 376)], fibs ? FR2 : na, bar_index, fibs ? FR2 : na, color=DayR1Color, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_FR2[1]) line_FR3 = line.new(bar_index[math.min(bars_sinse, 376)], fibs ? FR3 : na, bar_index, fibs ? FR3 : na, color=DayR1Color, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_FR3[1]) line_FS1 = line.new(bar_index[math.min(bars_sinse, 376)], fibs ? FS1 : na, bar_index, fibs ? FS1 : na, color=DayS1Color, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_FS1[1]) line_FS2 = line.new(bar_index[math.min(bars_sinse, 376)], fibs ? FS2 : na, bar_index, fibs ? FS2 : na, color=DayS1Color, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_FS2[1]) line_FS3 = line.new(bar_index[math.min(bars_sinse, 376)], fibs ? FS3 : na, bar_index, fibs ? FS3 : na, color=DayS1Color, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_FS3[1]) //Running CPR getSeries(e, timeFrame) => request.security(syminfo.tickerid, 'D', e, lookahead=barmerge.lookahead_on) tH = getSeries(high, 'D') tL = getSeries(low, 'D') tC = getSeries(close, 'D') // Tomorrow Pivot Range tP = (tH + tL + tC) / 3 tTC = (tH + tL) / 2 tBC = tP - tTC + tP // Resistance Levels tR3 = tH + 2 * (tP - tL) tR2 = tP + tH - tL tR1 = tP * 2 - tL // Support Levels tS1 = tP * 2 - tH tS2 = tP - (tH - tL) tS3 = tL - 2 * (tH - tP) pcolor2 = tTC < tBC ? color.blue:color.purple vcpr = tL > math.max(dcprTC, dcprBC) or tH < math.min(dcprTC, dcprBC) ? color.yellow : #6050DC //Plotting Day Pivot //plot(disp_d_cpr ? DayPivot:na, title = "DPivot" , color = DayPivotColor, style = plot.style_circles, linewidth =1) plot(runCPR and intday1 ? dcprpivot : na, title='DPivot', color=color.new(vcpr, 50), style=plot.style_circles, linewidth=1) DBC = plot(runCPR and intday1 ? dcprBC : na, title='DBC', color=color.new(vcpr, 50), style=plot.style_circles, linewidth=1) DTC = plot(runCPR and intday1 ? dcprTC : na, title='DTC', color=color.new(vcpr, 50), style=plot.style_circles, linewidth=1) DayPivotColor = dcprpivot != dcprpivot[1] ? na : #6050DC fTransp = 80 fcolor = dcprpivot != dcprpivot[1] ? na : color.blue fcolor1 = dcprTC != dcprTC[1] ? na : color.purple pcolor1 = dcprTC > dcprBC ? fcolor : fcolor1 fill(DTC, DBC, color=color.new(pcolor1, fTransp)) //Camarillas r = D_High - D_Low //Calculate pivots CR6 = D_High / D_Low * D_Close //Bull target 2 CR4 = D_Close + r * (1.1 / 2) //Bear Last Stand CR3 = D_Close + r * (1.1 / 4) //Bear Reversal Low CR5 = CR4 + 1.168 * (CR4 - CR3) //Bull Target 1 CR35 = CR4 - (CR4 - CR3) / 2 //Bear Reversal High CS3 = D_Close - r * (1.1 / 4) //Bull Reversal High CS4 = D_Close - r * (1.1 / 2) //Bull Last Stand CS6 = D_Close - (CR6 - D_Close) //Bear Target 2 CS35 = CS3 - (CS3 - CS4) / 2 //Bull Reversal Low CS5 = CS4 - 1.168 * (CS3 - CS4) //Bear Target 1 line_CR4 = line.new(bar_index[math.min(bars_sinse, 376)], showCamRes?CR4 :na, bar_index, showCamRes?CR4 :na, color=color.new(#7CFC00, lTransp), style = line.style_dotted,width=2, extend = extend.none) line.delete(line_CR4[1]) line_CR3 = line.new(bar_index[math.min(bars_sinse, 376)], showCamRes?CR3 :na, bar_index, showCamRes?CR3 :na, color=color.new(#7CFC00, lTransp), style = line.style_dotted,width=2, extend = extend.none) line.delete(line_CR3[1]) line_CR35 = line.new(bar_index[math.min(bars_sinse, 376)], showCamRes?CR35 :na, bar_index, showCamRes?CR35 :na, color=color.new(color.red, lTransp), style = line.style_dotted,width=1, extend = extend.none) line.delete(line_CR35[1]) line_CS3 = line.new(bar_index[math.min(bars_sinse, 376)], showCamSup?CS3 :na, bar_index, showCamSup?CS3 :na, color=color.new(#7CFC00, lTransp), style = line.style_dotted,width=2, extend = extend.none) line.delete(line_CS3[1]) line_CS4 = line.new(bar_index[math.min(bars_sinse, 376)], showCamSup?CS4 :na, bar_index, showCamSup?CS4 :na, color=color.new(#7CFC00, lTransp), style = line.style_dotted,width=2, extend = extend.none) line.delete(line_CS4[1]) line_CS35 = line.new(bar_index[math.min(bars_sinse, 376)], showCamRes?CS35 :na, bar_index, showCamSup?CS35 :na, color=color.new(color.green, lTransp), style = line.style_dotted,width=1, extend = extend.none) line.delete(line_CS35[1]) //Daily Range onintraChart = timeframe.isintraday lTransp1 = 30 OPEN = request.security(syminfo.tickerid, 'D', open, barmerge.gaps_off, barmerge.lookahead_on) //ADR L dayrange = high - low r1 = request.security(syminfo.tickerid, resolution, dayrange[1], barmerge.gaps_off, barmerge.lookahead_on) r2 = request.security(syminfo.tickerid, resolution, dayrange[2], barmerge.gaps_off, barmerge.lookahead_on) r3 = request.security(syminfo.tickerid, resolution, dayrange[3], barmerge.gaps_off, barmerge.lookahead_on) r4 = request.security(syminfo.tickerid, resolution, dayrange[4], barmerge.gaps_off, barmerge.lookahead_on) r5 = request.security(syminfo.tickerid, resolution, dayrange[5], barmerge.gaps_off, barmerge.lookahead_on) r6 = request.security(syminfo.tickerid, resolution, dayrange[6], barmerge.gaps_off, barmerge.lookahead_on) r7 = request.security(syminfo.tickerid, resolution, dayrange[7], barmerge.gaps_off, barmerge.lookahead_on) r8 = request.security(syminfo.tickerid, resolution, dayrange[8], barmerge.gaps_off, barmerge.lookahead_on) r9 = request.security(syminfo.tickerid, resolution, dayrange[9], barmerge.gaps_off, barmerge.lookahead_on) r10 = request.security(syminfo.tickerid, resolution, dayrange[10], barmerge.gaps_off, barmerge.lookahead_on) adr_10 = (r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8 + r9 + r10) / 10 adr_9 = (r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8 + r9) / 9 adr_8 = (r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8) / 8 adr_7 = (r1 + r2 + r3 + r4 + r5 + r6 + r7) / 7 adr_6 = (r1 + r2 + r3 + r4 + r5 + r6) / 6 adr_5 = (r1 + r2 + r3 + r4 + r5) / 5 adr_4 = (r1 + r2 + r3 + r4) / 4 adr_3 = (r1 + r2 + r3) / 3 adr_2 = (r1 + r2) / 2 adr_1 = r1 //plot adrhigh10 = OPEN + adr_10 / 2 adrlow10 = OPEN - adr_10 / 2 adrhigh5 = OPEN + adr_5 / 2 adrlow5 = OPEN - adr_5 / 2 //if disp_drangeh //_d_adrhigh10 = line.new(start, adrhigh10, end, adrhigh10, xloc.bar_time, color=color.new(color.silver, lTransp1), style=line.style_dotted, width=1) //line.delete(_d_adrhigh10[1]) // _d_adrhigh5 = line.new(start, adrhigh5, end, adrhigh5, xloc.bar_time, color=color.new(color.silver, lTransp1), style=line.style_dotted, width=1) // line.delete(_d_adrhigh5[1]) // linefill.new(_d_adrhigh10, _d_adrhigh5, color.new(color.red, 80)) //if disp_drangel //_d_adrlow10 = line.new(start, adrlow10, end, adrlow10, xloc.bar_time, color=color.new(color.silver, lTransp1), style=line.style_dotted, width=1) //line.delete(_d_adrlow10[1]) // _d_adrlow5 = line.new(start, adrlow5, end, adrlow5, xloc.bar_time, color=color.new(color.silver, lTransp1), style=line.style_dotted, width=1) // line.delete(_d_adrlow5[1]) // linefill.new(_d_adrlow10, _d_adrlow5, color.new(color.green, 80)) if onintraChart line_adrhigh10 = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes?adrhigh10 :na, bar_index, showTodayRes?adrhigh10 :na, color=color.new(color.silver, lTransp1), style = line.style_dotted,width=1, extend = extend.none) line.delete(line_adrhigh10[1]) line_adrhigh5 = line.new(bar_index[math.min(bars_sinse, 376)], showTodayRes?adrhigh5 :na, bar_index, showTodayRes?adrhigh5 :na, color=color.new(color.silver, lTransp1), style = line.style_dotted,width=1, extend = extend.none) line.delete(line_adrhigh5[1]) line_adrlow10 = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup?adrlow10 :na, bar_index, showTodaySup?adrlow10 :na, color=color.new(color.silver, lTransp1), style = line.style_dotted,width=1, extend = extend.none) line.delete(line_adrlow10[1]) line_adrlow5 = line.new(bar_index[math.min(bars_sinse, 376)], showTodaySup?adrlow5 :na, bar_index, showTodaySup?adrlow5 :na, color=color.new(color.silver, lTransp1), style = line.style_dotted,width=1, extend = extend.none) line.delete(line_adrlow5[1]) linefill.new(line_adrhigh10, line_adrhigh5, color.new(color.silver, 80)) linefill.new(line_adrlow10, line_adrlow5, color.new(color.silver, 80)) //Daily Range //200 EMA longest = ta.ema(close, 200) plot(longest, color = color.new(color.white,60)) //Signals atrPeriod = 23 factor = 2.6 tp_trigger = 0.7 * 0.01 ttp_trigger = 0.5 * 0.01 sl_trigger = 0.4 * 0.01 [supertrend, direction] = ta.supertrend(factor, atrPeriod) upTrend = plot(use_tp ? direction < 0 ? supertrend : na : na, "Up Trend", color = color.green, style=plot.style_circles, show_last = 5) downTrend = plot(use_tp ? direction < 0? na : supertrend : na, "Down Trend", color = color.red, style=plot.style_circles, show_last = 5) plotshape(use_tp ? ta.crossover(close,supertrend) : na ,text="BUY",color=color.green,textcolor=color.green,location=location.belowbar, show_last = 25) plotshape(use_tp ? ta.crossunder(close, supertrend): na ,text="SELL",color=color.red,textcolor=color.red, show_last = 25) buy=ta.crossover(close,supertrend) sell=ta.crossunder(close,supertrend) since_buy = ta.barssince(buy) since_sell = ta.barssince(sell) buy_trend = since_sell > since_buy sell_trend = since_sell < since_buy change_trend = (buy_trend and sell_trend[1]) or (sell_trend and buy_trend[1]) entry_price = ta.valuewhen(buy or sell, close, 0) var tp_price_trigger = -1.0 var sl_price_trigger = -1.0 var ttp_price_trigger = -1.0 var is_tp_trigger_hit = false var tp_trail = 0.0 tp_close_long = false tp_close_short = false if use_tp if change_trend tp_price_trigger := entry_price * (1.0 + (buy_trend ? 1.0 : sell_trend ? -1.0 : na) * tp_trigger) sl_price_trigger := entry_price * (1.0 + (buy_trend ? -1.0 : sell_trend ? 1.0 : na) * sl_trigger) ttp_price_trigger := entry_price * (1.0 + (buy_trend ? 1.0 : sell_trend ? -2.4 : na) * tp_trigger + ttp_trigger) is_tp_trigger_hit := false if buy_trend is_tp_trigger_hit := (high >= tp_price_trigger) or (not change_trend and is_tp_trigger_hit[1]) tp_trail := math.max(high, change_trend ? tp_price_trigger : tp_trail[1]) tp_close_long := (is_tp_trigger_hit and (high <= tp_trail * (1.0 - ttp_trigger))) or (not change_trend and tp_close_long[1]) else if sell_trend is_tp_trigger_hit := (low <= tp_price_trigger) or (not change_trend and is_tp_trigger_hit[1]) tp_trail := math.min(low, change_trend ? tp_price_trigger : tp_trail[1]) tp_close_short := (is_tp_trigger_hit and (low >= tp_trail * (1.0 + ttp_trigger))) or (not change_trend and tp_close_short[1]) plot(use_tp and tp_price_trigger != -1.0 ? tp_price_trigger : na,title='Take Profit Price Trigger', color=color.blue,style=plot.style_cross, linewidth=1, show_last = 5) plot(use_tp and sl_price_trigger != -1.0 ? sl_price_trigger : na,title='SL Trigger', color=color.red,style=plot.style_cross, linewidth=1, show_last = 5) plot(use_tp ? entry_price : na,title='Entry Price Trigger', color=color.yellow,style=plot.style_cross, linewidth=1, show_last=5) plot(use_tp and ttp_price_trigger != -1.0 ? ttp_price_trigger : na,title='Trailing Profit Price Trigger', color=color.blue,style=plot.style_cross, linewidth=1, show_last =5) buytargethit = ta.crossover(high,tp_price_trigger) selltargethit = ta.crossunder(low,tp_price_trigger) selltargethit1 = ta.crossunder(low, ta.valuewhen(selltargethit,low,0)) plotshape(use_tp and buy_trend and buytargethit,color=color.green,location=location.abovebar,style=shape.diamond,size=size.tiny, show_last = 25) plotshape(use_tp and sell_trend and selltargethit,color=color.red,location=location.belowbar,style=shape.diamond,size=size.tiny, show_last = 25) cond1 = use_tp and buy_trend and open > entry_price and close > entry_price ? color.orange : na cond2 = use_tp and sell_trend and open < entry_price and close < entry_price ? color.purple : na //barcolor(cond1, show_last = 75) //barcolor(cond2, show_last = 75) // // Note: Week of Sunday=1...Saturday=7 IsWeekend(_date) => dayofweek(_date) == 7 or dayofweek(_date) == 1 // Skip Weekend SkipWeekend(_date) => _d = dayofweek(_date) _mul = _d == 6 ? 3 : _d == 7 ? 2 : 1 _date + _mul * 86400000 // Get Next Working Day GetNextWorkingDay(_date) => _dt = SkipWeekend(_date) _dt // Today's Session Start timestamp y = year(timenow) m = month(timenow) d = dayofmonth(timenow) // Start & End time for Today's CPR start = timestamp(y, m, d, 09, 15) end = start + 86400000 // Plot Today's CPR shouldPlotToday = timenow > start tom_start = start tom_end = end // Start & End time for Tomorrow's CPR if shouldPlotToday tom_start := GetNextWorkingDay(start) tom_end := tom_start + 86400000 tom_end //Day_High/Low showDHL = input.bool(false, title='DHL', inline='11', group = 'Others') line_th_d = line.new(bar_index[math.min(bars_sinse, 376)], showDHL?dhigh :na, bar_index, showDHL?dhigh :na, color=#0FC0FC, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_th_d[1]) label_th_d = label.new(bar_index, showDHL?dhigh : na, text="HoD", textcolor=#0FC0FC, style= label.style_none, size=size.small) label.delete(label_th_d[1]) line_tl_d = line.new(bar_index[math.min(bars_sinse, 376)], showDHL?dlow :na, bar_index, showDHL?dlow :na, color=#0FC0FC, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_tl_d[1]) label_tl_d = label.new(bar_index, showDHL?dlow : na, text="LoD", textcolor=#0FC0FC, style= label.style_none, size=size.small) label.delete(label_tl_d[1]) // Get High & Low 60 showORB = input.bool(false, title='IB', inline='11', group = 'Others') orbTimeFrame = "60" sessSpec = "0915-1530" rColor = color.red sColor = color.green getSeries1(_e, _timeFrame) => request.security(syminfo.tickerid, _timeFrame, _e, lookahead=barmerge.lookahead_on) is_newbar(res, sess) => t = time(res, sess) na(t[1]) and not na(t) or t[1] < t newbar = is_newbar("375", sessSpec) var float orbH = na var float orbL = na var float orbH1 = na var float orbL1 = na if newbar if newbar orbH := getSeries1(high, '60') orbL := getSeries1(low, '60') // Today's Session Start timestamp y1 = year(timenow) m1 = month(timenow) d1 = dayofmonth(timenow) // Start & End time for Today start1 = timestamp(y1, m1, d1, 09, 15) end1 = start1 + 86400000 // Plot only if session started isToday1 = timenow > start1 // Plot selected timeframe's High, Low & Avg line_orbH = line.new(bar_index[math.min(bars_sinse, 376)], showORB and intday ?orbH :na, bar_index, showORB?orbH :na, color=rColor, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_orbH[1]) label_orbH = label.new(bar_index, showORB and intday?orbH : na, text="IB", textcolor=#0FC0FC, style= label.style_none, size=size.small) label.delete(label_orbH[1]) line_orbL = line.new(bar_index[math.min(bars_sinse, 376)], showORB and intday ?orbL :na, bar_index, showORB?orbL :na, color=sColor, style = line.style_dotted,width=1, extend = extend.none) line.delete(line_orbL[1]) label_orbL = label.new(bar_index, showORB and intday ?orbL : na, text="IB", textcolor=#0FC0FC, style= label.style_none, size=size.small) label.delete(label_orbL[1]) //Stats //show_table = input(true, "Dash", inline='12') // RSI rsi = ta.rsi(close, 14) //vwap vwap1=(ta.vwap>close)?1:0 // Supertrend [sup_value, sup_dir] = ta.supertrend(2.7, 23) //---- ADX-DMI code start {----// adxP = 14 adxS = 14 var ADXColor = color.white var ADXText = '' [diplus, diminus, adx] = ta.dmi(adxP, adxS) //---- Calculate Change & %Change code start {----// [ts1,ts1C,ts1PDH,ts1PDL] = request.security(syminfo.tickerid,'D',[close,close[1],high[1],low[1]]) ts1Chng = (ts1-ts1C) ts1p = (ts1-ts1C)*100/ts1C /////////// // PLOTS // var tbl = table.new(position.bottom_right, 7, 41, frame_color=#151715, frame_width=1, border_width=1, border_color=color.new(color.white, 60)) if barstate.islast and show_table table.cell(tbl, 0, 0, 'ADX', text_halign = text.align_center, bgcolor = color.new(color.blue, 60), text_color = color.white, text_size = size.small) table.cell(tbl, 1, 0, 'RSI', text_halign = text.align_center, bgcolor = color.new(color.blue, 60), text_color = color.white, text_size = size.small) table.cell(tbl, 2, 0, 'VWAP', text_halign = text.align_center, bgcolor = color.new(color.blue, 60), text_color = color.white, text_size = size.small) table.cell(tbl, 3, 0, 'ST', text_halign = text.align_center, bgcolor = color.new(color.blue, 60), text_color = color.white, text_size = size.small) table.cell(tbl, 4, 0, 'CH', text_halign = text.align_center, bgcolor = color.new(color.blue, 60), text_color = color.white, text_size = size.small) colgreen = color.new(color.green, 50) colred = color.new(color.red, 60) rsi_col = rsi > 60 ? colgreen : rsi < 40 ? colred : color.black vwap_text = vwap1 < 1 ? "Up" : "Down" vwap_col = vwap1 < 1 ? colgreen: colred sup_text = sup_dir > 0 ? "Down" : "Up" sup_col = sup_dir > 0 ? colred : colgreen adx_col = diplus > diminus ? colgreen : diplus < diminus ? colred : color.black chval_col = ts1Chng > 0 ? colgreen : colred if show_table table.cell(tbl, 0, 1, str.tostring((adx), "#.##"), text_halign = text.align_center, bgcolor = adx_col, text_color = color.white, text_size = size.auto) table.cell(tbl, 1, 1, str.tostring((rsi), "#.##"), text_halign = text.align_center, bgcolor = rsi_col, text_color = color.white, text_size = size.auto) table.cell(tbl, 2, 1, str.tostring(vwap_text), text_halign = text.align_center, bgcolor = vwap_col, text_color = color.white, text_size = size.auto) table.cell(tbl, 3, 1, sup_text, text_halign = text.align_center, bgcolor = sup_col, text_color = color.white, text_size = size.auto) table.cell(tbl, 4, 1, str.tostring((ts1Chng), "#.##"), text_halign = text.align_center, bgcolor = chval_col, text_color = color.white, text_size = size.auto) //PCVwap PlotVWAP = input.bool(false, title='VWAP', inline='12') //Previous Day's Closing Vwap (Pvwap) newday(res) => t = time(res) ta.change(t) != 0 ? 1 : 0 new_day = newday('D') prev_vwap = ta.valuewhen(new_day, int(ta.vwap[1]), 0) //col = close > prev_vwap ? close > ta.vwap ? color.lime : color.blue : close < ta.vwap ? color.red : color.purple line_pvwap = line.new(bar_index[math.min(bars_sinse, 376)], PlotVWAP and intday1 ? prev_vwap :na, bar_index, PlotVWAP and intday1 ? prev_vwap :na, color=color.new(color.yellow, 50), style = line.style_dashed,width=1, extend = extend.none) line.delete(line_pvwap[1]) pvcolor = color.new(color.yellow,50) plot(PlotVWAP and intday1 ? ta.vwap : na, color = color.new(pvcolor,(100/120)*(last_bar_index - bar_index))) //mvwp mvwap = ta.ema(ta.vwap, 50) mvcolor = color.new(color.red,50) //plot(PlotVWAP and intday1 ? mvwap : na, color = color.new(mvcolor,(100/100)*(last_bar_index - bar_index))) vwapcol = PlotVWAP and close > prev_vwap and close > ta.vwap and close > mvwap ? color.lime : PlotVWAP and close < prev_vwap and close < ta.vwap and close < mvwap ? color.red : PlotVWAP and close > ta.vwap and close < prev_vwap ? color.green : PlotVWAP and close < ta.vwap and close > prev_vwap ? color.maroon : na //barcolor(vwapcol, show_last = 75) //Developing Pivot show_d = input(false, title='DPivot', inline='12') is_new_bar(t) => ta.change(time(t)) != 0 get_ohlc(t) => var float _open = na var float _high = na var float _low = na var float _close = na _switch = is_new_bar(t) _open := _switch ? open : nz(_open[1], open) _high := _switch or high > _high[1] ? high : nz(_high[1], high) _low := _switch or low < _low[1] ? low : nz(_low[1], low) _close := close [_open, _high, _low, _close] //[o, h, l, c] = get_ohlc(tf) [o, h, l, c] = get_ohlc(resolution) float p_pivot = 0.0 float p_bc = 0.0 float p_tc = 0.0 float p_h = 0.0 float p_l = 0.0 float d_pivot = 0.0 float d_bc = 0.0 float d_tc = 0.0 d_pivot := math.avg(h, l, c) d_bc := math.avg(h, l) d_tc := d_pivot - d_bc + d_pivot if is_new_bar(resolution) p_pivot := d_pivot[1] p_bc := d_bc[1] p_tc := d_tc[1] p_h := h[1] p_l := l[1] p_l else p_pivot := p_pivot[1] p_bc := p_bc[1] p_tc := p_tc[1] p_h := p_h[1] p_l := p_l[1] p_l r_1 = p_pivot + p_pivot - p_l s_1 = p_pivot - (p_h - p_pivot) r_2 = p_pivot + p_h - p_l s_2 = p_pivot - (p_h - p_l) r_3 = p_h + 2 * (p_pivot - p_l) s_3 = p_l - 2 * (p_h - p_pivot) //r_color = show_levels ? color.red : na //s_color = show_levels ? color.green : na // Developing d_color = show_d ? d_tc > d_bc and d_pivot < p_pivot ? color.orange : d_tc < d_bc and d_pivot > p_pivot ? color.orange : d_pivot > d_bc ? color.green : d_pivot < d_bc ? color.red : color.silver : na len = 5 q=ta.ema(d_pivot, len) b=ta.ema(d_bc, len) t=ta.ema(d_tc, len) //plot(d_pivot, color=d_color, title='D_PIVOT') plot(show_d ? q : na, color = color.new(d_color,(100/100)*(last_bar_index - bar_index)), title='D_PIVOT') bc = input(false, "BC" , inline='12') barcolor(bc ? vwapcol : na, show_last = 75) barcolor(bc ? cond1 : na, show_last = 75) barcolor(bc ? cond2 : na, show_last = 75) //vwap for index string i_maType = syminfo.tickerid Symb = switch i_maType "NSE:BANKNIFTY" => "NSE:BANKNIFTY1!" "NSE:NIFTY" => "NSE:NIFTY1!" // Default used when the cases first cases do not match. => syminfo.tickerid vwapp2 = request.security(Symb, "", ta.vwap) //plot(vwapp2) //Tomorrow CPR if showTomorrowCPR _t_tc = line.new(tom_start, tTC, tom_end, tTC, xloc.bar_time, color=color.new(cprColor, lTransp)) line.delete(_t_tc[1]) _t_p = line.new(tom_start, tP, tom_end, tP, xloc.bar_time, color=color.new(cprColor, lTransp)) line.delete(_t_p[1]) _t_bc = line.new(tom_start, tBC, tom_end, tBC, xloc.bar_time, color=color.new(cprColor, lTransp)) line.delete(_t_bc[1]) linefill.new(_t_tc, _t_bc, color.new(pcolor2, 80)) _t_R1 = line.new(tom_start, tR1, tom_end, tR1, xloc.bar_time, color=color.new(DayR1Color, lTransp)) line.delete(_t_R1[1]) _t_R2 = line.new(tom_start, tR2, tom_end, tR2, xloc.bar_time, color=color.new(DayR1Color, lTransp)) line.delete(_t_R2[1]) _t_S1 = line.new(tom_start, tS1, tom_end, tS1, xloc.bar_time, color=color.new(DayS1Color, lTransp)) line.delete(_t_S1[1]) _t_S2 = line.new(tom_start, tS2, tom_end, tS2, xloc.bar_time, color=color.new(DayS1Color, lTransp)) line.delete(_t_S2[1]) showFibo = input.bool(false, title='Fibo', inline='11', group = 'Others') FPeriod = 500 Fhigh=ta.highest(FPeriod) Flow=ta.lowest(FPeriod) FH=ta.highestbars(high,FPeriod) FL=ta.lowestbars(low,FPeriod) downfibo = FH < FL F0 = downfibo ? Flow : Fhigh F236 = downfibo ? (Fhigh-Flow)*0.236+Flow : Fhigh-(Fhigh-Flow)*0.236 F382 = downfibo ? (Fhigh-Flow)*0.382+Flow : Fhigh-(Fhigh-Flow)*0.382 F500 = downfibo ? (Fhigh-Flow)*0.500+Flow : Fhigh-(Fhigh-Flow)*0.500 F618 = downfibo ? (Fhigh-Flow)*0.618+Flow : Fhigh-(Fhigh-Flow)*0.618 F786 = downfibo ? (Fhigh-Flow)*0.786+Flow : Fhigh-(Fhigh-Flow)*0.786 F1000 = downfibo ? (Fhigh-Flow)*1.000+Flow : Fhigh-(Fhigh-Flow)*1.000 F1618 = downfibo ? (Fhigh-Flow)*1.618+Flow : Fhigh-(Fhigh-Flow)*1.618 Fcolor = downfibo ? #0bf10b : #d44f56c4 Foffset = downfibo ? FH : FL //plot(F0,color=Fcolor,linewidth=2,trackprice=true,show_last=1,title='0',transp=0) //plot(F236,color=Fcolor,linewidth=1,trackprice=true,show_last=1,title='0.236',transp=0) //plot(F382,color=Fcolor,linewidth=1,trackprice=true,show_last=1,title='0.382',transp=0) //plot(F500,color=Fcolor,linewidth=2,trackprice=true,show_last=1,title='0.5',transp=0) //plot(F618,color=Fcolor,linewidth=1,trackprice=true,show_last=1,title='0.618',transp=0) //plot(F786,color=Fcolor,linewidth=1,trackprice=true,show_last=1,title='0.786',transp=0) //plot(F1000,color=Fcolor,linewidth=2,trackprice=true,show_last=1,title='1',transp=0) //plot(plotF1618 and F1618 ? F1618 : na,color=Fcolor,linewidth=3,trackprice=true,show_last=1,title='1.618',transp=0) resolution1 = 'D' // Function returns 1 when starting with first bar of the day firstbar1(resolution1) => ch1 = 0 if resolution1 == 'Y' t1 = year(time('D')) ch1 := ta.change(t) != 0 ? 1 : 0 ch1 else t1 = time(resolution1) ch1 := ta.change(t) != 0 ? 1 : 0 ch1 ch1 pp_res1 = resolution1 bars_sinse1 = 0 bars_sinse1 := firstbar1(pp_res1) ? 0 : bars_sinse1[1] + 1 l_F0 = line.new(bar_index[math.max(bars_sinse1, 100)], showFibo ? F0 : na, bar_index, showFibo ? F0 : na, color=color.new(Fcolor,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=2) line.delete(l_F0[1]) l_F236 = line.new(bar_index[math.max(bars_sinse1, 75)], showFibo ? F236 : na, bar_index, showFibo ? F236 : na, color=color.new(Fcolor,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) line.delete(l_F236[1]) l_F382 = line.new(bar_index[math.max(bars_sinse1, 75)], showFibo ? F382 : na, bar_index, showFibo ? F382 : na, color=color.new(Fcolor,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) line.delete(l_F382[1]) l_F500 = line.new(bar_index[math.max(bars_sinse1, 75)], showFibo ? F500 : na, bar_index, showFibo ? F500 : na, color=color.new(Fcolor,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) line.delete(l_F500[1]) l_F618 = line.new(bar_index[math.max(bars_sinse1, 75)], showFibo ? F618 : na, bar_index, showFibo ? F618 : na, color=color.new(Fcolor,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) line.delete(l_F618[1]) l_F786 = line.new(bar_index[math.max(bars_sinse1, 75)], showFibo ? F786 : na, bar_index, showFibo ? F786 : na, color=color.new(Fcolor,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=1) line.delete(l_F786[1]) l_F1000 = line.new(bar_index[math.max(bars_sinse1, 100)], showFibo ? F1000 : na, bar_index, showFibo ? F1000 : na, color=color.new(Fcolor,(100/25)*(last_bar_index - bar_index)), style=line.style_dotted, extend=extend.none, width=2) line.delete(l_F1000[1]) //plotchar(F0 , 'high','High', location.absolute, show_last = 1, color = #ED381C, offset = 4, editable = false, size = size.tiny) label_F0 = showFibo ? label.new(x=ll_offset, y=F0, xloc=xloc.bar_time, yloc=yloc.price, text="High : " + str.tostring(F0), style=label.style_none, textcolor=color.yellow, size=l_size) : na label.delete(label_F0[1]) label_F1000 = showFibo ? label.new(x=ll_offset, y=F1000, xloc=xloc.bar_time, yloc=yloc.price, text="Low : " + str.tostring(F1000), style=label.style_none, textcolor=color.yellow, size=l_size) : na label.delete(label_F1000[1]) label_F236 = showFibo ? label.new(x=ll_offset, y=F236, xloc=xloc.bar_time, yloc=yloc.price, text="23.6" , style=label.style_none, textcolor=Fcolor, size=l_size) : na label.delete(label_F236[1]) label_F382 = showFibo ? label.new(x=ll_offset, y=F382, xloc=xloc.bar_time, yloc=yloc.price, text="38.2" , style=label.style_none, textcolor=Fcolor, size=l_size) : na label.delete(label_F382[1]) label_F500 = showFibo ? label.new(x=ll_offset, y=F500, xloc=xloc.bar_time, yloc=yloc.price, text="50" , style=label.style_none, textcolor=Fcolor, size=l_size) : na label.delete(label_F500[1]) label_F618 = showFibo ? label.new(x=ll_offset, y=F618, xloc=xloc.bar_time, yloc=yloc.price, text="61.8" , style=label.style_none, textcolor=Fcolor, size=l_size) : na label.delete(label_F618[1]) label_F786 = showFibo ? label.new(x=ll_offset, y=F786, xloc=xloc.bar_time, yloc=yloc.price, text="78.6" , style=label.style_none, textcolor=Fcolor, size=l_size) : na label.delete(label_F786[1]) //EMA Bands emabands = input(false, "EMABands" , inline='12') ema_5 = ta.ema(close, 5) ema_9 = ta.ema(close, 9) ema_20 = ta.ema(close, 20) a = plot(emabands ? ema_5 : na, display=display.none) bb = plot(emabands ? ema_9 : na, display=display.none) cc = plot(emabands ? ema_20 : na, display=display.none) up = ema_5 > ema_20 down = ema_5 < ema_20 mycolor = up ? color.green : down ? color.red : na fill(a, cc, color=color.new(mycolor, 70)) //ADR plots //#region -------------------- Inputs //hist_values = input.bool(defval = false, title = 'Show Past ADRs?') //show_rec = input.bool(defval = false, title = 'Show Recommended Ranges?') //res = input.timeframe(defval = 'D', title = 'Resolution', options = ['D','W','M']) res = 'D' //#endregion //#region -------------------- Functions daily_calc() => [day_one_high, day_one_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[1], low[1]], lookahead = barmerge.lookahead_on) [day_two_high, day_two_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[2], low[2]], lookahead = barmerge.lookahead_on) [day_three_high, day_three_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[3], low[3]], lookahead = barmerge.lookahead_on) [day_four_high, day_four_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[4], low[4]], lookahead = barmerge.lookahead_on) [day_five_high, day_five_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[5], low[5]], lookahead = barmerge.lookahead_on) adr = ((day_one_high - day_one_low) + (day_two_high - day_two_low) + (day_three_high - day_three_low) + (day_four_high - day_four_low) + (day_five_high - day_five_low)) / 5 yesterday_calc() => [day_one_high, day_one_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[1], low[1]], lookahead = barmerge.lookahead_on) y_move = day_one_high - day_one_low yesterday_adr() => [day_one_high, day_one_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[2], low[2]], lookahead = barmerge.lookahead_on) [day_two_high, day_two_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[3], low[3]], lookahead = barmerge.lookahead_on) [day_three_high, day_three_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[4], low[4]], lookahead = barmerge.lookahead_on) [day_four_high, day_four_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[5], low[5]], lookahead = barmerge.lookahead_on) [day_five_high, day_five_low] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [high[6], low[6]], lookahead = barmerge.lookahead_on) y_adr = ((day_one_high - day_one_low) + (day_two_high - day_two_low) + (day_three_high - day_three_low) + (day_four_high - day_four_low) + (day_five_high - day_five_low)) / 5 nround(x) => n = math.round(x / syminfo.mintick) * syminfo.mintick pip_to_whole(number) => atr = ta.atr(14) if syminfo.type == 'forex' pips = atr < 1.0 ? (number / syminfo.mintick) / 10 : number pips := atr >= 1.0 and atr < 100.0 and (syminfo.currency == 'JPY' or syminfo.currency == 'HUF' or syminfo.currency == 'INR') ? pips * 100 : pips else number //#endregion //#region -------------------- Function Calls adr = daily_calc() adr_pips = pip_to_whole(adr) adr_pips := math.round(adr_pips) y_move = yesterday_calc() y_move_pips = pip_to_whole(y_move) y_move_pips := math.round(y_move_pips) y_move_75 = yesterday_adr() y_move_p = pip_to_whole(y_move_75) y_move_p := math.round(y_move_p) y_move_75_pips = y_move_p * 0.75 y_move_75_pips := math.round(y_move_75_pips) //#endregion //#region -------------------- Daily Open Calls //Calc Open dopen1 = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, open, lookahead = barmerge.lookahead_on) [dday, dclose_y, dclose_t] = request.security(ticker.new(syminfo.prefix, syminfo.ticker), res, [time_tradingday, time_close(res)[1], time_close(res)], lookahead = barmerge.lookahead_on) //#endregion //#region -------------------- Line / Label Vars and ADR Calculations var line tl = na var line high_100 = na var line high_75 = na var line high_50 = na var line high_25 = na var line low_25 = na var line low_50 = na var line low_75 = na var line low_100 = na //Labels var label label_t1_open = na var label label_high_100 = na var label label_high_75 = na var label label_high_50 = na var label label_high_25 = na var label label_low_25 = na var label label_low_50 = na var label label_low_75 = na var label label_low_100 = na //ADR Percentage Calculations high_100_p = dopen1 + adr high_75_p = dopen1 + adr * 0.75 high_50_P = dopen1 + adr * 0.50 high_25_p = dopen1 + adr * 0.25 low_25_p = dopen1 - adr * 0.25 low_50_p = dopen1 - adr * 0.50 low_75_p = dopen1 - adr * 0.75 low_100_p = dopen1 - adr //#endregion //#region -------------------- Drawing and Deleting Lines //if hist_values //if ta.change(dclose_y) //tl := line.new(dclose_y, dopen1, dclose_t, dopen1 , xloc = xloc.bar_time, color = color.new(color.white, 50), style = line.style_solid) //high_100 := line.new(dclose_y, high_100_p, dclose_t, high_100_p, color = color.new(#5bd50f, 10), style = line.style_solid, xloc = xloc.bar_time) //high_75 := line.new(dclose_y, high_75_p, dclose_t, high_75_p, color = color.new(#5bd50f, 20), style = line.style_solid, xloc = xloc.bar_time) //high_50 := line.new(dclose_y, high_50_P, dclose_t, high_50_P, color = color.new(#5bd50f, 30), style = line.style_solid, xloc = xloc.bar_time) //high_25 := line.new(dclose_y, high_25_p, dclose_t, high_25_p, color = color.new(#5bd50f, 40), style = line.style_solid, xloc = xloc.bar_time) //low_25 := line.new(dclose_y, low_25_p, dclose_t, low_25_p, color = color.new(#ea2700, 40), style = line.style_solid, xloc = xloc.bar_time) //low_50 := line.new(dclose_y, low_50_p, dclose_t, low_50_p, color = color.new(#ea2700, 30), style = line.style_solid, xloc = xloc.bar_time) //low_75 := line.new(dclose_y, low_75_p, dclose_t, low_75_p, color = color.new(#ea2700, 20), style = line.style_solid, xloc = xloc.bar_time) //low_100 := line.new(dclose_y, low_100_p, dclose_t, low_100_p, color = color.new(#ea2700, 10), style = line.style_solid, xloc = xloc.bar_time) if showadr tl := line.new(dclose_y, dopen1, last_bar_time, dopen1 , xloc = xloc.bar_time, color = color.new(color.white, 50), style = line.style_solid) high_100 := line.new(dclose_y, high_100_p, last_bar_time, high_100_p, color = color.new(#5bd50f, 10), style = line.style_solid, xloc = xloc.bar_time) high_75 := line.new(dclose_y, high_75_p, last_bar_time, high_75_p, color = color.new(#5bd50f, 20), style = line.style_solid, xloc = xloc.bar_time) high_50 := line.new(dclose_y, high_50_P, last_bar_time, high_50_P, color = color.new(#5bd50f, 30), style = line.style_solid, xloc = xloc.bar_time) high_25 := line.new(dclose_y, high_25_p, last_bar_time, high_25_p, color = color.new(#5bd50f, 40), style = line.style_solid, xloc = xloc.bar_time) low_25 := line.new(dclose_y, low_25_p, last_bar_time, low_25_p, color = color.new(#ea2700, 40), style = line.style_solid, xloc = xloc.bar_time) low_50 := line.new(dclose_y, low_50_p, last_bar_time, low_50_p, color = color.new(#ea2700, 30), style = line.style_solid, xloc = xloc.bar_time) low_75 := line.new(dclose_y, low_75_p, last_bar_time, low_75_p, color = color.new(#ea2700, 20), style = line.style_solid, xloc = xloc.bar_time) low_100 := line.new(dclose_y, low_100_p, last_bar_time, low_100_p, color = color.new(#ea2700, 10), style = line.style_solid, xloc = xloc.bar_time) label_t1_open := label.new(last_bar_time, dopen1, size = size.small, text = ' ' + 'Open - ' + str.tostring(dopen1), style = label.style_none, textcolor = color.new(color.white, 50), xloc = xloc.bar_time) label_high_100 := label.new(last_bar_time, high_100_p, size = size.small, text = ' ' + '100.00% ' , style = label.style_none, textcolor = color.new(#5bd50f, 10), xloc = xloc.bar_time) label_high_75 := label.new(last_bar_time, high_75_p, size = size.small, text = ' ' + '75.00% ', style = label.style_none, textcolor = color.new(#5bd50f, 20), xloc = xloc.bar_time) label_high_50 := label.new(last_bar_time, high_50_P, size = size.small, text = ' ' + '50.00% ', style = label.style_none, textcolor = color.new(#5bd50f, 30), xloc = xloc.bar_time) label_high_25 := label.new(last_bar_time, high_25_p, size = size.small, text = ' ' + '25.00% ', style = label.style_none, textcolor = color.new(#5bd50f, 40), xloc = xloc.bar_time) label_low_25 := label.new(last_bar_time, low_25_p, size = size.small, text = ' ' + '25.00% ', style = label.style_none, textcolor = color.new(#ea2700, 40), xloc = xloc.bar_time) label_low_50 := label.new(last_bar_time, low_50_p, size = size.small, text = ' ' + '50.00% ', style = label.style_none, textcolor = color.new(#ea2700, 30), xloc = xloc.bar_time) label_low_75 := label.new(last_bar_time, low_75_p, size = size.small, text = ' ' + '75.00% ', style = label.style_none, textcolor = color.new(#ea2700, 20), xloc = xloc.bar_time) label_low_100 := label.new(last_bar_time, low_100_p, size = size.small, text = ' ' + '100.00% ', style = label.style_none, textcolor = color.new(#ea2700, 10), xloc = xloc.bar_time) //Delete Label label.delete(label_t1_open[1]) label.delete(label_high_100[1]) label.delete(label_high_75[1]) label.delete(label_high_50[1]) label.delete(label_high_25[1]) label.delete(label_low_25[1]) label.delete(label_low_50[1]) label.delete(label_low_75[1]) label.delete(label_low_100[1]) //Delete Line line.delete(tl[1]) line.delete(high_100[1]) line.delete(high_75[1]) line.delete(high_50[1]) line.delete(high_25[1]) line.delete(low_25[1]) line.delete(low_50[1]) line.delete(low_75[1]) line.delete(low_100[1]) //#endregion
Index Overlay
https://www.tradingview.com/script/rgfD8ks3-Index-Overlay/
carlob777
https://www.tradingview.com/u/carlob777/
112
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© carlob777 //@version=5 indicator("Index Overlay", overlay=true, max_lines_count=500) // --------------- INPUTS --------------- var GRP0 = "CODED by @carlob777" sessionInput = input.string("Set New York time", title='Timezone', options=['Set New York time'], group=GRP0, tooltip= 'please use this indicator only with the New York timezone on your chart') hoursOffsetInput = '-5' newDayHr = 0 res = "D" var GRP2 = "Quick Settings" showMidnightOpen = input.bool(true, title='Midnight Open', group=GRP2, tooltip = 'show midnight open line') ShowMidnight = input.bool(true, "Show True Day Separator", group = GRP2, tooltip = 'show day separator bands') showSundayOpen = input.bool(true, title='Sunday Open', group=GRP2, tooltip = 'show true weekly market open') showFVG = input.bool(false, title = 'Fair Value Gap', group = GRP2, tooltip = 'show FVGs') showVWAP = input(false, title="VWAP", group=GRP2, tooltip = 'show VWAP anchored to midnight') showBreakout = input(false, title="Breakout Probability", group=GRP2, tooltip = 'show the breakout probability for the current candle') showDailyDividers = input.bool(true, title='Day Labels', group=GRP2, tooltip = 'show day labels') showTDHTLD = input.bool(false, title='Todays High & Low', group = GRP2, tooltip = 'show today high & low, calculated from midnight to 9:30 equity open') //showPDHPDL = input.bool(false, title='Yesterdays High & Low', group = GRP2, tooltip = 'show yesterday high & low, calculated from midnight to 11:59pm NY time') showTT = input.bool(true, title='Trading Time Window', group = GRP2, tooltip = 'show the time window to trade, from 9:30 to 12:00 NY time') //i_isDailyEnabled = input(true, "Show BSL & SSL Liquitidy Lines", group=GRP2, tooltip = 'show intraday liqidity pools' ) ///// liquidity var GRP3 = "midnight & sunday open settings" //midnight midnightColor = input.color(color.new(#673ab7, 0), title='Midnight Line & Label Color', group=GRP3) midnightExtendHours = input.int(24, title='Line Extend hours', minval=1, maxval=24, group=GRP3, tooltip = '24 hours default means that the Midnight Open line will last all day, until next Midnight Open') //sunday open sundayColor = input.color(color.new(#434651, 0), title='Sunday Line & Label Color', group=GRP3) sundayExtendHours = input.int(120, title='Line Extend hours', minval=1, maxval=120, group=GRP3, tooltip = '120 hours default means that the Sunday Open line will last all week, until next Sunday Open') //general settings lines for both minight and sunday open var GRP4 = "Lines General settings" openLineStyle = input.string(title="Orizontal Line Style", defval="Dotted", options=["Solid", "Dashed", "Dotted"], group=GRP4) openWidth = input.int(1, title='Orizontal Line Width', minval=1, maxval=4, group=GRP4) openLabelSize = input.string("Small", title='Label Size', options=['Auto', 'Tiny', 'Small', 'Normal'], group=GRP4) openMaxLines = 1 TTColor = input.color(color.new(#434651, 80), title='Trading Time Lines Color', group=GRP4) var GRP5 = "day labels" dividerLineTextColor = input(color.gray, 'Text Color', group=GRP5) dayLabelOffset = input.int(10, title='Labels Offset', minval=1, maxval=48, group=GRP5) midnightColor1 = color.new(#5d606b, 90) midnight = input.session("0000-0001:1234567", "True Day Open", group = GRP5) var GRP1 = "vwap settings" vwapColor = input(color.blue, 'VWAP Color', group=GRP1) srcVWAP = input(title = "Source", defval = hlc3, group=GRP1) offsetVWAP = input(0, title="Offset", group=GRP1) showBand_1 = input(true, title="", group=GRP1, inline="band_1") stdevMult_1 = input(1.0, title="Bands Multiplier #1", group=GRP1, inline="band_1") Band_1Color = input(color.new(color.green, 70), "Color", inline ="band_1",group=GRP1) showBand_2 = input(true, title="", group=GRP1, inline="band_2") stdevMult_2 = input(1.5, title="Bands Multiplier #2", group=GRP1, inline="band_2") Band_2Color = input(color.new(color.olive, 70), "Color", inline="band_2", group=GRP1) showBand_3 = input(true, title="", group=GRP1, inline="band_3") stdevMult_3 = input(2.0, title="Bands Multiplier #3", group=GRP1, inline="band_3") Band_3Color = input(color.new(color.teal, 70), "Color", inline="band_3", group=GRP1) var GRP6 = 'Todays High & Low Settings' //showLabels = input.bool(defval=true, title="Show labels on Day Lines ", group=GRP6) //tdhAlert = input(false, title = "Todays High Liquidation Alert", group=GRP6, inline='alert') //tdlAlert = input(false, title = "Todays Low Liquidation Alert", group=GRP6, inline='alert') // --------------- INPUTS --------------- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////// ================== LOGIC ===================== ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// is_newbar(sess) => t = time(res, sess, "America/New_York") na(t[1]) and not na(t) or t[1] < t is_session(sess) => not na(time(timeframe.period, sess, "America/New_York")) //highlight midnight MidnightNewbar = is_newbar(midnight) MidnightSession = is_session(midnight) float midnightLow = na midnightLow := if MidnightSession if MidnightNewbar low else math.min(midnightLow[1],low) else midnightLow float midnightHigh = na midnightHigh := if MidnightSession if MidnightNewbar high else math.max(midnightHigh[1],high) else midnightHigh bgcolor(MidnightSession and ShowMidnight ? midnightColor1 : na) // --------------- CONSTANTS --------------- TIMEZONE = "GMT"+hoursOffsetInput ISNEWDAY = dayofweek != dayofweek[1] TRANSPARENT = color.new(color.white, 100) exchangeOffset = hour(timenow, TIMEZONE) - hour(timenow, syminfo.timezone) HOUR = hour + exchangeOffset <= 23 ? hour + exchangeOffset : (hour + exchangeOffset) - 24 // label.new(bar_index, high, str.tostring(HOUR)) // --------------- CONSTANTS --------------- // --------------- FUNCTIONS --------------- reso(exp, res) => request.security(syminfo.tickerid, res, exp, lookahead=barmerge.lookahead_on) getLineStyle(_style) => _linestyle = _style == "Dotted" ? line.style_dotted : _style == "Dashed" ? line.style_dashed : line.style_solid _linestyle getlabelSize(_labelSize) => _size = _labelSize == "auto" ? size.auto : _labelSize == "Tiny" ? size.tiny : _labelSize == "Small" ? size.small : _labelSize == "Normal" ? size.normal : size.huge _size addToArray(_array, _val) => array.push(_array, _val) resolutionInMinutes() => 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) int(resInMinutes) tfInMinutes(simple string tf = "") => float chartTf = 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) float result = tf == "" ? chartTf : request.security(syminfo.tickerid, tf, chartTf) inTimeframe(_t) => tfInMinutes(_t) > tfInMinutes(timeframe.period) getOhlcData(_t, _var, _offset) => o = reso(open[_offset], _t) h = reso(high[_offset], _t) l = reso(low[_offset], _t) c = reso(close[_offset], _t) show = _var != "Off" and inTimeframe(_t) _time = time(_t) newbar = na(_time[1]) or _time > _time[1] hl = _var == 'HL' or _var == 'OHLC' oc = _var == 'OC' or _var == 'OHLC' [o, h, l, c, show, newbar, hl, oc] getLastElementInArray(_arr) => _size = array.size(_arr) _el = _size > 0 ? array.get(_arr, _size-1) : na _el // --------------- FUNCTIONS --------------- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////// ================== LINES ===================== ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var line[] midnightLines = array.new_line(0) var label[] midnightLabels = array.new_label(0) var line[] sundayLines = array.new_line(0) var label[] sundayLabels = array.new_label(0) inMidnight = HOUR == 0 and minute == 0 inSunday = HOUR == 18 and minute == 0 and dayofweek == dayofweek.sunday LABEL_SPACE = " " //Midnight plot line if inMidnight and not inMidnight[1] and showMidnightOpen _extend = midnightExtendHours * 3600000 array.push(midnightLines, line.new(time, open, time + _extend, open, xloc=xloc.bar_time, color=midnightColor, style=getLineStyle(openLineStyle), width=openWidth)) array.push(midnightLabels, label.new(time + _extend, open, "Midnight Open" + LABEL_SPACE, xloc=xloc.bar_time, style=label.style_none, size=getlabelSize(openLabelSize), textcolor=midnightColor)) // EXTEND // DELETE OLD if array.size(midnightLines) > openMaxLines line.delete(array.shift(midnightLines)) if array.size(midnightLabels) > openMaxLines label.delete(array.shift(midnightLabels)) //sunday open plot line if inSunday and not inSunday[1] and showSundayOpen _extend1 = sundayExtendHours * 3600000 array.push(sundayLines, line.new(time, open, time + _extend1, open, xloc=xloc.bar_time, color=sundayColor, style=getLineStyle(openLineStyle), width=openWidth)) array.push(sundayLabels, label.new(time + _extend1, open, "Sunday Open" + LABEL_SPACE, xloc=xloc.bar_time, style=label.style_none, size=getlabelSize(openLabelSize), textcolor=sundayColor)) // EXTEND // DELETE OLD if array.size(sundayLines) > openMaxLines line.delete(array.shift(sundayLines)) if array.size(sundayLabels) > openMaxLines label.delete(array.shift(sundayLabels)) // --------------- TIME LINES --------------- // Divider tickerExchangeOffset = 5 int dayLabelStartTime = 1 _rin = resolutionInMinutes() if syminfo.timezone == 'Etc/UTC' dayLabelStartTime += tickerExchangeOffset dayLabelStartTime isStartTime = HOUR == newDayHr and HOUR[1] != newDayHr //and minute == 0 _inTimeframe = _rin <= 180 and timeframe.isintraday // if barstate.islastHOUR // label.new(bar_index, high, str.tostring(hour) + "\n" + str.tostring(exchangeOffset)) txtMonH = "Monday" txtTueH = "Tuesday" txtWedH = "Wednesday" txtThuH = "Thursday" txtFriH = "Friday" txtSatH = "Saturday" txtSunH = "Sunday" txtMonV = "M\no\nn\nd\na\ny" txtTueV = "T\nu\ne\ns\nd\na\ny" txtWedV = "W\ne\nd\nn\ne\ns\nd\na\ny" txtThuV = "T\nh\nu\nr\ns\nd\na\ny" txtFriV = "F\nr\ni\nd\na\ny" txtSatV = "S\na\nt\nu\nr\nd\na\ny" txtSunV = "S\nu\nn\nd\na\ny" isMon() => _inTimeframe and showDailyDividers ? HOUR == dayLabelStartTime and minute == 0 and dayofweek == dayofweek.monday : false isTue() => _inTimeframe and showDailyDividers ? HOUR == dayLabelStartTime and minute == 0 and dayofweek == dayofweek.tuesday : false isWed() => _inTimeframe and showDailyDividers ? HOUR == dayLabelStartTime and minute == 0 and dayofweek == dayofweek.wednesday : false isThu() => _inTimeframe and showDailyDividers ? HOUR == dayLabelStartTime and minute == 0 and dayofweek == dayofweek.thursday : false isFri() => _inTimeframe and showDailyDividers ? HOUR == dayLabelStartTime and minute == 0 and dayofweek == dayofweek.friday : false isSat() => _inTimeframe and showDailyDividers ? HOUR == dayLabelStartTime and minute == 0 and dayofweek == dayofweek.saturday : false isSun() => _inTimeframe and showDailyDividers ? HOUR == dayLabelStartTime and minute == 0 and dayofweek == dayofweek.sunday : false _offset = _rin <= 7 ? math.round(dayLabelOffset * 12) : _rin <= 14 ? math.round(dayLabelOffset * 6) : _rin <= 20 ? math.round(dayLabelOffset * 4) : _rin <= 30 ? math.round(dayLabelOffset * 2) : _rin <= 60 ? math.round(dayLabelOffset * 1) : math.round(dayLabelOffset * 0.2) plotshape(isMon(), text=txtMonH, color=TRANSPARENT, offset=_offset, style=shape.circle, location=location.bottom, textcolor=dividerLineTextColor, size=size.tiny, editable=false) plotshape(isTue(), text=txtTueH, color=TRANSPARENT, offset=_offset, style=shape.circle, location=location.bottom, textcolor=dividerLineTextColor, size=size.tiny, editable=false) plotshape(isWed(), text=txtWedH, color=TRANSPARENT, offset=_offset, style=shape.circle, location=location.bottom, textcolor=dividerLineTextColor, size=size.tiny, editable=false) plotshape(isThu(), text=txtThuH, color=TRANSPARENT, offset=_offset, style=shape.circle, location=location.bottom, textcolor=dividerLineTextColor, size=size.tiny, editable=false) plotshape(isFri(), text=txtFriH, color=TRANSPARENT, offset=_offset, style=shape.circle, location=location.bottom, textcolor=dividerLineTextColor, size=size.tiny, editable=false) plotshape(isSat(), text=txtSatH, color=TRANSPARENT, offset=_offset, style=shape.circle, location=location.bottom, textcolor=dividerLineTextColor, size=size.tiny, editable=false) plotshape(isSun(), text=txtSunH, color=TRANSPARENT, offset=_offset, style=shape.circle, location=location.bottom, textcolor=dividerLineTextColor, size=size.tiny, editable=false) // --------------- SESSIONS --------------- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////// ================== VWAP ANCHORED ===================== ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// currentOnly = false if year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time) currentOnly := true if barstate.islast and ta.cum(volume) == 0 runtime.error("No volume is provided by the data vendor.") float vwapValue = na float upperBandValue1 = na float lowerBandValue1 = na float upperBandValue2 = na float lowerBandValue2 = na float upperBandValue3 = na float lowerBandValue3 = na if not (timeframe.isdwm) [_vwap, _stdevUpper, _] = ta.vwap(srcVWAP, inMidnight, 1) vwapValue := _vwap stdevAbs = _stdevUpper - _vwap upperBandValue1 := _vwap + stdevAbs * stdevMult_1 lowerBandValue1 := _vwap - stdevAbs * stdevMult_1 upperBandValue2 := _vwap + stdevAbs * stdevMult_2 lowerBandValue2 := _vwap - stdevAbs * stdevMult_2 upperBandValue3 := _vwap + stdevAbs * stdevMult_3 lowerBandValue3 := _vwap - stdevAbs * stdevMult_3 plot(showVWAP and currentOnly ? vwapValue : na, title='VWAP', color=vwapColor, display = display.all - display.price_scale) plot(showVWAP and showBand_1 and currentOnly ? upperBandValue1 : na, title="Upper Band #1", color=Band_1Color, offset=offsetVWAP, display = display.all - display.price_scale) plot(showVWAP and showBand_1 and currentOnly ? lowerBandValue1 : na, title="Lower Band #1", color=Band_1Color, offset=offsetVWAP, display = display.all - display.price_scale) //fill(upperBand_1, lowerBand_1, title="Bands Fill #1", color= color.new(color.green, 99) , display = showBand_1 ? display.all : display.none) plot(showVWAP and showBand_2 and currentOnly ? upperBandValue2 : na, title="Upper Band #2", color=Band_2Color, offset=offsetVWAP, display = display.all - display.price_scale) plot(showVWAP and showBand_2 and currentOnly ? lowerBandValue2 : na, title="Lower Band #2", color=Band_2Color, offset=offsetVWAP, display = display.all - display.price_scale) //fill(upperBand_2, lowerBand_2, title="Bands Fill #2", color= color.new(color.olive, 99) , display = showBand_2 ? display.all : display.none) plot(showVWAP and showBand_3 and currentOnly ? upperBandValue3 : na, title="Upper Band #3", color=Band_3Color, offset=offsetVWAP, display = display.all - display.price_scale) plot(showVWAP and showBand_3 and currentOnly ? lowerBandValue3 : na, title="Lower Band #3", color=Band_3Color, offset=offsetVWAP, display = display.all - display.price_scale) //fill(upperBand_3, lowerBand_3, title="Bands Fill #3", color= color.new(color.teal, 99) , display = showBand_3 ? display.all : display.none) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////// ================== TDH & TDL liquidity + trading time window ===================== ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Sessions and inputs i_timezone = "America/New_York" i_showDaysDraw = 1 var TodayStart = time // Store the timestamp when a new day starts inputMaxInterval = 30 showIndicator = (timeframe.multiplier <= inputMaxInterval) and (timeframe.isintraday) // If current timeframe is lower or equal to input then showIndicator = true i_linestyle = input.string(title="Vertical Line Style", options=["solid", "dotted", "dashed"], defval="solid",group=GRP4, inline="Line") // Default value is dotted to avoid drawing over wicks i_lineWidth = input.int(title="Line Width", defval=1, minval=1, maxval=5, group=GRP4, inline="Line", tooltip="Linestyle settings for the vertical dividers") // Set the linewidth of the vertical lines i_linestyleLevels = "dashed" i_lineWidthLevels = 1 // Daily Session settings group_daily = "Daily Session" i_DailySession = "0000-0930:1234567" DailySession = time(timeframe.period, i_DailySession, i_timezone) // Calculate time for the Globex/Overnight session. var float Daily_hi = na // Daily High var float Daily_lo = na // Daily Low showDailyHigh = showTDHTLD i_DailyHighCol = input.color(title="Todays High Color", defval=color.new(#3f62ff, 50), group=GRP6, inline="High") showDailyLow = showTDHTLD i_DailyLowCol = input.color(title="Todays Low Color", defval=color.new(#b22833, 50), group=GRP6, inline="High") var DailyHighLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=na, color=i_DailyHighCol, width=i_lineWidthLevels) // Today's High Price level line var DailyHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // Today's High Price label var DailyLowLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=na, color=i_DailyLowCol, width=i_lineWidthLevels) // Today's Low Price level line var DailyLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=color.new(color.gray, 90), textcolor=color.white, style=label.style_label_left, size=size.small) // Today's Low Price label var DailySessionStart = time // To register the timestamp when the Daily Session begins // Globex (or Overnight) session settings and inputs i_GlobexSession = "1700-0830:1234567" GlobexSession = time(timeframe.period, i_GlobexSession, i_timezone) // Calculate time for the Globex/Overnight session. var float Globex_open = na // Store the Globex Opening price var float Globex_hi = na // High for the Globex Session var float Globex_lo = na // Low for the Globex Session // Globex Low line var GlobexSessionStart = time // To register the timestamp when the Globex Overnight Session begins // -------------------------------- KILLZONE SESSIONS --------------------------------------------------------------------------- //ASIA Killzone Inputs and Settings showLine_Asian = false i_AsianSession = "2000-0000" AsianSession = time(timeframe.period, i_AsianSession, i_timezone) // Calculate time for the Asian session. i_AsianSessionHour = 20 i_AsianSessionMin = 00 AsianSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_AsianSessionHour, i_AsianSessionMin, 00)-86400000 // Coordinate for Asian Killzone Start time (minus 1 day) i_AsianSessionEndHour = 23 i_AsianSessionEndMin = 59 AsianSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_AsianSessionEndHour, i_AsianSessionEndMin, 00)-86400000 // Coordinate for Asian Killzone End time (minus 1 day) showLevel_Asian = false // London Killzone session settings and inputs showLine_London = false i_LondonSessionHour = 02 i_LondonSessionMin = 00 LondonSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_LondonSessionHour, i_LondonSessionMin, 00) // Coordinate for London Killzone Start time i_LondonSessionEndHour = 5 i_LondonSessionEndMin = 0 LondonSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_LondonSessionEndHour, i_LondonSessionEndMin, 00) // Coordinate for London Killzone End time showLevel_London = false // NY Open Killzone session settings and inputs showLine_NYKZ = false i_NYKZSessionHour = 07 i_NYKZSessionMin = 00 NYKZSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_NYKZSessionHour, i_NYKZSessionMin, 00) // Coordinate for NY Killzone Start time i_NYKZSessionEndHour = 10 i_NYKZSessionEndMin = 0 NYKZSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_NYKZSessionEndHour, i_NYKZSessionEndMin, 00) // Coordinate for NY Killzone End time showLevel_NYKZ = false // New York Session settings and inputs ny_group = "New York Session Vertical Settings" nyprice_group = "New York Price Horizontal Level Settings" nytime_group = "New York Session Time Settings" cmeprice_group = "CME Price Horizontal Level Settings" i_NYMNVertCol = color.new(color.fuchsia,0) i_AMSessionCol = color.new(color.blue,0) //////////////////////////////////////////// 930 linea verticaleeeee /////////////////////////////////////////////////// showLine_CME = showTT i_CMESessionCol = TTColor ///////////////////////////////////////////////// 12 vertical lineeee ////////////////////////////////////////////////// showLine_Lunch = showTT i_LunchSessionCol = TTColor //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// i_LunchSessionFillCol= color.new(color.red,80) i_PMSessionCol = color.new(color.blue,0) i_NYSessionEndCol = color.new(color.blue,0) NYMNOpenTime = timestamp(i_timezone, year, month, dayofmonth, 00, 00, 00) // Coordinate for NY Midnight Opening Time coordinate (Every day 00:00) AMSessionTime = timestamp(i_timezone, year, month, dayofmonth, 08, 30, 00) // Coordinate for NY AM Start session time PMSessionTime = timestamp(i_timezone, year, month, dayofmonth, 13, 00, 00) CMESessionTime = timestamp(i_timezone, year, month, dayofmonth, 09, 30, 00) // Coordinate for CME Start session time var CMESessionLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_CMESessionCol, width=i_lineWidth) // CME Open Vertical Line LunchSessionTime = timestamp(i_timezone, year, month, dayofmonth, 12, 00, 00) // Coordinate for Lunch Start time var LunchStartLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LunchSessionCol, width=i_lineWidth) // Lunch Start Vertical Line var NYSessionEndTime= timestamp(i_timezone, year, month, dayofmonth, 16, 30, 00) // Coordinate for NY End of session time (this is also the terminus for the Level lines) // HTF Lines // LOGGING FUNCTION var logsize = 50 var bar_arr = array.new_int(logsize) var time_arr = array.new_string(logsize) var msg_arr = array.new_string(logsize) var type_arr = array.new_string(logsize) log_msg(message, type) => array.push(bar_arr, bar_index) array.push(time_arr, str.tostring(year) + "-" + str.tostring(month) + "-" + str.tostring(dayofmonth) + " " + str.tostring(hour(time,i_timezone)) + ":" + str.tostring(minute(time,i_timezone)) + ":" + str.tostring(second(time,i_timezone))) array.push(msg_arr, message) array.push(type_arr, type) // Housekeeping, delete the oldest log entries. This prevents the array from becoming too big. array.shift(bar_arr) array.shift(time_arr) array.shift(msg_arr) array.shift(type_arr) // END LOGGING CODE // *** End of inputs and variables // Convert linestyle linestyle = (i_linestyle == "solid") ? line.style_solid : (i_linestyle == "dashed") ? line.style_dashed : line.style_dotted // Default value is dotted to avoid drawing over wicks // Functions // Function to draw Vertical Lines vline(Start, Color, linestyle, LineWidth) => line.new(x1=Start, y1=low - ta.tr, x2=Start, y2=high + ta.tr, xloc=xloc.bar_time, extend=extend.both, color=Color, style=linestyle, width=LineWidth) // End function // Function for determining the Start of a Session (taken from the Pinescript manual: https://www.tradingview.com/pine-script-docs/en/v5/concepts/Sessions.html ) sessionBegins(sess) => t = time("", sess , i_timezone) showIndicator and (not barstate.isfirst) and na(t[1]) and not na(t) // End session function // Housekeeping - Remove old drawing objects housekeeping(days) => // Delete old drawing objects // One day is 86400000 milliseconds removal_timestamp = AsianSessionTime - (days * 86400000) // Remove every drawing object older than the start of the Asian Session. a_allLines = line.all a_allLabels = label.all // Remove old lines if array.size(a_allLines) > 0 for i = 0 to array.size(a_allLines) - 1 line_x2 = line.get_x2(array.get(a_allLines, i)) if line_x2 < removal_timestamp line.delete(array.get(a_allLines, i)) // Remove old labels if array.size(a_allLabels) > 0 for i = 0 to array.size(a_allLabels) - 1 label_x = label.get_x(array.get(a_allLabels, i)) if label_x < removal_timestamp label.delete(array.get(a_allLabels, i)) // End of housekeeping function // *** End of all functions // ************************** << // Start MAIN Logic // Daily Session Start | this works for everything but stocks if sessionBegins(i_DailySession) // When a new Daily Session is started log_msg("Daily Session Start", 'medium') log_msg("You are trading: " + syminfo.ticker + " and its asset class is: " + syminfo.type, 'medium') DailySessionStart := time // Store the Session Starting timestamp NYMNOpenTime := time // Calculate timestamps for the coming session // Killzone vertical line timestamps if AsianSessionTime < DailySessionStart // If the AsianSessionTime is in the past, then add 1 day AsianSessionTime := AsianSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if AsianSessionEndTime < DailySessionStart // If the AsianSessionEndTime is in the past, then add 1 day AsianSessionEndTime := AsianSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if LondonSessionTime < DailySessionStart // If the LondonSessionTime is in the past, then add 1 day LondonSessionTime := LondonSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if LondonSessionEndTime < DailySessionStart // If the LondonSessionEndTime is in the past, then add 1 day LondonSessionEndTime := LondonSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if NYKZSessionTime < DailySessionStart // If the NYKZSessionTime is in the past, then add 1 day NYKZSessionTime := NYKZSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if NYKZSessionEndTime < DailySessionStart // If the NYKZSessionEndTime is in the past, then add 1 day NYKZSessionEndTime := NYKZSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should // Session vertical line timestamps if AMSessionTime < DailySessionStart // If the AMSessionTime is in the past, then add 1 day AMSessionTime := AMSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if AMSessionTime < DailySessionStart // If the AMSessionTime is in the past, then add 1 day AMSessionTime := AMSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if CMESessionTime < DailySessionStart // If the NYSessionEndTime is in the past, then add 1 day CMESessionTime := CMESessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if LunchSessionTime < DailySessionStart // If the LunchSessionTime is in the past, then add 1 day LunchSessionTime := LunchSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if PMSessionTime < DailySessionStart // If the PMSessionTime is in the past, then add 1 day PMSessionTime := PMSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should NYSessionEndTime := timestamp(i_timezone, year, month, dayofmonth, 16, 30, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) if NYSessionEndTime < DailySessionStart // If the NYSessionEndTime is in the past, then add 1 day NYSessionEndTime := NYSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should // We are entering Daily Session hours; reset hi/lo. Daily_hi := high Daily_lo := low // Initialize the drawings for today if showDailyHigh // Draw the Daily Open Vertical Line DailyHighLine := line.new(x1=NYMNOpenTime, y1=Daily_hi, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Daily_hi, color=i_DailyHighCol, width=i_lineWidthLevels) // Today's High Price level line if showDailyLow DailyLowLine := line.new(x1=NYMNOpenTime, y1=Daily_lo, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Daily_lo, color=i_DailyLowCol, width=i_lineWidthLevels) // Today's Low Price level line // When a new day start, draw all the vertical lines // Draw the CME Open Start Line if (showLine_CME and showIndicator) CMESessionLine := vline(CMESessionTime, i_CMESessionCol, linestyle, i_lineWidth) // Draw the NY Lunch Start Line if (showLine_Lunch and showIndicator) LunchStartLine := vline(LunchSessionTime, i_LunchSessionCol, linestyle, i_lineWidth) // *** End of Vertical Lines section else if DailySession // We are in allowed DailySession hours; track hi/lo. Daily_hi := math.max(high, Daily_hi) Daily_lo := math.min(low, Daily_lo) if (Daily_hi > Daily_hi[1]) if showDailyHigh line.set_y1(id=DailyHighLine, y=Daily_hi) line.set_y2(id=DailyHighLine, y=Daily_hi) if (Daily_lo < Daily_lo[1]) if showDailyLow line.set_y1(id=DailyLowLine, y=Daily_lo) line.set_y2(id=DailyLowLine, y=Daily_lo) // END Daily Session Code //condizioni per alert === dopo 9:30, che liquida tdh o tdl //TDHalert = (close, DailyHighLine) // Do housekeeping of old objects - remove everything before the number of days set housekeeping(i_showDaysDraw) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////// ================== FVG ===================== ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// _bullImb = showFVG _bullCol = input.color(color.new(#4599e2, 60), "Bullish FVG Color", group="Fair Value Gap Settings", inline="1") _bullColBorder = input.color(color.new(#254e85, 75), "     Border", group="Fair Value Gap Settings", inline="1") _bearImb = showFVG _bearCol = input.color(color.new(#452581, 60), "Bearish FVG Color", group="Fair Value Gap Settings", inline="2") _bearColBorder = input.color(color.new(#411d5e, 81), "     Border", group="Fair Value Gap Settings", inline="2") _removeOld = input.bool(true, " Delete Mitigated FVGs", group="Fair Value Gap Settings") _width = input.int(0, "Extend FVG", minval=0, maxval=500, group="Fair Value Gap Settings") _totalCount = input.int(10, "Max FVGs to show", group="Fair Value Gap Settings") // Variables var bearBox = array.new_box() var bullBox = array.new_box() // Top Imbalance bearImb = low[2] <= open[1] and high >= close[1] bearGap = low[1] > high bearImbSize = low[2] - high if _bearImb and bearImb and bearImbSize > 0 or bearGap n = bearGap ? 1 : 2 array.push(bearBox, box.new(left=bar_index[1], top=low[n], right=bar_index+_width, bottom=high, bgcolor=_bearCol, border_color=_bearColBorder)) // Bottom Imbalance bullImb = high[2] >= open[1] and low <= close[1] bullImbSize = low - high[2] bullGap = high[1] < low if _bullImb and bullImb and bullImbSize > 0 or bullGap n = bullGap ? 1 : 2 array.push(bullBox, box.new(left=bar_index[1], top=low, right=bar_index+_width, bottom=high[n], bgcolor=_bullCol, border_color=_bullColBorder)) // Remove Mitigated remove_mitigate(arrayType, pos) => if array.size(arrayType) > 0 for i = array.size(arrayType) - 1 to 0 by 1 sbox = array.get(arrayType, i) top = box.get_top(sbox) bot = box.get_bottom(sbox) pass = pos =="Bull" ? low < bot + ((top - bot)/2) : high > top - ((top - bot)/2) if pass txt = pos =="Bull" ? "Bullish" : "Bearish" alert("Price (" + str.tostring(close) + ") inside "+txt+" Imbalance", alert.freq_once_per_bar) if _removeOld array.remove(arrayType, i) box.delete(sbox) // Run Functions remove_mitigate(bullBox, "Bull") remove_mitigate(bearBox, "Bear") // Remove Older Imb if array.size(bearBox) > _totalCount b = array.shift(bearBox) box.delete(b) if array.size(bullBox) > _totalCount b = array.shift(bullBox) box.delete(b) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////======= BREAKOUT PROBABILITY =======================/////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ~~ Tooltips { t1 = "The space between the levels can be adjusted with a percentage step. 1% means that each level is located 1% above/under the previous one." t2 = "Set the number of levels you want to display." t3 = "If a level got 0 % likelihood of being hit, the level is not displayed as default. Enable the option if you want to see all levels regardless of their values." t4 = "Enable this option if you want to display the backtest statistics for that a new high or low is made." string [] tbl_tips = array.from("Number of times price has reached the first highest percentage level", "Number of times price failed to reach the first highest percentage level", "Win/Loss ratio") //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Inputs { perc = input.float(1.0,title="Percentage Step",step=.1,minval=0,group="Breakout Probability Settings",tooltip=t1) nbr = input.int(1, title="Number of Lines",maxval=5,minval=1,group="Breakout Probability Settings",tooltip=t2) upCol = input.color(color.new(#333333, 0),title="",inline="col",group="Breakout Probability Settings"),dnCol=input.color(color.new(#333333, 0),title="",inline="col",group="Breakout Probability Settings") var bool [] bools = array.from(true,false) var bool [] alert_bool = array.from( input.bool(true,title="Ticker ID",group="Any alert() function call"), input.bool(true,title="High/Low Price",group="Any alert() function call"), input.bool(true,title="Bullish/Bearish Bias",group="Any alert() function call"), input.bool(true,title="Bullish/Bearish Percentage",group="Any alert() function call")) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Variables { b = bar_index o = open h = high l = low c = close step = c*(perc/100) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Save Values In Matrix { var total = matrix.new<int>(7,4,0) var vals = matrix.new<float>(5,4,0.0) var lines = matrix.new<line>(1,10,line(na)) var labels = matrix.new<label>(1,10,label(na)) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Save Number Of Green & Red Candles { green = c[1]>o[1] red = c[1]<o[1] if green prev = matrix.get(total,5,0) matrix.set(total,5,0,prev+1) if red prev = matrix.get(total,5,1) matrix.set(total,5,1,prev+1) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Functions { //Lines CreateLine(p,i,c)=> prevLine = matrix.get(lines,0,i) line.delete(prevLine) li = line.new(b[1],p,b,p,color=c,width=2) matrix.set(lines,0,i,li) //Labels CreateLabel(p,i,c,r,v)=> prevLabel = matrix.get(labels,0,i) label.delete(prevLabel) la = label.new(b+1,p,text=str.tostring(matrix.get(vals,r,v),format.percent), style=label.style_label_left,color=color.new(color.black,100),textcolor=c) matrix.set(labels,0,i,la) //Score Calculation Score(x,i)=> ghh = matrix.get(total,i,0) gll = matrix.get(total,i,1) rhh = matrix.get(total,i,2) rll = matrix.get(total,i,3) gtotal = matrix.get(total,5,0) rtotal = matrix.get(total,5,1) hh = h>=h[1] + x ll = l<=l[1] - x if green and hh matrix.set(total,i,0,ghh+1) matrix.set(vals,i,0,math.round(((ghh+1)/gtotal)*100,2)) if green and ll matrix.set(total,i,1,gll+1) matrix.set(vals,i,1,math.round(((gll+1)/gtotal)*100,2)) if red and hh matrix.set(total,i,2,rhh+1) matrix.set(vals,i,2,math.round(((rhh+1)/rtotal)*100,2)) if red and ll matrix.set(total,i,3,rll+1) matrix.set(vals,i,3,math.round(((rll+1)/rtotal)*100,2)) //Backtest Backtest(v)=> p1 = matrix.get(total,6,0) p2 = matrix.get(total,6,1) if v==h[1] if h>=v matrix.set(total,6,0,p1+1) else matrix.set(total,6,1,p2+1) else if l<=v matrix.set(total,6,0,p1+1) else matrix.set(total,6,1,p2+1) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} // ~~ Code { //Run Score Function Score(0,0) Score(step,1) Score(step*2,2) Score(step*3,3) Score(step*4,4) //Fetch Score Values a1 = matrix.get(vals,0,0) b1 = matrix.get(vals,0,1) a2 = matrix.get(vals,0,2) b2 = matrix.get(vals,0,3) //Lines & Labels & Alerts for i=0 to nbr-1 hide = array.get(bools,0) if not hide or (hide and (green?math.min(matrix.get(vals,i,0), matrix.get(vals,i,1))>0: math.min(matrix.get(vals,i,2), matrix.get(vals,i,3))>0)) hi = h[1]+(step*i) lo = l[1]-(step*i) //Plot Lines if showBreakout CreateLine(hi,i,upCol) CreateLine(lo,5+i,dnCol) //Plot Labels if green and showBreakout CreateLabel(hi,i,upCol,i,0) CreateLabel(lo,5+i,dnCol,i,1) else if showBreakout CreateLabel(hi,i,upCol,i,2) CreateLabel(lo,5+i,dnCol,i,3) //Create Alert if array.includes(alert_bool, true) s1 = str.tostring(syminfo.ticker) s2 = "High Price: "+str.tostring(math.round_to_mintick(h[1]))+ " | Low Price: "+str.tostring(math.round_to_mintick(l[1])) s3 = green?(math.max(a1,b1)==a1?"BULLISH":"BEARISH"): (math.max(a2,b2)==a2?"BULLISH":"BEARISH") s4 = green?(math.max(a1,b1)==a1?a1:b1):(math.min(a2,b2)==a2?a2:b2) s5 = red ?(math.max(a2,b2)==a2?a2:b2):(math.min(a1,b1)==a1?a1:b1) string [] str_vals = array.from(s1,s2,"BIAS: "+s3, "Percentage: High: "+str.tostring(s4,format.percent) +" | Low: "+str.tostring(s5,format.percent)) output = array.new_string() for x=0 to array.size(alert_bool)-1 if array.get(alert_bool,x) array.push(output,array.get(str_vals,x)) //Alert Is Triggered On Every Bar Open With Bias And Percentage Ratio alert(array.join(output,'\n'),alert.freq_once_per_bar) else //Delete Old Lines & Labels line.delete(matrix.get(lines,0,i)) line.delete(matrix.get(lines,0,5+i)) label.delete(matrix.get(labels,0,i)) label.delete(matrix.get(labels,0,5+i)) //Run Backtest Function Backtest(green?(math.max(a1,b1)==a1?h[1]:l[1]):(math.max(a2,b2)==a2?h[1]:l[1])) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
Session candles & reversals / quantifytools
https://www.tradingview.com/script/HjXrfMMg-Session-candles-reversals-quantifytools/
quantifytools
https://www.tradingview.com/u/quantifytools/
758
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© quantifytools //@version=5 indicator("Session candles & session reversals (+ Backtest)", max_boxes_count=500, max_lines_count=500, max_labels_count=500, overlay=true) // Inputs //Session time, session candle offset and show/hide session candle groupSession = "Sessions" //Session 1 (London) show_london = input(title='Show session #1', defval=true, inline="london", group=groupSession) i_londonOffset = input.int(0, "", inline="london", minval=0, group=groupSession, tooltip="Moves candle forward by specified amount of bars.") london = input.session(title="Session #1 period", defval='0800-1700', tooltip="London by default (UTC)", group=groupSession) //Session 2 (New York) show_ny = input(title='Show session #2', defval=true, inline="ny", group=groupSession) i_nyOffset = input.int(0, "", inline="ny", minval=0, group=groupSession) ny = input.session(title="Session #2 period", defval='1300-2200', tooltip="New York by default (UTC)", group=groupSession) //Session 3 (Sydney) show_sydney = input(title='Show session #3', defval=true, inline="sydney", group=groupSession) i_sydneyOffset = input.int(0, "", inline="sydney", minval=0, group=groupSession) sydney = input.session(title="Session #3 period", defval='2100-0600', tooltip="Sydney by default (UTC)", group=groupSession) //Session 4 (Tokyo) show_tokyo = input(title='Show session #4', defval=true, inline="tokyo", group=groupSession) i_tokyoOffset = input.int(0, "", inline="tokyo", minval=0, group=groupSession) tokyo = input.session(title="Session #4 period", defval='0000-0900', tooltip="Tokyo by default (UTC)", group=groupSession) //Session moving average type, length and selected sessions for MA groupMa = "Session moving average" i_smoothingType = input.string("SMA", "", options=["SMA", "EMA", "HMA", "RMA", "WMA"], group=groupMa, inline="ma") i_sessionMaLength = input.int(20, "", group=groupMa, inline="ma") i_useSession1Ma = input.bool(true, "Include session #1", group=groupMa) i_useSession2Ma = input.bool(true, "Include session #2", group=groupMa) i_useSession3Ma = input.bool(true, "Include session #3", group=groupMa) i_useSession4Ma = input.bool(true, "Include session #4", group=groupMa) //Hide chart candles/bars, highlight sessions for selected session candles, hide timeframe notification, numerize sessions groupChart = "Chart" i_highlightBt = input.string("None", "Highlight backtesting visuals", options=["None", "Session #1", "Session #2", "Session #3", "Session #4"], group=groupChart) i_hideChart = input.bool(true, "Hide chart", tooltip="", group=groupChart) i_highlightSession = input.bool(false, "Highlight session periods", group=groupChart, tooltip="Highlights session periods on chart background.") i_numberedSessions = input.bool(false, "Numerize sessions", group=groupChart, tooltip="Replaces L, N, S, T with 1, 2, 3, 4. Helps with custom sessions.") i_hideNotification = input.bool(false, "Hide timeframe notification", group=groupChart, tooltip="Hides timeframe notification that pops up when timeframe is > 1 hour.") //Colors groupColor= "Colors" i_maColUp = input.color(color.green, "MA β–²", group=groupColor, inline="ma") i_maColDown = input.color(color.red, "MA β–Ό", group=groupColor, inline="ma") i_londonColUp = input.color(#c8e6c9, "Session #1 β–²", group=groupColor, inline="session1") i_londonColDown = input.color(#faa1a4, "Session #1 β–Ό", group=groupColor, inline="session1") i_londonColSession = input.color(color.gray, "Session #1 ON", group=groupColor, inline="session1", tooltip="Session background color. Visible only if enabled.") i_nyColUp = input.color(#81c784, "Session #2 β–²", group=groupColor, inline="session2") i_nyColDown = input.color(#f46166, "Session #2 β–Ό", group=groupColor, inline="session2") i_nyColSession = input.color(color.black, "Session #2 ON", group=groupColor, inline="session2") i_sydneyColUp = input.color(#05900b, "Session #3 β–²", group=groupColor, inline="session3") i_sydneyColDown = input.color(#f23645, "Session #3 β–Ό", group=groupColor, inline="session3") i_sydneyColSession = input.color(color.blue, "Session #3 ON", group=groupColor, inline="session3") i_tokyoColUp = input.color(#004505, "Session #4 β–²", group=groupColor, inline="session4") i_tokyoColDown = input.color(#880e4f, "Session #4 β–Ό", group=groupColor, inline="session4") i_tokyoColSession = input.color(color.navy, "Session #4 ON", group=groupColor, inline="session4") // Session start, on and end functions sessionStart(session) => na(time(timeframe.period, session, "GMT"))[1] and not na(time(timeframe.period, session, "GMT")) sessionOn(session) => not na(time(timeframe.period, session, "GMT")) sessionEnd(session) => na(time(timeframe.period, session, "GMT")) and not na(time(timeframe.period, session, "GMT"))[1] // Session OHLC arrays //London var londonOpen = array.new_float(0, 0) var londonHigh = array.new_float(0, 0) var londonLow = array.new_float(0, 0) var londonClose = array.new_float(0, 0) recentLondonOpen = array.size(londonOpen) > 0 ? array.get(londonOpen, 0) : na recentLondonHigh = array.size(londonHigh) > 0 ? array.get(londonHigh, 0) : na recentLondonLow = array.size(londonLow) > 0 ? array.get(londonLow, 0) : na recentLondonClose = array.size(londonClose) > 0 ? array.get(londonClose, 0) : na //New York var nyOpen = array.new_float(0, 0) var nyHigh = array.new_float(0, 0) var nyLow = array.new_float(0, 0) var nyClose = array.new_float(0, 0) recentNyOpen = array.size(nyOpen) > 0 ? array.get(nyOpen, 0) : na recentNyHigh = array.size(nyHigh) > 0 ? array.get(nyHigh, 0) : na recentNyLow = array.size(nyLow) > 0 ? array.get(nyLow, 0) : na recentNyClose = array.size(nyClose) > 0 ? array.get(nyClose, 0) : na //Sydney var sydneyOpen = array.new_float(0, 0) var sydneyHigh = array.new_float(0, 0) var sydneyLow = array.new_float(0, 0) var sydneyClose = array.new_float(0, 0) recentSydneyOpen = array.size(sydneyOpen) > 0 ? array.get(sydneyOpen, 0) : na recentSydneyHigh = array.size(sydneyHigh) > 0 ? array.get(sydneyHigh, 0) : na recentSydneyLow = array.size(sydneyLow) > 0 ? array.get(sydneyLow, 0) : na recentSydneyClose = array.size(sydneyClose) > 0 ? array.get(sydneyClose, 0) : na //Tokyo var tokyoOpen = array.new_float(0, 0) var tokyoHigh = array.new_float(0, 0) var tokyoLow = array.new_float(0, 0) var tokyoClose = array.new_float(0, 0) recentTokyoOpen = array.size(tokyoOpen) > 0 ? array.get(tokyoOpen, 0) : na recentTokyoHigh = array.size(tokyoHigh) > 0 ? array.get(tokyoHigh, 0) : na recentTokyoLow = array.size(tokyoLow) > 0 ? array.get(tokyoLow, 0) : na recentTokyoClose = array.size(tokyoClose) > 0 ? array.get(tokyoClose, 0) : na // Session calculations //Initializing session highest high/lowest low trackers var float londonHh = 0 var float londonLl = 0 var float nyHh = 0 var float nyLl = 0 var float sydneyHh = 0 var float sydneyLl = 0 var float tokyoHh = 0 var float tokyoLl = 0 //London calculations //If session starts, add open to array, high to HH tracker, low to LL tracker if sessionStart(london) array.unshift(londonOpen, open) londonHh := high londonLl := low //If session is on and high > HH tracker value, replace HH tracker value with high if sessionOn(london) and high > londonHh[1] londonHh := high //If session is on and low < LL tracker value, replace LL tracker value with low if sessionOn(london) and low < londonLl[1] londonLl := low //If session has ended, add session close (candle open, because session ended 1 time period ago) and add highest high/lowest low to session arrays if sessionEnd(london) array.unshift(londonClose, open) array.unshift(londonHigh, londonHh) array.unshift(londonLow, londonLl) //Repeating above steps for all other sessions. //New York calculations if sessionStart(ny) array.unshift(nyOpen, open) nyHh := high nyLl := low if sessionOn(ny) and high > nyHh[1] nyHh := high if sessionOn(ny) and low < nyLl[1] nyLl := low if sessionEnd(ny) array.unshift(nyClose, open) array.unshift(nyHigh, nyHh) array.unshift(nyLow, nyLl) //Sydney calculations if sessionStart(sydney) array.unshift(sydneyOpen, open) sydneyHh := high sydneyLl := low if sessionOn(sydney) and high > sydneyHh[1] sydneyHh := high if sessionOn(sydney) and low < sydneyLl[1] sydneyLl := low if sessionEnd(sydney) array.unshift(sydneyClose, open) array.unshift(sydneyHigh, sydneyHh) array.unshift(sydneyLow, sydneyLl) //Tokyo calculations if sessionStart(tokyo) array.unshift(tokyoOpen, open) tokyoHh := high tokyoLl := low if sessionOn(tokyo) and high > tokyoHh[1] tokyoHh := high if sessionOn(tokyo) and low < tokyoLl[1] tokyoLl := low if sessionEnd(tokyo) array.unshift(tokyoClose, open) array.unshift(tokyoHigh, tokyoHh) array.unshift(tokyoLow, tokyoLl) //Function to keep array sizes fixed arraySize(sessionOpen, sessionHigh, sessionLow, sessionClose) => sizeLimit = 2 if array.size(sessionOpen) >sizeLimit array.remove(sessionOpen, sizeLimit) array.remove(sessionHigh, sizeLimit) array.remove(sessionLow, sizeLimit) array.remove(sessionClose, sizeLimit) //Clearing arrays arraySize(londonOpen, londonHigh, londonLow, londonClose) arraySize(nyOpen, nyHigh, nyLow, nyClose) arraySize(sydneyOpen, sydneyHigh, sydneyLow, sydneyClose) arraySize(tokyoOpen, tokyoHigh, tokyoLow, tokyoClose) // Session moving average //Function for user defined smoothing method smoothedValue(source, length) => i_smoothingType == "SMA" ? ta.sma(source, length) : i_smoothingType == "EMA" ? ta.ema(source, length) : i_smoothingType == "HMA" ? ta.hma(source, length) : i_smoothingType == "RMA" ? ta.rma(source, length) : ta.wma(source, length) //Session MA's, if not included use 0 londonSma = i_useSession1Ma ? smoothedValue(recentLondonClose, i_sessionMaLength) : 0 nySma = i_useSession2Ma ? smoothedValue(recentNyClose, i_sessionMaLength) : 0 sydneySma = i_useSession3Ma ? smoothedValue(recentSydneyClose, i_sessionMaLength) : 0 tokyoSma = i_useSession4Ma ? smoothedValue(recentTokyoClose, i_sessionMaLength) : 0 //Calculate amount of sessions included in MA calculation int maDivider = 0 if i_useSession1Ma maDivider += 1 if i_useSession2Ma maDivider += 1 if i_useSession3Ma maDivider += 1 if i_useSession4Ma maDivider += 1 //Selected session MA's divided by amount of selected sessions hybridSma = (nySma + tokyoSma + londonSma + sydneySma) / maDivider // Session reversals //Session reversal function with session OHLC variables sessionReversal(sessionOpen, sessionHigh, sessionLow, sessionClose) => //Position of session close relative to range (high - low) sessionPos = (sessionClose - sessionLow) / (sessionHigh - sessionLow) //Position of session open relative to range (high - low) sessionOpenPos = (sessionOpen - sessionLow) / (sessionHigh - sessionLow) //Session high lower than previous high, session low lower than previous low, close >= 65% position (1% being low, 100% being high) and session open at >= 40% position relative to range. A wick up. wickUp = sessionHigh < sessionHigh[1] and sessionLow < sessionLow[1] and sessionPos >= 0.65 and sessionOpenPos >= 0.40 //Session high higher than previous high, session low higher than previous low, close <= 35% position and session open <= 60% position relative to range. A wick down. wickDown = sessionHigh > sessionHigh[1] and sessionLow > sessionLow[1] and sessionPos <= 0.35 and sessionOpenPos <= 0.60 //Session high higher than previous high, session low lower than previous low and close position at same 65%/35% values. Engulfing candle up/down. engulfUp = sessionHigh > sessionHigh[1] and sessionLow < sessionLow[1] and sessionPos >= 0.65 engulfDown = sessionHigh > sessionHigh[1] and sessionLow < sessionLow[1] and sessionPos <= 0.35 [wickUp, wickDown, engulfUp, engulfDown] //Fetching session reversals for each session [wickUpLondon, wickDownLondon, engulfUpLondon, engulfDownLondon] = sessionReversal(recentLondonOpen, recentLondonHigh, recentLondonLow, recentLondonClose) [wickUpNy, wickDownNy, engulfUpNy, engulfDownNy] = sessionReversal(recentNyOpen, recentNyHigh, recentNyLow, recentNyClose) [wickUpSydney, wickDownSydney, engulfUpSydney, engulfDownSydney] = sessionReversal(recentSydneyOpen, recentSydneyHigh, recentSydneyLow, recentSydneyClose) [wickUpTokyo, wickDownTokyo, engulfUpTokyo, engulfDownTokyo] = sessionReversal(recentTokyoOpen, recentTokyoHigh, recentTokyoLow, recentTokyoClose) // Session reversal backtest //Sessions are backtested by calculating odds of next matching session closing in supporting direction, known as win rate. //Magnitude is measured by calculating percentage increase/decrease between session reversal close and next session high/low. This calculation is done only when a reversal is succesful (closes higher/lower compared previous matching session). //Session reversal backtest function sessionReversalBt(wickUp, wickDown, engulfUp, engulfDown, sessionClose, sessionHigh, sessionLow, session) => //Get bar_index space between sessions btPeriod = ta.valuewhen(sessionEnd(session), bar_index, 0) - ta.valuewhen(sessionEnd(session), bar_index, 1) //Initializing counters var int sessionRevUpCount = 0 var int sessionRevDownCount = 0 var int succesfulRevUpCount = 0 var int succesfulRevDownCount = 0 var float revUpDepth = 0 var float revDownDepth = 0 //Any reversal up/down, either wick or engulfing. anyRevUp = wickUp or engulfUp anyRevDown = wickDown or engulfDown //Add 1 to reversal counter when session reversal occurs if anyRevUp sessionRevUpCount += 1 else if anyRevDown sessionRevDownCount += 1 //If session closes higher than previous session and previous session was a reversal, add 1 to succesful reversal counter. Add percentage increase (from previous session close to current session high) to magnitude counter. if sessionClose > sessionClose[1] and anyRevUp[btPeriod] succesfulRevUpCount += 1 revUpDepth += (sessionHigh / sessionClose[1]) - 1 //Same, but for reversals down if sessionClose < sessionClose[1] and anyRevDown[btPeriod] succesfulRevDownCount += 1 revDownDepth += (sessionLow / sessionClose[1]) - 1 //Form win rates by dividing succesful reversal count with total reversal count revUpWr = math.round((succesfulRevUpCount / sessionRevUpCount) * 100, 0) revDownWr = math.round((succesfulRevDownCount / sessionRevDownCount) * 100, 0) //Form average magnitude by dividing percentage increase/decrease with total reversal count revUpMagnitude = math.round((revUpDepth / sessionRevUpCount) * 100, 2) revDownMagnitude = math.round((revDownDepth / sessionRevDownCount) * 100, 2) [sessionRevUpCount, sessionRevDownCount, succesfulRevDownCount, succesfulRevUpCount, revUpDepth, revDownDepth, revUpWr, revDownWr, revUpMagnitude, revDownMagnitude] //Fetching backtest results for each session reversal [revUpsLondon, revDownsLondon, sRevDownsLondon, sRevUpsLondon, LondonUpDepth, LondonDownDepth, LondonRevUpWr, LondonRevDownWr, LondonRevUpMagnitude, LondonRevDownMagnitude] = sessionReversalBt(wickUpLondon, wickDownLondon, engulfUpLondon, engulfDownLondon, recentLondonClose, recentLondonHigh, recentLondonLow, london) [revUpsNy, revDownsNy, sRevDownsNy, sRevUpsNy, NyUpDepth, NyDownDepth, NyRevUpWr, NyRevDownWr, NyRevUpMagnitude, NyRevDownMagnitude] = sessionReversalBt(wickUpNy, wickDownNy, engulfUpNy, engulfDownNy, recentNyClose, recentNyHigh, recentNyLow, ny) [revUpsSydney, revDownsSydney, sRevDownsSydney, sRevUpsSydney, SydneyUpDepth, SydneyDownDepth, SydneyRevUpWr, SydneyRevDownWr, SydneyRevUpMagnitude, SydneyRevDownMagnitude] = sessionReversalBt(wickUpSydney, wickDownSydney, engulfUpSydney, engulfDownSydney, recentSydneyClose, recentSydneyHigh, recentSydneyLow, sydney) [revUpsTokyo, revDownsTokyo, sRevDownsTokyo, sRevUpsTokyo, TokyoUpDepth, TokyoDownDepth, TokyoRevUpWr, TokyoRevDownWr, TokyoRevUpMagnitude, TokyoRevDownMagnitude] = sessionReversalBt(wickUpTokyo, wickDownTokyo, engulfUpTokyo, engulfDownTokyo, recentTokyoClose, recentTokyoHigh, recentTokyoLow, tokyo) // Plot related calculations //Current timeframe currentTf = timeframe.in_seconds(timeframe.period) / 60 //Note users when timeframe is above 1H and possibly not matching with selected session time periods tfNotification = currentTf > 60 and i_hideNotification == false ? "(!) Make sure timeframe supports selected session time periods. By default 1H is recommended." : "" //Session candle colors londonColor = recentLondonClose > recentLondonClose[1] ? i_londonColUp : i_londonColDown nyColor = recentNyClose > recentNyOpen ? i_nyColUp : i_nyColDown sydneyColor = recentSydneyClose > recentSydneyClose[1] ? i_sydneyColUp : i_sydneyColDown tokyoColor = recentTokyoClose > recentTokyoClose[1] ? i_tokyoColUp : i_tokyoColDown //MA color, using "switch" method to avoid incorrect colors when MA value is equal to last MA value (happens on lower timeframes) var color maCol = color.gray if hybridSma > hybridSma[1] maCol := i_maColUp if hybridSma == hybridSma[1] maCol := maCol[1] if hybridSma < hybridSma[1] maCol := i_maColDown //Session candle visuals borderWidth = 0 linewidth = 2 //Session reversal colors //Any session reversal anyWickUp = wickUpNy or wickUpLondon or wickUpSydney or wickUpTokyo anyWickDown = wickDownNy or wickDownLondon or wickDownSydney or wickDownTokyo anyEngulfUp = engulfUpNy or engulfUpLondon or engulfUpSydney or engulfUpTokyo anyEngulfDown = engulfDownNy or engulfDownLondon or engulfDownSydney or engulfDownTokyo //Session reversal color revCol = anyWickUp ? color.green : anyWickDown ? color.red : anyEngulfUp ? color.teal : anyEngulfDown ? color.maroon : na //Reversal number/text. Use LNST by default, 1-4 if numerized sessions is on. session1Text = i_numberedSessions ? "1" : "L" session2Text = i_numberedSessions ? "2" : "N" session3Text = i_numberedSessions ? "3" : "S" session4Text = i_numberedSessions ? "4" : "T" //Reversal label texts revUpL = "β–²" + "\n" + session1Text revDownL = session1Text + "\n" + "β–Ό" revUpN = "β–²" + "\n" + session2Text revDownN = session2Text + "\n" + "β–Ό" revUpS = "β–²" + "\n" + session3Text revDownS = session3Text + "\n" + "β–Ό" revUpT = "β–²" + "\n" + session4Text revDownT = session4Text + "\n" + "β–Ό" //Highest session reversal up win rate highestWrUp = LondonRevUpWr >= NyRevUpWr and LondonRevUpWr >= SydneyRevUpWr and LondonRevUpWr >= TokyoRevUpWr ? 1 : NyRevUpWr >= LondonRevUpWr and NyRevUpWr >= SydneyRevUpWr and NyRevUpWr >= TokyoRevUpWr ? 2 : SydneyRevUpWr >= LondonRevUpWr and SydneyRevUpWr >= NyRevUpWr and SydneyRevUpWr >= TokyoRevUpWr ? 3 : 4 //Highest session reversal down win rate highestWrDown = LondonRevDownWr >= NyRevDownWr and LondonRevDownWr >= SydneyRevDownWr and LondonRevDownWr >= TokyoRevDownWr ? 1 : NyRevDownWr >= LondonRevDownWr and NyRevDownWr >= SydneyRevDownWr and NyRevDownWr >= TokyoRevDownWr ? 2 : SydneyRevDownWr >= LondonRevDownWr and SydneyRevDownWr >= NyRevDownWr and SydneyRevDownWr >= TokyoRevDownWr ? 3 : 4 //Highest session magnitude up highestMagnitudeUp = LondonRevUpMagnitude >= NyRevUpMagnitude and LondonRevUpMagnitude >= SydneyRevUpMagnitude and LondonRevUpMagnitude >= TokyoRevUpMagnitude ? 1 : NyRevUpMagnitude >= LondonRevUpMagnitude and NyRevUpMagnitude >= SydneyRevUpMagnitude and NyRevUpMagnitude >= TokyoRevUpMagnitude ? 2 : SydneyRevUpMagnitude >= LondonRevUpMagnitude and SydneyRevUpMagnitude >= NyRevUpMagnitude and SydneyRevUpMagnitude >= TokyoRevUpMagnitude ? 3 : 4 //Highest session magnitude down highestMagnitudeDown = LondonRevDownMagnitude <= NyRevDownMagnitude and LondonRevDownMagnitude <= SydneyRevDownMagnitude and LondonRevDownMagnitude <= TokyoRevDownMagnitude ? 1 : NyRevDownMagnitude <= LondonRevDownMagnitude and NyRevDownMagnitude <= SydneyRevDownMagnitude and NyRevDownMagnitude <= TokyoRevDownMagnitude ? 2 : SydneyRevDownMagnitude <= LondonRevDownMagnitude and SydneyRevDownMagnitude <= NyRevDownMagnitude and SydneyRevDownMagnitude <= TokyoRevDownMagnitude ? 3 : 4 //Reversal backtest table texts. Add πŸ”Έ if given session reversal backtest metric is best perofrming revUpLText = session1Text + " β–² : " + str.tostring(revUpsLondon) + " | " + "WR: " + str.tostring(LondonRevUpWr) + "%" + (highestWrUp == 1 ? " πŸ”Έ" : "") + " | " + "M: " + str.tostring(LondonRevUpMagnitude) + "%" + (highestMagnitudeUp == 1 ? " πŸ”Έ" : "") revDownLText = session1Text + " β–Ό : " + str.tostring(revDownsLondon) + " | " + "WR: " + str.tostring(LondonRevDownWr) + "%" + (highestWrDown == 1 ? " πŸ”Έ" : "") + " | " + " M: " + str.tostring(LondonRevDownMagnitude) + "%" + (highestMagnitudeDown == 1 ? " πŸ”Έ" : "") revUpNText = session2Text + " β–² : " + str.tostring(revUpsNy) + " | " + "WR: " + str.tostring(NyRevUpWr) + "%" + (highestWrUp == 2 ? " πŸ”Έ" : "") + " | " + "M: " + str.tostring(NyRevUpMagnitude) + "%" + (highestMagnitudeUp == 2 ? " πŸ”Έ" : "") revDownNText = session2Text + " β–Ό : " + str.tostring(revDownsNy) + " | " + "WR: " + str.tostring(NyRevDownWr) + "%" + (highestWrDown == 2 ? " πŸ”Έ" : "") + " | " + " M: " + str.tostring(NyRevDownMagnitude) + "%" + (highestMagnitudeDown == 2 ? " πŸ”Έ" : "") revUpSText = session3Text + " β–² : " + str.tostring(revUpsSydney) + " | " + "WR: " + str.tostring(SydneyRevUpWr) + "%" + (highestWrUp == 3 ? " πŸ”Έ" : "") + " | " + "M: " + str.tostring(SydneyRevUpMagnitude) + "%" + (highestMagnitudeUp == 3 ? " πŸ”Έ" : "") revDownSText = session3Text + " β–Ό : " + str.tostring(revDownsSydney) + " | " + "WR: " + str.tostring(SydneyRevDownWr) + "%" + (highestWrDown == 3 ? " πŸ”Έ" : "") + " | " + " M: " + str.tostring(SydneyRevDownMagnitude) + "%" + (highestMagnitudeDown == 3 ? " πŸ”Έ" : "") revUpTText = session4Text + " β–² : " + str.tostring(revUpsTokyo) + " | " + "WR: " + str.tostring(TokyoRevUpWr) + "%" + (highestWrUp == 4 ? " πŸ”Έ" : "") + " | " + "M: " + str.tostring(TokyoRevUpMagnitude) + "%" + (highestMagnitudeUp == 4 ? " πŸ”Έ" : "") revDownTText = session4Text + " β–Ό : " + str.tostring(revDownsTokyo) + " | " + "WR: " + str.tostring(TokyoRevDownWr) + "%" + (highestWrDown == 4 ? " πŸ”Έ" : "") + " | " + " M: " + str.tostring(TokyoRevDownMagnitude) + "%" + (highestMagnitudeDown == 4 ? " πŸ”Έ" : "") //Function for forming session candles using line and box, available for first 500 bars. Clear look. Forming session reversal labels also. sessionCandles(session, sessionOffset, sessionOpen, sessionHigh, sessionLow, sessionClose, sessionWickUp, sessionEngUp, sessionWickDown, sessionEngDown, sessionCol, revUpText, revDownText) => //Session candles if sessionEnd(session)[1] line.new(bar_index + sessionOffset, sessionHigh, bar_index + sessionOffset, sessionLow, xloc=xloc.bar_index, color=sessionCol, width=linewidth, style=line.style_solid) box.new(left=bar_index - 1 + sessionOffset, top=sessionClose, right=bar_index + 1 + sessionOffset, bottom=sessionOpen, bgcolor=sessionCol, border_color=color.new(color.white, 100), border_width=borderWidth) //Session reversals if (sessionWickUp or sessionEngUp) and sessionEnd(session)[1] and barstate.isconfirmed label.new(x=bar_index + sessionOffset, y=sessionLow, xloc=xloc.bar_index, yloc=yloc.price, text=revUpText, style=label.style_label_up, textcolor=color.new(revCol, 1), color=color.new(color.green, 100), size=size.normal) if (sessionWickDown or sessionEngDown) and sessionEnd(session)[1] and barstate.isconfirmed label.new(x=bar_index + sessionOffset, y=sessionHigh, xloc=xloc.bar_index, yloc=yloc.price, text=revDownText, style=label.style_label_down, textcolor=color.new(revCol, 1), color=color.new(color.red, 100), size=size.normal) //Function for forming session candles using plotcandle() function, available for all bars. Not so clear, but goes back indefinitely. sessionCandles2(session, sessionOffset, showSession, sessionOpen, sessionHigh, sessionLow, sessionClose) => //Session OHLC values with offset for plotcandle() function sessionEndO = ta.barssince(sessionEnd(session)) == 1 + sessionOffset and showSession ? sessionOpen : na sessionEndH = ta.barssince(sessionEnd(session)) == 1 + sessionOffset and showSession ? sessionHigh : na sessionEndL = ta.barssince(sessionEnd(session)) == 1 + sessionOffset and showSession ? sessionLow : na sessionEndC = ta.barssince(sessionEnd(session)) == 1 + sessionOffset and showSession ? sessionClose : na [sessionEndO, sessionEndH, sessionEndL, sessionEndC] //Function for forming backtest visuals. sessionReversalBtVisuals(session, sessionHigh, sessionLow, sessionClose, succesfulRevsUp, succesfulRevsDown, revsUp, revsDown, revUpWr, revUpMagnitude, revDownWr, revDownMagnitude, sessionOffset) => //Get bar_index space between session reversals btPeriod = ta.valuewhen(sessionEnd(session), bar_index, 0) - ta.valuewhen(sessionEnd(session), bar_index, 1) //Reversal up texts sRevUpMagnitudeText = " Gain: +" + str.tostring(math.round((sessionHigh / sessionClose[1]) - 1, 4) * 100) + "%" + "\n" + "β—£ Avg: +" + str.tostring(revUpMagnitude) + "%" sRevUpWrText = "\n" + "\n" + "\n" + "Succesful: " + str.tostring(succesfulRevsUp) + "\n" + "Win rate: " + str.tostring(revUpWr) + "%" revUpCountText = "\n" + "\n" + "Count: " + str.tostring(revsUp) //Reversal down texts sRevDownMagnitudeText = "β—€ Gain: " + str.tostring(math.round((sessionLow / sessionClose[1]) - 1, 4) * 100) + "%" + "\n" + " Avg: " + str.tostring(revDownMagnitude) + "%" sRevDownWrText = "Succesful: " + str.tostring(succesfulRevsDown) + "\n" + "Win rate: " + str.tostring(revDownWr) + "%" + "\n" + "\n" + "\n" revDownCountText = "Count: " + str.tostring(revsDown) + "\n" + "\n" //If reversal is succesful and session ended 1 period ago, plot line and labels if succesfulRevsUp > succesfulRevsUp[1] and sessionEnd(session)[1] line.new(bar_index[btPeriod] + sessionOffset, sessionClose[1], bar_index + sessionOffset, sessionHigh, xloc=xloc.bar_index, color=color.white, width=1, style=line.style_solid) label.new(x=bar_index + sessionOffset, y=sessionHigh, xloc=xloc.bar_index, yloc=yloc.price, text=sRevUpMagnitudeText, style=label.style_label_lower_left, textcolor=color.new(color.white, 1), color=color.new(color.green, 100), size=size.normal) label.new(x=bar_index[btPeriod] + sessionOffset, y=sessionLow[btPeriod], xloc=xloc.bar_index, yloc=yloc.price, text=sRevUpWrText, style=label.style_label_up, textcolor=color.new(color.white, 1), color=color.new(color.green, 100), size=size.normal) //If reversal occurs, plot label if revsUp > revsUp[1] label.new(x=bar_index + sessionOffset, y=sessionLow, xloc=xloc.bar_index, yloc=yloc.price, text=revUpCountText, style=label.style_label_up, textcolor=color.new(color.white, 1), color=color.new(color.green, 100), size=size.normal) //If reversal is succesful and session ended 1 period ago, plot line and labels if succesfulRevsDown > succesfulRevsDown[1] and sessionEnd(session)[1] line.new(bar_index[btPeriod] + sessionOffset, sessionClose[1], bar_index + sessionOffset, sessionLow, xloc=xloc.bar_index, color=color.white, width=1, style=line.style_solid) label.new(x=bar_index + sessionOffset, y=sessionLow, xloc=xloc.bar_index, yloc=yloc.price, text=sRevDownMagnitudeText, style=label.style_label_upper_left, textcolor=color.new(color.white, 1), color=color.new(color.red, 100), size=size.normal) label.new(x=bar_index[btPeriod] + sessionOffset, y=sessionHigh[btPeriod], xloc=xloc.bar_index, yloc=yloc.price, text=sRevDownWrText, style=label.style_label_down, textcolor=color.new(color.white, 1), color=color.new(color.green, 100), size=size.normal) //If reversal occurs, plot label if revsDown > revsDown[1] label.new(x=bar_index + sessionOffset, y=sessionHigh, xloc=xloc.bar_index, yloc=yloc.price, text=revDownCountText, style=label.style_label_down, textcolor=color.new(color.white, 1), color=color.new(color.green, 100), size=size.normal) //Session candles using line and box londonCandles = show_london ? sessionCandles(london, i_londonOffset, recentLondonOpen, recentLondonHigh, recentLondonLow, recentLondonClose, wickUpLondon, engulfUpLondon, wickDownLondon, engulfDownLondon, londonColor, revUpL, revDownL) : na nyCandles = show_ny ? sessionCandles(ny, i_nyOffset, recentNyOpen, recentNyHigh, recentNyLow, recentNyClose, wickUpNy, engulfUpNy, wickDownNy, engulfDownNy, nyColor, revUpN, revDownN) : na sydneyCandles = show_sydney ? sessionCandles(sydney, i_sydneyOffset, recentSydneyOpen, recentSydneyHigh, recentSydneyLow, recentSydneyClose, wickUpSydney, engulfUpSydney, wickDownSydney, engulfDownSydney, sydneyColor, revUpS, revDownS) : na tokyoCandles = show_tokyo ? sessionCandles(tokyo, i_tokyoOffset, recentTokyoOpen, recentTokyoHigh, recentTokyoLow, recentTokyoClose, wickUpTokyo, engulfUpTokyo, wickDownTokyo, engulfDownTokyo, tokyoColor, revUpT, revDownT) : na //Session candles using plotcandle() [sessionEndLondonO, sessionEndLondonH, sessionEndLondonL, sessionEndLondonC] = sessionCandles2(london, i_londonOffset, show_london, recentLondonOpen, recentLondonHigh, recentLondonLow, recentLondonClose) [sessionEndNyO, sessionEndNyH, sessionEndNyL, sessionEndNyC] = sessionCandles2(ny, i_nyOffset, show_ny, recentNyOpen, recentNyHigh, recentNyLow, recentNyClose) [sessionEndSydneyO, sessionEndSydneyH, sessionEndSydneyL, sessionEndSydneyC] = sessionCandles2(sydney, i_sydneyOffset, show_sydney, recentSydneyOpen, recentSydneyHigh, recentSydneyLow, recentSydneyClose) [sessionEndTokyoO, sessionEndTokyoH, sessionEndTokyoL, sessionEndTokyoC] = sessionCandles2(tokyo, i_tokyoOffset, show_tokyo, recentTokyoOpen, recentTokyoHigh, recentTokyoLow, recentTokyoClose) //Session reversal backtest visuals londonBtVisuals = i_highlightBt == "Session #1" and show_london ? sessionReversalBtVisuals(london, recentLondonHigh, recentLondonLow, recentLondonClose, sRevUpsLondon, sRevDownsLondon, revUpsLondon, revDownsLondon, LondonRevUpWr, LondonRevUpMagnitude, LondonRevDownWr, LondonRevDownMagnitude, i_londonOffset) : na nyBtVisuals = i_highlightBt == "Session #2" and show_ny ? sessionReversalBtVisuals(ny, recentNyHigh, recentNyLow, recentNyClose, sRevUpsNy, sRevDownsNy, revUpsNy, revDownsNy, NyRevUpWr, NyRevUpMagnitude, NyRevDownWr, NyRevDownMagnitude, i_nyOffset) : na sydneyBtVisuals = i_highlightBt == "Session #3" and show_sydney ? sessionReversalBtVisuals(sydney, recentSydneyHigh, recentSydneyLow, recentSydneyClose, sRevUpsSydney, sRevDownsSydney, revUpsSydney, revDownsSydney, SydneyRevUpWr, SydneyRevUpMagnitude, SydneyRevDownWr, SydneyRevDownMagnitude, i_sydneyOffset) : na tokyoBtVisuals = i_highlightBt == "Session #4" and show_tokyo ? sessionReversalBtVisuals(tokyo, recentTokyoHigh, recentTokyoLow, recentTokyoClose, sRevUpsTokyo, sRevDownsTokyo, revUpsTokyo, revDownsTokyo, TokyoRevUpWr, TokyoRevUpMagnitude, TokyoRevDownWr, TokyoRevDownMagnitude, i_tokyoOffset) : na // Plots //MA plot(hybridSma, color=maCol, title="Session moving average") //Regular session candle using plotcandle() function. plotcandle(sessionEndLondonO, sessionEndLondonH, sessionEndLondonL, sessionEndLondonC, color=londonColor) plotcandle(sessionEndNyO, sessionEndNyH, sessionEndNyL, sessionEndNyC, color=nyColor) plotcandle(sessionEndSydneyO, sessionEndSydneyH, sessionEndSydneyL, sessionEndSydneyC, color=sydneyColor) plotcandle(sessionEndTokyoO, sessionEndTokyoH, sessionEndTokyoL, sessionEndTokyoC, color=tokyoColor) //Session period background highlights bgcolor(i_highlightSession == true and show_london == true and sessionOn(london) ? color.new(i_londonColSession, 90) : na) bgcolor(i_highlightSession == true and show_london == true and sessionStart(london) ? color.new(i_londonColSession, 50) : na) bgcolor(i_highlightSession == true and show_london == true and sessionEnd(london) ? color.new(i_londonColSession, 50) : na) bgcolor(i_highlightSession == true and show_ny == true and sessionOn(ny) ? color.new(i_nyColSession, 90) : na) bgcolor(i_highlightSession == true and show_ny == true and sessionStart(ny) ? color.new(i_nyColSession, 50) : na) bgcolor(i_highlightSession == true and show_ny == true and sessionEnd(ny) ? color.new(i_nyColSession, 50) : na) bgcolor(i_highlightSession == true and show_sydney == true and sessionOn(sydney) ? color.new(i_sydneyColSession, 90) : na) bgcolor(i_highlightSession == true and show_sydney == true and sessionStart(sydney) ? color.new(i_sydneyColSession, 50) : na) bgcolor(i_highlightSession == true and show_sydney == true and sessionEnd(sydney) ? color.new(i_sydneyColSession, 50) : na) bgcolor(i_highlightSession == true and show_tokyo == true and sessionOn(tokyo) ? color.new(i_tokyoColSession, 90) : na) bgcolor(i_highlightSession == true and show_tokyo == true and sessionStart(tokyo) ? color.new(i_tokyoColSession, 50) : na) bgcolor(i_highlightSession == true and show_tokyo == true and sessionEnd(tokyo) ? color.new(i_tokyoColSession, 50) : na) //Hide chart barcolor(i_hideChart == true ? color.new(color.white, 100) : na) // Alerts //Confirmed session candle closes alertcondition(sessionEnd(london)[1], "Confirmed session #1 candle close", "Confirmed session #1 candle close detected") alertcondition(sessionEnd(ny)[1], "Confirmed session #2 candle close", "Confirmed session #2 candle close detected") alertcondition(sessionEnd(sydney)[1], "Confirmed session #3 candle close", "Confirmed session #3 candle close detected") alertcondition(sessionEnd(tokyo)[1], "Confirmed session #4 candle close", "Confirmed session #4 candle close detected") //Confirmed any session candle close anySessionClose = sessionEnd(london)[1] or sessionEnd(ny)[1] or sessionEnd(sydney)[1] or sessionEnd(tokyo)[1] alertcondition(anySessionClose, "Confirmed session (any) candle close", "Confirmed session (any) candle close detected") //Confirmed session reversals up alertcondition(revUpsLondon > revUpsLondon[1], "Confirmed session #1 reversal up", "Confirmed session #1 reversal up detected") alertcondition(revUpsNy > revUpsNy[1], "Confirmed session #2 reversal up", "Confirmed session #2 reversal up detected") alertcondition(revUpsSydney > revUpsSydney[1], "Confirmed session #3 reversal up", "Confirmed session #3 reversal up detected") alertcondition(revUpsTokyo > revUpsTokyo[1], "Confirmed session #4 reversal up", "Confirmed session #4 reversal up detected") //Confirmed any session reversal up anySessionRevUp = revUpsLondon > revUpsLondon[1] or revUpsNy > revUpsNy[1] or revUpsSydney > revUpsSydney[1] or revUpsTokyo > revUpsTokyo[1] alertcondition(anySessionRevUp, "Confirmed session (any) reversal up", "Confirmed session (any) reversal up detected") //Confirmed session reversals down alertcondition(revDownsLondon > revDownsLondon[1], "Confirmed session #1 reversal down", "Confirmed session #1 reversal down detected") alertcondition(revDownsNy > revDownsNy[1], "Confirmed session #2 reversal down", "Confirmed session #2 reversal down detected") alertcondition(revDownsSydney > revDownsSydney[1], "Confirmed session #3 reversal down", "Confirmed session #3 reversal down detected") alertcondition(revDownsTokyo > revDownsTokyo[1], "Confirmed session #4 reversal down", "Confirmed session #4 reversal down detected") //Confirmed any session reversal down anySessionRevDown = revDownsLondon > revDownsLondon[1] or revDownsNy > revDownsNy[1] or revDownsSydney > revDownsSydney[1] or revDownsTokyo > revDownsTokyo[1] alertcondition(anySessionRevDown, "Confirmed session (any) candle reversal down", "Confirmed session (any) reversal down detected") //Confirmed any session reversal up/down alertcondition(anySessionRevDown or anySessionRevUp, "Confirmed session (any) reversal up/down", "Confirmed session (any) reversal up/down detected") // Backtest table //Initialize backtest table and timeframe notification table var activeTable = table.new(position = position.top_right, columns = 50, rows = 50, bgcolor = color.rgb(29, 29, 29), border_width = 3, border_color = color.new(color.white, 100)) var notifyTable = table.new(position = position.bottom_right, columns = 50, rows = 50, bgcolor = color.new(color.white, 100), border_width = 3) //Populate backtest table cells table.cell(table_id = activeTable, column = 0, row = 0, text = revUpLText + "\n" + "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯" + "\n" + revDownLText, bgcolor=color.rgb(48, 48, 48), text_color = color.white) table.cell(table_id = activeTable, column = 1, row = 0, text = revUpNText + "\n" + "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯" + "\n" + revDownNText, bgcolor=color.rgb(48, 48, 48), text_color = color.white) table.cell(table_id = activeTable, column = 0, row = 2, text = revUpSText + "\n" + "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯" + "\n" + revDownSText, bgcolor=color.rgb(48, 48, 48), text_color = color.white) table.cell(table_id = activeTable, column = 1, row = 2, text = revUpTText + "\n" + "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯" + "\n" + revDownTText, bgcolor=color.rgb(48, 48, 48), text_color = color.white) //Populate timeframe notification table if applicable table.cell(table_id = notifyTable, column = 0, row = 0, text = "" + tfNotification, text_color=color.yellow, bgcolor = color.new(color.white, 100))
Rate of Change Candle Standardized (ROCCS)
https://www.tradingview.com/script/LEqcKpKw-Rate-of-Change-Candle-Standardized-ROCCS/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
74
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© peacefulLizard50262 //@version=5 indicator("CROC") OHLC(src, int len = 4) => Open = ta.sma(src[1], len) High = ta.highest(src, 1) Low = ta.lowest(src, 1) Close = ta.wma(src, len) [Open, High, Low, Close] source = input(close, "Source") length = input.int(9, "ROC Length") back = input.int(20, "Standardization Look Back") len = input.int(3, "Candle Transform Length") sel = input.bool(true, "Candle Colour", "Chance how the candles are colored. If this is enabled it will color the candles bassed on the transformed open/close. Otherwise this indicator will use source/source[1]") red = input.color(color.new(#ef5350, 0), "") green = input.color(color.new(#26a69a, 0), "") roc = (source - source[length])/source[length] sroc = (roc - ta.sma(roc, back)) / ta.stdev(roc, back) [Open, High, Low, Close] = OHLC(sroc, len) colour = sel ? Open < Close ? green : red : sroc > sroc[1] ? green : red plotcandle(Open, High, Low, Close, "RSI Candle", colour, colour, true, bordercolor = colour)
Fusion Oscillator (COMBINED RSI+MFI+MACD+CCI+TSI+RVI)
https://www.tradingview.com/script/OBIQtYWa-Fusion-Oscillator-COMBINED-RSI-MFI-MACD-CCI-TSI-RVI/
wbburgin
https://www.tradingview.com/u/wbburgin/
559
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© wbburgin //@version=5 //Updated the chart to reflect standard candles indicator("Fusion Oscillator (RSI+MFI+MACD+CCI+TSI+RVI)",shorttitle="Fusion Oscillator [wbburgin]",overlay=false) plotNonDir = input.bool(false,"Plot Nondirectionals",group="Display") plotDir = input.bool(true,"Plot Directionals",group="Display") showema = input.bool(false,"Plot Directionals EMA?",group="Display") emalength = input.int(14,"Directionals EMA Length",group="Display") alertCondition = input.string("Directional Source","Alert Condition", options=["Directional EMA","Directional Source"], group="Alert Management", tooltip="Changing this to 'Directional EMA' might mean you want to change the Directional Buy/Sell thresholds to -1 and 1.") overallLength = input.int(3,"Overall Length",group="Central") filter_nd = input.float(-0.25,"[-1,1] ND Buy/Sell Threshold",group="Central") filter_dSell = input.float(1.25,"Directional Sell Threshold",group="Central") filter_dBuy = input.float(-1.25,"Directional Buy Threshold",group="Central") correlationLength = input.int(50,"Correlation Length",group="Central") rsiLength = input.int(14,"RSI",group="Directionals") mfiLength = input.int(14,"MFI",group="Directionals") macdLength = input.int(12,"MACD",group="Directionals") cciLength = input.int(20,"CCI",group="Directionals") tsiLength = input.int(13,"TSI",group="Directionals") rviLength = input.int(10,"RVI",group="Directionals") atrLength = input.int(14,"ATR",group="Nondirectionals") adxLength = input.int(14,"ADX",group="Nondirectionals") //Directional Inputs //RSI rsi = (ta.rsi(close,rsiLength)-50)/20 //MFI mfi = (ta.mfi(close,mfiLength)-50)/20 //MACD [macdRaw, _, _] = ta.macd(close, macdLength*overallLength, macdLength*2*overallLength, 9) mHighest = ta.highest(macdRaw,macdLength*overallLength) mLowest = ta.lowest(macdRaw,macdLength*overallLength) macd = switch macdRaw > 0 => macdRaw/mHighest macdRaw < 0 => macdRaw/math.abs(mLowest) => 0 //CCI cci = ta.cci(close,cciLength*overallLength)/100 //TSI tsiRaw = ta.tsi(close,tsiLength*overallLength,tsiLength*2*overallLength) tHighest = ta.highest(tsiRaw,tsiLength*overallLength) tLowest = ta.lowest(tsiRaw,tsiLength*overallLength) tsi = switch tsiRaw > 0 => tsiRaw/tHighest tsiRaw < 0 => tsiRaw/math.abs(tLowest) => 0 //RVI offset = 0 maTypeInput = "SMA" maLengthInput = 14 bbMultInput = 2 src = close len = 14 stddev = ta.stdev(src, rviLength*overallLength) upper = ta.ema(ta.change(src) <= 0 ? 0 : stddev, len) lower = ta.ema(ta.change(src) > 0 ? 0 : stddev, len) rvi = ((upper / (upper + lower) * 100)-50)/20 super_dir = math.avg(rsi,mfi,macd,cci,tsi,rvi) signal = ta.sma(super_dir,5) hline(0) highman=hline(1) lowman=hline(-1) plot(plotDir==true?super_dir:na,color=color.white,title="Directional Jumper",linewidth=1) fill(highman,lowman,color.new(color.purple,95)) //Nondirectionals atrRaw = ta.atr(atrLength) atrStdev = ta.stdev(atrRaw,atrLength) atrEMA = ta.ema(atrRaw,atrLength) atr = (((atrRaw/atrEMA)-1)*(1+atrStdev))-1 [_, _, adxRaw] = ta.dmi(17, adxLength) adxStdev = ta.stdev(adxRaw,adxLength) adxEMA = ta.ema(adxRaw,adxLength) adx = (((adxRaw/adxEMA)-1)*(1+adxStdev)) super_nondirRough = math.avg(atr,adx) highestNondir = ta.highest(super_nondirRough,200) lowestNondir = ta.lowest(super_nondirRough,200) super_nondir = switch super_nondirRough > 0 => super_nondirRough/highestNondir super_nondirRough < 0 => super_nondirRough/math.abs(lowestNondir) => 0 correlation_nondir = ta.correlation(atr,adx,correlationLength) col_nondir = switch correlation_nondir >= .75 => color.new(color.yellow,35) correlation_nondir >= .66 => color.new(color.yellow,40) correlation_nondir >= .5 => color.new(color.yellow,45) => color.new(color.yellow,50) nonDirPlot=plot(plotNonDir==true?super_nondir:na,"Nondirectional Average",color=col_nondir) //Exponential Moving Average ema = ta.ema(super_dir,emalength) plot(showema==true?ema:na,color=color.yellow,title="Directional EMA") //Alerts alertSwitch = switch alertCondition=="Directional Source" => super_dir alertCondition=="Directional EMA" => ema buySignal = ta.crossover(alertSwitch,filter_dBuy) and super_nondir>=filter_nd sellSignal = ta.crossunder(alertSwitch,filter_dSell) and super_nondir>=filter_nd signalcolor = switch buySignal == true => color.new(color.green,75) sellSignal == true => color.new(color.red,75) => na bgcolor(signalcolor) alertcondition(buySignal,"Fusion Oscillator Buy Signal") alertcondition(sellSignal,"Fusion Oscillator Sell Signal")
Combined Moving Averages + Squeeze & Volume Spike Signals
https://www.tradingview.com/script/p4slw9Ze-Combined-Moving-Averages-Squeeze-Volume-Spike-Signals/
FriendOfTheTrend
https://www.tradingview.com/u/FriendOfTheTrend/
535
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© FriendOfTheTrend //@version=5 indicator("Combined Moving Averages + Squeeze & Volume Spike Signals", shorttitle="Combined Moving Averages", overlay=true) signalsOn = input.bool(true, title="Signals On/Off") squeezeOn = input.bool(true, title="Squeeze Signals On/Off") squeezeValue = input.float(.6, maxval=1, step=.01, title="Squeeze Value Multiplier", tooltip="This is the number to multiply the median gap of the cloud. The lower the number, the tighter the moving average squeeze will have to be to give a squeeze signal.") ma1On = input.bool(true, title="MA #1 On/Off") length1 = input.int(10, title="Moving Average Length #1") source1 = input.source(close, title="Indicator Source #1") aboveColor1 = input.color(color.lime, title="Price Above MA #1 Color") belowColor1 = input.color(color.red, title="Price Below MA #1 Color") ma2On = input.bool(true, title="MA #2 On/Off") length2 = input.int(50, title="Moving Average Length #2") source2 = input.source(close, title="Indicator Source #2") aboveColor2 = input.color(color.lime, title="Price Above MA #2 Color") belowColor2 = input.color(color.red, title="Price Below MA #2 Color") ma3On = input.bool(true, title="MA #3 On/Off") length3 = input.int(100, title="Moving Average Length #3") source3 = input.source(close, title="Indicator Source #3") aboveColor3 = input.color(color.lime, title="Price Above MA #3 Color") belowColor3 = input.color(color.red, title="Price Below MA #3 Color") ma4On = input.bool(true, title="MA #4 On/Off") length4 = input.int(500, title="Moving Average Length #4") source4 = input.source(close, title="Indicator Source #4") aboveColor4 = input.color(color.lime, title="Price Above MA #4 Color") belowColor4 = input.color(color.red, title="Price Below MA #4 Color") //Combined Moving Averages Calculations sma1 = ta.sma(source1, length1) ema1 = ta.ema(source1, length1) wma1 = ta.wma(source1, length1) vwma1 = ta.vwma(source1, length1) hma1 = ta.hma(source1, length1) rma1 = ta.rma(source1, length1) ma1 = (sma1 + ema1 + wma1 + vwma1 + hma1 + rma1) / 6 sma2 = ta.sma(source2, length2) ema2 = ta.ema(source2, length2) wma2 = ta.wma(source2, length2) vwma2 = ta.vwma(source2, length2) hma2 = ta.hma(source2, length2) rma2 = ta.rma(source2, length2) ma2 = (sma2 + ema2 + wma2 + vwma2 + hma2 + rma2) / 6 sma3 = ta.sma(source3, length3) ema3 = ta.ema(source3, length3) wma3 = ta.wma(source3, length3) vwma3 = ta.vwma(source3, length3) hma3 = ta.hma(source3, length3) rma3 = ta.rma(source3, length3) ma3 = (sma3 + ema3 + wma3 + vwma3 + hma3 + rma3) / 6 sma4 = ta.sma(source4, length4) ema4 = ta.ema(source4, length4) wma4 = ta.wma(source4, length4) vwma4 = ta.vwma(source4, length4) hma4 = ta.hma(source4, length4) rma4 = ta.rma(source4, length4) ma4 = (sma4 + ema4 + wma4 + vwma4 + hma4 + rma4) / 6 //Cloud Squeeze squeeze = false diff = ma2 > ma3 ? ma2 - ma3 : ma3 - ma2 medianDiff = ta.median(diff, 200) if diff < (medianDiff*squeezeValue) squeeze := true bgcolor(squeezeOn and squeeze ? color.rgb(255, 235, 59, 90) : na) //Volume Spike Signals volumeMedian = ta.median(volume, 10) volumeBuy = false highVolumeBuy = false if volume > volumeMedian and volume < volumeMedian*2 volumeBuy := true if volume > volumeMedian*2 highVolumeBuy := true //Line & Cloud Colors redCloud = false greenCloud = false if ma2 > ma3 greenCloud := true else redCloud := true //Plots plot(ma1On ? ma1 : na, title="Moving Average #1", color=ma1 > ma1[1] ? aboveColor1 : belowColor1, style=plot.style_line, linewidth=2) ma50 = plot(ma2On ? ma2 : na, title="Moving Average #2", color=greenCloud ? aboveColor2 : belowColor2, style=plot.style_line, linewidth=3) ma100 = plot(ma3On ? ma3 : na, title="Moving Average #3", color=greenCloud ? aboveColor3 : belowColor3, style=plot.style_line, linewidth=3) plot(ma4On ? ma4 : na, title="Moving Average #4", color=ma4 > ma4[1] ? aboveColor4 : belowColor4, style=plot.style_line, linewidth=4) fill(ma50, ma100, color=greenCloud and highVolumeBuy ? color.rgb(0, 230, 119, 10) : greenCloud and volumeBuy ? color.rgb(0, 230, 119, 50) : greenCloud ? color.rgb(0, 230, 119, 80) : redCloud and highVolumeBuy ? color.rgb(255, 82, 82, 10) : redCloud and volumeBuy ? color.rgb(255, 82, 82, 50) : redCloud ? color.rgb(255, 82, 82, 80) : na) //Signals candleInCloud = false greenCandle = close > open redCandle = open > close if greenCloud and greenCandle if close > ma3 and open < ma2 candleInCloud := true if redCloud and redCandle if close < ma3 and open > ma2 candleInCloud := true upSignal = greenCandle and greenCloud and volumeBuy and candleInCloud and ma2 > ma2[1] and ma3 > ma3[1] or greenCandle and greenCloud and highVolumeBuy and candleInCloud and ma2 > ma2[1] and ma3 > ma3[1] downSignal = redCandle and redCloud and volumeBuy and candleInCloud and ma2 < ma2[1] and ma3 < ma3[1] or redCandle and redCloud and highVolumeBuy and candleInCloud and ma2 < ma2[1] and ma3 < ma3[1] plotshape(signalsOn ? upSignal : na, title="Buy Signal", style=shape.labelup, location=location.belowbar, color=color.lime, size=size.normal) plotshape(signalsOn ? downSignal : na, title="Sell Signal", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.normal)
BTC NEW ADDRESS MOMENTUM: Onchain
https://www.tradingview.com/script/VFVaS6oz-BTC-NEW-ADDRESS-MOMENTUM-Onchain/
cryptoonchain
https://www.tradingview.com/u/cryptoonchain/
74
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© MJShahsavar //@version=5 indicator("BTC NEW ADDRESS MOMENTUM: Onchain", timeframe = "D", overlay=false) R = input.symbol("BTC_NEWADDRESSES", "Symbol") src = request.security(R, 'D', close) D = ta.sma(src, 30) M = ta.sma(src, 365) plot (M, color= color.red , linewidth=1) plot (D, color= color.blue , linewidth=1)
SPY DXY VIX Monitor
https://www.tradingview.com/script/uSNT921f-SPY-DXY-VIX-Monitor/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
60
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© peacefulLizard50262 //@version=5 indicator("I SPY", overlay = true) diff(_src) => (_src + 2 * _src[1] - 2 * _src[3] - _src[4]) / 8 style = input.string("Middle Right", "Position", ["Bottom Left","Bottom Middle","Bottom Right","Middle Left","Middle Center","Middle Right", "Top Left","Top Middle","Top Right"]) txt_col = input.color(color.new(#c8d7ff, 0), "Title Color", inline = "bull", group = "Settings") box_col = input.color(color.new(#202236, 10), "", inline = "bull", group = "Settings") location() => switch style "Bottom Left" => position.bottom_left "Bottom Middle" => position.bottom_center "Bottom Right" => position.bottom_right "Middle Left" => position.middle_left "Middle Center" => position.middle_center "Middle Right" => position.middle_right "Top Left" => position.top_left "Top Middle" => position.top_center "Top Right" => position.top_right spy = request.security("SPY", timeframe.period , close) dxy = request.security("DXY", timeframe.period , close) vix = request.security("VIX", timeframe.period , close) us10y = request.security("US10Y", timeframe.period , close) var tbl = table.new(location(), 4, 5) if barstate.islast table.cell(tbl, 0, 0, "Symbol", text_color = txt_col, bgcolor = box_col, tooltip = "Symbol for that line.") table.cell(tbl, 1, 0, "Price", text_color = txt_col, bgcolor = box_col, tooltip = "Price of Symbol") table.cell(tbl, 2, 0, "Direction", text_color = txt_col, bgcolor = box_col, tooltip = "Direction of the Symbol") main(name, source, n) => exn = name dir = diff(source) Diff_Score = dir < 0 ? "↓" : dir > 0 ? "↑" : "β†’" if barstate.islast table.cell(tbl, 0, n, exn, text_color = txt_col, bgcolor = box_col) table.cell(tbl, 1, n, str.tostring(source), text_color = txt_col, bgcolor = box_col) table.cell(tbl, 2, n, Diff_Score, text_color = txt_col, bgcolor = box_col) main("SPY", spy, 1) main("DXY", dxy, 2) main("VIX", vix, 3) main("US10Y", us10y, 4)
Signal #1
https://www.tradingview.com/script/PscqSEFY/
Namlee8
https://www.tradingview.com/u/Namlee8/
46
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 int MAX_BARS_BACK = 1000 indicator("Signal #1", max_bars_back = MAX_BARS_BACK, timeframe = "", timeframe_gaps = false, precision = 2) // v3, 2022.11.06 13:05 // This code was written using the recommendations from the Pine Scriptβ„’ User Manual's Style Guide: // https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html import LucF/ta/2 as LucfTa //#region β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Constants and inputs // Key levels float LEVEL_MID = 0. float LEVEL_HI = 0.3 float LEVEL_LO = -0.3 // Colors color BLUE = #3179f5 color GRAY = #434651 color GRAY_LT = #9598a1 color GREEN = #006200 color LIME = #00FF00 color MAROON = #800000 color ORANGE = #e65100 color PINK = #FF0080 color YELLOW = #fbc02d color BLUE_DK = #013bca color PURPLE = #C314EB // MAs string MA01 = "Simple MA" string MA02 = "Exponential MA" string MA03 = "Wilder MA" string MA04 = "Weighted MA" string MA05 = "Volume-weighted MA" string MA06 = "Arnaud Legoux MA" string MA07 = "Hull MA" string MA08 = "Symmetrically-weighted MA" // Bar coloring modes string CB1 = "Buoyancy line" string CB2 = "MA line" string CB3 = "Channel fill" string CB4 = "MA fill" // Bar coloring modes 2 string CB12 = "SOTT MA" string CB22 = "MA of MA" string CB32 = "Channel fill" string CB42 = "MA fill" // Tooltips string TT_TARGET = "This value specifies the number of bars for which volume is added to calculate the target." string TT_LINE = "'πŸ‘‘' and 'πŸ‘“' indicate bull/bear conditions, which occur when the line is above/below the centerline." string TT_CHANNEL = "'πŸ‘‘' and 'πŸ‘“' indicate bull/bear conditions, which occur when buoyancy is above/below its MA while not also being above/below the centerline. \n\n'πŸ‘‘πŸ‘‘' and 'πŸ‘“πŸ‘“' indicate strong bull/bear conditions, which require buoyancy to be above/below its MA, and above/below the centerline." // Tooltips 2 string TT_SIGNAL = "You specify here the type and length of the MA you want applied to the instant SOTT value. You can view the instant value by using a length of 1. \n\nNOTE: The length of this MA must be smaller than that of the second MA defined below. \n\n'πŸ‘‘' and 'πŸ‘“' indicate bull/bear conditions, which occur when the line is above/below the centerline." string TT_MA = "You specify here the type and length of the MA you want applied to the MA of SOTT defined above, so this is an MA of an MA. \n\n'πŸ‘‘' and 'πŸ‘“' indicate bull/bear conditions, which occur when the line is above/below the centerline." string TT_CHANNEL2 = "'πŸ‘‘' and 'πŸ‘“' indicate bull/bear conditions, which occur when the first MA is above/below the second MA while not also being above/below the centerline. \n\n'πŸ‘‘πŸ‘‘' and 'πŸ‘“πŸ‘“' indicate strong bull/bear conditions, which require the first MA to be above/below the second MA, and above/below the centerline." string TT_MAFILL = "'πŸ‘‘' and 'πŸ‘“' indicate bull/bear conditions, which occur when the second MA is above/below the centerline." // Inputs int periodInput = input.int(20, "Target bars", inline = "target", minval = 1, maxval = int(MAX_BARS_BACK / 4), tooltip = TT_TARGET) bool buoyancyShowInput = input.bool(true, "Buoyancy", inline = "buoyancy") color buoyancyUpColorInput = input.color(GRAY_LT, "πŸ‘‘", inline = "buoyancy") color buoyancyDnColorInput = input.color(GRAY_LT, "πŸ‘“", inline = "buoyancy", tooltip = TT_LINE) bool maShowInput = input.bool(false, "MA line", inline = "ma") color maUpColorInput = input.color(YELLOW, "β€ƒπŸ‘‘", inline = "ma") color maDnColorInput = input.color(ORANGE, "πŸ‘“", inline = "ma") string maTypeInput = input.string(MA06, "", inline = "ma", options = [MA01, MA02, MA03, MA04, MA05, MA06, MA07, MA08]) int maLengthInput = input.int(20, "Length", inline = "ma", minval = 2, tooltip = TT_LINE) bool channelShowInput = input.bool(true, "Channel", inline = "channel") color channelUpColorInput = input.color(GREEN, "β€Šβ€‚πŸ‘‘", inline = "channel") color channelDnColorInput = input.color(MAROON, "πŸ‘“", inline = "channel") color channelUpUpColorInput = input.color(LIME, "πŸ‘‘πŸ‘‘", inline = "channel") color channelDnDnColorInput = input.color(PINK, "πŸ‘“πŸ‘“", inline = "channel", tooltip = TT_CHANNEL) bool maFillShowInput = input.bool(true, "MA fill", inline = "maFill") color maFillUpColorInput = input.color(GRAY, "β€‰β€‰β€ƒπŸ‘‘", inline = "maFill") color maFillDnColorInput = input.color(BLUE, "πŸ‘“", inline = "maFill") bool colorBarsInput = input.bool(false, "Color chart bars using the color of", inline = "bars") string colorBarsModeInput = input.string(CB3, "", inline = "bars", options = [CB1, CB2, CB3, CB4]) // Inputs2 bool signalShowInput = input.bool(true, "SOTT MA", inline = "signal") color signalUpColorInput = input.color(GREEN, "β€Šβ€ŠπŸ‘‘", inline = "signal") color signalDnColorInput = input.color(MAROON, "πŸ‘“", inline = "signal") string signalTypeInput = input.string(MA06, "", inline = "signal", options = [MA01, MA02, MA03, MA04, MA05, MA06, MA07, MA08]) int signalLengthInput = input.int(20, "Length", inline = "signal", minval = 1, tooltip = TT_SIGNAL) bool maShowInput2 = input.bool(false, "MA of MA", inline = "ma2") color maUpColorInput2 = input.color(YELLOW, "β€ŠπŸ‘‘", inline = "ma2") color maDnColorInput2 = input.color(BLUE_DK, "πŸ‘“", inline = "ma2") string maTypeInput2 = input.string(MA01, "", inline = "ma2", options = [MA01, MA02, MA03, MA04, MA05, MA06, MA07, MA08]) int maLengthInput2 = input.int(20, "Length", inline = "ma2", minval = 2, tooltip = TT_MA) bool channelShowInput2 = input.bool(true, "Channel", inline = "channel2") color channelUpColorInput2 = input.color(GREEN, "β€Šβ€‚πŸ‘‘", inline = "channel2") color channelDnColorInput2 = input.color(MAROON, "πŸ‘“", inline = "channel2") color channelUpUpColorInput2 = input.color(LIME, "πŸ‘‘πŸ‘‘", inline = "channel2") color channelDnDnColorInput2 = input.color(PURPLE, "πŸ‘“πŸ‘“", inline = "channel2", tooltip = TT_CHANNEL2) bool maFillShowInput2 = input.bool(true, "MA fill", inline = "maFill2") color maFillUpColorInput2 = input.color(YELLOW, "β€‰β€‰β€ƒπŸ‘‘", inline = "maFill2") color maFillDnColorInput2 = input.color(BLUE, "πŸ‘“", inline = "maFill2", tooltip = TT_MAFILL) bool colorBarsInput2 = input.bool(false, "Color chart bars using the color of", inline = "bars") string colorBarsModeInput2 = input.string(CB3, "", inline = "bars", options = [CB1, CB2, CB3, CB4]) //#endregion //#region β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Calculations // 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.") // Calculate buoyancy and its MA. float buoyancy = LucfTa.buoyancy(volume, periodInput, MAX_BARS_BACK) float ma = LucfTa.ma(maTypeInput, buoyancy, maLengthInput) // States bool maIsBull = ma > LEVEL_MID bool buoyancyIsBull = buoyancy > LEVEL_MID bool channelIsBull = buoyancy > ma // Validate MA lengths.2 if signalLengthInput > maLengthInput runtime.error("The length of the SOTT MA must be less than or equal to that of the second MA.") // Instant SOTT2 float sott = LucfTa.sott() // MAs2 float signal = LucfTa.ma(signalTypeInput, sott, signalLengthInput) float ma2 = LucfTa.ma(maTypeInput2, signal, maLengthInput2) // States2 bool maIsBull2 = ma2 > LEVEL_MID bool signalIsBull2 = signal > LEVEL_MID bool channelIsBull2 = signal > ma2 //#endregion //#region β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” Plots // Plotting colors color channelColor = channelIsBull ? buoyancyIsBull ? channelUpUpColorInput : channelUpColorInput : buoyancyIsBull ? channelDnColorInput : channelDnDnColorInput color buoyancyColor = buoyancyIsBull ? buoyancyUpColorInput : buoyancyDnColorInput color maColor = maIsBull ? maUpColorInput : maDnColorInput color maChannelTopColor = maIsBull ? maFillUpColorInput : color.new(maFillDnColorInput, 95) color maChannelBotColor = maIsBull ? color.new(maFillUpColorInput, 95) : maFillDnColorInput // Plotting colors2 color channelColor2 = channelIsBull2 ? signalIsBull2 ? channelUpUpColorInput2 : channelUpColorInput2 : signalIsBull2 ? channelDnColorInput2 : channelDnDnColorInput2 color signalColor = signalIsBull2 ? signalUpColorInput : signalDnColorInput color maColor2 = maIsBull ? maUpColorInput : maDnColorInput color maChannelTopColor2 = maIsBull ? maFillUpColorInput : color.new(maFillDnColorInput, 95) color maChannelBotColor2 = maIsBull ? color.new(maFillUpColorInput, 95) : maFillDnColorInput // Plots buoyancyPlot = plot(buoyancy, "Buoyancy", buoyancyShowInput ? buoyancyColor : na) maPlot = plot(ma, "MA", maShowInput ? maColor : na) zeroPlot = plot(LEVEL_MID, "Phantom Mid Level", display = display.none) // Plots2 signalPlot = plot(signalShowInput or channelShowInput ? signal : na, "SOTT MA", signalShowInput ? signalColor : na, 2) maPlot2 = plot(ma, "MA of MA", maShowInput ? maColor : na) zeroPlot2 = plot(LEVEL_MID, "Phantom Mid Level", display = display.none) // Fill the MA channel (the space between the middle level and the MA). fill(maPlot, zeroPlot, not maFillShowInput ? na : maIsBull ? LEVEL_HI : LEVEL_MID, maIsBull ? LEVEL_MID : LEVEL_LO, maChannelTopColor, maChannelBotColor) // Fill the MA channel (the space between the middle level and the MA).2 fill(maPlot, zeroPlot, not maFillShowInput ? na : maIsBull ? LEVEL_HI * 0.7 : LEVEL_MID, maIsBull ? LEVEL_MID : LEVEL_LO * 0.7, maChannelTopColor, maChannelBotColor) // Fill the buoyancy channel (between the buoyancy line and its MA). fill(maPlot, buoyancyPlot, ma, not channelShowInput ? na : buoyancy, color.new(channelColor, 70), channelColor) // Fill the signal channel (between the two MAs).2 fill(maPlot, signalPlot, ma, not channelShowInput ? na : signal, color.new(channelColor, 70), channelColor) // Levels hline(LEVEL_HI, "High level", buoyancyUpColorInput, hline.style_dotted) hline(LEVEL_MID, "Mid level", color.gray, hline.style_dotted) hline(LEVEL_LO, "Low level", buoyancyDnColorInput, hline.style_dotted) // Levels2 hline(LEVEL_HI, "High level", signalUpColorInput, hline.style_dotted) hline(LEVEL_MID, "Mid level", color.gray, hline.style_dotted) hline(LEVEL_LO, "Low level", signalDnColorInput, hline.style_dotted) // Instant SOTT for Data Window.2 plot(sott, "Instant SOTT", display = display.data_window) // Color bars color barColor = switch colorBarsModeInput CB1 => buoyancyColor CB2 => maColor CB3 => channelColor CB4 => maIsBull ? maFillUpColorInput : maFillDnColorInput => na barcolor(colorBarsInput ? barColor : na) // Color bars color barColor2 = switch colorBarsModeInput CB12 => signalColor CB22 => maColor CB32 => channelColor CB42 => maIsBull ? maFillUpColorInput : maFillDnColorInput => na barcolor(colorBarsInput ? barColor : na) //#endregion
FluidTrades - SMC Lite
https://www.tradingview.com/script/YdtBEh4F-FluidTrades-SMC-Lite/
Pmgjiv
https://www.tradingview.com/u/Pmgjiv/
4,433
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© Pmgjiv //@version=5 indicator("FluidTrades - SMC Lite ", overlay = true, max_labels_count = 500, max_boxes_count = 500, max_lines_count = 500, max_bars_back = 1000) // //SETTINGS // // INDICATOR SETTINGS swing_length = input.int(10, title = 'Swing High/Low Length', group = 'Settings', minval = 1, maxval = 50) history_of_demand_to_keep = input.int(20, title = 'History To Keep', minval = 5, maxval = 50) box_width = input.float(2.5, title = 'Supply/Demand Box Width', group = 'Settings', minval = 1, maxval = 10, step = 0.5) // INDICATOR VISUAL SETTINGS show_zigzag = input.bool(false, title = 'Show Zig Zag', group = 'Visual Settings', inline = '1') show_price_action_labels = input.bool(false, title = 'Show Price Action Labels', group = 'Visual Settings', inline = '2') supply_color = input.color(color.new(#EDEDED,70), title = 'Supply', group = 'Visual Settings', inline = '3') supply_outline_color = input.color(color.new(color.white,75), title = 'Outline', group = 'Visual Settings', inline = '3') demand_color = input.color(color.new(#00FFFF,70), title = 'Demand', group = 'Visual Settings', inline = '4') demand_outline_color = input.color(color.new(color.white,75), title = 'Outline', group = 'Visual Settings', inline = '4') bos_label_color = input.color(color.white, title = 'BOS Label', group = 'Visual Settings', inline = '5') poi_label_color = input.color(color.white, title = 'POI Label', group = 'Visual Settings', inline = '7') swing_type_color = input.color(color.black, title = 'Price Action Label', group = 'Visual Settings', inline = '8') zigzag_color = input.color(color.new(#000000,0), title = 'Zig Zag', group = 'Visual Settings', inline = '9') // //END SETTINGS // // //FUNCTIONS // // FUNCTION TO ADD NEW AND REMOVE LAST IN ARRAY f_array_add_pop(array, new_value_to_add) => array.unshift(array, new_value_to_add) array.pop(array) // FUNCTION SWING H & L LABELS f_sh_sl_labels(array, swing_type) => var string label_text = na if swing_type == 1 if array.get(array, 0) >= array.get(array, 1) label_text := 'HH' else label_text := 'LH' label.new(bar_index - swing_length, array.get(array,0), text = label_text, style=label.style_label_down, textcolor = swing_type_color, color = color.new(swing_type_color, 100), size = size.tiny) else if swing_type == -1 if array.get(array, 0) >= array.get(array, 1) label_text := 'HL' else label_text := 'LL' label.new(bar_index - swing_length, array.get(array,0), text = label_text, style=label.style_label_up, textcolor = swing_type_color, color = color.new(swing_type_color, 100), size = size.tiny) // FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING f_check_overlapping(new_poi, box_array, atr) => atr_threshold = atr * 2 okay_to_draw = true for i = 0 to array.size(box_array) - 1 top = box.get_top(array.get(box_array, i)) bottom = box.get_bottom(array.get(box_array, i)) poi = (top + bottom) / 2 upper_boundary = poi + atr_threshold lower_boundary = poi - atr_threshold if new_poi >= lower_boundary and new_poi <= upper_boundary okay_to_draw := false break else okay_to_draw := true okay_to_draw // FUNCTION TO DRAW SUPPLY OR DEMAND ZONE f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atr) => atr_buffer = atr * (box_width / 10) box_left = array.get(bn_array, 0) box_right = bar_index var float box_top = 0.00 var float box_bottom = 0.00 var float poi = 0.00 if box_type == 1 box_top := array.get(value_array, 0) box_bottom := box_top - atr_buffer poi := (box_top + box_bottom) / 2 else if box_type == -1 box_bottom := array.get(value_array, 0) box_top := box_bottom + atr_buffer poi := (box_top + box_bottom) / 2 okay_to_draw = f_check_overlapping(poi, box_array, atr) // okay_to_draw = true //delete oldest box, and then create a new box and add it to the array if box_type == 1 and okay_to_draw box.delete( array.get(box_array, array.size(box_array) - 1) ) f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right = box_right, bottom = box_bottom, border_color = supply_outline_color, bgcolor = supply_color, extend = extend.right, text = 'SUPPLY', text_halign = text.align_center, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) box.delete( array.get(label_array, array.size(label_array) - 1) ) f_array_add_pop(label_array, box.new( left = box_left, top = poi, right = box_right, bottom = poi, border_color = color.new(poi_label_color,90), bgcolor = color.new(poi_label_color,90), extend = extend.right, text = 'POI', text_halign = text.align_left, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) else if box_type == -1 and okay_to_draw box.delete( array.get(box_array, array.size(box_array) - 1) ) f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right = box_right, bottom = box_bottom, border_color = demand_outline_color, bgcolor = demand_color, extend = extend.right, text = 'DEMAND', text_halign = text.align_center, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) box.delete( array.get(label_array, array.size(label_array) - 1) ) f_array_add_pop(label_array, box.new( left = box_left, top = poi, right = box_right, bottom = poi, border_color = color.new(poi_label_color,90), bgcolor = color.new(poi_label_color,90), extend = extend.right, text = 'POI', text_halign = text.align_left, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) // FUNCTION TO CHANGE SUPPLY/DEMAND TO A BOS IF BROKEN f_sd_to_bos(box_array, bos_array, label_array, zone_type) => if zone_type == 1 for i = 0 to array.size(box_array) - 1 level_to_break = box.get_top(array.get(box_array,i)) // if ta.crossover(close, level_to_break) if close >= level_to_break copied_box = box.copy(array.get(box_array,i)) f_array_add_pop(bos_array, copied_box) mid = (box.get_top(array.get(box_array,i)) + box.get_bottom(array.get(box_array,i))) / 2 box.set_top(array.get(bos_array,0), mid) box.set_bottom(array.get(bos_array,0), mid) box.set_extend( array.get(bos_array,0), extend.none) box.set_right( array.get(bos_array,0), bar_index) box.set_text( array.get(bos_array,0), 'BOS' ) box.set_text_color( array.get(bos_array,0), bos_label_color) box.set_text_size( array.get(bos_array,0), size.small) box.set_text_halign( array.get(bos_array,0), text.align_center) box.set_text_valign( array.get(bos_array,0), text.align_center) box.delete(array.get(box_array, i)) box.delete(array.get(label_array, i)) if zone_type == -1 for i = 0 to array.size(box_array) - 1 level_to_break = box.get_bottom(array.get(box_array,i)) // if ta.crossunder(close, level_to_break) if close <= level_to_break copied_box = box.copy(array.get(box_array,i)) f_array_add_pop(bos_array, copied_box) mid = (box.get_top(array.get(box_array,i)) + box.get_bottom(array.get(box_array,i))) / 2 box.set_top(array.get(bos_array,0), mid) box.set_bottom(array.get(bos_array,0), mid) box.set_extend( array.get(bos_array,0), extend.none) box.set_right( array.get(bos_array,0), bar_index) box.set_text( array.get(bos_array,0), 'BOS' ) box.set_text_color( array.get(bos_array,0), bos_label_color) box.set_text_size( array.get(bos_array,0), size.small) box.set_text_halign( array.get(bos_array,0), text.align_center) box.set_text_valign( array.get(bos_array,0), text.align_center) box.delete(array.get(box_array, i)) box.delete(array.get(label_array, i)) // FUNCTION MANAGE CURRENT BOXES BY CHANGING ENDPOINT f_extend_box_endpoint(box_array) => for i = 0 to array.size(box_array) - 1 box.set_right(array.get(box_array, i), bar_index + 100) // //END FUNCTIONS // // //CALCULATIONS // // CALCULATE ATR atr = ta.atr(50) // CALCULATE SWING HIGHS & SWING LOWS swing_high = ta.pivothigh(high, swing_length, swing_length) swing_low = ta.pivotlow(low, swing_length, swing_length) // ARRAYS FOR SWING H/L & BN var swing_high_values = array.new_float(5,0.00) var swing_low_values = array.new_float(5,0.00) var swing_high_bns = array.new_int(5,0) var swing_low_bns = array.new_int(5,0) // ARRAYS FOR SUPPLY / DEMAND var current_supply_box = array.new_box(history_of_demand_to_keep, na) var current_demand_box = array.new_box(history_of_demand_to_keep, na) // ARRAYS FOR SUPPLY / DEMAND POI LABELS var current_supply_poi = array.new_box(history_of_demand_to_keep, na) var current_demand_poi = array.new_box(history_of_demand_to_keep, na) // ARRAYS FOR BOS var supply_bos = array.new_box(5, na) var demand_bos = array.new_box(5, na) // //END CALCULATIONS // // NEW SWING HIGH if not na(swing_high) //MANAGE SWING HIGH VALUES f_array_add_pop(swing_high_values, swing_high) f_array_add_pop(swing_high_bns, bar_index[swing_length]) if show_price_action_labels f_sh_sl_labels(swing_high_values, 1) f_supply_demand(swing_high_values, swing_high_bns, current_supply_box, current_supply_poi, 1, atr) // NEW SWING LOW else if not na(swing_low) //MANAGE SWING LOW VALUES f_array_add_pop(swing_low_values, swing_low) f_array_add_pop(swing_low_bns, bar_index[swing_length]) if show_price_action_labels f_sh_sl_labels(swing_low_values, -1) f_supply_demand(swing_low_values, swing_low_bns, current_demand_box, current_demand_poi, -1, atr) f_sd_to_bos(current_supply_box, supply_bos, current_supply_poi, 1) f_sd_to_bos(current_demand_box, demand_bos, current_demand_poi, -1) f_extend_box_endpoint(current_supply_box) f_extend_box_endpoint(current_demand_box) //ZIG ZAG h = ta.highest(high, swing_length * 2 + 1) l = ta.lowest(low, swing_length * 2 + 1) f_isMin(len) => l == low[len] f_isMax(len) => h == high[len] var dirUp = false var lastLow = high * 100 var lastHigh = 0.0 var timeLow = bar_index var timeHigh = bar_index var line li = na f_drawLine() => _li_color = show_zigzag ? zigzag_color : color.new(#ffffff,100) line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow, xloc.bar_index, color=_li_color, width=2) if dirUp if f_isMin(swing_length) and low[swing_length] < lastLow lastLow := low[swing_length] timeLow := bar_index line.delete(li) li := f_drawLine() li if f_isMax(swing_length) and high[swing_length] > lastLow lastHigh := high[swing_length] timeHigh := bar_index dirUp := false li := f_drawLine() li if not dirUp if f_isMax(swing_length) and high[swing_length] > lastHigh lastHigh := high[swing_length] timeHigh := bar_index line.delete(li) li := f_drawLine() li if f_isMin(swing_length) and low[swing_length] < lastHigh lastLow := low[swing_length] timeLow := bar_index dirUp := true li := f_drawLine() if f_isMax(swing_length) and high[swing_length] > lastLow lastHigh := high[swing_length] timeHigh := bar_index dirUp := false li := f_drawLine() li // if barstate.islast // label.new(x = bar_index + 10, y = close[1], text = str.tostring( array.size(current_supply_poi) )) // label.new(x = bar_index + 20, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 0)))) // label.new(x = bar_index + 30, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 1)))) // label.new(x = bar_index + 40, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 2)))) // label.new(x = bar_index + 50, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 3)))) // label.new(x = bar_index + 60, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 4))))
Money Flow Index/MFIma/smooth vol-mfi
https://www.tradingview.com/script/8kMu2j8H-Money-Flow-Index-MFIma-smooth-vol-mfi/
adishaz
https://www.tradingview.com/u/adishaz/
37
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© adishaz //@version=5 indicator(title="Money Flow Index/MFIma/smooth vol-mfi", shorttitle="MFI", format=format.price, precision=2, timeframe="", timeframe_gaps=true) length = input.int(title="Length mfi", defval=14, minval=1, maxval=2000) lengthMA = input.int(title="Length mfi-MA", defval=5, minval=1, maxval=2000) lengthMAvol = input.int(title="Length MA VOL for smooth mfi", defval=5, minval=1, maxval=2000) src = input(hlc3) mf = ta.mfi(src, length) MF= ta.sma(mf,lengthMA ) plot(mf, "MF", color=#7E57C2) plot(MF, "MFma", color=#040108) overbought=hline(80, title="Overbought", color=#787B86) hline(50, "Middle Band", color=color.new(#787B86, 50)) oversold=hline(20, title="Oversold", color=#787B86) fill(overbought, oversold, color=color.rgb(126, 87, 194, 90), title="Background") volMA= ta.ema(volume,lengthMAvol) float upper = math.sum(volMA * (ta.change(src) <= 0.0 ? 0.0 : src), length) float lower = math.sum(volMA * (ta.change(src) >= 0.0 ? 0.0 : src), length) mfi = 100.0 - (100.0 / (1.0 + upper / lower)) plot(mfi, "MFI SMOOTH", color=color.rgb(240, 6, 25))
Slow but limitless moving averages
https://www.tradingview.com/script/otnUhtTp-Slow-but-limitless-moving-averages/
f4r33x
https://www.tradingview.com/u/f4r33x/
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/ // Β© f4r33x //@version=5 indicator("Slow but limitless moving averages", overlay = true) import PineCoders/LibraryStopwatch/1 as sw import f4r33x/EncoderDecoder/4 as ed import f4r33x/String_Encoder_Decoder/1 as sed import f4r33x/fast_utils/4 as fu import f4r33x/ReduceSecurityCalls/2 as rsc nonRepaintingSecurity(sym, tf, expr) => request.security(sym, tf, expr[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1] ifSecurity(sym, tf, expr) => request.security(sym, tf, expr) resource_tf(string src, string tf, string inp_tf1, string inp_tf2=na, string inp_tf3=na, string inp_tf4=na, string inp_tf5=na, string inp_tf6=na, matrix<float> out_tf1=na, matrix<float> out_tf2=na, matrix<float> out_tf3=na, matrix<float> out_tf4=na, matrix<float> out_tf5=na, matrix<float> out_tf6=na) => matrix<float> findmat = switch tf inp_tf1 => out_tf1 inp_tf2 => out_tf2 inp_tf3 => out_tf3 inp_tf4 => out_tf4 inp_tf5 => out_tf5 inp_tf6 => out_tf6 int row = switch src 'open' => 0 'high' => 1 'low' => 2 'close' => 3 'custom' => 4 out = matrix.row(findmat, row) out change_tf(string tf, string inp_tf1, string inp_tf2=na, string inp_tf3=na, string inp_tf4=na, string inp_tf5=na, string inp_tf6=na, bool change_tf1, bool change_tf2 = na, bool change_tf3 = na, bool change_tf4 = na,bool change_tf5= na, bool change_tf6 = na) => bool out = switch tf inp_tf1 => change_tf1 inp_tf2 => change_tf2 inp_tf3 => change_tf3 inp_tf4 => change_tf4 inp_tf5 => change_tf5 inp_tf6 => change_tf6 out inp_l = input.int(defval = 22, title = 'length of htf') inp_tf1 =input.timeframe(defval = '1D', title = 'TF1') change_tf1 = timeframe.change(inp_tf1) inp_tf2 =input.timeframe(defval = '30', title = 'TF2') change_tf2 = timeframe.change(inp_tf2) inp_tf3 = timeframe.period inp_sym =input.symbol(defval = 'BYBIT:BTCUSDT.P',title = 'symbol') inp_method =1 inp_refresh=input.int(defval=0, title = 'CLICK TO REFRESH') inp_l1=input.int(defval=14, title = 'l1') inp_l2=input.int(defval=21, title = 'l2') inp_l3=input.int(defval=22, title = 'l3') inp_type1=input.string(defval='EMA', title = 'type1', options = ['RMA','SMA','EMA','HMA_slow','WMA']) inp_type2=input.string(defval='EMA', title = 'type2', options = ['RMA','SMA','EMA','HMA_slow','WMA']) inp_type3=input.string(defval='EMA', title = 'type3', options = ['RMA','SMA','EMA','HMA_slow','WMA']) inp_source1=input.string(defval='close', title = 'source1') inp_source2=input.string(defval='high', title = 'source2') inp_source3=input.string(defval='low', title = 'source3') arr_l = array.from(inp_l1,inp_l2,inp_l3) arr_t = array.from(inp_type1,inp_type2,inp_type3) arr_s = array.from(inp_source1,inp_source2,inp_source3) arr_tf =array.from(inp_tf1,inp_tf2,inp_tf3) float a = na float b = na float c = na //var mat_inouts = matrix.new<float>(100,0,na) //var mat_inouts2 = matrix.new<string>(2,0,na) var arr_in =array.new_string(0) var arr_out=array.new_float(0) var mat_out1= matrix.new<float>(0,0, na) var mat_out2= matrix.new<float>(0,0, na) var mat_out3= matrix.new<float>(0,0, na) inp_o =input.string(defval = 'open', title = 'input first parsed value') inp_o_l=input.int(defval = 14, title = 'input first parsed value') //o =fu.resource('open') o = switch inp_o 'open' => open 'high' => high 'low' => low 'close'=> close 'ema' => ta.ema(fu.resource(inp_source1), inp_o_l) h =fu.resource('high') l =fu.resource('low') cl =fu.resource('close') custom = volume/10000 if barstate.isfirst or timeframe.change(inp_tf1) mat_out1 := ifSecurity(inp_sym, inp_tf1, rsc.ParseSource(o=o, h=h, l=l, c=cl, custom =custom, length =inp_l)) //, custom =ta.tr(true) if barstate.isfirst or timeframe.change(inp_tf2) mat_out2 := ifSecurity(inp_sym, inp_tf2, rsc.ParseSource(o=o, h=h, l=l, c=cl, custom =custom, length =inp_l)) //, custom =ta.tr(true) if barstate.isfirst or timeframe.change(inp_tf3) mat_out3 := ifSecurity(inp_sym, inp_tf3, rsc.ParseSource(o=o, h=h, l=l, c=cl, custom =custom, length =inp_l)) //, custom =ta.tr(true) wma(float[] source, series int length, float[] arr_o, int i) => sum = 0.0 for index = 0 to length - 1 sum := sum + array.get(source, index) * (length - index) lSum = length * (length + 1) / 2 res = sum / lSum array.set(arr_o, i, res) res wma(float[] source, series int length) => sum = 0.0 for index = 0 to length - 1 sum := sum + array.get(source, index) * (length - index) lSum = length * (length + 1) / 2 res = sum / lSum res wma(float[] source, series int length, float[] arr_o, int i, bool tf_changed) => float res = na if tf_changed sum = 0.0 for index = 0 to length - 1 sum := sum + array.get(source, index) * (length - i) lSum = length * (length + 1) / 2 res := sum / lSum array.set(arr_o, i, res) res wma(string source, float length, float[] arr_o, int i) => sum = 0.0 for index = 0 to length - 1 sum := sum + fu.resource(source, index) * (length - index) lSum = length * (length + 1) / 2 res = sum / lSum array.set(arr_o, i, res) res wma(string source, float length) => sum = 0.0 for i = 0 to length - 1 sum := sum + fu.resource(source, i) * (length - i) lSum = length * (length + 1) / 2 sum / lSum wma(string source, float length, int h) => sum = 0.0 for i = 0 to length - 1 sum := sum + fu.resource(source, i+h) * (length - i) lSum = length * (length + 1) / 2 sum / lSum ema(array<float> source, int length, array<float> arr_o, int i) => float ema = na if i == -1 runtime.error('push inputs to matrix') k = 2 / (length + 1) currentEma = array.get(arr_o , i) if na(currentEma) for index = 0 to length-1 src = array.get(source, length-1-index) ema := na(currentEma) ? src : src * k + (1 - k) * currentEma currentEma := ema array.set(arr_o , i, ema) else src = array.get(source, 0) ema := src * k + (1 - k) * currentEma array.set(arr_o , i, ema) ema ema(array<float> source, int length, array<float> arr_o, int i, bool tf_changed) => float ema = na k = 2 / (length + 1) if i == -1 runtime.error('push inputs to matrix') currentEma = array.get(arr_o , i) if na(currentEma) for index = 0 to length-1 src = array.get(source, length-1-index) ema := na(currentEma) ? src : src * k + (1 - k) * currentEma currentEma := ema array.set(arr_o , i, ema) if tf_changed src = array.get(source, 0) ema := src * k + (1 - k) * currentEma array.set(arr_o , i, ema) ema(float source, int length, float[] arr_out, int i) => if i == -1 runtime.error('push inputs to matrix') k = 2 / (length + 1) float ema = na currentEma = array.get(arr_out , i) ema := na(currentEma) ? source : source * k + (1 - k) * currentEma array.set(arr_out, i, ema) ema rma(float source, int length, float[] arr_out, int i) => if i == -1 runtime.error('push inputs to matrix') float rma = na currentRma = array.get(arr_out , i) rma := na(currentRma) ? source : (currentRma * (length-1) + source)/length array.set(arr_out, i, rma) rma //ta.rma() rma(array<float> source, int length, array<float> arr_o, int i, bool tf_changed) => float rma = na if i == -1 runtime.error('push inputs to matrix') currentRma = array.get(arr_o , i) if na(currentRma) for index = 0 to length-1 src = array.get(source, length-1-index) rma := na(currentRma) ? src : (currentRma * (length-1) + src)/length currentRma := rma array.set(arr_o , i, rma) if tf_changed src = array.get(source, 0) rma := (currentRma * (length-1) + src)/length array.set(arr_o , i, rma) rma(array<float> source, int length, array<float> arr_o, int i) => float rma = na if i == -1 runtime.error('push inputs to matrix') currentRma = array.get(arr_o , i) if na(currentRma) for index = 0 to length-1 src = array.get(source, length-1-index) rma := na(currentRma) ? src : (currentRma * (length-1) + src)/length currentRma := rma array.set(arr_o , i, rma) else src = array.get(source, 0) rma := (currentRma * (length-1) + src)/length array.set(arr_o , i, rma) rma sma(string source, int length, float[] arr_out, int i, bool tf_changed) => float sma = 0 float presma =array.get(arr_out, i) if na(presma) for index = 0 to length-1 sma := sma + fu.resource(source, index)/length array.set(arr_out, i, sma) else if tf_changed sma:= presma + (fu.resource(source) - fu.resource(source, length))/length array.set(arr_out, i, sma) sma sma(string source, int length, float[] arr_out, int i) => float sma = 0 float presma =array.get(arr_out, i) if na(presma) for index = 0 to length-1 sma := sma + fu.resource(source, index)/length else sma:= presma + (fu.resource(source) - fu.resource(source, length))/length array.set(arr_out, i, sma) sma sma(float[] source, int length, float[] arr_out, int i) => float sma = na sma := array.avg(array.slice(source, 0, length)) array.set(arr_out, i, sma) sma // vwma(string source, int length, float[] arr_out, int i) => // ta.vwma() hma(series string src, series int length, float[] arr_out, int i) => size = math.floor(math.sqrt(length)) arr_temp = array.new<float>(size, na) for index=0 to size -1 res = 2 * wma(src, math.floor(length / 2), h= index) - wma(src, length, h= index) array.set(arr_temp, index, res) hma = wma(arr_temp, size) array.set(arr_out, i, hma) hma hma(series float[] source, series int length, float[] arr_out, int i) => size = array.size(source) l_sqrt =math.floor(math.sqrt(length)) if size < length+l_sqrt-1 runtime.error('array size for hma should be at least (length + square_root of length -1)') hmaRange = array.new_float(0) for i=0 to (l_sqrt-1) arr_temp=array.slice(source, l_sqrt-1-i, size) wma1 = wma(arr_temp, math.floor(length / 2)) wma2 = wma(arr_temp, length) array.unshift(hmaRange, 2 * wma1 - wma2) float hma = na if array.size(hmaRange) == l_sqrt hma := wma(hmaRange, l_sqrt) array.set(arr_out, i, hma) hma if inp_method == 1 if barstate.isfirst temp_arr = array.new_string(0) string val1 =na string val2 =na string val3 =na string val4 =na var str_arr_l=fu.stringify(arr_l) for i=0 to array.size(arr_l)-1 val1 := array.get(str_arr_l, i) for i=0 to array.size(arr_t)-1 val2 := array.get(arr_t, i) for i=0 to array.size(arr_s)-1 val3 := array.get(arr_s, i) for i=0 to array.size(arr_tf)-1 val4 := array.get(arr_tf, i) array.push(temp_arr, sed.encode(val1, val2, val3, val4)) temp_arr := fu.arrdedup(temp_arr) arr_in := temp_arr arr_out := array.new_float(array.size(temp_arr), na) for [i, ident] in arr_in arr_temp = sed.decode(ident) length = int(str.tonumber(array.get(arr_temp, 0))) type = array.get(arr_temp, 1) rawsrc = array.get(arr_temp, 2) tf = array.get(arr_temp, 3) if tf == timeframe.period source = fu.resource(rawsrc) switch type 'EMA' => ema(source, length, arr_out, i) 'SMA' => sma(rawsrc, length, arr_out, i) 'RMA' => rma(source, length, arr_out, i) 'WMA' => wma(rawsrc, length, arr_out, i) 'HMA_slow' => hma(rawsrc, length, arr_out, i) //'EHMA' => hma(rawsrc, length, arr_out, i) if tf != timeframe.period and change_tf(tf, inp_tf1 = inp_tf1, inp_tf2 = inp_tf2, change_tf1 = change_tf1,change_tf2 = change_tf2) arr_src = resource_tf(src =rawsrc, tf= tf, inp_tf1 = inp_tf1, inp_tf2 = inp_tf2,inp_tf3 = inp_tf3, out_tf1 = mat_out1,out_tf2 = mat_out2, out_tf3 = mat_out3) switch type 'EMA' => ema(arr_src, length, arr_out, i) 'SMA' => sma(arr_src, length, arr_out, i) 'RMA' => rma(arr_src, length, arr_out, i) 'WMA' => wma(arr_src, length, arr_out, i) 'HMA_slow' => hma(arr_src, length, arr_out, i) //'EHMA' => ehma(arr_src, length, arr_out, i) a := array.get(arr_out, array.indexof(arr_in,sed.encode(str.tostring(inp_l1), inp_type1, inp_source1, inp_tf1))) b := array.get(arr_out, array.indexof(arr_in,sed.encode(str.tostring(inp_l2), inp_type2, inp_source2, inp_tf2))) //c := array.get(arr_out, array.indexof(arr_in,sed.encode(str.tostring(inp_l3), inp_type3, inp_source3, inp_tf3))) // plot(request.security(inp_sym, inp_tf1, ta.ema(fu.resource(inp_source1), inp_l1)), title = 'compare to my ma 1', color = color.yellow) // plot(request.security(inp_sym, inp_tf2, ta.ema(fu.resource(inp_source2), inp_l2)), title = 'compare to my ma 2', color = color.purple) // plot(request.security(inp_sym, inp_tf3, ta.ema(fu.resource(inp_source3), inp_l3)), title = 'compare to my ma 3', color = color.white) float ta_ma_l1 = switch inp_type1 'RMA' => ifSecurity(inp_sym, inp_tf1, ta.rma(fu.resource(inp_source1), inp_l1)) 'SMA' => ifSecurity(inp_sym, inp_tf1, ta.sma(fu.resource(inp_source1), inp_l1)) 'EMA' => ifSecurity(inp_sym, inp_tf1, ta.ema(fu.resource(inp_source1), inp_l1)) 'HMA' => ifSecurity(inp_sym, inp_tf1, ta.hma(fu.resource(inp_source1), inp_l1)) //'VWMA' => ta.vwma(close,inp_l1) 'WMA' => ifSecurity(inp_sym, inp_tf1, ta.wma(fu.resource(inp_source1), inp_l1)) float ta_ma_l2 = switch inp_type2 'RMA' => ifSecurity(inp_sym, inp_tf2, ta.rma(fu.resource(inp_source2), inp_l2)) 'SMA' => ifSecurity(inp_sym, inp_tf2, ta.sma(fu.resource(inp_source2), inp_l2)) 'EMA' => ifSecurity(inp_sym, inp_tf2, ta.ema(fu.resource(inp_source2), inp_l2)) 'HMA' => ifSecurity(inp_sym, inp_tf2, ta.hma(fu.resource(inp_source2), inp_l2)) //'VWMA' => ta.vwma(close,inp_l2) 'WMA' => ifSecurity(inp_sym, inp_tf2, ta.wma(fu.resource(inp_source2), inp_l2)) plot(ta_ma_l1, title = 'compare to my ma 1', color = color.yellow) plot(ta_ma_l2, title = 'compare to my ma 2', color = color.rgb(255, 0, 234)) plot(3*ta.wma(fu.resource(inp_source2),math.floor(inp_l2/2)) - 2*ta.ema(fu.resource(inp_source2),math.floor(inp_l2/2))) // a = matrix.get(mat_inouts, 1, array.indexof(matrix.row(mat_inouts,0), 140203)) // b = matrix.get(mat_inouts, 1, array.indexof(matrix.row(mat_inouts,0), 210203)) // c = matrix.get(mat_inouts, 1, array.indexof(matrix.row(mat_inouts,0), 510203)) plot(a, title='my_ma l1', color = color.green) plot(b, title='my_ma l2', color = color.red) //plot(c, title='my_ma l3', color = color.rgb(47, 0, 255)) res = str.tostring(mat_out1) // res2 = inp_method == 1 ? str.tostring(matrix.row(mat_inouts, 1)) : str.tostring(arr_out) res3 = str.tostring(arr_in) [timePerBarInMs, totalTimeInMs, barsTimed, barsNotTimed] = sw.stopwatchStats() msElapsed = sw.stopwatch() if barstate.islast var table t = table.new(position.middle_right, 1, 1) var txt = str.tostring(timePerBarInMs, "ms/bar: #.######\n") + str.tostring(totalTimeInMs, "Total time (ms): #,###.######\n") + str.tostring(barsTimed + barsNotTimed, "Bars analyzed: #\n") + str.tostring(a-ta_ma_l1, "Result: #.################\n")+ res + '\n' + res3 + '\n' // res2 table.cell(t, 0, 0, txt, bgcolor = color.yellow, text_halign = text.align_right) // if barstate.islast // labtext = // label=label.new(last_bar_index, high, labtext, textalign = text.align_left) // label.delete(label[1])
RODO Fair Value Indicator
https://www.tradingview.com/script/obW8fK2i-RODO-Fair-Value-Indicator/
rodopacapital
https://www.tradingview.com/u/rodopacapital/
19
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β©rodotoken //@version=5 indicator('RODO Fair Value', overlay=true, shorttitle='RODOAS') inv = input(50, 'My RODO tokens') avp = input(6.70, 'My Average Price in USD') trade = input(500, 'Trade value') usdwu = input(68.63 , 'USD Weight (Ethereum) in %' ) usdwp = input(15.91 , 'USD Weight(Polygon) in %' ) ethw = input(5.66 , 'ETH Weight in %' ) bnbw = input(5.10 , 'BNB Weight in %' ) maticw = input(1.15 , 'MATIC Weight in %' ) hexw = input(1.33 , 'HEX Weight in %' ) uniw = input(1.09, 'UNI Weight in %' ) linkw = input(1.14, 'LINK Weight in %' ) rodo = nz(request.security("UNISWAP3ETH:RODOUSDC", timeframe.period, close)) rodo1 = nz(request.security("UNISWAP3POLYGON:RODOUSDC", timeframe.period, close)) rodo_eth = nz(request.security('UNISWAP3ETH:RODOWETH', timeframe.period, close)) eth = nz(request.security('UNISWAP3ETH:WETHUSDC', timeframe.period, close)) bnb = nz(request.security('BINANCE:BNBUSD', timeframe.period, close)) rodo_matic = nz(request.security('UNISWAP3POLYGON:RODOWMATIC', timeframe.period, close)) matic = nz(request.security('UNISWAP3POLYGON:WMATICUSDC', timeframe.period, close)) hex = nz(request.security('UNISWAP3POLYGON:HEXUSDC', timeframe.period, close)) uni = nz(request.security('UNISWAP3POLYGON:UNIUSDC', timeframe.period, close)) rodo_link = nz(request.security('UNISWAP3ETH:RODOLINK', timeframe.period, close)) link = nz(request.security('UNISWAP3ETH:LINKUSDC', timeframe.period, close)) // Calculating real time values rodoeth = rodo_eth * eth rodobnb = (rodo/bnb[1]) * bnb rodomatic1 = rodo_matic * matic rodomatic = (rodo/matic[1]) * matic rodohex = (rodo/hex[1]) * hex rodouni = (rodo/uni[1]) * uni rodolink = rodo_link* link //// Calculating USD Value usdw = (usdwu + usdwp)/100 usdcp = (rodo*(usdwu/100)) + (rodo1*(usdwp/100)) actual = (rodo1 + rodo)/2 // Calculating fair value * weights fvw = usdcp + (rodoeth*(ethw/100)) + (rodobnb*(bnbw/100)) + (rodomatic*(maticw/100)) + (rodohex*(hexw/100)) + (rodouni*(uniw/100)) + (rodolink*(linkw/100)) mid = (actual + rodoeth + rodomatic1 + rodohex + rodouni + rodolink + rodobnb)/7 // Calculating investment values invest = inv*fvw entryv = inv*avp profit_loss = invest - entryv //Calculating returns roi = (fvw - actual)/actual*100 roieth = (fvw - rodoeth)/rodoeth*100 roimat= (fvw - rodomatic1)/rodomatic1*100 roibnb = (fvw - rodobnb)/rodobnb*100 roilink = (fvw - rodolink)/rodolink*100 roiuni = (fvw - rodouni)/rodouni*100 roihex = (fvw - rodohex)/rodohex*100 // calculating dolar value returns usdv = (roi * trade) /100 ethv = (roieth * trade) /100 matv = (roimat * trade) /100 bnbv = (roibnb * trade) /100 univ = (roiuni * trade) /100 linkv = (roilink * trade) /100 hexv = (roihex * trade) /100 // Decimal Truncation truncate(number, decimals) => truncateFactor = math.pow(10, decimals) a = int(number * truncateFactor) / truncateFactor str.tostring(a) usd_roi = truncate(roi, 2) eth_roi = truncate(roieth, 2) mat_roi = truncate(roimat, 2) bnb_roi = truncate(roibnb, 2) uni_roi = truncate(roiuni, 2) hex_roi = truncate(roihex, 2) link_roi = truncate(roilink, 2) usd_ret = truncate(usdv, 2) eth_ret = truncate(ethv, 2) mat_ret = truncate(matv, 2) bnb_ret = truncate(bnbv, 2) uni_ret = truncate(univ, 2) hex_ret = truncate(hexv, 2) link_ret = truncate(linkv, 2) investment = truncate(invest,0) invret = truncate(profit_loss,0) bgcol = roi >= 0 ? #01796F : #8A3324 ethcol = roieth >= 0 ? #01796F : #8A3324 maticcol = roimat >= 0 ? #01796F : #8A3324 bnbcol = roibnb >= 0 ? #01796F : #8A3324 unicol = roiuni >= 0 ? #01796F : #8A3324 hexcol = roihex >= 0 ? #01796F : #8A3324 linkcol = roilink >= 0 ? #01796F : #8A3324 fvcol = actual > fvw ? #8A3324 : #01796F inv_status = invest > entryv ? ' $ Profit' : ' $ Loss' inv_col = invest > entryv ? #01796F : #8A3324 // Table customisation var table chart = table.new(position.bottom_left, 8, 31, border_width=1) if barstate.islast table.cell(chart, 0, 0, text='My Investment', bgcolor=inv_col, text_color=color.white, text_size = size.normal) table.cell(chart, 1, 0, text='USD', bgcolor=bgcol, text_color=color.white, text_size = size.normal) table.cell(chart, 2, 0, text='ETH', bgcolor=ethcol, text_color=color.white, text_size = size.normal) table.cell(chart, 3, 0, text='MATIC', bgcolor=maticcol, text_color=color.white, text_size = size.normal) table.cell(chart, 4, 0, text='BNB', bgcolor=bnbcol, text_color=color.white, text_size = size.normal) table.cell(chart, 5, 0, text='LINK', bgcolor=unicol, text_color=color.white, text_size = size.normal) table.cell(chart, 6, 0, text='UNI', bgcolor=hexcol, text_color=color.white, text_size = size.normal) table.cell(chart, 7, 0, text='HEX', bgcolor=linkcol, text_color=color.white, text_size = size.normal) table.cell(chart, 0, 1, text=str.tostring(investment)+ ' $', text_size = size.normal , bgcolor=inv_col, text_color=color.white) table.cell(chart, 1, 1, text=str.tostring(usd_roi)+'%', text_size = size.normal , bgcolor=color.black, text_color=color.white) table.cell(chart, 2, 1, text=str.tostring(eth_roi)+'%', text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 3, 1, text=str.tostring(mat_roi)+'%', text_size = size.normal , bgcolor=color.black, text_color=color.white) table.cell(chart, 4, 1, text=str.tostring(bnb_roi)+'%', text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 5, 1, text=str.tostring(uni_roi)+'%', text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 6, 1, text=str.tostring(hex_roi)+'%', text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 7, 1, text=str.tostring(link_roi)+'%', text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 0, 2, text=str.tostring(invret)+ inv_status, text_size = size.normal , bgcolor=inv_col, text_color=color.white) table.cell(chart, 1, 2, text=str.tostring(usd_ret), text_size = size.normal , bgcolor=color.black, text_color=color.white) table.cell(chart, 2, 2, text=str.tostring(eth_ret), text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 3, 2, text=str.tostring(mat_ret), text_size = size.normal , bgcolor=color.black, text_color=color.white) table.cell(chart, 4, 2, text=str.tostring(bnb_ret), text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 5, 2, text=str.tostring(uni_ret), text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 6, 2, text=str.tostring(hex_ret), text_size = size.normal, bgcolor=color.black, text_color=color.white) table.cell(chart, 7, 2, text=str.tostring(link_ret), text_size = size.normal, bgcolor=color.black, text_color=color.white) plot(rodoeth, title="RODO/ETH", color = color.red, trackprice=true, display = display.none) plot(rodobnb, title = "RODO/BNB", color = color.gray, trackprice = false , display = display.none) plot(rodomatic1, title = 'RODO/MATIC', color = color.yellow , display = display.none) plot(rodohex, title = 'RODO/HEX', color = color.gray, display = display.none) plot(rodouni, title = 'RODO/UNI', color = color.maroon, display = display.none) plot(rodolink, title = 'RODO/LINK', color = color.gray, display = display.none) plot(fvw, 'FAIR VALUE', color = fvcol, linewidth = 2, trackprice=true,display = display.all) plot(actual, 'USDC VALUE', color = color.blue, linewidth = 2) plot(mid, 'Arbitrage Value', color = color.red, linewidth = 1, trackprice=true , display = display.none)
VFIBs Agreement
https://www.tradingview.com/script/NhdfoJzC-VFIBs-Agreement/
jpwall
https://www.tradingview.com/u/jpwall/
11
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© jpwall //@version=5 indicator("VFIBs Agreement") // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Β© jpwall bars_vwma_st = input(title="VWMA (Short Term) Bars Back", defval = 50) bars_vwma_lt = input(title="VWMA (Long Term) Bars Back", defval = 200) bars_atr = input(title="ATR Bars Back", defval = 14) fib_1 = input(title="Fibonacci Value #1", defval = 1.618) fib_2 = input(title="Fibonacci Value #2", defval = 2.36) fib_3 = input(title="Fibonacci Value #3", defval = 3.82) fib_4 = input(title="Fibonacci Value #4", defval = 5) fib_5 = input(title="Fibonacci Value #5", defval = 6.18) fib_6 = input(title="Fibonacci Value #6", defval = 10) overbought_line_lvl = input(title="Overbought Line Level", defval = 15) oversold_line_lvl = input(title="Oversold Line Level", defval = -15) vwma_st_sma = input(title="VWMA Fibonacci Level Range (Short Term) SMA Length", defval=7) vwma_lt_sma = input(title="VWMA Fibonacci Level Range (Long Term) SMA Length", defval=7) overbought_vwma_lvl = input(title="VWMA Fibonacci Level Range Overbought (Long Term) Value", defval=18) overbought_vwma_lvl_extra = input(title="VWMA Fibonacci Level Range Extra Overbought (Long Term) Value", defval=19.5) oversold_vwma_lvl = input(title="VWMA Fibonacci Level Range Oversold (Long Term) Value", defval=-18) oversold_vwma_lvl_extra = input(title="VWMA Fibonacci Level Range Extra Oversold (Long Term) Value", defval=-19.5) vwma_st_base_color = input.color(title="VWMA Fibonacci Level Range (Short Term) Color", defval=color.yellow) vwma_lt_base_color = input.color(title="VWMA Fibonacci Level Range (Long Term) Color", defval=color.teal) overbought_line_c = input.color(title="Overbought Line Color", defval=color.red) oversold_line_c = input.color(title="Oversold Line Color", defval=color.green) bg_transp = input(title="Background Transparency", defval=75) long_vwma_oversold = input.color(title="VWMA Fibonacci Level Range Oversold (Long Term) Background", defval=color.green) long_vwma_oversold_xtra = input.color(title="VWMA Fibonacci Level Range Extra Oversold (Long Term) Background", defval=color.lime) long_vwma_overbought = input.color(title="VWMA Fibonacci Level Range Overbought (Long Term) Background", defval=color.red) long_vwma_overbought_xtra = input.color(title="VWMA Fibonacci Level Range Extra Overbought (Long Term) Background", defval=color.maroon) default_bg = input.color(title="Default Background", defval=color.gray) mid = ta.vwma(math.avg(high, low, close), bars_vwma_lt) mid_st = ta.vwma(math.avg(high, low, close), bars_vwma_st) atr = ta.atr(bars_atr) tf1 = (atr * fib_1) + mid tf2 = (atr * fib_2) + mid tf3 = (atr * fib_3) + mid tf4 = (atr * fib_4) + mid tf5 = (atr * fib_5) + mid tf6 = (atr * fib_6) + mid bf1 = mid - (atr * fib_1) bf2 = mid - (atr * fib_2) bf3 = mid - (atr * fib_3) bf4 = mid - (atr * fib_4) bf5 = mid - (atr * fib_5) bf6 = mid - (atr * fib_6) tf1_st = (atr * fib_1) + mid_st tf2_st = (atr * fib_2) + mid_st tf3_st = (atr * fib_3) + mid_st tf4_st = (atr * fib_4) + mid_st tf5_st = (atr * fib_5) + mid_st tf6_st = (atr * fib_6) + mid_st bf1_st = mid_st - (atr * fib_1) bf2_st = mid_st - (atr * fib_2) bf3_st = mid_st - (atr * fib_3) bf4_st = mid_st - (atr * fib_4) bf5_st = mid_st - (atr * fib_5) bf6_st = mid_st - (atr * fib_6) float avg = math.avg(high, low, open, close) get_loc() => val = -6 * math.log(1 * 5) if close < mid if close < bf1 val := -6 * math.log(2 * 5) if close < bf2 val := -6 * math.log(3 * 5) if close < bf3 val := -6 * math.log(4 * 5) if close < bf4 val := -6 * math.log(5 * 5) if close < bf5 val := -6 * math.log(6 * 5) if close < bf6 val := -6 * math.log(7 * 5) else val := 6 * math.log(7 * 5) if close < tf6 val := 6 * math.log(6 * 5) if close < tf5 val := 6 * math.log(5 * 5) if close < tf4 val := 6 * math.log(4 * 5) if close < tf3 val := 6 * math.log(3 * 5) if close < tf2 val := 6 * math.log(2 * 5) if close < tf1 val := 6 * math.log(1 * 5) val get_loc_st() => val = -6 * math.log(1 * 5) if close < mid_st if close < bf1_st val := -6 * math.log(2 * 5) if close < bf2_st val := -6 * math.log(3 * 5) if close < bf3_st val := -6 * math.log(4 * 5) if close < bf4_st val := -6 * math.log(5 * 5) if close < bf5_st val := -6 * math.log(6 * 5) if close < bf6_st val := -6 * math.log(7 * 5) else val := 6 * math.log(7 * 5) if close < tf6_st val := 6 * math.log(6 * 5) if close < tf5_st val := 6 * math.log(5 * 5) if close < tf4_st val := 6 * math.log(4 * 5) if close < tf3_st val := 6 * math.log(3 * 5) if close < tf2_st val := 6 * math.log(2 * 5) if close < tf1_st val := 6 * math.log(1 * 5) val float long_sma = ta.sma(get_loc(), vwma_lt_sma) float short_sma = ta.sma(get_loc_st(), vwma_st_sma) color barc = if long_sma >= overbought_vwma_lvl_extra long_vwma_overbought_xtra else if long_sma >= overbought_vwma_lvl long_vwma_overbought else if long_sma >= 0 default_bg else if long_sma <= oversold_vwma_lvl_extra long_vwma_oversold_xtra else if long_sma <= oversold_vwma_lvl long_vwma_oversold else default_bg plot(long_sma, color=vwma_lt_base_color, linewidth=3) plot(short_sma, color=vwma_st_base_color, linewidth=2) bgcolor(barc, transp=bg_transp) hline(overbought_line_lvl, color=overbought_line_c, linewidth=2) hline(0) hline(oversold_line_lvl, color=oversold_line_c, linewidth=2)
Secretariat
https://www.tradingview.com/script/13FkWr0z-Secretariat/
MrBadger
https://www.tradingview.com/u/MrBadger/
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/ // Β© MrBadger //@version=5 indicator("Secretariat",overlay=true) // Inputs high_low_lookback = input(50,"High/Low lookback") locationForTrendState = input("bottom", "Location for trend state if visible", "location for trendstate if visible") showTrendState = input(true, "Trend state") allowEntriesOffFastMA = input(false, "Allow aggresive entries (off fast MA)") debugMarkers = input(false,"Show debug markers") //Set MA's maFast = ta.ema(close,9) maSlow = ta.wma(close,30) // Plot MAS plot(maFast,color=color.red,title="secritariate fast") plot(maSlow,color=color.navy,title="secritariate slow") // Bullsih or bearish according to moving averages maBullish = (maFast > maSlow) maBearish = (maFast < maSlow) // Plot the trendstate plotshape((maBullish and showTrendState), color=color.green, location = (locationForTrendState == "bottom" ? location.bottom : location.top), size=size.tiny) plotshape((maBearish and showTrendState), color=color.red, location =(locationForTrendState == "bottom" ? location.bottom : location.top), size=size.tiny) //movingStop = maBullish ? ta.lowest(low,12) : ta.highest(high,12) //plot(movingStop, color=(maBullish ? color.orange : color.blue)) // Should we draw dots? bool lowestInLookback = na bool highestInLookback = na lowestInLookback := (low <= ta.lowest(low,high_low_lookback) ? true : false ) and maBearish highestInLookback := (high >= ta.highest(high,high_low_lookback) ? true : false) and maBullish plotshape(lowestInLookback, title="Low dots", style=shape.circle, color=color.red, location=location.belowbar, size=size.tiny) plotshape(highestInLookback, title="High dots", style=shape.circle, color=color.blue, location=location.abovebar, size=size.tiny) var string dotStatus = na sellEntryOnSlow = false buyEntryOnSlow = false sellEntryOnFast = false buyEntryOnFast = false if lowestInLookback and maBearish dotStatus := "PENDING SELL" if highestInLookback and maBullish dotStatus := "PENDING BUY" if ta.crossunder(close,maSlow) if dotStatus == "PENDING SELL" if close < maSlow sellEntryOnSlow := true dotStatus := "SELL" if ta.crossover(close,maSlow) if dotStatus == "PENDING BUY" if close > maSlow buyEntryOnSlow := true dotStatus := "BUY" if ta.crossunder(close,maFast) and dotStatus == "PENDING SELL" and allowEntriesOffFastMA and (close < maFast) sellEntryOnFast := true dotStatus := "SELL" if ta.crossover(close,maFast) and dotStatus == "PENDING BUY" and allowEntriesOffFastMA and (close > maFast) buyEntryOnFast := true dotStatus := "BUY" if (dotStatus == "PENDING BUY" or dotStatus == "BUY" ) and ta.crossunder(maFast,maSlow) dotStatus := "NO TRADE" if (dotStatus == "PENDING SELL" or dotStatus == "SELL") and ta.crossover(maFast,maSlow) dotStatus := "NO TRADE" plotshape((ta.crossunder(maFast,maSlow) and debugMarkers ? maFast : na), title="cancel buys", style=shape.xcross, color=color.red, location=location.absolute) plotshape((ta.crossover(maFast,maSlow) and debugMarkers ? maFast :na), title="cancel sells", style=shape.xcross, color=color.green, location=location.absolute) plotshape((dotStatus == "PENDING SELL" and debugMarkers ? maFast : na), title="pending sell", style=shape.diamond, color=color.red, location=location.absolute) plotshape((dotStatus == "PENDING BUY" and debugMarkers ? maFast :na), title="pending buy", style=shape.diamond, color=color.green, location=location.absolute) // TRADE SIGNALS sellEntryCandle = (dotStatus == "SELL") buyEntryCandle = (dotStatus == "BUY") plotshape(sellEntryCandle, "Sell signal", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.tiny) plotshape(buyEntryCandle, "Buy signal", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny) // END TRADES SIGNALS alertcondition(sellEntryOnFast,"Secretariat aggressive sell","Secretariat bearish pull back to fast") alertcondition(sellEntryOnSlow,"Secretariat sell","Secretariat bearish pull back to slow") alertcondition(buyEntryOnFast,"Secretariat aggressive buy","Secretariat bullish pull back to fast") alertcondition(buyEntryOnSlow,"Secretariat buy","Secretariat bullish pull back to slow") dotStatus := ( dotStatus == "BUY" or dotStatus == "SELL" ? "NO TRADE" : dotStatus)
Fibonacci Bollinger Band Cluster
https://www.tradingview.com/script/zQwjKQff-Fibonacci-Bollinger-Band-Cluster/
LeafAlgo
https://www.tradingview.com/u/LeafAlgo/
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/ // Β© PlantFi //@version=5 indicator(shorttitle="FIB BB Cluster", title="Fibonacci Bollinger Band Cluster", overlay=true, timeframe="", timeframe_gaps=true) length = input.int(20, minval=1) src = input(ohlc4, title="Source") // Fib MA hfib_ma_3 = ta.ema(high, 3) hfib_ma_5 = ta.ema(high, 5) hfib_ma_8 = ta.ema(high, 8) hfib_ma_13 = ta.ema(high, 13) hfib_ma_21 = ta.ema(high, 21) hfib_ma_34 = ta.ema(high, 34) hfib_ma_55 = ta.ema(high, 55) hfib_ma_89 = ta.ema(high, 89) hfib_ma_144 = ta.ema(high, 144) hfib_ma_233 = ta.ema(high, 233) fib_high = (hfib_ma_3 + hfib_ma_5 + hfib_ma_8 + hfib_ma_13 + hfib_ma_21 + hfib_ma_34 + hfib_ma_55 + hfib_ma_89 + hfib_ma_144 + hfib_ma_233) / 10 plot(fib_high, linewidth=3, color = (fib_high < close) ? color.green : color.red) lfib_ma_3 = ta.ema(low, 3) lfib_ma_5 = ta.ema(low, 5) lfib_ma_8 = ta.ema(low, 8) lfib_ma_13 = ta.ema(low, 13) lfib_ma_21 = ta.ema(low, 21) lfib_ma_34 = ta.ema(low, 34) lfib_ma_55 = ta.ema(low, 55) lfib_ma_89 = ta.ema(low, 89) lfib_ma_144 = ta.ema(low, 144) lfib_ma_233 = ta.ema(low, 233) fib_low = (lfib_ma_3 + lfib_ma_5 + lfib_ma_8 + lfib_ma_13 + lfib_ma_21 + lfib_ma_34 + lfib_ma_55 + lfib_ma_89 + lfib_ma_144 + lfib_ma_233) / 10 plot(fib_low, linewidth=3, color = (fib_low < close) ? color.lime : color.orange) cfib_ma_3 = ta.ema(ohlc4, 3) cfib_ma_5 = ta.ema(ohlc4, 5) cfib_ma_8 = ta.ema(ohlc4, 8) cfib_ma_13 = ta.ema(ohlc4, 13) cfib_ma_21 = ta.ema(ohlc4, 21) cfib_ma_34 = ta.ema(ohlc4, 34) cfib_ma_55 = ta.ema(ohlc4, 55) cfib_ma_89 = ta.ema(ohlc4, 89) cfib_ma_144 = ta.ema(ohlc4, 144) cfib_ma_233 = ta.ema(ohlc4, 233) fib_ohlc4 = (cfib_ma_3 + cfib_ma_5 + cfib_ma_8 + cfib_ma_13 + cfib_ma_21 + cfib_ma_34 + cfib_ma_55 + cfib_ma_89 + cfib_ma_144 + cfib_ma_233) / 10 plot(fib_ohlc4, 'FIB_OHLC4', color=color.white, linewidth=4) // Bands basis = fib_ohlc4 dev_1 = 1 * ta.stdev(src, length) dev_2 = 2 * ta.stdev(src, length) dev_3 = 3 * ta.stdev(src, length) dev_5 = 5 * ta.stdev(src, length) dev_8 = 8 * ta.stdev(src, length) upper_1 = basis + dev_1 upper_2 = basis + dev_2 upper_3 = basis + dev_3 upper_5 = basis + dev_5 upper_8 = basis + dev_8 f_upper = (upper_1 + upper_2 + upper_3 + upper_5 + upper_8) / 5 p_f_upper = plot(f_upper, "Upper", color=color.white, linewidth=4) plot(upper_1, 'Upper_1', color=color.lime) plot(upper_2, 'Upper_2', color=color.lime) plot(upper_3, 'Upper_3', color=color.lime) lower_1 = basis - dev_1 lower_2 = basis - dev_2 lower_3 = basis - dev_3 lower_5 = basis - dev_5 lower_8 = basis - dev_8 f_lower = (lower_1 + lower_2 + lower_3 + lower_5 + lower_8) / 5 p_f_lower = plot(f_lower, "Lower", color=color.white, linewidth=4) plot(lower_1, 'Lower_1', color=color.red) plot(lower_2, 'Lower_2', color=color.red) plot(lower_3, 'Lower_3', color=color.red) fill(p_f_upper, p_f_lower, title = "Background", color=color.rgb(33, 150, 243, 95))