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
Quickfingers Luc base scanner - version 2
https://www.tradingview.com/script/C2reWr87-Quickfingers-Luc-base-scanner-version-2/
rex_wolfe
https://www.tradingview.com/u/rex_wolfe/
154
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rex_wolfe // Quickfingers Luc (QFL) base scanner - Marvin // Version 2.2 (Marvin) //@version=5 indicator(title = "Quickfingers Luc base scanner - Marvin", shorttitle = "QFL Marvin", overlay = true, max_lines_count = 500) // Get user input factor = input.float(title = "Volatility factor", tooltip = "This value is multiplied by the volatility measured as a percent. The price needs to move up or down by more than the resulting percentage to confirm a base or top respectively. Note: This value is ONLY used if the following tickbox is unchecked.", defval = 5.2, step = 0.1, minval = 0.1) useManual = input.bool(title = "Use manual-based measures", tooltip = "If unticked, the above volatility factor will be used to confirm bases and tops and the following manual percentage value will be ignored. If ticked, the reverse is true.", defval = false) move = input.float(title = "Move to confirm previous base or top (%)", tooltip = "Price needs to move up or down by more than this percentage to confirm the previous base or top respectively. Note: This value is ONLY used if the above tickbox is checked.", defval = 5, step = 0.1, minval = 0) / 100 crack = input.float(title = "Crack below base (%)", tooltip = "Price needs to fall more than this percentage below the base to flag a buy signal.", defval = 3, step = 0.1, minval = 0.1) / 100 // Select information to show on the chart showBuys = input.string(title = "Show buy signals", options = ["First", "All", "None"], tooltip = "Show all buy signals, first buy signal only, or no buy signals.", defval = "First") showBases = input.bool(title = "Show bases", tooltip = "Shows bases.", defval = true) showTops = input.bool(title = "Show tops", tooltip = "Shows hidden calculations that are used to find new bases.", defval = false) showLowest = input.bool(title = "Show simple lowest lows", tooltip = "Shows hidden calculations that are used to find new bases.", defval = false) showHighest = input.bool(title = "Show simple highest highs", tooltip = "Shows hidden calculations that are used to find the pump from the base.", defval = false) // Declare variables var atrp = float(na) var highestHigh = float(high) var top = float(high) var lowestLow = float(low) var base = float(low) var buyLimit = float(na) var buyFlag = bool(false) var flag = string("first") var count = int(0) var saveCount = int(0) var fill = bool(false) var labelText = string(na) var box buyRange = na // Index the count by one count := count + 1 // Reset buy limit buyLimit := na // Calculate volatility using a hybrid average true range as a percentage and then smoothed if useManual == false atrp := ta.tr / hl2 move := ta.sma(atrp, 200) * factor // Need to do something different at the start of the time series to seed the variables if flag == "first" if (highestHigh - low ) / highestHigh > move flag := "top" top := highestHigh highestHigh := high count := 0 else if (high - lowestLow) / lowestLow > move flag := "base" base := lowestLow lowestLow := low count := 0 // Find next TOP else if flag == "base" if low < lowestLow lowestLow := low if high > highestHigh highestHigh := high lowestLow := low count := 0 if (highestHigh[1] - low) / highestHigh[1] > move // Top is confirmed therefore save details flag := "top" fill := true top := highestHigh[1] saveCount := count[1] + 1 // Reset variables highestHigh := high lowestLow := low count := 0 // Find next BASE else if flag == "top" if high > highestHigh highestHigh := high if low < lowestLow highestHigh := high lowestLow := low count := 0 if (high - lowestLow[1]) / lowestLow[1] > move // Base is confirmed therefore save details flag := "base" fill := true base := lowestLow[1] saveCount := count[1] + 1 // Reset variables highestHigh := high lowestLow := low count := 0 buyFlag := false // Set buy condition if showBuys == "All" or (showBuys == "First" and buyFlag == false) if (base - low) / base > crack buyLimit := base * (1 - crack) buyFlag := true // Plot the optional extra information plot(showLowest ? lowestLow : na, title = "Simple lowest low", color = color.purple) plot(showHighest ? highestHigh : na, title = "Simple highest high", color = color.purple) plot(showTops ? top : na, "Top", color = top == top[1] ? color.new(color.purple, 0) : color.new(color.white, 100)) // Fill the gap between the top and when it was identified with a dotted line if fill and showTops and flag == "top" line.new(bar_index - saveCount, top, bar_index, top, color = color.purple, style=line.style_dotted) // This line causes repainting fill := false // Plot bases plot(showBases ? base : na, "Base", color = base == base[1] ? color.new(color.blue, 0) : color.new(color.white, 100)) // Fill the gap between the base and when it was identified with a dotted line if fill and showBases and flag == "base" line.new(bar_index - saveCount, base, bar_index, base, color = color.blue, style=line.style_dotted) // This line causes repainting fill := false // Plot buy signals plotshape(showBuys == "All" ? buyLimit : na, title="Buy flag", text="B", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.blue, textcolor=color.white) if showBuys == "First" if buyLimit label.new(x = bar_index, y = buyLimit, text = "Buy < " + str.tostring(buyLimit), color = color.blue, style = label.style_label_upper_right, textcolor = color.white) buyRange := box.new(left = bar_index, top = buyLimit, right = bar_index + 1, bottom = lowestLow, border_color = color.new(color.blue, 90), bgcolor = color.new(color.blue, 90)) else if buyFlag == true box.set_rightbottom(buyRange, bar_index + 1, lowestLow) // This line causes repainting // Variable sent to the data window that shows the size of move currently being used to confirm bases and tops plotchar(move * 100, "Move (%)", "", location.bottom, color = color.new(color.white, 100)) // Send an alert if buyLimit alert("QFL buy " + syminfo.tickerid + " below $" + str.tostring(buyLimit) + ".", freq = alert.freq_once_per_bar) // Roger, Candy, Elwood, Blacky, Bill. Not yet, Captain Chaos, not yet.
RSI Dashboard Monitor [Skiploss]
https://www.tradingview.com/script/Zcw4cmR4-RSI-Dashboard-Monitor-Skiploss/
Skiploss
https://www.tradingview.com/u/Skiploss/
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/ // © Skiploss //@version=5 //indicator(title = "RSI Dashboard [Skiploss]", shorttitle = "RSID v0.77", overlay = true) // Overlay ON indicator(title = "RSI Dashboard Monitor [Skiploss]", shorttitle = "RSID M v0.77") // Overlay OFF // Input Symbol 01-04 input_symbol_ticker_01 = input(true, "", inline = "1", group = "Symbol") input_symbol_01 = input.symbol("PEPPERSTONE:US30", "", inline = "1", group = "Symbol") input_symbol_ticker_02 = input(false, "", inline = "2", group = "Symbol") input_symbol_02 = input.symbol("PEPPERSTONE:GER40", "", inline = "2", group = "Symbol") input_symbol_ticker_03 = input(false, "", inline = "3", group = "Symbol") input_symbol_03 = input.symbol("PEPPERSTONE:XAUUSD", "", inline = "3", group = "Symbol") input_symbol_ticker_04 = input(false, "", inline = "4", group = "Symbol") input_symbol_04 = input.symbol("PEPPERSTONE:SPOTCRUDE", "", inline = "4", group = "Symbol") // Relative Strength Index Setting relative_strength_index_length = input.int(title = "RSI Length", defval = 14, minval = 2, maxval = 365, group = 'RSI Setting') relative_strength_index_overbought_max = input.int(title = "Overbought Max", defval = 75, minval = 51, maxval = 100, group = 'RSI Setting') relative_strength_index_overbought_med = input.int(title = "Overbought Med", defval = 65, minval = 51, maxval = 100, group = 'RSI Setting') relative_strength_index_overbought_min = input.int(title = "Overbought Min", defval = 55, minval = 51, maxval = 100, group = 'RSI Setting') relative_strength_index_oversold_max = input.int(title = "Oversold Max", defval = 25, minval = 0, maxval = 50, group = 'RSI Setting') relative_strength_index_oversold_med = input.int(title = "Oversold Med", defval = 35, minval = 0, maxval = 50, group = 'RSI Setting') relative_strength_index_oversold_min = input.int(title = "Oversold Min", defval = 45, minval = 0, maxval = 50, group = 'RSI Setting') relative_strength_index = ta.rsi(close, relative_strength_index_length) // Style Setting dashboard_location = input.session("Bottom Left", "Dashboard Location", options = ["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"], group = 'Style Settings') dashboard_text_size = input.session( 'Normal', "Dashboard Size", options = ["Tiny","Small","Normal","Large"], group = 'Style Settings') color_status_overbought_max = input(#8ebbff, 'Overbought Color Max', group = 'Style Setting') color_status_overbought_med = input(#b0cfff, 'Overbought Color Med', group = 'Style Setting') color_status_overbought_min = input(#c7ddff, 'Overbought Color Min', group = 'Style Setting') color_status_oversold_max = input(#ff8e8e, 'Oversold Color Max', group = 'Style Setting') color_status_oversold_med = input(#ffb0b0, 'Oversold Color Med', group = 'Style Setting') color_status_oversold_min = input(#ffc7c7, 'Oversold Color Min', group = 'Style Setting') color_status_neutral = input(#ffffff, 'Neutral Color', group = 'Style Setting') color_text = input(#141823, 'Text Color', group = 'Style Setting') transparency = input.int(35, 'Transparency', minval = 0, maxval = 100, group = 'Style Setting') // Timeframes timeframe_01 = input.timeframe( "1", title = "1st", group = "Resolution") timeframe_02 = input.timeframe( "5", title = "2nd", group = "Resolution") timeframe_03 = input.timeframe( "15", title = "3rd", group = "Resolution") timeframe_04 = input.timeframe( "30", title = "4th", group = "Resolution") timeframe_05 = input.timeframe( "60", title = "5th", group = "Resolution") timeframe_06 = input.timeframe("120", title = "6th", group = "Resolution") timeframe_07 = input.timeframe("240", title = "7th", group = "Resolution") timeframe_08 = input.timeframe("480", title = "8th", group = "Resolution") timeframe_09 = input.timeframe( "D", title = "9th", group = "Resolution") timeframe_10 = input.timeframe( "W", title = "10th", group = "Resolution") // Relative Strength Index Values // Symbol 01 symbol_01_value_01 = request.security(input_symbol_01, timeframe_01, ta.rsi(close,relative_strength_index_length)) symbol_01_value_02 = request.security(input_symbol_01, timeframe_02, ta.rsi(close,relative_strength_index_length)) symbol_01_value_03 = request.security(input_symbol_01, timeframe_03, ta.rsi(close,relative_strength_index_length)) symbol_01_value_04 = request.security(input_symbol_01, timeframe_04, ta.rsi(close,relative_strength_index_length)) symbol_01_value_05 = request.security(input_symbol_01, timeframe_05, ta.rsi(close,relative_strength_index_length)) symbol_01_value_06 = request.security(input_symbol_01, timeframe_06, ta.rsi(close,relative_strength_index_length)) symbol_01_value_07 = request.security(input_symbol_01, timeframe_07, ta.rsi(close,relative_strength_index_length)) symbol_01_value_08 = request.security(input_symbol_01, timeframe_08, ta.rsi(close,relative_strength_index_length)) symbol_01_value_09 = request.security(input_symbol_01, timeframe_09, ta.rsi(close,relative_strength_index_length)) symbol_01_value_10 = request.security(input_symbol_01, timeframe_10, ta.rsi(close,relative_strength_index_length)) // Symbol 02 symbol_02_value_01 = request.security(input_symbol_02, timeframe_01, ta.rsi(close,relative_strength_index_length)) symbol_02_value_02 = request.security(input_symbol_02, timeframe_02, ta.rsi(close,relative_strength_index_length)) symbol_02_value_03 = request.security(input_symbol_02, timeframe_03, ta.rsi(close,relative_strength_index_length)) symbol_02_value_04 = request.security(input_symbol_02, timeframe_04, ta.rsi(close,relative_strength_index_length)) symbol_02_value_05 = request.security(input_symbol_02, timeframe_05, ta.rsi(close,relative_strength_index_length)) symbol_02_value_06 = request.security(input_symbol_02, timeframe_06, ta.rsi(close,relative_strength_index_length)) symbol_02_value_07 = request.security(input_symbol_02, timeframe_07, ta.rsi(close,relative_strength_index_length)) symbol_02_value_08 = request.security(input_symbol_02, timeframe_08, ta.rsi(close,relative_strength_index_length)) symbol_02_value_09 = request.security(input_symbol_02, timeframe_09, ta.rsi(close,relative_strength_index_length)) symbol_02_value_10 = request.security(input_symbol_02, timeframe_10, ta.rsi(close,relative_strength_index_length)) // Symbol 03 symbol_03_value_01 = request.security(input_symbol_03, timeframe_01, ta.rsi(close,relative_strength_index_length)) symbol_03_value_02 = request.security(input_symbol_03, timeframe_02, ta.rsi(close,relative_strength_index_length)) symbol_03_value_03 = request.security(input_symbol_03, timeframe_03, ta.rsi(close,relative_strength_index_length)) symbol_03_value_04 = request.security(input_symbol_03, timeframe_04, ta.rsi(close,relative_strength_index_length)) symbol_03_value_05 = request.security(input_symbol_03, timeframe_05, ta.rsi(close,relative_strength_index_length)) symbol_03_value_06 = request.security(input_symbol_03, timeframe_06, ta.rsi(close,relative_strength_index_length)) symbol_03_value_07 = request.security(input_symbol_03, timeframe_07, ta.rsi(close,relative_strength_index_length)) symbol_03_value_08 = request.security(input_symbol_03, timeframe_08, ta.rsi(close,relative_strength_index_length)) symbol_03_value_09 = request.security(input_symbol_03, timeframe_09, ta.rsi(close,relative_strength_index_length)) symbol_03_value_10 = request.security(input_symbol_03, timeframe_10, ta.rsi(close,relative_strength_index_length)) // Symbol 04 symbol_04_value_01 = request.security(input_symbol_04, timeframe_01, ta.rsi(close,relative_strength_index_length)) symbol_04_value_02 = request.security(input_symbol_04, timeframe_02, ta.rsi(close,relative_strength_index_length)) symbol_04_value_03 = request.security(input_symbol_04, timeframe_03, ta.rsi(close,relative_strength_index_length)) symbol_04_value_04 = request.security(input_symbol_04, timeframe_04, ta.rsi(close,relative_strength_index_length)) symbol_04_value_05 = request.security(input_symbol_04, timeframe_05, ta.rsi(close,relative_strength_index_length)) symbol_04_value_06 = request.security(input_symbol_04, timeframe_06, ta.rsi(close,relative_strength_index_length)) symbol_04_value_07 = request.security(input_symbol_04, timeframe_07, ta.rsi(close,relative_strength_index_length)) symbol_04_value_08 = request.security(input_symbol_04, timeframe_08, ta.rsi(close,relative_strength_index_length)) symbol_04_value_09 = request.security(input_symbol_04, timeframe_09, ta.rsi(close,relative_strength_index_length)) symbol_04_value_10 = request.security(input_symbol_04, timeframe_10, ta.rsi(close,relative_strength_index_length)) // Table var table_position = dashboard_location == 'Top Left' ? position.top_left : dashboard_location == 'Bottom Left' ? position.bottom_left : dashboard_location == 'Middle Right' ? position.middle_right : dashboard_location == 'Bottom Center' ? position.bottom_center : dashboard_location == 'Top Right' ? position.top_right : position.bottom_right var table_text_size = dashboard_text_size == 'Tiny' ? size.tiny : dashboard_text_size == 'Small' ? size.small : dashboard_text_size == 'Normal' ? size.normal : size.large var dashboard = table.new(table_position,12,5, frame_color = color_text, frame_width = 1, border_color= color_text, border_width= 1) if (barstate.islast) //headings table.cell(dashboard, 1, 0, 'Symbols' , width = 12 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 2, 0, timeframe_01 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 3, 0, timeframe_02 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 4, 0, timeframe_03 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 5, 0, timeframe_04 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 6, 0, timeframe_05 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 7, 0, timeframe_06 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 8, 0, timeframe_07 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 9, 0, timeframe_08 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 10, 0, timeframe_09 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 11, 0, timeframe_10 , width = 7 ,text_color=color.white,text_size=table_text_size,bgcolor=color.black) // Symbol 01 if input_symbol_ticker_01 table.cell(dashboard, 1, 1, str.replace_all(input_symbol_01, syminfo.prefix + ":", ''),text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 2, 1, str.tostring(symbol_01_value_01, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_01 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_01 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_01 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_01 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_01 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_01 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 3, 1, str.tostring(symbol_01_value_02, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_02 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_02 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_02 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_02 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_02 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_02 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 4, 1, str.tostring(symbol_01_value_03, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_03 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_03 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_03 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_03 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_03 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_03 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 5, 1, str.tostring(symbol_01_value_04, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_04 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_04 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_04 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_04 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_04 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_04 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 6, 1, str.tostring(symbol_01_value_05, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_05 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_05 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_05 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_05 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_05 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_05 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 7, 1, str.tostring(symbol_01_value_06, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_06 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_06 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_06 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_06 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_06 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_06 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 8, 1, str.tostring(symbol_01_value_07, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_07 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_07 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_07 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_07 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_07 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_07 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 9, 1, str.tostring(symbol_01_value_08, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_08 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_08 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_08 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_08 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_08 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_08 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 10, 1, str.tostring(symbol_01_value_09, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_09 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_09 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_09 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_09 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_09 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_09 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 11, 1, str.tostring(symbol_01_value_10, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_01_value_10 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_01_value_10 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_01_value_10 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_01_value_10 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_01_value_10 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_01_value_10 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) // Symbol 02 if input_symbol_ticker_02 table.cell(dashboard, 1, 2, str.replace_all(input_symbol_02, syminfo.prefix + ":", ''),text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 2, 2, str.tostring(symbol_02_value_01, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_01 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_01 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_01 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_01 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_01 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_01 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 3, 2, str.tostring(symbol_02_value_02, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_02 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_02 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_02 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_02 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_02 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_02 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 4, 2, str.tostring(symbol_02_value_03, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_03 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_03 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_03 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_03 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_03 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_03 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 5, 2, str.tostring(symbol_02_value_04, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_04 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_04 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_04 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_04 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_04 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_04 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 6, 2, str.tostring(symbol_02_value_05, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_05 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_05 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_05 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_05 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_05 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_05 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 7, 2, str.tostring(symbol_02_value_06, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_06 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_06 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_06 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_06 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_06 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_06 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 8, 2, str.tostring(symbol_02_value_07, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_07 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_07 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_07 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_07 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_07 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_07 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 9, 2, str.tostring(symbol_02_value_08, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_08 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_08 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_08 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_08 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_08 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_08 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 10, 2, str.tostring(symbol_02_value_09, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_09 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_09 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_09 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_09 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_09 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_09 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 11, 2, str.tostring(symbol_02_value_10, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_02_value_10 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_02_value_10 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_02_value_10 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_02_value_10 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_02_value_10 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_02_value_10 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) // Symbol 03 if input_symbol_ticker_03 table.cell(dashboard, 1, 3, str.replace_all(input_symbol_03, syminfo.prefix + ":", ''),text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 2, 3, str.tostring(symbol_03_value_01, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_01 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_01 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_01 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_01 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_01 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_01 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 3, 3, str.tostring(symbol_03_value_02, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_02 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_02 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_02 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_02 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_02 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_02 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 4, 3, str.tostring(symbol_03_value_03, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_03 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_03 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_03 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_03 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_03 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_03 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 5, 3, str.tostring(symbol_03_value_04, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_04 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_04 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_04 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_04 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_04 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_04 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 6, 3, str.tostring(symbol_03_value_05, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_05 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_05 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_05 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_05 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_05 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_05 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 7, 3, str.tostring(symbol_03_value_06, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_06 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_06 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_06 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_06 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_06 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_06 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 8, 3, str.tostring(symbol_03_value_07, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_07 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_07 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_07 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_07 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_07 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_07 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 9, 3, str.tostring(symbol_03_value_08, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_08 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_08 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_08 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_08 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_08 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_08 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 10, 3, str.tostring(symbol_03_value_09, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_09 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_09 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_09 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_09 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_09 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_09 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 11, 3, str.tostring(symbol_03_value_10, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_03_value_10 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_03_value_10 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_03_value_10 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_03_value_10 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_03_value_10 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_03_value_10 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) // Symbol 04 if input_symbol_ticker_04 table.cell(dashboard, 1, 4, str.replace_all(input_symbol_04, syminfo.prefix + ":", ''),text_color=color.white,text_size=table_text_size,bgcolor=color.black) table.cell(dashboard, 2, 4, str.tostring(symbol_04_value_01, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_01 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_01 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_01 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_01 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_01 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_01 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 3, 4, str.tostring(symbol_04_value_02, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_02 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_02 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_02 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_02 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_02 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_02 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 4, 4, str.tostring(symbol_04_value_03, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_03 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_03 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_03 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_03 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_03 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_03 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 5, 4, str.tostring(symbol_04_value_04, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_04 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_04 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_04 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_04 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_04 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_04 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 6, 4, str.tostring(symbol_04_value_05, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_05 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_05 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_05 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_05 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_05 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_05 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 7, 4, str.tostring(symbol_04_value_06, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_06 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_06 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_06 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_06 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_06 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_06 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 8, 4, str.tostring(symbol_04_value_07, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_07 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_07 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_07 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_07 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_07 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_07 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 9, 4, str.tostring(symbol_04_value_08, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_08 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_08 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_08 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_08 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_08 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_08 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 10, 4, str.tostring(symbol_04_value_09, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_09 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_09 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_09 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_09 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_09 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_09 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency)) table.cell(dashboard, 11, 4, str.tostring(symbol_04_value_10, '#.##'),text_color=color_text,text_size=table_text_size, bgcolor=color.new(symbol_04_value_10 >= relative_strength_index_overbought_max ? color_status_overbought_max : symbol_04_value_10 >= relative_strength_index_overbought_med ? color_status_overbought_med : symbol_04_value_10 >= relative_strength_index_overbought_min ? color_status_overbought_min : symbol_04_value_10 <= relative_strength_index_oversold_max ? color_status_oversold_max : symbol_04_value_10 <= relative_strength_index_oversold_med ? color_status_oversold_med : symbol_04_value_10 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral,transparency))
Reversal picker
https://www.tradingview.com/script/FTcGkE3K-Reversal-picker/
Gudanin
https://www.tradingview.com/u/Gudanin/
355
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Gudanin //@version=5 indicator("Reversal picker", overlay = true) //line variables line1 = ta.sma(close, 14) line2 = ta.sma(close, 200) highrsi = ta.rsi(close,14) > 50 lowrsi = ta.rsi(close,14) < 50 line11 = ta.sma(close, 19) line22 = ta.sma(close, 21) highrsi1 = ta.rsi(close,14) >= 65 lowrsi1 = ta.rsi(close,14) <= 35 //Reversal logic BuyP= line11 > line22 and highrsi1 and line1 > line2 and highrsi var label up = na var label down = na var line l = na var float first_close = na var bool can_draw = false var line l1 = na var float first_close1 = na var bool can_draw1 = false //support and resistance line colors color supportlinecolor = input.color(color.green, "Support line color") color resistancelinecolor = input.color(color.red, "Resistance line color") //label colors color buylabelcolor = input.color(color.green, "Buy label color") color selllabelcolor = input.color(color.red, "Sell label color") //text colors color buylabeltextcolor = input.color(color.white, "Buy label text color") color selllabeltextcolor = input.color(color.white, "Sell label text color") if(line11 > line22 and highrsi1 and line1 > line2 and highrsi) first_close := close // Reset session high can_draw := true // We are allowed to draw a line l := line.new(bar_index-1, first_close, bar_index, first_close, color=resistancelinecolor, xloc = xloc.bar_index, extend = extend.both,width=2) line.delete(l[1]) if(na(up)) //Does not exist, create one up := label.new(bar_index, close, "Price reversing \n Sell below resistance line", color=selllabelcolor, yloc=yloc.abovebar, textcolor = selllabeltextcolor) else label.set_x(up, bar_index) if(line11 < line22 and lowrsi and line1 < line2 and lowrsi ) first_close1 := open // Reset session high can_draw1 := true // We are allowed to draw a line l1 := line.new(bar_index-1, first_close1, bar_index, first_close1, color=supportlinecolor, xloc = xloc.bar_index, extend = extend.both,width=2) line.delete(l1[1]) if(na(down)) //Does not exist, create one down := label.new(bar_index, close, "Price reversing \n Buy above support line", color=buylabelcolor, yloc=yloc.belowbar, style = label.style_label_up, textcolor = buylabeltextcolor) else label.set_x(down, bar_index)
InflationRate
https://www.tradingview.com/script/R9bW2Ov5-InflationRate/
easonoic
https://www.tradingview.com/u/easonoic/
2
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © easonoic //@version=5 indicator("InflationRate", overlay=true) TIPS10Y = input.symbol("DFII10", "Symbol") US10Y = input.symbol("US10Y", "Symbol") tips10y_s_o = request.security(TIPS10Y, 'D', open) us10y_s_o = request.security(US10Y, 'D', open) tips10y_s_c = request.security(TIPS10Y, 'D', close) us10y_s_c = request.security(US10Y, 'D', close) tips10y_s_high = request.security(TIPS10Y, 'D', high) us10y_s_high = request.security(US10Y, 'D', high) tips10y_s_low = request.security(TIPS10Y, 'D', low) us10y_s_low = request.security(US10Y, 'D', low) InflationRate_o = us10y_s_o - tips10y_s_o InflationRate_c = us10y_s_c - tips10y_s_c InflationRate_high = us10y_s_high - tips10y_s_high InflationRate_low = us10y_s_low - tips10y_s_low plotcandle(InflationRate_o, InflationRate_high, InflationRate_low, InflationRate_c, title='InflationRate', color = InflationRate_o < InflationRate_c ? color.green : color.red, wickcolor=color.black) plot(0, linewidth=1) plot(InflationRate_c, color=color.red, linewidth=2)
BitCoin RSI Trend
https://www.tradingview.com/script/HhxbaJSS-BitCoin-RSI-Trend/
crypto_tycho
https://www.tradingview.com/u/crypto_tycho/
38
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © marvixino //@version=5 indicator("BitCoin RSI Trend", "BTC RSI", true) string BTC_TREND = 'Config » BTC RSI Trend' btcTF = input.timeframe("240", "BTC Timeframe", group=BTC_TREND,tooltip="Time in minutes.") btcRsiLen = input.int(14, "BTC Length", step=1, minval=1, group=BTC_TREND) btcTopRsi = input.int(70, "BTC Max Level", step=1, minval=3, group=BTC_TREND) btcMinRsi = input.int(50, "BTC Min Level", step=1, minval=3, group=BTC_TREND) enbaleBG = input.bool(true, "Color Background") enbaleBarPlot = input.bool(true, "Show BTC RSI") labelColor = input.color(color.white, "Label BG") labelTextColor = input.color(color.black, "Label Text") getRsi(sym, tf, src) => request.security(sym, tf, src[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1] btcRsi = getRsi("BINANCE:BTCUSD", btcTF, ta.rsi(close, btcRsiLen)) plot(btcRsi, "RSI", color=color.new(color.blue, 100)) rsiColor = btcRsi > btcMinRsi and btcRsi < btcTopRsi ? color.new(color.green,80) : color.new(color.red,80) bgcolor(enbaleBG ? rsiColor : na) if barstate.islast and barstate.isnew and enbaleBarPlot label.new(bar_index, high, str.tostring(math.round(btcRsi,1)), color =labelColor, textcolor =labelTextColor)
Multi IND Dashboard [Skiploss]
https://www.tradingview.com/script/46o3jDTx-Multi-IND-Dashboard-Skiploss/
Skiploss
https://www.tradingview.com/u/Skiploss/
135
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Skiploss //@version=5 indicator(title = "Multi IND Dashboard [Skiploss]", shorttitle = "MINDD v0.77", overlay = true) // Overlay ON //indicator(title = "Multi IND Dashboard [Skiploss]", shorttitle = "MINDD v0.77") // Overlay OFF // Input System symbol input_symbol = syminfo.tickerid // Input Bools Indicator input_indicator_ticker_01 = input(true, "Change", group = "Indicator") input_indicator_ticker_02 = input(true, "RSI", group = "Indicator") input_indicator_ticker_03 = input(true, "ATR", group = "Indicator") input_indicator_ticker_04 = input(true, "Aligator", group = "Indicator") input_indicator_ticker_05 = input(true, "Super Trend", group = "Indicator") // Relative Strength Index Setting relative_strength_index_length = input.int(title = "Length", defval = 14, minval = 2, maxval = 365, group = 'RSI Setting') relative_strength_index_source = input.source(close, "Source", group = 'RSI Setting') relative_strength_index_overbought_max = input.int(title = "Overbought Max Level", defval = 75, minval = 51, maxval = 100, group = 'RSI Setting') color_status_overbought_max = input(#8ebbff, 'Color Max', group = 'RSI Setting') relative_strength_index_overbought_med = input.int(title = "Overbought Med Level", defval = 65, minval = 51, maxval = 100, group = 'RSI Setting') color_status_overbought_med = input(#b0cfff, 'Color Med', group = 'RSI Setting') relative_strength_index_overbought_min = input.int(title = "Overbought Min Level", defval = 55, minval = 51, maxval = 100, group = 'RSI Setting') color_status_overbought_min = input(#c7ddff, 'Color Min', group = 'RSI Setting') relative_strength_index_oversold_max = input.int(title = "Oversold Max Level", defval = 25, minval = 0, maxval = 50, group = 'RSI Setting') color_status_oversold_max = input(#ff8e8e, 'Color Max', group = 'RSI Setting') relative_strength_index_oversold_med = input.int(title = "Oversold Med Level", defval = 35, minval = 0, maxval = 50, group = 'RSI Setting') color_status_oversold_med = input(#ffb0b0, 'Color Med', group = 'RSI Setting') relative_strength_index_oversold_min = input.int(title = "Oversold Min Level", defval = 45, minval = 0, maxval = 50, group = 'RSI Setting') color_status_oversold_min = input(#ffc7c7, 'Color Min', group = 'RSI Setting') relative_strength_index = ta.rsi(relative_strength_index_source, relative_strength_index_length) // ATR Setting atr_length = input.int(title = "Length", defval = 14, minval = 1, group = 'ATR Setting') atr_smoothing = input.string(title = "Smoothing", defval = "RMA", options = ["RMA", "SMA", "EMA", "WMA"], group = 'ATR Setting') ma_function(atr_source, atr_length) => switch atr_smoothing "RMA" => ta.rma(atr_source, atr_length) "SMA" => ta.sma(atr_source, atr_length) "EMA" => ta.ema(atr_source, atr_length) => ta.wma(atr_source, atr_length) atr_formula = ma_function(ta.tr(true),atr_length) // Alligator Setting var alligator_status_text = '' var alligator_status_color = color.white jaw_length = input.int(13, minval=1, title="Jaw Length", group = 'Alligator Setting') teeth_length = input.int(8, minval=1, title="Teeth Length", group = 'Alligator Setting') lips_length = input.int(5, minval=1, title="Lips Length", group = 'Alligator Setting') smma(src, length) => smma = 0.0 smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1) + src) / length smma jaw = smma(hl2, jaw_length) teeth = smma(hl2, teeth_length) lips = smma(hl2, lips_length) // Super Trend Sitting supertrend_atr_length = input(10, "ATR Length", group = 'Supertrend Setting') supertrend_factor = input.float(3.0, "Factor", step = 0.01, group = 'Supertrend Setting') Supertrend_(supertrend_factor, supertrend_atr_length) => [supertrend, trend] = ta.supertrend(supertrend_factor, supertrend_atr_length) supertrend_formula = trend == 1 ? false : true [supertrend_formula] [supertrend_formula] = Supertrend_(supertrend_factor, supertrend_atr_length) // Style Setting dashboard_location = input.session("Bottom Left", "Dashboard Location", options = ["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"], group = 'Style Settings') dashboard_text_size = input.session( 'Normal', "Dashboard Size", options = ["Tiny","Small","Normal","Large"], group = 'Style Settings') transparency = input.int(35, 'Transparency', minval = 0, maxval = 100, group = 'Style Settings') color_status_bullish = input(#8ebbff, 'Bullish Color', group = 'Style Settings') color_status_bearish = input(#ff8e8e, 'Bearish Color', group = 'Style Settings') color_status_neutral = input(#ffffff, 'Neutral Color', group = 'Style Settings') // Timeframes timeframe_01 = input.timeframe( "1", title = "1st", group = "Resolution") timeframe_02 = input.timeframe( "5", title = "2nd", group = "Resolution") timeframe_03 = input.timeframe( "15", title = "3rd", group = "Resolution") timeframe_04 = input.timeframe( "30", title = "4th", group = "Resolution") timeframe_05 = input.timeframe( "60", title = "5th", group = "Resolution") timeframe_06 = input.timeframe("120", title = "6th", group = "Resolution") timeframe_07 = input.timeframe("240", title = "7th", group = "Resolution") timeframe_08 = input.timeframe("480", title = "8th", group = "Resolution") timeframe_09 = input.timeframe( "D", title = "9th", group = "Resolution") timeframe_10 = input.timeframe( "W", title = "10th", group = "Resolution") // indicator_01_value_XX : Change // indicator_02_value_XX : RSI // indicator_03_value_XX : ATR // indicator_04_value_XX : Aligator (jaw/teeth/lips) // indicator_05_value_XX : Supper Trend [indicator_01_value_01, indicator_02_value_01, indicator_03_value_01, indicator_04_value_01_jaw, indicator_04_value_01_teeth, indicator_04_value_01_lips, indicator_05_value_01] = request.security(input_symbol, timeframe_01, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_02, indicator_02_value_02, indicator_03_value_02, indicator_04_value_02_jaw, indicator_04_value_02_teeth, indicator_04_value_02_lips, indicator_05_value_02] = request.security(input_symbol, timeframe_02, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_03, indicator_02_value_03, indicator_03_value_03, indicator_04_value_03_jaw, indicator_04_value_03_teeth, indicator_04_value_03_lips, indicator_05_value_03] = request.security(input_symbol, timeframe_03, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_04, indicator_02_value_04, indicator_03_value_04, indicator_04_value_04_jaw, indicator_04_value_04_teeth, indicator_04_value_04_lips, indicator_05_value_04] = request.security(input_symbol, timeframe_04, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_05, indicator_02_value_05, indicator_03_value_05, indicator_04_value_05_jaw, indicator_04_value_05_teeth, indicator_04_value_05_lips, indicator_05_value_05] = request.security(input_symbol, timeframe_05, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_06, indicator_02_value_06, indicator_03_value_06, indicator_04_value_06_jaw, indicator_04_value_06_teeth, indicator_04_value_06_lips, indicator_05_value_06] = request.security(input_symbol, timeframe_06, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_07, indicator_02_value_07, indicator_03_value_07, indicator_04_value_07_jaw, indicator_04_value_07_teeth, indicator_04_value_07_lips, indicator_05_value_07] = request.security(input_symbol, timeframe_07, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_08, indicator_02_value_08, indicator_03_value_08, indicator_04_value_08_jaw, indicator_04_value_08_teeth, indicator_04_value_08_lips, indicator_05_value_08] = request.security(input_symbol, timeframe_08, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_09, indicator_02_value_09, indicator_03_value_09, indicator_04_value_09_jaw, indicator_04_value_09_teeth, indicator_04_value_09_lips, indicator_05_value_09] = request.security(input_symbol, timeframe_09, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) [indicator_01_value_10, indicator_02_value_10, indicator_03_value_10, indicator_04_value_10_jaw, indicator_04_value_10_teeth, indicator_04_value_10_lips, indicator_05_value_10] = request.security(input_symbol, timeframe_10, [close-close[1], ta.rsi(close,relative_strength_index_length), atr_formula, jaw, teeth, lips, supertrend_formula]) // Dashboard Create var table_position = dashboard_location == 'Top Left' ? position.top_left : dashboard_location == 'Bottom Left' ? position.bottom_left : dashboard_location == 'Middle Right' ? position.middle_right : dashboard_location == 'Bottom Center' ? position.bottom_center : dashboard_location == 'Top Right' ? position.top_right : position.bottom_right var table_text_size = dashboard_text_size == 'Tiny' ? size.tiny : dashboard_text_size == 'Small' ? size.small : dashboard_text_size == 'Normal' ? size.normal : size.large var dashboard = table.new(table_position,12,6, frame_color = #141823, frame_width = 1, border_color= #141823, border_width= 1) if (barstate.islast) //Headings table.cell(dashboard, 1, 0, ' Info.', width = 5, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 2, 0, timeframe_01, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 3, 0, timeframe_02, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 4, 0, timeframe_03, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 5, 0, timeframe_04, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 6, 0, timeframe_05, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 7, 0, timeframe_06, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 8, 0, timeframe_07, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 9, 0, timeframe_08, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 10, 0, timeframe_09, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 11, 0, timeframe_10, width = 3, text_color = color.white, text_size = table_text_size, bgcolor = color.black) // Indicator 01 if input_indicator_ticker_01 table.cell(dashboard, 1, 1, "Change", text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 2, 1, str.tostring(indicator_01_value_01, '#.#####'), text_color = color.new(indicator_01_value_01 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 3, 1, str.tostring(indicator_01_value_02, '#.#####'), text_color = color.new(indicator_01_value_02 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 4, 1, str.tostring(indicator_01_value_03, '#.#####'), text_color = color.new(indicator_01_value_03 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 5, 1, str.tostring(indicator_01_value_04, '#.#####'), text_color = color.new(indicator_01_value_04 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 6, 1, str.tostring(indicator_01_value_05, '#.#####'), text_color = color.new(indicator_01_value_05 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 7, 1, str.tostring(indicator_01_value_06, '#.#####'), text_color = color.new(indicator_01_value_06 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 8, 1, str.tostring(indicator_01_value_07, '#.#####'), text_color = color.new(indicator_01_value_07 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 9, 1, str.tostring(indicator_01_value_08, '#.#####'), text_color = color.new(indicator_01_value_08 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 10, 1, str.tostring(indicator_01_value_09, '#.#####'), text_color = color.new(indicator_01_value_09 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 11, 1, str.tostring(indicator_01_value_10, '#.#####'), text_color = color.new(indicator_01_value_10 > 0 ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) // Indicator 02 if input_indicator_ticker_02 table.cell(dashboard, 1, 2, "RSI", text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 2, 2, str.tostring(indicator_02_value_01, '#.##'), text_color = color.new(indicator_02_value_01 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_01 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_01 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_01 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_01 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_01 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 3, 2, str.tostring(indicator_02_value_02, '#.##'), text_color = color.new(indicator_02_value_02 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_02 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_02 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_02 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_02 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_02 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 4, 2, str.tostring(indicator_02_value_03, '#.##'), text_color = color.new(indicator_02_value_03 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_03 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_03 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_03 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_03 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_03 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 5, 2, str.tostring(indicator_02_value_04, '#.##'), text_color = color.new(indicator_02_value_04 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_04 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_04 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_04 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_04 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_04 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 6, 2, str.tostring(indicator_02_value_05, '#.##'), text_color = color.new(indicator_02_value_05 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_05 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_05 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_05 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_05 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_05 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 7, 2, str.tostring(indicator_02_value_06, '#.##'), text_color = color.new(indicator_02_value_06 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_06 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_06 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_06 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_06 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_06 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 8, 2, str.tostring(indicator_02_value_07, '#.##'), text_color = color.new(indicator_02_value_07 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_07 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_07 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_07 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_07 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_07 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 9, 2, str.tostring(indicator_02_value_08, '#.##'), text_color = color.new(indicator_02_value_08 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_08 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_08 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_08 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_08 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_08 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 10, 2, str.tostring(indicator_02_value_09, '#.##'), text_color = color.new(indicator_02_value_09 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_09 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_09 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_09 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_09 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_09 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 11, 2, str.tostring(indicator_02_value_10, '#.##'), text_color = color.new(indicator_02_value_10 >= relative_strength_index_overbought_max ? color_status_overbought_max : indicator_02_value_10 >= relative_strength_index_overbought_med ? color_status_overbought_med : indicator_02_value_10 >= relative_strength_index_overbought_min ? color_status_overbought_min : indicator_02_value_10 <= relative_strength_index_oversold_max ? color_status_oversold_max : indicator_02_value_10 <= relative_strength_index_oversold_med ? color_status_oversold_med : indicator_02_value_10 <= relative_strength_index_oversold_min ? color_status_oversold_min : color_status_neutral, 0), text_size = table_text_size, bgcolor = color.black) // Indicator 03 if input_indicator_ticker_03 table.cell(dashboard, 1, 3, "ATR", text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 2, 3, str.tostring(indicator_03_value_01, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 3, 3, str.tostring(indicator_03_value_02, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 4, 3, str.tostring(indicator_03_value_03, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 5, 3, str.tostring(indicator_03_value_04, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 6, 3, str.tostring(indicator_03_value_05, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 7, 3, str.tostring(indicator_03_value_06, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 8, 3, str.tostring(indicator_03_value_07, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 9, 3, str.tostring(indicator_03_value_08, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 10, 3, str.tostring(indicator_03_value_09, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 11, 3, str.tostring(indicator_03_value_10, '#.#####'), text_color = color.white, text_size = table_text_size, bgcolor = color.black) // Indicator 04 if input_indicator_ticker_04 table.cell(dashboard, 1, 4, "Alligator",text_color=color.white,text_size=table_text_size,bgcolor=color.black) if indicator_04_value_01_lips > indicator_04_value_01_teeth and indicator_04_value_01_teeth > indicator_04_value_01_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_01_lips < indicator_04_value_01_teeth and indicator_04_value_01_teeth < indicator_04_value_01_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_01_lips > indicator_04_value_01_teeth and indicator_04_value_01_teeth < indicator_04_value_01_jaw or indicator_04_value_01_lips < indicator_04_value_01_teeth and indicator_04_value_01_teeth > indicator_04_value_01_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 2, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_02_lips > indicator_04_value_02_teeth and indicator_04_value_02_teeth > indicator_04_value_02_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_02_lips < indicator_04_value_02_teeth and indicator_04_value_02_teeth < indicator_04_value_02_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_02_lips > indicator_04_value_02_teeth and indicator_04_value_02_teeth < indicator_04_value_02_jaw or indicator_04_value_02_lips < indicator_04_value_02_teeth and indicator_04_value_02_teeth > indicator_04_value_02_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 3, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_03_lips > indicator_04_value_03_teeth and indicator_04_value_03_teeth > indicator_04_value_03_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_03_lips < indicator_04_value_03_teeth and indicator_04_value_03_teeth < indicator_04_value_03_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_03_lips > indicator_04_value_03_teeth and indicator_04_value_03_teeth < indicator_04_value_03_jaw or indicator_04_value_03_lips < indicator_04_value_03_teeth and indicator_04_value_03_teeth > indicator_04_value_03_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 4, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_04_lips > indicator_04_value_04_teeth and indicator_04_value_04_teeth > indicator_04_value_04_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_04_lips < indicator_04_value_04_teeth and indicator_04_value_04_teeth < indicator_04_value_04_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_04_lips > indicator_04_value_04_teeth and indicator_04_value_04_teeth < indicator_04_value_04_jaw or indicator_04_value_04_lips < indicator_04_value_04_teeth and indicator_04_value_04_teeth > indicator_04_value_04_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 5, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_05_lips > indicator_04_value_05_teeth and indicator_04_value_05_teeth > indicator_04_value_05_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_05_lips < indicator_04_value_05_teeth and indicator_04_value_05_teeth < indicator_04_value_05_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_05_lips > indicator_04_value_05_teeth and indicator_04_value_05_teeth < indicator_04_value_05_jaw or indicator_04_value_05_lips < indicator_04_value_05_teeth and indicator_04_value_05_teeth > indicator_04_value_05_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 6, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_06_lips > indicator_04_value_06_teeth and indicator_04_value_06_teeth > indicator_04_value_06_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_06_lips < indicator_04_value_06_teeth and indicator_04_value_06_teeth < indicator_04_value_06_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_06_lips > indicator_04_value_06_teeth and indicator_04_value_06_teeth < indicator_04_value_06_jaw or indicator_04_value_06_lips < indicator_04_value_06_teeth and indicator_04_value_06_teeth > indicator_04_value_06_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 7, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_07_lips > indicator_04_value_07_teeth and indicator_04_value_07_teeth > indicator_04_value_07_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_07_lips < indicator_04_value_07_teeth and indicator_04_value_07_teeth < indicator_04_value_07_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_07_lips > indicator_04_value_07_teeth and indicator_04_value_07_teeth < indicator_04_value_07_jaw or indicator_04_value_07_lips < indicator_04_value_07_teeth and indicator_04_value_07_teeth > indicator_04_value_07_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 8, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_08_lips > indicator_04_value_08_teeth and indicator_04_value_08_teeth > indicator_04_value_08_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_08_lips < indicator_04_value_08_teeth and indicator_04_value_08_teeth < indicator_04_value_08_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_08_lips > indicator_04_value_08_teeth and indicator_04_value_08_teeth < indicator_04_value_08_jaw or indicator_04_value_08_lips < indicator_04_value_08_teeth and indicator_04_value_08_teeth > indicator_04_value_08_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 9, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_09_lips > indicator_04_value_09_teeth and indicator_04_value_09_teeth > indicator_04_value_09_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_09_lips < indicator_04_value_09_teeth and indicator_04_value_09_teeth < indicator_04_value_09_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_09_lips > indicator_04_value_09_teeth and indicator_04_value_09_teeth < indicator_04_value_09_jaw or indicator_04_value_09_lips < indicator_04_value_09_teeth and indicator_04_value_09_teeth > indicator_04_value_09_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 10, 4, str.tostring(alligator_status_text),text_color = alligator_status_color,text_size=table_text_size, bgcolor = color.black) if indicator_04_value_10_lips > indicator_04_value_10_teeth and indicator_04_value_10_teeth > indicator_04_value_10_jaw alligator_status_text := "Bullish" alligator_status_color := color_status_bullish if indicator_04_value_10_lips < indicator_04_value_10_teeth and indicator_04_value_10_teeth < indicator_04_value_10_jaw alligator_status_text := "Bearish" alligator_status_color := color_status_bearish else if indicator_04_value_10_lips > indicator_04_value_10_teeth and indicator_04_value_10_teeth < indicator_04_value_10_jaw or indicator_04_value_10_lips < indicator_04_value_10_teeth and indicator_04_value_10_teeth > indicator_04_value_10_jaw alligator_status_text := "Neutral" alligator_status_color := color_status_neutral table.cell(dashboard, 11, 4, str.tostring(alligator_status_text),text_color=alligator_status_color,text_size=table_text_size, bgcolor = color.black) // Indicator 05 if input_indicator_ticker_05 table.cell(dashboard, 1, 5, "Supertrend", text_color = color.white, text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 2, 5, indicator_05_value_01 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_01 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 3, 5, indicator_05_value_02 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_02 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 4, 5, indicator_05_value_03 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_03 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 5, 5, indicator_05_value_04 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_04 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 6, 5, indicator_05_value_05 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_05 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 7, 5, indicator_05_value_06 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_06 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 8, 5, indicator_05_value_07 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_07 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 9, 5, indicator_05_value_08 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_08 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 10, 5, indicator_05_value_09 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_09 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black) table.cell(dashboard, 11, 5, indicator_05_value_10 ? str.tostring('Bullish') : str.tostring('Bearish'), text_color = color.new(indicator_05_value_10 == true ? color_status_bullish : color_status_bearish, 0), text_size = table_text_size, bgcolor = color.black)
Back to the Future
https://www.tradingview.com/script/GT5qiaB0-Back-to-the-Future/
RafaelZioni
https://www.tradingview.com/u/RafaelZioni/
378
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RafaelZioni //@version=5 indicator(title='Back to the Future', overlay=true) //INPUTS // len = input.int(100, minval=1) off = 0 dev = input(2, 'Deviation') len1 = input.int(30, minval=1) off1 = 0 dev1 = input(2, 'Deviation1') c1 = close lreg1 = ta.linreg(c1, len, off) lreg_x1 = ta.linreg(c1, len, off + 1) b1 = bar_index s1 = lreg1 - lreg_x1 intr1 = lreg1 - b1 * s1 dS1 = 0.0 for i1 = 0 to len - 1 by 1 dS1 += math.pow(c1[i1] - (s1 * (b1 - i1) + intr1), 2) dS1 de1 = math.sqrt(dS1 / len) up1 = -de1 * dev + lreg1 down1 = de1 * dev + lreg1 // // t1 = 0 x11 = bar_index - len x21 = bar_index y11 = s1 * (bar_index - len) + intr1 y21 = lreg1 u1 = t1 <= 0 or bar_index < t1 if u1 line pr1 = line.new(x11, y11, x21, y21, xloc.bar_index, extend.right, color.red, width=2) line.delete(pr1[1]) line px1 = line.new(x11, de1 * dev + y11, x21, de1 * dev + y21, xloc.bar_index, extend.right, width=2) line.delete(px1[1]) line pz1 = line.new(x11, -de1 * dev + y11, x21, -de1 * dev + y21, xloc.bar_index, extend.right, width=2) line.delete(pz1[1]) // c = close[len1] lreg = ta.linreg(c, len1, off1) lreg_x = ta.linreg(c, len1, off1 + 1) b = bar_index s = lreg - lreg_x intr = lreg - b * s dS = 0.0 for i = 0 to len1 - 1 by 1 dS += math.pow(c[i] - (s * (b - i) + intr), 2) dS de = math.sqrt(dS / len1) up = -de * dev + lreg down = de * dev + lreg // t = 0 x1 = bar_index - len x2 = bar_index y1 = s * (bar_index - len) + intr y2 = lreg u = t <= 0 or bar_index < t if u line pr = line.new(x1, y1, x2, y2, xloc.bar_index, extend.right, color.red, style=line.style_dashed, width=2) line.delete(pr[1]) line px = line.new(x1, de * dev + y1, x2, de * dev + y2, xloc.bar_index, extend.right, style=line.style_dashed, width=2) line.delete(px[1]) line pz = line.new(x1, -de * dev + y1, x2, -de * dev + y2, xloc.bar_index, extend.right, style=line.style_dashed, width=2) line.delete(pz[1]) // bu = ta.crossover(close, lreg) sz = ta.crossunder(close, lreg) bu1 = ta.crossover(close, up) sz1 = ta.crossunder(close, up) bu2 = ta.crossover(close, down) sz2 = ta.crossunder(close, down) plotshape(sz, style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0), size=size.tiny) plotshape(bu, style=shape.triangleup, location=location.belowbar, color=color.new(color.blue, 0), size=size.tiny) plotshape(sz1, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(bu1, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny) plotshape(sz2, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny) plotshape(bu2, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny)
Multiple Stock RSI Check
https://www.tradingview.com/script/5gemMGkB-Multiple-Stock-RSI-Check/
Srinivas_SIP
https://www.tradingview.com/u/Srinivas_SIP/
13
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © sateesh1496 //@version=5 // Define the symbols of the stocks to check t1 = input.symbol('NSE:HDFCBANK') t2 = input.symbol('NSE:ICICIBANK') t3 = input.symbol('NSE:KOTAKBANK') t4 = input.symbol('NSE:AXISBANK') t5 = input.symbol('NSE:SBIN') indicator('Multiple Stock RSI Check') // Define a variable to keep track of the count of stocks with RSI > 55 count = 0 //get historical close prices for each stock closePrice1 = request.security(t1, 'D', close) closePrice2 = request.security(t2, 'D', close) closePrice3 = request.security(t3, 'D', close) closePrice4 = request.security(t4, 'D', close) closePrice5 = request.security(t5, 'D', close) //Get the RSI of the stocks rsi1 = ta.rsi(closePrice1, 14) rsi2 = ta.rsi(closePrice2, 14) rsi3 = ta.rsi(closePrice3, 14) rsi4 = ta.rsi(closePrice4, 14) rsi5 = ta.rsi(closePrice5, 14) //Checking RSI of each stock if rsi1 > 55 count += 1 count if rsi2 > 55 count += 1 count if rsi3 > 55 count += 1 count if rsi4 > 55 count += 1 count if rsi5 > 55 count += 1 count //Plotting the count plot(count, style=plot.style_histogram) //label.new(bar_index, high, tostring(count) + " stocks RSI > 55")
Nick_OS Ranges
https://www.tradingview.com/script/U4Psokdb-Nick-OS-Ranges/
NickMaterazzo
https://www.tradingview.com/u/NickMaterazzo/
29
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © 2022 NickMaterazzo // 2022-12-21 - Updated to allow for weekly and monthly timeframes, added decimal input for labels //@version=5 indicator("Nick Ranges", overlay=true, max_labels_count = 500) // Yellow, Gray, Cyan, Fuchsia // ============================ // Shenanigans to account for Daylight Savings // Add "GMT" to timestamps to synchronize timezones HourNY = hour(time, "America/New_York") HourUTC = hour(time, "UTC") DST = HourUTC - HourNY == 5 or HourUTC - HourNY == -19 ? false : HourUTC - HourNY == 4 or HourUTC - HourNY == -20 ? true : na GMT = "GMT-5" if DST GMT := "GMT-4" // ============================ resolution = input.timeframe('D', "Timeframe Resolution", options=['D', 'W', 'M']) lookback = input(250, "Lookback Window") nth1 = input(30, "Range 1 nth") nth2 = input(10, "Range 2 nth") nth3 = input(3, "Range 3 nth") dayHigh = request.security(syminfo.tickerid, resolution, high, lookahead=barmerge.lookahead_off) dayLow = request.security(syminfo.tickerid, resolution, low, lookahead=barmerge.lookahead_off) dayClose = request.security(syminfo.tickerid, resolution, close, lookahead=barmerge.lookahead_off) dayOpen = request.security(syminfo.tickerid, resolution, open, lookahead=barmerge.lookahead_off) var upArray = array.new_float(1, 0) var downArray = array.new_float(1, 0) var closeArray = array.new_float(1, dayClose) priorClose = array.get(closeArray,array.size(closeArray) - 1) priorHigh = array.get(upArray,array.size(upArray) - 1) priorLow = array.get(downArray,array.size(downArray) - 1) dayUp = math.log(dayHigh / priorClose) //(dayHigh - priorClose) / priorClose dayDown = math.log(dayLow / priorClose) //(dayLow - priorClose) / priorClose loading = array.size(upArray) > math.max(nth1,nth2,nth3) rangeHigh1 = loading ? (array.max(upArray,nth1 - 1) + 1) * priorClose : na rangeLow1 = loading ? (array.min(downArray,nth1 - 1) + 1) * priorClose : na rangeHigh2 = loading ? (array.max(upArray,nth2 - 1) + 1) * priorClose : na rangeLow2 = loading ? (array.min(downArray,nth2 - 1) + 1) * priorClose : na rangeHigh3 = loading ? (array.max(upArray,nth3 - 1) + 1) * priorClose : na rangeLow3 = loading ? (array.min(downArray,nth3 - 1) + 1) * priorClose : na avgRangeHigh = loading ? (array.avg(upArray) + 1) * priorClose : na avgRangeLow = loading ? (array.avg(downArray) + 1) * priorClose : na if timeframe.change(resolution) array.push(closeArray, dayClose) array.push(upArray, dayUp) array.push(downArray, dayDown) if array.size(upArray) > lookback array.shift(upArray) if array.size(downArray) > lookback array.shift(downArray) rthToggle = input(false, "Only plot during RTH?") plotTime = rthToggle ? time >= timestamp(GMT, year, month, dayofmonth, 9, 0, 0) and time <= timestamp(GMT, year, month, dayofmonth, 16, 0, 0) : true plot(plotTime ? avgRangeHigh : na, color=color.yellow, style=plot.style_circles,offset = -1) plot(plotTime ? avgRangeLow : na, color=color.yellow, style=plot.style_circles,offset = -1) plot(plotTime ? rangeHigh1 : na, color=color.silver, style=plot.style_circles,offset = -1) plot(plotTime ? rangeLow1 : na, color=color.silver, style=plot.style_circles,offset = -1) plot(plotTime ? rangeHigh2 : na, color=color.aqua, style=plot.style_circles,offset = -1) plot(plotTime ? rangeLow2 : na, color=color.aqua, style=plot.style_circles,offset = -1) plot(plotTime ? rangeHigh3 : na, color=color.fuchsia, style=plot.style_circles,offset = -1) plot(plotTime ? rangeLow3 : na, color=color.fuchsia, style=plot.style_circles,offset = -1) // if session.islastbar_regular // r1 = line.new(bar_index, rangeHigh1, bar_index + 10, rangeHigh1, color=color.white) // r2 = line.new(bar_index, rangeHigh2, bar_index + 10, rangeHigh2, color=color.white) // r3 = line.new(bar_index, rangeHigh3, bar_index + 10, rangeHigh3, color=color.white) // line.delete(l1[1]) decimalsToRound = input(0, "# of decimals for labels") toggleLabels = input(true, "Toggle Labels?") if toggleLabels and timeframe.change(resolution)[1] and loading l1 = label.new(bar_index, avgRangeHigh, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(avgRangeHigh,decimalsToRound))) l2 = label.new(bar_index, avgRangeLow, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(avgRangeLow,decimalsToRound))) l3 = label.new(bar_index, rangeHigh1, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(rangeHigh1,decimalsToRound))) l4 = label.new(bar_index, rangeHigh2, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(rangeHigh2,decimalsToRound))) l5 = label.new(bar_index, rangeHigh3, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(rangeHigh3,decimalsToRound))) l6 = label.new(bar_index, rangeLow1, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(rangeLow1,decimalsToRound))) l7 = label.new(bar_index, rangeLow2, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(rangeLow2,decimalsToRound))) l8 = label.new(bar_index, rangeLow3, style=label.style_none, textcolor=color.white, textalign=text.align_left, text=str.tostring(math.round(rangeLow3,decimalsToRound)))
Aggregated Volume Profile Spot & Futures
https://www.tradingview.com/script/P2XgvcKM-Aggregated-Volume-Profile-Spot-Futures/
HALDRO
https://www.tradingview.com/u/HALDRO/
679
study
5
MPL-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 Project // —————— https://www.tradingview.com/script/P2XgvcKM-Aggregated-Volume-Profile-Spot-Futures/ // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // @version=5 indicator(title='Aggregated Volume Profile Spot & Futures', shorttitle='Aggregated Volume Profile', overlay=true, precision=4, linktoseries=true, max_bars_back=1000, max_lines_count=500) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— Tips TTmode = '𝐃𝐚𝐭𝐚 𝐓𝐲𝐩𝐞 ➖ Choose Single or Aggregated data.' TTspot = 'Spot Volume Pairs' TTperp = 'Futures Volume Pairs' TTEX = 'You can write any name of the exchange in any field in the Exchanges group and get the result. Example: BITMEX\nHUOBI\nMEXC\nGATEIO and others. \n*Be careful and check if there is such a ticker on TV.' // —————— Inputs groupset = '➤ SETTINGS' coinusd = input.string('USD', ' Volume By', group = groupset, inline = 'MODE', options = ['COIN', 'USD', 'EUR', 'RUB']) datatype = input.string('Aggregated', ' Data Type   ', group = groupset, inline = 'MODE', options = ['Aggregated', 'Single'], tooltip = TTmode) delta_type = input.string('Both', ' Delta Type', group = groupset, inline = 'DELT', options = ['Both', 'Bullish', 'Bearish']) lookback = input.int (250, ' Volume Lookback Depth', group = groupset, minval = 10, maxval = 1000, step = 10) max_bars = input.int (500, ' Number of Bars', group = groupset, minval = 10, maxval = 500, step = 25) bar_mult = input.int (35, ' Bar Length Multiplier', group = groupset, minval = 10, maxval = 100, step = 5) bar_offset = input.int (35, ' Bar Horizontal Offset', group = groupset, minval = 0, maxval = 100, step = 5) bar_width = input.int (1, ' Bar Width', group = groupset, minval = 1, maxval = 20) poc_show = input.bool (true, ' Show POC Line', group = groupset, inline = 'DELT') bar_color = input.color (#335367, ' Bar Color', group = groupset, inline = 'COLR') poc_color = input.color (#a13c44, ' POC Color', group = groupset, inline = 'COLR') groupcur = '➤ CURRENCY' PERP1 = input.bool (true, '  USD.P     ', group = groupcur, inline = 'CUR1') PERP2 = input.bool (true, '  USDT.P ', group = groupcur, inline = 'CUR1', tooltip = TTperp) SPOT1 = input.bool (true, '  USDT   ', group = groupcur, inline = 'CUR2') SPOT2 = input.bool (true, '᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎', group = groupcur, inline = 'CUR2') XSPOT2 = input.string('USD', '᠎', group = groupcur, inline = 'CUR2', options = ['USD', 'USDC', 'BUSD', 'DAI', 'EUR'], tooltip = TTspot) groupexc = '➤ EXCHANGES' EX_NO1 = input.bool (true, '1', group = groupexc, inline = 'EX1') IN_NO1 = input.string('BINANCE', '', group = groupexc, inline = 'EX1') EX_NO2 = input.bool (true, '2', group = groupexc, inline = 'EX1') IN_NO2 = input.string('BYBIT', '', group = groupexc, inline = 'EX1') EX_NO3 = input.bool (true, '3', group = groupexc, inline = 'EX1') IN_NO3 = input.string('OKEX', '', group = groupexc, inline = 'EX1') EX_NO4 = input.bool (true, '4', group = groupexc, inline = 'EX2') IN_NO4 = input.string('COINBASE', '', group = groupexc, inline = 'EX2') EX_NO5 = input.bool (true, '5', group = groupexc, inline = 'EX2') IN_NO5 = input.string('BITFINEX', '', group = groupexc, inline = 'EX2') EX_NO6 = input.bool (true, '6', group = groupexc, inline = 'EX2') IN_NO6 = input.string('BITSTAMP', '', group = groupexc, inline = 'EX2') EX_NO7 = input.bool (true, '7', group = groupexc, inline = 'EX3') IN_NO7 = input.string('DERIBIT', '', group = groupexc, inline = 'EX3') EX_NO8 = input.bool (true, '8', group = groupexc, inline = 'EX3') IN_NO8 = input.string('PHEMEX', '', group = groupexc, inline = 'EX3') EX_NO9 = input.bool (true, '9', group = groupexc, inline = 'EX3') IN_NO9 = input.string('MEXC', '', group = groupexc, inline = 'EX3', tooltip = TTEX) VAREUR = request.security('FX_IDC:EURUSD', timeframe.period, close) VARRUB = request.security('(MOEX:USDRUB_TOM+MOEX:USDRUB_TOD)/2', timeframe.period, close) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— Aggregated Volume Calculate Vtype = str.lower(syminfo.volumetype) CurrentVolume = Vtype=='tick' or Vtype=='quote' or Vtype=='usd' ? volume / close : volume GetTicker(exchange, typeSymbol) => GetTicker = exchange + ':' + syminfo.basecurrency + typeSymbol FixBitmex = exchange == 'BITMEX' ? str.replace(GetTicker, 'BTC', 'XBT') : GetTicker Ticker = FixBitmex GetRequest(Ticker) => GetVolume = request.security(Ticker, timeframe.period, CurrentVolume, ignore_invalid_symbol=true) CheckVolume = GetVolume[1] > 0 ? GetVolume : 0 GetExchange(typeSymbol)=> EX_1 = EX_NO1 ? GetRequest( GetTicker(IN_NO1, typeSymbol) ) : 0 EX_2 = EX_NO2 ? GetRequest( GetTicker(IN_NO2, typeSymbol) ) : 0 EX_3 = EX_NO3 ? GetRequest( GetTicker(IN_NO3, typeSymbol) ) : 0 EX_4 = EX_NO4 ? GetRequest( GetTicker(IN_NO4, typeSymbol) ) : 0 EX_5 = EX_NO5 ? GetRequest( GetTicker(IN_NO5, typeSymbol) ) : 0 EX_6 = EX_NO6 ? GetRequest( GetTicker(IN_NO6, typeSymbol) ) : 0 EX_7 = EX_NO7 ? GetRequest( GetTicker(IN_NO7, typeSymbol) ) : 0 EX_8 = EX_NO8 ? GetRequest( GetTicker(IN_NO8, typeSymbol) ) : 0 EX_9 = EX_NO9 ? GetRequest( GetTicker(IN_NO9, typeSymbol) ) : 0 [EX_1, EX_2, EX_3, EX_4, EX_5, EX_6, EX_7, EX_8, EX_9] EditVolume(type)=> Type = array.sum(type) Volume = coinusd == 'USD' ? Type*close : coinusd == 'EUR' ? Type*(1/VAREUR)*close : coinusd == 'RUB' ? Type*(VARRUB/1)*close : Type Volume // —————— Get Volume [PERP2_1, PERP2_2, PERP2_3, PERP2_4, PERP2_5, PERP2_6, PERP2_7, PERP2_8, PERP2_9] = GetExchange(PERP1 ? 'USDT.P' : '0') [PERP1_1, PERP1_2, PERP1_3, PERP1_4, PERP1_5, PERP1_6, PERP1_7, PERP1_8, PERP1_9] = GetExchange(PERP2 ? 'USD.P' : '0') [SPOT1_1, SPOT1_2, SPOT1_3, SPOT1_4, SPOT1_5, SPOT1_6, SPOT1_7, SPOT1_8, SPOT1_9] = GetExchange(SPOT1 ? 'USDT' : '0') [SPOT2_1, SPOT2_2, SPOT2_3, SPOT2_4, SPOT2_5, SPOT2_6, SPOT2_7, SPOT2_8, SPOT2_9] = GetExchange(SPOT2 ? XSPOT2 : '0') // —————— Processing Volume GetSpotEX_1 = EditVolume(array.from(SPOT1_1, SPOT2_1)), GetPerpEX_1 = EditVolume(array.from(PERP1_1, PERP2_1)) GetSpotEX_2 = EditVolume(array.from(SPOT1_2, SPOT2_2)), GetPerpEX_2 = EditVolume(array.from(PERP1_2, PERP2_2)) GetSpotEX_3 = EditVolume(array.from(SPOT1_3, SPOT2_3)), GetPerpEX_3 = EditVolume(array.from(PERP1_3, PERP2_3)) GetSpotEX_4 = EditVolume(array.from(SPOT1_4, SPOT2_4)), GetPerpEX_4 = EditVolume(array.from(PERP1_4, PERP2_4)) GetSpotEX_5 = EditVolume(array.from(SPOT1_5, SPOT2_5)), GetPerpEX_5 = EditVolume(array.from(PERP1_5, PERP2_5)) GetSpotEX_6 = EditVolume(array.from(SPOT1_6, SPOT2_6)), GetPerpEX_6 = EditVolume(array.from(PERP1_6, PERP2_6)) GetSpotEX_7 = EditVolume(array.from(SPOT1_7, SPOT2_7)), GetPerpEX_7 = EditVolume(array.from(PERP1_7, PERP2_7)) GetSpotEX_8 = EditVolume(array.from(SPOT1_8, SPOT2_8)), GetPerpEX_8 = EditVolume(array.from(PERP1_8, PERP2_8)) GetSpotEX_9 = EditVolume(array.from(SPOT1_9, SPOT2_9)), GetPerpEX_9 = EditVolume(array.from(PERP1_9, PERP2_9)) SPOT = GetSpotEX_1 + GetSpotEX_2 + GetSpotEX_3 + GetSpotEX_4 + GetSpotEX_5 + GetSpotEX_6 + GetSpotEX_7 + GetSpotEX_8 + GetSpotEX_9 PERP = GetPerpEX_1 + GetPerpEX_2 + GetPerpEX_3 + GetPerpEX_4 + GetPerpEX_5 + GetPerpEX_6 + GetPerpEX_7 + GetPerpEX_8 + GetPerpEX_9 Volume = datatype == 'Single' ? EditVolume(array.from(CurrentVolume)) : SPOT + PERP + (EditVolume(array.from(CurrentVolume))) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // ————————————————————————————————————————————————— Volume Profile ——————————————————————————————————————————————————— \\ // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ float Vmax = 0.0 int VmaxId = 0 var int first = time price_levels = array.new_float(max_bars + 1, 0.0) interval_volumes = array.new_float(max_bars, 0.0) volumes_totals = array.new_float(max_bars, 0.0) bar_widths = array.new_int(max_bars, 0) float HH = ta.highest(high, lookback) float LL = ta.lowest(low, lookback) if barstate.islast float HL = (HH - LL) / max_bars for j = 1 to max_bars + 1 by 1 array.set(price_levels, j - 1, LL + HL * j) for i = 0 to lookback - 1 by 1 int j_interval_count = 0 array.fill(volumes_totals, 0.0) for j = 0 to max_bars - 1 by 1 float j_price_level = array.get(price_levels, j) if low[i] < j_price_level and high[i] > j_price_level and (delta_type == 'Bullish' ? close[i] >= open[i] : delta_type == 'Bearish' ? close[i] <= open[i] : true) float j_volumes_totals = array.get(volumes_totals, j) float new_volume_total = j_volumes_totals + nz(Volume[i]) array.set(volumes_totals, j, new_volume_total) j_interval_count += 1 j_interval_count for j = 0 to max_bars - 1 by 1 float j_interval_volume = array.get(interval_volumes, j) float j_volumes_totals = array.get(volumes_totals, j) float dj_interval_volume = j_interval_volume + (j_interval_count > 0 ? j_volumes_totals / j_interval_count : 0.0) array.set(interval_volumes, j, dj_interval_volume) Vmax := array.max(interval_volumes) VmaxId := array.indexof(interval_volumes, Vmax) for j = 0 to max_bars - 1 by 1 float j_interval_volume = array.get(interval_volumes, j) int j_bar_widths = math.round(bar_mult * j_interval_volume / Vmax) array.set(bar_widths, j, j_bar_widths) if barstate.isfirst first := time first change = ta.change(time) x_loc = timenow + math.round(change * bar_offset) f_setup_bar(n) => x1 = VmaxId == n and poc_show ? math.max(time[lookback], first) : timenow + math.round(change * (bar_offset - array.get(bar_widths, n))) ys = array.get(price_levels, n) line.new(x1=x1, y1=ys, x2=x_loc, y2=ys, xloc=xloc.bar_time, extend=extend.none, color=VmaxId == n ? poc_color : bar_color, style=line.style_solid, width=bar_width) if barstate.islast for i = 0 to max_bars - 1 by 1 f_setup_bar(i) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\
Variation analysis 1.1
https://www.tradingview.com/script/VtTWkdw5-Variation-analysis-1-1/
celsorodrigomf
https://www.tradingview.com/u/celsorodrigomf/
35
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © celsorodrigomf //@version=5 indicator("Analise de Variação 1.0" , "AV_1", overlay=true) // Enable or disable pivot labels pricebase = input(0, "Start price") showLabels = input(true, title="Show Labels?") showInner = input(true, title="Plot Inner Levels?") // Step 2. Calculate indicator values // Create a function to fetch daily GetData(res, data) => request.security(syminfo.tickerid, res, data[1],lookahead=barmerge.lookahead_on) dailyClose = pricebase == 0 ? GetData("D", close) : pricebase rs = dailyClose // Calculate levels values rs2 = rs * 0.0025 + rs rs3 = rs * 0.005 + rs rs4 = rs * 0.0075 + rs rs5 = rs * 0.01 + rs rs6 = rs * 0.0125 + rs rs7 = rs * 0.015 + rs rs8 = rs * 0.0175 + rs rs9 = rs * 0.02 + rs rs10 = rs * 0.0225 + rs rs11 = rs * 0.025 + rs rs12 = rs * 0.0275 + rs rs13 = rs * 0.03 + rs rs14 = rs * 0.0325 + rs rs15 = rs * 0.035 + rs rs16 = rs * 0.0375 + rs rs17 = rs * 0.04 + rs rs18 = rs * 0.0425 + rs rs19 = rs * 0.045 + rs rs20 = rs * 0.0475 + rs // rs21 = rs - rs * 0.0025 rs22 = rs - rs * 0.005 rs23 = rs - rs * 0.0075 rs24 = rs - rs * 0.01 rs25 = rs - rs * 0.0125 rs26 = rs - rs * 0.015 rs27 = rs - rs * 0.0175 rs28 = rs - rs * 0.02 rs29 = rs - rs * 0.0225 rs30 = rs - rs * 0.025 rs31 = rs - rs * 0.0275 rs32 = rs - rs * 0.03 rs33 = rs - rs * 0.0325 rs34 = rs - rs * 0.035 rs35 = rs - rs * 0.0375 rs36 = rs - rs * 0.04 rs37 = rs - rs * 0.0425 rs38 = rs - rs * 0.045 rs39 = rs - rs * 0.0475 plot(rs, title ="0%" , style=plot.style_line,color=color.yellow,linewidth=2) plot(showInner ? rs2 : na , title = "0.25%", style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs3, title = "0.5%" , style=plot.style_linebr, color=#034706,linewidth=2) plot(showInner ? rs4 : na , title = "0.75%" , style=plot.style_circles, color=#4caf4f45 ,linewidth=1) plot(rs5, title = "1.0%" , style=plot.style_line, color=color.green,linewidth=3) plot(showInner ? rs6 : na , title = "1.25%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs7, title = "1.5%" , style=plot.style_linebr, color=#034706,linewidth=2) plot(showInner ? rs8 : na , title = "1.75%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs9, title = "2.0%" , style=plot.style_line, color=color.green,linewidth=3) plot(showInner ? rs10 : na , title = "2.25%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs11, title = "2.5%" , style=plot.style_linebr, color=#034706,linewidth=2) plot(showInner ? rs12 : na , title = "2.75%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs13, title = "3.0%" , style=plot.style_line, color=color.green,linewidth=3) plot(showInner ? rs14 : na , title = "3.25%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs15, title = "3.5%" , style=plot.style_linebr, color=#034706,linewidth=2) plot(showInner ? rs16 : na , title = "3.75%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs17, title = "4.0%" , style=plot.style_line, color=color.green,linewidth=3) plot(showInner ? rs18 : na , title = "4.25%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(rs19, title = "4.5%" , style=plot.style_linebr, color=#034706,linewidth=2) plot(showInner ? rs20 : na , title = "4.75%" , style=plot.style_circles, color=#4caf4f45,linewidth=1) plot(showInner ? rs21 : na , title="-0.25%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs22, title="-0.5%" , style=plot.style_linebr, color=#6d0e0e,linewidth=2) plot(showInner ? rs23 : na , title="-0.75%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs24, title="-1.0%" , style=plot.style_line, color=color.red,linewidth=3) plot(showInner ? rs25 : na , title="-1.25%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs26, title="-1.5%" , style=plot.style_linebr, color=#6d0e0e,linewidth=2) plot(showInner ? rs27 : na , title="-1.75%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs28, title="-2.0%" , style=plot.style_line, color=color.red,linewidth=3) plot(showInner ? rs29 : na , title="-2.25%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs30, title="-2.5%" , style=plot.style_linebr, color=#6d0e0e,linewidth=2) plot(showInner ? rs31 : na , title="-2.75%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs32, title="-3.0%" , style=plot.style_line, color=color.red,linewidth=3) plot(showInner ? rs33 : na , title="-3.25%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs34, title="-3.5%" , style=plot.style_linebr, color=#6d0e0e,linewidth=2) plot(showInner ? rs35 : na , title="-3.75%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs36, title="-4.0%" , style=plot.style_line, color=color.red,linewidth=3) plot(showInner ? rs37 : na , title="-4.25%" , style=plot.style_circles, color=#a0292952,linewidth=1) plot(rs38, title="-4.5%" , style=plot.style_linebr, color=#6d0e0e,linewidth=2) plot(showInner ? rs39 : na , title="-4.75%" , style=plot.style_circles, color=#a0292952,linewidth=1) if showLabels nLabel0 = label.new(bar_index,rs + 25, text="0%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel05 = label.new(bar_index,rs3 + 25, text="0.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel1 = label.new(bar_index,rs5 + 25, text="1%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel15 = label.new(bar_index,rs7 + 25, text="1.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel2 = label.new(bar_index,rs9 + 25, text="2%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel25 = label.new(bar_index,rs11 + 25, text="2.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel3 = label.new(bar_index,rs13 + 25, text="3%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel35 = label.new(bar_index,rs15 + 25, text="3.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel4 = label.new(bar_index,rs17 + 25, text="4%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel45 = label.new(bar_index,rs19 + 25, text="4.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_05 = label.new(bar_index,rs22 + 25, text="-5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_1 = label.new(bar_index,rs24 + 25, text="-1%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_15 = label.new(bar_index,rs26 + 25, text="-1.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_2 = label.new(bar_index,rs28 + 25, text="-2%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_25 = label.new(bar_index,rs30 + 25, text="-2.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_3 = label.new(bar_index,rs32 + 25, text="-3%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_35 = label.new(bar_index,rs34 + 25, text="-3.5%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_4 = label.new(bar_index,rs36 + 25, text="-4%" , size=size.small , style = label.style_label_left, color = #ffffff) nLabel_45 = label.new(bar_index,rs38 + 25, text="4.5%" , size=size.small , style = label.style_label_left, color = #ffffff) label.delete(nLabel0[1]) label.delete(nLabel05[1]) label.delete(nLabel1[1]) label.delete(nLabel15[1]) label.delete(nLabel2[1]) label.delete(nLabel25[1]) label.delete(nLabel3[1]) label.delete(nLabel35[1]) label.delete(nLabel4[1]) label.delete(nLabel45[1]) label.delete(nLabel_05[1]) label.delete(nLabel_1[1]) label.delete(nLabel_15[1]) label.delete(nLabel_2[1]) label.delete(nLabel_25[1]) label.delete(nLabel_3[1]) label.delete(nLabel_35[1]) label.delete(nLabel_4[1]) label.delete(nLabel_45[1])
Relative Strength Index Ex
https://www.tradingview.com/script/2N5l16dN-Relative-Strength-Index-Ex/
gautamsatpathy
https://www.tradingview.com/u/gautamsatpathy/
29
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © gautamsatpathy //@version=5 indicator(title="Relative Strength Index Ex", shorttitle="RSI Ex", format=format.price, precision=2, timeframe="", timeframe_gaps=true) /////////////////////////////////////////////////////////////////////////////// // functions /////////////////////////////////////////////////////////////////////////////// ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) /////////////////////////////////////////////////////////////////////////////// // Inputs /////////////////////////////////////////////////////////////////////////////// rsiLengthInput = input.int( 12, minval=1, title = "RSI Length", group = "RSI Settings") rsiSourceInput = input.source( close, "Source", group="RSI Settings" ) maTypeInput = input.string( "SMA", title = "MA Type", options = ["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = "MA Settings" ) maLengthInput = input.int( 4, title = "MA Length", group = "MA Settings" ) bbMultInput = input.float( 2.0, minval = 0.001, maxval = 50, title = "BB StdDev", group = "MA Settings" ) rsima2len = input.int( 12, minval = 1, title = "RSI MA 2 Length" ) /////////////////////////////////////////////////////////////////////////////// // Calc /////////////////////////////////////////////////////////////////////////////// up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput) down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) rsiMA = ma(rsi, maLengthInput, maTypeInput) isBB = maTypeInput == "Bollinger Bands" rsima2 = ta.sma( rsi, rsima2len ) /////////////////////////////////////////////////////////////////////////////// // Plot /////////////////////////////////////////////////////////////////////////////// plot( rsi, "RSI", color = color.fuchsia, linewidth = 2 ) // #7E57C2 plot( rsiMA, "RSI-based MA", color = color.orange, linewidth = 2 ) // RSI Bands rsiUpperBand = hline( 70, "RSI Upper Band", color = #787B86, linewidth = 1 ) hline( 50, "RSI Middle Band", color = color.new(#787B86, 50), linewidth = 1 ) rsiLowerBand = hline( 30, "RSI Lower Band", color = #787B86, linewidth = 1 ) fill( rsiUpperBand, rsiLowerBand, color = color.rgb(126, 87, 194, 90), title = "RSI Background Fill" ) // Bollinger on RSI bbUpperBand = plot( isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green ) bbLowerBand = plot( isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green ) fill( bbUpperBand, bbLowerBand, color = isBB ? color.new(color.green, 90) : na, title = "Bollinger Bands Background Fill" ) // RSI MA 2 plot( rsima2, "RSI-based MA 2", color = color.black, linewidth = 2 ) // RSI Support & Resistance Bands rsiResistanceBand = hline( 55, "RSI Resistance Band", color = #787B86, linewidth = 1 ) rsiSupportBand = hline( 45, "RSI Support Band", color = #787B86, linewidth = 1 ) fill( rsiResistanceBand, rsiSupportBand, color = color.rgb(255, 255, 0, 90), title = "RSI R-S Band Fill" )
US Fed Rate Hike Historical Dates
https://www.tradingview.com/script/aNp5IIBy-US-Fed-Rate-Hike-Historical-Dates/
SnarkyPuppy
https://www.tradingview.com/u/SnarkyPuppy/
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/ // © SnarkyPuppy //@version=5 indicator("US Fed Rate Hike Review", overlay=true) ///Hikes color2=color.rgb(76, 160, 230, 80) plot((year==1980? high:0),style=plot.style_area, color= color2) plot((month==02 and year==1994? high:0),style=plot.style_area, color= color2) plot((month==02 and year==1994? high:0),style=plot.style_area, color= color2) plot((month==08 and year==1994? high:0),style=plot.style_area, color= color2) plot((month==11 and year==1995? high:0),style=plot.style_area, color= color2) plot((month==01 and year==1995? high:0),style=plot.style_area, color= color2) plot((month==07 and year==1995? high:0),style=plot.style_area, color= color2) plot((month==12 and year==1995? high:0),style=plot.style_area, color= color2) plot((month==03 and year==1997? high:0),style=plot.style_area, color= color2) plot((month==02 and year==1999? high:0),style=plot.style_area, color= color2) plot((month==08 and year==1999? high:0),style=plot.style_area, color= color2) plot((month==11 and year==1999? high:0),style=plot.style_area, color= color2) plot((month==02 and year==2000? high:0),style=plot.style_area, color= color2) plot((month==03 and year==2000? high:0),style=plot.style_area, color= color2) plot((month==05 and year==2000? high:0),style=plot.style_area, color= color2) plot((month==06 and year==2004? high:0),style=plot.style_area, color= color2) plot((month==08 and year==2004? high:0),style=plot.style_area, color= color2) plot((month==11 and year==2004? high:0),style=plot.style_area, color= color2) plot((month==12 and year==2004? high:0),style=plot.style_area, color= color2) plot((month==02 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==03 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==06 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==08 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==09 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==11 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==12 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==01 and year==2006? high:0),style=plot.style_area, color= color2) plot((month==03 and year==2006? high:0),style=plot.style_area, color= color2) plot((month==05 and year==2006? high:0),style=plot.style_area, color= color2) plot((month==06 and year==2005? high:0),style=plot.style_area, color= color2) plot((month==12 and year==2015? high:0),style=plot.style_area, color= color2) plot((month==12 and year==2015? high:0),style=plot.style_area, color= color2) plot((month==03 and year==2017? high:0),style=plot.style_area, color= color2) plot((month==06 and year==2017? high:0),style=plot.style_area, color= color2) plot((month==12 and year==2017? high:0),style=plot.style_area, color= color2) plot((month==03 and year==2018? high:0),style=plot.style_area, color= color2) plot((month==06 and year==2018? high:0),style=plot.style_area, color= color2) plot((month==09 and year==2018? high:0),style=plot.style_area, color= color2) plot((month==12 and year==2018? high:0),style=plot.style_area, color= color2) plot((month==03 and year==2022? high:0),style=plot.style_area, color= color2) plot((month==05 and year==2022? high:0),style=plot.style_area, color= color2) plot((month==06 and year==2022? high:0),style=plot.style_area, color= color2) plot((month==07 and year==2022? high:0),style=plot.style_area, color= color2) plot((month==09 and year==2022? high:0),style=plot.style_area, color= color2) plot((month==11 and year==2022? high:0),style=plot.style_area, color= color2) plot((month==12 and year==2022? high:0),style=plot.style_area, color= color2)
Market Breadth: Trends & Breakouts
https://www.tradingview.com/script/x7gm9JQz-Market-Breadth-Trends-Breakouts/
groks
https://www.tradingview.com/u/groks/
73
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © groks // // What percent of a market's constituents are participating in trends and breakouts? And can that // give clues to market direction before it is reflected in the market price? // // Default data sourcees are for the S&P 500, but you can use data for another market, or change // the length of trends or breakouts. // //@version=5 indicator("Market Breadth: Trends & Breakouts") above_slow_avg_sym = input.symbol("S5TH", "% Above slow average") above_fast_avg_sym = input.symbol("S5FI", "% Above fast average") new_hi_sym = input.symbol("MAHP", "# New highs") new_lo_sym = input.symbol("MALP", "# New lows") denom = input.int(500, "Size of index", tooltip="Needed to convert number of new highs to percent of new highs") // Most of this data seems to be only available at daily resolution or above. Using indicator(timeframe="1D") produces a glitchy display. var tf = timeframe.ismonthly ? "1M" : timeframe.isweekly ? "1W" : "1D" slow = request.security(above_slow_avg_sym, tf, close) fast = request.security(above_fast_avg_sym, tf, close) hi = request.security(new_hi_sym, tf, close) lo = request.security(new_lo_sym, tf, close) var gray2 = color.new(color.gray, 80) zero = plot(0, "0", color=color.gray) plot(50, "50% line", color=gray2) plot(-50, "-50% line", color=gray2) plot(100, "100% line", color=gray2) plot(-100, "-100% line", color=gray2) var blue = color.new(color.blue, 80) a = plot(slow, "Percent above slow moving average", color=blue) b = plot(slow - 100, "Percent below slow moving average", color=blue) fill(a, b, color=blue, title="Slow moving average fill") var blue2 = color.new(color.blue, 60) a2 = plot(fast, "Percent above fast moving average", color=blue2) b2 = plot(fast - 100, "Percent below fast moving average", color=blue2) fill(a2, b2, color=color.new(blue2, 100), title="Fast moving average fill") pct_hi = (100 / denom) * hi hi_line = plot(pct_hi, "% New high", color=color.green) fill(zero, hi_line, color=color.green, title="% New high fill") pct_lo = ((100 / denom) * lo) lo_line = plot(-pct_lo, "% New low", color=color.red) fill(zero, lo_line, color=color.red, title="% New low fill")
Historical Average
https://www.tradingview.com/script/nVfFImtF-Historical-Average/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
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/ // © peacefulLizard50262 //@version=5 indicator("Historical Average", overlay = true) source = input.source(close, "Source") select = input.string("SMA", "Select", ["SMA","LWMA","EMA","DEMA","TEMA","QEMA"]) simple_moving_average(source)=> var float sum = na var int count = na if close == close count := nz(count[1]) + 1 sum := nz(sum[1]) + source sum/count linear_weighted_moving_average(source)=> var float sum = na var int count = na if close == close count := nz(count[1]) + 1 sum := nz(sum[1]) + (source * count) sum/count/count exponential_moving_average(source)=> var float ema = 0.0 var int count = 0 if open == open count := nz(count[1]) + 1 ema := (1.0 - 2.0 / (count + 1.0)) * nz(ema[1]) + 2.0 / (count + 1.0) * source ema double_exponential_moving_average(source)=> var float ema1 = 0.0 var float ema2 = 0.0 var int count = 0 if close == close count := nz(count[1]) + 1 ema1 := (1.0 - 2.0 / (count + 1.0)) * nz(ema1[1]) + 2.0 / (count + 1.0) * source ema2 :=(1.0 - 2.0 / (count + 1.0)) * nz(ema2[1]) + 2.0 / (count + 1.0) * ema1 2 * ema1 - ema2 triple_exponential_moving_average(source)=> var float ema1 = 0.0 var float ema2 = 0.0 var float ema3 = 0.0 var int count = 0 if close == close count := nz(count[1]) + 1 ema1 := (1.0 - 2.0 / (count + 1.0)) * nz(ema1[1]) + 2.0 / (count + 1.0) * source ema2 :=(1.0 - 2.0 / (count + 1.0)) * nz(ema2[1]) + 2.0 / (count + 1.0) * ema1 ema3 :=(1.0 - 2.0 / (count + 1.0)) * nz(ema3[1]) + 2.0 / (count + 1.0) * ema2 3 * ema1 - 3 * ema2 + ema3 quadruple_exponential_moving_average(source)=> var float ema1 = 0.0 var float ema2 = 0.0 var float ema3 = 0.0 var float ema4 = 0.0 var int count = 0 if close == close count := nz(count[1]) + 1 ema1 := (1.0 - 2.0 / (count + 1.0)) * nz(ema1[1]) + 2.0 / (count + 1.0) * source ema2 :=(1.0 - 2.0 / (count + 1.0)) * nz(ema2[1]) + 2.0 / (count + 1.0) * ema1 ema3 :=(1.0 - 2.0 / (count + 1.0)) * nz(ema3[1]) + 2.0 / (count + 1.0) * ema2 ema4 :=(1.0 - 2.0 / (count + 1.0)) * nz(ema4[1]) + 2.0 / (count + 1.0) * ema3 4 * ema1 - 6 * ema2 + 4 * ema3 - ema4 ma(source, select)=> switch select "SMA" => simple_moving_average(source) "LWMA" => linear_weighted_moving_average(source) "EMA" => exponential_moving_average(source) "DEMA" => double_exponential_moving_average(source) "TEMA" => triple_exponential_moving_average(source) "QEMA" => quadruple_exponential_moving_average(source) average = ma(source, select) plot(average, "Average")
Harmonic Patterns Based Supertrend
https://www.tradingview.com/script/Uf882Tc7-Harmonic-Patterns-Based-Supertrend/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
666
study
5
MPL-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 import HeWhoMustNotBeNamed/HSupertrend/2 as hs indicator('Harmonic Patterns Based Supertrend', 'HP-Supertrend [Trendoscope]', overlay=true, max_lines_count = 500) base = input.string('CD', 'Base', ['minmax', 'correction', 'CD'], group="Supertrend") entryPercent = input.int(30, 'Entry %', minval=30, maxval = 200, step=5, group='Supertrend') stopPercent = input.int(5, 'Stop %', minval=0, maxval = 30, step=5, group='Supertrend') useClosePrices = input.bool(true, 'Use Close Prices', group='Supertrend') errorPercent = input.int(8, title='Error %', minval=3, step=5, maxval=21, group='Harmonic Patterns', tooltip='Error threshold for calculation on patterns. Increased error threshold will reduce the accuracy of patterns. Lower error threshold will reduce number of patterns detected.') zigzagLength = input.int(8, step=5, minval=3, title='Zigzag', group='Harmonic Patterns', tooltip='Zigzag Length on which pattern detection is built') logScale = input.bool(false, 'Log Scale', group='Harmonic Patterns', tooltip='If selected, patterns are scanned on log scale instead of regular price scale') showHarmonicPatterns = input.bool(true, 'Display Harmonic Patterns', group='Harmonic Patterns', tooltip='If selected, harmonic patterns scanned will be drawn on chart') [dir, supertrend] = hs.hsupertrend(hs.ZigzagProperties.new(zigzagLength, na), hs.PatternProperties.new(base, entryPercent, stopPercent, useClosePrices, logScale), errorPercent, showHarmonicPatterns, color.blue ) plot(supertrend, 'HarmonicSupertrend', color=dir>0? color.green: color.red)
(mab) Volume Index
https://www.tradingview.com/script/IUdFxFrl-mab-Volume-Index/
happymab
https://www.tradingview.com/u/happymab/
73
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © happymab // // V 1.0 // // The (mab) Volume Index measures volume momentum. The formula is somewhat similar to the formula of RSI but // uses volume instead of price. The price is calculated as the average of open, high, low and close prices // and is used to determine if the volume is counted as up-volume or down-volume. // //@version=5 indicator("(mab) Volume Index", shorttitle="(mab)Mvi", overlay=false) // (mab) Colors col_none = color.new(color.white, 100) // Green col_darkSpringGreen = #137547 col_lightGreen = #8fe388 col_springGreen = #61FF7E col_malachite = #4CE949 col_mediumAquamarine = #69DC9E col_Citron = #8EA604 col_yellowGreen = #97DB4F // Red col_rubyRed = #931621 col_redPigment = #ef1010 col_middleRed = #E88873 col_radicalRed = #FF1053 // Orange col_outrageousOrange = #fc7753 col_orangeSoda = #EB5133 col_tartOrange = #F75550 col_orangeRedCrayola = #FE5F55 // Pink col_shockingPinkCrayola = #FB62F6 col_congoPink = #FE8E86 // Purple col_mysticMaroon = #bc387d col_darkBluePurple = #311b92 col_plumWeb = #F9B9F2 // Blue col_trurfsBlue = #0091eb col_honoluluBlue = #176da3 col_GreenBlueCrayola = #1e91d6 col_vividSkyBlue = #42cafd col_skyBlueCrayola = #51E5FF // Yellow col_maximumYellowRed = #fec149 col_rajah = #FFAA5A col_honeyYellow = #FBAF00 col_minionYellow = #FDE74C // White col_navajo_white = #FEDB9B col_seeshell = #fef4ec // Blue-Purple col_blue1 = #CFEAF1 col_blue2 = #BBD2E7 col_blue3 = #A6BADC col_blue4 = #92A2D2 col_blue5 = #7D8AC7 col_blue6 = #6972BD col_blue7 = #545AB2 col_blue8 = #4042A8 col_blue9 = #2B2A9D ////////////////////////////////// // MVI ////////////////////////////////// src = input.source(ohlc4, title="Source") length = input.int(14, title="Length", minval=1, maxval=2000) emaLength = input.int(13, title="EMA length", minval=1, maxval=2000) oversold = input.float(25.0, title="Oversold", minval=0.0) overbought = input.float(75.0, title="Overbought", minval=0.0) midline = 50.0 // Index calculation function _calcIndex(up, dn, len) => rs = ta.rma(up, len) / ta.rma(dn, len) res = 100 - 100 / (1 + rs) res // MVI mviUp = src > src[1] ? volume : 0 mviDown = src[1] > src ? volume : 0 mvi = _calcIndex(mviUp, mviDown, length) mviEma = ta.ema(mvi, emaLength) // Plot band band1 = plot(oversold, title="Oversold", color=color.new(col_lightGreen, 75), style=plot.style_cross, linewidth=1, join=true, display=display.none) band2 = plot(overbought, title="Overbought", color=color.new(col_outrageousOrange, 75), style=plot.style_cross, linewidth=1, join=true, display=display.none) plot(midline, title="Midline", color=color.new(col_seeshell, 75), style=plot.style_line, linewidth=1, join=true, display=display.none) fill(band1, band2, color=color.new(col_blue3, 80), title="Background") // Plot index plot(mvi, title="MVI", color=color.new(col_blue3, 50), style=plot.style_area, histbase=50, linewidth=1) plot(mviEma, title="MVI EMA", color=color.new(col_blue1, 50), style=plot.style_line, histbase=50, linewidth=1, display=display.none)
Diff_US10Y_US03Y
https://www.tradingview.com/script/bJlY5ueO-Diff-US10Y-US03Y/
easonoic
https://www.tradingview.com/u/easonoic/
6
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © easonoic //@version=5 indicator("Diff_US10Y_US03Y", overlay=true) US03MY = input.symbol("US03MY", "Symbol") US10Y = input.symbol("US10Y", "Symbol") us03my_s_o = request.security(US03MY, 'D', open) us10y_s_o = request.security(US10Y, 'D', open) us03my_s_c = request.security(US03MY, 'D', close) us10y_s_c = request.security(US10Y, 'D', close) us03my_s_high = request.security(US03MY, 'D', high) us10y_s_high = request.security(US10Y, 'D', high) us03my_s_low = request.security(US03MY, 'D', low) us10y_s_low = request.security(US10Y, 'D', low) US10Y_US03MY_diff_o = us10y_s_o - us03my_s_o US10Y_US03MY_diff_c = us10y_s_c - us03my_s_c US10Y_US03MY_diff_high = us10y_s_high - us03my_s_high US10Y_US03MY_diff_low = us10y_s_low - us03my_s_low bool upBar = US10Y_US03MY_diff_c > US10Y_US03MY_diff_o plotcandle(US10Y_US03MY_diff_o, US10Y_US03MY_diff_high, US10Y_US03MY_diff_low, US10Y_US03MY_diff_c, title='Diff_US10Y_US03Y', color = US10Y_US03MY_diff_o > US10Y_US03MY_diff_c ? color.green : color.red, wickcolor=color.black) plot(0)
RLT Gaps
https://www.tradingview.com/script/NsDGKgBj-RLT-Gaps/
MattDeLong
https://www.tradingview.com/u/MattDeLong/
194
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MattDeLong //@version=5 indicator("RLT Gaps", overlay=false) gapsize = input.float(title="Gap Size", minval=0.01, maxval=25.0, step=0.01, defval=2.0, confirm=false) sizeOfGap = ((close[1]-open)/close[1]) * -100 asizeOfGap = math.abs(sizeOfGap) plot(sizeOfGap, title='sizeOfGap', color=color.orange, linewidth=1) bullgng = close[1]<open[1] and open>close[1] and timeframe.isdaily and asizeOfGap>=gapsize bullrtg = close[1]>open[1] and open>close[1] and timeframe.isdaily and asizeOfGap>=gapsize beargng = close[1]>open[1] and open<close[1] and timeframe.isdaily and asizeOfGap>=gapsize bearrtg = close[1]<open[1] and open<close[1] and timeframe.isdaily and asizeOfGap>=gapsize plotshape(bullgng, style=shape.flag, location=location.bottom, color=color.green, text='GNG') plotshape(bullrtg, style=shape.xcross, location=location.bottom, color=color.green, text='RTG') plotshape(beargng, style=shape.flag, location=location.bottom, color=color.red, text='GNG') plotshape(bearrtg, style=shape.xcross, location=location.bottom, color=color.red, text='RTG')
R Squared - Momentum
https://www.tradingview.com/script/kr2oqQAT-R-Squared-Momentum/
Crak_Trading
https://www.tradingview.com/u/Crak_Trading/
20
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Crak_Trading //@version=5 indicator("R Squared - Momentum") len = input.int(21, title = "Length") src = input(hlc3, title = "Source") f_rsq(_src, _period) => x = _period y = _src avg = 0.0 for i = 0 to x avg := avg + y[i] / x avg diff = y - avg diffsqr = math.pow(diff, 2) diffsum = math.sum(diffsqr, x) linereg = ta.linreg(y, x, 0) est = linereg - avg estsqr = math.pow(est, 2) estsum = math.sum(estsqr, x) r2 = 1 - diffsum / estsum r2line = f_rsq(src, len) sm = ta.sma(r2line, 5) up = r2line > r2line[1] ? color.green : color.red plot(r2line, color = up, style = plot.style_line) plot(sm, color = color.gray, style=plot.style_line)
FOREX MASTER PATTERN Value Lines by nnam
https://www.tradingview.com/script/6MV8ibbr-FOREX-MASTER-PATTERN-Value-Lines-by-nnam/
nnamdert
https://www.tradingview.com/u/nnamdert/
324
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © nnamdert //Updated November 05, 2023 //@version=5 indicator("FOREX MASTER PATTERN Value Lines by nnam", overlay=true, max_lines_count = 500) // BEGIN SCRIPT // valueline_timeframe = input.timeframe( // defval = '', // title = 'Value Line TimeFrame', // //options = [], // group = 'Line Settings', // tooltip='Unchecking this box will hide the Forex Master Pattern Value Lines on the chart.' // ) // //HANDLES MAX_LINES_COUNTS ISSUE================================================================================================// lineLimitInput = input.int( // defval = 100, // minval = 1, // maxval = 499, // title = 'Max Lines to Show (Total of ALL Lines combined)', // tooltip = 'Adjust this number to increase or decrease the total number of lines seen on the chart. (ONLY this indicator)', // group = 'Line Settings' // ) // if array.size(line.all) > lineLimitInput // for i = 0 to array.size(line.all) - lineLimitInput - 1 // line.delete(array.get(line.all, i)) // //BEGIN Get User Inputs=========================================================================================================// //BEGIN Get User Inputs - Line Settings // hide_pivot_lines = input.bool(false, title = 'hide Pivot Lines?', group = 'Show Pivot Lines') // show_lines = input.bool( // defval = true, // title = 'Show Lines on chart', // group = 'Line Settings', // tooltip = 'Unchecking this box will hide ALL lines on the chart - NO LINES generated by this indicator will appear' // ) // show_valuelines = input.bool( // defval = true, // title = 'Show Value Lines on chart', // group = 'Line Settings', // tooltip='Unchecking this box will hide the Forex Master Pattern Value Lines on the chart.' // ) // total_vl_to_show = input.int( // defval = 3, // title = 'Total number of Value Lines to Show on Chart', // group = 'Line Settings', // tooltip = 'Change this number to the number of Historical Value Lines you would like to see on the chart' // ) // show_expansion_guide_lines = input.bool( // defval = true, // title = 'Show Expansion Guidelines on chart', // group = 'Line Settings', // tooltip='Unchecking this box will hide the Red and Green Expansion Guides on the chart.' // ) // value_line_width_settings = input.int( // defval = 2, // title = 'Set Value Line Width', // group = 'Line Settings', // tooltip = 'Use this option to set the width of the Forex master Pattern Value Line (default is 1, max is 8)', // minval = 1, // maxval = 8 // ) // value_line_length_settings = input.int( // defval = 500, // title = 'Set Value Line Length', // group = 'Line Settings', // tooltip = 'Use this option to set the lenth of the Forex master Pattern Value Line (default is 100, max is 100)', // minval = 1, // maxval = 500 // ) // only_show_last_value_line = input.bool( // defval = false, // title = 'Only show last Value Line on Chart?', // group = 'Line Settings', // tooltip = 'If box is checked only most recent Value Line will be visible, even if most recent box is not in the same location' // ) // showOnlyLastBox = input.bool( // defval = false, // title = 'show last box only', // group = 'Box Settings', // tooltip = 'If box is checked only the most recent contraction box will be shown on the chart' // ) // show_Expansion_Area = input.bool( // defval = false, // title = 'Show Expansion Area (coming soon)', // group = 'Expansion Area Settings (coming Soon!)', // tooltip = 'This feature is not implemented yet' // ) // show_expansion_guidelines = input.bool( // defval = false, // title = 'Show Expansion GuideLines on Chart (coming soon)', // group = 'Expansion Area Settings (coming Soon!)', // tooltip = 'This feature is not implemented yet' // ) // //END Get User Inputs - Line Settings===========================================================================================// //BEGIN Get User Inputs - BARS==================================================================================================// //BEGIN Get User Inputs - BAR COLORS // color_code_candles = input.bool( // defval=true, // title = 'Color Code the Candles', // tooltip = 'Turn on Color Coded Candles. Expansion. Contraction, Bullish and Bearish Candles will be shaded as listed below.', // group = 'Candle Colors' // ) // inside_bar_color = input.color( // defval = color.white, // title = 'Contraction Candles', // tooltip = 'This is the color of the Strat Inside Bar - otherwise known as 1', // group = 'Candle Colors', // inline = 'inside outside', // confirm = false) // outside_bar_color = input.color( // defval = color.yellow, // title = 'Expansion Candles', // tooltip = 'This is the color of the Strat Outside Bar - otherwise known as 3', // group = 'Candle Colors', // inline = 'inside outside', // confirm = false) // twoup_bar_color = input.color( // defval = color.lime, // title = 'Bullish Candle', // tooltip = 'This is the color of the Strat 2 UP Bar', // group = 'Candle Colors', // inline = 'twobars', // confirm = false) // twodown_bar_color = input.color( // defval = color.maroon, // title = 'Bearish Candle', // tooltip = 'This is the color of the Strat 2 DOWN Bar', // group = 'Candle Colors', // inline = 'twobars', // confirm = false) // bearish_engulfing_bar_color = input.color( // defval = color.new(color.fuchsia, 0), // title = 'Bearish Engulfing Candle', // tooltip = 'This is the color of a Bearish Engulfing Candle', // group = 'Candle Colors', // inline = 'engulfing', // confirm = false) // bullish_engulfing_bar_color = input.color( // defval = color.new(color.blue, 0), // title = 'Bullish Engulfing Candle', // tooltip = 'This is the color of a Bullish Engulfing Candle', // group = 'Candle Colors', // inline = 'engulfing', // confirm = false) // //END Get User Inputs - BAR COLORS // //BEGIN Get User Inputs - ENGULFING BARS========================================================================================// show_engulfing_patterns = input.bool( // defval=true, // title = 'Show Engulfing Patterns?', // group = 'Engulfing Patterns' // ) // show_bullish_engulfing_patterns = input.bool( // defval=true, // title ='Show Bullish Engulfing Candles', // group = 'Engulfing Patterns') // show_bearish_engulfing_patterns = input.bool( // defval=true, // title ='Show Bearish Engulfing Candles', // group = 'Engulfing Patterns') // //END Get User Inputs - ENGULFING BARS==========================================================================================// //BEGIN STRAT SCENARIO INDENTIFIERS=============================================================================================// atr = ta.atr(14) // bar_green = close >= open // bar_red = close < open // bar_inside = (high <= high[1]) and (low >= low[1]) // bar_twoup = (high > high[1]) and (low >= low[1]) // bar_twodown = (high <= high[1]) and (low < low[1]) // bar_outside = (high > high[1]) and (low < low[1]) // bar_openTime = time // bar_lowPrice = low // bar_highPrice = high // bar_two_up_green = bar_twoup and bar_green // bar_two_up_red = bar_twoup and bar_red // bar_two_down_red = bar_twodown and bar_red // bar_inside_green = bar_inside and bar_green // bar_outside_green = bar_outside and bar_green // bar_outside_red = bar_outside and bar_red // bar_continuation_green = open[1] <= low and bar_green // //END STRAT SCENARIO INDENTIFIERS===============================================================================================// //BEGIN BEARISH ENGULFING DEFINITION+===========================================================================================// bar_bearish_engulfing = // //CLOSE Price of the CURRENT Engulfing candle /session must be (less than) the OPEN Price of PREVIOUS session // close < open[1] // //OPEN Price of the CURRENT Engulfing candle /session must be (greater than) the CLOSE Price of PREVIOUS session // and open > close[1] // //Previous Session (before the engulfing candle) - the candle /session being Engulfed MUST be a GREEN candle /session // and (close[1] >= open[1]) // //OPEN and CLOSE of the CURRENT Engulfing Session is (greater than or equal to) the previous candle /session being Engulfed and // //is LARGER by a factor of 2 - (or basically twice as big) - ENGULFING CANDLE MUST BE RED [open - close = RED] // and (open - close) >= ((close[1] - open[1]) * 6) // //CURRENT Engulfing candle /session needs to be (greater than) the atr // and (open - close) >= atr // //END BEARISH ENGULFING DEFINITION==============================================================================================// //BEGIN BULLISH ENGULFING DEFINITION============================================================================================// bar_bullish_engulfing = // close > open[1] // and open < close[1] // and (close[1] <= open[1]) // and (close - open) >= ((open[1] - close[1]) * 6) // and (close - open) >= atr // //END BULLISH ENGULFING DEFINITION==============================================================================================// //Begin Bar Colors==============================================================================================================// //Expansion Candle also known as Strat 3 Outside Bar // barcolor( // not bar_bearish_engulfing // and not bar_bullish_engulfing // and color_code_candles // and (high > high[1] // and low < low[1]) ? // color.new(outside_bar_color, 0) : na, title = '3 Outside Bar') // barcolor( // not bar_bullish_engulfing // and not bar_bearish_engulfing // and color_code_candles // and (high > high[1] // and low >= low[1]) ? // color.new(twoup_bar_color, 0) : na, title = '2 up') // barcolor( // not bar_bullish_engulfing // and not bar_bearish_engulfing // and color_code_candles // and (high <= high[1] // and low < low[1]) ? // color.new(twodown_bar_color, 0) : na, title = '2 down') // barcolor( // not bar_bullish_engulfing // and not bar_bearish_engulfing // and color_code_candles // and (high <= high[1] // and low >= low[1]) ? // color.new(inside_bar_color, 0) : na, title = '1 Inside Bar') // barcolor( // bar_bullish_engulfing // and show_bullish_engulfing_patterns // and show_engulfing_patterns // and color_code_candles ? // color.new(bullish_engulfing_bar_color, 0) : na, title = 'Bullish Engulfing') // barcolor( // bar_bearish_engulfing // and show_bearish_engulfing_patterns // and show_engulfing_patterns // and color_code_candles ? // color.new(bearish_engulfing_bar_color, 0) : na, title = 'Bearish Engulfing') // //bear_candle = open > close // //bull_candle = close > open // //plotcandle(bull_candle ? open : na, bull_candle ? high: na, bull_candle ? low: na, bull_candle ? close: na, // // wickcolor=color.new(color.lime, 0), // // bordercolor=color.new(color.lime, 0) // // ) // //plotcandle(bear_candle ? open: na, bear_candle ? high: na, bear_candle ? low: na, bear_candle ? close: na, // // wickcolor=color.new(color.red, 0), // // bordercolor=color.new(color.red, 0) // // ) // //End Bar Colors================================================================================================================// // // //BEGIN CONTRACTION BOXES=======================================================================================================// //showOnlyLastBox = input.bool(false, title = 'show last box only') //is above in global inputs leaving here for // //standalone box script if required // // variables // var box myBox = na // var float boxHigh = na // var float boxLow = na // varip int barIndex = 1 // varip bool f = false // // oneone = request.security(syminfo.tickerid, valueline_timeframe, bar_inside) // not recommended as it can cause issues // if oneone == true 1 else na // if oneone and oneone[1] and not oneone[2] and barstate.isconfirmed // boxHigh := high[1] // was high[1] boxLow := low[1] // was high[1] f := true if showOnlyLastBox box.delete(id=myBox[1]) myBox := box.new(bar_index-1, high, bar_index, low, bgcolor=color.new(#405fcf, 50), border_width=2) // high and low were [1] barIndex := barIndex+1 else if oneone and oneone[1] and oneone[2] and barstate.isconfirmed // box.set_right(myBox[1], bar_index) barIndex := barIndex+1 else if oneone[2] and oneone[1] and not oneone and barstate.isconfirmed // box.set_right(myBox[1], bar_index) barIndex := barIndex else if not oneone[1] and not oneone // f := false //END CONTRACTION BOXES=========================================================================================================// //lines // //midline // //EmaCross = ta.crossover(shortest, short) (future use) // var float middleBody = na //midline = line.new(bar_index[1], middleBody, bar_index+value_line_length_settings, middleBody, width = value_line_width_settings) //, extend=extend.right) //if oneone and oneone[1] and show_lines and not only_show_last_value_line // middleBody := (((high + high[1]) / 2) + ((low + low[1]) / 2)) / 2 //was (open + close) / 2 or (high + low) / 2 // midline = line.new(bar_index[1], middleBody, bar_index+value_line_length_settings, middleBody, width = value_line_width_settings) //, extend=extend.right) //else // if oneone and oneone[1] and show_lines and only_show_last_value_line // middleBody := (((high + high[1]) / 2) + ((low + low[1]) / 2)) / 2 //was (open + close) / 2 or (high + low) / 2 // midline = line.new(bar_index[1], middleBody, bar_index+value_line_length_settings, middleBody, width = value_line_width_settings) //, extend=extend.right) // line.delete(midline[2]) //NotValid = not oneone //if NotValid // middleBody := na //Value Line var line [] value_line_array = array.new_line() var line value_line_01 = na if oneone and oneone[1] and show_lines and show_valuelines middleBody := (((high + high[1]) / 2) + ((low + low[1]) / 2)) / 2 //was (open + close) / 2 or (high + low) / 2 value_line_01 := line.new(bar_index[1], middleBody, bar_index+value_line_length_settings, middleBody, color = color.new(color.blue, 0), width = value_line_width_settings) array.push(value_line_array, value_line_01) if array.size(value_line_array) > total_vl_to_show line.delete(array.shift(value_line_array)) //plot(middleBody, color=color.lime, style=plot.style_linebr, trackprice=true) //END MIDLINE SCRIPT============================================================================================================// //BEGIN ENGULFING CANDLE ALERTS=================================================================================================// alertcondition( // bar_bullish_engulfing, // title = 'Bullish Engulfing Alert', // message = 'Bullish Engulfing Pattern Identified' // ) // alertcondition( // bar_bearish_engulfing, // title = 'Bearish Engulfing Alert', // message = 'Bearish Engulfing Pattern Identified' // ) // //END ENGULFING CANDLE ALERTS===================================================================================================// //BEGIN ENGULFING CANDLE PLOTS==================================================================================================// //plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display) → void=========+// //show_engulfing_patterns and show_bullish_engulfing_patterns ? // plotshape(not show_engulfing_patterns or not show_bullish_engulfing_patterns ? na : // bar_bullish_engulfing, // title = 'Bullish Engulfing Plot', // style = shape.arrowup, // location = location.belowbar, // color = color.new(color.blue,0), // size = size.large, // show_last = 2000) // //show_engulfing_patterns and show_bearish_engulfing_patterns ? // plotshape(not show_engulfing_patterns or not show_bearish_engulfing_patterns ? na : // bar_bearish_engulfing, // title = 'Bearish Engulfing Plot', // style = shape.arrowdown, // location = location.abovebar, // color = color.new(color.fuchsia,0), // size = size.large, // show_last = 2000) // //END ENGULFING CANDLE PLOTS====================================================================================================// // // mom_len = input.int(12, minval=1, title="Length") mom_src = input(close, title="Source") mom = mom_src - mom_src[mom_len] bullish_momentum = mom > mom[1] //and mom > 0.00 bearish_momentum = mom < mom[1] //and mom < 0.00 bullish_reversal = mom[3] > mom[2] and mom[2] < mom[1] bearishreversal = mom[3] <mom[2] and mom[2] > mom[1] // TDI TDI_GRP_01 = 'Traders Dynamic Index Settings' // Core indicator inputs rsiPeriod = input.int(21, minval = 1, title = "RSI Period", group = TDI_GRP_01) bandLength = input.int(34, minval = 1, title = "Band Length", group = TDI_GRP_01) lengthtradesl = input.int(2, minval = 1, title = "Fast MA on RSI", group = TDI_GRP_01) lengthrsipl = input.int(7, minval = 0, title = "Slow MA on RSI", group = TDI_GRP_01) tdi_src = input.source(close, title = 'TDI Source', group = TDI_GRP_01) r_1 = ta.rsi(tdi_src, rsiPeriod) // RSI of Close ma_1 = ta.sma(r_1, bandLength) // Moving Average of RSI [current] offs_1 = (1.6185 * ta.stdev(r_1, bandLength)) // Offset up_1 = ma_1 + offs_1 // Upper Bands dn_1 = ma_1 - offs_1 // Lower Bands mid_1 = (up_1 + dn_1) / 2 // Average of Upper and Lower Bands slowMA_1 = ta.sma(r_1, lengthrsipl) // Moving Average of RSI 2 bars back fastMA_1 = ta.sma(r_1, lengthtradesl) // Moving Average of RSI 7 bar // Overlay False plots //plot(up_1, title = "Upper Band", color = #1976d2, linewidth = 2) //plot(dn_1, title = "Lower Band", color = #1976d2, linewidth = 2) //plot(mid_1, title = "Middle Band", color = #fbc02d, linewidth = 2) //plot(fastMA_1, title = "Fast MA", color = #388e3c, linewidth = 2) //plot(slowMA_1, title = "Slow MA", color = #b71c1c, linewidth = 2) //hline(20, title = "Extremely Oversold", color = #5d606b ) //hline(30, title = "Highly Oversold", color = #787b86 ) //hline(40, title = "Oversold", color = #b2b5be ) //hline(50, title = "Midline", color = #d1d4dc ) //hline(60, title = "Overbought", color = #b2b5be ) //hline(70, title = "Highly Overbought", color = #787b86 ) //hline(80, title = "Extremely Overbought", color = #5d606b ) bullishmove = fastMA_1 > up_1 and fastMA_1 > 68 bearishmove = fastMA_1 < dn_1 and fastMA_1 < 32 //plotarrow(bullishmove and bullish_momentum ? high : na, colorup = color.lime) plotshape(bullishmove and bullish_momentum ? high : na, style = shape.arrowup, color = color.new(color.lime, 0), size = size.normal, location = location.abovebar) //plotarrow(bearishmove and bearish_momentum ? low : na, colordown = color.new(#FF0000, 0)) plotshape(bearishmove and bearish_momentum ? low : na, style = shape.arrowdown, color = color.new(#FF0000, 0), size = size.normal, location = location.belowbar) //Bearish Reversal Line var line [] reversal_line_bearish_array = array.new_line() var line reversal_line_bearish = na if (bullishmove[1] and bullish_momentum[1]) and not (bullishmove and bullish_momentum) and show_lines reversal_line_bearish := line.new(bar_index, high, bar_index+3, high, color = color.new(color.red, 0), width = 2) array.push(reversal_line_bearish_array, reversal_line_bearish) if array.size(reversal_line_bearish_array) > 10 line.delete(array.shift(reversal_line_bearish_array)) //Bullish Reversal Line var line [] reversal_line_bullish_array = array.new_line() var line reversal_line_bullish = na if (bearishmove[1] and bearish_momentum[1]) and not (bearishmove and bearish_momentum) and show_lines reversal_line_bullish := line.new(bar_index, low, bar_index+3, low, color = color.new(color.lime, 0), width = 2) array.push(reversal_line_bullish_array, reversal_line_bullish) if array.size(reversal_line_bullish_array) > 10 line.delete(array.shift(reversal_line_bullish_array)) //BEGIN Definitions=============================================================================================================// bull_price = high // bullish_break = // bull_price > high[1] // and bull_price > high[2] // and bull_price > high[3] // and bull_price > high[4] // and bull_price > high[5] // and bull_price > high[6] // and bull_price > high[7] // and bull_price > high[8] // and bull_price > high[9] // and bull_price > high[10] // and bull_price > high[11] // and bull_price > high[12] // and bull_price > high[13] // and bull_price > high[14] // and bull_price > high[15] // and bull_price > high[16] // and bull_price > high[17] // and bull_price > high[18] // and bull_price > high[19] // and bull_price > high[20] // and bull_price > high[21] // //and price > high[22] // //and price > high[23] // //and price > high[24] // //and price > high[25] // //and price > high[26] // // // price = close // bearish_break = // price < low[1] // and price < low[2] // and price < low[3] // and price < low[4] // and price < low[5] // and price < low[6] // and price < low[7] // and price < low[8] // and price < low[9] // and price < low[10] // and price < low[11] // and price < low[11] // and price < low[12] // and price < low[13] // and price < low[14] // and price < low[15] // and price < low[16] // and price < low[17] // and price < low[18] // and price < low[19] // and price < low[20] // and price < low[21] // //and price < low[22] // //and price < low[23] // //and price < low[24] // //and price < low[25] // //and price < low[26] // // // bearish_signal = (bearish_break[1] and not bearish_break) // bullish_signal = (bullish_break[1] and not bullish_break) // // // var line bullishline = na // if barstate.isconfirmed and bullish_signal and show_lines and show_expansion_guide_lines //bullish_break // bullishline := line.new( // x1=bar_index[1], // y1=high[1], // x2=bar_index+50, // y2=high[1], // color = color.new(color.red, 0), // extend = extend.none // ) // line.delete(bullishline[1]) // //PLOTSHAPES BEARISH============================================================================================================// // // var line bearishline = na // if barstate.isconfirmed and bearish_signal and show_lines and show_expansion_guide_lines// bearish_break // bearishline := line.new( // bar_index[1], // low[1], // bar_index+50, // low[1], // color = color.new(color.green, 0), // extend = extend.none // ) // line.delete(bearishline[1]) // //END Script====================================================================================================================//
Generalized Smooth Step
https://www.tradingview.com/script/UBnmr6qA-generalized-smooth-step/
tarasenko_
https://www.tradingview.com/u/tarasenko_/
170
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tarasenko_ //@version=5 indicator("Generalized Smooth Step", precision = 2) // Input p = input(36, "Lookback") eq_order = input.int(5, "Order of the equation (1-18)", 0, 18) // Functions // Pascal triangle pascal_triangle(int a, int b) => float result = 1. for i = 0 to b if i != b result *= (a - i) / (i + 1) result // Smoothstep of Nth order equation general_smoothstep(int N, x) => array<string> nums = array.new<string>(0) result = 0. for n = 0 to N result += pascal_triangle(-N - 1, n) * pascal_triangle(2 * N + 1, N - n) * math.pow(x, N + n + 1) result // Calculations h = ta.highest(close, p) l = ta.lowest(close, p) osc = (close - l) / (h - l) smooth_step = general_smoothstep(eq_order, osc) col = smooth_step > 0.5 ? #00FF00 : #FF0000 // Plottings plot(smooth_step, "Smooth Step", col, 1) hline(0.5) barcolor(col) // Alerts alertcondition(col != col[1], "Colour changed!", "Smooth's Step colour change!")
Probabilities Module - The Quant Science
https://www.tradingview.com/script/c59tBqoE-Probabilities-Module-The-Quant-Science/
thequantscience
https://www.tradingview.com/u/thequantscience/
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/ // © thequantscience //@version=5 indicator(title = "Probabilities") // ENTRY AND EXIT CONDITION entry_condition = close > open // Replace with your entry condition TPcondition_exit = close < open // Replace with your take profit condition SLcondition_exit = ta.roc(close, 1) > 0.10 // Replace with your stop loss condition // LOOKBACK PERIOD look = input.int(defval = 30, minval = 0, maxval = 500, title = "Lookback period") // LOGIC Probabilities(lookback) => isActiveLong = false isActiveLong := nz(isActiveLong[1], false) isSellLong = false isSellLong := nz(isSellLong[1], false) int positive_results = 0 int negative_results = 0 float positive_percentage_probabilities = 0 float negative_percentage_probabilities = 0 LONG = not isActiveLong and entry_condition == true CLOSE_LONG_SL = not isSellLong and SLcondition_exit == true CLOSE_LONG_TP = not isSellLong and TPcondition_exit == true for i = 1 to lookback if (LONG[i]) isActiveLong := true isSellLong := false if (CLOSE_LONG_TP[i]) isActiveLong := false isSellLong := true positive_results += 1 if (CLOSE_LONG_SL[i]) isActiveLong := false isSellLong := true negative_results += 1 positive_relative_probabilities = positive_results / lookback negative_relative_probabilities = negative_results / lookback positive_percentage_probabilities := positive_relative_probabilities * 100 negative_percentage_probabilities := negative_relative_probabilities * 100 positive_percentage_probabilities probabilities = Probabilities(look) plot(probabilities, color = color.aqua)
DCF Approximation
https://www.tradingview.com/script/w8nabIYQ-DCF-Approximation/
kulitam
https://www.tradingview.com/u/kulitam/
48
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © kulitam //@version=5 indicator("DCF approximation") // Set the forecast period (in years) and the margin of safety period = 10 margin_of_safety = 0.2 // Get values for stock statistics totalEquity = request.financial(syminfo.tickerid, "TOTAL_EQUITY", "FY") totalDebt = request.financial(syminfo.tickerid, "TOTAL_DEBT", "FY") totalOperExpense = request.financial(syminfo.tickerid, "TOTAL_OPER_EXPENSE", "FY") capitExpenditues = request.financial(syminfo.tickerid, "CAPITAL_EXPENDITURES", "FY") //free_fcf = request.financial(syminfo.tickerid, "FREE_CASH_FLOW", "FQ") // Calculate the WACC using the following formula: // WACC = (Weight of Equity * Cost of Equity + Weight of Debt * Cost of Debt) * (1 - Tax Rate) weight_of_equity = totalEquity cost_of_equity = 0.12 weight_of_debt = 0.4 cost_of_debt = totalDebt tax_rate = 0.3 wacc = (weight_of_equity * cost_of_equity + weight_of_debt * cost_of_debt) * (1 - tax_rate) // Calculate the discount rate by adding the margin of safety to the WACC discount_rate = wacc + margin_of_safety // Calculate the annual free cash flow (FCF) using the following formula: // FCF = (Revenue - Operating Expenses - Capital Expenditures - Taxes) / (1 - Tax Rate) revenue = close * volume operating_expenses = totalOperExpense capital_expenditures = capitExpenditues annual_fcf = (revenue - operating_expenses - capital_expenditures) / (1 - tax_rate) // Calculate the total discounted cash flow (DCF) by summing the discounted annual FCFs dcf = 0.0 for i = 1 to period dcf := dcf + annual_fcf / math.pow((1 + discount_rate), i) // Calculate the current price percentage relative to the DCF price_percent = close / dcf // Plot the DCF on the chart in different colors depending on the value of the current price percentage plot(dcf, "DCF", color=price_percent > 1.10 ? color.green : price_percent < 0.90 ? color.red : color.orange, linewidth=2) //Unused code - Previous versions //
Trend Bands [starlord_xrp]
https://www.tradingview.com/script/xZMgXxXW-Trend-Bands-starlord-xrp/
starlord_xrp
https://www.tradingview.com/u/starlord_xrp/
44
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © starlord_xrp //@version=5 indicator("Trend Bands [starlord_xrp]", overlay = true) ema9 = ta.ema(close, 9) ema10 = ta.ema(close, 10) ema12 = ta.ema(close, 12) ema14 = ta.ema(close, 14) ema16 = ta.ema(close, 16) ema18 = ta.ema(close, 18) ema20 = ta.ema(close, 20) ema22 = ta.ema(close, 22) ema24 = ta.ema(close, 24) ema26 = ta.ema(close, 26) ema28 = ta.ema(close, 28) ema30 = ta.ema(close, 30) color ema9_c = ta.rising(ema9, 1) ? color.green : color.red color ema10_c = ta.rising(ema10, 1) ? color.green : color.red color ema12_c = ta.rising(ema12, 1) ? color.green : color.red color ema14_c = ta.rising(ema14, 1) ? color.green : color.red color ema16_c = ta.rising(ema16, 1) ? color.green : color.red color ema18_c = ta.rising(ema18, 1) ? color.green : color.red color ema20_c = ta.rising(ema20, 1) ? color.green : color.red color ema22_c = ta.rising(ema22, 1) ? color.green : color.red color ema24_c = ta.rising(ema24, 1) ? color.green : color.red color ema26_c = ta.rising(ema26, 1) ? color.green : color.red color ema28_c = ta.rising(ema28, 1) ? color.green : color.red color ema30_c = ta.rising(ema30, 1) ? color.green : color.red plot(ema9, color=ema9_c) plot(ema10, color=ema10_c) plot(ema12, color=ema12_c) plot(ema14, color=ema14_c) plot(ema16, color=ema16_c) plot(ema18, color=ema18_c) plot(ema20, color=ema20_c) plot(ema22, color=ema22_c) plot(ema24, color=ema24_c) plot(ema26, color=ema26_c) plot(ema28, color=ema28_c) plot(ema30, color=ema30_c) int green_count = 0 if ema9_c == color.green green_count += 1 if ema10_c == color.green green_count += 1 if ema12_c == color.green green_count += 1 if ema14_c == color.green green_count += 1 if ema16_c == color.green green_count += 1 if ema18_c == color.green green_count += 1 if ema20_c == color.green green_count += 1 if ema22_c == color.green green_count += 1 if ema24_c == color.green green_count += 1 if ema26_c == color.green green_count += 1 if ema28_c == color.green green_count += 1 if ema30_c == color.green green_count += 1 color bar_color = na //plot (green_count, "green count") if green_count > 5 and green_count < 12 bar_color := color.green else if (green_count == 12) bar_color := color.lime else if green_count == 5 bar_color := color.yellow else if green_count < 5 and green_count > 0 bar_color := color.red else if green_count == 0 bar_color := color.maroon bool short_pullback = na bool long_pullback = na if green_count[1] < 5 and green_count[2] < 5 and ta.crossunder(green_count, 1) short_pullback := true if green_count[1] > 5 and green_count[2] > 5 and ta.crossover(green_count, 11) long_pullback := true ema200 = ta.ema(close, 200) ema200_std_dif_low = ema200+(ema200*0.005) ema200_std_dif_high = ema200-(ema200*0.005) plot(ema200, "ema200", color.silver, 3) plotshape(long_pullback, "Pullback", shape.diamond, location.abovebar, color.teal, 0, "Pullback") plotshape(short_pullback, "Pullback", shape.diamond, location.belowbar, color.teal, 0, "Pullback") barcolor(bar_color)
TableBuilder
https://www.tradingview.com/script/M5bOQFxy/
ironpark
https://www.tradingview.com/u/ironpark/
14
library
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ironpark //@version=5 // @description A helper library to make it simpler to create tables in pinescript library("TableBuilder",overlay = true) export type CellStyle color text_color string text_halign string text_valign int text_size color bgcolor string tooltip string text_font_family export type TableStyle color bgcolor color frame_color int frame_width color border_color int border_width CellStyle default_cell_style export type Cell table ref int column int row export type Row table ref int row array<Cell> cells export type Table table body array<Row> rows export DefaultDarkStyle() => style = TableStyle.new() style.bgcolor := color.rgb(15, 16, 46, 61) style.border_color :=color.rgb(0, 0, 0, 38) style.border_width := 1 style.frame_color :=color.rgb(0, 0, 0, 38) style.frame_width := 3 style // Cell Methods // @function Change the size (width, height) of the table cell. // @returns Cell export method Size(Cell this,int width,int height) => table.cell_set_width(table_id = this.ref,column = this.column, row = this.row,width = width) table.cell_set_height(table_id = this.ref,column = this.column, row = this.row,height = height) this // @function Change the width of the table cell. // @returns Cell export method Width(Cell this,int width) => table.cell_set_width(table_id = this.ref,column = this.column, row = this.row,width = width) this // @function Change the height of the table cell. // @returns Cell export method Height(Cell this,int height) => table.cell_set_height(table_id = this.ref,column = this.column, row = this.row,height = height) this // @function Change the text of the table cell. // @returns Cell export method Text(Cell this,string text_) => table.cell_set_text(table_id = this.ref,column = this.column,row = this.row,text = text_) this // @function Change the text size of the table cell. // @returns Cell export method TextSize(Cell this,string text_size) => table.cell_set_text_size(table_id = this.ref,column = this.column,row = this.row,text_size = text_size) this // @function Change the text color of the table cell. // @returns Cell export method TextColor(Cell this,color c) => table.cell_set_text_color(table_id = this.ref,column = this.column,row = this.row,text_color = c) this // @function Change the background color of the table cell. // @returns Cell export method Bg(Cell this,color c) => table.cell_set_bgcolor(table_id = this.ref,column = this.column,row = this.row,bgcolor = c) this // @function Change the font family of the table cell. // @returns Cell export method Font(Cell this,string text_font_family) => table.cell_set_text_font_family(this.ref,this.column,this.row,text_font_family) this // @function Change the horizontal align of the table cell. // @returns Cell export method AlignH(Cell this,string halign) => table.cell_set_text_halign(this.ref,this.column,this.row,halign) this // @function Change the vertical align of the table cell. // @returns Cell export method AlignV(Cell this,string valign) => table.cell_set_text_valign(this.ref,this.column,this.row,valign) this // === Row Methods === // @function Get the cell corresponding to the column number // @param column // @returns Cell export method C(Row this,int column) => this.cells.get(column) // @function Set text // @param c0 ... c29 // @returns Row export method Text(Row this,string c0=na,string c1=na,string c3=na,string c4=na,string c5=na,string c6=na,string c7=na,string c8=na,string c9=na,string c10=na,string c11=na,string c12=na,string c13=na,string c14=na,string c15=na,string c16=na,string c17=na,string c18=na,string c19=na,string c20=na,string c21=na,string c22=na,string c23=na,string c24=na,string c25=na,string c26=na,string c27=na,string c28=na,string c29=na) => args = array.from(c0,c1,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29) for c = 0 to math.min(args.size(),this.cells.size())-1 by 1 this.C(c).Text(args.get(c)) this // @function Change the horizontal align of all cells in that row // @returns Cell export method AlignH(Row this,string halign) => for c = 0 to this.cells.size()-1 by 1 table.cell_set_text_halign(this.ref,c,this.row,halign) this // @function Change the vertical of all cells in that row // @returns Cell export method AlignV(Row this,string valign) => for c = 0 to this.cells.size()-1 by 1 table.cell_set_text_valign(this.ref,c,this.row,valign) this // @function Change the width of all cells in that row // @returns Row export method Font(Row this,string text_font_family) => for c = 0 to this.cells.size()-1 by 1 this.C(c).Font(text_font_family) this // @function Change the width of all cells in that row // @returns Row export method Size(Row this,int width,int height) => for c = 0 to this.cells.size()-1 by 1 this.C(c).Size(width,height) this // @function Change the width of all cells in that row // @returns Row export method Width(Row this,int width) => for c = 0 to this.cells.size()-1 by 1 this.C(c).Width(width) this // @function Change the height of all cells in that row // @returns Row export method Height(Row this,int height) => for c = 0 to this.cells.size()-1 by 1 this.C(c).Height(height) this // @function Change the text color of all cells in that row // @returns Row export method TextColor(Row this,color text_color) => for c = 0 to this.cells.size()-1 by 1 this.C(c).TextColor(text_color) this // @function Set text size // @returns Row export method TextSize(Row this,string text_size) => for c = 0 to this.cells.size()-1 by 1 this.C(c).TextSize(text_size) this // @function Change the background color of all cells in that row // @returns Row export method Bg(Row this,color bg) => for c = 0 to this.cells.size()-1 by 1 this.C(c).Bg(bg) this // === Table Methods === export method C(Table this,int column,int row)=> this.rows.get(row).C(column) export method R(Table this,int row)=> this.rows.get(row) export method Style(Table this,TableStyle style)=> table.set_bgcolor(this.body,style.bgcolor) table.set_border_color(this.body,style.border_color) table.set_frame_color(this.body,style.frame_color) table.set_frame_width(this.body,style.frame_width) table.set_border_width(this.body,style.border_width) this export method Position(Table this,string position)=> table.set_position(this.body,position) this export new(string position,int columns,int rows,TableStyle style = na)=> body = table.new(position,columns,rows) _rows = array.new<Row>(rows) for r = 0 to rows-1 by 1 _columns = array.new<Cell>(columns) for c = 0 to columns-1 by 1 _columns.set(c,Cell.new(body,c,r)) _rows.set(r,Row.new(body,r,_columns)) tb = Table.new(body,_rows) tb.Style(na(style) ? DefaultDarkStyle() : style) tb // Example Code var tbb = new(position.middle_center,3,5) if barstate.isconfirmed header = tbb.R(0).TextColor(color.red).TextSize(size.large).Font(font.family_monospace) header.Text("Header 0","Header 2","Header 3") tbb.R(1).TextColor(color.white).TextSize(size.normal).Text("A","B","C").Bg(color.rgb(255, 255, 255, 74)) tbb.R(2).TextColor(color.white).TextSize(size.normal).Text("A","B","C") tbb.R(3).TextColor(color.white).TextSize(size.normal).Text("A","B","C").Bg(color.rgb(255, 255, 255, 74)) tbb.R(4).TextColor(color.white).TextSize(size.normal).Text("A","B","C")
Feature Scaling
https://www.tradingview.com/script/t46PW12i-Feature-Scaling/
serkany88
https://www.tradingview.com/u/serkany88/
10
library
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © serkany88 //@version=5 // @description FS: This library helps you scale your data to certain ranges or standarize, normalize, unit scale or min-max scale your data in your prefered way. Mostly used for normalization purposes. library("Feature_Scaling") // @function minmaxscale Min-max normalization scales your data to set minimum and maximum range // @param source Source data you want to use // @param min Minimum value you want // @param max Maximum value you want // @param length Length of the data you want taken into account // @returns res Data scaled to the set minimum and maximum range export minmaxscale(float source, float min, float max, int length) => lowest = ta.lowest(source, length) highest = ta.highest(source, length) res = min + (source - lowest) * (max - min) / (highest - lowest) res // @function meanscale Mean normalization of your data // @param source Source data you want to use // @param length Length of the data you want taken into account // @returns res Mean normalization result of the source export meanscale(float source, int length) => lowest = ta.lowest(source, length) highest = ta.highest(source, length) mean = ta.sma(source, length) res = (source - mean) / (highest - lowest) res // @function standarize Standarization of your data // @param source Source data you want to use // @param length Length of the data you want taken into account // @param biased Whether to do biased calculation while taking standard deviation, default is true // @returns res Standarized data export standarize(float source, int length, bool biased = true) => mean = ta.sma(source, length) stdev = ta.stdev(source, length, biased) res = (source - mean) / stdev res // @function unitlength Scales your data into overall unit length // @param source Source data you want to use // @param length Length of the data you want taken into account // @returns res Your data scaled to the unit length export unitlength(float source, int length) => lowest = ta.lowest(source, length) highest = ta.highest(source, length) res = source / (highest - lowest) res
Multiple Divergences (UDTs - objects) - Educational
https://www.tradingview.com/script/ZlN4Hjz9-Multiple-Divergences-UDTs-objects-Educational/
fikira
https://www.tradingview.com/u/fikira/
335
study
5
MPL-2.0
fi(ki)=>'ra' // ©fikira - This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 indicator('Multiple Divergences (UDTs - objects)' , max_lines_count=500, max_labels_count=500, overlay=true) // max_bars_back=2000, // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ input's ]–––––––––––––––––––––––––––––––––––––––––––––––––––––– int left = input.int ( 3, 'left' , minval= 1, maxval= 100) int right = input.int ( 1, 'right' , minval= 1, maxval= 100) int mx = input.int ( 750, 'max values', minval=100, maxval=2000) bool trsi = input.bool ( true, '' , inline='1', group='Oscillators (+ length)') int l_rsi = input.int ( 14, 'RSI' , minval= 1, maxval= 100, inline='1', group='Oscillators (+ length)') color bl1 = input.color (color.lime , '' , inline='1', group='Oscillators (+ length)') color br1 = input.color (#FF0000 , '' , inline='1', group='Oscillators (+ length)') bool tCci = input.bool ( true, '' , inline='2', group='Oscillators (+ length)') int l_cci = input.int ( 14, 'CCI' , minval= 1, maxval= 100, inline='2', group='Oscillators (+ length)') color bl2 = input.color (color.olive , '' , inline='2', group='Oscillators (+ length)') color br2 = input.color (color.red , '' , inline='2', group='Oscillators (+ length)') bool tMfi = input.bool ( true, '' , inline='3', group='Oscillators (+ length)') int l_mfi = input.int ( 14, 'MFI' , minval= 1, maxval= 100, inline='3', group='Oscillators (+ length)') color bl3 = input.color (color.yellow, '' , inline='3', group='Oscillators (+ length)') color br3 = input.color (color.orange, '' , inline='3', group='Oscillators (+ length)') // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ UDT's ]–––––––––––––––––––––––––––––––––––––––––––––––––––––– // @type An object of highs and lows // @field b bar_index - right // @field h high[right] // @field l low [right] // @field isPh is Pivot High // @field isPl is Pivot Low type HLs int b = na float h = na float l = na bool isPh = false bool isPl = false // @type An object of oscillator values // @field b bar_index - right // @field o oscillator[right] // @field isPh is Pivot High // @field isPl is Pivot Low type Osc int b = na float o = na bool isPh = false bool isPl = false // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ array's ]–––––––––––––––––––––––––––––––––––––––––––––––––––––– var HLs[] aHLs = array.new <HLs>() var Osc[] aRSI = array.new <Osc>() var Osc[] aCCI = array.new <Osc>() var Osc[] aMFI = array.new <Osc>() var line[] aLn = array.new <line>() // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ data ]–––––––––––––––––––––––––––––––––––––––––––––––––––––– int sz = array.size ( aHLs ) int ls = array.size ( aLn ) float hi = nz(high [right]) float lo = nz(low [right]) int bx = nz(bar_index - right ) // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ functions ]–––––––––––––––––––––––––––––––––––––––––––––––––––––– // @function Fills Oscillator array aOsc(series bool osc_ph, series bool osc_pl, series float osc, Osc[] aOsc) => max_bars_back(osc, 2000) os = nz(osc [right]) switch osc_ph => get = Osc.new(bx, os, true , false), array.unshift(aOsc, get) osc_pl => get = Osc.new(bx, os, false, true ), array.unshift(aOsc, get) => get = Osc.new(bx, os, false, false), array.unshift(aOsc, get) // @function Checks for Regular Divergence (high/low) Reg_Div_Piv(series HLs getZ, series string BlBr) => // - - - - - // getZ = current Pivot point max_bars_back(time, 2000) // prevents "Pine cannot determine the referencing length of a series. Try using max_bars_back ..." error bull = BlBr == 'bl' // - - - - - - - - - - - - - // bullish/bearish divergence check = false // checks for a non-pierced DIV line int x1 = na, float y1 = na, int x2 = na, float y2 = na // if sz > right // - - - - - - - - - - - - - // if enough data in array //-{ // for i = 0 to sz - right // getA = array.get(aHLs, i) // - - - - - // getA = point in history if (bull ? getA.isPl : getA.isPh) // if getA is a Pivot point _x1 = getA.b, _y1 = (bull ? getA.l : getA.h) // collect data _x2 = getZ.b, _y2 = (bull ? getZ.l : getZ.h) // if (bull ? _y2 < _y1 : _y2 > _y1) // - - - - - // if condition for DIV is true testline = line.new(_x1, _y1, _x2, _y2) // create testline bix = bar_index - _x1 // //-{ // for j = right to bix // - - - - - // check if high/low pierces testline in between getY = array.get(aHLs, j) // if (bull ? getY.l < line.get_price(testline, getY.b) : // getY.h > line.get_price(testline, getY.b) ) // break // - - - - - - - - - - // if pierced -> break, check remains false if j == bix // if at end of loop check := true // - - - - - // else -> collect data for output x1 := getA.b, y1 := (bull ? getA.l : getA.h) // x2 := getZ.b, y2 := (bull ? getZ.l : getZ.h) // // }- // line.delete(testline) // - - - - - // deleted testline // }- // [check, x1, y1, x2, y2]// - - - - - - - - - - - - - // output // @function Checks for Regular Divergence (oscillator) Reg_Div_Osc(Osc[] aOsc, series int pv_x1, series int pv_x2, series string BlBr) => // aOsc = array of oscillator values max_bars_back(time, 2000) // prevents "Pine cannot determine the referencing length of a series. Try using max_bars_back ..." error bull = BlBr == 'bl' // - - - - - - - - - - - - - // bullish/bearish divergence check = false // checks for a non-pierced DIV line int x1 = na, float y1 = na, int x2 = na, float y2 = na // if sz > right and array.size(aOsc) > 0 // - - - - - // if enough data in array getZ = array.get (aOsc , 0) // get current oscillator data //-{ // for i = 0 to sz - right // getA = array.get(aOsc , i) // - - - - - // getA = point in history _x1 = getA.b, _y1 = getA.o, _x2 = getZ.b, _y2 = getZ.o // isPiv = (bull ? getA.isPl : getA.isPh) // if getA is a Pivot point if isPiv and math.abs(pv_x1 - _x1) < 3 and math.abs(pv_x2 - _x2) < 3 // if Piv high/low is not too far from Piv Oscillator if (bull ? _y2 > _y1 : _y2 < _y1) // - - - - - // if condition for DIV is true testline = line.new(_x1, _y1, _x2, _y2) // create testline bix = bar_index - _x1 // //-{ // for j = right to bix // - - - - - // check if oscillator pierces testline in between getY = array.get(aOsc, j) // if (bull ? getY.o < line.get_price(testline, getY.b) : // getY.o > line.get_price(testline, getY.b) ) // break // - - - - - - - - - - // if pierced -> break, check remains false if j == bix // if at end of loop check := true // - - - - - // else -> collect data for output x1 := getA.b, y1 := getA.o // x2 := getZ.b, y2 := getZ.o // // }- // line.delete(testline) // - - - - - // deleted testline // }- // [check, x1, y1, x2, y2]// - - - - - - - - - - - - - // output // @function Draws a line when divergence is spotted draw(series string BlBr, series bool toggle, Osc[] aOsc, series int x1, series float y1, series int x2, series float y2, series color col) => int check = 0 bool bull = BlBr == 'bl' if toggle [ch_osc, x1_o, y1_o, x2_o, y2_o] = Reg_Div_Osc(aOsc, x1, x2, bull ? 'bl' : 'br') if ch_osc check := 1 array.unshift(aLn, line.new(x1, y1, x2, y2, color=col, width=1)) check // @function Cleans array when full pop(arr) => if array.size(arr) > mx array.pop(arr) // @function Lines are dotted when unconfirmed DIV, solid if confirmed setLine(series int n) => line ln = ls > n ? array.get(aLn, n) : na line.set_style(ln, bar_index - line.get_x2(ln) <= right ? line.style_dotted : line.style_solid ) // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ Action ]–––––––––––––––––––––––––––––––––––––––––––––––––––––– // calculate values -{ float rsi = ta.rsi (close , l_rsi) float cci = ta.cci (close , l_cci) float mfi = ta.mfi (close , l_mfi) ph = ta.pivothigh( left, right) pl = ta.pivotlow ( left, right) rsi_ph = ta.pivothigh(rsi , left, right) rsi_pl = ta.pivotlow (rsi , left, right) cci_ph = ta.pivothigh(cci , left, right) cci_pl = ta.pivotlow (cci , left, right) mfi_ph = ta.pivothigh(mfi , left, right) mfi_pl = ta.pivotlow (mfi , left, right) // } // add object (Osc.new) to array -{ if trsi aOsc(rsi_ph, rsi_pl, rsi, aRSI) if tCci aOsc(cci_ph, cci_pl, cci, aCCI) if tMfi aOsc(mfi_ph, mfi_pl, mfi, aMFI) // } // add object (HLs.new) to array -{ switch // ph => getZ = HLs.new(bx, hi, lo, true , false), array.unshift(aHLs, getZ) [check, x1, y1, x2, y2] = Reg_Div_Piv(getZ, 'br') if check check1 = draw('br', trsi, aRSI, x1, y1, x2, y2, br1) check2 = draw('br', tCci, aCCI, x1, y1, x2, y2, br2) check3 = draw('br', tMfi, aMFI, x1, y1, x2, y2, br3) total = check1 + check2 + check3 if total > 0 label.new( bx, hi, style=label.style_label_down, text=str.tostring(total), color=color.new(#FF0000, 90), textcolor=#FF0000 ) // pl => getZ = HLs.new(bx, hi, lo, false, true ), array.unshift(aHLs, getZ) [check, x1, y1, x2, y2] = Reg_Div_Piv(getZ, 'bl') if check check1 = draw('bl', trsi, aRSI, x1, y1, x2, y2, bl1) check2 = draw('bl', tCci, aCCI, x1, y1, x2, y2, bl2) check3 = draw('bl', tMfi, aMFI, x1, y1, x2, y2, bl3) total = check1 + check2 + check3 if total > 0 label.new( bx, lo, style=label.style_label_up , text=str.tostring(total), color=color.new(#00FF00, 90), textcolor=#00FF00 ) // => array.unshift(aHLs, HLs.new(bx, hi, lo, false, false)) // } // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ ––––––––– ]–––––––––––––––––––––––––––––––––––––––––––––––––––––– // clean array's pop(aHLs), pop(aRSI), pop(aCCI), pop(aMFI) // clean line array if ls > 500 line.delete(array.pop(aLn)) // set line style setLine(0), setLine(1), setLine(2) // ––––––––––––––––––––––––––––––––––––––––––––––––––––––[ ––––––––– ]––––––––––––––––––––––––––––––––––––––––––––––––––––––
Average Deviation Bands (ADB)
https://www.tradingview.com/script/kM30wWVS-Average-Deviation-Bands-ADB/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
30
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © peacefulLizard50262 //@version=5 indicator("Average Deviation Bands", overlay = true) dev = input.int(20, "Length") x1 = input.bool(true, "Band 1", inline = "x1") x2 = input.bool(false, "Band 2", inline = "x2") x3 = input.bool(false, "Band 3", inline = "x3") xn = input.bool(false, "Band 4", inline = "x4") l1 = input.float(1 , "", 0, 100, 0.25, inline = "x1") l2 = input.float(2 , "", 0, 100, 0.25, inline = "x2") l3 = input.float(3 , "", 0, 100, 0.25, inline = "x3") l4 = input.float(4 , "", 0, 100, 0.25, inline = "x4") deviation = ta.stdev(close, dev) average = ta.sma(close, dev) var float average_deviation_sum = na var int average_deviation_counter = na if close == close average_deviation_counter := nz(average_deviation_counter[1]) + 1 average_deviation_sum := nz(average_deviation_sum[1]) + deviation average_deviation = average_deviation_sum/average_deviation_counter center = plot(average, "Average", color.orange) x1_top = plot(x1 ? average + average_deviation * l1 : na, "x1 Top", #163adb) x1_bot = plot(x1 ? average - average_deviation * l1 : na, "x1 Bot", #163adb) x2_top = plot(x2 ? average + average_deviation * l2 : na, "x2 Top", #2342cc) x2_bot = plot(x2 ? average - average_deviation * l2 : na, "x2 Bot", #2342cc) x3_top = plot(x3 ? average + average_deviation * l3 : na, "x3 Top", #2e46af) x3_bot = plot(x3 ? average - average_deviation * l3 : na, "x3 Bot", #2e46af) xn_top = plot(xn ? average + average_deviation * l4 : na, "x3 Top", #5b2eaf) xn_bot = plot(xn ? average - average_deviation * l4 : na, "x3 Bot", #5b2eaf) fill(x1_top, x1_bot, color.new(#163adb, 95)) fill(x2_top, x2_bot, color.new(#2342cc, 95)) fill(x3_top, x3_bot, color.new(#2e46af, 95)) fill(xn_top, xn_bot, color.new(#5b2eaf, 95))
Stockbee Momentum Burst
https://www.tradingview.com/script/6h74IRYK-Stockbee-Momentum-Burst/
shaaah10
https://www.tradingview.com/u/shaaah10/
248
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © shaaah10 //@version=5 indicator(title="Stockbee", overlay=true) // INPUT var string GP1 = 'MOMENTUM BURST' input_bull = input.bool(defval=true, title="Bullish", group = GP1) input_bear = input.bool(defval=true, title="Bearish", group = GP1) var string GP2 = 'THRESHOLD' input_percent = input.bool(defval=true, title="Percent", group = GP2) input_dollar = input.bool(defval=true, title="Dollar", group = GP2) var string GP3 = 'MOMENTUM FILTER' input_momentum_bull = input.bool(defval=false, title="EMA 10 > 20", group = GP3) input_momentum_bear = input.bool(defval=false, title="EMA 10 < 20", group = GP3) input_momentum_divide = input.bool(defval=false, title="Linked", tooltip = "This will override all other momentum filters, bullish candles will be displayed when EMA 10 > 20 and bearish candles when EMA 10 < 20", group = GP3) var string gp4 = "REVERSAL" input_bull_r = input.bool(defval = true, title="Bullish", group = gp4) input_bear_r = input.bool(defval = true, title="Bearish", group = gp4) input_remove = input.bool(defval = false, title="Remove P/V", tooltip = "Check to remove the price and volume requirement", group = gp4) label_size = input.string("auto", "Label Size", options = ["huge", "large", "normal", "small", "tiny", "auto"], group = gp4) // BULLISH bullish_pt = (close/close[1]>=1.04) and (close>open) and ((close-open)>=(close[1]-open[1])) and (close>close[1]) and (volume>=100000) and (volume>volume[1]) bullish_db = (close-open>=0.9) and (close>open) and ((close-open)>=(close[1]-open[1])) and (close>close[1]) and (volume>=100000) bullish_hod = (close-low)/(high-low)>=0.7 bullish_linear = close[1]/close[2]<=1.02 bull_percent = bullish_pt and bullish_hod and bullish_linear bull_dollar = bullish_db and bullish_hod and bullish_linear // BEARISH bearish_pt = (close/close[1]<=0.96) and (close<open) and (close<close[1]) and (volume>=100000) and (volume>volume[1]) bearish_db = (open-close>=0.9) and (close<open) and (close<close[1]) and (volume>=100000) bearish_re = math.abs(open-close) >= math.abs(open[1]-close[1]) bearish_lod = (close-low)/(high-low)<=0.3 bearish_linear = close[1]/close[2]>=0.98 volume_length = ta.lowest(volume, 3) min_volume = volume_length >= 100000 bear_percent = bearish_pt and bearish_linear and min_volume and bearish_re and bearish_lod bear_dollar = bearish_db and bearish_linear and min_volume and bearish_re and bearish_lod //BULLISH l_minl5 = low == ta.lowest(low, 5) ol_co = (open-low) > (close-open) cl_hl = ((close-low)/(high-low)) >= 0.6 vol = volume >= 900000 price = close >= 10 volume_length_r = ta.lowest(volume, 3) vol_avg = volume_length >= 1000000 bullish_reversal = l_minl5 and ol_co and cl_hl and vol and price and vol_avg bullish_reversal_bypass = l_minl5 and ol_co and cl_hl //BEARISH bear_vol = volume >= 1000000 bear_price = close >= 10 bear_volavg = volume_length_r >= 1000000 bear_change = (close[0]/close[1]) > 0.99 bear_clhl = ((close-low)/(high-low)) <= 0.8 bear_rsi = ta.rsi(close, 3) >= 80 bearish_reversal = bear_vol and bear_price and bear_volavg and bear_change and bear_clhl and bear_rsi bearish_reversal_bypass = bear_change and bear_clhl and bear_rsi // MOMENTUM FILTER bull_momentum = ta.ema(close, 10) > ta.ema(close, 20) bear_momentum = ta.ema(close, 10) < ta.ema(close, 20) // COLOR BAR color_percent = bull_percent ? color.rgb(27, 94 ,32) : bear_percent ? color.rgb(178, 40, 51) : na color_dollar = bull_dollar ? color.green : bear_dollar ? color.red : na color_neutral = close > open ? color.rgb(200, 230, 201, 30) : close < open ? color.rgb(252, 203, 205, 30) : na color_bar = if ((input_bull and input_percent and bull_percent) or (input_bear and input_percent and bear_percent) == true) color_percent else if ((input_bull and input_dollar and bull_dollar) or (input_bear and input_dollar and bear_dollar) == true) color_dollar else color_neutral // COLOR FILTER color_momentum_combo = bull_momentum or bear_momentum ? color_bar : color_neutral color_momentum_bull = bull_momentum ? color_bar : color_neutral color_momentum_bear = bear_momentum ? color_bar : color_neutral color_momentum_divide = bull_momentum and input_bull and ((input_percent and bull_percent) or (input_dollar and bull_dollar)) ? color_bar : bear_momentum and input_bear and ((input_bear and bear_percent) or (input_bear and bear_dollar)) ? color_bar : color_neutral print_color = if (input_momentum_divide == true) color_momentum_divide else if (input_momentum_bull and input_momentum_bear == true) color_momentum_combo else if (input_momentum_bull == true) color_momentum_bull else if (input_momentum_bear == true) color_momentum_bear else color_bar // PLOT MOMENTUM BURST barcolor(print_color) // PLOT REVERSAL if ((input_bull_r and bullish_reversal == true) and (input_remove == false)) label_bull = label.new(bar_index[0], high, style=label.style_triangleup, size=label_size), label.set_yloc(label_bull, yloc.belowbar), label.set_color(label_bull, color.green), label.set_tooltip(label_bull, "Bullish Reversal") if ((input_bear_r and bearish_reversal == true) and (input_remove == false)) label_bear = label.new(bar_index[0], high, style=label.style_triangledown, size=label_size), label.set_yloc(label_bear, yloc.abovebar), label.set_color(label_bear, color.red), label.set_tooltip(label_bear, "Bearish Reversal") if (input_bull_r and bullish_reversal_bypass and input_remove) label_bull_bypass = label.new(bar_index[0], high, style=label.style_triangleup, size=label_size), label.set_yloc(label_bull_bypass, yloc.belowbar), label.set_color(label_bull_bypass, color.green), label.set_tooltip(label_bull_bypass, "Bullish Reversal") if (input_bear_r and bearish_reversal_bypass and input_remove) label_bear_bypass = label.new(bar_index[0], high, style=label.style_triangledown, size=label_size), label.set_yloc(label_bear_bypass, yloc.abovebar), label.set_color(label_bear_bypass, color.red), label.set_tooltip(label_bear_bypass, "Bearish Reversal")
Wicks percentages
https://www.tradingview.com/script/gKvWyt9i/
angelreyesm
https://www.tradingview.com/u/angelreyesm/
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/ // © angelreyesm //@version=5 indicator("Wicks percentages", overlay = true) // Definimos las variables necesarias para calcular el porcentaje de la mecha superior y la mecha inferior upperWick = high - math.max(open, close) lowerWick = math.min(open, close) - low // Calculamos el porcentaje de la mecha superior y la mecha inferior upperWickPercentage = (upperWick / (high - low)) * 100 lowerWickPercentage = (lowerWick / (high - low)) * 100 // Redondiamos los valores hacia abajo upperWickPercentage1 = math.floor(upperWickPercentage) lowerWickPercentage1 = math.floor(lowerWickPercentage) // Mostramos los valores en la ventana de información de cada vela label.new(bar_index, high,str.tostring(upperWickPercentage1), color = color.white) label.new(bar_index, low, str.tostring(lowerWickPercentage1), yloc = yloc.belowbar, color = color.white)
Orb breakout
https://www.tradingview.com/script/MwxMQzFR-Orb-breakout/
Shauryam_or
https://www.tradingview.com/u/Shauryam_or/
570
study
5
MPL-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) buy_cond=ta.crossover(close[2],s_high) and high[1]>high[2] and high>high[1] sell_cond=ta.crossunder(close[2],s_low) and low[1]<low[2] and low<low[1] plotshape(buy_cond,title = "Buy",style = shape.labelup,location = location.belowbar,color = color.green,text = "Buy",textcolor =color.white) plotshape(sell_cond,title = "Sell",style = shape.labeldown,location = location.abovebar,color = color.red,text = "Sell",textcolor =color.white) alertcondition(buy_cond,title = "Buy",message ="Buy Signal Formed") alertcondition(sell_cond,title = "Sell",message ="Sell Signal Formed")
Average Range @coldbrewrosh
https://www.tradingview.com/script/d1bNjbFy-Average-Range-coldbrewrosh/
coldbrewrosh
https://www.tradingview.com/u/coldbrewrosh/
138
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © coldbrewrosh //@version=5 indicator(title="Average Range @coldbrewrosh", overlay=true, max_bars_back = 1000) Bool_5D = input(true, "5 Day AR", group="AR") Bool_1M = input(true, "1 Month AR", group="AR") Bool_3M = input(true, "3 Month AR", group = "AR") Bool_1Y = input(true, "1 Year AR", group = "AR") Bool_5D_Opp = input(true, "5 Day Opposite Move AR", group="Opposite AR") Bool_1M_Opp = input(true, "1 Month Opposite Move AR", group="Opposite AR") Bool_3M_Opp = input(true, "3 Month Opposite Move AR", group="Opposite AR") Bool_1Y_Opp = input(true, "1 Year Opposite Move AR", group="Opposite AR") DHigh = request.security(syminfo.tickerid, 'D', high) DLow = request.security(syminfo.tickerid, 'D', low) DOpen = request.security(syminfo.tickerid, 'D', open) DClose = request.security(syminfo.tickerid, 'D', close) // Function to convert forex pips into whole numbers atr = ta.atr(14) toWhole(number) => if syminfo.type == "forex" // This method only works on forex pairs _return = atr < 1.0 ? (number / syminfo.mintick) / 10 : number _return := atr >= 1.0 and atr < 100.0 and syminfo.currency == "JPY" ? _return * 100 : _return else number BullATR(period)=> j = 0 BullATR = 0.0 BullATRCount = 0 for i = 1 to 365 if DOpen[j] < DClose[j] BullATR := BullATR + ( DHigh[j] - DOpen[j] ) BullATRCount := BullATRCount + 1 if BullATRCount == period break j := j + 1 j := 0 _return = math.round(toWhole(BullATR / period), 2) BearATR(period)=> j = 0 BearATR = 0.0 BearATRCount = 0 for i = 1 to 365 if DOpen[j] > DClose[j] BearATR := BearATR + ( DOpen[j] - DLow[j] ) BearATRCount := BearATRCount + 1 if BearATRCount == period break j := j + 1 j := 0 _return = math.round(toWhole(BearATR / period), 2) BullOpp(period)=> j = 0 BullATR = 0.0 BullATRCount = 0 for i = 1 to 365 if DOpen[j] < DClose[j] BullATR := BullATR + ( DOpen[j] - DLow[j] ) BullATRCount := BullATRCount + 1 if BullATRCount == period break j := j + 1 j := 0 _return = math.round(toWhole(BullATR / period), 2) BearOpp(period)=> j = 0 BearATR = 0.0 BearATRCount = 0 for i = 1 to 365 if DOpen[j] > DClose[j] BearATR := BearATR + ( DHigh[j] - DOpen[j] ) BearATRCount := BearATRCount + 1 if BearATRCount == period break j := j + 1 j := 0 _return = math.round(toWhole(BearATR / period), 2) BullTR5 = BullATR(5) BearTR5 = BearATR(5) BullTR20 = BullATR(20) BearTR20 = BearATR(20) BullTR60 = BullATR(60) BearTR60 = BearATR(60) BullTR240 = BullATR(240) BearTR240 = BearATR(240) BullOR5 = BullOpp(5) BearOR5 = BearOpp(5) BullOR20 = BullOpp(20) BearOR20 = BearOpp(20) BullOR60 = BullOpp(60) BearOR60 = BearOpp(60) BullOR240 = BullOpp(240) BearOR240 = BearOpp(240) var table ATR = table.new(position.top_right, columns = 2, rows = 8, border_width=1) if barstate.islast if Bool_5D == true table.cell(ATR, column = 0, row = 0, text=str.tostring("Bullish 5 Day Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 0, text=(str.tostring(BullTR5) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(ATR, column = 0, row = 1, text=str.tostring("Bearish 5 Day Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 1, text=(str.tostring(BearTR5) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) if Bool_1M == true table.cell(ATR, column = 0, row = 2, text=str.tostring("Bullish 1M Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 2, text=(str.tostring(BullTR20) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(ATR, column = 0, row = 3, text=str.tostring("Bearish 1M Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 3, text=(str.tostring(BearTR20) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) if Bool_3M == true table.cell(ATR, column = 0, row = 4, text=str.tostring("Bullish 3M Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 4, text=(str.tostring(BullTR60) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(ATR, column = 0, row = 5, text=str.tostring("Bearish 3M Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 5, text=(str.tostring(BearTR60) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) if Bool_1Y == true table.cell(ATR, column = 0, row = 6, text=str.tostring("Bullish 1Y Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 6, text=(str.tostring(BullTR240) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(ATR, column = 0, row = 7, text=str.tostring("Bearish 1Y Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(ATR, column = 1, row = 7, text=(str.tostring(BearTR240) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) var table OPPR = table.new(position.bottom_right, columns = 2, rows = 8, border_width=1) if barstate.islast if Bool_5D_Opp == true table.cell(OPPR, column = 0, row = 0, text=str.tostring("Bullish 5 Day Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 0, text=(str.tostring(BullOR5) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(OPPR, column = 0, row = 1, text=str.tostring("Bearish 5 Day Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 1, text=(" " + str.tostring(BearOR5) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) if Bool_1M_Opp == true table.cell(OPPR, column = 0, row = 2, text=str.tostring("Bullish 1M Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 2, text=(str.tostring(BullOR20) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(OPPR, column = 0, row = 3, text=str.tostring("Bearish 1M Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 3, text=(str.tostring(BearOR20) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) if Bool_3M_Opp == true table.cell(OPPR, column = 0, row = 4, text=str.tostring("Bullish 3M Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 4, text=(str.tostring(BullOR60) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(OPPR, column = 0, row = 5, text=str.tostring("Bearish 3M Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 5, text=(str.tostring(BearOR60) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) if Bool_1Y_Opp == true table.cell(OPPR, column = 0, row = 6, text=str.tostring("Bullish 1Y Open to Low ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 6, text=(str.tostring(BullOR240) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto) table.cell(OPPR, column = 0, row = 7, text=str.tostring("Bearish 1Y Open to High ") , bgcolor=color.black, text_color=color.white, text_halign=text.align_left, text_size=size.auto) table.cell(OPPR, column = 1, row = 7, text=(str.tostring(BearOR240) + " pips") , bgcolor=color.black, text_color=color.white, text_halign=text.align_right, text_size=size.auto)
1st Gray Cross Signals ━ Histogram SQZMOM [whvntr][LazyBear]
https://www.tradingview.com/script/v0iyvSsj-1st-Gray-Cross-Signals-Histogram-SQZMOM-whvntr-LazyBear/
whvntr
https://www.tradingview.com/u/whvntr/
315
study
5
MPL-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 // ─© whvntr (Tyler Ray) indicator(title='1st Gray Cross Signals ━ Histogram SQZMOM [whvntr][LazyBear]', shorttitle='SQZMOM_whvntr' , overlay = false, scale = scale.right) // With all due credit @ user LazyBear & John F. Carter's book: Chapter 11 of "Mastering the Trade". // LazyBear wrote: "Mr.Carter suggests waiting till the first gray after a black cross, // ✓ and taking a position in the direction of the momentum (for ex., if momentum value // is above zero, go long). Exit the position when the momentum changes // (increase or decrease --- signified by a color change)." // I have done just that. Now at each "first gray after a black cross", there are now Bearish and // Bullish highights.. The highlights only appear in the direction of the momentum. color INVS = #00000000 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ℹ️ Multiple Sources ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% changeSource = input.source(title='ℹ️' , defval = close , group = "Alternate Source") //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 🗓️ Timeframe ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% keepFrame = true keepFrameFor = keepFrame ? timeframe.period : timeframe.period //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ╍╍ Lengths ─ LazyBear © //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% length = input(20 , title ='┅', group = 'Bollinger Bands Length' , tooltip = 'Bollinger Bands consist of a middle band (which is a moving average) and an upper and lower band. These upper and lower bands are set above and below the moving average by a certain number of standard deviations of price, thus incorporating volatility') mult = input(2.0 , title = '×', group = 'Bollinger Bands MultFactor') lengthKC = input(20 , title = '┅', group = 'Keltner Channel Length' , tooltip = "Keltner Channels are volatility-based bands that are placed on either side of an asset's price and can aid in determining the direction of a trend. The Keltner channel uses the average-true range (ATR) or volatility, with breaks above or below the top and bottom barriers signaling a continuation") multKC = input(1.5 , title ='×', group ='Keltner Channel MultFactor') trueRange = input.bool(true , title = '' , group = '☑ True Range (Keltner Channel)' , tooltip = 'Average-true range (ATR) with breaks above or below the top and bottom barriers signaling a continuation') kc__tr = trueRange ? true : na //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%CSS%%%%%%%%%%%%%%%%%%%%%%%%% // CSS Menu ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bg_bear_css = input.color(color.rgb(120, 123, 134, 64) , '‎ ‎ ' , group = 'Highlights' , inline = 'exit') bg_bull_css = input.color(color.rgb(120, 123, 134, 64) ,'‎ ‎ ' , group = 'Highlights' , inline = 'take') sqz_pos_mom_css = input(#00ff00b2,'⌟' , group = "Positive Momentum") sqz_pos_mom_rev_css = input(#008000ae,'⌞' , group = "Positive Momentum Reversing") sqz_neg_mom_css = input(#ff0000ae,'⌝' , group = "Negative Momentum") sqz_neg_mom_rev_css = input(#800000a7,'⌜' , group = "Negative Momentum Reversing") sqz_no_css = input(#0023a1,'∅' , group = "No Squeeze") sqz_ON_css = input(color.rgb(0, 0, 0),'⏳' , group = "Squeeze Entered (Preparing)" , tooltip = '"Black crosses on the midline show that the market just entered a squeeze (Bollinger Bands are within Keltner Channel). This signifies low volatility, market preparing itself for an explosive move (up or down)"') sqz_released_css = input(color.gray,'🌋' , tooltip = '"Gray crosses signify "Squeeze release""' , group = "Squeeze Release (Released)") // New - Set visibility based on input var hlines_visibility = input.bool(false, title="Toggle", group = 'Bands', inline = 'switch') var upperline_css = input.color(color.white , title = '☱' , group = 'Bands' , inline = 'upperline') var midline_css = input.color(INVS , title = '☲' , group = 'Bands' , inline = 'midline') var lowline_css = input.color(color.white , title = '☴' , group = 'Bands' , inline = 'lowerline') //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%BOLL%%%%%%%%%%%%%%%%%%%%%%%% // 🎳 Bollinger Bands ─ LazyBear © //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% basis = ta.sma(changeSource, length) dev = multKC * ta.stdev(changeSource, length) upperBB = basis + dev lowerBB = basis - dev //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ☶ Keltner Channel ─ LazyBear © //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ma = ta.sma(changeSource, lengthKC) range_1 = kc__tr ? ta.tr : high - low rangema = ta.sma(range_1, lengthKC) upperKC = ma + rangema * multKC lowerKC = ma - rangema * multKC //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 🍋 Squeeze Indication ─ LazyBear © //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sqzOn = lowerBB > lowerKC and upperBB < upperKC sqzOff = lowerBB < lowerKC and upperBB > upperKC noSqz = sqzOn == false and sqzOff == false //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // 📊 Histogram ─ LazyBear © //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% val = ta.linreg(changeSource - math.avg(math.avg(ta.highest(high, lengthKC), ta.lowest(low, lengthKC)), ta.sma(close, lengthKC)), lengthKC, 0) iff_1 = val > nz(val[1]) ? sqz_pos_mom_css : sqz_pos_mom_rev_css iff_2 = val < nz(val[1]) ? sqz_neg_mom_css : sqz_neg_mom_rev_css bcolor = val > 0 ? iff_1 : iff_2 scolor = noSqz ? sqz_no_css : sqzOn ? sqz_ON_css : sqz_released_css //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%INT%%%%%%%%%%%%%%%%%%%%%%%%% plot_hist = input.bool(true , group = '☑ LazyBear Histogram' , tooltip = 'LazyBear Histogram' , title = '') plot_cross = input.bool(true , group ='☑ LazyBear Crosses' , tooltip = 'LazyBear Crosses' , title = '') zero_line = 0 var string plotStyle = input.string('Columns' , title='🛞' , options=['Histogram', 'Columns'] , group = 'Bands') lineStyle = plotStyle == 'Histogram' ? plot.style_histogram : plot.style_columns plot(plot_hist ? val : na, color = bcolor , title = 'Use Condition: SQZ_MULT..' , style= plotStyle == 'Histogram' ? plot.style_histogram : plot.style_columns , linewidth=4 , offset = 0 , editable = false) plot(plot_cross ? zero_line : na, color=scolor , title = 'Use Condition: SQZ_MULT..' , style=plot.style_cross,linewidth=2 ,offset = 0 , editable = false) show_bg_exit = input.bool(true , title = '‎ 𝑺𝒉𝒐𝒓𝒕𝒔' , group = 'Highlights' , inline = 'exit') hide_bg_exit = show_bg_exit ? true : na show_bg_take = input.bool(true , title = '‎ 𝑳𝒐𝒏𝒈𝒔' , group = 'Highlights' , inline = 'take') hide_bg_take = show_bg_take ? true : na float upperint = input.float(2 , title = '' , group = 'Bands' , inline = 'upperline' , step = 0.05 , minval = 0) float midint = input.float(0 , title = '' , group = 'Bands' , inline = 'midline' , step = 0.05) float lowerint = input.float(-2 , title = '' , group = 'Bands' , inline = 'lowerline' , step = 0.05 , maxval = 0) //%%%%%%%%%%%%%%%%%%%%%%%%%PLOT%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%HLINE%%%%%%%%%%%%%%%%%%%%%% hline(hlines_visibility ? upperint : na, 'Upperline' , linestyle = hline.style_dashed , linewidth = 1 , color = upperline_css , editable = false) hline(hlines_visibility ? midint : na, 'Midline' , linestyle = hline.style_solid , linewidth = 1 , color = midline_css , editable = false) hline(hlines_visibility ? lowerint : na, 'Lowerline' , linestyle = hline.style_dashed , linewidth = 1 , color = lowline_css , editable = false) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% non_repainting = barstate.isconfirmed == true //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ✛ First Gray EXIT Position ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pos = val > nz(val[1]) not_pos = not pos exit_pos = scolor == sqz_released_css bear_sqz_bg = request.security(syminfo.tickerid , keepFrameFor , exit_pos[0] and not exit_pos[1] and not_pos and non_repainting) bear_sqz_alert = request.security(syminfo.tickerid , keepFrameFor , exit_pos[0] and not exit_pos[1] and not_pos and non_repainting) bear_bg_pick = bear_sqz_bg[0] and not bear_sqz_bg[1] bear_alert = bear_sqz_alert[0] and not bear_sqz_alert[1] //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ✛ First Gray TAKE Position ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% neg = val < nz(val[1]) not_neg = not neg take_pos = scolor == sqz_released_css bull_sqz_bg = request.security(syminfo.tickerid , keepFrameFor , take_pos[0] and not take_pos[1] and not_neg and non_repainting) bull_sqz_alert = request.security(syminfo.tickerid , keepFrameFor , take_pos[0] and not take_pos[1] and not_neg and non_repainting) bull_bg_pick = bull_sqz_bg[0] and not bull_sqz_bg[1] bull_alert = bull_sqz_alert[0] and not bull_sqz_alert[1] //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ║ Highlight ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bg_bear = bear_bg_pick bgcolor(bg_bear and hide_bg_exit ? bg_bear_css : INVS , title = '𝘚𝘩𝘰𝘳𝘵𝘴' , editable = false) bg_bull = bull_bg_pick bgcolor(bg_bull and hide_bg_take ? bg_bull_css : INVS , title = '𝘓𝘰𝘯𝘨𝘴' , editable = false) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🌙 Alerts ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ if bear_alert == true and close[1] == bear_alert alert("➖ 𝙂𝙤 𝙎𝙝𝙤𝙧𝙩", alert.freq_once_per_bar_close) alertcondition(bear_alert , title= "➖ 𝑺𝒉𝒐𝒓𝒕𝒔" , message = '➖ SQZ_MULT ━ whvntr') if bull_alert == true and close[1] == bull_alert alert("➕ 𝙂𝙤 𝙇𝙤𝙣𝙜", alert.freq_once_per_bar_close) alertcondition(bull_alert , title= "➕ 𝑳𝒐𝒏𝒈𝒔" , message = '➕ SQZ_MULT ━ whvntr') //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🌙 Alerts ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
New Highs-New-Lows on US Stock Market - Sub Chart Edition
https://www.tradingview.com/script/sSEE6AII/
Benni_R
https://www.tradingview.com/u/Benni_R/
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/ // © Benni_R //@version=5 indicator("New Highs-New-Lows on US Stock Market - Sub Chart Edition", overlay = false) //Inputs Cons_NYSE = input.bool(true,title = "NYSE:",group="Exchange",tooltip="Consider new highs and lows of NYSE?") Cons_AMEX = input.bool(true,title = "AMEX:",group="Exchange",tooltip="Consider new highs and lows of AMEX?") Cons_NASDAQ = input.bool(true,title = "NASDAQ:",group="Exchange",tooltip="Consider new highs and lows of NASDAQ?") Act_Str_1 = input.bool(true,title="Highlight Divergences", group = "Divergence-Settings") Hoch_S = input.source(high, title="Source for divergence highs: ", group = "Divergence-Settings", inline = "1") Tief_S = input.source(low, title="Source for divergence highs: ", group = "Divergence-Settings", inline = "1") MBuSS=input.int(10,title="Minimum Bull Signal Strength [0-100%]:", tooltip = "0: Show every signal // 100: Filter everything but hyper signal", minval=0, maxval=100, group = "Signal") MBeSS=input.int(10,title="Minimum Bear Signal Strength [0-100%]:", tooltip = "0: Show every signal // 100: Filter everything but hyper signal", minval=0, maxval=100, group = "Signal") EMA_NHNL_Lenghts = input.int(50, title = "Lenghts of EMA-NHNL:", group ="EMA", inline = "3") EMA_Color = input.color(color.blue, title="",group="EMA", inline = "3") //Variables var float Last_Hoch = 0 //initialise last high var float Last_NHNL_H = 0 //initialise last NHNL value on last high var int Last_Hoch_Barindex = na //initialise last High Barindex var float Last_Tief = 999999999 //initialise last low var float Last_NHNL_T = 100 // initialise last NHNL value on last high var int Last_Tief_Barindex = na //initialise last Low Barindex Bull_Div = false //initialise bullish divergence Bear_Div = false //initialise bearish divergence Signal_long = false //initialise long Signal Signal_short = false //initialise short Signal float BeSS_2_Faktor = 0 //initialise Bearish signal strength float BuSS_2_Faktor = 0 //initialise bullish signal strength //Funktions f_Security(_Sym) => Wert = request.security_lower_tf(_Sym, 'D', close) f_line(X1, X2, Y1, Y2, Color) => // Verticle Line Function, ≈50-54 lines maximum allowable per indicator Ergebnis = line.new(X1, Y1, X2, Y2, xloc.bar_index, extend.none, Color, style=line.style_solid, width=1) // Suitable for study(overlay=false) and RSI, Stochastic, etc... //Import NHNL Values float[] NYSE_H = Cons_NYSE ? f_Security('INDEX:HIGN') : na float[] NYSE_L = Cons_NYSE ? f_Security('INDEX:LOWN') : na float[] AMEX_H = Cons_AMEX ? f_Security('INDEX:HIGA') : na float[] AMEX_L = Cons_AMEX ? f_Security('INDEX:LOWA') : na float[] NASDAQ_H = Cons_NASDAQ ? f_Security('INDEX:HIGQ') : na float[] NASDAQ_L = Cons_NASDAQ ? f_Security('INDEX:LOWQ') : na NHNL = (Cons_NYSE ? array.sum(NYSE_H) - array.sum(NYSE_L) : 0) + (Cons_AMEX ? array.sum(AMEX_H) - array.sum(AMEX_L) : 0) + (Cons_NASDAQ ? array.sum(NASDAQ_H) - array.sum(NASDAQ_L) : 0) //EMA's EMA_NHNL = ta.ema(NHNL,EMA_NHNL_Lenghts) MA_Fast = ta.ema(close,10) MA_Slow = ta.ema(close,50) //Check if new high Neues_Hoch = Hoch_S[2] < Hoch_S[1] and Hoch_S[0] < Hoch_S[1] // Check if bearish divergence between NHNL and price if Neues_Hoch and Hoch_S[1] > Last_Hoch Bear_Div := NHNL[1] < Last_NHNL_H if Bear_Div and Last_Hoch_Barindex > 0 and Act_Str_1 f_line(Last_Hoch_Barindex, bar_index[1], Last_NHNL_H, NHNL[1], color.red) Signal_short := true BeSS_2_Faktor := NHNL[1]/Last_NHNL_H*100 Last_Hoch := Hoch_S[1] Last_NHNL_H := NHNL[1] Last_Hoch_Barindex := bar_index[1] // Reset last high values if fast EMA crosse slow EMA below if MA_Fast[1] > MA_Slow[1] and MA_Fast < MA_Slow Last_Hoch := 0 Last_NHNL_H := 0 Last_Hoch_Barindex := na //Check if new low Neues_Tief = Tief_S[2] > Tief_S[1] and Tief_S[0] > Tief_S[1] // Check if bullish divergence between NHNL and price if Neues_Tief and Tief_S[1] < Last_Tief Bull_Div := NHNL[1] > Last_NHNL_T if Bull_Div and Last_Tief_Barindex > 0 and Act_Str_1 f_line(Last_Tief_Barindex, bar_index[1], Last_NHNL_T, NHNL[1], color.green) Signal_long:= true BuSS_2_Faktor:= NHNL[1]/Last_NHNL_T*100 Last_Tief := Tief_S[1] Last_NHNL_T := NHNL[1] Last_Tief_Barindex := bar_index[1] // Reset last low values if fast EMA crosse slow EMA up if MA_Fast[1] < MA_Slow[1] and MA_Fast > MA_Slow Last_Tief := 999999999 Last_NHNL_T := 100 Last_Tief_Barindex := na // Evaluate Signal strength BeSS_1 = EMA_NHNL > 150 ? 3 : EMA_NHNL >= 120 ? 10 : EMA_NHNL >= 90 ? 20 : EMA_NHNL >= 60 ? 30 : EMA_NHNL >= 30 ? 40 : 50 BeSS_2 = BeSS_2_Faktor > 80 ? 2 : BeSS_2_Faktor <= 80 ? 10 : BeSS_2_Faktor <= 60 ? 20 : BeSS_2_Faktor <= 40 ? 30 : BeSS_2_Faktor <= 20 ? 40 : 50 BuSS_1 = EMA_NHNL < -150 ? 3 : EMA_NHNL <= -120 ? 10 : EMA_NHNL <= -90 ? 20 : EMA_NHNL <= -60 ? 30 : EMA_NHNL <= -30 ? 40 : 50 BuSS_2 = BuSS_2_Faktor > 80 ? 2 : BuSS_2_Faktor <= 80 ? 10 : BuSS_2_Faktor <= 60 ? 20 : BuSS_2_Faktor <= 40 ? 30 : BuSS_2_Faktor <= 20 ? 40 : 50 Bear_signal_strengh = BeSS_1 + BeSS_2 Bull_signal_strengh = BuSS_1 + BuSS_2 //plot plot(NHNL, title="Net New High/Low", color= NHNL>=0 ? color.new(color.green, 50) : color.new(color.red, 50), style= plot.style_columns) plot(EMA_NHNL, title="EMA New High/Low", color=EMA_Color, style= plot.style_line) bgcolor(Signal_long and (Bull_signal_strengh >= MBuSS)? color.new(color.green, 100-Bull_signal_strengh) : Signal_short and (Bear_signal_strengh >= MBeSS)? color.new(color.red, 100-Bear_signal_strengh) : na)
inverse_fisher_transform_adaptive_stochastic
https://www.tradingview.com/script/uMTi9oYD-inverse-fisher-transform-adaptive-stochastic/
palitoj_endthen
https://www.tradingview.com/u/palitoj_endthen/
63
study
5
MPL-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 = 'ehlers_inverse_fisher_transform_of_adaptive_stochastic', shorttitle = 'inverse_fisher_adaptive_stochastic', overlay = false) // input hp_period = input.int(defval = 48, title = 'High-pass Period', group = 'Value', tooltip = 'Determines the length of High-pass Period') src = input.source(defval = close, title = 'Source', group = 'Options', tooltip = 'Determines the source of input data, default to close') // variable avg_length = 3 m = 0 n = 0 x = 0.00 y = 0.00 alpha1 = 0.00 hp = 0.00 a1 = 0.00 b1 = 0.00 c1 = 0.00 c2 = 0.00 c3 = 0.00 filt = 0.00 sx = 0.00 sy = 0.00 sxx = 0.00 syy = 0.00 sxy = 0.00 sp = 0.00 spx = 0.00 max_pwr = 0.00 dominant_cycle = 0.00 // arrays var corr = array.new_float(50) var cosine_part = array.new_float(50) var sine_part = array.new_float(50) var sq_sum = array.new_float(50) var r1 = array.new_float(50) var r2 = array.new_float(50) var pwr = array.new_float(50) // compute inferse fisher transform of adaptive stochastic // highpass filter cyclic components whose periods are shorter than 48 bars pi = 2*math.asin(1) alpha1 := (math.cos(.707*2*pi/hp_period) + math.sin(.707*2*pi/hp_period)-1)/math.cos(.707*2*pi/hp_period) hp := (1-alpha1/2)*(1-alpha1/2)*(src-2*src[1]+src[2])+2*(1-alpha1)*nz(hp[1])-(1-alpha1)*(1-alpha1)*nz(hp[2]) // smooth with super smoother filter a1 := math.exp(-1.414*3.14159/10) b1 := 2*a1*math.cos(1.414*180/10) c2 := b1 c3 := -a1*a1 c1 := 1-c2-c3 filt := c1*(hp+hp[1])/2+c2*nz(filt[1])+c3*nz(filt[2]) // pearson correlation for each value of lag for lag = 0 to 48 // set the averaging length as m m := avg_length if avg_length == 0 m := lag // initialize correlation sums sx := 0.00 sy := 0.00 sxx := 0.00 syy := 0.00 sxy := 0.00 // advance samples of both data streams and sum pearson components for count = 0 to m-1 x := filt[count] y := filt[lag+count] sx := sx+x sy := sy+y sxx := sxx+x*x sxy := sxy+x*y syy := syy+y*y // compute correlation for each value of lag if (m*sxx-sx*sx)*(m*syy-sy*sy) > 0 array.set(corr, lag, ((m*sxy-sx*sy)/math.sqrt((m*sxx-sx*sx)*(m*syy-sy*sy)))) for period = 10 to 48 array.set(cosine_part, period, 0) array.set(sine_part, period, 0) for n2 = 3 to 48 array.set(cosine_part, period, nz(array.get(cosine_part, period))+nz(array.get(corr, n2))*math.cos(360*n2/period)) array.set(sine_part, period, nz(array.get(sine_part, period))+nz(array.get(corr, n2))*math.sin(360*n2/period)) array.set(sq_sum, period, nz(array.get(cosine_part, period)) * nz(array.get(cosine_part, period))+nz(array.get(sine_part, period))*nz(array.get(sine_part, period))) for period2 = 10 to 48 array.set(r2, period2, nz(array.get(r1, period2))) array.set(r1, period2, .2*nz(array.get(sq_sum, period2))*nz(array.get(sq_sum, period2))+.8*nz(array.get(r2, period2))) // find maximum power level for normalization max_pwr := .995*max_pwr for period3 = 10 to 48 if nz(array.get(r1, period3)) > max_pwr max_pwr := nz(array.get(r1, period3)) for period4 = 3 to 48 array.set(pwr, period4, nz(array.get(r1, period4))/max_pwr) // compute the dominant cycle using the cg of the spectrum for period5 = 10 to 48 if nz(array.get(pwr, period5)) >= .5 spx := spx+period5*nz(array.get(pwr, period5)) sp := sp+nz(array.get(pwr, period5)) if sp != 0 dominant_cycle := spx/sp if dominant_cycle < 10 dominant_cycle := 10 if dominant_cycle > 48 dominant_cycle := 48 // stochastic compuation start here highest = 0.00 lowest = 0.00 stoc = 0.00 smooth_num = 0.00 smooth_denom = 0.00 adaptive_stoc = 0.00 highest := filt lowest := filt for i = 0 to dominant_cycle-1 if filt[i] > highest highest := filt[i] if filt[i] < lowest lowest := filt[i] stoc := (filt-lowest)/(highest-lowest) adaptive_stoc := c1*(stoc+stoc[1])/2+c2*nz(adaptive_stoc[1])+c3*nz(adaptive_stoc[2]) value1 = 0.00 ifish = 0.00 trigger = 0.00 value1 := 2*(adaptive_stoc-.5) ifish := (math.exp(2*3*value1)-1)/(math.exp(2*3*value1)+1) trigger := .9*ifish[1] // visualize color_con = ifish > trigger and ifish > ifish[1] ? color.green : color.red color_con_ = ifish > trigger and ifish > ifish[1] plot(ifish, color = color_con, linewidth = 3) plot(trigger, color = color.new(color.aqua, 50)) // create alert alertcondition((not color_con_[1] and color_con_), title = 'Entry', message = 'Buy/Long entry detected') alertcondition((color_con_ and not color_con_), title = 'Close', message = 'Sell/Short entry detected') // // strategy test // long_condition = not (color_con_[1] and color_con_) // if long_condition // strategy.entry('long', strategy.long) // short_condition = color_con_[1] and not color_con_ // if short_condition // strategy.exit('exit', 'long', profit = 10, loss = 1)
Stoch RSI 15 min - multi time frame table
https://www.tradingview.com/script/d0DKkAeO-Stoch-RSI-15-min-multi-time-frame-table/
TaTaTaCrypto
https://www.tradingview.com/u/TaTaTaCrypto/
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/ // © TaTaTaCrypto //@version=5 indicator("Stoch RSI",overlay = true) lengthRSI = input.int(14, "Length RSI") lengthMovingAverage = input.int(3, "Length Moving Average") rsi_curr = ta.rsi(close, lengthRSI) stochRSI = ta.stoch(rsi_curr,rsi_curr,rsi_curr, lengthRSI) stochRSI_smoth = ta.sma(stochRSI, lengthMovingAverage) //T15_RSI_Ticker_R = T15_RSI_TickerR = request.security(syminfo.tickerid ,timeframe.period ,stochRSI_smoth) T15_RSI_Ticker = request.security(syminfo.tickerid ,timeframe.period ,stochRSI_smoth[barstate.isrealtime ? 1:0]) //T15_RSI_BTC = request.security("BTCUSDT" ,timeframe.period ,stochRSI_smoth[barstate.isrealtime ? 1:0]) //T15_RSI_ETH = request.security("ETHUSDT" ,timeframe.period ,stochRSI_smoth[barstate.isrealtime ? 1:0]) T30_RSI_Ticker = request.security(syminfo.tickerid ,"30" ,stochRSI_smoth[barstate.isrealtime ? 1:0]) T60_RSI_Ticker = request.security(syminfo.tickerid ,"60" ,stochRSI_smoth[barstate.isrealtime ? 1:0]) T4h_RSI_Ticker = request.security(syminfo.tickerid ,"240" ,stochRSI_smoth[barstate.isrealtime ? 1:0]) T12h_RSI_Ticker = request.security(syminfo.tickerid ,"720" ,stochRSI_smoth[barstate.isrealtime ? 1:0]) table panel = table.new(position.top_right, 2, 7,frame_width=1, border_width=1, border_color=color.new(color.white, 100)) if barstate.islast // Populate the table on the last bar table.cell(panel, 0, 0, "Stoch MA" + "3" + " l"+"14", bgcolor =color.white) table.cell(panel, 0, 1, "15minR", bgcolor = color.white) table.cell(panel, 0, 2, "15min", bgcolor = color.white) table.cell(panel, 0, 3, "30min", bgcolor =color.white) table.cell(panel, 0, 4, "1h", bgcolor = color.white) table.cell(panel, 0, 5, "4h", bgcolor = color.white) table.cell(panel, 0, 6, "12h", bgcolor = color.white) table.cell(panel, 1, 1, str.tostring(T15_RSI_TickerR,'#.#'), bgcolor = #fcfcfc) table.cell(panel, 1, 2, str.tostring(T15_RSI_Ticker,'#.#'), bgcolor = #fcfcfc) table.cell(panel, 1, 3, str.tostring(T30_RSI_Ticker,'#.#'), bgcolor = #fcfcfc) table.cell(panel, 1, 4, str.tostring(T60_RSI_Ticker,'#.#'), bgcolor = #fcfcfc) table.cell(panel, 1, 5, str.tostring(T4h_RSI_Ticker,'#.#'), bgcolor = #fcfcfc) table.cell(panel, 1, 6, str.tostring(T12h_RSI_Ticker,'#.#'), bgcolor = #fcfcfc) table.merge_cells(panel,0,0,1,0) //table.merge_cells(panel,0,0,1,0)
Price Cross ━ [whvntr]
https://www.tradingview.com/script/Q480n0H3-Price-Cross-whvntr/
whvntr
https://www.tradingview.com/u/whvntr/
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/ //@version=5 indicator(title='Price Cross ━ [whvntr]', format=format.price, precision=2, overlay = false, shorttitle='Price Cross') //%%%%%%%%%%%%%%%%%%%%%%%%%%%SRC%%%%%%%%%%%%%%%%%%%%%%% float source = input(close, group = 'Source' , inline = "top") norepainting = barstate.isconfirmed == true var macd_color_t = true //%%%%%%%%%%%%%%%%%%%%%%%%%%TIP%%%%%%%%%%%%%%%%%%%%%%%% // ─© whvntr string MACDDEFNI = 'investopedia.com: "Moving Average Convergence Divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of a securitys price. Traders use the MACD to identify when bullish or bearish momentum is high to identify entry and exit points for trades.." So, then, also one could deduct that a SMA, crossed with the MACD, could show the relationship between the bullish or bearish momentum of the MACD." that will cross with the EMAs (MACD)' string HIDDENDIVERGENCE = 'Adjust the length of the SMA that will cross with the EMAs (MACD)' //%%%%%%%%%%%%%%%%%%%%%%%%%LAO%%%%%%%%%%%%%%%%%%%%%%%%% // ─© whvntr color BRIGHTDOT = #f8bbd0 float FLOAT = na color TRANSP = #00000000 var show_dots = true var macd_midline = true //%%%%%%%%%%%%%%%%%%%%%%%%%CSS%%%%%%%%%%%%%%%%%%%%%%%%% // ─© whvntr var sma_line = input.color(#00ff00 , title = '―――' , group = 'SMA & EMAs' , tooltip= 'SMA') var macd_line = input.color(#ff0000 , title = '〳' , group = 'SMA & EMAs' , tooltip = 'EMAs') var bear_bright_dot_css = input.color(#ff0000 , title = '◉' , group = 'Dots' , inline = 'dots') var bull_bright_dot_css = input.color(#00ff2a , title = ' ‎ ‎ ' , group = 'Dots' , inline = 'dots') var bear_highlight_css = input.color(color.new(#ff0000, 70) , title = '☼' , group = 'Highlights' , inline = 'highlight') var bull_highlight_css = input.color(color.new(#00ff00, 80) , title = ' ‎ ‎ ' , group = 'Highlights' , inline = 'highlight') var bear_barcolor_css = input.color(color.new(#ff0000, 25) , title = '🕯‎ ‎' , group = 'Bar Colors' , inline = 'barcolor') var bull_barcolor_css = input.color(color.new(#00ff00, 32) , title = ' ‎ ‎ ' , group = 'Bar Colors' , inline = 'barcolor') var upperline_css = input.color(#4CAF50 , title = '𝘜𝘱𝘱𝘦𝘳𝘭𝘪𝘯𝘦 ‎' , group = '' , inline = 'upperline') var midline_css = input.color(#ffa726 , title = '𝘔𝘪𝘥𝘭𝘪𝘯𝘦 ‎ ‎ ‎ ‎ ‎‎' , group = '' , inline = 'midline') var lowline_css = input.color(#FF5252 , title = '𝘓𝘰𝘸𝘦𝘳𝘭𝘪𝘯𝘦 ‎ ‎' , group = '' , inline = 'lowerline') //%%%%%%%%%%%%%%%%%%%%%%%%%%MACD%%%%%%%%%%%%%%%%%%%%%%% // ─© whvntr ema_len_26 = input.int(7, minval=1 , title= '┉ ┉' , group = 'MACD' , tooltip = MACDDEFNI , inline = 'macd_bear') ema_len_12 = input.int(5, minval=1 , title= '┉' , group = 'MACD' , tooltip = MACDDEFNI , inline = 'macd_bear') ema_26 = ta.ema(source, ema_len_26) ema_12 = ta.ema(source, ema_len_12) macd = ema_12 - ema_26 sma_len_10 = input(10, title = '⦿' , group = "Hidden Divergence Length ‎" , tooltip = HIDDENDIVERGENCE) // Circles Formula ─ TheLark (Modified) cross_ = ta.sma(macd, sma_len_10) out_ = macd in_ = cross_ macd_cross = out_ >= in_ macd_color_highlights = (macd_color_t) ? (macd_cross ? bull_highlight_css : bear_highlight_css) : BRIGHTDOT macd_color_brightdots = (macd_color_t) ? (macd_cross ? bull_bright_dot_css : bear_bright_dot_css) : BRIGHTDOT hidden_dot = out_ // ─© whvntr //%%%%%%%%%%%%%%%%%%%%%%%%%INT%%%%%%%%%%%%%%%%%%%%%%%%% float upperint = input.float(0.0002 , title = '' , group = '' , inline = 'upperline' , step = 0.0001 , minval = 0) float midint = input.float(0 , title = '' , group = '' , inline = 'midline' , step = 0.0001) float lowerint = input.float(-0.0002 , title = '' , group = '' , inline = 'lowerline' , step = 0.0001 , maxval = 0) //%%%%%%%%%%%%%%%%%%%%%%%%%PLOT%%%%%%%%%%%%%%%%%%%%%%%% plot(macd , title ='MACD', color = macd_line , style = plot.style_line, linewidth = 1 , editable = false) plot(macd_midline and in_ ? in_ : FLOAT , title ='SMA', color = sma_line , style = plot.style_line, linewidth = 1 , editable = false) plotshape(show_dots and ta.cross(out_, in_) and norepainting ? hidden_dot : FLOAT , location = location.absolute , size = size.small , title = 'Dot' , style = shape.circle , color = macd_color_highlights , editable = false) plotshape(show_dots and ta.cross(out_, in_) and norepainting ? hidden_dot : FLOAT , location = location.absolute , size = size.tiny , title = 'Dot' , style = shape.circle , color = macd_color_brightdots , editable = false) //%%%%%%%%%%%%%%%%%%%%%%%%%%HLINE%%%%%%%%%%%%%%%%%%%%%% hline(upperint, 'Upperline' , linestyle = hline.style_dotted , linewidth = 1 , color = upperline_css , editable = true) hline(midint, 'Midline' , linestyle = hline.style_solid , linewidth = 2 , color = midline_css , editable = true) hline(lowerint, 'Lowerline' , linestyle = hline.style_dotted , linewidth = 1 , color = lowline_css , editable = true) //%%%%%%%%%%%%%%%%%%%%%%%BAR%%%%%%%%%%%%%%%%%%%%%%%%% var color recent_bar_color = na var int last_bull_cross = na var int last_bear_cross = na isBearBright() => bool bearBright = false if ta.cross(out_, in_) and norepainting and macd_color_brightdots == bear_bright_dot_css bearBright := true bearBright isBullBright() => bool bullBright = false if ta.cross(out_, in_) and norepainting and macd_color_brightdots == bull_bright_dot_css bullBright := true bullBright if isBearBright() recent_bar_color := bear_barcolor_css else if isBullBright() recent_bar_color := bull_barcolor_css else if last_bull_cross > last_bear_cross recent_bar_color := bull_barcolor_css // Barcolor switch var bool use_barcolor = input(false , title = "Check for custom bar colors" , group = 'Source' , inline = "Top") // Barcolor barcolor(use_barcolor ? recent_bar_color : na)
New Highs-New-Lows on US Stock Market - Main Chart Edition
https://www.tradingview.com/script/0q6fkTpa/
Benni_R
https://www.tradingview.com/u/Benni_R/
135
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Benni_R //@version=5 indicator("New Highs-New-Lows on US Stock Market - Main Chart Edition", overlay = true) //Inputs Cons_NYSE = input.bool(true,title = "NYSE:",group="Exchange",tooltip="Consider new highs and lows of NYSE?") Cons_AMEX = input.bool(true,title = "AMEX:",group="Exchange",tooltip="Consider new highs and lows of AMEX?") Cons_NASDAQ = input.bool(true,title = "NASDAQ:",group="Exchange",tooltip="Consider new highs and lows of NASDAQ?") Act_Str_1 = true //input.bool(true,title="Highlight Divergences", group = "Divergence-Settings") Hoch_S = input.source(high, title="Source for divergence highs: ", group = "Divergence-Settings", inline = "1") Tief_S = input.source(low, title="Source for divergence highs: ", group = "Divergence-Settings", inline = "1") MBuSS=input.int(10,title="Minimum Bull Signal Strength [0-100%]:", tooltip = "0: Show every signal // 100: Filter everything but hyper signal", minval=0, maxval=100, group = "Signal") MBeSS=input.int(10,title="Minimum Bear Signal Strength [0-100%]:", tooltip = "0: Show every signal // 100: Filter everything but hyper signal", minval=0, maxval=100, group = "Signal") EMA_NHNL_Lenghts = input.int(50, title = "Lenghts of EMA-NHNL:", group ="EMA", inline = "3") EMA_Color = input.color(color.blue, title="",group="EMA", inline = "3") //Variables var float Last_Hoch = 0 //initialise last high var float Last_NHNL_H = 0 //initialise last NHNL value on last high var int Last_Hoch_Barindex = na //initialise last High Barindex var float Last_Tief = 999999999 //initialise last low var float Last_NHNL_T = 100 // initialise last NHNL value on last high var int Last_Tief_Barindex = na //initialise last Low Barindex Bull_Div = false //initialise bullish divergence Bear_Div = false //initialise bearish divergence Signal_long = false //initialise long Signal Signal_short = false //initialise short Signal float BeSS_2_Faktor = 0 //initialise Bearish signal strength float BuSS_2_Faktor = 0 //initialise bullish signal strength //Funktions f_Security(_Sym) => Wert = request.security_lower_tf(_Sym, 'D', close) f_line(X1, X2, Y1, Y2, Color) => // Verticle Line Function, ≈50-54 lines maximum allowable per indicator Ergebnis = line.new(X1, Y1, X2, Y2, xloc.bar_index, extend.none, Color, style=line.style_solid, width=1) // Suitable for study(overlay=false) and RSI, Stochastic, etc... //Import NHNL Values float[] NYSE_H = Cons_NYSE ? f_Security('INDEX:HIGN') : na float[] NYSE_L = Cons_NYSE ? f_Security('INDEX:LOWN') : na float[] AMEX_H = Cons_AMEX ? f_Security('INDEX:HIGA') : na float[] AMEX_L = Cons_AMEX ? f_Security('INDEX:LOWA') : na float[] NASDAQ_H = Cons_NASDAQ ? f_Security('INDEX:HIGQ') : na float[] NASDAQ_L = Cons_NASDAQ ? f_Security('INDEX:LOWQ') : na NHNL = (Cons_NYSE ? array.sum(NYSE_H) - array.sum(NYSE_L) : 0) + (Cons_AMEX ? array.sum(AMEX_H) - array.sum(AMEX_L) : 0) + (Cons_NASDAQ ? array.sum(NASDAQ_H) - array.sum(NASDAQ_L) : 0) //EMA's EMA_NHNL = ta.ema(NHNL,EMA_NHNL_Lenghts) MA_Fast = ta.ema(close,10) MA_Slow = ta.ema(close,50) //Check if new high Neues_Hoch = Hoch_S[2] < Hoch_S[1] and Hoch_S[0] < Hoch_S[1] // Check if bearish divergence between NHNL and price if Neues_Hoch and Hoch_S[1] > Last_Hoch Bear_Div := NHNL[1] < Last_NHNL_H if Bear_Div and Last_Hoch_Barindex > 0 and Act_Str_1 f_line(Last_Hoch_Barindex, bar_index[1], Last_Hoch, Hoch_S[1], color.red) Signal_short := true BeSS_2_Faktor := NHNL[1]/Last_NHNL_H*100 Last_Hoch := Hoch_S[1] Last_NHNL_H := NHNL[1] Last_Hoch_Barindex := bar_index[1] // Reset last high values if fast EMA crosse slow EMA below if MA_Fast[1] > MA_Slow[1] and MA_Fast < MA_Slow Last_Hoch := 0 Last_NHNL_H := 0 Last_Hoch_Barindex := na //Check if new low Neues_Tief = Tief_S[2] > Tief_S[1] and Tief_S[0] > Tief_S[1] // Check if bullish divergence between NHNL and price if Neues_Tief and Tief_S[1] < Last_Tief Bull_Div := NHNL[1] > Last_NHNL_T if Bull_Div and Last_Tief_Barindex > 0 and Act_Str_1 f_line(Last_Tief_Barindex, bar_index[1], Last_Tief, Tief_S[1], color.green) Signal_long:= true BuSS_2_Faktor:= NHNL[1]/Last_NHNL_T*100 Last_Tief := Tief_S[1] Last_NHNL_T := NHNL[1] Last_Tief_Barindex := bar_index[1] // Reset last low values if fast EMA crosse slow EMA up if MA_Fast[1] < MA_Slow[1] and MA_Fast > MA_Slow Last_Tief := 999999999 Last_NHNL_T := 100 Last_Tief_Barindex := na // Evaluate Signal strength BeSS_1 = EMA_NHNL > 150 ? 3 : EMA_NHNL >= 120 ? 10 : EMA_NHNL >= 90 ? 20 : EMA_NHNL >= 60 ? 30 : EMA_NHNL >= 30 ? 40 : 50 BeSS_2 = BeSS_2_Faktor > 80 ? 2 : BeSS_2_Faktor <= 80 ? 10 : BeSS_2_Faktor <= 60 ? 20 : BeSS_2_Faktor <= 40 ? 30 : BeSS_2_Faktor <= 20 ? 40 : 50 BuSS_1 = EMA_NHNL < -150 ? 3 : EMA_NHNL <= -120 ? 10 : EMA_NHNL <= -90 ? 20 : EMA_NHNL <= -60 ? 30 : EMA_NHNL <= -30 ? 40 : 50 BuSS_2 = BuSS_2_Faktor > 80 ? 2 : BuSS_2_Faktor <= 80 ? 10 : BuSS_2_Faktor <= 60 ? 20 : BuSS_2_Faktor <= 40 ? 30 : BuSS_2_Faktor <= 20 ? 40 : 50 Bear_signal_strengh = BeSS_1 + BeSS_2 Bull_signal_strengh = BuSS_1 + BuSS_2 //plot plotshape(Signal_long and (Bull_signal_strengh >= MBuSS)? 1 : na, title = "Bull RSI Divergence", style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 100-Bull_signal_strengh), size=size.small) plotshape(Signal_short and (Bear_signal_strengh >= MBeSS)? 1 : na, title = "Bear RSI Divergence", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 100-Bear_signal_strengh), size=size.small) bgcolor(Signal_long and (Bull_signal_strengh >= MBuSS)? color.new(color.green, 100-Bull_signal_strengh) : Signal_short and (Bear_signal_strengh >= MBeSS)? color.new(color.red, 100-Bear_signal_strengh) : na)
(mab) Money Flow - MMF
https://www.tradingview.com/script/IeNmXP3k-mab-Money-Flow-MMF/
happymab
https://www.tradingview.com/u/happymab/
96
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © happymab // // V 2.1 // // This script implements the (mab) Money Flow (MMF) indicator. The MMF is calculated using a // formula inspired by RSI. In contrast to RSI, MMF uses the average of open, high, low and // close as price source. This average price is then multiplied with the volume as input for // the RSI like formula to calculate the value. // // The multi timer frame feature allows to show a second MMF calculated in a higher time frame. This allows additional // analysis like comparing the values of the two timeframes to detect if a trend is weakening. Divergences detected in the // high time frame MMF are powerful signals too. // // Note that the MMF is different than other money flow indices like MFI or CMF. // // Version History // // 1.0 : Initial implementation // 2.0 : // - Prevent error if volume data is not available. Use only price data is that case. // - Highlight stupid overbought and stupid oversold condition if ema is in overbought / oversold teritorry // 2.1: // - Added multi time frame capability; add an MMF calculated in a higher time frame (shown as background area as default) // //@version=5 indicator("(mab) Money Flow - MMF", shorttitle="(mab)Mmf", overlay=false) // (mab) Colors col_none = color.new(color.white, 100) // Green col_darkSpringGreen = #137547 col_lightGreen = #8fe388 col_springGreen = #61FF7E col_malachite = #4CE949 col_mediumAquamarine = #69DC9E col_Citron = #8EA604 col_yellowGreen = #97DB4F // Red col_rubyRed = #931621 col_redPigment = #ef1010 col_middleRed = #E88873 col_radicalRed = #FF1053 // Orange col_outrageousOrange = #fc7753 col_orangeSoda = #EB5133 col_tartOrange = #F75550 col_orangeRedCrayola = #FE5F55 // Pink col_shockingPinkCrayola = #FB62F6 col_congoPink = #FE8E86 // Purple col_mysticMaroon = #bc387d col_darkBluePurple = #311b92 col_plumWeb = #F9B9F2 // Blue col_trurfsBlue = #0091eb col_honoluluBlue = #176da3 col_GreenBlueCrayola = #1e91d6 col_vividSkyBlue = #42cafd col_skyBlueCrayola = #51E5FF // Yellow col_maximumYellowRed = #fec149 col_rajah = #FFAA5A col_honeyYellow = #FBAF00 col_minionYellow = #FDE74C // White col_navajo_white = #FEDB9B col_seeshell = #fef4ec // Blue-Purple col_blue1 = #CFEAF1 col_blue2 = #BBD2E7 col_blue3 = #A6BADC col_blue4 = #92A2D2 col_blue5 = #7D8AC7 col_blue6 = #6972BD col_blue7 = #545AB2 col_blue8 = #4042A8 col_blue9 = #2B2A9D ////////////////////////////////// // MMF ////////////////////////////////// src = input.source(ohlc4, title="Source") mmfLength = input.int(14, title="Length", minval=1, maxval=2000) emaLength = input.int(13, title="EMA length", minval=1, maxval=2000) oversold = input.float(25.0, title="Oversold", minval=0.0) overbought = input.float(75.0, title="Overbought", minval=0.0) tfMultiplier = input.int(3, title='Multiplier for high timeframe', minval=1) slowMmfSmoothLength = input.int(3, title='High timeframe MMF smooth length', minval=1) midline = 50.0 _getHighTimeframe() => highTf = '' chartTfSec = timeframe.in_seconds() int highTfSec = chartTfSec * tfMultiplier if highTfSec <= 5 highTf := '5S' else if highTfSec <= 10 highTf := '10S' else if highTfSec <= 15 highTf := '15S' else if highTfSec <= 30 highTf := '30S' else if highTfSec <= 60 highTf := '1' else if (highTfSec / 60) < 1440 highTf := str.tostring(highTfSec/60) else if (highTfSec / 86400) < 365 highTf := str.tostring(highTfSec/86400, '#') + 'D' else highTf := '12M' highTf // MMF _mmf() => mmfUp = nz(volume, 1.0) * math.max(src - src[1], 0) mmfDown = nz(volume, 1.0) * math.max(src[1] - src, 0) rs = ta.rma(mmfUp, mmfLength) / ta.rma(mmfDown, mmfLength) res = 100 - 100 / (1 + rs) mmf = _mmf() mmfHtf = ta.ema(request.security(syminfo.tickerid, _getHighTimeframe(), _mmf()), slowMmfSmoothLength) mmfEma = ta.ema(mmf, emaLength) isMmfOverbought = mmf > overbought isMmfOversold = mmf < oversold isMmfStupidOverbought = mmfEma > overbought isMmfStupidOversold = mmfEma < oversold // Plot indices plot(mmf, title="MMF", color=color.new(col_maximumYellowRed, 0), style=plot.style_line, histbase=50, linewidth=1) plot(mmfHtf, title="MMF high timeframe", color=color.new(col_plumWeb, 80), style=plot.style_area, histbase=50, linewidth=1) plot(mmfEma, title="MMF EMA", color=color.new(col_orangeSoda, 0), style=plot.style_line, histbase=50, linewidth=1) // Plot band band1 = plot(0.0, title="band1", color=col_none, style=plot.style_line, linewidth=1, display=display.none) band2 = plot(oversold, title="Oversold", color=color.new(col_seeshell, 80), style=plot.style_cross, linewidth=1, join=true) band3 = plot(overbought, title="Overbought", color=color.new(col_seeshell, 80), style=plot.style_cross, linewidth=1, join=true) band4 = plot(100.0, title="band4", color=col_none, style=plot.style_line, linewidth=1, display=display.none) plot(midline, title="Midline", color=color.new(col_seeshell, 80), style=plot.style_line, linewidth=1, join=true) fill(band2, band3, color=color.new(col_mysticMaroon, 90), title="Background") // Plot overbought / oversold highlight fill(band1, band2, color = isMmfOversold and not isMmfStupidOversold ? color.new(col_lightGreen, 85) : col_none, title="MMF oversold", display=display.none) fill(band3, band4, color = isMmfOverbought and not isMmfStupidOverbought? color.new(col_outrageousOrange, 85) : col_none, title="MMF overbought", display=display.none) fill(band1, band2, color = isMmfStupidOversold ? color.new(col_lightGreen, 80) : col_none, title="MMF stupid oversold") fill(band3, band4, color = isMmfStupidOverbought ? color.new(col_outrageousOrange, 70) : col_none, title="MMF stupid overbought") // Alerts if isMmfOverbought alert("MMF overbought: " + str.tostring(mmf), alert.freq_once_per_bar_close) if isMmfOversold alert("MMF oversold: " + str.tostring(mmf), alert.freq_once_per_bar_close) if isMmfStupidOverbought alert("MMF stupid overbought: " + str.tostring(mmf), alert.freq_once_per_bar_close) if isMmfStupidOversold alert("MMF stupid oversold: " + str.tostring(mmf), alert.freq_once_per_bar_close)
Bear Bull Ratio (BBR)
https://www.tradingview.com/script/ROSKCfLR-Bear-Bull-Ratio-BBR/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
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/ // © peacefulLizard50262 //@version=5 indicator("Bear Bull Ratio") true_range = input.bool(false, "Enable True Range Mode") length = input.int(20, "Windowed Length", 1) bear_bull_ratio()=> var float open_count = 0 var float close_count = 0 if open > close and close < close[1] open_count := nz(open_count[1]) + 1 if open < close and close < close[1] open_count := nz(open_count[1]) + 1 if open < close and close > close[1] close_count := nz(close_count[1]) + 1 if open > close and close > close[1] close_count := nz(close_count[1]) + 1 bear_bull_ratio = (close_count/(open_count + close_count)) * 100 bear_bull_ratio_average()=> var float open_count = 0 var float close_count = 0 if open > close and close < close[1] open_count := nz(open_count[1]) + 1 if open < close and close < close[1] open_count := nz(open_count[1]) + 1 if open < close and close > close[1] close_count := nz(close_count[1]) + 1 if open > close and close > close[1] close_count := nz(close_count[1]) + 1 bear_bull_ratio = (close_count/(open_count + close_count)) * 100 var float average_open_close = 0 var int average_open_close_counter = 0 if close == close average_open_close_counter := nz(average_open_close_counter[1]) + 1 average_open_close := nz(average_open_close[1]) + bear_bull_ratio average_ratio = average_open_close/average_open_close_counter bear_bull_ratio_true_range()=> var float open_count = 0 var float close_count = 0 if open > close and close < close[1] open_count := nz(open_count[1]) + (high - low) if open < close and close < close[1] open_count := nz(open_count[1]) + (high - low) if open < close and close > close[1] close_count := nz(close_count[1]) + (high - low) if open > close and close > close[1] close_count := nz(close_count[1]) + (high - low) bear_bull_ratio = (close_count/(open_count + close_count)) * 100 bear_bull_ratio_average_true_range()=> var float open_count = 0 var float close_count = 0 if open > close and close < close[1] open_count := nz(open_count[1]) + (high - low) if open < close and close < close[1] open_count := nz(open_count[1]) + (high - low) if open < close and close > close[1] close_count := nz(close_count[1]) + (high - low) if open > close and close > close[1] close_count := nz(close_count[1]) + (high - low) bear_bull_ratio = (close_count/(open_count + close_count)) * 100 var float average_open_close = 0 var int average_open_close_counter = 0 if close == close average_open_close_counter := nz(average_open_close_counter[1]) + 1 average_open_close := nz(average_open_close[1]) + bear_bull_ratio average_ratio = average_open_close/average_open_close_counter plot(true_range ? bear_bull_ratio_true_range() : bear_bull_ratio(), "Bear Bull Ratio", color.orange) plot(ta.wma(true_range ? bear_bull_ratio_true_range() : bear_bull_ratio(), length), "Windowed Average Bear Bull Ratio") plot(true_range ? bear_bull_ratio_average_true_range() : bear_bull_ratio_average(), "Average Bear Bull Ratio", color.gray)
Fibonacci Bollinger Bands (FBB)
https://www.tradingview.com/script/2NHVDr0u-Fibonacci-Bollinger-Bands-FBB/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
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/ // © peacefulLizard50262 //@version=5 indicator("Fibonacci Moving Average", "FMA", true) metallic_mean(source)=> (source+math.sqrt(math.pow(source, 2) + 4))/2 fma(source, length)=> float src = metallic_mean(source) var float weight_sum = na var float sum = na for i = 0 to length - 1 weight = metallic_mean(i) weight_sum := nz(weight_sum[1]) + weight sum := nz(sum[1]) + src * weight out = (sum - nz(sum[length]))/(weight_sum - nz(weight_sum[length])) fstdev(source, length)=> math.sqrt(math.sum(math.pow(metallic_mean(source) - fma(source, length), 2), length)/(length-1)) source = input.source(close, "Source") length = input.int(20, "Length", 2) up_two = input.bool(false, "High | 0.236", group = "High") up_three = input.bool(false, "High | 0.382", group = "High") up_four = input.bool(false, "High | 0.5", group = "High") up_five = input.bool(false, "High | 0.618", group = "High") up_six = input.bool(true, "High | 0.764", group = "High") up_one = input.bool(false, "High | 1", group = "High") up_seven = input.bool(true, "High | 1.618", group = "High") up_eight = input.bool(true, "High | 2.618", group = "High") down_two = input.bool(false, "Low | 0.236", group = "Low") down_three = input.bool(false, "Low | 0.382", group = "Low") down_four = input.bool(false, "Low | 0.5", group = "Low") down_five = input.bool(false, "Low | 0.618", group = "Low") down_six = input.bool(true, "Low | 0.764", group = "Low") down_one = input.bool(false, "Low | 1", group = "Low") down_seven = input.bool(true, "Low | 1.618", group = "Low") down_eight = input.bool(true, "Low | 2.618", group = "Low") avg = fma(source, length) dev = fstdev(source, length) up = up_one ? avg + dev : na up_0 = (up_two ? avg : na) + (0.236*dev) up_1 = (up_three ? avg : na) + (0.382*dev) up_2 = (up_four ? avg : na) + (0.5*dev) up_3 = (up_five ? avg : na) + (0.618*dev) up_4 = (up_six ? avg : na) + (0.786*dev) up_5 = (up_seven ? avg : na) + (1.618*dev) up_6 = (up_eight ? avg : na) + (2.618*dev) dn = down_one ? avg - dev : na dn_0 = (down_two ? avg : na) - (0.236*dev) dn_1 = (down_three ? avg : na) - (0.382*dev) dn_2 = (down_four ? avg : na) - (0.5*dev) dn_3 = (down_five ? avg : na) - (0.618*dev) dn_4 = (down_six ? avg : na) - (0.786*dev) dn_5 = (down_seven ? avg : na) - (1.618*dev) dn_6 = (down_eight ? avg : na) - (2.618*dev) plot(avg, "Center", #787b86) plot(up, "1.0 Up", #787b86) plot(dn, "1.0 Down", #787b86) plot(up_0, "0.236 Up", #f44336) plot(up_1, "0.382 Up", #81c784) plot(up_2, "0.5 Up", #4caf50) plot(up_3, "0.618 Up", #009688) plot(up_4, "0.786 Up", #64b5f6) plot(up_5, "1.618 Up", #2962ff) plot(up_6, "2.618 Up", #f44336) plot(dn_0, "0.236 Down", #f44336) plot(dn_1, "0.382 Down", #81c784) plot(dn_2, "0.5 Down", #4caf50) plot(dn_3, "0.618 Down", #009688) plot(dn_4, "0.786 Down", #64b5f6) plot(dn_5, "1.618 Down", #2962ff) plot(dn_6, "2.618 Down", #f44336)
AQ ema200
https://www.tradingview.com/script/ZL7lwSLK-AQ-ema200/
nkqforex2021
https://www.tradingview.com/u/nkqforex2021/
161
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © nkqforex2021 //@version=5 indicator("AQ ema for XAUUSD") string symbol=syminfo.ticker Ema_value=input(defval = 200) //float m1_rank=input.float(defval = 16) m1_rank=switch symbol "EURUSD"=>0.006 "GBPUSD"=>0.011 "USDJPY"=>1.4 "XAUUSD"=>17 "AUDUSD"=>0.006 "USDCAD"=>0.006 "USDCHF"=>0.008 "NZDUSD"=>0.006 "GBPJPY"=>1.690 //float m2_rank=input.float(defval = 25) m2_rank=switch symbol "EURUSD"=>0.008 "GBPUSD"=>0.016 "USDJPY"=>2 "XAUUSD"=>24 "AUDUSD"=>0.008 "USDCAD"=>0.009 "USDCHF"=>0.011 "NZDUSD"=>0.008 "GBPJPY"=>2.510 //float Stoplevel=input.float(defval = 34) Stoplevel=switch symbol "EURUSD"=>m1_rank*2 "GBPUSD"=>m1_rank*2 "USDJPY"=>m1_rank*2 "XAUUSD"=>m1_rank*2 "AUDUSD"=>m1_rank*2 "USDCAD"=>m1_rank*2 "USDCHF"=>m1_rank*2 "NZDUSD"=>m1_rank*2 "GBPJPY"=>m1_rank*2 color a=color.green h=high c=low float k=0 ema=ta.ema(close,Ema_value) if h>ema k:=h-ema else k:=c-ema a:=color.red plot(k,"signal",a) plot(0,"midle",color.rgb(82, 76, 76)) plot((m1_rank),"top5m",color.rgb(14, 87, 17)) plot((m1_rank)*(-1),"bot5m",color.rgb(33, 83, 33)) plot((m2_rank),"top15m",color.rgb(124, 117, 41)) plot((m2_rank)*(-1),"bot15m",color.rgb(126, 119, 44)) plot((Stoplevel),"toph1",color.red) plot((Stoplevel)*(-1),"both1",color.red)
Lines and Table for risk management
https://www.tradingview.com/script/02Nx4aeh-Lines-and-Table-for-risk-management/
TaTaTaCrypto
https://www.tradingview.com/u/TaTaTaCrypto/
131
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © TaTaTaCrypto //@version=5 indicator(title="Lines for Take Profit and Stop Loss", overlay=true) //Input options leverage = input.int(1, "Leverage") percent = input.float(0.5,'Stepsize (x Leverage)') f1 = (100-(percent*1*leverage))/100 f2 = (100-(percent*2*leverage))/100 f3 = (100-(percent*3*leverage))/100 f4 = (100+(percent*1*leverage))/100 f5 = (100+(percent*2*leverage))/100 f6 = (100+(percent*3*leverage))/100 //horizontal lines - empty line variables var line l985 = na var line l99 = na var line l995 = na var line l0 = na var line l1005 = na var line l101 = na var line l1015 = na table panel = table.new(position.top_right, 2, 8,frame_width=1, border_width=1, border_color=color.new(color.white, 100)) if barstate.islast l985 := line.new(x1=bar_index[1], y1=close*f3, x2=bar_index, y2=close*f3, width=1, extend=extend.both) l99 := line.new(x1=bar_index[1], y1=close*f2 , x2=bar_index, y2=close*f2, width=1, extend=extend.both) l995 := line.new(x1=bar_index[1], y1=close*f1, x2=bar_index, y2=close*f1, width=1, extend=extend.both) l0 := line.new(x1=bar_index[1], y1=close*1, x2=bar_index, y2=close*1, width=1, extend=extend.both) l1005 := line.new(x1=bar_index[1], y1=close*f4, x2=bar_index, y2=close*f4, width=1, extend=extend.both) l101 := line.new(x1=bar_index[1], y1=close*f5, x2=bar_index, y2=close*f5, width=1, extend=extend.both) l1015 := line.new(x1=bar_index[1], y1=close*f6, x2=bar_index, y2=close*f6, width=1, extend=extend.both) line.set_color(id=l985, color=color.gray) line.set_style(id=l985, style=line.style_solid) line.set_color(id=l99, color=color.gray) line.set_style(id=l99, style=line.style_solid) line.set_color(id=l995, color=color.gray) line.set_style(id=l995, style=line.style_solid) line.set_color(id=l0, color=color.gray) line.set_style(id=l0, style=line.style_dashed) line.set_color(id=l1005, color=color.gray) line.set_style(id=l1005, style=line.style_solid) line.set_color(id=l101, color=color.gray) line.set_style(id=l101, style=line.style_solid) line.set_color(id=l1015, color=color.gray) line.set_style(id=l1015, style=line.style_solid) table.cell(panel, 0, 0, "Leverage X "+str.tostring(leverage), bgcolor =color.white) table.cell(panel, 0, 3, "+"+str.tostring(percent*1*leverage)+"%", bgcolor =color.white) table.cell(panel, 0, 2, "+"+str.tostring(percent*2*leverage)+"%", bgcolor = color.white) table.cell(panel, 0, 1, "+"+str.tostring(percent*3*leverage)+"%", bgcolor = color.white) table.cell(panel, 0, 4, "Price", bgcolor = color.white) table.cell(panel, 0, 5, "-"+str.tostring(percent*leverage)+"%", bgcolor = color.white) table.cell(panel, 0, 6, "-"+str.tostring(percent*2*leverage)+"%" ,bgcolor = color.white) table.cell(panel, 0, 7, "-"+str.tostring(percent*3*leverage)+"%", bgcolor = color.white) table.cell(panel, 1, 1, str.tostring(close*f6,'#.####'), bgcolor = #fcfcfc) table.cell(panel, 1, 2, str.tostring(close*f5,'#.####'), bgcolor = #fcfcfc) table.cell(panel, 1, 3, str.tostring(close*f4,'#.####'), bgcolor = #fcfcfc) table.cell(panel, 1, 4, str.tostring(close,'#.####'), bgcolor = #fcfcfc) table.cell(panel, 1, 5, str.tostring(close*f1,'#.####'), bgcolor = #fcfcfc) table.cell(panel, 1, 6, str.tostring(close*f2,'#.####'), bgcolor = #fcfcfc) table.cell(panel, 1, 7, str.tostring(close*f3,'#.####'), bgcolor = #fcfcfc) table.merge_cells(panel,0,0,1,0) // end of script here
Volume Crop ━ Hidden Volume Divergence [whvntr]
https://www.tradingview.com/script/FTabKFhw-Volume-Crop-Hidden-Volume-Divergence-whvntr/
whvntr
https://www.tradingview.com/u/whvntr/
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/ // ─© whvntr Tyler Ray // @version=5 // • Hidden Divergence formula by TheLark. // • Filter for that divergence formula by ─© whvntr // • I have filtered the hidden divergence formula to display only signals on one side of // midline, by using my "Mideline Tool", and thereby filtering out a lot of false siganls. indicator(title='Volume Crop ━ Hidden Volume Divergence [whvntr]', format=format.volume, precision=2, overlay = true, shorttitle='VOL_CROP ━ whvntr') //######################################################### // ℹ️ Source ─© whvntr //######################################################### float src = volume //######################################################### // ℹ️ Source ─© whvntr //######################################################### //######################################################### // ╸> ╸ ╸> ╸ ╸ ╸> ─© whvntr //######################################################### var s_b = true var s_b_1 = true var s_b_2 = true var s_b_3 = true var not_s_b = not s_b var not_s_b_1 = not s_b_1 var not_s_b_2 = not s_b_2 var not_s_b_3 = not s_b_3 // ╸> ╸ ╸> ╸ ╸ ╸> var s_l = true var s_l_1 = true var s_l_2 = true var s_l_3 = true var not_s_l = not s_l var not_s_l_1 = not s_l_1 var not_s_l_2 = not s_l_2 var not_s_l_3 = not s_l_3 //######################################################### // ╸> ╸ ╸> ╸ ╸ ╸> ─© whvntr //######################################################### //######################################################### // 🗓️ Multiple Timeframes ─© whvntr //######################################################### keepFrame = input.bool(defval = true , title = '' , group = '☑ Chart Timeframe ‎ ‎ ✗☐ To Use Multi') keepFrameFor = keepFrame ? timeframe.period : timeframe.period changetframeBear = input.timeframe (title='📕' , defval ='10', group = "Multiple Timeframes" , inline = 'books' , tooltip = '🐼 ‎ & ‎ 🐂') changetframeBull = input.timeframe(title='📘' , defval='10' , inline = 'books' , group = 'Multiple Timeframes' , tooltip = '🐼 ‎ & ‎ 🐂') alt_period_bear = keepFrame ? keepFrameFor : changetframeBear alt_period_bull = keepFrame ? keepFrameFor : changetframeBull //######################################################### // 🗓️ Multiple Timeframes ─© whvntr //######################################################### //######################################################### // Tooltips ─© whvntr //######################################################### string MIDLINETOOLBEAR = '🐼 Adjusting this line will alter the inclusion spots for the MACD cross signals' string MACDDEFBEAR = '🐼 MACD is calculated by subtracting the long-term EMA (26 periods) from the short-term EMA (12 periods). An EMA is a type of moving average (MA) that places a greater weight and significance on the most recent data points. The exponential moving average is also referred to as the exponentially weighted moving average' string HIDDENDIVERGENCEBEAR = '🐼 Adjust the length of the SMA that will cross with the EMAs (MACD)' string MIDLINETOOLBULL = '🐂 Adjusting this line will alter the inclusion spots for the MACD cross signals' string MACDDEFBULL = '🐂 MACD is calculated by subtracting the long-term EMA (26 periods) from the short-term EMA (12 periods). An EMA is a type of moving average (MA) that places a greater weight and significance on the most recent data points. The exponential moving average is also referred to as the exponentially weighted moving average' string HIDDENDIVERGENCEBULL = '🐂 Adjust the length of the SMA that will cross with the EMAs (MACD)' string REPAINTING = 'Checking this box will permit signals to show before the realtime bar has closed' //######################################################### // Tooltips ─© whvntr //######################################################### //######################################################### // Detect Short/Longs ─© whvntr //######################################################### shorts_input = input.bool(true , title = "𝘚𝘩𝘰𝘳𝘵𝘴" , group = 'Detect' , inline = 'exit_arrow') longs_input = input.bool(true , title = "𝘓𝘰𝘯𝘨𝘴‎ ‎ " , group = 'Detect' , inline = 'take_arrow') //######################################################### // Detect Short/Longs ─© whvntr //######################################################### //######################################################### // ☐ or ✔ ─© whvntr //######################################################### var bull_spot_true = true var bear_spot_true = true var arrow_below_color_true = true var arrow_above_color_true = true //######################################################### // ☐ or ✔ ─© whvntr //######################################################### //######################################################### // 🖌︎ CSS Menu ─© whvntr //######################################################### arrow_above_color_css = input.color(#be0e49,'' , group = 'Detect' , inline = 'exit_arrow') arrow_below_color_css = input.color(#2962ff,'' , group = 'Detect' , inline = 'take_arrow') bear_dot_css = input(#f8bbd0,'•' , group = 'Dots & Arrow Lengths' , inline = 'exit_dot') bull_dot_css = input(#5fd0ff,'•' , group = 'Dots & Arrow Lengths' , inline = 'take_dot') //######################################################### // 🖌︎ CSS Menu ─© whvntr //######################################################### //######################################################### // ╍╍ MACD 🐼 ─© whvntr //######################################################### ema_len_26_bear = input.int(7, minval=1 , title= '┉ ┉' , group = 'MACD Bearish' , tooltip = MACDDEFBEAR , inline = 'macd_bear') ema_len_12_bear = input.int(5, minval=1 , title= '┉' , group = 'MACD Bearish' , tooltip = MACDDEFBEAR , inline = 'macd_bear') ema_26_bear = ta.ema(src, ema_len_26_bear) ema_12_bear = ta.ema(src, ema_len_12_bear) macd_bear = ema_12_bear - ema_26_bear sma_len_10_bear = input(10, title = '⦿' , group = "Hidden Divergence Length ‎" , tooltip = HIDDENDIVERGENCEBEAR) //######################################################### // ╍╍ MACD 🐼 ─© whvntr //######################################################### //######################################################### // ◉ Circles Formula 🐼 ─ TheLark © //######################################################### cross_bear = ta.sma(macd_bear, sma_len_10_bear) out_bear = request.security(syminfo.tickerid, alt_period_bear , macd_bear) in_bear = request.security(syminfo.tickerid, alt_period_bear , cross_bear) macd_bear_cross = out_bear >= in_bear arrow_above = arrow_above_color_true ? macd_bear_cross ? na : arrow_above_color_css : na locate_bear = in_bear bear_spot = ta.cross(out_bear, in_bear) ? locate_bear : na dot_above = arrow_below_color_true ? macd_bear_cross ? na : bear_dot_css : na //######################################################### // ◉ Circles Formula 🐼 ─ TheLark © //######################################################### var r_t_b = true var r_t_l = true if barstate.isconfirmed == false and barstate.isrealtime == true r_t_b := false if barstate.isconfirmed == false and barstate.isrealtime == true r_t_l := false //######################################################### // ⚙️ Midline Tool 🐼 ─© whvntr //########################################################## midline_bear = input.float(defval = 0, minval = -50000000000 , maxval = 50000000000, step = 1000, title = '🎮' , group = 'Midline Tool ‎' , tooltip = MIDLINETOOLBEAR) bear_found_midline_tool = ta.cross(bear_spot, midline_bear) no_repaint_bear = bear_found_midline_tool and r_t_b bear_alert = bear_found_midline_tool[0] and not bear_found_midline_tool[1] and r_t_b //######################################################### // ⚙️ Midline Tool 🐼 ─© whvntr //######################################################### //######################################################### // 🎯 Arrow Length Feature 🐼 Position ─© whvntr //######################################################### string one_len_bear = '╸' string two_len_bear = '╸ ╸' string three_len_bear = '╸ ╸ ╸' arrow_style_bear = input.string(defval = '╸ ╸ ╸' , title = '‎ ‎ ' , inline = 'exit_dot' , options = [one_len_bear, two_len_bear, three_len_bear] , group = 'Dots & Arrow Lengths' , tooltip = 'Adjust the length of the arrows') var get_1_bear = arrow_style_bear == one_len_bear var get_2_bear = arrow_style_bear == two_len_bear var get_3_bear = arrow_style_bear == three_len_bear if arrow_style_bear == one_len_bear not_s_b_1 := true if arrow_style_bear == two_len_bear not_s_b_2 := true if arrow_style_bear == three_len_bear not_s_b_3 := true plotchar(no_repaint_bear and not_s_b_1 and shorts_input , title = '' , text = '|\nv' , textcolor = arrow_above , location=location.abovebar , offset=0 , color = dot_above , char = '•' , size=size.tiny, editable = false) plotchar(no_repaint_bear and not_s_b_2 and shorts_input , title = '' , text = '|\n|\nv' , textcolor = arrow_above , location=location.abovebar , offset=0, color = dot_above , char = '•' , size=size.tiny, editable = false) plotchar(no_repaint_bear and not_s_b_3 and shorts_input , title = '' , text = '|\n|\n|\nv' , textcolor = arrow_above , location=location.abovebar , offset=0, color = dot_above , char = '•' , size=size.tiny, editable = false) //######################################################### // 🎯 Arrow Length Feature 🐼 Position ─© whvntr //######################################################### //######################################################### // ╍╍ MACD 🐂 ─© whvntr //######################################################### ema_len_26_bull = input.int(7, minval=1 , title= '┉ ┉' , group = 'MACD Bullish' , tooltip = MACDDEFBULL , inline = 'macd_bull') ema_len_12_bull = input.int(5, minval=1 , group = 'MACD Bullish' , title= '┉' , tooltip = MACDDEFBULL , inline = 'macd_bull') ema_26_bull = ta.ema(src, ema_len_26_bull) ema_12_bull = ta.ema(src, ema_len_12_bull) macd_bull = ema_12_bull - ema_26_bull sma_len_10_bull = input(10 , title = '⦿' , group = "Hidden Divergence Length" , tooltip = HIDDENDIVERGENCEBULL) //######################################################### // ╍╍ MACD 🐂 ─© whvntr //######################################################### //######################################################### // ◉ Circles Formula 🐂 ─ TheLark © //######################################################### cross_bull = ta.sma(macd_bull, sma_len_10_bull) out_bull = request.security(syminfo.tickerid , alt_period_bull, macd_bull) in_bull = request.security(syminfo.tickerid , alt_period_bull, cross_bull) macd_bull_cross = out_bull >= in_bull arrow_below = arrow_below_color_true ? macd_bull_cross ? arrow_below_color_css : na : na locate_bull = in_bull bull_spot = ta.cross(out_bull, in_bull) ? locate_bull : na via_bull = bull_spot_true and bull_spot dot_below = arrow_below_color_true ? macd_bull_cross ? bull_dot_css : na : na //######################################################### // ◉ Circles Formula 🐂 ─ TheLark © //######################################################### //######################################################### // ⚙️ Midline Tool 🐂 ─© whvntr //######################################################### midline_bull = input.float(defval = 0 , minval = -50000000000 , maxval = 50000000000, step = 1000, title = '🎮' , group = 'Midline Tool' , tooltip = MIDLINETOOLBULL) bull_found_midline_tool = ta.cross(bull_spot, midline_bull) no_repaint_bull = bull_found_midline_tool and r_t_l bull_alert = bull_found_midline_tool and r_t_l //######################################################### // ⚙️ Midline Tool 🐂 ─© whvntr //######################################################### //######################################################### // 🎯 Arrow Length Feature 🐂 Position ─© whvntr //######################################################### string one_len_bull = '╸' string two_len_bull = '╸ ╸' string three_len_bull = '╸ ╸ ╸' arrow_style_bull = input.string(defval = '╸ ╸ ╸' , title = '‎ ‎ ' , inline = 'take_dot' , options = [one_len_bull, two_len_bull, three_len_bull] , group = 'Dots & Arrow Lengths' , tooltip = 'Adjust the length of the arrows') var get_1_bull = arrow_style_bull == one_len_bull var get_2_bull = arrow_style_bull == two_len_bull var get_3_bull = arrow_style_bull == three_len_bull if arrow_style_bull == one_len_bull not_s_l_1 := true if arrow_style_bull == two_len_bull not_s_l_2 := true if arrow_style_bull == three_len_bull not_s_l_3 := true plotchar(no_repaint_bull and not_s_l_1 and longs_input , title = '' , text = 'ʌ\n|' , textcolor = arrow_below , location=location.belowbar , offset=0, color = dot_below , char = '•' , size=size.tiny, editable = false) plotchar(no_repaint_bull and not_s_l_2 and longs_input , title = '' , text = 'ʌ\n|\n|' , textcolor = arrow_below , location=location.belowbar , offset=0, color = dot_below , char = '•' , size=size.tiny, editable = false) plotchar(no_repaint_bull and not_s_l_3 and longs_input , title = '' , text = 'ʌ\n|\n|\n|' , textcolor = arrow_below , location=location.belowbar , offset=0, color = dot_below , char = '•' , size=size.tiny, editable = false) //######################################################### // 🎯 Arrow Length Feature 🐂 Position ─© whvntr //#########################################################
Body- and Shadowsizes
https://www.tradingview.com/script/IVTFtefh/
martinislichten
https://www.tradingview.com/u/martinislichten/
8
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © martinislichten //@version=5 indicator("Mein Skript") //Init of variables float ls = 0 float bd = 0 float us = 0 float ls1 = 0 float bd1 = 0 float us1 = 0 float tra1 = 0 float tra2 = 0 float tra3 = 0 length = input.int(100, 'lookback', minval = 1) //Length of Lookback for Calculation length1 = input.int(2001, 'lookback1', minval = 1) //Length of Lookback for Comparison deltalookback = input.int (20, "deltalookback", minval = 3) //Length of Lookback for Delta-Calculation //Calculation of Shadow and Body Sizes for wanted length for i = 0 to length - 1 if close[i] < open[i] ls += close[i] - low[i] bd += open[i] - close[i] us += high[i] - open[i] else if close[i] > open[i] ls += open[i] - low[i] bd += close[i] - open[i] us += high[i] - close[i] //Calculation of Shadow and Body Sizes for compared length for j = 0 to length1 - 1 if close[j] < open[j] ls1 += close[j] - low[j] bd1 += open[j] - close[j] us1 += high[j] - open[j] else if close[j] > open[j] ls1 += open[j] - low[j] bd1 += close[j] - open[j] us1 += high[j] - close[j] ta.pivothigh(length,0) //Relation of the bigger to the smaller Lookback, so that the same amount of candles will be compared later on //Verhältnis der zwei Lookbacks, sodass gleiche Zeiträume miteinander verglichen werden float verhlengthes1 = length1/length //Average of the comparing lookback, adjusted to amount of candles of the bigger one //Durschnitt der jeweiligen Größen angepasst auf die kürzere Länge avgLS1 = ls1/verhlengthes1 avgBS1 = bd1/verhlengthes1 avgUS1 = us1/verhlengthes1 //Differences of shadow and bodysizes for f = 0 to deltalookback - 1 tra1 += ls[f] - ls[f + 1] for f = 0 to deltalookback - 1 tra2 += bd[f] - bd[f + 1] for f = 0 to deltalookback - 1 tra3 += us[f] - us[f + 1] //plot //Zeichnen plot(ls,"Lower Shadow Size", color = color.red) plot(bd,"Body Size", color = color.yellow, linewidth = 3) plot(us,"Upper Shadow Size", color = color.green) plot(avgLS1,"Average Lower Shadow Size", color = color.blue) plot(avgBS1,"Average Body Size", color = color.purple, linewidth = 3) plot(avgUS1,"Average Upper Shadow Size", color = color.navy) plot(ls1,"Lower Shadow Size To Compare", color = color.black) plot(bd1,"Body Size To Compare", color = color.lime, linewidth = 3) plot(us1,"Upper Shadow Size To Compare", color = color.silver) plot(tra1,"Delta of Lower Shadows", color = color.orange) plot(tra2,"Delta of Bodies", color = color.aqua) plot(tra3,"Delta of Higher Shadows", color = color.teal) //plot(close)
Fiat Currency and Gold Indices (FGXY) Candles
https://www.tradingview.com/script/yKvnQZ9t-Fiat-Currency-and-Gold-Indices-FGXY-Candles/
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 // Credit to @loxx for the stock DXY in pinescript //@version=5 indicator("Fiat Currency and Gold Indices (FGXY) Candles",shorttitle="FGXY",overlay = false,timeframe='', timeframe_gaps = true) transparency = input.int(0,'Transparency') greencolor = color.new(input.color(#ACFB00,'Up Color'),transparency) redcolor = color.new(input.color(#FF0000,'Down Color'),transparency) //Default: Gold Index str = input.string("CAD","(3 Letter Prefix: XAU,USD,CAD,EUR etc.)",group='Main Currency') pair1 =input.string("EUR",'Currency Pair #1 (3 Letter Prefix)',group="Pair 1") pair2 =input.string("JPY",'Currency Pair #2 (3 Letter Prefix)',group="Pair 2") pair3 =input.string("GBP",'Currency Pair #3 (3 Letter Prefix)',group="Pair 3") pair4 =input.string("CAD",'Currency Pair #4 (3 Letter Prefix)',group="Pair 4") pair5 =input.string("SEK",'Currency Pair #5 (3 Letter Prefix)',group="Pair 5") pair6 =input.string("CHF",'Currency Pair #6 (3 Letter Prefix)',group="Pair 6") var string EUR = str == "USD" ? pair1+"USD": str == "XAU"? str + pair1 : str != "EUR" ? str + pair1 : pair1 + "USD"// "" + str : var string JPY = str == "USD" ? "USD"+pair2 : str == "XAU"? str + pair2 : str != "JPY" ? str + pair2 : "USD" + pair2 // str + "JPY" : var string GBP = str == "USD" ? pair3+"USD": str == "XAU"? str + pair3 : str != "GBP" ? str + pair3 : pair3 + "USD" // "" + str : var string CAD = str == "USD" ? "USD"+pair4 : str == "XAU"? str + pair4 : str != "CAD" ? str + pair4 : "USD" + pair4 // str + "" var string SEK = str == "USD" ? "USD"+pair5 : str == "XAU"? "XAUSEK1630GMTSEK": str != "SEK" ? str + pair5 : "USD" + pair5 // st + "" var string CHF = str == "USD" ? "USD"+pair6 : str == "XAU"? str + pair6 : str != "CHF" ? str + pair6 : "USD" + pair6 // str + "" //Default DXY Weights sym1 = EUR , weight1 = input.float(0.576,group='Pair 1') sym2 = JPY , weight2 = input.float(0.136,group='Pair 2') sym3 = GBP , weight3 = input.float(0.119,group='Pair 3') sym4 = CAD , weight4 = input.float(0.091,group='Pair 4') sym5 = SEK , weight5 = input.float(0.042,group='Pair 5') sym6 = CHF , weight6 = input.float(0.036,group='Pair 6') //OHLC eurc = request.security(sym1, timeframe.period, nz(close,close[1])) euro = request.security(sym1, timeframe.period, nz(open ,open [1])) eurh = request.security(sym1, timeframe.period, nz(high ,high [1])) eurl = request.security(sym1, timeframe.period, nz(low ,low [1])) jpyc = request.security(sym2, timeframe.period, nz(close,close[1])) jpyo = request.security(sym2, timeframe.period, nz(open ,open [1])) jpyh = request.security(sym2, timeframe.period, nz(high ,high [1])) jpyl = request.security(sym2, timeframe.period, nz(low ,low [1])) gbpc = request.security(sym3, timeframe.period, nz(close,close[1])) gbpo = request.security(sym3, timeframe.period, nz(open ,open [1])) gbph = request.security(sym3, timeframe.period, nz(high ,high [1])) gbpl = request.security(sym3, timeframe.period, nz(low ,low [1])) cadc = request.security(sym4, timeframe.period, nz(close,close[1])) cado = request.security(sym4, timeframe.period, nz(open ,open [1])) cadh = request.security(sym4, timeframe.period, nz(high ,high [1])) cadl = request.security(sym4, timeframe.period, nz(low ,low [1])) sekc = request.security(sym5, timeframe.period, nz(close,close[1])) seko = request.security(sym5, timeframe.period, nz(open ,open [1])) sekh = request.security(sym5, timeframe.period, nz(high ,high [1])) sekl = request.security(sym5, timeframe.period, nz(low ,low [1])) chfc = request.security(sym6, timeframe.period, nz(close,close[1])) chfo = request.security(sym6, timeframe.period, nz(open ,open [1])) chfh = request.security(sym6, timeframe.period, nz(high ,high [1])) chfl = request.security(sym6, timeframe.period, nz(low ,low [1])) g=str=="XAU"?1:-1 //Apply DXY formula to OHLC values dxyClose = 50.14348112 * math.pow(eurc, g*weight1) * math.pow(jpyc, weight2) * math.pow(gbpc, -1*weight3) * math.pow(cadc, weight4) * math.pow(sekc, weight5) * math.pow(chfc, weight6) dxyOpen = 50.14348112 * math.pow(euro, g*weight1) * math.pow(jpyo, weight2) * math.pow(gbpo, -1*weight3) * math.pow(cado, weight4) * math.pow(seko, weight5) * math.pow(chfo, weight6) dxyHigh = 50.14348112 * math.pow(eurh, g*weight1) * math.pow(jpyh, weight2) * math.pow(gbph, -1*weight3) * math.pow(cadh, weight4) * math.pow(sekh, weight5) * math.pow(chfh, weight6) dxyLow = 50.14348112 * math.pow(eurl, g*weight1) * math.pow(jpyl, weight2) * math.pow(gbpl, -1*weight3) * math.pow(cadl, weight4) * math.pow(sekl, weight5) * math.pow(chfl, weight6) color= dxyOpen < dxyClose ? greencolor : redcolor //Plot plotcandle(dxyOpen, dxyHigh, dxyLow, dxyClose, title='FGXY', color =color,bordercolor=color, wickcolor=color)
True Bitcoin Value USD - Mario M
https://www.tradingview.com/script/CGOKMxuD-True-Bitcoin-Value-USD-Mario-M/
m.moerman58
https://www.tradingview.com/u/m.moerman58/
26
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //Author - Mario Moerman //@version=4 study("True Bitcoin Value - Mario M" ,overlay=true) // INPUTS p_china = 0.04 p_og = 0.05 p_new = 0.0645 elec_pct = 1 plot_mp = true // DATA fees = security("QUANDL:BCHAIN/TRFUS","D",close) elec_consumption() => // Cambridge Bitcoin Electricity Consumption Index (CBECI) - Bitcoin's global electricity consumption in TwH. // NB: Uses MONTHLY averages of raw data from CBECI. TV script run-time is too slow with Daily/Weekly data here. // This requires manual updating once a month for ongoing accuracy. d = dayofmonth m = month y = year e = float(na) e := d==1 and m==1 and y==2012? 0.06 : d==8 and m==1 and y==2012? 0.07 : d==15 and m==1 and y==2012? 0.07 : d==22 and m==1 and y==2012? 0.07 : d==29 and m==1 and y==2012? 0.07 : d==5 and m==2 and y==2012? 0.08 : d==12 and m==2 and y==2012? 0.07 : d==19 and m==2 and y==2012? 0.07 : d==26 and m==2 and y==2012? 0.08 : d==4 and m==3 and y==2012? 0.08 : d==11 and m==3 and y==2012? 0.08 : d==18 and m==3 and y==2012? 0.08 : d==25 and m==3 and y==2012? 0.09 : d==1 and m==4 and y==2012? 0.09 : d==8 and m==4 and y==2012? 0.08 : d==15 and m==4 and y==2012? 0.08 : d==22 and m==4 and y==2012? 0.08 : d==29 and m==4 and y==2012? 0.08 : d==6 and m==5 and y==2012? 0.09 : d==13 and m==5 and y==2012? 0.09 : d==20 and m==5 and y==2012? 0.09 : d==27 and m==5 and y==2012? 0.08 : d==3 and m==6 and y==2012? 0.08 : d==10 and m==6 and y==2012? 0.09 : d==17 and m==6 and y==2012? 0.09 : d==24 and m==6 and y==2012? 0.09 : d==1 and m==7 and y==2012? 0.09 : d==8 and m==7 and y==2012? 0.1 : d==15 and m==7 and y==2012? 0.1 : d==22 and m==7 and y==2012? 0.1 : d==29 and m==7 and y==2012? 0.11 : d==5 and m==8 and y==2012? 0.11 : d==12 and m==8 and y==2012? 0.12 : d==19 and m==8 and y==2012? 0.13 : d==26 and m==8 and y==2012? 0.13 : d==2 and m==9 and y==2012? 0.14 : d==9 and m==9 and y==2012? 0.15 : d==16 and m==9 and y==2012? 0.15 : d==23 and m==9 and y==2012? 0.16 : d==30 and m==9 and y==2012? 0.16 : d==7 and m==10 and y==2012? 0.15 : d==14 and m==10 and y==2012? 0.17 : d==21 and m==10 and y==2012? 0.17 : d==28 and m==10 and y==2012? 0.18 : d==4 and m==11 and y==2012? 0.18 : d==11 and m==11 and y==2012? 0.18 : d==18 and m==11 and y==2012? 0.17 : d==25 and m==11 and y==2012? 0.19 : d==2 and m==12 and y==2012? 0.2 : d==9 and m==12 and y==2012? 0.07 : d==16 and m==12 and y==2012? 0.05 : d==23 and m==12 and y==2012? 0.05 : d==30 and m==12 and y==2012? 0.05 : d==6 and m==1 and y==2013? 0.05 : d==13 and m==1 and y==2013? 0.05 : d==20 and m==1 and y==2013? 0.05 : d==27 and m==1 and y==2013? 0.05 : d==3 and m==2 and y==2013? 0.13 : d==10 and m==2 and y==2013? 0.18 : d==17 and m==2 and y==2013? 0.18 : d==24 and m==2 and y==2013? 0.18 : d==3 and m==3 and y==2013? 0.19 : d==10 and m==3 and y==2013? 0.21 : d==17 and m==3 and y==2013? 0.23 : d==24 and m==3 and y==2013? 0.3 : d==31 and m==3 and y==2013? 0.32 : d==7 and m==4 and y==2013? 0.35 : d==14 and m==4 and y==2013? 1.02 : d==21 and m==4 and y==2013? 0.78 : d==28 and m==4 and y==2013? 0.44 : d==5 and m==5 and y==2013? 0.45 : d==12 and m==5 and y==2013? 0.51 : d==19 and m==5 and y==2013? 0.51 : d==26 and m==5 and y==2013? 0.53 : d==2 and m==6 and y==2013? 0.65 : d==9 and m==6 and y==2013? 0.77 : d==16 and m==6 and y==2013? 0.85 : d==23 and m==6 and y==2013? 0.89 : d==30 and m==6 and y==2013? 0.35 : d==7 and m==7 and y==2013? 0.3 : d==14 and m==7 and y==2013? 0.34 : d==21 and m==7 and y==2013? 0.38 : d==28 and m==7 and y==2013? 0.4 : d==4 and m==8 and y==2013? 0.49 : d==11 and m==8 and y==2013? 0.61 : d==18 and m==8 and y==2013? 0.71 : d==25 and m==8 and y==2013? 0.82 : d==1 and m==9 and y==2013? 1.04 : d==8 and m==9 and y==2013? 1.15 : d==15 and m==9 and y==2013? 1.49 : d==22 and m==9 and y==2013? 0.91 : d==29 and m==9 and y==2013? 0.51 : d==6 and m==10 and y==2013? 0.58 : d==13 and m==10 and y==2013? 0.72 : d==20 and m==10 and y==2013? 1.03 : d==27 and m==10 and y==2013? 1.29 : d==3 and m==11 and y==2013? 1.43 : d==10 and m==11 and y==2013? 1.19 : d==17 and m==11 and y==2013? 1.47 : d==24 and m==11 and y==2013? 1.55 : d==1 and m==12 and y==2013? 3.64 : d==8 and m==12 and y==2013? 8.61 : d==15 and m==12 and y==2013? 5.42 : d==22 and m==12 and y==2013? 2.86 : d==29 and m==12 and y==2013? 3.11 : d==5 and m==1 and y==2014? 3.46 : d==12 and m==1 and y==2014? 4.31 : d==19 and m==1 and y==2014? 4.74 : d==26 and m==1 and y==2014? 5.27 : d==2 and m==2 and y==2014? 5.93 : d==9 and m==2 and y==2014? 6.48 : d==16 and m==2 and y==2014? 7.29 : d==23 and m==2 and y==2014? 8.32 : d==2 and m==3 and y==2014? 8.84 : d==9 and m==3 and y==2014? 6 : d==16 and m==3 and y==2014? 5.74 : d==23 and m==3 and y==2014? 6.47 : d==30 and m==3 and y==2014? 7.15 : d==6 and m==4 and y==2014? 6.71 : d==13 and m==4 and y==2014? 2.79 : d==20 and m==4 and y==2014? 3.19 : d==27 and m==4 and y==2014? 3.31 : d==4 and m==5 and y==2014? 3.43 : d==11 and m==5 and y==2014? 3.74 : d==18 and m==5 and y==2014? 4.21 : d==25 and m==5 and y==2014? 4.39 : d==1 and m==6 and y==2014? 4.66 : d==8 and m==6 and y==2014? 5.08 : d==15 and m==6 and y==2014? 5.62 : d==22 and m==6 and y==2014? 6.59 : d==29 and m==6 and y==2014? 7.04 : d==6 and m==7 and y==2014? 5.4 : d==13 and m==7 and y==2014? 5.32 : d==20 and m==7 and y==2014? 5.59 : d==27 and m==7 and y==2014? 5.32 : d==3 and m==8 and y==2014? 5.96 : d==10 and m==8 and y==2014? 6.13 : d==17 and m==8 and y==2014? 6.71 : d==24 and m==8 and y==2014? 7.75 : d==31 and m==8 and y==2014? 3.33 : d==7 and m==9 and y==2014? 2.83 : d==14 and m==9 and y==2014? 2.93 : d==21 and m==9 and y==2014? 3.4 : d==28 and m==9 and y==2014? 3.14 : d==5 and m==10 and y==2014? 3.45 : d==12 and m==10 and y==2014? 3.41 : d==19 and m==10 and y==2014? 3.4 : d==26 and m==10 and y==2014? 3.49 : d==2 and m==11 and y==2014? 3.83 : d==9 and m==11 and y==2014? 3.92 : d==16 and m==11 and y==2014? 3.8 : d==23 and m==11 and y==2014? 3.8 : d==30 and m==11 and y==2014? 3.9 : d==7 and m==12 and y==2014? 2.99 : d==14 and m==12 and y==2014? 3.06 : d==21 and m==12 and y==2014? 2.8 : d==28 and m==12 and y==2014? 3.24 : d==4 and m==1 and y==2015? 3.43 : d==11 and m==1 and y==2015? 3.17 : d==18 and m==1 and y==2015? 3.24 : d==25 and m==1 and y==2015? 3.03 : d==1 and m==2 and y==2015? 3.32 : d==8 and m==2 and y==2015? 3.31 : d==15 and m==2 and y==2015? 3.39 : d==22 and m==2 and y==2015? 3.62 : d==1 and m==3 and y==2015? 3.54 : d==8 and m==3 and y==2015? 3.61 : d==15 and m==3 and y==2015? 3.55 : d==22 and m==3 and y==2015? 3.5 : d==29 and m==3 and y==2015? 3.84 : d==5 and m==4 and y==2015? 3.65 : d==12 and m==4 and y==2015? 3.54 : d==19 and m==4 and y==2015? 3.4 : d==26 and m==4 and y==2015? 2.12 : d==3 and m==5 and y==2015? 2.9 : d==10 and m==5 and y==2015? 3.53 : d==17 and m==5 and y==2015? 3.83 : d==24 and m==5 and y==2015? 3.54 : d==31 and m==5 and y==2015? 3.62 : d==7 and m==6 and y==2015? 3.67 : d==14 and m==6 and y==2015? 3.79 : d==21 and m==6 and y==2015? 3.65 : d==28 and m==6 and y==2015? 3.81 : d==5 and m==7 and y==2015? 3.8 : d==12 and m==7 and y==2015? 3.88 : d==19 and m==7 and y==2015? 3.92 : d==26 and m==7 and y==2015? 4.01 : d==2 and m==8 and y==2015? 4.02 : d==9 and m==8 and y==2015? 3.95 : d==16 and m==8 and y==2015? 4.02 : d==23 and m==8 and y==2015? 3.95 : d==30 and m==8 and y==2015? 2.5 : d==6 and m==9 and y==2015? 2.22 : d==13 and m==9 and y==2015? 2.12 : d==20 and m==9 and y==2015? 2.05 : d==27 and m==9 and y==2015? 2.2 : d==4 and m==10 and y==2015? 2.23 : d==11 and m==10 and y==2015? 2.15 : d==18 and m==10 and y==2015? 2.2 : d==25 and m==10 and y==2015? 2.23 : d==1 and m==11 and y==2015? 2.58 : d==8 and m==11 and y==2015? 3.95 : d==15 and m==11 and y==2015? 4.27 : d==22 and m==11 and y==2015? 4.5 : d==29 and m==11 and y==2015? 4.7 : d==6 and m==12 and y==2015? 4.95 : d==13 and m==12 and y==2015? 5.62 : d==20 and m==12 and y==2015? 6.01 : d==27 and m==12 and y==2015? 6.43 : d==3 and m==1 and y==2016? 4.76 : d==10 and m==1 and y==2016? 4.13 : d==17 and m==1 and y==2016? 4.03 : d==24 and m==1 and y==2016? 4.5 : d==31 and m==1 and y==2016? 4.87 : d==7 and m==2 and y==2016? 5.45 : d==14 and m==2 and y==2016? 5.98 : d==21 and m==2 and y==2016? 5.53 : d==28 and m==2 and y==2016? 5.54 : d==6 and m==3 and y==2016? 5.84 : d==13 and m==3 and y==2016? 5.87 : d==20 and m==3 and y==2016? 5.83 : d==27 and m==3 and y==2016? 5.99 : d==3 and m==4 and y==2016? 6.06 : d==10 and m==4 and y==2016? 6.47 : d==17 and m==4 and y==2016? 6.51 : d==24 and m==4 and y==2016? 6.44 : d==1 and m==5 and y==2016? 6.33 : d==8 and m==5 and y==2016? 7.02 : d==15 and m==5 and y==2016? 6.92 : d==22 and m==5 and y==2016? 7.07 : d==29 and m==5 and y==2016? 7.13 : d==5 and m==6 and y==2016? 5.88 : d==12 and m==6 and y==2016? 5.48 : d==19 and m==6 and y==2016? 5.52 : d==26 and m==6 and y==2016? 5.5 : d==3 and m==7 and y==2016? 5.74 : d==10 and m==7 and y==2016? 5.68 : d==17 and m==7 and y==2016? 5.55 : d==24 and m==7 and y==2016? 4.53 : d==31 and m==7 and y==2016? 3.93 : d==7 and m==8 and y==2016? 4.43 : d==14 and m==8 and y==2016? 4.13 : d==21 and m==8 and y==2016? 4.33 : d==28 and m==8 and y==2016? 4.31 : d==4 and m==9 and y==2016? 4.5 : d==11 and m==9 and y==2016? 4.45 : d==18 and m==9 and y==2016? 4.78 : d==25 and m==9 and y==2016? 4.79 : d==2 and m==10 and y==2016? 4.95 : d==9 and m==10 and y==2016? 5.31 : d==16 and m==10 and y==2016? 4.76 : d==23 and m==10 and y==2016? 5.01 : d==30 and m==10 and y==2016? 5.2 : d==6 and m==11 and y==2016? 4.93 : d==13 and m==11 and y==2016? 5.48 : d==20 and m==11 and y==2016? 5.55 : d==27 and m==11 and y==2016? 5.67 : d==4 and m==12 and y==2016? 5.9 : d==11 and m==12 and y==2016? 6.09 : d==18 and m==12 and y==2016? 5.95 : d==25 and m==12 and y==2016? 6.42 : d==1 and m==1 and y==2017? 6.59 : d==8 and m==1 and y==2017? 6.71 : d==15 and m==1 and y==2017? 7.2 : d==22 and m==1 and y==2017? 7.87 : d==29 and m==1 and y==2017? 8.28 : d==5 and m==2 and y==2017? 7.41 : d==12 and m==2 and y==2017? 6.54 : d==19 and m==2 and y==2017? 6.87 : d==26 and m==2 and y==2017? 7.27 : d==5 and m==3 and y==2017? 7 : d==12 and m==3 and y==2017? 7.34 : d==19 and m==3 and y==2017? 7.62 : d==26 and m==3 and y==2017? 7.69 : d==2 and m==4 and y==2017? 6.34 : d==9 and m==4 and y==2017? 6.48 : d==16 and m==4 and y==2017? 7.21 : d==23 and m==4 and y==2017? 7.43 : d==30 and m==4 and y==2017? 7.46 : d==7 and m==5 and y==2017? 7.75 : d==14 and m==5 and y==2017? 8.31 : d==21 and m==5 and y==2017? 9.83 : d==28 and m==5 and y==2017? 11.95 : d==4 and m==6 and y==2017? 12.68 : d==11 and m==6 and y==2017? 13.34 : d==18 and m==6 and y==2017? 12.64 : d==25 and m==6 and y==2017? 12.86 : d==2 and m==7 and y==2017? 13.48 : d==9 and m==7 and y==2017? 12.84 : d==16 and m==7 and y==2017? 14.27 : d==23 and m==7 and y==2017? 11.68 : d==30 and m==7 and y==2017? 11.77 : d==6 and m==8 and y==2017? 11.85 : d==13 and m==8 and y==2017? 13.86 : d==20 and m==8 and y==2017? 15.32 : d==27 and m==8 and y==2017? 12.12 : d==3 and m==9 and y==2017? 15.67 : d==10 and m==9 and y==2017? 16.76 : d==17 and m==9 and y==2017? 17.84 : d==24 and m==9 and y==2017? 17.41 : d==1 and m==10 and y==2017? 17.47 : d==8 and m==10 and y==2017? 18.95 : d==15 and m==10 and y==2017? 19.03 : d==22 and m==10 and y==2017? 21.85 : d==29 and m==10 and y==2017? 20.83 : d==5 and m==11 and y==2017? 21.5 : d==12 and m==11 and y==2017? 18.33 : d==19 and m==11 and y==2017? 20.88 : d==26 and m==11 and y==2017? 22.33 : d==3 and m==12 and y==2017? 23.62 : d==10 and m==12 and y==2017? 30.97 : d==17 and m==12 and y==2017? 45.74 : d==24 and m==12 and y==2017? 44.99 : d==31 and m==12 and y==2017? 46.55 : d==7 and m==1 and y==2018? 47.98 : d==14 and m==1 and y==2018? 51.15 : d==21 and m==1 and y==2018? 42.57 : d==28 and m==1 and y==2018? 39.36 : d==4 and m==2 and y==2018? 39.93 : d==11 and m==2 and y==2018? 38.28 : d==18 and m==2 and y==2018? 35.6 : d==25 and m==2 and y==2018? 36.18 : d==4 and m==3 and y==2018? 37.7 : d==11 and m==3 and y==2018? 40.35 : d==18 and m==3 and y==2018? 40.6 : d==25 and m==3 and y==2018? 40.06 : d==1 and m==4 and y==2018? 39.42 : d==8 and m==4 and y==2018? 38.2 : d==15 and m==4 and y==2018? 38.79 : d==22 and m==4 and y==2018? 41.62 : d==29 and m==4 and y==2018? 38.76 : d==6 and m==5 and y==2018? 39.9 : d==13 and m==5 and y==2018? 39.9 : d==20 and m==5 and y==2018? 40.28 : d==27 and m==5 and y==2018? 44.27 : d==3 and m==6 and y==2018? 45.3 : d==10 and m==6 and y==2018? 47.4 : d==17 and m==6 and y==2018? 49.05 : d==24 and m==6 and y==2018? 53.42 : d==1 and m==7 and y==2018? 47.16 : d==8 and m==7 and y==2018? 47.61 : d==15 and m==7 and y==2018? 45.23 : d==22 and m==7 and y==2018? 50.59 : d==29 and m==7 and y==2018? 56.59 : d==5 and m==8 and y==2018? 59.65 : d==12 and m==8 and y==2018? 56.41 : d==19 and m==8 and y==2018? 52.43 : d==26 and m==8 and y==2018? 53.33 : d==2 and m==9 and y==2018? 55.81 : d==9 and m==9 and y==2018? 51.16 : d==16 and m==9 and y==2018? 51.66 : d==23 and m==9 and y==2018? 53.82 : d==30 and m==9 and y==2018? 56.06 : d==7 and m==10 and y==2018? 52.93 : d==14 and m==10 and y==2018? 52.24 : d==21 and m==10 and y==2018? 53.6 : d==28 and m==10 and y==2018? 51.55 : d==4 and m==11 and y==2018? 54.74 : d==11 and m==11 and y==2018? 48.23 : d==18 and m==11 and y==2018? 46.6 : d==25 and m==11 and y==2018? 41.38 : d==2 and m==12 and y==2018? 35.5 : d==9 and m==12 and y==2018? 32.97 : d==16 and m==12 and y==2018? 33.47 : d==23 and m==12 and y==2018? 36.59 : d==30 and m==12 and y==2018? 38.17 : d==6 and m==1 and y==2019? 39.55 : d==13 and m==1 and y==2019? 39.38 : d==20 and m==1 and y==2019? 37.81 : d==27 and m==1 and y==2019? 38.83 : d==3 and m==2 and y==2019? 38.73 : d==10 and m==2 and y==2019? 39.82 : d==17 and m==2 and y==2019? 39.16 : d==24 and m==2 and y==2019? 39.57 : d==3 and m==3 and y==2019? 40.94 : d==10 and m==3 and y==2019? 38.61 : d==17 and m==3 and y==2019? 41 : d==24 and m==3 and y==2019? 44.54 : d==31 and m==3 and y==2019? 42.55 : d==7 and m==4 and y==2019? 39.52 : d==14 and m==4 and y==2019? 40.48 : d==21 and m==4 and y==2019? 43.06 : d==28 and m==4 and y==2019? 42.21 : d==5 and m==5 and y==2019? 44.98 : d==12 and m==5 and y==2019? 43.23 : d==19 and m==5 and y==2019? 47.07 : d==26 and m==5 and y==2019? 50.84 : d==2 and m==6 and y==2019? 56.13 : d==9 and m==6 and y==2019? 54.99 : d==16 and m==6 and y==2019? 48.99 : d==23 and m==6 and y==2019? 53.38 : d==30 and m==6 and y==2019? 64.61 : d==7 and m==7 and y==2019? 68.53 : d==14 and m==7 and y==2019? 68.12 : d==21 and m==7 and y==2019? 66.78 : d==28 and m==7 and y==2019? 63.38 : d==4 and m==8 and y==2019? 64.43 : d==11 and m==8 and y==2019? 65.27 : d==18 and m==8 and y==2019? 62.25 : d==25 and m==8 and y==2019? 67.32 : d==1 and m==9 and y==2019? 67.53 : d==8 and m==9 and y==2019? 72.54 : d==15 and m==9 and y==2019? 76.34 : d==22 and m==9 and y==2019? 81.31 : d==29 and m==9 and y==2019? 76.85 : d==6 and m==10 and y==2019? 74.32 : d==13 and m==10 and y==2019? 76.37 : d==20 and m==10 and y==2019? 74.58 : d==27 and m==10 and y==2019? 75.7 : d==3 and m==11 and y==2019? 71.07 : d==10 and m==11 and y==2019? 71.83 : d==17 and m==11 and y==2019? 73.81 : d==24 and m==11 and y==2019? 70.91 : d==1 and m==12 and y==2019? 65.97 : d==8 and m==12 and y==2019? 69.74 : d==15 and m==12 and y==2019? 64.55 : d==22 and m==12 and y==2019? 71.42 : d==29 and m==12 and y==2019? 66.49 : d==5 and m==1 and y==2020? 76.84 : d==12 and m==1 and y==2020? 75.13 : d==19 and m==1 and y==2020? 76.51 : d==26 and m==1 and y==2020? 80.9 : d==2 and m==2 and y==2020? 79.81 : d==9 and m==2 and y==2020? 81.15 : d==16 and m==2 and y==2020? 79.68 : d==23 and m==2 and y==2020? 85.03 : d==1 and m==3 and y==2020? 85.22 : d==8 and m==3 and y==2020? 87.07 : d==15 and m==3 and y==2020? 77.14 : d==22 and m==3 and y==2020? 53.97 : d==29 and m==3 and y==2020? 52.07 : d==5 and m==4 and y==2020? 60.1 : d==12 and m==4 and y==2020? 75.36 : d==19 and m==4 and y==2020? 78.98 : d==26 and m==4 and y==2020? 76.09 : d==3 and m==5 and y==2020? 80.15 : d==10 and m==5 and y==2020? 81.8 : d==17 and m==5 and y==2020? 68.6 : d==24 and m==5 and y==2020? 48.84 : d==31 and m==5 and y==2020? 48.76 : d==7 and m==6 and y==2020? 52.29 : d==14 and m==6 and y==2020? 54.34 : d==21 and m==6 and y==2020? 50.34 : d==28 and m==6 and y==2020? 54.59 : d==5 and m==7 and y==2020? 55.46 : d==12 and m==7 and y==2020? 54.6 : d==19 and m==7 and y==2020? 50.91 : d==26 and m==7 and y==2020? 54.67 : d==2 and m==8 and y==2020? 56.71 : d==9 and m==8 and y==2020? 60.28 : d==16 and m==8 and y==2020? 63.45 : d==23 and m==8 and y==2020? 59.15 : d==30 and m==8 and y==2020? 59.78 : d==6 and m==9 and y==2020? 60.26 : d==13 and m==9 and y==2020? 64.41 : d==20 and m==9 and y==2020? 66.06 : d==27 and m==9 and y==2020? 66.29 : d==4 and m==10 and y==2020? 60.36 : d==11 and m==10 and y==2020? 60.05 : d==18 and m==10 and y==2020? 66.09 : d==25 and m==10 and y==2020? 61.11 : d==1 and m==11 and y==2020? 51.14 : d==8 and m==11 and y==2020? 65.24 : d==15 and m==11 and y==2020? 80.76 : d==22 and m==11 and y==2020? 89.54 : d==29 and m==11 and y==2020? 83.36 : d==6 and m==12 and y==2020? 83.85 : d==13 and m==12 and y==2020? 84.67 : d==20 and m==12 and y==2020? 85.38 : d==27 and m==12 and y==2020? 86.5 : d==3 and m==1 and y==2021? 99.96 : d==10 and m==1 and y==2021? 109.01 : d==17 and m==1 and y==2021? 109.34 : d==24 and m==1 and y==2021? 105.8 : d==31 and m==1 and y==2021? 108.78 : d==7 and m==2 and y==2021? 113.68 : d==14 and m==2 and y==2021? 111.34 : d==21 and m==2 and y==2021? 114.37 : d==28 and m==2 and y==2021? 120.55 : d==7 and m==3 and y==2021? 119.87 : d==14 and m==3 and y==2021? 121.87 : d==21 and m==3 and y==2021? 124.68 : d==28 and m==3 and y==2021? 129.81 : d==4 and m==4 and y==2021? 125.94 : d==11 and m==4 and y==2021? 133.9 : d==18 and m==4 and y==2021? 117.6 : d==25 and m==4 and y==2021? 116.23 : d==2 and m==5 and y==2021? 125.59 : d==9 and m==5 and y==2021? 138.55 : d==16 and m==5 and y==2021? 134.59 : d==23 and m==5 and y==2021? 106.06 : d==30 and m==5 and y==2021? 107.26 : d==6 and m==6 and y==2021? 105.36 : d==13 and m==6 and y==2021? 92.83 : d==20 and m==6 and y==2021? 83.74 : d==27 and m==6 and y==2021? 64.85 : d==4 and m==7 and y==2021? 61.9 : d==11 and m==7 and y==2021? 66.83 : d==18 and m==7 and y==2021? 69.41 : d==25 and m==7 and y==2021? 68.89 : d==1 and m==8 and y==2021? 77.92 : d==8 and m==8 and y==2021? 79.39 : d==15 and m==8 and y==2021? 82.65 : d==22 and m==8 and y==2021? 87.07 : d==29 and m==8 and y==2021? 92.65 : d==5 and m==9 and y==2021? 91.17 : d==12 and m==9 and y==2021? 94.3 : d==19 and m==9 and y==2021? 98.54 : d==26 and m==9 and y==2021? 96.21 : d==3 and m==10 and y==2021? 98.84 : d==10 and m==10 and y==2021? 99.21 : d==17 and m==10 and y==2021? 101.76 : d==24 and m==10 and y==2021? 106.24 : d==31 and m==10 and y==2021? 111.68 : d==7 and m==11 and y==2021? 116.45 : d==14 and m==11 and y==2021? 114.26 : d==21 and m==11 and y==2021? 114.62 : d==28 and m==11 and y==2021? 110.6 : d==5 and m==12 and y==2021? 118.51 : d==12 and m==12 and y==2021? 121.88 : d==19 and m==12 and y==2021? 112.55 : d==26 and m==12 and y==2021? 120.29 : d==2 and m==1 and y==2022? 119.19 : d==9 and m==1 and y==2022? 117.33 : d==16 and m==1 and y==2022? 130.54 : d==23 and m==1 and y==2022? 126.67 : d==30 and m==1 and y==2022? 125.4 : d==6 and m==2 and y==2022? 116.02 : d==13 and m==2 and y==2022? 126.43 : d==20 and m==2 and y==2022? 137.13 : d==27 and m==2 and y==2022? 117.54 : d==6 and m==3 and y==2022? 119.82 : d==13 and m==3 and y==2022? 122.52 : d==20 and m==3 and y==2022? 126.38 : d==27 and m==3 and y==2022? 125.28 : d==3 and m==4 and y==2022? 128.57 : d==10 and m==4 and y==2022? 131.8 : d==17 and m==4 and y==2022? 125.56 : d==24 and m==4 and y==2022? 126.89 : d==1 and m==5 and y==2022? 132.89 : d==8 and m==5 and y==2022? 132.1 : d==15 and m==5 and y==2022? 125.38 : d==22 and m==5 and y==2022? 119.22 : d==29 and m==5 and y==2022? 120.04 : d==5 and m==6 and y==2022? 117.89 : d==12 and m==6 and y==2022? 128.79 : d==19 and m==6 and y==2022? 105.19 : d==26 and m==6 and y==2022? 92.26 : d==3 and m==7 and y==2022? 91.91 : d==10 and m==7 and y==2022? 84.87 : d==17 and m==7 and y==2022? 80.07 : d==24 and m==7 and y==2022? 83.87 : d==31 and m==7 and y==2022? 88.81 : d==7 and m==8 and y==2022? 91.01 : d==14 and m==8 and y==2022? 88.5 : d==21 and m==8 and y==2022? 92.17 : d==28 and m==8 and y==2022? 97.3 : d==4 and m==9 and y==2022? 94.8 : d==11 and m==9 and y==2022? 96.54 : d==18 and m==9 and y==2022? 95.34 : d==25 and m==9 and y==2022? 92.67 : d==2 and m==10 and y==2022? 96.61 : d==9 and m==10 and y==2022? 105.96 : d==16 and m==10 and y==2022? 106.5 : d==23 and m==10 and y==2022? 100.36 : d==30 and m==10 and y==2022? 97.93 : d==6 and m==11 and y==2022? 101.41 : d==13 and m==11 and y==2022? 102.5 : d==20 and m==11 and y==2022? 94.18 : d==27 and m==11 and y==2022? 80.79 : d==4 and m==12 and y==2022? 86.58 : d==11 and m==12 and y==2022? 92.49 : d==18 and m==12 and y==2022? 88.68 : d==25 and m==12 and y==2022? 83.68 : d==1 and m==1 and y==2023? 91.37 : d==8 and m==1 and y==2023? 94.75 : d==15 and m==1 and y==2023? 98.16 : d==22 and m==1 and y==2023? 102.84 : d==29 and m==1 and y==2023? 115.62 : na e btc_mined_per_day() => blocks_per_day = 144 block_reward = time < timestamp(2012,11,28,0,0) ? 50 : time < timestamp(2016,7,9,0,0) ? 25 : time < timestamp(2020,5,11,19,0) ? 12.5 : time < timestamp(2024,5,12,0,0) ? 6.25 : 3.125 // 2024 estimate btc_per_day = blocks_per_day*block_reward btc_per_day // CALCULATIONS miner_price = close + fees/btc_mined_per_day() elec = float(na) elec := na(elec_consumption()) ? elec[1] : elec_consumption() p = time < timestamp(2019,6,30,0,0) ? p_og : time < timestamp(2021,4,20,0,0) ? p_china : p_new btc_elec_cost = float(na) btc_elec_cost := (elec/365.25)*pow(10,9) / btc_mined_per_day() * p //convert: --> days --> KwH --> Per BTC --> * Price/KwH total_cost = btc_elec_cost/elec_pct osc_e = (miner_price/btc_elec_cost - 1.0)*100.0 osc_t = (miner_price/total_cost - 1.0)*100.0 // PLOT c = close clr = total_cost > c ? color.green : color.red tc = plot(total_cost,color=clr,linewidth=2,title="TBV") cp = plot(c,color=color.rgb(0, 0, 0, 100),linewidth=1,title="Close") fill(tc,cp,color=clr,transp=70,title="TBV Fill")
ATR Oscillator - Index (Average True range Oscillator)
https://www.tradingview.com/script/uppeJ3eo/
kaptankirk
https://www.tradingview.com/u/kaptankirk/
63
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © KaptanKirk - Süleyman Sülün - @TheSulun //@version=5 indicator(title="Average True Range Oscillator", shorttitle="ATRO", format=format.price, precision=2, timeframe="", timeframe_gaps=true, overlay = false) ATR_per=input.int(14, "ATR Per") atr=ta.atr(ATR_per) Max_Min_per=input.int(20,"Period for ATR Max and Min") // Within how many bars (periods) should the ATR max and min values be determined? atrMax=ta.highest(atr,Max_Min_per) // Maximum ATR value in the specified period atrMin=ta.lowest(atr,Max_Min_per) // Minimum ATR value in the specified period ATR_Oscillator=100/((atrMax-atrMin)/(atr-atrMin)) // Calculation of the percentage of the difference between the Max and Min ATR values in the specified range of the instantaneous ATR value. So the process of converting this range to % oscillator. ATRO_SMA_Per=input.int(1, minval=1, title="SMA for ATR Oscillator") // The 'SMA Period' of the 'ATR Oscillator' can be increased to soften the 'ATR Oscillator' plot. plot(ta.sma(ATR_Oscillator,ATRO_SMA_Per), title="ATR Oscillator", color=color.navy, linewidth = 2, style=plot.style_line)
RedK K-MACD : a MACD with some more muscles
https://www.tradingview.com/script/BmfyvjgU-RedK-K-MACD-a-MACD-with-some-more-muscles/
RedKTrader
https://www.tradingview.com/u/RedKTrader/
684
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RedKTrader //@version=5 indicator('RedK K-MACD v1.3', shorttitle='K-MACD v1.3', explicit_plot_zorder = true, timeframe='', timeframe_gaps=false) // --------------------------------------------------------------------------------------------------------------- // MoBars v4.0 - aka K-MACD or MORE MACD (MORE = MoBars + RElative mode) // Added a 4th MA -represented as a line plot - should be used with very short length as a proxy to the price itself // - also added the orange (signal) line that closely follows the proxy, for improved visualization of short term momentum change // Price proxy default is set to RSS_WMA(close, 8) -- this is in reality a smoothed WMA(close, 3), which is fast enough to represent price // the Signal line is set by default to WMA(Proxy, 7) - as initial values to experiment with // can now use MoBars v4.0 to view a setup of price against 3 MA's - like in the Minervini template - Cup & Handle, High Tight Flag..and similar formations // - updated inputs to allow choice of source price for all MA's. Close price would be most common // *** - in this version, added a calculation oprion for momentum as % of the filter (called "relative" versus the absolute approach in a classic MACD) - this adds couple of improvements // 1 - when a chart is zoomed out to view a long time window (example: 5 years on 1W bars), values from extreme ends of time axis are comparable and scaled properly - not the case with a MACD // 2 - these % values can be directly used in analysis or to set SL (for example, price was x% below the filter MA at so-and-so time) - which is more meaningful than looking at an abs value // 3 - the momentum values can be comapred across different assets / symbols //============================================================================== // updated this version of LazyLine() to reflect a regular WMA for length < 5 f_LazyLine(_data, _length) => w1 = 0, w2 = 0, w3 = 0 L1 = 0.0, L2 = 0.0, L3 = 0.0 w = _length / 3 if _length > 4 w2 := math.round(w) w1 := math.round((_length - w2) / 2) w3 := int((_length - w2) / 2) L1 := ta.wma(_data, w1) L2 := ta.wma(L1, w2) L3 := ta.wma(L2, w3) else L3 := ta.wma(_data, _length) L3 //============================================================================== // ============================================================================= f_getMA(source, length, mtype) => mtype == "SMA" ? ta.sma(source, length) : mtype == "EMA" ? ta.ema(source, length) : mtype == "WMA" ? ta.wma(source, length) : mtype == "HMA" ? ta.hma(source, length) : f_LazyLine(source, length) // ============================================================================= // ------------------------------------------------------------------------------------------------ // Inputs // ------------------------------------------------------------------------------------------------ grp_1 = 'Price Proxy & Signal Lines :' grp_2 = 'Fast & Slow Lines :' grp_3 = 'Filter MA / Baseline :' Calc_Opt = input.string('Relative', title = 'Calc Option', options = ['Relative', 'Classic']) Proxy_Src = input.source(close, title='Proxy Source', inline = 'Proxy', group = grp_1) Proxy_Length = input.int(8, title = 'Length', minval = 1, inline = 'Proxy', group = grp_1) Proxy_Type = input.string('RSS_WMA', title = 'Type', inline = 'Proxy', options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA'], group = grp_1) Sig_Delay = input.int(7, title = 'Proxy Signal Delay', minval = 1, inline = 'Signal', group = grp_1) Sig_Type = input.string('EMA', title = 'Type', inline = 'Signal', options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA'], group = grp_1) Fast_Src = input.source(close, title='Fast MA Source', inline = 'Fast', group = grp_2) Fast_Length = input.int(10, title = 'Length', minval = 1, inline = 'Fast', group = grp_2) Fast_Type = input.string('SMA', title = 'Type', inline = 'Fast', options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA'], group = grp_2) Slow_Src = input.source(close, title='Slow MA Source', inline = 'Slow', group = grp_2) Slow_Length = input.int(20, title='Length', minval = 1, inline = 'Slow', group = grp_2) Slow_Type = input.string('SMA', title = 'Type', inline = 'Slow', options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA'], group = grp_2) Slow_Delay = input.int(3, title='Slow Delay (1 = None)', minval = 1, group = grp_2) Fil_Src = input.source(close, title='Source', inline = 'Filter', group = grp_3) Fil_Length = input.int(40, title='Length', minval = 1, inline = 'Filter', group = grp_3) Fil_Type = input.string('SMA', title = 'Type', inline = 'Filter', group = grp_3, options = ['RSS_WMA', 'WMA', 'EMA', 'SMA', 'HMA']) // ------------------------------------------------------------------------------------------------ // Calculation // ------------------------------------------------------------------------------------------------ Proxy = f_getMA(Proxy_Src, Proxy_Length, Proxy_Type) Fast = f_getMA(Fast_Src, Fast_Length, Fast_Type) Slow = f_getMA(Slow_Src, Slow_Length, Slow_Type) Filter = f_getMA(Fil_Src, Fil_Length, Fil_Type) // If "Relative" Calc option was selected for momentum calc, then we divide by Filter value and multiply by 100 -- else, use 1 (that's the classic MACD mode) Calc_Adj = Calc_Opt == "Relative" ? 100 / Filter : 1 Proxy_M = (Proxy - Filter) * Calc_Adj Signal_M = f_getMA(Proxy_M, Sig_Delay, Sig_Type) Fast_M = (Fast - Filter) * Calc_Adj Slow_M = (Slow - Filter) * Calc_Adj Rel_M = ta.wma(Slow_M, Slow_Delay) // prep the Momentum bars o = fixnan(Rel_M) // fixes NaN values - observed mainly on Renko c = fixnan(Fast_M) h = math.max(o, c) l = math.min(o, c) body = h - l // check if bar body is increasing rising = ta.change(body) > 0 // ------------------------------------------------------------------------------------------------ // Colors & Plots // ------------------------------------------------------------------------------------------------ c_barup = color.new(#11ff20, 60) c_bardn = color.new(#ff1111, 60) c_bardj = color.new(#ffffff, 50) c_barupb = color.new(#1b5e20, 50) c_bardnb = color.new(#981919, 50) c_bardjb = color.new(#9598a1, 50) c_base = color.new(#2424f0, 50) // 2-color for Proxy Line c_prox = Proxy_M > 0 ? color.new(#33ff00, 0) : color.new(#ff1111, 0) c_sig = color.new(#00bcd4, 25) hline(0, title = 'Base Line', color = c_base, linestyle = hline.style_solid, linewidth = 2) barcolor = c > o and rising ? c_barup : c < o and rising ? c_bardn : c_bardj borcolor = c > o and rising ? c_barupb : c < o and rising ? c_bardnb : c_bardjb plotcandle(o, h, l, c, 'MoBars', barcolor, barcolor, bordercolor = borcolor, display = display.pane) plot(Signal_M, title='Proxy Signal', color = c_sig, linewidth = 2) plot(Proxy_M, title='Price Proxy MA', color = c_prox, linewidth = 3) // =========================================================================================================== // .................. alerts // the momentum alerts will trigger as soon as the Momentum Bar "touches" above or below the filter line // in K-MACD, New alerts added for when the Price proxy crosses the signal line // and for when the price proxy crosses the zero line - this one possibly the most commonly used alert, so will appear first in alerts list // =========================================================================================================== Al_Mobars_up = ta.crossover(h, 0) Al_Mobars_dn = ta.crossunder(l, 0) Al_Mobars_swing = Al_Mobars_up or Al_Mobars_dn alertcondition(Al_Mobars_up, "C1. MoBars Crossing 0 Up", "MoBars Up - Bullish Mode Detected!") alertcondition(Al_Mobars_dn, "C2. MoBars Crossing 0 Down", "MoBars Down - Bearish Mode Detected!") alertcondition(Al_Mobars_swing, "C3. MoBars Crossing 0", "Mobars Swing - Possible Reversal Detected!") // More Alerts Al_Price_up = ta.crossover(Proxy_M, 0) Al_Price_dn = ta.crossunder(Proxy_M, 0) Al_Price_swing = Al_Price_up or Al_Price_up alertcondition(Al_Price_up, "A1. Proxy Crossing 0 Up", "Proxy Above 0 - Long Mode Detected!") alertcondition(Al_Price_dn, "A2. Proxy Crossing 0 Down", "Proxy Below 0 - Short Mode Detected!") alertcondition(Al_Price_swing, "A3. Proxy Crossing 0", "Proxy Swing - Possible Reversal Detected!") Al_Price_x_Singal_up = ta.crossover(Proxy_M, Signal_M) Al_Price_x_Singal_dn = ta.crossunder(Proxy_M, Signal_M) Al_Price_x_Singal = ta.cross(Proxy_M, Signal_M) alertcondition(Al_Price_x_Singal_up, "B1. Proxy Crossing Signal Up", "Proxy Crossing Signal Up!") alertcondition(Al_Price_x_Singal_dn, "B2. Proxy Crossing Signal Down", "Proxy Crossing Signal Down!") alertcondition(Al_Price_x_Singal, "B3. Proxy Crossing Signal", "Proxy Crossing Signal!") // =========================================================================================================== // Price hitting a "New 52wk Hi/Lo": // Using a simple approach - works only on TF's 1D and higher - may improve as/if needed // v1.2 : Fixed the workaround for periods on chart less than 52WK since IPO (like MBLY, XPEV,..etc) - by using the all-time hi/lo values instead // - so now this would work from wk #2 as "new all-time hi/lo" -- values are printed in the data windows for use. var HiBL = high, var LoBL = low var lkhi = HiBL, var lklo = LoBL lkhi := math.max(lkhi, high) lklo := math.min(lklo, low) [hi52WK, lo52WK] = request.security(syminfo.tickerid, "W", [ta.highest(52), ta.lowest(52)]) // if the security call returns NA, use last known hi/lo values v_hi52WK = na(hi52WK) ? lkhi : hi52WK v_lo52WK = na(lo52WK) ? lklo : lo52WK plotchar(lkhi, "All-time Hi", char = "", color = color.yellow, editable = false, display = display.data_window) plotchar(lklo, "All-time Lo", char = "", color = color.yellow, editable = false, display = display.data_window) // This ensures we don't miss new 52Wk Hi/Lo's that we hit in the current week. // assuming trading week is 5 days (any issue with futures & crypto's ?) [hi1WK, lo1WK] = request.security(syminfo.tickerid, "D", [ta.highest(5), ta.lowest(5)]) MaxHi = math.max(v_hi52WK, hi1WK) MaxLo = math.min(v_lo52WK, lo1WK) //set a flag if a new 52Wk Hi/Lo occurs N52HL = high == MaxHi ? 1 : low == MaxLo ? -1 : 0 //plot NewHL = N52HL == 0 ? na : 0 c_NewHL = N52HL == 1 ? color.green : color.red plot(NewHL, title = "New 52wk Hi/Lo", color = c_NewHL, linewidth = 5, style = plot.style_circles, display = display.pane) gain52Wk = (close - MaxLo) / (MaxHi - MaxLo) * 100 plotchar(MaxHi, "52Wk Hi", char = "", color = color.green, editable = false, display = display.status_line + display.data_window) plotchar(MaxLo, "52Wk Low", char = "", color = color.red, editable = false, display = display.status_line + display.data_window) plotchar(gain52Wk, "Price % within 52Wk Hi/Low", char = "", color = gain52Wk > 50 ? color.green : color.red, editable=false, display=display.status_line + display.data_window)
Trend and Momentum Dashboard
https://www.tradingview.com/script/ClSMIIm7-Trend-and-Momentum-Dashboard/
Lantzwat
https://www.tradingview.com/u/Lantzwat/
167
study
5
MPL-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('Trend and Momentum Dashboard', "TMD", max_bars_back = 5000) // ... based on Fibonacci levels SetTFperiod(tf,b ) => setper = tf == 'M' ? 6 : tf == 'W' ? 12 : tf=="2D"? 12: tf == 'D' ? 20 : tf == '240' ? 28 : tf == '180' ? 28 : tf == '120' ? 32 : tf == '60' ? 36 : tf == '45' ? 36 : tf == '30' ? 42 : tf == '15' ? 42 : tf == '5' ? 48 : tf == '3' ? 60 : tf == '1' ? 60 : 20 if b == true // calculation taken from Dynamic RSI Momentum (DRM Strategy) by QuantNomad mlen = 10 dsrc = close mVal = dsrc - dsrc[mlen] // Calculation Price vs Momentum dcorr = ta.correlation(dsrc, mVal, mlen) dcorr := dcorr > 1 or dcorr < -1 ? float(na) : dcorr var dLen = 0 min_d = int(setper/2) max_d = int(setper * 1.5) setper := int(min_d + nz(math.round((1 - dcorr) * (max_d-min_d) / 2, 0), 0)) setper lw = input(25,"Linewidth") bcolor = input.bool(true, "5 color vs 3 color") bbar = input.bool(true,"Background - last bar in period vs trading zones") baseline = input.int(1, "Bullish/Bearish threshold") bDyn = true len = SetTFperiod(timeframe.period, bDyn) //Tickers = "SPY;XLY;XLC;XLK;XLRE;XLP;XLV;XLF;XLB;XLU;XLI;XLE;IYT" //Descriptions="S&P500;Consumer Discretionary;Communication;Technology;Real Estate;Consumer Staples;Health Care;Financials;Materials;Utilities;Industrials;Energy;Transport" tick0 = input.string("SPY", inline="0") descr0 = input.string("S&P500", inline="0") tick1 = input.string("XLY", inline="1") descr1 = input.string("Consumer Discretionary", inline="1") tick2 = input.string("XLC", inline="2") descr2 = input.string("Communication", inline="2") tick3 = input.string("XLK", inline="3") descr3 = input.string("Technology", inline="3") tick4 = input.string("XLRE", inline="4") descr4 = input.string("Real Estate", inline="4") tick5 = input.string("XLP", inline="5") descr5 = input.string("Consumer Staples", inline="5") tick6 = input.string("XLV", inline="6") descr6 = input.string("Health Care", inline="6") tick7 = input.string("XLF", inline="7") descr7 = input.string("Financials", inline="7") tick8 = input.string("XLB", inline="8") descr8 = input.string("Materials", inline="8") tick9 = input.string("XLU", inline="9") descr9 = input.string("Utilities", inline="9") tick10 = input.string("XLI", inline="10") descr10 = input.string("Industrials", inline="10") tick11 = input.string("XLE", inline="11") descr11 = input.string("Energy", inline="11") tick12 = input.string("IYT", inline="12") descr12 = input.string("Transport", inline="12") _label(float yPosition, string Name) => var TEXTCOLOR = color.new(color.white,50) if barstate.islast var _label = label.new(bar_index, y=yPosition, text=Name, color=color.new(color.white, 100), textcolor=TEXTCOLOR, style=label.style_label_left, size=size.small, textalign=text.align_left, text_font_family=font.family_monospace) label.set_x(_label, bar_index) // ==================================================================================================================================================================================================== // Helper functions because of Series int and Simple int issue in Pinescript // Script Functions Allowing Series As Length - PineCoders FAQ // @author=alexgrover, for PineCoders Ema2(src,p) => ema = 0. sf = 2/(p+1) ema := nz(ema[1] + sf*(src - ema[1]),src) Atr2(p) => atr = 0. Tr = math.max(high,close[1]) - math.min(low,close[1]) atr := nz(atr[1] + (Tr - atr[1])/p,Tr) /// ---------------------------------------------------------------------------------------------------------------------------------- // Fibonacci calculation is a modified version of eykpunters "Fibonacci Zone Oscillator With MACD Histogram" CalcFibRange(sec) => //Calculate Donchian Channel per = SetTFperiod(timeframe.period, bDyn) src_close = request.security(sec, timeframe.period, close) src_high = request.security(sec, timeframe.period, high) src_low = request.security(sec, timeframe.period, low) hl = ta.highest(src_high,per) //High Line (Border) ll = ta.lowest(src_low,per) //Low Line (Border) varwidth = math.round(2 + per / 25 - 6 / per, 1) dis = Atr2(per) //Calculate Fibonacci levels don = hl - ll //range of the Donchian channel hf = hl - don * 0.236 //Highest Fibonacci line cfh = hl - don * 0.382 //Center High Fibonacci line cfl = hl - don * 0.618 //Center Low Fibonacci line lf = hl - don * 0.786 //Lowest Fibonacci line 0.764 ohf = cfh + varwidth * dis llf = cfl - varwidth * dis //Calculate relative position of close poshigh = src_close > ohf posup = src_close <= ohf and src_close >= hf //in uptrend area posabove = src_close <= hf and src_close > cfh //in prudent buyers area posmiddle= src_close <= cfh and src_close > cfl //in center area posunder = src_close <= cfl and src_close > lf //in prudent sellers area posdown = src_close <= lf and src_close > llf //in downtrend area poslow = src_close < llf fibrange = poshigh? 2: posup? 2: posabove? 1: posmiddle ? 0: posunder? -1: posdown? -2: 0 if sec == "" fibrange := 0 fibrange FibColoring(fibrange, postransp) => fibcolor = color.gray if bcolor fibcolor := fibrange == 3 ? color.new(color.navy, postransp): fibrange == 2 ? color.new(color.blue,postransp): fibrange == 1 ? color.new(color.rgb(128, 194, 248),postransp): fibrange == 0 ? color.new(color.gray,postransp): fibrange == -1 ? color.new(color.rgb(250, 149, 149),postransp): fibrange == -2 ? color.new(color.red,postransp): color.new(color.maroon, postransp) else fibcolor := fibrange == 3 ? color.new(color.navy, postransp): fibrange == 2 ? color.new(color.blue,postransp): fibrange == 1 ? color.new(color.blue,postransp): fibrange == 0 ? color.new(color.gray,90): fibrange == -1 ? color.new(color.red,postransp): fibrange == -2 ? color.new(color.red,postransp): color.new(color.maroon, postransp) fibcolor /// ---------------------------------------------------------------------------------------------------------------------------------- // initializing ps = plot.style_stepline pos = 00 fib = 0 fibrange = 0 col = color.red // Calculation and plotting starts here .... pos := pos - 10 fibrange := CalcFibRange(tick0) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr0) pos := pos - 10 fibrange := CalcFibRange(tick1) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr1) pos := pos - 10 fibrange := CalcFibRange(tick2) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr2) pos := pos - 10 fibrange := CalcFibRange(tick3) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr3) pos := pos - 10 fibrange := CalcFibRange(tick4) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr4) pos := pos - 10 fibrange := CalcFibRange(tick5) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr5) pos := pos - 10 fibrange := CalcFibRange(tick6) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr6) pos := pos - 10 fibrange := CalcFibRange(tick7) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr7) pos := pos - 10 fibrange := CalcFibRange(tick8) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr8) pos := pos - 10 fibrange := CalcFibRange(tick9) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr9) pos := pos - 10 fibrange := CalcFibRange(tick10) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr10) pos := pos - 10 fibrange := CalcFibRange(tick11) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr11) pos := pos - 10 fibrange := CalcFibRange(tick12) col := FibColoring(fibrange,20) fib := fib + fibrange plot(pos, linewidth=lw, style=ps, color=col) _label(pos, descr12) /// ---------------------------------------------------------------------------------------------------------------------------------- // Plot trading zones - sum of all fibonacci levels ... fibcol = fib > baseline ? color.blue : color.red plot(5, color = fib > baseline ? color.blue : color.red, style=ps, linewidth = lw / 4) bgcolor(not bbar ? color.new(fibcol, 70) : na) /// ---------------------------------------------------------------------------------------------------------------------------------- // Highlight last bar in period tf = timeframe.period period = tf=="M"? "W": tf=="W"? "D": tf=="D"? "W": tf=="240"? "D": tf=="180"? "D": tf=="120"? "D": tf=="60"? "D": tf=="30"? "D": tf=="15"? "D": tf=="5"? "60": tf=="3"? "60": tf=="1"? "60": "W" is_newbar(res) => t = time(res) ta.change(t) != 0 ? 1 : 0 bgcolor(is_newbar(period) == 1 and bbar ? color.new(color.gray,96) : na, offset=-1)
Trop Bands
https://www.tradingview.com/script/vJoZkBI2-Trop-Bands/
Troptrap
https://www.tradingview.com/u/Troptrap/
21
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Troptrap //@version=5 indicator("Trop Bands",overlay=true) len = input.int(title="Ema length",defval=9) src = input.source(defval=hlc3) sns = input.float(title="Sensitivity",defval=0.25 ) innerdi = input.bool(title="Display inner signals", defval=false) ema = ta.ema(src,len) uph = 0.0 dnl = 0.0 stup = src[1]<ema and src>ema? src:na uph := src>ema?ta.highest(len):uph[1] udiff = uph-ema upper = fixnan(ta.ema(src+udiff,len)) plot(uph?upper:upper[1],color=color.red, title = "upper") stdn = src[1]>ema and src<ema? src:na dnl := src<ema?ta.lowest(len):dnl[1] ddiff = ema-dnl lower = fixnan(ta.ema(src-ddiff,len)) plot(dnl?lower:lower[1],color=color.green, title = "lower") plot(ema, title="ema") smooth = input(title='Smooth', defval=10) sma = input(title='SMA', defval=true) // bar = (close - open) / open p = ta.percentile_nearest_rank(bar, 1, 100) di = 0.0 va = 0.0 h = 0.0 l = 0.0 h := high>high[2]?high:high[2] l := low<low[2]?low:low[2] va := h - l va := sma?ta.sma(va,10):math.avg(va,10) if va == 0 va := 1 va k = 3 * close / va p *= k bp = 1.0 sp = 1.0 bp := close>open?volume:volume/p sp := close>open?volume/p:volume di := math.abs(bp)>math.abs(sp)?sp/bp:bp/sp di := ta.ema(di, smooth) xtr = di>sns and high>upper?di:di<(-1*sns) and low<lower?di:na plotshape(xtr>0, location = location.abovebar, style = shape.triangledown, size = size.normal, color=color.red, title = "out of bands upper") plotshape(xtr<0, location = location.belowbar,style = shape.triangleup, size = size.normal, color=color.green, title = "out of bands lower") xtrin = di>sns and high<upper?di:di<(-1*sns) and low>lower?di:na plotshape(innerdi and xtrin>0, location = location.abovebar, style = shape.triangledown, size = size.tiny, color=color.red, title = "inside bands upper") plotshape(innerdi and xtrin<0, location = location.belowbar,style = shape.triangleup, size = size.tiny, color=color.green, title = "inside bands lower")
Harmonic Patterns Based Trend Follower
https://www.tradingview.com/script/UivE2izt-Harmonic-Patterns-Based-Trend-Follower/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
1,576
study
5
MPL-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 import HeWhoMustNotBeNamed/rzigzag/10 as zg import HeWhoMustNotBeNamed/eHarmonicpatternsLogScale/1 as hp indicator('Harmonic Patterns Based Trend Follower', 'HP-TF [Trendoscope]', overlay=true, max_lines_count = 500) base = input.string('CD', 'Base', ['minmax', 'correction', 'CD'], group="Supertrend", tooltip='Base for which entry/stop and thus range can be calculated') entryPercent = input.int(30, 'Entry %', minval=30, maxval = 200, step=5, group='Supertrend', tooltip = 'Percent of Base from D for entry in pattern direction') stopPercent = input.int(5, 'Stop %', minval=0, maxval = 30, step=5, group='Supertrend', tooltip = 'Percent of Base from D for exit in opposite direction') useClosePrices = input.bool(true, 'Use Close Prices', group='Supertrend', tooltip = 'Use close prices for finding breakouts and calculate trend direction') errorPercent = input.int(3, title='Error %', minval=3, step=5, maxval=21, group='Harmonic Patterns', tooltip='Error threshold for calculation on patterns. Increased error threshold will reduce the accuracy of patterns. Lower error threshold will reduce number of patterns detected.') zigzagLength = input.int(8, step=5, minval=3, title='Zigzag', group='Harmonic Patterns', tooltip='Zigzag Length on which pattern detection is built') logScale = input.bool(false, 'Log Scale', group='Harmonic Patterns', tooltip='If selected, patterns are scanned on log scale instead of regular price scale') showHarmonicPatterns = input.bool(true, 'Display Harmonic Patterns', group='Harmonic Patterns', tooltip='If selected, harmonic patterns scanned will be drawn on chart') depth = 10 startIndex = 1 var float bullishRange = na var float bearishRange = na var int trend = na [zigzagmatrix, zgFlags] = zg.zigzag(zigzagLength, array.from(high, low), depth, 0) if(matrix.rows(zigzagmatrix) >= startIndex+5) existingPattern = false isHarmonicPattern = false x = matrix.get(zigzagmatrix, startIndex+4, 0) a = matrix.get(zigzagmatrix, startIndex+3, 0) b = matrix.get(zigzagmatrix, startIndex+2, 0) c = matrix.get(zigzagmatrix, startIndex+1, 0) d = matrix.get(zigzagmatrix, startIndex, 0) patterns = hp.isHarmonicPattern(x, a, b, c, d, array.new<bool>(), true, errorPercent, logScale=logScale) if(array.includes(patterns, true) and array.get(zgFlags, 1)) xBar = matrix.get(zigzagmatrix, startIndex+4, 1) aBar = matrix.get(zigzagmatrix, startIndex+3, 1) bBar = matrix.get(zigzagmatrix, startIndex+2, 1) cBar = matrix.get(zigzagmatrix, startIndex+1, 1) dBar = matrix.get(zigzagmatrix, startIndex, 1) if showHarmonicPatterns line.new(int(xBar), x, int(aBar), a, color=color.blue, style = line.style_dotted, width = 0) line.new(int(aBar), a, int(bBar), b, color=color.blue, style = line.style_dotted, width = 0) line.new(int(bBar), b, int(cBar), c, color=color.blue, style = line.style_dotted, width = 0) line.new(int(cBar), c, int(dBar), d, color=color.blue, style = line.style_dotted, width = 0) line.new(int(bBar), b, int(dBar), d, color=color.blue, style = line.style_dotted, width = 0) line.new(int(xBar), x, int(bBar), b, color=color.blue, style = line.style_dotted, width = 0) dir = matrix.get(zigzagmatrix, startIndex, 3) baseValue = base == 'minmax' ? math.max(x,a,b,c,d) - math.min(x,a,b,c,d) : base == 'correction'? math.abs((dir > 0? math.max(a, c) : math.min(a, c)) - d) : math.abs(c-d) entryRange = d - math.sign(dir)*baseValue*(entryPercent/100) stopRange = d + math.sign(dir)*baseValue*(stopPercent/100) newBullishRange = math.max(entryRange, stopRange) newBearishRange = math.min(entryRange, stopRange) bullishRange := trend < 0? math.min(bullishRange, newBullishRange) : newBullishRange bearishRange := trend > 0? math.max(bearishRange, newBearishRange) : newBearishRange highPrice = useClosePrices? close : high lowPrice = useClosePrices ? close : low trend := highPrice >= bullishRange? 1 : lowPrice <=bearishRange? -1 : trend trendColor = trend>0? color.lime : trend < 0? color.red: color.silver plot(bullishRange, "BullishRange", color=color.green) plot(bearishRange, "BearishRange", color=color.red) barcolor(trendColor) plot(trend, "Trend", trendColor, display = display.data_window)
Market Snapshot
https://www.tradingview.com/script/JwOeYeTV-Market-Snapshot/
Amphibiantrading
https://www.tradingview.com/u/Amphibiantrading/
89
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © smashapalooza //@version=5 indicator("Market Snapshot", overlay=true) //chose table position and colors i_tableypos = input.string("bottom", "Y", inline = "i1", options = ["top", "middle", "bottom"], group="Table Settings") i_tablexpos = input.string("left", "X", inline = "i1", options = ["right","center", "left"], group="Table Settings") i_bgcolor = input(defval=color.new(color.orange,65), title='Background Color', inline = "k1") i_textcolor = input(defval=color.black, title='Text Color', inline = "k1") i_tablesize = input.string("normal", "Table Size", options = ["small","normal","large","huge"]) marketselect = input.string("Nasdaq", "Select Index", options = ["Nasdaq", "SPX"], group = "Market Data") imatype = input.string("EMA", "Moving Average 1", options = ["EMA", "SMA"], group = "Market Data", inline = "n1") imalength = input.int(21, "", minval = 1, step = 1, group = "Market Data", inline = "n1") imatype1 = input.string("SMA", "Moving Average 2", options = ["EMA", "SMA"], group = "Market Data", inline = "n2") imalength1 = input.int(50, "", minval = 1, step = 1, group = "Market Data", inline = "n2") inas = input(true, "Nasdaq", inline = "a1", group = "Net High / Low Data") inyse = input(false, "NYSE", inline = "a1", group = "Net High / Low Data") //create var table var table dashboard = table.new(i_tableypos + "_" +i_tablexpos, 2,7, bgcolor=i_bgcolor,frame_color=color.black, frame_width = 2, border_color = color.black, border_width = 1) // function to switch index to proper symbols indexselect = switch marketselect "Nasdaq" => "IXIC" "SPX" => "SPX" // info for table cells comp = request.security(indexselect, "D", close) putcall = request.security('PCP', 'D', close) fiftydayspx = request.security("s5fi", "D", close) twohundreddayspx = request.security("s5th", "D", close) fiftydaycomp = request.security("ncfi", "D", close) twohundreddaycomp = request.security("ncth", "D", close) ema1 = imatype == "EMA" ? ta.ema(comp,imalength) : imatype == "SMA" ? ta.sma(comp, imalength) : na sma1 = imatype1 == "EMA" ? ta.ema(comp,imalength1) : imatype1 == "SMA" ? ta.sma(comp, imalength1) : na //get net highs / lows data hq = request.security("HIGQ", "D", close) lq = request.security("LOWQ", "D", close) hn = request.security("HIGN", "D", close) ln = request.security("LOWN", "D", close) //decide which symbols to use in net h/l equation higq = inas ? hq : 0 lowq = inas ? lq : 0 hign = inyse ? hn : 0 lown = inyse ? ln : 0 // calculate distance to ma's and net high / lows distema1 = (comp / ema1) - 1 distema2 = (comp / sma1) - 1 nethighlow = hign + higq - lown - lowq // row titles Pcalltitle = "Put Call Ratio:" Nethltitle = "Net Highs / Lows:" fiftydaytitle = "% of Stocks > 50 day:" twohundreddaytitle = "% of Stocks > 200 day:" dist2title = "Distance to " + str.tostring(imalength, "0 ") + imatype + ":" dist2title1 = "Distance to " + str.tostring(imalength1, "0 ") + imatype1 + ":" // display table if (barstate.islast and marketselect == "Nasdaq") table(dashboard) table.merge_cells(dashboard,0,0,1,0) table.cell(dashboard,0,0, "Nasdaq", text_color=i_textcolor, text_size = i_tablesize, text_valign = text.align_center) table.cell(dashboard,0,1, Pcalltitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,2, Nethltitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,3, fiftydaytitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,4, twohundreddaytitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,5, dist2title, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,6, dist2title1, text_color=i_textcolor,text_size = i_tablesize) // table.cell(dashboard,1,0, str.tostring(comp, "##.##"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,1, str.tostring(putcall), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,2, str.tostring(nethighlow), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,3, str.tostring(fiftydaycomp, "#.##"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,4, str.tostring(twohundreddaycomp, "#.##"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,5, str.tostring(distema1, "#.##%"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,6, str.tostring(distema2, "#.##%"), text_color=i_textcolor,text_size = i_tablesize) else if (barstate.islast and marketselect == "SPX") table(dashboard) table.merge_cells(dashboard,0,0,1,0) table.cell(dashboard,0,0, "SPX", text_color=i_textcolor, text_size = i_tablesize, text_valign = text.align_center) table.cell(dashboard,0,1, Pcalltitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,2, Nethltitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,3, fiftydaytitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,4, twohundreddaytitle, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,5, dist2title, text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,0,6, dist2title1, text_color=i_textcolor,text_size = i_tablesize) // table.cell(dashboard,1,0, str.tostring(comp, "##.##"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,1, str.tostring(putcall), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,2, str.tostring(nethighlow), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,3, str.tostring(fiftydayspx, "#.##"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,4, str.tostring(twohundreddayspx, "#.##"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,5, str.tostring(distema1, "#.##%"), text_color=i_textcolor,text_size = i_tablesize) table.cell(dashboard,1,6, str.tostring(distema2, "#.##%"), text_color=i_textcolor,text_size = i_tablesize)
Trend Line Adam Moradi v1 (Tutorial Content)
https://www.tradingview.com/script/7nYt1gP8-Trend-Line-Adam-Moradi-v1-Tutorial-Content/
TradeAdam
https://www.tradingview.com/u/TradeAdam/
488
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © TradeAdam //@version=5 indicator('Trend Line AdamMoradi_v1 (Tutorial Content)', overlay=true, max_bars_back=4000) _period = input.int(defval=24, title='Pivot _period', minval=10, maxval=50) PivotPointNumber = input.int(defval=6, title='Number of Pivots to be controlled', minval=2, maxval=6) up_trend_color = input.color(defval=color.lime, title='Up Trend Colors', inline='tcol') down_trend_color = input.color(defval=color.red, title='Down Trend Colors', inline='tcol') float pivot_high = ta.pivothigh(_period, _period) float pivot_low = ta.pivotlow(_period, _period) var trend_top_values = array.new_float(PivotPointNumber) //high pivot point var trend_top_position = array.new_int(PivotPointNumber) //pivot position var trend_bottom_values = array.new_float(PivotPointNumber) //low pivot point var trend_bottom_position = array.new_int(PivotPointNumber) //pivot position add_to_array(apointer1, apointer2, val) => array.unshift(apointer1, val) array.unshift(apointer2, bar_index) array.pop(apointer1) array.pop(apointer2) if pivot_high add_to_array(trend_top_values, trend_top_position, pivot_high) if pivot_low add_to_array(trend_bottom_values, trend_bottom_position, pivot_low) // line definitions maxline = 3 var bottom_lines = array.new_line(maxline, na) var top_lines = array.new_line(maxline, na) //var ticksize = syminfo.mintick // Pivot point loop to control the existence of a trend line count_line_low = 0 count_line_high = 0 starttime = timestamp(0, 0, 0, 0, 0, 0) // bottom trend line calc if time >= starttime for x = 0 to maxline - 1 by 1 line.delete(array.get(bottom_lines, x)) line.delete(array.get(top_lines, x)) for pivot1 = 0 to PivotPointNumber - 2 by 1 up_val1 = 0.0 up_val2 = 0.0 up1 = 0 up2 = 0 if count_line_low <= maxline for pivot2 = PivotPointNumber - 1 to pivot1 + 1 by 1 value1 = array.get(trend_bottom_values, pivot1) value2 = array.get(trend_bottom_values, pivot2) position1 = array.get(trend_bottom_position, pivot1) position2 = array.get(trend_bottom_position, pivot2) if value1 > value2 different = (value1 - value2) / (position1 - position2) high_line = value2 + different low_location = bar_index low_value = low valid = true for x = position2 + 1 - _period to bar_index by 1 if close[bar_index - x] < high_line valid := false break low_location := x low_value := high_line high_line += different high_line if valid up_val1 := high_line - different up_val2 := value2 up1 := low_location up2 := position2 break d_value1 = 0.0 d_value2 = 0.0 d_position1 = 0 d_position2 = 0 //top trend line calc if count_line_high <= maxline for pivot2 = PivotPointNumber - 1 to pivot1 + 1 by 1 value1 = array.get(trend_top_values, pivot1) value2 = array.get(trend_top_values, pivot2) position1 = array.get(trend_top_position, pivot1) position2 = array.get(trend_top_position, pivot2) if value1 < value2 different = (value2 - value1) / float(position1 - position2) high_line = value2 - different low_location = bar_index low_value = high valid = true for x = position2 + 1 - _period to bar_index by 1 if close[bar_index - x] > high_line valid := false break low_location := x low_value := high_line high_line -= different high_line if valid d_value1 := high_line + different d_value2 := value2 d_position1 := low_location d_position2 := position2 break // if there is continues uptrend line then draw it if up1 != 0 and up2 != 0 and count_line_low < maxline count_line_low += 1 array.set(bottom_lines, count_line_low - 1, line.new(up2 - _period, up_val2, up1, up_val1, color=up_trend_color)) // if there is continues downtrend line then draw it if d_position1 != 0 and d_position2 != 1 and count_line_high < maxline count_line_high += 1 array.set(top_lines, count_line_high - 1, line.new(d_position2 - _period, d_value2, d_position1, d_value1, color=down_trend_color))
Fibonacci Moving Average (FMA)
https://www.tradingview.com/script/6pxgp2vh-Fibonacci-Moving-Average-FMA/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
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/ // © peacefulLizard50262 //@version=5 indicator("Fibonacci Moving Average", "FMA", true) metallic_mean(source)=> (source+math.sqrt(math.pow(source, 2) + 4))/2 mwma(source, length)=> float src = metallic_mean(source) var float weight_sum = na var float sum = na for i = 0 to length - 1 weight = metallic_mean(i) weight_sum := nz(weight_sum[1]) + weight sum := nz(sum[1]) + src * weight out = (sum - nz(sum[length]))/(weight_sum - nz(weight_sum[length])) source = input.source(close, "Source") length = input.int(20, "Length", 2) plot(mwma(source, length))
Market Crashes/Chart Timeframes Highlight
https://www.tradingview.com/script/4JIHGvDU-Market-Crashes-Chart-Timeframes-Highlight/
RexDogActual
https://www.tradingview.com/u/RexDogActual/
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/ // © xkavalis //@version=5 indicator("Market Crashes/Timeframes Highlight", "MCTH", overlay=true) ////bool in_87_Timeframe = time > s_first_date and time < e_first_date first_start_date = input.time(timestamp("07 Sep 1987 00:00 +0300"), "1st Timeframe Start", "Enter Start Date","","Timeframe 1") first_end_date = input.time(timestamp("31 Dec 1987 00:00 +0300"), "1st Timeframe End", "Enter End Date","","Timeframe 1") second_start_date = input.time(timestamp("01 Jul 1990 00:00 +0300"), "2nd Timeframe Start", "Enter Start Date","","Timeframe 2") second_end_date = input.time(timestamp("31 Oct 1990 00:00 +0300"), "2nd Timeframe End", "Enter End Date","","Timeframe 2") third_start_date = input.time(timestamp("06 Mar 2000 00:00 +0300"), "3rd Timeframe Start", "Enter Start Date","","Timeframe 3") third_end_date = input.time(timestamp("31 Aug 2002 00:00 +0300"), "3rd Timeframe End", "Enter End Date","","Timeframe 3") fourth_start_date = input.time(timestamp("01 Sep 2007 00:00 +0300"), "4th Timeframe Start", "Enter Start Date","","Timeframe 4") fourh_end_date = input.time(timestamp("01 Apr 2009 00:00 +0300"), "4th Timeframe End", "Enter End Date","","Timeframe 4") fifth_start_date = input.time(timestamp("16 Dec 2016 00:00 +0300"), "5th Timeframe Start", "Enter Start Date","","Timeframe 5") fifth_end_date = input.time(timestamp("31 Jan 2019 00:00 +0300"), "5th Timeframe End", "Enter End Date","","Timeframe 5") sixth_start_date = input.time(timestamp("01 Feb 2020 00:00 +0300"), "6th Timeframe Start", "Enter Start Date","","Timeframe 6") sixth_end_date = input.time(timestamp("26 May 2020 00:00 +0300"), "6th Timeframe End", "Enter End Date","","Timeframe 6") seventh_start_date = input.time(timestamp("01 Apr 2021 00:00 +0300"), "7th Timeframe Start", "Enter Start Date","","Timeframe 7") seventh_end_date = input.time(timestamp("15 Aug 2022 00:00 +0300"), "7th Timeframe End", "Enter End Date","","Timeframe 7") bgcolor(time > first_start_date and time < first_end_date ? color.new(color.gray, 80) : na, offset=0, title="1st Timeframe") bgcolor(time > second_start_date and time < second_end_date ? color.new(color.gray, 80) : na, offset=0, title="2nd Timeframe") bgcolor(time > third_start_date and time < third_end_date ? color.new(color.gray, 80) : na, offset=0, title="3rd Timeframe") bgcolor(time > fourth_start_date and time < fourh_end_date ? color.new(color.gray, 80) : na, offset=0, title="4th Timeframe") bgcolor(time > fifth_start_date and time < fifth_end_date ? color.new(color.gray, 80) : na, offset=0, title="5th Timeframe") bgcolor(time > sixth_start_date and time < sixth_end_date ? color.new(color.gray, 80) : na, offset=0, title="6th Timeframe") bgcolor(time > seventh_start_date and time < seventh_end_date ? color.new(color.gray, 80) : na, offset=0, title="7th Timeframe")
Crypto Index (DXY) Candles
https://www.tradingview.com/script/t4qj2jrU-Crypto-Index-DXY-Candles/
EsIstTurnt
https://www.tradingview.com/u/EsIstTurnt/
32
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // @ esistturnt // Credit to @loxx for the stock DXY in pinescript //@version=5 indicator("Crypto Index (CXY) Candles",shorttitle="CXY",overlay = false,timeframe='', timeframe_gaps = true) greencolor = #ACFB00 redcolor = #FF0000 DXYCXY=input.bool(false,'Show Standard DXY') sym1=DXYCXY?"EURUSD":input.string("BTCUSDTPERP",group='Symbol 1'),weight1=input.float(0.576,group='Symbol 1') sym2=DXYCXY?"USDJPY":input.string("ETHUSDTPERP",group='Symbol 2'),weight2=input.float(0.136,group='Symbol 2') sym3=DXYCXY?"GBPUSD":input.string("ADAUSDTPERP",group='Symbol 3'),weight3=input.float(0.119,group='Symbol 3') sym4=DXYCXY?"USDCAD":input.string("SOLUSDTPERP",group='Symbol 4'),weight4=input.float(0.091,group='Symbol 4') sym5=DXYCXY?"USDSEK":input.string("BNBUSDTPERP",group='Symbol 5'),weight5=input.float(0.042,group='Symbol 5') sym6=DXYCXY?"USDCHF":input.string("XMRUSDTPERP",group='Symbol 6'),weight6=input.float(0.036,group='Symbol 6') eurc = request.security(sym1, timeframe.period, close) euro = request.security(sym1, timeframe.period, open ) eurh = request.security(sym1, timeframe.period, high ) eurl = request.security(sym1, timeframe.period, low ) jpyc = request.security(sym2, timeframe.period, close) jpyo = request.security(sym2, timeframe.period, open ) jpyh = request.security(sym2, timeframe.period, high ) jpyl = request.security(sym2, timeframe.period, low ) gbpc = request.security(sym3, timeframe.period, close) gbpo = request.security(sym3, timeframe.period, open ) gbph = request.security(sym3, timeframe.period, high ) gbpl = request.security(sym3, timeframe.period, low ) cadc = request.security(sym4, timeframe.period, close) cado = request.security(sym4, timeframe.period, open ) cadh = request.security(sym4, timeframe.period, high ) cadl = request.security(sym4, timeframe.period, low ) sekc = request.security(sym5, timeframe.period, close) seko = request.security(sym5, timeframe.period, open ) sekh = request.security(sym5, timeframe.period, high ) sekl = request.security(sym5, timeframe.period, low ) chfc = request.security(sym6, timeframe.period, close) chfo = request.security(sym6, timeframe.period, open ) chfh = request.security(sym6, timeframe.period, high ) chfl = request.security(sym6, timeframe.period, low ) dxyClose =DXYCXY? 50.14348112 * math.pow(eurc, -1*weight1) *math.pow(jpyc, weight2) * math.pow(gbpc, -1*weight3) * math.pow(cadc, weight4) * math.pow(sekc, weight5) * math.pow(chfc, weight6) : 50.14348112 * math.pow(eurc, weight1) * math.pow(jpyc, weight2) * math.pow(gbpc, weight3) * math.pow(cadc, weight4) * math.pow(sekc, weight5) * math.pow(chfc, weight6) dxyOpen = DXYCXY? 50.14348112 * math.pow(euro, -1*weight1) * math.pow(jpyo, weight2) * math.pow(gbpo, -1*weight3) * math.pow(cado, weight4) * math.pow(seko, weight5) * math.pow(chfo, weight6) : 50.14348112 * math.pow(euro, weight1) * math.pow(jpyo, weight2) * math.pow(gbpo, weight3) * math.pow(cado, weight4) * math.pow(seko, weight5) * math.pow(chfo, weight6) dxyHigh = DXYCXY? 50.14348112 * math.pow(eurh, -1*weight1) * math.pow(jpyh, weight2) * math.pow(gbph, -1*weight3) * math.pow(cadh, weight4) * math.pow(sekh, weight5) * math.pow(chfh, weight6) : 50.14348112 * math.pow(eurh, weight1) * math.pow(jpyh, weight2) * math.pow(gbph, weight3) * math.pow(cadh, weight4) * math.pow(sekh, weight5) * math.pow(chfh, weight6) dxyLow = DXYCXY? 50.14348112 * math.pow(eurl, -1*weight1) * math.pow(jpyl, weight2) * math.pow(gbpl, -1*weight3) * math.pow(cadl, weight4) * math.pow(sekl, weight5) * math.pow(chfl, weight6) : 50.14348112 * math.pow(eurl, weight1) * math.pow(jpyl, weight2) * math.pow(gbpl, weight3) * math.pow(cadl, weight4) * math.pow(sekl, weight5) * math.pow(chfl, weight6) color= dxyOpen < dxyClose ? greencolor : redcolor plotcandle(dxyOpen, dxyHigh, dxyLow, dxyClose, title='Title', color =color,bordercolor=color, wickcolor=color)
Visible Fibonacci
https://www.tradingview.com/script/Udh0nm6f-Visible-Fibonacci/
TradingView
https://www.tradingview.com/u/TradingView/
1,864
study
5
MPL-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("Visible Fibonacci", "Visible Fib", true, max_lines_count = 500) // Visible Fibonacci // v1, 2023.01.01 // This code was written using the recommendations from the Pine Script™ User Manual's Style Guide: // https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html import PineCoders/VisibleChart/4 as chart //#region ———————————————————— Constants and Inputs // ————— Constants // Colors color GRAY = color.gray color RED = color.red color ORANGE = color.orange color TEAL = color.teal color RUBY = #e91e63 color AQUA = color.aqua color BLUE = color.blue color GREEN = color.green color PURPLE = color.purple color LIME = color.lime color FUCHSIA = color.fuchsia // Line Type string TY01 = " ─ Line" string TY02 = " ┄ Dashed line" string TY03 = " ┉ Dotted line" // Fib level type string LV01 = "Values" string LV02 = "Percent" // Fib calculation type string FT01 = "Visible Chart Range" string FT02 = "Visible Zig Zag" // Label placement string LB01 = "Left" string LB02 = "Center" string LB03 = "Right" string LB04 = "Top" string LB05 = "Middle" string LB06 = "Bottom" // Label Size string SZ01 = "tiny" string SZ02 = "small" string SZ03 = "normal" string SZ04 = "large" string SZ05 = "huge" // Tool Tips string TT_FT = "Choose from 2 calculation types: \n\n• 'Visible Chart Range' \nCalculates the Fibonacci retracement based on the high and low of the visible chart range. \n\n• 'Visible Zig Zag' \nCalculates the Fibonacci retracement based on zig zag pivots within the visible chart range." string TT_ZZ = "Show Zig Zag lines when the 'Visible Zig Zag' display type is enabled." string TT_MP = "When enabled, adds a pivot in the opposite direction if a new pivot is not found in the number of bars in the 'Pivot Length'." string TT_PL = "Number of bars back to track pivots (ex. Highest point in 50 bars)." string TT_ZA = "Your choices here dictate the Zig Zag line color, line width, and line style." string TT_LP = "Places the fib retracement on the nth pivot point back from the last visible pivot." // Inputs string fibTypeInput = input.string(FT01, "Fib Calculation Type", options = [FT01, FT02], tooltip = TT_FT) string GRP1 = "Visible ZigZag" bool showZZInput = input.bool(true, "Show Zig Zag", group = GRP1, inline = "00", tooltip = TT_ZZ) bool addPivotInput = input.bool(true, "Detect additional pivots", group = GRP1, inline = "01", tooltip = TT_MP) int lengthInput = input.int(50, "   Pivot Length", group = GRP1, minval = 1, tooltip = TT_PL) color zzBullColorInput = input.color(GRAY, "   ", group = GRP1, inline = "02") color zzBearColorInput = input.color(GRAY, "", group = GRP1, inline = "02") int zzwidthInput = input.int(2, "", group = GRP1, inline = "02", minval = 1) string zzStyleInput = input.string(TY01, "", group = GRP1, inline = "02", tooltip = TT_ZA, options = [TY01, TY02, TY03]) int pivotInput = input.int(1, "   nth Last Pivot", group = GRP1, minval = 0, tooltip = TT_LP) string GRP2 = "Fib Levels" bool extendRtInput = input.bool(true, "Extend to real time", group = GRP2) bool extendRightInput = input.bool(false, "Extend lines right", group = GRP2) bool extendLeftInput = input.bool(false, "Extend lines left", group = GRP2) bool trendLineInput = input.bool(true, "Trend Line", group = GRP2, inline = "10") color trendColorInput = input.color(GRAY, "", group = GRP2, inline = "10") int trendWidthInput = input.int(1, "", group = GRP2, inline = "10", minval = 1) string trendStyleInput = input.string(TY02, "", group = GRP2, inline = "10", options = [TY01, TY02, TY03]) int levelsWidthInput = input.int(1, "Levels Line", group = GRP2, inline = "11", minval = 1) string fibStyleInput = input.string(TY01, "", group = GRP2, inline = "11", options = [TY01, TY02, TY03]) string extStyleInput = input.string(TY03, "", group = GRP2, inline = "11", options = [TY01, TY02, TY03]) bool show000Input = input.bool(true, "", group = GRP2, inline = "20") float level000Input = input.float(0, "", group = GRP2, inline = "20") color color000Input = input.color(GRAY, "", group = GRP2, inline = "20") bool show236Input = input.bool(true, "", group = GRP2, inline = "20") float level236Input = input.float(0.236, "", group = GRP2, inline = "20") color color236Input = input.color(RED, "", group = GRP2, inline = "20") bool show382Input = input.bool(true, "", group = GRP2, inline = "21") float level382Input = input.float(0.382, "", group = GRP2, inline = "21") color color382Input = input.color(ORANGE, "", group = GRP2, inline = "21") bool show500Input = input.bool(true, "", group = GRP2, inline = "21") float level500Input = input.float(0.5, "", group = GRP2, inline = "21") color color500Input = input.color(GREEN, "", group = GRP2, inline = "21") bool show618Input = input.bool(true, "", group = GRP2, inline = "22") float level618Input = input.float(0.618, "", group = GRP2, inline = "22") color color618Input = input.color(TEAL, "", group = GRP2, inline = "22") bool show786Input = input.bool(true, "", group = GRP2, inline = "22") float level786Input = input.float(0.786, "", group = GRP2, inline = "22") color color786Input = input.color(AQUA, "", group = GRP2, inline = "22") bool show100Input = input.bool(true, "", group = GRP2, inline = "23") float level100Input = input.float(1, "", group = GRP2, inline = "23") color color100Input = input.color(GRAY, "", group = GRP2, inline = "23") bool show161Input = input.bool(true, "", group = GRP2, inline = "23") float level161Input = input.float(1.618, "", group = GRP2, inline = "23") color color161Input = input.color(BLUE, "", group = GRP2, inline = "23") bool show261Input = input.bool(true, "", group = GRP2, inline = "24") float level261Input = input.float(2.618, "", group = GRP2, inline = "24") color color261Input = input.color(RED, "", group = GRP2, inline = "24") bool show361Input = input.bool(true, "", group = GRP2, inline = "24") float level361Input = input.float(3.618, "", group = GRP2, inline = "24") color color361Input = input.color(PURPLE, "", group = GRP2, inline = "24") bool show423Input = input.bool(true, "", group = GRP2, inline = "25") float level423Input = input.float(4.236, "", group = GRP2, inline = "25") color color423Input = input.color(RUBY, "", group = GRP2, inline = "25") bool show127Input = input.bool(false, "", group = GRP2, inline = "25") float level127Input = input.float(1.272, "", group = GRP2, inline = "25") color color127Input = input.color(ORANGE, "", group = GRP2, inline = "25") bool show141Input = input.bool(false, "", group = GRP2, inline = "26") float level141Input = input.float(1.414, "", group = GRP2, inline = "26") color color141Input = input.color(RED, "", group = GRP2, inline = "26") bool show227Input = input.bool(false, "", group = GRP2, inline = "26") float level227Input = input.float(2.272, "", group = GRP2, inline = "26") color color227Input = input.color(ORANGE, "", group = GRP2, inline = "26") bool show241Input = input.bool(false, "", group = GRP2, inline = "27") float level241Input = input.float(2.414, "", group = GRP2, inline = "27") color color241Input = input.color(GREEN, "", group = GRP2, inline = "27") bool show200Input = input.bool(false, "", group = GRP2, inline = "27") float level200Input = input.float(2, "", group = GRP2, inline = "27") color color200Input = input.color(TEAL, "", group = GRP2, inline = "27") bool show300Input = input.bool(false, "", group = GRP2, inline = "28") float level300Input = input.float(3, "", group = GRP2, inline = "28") color color300Input = input.color(AQUA, "", group = GRP2, inline = "28") bool show327Input = input.bool(false, "", group = GRP2, inline = "28") float level327Input = input.float(3.272, "", group = GRP2, inline = "28") color color327Input = input.color(GRAY, "", group = GRP2, inline = "28") bool show341Input = input.bool(false, "", group = GRP2, inline = "29") float level341Input = input.float(3.414, "", group = GRP2, inline = "29") color color341Input = input.color(BLUE, "", group = GRP2, inline = "29") bool show400Input = input.bool(false, "", group = GRP2, inline = "29") float level400Input = input.float(4, "", group = GRP2, inline = "29") color color400Input = input.color(RED, "", group = GRP2, inline = "29") bool show427Input = input.bool(false, "", group = GRP2, inline = "30") float level427Input = input.float(4.272, "", group = GRP2, inline = "30") color color427Input = input.color(PURPLE, "", group = GRP2, inline = "30") bool show441Input = input.bool(false, "", group = GRP2, inline = "30") float level441Input = input.float(4.414, "", group = GRP2, inline = "30") color color441Input = input.color(RUBY, "", group = GRP2, inline = "30") bool show461Input = input.bool(false, "", group = GRP2, inline = "31") float level461Input = input.float(4.618, "", group = GRP2, inline = "31") color color461Input = input.color(ORANGE, "", group = GRP2, inline = "31") bool show476Input = input.bool(false, "", group = GRP2, inline = "31") float level476Input = input.float(4.764, "", group = GRP2, inline = "31") color color476Input = input.color(TEAL, "", group = GRP2, inline = "31") bool useFillInput = input.bool(true, "Background", group = GRP2, inline = "32") int bgTranspInput = input.int(90, "", group = GRP2, inline = "32") bool invertFibInput = input.bool(false, "Reverse", group = GRP2) bool useLogScaleInput = input.bool(false, "Log scale Fibs", group = GRP2) string GRP3 = "Labels" bool showPricesInput = input.bool(true, "Prices", group = GRP3) bool showLevelsInput = input.bool(true, "Levels", group = GRP3, inline = "40") string levelTypeInput = input.string(LV01, "", group = GRP3, inline = "40", options = [LV01, LV02]) string labelXInput = input.string(LB01, "Fib Labels", group = GRP3, inline = "41", options = [LB01, LB02, LB03]) string labelYInput = input.string(LB04, "", group = GRP3, inline = "41", options = [LB04, LB05, LB06]) string labelSizeInput = input.string(SZ03, "", group = GRP3, inline = "41", options = [SZ01, SZ02, SZ03, SZ04, SZ05]) bool tLabelsInput = input.bool(true, "Time Labels", group = GRP3, inline = "42") string tLabelSizeInput = input.string(SZ03, "", group = GRP3, inline = "42", options = [SZ01, SZ02, SZ03, SZ04, SZ05]) //#endregion //#region ———————————————————— User-defined Types // @type A coordinate in price and time. // @field y A value on the Y axis (price). // @field x A value on the X axis (time). type point float y int x // @type A level of significance used to determine directional movement or potential support and resistance. // @field start The coordinate of the previous `pivotPoint`. // @field end The coordinate of the current `pivotPoint`. // @field dir Direction of movement of the `pivotPoint`. A value of 1 is used for an upward direction, -1 for downward. // @field ln A line object connecting the `start` to the `end`. // @field bars Number of bars in the pivot. Default is 0 bars. type pivotPoint point start point end int dir line ln int bars = 0 // @type Horizontal levels that indicate possible support and resistance where price could potentially reverse direction. // @field level A Fibonacci ratio as a decimal. // @field fibColor A color for the lines and labels. // @field fibLine A line object for the main fib level. // @field extLine A line object for the fib level that is extended from the last pivot to the last bar. // @field fibLabel A label to display the `level` at the `fibLine`. type fibLevel float level color fibColor line fibLine line extLine label fibLabel //#endregion //#region ———————————————————— Global Variables // Arrays for lines, labels, and colors. var array<float> levels = array.new<float>() var array<fibLevel> fibLevels = array.new<fibLevel>() var array<int> sortedArray = array.new<int>() // Set line extension type. string extendExt = extendRightInput ? extend.right : extend.none string extendFib = switch not extendRtInput and extendLeftInput and extendRightInput => extend.both not extendRtInput and extendRightInput => extend.right extendLeftInput => extend.left => extend.none // Label display conditions. bool showLabels = showPricesInput or showLevelsInput bool showPercent = levelTypeInput == LV02 string labelStyle = switch labelYInput == LB04 and labelXInput == LB01 => label.style_label_lower_right labelYInput == LB05 and labelXInput == LB01 => label.style_label_right labelYInput == LB06 and labelXInput == LB01 => label.style_label_upper_right labelYInput == LB04 and labelXInput == LB02 => label.style_label_down labelYInput == LB05 and labelXInput == LB02 => label.style_label_center labelYInput == LB06 and labelXInput == LB02 => label.style_label_up labelYInput == LB04 and labelXInput == LB03 => label.style_label_lower_left labelYInput == LB05 and labelXInput == LB03 => label.style_label_left labelYInput == LB06 and labelXInput == LB03 => label.style_label_upper_left // Determine display type. bool useZigZag = fibTypeInput == FT02 //#endregion //#region ———————————————————— Functions // @function Converts a value from exponential to logarithmic form. // @param value (series float) The value to convert to log. // @returns (float) The log value. toLog(series float value) => float exponent = math.abs(value) float product = math.log10(exponent + 0.0001) + 4 float result = exponent < 1e-8 ? 0 : value < 0 ? - product : product // @function Converts a value from logarithmic to exponential form. // @param value (series float) The value to convert from log. // @returns (float) The exponential value. fromLog(series float value) => float exponent = math.abs(value) float product = math.pow(10, exponent - 4) - 0.0001 float result = exponent < 1e-8 ? 0 : value < 0 ? - product : product // @function Determines a fib price based on the chart's high and low price dependant on if the fib retracement is bullish or bearish. Converts to log scale when dictated by user-selection. // @param value (series float) Fib level in decimal form. // @param hiPrice (series float) Retracement high. // @param loPrice (series float) Retracement low. // @param isBull (series bool) Condition determining if the retracement is bullish. // @returns (float) The fib price. getPrice(series float value, series float hiPrice, series float loPrice, series bool isBull) => float hiPoint = useLogScaleInput ? toLog(hiPrice) : hiPrice float loPoint = useLogScaleInput ? toLog(loPrice) : loPrice float fibPrice = isBull and invertFibInput or not isBull and not invertFibInput ? loPoint + ((hiPoint - loPoint) * value) : hiPoint - ((hiPoint - loPoint) * value) float result = useLogScaleInput ? fromLog(fibPrice) : fibPrice // @function Determines a line style based on a user defined input string matching one of the `TY*` constants. // @param styleString (series string) Input string. // @returns (string) A string in `line.style*` format. lineStyle(simple string styleString) => string result = switch styleString TY01 => line.style_solid TY02 => line.style_dashed TY03 => line.style_dotted // @function Populates global arrays with a `fibLevel` object and fib value when the corresponding input condition is selected. // @param condition (simple bool) Condition to determine if the fib level is to be displayed. // @param value (simple float) Value of the user-defined fib level. // @param color (series color) Color for the fib line and label. // @returns (void) Function has no return. populate(simple bool condition, simple float value, series color color) => if condition fibLevel fib = fibLevel.new(value, color) fib.fibLine := line.new(na, na, na, na, xloc.bar_time, extendFib, color, lineStyle(fibStyleInput), levelsWidthInput) if extendRtInput fib.extLine := line.new(na, na, na, na, xloc.bar_time, extendExt, color, lineStyle(extStyleInput), levelsWidthInput) if showLabels fib.fibLabel := label.new(na, na, "", xloc.bar_time, yloc.price, color(na), labelStyle, color, labelSizeInput) array.push(levels, value) array.push(fibLevels, fib) // @function Sets a linefill object between each fibLevel object. // @returns (void) Function has no return. setBg() => line temp1 = na line temp2 = na for sortedIndex in sortedArray fibLevel fib = array.get(fibLevels, sortedIndex) color fillColor = color.new(fib.fibColor, bgTranspInput) if not na(temp1) linefill.new(temp1, fib.fibLine, fillColor) if extendRtInput linefill.new(temp2, fib.extLine, fillColor) temp1 := fib.fibLine temp2 := fib.extLine // @function Determines a string for use within a fib label. The text will contain the fib price/percent and/or the fib level dependant on user selections for "Prices" and "Levels". // @param value (series float) The fib level from one of the `level*Input` user selections. // @param price (series float) The corresponding price level for the fib level. // @returns (string) A string containing the fib `value` and/or the fib `price`. labelText(series float value, series float price) => string levelString = showPercent ? str.tostring(value * 100, format.percent) : str.format("{0, number, #.###}", value) string result = switch showPricesInput and showLevelsInput => str.format("{0}({1})", levelString, str.tostring(price, format.mintick)) showPricesInput => str.format("({0})", str.tostring(price, format.mintick)) showLevelsInput => levelString // @function Determines a X time coordinate in UNIX time for fib labels dependant on the user's location selection of "Labels", and the `LB*` constants. // @returns (int) A time for fib labels. labelTime(series int leftTime, series int rightTime) => int result = switch labelXInput LB01 => leftTime LB02 => int(math.avg(leftTime, extendRtInput ? chart.right_visible_bar_time : rightTime)) LB03 => extendRtInput ? chart.right_visible_bar_time : rightTime // @function Produces a label with the formatted time and price for the point it is placed. Continues to update the location and text on each bar. // @param x (series int) Bar UNIX time of the label position. // @param y (series float) Price of the label position. // @param color (simple color) Color for the text and label. // @param style (series string) Label style. Accepts one of the `label.style_*` built-in constants. // @returns (void) Function has no return. timeLabel(series int x, series float y, simple color color, series string style) => var label timeLabel = label.new(na, na, na, xloc.bar_time, yloc.price, color.new(color, 80), style, color, tLabelSizeInput) label.set_xy(timeLabel, x, y) label.set_text(timeLabel, str.format("{0}\n{1,time, dd/MM/yy @ HH:mm:ss}", str.tostring(y, format.mintick), x)) // @function Produces a line object that sets it's bar time and price on each bar. // @param x1 (series int) bar UNIX time of the first point of the line. // @param y1 (series float) Price of the first point of the line. // @param x2 (series int) bar UNIX time of the second point of the line. // @param y2 (series float) Price of the second point of the line. // @returns (void) Function has no return. hiLoLine(series int x1, series float y1, series int x2, series float y2) => var line hiLoLine = line.new(na, na, na, na, xloc.bar_time, extend.none, trendColorInput, lineStyle(trendStyleInput), trendWidthInput) line.set_xy1(hiLoLine, x1, y1) line.set_xy2(hiLoLine, x2, y2) // @function Updates price and time of `fibLevel`s and label text. // @param leftTime (series int) bar UNIX time of the first point of the fib retracement. // @param rightTime (series int) bar UNIX time of the second point of the fib retracement. // @param hiPrice (series float) Price of the high point of the fib retracement. // @param loPrice (series float) Price of the low point of the fib retracement. // @param isBull (series bool) Condition to determine if the retracement is bullish. // @returns (void) Function has no return. setLevels(series int leftTime, series int rightTime, series float hiPrice, series float loPrice, series bool isBull) => int labelTime = labelTime(leftTime, rightTime) for fib in fibLevels float fibPrice = getPrice(fib.level, hiPrice, loPrice, isBull) line.set_xy1(fib.fibLine, leftTime, fibPrice) line.set_xy2(fib.fibLine, rightTime, fibPrice) if extendRtInput line.set_xy1(fib.extLine, rightTime, fibPrice) line.set_xy2(fib.extLine, chart.right_visible_bar_time, fibPrice) if showLabels label.set_xy(fib.fibLabel, labelTime, fibPrice) label.set_text(fib.fibLabel, labelText(fib.level, fibPrice)) // @function Adds a `value` to the begining of the `id` array, while removing from the end of the array if the array size exceeds the `max` size. // @param id (any array type) An array object. // @param max (simple int) The maximum size of the array. // @param value (series <type of the array's elements>) The value to add to the start of the array. // @returns (void) Function has no return. addToArray(id, simple int max, value) => array.unshift(id, value) if array.size(id) > max array.pop(id) // @function Creates and adds a new "pivotPoint" object to the `pivotArray` when a change in `dir` is detected. Sets a line between the new and previous pivot points when "show zigzag" is enabled. // @param length (simple int) Number of bars to search for a "pivotPoint". // @param pivotArray (array<pivotPoint>) An array of "pivotPoints". // @param addPivots (simple bool) Condition to search for additonal pivots, Adds a pivot in the opposite direction if a pivot is not found in `length` bars. Default is true. // @returns (void) Function has no return. addPivot(simple int length, array<pivotPoint> pivotArray, simple bool addPivots = true) => pivotPoint piv = array.get(pivotArray, 0) int altLen = math.max(piv.bars, 1) int hiBar = ta.highestbars(length) int loBar = ta.lowestbars(length) int altHiBar = ta.highestbars(altLen) int altLoBar = ta.lowestbars(altLen) float altHi = ta.highest(altLen) float altLo = ta.lowest(altLen) bool missedPiv = piv.bars >= length and addPivots and not (hiBar == 0 and high > piv.end.y or loBar == 0 and low < piv.end.y) var int dir = na dir := switch missedPiv => nz(dir, altHiBar < altLoBar ? 1 : -1) * -1 hiBar + loBar == 0 => dir * -1 hiBar == 0 => 1 loBar == 0 => -1 => dir if dir != dir[1] and time <= chart.right_visible_bar_time [hiLo, altHiLo, offset, lineColor] = switch dir > 0 => [high, altHi, altHiBar, zzBullColorInput] => [low, altLo, altLoBar, zzBearColorInput] [pivY, bars] = switch missedPiv => [altHiLo, math.abs(offset)] => [hiLo, 0] point newPoint = point.new(pivY, time[bars]) pivotPoint pivot = pivotPoint.new(piv.end, newPoint, dir, bars = bars) if showZZInput and time >= chart.left_visible_bar_time pivot.ln := line.new(piv.end.x, piv.end.y, time[bars], pivY, xloc.bar_time, extend.none, lineColor, lineStyle(zzStyleInput), zzwidthInput) addToArray(pivotArray, math.max(3, pivotInput + 1), pivot) // @function Updates the price and time of the developing "pivotPoint" if the latest calculated "point" exceeds the last committed value. // @param length (simple int) Number of bars to search for a "pivotPoint". // @param pivotArray (array<pivotPoint>) An array of "pivotPoints". // @returns (void) Function has no return. updatePivot(simple int length, array<pivotPoint> pivotArray) => if time <= chart.right_visible_bar_time pivotPoint piv = array.get(pivotArray, 0) int dir = piv.dir float hiLo = dir > 0 ? high : low piv.bars += 1 if hiLo * dir > piv.end.y * dir piv.end.y := hiLo piv.end.x := time piv.bars := 0 if showZZInput and time >= chart.left_visible_bar_time if na(piv.ln) color lineColor = dir > 0 ? zzBullColorInput : zzBearColorInput piv.ln := line.new(piv.start.x, piv.start.y, time, hiLo, xloc.bar_time, extend.none, lineColor, lineStyle(zzStyleInput), zzwidthInput) line.set_xy2(piv.ln, time, hiLo) // @function Calculates Zig Zag based on pivots formed over the lookback `length`. // @param length (simple int) Number of bars to search for a "pivotPoint". // @param addPivots (simple bool) Condition to search for additonal pivots, Adds a pivot in the opposite direction if a pivot is not found in `length` bars. Default is true. // @returns (array<pivotPoint>) An array of "pivotPoint" objects. zigZag(simple int length, simple bool addPivots = true) => var array<pivotPoint> pivots = array.new<pivotPoint>(1, pivotPoint.new(point.new(close), point.new(close))) updatePivot(length, pivots) addPivot(length, pivots, addPivots) pivots // @function Renders a start "point" and end "point" for the `nthPivot` back in the visible range when "Use zig zag" is enabled, and returns the 2 coordinates as a tuple. // @param nthPivot (simple int) The nth pivot. // @returns ([int, float, int, float]) The start point time, the start point price, the end point time, the end point price. findHiLo(simple int nthPivot) => int leftX = na float leftY = na int rightX = na float rightY = na if useZigZag array<pivotPoint> pivotArray = zigZag(lengthInput, addPivotInput) if barstate.islast pivotPoint pivot = array.get(pivotArray, nthPivot) leftX := pivot.start.x leftY := pivot.start.y rightX := pivot.end.x rightY := pivot.end.y if showZZInput line.set_style(pivot.ln, lineStyle(trendStyleInput)) [leftX, leftY, rightX, rightY] //#endregion //#region ———————————————————— Calculations // Determine pivot points when "use zig zag" is enabled. [leftX, leftY, rightX, rightY] = findHiLo(pivotInput) // Fib high and low values and their time x-coordinate. bool zzBull = leftY < rightY float chartHigh = useZigZag ? math.max(leftY, rightY) : chart.high() float chartLow = useZigZag ? math.min(leftY, rightY) : chart.low() int hiTime = useZigZag ? zzBull ? rightX : leftX : chart.highBarTime() int loTime = useZigZag ? zzBull ? leftX : rightX : chart.lowBarTime() bool isBull = useZigZag ? zzBull : loTime < hiTime int leftTime = math.min(hiTime, loTime) int rightTime = math.max(hiTime, loTime) // Determine label style for time labels. string hiTimeStyle = isBull ? label.style_label_lower_right : label.style_label_lower_left string loTimeStyle = isBull ? label.style_label_upper_left : label.style_label_upper_right // Create fibLevel objects on first bar, populate levels array, create sortedArray for object sorting. if barstate.isfirst populate(show000Input, level000Input, color000Input) populate(show236Input, level236Input, color236Input) populate(show382Input, level382Input, color382Input) populate(show500Input, level500Input, color500Input) populate(show618Input, level618Input, color618Input) populate(show786Input, level786Input, color786Input) populate(show100Input, level100Input, color100Input) populate(show161Input, level161Input, color161Input) populate(show261Input, level261Input, color261Input) populate(show361Input, level361Input, color361Input) populate(show423Input, level423Input, color423Input) populate(show127Input, level127Input, color127Input) populate(show141Input, level141Input, color141Input) populate(show227Input, level227Input, color227Input) populate(show241Input, level241Input, color241Input) populate(show200Input, level200Input, color200Input) populate(show300Input, level300Input, color300Input) populate(show327Input, level327Input, color327Input) populate(show341Input, level341Input, color341Input) populate(show400Input, level400Input, color400Input) populate(show427Input, level427Input, color427Input) populate(show441Input, level441Input, color441Input) populate(show461Input, level461Input, color461Input) populate(show476Input, level476Input, color476Input) sortedArray := array.sort_indices(levels) if useFillInput setBg() // Set fibLevel properties on last bar. Draw time labels and hi/lo line. if barstate.islast setLevels(leftTime, rightTime, chartHigh, chartLow, isBull) if tLabelsInput timeLabel(hiTime, chartHigh, LIME, hiTimeStyle) timeLabel(loTime, chartLow, FUCHSIA, loTimeStyle) if trendLineInput and not (showZZInput and useZigZag) hiLoLine(hiTime, chartHigh, loTime, chartLow) //#endregion
The Ganesh Trend
https://www.tradingview.com/script/HRzSXIjM-The-Ganesh-Trend/
gshedge63
https://www.tradingview.com/u/gshedge63/
57
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © gshedge63 //@version=4 study(title="The Ganesh Trend - Nifty", overlay=true) float call_sl = na float put_sl = na float call_tg = na float put_tg = na High = max(high,high[1]) Low = min(low,low[1]) //buy = (close>open) and ((high-close)<=(0.33*(high-low))) and ((open-low)<=0.05*(high-low)) Hammer = (close>open) and ((high-close)<=(0.25*(high-low))) and ((high-low)>=0.0011*(low)) and (open-low)>=0.45*(high-low) and (close-low)<=81 Hammer2 = (close>open[1]) and (open<close) and ((High-close)<=(0.25*(High-Low))) and ((High-Low)>=0.0012*(low)) and (open[1]-Low)>=0.45*(High-Low) and (close-Low)<=101 //sell = (open>close) and ((close-low)<=(0.33*(high-low))) and ((high-open)<=0.05*(high-low)) Ihammer = (open>close) and ((close-low)<=(0.25*(high-low))) and ((high-low)>=0.0011*(low)) and (high-open)>=0.45*(high-low) and (high-close)<=81 Ihammer2 = (close<open[1]) and (close<open) and ((close-Low)<=(0.25*(High-Low))) and ((High-Low)>=0.0012*(low)) and (High-open[1])>=0.45*(High-Low) and (High-close)<=101 if Hammer==true call_sl := int(low - 0.5*(high-low)) call_tg := int(high + 1.5*(high-call_sl)) else if Hammer2==true call_sl := int(Low - 0.2*(High-Low)) call_tg := int(High + 1.5*(High-call_sl)) else if Ihammer==true put_sl := int(high + 0.5*(high-low)) put_tg := int(low - 1.5*(put_sl-low)) else if Ihammer2==true put_sl := int(High + 0.2*(High-Low)) put_tg := int(Low - 1.5*(put_sl-Low)) plotshape(Hammer==true or Hammer2==true, location=location.belowbar, text="CALL", textcolor=color.white, style=shape.arrowup, size=size.normal, color=color.green) plotshape(Ihammer==true or Ihammer2==true , location=location.abovebar, text="PUT", textcolor=color.white, style=shape.arrowdown, size=size.normal, color=color.red) plot(call_sl, color=color.red, linewidth=1,style=plot.style_circles) plot(put_sl, color=color.red, linewidth=1,style=plot.style_circles) plot(call_tg, color=color.green, linewidth=2,style=plot.style_circles) plot(put_tg, color=color.green, linewidth=2,style=plot.style_circles)
Band Based Trend Filter
https://www.tradingview.com/script/qZRHn0Y5-Band-Based-Trend-Filter/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
282
study
5
MPL-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("Band Based Trend Filter") import HeWhoMustNotBeNamed/ta/1 as eta import HeWhoMustNotBeNamed/arrays/1 as pa timeframe = input.timeframe("", "Timeframe", group="Bands", inline="tf", tooltip = 'Timeframe for band calculation') bandType = input.string('Bollinger Bands', '', ['Bollinger Bands', 'Keltner Channel', 'Donchian Channel'], group='Bands', inline='b1') maType = input.string('sma', '', options=['sma', 'ema', 'hma', 'rma', 'wma', 'vwma', 'highlow', 'linreg', 'median'], inline = 'b1', group='Bands') maLength = input.int(20, '', minval = 5, step=5, inline = 'b1', group='Bands') multiplier = input.float(3.0, '', step=0.5, minval=0.5, group='Bands', inline='b1', tooltip = 'Band parameters let you select type of band/channel, moving average base, length and multiplier') useTrueRange = input.bool(true, 'Use True Range (For KC only)', group='Bands', tooltip = 'Used only for keltener channel calculation') sticky = input.bool(true, 'Sticky', group='Bands', tooltip = 'Sticky bands avoids changing the band unless there is breach. Meaning, band positions only change when price is outside the band.') trendConfirmationCount = input.int(3, 'Trend Confirmation Count', group='Trend', tooltip = 'Trend is defined only after reaching certain count') inverseTrendDirection = input.bool(false, 'Inverse Trend', group='Trend', tooltip = 'Reverse trend direction - select this to be bearish when sentiment is bullish and vice versa') colorCandles = input.bool(false, 'Color Bars', group='Trend', tooltip = 'If selected, colors bar based on trend') float upper = 0.0 float lower = 0.0 float middle = 0.0 indexHighTF = barstate.isrealtime ? 1 : 0 indexCurrTF = barstate.isrealtime ? 0 : 1 [bmiddle, bupper, blower] = request.security(syminfo.tickerid, timeframe, eta.bb(close[indexHighTF], maType, maLength, multiplier, sticky), lookahead=barmerge.lookahead_on) [kmiddle, kupper, klower] = request.security(syminfo.tickerid, timeframe, eta.kc(close[indexHighTF], maType, maLength, multiplier, useTrueRange, sticky), lookahead=barmerge.lookahead_on) [dmiddle, dupper, dlower] = request.security(syminfo.tickerid, timeframe, eta.dc(maLength, false, close, sticky), lookahead=barmerge.lookahead_on) if(bandType == 'Bollinger Bands') upper := bupper[indexCurrTF] lower := blower[indexCurrTF] middle := bmiddle[indexCurrTF] if(bandType == 'Keltner Channel') upper := kupper[indexCurrTF] lower := klower[indexCurrTF] middle := kmiddle[indexCurrTF] if(bandType == 'Donchian Channel') upper := dupper[indexCurrTF] lower := dlower[indexCurrTF] middle := dmiddle[indexCurrTF] var flag = true flag := flag or ta.crossover(close, middle) or ta.crossunder(close, middle) var uptrendCount = 0 var downtrendCount = 0 closeAboveTop = close >= upper closeBelowBottom = close <= lower if(flag) if(closeAboveTop) downtrendCount := 0 uptrendCount := uptrendCount + 1 if(closeBelowBottom) uptrendCount := 0 downtrendCount := downtrendCount+1 uptrend = plot(uptrendCount, "uptrend", color=color.green) downtrend = plot(downtrendCount, "downtrend", color=color.red) fillColor = uptrendCount>downtrendCount? color.green : color.red fill(plot1 = uptrend, plot2= downtrend, top_value = 10, bottom_value = 0, top_color = color.new(fillColor, 60), bottom_color = color.new(color.silver, 90)) trend = uptrendCount >= trendConfirmationCount? 1: downtrendCount >= trendConfirmationCount? -1 : 0 inverseTrend = uptrendCount >= trendConfirmationCount? -1 : downtrendCount >= trendConfirmationCount? 1 : 0 barcolor(colorCandles ? ((inverseTrendDirection? inverseTrend : trend) > 0? color.green : trend < 0? color.red : color.silver) : na) plot(inverseTrendDirection?inverseTrend:trend, "Trend", display = display.data_window)
Trendly
https://www.tradingview.com/script/OYwWEtX9-Trendly/
sudoMode
https://www.tradingview.com/u/sudoMode/
327
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © sudoMode // @version=5 // @description ATR based trend detector // @release=1.1.2 indicator(title = 'Multi-Timeframe Trends', shorttitle = 'Trendly', overlay = true) // --- user input --- // input groups atr_group = 'ATR' visuals_group = 'Visuals' scalper_group = 'Scalper timeframes (in seconds)' intra_group = 'Intraday timeframes (in minutes)' swing_group = 'Swing timeframes (in hours)' // atr params // tooltips tt_length = 'Number of bars to look back while calculating ATR' tt_factor = 'Multiplier for ATR' tt_sensitivity = 'Higher the value, greater the gap between price & the trend line' length = input.int(14, 'Length', 2, 300, group = atr_group, inline = '1') factor = input.float(2, 'Factor', 2, 50, step = 1, group = atr_group, inline = '1') sensitivity = input.float(0.5, 'Sensitivity', 0.1, 1, step = 0.1, group = atr_group, inline = '1') multiplier = math.pow(factor, 1.1 - sensitivity) plot(multiplier, display = display.data_window, title = 'Multiplier') // visuals params // tooltips tt_table = 'Toggle the visibility of trend table' tt_line = 'Display ATR bands \n - Green indicates bullish movement \n - Red indicates bearish movement \n - White indicates sideways movement or a loss in momentum' tt_width = 'Conifgure thickness of the plot line' show_trend_table = input.bool(true, 'Trend Table', group = visuals_group, inline = '2') table_position = input.string('Bottom-Right', 'Table Position', group = visuals_group, inline = '2', options = ['Bottom-Right', 'Bottom-Left', 'Top-Right', 'Top-Left']) text_size = input.string('Tiny', 'Text Size', group = visuals_group, inline = '2', options = ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge']) show_trend_line = input.bool(true, 'Trend Line', group = visuals_group, inline = '3') line_width = input.int(3, 'Line Width', minval=1, maxval=5, group = visuals_group, inline = '3') // timeframe params tf11 = input.string( '5', '', options = [ '1', '3', '5'], inline = '3', group = scalper_group) tf12 = input.string('15', '', options = ['10', '15', '20'], inline = '3', group = scalper_group) tf13 = input.string('30', '', options = ['30', '45', '60'], inline = '3', group = scalper_group) tf21 = input.string( '3', '', options = ['1', '3', '5'], inline = '4', group = intra_group) tf22 = input.string('15', '', options = ['10', '15', '20'], inline = '4', group = intra_group) tf23 = input.string('30', '', options = ['30', '45', '60'], inline = '4', group = intra_group) tf31 = input.string('1', '', options = ['1', '2', '3'], inline = '5', group = swing_group) tf32 = input.string('4', '', options = ['4', '5', '6'], inline = '5', group = swing_group) tf33 = input.string('8', '', options = ['8', '12', '24'], inline = '5', group = swing_group) // --- constants --- // colors white = color.white green = color.rgb(66, 222, 66, 33) red = color.rgb(222, 66, 66, 33) gray = color.gray fill_white = color.new(white, 90) fill_green = color.new(green, 90) fill_red = color.new(red, 90) // direction symbol up = '⬆' down = '⬇' // --- utils --- // get true range on the given timeframe // trueRange = math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1])) get_true_range(timeframe) => h = request.security(syminfo.tickerid, timeframe, high) l = request.security(syminfo.tickerid, timeframe, low) c = request.security(syminfo.tickerid, timeframe, close) na(h[1]) ? h - l : math.max(math.max(h - l, math.abs(h - c[1])), math.abs(l - c[1])) // get average true range get_atr(timeframe = timeframe.period, length = 14) => ta.rma(get_true_range(timeframe = timeframe), length) // compute trendline & direction trend_detector(timeframe, length, multiplier) => // get source & atr, based on timeframe source = request.security(syminfo.tickerid, timeframe, hl2) atr = get_atr(timeframe, length) // init trend lines down_trend = source + (multiplier * atr) up_trend = source - (multiplier * atr) last_up_trend = nz(up_trend[1]) last_down_trend = nz(down_trend[1]) // find latest trend up_trend := up_trend > last_up_trend or last_up_trend > hl2[1] ? up_trend : last_up_trend down_trend := down_trend < last_down_trend or last_down_trend < hl2[1] ? down_trend : last_down_trend // set trend direction: 0 -> horizontal | 1 -> up | -1 -> down int direction = 0 float trend = na last_trend = nz(trend[1]) if not na(atr) direction := last_trend >= last_down_trend ? (close > down_trend ? 1 : -1) : (close < up_trend ? -1 : 1) trend := direction == 0 ? trend : (direction == 1 ? up_trend : down_trend) [trend, direction] // --- plot trend lines --- // for current time frame [trend, direction] = trend_detector(timeframe = timeframe.period, length = length, multiplier = multiplier) center = (open + close) / 2 fill_space = plot(center, display = display.none) display = show_trend_line ? display.all : display.none line_color = trend == trend[1] ? white : (direction == 1 ? green : red) fill_color = trend == trend[1] ? fill_white : (direction == 1 ? fill_green : fill_red) bullish_trend = direction > 0 ? trend : na bearish_trend = direction < 0 ? trend : na bullish = plot(bullish_trend, 'Bullish', color = line_color, style = plot.style_linebr, linewidth = line_width, display = display) fill(fill_space, bullish, fill_color, fillgaps = false, display = display) bearish = plot(bearish_trend, 'Bearish', color = line_color, style = plot.style_linebr, linewidth = line_width, display = display) fill(fill_space, bearish, fill_color, fillgaps = false, display = display) position_map() => switch table_position 'Bottom-Right' => position.bottom_right 'Bottom-Left' => position.bottom_left 'Top-Right' => position.top_right 'Top-Left' => position.top_left => position.bottom_right text_size_map(size='Auto') => switch size 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal 'Large' => size.large 'Huge' => size.huge 'Auto' => size.auto => size.tiny // --- trend table --- if show_trend_table var tab = table.new(position_map(), columns = 9, rows = 3, border_color = color.rgb(100, 160, 256, 66), border_width = 1) // title table.cell(tab, 1, 0, 'Scalper', text_size = text_size_map(), text_color = color.gray) // headers table.cell(tab, 0, 1, tf11 + ' sec', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) table.cell(tab, 1, 1, tf12 + ' sec', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) table.cell(tab, 2, 1, tf13 + ' sec', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) // cells [t11, d11] = trend_detector(timeframe = tf11+'S', length = length, multiplier = multiplier) [t12, d12] = trend_detector(timeframe = tf12+'S', length = length, multiplier = multiplier) [t13, d13] = trend_detector(timeframe = tf13+'S', length = length, multiplier = multiplier) c11 = d11 > 0 ? up : down, tc11 = d11 > 0 ? green : red c12 = d12 > 0 ? up : down, tc12 = d12 > 0 ? green : red c13 = d13 > 0 ? up : down, tc13 = d13 > 0 ? green : red table.cell(tab, 0, 2, c11, text_size = size.large, text_color = tc11) table.cell(tab, 1, 2, c12, text_size = size.large, text_color = tc12) table.cell(tab, 2, 2, c13, text_size = size.large, text_color = tc13) // title table.cell(tab, 4, 0, 'Intraday', text_size = text_size_map(), text_color = color.gray) // headers table.cell(tab, 4, 1, tf22 + ' min', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) table.cell(tab, 5, 1, tf23 + ' min', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) table.cell(tab, 3, 1, tf21 + ' min', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) // cells [t21, d21] = trend_detector(timeframe = tf21, length = length, multiplier = multiplier) [t22, d22] = trend_detector(timeframe = tf22, length = length, multiplier = multiplier) [t23, d23] = trend_detector(timeframe = tf23, length = length, multiplier = multiplier) c21 = d21 > 0 ? up : down, tc21 = d21 > 0 ? green : red c22 = d22 > 0 ? up : down, tc22 = d22 > 0 ? green : red c23 = d23 > 0 ? up : down, tc23 = d23 > 0 ? green : red table.cell(tab, 3, 2, c21, text_size = size.large, text_color = tc21) table.cell(tab, 4, 2, c22, text_size = size.large, text_color = tc22) table.cell(tab, 5, 2, c23, text_size = size.large, text_color = tc23) // title table.cell(tab, 7, 0, 'Swing', text_size = text_size_map(), text_color = color.gray) // headers table.cell(tab, 6, 1, tf31 + ' hour', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) table.cell(tab, 7, 1, tf32 + ' hour', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) table.cell(tab, 8, 1, tf33 + ' hour', text_size = text_size_map(text_size), text_color = color.new(color.gray, 20)) // cells [t31, d31] = trend_detector(timeframe = str.tostring(str.tonumber(tf31)*60), length = length, multiplier = multiplier) [t32, d32] = trend_detector(timeframe = str.tostring(str.tonumber(tf32)*60), length = length, multiplier = multiplier) [t33, d33] = trend_detector(timeframe = str.tostring(str.tonumber(tf33)*60), length = length, multiplier = multiplier) c31 = d31 > 0 ? up : down, tc31 = d31 > 0 ? green : red c32 = d32 > 0 ? up : down, tc32 = d32 > 0 ? green : red c33 = d33 > 0 ? up : down, tc33 = d33 > 0 ? green : red table.cell(tab, 6, 2, c31, text_size = size.large, text_color = tc31) table.cell(tab, 7, 2, c32, text_size = size.large, text_color = tc32) table.cell(tab, 8, 2, c33, text_size = size.large, text_color = tc33)
Support and Resistance
https://www.tradingview.com/script/c2U4et6K-Support-and-Resistance/
faytterro
https://www.tradingview.com/u/faytterro/
1,503
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © faytterro //@version=5 indicator("Support and Resistance", overlay = true, max_bars_back =1500) trn=50 o = input.int(0, "previous supports and resistances" , minval = 0) len=input.int(20, "previous supports and resistances length", minval = 1) cs = input.color(color.rgb(0,255,0,trn), "Support Color") cr = input.color(color.rgb(255,0,0,trn), "Resistance Color") r = high<low[2]-(high[2]-low[2]) and math.abs(close[1]-open[1])>(high[2]-low[2])*2 r2 = high<math.min(low[3],low[4])-(math.max(high[3],high[4])-math.min(low[3],low[4])) and math.abs(close[1]-open[2])>(math.max(high[3],high[4])-math.min(low[3],low[4]))*2 for i=1 to 4 r2:= r2 and r2[i]==false r:= r and r2[i-1]==false s= low>high[2]-(high[2]-low[2]) and math.abs(close[1]-open[1])>(high[2]-low[2])*2 s2 = low>math.max(high[3],high[4])+(math.max(high[3],high[4])-math.min(low[3],low[4])) and math.abs(close[1]-open[2])>(math.max(high[3],high[4])-math.min(low[3],low[4]))*2 for i=1 to 4 s2 := s2 and s2[i]==false s:= s and s2[i-1]==false ass= ta.crossover(close,ta.valuewhen(r,high[2],o)) for i = 1 to ta.barssince(r) ass:= ass and ass[i]==false k=ta.barssince(ass)<ta.barssince(r)? ta.barssince(ass) : -2 box=box.new(ta.valuewhen(r,bar_index,o)-2, ta.valuewhen(r,high[2],o), o==0? last_bar_index-k :ta.valuewhen(r,bar_index,o)-2+len, ta.valuewhen(r,low[2],o), bgcolor = cr, border_color = color.rgb(71, 89, 139,100)) box.delete(box[1]) bass= ta.crossunder(close,ta.valuewhen(r,high[2],o)) for i = 1 to ta.barssince(r) bass:= bass and bass[i]==false bk=ta.barssince(bass)<ta.barssince(r)? ta.barssince(bass) : -2 bbox=box.new(last_bar_index-k, ta.valuewhen(r,high[2],o), last_bar_index-bk,ta.valuewhen(r,low[2],o), bgcolor = cs, border_color = color.rgb(71, 89, 139,100)) box.delete(bbox[o<1? 1 : 0]) ass2= ta.crossover(close,math.max(ta.valuewhen(r2,high[3],o), ta.valuewhen(r2,high[4],o))) for i = 1 to ta.barssince(r2) ass2:= ass2 and ass2[i]==false k2=ta.barssince(ass2)<ta.barssince(r2)? ta.barssince(ass2) : -2 box2=box.new(ta.valuewhen(r2,bar_index,o)-4, ///last_bar_index-ta.barssince(r2)-4 math.max(ta.valuewhen(r2,high[3],o), ta.valuewhen(r2,high[4],o)), o==0? last_bar_index-k2 : ta.valuewhen(r2,bar_index,o)-4 + len , math.min(ta.valuewhen(r2,low[3],o), ta.valuewhen(r2,low[4],o)), bgcolor = cr, border_color = color.rgb(71, 89, 139,100)) box.delete(box2[1]) bass2= ta.crossunder(close,math.max(ta.valuewhen(r2,high[3],o), ta.valuewhen(r2,high[4],o))) for i = 1 to ta.barssince(r2) bass2:= bass2 and bass2[i]==false bk2=ta.barssince(bass2)<ta.barssince(r2)? ta.barssince(bass2) : -2 bbox2=box.new(last_bar_index-k2, math.max(ta.valuewhen(r2,high[3],o), ta.valuewhen(r2,high[4],o)), last_bar_index-bk2, math.min(ta.valuewhen(r2,low[3],o), ta.valuewhen(r2,low[4],o)), bgcolor = cs, border_color = color.rgb(71, 89, 139,100)) box.delete(bbox2[o==0? 1:0]) akk = ta.crossunder(close,ta.valuewhen(s,low[2],o)) for i=1 to ta.barssince(s) akk:= akk and akk[i]==false k4=ta.barssince(akk)<ta.barssince(s)? ta.barssince(akk) : -2 box4=box.new(ta.valuewhen(s,bar_index,o)-2, ta.valuewhen(s,high[2],o), o==0? last_bar_index-k4 :ta.valuewhen(s,bar_index,o)-2+len, ta.valuewhen(s,low[2],o), bgcolor = cs, border_color = color.rgb(71, 89, 139,100)) box.delete(box4[1]) akk2 = ta.crossunder(close,math.min(ta.valuewhen(s2,low[3],o),ta.valuewhen(s2,low[4],o))) for i=1 to ta.barssince(s2) akk2:= akk2 and akk2[i]==false k5=ta.barssince(akk2)<ta.barssince(s2)? ta.barssince(akk2) : -2 box5=box.new(ta.valuewhen(s2,bar_index,o)-4, math.max(ta.valuewhen(s2,high[3],o),ta.valuewhen(s2,high[4],o)), o==0? last_bar_index-k5 : ta.valuewhen(s2,bar_index,o)-4+len , math.min(ta.valuewhen(s2,low[3],o),ta.valuewhen(s2,low[4],o)), bgcolor = cs, border_color = color.rgb(71, 89, 139,100)) box.delete(box5[1]) bakk = ta.crossover(close,ta.valuewhen(s,low[2],o)) for i=1 to ta.barssince(s) bakk:= bakk and bakk[i]==false bk4=ta.barssince(bakk)<ta.barssince(s)? ta.barssince(bakk) : -2 bbox4=box.new(last_bar_index-k4, ta.valuewhen(s,high[2],o), last_bar_index-bk4, ta.valuewhen(s,low[2],o), bgcolor = cr, border_color = color.rgb(71, 89, 139,100)) box.delete(bbox4[o==0? 1:0]) bakk2 = ta.crossover(close,math.min(ta.valuewhen(s2,low[3],o),ta.valuewhen(s2,low[4],o))) for i=1 to ta.barssince(s2) bakk2:= bakk2 and bakk2[i]==false bk5=ta.barssince(bakk2)<ta.barssince(s2)? ta.barssince(bakk2) : -2 bbox5=box.new(last_bar_index-k5, math.max(ta.valuewhen(s2,high[3],o),ta.valuewhen(s2,high[4],o)), last_bar_index-bk5, math.min(ta.valuewhen(s2,low[3],o),ta.valuewhen(s2,low[4],o)), bgcolor = cr, border_color = color.rgb(71, 89, 139,100)) box.delete(bbox5[o==0?1:0])
[LazyBear] SQZ Momentum + 1st Gray Cross Signals ━ whvntr
https://www.tradingview.com/script/oqkCyNg7-LazyBear-SQZ-Momentum-1st-Gray-Cross-Signals-whvntr/
whvntr
https://www.tradingview.com/u/whvntr/
285
study
5
MPL-2.0
//This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 // ─© whvntr Tyler Ray indicator(title='[LazyBear] SQZ Momentum + 1st Gray Cross Signals', shorttitle='SQZ_MULT ━ whvntr' , overlay= true) // With all due credit @ user LazyBear & John F. Carter's book: Chapter 11 of "Mastering the Trade". // LazyBear wrote: "Mr.Carter suggests waiting till the first gray after a black cross, // ✓ and taking a position in the direction of the momentum (for ex., if momentum value // is above zero, go long). Exit the position when the momentum changes // (increase or decrease --- signified by a color change)." // I have done just that. Now at each "first gray after a black cross", there are now Bearish and // Bullish signals.. The signals only appear in the direction of the momentum. color INVS = #00000000 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ╸> ╸ ╸> ╸ ╸ ╸> ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ var a_t_b = true var not_a_t_b = not a_t_b var a_t_l = true var not_a_t_l = not a_t_l var s_b = true var s_b_1 = true var s_b_2 = true var s_b_3 = true var not_s_b = not s_b var not_s_b_1 = not s_b_1 var not_s_b_2 = not s_b_2 var not_s_b_3 = not s_b_3 // ╸> ╸ ╸> ╸ ╸ ╸> var s_l = true var s_l_1 = true var s_l_2 = true var s_l_3 = true var not_s_l = not s_l var not_s_l_1 = not s_l_1 var not_s_l_2 = not s_l_2 var not_s_l_3 = not s_l_3 //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ╸> ╸ ╸> ╸ ╸ ╸> ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ℹ️ Multiple Sources ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ changeSource = input.source(title='ℹ️' , defval = close , group = "Alternate Source") //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ℹ️ Multiple Sources ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🗓️ Multiple Timeframes ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ keepFrame = input.bool(defval = true , title = '' , group = '☑ Chart Timeframe ‎ ‎ ✗☐ To Use Multi') keepFrameFor = keepFrame ? timeframe.period : timeframe.period changetframeBear = input.timeframe (title='📕' , defval='60' , group = "Multiple Timeframes" , inline = 'Timeframes' , tooltip = '🐼 Bearish Timeframes') changetframeBull = input.timeframe(title='📗' , defval='60' , inline = 'Timeframes' , group = 'Multiple Timeframes' , tooltip = '🐼 ‎ & ‎ 🐂') alt_period_bear = keepFrame ? keepFrameFor : changetframeBear alt_period_bull = keepFrame ? keepFrameFor : changetframeBull //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🗓️ Multiple Timeframes ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ╍╍ Lengths ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ length = input(20 , title ='┅', group = 'Bollinger Bands Length' , tooltip = 'Bollinger Bands consist of a middle band (which is a moving average) and an upper and lower band. These upper and lower bands are set above and below the moving average by a certain number of standard deviations of price, thus incorporating volatility') mult = input(2.0 , title = '×', group = 'Bollinger Bands MultFactor') lengthKC = input(20 , title = '┅', group = 'Keltner Channel Length' , tooltip = "Keltner Channels are volatility-based bands that are placed on either side of an asset's price and can aid in determining the direction of a trend. The Keltner channel uses the average-true range (ATR) or volatility, with breaks above or below the top and bottom barriers signaling a continuation") multKC = input(1.5 , title ='×', group ='Keltner Channel MultFactor') trueRange = input.bool(true , title = '' , group = '☑ True Range (Keltner Channel)' , tooltip = 'Average-true range (ATR) with breaks above or below the top and bottom barriers signaling a continuation') kc__tr = trueRange ? true : na //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ╍╍ Lengths ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎨 CSS Menu ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ sqz_exit_arrow_css = input.color(#b2283483,'⬇‎ ‎ ' , group = 'Arrows & Highlights' , inline = 'exit_arrow') sqz_take_arrow_css = input.color(#008000ae,'⬆‎ ‎ ' , group = 'Arrows & Highlights' , inline = 'take_arrow') bg_bear_css = input.color(color.rgb(181 , 181, 181, 87),'‎ ‎ ' , group = 'Arrows & Highlights' , inline = 'exit_arrow') bg_bull_css = input.color(color.rgb(181 , 181, 181, 87),'‎ ‎ ' , group = 'Arrows & Highlights' , inline = 'take_arrow') sqz_exit_dot_css = input(#ff0000ae,'•' , group = 'Dots & Arrow Length' , inline = 'exit_dot') sqz_take_dot_css = input(#00ff00b2,'•' , group = 'Dots & Arrow Length' , inline = 'take_dot') sqz_pos_mom_css = input(#00ff00b2,'⌟' , group = "Positive Momentum") sqz_pos_mom_rev_css = input(#008000ae,'⌞' , group = "Positive Momentum Reversing") sqz_neg_mom_css = input(#ff0000ae,'⌝' , group = "Negative Momentum") sqz_neg_mom_rev_css = input(#800000a7,'⌜' , group = "Negative Momentum Reversing") sqz_no_css = input(#0023a1,'∅' , group = "No Squeeze") sqz_ON_css = input(color.rgb(0, 0, 0),'⏳' , group = "Squeeze Entered (Preparing)" , tooltip = '"Black crosses on the midline show that the market just entered a squeeze (Bollinger Bands are within Keltner Channel). This signifies low volatility, market preparing itself for an explosive move (up or down)"') sqz_released_css = input(color.gray,'🌋' , tooltip = '"Gray crosses signify "Squeeze release""' , group = "Squeeze Release (Released)") //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎨 CSS Menu ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎳 Bollinger Bands ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ basis = ta.sma(changeSource, length) dev = multKC * ta.stdev(changeSource, length) upperBB = basis + dev lowerBB = basis - dev //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎳 Bollinger Bands ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ☶ Keltner Channel ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ma = ta.sma(changeSource, lengthKC) range_1 = kc__tr ? ta.tr : high - low rangema = ta.sma(range_1, lengthKC) upperKC = ma + rangema * multKC lowerKC = ma - rangema * multKC //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ☶ Keltner Channel ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🍋 Squeeze Indication ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ sqzOn = lowerBB > lowerKC and upperBB < upperKC sqzOff = lowerBB < lowerKC and upperBB > upperKC noSqz = sqzOn == false and sqzOff == false //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🍋 Squeeze Indication ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 📊 Histogram ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ val = ta.linreg(changeSource - math.avg(math.avg(ta.highest(high, lengthKC), ta.lowest(low, lengthKC)), ta.sma(close, lengthKC)), lengthKC, 0) iff_1 = val > nz(val[1]) ? sqz_pos_mom_css : sqz_pos_mom_rev_css iff_2 = val < nz(val[1]) ? sqz_neg_mom_css : sqz_neg_mom_rev_css bcolor = val > 0 ? iff_1 : iff_2 scolor = noSqz ? sqz_no_css : sqzOn ? sqz_ON_css : sqz_released_css //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 📊 Histogram ─ LazyBear © //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 💡 Show/Hide Signal Groups ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ plot_hist = input.bool(true , group = '☑ LazyBear Histogram' , tooltip = 'LazyBear Histogram' , title = '') plot_cross = input.bool(true , group ='☑ LazyBear Crosses' , tooltip = 'LazyBear Crosses' , title = '') zero_line = 0 plot(plot_hist ? val : na, color = bcolor , title = 'Use Condition: SQZ_MULT..' , style=plot.style_histogram, linewidth=4, offset = 0 , editable = false) plot(plot_cross ? zero_line : na, color=scolor , title = 'Use Condition: SQZ_MULT..' , style=plot.style_cross,linewidth=2 ,offset = 0 , editable = false) show_neg_mom = input.bool(true, '' , group = '☑ Show Bearish' , tooltip = 'Show bearish signals ─ For a multi-source histogram, hide signal groups and move indicator to a new pane') hide_neg_mom = show_neg_mom ? true : na show_pos_mom = input.bool(true, '' , group = '☑ Show Bullish' , tooltip = 'Show bullish signals ─ For a multi-source histogram, hide signal groups and move indicator to a new pane') hide_pos_mom = show_pos_mom ? true : na show_bg_exit = input.bool(false , title = '‎ 𝘚𝘩𝘰𝘳𝘵𝘴' , group = 'Arrows & Highlights' , inline = 'exit_arrow') hide_bg_exit = show_bg_exit ? true : na show_bg_take = input.bool(false , title = '‎ 𝘓𝘰𝘯𝘨𝘴' , group = 'Arrows & Highlights' , inline = 'take_arrow') hide_bg_take = show_bg_take ? true : na //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 💡 Show/Hide Signal Groups ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ non_repainting = barstate.isconfirmed == true //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ✛ First Gray EXIT Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ pos = val > nz(val[1]) not_pos = not pos exit_pos = scolor == sqz_released_css bear_sqz = request.security(syminfo.tickerid , alt_period_bear , exit_pos[0] and not exit_pos[1] and not_pos and hide_neg_mom and non_repainting) bear_sqz_bg = request.security(syminfo.tickerid , alt_period_bear , exit_pos[0] and not exit_pos[1] and not_pos and non_repainting) bear_sqz_alert = request.security(syminfo.tickerid , alt_period_bear , exit_pos[0] and not exit_pos[1] and not_pos and non_repainting) bear_arw_pick = bear_sqz[0] and not bear_sqz[1] bear_bg_pick = bear_sqz_bg[0] and not bear_sqz_bg[1] bear_alert = bear_sqz_alert[0] and not bear_sqz_alert[1] //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ✛ First Gray EXIT Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎯 Arrow Length Feature EXIT Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ string one_len_bear = '╸' string two_len_bear = '╸ ╸' string three_len_bear = '╸ ╸ ╸' arrow_style_bear = input.string(defval = '╸ ╸ ╸' , title = '‎ ‎ ' , inline = 'exit_dot' , options = [one_len_bear, two_len_bear, three_len_bear] , group = 'Dots & Arrow Length' , tooltip = 'Adjust the length of the arrows') var get_1_bear = arrow_style_bear == one_len_bear var get_2_bear = arrow_style_bear == two_len_bear var get_3_bear = arrow_style_bear == three_len_bear if arrow_style_bear == one_len_bear not_s_b_1 := true if arrow_style_bear == two_len_bear not_s_b_2 := true if arrow_style_bear == three_len_bear not_s_b_3 := true plotchar(bear_arw_pick and not_s_b_1 , title = 'Use Condition: SQZ_MULT..' , text = '|\nv' , textcolor = sqz_exit_arrow_css , location=location.abovebar , offset=0, color = sqz_exit_dot_css , char = '•' , size=size.tiny, editable = false) plotchar(bear_arw_pick and not_s_b_2 , title = 'Use Condition: SQZ_MULT..' , text = '|\n|\nv' , textcolor = sqz_exit_arrow_css , location=location.abovebar , offset=0, color = sqz_exit_dot_css , char = '•' , size=size.tiny, editable = false) plotchar(bear_arw_pick and not_s_b_3 , title = 'Use Condition: SQZ_MULT..' , text = '|\n|\n|\nv' , textcolor = sqz_exit_arrow_css , location=location.abovebar , offset=0, color = sqz_exit_dot_css , char = '•' , size=size.tiny, editable = false) //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎯 Arrow Length Feature EXIT Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ✛ First Gray TAKE Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ neg = val < nz(val[1]) not_neg = not neg take_pos = scolor == sqz_released_css bull_sqz = request.security(syminfo.tickerid , alt_period_bull , take_pos[0] and not take_pos[1] and not_neg and hide_pos_mom and non_repainting) bull_sqz_bg = request.security(syminfo.tickerid , alt_period_bull , take_pos[0] and not take_pos[1] and not_neg and non_repainting) bull_sqz_alert = request.security(syminfo.tickerid , alt_period_bull , take_pos[0] and not take_pos[1] and not_neg and non_repainting) bull_arw_pick = bull_sqz[0] and not bull_sqz[1] bull_bg_pick = bull_sqz_bg[0] and not bull_sqz_bg[1] bull_alert = bull_sqz_alert[0] and not bull_sqz_alert[1] //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ✛ First Gray TAKE Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎯 Arrow Length Feature TAKE Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ string one_len_bull = '╸' string two_len_bull = '╸ ╸' string three_len_bull = '╸ ╸ ╸' arrow_style_bull = input.string(defval = '╸ ╸ ╸' , title = '‎ ‎ ' , inline = 'take_dot' , options = [one_len_bull, two_len_bull, three_len_bull] , group = 'Dots & Arrow Length' , tooltip = 'Adjust the length of the arrows') var get_1_bull = arrow_style_bull == one_len_bull var get_2_bull = arrow_style_bull == two_len_bull var get_3_bull = arrow_style_bull == three_len_bull if arrow_style_bull == one_len_bull not_s_l_1 := true if arrow_style_bull == two_len_bull not_s_l_2 := true if arrow_style_bull == three_len_bull not_s_l_3 := true plotchar(bull_arw_pick and not_s_l_1 , title = 'Use Condition: SQZ_MULT..' , text = 'ʌ\n|' , textcolor = sqz_take_arrow_css , location=location.belowbar , offset=0, color = sqz_take_dot_css , char = '•' , size=size.tiny, editable = false) plotchar(bull_arw_pick and not_s_l_2 , title = 'Use Condition: SQZ_MULT..' , text = 'ʌ\n|\n|' , textcolor = sqz_take_arrow_css , location=location.belowbar , offset=0, color = sqz_take_dot_css , char = '•' , size=size.tiny, editable = false) plotchar(bull_arw_pick and not_s_l_3 , title = 'Use Condition: SQZ_MULT..' , text = 'ʌ\n|\n|\n|' , textcolor = sqz_take_arrow_css , location=location.belowbar , offset=0, color = sqz_take_dot_css , char = '•' , size=size.tiny, editable = false) //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🎯 Arrow Length Feature TAKE Position ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ║ Highlight ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ bg_bear = bear_bg_pick bgcolor(bg_bear and hide_bg_exit ? bg_bear_css : INVS , title = '𝘚𝘩𝘰𝘳𝘵𝘴' , editable = false) bg_bull = bull_bg_pick bgcolor(bg_bull and hide_bg_take ? bg_bull_css : INVS , title = '𝘓𝘰𝘯𝘨𝘴' , editable = false) //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // ║ Highlight ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🌙 Alerts ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ if bear_alert == true and close[1] == bear_alert alert("➖ 𝙂𝙤 𝙎𝙝𝙤𝙧𝙩", alert.freq_once_per_bar_close) alertcondition(bear_alert , title= "➖ 𝑺𝒉𝒐𝒓𝒕𝒔" , message = '➖ SQZ_MULT ━ whvntr') if bull_alert == true and close[1] == bull_alert alert("➕ 𝙂𝙤 𝙇𝙤𝙣𝙜", alert.freq_once_per_bar_close) alertcondition(bull_alert , title= "➕ 𝑳𝒐𝒏𝒈𝒔" , message = '➕ SQZ_MULT ━ whvntr') //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // 🌙 Alerts ─© whvntr //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
SAFE MARGINE_OS
https://www.tradingview.com/script/ifJk2WxZ-SAFE-MARGINE-OS/
shakibsharifian
https://www.tradingview.com/u/shakibsharifian/
15
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © shakibsharifian //OPEN SOURCE //@version=5 indicator("SAFE MARGINE_OS",overlay=true) txtOpt1="OC-Based" txtOpt2="HL-Based" txtOpt3="MID-Based" //Counter countIt(mtd,bkw,val)=> int cnt=0 for int ii=0 to bkw-1 if (mtd==txtOpt1) and (val>=math.min(close[ii],open[ii]) and val<=math.max(close[ii],open[ii])) cnt:=cnt+1 if (mtd==txtOpt2) and (val>=low[ii] and val<=high[ii]) cnt:=cnt+1 if (mtd==txtOpt3) and (val>=low[ii] and val<=high[ii]) cnt:=cnt+1 cnt array_scalerMult(a,b)=> itr=array.size(a) float sum=0 for int i=0 to itr-1 sum:=sum+(array.get(a,i)*array.get(b,i)) sum balanceCal(setArr,cntSetArr)=> float res=na res:=(array_scalerMult(setArr,cntSetArr)/array.sum(cntSetArr)) res bk = input.int(24, minval=1, title='BACKWARD',group='GENERAL',inline='a') //marg = input.int(25, minval=1,maxval=100, title='MARGINE(%)',group='GENERAL',inline='b') mem = input.int(100, minval=1, title='MEMORY',group='GENERAL',inline='c') refresh=input.int(600000,minval=1,title='REFRESH in mili-Sec',group='GENERAL',inline='d') string mtd = input.string(txtOpt1,title='Method',options=[txtOpt1,txtOpt2,txtOpt3],group='METHODOLOGY',inline='a') bool safeVis=input.bool(true,title='Show Safest',group='DISPLAY',inline='a') bool balVis=input.bool(true,title='Show Balance',group='DISPLAY',inline='b') bool avgSafeVis=input.bool(true,title='Show AVG Safest',group='DISPLAY',inline='d') bool supBalVis=input.bool(true,title='Show Super Balance',group='DISPLAY',inline='e') //INI var memo=array.new<float>() var memo2=array.new<float>() setPoints=array.new<float>() float highRng=na float lowRng=na float balanceRef=na //MAIN for int i=0 to bk-1 if (mtd==txtOpt1) array.push(setPoints,close[i]) array.push(setPoints,open[i]) if (mtd==txtOpt2) array.push(setPoints,high[i]) array.push(setPoints,low[i]) if (mtd==txtOpt3) array.push(setPoints,hl2[i]) array.push(setPoints,ohlc4[i]) array.sort(setPoints,order.ascending) cntSetPoint=array.new<int>(array.size(setPoints),0) if bk<bar_index for int rdIt=0 to (2*bk)-1 thisCnt=countIt(mtd,bk,array.get(setPoints,rdIt)) array.set(cntSetPoint,rdIt,thisCnt) orderedCntId=array.sort_indices(cntSetPoint,order.descending) highRng:=array.get(setPoints,array.get(orderedCntId,0)) highPer=int((array.get(cntSetPoint,array.get(orderedCntId,0))/bk)*100) lbl=label.new(bar_index+2,highRng,'Safety: '+str.tostring(highPer)+'% in '+str.tostring(highRng),style=label.style_label_left,textcolor=color.black,color=color.white) lblSafeVis=safeVis==true?1:0 label.delete(lbl[lblSafeVis]) hiRngPl=plot(highRng, title="High Range", color=safeVis==true?color.new(#c4dbd7, 55):na, linewidth=2) //loRngPl=plot(lowRng, title="Low Range", color = na, linewidth=2) //closePL=plot(close,color=na) //fill(hiRngPl,loRngPl,title='Safest',color=color.new(#c4dbd7, 15)) //fill(closePL,hiRngPl,title='Status',color=close>highRng?color.new(#78f192, 85):color.new(#f3727d, 85)) balanceRef:=balanceCal(setPoints,cntSetPoint) balanceRefPl=plot(balanceRef, title="Balance", color=balVis==true?color.new(#eed64d, 0):na, linewidth=1,style=plot.style_cross) lblbalRef=label.new(bar_index+2,balanceRef,'balance: '+str.tostring(balanceRef),style=label.style_label_left,textcolor=color.black,color=color.white) lblBalVis=balVis==true?1:0 label.delete(lblbalRef[lblBalVis]) if (time%refresh)==0 array.push(memo,highRng) array.push(memo2,balanceRef) if array.size(memo)>mem delIt=array.shift(memo) if array.size(memo2)>mem delIt=array.shift(memo2) balance=array.avg(memo) superBalance=array.avg(memo2) balancePl=plot(balance, title="AVG SAFE", color=avgSafeVis==true?color.new(#df46b8, 0):na, linewidth=1,style=plot.style_line) lblbal=label.new(bar_index+2,balance,'AVG SAFE: '+str.tostring(balance),style=label.style_label_left,textcolor=color.black,color=color.white) lblAvgSafeVis=avgSafeVis==true?1:0 label.delete(lblbal[lblAvgSafeVis]) superBalancePl=plot(superBalance, title="Super Balance", color=supBalVis==true?color.new(#64f564, 0):na, linewidth=1,style=plot.style_line) lblbalAvg=label.new(bar_index+2,superBalance,'Super balance: '+str.tostring(superBalance),style=label.style_label_left,textcolor=color.black,color=color.white) lblSupBalVis=supBalVis==true?1:0 label.delete(lblbalAvg[lblSupBalVis])
Distribution Days
https://www.tradingview.com/script/OofugEhe-Distribution-Days/
Neeshant112
https://www.tradingview.com/u/Neeshant112/
49
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Neeshant112 //@version=5 indicator(title='Distribution', shorttitle='Distribution Days', format=format.volume, overlay=true) //Input Parameters distributionDayThreshold = input.float(title='Distribution Threshold (%)', defval=-0.2, minval=-3.14, maxval=-0.1, step=0.05) length = input.int(title='Distrbution Period (in focus)', defval=25, minval=10, maxval=100, step=1) showFor = input.int(title='Distrbution Period (perspective)', defval=100, minval=10, maxval=100, step=1) negateDistribution = input.float(title='Negate Distribution (%)', defval=5.0, minval=1.0, maxval=10.0, step=0.25) negateDistribution := 1 + negateDistribution / 100 //generic functions truncate(number, decimals) => factor = math.pow(10, decimals) int(number * factor) / factor //Variables ------------------------------------- var line hline = line.new(na, na, na, na, extend=extend.right, color=#ff6361) var label negateDistribution_label = label.new(na, na, 'text') var int bar_last_distribution = na var float close_last_distribution = na //Functions ------------------------------------- hasVolumeIncreased = ta.change(volume) > 0 priceChangePercent = ta.change(close) / close[1] * 100 barIndex = bar_index //Check if it's a distribution day (excluding negation logic) isDistributionDay = priceChangePercent < distributionDayThreshold and hasVolumeIncreased ? 1 : 0 var test_y = -1.0 var test_x1 = -1.0 //Draw line for distribution negation level if isDistributionDay and bar_index <= barIndex and bar_index > barIndex - showFor //and lowest(close, 100) //if lowest candle is considered for negation y = close * negateDistribution line.set_xy1(hline, bar_index - 1, y) line.set_xy2(hline, na, y) test_y := y test_x1 := bar_index test_x1 line.set_x2(hline, bar_index) crossover1 = ta.crossover(close, test_y) ? 1 : 0 //var isNegated = 0 //if (crossover1 and (bar_index > line.get_x1(hline))) // line.delete(hline) // also trigger alert // label.delete(negateDistribution_label) //if(line.get_x1(hline)) // isDistributionDay := 0 //Count number of distribution days during the loopback period calculateDistributions() => count = 0 for _i = 0 to length - 1 by 1 count += isDistributionDay[_i] count countDist = calculateDistributions() //cross = crossover(close, test_y) ? 1:0 //ToDo: if cross == 1 when bar_index > test_x1 ---> negated distribution if barstate.islast label.set_x(negateDistribution_label, bar_index) label.set_y(negateDistribution_label, test_y) label.set_text(negateDistribution_label, str.tostring(truncate(countDist, 0)) + ' Distributions negate at ' + str.tostring(truncate(test_y, 2))) label.set_textcolor(negateDistribution_label, color.white) label.set_color(negateDistribution_label, color=#F95D6A) //Paint all distribution days bgcolor(isDistributionDay ? color.red : na, title='DistributionDay', show_last=showFor, transp=90) plot(crossover1, 'cross', display=display.none) plot(test_x1, 'X-axis', display=display.none) //plot(test_y, "Y-axis") //plot(bar_index, "bar_index") plot(crossover1 and bar_index > test_x1 ? 1 : 0, 'cross+bar', display=display.none)
Tick based chart [DotH]
https://www.tradingview.com/script/6c7SubyL-Tick-based-chart-DotH/
doth4581
https://www.tradingview.com/u/doth4581/
179
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © doth4581 (DotH) // Version 1.0 - 2nd January 2023 // This is an implementation for displaying a tick based chart in Trading View. // // Tick based charts are charts with candles that are rendered in the same way as traditional candles. // However, instead of rendering a new candle at a specific time period,tick based candles are rendered after // a set number of ticks have occured. // There are benefits to using ticks based candles, as each candle represents the same number of "price moves" // For more info see this page (not affiliated with me): // https://www.centralcharts.com/en/gm/1-learn/7-technical-analysis/29-chart/569-understanding-tick-charts // // Limitations/known issues: // - Currently the indicator has been restricted to 100 candles. This is for limiting the line and box usage to a max of 300 objects. // - On timeframes above 1 minute, the seconds values will always be 0. In order to be able to see seconds values in the chart scale // you need to be on a second level chart, which requires a premium TradingView subscription. // - Changing the parameters in the settings will cause the chart to empty and start redrawing from its first candle again. This is // because the tick chart is being drawn from realtime data, unlike the standard TradingView charts. // // TODOs & Bugs: // - Add some moving average indicators (SMA, EMA as a minmum) // - Add a corresponding tick based volume chart // - Create RSI, MACD, BB variations of this indicator // if you have any ideas/suggestions or bug reports, please feel free to let me know, however keep in mind // that I do not have too much spare time to add things, so updates are going to be sporadic. // // CODE REUSE: // If you plan to use this code to make a derivative indicator or strategy, it would be nice to know, // so let me know if you like! // //@version=5 indicator(shorttitle = "TBC", title="Tick based chart [DotH]", overlay=false,max_boxes_count = 100,max_lines_count = 200,max_bars_back = 2) //Input parameters int ticks_per_candle=input.int(20,"Ticks per candle",1,1000,1) int max_candles_in_chart=input.int(50,"Max number of candles to render",5,100,1) int scale_labels_pos_ticksize=input.int(1,"Time scale labels position below ticksize multiplier",0,100,1) //Initialize our globals varip openp=open varip highp=high varip lowp=low varip closep=close varip timep=time varip tick_count = ticks_per_candle varip open_prices = array.new_float() varip high_prices = array.new_float() varip low_prices = array.new_float() varip close_prices = array.new_float() varip close_times = array.new_int() varip tick_counter = array.new_int(1,ticks_per_candle+1) varip new_candle = array.new_bool(1,true) varip openID=0 varip highID=1 varip lowID=2 varip closeID=3 varip timeID=4 varip prices = array.new_float(5,close) //Reset a candle for first use reset_candle_prices() => array.set(prices,openID,close) array.set(prices,highID,close) array.set(prices,lowID,close) array.set(prices,closeID,close) array.set(prices,timeID,time) //Calculate OHLC of candle update_candle_prices(tick_price) => array.set(prices,timeID,time) if array.get(new_candle,0) array.set(prices,openID,tick_price) array.set(prices,highID,tick_price) array.set(prices,lowID,tick_price) array.set(prices,closeID,tick_price) array.set(new_candle,0,false) else array.set(prices,highID,math.max(array.get(prices,highID), tick_price)) array.set(prices,lowID,math.min(array.get(prices,lowID), tick_price)) array.set(prices,closeID,tick_price) //Update and close the last candle and add a new candle save_candle() => array.unshift(open_prices,array.get(prices,openID)) array.unshift(high_prices,array.get(prices,highID)) array.unshift(low_prices,array.get(prices,lowID)) array.unshift(close_prices,array.get(prices,closeID)) array.unshift(close_times,int(array.get(prices,timeID))) reset_candle_prices() if (array.size(open_prices)>max_candles_in_chart) array.pop(open_prices) array.pop(high_prices) array.pop(low_prices) array.pop(close_prices) array.pop(close_times) //Update values of last candle update_last_candle() => array.set(high_prices,0,array.get(prices,highID)) array.set(low_prices,0,array.get(prices,lowID)) array.set(close_prices,0,array.get(prices,closeID)) array.set(close_times,0,int(array.get(prices,timeID))) //Calculate candles updatecandles(tick_price) => update_candle_prices(tick_price) tick_counter_newval = array.get(tick_counter,0)+1 array.set(tick_counter,0,tick_counter_newval) if array.get(tick_counter,0) >= tick_count save_candle() array.set(tick_counter,0,0) array.set(new_candle,0,false) //If this is the last bar, calculate our tick based candles if last_bar_index==bar_index updatecandles(close) //Clear all previous boxes a_allBoxes = box.all if array.size(a_allBoxes) > 0 for i = 0 to array.size(a_allBoxes) - 1 box.delete(array.get(a_allBoxes, i)) //Clear all previous labels a_allLabels = label.all if array.size(a_allLabels) > 0 for i = 0 to array.size(a_allLabels) - 1 label.delete(array.get(a_allLabels, i)) //Clear all previous lines a_allLines = line.all if array.size(a_allLines) > 0 for i = 0 to array.size(a_allLines) - 1 line.delete(array.get(a_allLines, i)) // Calculate scale and time labeling minimum and maximum positions lowPosT=math.min(array.min(low_prices),array.get(prices,lowID))-syminfo.mintick*scale_labels_pos_ticksize highPosT=math.max(array.max(high_prices),array.get(prices,highID))+syminfo.mintick*scale_labels_pos_ticksize //Render past candles if array.size(open_prices)>0 for i = 0 to array.size(open_prices)-1 by 1 pos=i*3 openp:=array.get(open_prices,i) highp:=array.get(high_prices,i) lowp:=array.get(low_prices,i) closep:=array.get(close_prices,i) timep:=array.get(close_times,i) past_candles_color=openp>closep?color.red:color.rgb(37, 190, 150) box.new(bar_index-pos,math.max(openp,closep),bar_index-pos+2,math.min(openp,closep),past_candles_color,1,line.style_solid,extend.none,xloc.bar_index,past_candles_color) line.new(bar_index-pos+1,math.max(openp,closep),bar_index-pos+1,highp,color = past_candles_color,width = 2) line.new(bar_index-pos+1,math.min(openp,closep),bar_index-pos+1,lowp,color = past_candles_color,width = 2) if pos%30==0 and pos>15 label.new(bar_index-pos+1,lowPosT,str.format_time(timep,'MM/DD-HH:mm:ss'),size = size.tiny,textcolor = color.white,style = label.style_none,yloc = yloc.price,textalign = text.align_center,text_font_family=font.family_monospace) line.new(bar_index-pos+1,lowPosT,bar_index-pos+1,highPosT,color = color.gray,width = 1,style = line.style_dotted) //Render current candle lpos=-3 current_candle_color=array.get(prices,openID)>array.get(prices,closeID)?color.red:color.rgb(37, 190, 150) box.new(bar_index-lpos,math.max(array.get(prices,openID),array.get(prices,closeID)),bar_index-lpos+2,math.min(array.get(prices,openID),array.get(prices,closeID)),current_candle_color,1,line.style_solid,extend.none,xloc.bar_index,current_candle_color) line.new(bar_index-lpos+1,math.max(array.get(prices,openID),array.get(prices,closeID)),bar_index-lpos+1,array.get(prices,highID),color = current_candle_color,width = 2) line.new(bar_index-lpos+1,math.min(array.get(prices,openID),array.get(prices,closeID)),bar_index-lpos+1,array.get(prices,lowID),color = current_candle_color,width = 2) label.new(bar_index-lpos+1,lowPosT,str.format_time(int(array.get(prices,timeID)),'MM/DD-HH:mm:ss'),size = size.tiny,textcolor = color.white,style = label.style_none,yloc = yloc.price,textalign = text.align_center,text_font_family=font.family_monospace) line.new(bar_index-lpos+1,lowPosT,bar_index-lpos+1,highPosT,color = color.gray,width = 1,style = line.style_dotted)
Volume Weighted Exponential Moving Average Suite (VWEMA)
https://www.tradingview.com/script/WiBVL5Hl-Volume-Weighted-Exponential-Moving-Average-Suite-VWEMA/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
18
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © peacefulLizard50262 //@version=5 indicator("Advanced EMA", timeframe = "", overlay = true) import RicardoSantos/JohnEhlersFourierTransform/4 as r import lastguru/DominantCycle/2 as d bes(float source = close, float length = 9, daily_reset = false, volume_weight = false, cumulative = false)=> alpha = 2 / (length + 1) var float smoothed = na var float vol = na var float counter = na Volume = volume_weight ? volume : 1 counter := session.isfirstbar ? 1 : counter[1] + 1 Alpha = (session.isfirstbar and daily_reset) ? (cumulative ? 2 / (counter + 1) : 1) : (cumulative ? 2 / (counter + 1) : alpha) vol := na(volume) or (session.isfirstbar and daily_reset) ? Volume : Alpha * Volume + (1 - Alpha) * nz(vol[1]) smoothed := na(smoothed) or (session.isfirstbar and daily_reset) ? source * Volume : Alpha * (source * Volume) + (1 - Alpha) * nz(smoothed[1]) out = smoothed/vol dema(float source = close, float length = 9, daily_reset = false, volume_weight = false, cumulative = false)=> e1 = bes(source, length, daily_reset, volume_weight, cumulative) e2 = bes(e1, length, daily_reset, volume_weight, cumulative) dema = 2 * e1 - e2 tema(float source = close, float length = 9, daily_reset = false, volume_weight = false, cumulative = false) => e1 = bes(source, length, daily_reset, volume_weight, cumulative) e2 = bes(e1, length, daily_reset, volume_weight, cumulative) e3 = bes(e2, length, daily_reset, volume_weight, cumulative) tema = 3 * (e1 - e2) + e3 ehma(float source = close, float length = 9, daily_reset = false, volume_weight = false, cumulative = false)=> ehma1 = bes(2 * bes(source, int(length/2), daily_reset, volume_weight, cumulative) - bes(source, length, daily_reset, volume_weight, cumulative), int(math.sqrt(length/2)), volume_weight, cumulative) stdev(source, length, average)=> alpha = 2 / (length + 1) var float smoothed = na smoothed := alpha * math.pow(source-average, 2) + (1 - alpha) * nz(smoothed[1]) estdev = math.sqrt(smoothed) source = input.source(close, "Source") style = input.string("EMA", "Style", ["EMA","DEMA","TEMA","EHMA"]) select = input.string("MAMA", "Dominant Cycle Style", ["MAMA","PA","Phase","DFT","DFT2"]) max_length = input.int(100, "Max Length", 2) min_length = input.int(4, "Min Length", 1) volume_weight = input.bool(true, "Volume Weighting") daily_reset = input.bool(false, "Daily Reset") cumulative = input.bool(false, "Cumulative Length", "Enable Daily Reset to enjoy this feature.") manual_length = input.bool(false, "Manual Length", inline = "length") length = input.float(20.5, "", 0.5, 1000, 0.5, inline = "length") showBand_1 = input(false, "", group="Standard Deviation Bands Settings", inline="band_1") stdevMult_1 = input(1.0, "Bands Multiplier #1", group="Standard Deviation Bands Settings", inline="band_1") showBand_2 = input(false, "", group="Standard Deviation Bands Settings", inline="band_2") stdevMult_2 = input(2.0, "Bands Multiplier #2", group="Standard Deviation Bands Settings", inline="band_2") showBand_3 = input(false, "", group="Standard Deviation Bands Settings", inline="band_3") stdevMult_3 = input(3.0, "Bands Multiplier #3", group="Standard Deviation Bands Settings", inline="band_3") if volume_weight and barstate.islast and ta.cum(volume) == 0 runtime.error("No volume is provided by the data vendor.") if max_length < min_length runtime.error("Max length must be greater than min length.") // if max_length - min_length > 100 // runtime.error("Max length minus min length must be less than 100.") if manual_length and cumulative runtime.error("You can not have Cumulative Weight and Manual Length enabled at the same time.") if cumulative and not daily_reset runtime.error("To enable 'Cumulative' you must also enable Daily Reset.") dom()=> if select == "DFT2" [dominant_cycle, db] = r.transformed_dft(source, min_length, max_length) switch select "DFT2" => ta.cum(dominant_cycle) / (bar_index + 1) else switch select "MAMA" => d.mamaPeriod(source, min_length, max_length) "PA" => d.paPeriod(source, min_length, max_length) "Phase" => d.phasePeriod(source, min_length, max_length) "DFT" => d.dftPeriod(source, min_length, max_length) wave_l = manual_length ? length : dom() ma()=> switch style "EMA" => bes(source, wave_l, daily_reset, volume_weight, cumulative) "DEMA" => dema(source, wave_l, daily_reset, volume_weight, cumulative) "TEMA" => tema(source, wave_l, daily_reset, volume_weight, cumulative) "EHMA" => ehma(source, wave_l, daily_reset, volume_weight, cumulative) basis = ma() dev_1 = stdev(source, wave_l, basis) * stdevMult_1 dev_2 = stdev(source, wave_l, basis) * stdevMult_2 dev_3 = stdev(source, wave_l, basis) * stdevMult_3 center = plot(basis, "Cycle EMA", color.orange) upperBandValue1 = showBand_1 ? basis + dev_1 : na lowerBandValue1 = showBand_1 ? basis - dev_1 : na upperBandValue2 = showBand_2 ? basis + dev_2 : na lowerBandValue2 = showBand_2 ? basis - dev_2 : na upperBandValue3 = showBand_3 ? basis + dev_3 : na lowerBandValue3 = showBand_3 ? basis - dev_3 : na upperBand_1 = plot(upperBandValue1, title="Upper Band #1", color=color.green) lowerBand_1 = plot(lowerBandValue1, title="Lower Band #1", color=color.green) fill(upperBand_1, lowerBand_1, title="Bands Fill #1", color= color.new(color.green, 95)) upperBand_2 = plot(upperBandValue2, title="Upper Band #2", color=color.olive) lowerBand_2 = plot(lowerBandValue2, title="Lower Band #2", color=color.olive) fill(upperBand_2, lowerBand_2, title="Bands Fill #2", color= color.new(color.olive, 95)) upperBand_3 = plot(upperBandValue3, title="Upper Band #3", color=color.teal) lowerBand_3 = plot(lowerBandValue3, title="Lower Band #3", color=color.teal) fill(upperBand_3, lowerBand_3, title="Bands Fill #3", color= color.new(color.teal, 95))
JustaBox_NY_Lex
https://www.tradingview.com/script/J2B4wXYU-JustaBox-NY-Lex/
LexingtonStanley
https://www.tradingview.com/u/LexingtonStanley/
15
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LexingtonStanley //@version=5 //{ Inputs indicator("JustaBox_NY", overlay=true, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500 ) dataalert = input.bool(false,"Spreadsheet Alert", "READ THIS: Set chart to UTC -5 and 5 minute time period \n\nSends an alert with data for each session in an easy to add to excel format, alert system is limited to 4096 characters of text which will give you about 10 days of data at a time and it wont work if replay mode is turned on, thats a trading view limitation.\n\nLIMITATION: you may get an array error, this is because the loops need a full day to resolve, if 'Session to Session' is unticked the loops resolve at the start of the next session of the same name, so for NY, loop runs 10:30 - 09:30 the next day. In 'manual date range' you would make sure not to start or end on a weekend or bank holiday and use 10:15 to 10:15 for start and end.\n\nOnce turned on set an alert using the three dots on the indicator settings bar, sometimes takes a minute, make sure send to email is turned on.\n\nFrom your email, copy everything the first time, (the following times you dont need to copy the titles) then paste into cell 'A1' in excel.\n\nSelect that cell and find 'text to columns' in excels Data tab, select 'delineated' and select only 'semicolons' click finish. \n\nSelect all of row 1 and copy it, then rightclick in cell A2 and select 'Paste-transpose', this will seperate the days into rows.\n\nThen select A2 down to the last populated cell and go back to 'text to columns'... use delineated again but this time turn off semicolon and use only 'commas', click finish. \n\nVoila.\n\nHistoric Data colloction is limited to how far you can look back on that symbol on a 5 minute chart, for pro+ its 20000 bars or about 72 trading days\n this indicator only gives data for NY session use other two indicators JustaBox_LDN and JustaBox_TKO to pull tokyo and london data otherwise functionality is the same. (trying to pull data into an alert from more than one loop hit a limit)") sessiontosession = input.bool(false, "Session to Session", "Session to Session:\nSets whether the backtest runs each days test for 23 hours until the start of the next session of the same name e.g. NY to NY or whether it tests until the start of the next logical session e.g. NY to Tokyo, if ticked it runs to next logical session, unticked the full day, each option includes an identifier for each days data so you can seperate the two in excel later") symbol = input.string("US500", "Symbol Identifier for Data Alert", tooltip="What you enter here will be exported with the rest of the data as a symbol/pair identifier for each alert so you can filter by symbol later on") timeish = input.bool(false,"Manual Date Range", tooltip = "Set chart to UTC -5. If using data alert, make sure not to start or finish on weekend or bank holiday and set start and end times to middle of session you want") start = input.time(timestamp("19 December 2022 1000, gmt-5")) end = input.time(timestamp("28 December 2022 1000, gmt-5")) start2 = timenow - (((1000*60)*60)*24)*11 end2 = timenow nytrue = input.bool(true ,"NY Session",inline = "session") boxlabel = input.float(20.0, "Top Label Height",inline = "labelheight", tooltip = "Labels mainly added to check code was working, can be useful for visual backtesting or turned off, these set how far above or below the session box they sit in price.") sessionlabel = input.float(10.0, "Btm Label Height",inline = "labelheight",tooltip = "Labels mainly added to check code was working, can be useful for visual backtesting or turned off, these set how far above or below the session box they sit in price.") ldntrue = input.bool(false,"London Session",inline = "session") tkotrue = input.bool(false,"Tokio Session",inline = "session") stdlevels = input.bool(true, "Show STD Levels") labelson = input.bool(true ,"Session Labels",inline = "labels") fiblabels = input.bool(false,"STD Level and Price Labels",inline = "labels") colorcandles = input.bool(true, "Color Candles", tooltip = "When on candles are colored differently if you get a buy or sell symbol they are also on a gradient which changes color the further from the mid point of the daily range they get. May only work for the NY session") nycolor1 = input.color(color.green,"NY Color 1",inline = "nycolor") nycolor2 = input.color(color.rgb(83, 86, 250),"NY Color 2",inline = "nycolor") ldncolor1 = input.color(color.rgb(253, 1, 14),"London Color 1",inline = "ldcolor") ldncolor2 = input.color(color.rgb(208, 255, 0),"London Color 2",inline = "ldcolor") tycolor1 = input.color(color.rgb(2, 250, 250),"Tokyo Color 1",inline = "tycolor") tycolor2 = input.color(color.rgb(162, 0, 255),"Tokyo Color 2",inline = "tycolor") ipdaon = input.bool(false, "60 Day Highs and Lows", tooltip = "Crude attempt and marking interbank highs and lows, marks 3 highs and 3 lows, one each from 10-20 days, 20-40 and 40 to 59 days ago(59 was limit of lookback on pro subscription, may throw an error if not enough history") //} //{ Initial Variables and Arrays InSession(sessionTime, sessionTimeZone=syminfo.timezone) => not na(time(timeframe.period, sessionTime, sessionTimeZone)) arraysess = InSession("1025-1030" , "GMT-5") prearray1 = InSession("1020-1025" , "GMT-5") prearray3 = InSession("1920-1925" , "GMT-5") prearray2 = InSession("0350-0355" , "GMT-5") array1off = InSession("0925-0930" , "GMT-5") array2off = InSession("0255-0300" , "GMT-5") array3off = InSession("1825-1830" , "GMT-5") opensess1 = InSession("0930-0935" , "GMT-5") opensess3 = InSession("1830-1835" , "GMT-5") opensess2 = InSession("0300-0305" , "GMT-5") arraysess2 = InSession("0355-0400" , "GMT-5") arraysess3 = InSession("1925-1930" , "GMT-5") nysess = InSession("0930-1030" , "GMT-5") london = InSession("0300-0400" , "GMT-5") tokio = InSession("1830-1930" , "GMT-5") var int arrayplusz = 0 var int arrayplusz2 = 0 var int arrayplusz3 = 0 var float nyopen = na var float nyopen2 = na var float nyclose = na var float nyclose2 = na var float ldnopen = na var float ldnopen2 = na var float ldnclose = na var float ldnclose2 = na var float tyopen = na var float tyopen2 = na var float tyclose = na var float tyclose2 = na bool indate = na box boxy = na box boxy2 = na box boxy3 = na box boxy4 = na box boxy5 = na box boxy6 = na box boxy7 = na box boxy8 = na label label1 = na label label2 = na label label3 = na label label4 = na label label5 = na label label6 = na label label7 = na label label8 = na var int bartimesignal = na var int bartimesignal2 = na var int bartimesignal3 = na label linelabel1 = na label linelabel2 = na label linelabel3 = na label linelabel4 = na label linelabel5 = na label linelabel6 = na label linelabel7 = na label linelabel8 = na label linelabel9 = na label linelabel10 = na label linelabel11 = na label linelabel12 = na label linelabel13 = na label linelabel14 = na label linelabel15 = na label linelabel16 = na label linelabel17 = na line usline1 = na line usline2 = na line usline3 = na line usline4 = na line usline5 = na line usline6 = na line usline7 = na line usline8 = na line usline9 = na line usline10 = na line usline11 = na float top2 = na float btm2 = na line usline12 = na line usline13 = na line usline14 = na line usline15 = na line usline16 = na line usline17 = na float fib1 = na float fib2 = na float fib3 = na float fib4 = na float fib5 = na float fib6 = na float fib7 = na float fib8 = na float fib9 = na float fib10 = na float fib11 = na float fib12 = na float fib13 = na var int fib1x = na var int fib1xx = na var int fib2x = na var int fib3x = na var int fib4x = na var int fib5x = na var int fib6x = na var int fib7x = na var int fib8x = na var int fib9x = na var int fib10x = na var int fib11x = na var int fib12x = na var int fib13x = na var int top2x = na var int top2xx = na var int btm2x = na var int btm2xx = na var int topx = na var int bottomx = na var int fib1x2 = na var int fib1xx2 = na var int fib2x2 = na var int fib3x2 = na var int fib4x2 = na var int fib5x2 = na var int fib6x2 = na var int fib7x2 = na var int fib8x2 = na var int fib9x2 = na var int fib10x2 = na var int fib11x2 = na var int fib12x2 = na var int fib13x2 = na var int top2x2 = na var int top2xx2 = na var int btm2x2 = na var int btm2xx2 = na var int topx2 = na var int bottomx2 = na var int fib1x3 = na var int fib1xx3 = na var int fib2x3 = na var int fib3x3 = na var int fib4x3 = na var int fib5x3 = na var int fib6x3 = na var int fib7x3 = na var int fib8x3 = na var int fib9x3 = na var int fib10x3 = na var int fib11x3 = na var int fib12x3 = na var int fib13x3 = na var int top2x3 = na var int top2xx3 = na var int btm2x3 = na var int btm2xx3 = na var int topx3 = na var int bottomx3 = na float toplabelprice = na float bottomlabelprice = na float clrmax = na float clrmax2 = na float clrmax3 = na float clrmax4 = na float clrmin = na float clrmin2 = na float clrmin3 = na float clrmin4 = na bool topcross = na bool bottomcross = na bool topcross2 = na bool bottomcross2 = na bool topcross3 = na bool bottomcross3 = na var bool array1 = na var bool array2 = na var bool array3 = na var bool array4 = na var bool array5 = na var bool array6 = na var bool topb = na var bool top2b = na var bool top2bb = na var bool bottomb = na var bool btm2b = na var bool btm2bb = na var bool fib1b = na var bool fib1bb = na var bool fib2b = na var bool fib3b = na var bool fib4b = na var bool fib5b = na var bool fib6b = na var bool fib7b = na var bool fib8b = na var bool fib9b = na var bool fib10b = na var bool fib11b = na var bool fib12b = na var bool fib13b = na var bool topb2 = na var bool top2b2 = na var bool top2bb2 = na var bool bottomb2 = na var bool btm2b2 = na var bool btm2bb2 = na var bool fib1b2 = na var bool fib1bb2 = na var bool fib2b2 = na var bool fib3b2 = na var bool fib4b2 = na var bool fib5b2 = na var bool fib6b2 = na var bool fib7b2 = na var bool fib8b2 = na var bool fib9b2 = na var bool fib10b2 = na var bool fib11b2 = na var bool fib12b2 = na var bool fib13b2 = na var bool topb3 = na var bool top2b3 = na var bool top2bb3 = na var bool bottomb3 = na var bool btm2b3 = na var bool btm2bb3 = na var bool fib1b3 = na var bool fib1bb3 = na var bool fib2b3 = na var bool fib3b3 = na var bool fib4b3 = na var bool fib5b3 = na var bool fib6b3 = na var bool fib7b3 = na var bool fib8b3 = na var bool fib9b3 = na var bool fib10b3 = na var bool fib11b3 = na var bool fib12b3 = na var bool fib13b3 = na var int date = na var int date2 = na var int date3 = na string NYID = "NY" string LondonID = "London" string TokioID = "Tokio" string FrankfurtID = "Frankfurt" string weekday = na string sesslength = na var dates = array.new_int() var dates2 = array.new_int() var dates3 = array.new_int() var signaltimea = array.new_int() var signaltime2 = array.new_int() var signaltime3 = array.new_int() var nybarindexa = array.new_int() var ldnbarindexa = array.new_int() var tybarindexa = array.new_int() var top2xa = array.new_int() var top2xxa = array.new_int() var topxa = array.new_int() var btm2xa = array.new_int() var btm2xxa = array.new_int() var bottomxa = array.new_int() var fib1xa = array.new_int() var fib1xxa = array.new_int() var fib2xa = array.new_int() var fib3xa = array.new_int() var fib4xa = array.new_int() var fib5xa = array.new_int() var fib6xa = array.new_int() var fib7xa = array.new_int() var fib8xa = array.new_int() var fib9xa = array.new_int() var fib10xa = array.new_int() var fib11xa = array.new_int() var fib12xa = array.new_int() var fib13xa = array.new_int() var top2xa2 = array.new_int() var top2xxa2 = array.new_int() var topxa2 = array.new_int() var btm2xa2 = array.new_int() var btm2xxa2 = array.new_int() var bottomxa2 = array.new_int() var fib1xa2 = array.new_int() var fib1xxa2 = array.new_int() var fib2xa2 = array.new_int() var fib3xa2 = array.new_int() var fib4xa2 = array.new_int() var fib5xa2 = array.new_int() var fib6xa2 = array.new_int() var fib7xa2 = array.new_int() var fib8xa2 = array.new_int() var fib9xa2 = array.new_int() var fib10xa2 = array.new_int() var fib11xa2 = array.new_int() var fib12xa2 = array.new_int() var fib13xa2 = array.new_int() var top2xa3 = array.new_int() var top2xxa3 = array.new_int() var topxa3 = array.new_int() var btm2xa3 = array.new_int() var btm2xxa3 = array.new_int() var bottomxa3 = array.new_int() var fib1xa3 = array.new_int() var fib1xxa3 = array.new_int() var fib2xa3 = array.new_int() var fib3xa3 = array.new_int() var fib4xa3 = array.new_int() var fib5xa3 = array.new_int() var fib6xa3 = array.new_int() var fib7xa3 = array.new_int() var fib8xa3 = array.new_int() var fib9xa3 = array.new_int() var fib10xa3 = array.new_int() var fib11xa3 = array.new_int() var fib12xa3 = array.new_int() var fib13xa3 = array.new_int() var IDR_close_array = array.new_float() var colorgradarray = array.new_float() var sessionID = array.new_string() var sessionID2 = array.new_string() var sessionID3 = array.new_string() var signaldira = array.new_string() var signaldira2 = array.new_string() var signaldira3 = array.new_string() var symbola = array.new_string() var nyopenarray1 = array.new_float() var nyopenarray2 = array.new_float() var nyclosearray1 = array.new_float() var nyclosearray2 = array.new_float() var ldnopenarray1 = array.new_float() var ldnopenarray2 = array.new_float() var ldnclosearray1 = array.new_float() var ldnclosearray2 = array.new_float() var tyopenarray1 = array.new_float() var tyopenarray2 = array.new_float() var tyclosearray1 = array.new_float() var tyclosearray2 = array.new_float() var fib1a = array.new_bool() var fib1aa = array.new_bool() var fib2a = array.new_bool() var fib3a = array.new_bool() var fib4a = array.new_bool() var fib5a = array.new_bool() var fib6a = array.new_bool() var fib7a = array.new_bool() var fib8a = array.new_bool() var fib9a = array.new_bool() var fib10a = array.new_bool() var fib11a = array.new_bool() var fib12a = array.new_bool() var fib13a = array.new_bool() var top2a = array.new_bool() var top2aa = array.new_bool() var topa = array.new_bool() var bottoma = array.new_bool() var btm2a = array.new_bool() var btm2aa = array.new_bool() var fib1a2 = array.new_bool() var fib1aa2 = array.new_bool() var fib2a2 = array.new_bool() var fib3a2 = array.new_bool() var fib4a2 = array.new_bool() var fib5a2 = array.new_bool() var fib6a2 = array.new_bool() var fib7a2 = array.new_bool() var fib8a2 = array.new_bool() var fib9a2 = array.new_bool() var fib10a2 = array.new_bool() var fib11a2 = array.new_bool() var fib12a2 = array.new_bool() var fib13a2 = array.new_bool() var top2a2 = array.new_bool() var top2aa2 = array.new_bool() var topa2 = array.new_bool() var bottoma2 = array.new_bool() var btm2a2 = array.new_bool() var btm2aa2 = array.new_bool() var fib1a3 = array.new_bool() var fib1aa3 = array.new_bool() var fib2a3 = array.new_bool() var fib3a3 = array.new_bool() var fib4a3 = array.new_bool() var fib5a3 = array.new_bool() var fib6a3 = array.new_bool() var fib7a3 = array.new_bool() var fib8a3 = array.new_bool() var fib9a3 = array.new_bool() var fib10a3 = array.new_bool() var fib11a3 = array.new_bool() var fib12a3 = array.new_bool() var fib13a3 = array.new_bool() var top2a3 = array.new_bool() var top2aa3 = array.new_bool() var topa3 = array.new_bool() var bottoma3 = array.new_bool() var btm2a3 = array.new_bool() var btm2aa3 = array.new_bool() var ptopz = array.new_float() var pbottomz = array.new_float() var ptop2z = array.new_float() var pbtm2z = array.new_float() var p2topz = array.new_float() var p2bottomz = array.new_float() var p2top2z = array.new_float() var p2btm2z = array.new_float() var p3topz = array.new_float() var p3bottomz = array.new_float() var p3top2z = array.new_float() var p3btm2z = array.new_float() var topz = array.new_float() var bottomz = array.new_float() var top2z = array.new_float() var btm2z = array.new_float() var fib1z = array.new_float() var fib2z = array.new_float() var fib3z = array.new_float() var fib4z = array.new_float() var fib5z = array.new_float() var fib6z = array.new_float() var fib7z = array.new_float() var fib8z = array.new_float() var fib9z = array.new_float() var fib10z = array.new_float() var fib11z = array.new_float() var fib12z = array.new_float() var fib13z = array.new_float() var t2opz = array.new_float() var b2ottomz = array.new_float() var t2op2z = array.new_float() var b2tm2z = array.new_float() var f2ib1z = array.new_float() var f2ib2z = array.new_float() var f2ib3z = array.new_float() var f2ib4z = array.new_float() var f2ib5z = array.new_float() var f2ib6z = array.new_float() var f2ib7z = array.new_float() var f2ib8z = array.new_float() var f2ib9z = array.new_float() var f2ib10z = array.new_float() var f2ib11z = array.new_float() var f2ib12z = array.new_float() var f2ib13z = array.new_float() var t3opz = array.new_float() var b3ottomz = array.new_float() var t3op2z = array.new_float() var b3tm2z = array.new_float() var f3ib1z = array.new_float() var f3ib2z = array.new_float() var f3ib3z = array.new_float() var f3ib4z = array.new_float() var f3ib5z = array.new_float() var f3ib6z = array.new_float() var f3ib7z = array.new_float() var f3ib8z = array.new_float() var f3ib9z = array.new_float() var f3ib10z = array.new_float() var f3ib11z = array.new_float() var f3ib12z = array.new_float() var f3ib13z = array.new_float() var topz2 = array.new_float() var bottomz2 = array.new_float() var top2z2 = array.new_float() var btm2z2 = array.new_float() var fib1z2 = array.new_float() var fib2z2 = array.new_float() var fib3z2 = array.new_float() var fib4z2 = array.new_float() var fib5z2 = array.new_float() var fib6z2 = array.new_float() var fib7z2 = array.new_float() var fib8z2 = array.new_float() var fib9z2 = array.new_float() var fib10z2 = array.new_float() var fib11z2 = array.new_float() var fib12z2 = array.new_float() var fib13z2 = array.new_float() var topz3 = array.new_float() var bottomz3 = array.new_float() var top2z3 = array.new_float() var btm2z3 = array.new_float() var fib1z3 = array.new_float() var fib2z3 = array.new_float() var fib3z3 = array.new_float() var fib4z3 = array.new_float() var fib5z3 = array.new_float() var fib6z3 = array.new_float() var fib7z3 = array.new_float() var fib8z3 = array.new_float() var fib9z3 = array.new_float() var fib10z3 = array.new_float() var fib11z3 = array.new_float() var fib12z3 = array.new_float() var fib13z3 = array.new_float() var highpa = array.new_float() var highpa2 = array.new_float() var highpa3 = array.new_float() var lowpa = array.new_float() var lowpa2 = array.new_float() var lowpa3 = array.new_float() var nydayopena = array.new_float() var barcounta = array.new_bool() var sesslengtha = array.new_string() float highp = na float lowp = na var int arrayplus1 = 0 var int arrayplus2 = 0 var int arrayplus3 = 0 var bool candlecolorup = na var bool candlecolorup2 = na var bool candlecolorup3 = na var bool candlecolordown = na var bool candlecolordown2 = na var bool candlecolordown3 = na var bool startarray = false var bool startarray2 = false var bool startarray3 = false var bool nycleanarray1 = na var bool nycleanarray2 = na var bool ldncleanarray1 = na var bool ldncleanarray2 = na var bool tycleanarray1 = na var bool tycleanarray2 = na var bool barcount = na var bool barcount2 = na var bool barcount3 = na int rightlinex = na var int nybarindex = na var int ldnbarindex = na var int tybarindex = na var string signaldir = na var string signaldir2 = na var string signaldir3 = na var bool ptopb = na var bool p2topb = na var bool p3topb = na var bool ptop2b = na var bool p2top2b = na var bool p3top2b = na var bool pbtm2b = na var bool p2btm2b = na var bool p3btm2b = na var bool pfib1b = na var bool p2fib1b = na var bool p3fib1b = na var bool pfib3b = na var bool p2fib3b = na var bool p3fib3b = na var bool pfib4b = na var bool p2fib4b = na var bool p3fib4b = na var bool pfib5b = na var bool p2fib5b = na var bool p3fib5b = na var bool pfib6b = na var bool p2fib6b = na var bool p3fib6b = na var bool pfib7b = na var bool p2fib7b = na var bool p3fib7b = na var bool pfib8b = na var bool p2fib8b = na var bool p3fib8b = na var bool ptop2bb = na var bool p2top2bb = na var bool p3top2bb = na var bool pbtm2bb = na var bool p2btm2bb = na var bool p3btm2bb = na var bool pfib1bb = na var bool p2fib1bb = na var bool p3fib1bb = na var bool pfib2b = na var bool p2fib2b = na var bool p3fib2b = na var bool pfib9b = na var bool p2fib9b = na var bool p3fib9b = na var bool pfib10b = na var bool p2fib10b = na var bool p3fib10b = na var bool pfib11b = na var bool p2fib11b = na var bool p3fib11b = na var bool pfib12b = na var bool p2fib12b = na var bool p3fib12b = na var bool pfib13b = na var bool p2fib13b = na var bool p3fib13b = na var bool pbottomb = na var bool p2bottomb = na var bool p3bottomb = na peakcount = 0 nydayopen = request.security(syminfo.tickerid,"D", open) if sessiontosession array1off := InSession("1825-1830","GMT-5") array2off := InSession("0925-0930","GMT-5") array3off := InSession("0255-0300","GMT-5") else array1off := InSession("0925-0930" , "GMT-5") array2off := InSession("0255-0300" , "GMT-5") array3off := InSession("1825-1830" , "GMT-5") if not sessiontosession if arraysess array1 := true if arraysess2 array2 := true if arraysess3 array3 := true peakcount := 192 sesslength := "FS" if sessiontosession if arraysess array1 := true if arraysess2 array2 := true if arraysess3 array3 := true peakcount := 96 sesslength := "S2S" //} //{ Get HLOC for the previous 12 candles on each candle top = ta.highest(high,12) bottom = ta.lowest(low,12) topopen = ta.highest(open,12) topclose = ta.highest(close,12) btmopen = ta.lowest(open,12) btmclose = ta.lowest(close,12) dayweek = dayofweek //} //{ turn numerical dayofweek into text for labels etc if dayweek == 1 weekday := "Sunday" else if dayweek == 2 weekday := "Monday" else if dayweek == 3 weekday := "Tuesday" else if dayweek == 4 weekday := "Wednesday" else if dayweek == 5 weekday := "Thursday" else if dayweek == 6 weekday := "Friday" else if dayweek == 7 weekday := "Saturday" //} //{ Set date range automatically or via manual input in settings menu if timeish == false if (end2 >= time and start2 <= time) indate := true else indate := false else na if timeish if (end >= time and start <= time) indate := true else indate := false else na //Decide if high open is higher than high close or vice versa and whether low open is lower than low close or vice versa if topopen > topclose top2 := topopen else top2 := topclose if btmopen < btmclose btm2 := btmopen else btm2 := btmclose var float ptop = na var float pbottom = na var float ptop2 = na var float pbtm2 = na var float p2top = na var float p2bottom = na var float p2top2 = na var float p2btm2 = na var float p3top = na var float p3bottom = na var float p3top2 = na var float p3btm2 = na //} //{ Some Logics toplabelprice := top + boxlabel bottomlabelprice := bottom - sessionlabel colorgrad = top-bottom if arraysess array.push(colorgradarray,colorgrad) clrmax := array.max(colorgradarray) clrmin := array.min(colorgradarray) if arraysess2 array.push(colorgradarray,colorgrad) clrmax2 := array.max(colorgradarray) clrmin2 := array.min(colorgradarray) if arraysess3 array.push(colorgradarray,colorgrad) clrmax3 := array.max(colorgradarray) clrmin3 := array.min(colorgradarray) fib1 := top2 - ((top2 - btm2)* 0.5) fib2 := btm2 - ((top2 - btm2)* 2.5) fib3 := top2 + ((top2 - btm2)* 2.5) fib4 := top2 + ((top2 - btm2)* 0.5) fib5 := top2 + ((top2 - btm2)* 1) fib6 := top2 + ((top2 - btm2)* 1.5) fib7 := top2 + ((top2 - btm2)* 2) fib8 := top2 + ((top2 - btm2)* 3) fib9 := btm2 - ((top2 - btm2)* 0.5) fib10 := btm2 - ((top2 - btm2)* 1) fib11 := btm2 - ((top2 - btm2)* 1.5) fib12 := btm2 - ((top2 - btm2)* 2) fib13 := btm2 - ((top2 - btm2)* 3) //} highp := ta.highest(high,peakcount) lowp := ta.lowest(low,peakcount) //{ if barstate.isfirst array.push(nydayopena,0.0) array.push(signaltimea, 0) array.push(signaltime2, 0) array.push(signaltime3, 0) array.push(symbola, "symb") array.push(lowpa,0.0) array.push(lowpa2,0.0) array.push(lowpa3,0.0) array.push(highpa,0.0) array.push(highpa2,0.0) array.push(highpa3,0.0) array.push(signaldira, "secret is cheese") array.push(signaldira2, "secret is cheese") array.push(signaldira3, "secret is cheese") array.push(nybarindexa, 0) array.push(ldnbarindexa,0) array.push(tybarindexa,0) array.push(nyopenarray1,nyopen) array.push(nyopenarray2, nyopen2) array.push(nyclosearray1, nyclose) array.push(nyclosearray2, nyclose2) array.push(ldnopenarray1, nyopen) array.push(ldnopenarray2, nyopen2) array.push(ldnclosearray1, nyclose) array.push(ldnclosearray2, nyclose2) array.push(tyopenarray1, nyopen) array.push(tyopenarray2, nyopen2) array.push(tyclosearray1, nyclose) array.push(tyclosearray2, nyclose2) array.push(fib1xa, fib1x) array.push(fib1xxa, fib1xx) array.push(fib2xa, fib2x) array.push(fib3xa, fib3x) array.push(fib4xa, 0) array.push(fib5xa, 0) array.push(fib6xa, 0) array.push(fib7xa, 0) array.push(fib8xa, 0) array.push(fib9xa, 0) array.push(fib10xa, 0) array.push(fib11xa, 0) array.push(fib12xa, 0) array.push(fib13xa, 0) array.push(topxa, 0) array.push(top2xa, top2x) array.push(top2xxa, 0) array.push(btm2xa, 0) array.push(btm2xxa, 0) array.push(bottomxa, 0) array.push(fib1xa2, 0) array.push(fib1xxa2, 0) array.push(fib2xa2, 0) array.push(fib3xa2, 0) array.push(fib4xa2, 0) array.push(fib5xa2, 0) array.push(fib6xa2, 0) array.push(fib7xa2, 0) array.push(fib8xa2, 0) array.push(fib9xa2, 0) array.push(fib10xa2, 0) array.push(fib11xa2, 0) array.push(fib12xa2, 0) array.push(fib13xa2, 0) array.push(topxa2, 0) array.push(top2xa2, 0) array.push(top2xxa2, 0) array.push(btm2xa2, 0) array.push(btm2xxa2, 0) array.push(bottomxa2, 0) array.push(fib1xa3, 0) array.push(fib1xxa3, 0) array.push(fib2xa3, 0) array.push(fib3xa3, 0) array.push(fib4xa3, 0) array.push(fib5xa3, 0) array.push(fib6xa3, 0) array.push(fib7xa3, 0) array.push(fib8xa3, 0) array.push(fib9xa3, 0) array.push(fib10xa3, 0) array.push(fib11xa3, 0) array.push(fib12xa3, 0) array.push(fib13xa3, 0) array.push(topxa3, 0) array.push(top2xa3, 0) array.push(top2xxa3, 0) array.push(btm2xa3, 0) array.push(btm2xxa3, 0) array.push(bottomxa3, 0) array.push(fib1a, fib1b) array.push(fib1aa, false) array.push(fib2a, false) array.push(fib3a, false) array.push(fib4a, false) array.push(fib5a, false) array.push(fib6a, false) array.push(fib7a, false) array.push(fib8a, false) array.push(fib9a, false) array.push(fib10a, false) array.push(fib11a, false) array.push(fib12a, false) array.push(fib13a, false) array.push(topa, false) array.push(top2a, false) array.push(top2aa, false) array.push(bottoma, false) array.push(btm2a, false) array.push(btm2aa, false) array.push(fib1a2, false) array.push(fib1aa2, false) array.push(fib2a2, false) array.push(fib3a2, false) array.push(fib4a2, false) array.push(fib5a2, false) array.push(fib6a2, false) array.push(fib7a2, false) array.push(fib8a2, false) array.push(fib9a2, false) array.push(fib10a2, false) array.push(fib11a2, false) array.push(fib12a2, false) array.push(fib13a2, false) array.push(topa2, false) array.push(top2a2, false) array.push(top2aa2, false) array.push(bottoma2, false) array.push(btm2a2, false) array.push(btm2aa2, false) array.push(fib1a3, false) array.push(fib1aa3, false) array.push(fib2a3, false) array.push(fib3a3, false) array.push(fib4a3, false) array.push(fib5a3, false) array.push(fib6a3, false) array.push(fib7a3, false) array.push(fib8a3, false) array.push(fib9a3, false) array.push(fib10a3, false) array.push(fib11a3, false) array.push(fib12a3, false) array.push(fib13a3, false) array.push(topa3, false) array.push(top2a3, false) array.push(top2aa3, false) array.push(bottoma3, false) array.push(btm2a3, false) array.push(btm2aa3, false) array.push(dates , time) array.push(sessionID , NYID) array.push(ptopz , top ) array.push(pbottomz , bottom) array.push(ptop2z , top2) array.push(pbtm2z , btm2) array.push(topz , top ) array.push(bottomz , bottom) array.push(top2z , top2) array.push(btm2z , btm2) array.push(fib1z, 0.0) array.push(fib2z, 0.0) array.push(fib3z, 0.0) array.push(fib4z, 0.0) array.push(fib5z, 0.0) array.push(fib6z, 0.0) array.push(fib7z, 0.0) array.push(fib8z, 0.0) array.push(fib9z, 0.0) array.push(fib10z, 0.0) array.push(fib11z, 0.0) array.push(fib12z, 0.0) array.push(fib13z, 0.0) array.push(t2opz , top ) array.push(b2ottomz , bottom) array.push(t2op2z , top2) array.push(b2tm2z , btm2) array.push(f2ib1z, 0.0) array.push(f2ib2z, 0.0) array.push(f2ib3z, 0.0) array.push(f2ib4z, 0.0) array.push(f2ib5z, 0.0) array.push(f2ib6z, 0.0) array.push(f2ib7z, 0.0) array.push(f2ib8z, 0.0) array.push(f2ib9z, 0.0) array.push(f2ib10z, 0.0) array.push(f2ib11z, 0.0) array.push(f2ib12z, 0.0) array.push(f2ib13z, 0.0) array.push(t3opz , top ) array.push(b3ottomz , bottom) array.push(t3op2z , top2) array.push(b3tm2z , btm2) array.push(f3ib1z, 0.0) array.push(f3ib2z, 0.0) array.push(f3ib3z, 0.0) array.push(f3ib4z, 0.0) array.push(f3ib5z, 0.0) array.push(f3ib6z, 0.0) array.push(f3ib7z, 0.0) array.push(f3ib8z, 0.0) array.push(f3ib9z, 0.0) array.push(f3ib10z, 0.0) array.push(f3ib11z, 0.0) array.push(f3ib12z, 0.0) array.push(f3ib13z, 0.0) array.push(dates2 , time) array.push(sessionID2 , NYID) array.push(topz2 , top ) array.push(bottomz2 , bottom) array.push(top2z2 , top2) array.push(btm2z2 , btm2) array.push(p2topz , top ) array.push(p2bottomz , bottom) array.push(p2top2z , top2) array.push(p2btm2z , btm2) array.push(fib1z2, 0.0) array.push(fib2z2, 0.0) array.push(fib3z2, 0.0) array.push(fib4z2, 0.0) array.push(fib5z2, 0.0) array.push(fib6z2, 0.0) array.push(fib7z2, 0.0) array.push(fib8z2, 0.0) array.push(fib9z2, 0.0) array.push(fib10z2, 0.0) array.push(fib11z2, 0.0) array.push(fib12z2, 0.0) array.push(fib13z2, 0.0) array.push(dates3 , time) array.push(sessionID3 , NYID) array.push(topz3 , top ) array.push(bottomz3 , bottom) array.push(top2z3 , top2) array.push(btm2z3 , btm2) array.push(p3topz , top ) array.push(p3bottomz , bottom) array.push(p3top2z , top2) array.push(p3btm2z , btm2) array.push(fib1z3, 0.0) array.push(fib2z3, 0.0) array.push(fib3z3, 0.0) array.push(fib4z3, 0.0) array.push(fib5z3, 0.0) array.push(fib6z3, 0.0) array.push(fib7z3, 0.0) array.push(fib8z3, 0.0) array.push(fib9z3, 0.0) array.push(fib10z3, 0.0) array.push(fib11z3, 0.0) array.push(fib12z3, 0.0) array.push(fib13z3, 0.0) array.push(sesslengtha, sesslength) arrayplus1 := array.size(dates) arrayplus2 := array.size(dates2) arrayplus3 := array.size(dates3) arrayplusz := array.size(topz) arrayplusz2 := array.size(t2opz) arrayplusz3 := array.size(t3opz) nyopen := open nyopen2 := close nyclose := open nyclose2 := close if opensess2 and indate and ldntrue ldnopen := open ldnopen2 := close if arraysess2 and indate and ldntrue ldnclose := open ldnclose2 := close if opensess3 and indate and tkotrue tyopen := open tyopen2 := close if arraysess3 and indate and tkotrue tyclose := open tyclose2 := close if not indate nycleanarray1 := false nycleanarray2 := false ldncleanarray1 := false ldncleanarray2 := false tycleanarray1 := false tycleanarray2 := false if indate if nysess and nytrue boxy := box.new(bar_index[11], top, bar_index, bottom,bgcolor=color.new(color.from_gradient(colorgrad,clrmin,clrmax,nycolor1,nycolor2),65)) boxy2 := box.new(bar_index[11], top2, bar_index, btm2, bgcolor=color.new(color.from_gradient(colorgrad,clrmax,clrmin,nycolor1,nycolor2),65)) box.delete(boxy[1]) box.delete(boxy2[1]) if labelson label1 := label.new(bar_index,toplabelprice, text = "DR Top: "+ str.tostring(top,format.mintick)+ "\n DR Btm: " +str.tostring(bottom,format.mintick)+ "\n IDR Top: "+str.tostring(top2,format.mintick)+ "\n IDR Btm: "+str.tostring(btm2,format.mintick)+"\n9:30 O:"+str.tostring(open[11],format.mintick)+" C:"+str.tostring(close[11],format.mintick)+"\n10:30 O:"+str.tostring(open,format.mintick)+" C:"+str.tostring(close,format.mintick), yloc = yloc.price ,color=color.new(tycolor2,55), style=label.style_label_center, textcolor=color.rgb(255, 250, 252, 5), size=size.normal, textalign = text.align_center,text_font_family=font.family_monospace) label2 := label.new(bar_index[5.5],bottomlabelprice, text = "Session: NY:\n "+str.tostring(dayofmonth) +"/"+str.tostring(month)+"/"+str.tostring(year)+"\n"+str.tostring(weekday), yloc = yloc.price ,color=color.new(ldncolor2,55), style=label.style_text_outline, textcolor=color.rgb(248, 248, 248, 5), size=size.normal, textalign = text.align_center, text_font_family=font.family_monospace) label.delete(label1[1]) label.delete(label2[1]) if london and ldntrue boxy3 := box.new(bar_index[11], top, bar_index, bottom, bgcolor=color.new(color.from_gradient(colorgrad,clrmin2,clrmax2,ldncolor1,ldncolor2),65)) boxy4 := box.new(bar_index[11], top2, bar_index, btm2, bgcolor=color.new(color.from_gradient(colorgrad,clrmax2,clrmin2,ldncolor1,ldncolor2),65)) box.delete(boxy3[1]) box.delete(boxy4[1]) if labelson label3 := label.new(bar_index,toplabelprice, text = "DR Top: "+ str.tostring(top,format.mintick)+ "\n DR Btm: " +str.tostring(bottom,format.mintick)+ "\n IDR Top: "+str.tostring(top2,format.mintick)+ "\n IDR Btm: "+str.tostring(btm2,format.mintick), yloc = yloc.price ,color=color.new(nycolor1,55), style=label.style_label_center, textcolor=color.rgb(255, 250, 252, 5), size=size.normal, textalign = text.align_center,text_font_family=font.family_monospace) label4 := label.new(bar_index[5.5],bottomlabelprice, text = "Session: London:\n "+str.tostring(dayofmonth) +"/"+str.tostring(month)+"/"+str.tostring(year)+"\n"+str.tostring(weekday), yloc = yloc.price ,color=color.new(nycolor2,55), style=label.style_text_outline, textcolor=color.rgb(248, 248, 248, 5), size=size.normal, textalign = text.align_center, text_font_family=font.family_monospace) label.delete(label3[1]) label.delete(label4[1]) if tokio and tkotrue boxy5 := box.new(bar_index[11], top, bar_index, bottom, bgcolor=color.new(color.from_gradient(colorgrad,clrmin3,clrmax3,tycolor1,tycolor2),65)) boxy6 := box.new(bar_index[11], top2, bar_index, btm2, bgcolor=color.new(color.from_gradient(colorgrad,clrmax3,clrmin3,tycolor1,tycolor2),65)) box.delete(boxy5[1]) box.delete(boxy6[1]) if labelson label5 := label.new(bar_index,toplabelprice, text = "DR Top: "+ str.tostring(top,format.mintick)+ "\n DR Btm: " +str.tostring(bottom,format.mintick)+ "\n IDR Top: "+str.tostring(top2,format.mintick)+ "\n IDR Btm: "+str.tostring(btm2,format.mintick), yloc = yloc.price ,color=color.new(tycolor1,55), style=label.style_label_center, textcolor=color.rgb(255, 250, 252, 5), size=size.normal, textalign = text.align_center,text_font_family=font.family_monospace) label6 := label.new(bar_index[5.5],bottomlabelprice, text = "Session: Tokio:\n "+str.tostring(dayofmonth) +"/"+str.tostring(month)+"/"+str.tostring(year)+"\n"+str.tostring(weekday), yloc = yloc.price ,color=color.new(ldncolor1,55), style=label.style_text_outline, textcolor=color.rgb(248, 248, 248, 5), size=size.normal, textalign = text.align_center, text_font_family=font.family_monospace) label.delete(label5[1]) label.delete(label6[1]) if (arraysess and nytrue or arraysess2 and ldntrue or arraysess3 and tkotrue) and stdlevels and indate rightlinex := bar_index + 120 usline1 := line.new(bar_index[11],top,rightlinex,top, xloc= xloc.bar_index,color = color.aqua) usline2 := line.new(bar_index[11],top2,rightlinex,top2, xloc= xloc.bar_index,color = color.purple) usline3 := line.new(bar_index[11],bottom,rightlinex,bottom, xloc= xloc.bar_index,color = color.rgb(184, 169, 35)) usline4 := line.new(bar_index[11],btm2,rightlinex,btm2, xloc= xloc.bar_index,color = color.green) usline5 := line.new(bar_index[11],fib1,rightlinex,fib1, xloc= xloc.bar_index,color = color.rgb(38, 23, 235)) usline6 := line.new(bar_index[11],fib2,rightlinex,fib2, xloc= xloc.bar_index,color = color.rgb(9, 182, 116)) usline7 := line.new(bar_index[11],fib3,rightlinex,fib3, xloc= xloc.bar_index,color = color.rgb(189, 119, 235)) usline8 := line.new(bar_index[11],fib4,rightlinex,fib4, xloc= xloc.bar_index,color = color.rgb(57, 160, 108)) usline9 := line.new(bar_index[11],fib5,rightlinex,fib5, xloc= xloc.bar_index,color = color.rgb(161, 194, 12)) usline10 := line.new(bar_index[11],fib6,rightlinex,fib6, xloc= xloc.bar_index,color = color.rgb(235, 108, 23)) usline11 := line.new(bar_index[11],fib7,rightlinex,fib7, xloc= xloc.bar_index,color = color.rgb(175, 17, 17)) usline12 := line.new(bar_index[11],fib8,rightlinex,fib8, xloc= xloc.bar_index,color = color.rgb(235, 23, 207)) usline13 := line.new(bar_index[11],fib9,rightlinex,fib9, xloc= xloc.bar_index,color = color.rgb(131, 174, 209)) usline14 := line.new(bar_index[11],fib10,rightlinex,fib10, xloc= xloc.bar_index,color = color.rgb(0, 189, 189)) usline15 := line.new(bar_index[11],fib11,rightlinex,fib11, xloc= xloc.bar_index,color = color.rgb(112, 150, 7)) usline16 := line.new(bar_index[11],fib12,rightlinex,fib12, xloc= xloc.bar_index,color = color.rgb(182, 146, 49)) usline17 := line.new(bar_index[11],fib13,rightlinex,fib13, xloc= xloc.bar_index,color = color.rgb(211, 162, 240)) if fiblabels linelabel1 := label.new(bar_index[13],top + 1.5,"DR "+str.tostring(top,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel2 := label.new(bar_index[13],top2 - 1.5,"IDR "+str.tostring(top2,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel3 := label.new(bar_index[13],btm2 + 1.5,"IDR "+str.tostring(btm2,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel4 := label.new(bar_index[13],bottom - 1.5,"DR "+str.tostring(bottom,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel5 := label.new(bar_index[13],fib1 ,"0.5 " +str.tostring(fib1,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel6 := label.new(bar_index[13],fib2 ,"2.5 " +str.tostring(fib2,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel7 := label.new(bar_index[13],fib3 ,"2.5 " +str.tostring(fib3,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel8 := label.new(bar_index[13],fib4 ,"0.5 " +str.tostring(fib4,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel9 := label.new(bar_index[13],fib5 ,"1 "+ str.tostring(fib5,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel10 := label.new(bar_index[13],fib6,"1.5 "+ str.tostring(fib6,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel11 := label.new(bar_index[13],fib7,"2 "+ str.tostring(fib7,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel12 := label.new(bar_index[13],fib8,"3 "+ str.tostring(fib8,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel13 := label.new(bar_index[13],fib9,"0.5 "+ str.tostring(fib9,format.mintick),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel14 := label.new(bar_index[13],fib10,"1 "+str.tostring(fib10),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel15 := label.new(bar_index[13],fib11 ,"1.5 "+str.tostring(fib11),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel16 := label.new(bar_index[13],fib12 ,"2 "+str.tostring(fib12),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) linelabel17 := label.new(bar_index[13],fib13 ,"3 "+str.tostring(fib13),text_font_family = font.family_default ,yloc = yloc.price,color =color.rgb(255, 255, 255),style= label.style_none ,textcolor=color.white,size= size.normal, textalign= text.align_left) var barznting = 0 //} if prearray1 and indate and nytrue and startarray array.push(dates, date) array.push(sessionID , NYID) array.push(sesslengtha,sesslength) array.push(nybarindexa ,nybarindex ) array.push(signaldira ,signaldir ) array.push(signaltimea , bartimesignal) array.push(symbola ,symbol ) array.push(ptopz , ptop ) array.push( pbottomz ,pbottom ) array.push( ptop2z , ptop2 ) array.push(pbtm2z , pbtm2 ) array.push(nyopenarray1 , nyopen ) array.push( nyopenarray2 , nyopen2 ) array.push( nyclosearray1 , nyclose ) array.push( nyclosearray2 , nyclose2 ) array.push( nydayopena , nydayopen ) array.push(highpa , highp ) array.push(lowpa,lowp) array.push(fib1xa, fib1x) array.push(fib1xxa, fib1xx) array.push(fib2xa, fib2x) array.push(fib3xa, fib3x) array.push(fib4xa, fib4x) array.push(fib5xa, fib5x) array.push(fib6xa, fib6x) array.push(fib7xa, fib7x) array.push(fib8xa, fib8x) array.push(fib9xa, fib9x) array.push(fib10xa, fib10x) array.push(fib11xa, fib11x) array.push(fib12xa, fib12x) array.push(fib13xa, fib13x) array.push(topxa, topx) array.push(topa, ptopb) array.push(bottomxa, bottomx) array.push(bottoma, pbottomb) array.push(top2aa, ptop2bb) array.push(top2xxa, top2xx) array.push(top2xa, top2x) array.push(top2a, ptop2b) array.push(btm2aa, pbtm2bb) array.push(btm2xxa, btm2xx) array.push(btm2xa, btm2x) array.push(btm2a, pbtm2b) array.push(fib1a, pfib1b) array.push(fib1aa, pfib1bb) array.push(fib2a, pfib2b) array.push(fib3a, pfib3b) array.push(fib4a, pfib4b) array.push(fib5a, pfib5b) array.push(fib6a, pfib6b) array.push(fib7a, pfib7b) array.push(fib8a, pfib8b) array.push(fib9a, pfib9b) array.push(fib10a, pfib10b) array.push(fib11a, pfib11b) array.push(fib12a, pfib12b) array.push(fib13a, pfib13b) arrayplus1 := array.size(dates) ptopb := na ptop2b := na ptop2bb := na pbottomb := na pbtm2b := na pbtm2bb := na pfib1b := na pfib1bb := na pfib2b := na pfib3b := na pfib4b := na pfib5b := na pfib6b := na pfib7b := na pfib8b := na pfib9b := na pfib10b := na pfib11b := na pfib12b := na pfib13b := na fib1x := na fib1xx := na fib2x := na fib3x := na fib4x := na fib5x := na fib6x := na fib7x := na fib8x := na fib9x := na fib10x := na fib11x := na fib12x := na fib13x := na top2x := na top2xx := na btm2x := na btm2xx := na topx := na bottomx := na if arraysess and indate and nytrue date := time ptop := top pbottom := bottom ptop2 := top2 pbtm2 := btm2 nybarindex := bar_index nyopen := open[11] nyopen2 := close[11] nyclose := open nyclose2 := close linefill.new(usline12 ,usline7 ,color = color.new(color.from_gradient(fib8,fib13, fib8,ldncolor1,ldncolor2),75)) linefill.new(usline7 ,usline11 ,color = color.new(color.from_gradient(fib3,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline11 ,usline10 ,color = color.new(color.from_gradient(fib7,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline10 ,usline9 ,color = color.new(color.from_gradient(fib6,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline9 ,usline8 ,color = color.new(color.from_gradient(fib5,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline8 ,usline1 ,color = color.new(color.from_gradient(fib4,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline1 ,usline2 ,color = color.new(color.from_gradient(top,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline2 ,usline5 ,color = color.new(color.from_gradient(top2,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline5 ,usline4 ,color = color.new(color.from_gradient(fib1,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline4 ,usline3 ,color = color.new(color.from_gradient(bottom,fib13,fib8, ldncolor1,ldncolor2), 75)) linefill.new(usline3 ,usline13 ,color = color.new(color.from_gradient(btm2,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline13 ,usline14 ,color = color.new(color.from_gradient(fib9,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline14 ,usline15 ,color = color.new(color.from_gradient(fib10,fib13,fib8, ldncolor1,ldncolor2),75)) linefill.new(usline15 ,usline16 ,color = color.new(color.from_gradient(fib11,fib13,fib8 ,ldncolor1,ldncolor2),75)) linefill.new(usline16 ,usline6 ,color = color.new(color.from_gradient(fib12,fib13,fib8,ldncolor1,ldncolor2),75)) linefill.new(usline6 ,usline17 ,color = color.new(color.from_gradient(fib2,fib13,fib8,ldncolor1,ldncolor2),75)) array.push(topz , top ) array.push(bottomz , bottom) array.push(top2z , top2) array.push(btm2z , btm2) array.push(fib1z, fib1) array.push(fib2z, fib2) array.push(fib3z, fib3) array.push(fib4z, fib4) array.push(fib5z, fib5) array.push(fib6z, fib6) array.push(fib7z, fib7) array.push(fib8z, fib8) array.push(fib9z, fib9) array.push(fib10z,fib10) array.push(fib11z,fib11) array.push(fib12z,fib12) array.push(fib13z,fib13) nycleanarray1 := true nycleanarray2 := true startarray := true array1 := true arrayplusz := array.size(topz) topcross := low[1] < array.get(top2z,arrayplusz - 1) and close > array.get(top2z, arrayplusz - 1) bottomcross := high[1] > array.get(btm2z,arrayplusz - 1) and close < array.get(btm2z, arrayplusz - 1) if indate and nytrue if array1 and topcross and startarray array1 := false bartimesignal := bar_index t = array.get(top2z,arrayplusz - 1) bullsignal = label.new(bar_index,t,"Buy Signal "+str.tostring(bartimesignal), yloc= yloc.price, color = color.lime, style = label.style_cross,textcolor = color.white, size = size.normal) top2b := true btm2b := true fib1b := true fib3b := true fib4b := true fib5b := true fib6b := true fib7b := true fib8b := true bottomb := true nycleanarray1 := false signaldir := "Buy" bartimesignal := bar_index candlecolorup := true if array1 and bottomcross and startarray array1 := false bartimesignal := bar_index s = array.get(btm2z,arrayplusz - 1) bearsignal = label.new(bar_index,s,"Sell Signal", yloc= yloc.price, color = color.fuchsia, style = label.style_cross,textcolor = color.white, size = size.normal) top2bb := true btm2bb := true fib1bb := true fib2b := true fib9b := true fib10b := true fib11b := true fib12b := true fib13b := true topb := true nycleanarray2 := false signaldir := "Sell" bartimesignal := bar_index candlecolordown := true bool bottombuycross = na bottombuycross := close[1] > array.get(bottomz,arrayplusz - 1) and low < array.get(bottomz, arrayplusz - 1) if bottomb and bottombuycross pbottomb := true bottomx := bar_index bottomxl = label.new(bar_index, low, "Buy Signal Stop X "+str.tostring(bottomx)+" "+str.tostring(bottomb) ,style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) bottomb := false bool topsellcross = na topsellcross := close[1] < array.get(topz,arrayplusz - 1) and high > array.get(topz, arrayplusz - 1) if topb and topsellcross topx := bar_index topxl = label.new(bar_index, low, "Sell Signal Stop "+str.tostring(topx)+" "+str.tostring(topb),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) ptopb := true topb := false topsellcross := false bool top2buycross = na top2buycross := close[1] > array.get(top2z,arrayplusz - 1) and low < array.get(top2z, arrayplusz - 1) if top2b and top2buycross top2x := bar_index ptop2b := true idrx = label.new(bar_index, low, "Top IDR Buy X "+str.tostring(top2b)+" "+str.tostring(top2x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) top2b := false bool btm2buycross = na btm2buycross := close[1] > array.get(btm2z,arrayplusz - 1) and low < array.get(btm2z, arrayplusz - 1) if btm2b and btm2buycross btm2x := bar_index pbtm2b := true btm2xl = label.new(bar_index, low, "Btm IDR Buy X "+str.tostring(btm2x)+" "+str.tostring(btm2b),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) btm2b := false bool fib1buycross = na fib1buycross := close[1] > array.get(fib1z,arrayplusz - 1) and low < array.get(fib1z, arrayplusz - 1) if fib1b and fib1buycross fib1x := bar_index pfib1b := true fib1xl = label.new(bar_index, low, "Mid Buy X "+str.tostring(fib1x)+" "+str.tostring(fib1b),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib1b := false bool fib3buycross = na fib3buycross := close[1] < array.get(fib3z,arrayplusz - 1) and high > array.get(fib3z, arrayplusz - 1) if fib3b and fib3buycross fib3x := bar_index pfib3b := true fib3xl = label.new(bar_index, low, "2.5 Buy X "+str.tostring(fib3x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib3b := false bool fib4buycross = na fib4buycross := close[1] < array.get(fib4z,arrayplusz - 1) and high > array.get(fib4z, arrayplusz - 1) if fib4b and fib4buycross fib4x := bar_index pfib4b := true fib4xl = label.new(bar_index, low, "0.5 Buy X "+str.tostring(fib4x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib4b := false bool fib5buycross = na fib5buycross := close[1] < array.get(fib5z,arrayplusz - 1) and high > array.get(fib5z, arrayplusz - 1) if fib5b and fib5buycross fib5x := bar_index pfib5b := true fib5xl = label.new(bar_index, low, "1 Buy X "+str.tostring(fib5x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib5b := false bool fib6buycross = na fib6buycross := close[1] < array.get(fib6z,arrayplusz - 1) and high > array.get(fib6z, arrayplusz - 1) if fib6b and fib6buycross fib6x := bar_index pfib6b := true fib6xl = label.new(bar_index, low, "1.5 Buy X "+str.tostring(fib6x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib6b := false bool fib7buycross = na fib7buycross := close[1] < array.get(fib7z,arrayplusz - 1) and high > array.get(fib7z, arrayplusz - 1) if fib7b and fib7buycross fib7x := bar_index pfib7b := true fib7xl = label.new(bar_index, low, "2 Buy X "+str.tostring(fib7x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib7b := false bool fib8buycross = na fib8buycross := close[1] < array.get(fib8z,arrayplusz - 1) and high > array.get(fib8z, arrayplusz - 1) if fib8b and fib8buycross fib8x := bar_index pfib8b := true fib8xl = label.new(bar_index, low, "3 Buy X "+str.tostring(fib8x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib8b := false bool top2sellcross = na top2sellcross := close[1] < array.get(top2z,arrayplusz - 1) and high > array.get(top2z, arrayplusz - 1) if top2bb and top2sellcross and startarray top2xx := bar_index ptop2bb := true idrxx = label.new(bar_index, low, "Top Sell IDR X "+str.tostring(top2bb)+" "+str.tostring(top2xx),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) top2bb := false top2sellcross := false bool btm2sellcross = na btm2sellcross := close[1] < array.get(btm2z,arrayplusz - 1) and high > array.get(btm2z, arrayplusz - 1) if btm2bb and btm2sellcross btm2xx := bar_index pbtm2bb := true btm2xxl = label.new(bar_index, low, "Btm2 Sell IDR X "+str.tostring(btm2xx),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) btm2bb := false //btm2sellcross := false bool fib1sellcross = na fib1sellcross := close[1] < array.get(fib1z,arrayplusz - 1) and high > array.get(fib1z, arrayplusz - 1) if fib1bb and fib1sellcross fib1xx := bar_index pfib1bb := true fib1xxl = label.new(bar_index, low, "Mid Sell X "+str.tostring(fib1xx),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib1bb := false bool fib2sellcross = na fib2sellcross := close[1] > array.get(fib2z,arrayplusz - 1) and low < array.get(fib2z, arrayplusz - 1) if fib2b and fib2sellcross fib2x := bar_index pfib2b := true fib2xl = label.new(bar_index, low, "2.5 Sell cross "+str.tostring(fib2x)+" "+str.tostring(fib2b),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib2b := false bool fib9sellcross = na fib9sellcross := close[1] > array.get(fib9z,arrayplusz - 1) and low < array.get(fib9z, arrayplusz - 1) if fib9b and fib9sellcross fib9x := bar_index pfib9b := true fib9xl = label.new(bar_index, low, "0.5 Sell X "+str.tostring(fib9x)+" "+str.tostring(fib9b),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib9b := false bool fib10sellcross = na fib10sellcross := close[1] > array.get(fib10z,arrayplusz - 1) and low < array.get(fib10z, arrayplusz - 1) if fib10b and fib10sellcross fib10x := bar_index pfib10b := true fib10xl = label.new(bar_index, low, "1 Sell X "+str.tostring(fib10x)+" "+str.tostring(fib10b),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib10b := false bool fib11sellcross = na fib11sellcross := close[1] > array.get(fib11z,arrayplusz - 1) and low < array.get(fib11z, arrayplusz - 1) if fib11b and fib11sellcross fib11x := bar_index pfib11b := true fib11xl = label.new(bar_index, low, "1.5 Sell X "+str.tostring(fib11x)+" "+str.tostring(fib11b),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib11b := false bool fib12sellcross = na fib12sellcross := close[1] > array.get(fib12z,arrayplusz - 1) and low < array.get(fib12z, arrayplusz - 1) if fib12b and fib12sellcross fib12x := bar_index pfib12b := true fib12xl = label.new(bar_index, low, "2 Sell X "+str.tostring(fib12x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib12b := false bool fib13sellcross = na fib13sellcross := close[1] > array.get(fib13z,arrayplusz - 1) and low < array.get(fib13z, arrayplusz - 1) if fib13b and fib13sellcross fib13x := bar_index pfib13b := true fib13xl = label.new(bar_index, low, "3 Sell X "+str.tostring(fib13x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib13b := false if array1off candlecolorup := false candlecolordown := false if array1off and top2b//and (indate and nytrue) top2b :=false ptop2b := false top2x := na if array1off and top2bb// and (indate and nytrue) top2bb :=false ptop2bb := false top2xx := na if array1off and btm2b btm2b :=false pbtm2b := false btm2x := na if array1off and btm2bb //and (indate and nytrue) btm2bb :=false pbtm2bb := false btm2xx := na if array1off and fib1b//and (indate and nytrue) fib1b :=false pfib1b := false fib1x := na if array1off and fib1bb fib1bb :=false pfib1bb := false fib1xx := na if array1off and fib3b fib3b :=false pfib3b := false fib3x := na if array1off and fib4b fib4b :=false pfib4b := false fib4x := na if array1off and fib5b fib5b :=false pfib5b := false fib5x := na if array1off and fib6b fib6b :=false pfib6b := false fib6x := na if array1off and fib7b fib7b :=false pfib7b := false fib7x := na if array1off and fib8b fib8b :=false pfib8b := false fib8x := na if array1off and fib2b fib2b :=false pfib2b := false fib2x := na if array1off and fib9b fib9b :=false pfib9b := false fib9x := na if array1off and fib10b fib10b :=false pfib10b := false fib10x := na if array1off and fib11b fib11b :=false pfib11b := false fib11x := na if array1off and fib12b fib12b :=false pfib12b := false fib12x := na if array1off and fib13b fib13b :=false pfib13b := false fib13x := na if array1off and bottomb bottomb :=false pbottomb := false bottomx := na if array1off and topb topb :=false ptopb := false topx := na if nycleanarray1 and array1off ptop2b := na top2x := na pbtm2b := na btm2x := na pfib1b := na fib1x := na pfib3b := na fib3x := na pfib4b := na fib4x := na pfib5b := na fib5x := na pfib6b := na fib6x := na pfib7b := na fib7x := na pfib8b := na fib8x := na pbottomb := na bottomx := na if nycleanarray2 and array1off ptop2bb := na top2xx := na pbtm2bb := na btm2xx := na pfib1bb := na fib1xx := na pfib2b := na fib2x := na pfib9b := na fib9x := na pfib10b := na fib10x := na pfib11b := na fib11x := na pfib12b := na fib12x := na pfib13b := na fib13x := na ptopb := na topx := na if array1off and array1 bartimesignal := na signaldir := "none" if array1off barcount := false if prearray2 and indate and ldntrue and startarray2 array.push(dates2, date2) array.push(sessionID2 , NYID) array.push(sesslengtha,sesslength) array.push(ldnbarindexa ,ldnbarindex ) array.push(signaldira2 ,signaldir2 ) array.push(signaltime2 , bartimesignal2) array.push(symbola ,symbol ) array.push( p2topz , p2top ) array.push( p2bottomz ,p2bottom ) array.push( p2top2z , p2top2 ) array.push( p2btm2z , p2btm2 ) array.push(ldnopenarray1 , ldnopen ) array.push(ldnopenarray2 , ldnopen2 ) array.push(ldnclosearray1 , ldnclose ) array.push(ldnclosearray2 , ldnclose2 ) array.push( nydayopena , nydayopen ) array.push(highpa2 , highp ) array.push(lowpa2, lowp) array.push(fib1xa2, fib1x2) array.push(fib1xxa2,fib1xx2) array.push( fib2xa2, fib2x2) array.push( fib3xa2, fib3x2) array.push( fib4xa2, fib4x2) array.push( fib5xa2, fib5x2) array.push( fib6xa2, fib6x2) array.push( fib7xa2, fib7x2) array.push( fib8xa2, fib8x2) array.push( fib9xa2, fib9x2) array.push(fib10xa2,fib10x2) array.push(fib11xa2,fib11x2) array.push(fib12xa2,fib12x2) array.push(fib13xa2,fib13x2) array.push( fib1a2, fib1b2) array.push(fib1aa2, p2fib1bb) array.push( fib2a2, p2fib2b) array.push( fib3a2, p2fib3b) array.push( fib4a2, p2fib4b) array.push( fib5a2, p2fib5b) array.push( fib6a2, p2fib6b) array.push( fib7a2, p2fib7b) array.push( fib8a2, p2fib8b) array.push( fib9a2, p2fib9b) array.push(fib10a2, p2fib10b) array.push(fib11a2, p2fib11b) array.push(fib12a2, p2fib12b) array.push(fib13a2, p2fib13b) array.push(topxa2, topx2) array.push(topa2, p2topb) array.push(bottomxa, bottomx) array.push(bottoma, pbottomb) array.push(top2aa, ptop2bb) array.push(top2xxa, top2xx) array.push(top2xa2, top2x2) array.push(top2a2, p2top2b) array.push(btm2aa2, p2btm2bb) array.push(btm2xxa2, btm2xx2) array.push(btm2xa2, btm2x2) array.push(btm2a2, p2btm2b) arrayplus2 := array.size(dates2) p2topb := na p2top2b := na p2top2bb := na p2bottomb := na p2btm2b := na p2btm2bb := na p2fib1b := na p2fib1bb := na p2fib2b := na p2fib3b := na p2fib4b := na p2fib5b := na p2fib6b := na p2fib7b := na p2fib8b := na p2fib9b := na p2fib10b := na p2fib11b := na p2fib12b := na p2fib13b := na fib1x2 := na fib1xx2 := na fib2x2 := na fib3x2 := na fib4x2 := na fib5x2 := na fib6x2 := na fib7x2 := na fib8x2 := na fib9x2 := na fib10x2 := na fib11x2 := na fib12x2 := na fib13x2 := na top2x2 := na top2xx2 := na btm2x2 := na btm2xx2 := na topx2 := na bottomx2 := na if arraysess2 and indate and ldntrue date2 := time p2top := top p2bottom := bottom p2top2 := top2 p2btm2 := btm2 ldnbarindex := bar_index linefill.new(usline12 ,usline7 ,color = color.new(color.from_gradient(fib8,fib13, fib8,tycolor1,tycolor2),75)) linefill.new(usline7 ,usline11 ,color = color.new(color.from_gradient(fib3,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline11 ,usline10 ,color = color.new(color.from_gradient(fib7,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline10 ,usline9 ,color = color.new(color.from_gradient(fib6,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline9 ,usline8 ,color = color.new(color.from_gradient(fib5,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline8 ,usline1 ,color = color.new(color.from_gradient(fib4,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline1 ,usline2 ,color = color.new(color.from_gradient(top,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline2 ,usline5 ,color = color.new(color.from_gradient(top2,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline5 ,usline4 ,color = color.new(color.from_gradient(fib1,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline4 ,usline3 ,color = color.new(color.from_gradient(bottom,fib13,fib8, tycolor1,tycolor2), 75)) linefill.new(usline3 ,usline13 ,color = color.new(color.from_gradient(btm2,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline13 ,usline14 ,color = color.new(color.from_gradient(fib9,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline14 ,usline15 ,color = color.new(color.from_gradient(fib10,fib13,fib8, tycolor1,tycolor2),75)) linefill.new(usline15 ,usline16 ,color = color.new(color.from_gradient(fib11,fib13,fib8 ,tycolor1,tycolor2),75)) linefill.new(usline16 ,usline6 ,color = color.new(color.from_gradient(fib12,fib13,fib8,tycolor1,tycolor2),75)) linefill.new(usline6 ,usline17 ,color = color.new(color.from_gradient(fib2,fib13,fib8,tycolor1,tycolor2),75)) array.push(t2opz , top ) array.push(b2ottomz , bottom) array.push(t2op2z , top2) array.push(b2tm2z , btm2) array.push(f2ib1z, fib1) array.push(f2ib2z, fib2) array.push(f2ib3z, fib3) array.push(f2ib4z, fib4) array.push(f2ib5z, fib5) array.push(f2ib6z, fib6) array.push(f2ib7z, fib7) array.push(f2ib8z, fib8) array.push(f2ib9z, fib9) array.push(f2ib10z,fib10) array.push(f2ib11z,fib11) array.push(f2ib12z,fib12) array.push(f2ib13z,fib13) ldncleanarray1 := true ldncleanarray2 := true startarray2 := true array2 := true arrayplusz2 := array.size(t2opz) topcross2 := low[1] < array.get(t2op2z,arrayplusz2 - 1) and close > array.get(t2op2z, arrayplusz2 - 1) bottomcross2 := high[1] > array.get(b2tm2z,arrayplusz2 - 1) and close < array.get(b2tm2z, arrayplusz2 - 1) if indate and ldntrue if array2 and topcross2 and startarray2 array2 := false bartimesignal2 := bar_index g = array.get(t2op2z,arrayplusz2 - 1) bullsignal2 = label.new(bar_index,g,"Buy Signal "+str.tostring(bartimesignal), yloc= yloc.price, color = color.lime, style = label.style_cross,textcolor = color.white, size = size.normal) top2b2 := true btm2b2 := true fib1b2 := true fib3b2 := true fib4b2 := true fib5b2 := true fib6b2 := true fib7b2 := true fib8b2 := true bottomb2 := true ldncleanarray1 := false signaldir2 := "Buy" bartimesignal2 := bar_index candlecolorup2 := true if array2 and bottomcross2 and startarray2 array2 := false bartimesignal2 := bar_index f = array.get(b2tm2z,arrayplusz2 - 1) bearsignal2 = label.new(bar_index,f,"Sell Signal", yloc= yloc.price, color = color.fuchsia, style = label.style_cross,textcolor = color.white, size = size.normal) top2bb2 := true btm2bb2 := true fib1bb2 := true fib2b2 := true fib9b2 := true fib10b2 := true fib11b2 := true fib12b2 := true fib13b2 := true topb2 := true ldncleanarray2 := false signaldir2 := "Sell" candlecolordown2 := true bool bottombuycross2 = na bottombuycross2 := close[1] > array.get(b2ottomz,arrayplusz2 - 1) and low < array.get(b2ottomz, arrayplusz2 - 1) if bottomb2 and bottombuycross2 p2bottomb := true bottomx2 := bar_index bottomxl2 = label.new(bar_index, low, "Buy Signal Stop X "+str.tostring(bottomx)+" "+str.tostring(bottomb) ,style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) bottomb2 := false bool topsellcross2 = na topsellcross2 := close[1] < array.get(t2opz,arrayplusz2 - 1) and high > array.get(t2opz, arrayplusz2 - 1) if topb2 and topsellcross2 topx2 := bar_index topxl2 = label.new(bar_index, low, "Sell Signal Stop "+str.tostring(topx2)+" "+str.tostring(topb2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) p2topb := true topb2 := false topsellcross2 := false bool top2buycross2 = na top2buycross2 := close[1] > array.get(t2op2z,arrayplusz2 - 1) and low < array.get(t2op2z, arrayplusz2 - 1) if top2b2 and top2buycross2 top2x2 := bar_index p2top2b := true idrx2 = label.new(bar_index, low, "Top IDR Buy X "+str.tostring(top2b)+" "+str.tostring(top2x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) top2b2 := false bool btm2buycross2 = na btm2buycross2 := close[1] > array.get(b2tm2z,arrayplusz2 - 1) and low < array.get(b2tm2z, arrayplusz2 - 1) if btm2b2 and btm2buycross2 btm2x2 := bar_index p2btm2b := true btm2xl2 = label.new(bar_index, low, "Btm IDR Buy X "+str.tostring(btm2x2)+" "+str.tostring(btm2b2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) btm2b2 := false bool fib1buycross2 = na fib1buycross2 := close[1] > array.get(f2ib1z,arrayplusz2 - 1) and low < array.get(f2ib1z, arrayplusz2 - 1) if fib1b2 and fib1buycross2 fib1x2 := bar_index p2fib1b := true fib1xl2 = label.new(bar_index, low, "Mid Buy X "+str.tostring(fib1x2)+" "+str.tostring(fib1b2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib1b2 := false bool fib3buycross2 = na fib3buycross2 := close[1] < array.get(f2ib3z,arrayplusz2 - 1) and high > array.get(f2ib3z, arrayplusz2 - 1) if fib3b2 and fib3buycross2 fib3x2 := bar_index p2fib3b := true fib3xl2 = label.new(bar_index, low, "2.5 Buy X "+str.tostring(fib3x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib3b2 := false bool fib4buycross2 = na fib4buycross2 := close[1] < array.get(f2ib4z,arrayplusz2 - 1) and high > array.get(f2ib4z, arrayplusz2 - 1) if fib4b2 and fib4buycross2 fib4x2 := bar_index p2fib4b := true fib4xl2 = label.new(bar_index, low, "0.5 Buy X "+str.tostring(fib4x2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib4b2 := false bool fib5buycross2 = na fib5buycross2 := close[1] < array.get(f2ib5z,arrayplusz2 - 1) and high > array.get(f2ib5z, arrayplusz2 - 1) if fib5b2 and fib5buycross2 fib5x2 := bar_index p2fib5b := true fib5xl2 = label.new(bar_index, low, "1 Buy X "+str.tostring(fib5x2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib5b2 := false bool fib6buycross2 = na fib6buycross2 := close[1] < array.get(f2ib6z,arrayplusz2 - 1) and high > array.get(f2ib6z, arrayplusz2 - 1) if fib6b2 and fib6buycross2 fib6x2 := bar_index p2fib6b := true fib6xl2 = label.new(bar_index, low, "1.5 Buy X "+str.tostring(fib6x2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib6b2 := false bool fib7buycross2 = na fib7buycross2 := close[1] < array.get(f2ib7z,arrayplusz2 - 1) and high > array.get(f2ib7z, arrayplusz2 - 1) if fib7b2 and fib7buycross2 fib7x2 := bar_index p2fib7b := true fib7xl2 = label.new(bar_index, low, "2 Buy X "+str.tostring(fib7x2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib7b2 := false bool fib8buycross2 = na fib8buycross2 := close[1] < array.get(f2ib8z,arrayplusz2 - 1) and high > array.get(f2ib8z, arrayplusz2 - 1) if fib8b2 and fib8buycross2 fib8x2 := bar_index p2fib8b := true fib8xl2 = label.new(bar_index, low, "3 Buy X "+str.tostring(fib8x),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib8b2 := false var bool top2sellcross2 = na top2sellcross2 := close[1] < array.get(t2op2z,arrayplusz2 - 1) and high > array.get(t2op2z, arrayplusz2 - 1) if top2bb2 and top2sellcross2 and startarray2 top2xx2 := bar_index p2top2bb := true idrxx2 = label.new(bar_index, low, "Top Sell IDR X "+str.tostring(top2bb2)+" "+str.tostring(top2xx2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) top2bb2 := false top2sellcross2 := false bool btm2sellcross2 = na btm2sellcross2 := close[1] < array.get(b2tm2z,arrayplusz2 - 1) and high > array.get(b2tm2z, arrayplusz2 - 1) if btm2bb2 and btm2sellcross2 btm2xx2 := bar_index p2btm2bb := true btm2xxl2 = label.new(bar_index, low, "Btm2 Sell IDR X "+str.tostring(btm2xx2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) btm2bb2 := false //btm2sellcross := false bool fib1sellcross2 = na fib1sellcross2 := close[1] < array.get(f2ib1z,arrayplusz2 - 1) and high > array.get(f2ib1z, arrayplusz2 - 1) if fib1bb2 and fib1sellcross2 fib1xx2 := bar_index p2fib1bb := true fib1xxl2 = label.new(bar_index, low, "Mid Sell X "+str.tostring(fib1xx2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib1bb2 := false bool fib2sellcross2 = na fib2sellcross2 := close[1] > array.get(f2ib2z,arrayplusz2 - 1) and low < array.get(f2ib2z, arrayplusz2 - 1) if fib2b2 and fib2sellcross2 fib2x2 := bar_index p2fib2b := true fib2xl2 = label.new(bar_index, low, "2.5 Sell cross "+str.tostring(fib2x2)+" "+str.tostring(fib2b2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib2b2 := false bool fib9sellcross2 = na fib9sellcross2 := close[1] > array.get(f2ib9z,arrayplusz2 - 1) and low < array.get(f2ib9z, arrayplusz2 - 1) if fib9b2 and fib9sellcross2 fib9x2 := bar_index p2fib9b := true fib9xl2 = label.new(bar_index, low, "0.5 Sell X "+str.tostring(fib9x)+" "+str.tostring(fib9b2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib9b2 := false bool fib10sellcross2 = na fib10sellcross2 := close[1] > array.get(f2ib10z,arrayplusz2 - 1) and low < array.get(f2ib10z, arrayplusz2 - 1) if fib10b2 and fib10sellcross2 fib10x2 := bar_index p2fib10b := true fib10xl2 = label.new(bar_index, low, "1 Sell X "+str.tostring(fib10x2)+" "+str.tostring(fib10b2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib10b2 := false bool fib11sellcross2 = na fib11sellcross2 := close[1] > array.get(f2ib11z,arrayplusz2 - 1) and low < array.get(f2ib11z, arrayplusz2 - 1) if fib11b2 and fib11sellcross2 fib11x2 := bar_index p2fib11b := true fib11xl2 = label.new(bar_index, low, "1.5 Sell X "+str.tostring(fib11x2)+" "+str.tostring(fib11b2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib11b2 := false bool fib12sellcross2 = na fib12sellcross2 := close[1] > array.get(f2ib12z,arrayplusz2 - 1) and low < array.get(f2ib12z, arrayplusz2 - 1) if fib12b2 and fib12sellcross2 fib12x2 := bar_index p2fib12b := true fib12xl2 = label.new(bar_index, low, "2 Sell X "+str.tostring(fib12x2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib12b2 := false bool fib13sellcross2 = na fib13sellcross2 := close[1] > array.get(f2ib13z,arrayplusz2 - 1) and low < array.get(f2ib13z, arrayplusz2 - 1) if fib13b2 and fib13sellcross2 fib13x2 := bar_index p2fib13b := true fib13xl2 = label.new(bar_index, low, "3 Sell X "+str.tostring(fib13x2),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib13b2 := false if array2off candlecolorup2 := false candlecolordown2 := false if array2off and top2b2//and (indate and nytrue) top2b2 :=false p2top2b := false top2x2 := na if array2off and top2bb2// and (indate and nytrue) top2bb2 :=false p2top2bb := false top2xx2 := na if array2off and btm2b2 btm2b2 :=false p2btm2b := false btm2x2 := na if array2off and btm2bb2 //and (indate and nytrue) btm2bb2 :=false p2btm2bb := false btm2xx2 := na if array2off and fib1b2//and (indate and nytrue) fib1b2 :=false p2fib1b := false fib1x2 := na if array2off and fib1bb2 fib1bb2 :=false p2fib1bb := false fib1xx2 := na if array2off and fib3b2 fib3b2 :=false p2fib3b := false fib3x2 := na if array2off and fib4b2 fib4b2 :=false p2fib4b := false fib4x2 := na if array2off and fib5b2 fib5b2 :=false p2fib5b := false fib5x2 := na if array2off and fib6b2 fib6b2 :=false p2fib6b := false fib6x2 := na if array2off and fib7b2 fib7b2 :=false p2fib7b := false fib7x2 := na if array2off and fib8b2 fib8b2 :=false p2fib8b := false fib8x2 := na if array2off and fib2b2 fib2b2 :=false p2fib2b := false fib2x2 := na if array2off and fib9b2 fib9b2 :=false p2fib9b := false fib9x2 := na if array2off and fib10b2 fib10b2 :=false p2fib10b := false fib10x2 := na if array2off and fib11b2 fib11b2 :=false p2fib11b := false fib11x2 := na if array2off and fib12b2 fib12b2 :=false p2fib12b := false fib12x2 := na if array2off and fib13b2 fib13b2 :=false p2fib13b := false fib13x2 := na if array2off and bottomb2 bottomb2 :=false p2bottomb := false bottomx2 := na if array2off and topb2 topb2 :=false p2topb := false topx2 := na if ldncleanarray1 and array2off p2top2b := na top2x2 := na p2btm2b := na btm2x2 := na p2fib1b := na fib1x2 := na p2fib3b := na fib3x2 := na p2fib4b := na fib4x2 := na p2fib5b := na fib5x2 := na p2fib6b := na fib6x2 := na p2fib7b := na fib7x2 := na p2fib8b := na fib8x2 := na p2bottomb := na bottomx2 := na if ldncleanarray2 and array2off p2top2bb := na top2xx2 := na p2btm2bb := na btm2xx2 := na p2fib1bb := na fib1xx2 := na p2fib2b := na fib2x2 := na p2fib9b := na fib9x2 := na p2fib10b := na fib10x2 := na p2fib11b := na fib11x2 := na p2fib12b := na fib12x2 := na p2fib13b := na fib13x2 := na p2topb := na topx2 := na if array2off and array2 bartimesignal2 := na signaldir2 := "None" if array2off barcount2 := false if prearray3 and indate and tkotrue and startarray3 array.push(dates3, date3) array.push(sessionID3 , NYID) array.push(sesslengtha,sesslength) array.push(ldnbarindexa ,ldnbarindex ) array.push(signaldira3 ,signaldir3 ) array.push(signaltime3 , bartimesignal3) array.push(symbola ,symbol ) array.push( p3topz , p3top ) array.push( p3bottomz ,p3bottom ) array.push( p3top2z , p3top2 ) array.push( p3btm2z , p3btm2 ) array.push(ldnopenarray1 , ldnopen ) array.push(ldnopenarray2 , ldnopen2 ) array.push(ldnclosearray1 , ldnclose ) array.push(ldnclosearray2 , ldnclose2 ) array.push( nydayopena , nydayopen ) array.push(highpa3 , highp ) array.push(lowpa3, lowp) array.push(fib1xa3, fib1x3) array.push(fib1xxa3,fib1xx3) array.push( fib2xa3, fib2x3) array.push( fib3xa3, fib3x3) array.push( fib4xa3, fib4x3) array.push( fib5xa3, fib5x3) array.push( fib6xa3, fib6x3) array.push( fib7xa3, fib7x3) array.push( fib8xa3, fib8x3) array.push( fib9xa3, fib9x3) array.push(fib10xa3,fib10x3) array.push(fib11xa3,fib11x3) array.push(fib12xa3,fib12x3) array.push(fib13xa3,fib13x3) array.push( fib1a3, fib1b3) array.push(fib1aa3, p3fib1bb) array.push( fib2a3, p3fib2b) array.push( fib3a3, p3fib3b) array.push( fib4a3, p3fib4b) array.push( fib5a3, p3fib5b) array.push( fib6a3, p3fib6b) array.push( fib7a3, p3fib7b) array.push( fib8a3, p3fib8b) array.push( fib9a3, p3fib9b) array.push(fib10a3, p3fib10b) array.push(fib11a3, p3fib11b) array.push(fib12a3, p3fib12b) array.push(fib13a3, p3fib13b) array.push(topxa3, topx3) array.push(topa3, p3topb) array.push(bottomxa, bottomx) array.push(bottoma, pbottomb) array.push(top2aa, ptop2bb) array.push(top2xxa, top2xx) array.push(top2xa3, top2x3) array.push(top2a3, p3top2b) array.push(btm2aa3, p3btm2bb) array.push(btm2xxa3, btm2xx3) array.push(btm2xa3, btm2x3) array.push(btm2a3, p3btm2b) arrayplus3 := array.size(dates3) p3topb := na p3top2b := na p3top2bb := na p3bottomb := na p3btm2b := na p3btm2bb := na p3fib1b := na p3fib1bb := na p3fib2b := na p3fib3b := na p3fib4b := na p3fib5b := na p3fib6b := na p3fib7b := na p3fib8b := na p3fib9b := na p3fib10b := na p3fib11b := na p3fib12b := na p3fib13b := na fib1x3 := na fib1xx3 := na fib2x3 := na fib3x3 := na fib4x3 := na fib5x3 := na fib6x3 := na fib7x3 := na fib8x3 := na fib9x3 := na fib10x3 := na fib11x3 := na fib12x3 := na fib13x3 := na top2x3 := na top2xx3 := na btm2x3 := na btm2xx3 := na topx3 := na bottomx3 := na if arraysess3 and indate and tkotrue date2 := time p3top := top p3bottom := bottom p3top2 := top2 p3btm2 := btm2 tybarindex := bar_index linefill.new(usline12 ,usline7 ,color = color.new(color.from_gradient(fib8,fib13, fib8,nycolor1,nycolor2),75)) linefill.new(usline7 ,usline11 ,color = color.new(color.from_gradient(fib3,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline11 ,usline10 ,color = color.new(color.from_gradient(fib7,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline10 ,usline9 ,color = color.new(color.from_gradient(fib6,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline9 ,usline8 ,color = color.new(color.from_gradient(fib5,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline8 ,usline1 ,color = color.new(color.from_gradient(fib4,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline1 ,usline2 ,color = color.new(color.from_gradient(top,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline2 ,usline5 ,color = color.new(color.from_gradient(top2,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline5 ,usline4 ,color = color.new(color.from_gradient(fib1,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline4 ,usline3 ,color = color.new(color.from_gradient(bottom,fib13,fib8, nycolor1,nycolor2), 75)) linefill.new(usline3 ,usline13 ,color = color.new(color.from_gradient(btm2,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline13 ,usline14 ,color = color.new(color.from_gradient(fib9,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline14 ,usline15 ,color = color.new(color.from_gradient(fib10,fib13,fib8, nycolor1,nycolor2),75)) linefill.new(usline15 ,usline16 ,color = color.new(color.from_gradient(fib11,fib13,fib8 ,nycolor1,nycolor2),75)) linefill.new(usline16 ,usline6 ,color = color.new(color.from_gradient(fib12,fib13,fib8,nycolor1,nycolor2),75)) linefill.new(usline6 ,usline17 ,color = color.new(color.from_gradient(fib2,fib13,fib8,nycolor1,nycolor2),75)) array.push(t3opz , top ) array.push(b3ottomz , bottom) array.push(t3op2z , top2) array.push(b3tm2z , btm2) array.push(f3ib1z, fib1) array.push(f3ib2z, fib2) array.push(f3ib3z, fib3) array.push(f3ib4z, fib4) array.push(f3ib5z, fib5) array.push(f3ib6z, fib6) array.push(f3ib7z, fib7) array.push(f3ib8z, fib8) array.push(f3ib9z, fib9) array.push(f3ib10z,fib10) array.push(f3ib11z,fib11) array.push(f3ib12z,fib12) array.push(f3ib13z,fib13) tycleanarray1 := true tycleanarray2 := true startarray3 := true array3 := true arrayplusz3 := array.size(t3opz) topcross3 := low[1] < array.get(t3op2z,arrayplusz3 - 1) and close > array.get(t3op2z, arrayplusz3 - 1) bottomcross3 := high[1] > array.get(b3tm2z,arrayplusz3 - 1) and close < array.get(b3tm2z, arrayplusz3 - 1) if indate and tkotrue if array3 and topcross3 and startarray3 array3 := false bartimesignal3 := bar_index t = array.get(t3op2z,arrayplusz3 - 1) bullsignal3 = label.new(bar_index,t,"Buy Signal "+str.tostring(bartimesignal), yloc= yloc.price, color = color.lime, style = label.style_cross,textcolor = color.white, size = size.normal) top2b3 := true btm2b3 := true fib1b3 := true fib3b3 := true fib4b3 := true fib5b3 := true fib6b3 := true fib7b3 := true fib8b3 := true bottomb3 := true tycleanarray1 := false signaldir3 := "Buy" bartimesignal3 := bar_index candlecolorup3 := true if array3 and bottomcross3 and startarray3 array3 := false bartimesignal3 := bar_index s = array.get(b3tm2z,arrayplusz3 - 1) bearsignal3 = label.new(bar_index,s,"Sell Signal", yloc= yloc.price, color = color.fuchsia, style = label.style_cross,textcolor = color.white, size = size.normal) top2bb3 := true btm2bb3 := true fib1bb3 := true fib2b3 := true fib9b3 := true fib10b3 := true fib11b3 := true fib12b3 := true fib13b3 := true topb3 := true tycleanarray2 := false signaldir3 := "Sell" bartimesignal3 := bar_index candlecolordown3 := true bool bottombuycross3 = na bottombuycross3 := close[1] > array.get(b3ottomz,arrayplusz3 - 1) and low < array.get(b3ottomz, arrayplusz3 - 1) if bottomb3 and bottombuycross3 p3bottomb := true bottomx3 := bar_index bottomxl3 = label.new(bar_index, low, "Buy Signal Stop X "+str.tostring(bottomx3)+" "+str.tostring(bottomb3) ,style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) bottomb3 := false bool topsellcross3 = na topsellcross3 := close[1] < array.get(t3opz,arrayplusz3 - 1) and high > array.get(t3opz, arrayplusz3 - 1) if topb3 and topsellcross3 topx3 := bar_index topxl = label.new(bar_index, low, "Sell Signal Stop "+str.tostring(topx3)+" "+str.tostring(topb3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) p3topb := true topb3 := false topsellcross3 := false bool top2buycross3 = na top2buycross3 := close[1] > array.get(t3op2z,arrayplusz3 - 1) and low < array.get(t3op2z, arrayplusz3 - 1) if top2b3 and top2buycross3 top2x3 := bar_index p3top2b := true idrx3 = label.new(bar_index, low, "Top IDR Buy X "+str.tostring(top2b3)+" "+str.tostring(top2x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) top2b3 := false bool btm2buycross3 = na btm2buycross3 := close[1] > array.get(b3tm2z,arrayplusz3 - 1) and low < array.get(b3tm2z, arrayplusz3 - 1) if btm2b3 and btm2buycross3 btm2x3 := bar_index p3btm2b := true btm2xl3 = label.new(bar_index, low, "Btm IDR Buy X "+str.tostring(btm2x3)+" "+str.tostring(btm2b3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) btm2b3 := false bool fib1buycross3 = na fib1buycross3 := close[1] > array.get(f3ib1z,arrayplusz3 - 1) and low < array.get(f3ib1z, arrayplusz3 - 1) if fib1b3 and fib1buycross3 fib1x3 := bar_index p3fib1b := true fib1xl3 = label.new(bar_index, low, "Mid Buy X "+str.tostring(fib1x3)+" "+str.tostring(fib1b3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib1b3 := false bool fib3buycross3 = na fib3buycross3 := close[1] < array.get(f3ib3z,arrayplusz3 - 1) and high > array.get(f3ib3z, arrayplusz3 - 1) if fib3b3 and fib3buycross3 fib3x3 := bar_index p3fib3b := true fib3xl3 = label.new(bar_index, low, "2.5 Buy X "+str.tostring(fib3x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib3b3 := false bool fib4buycross3 = na fib4buycross3 := close[1] < array.get(f3ib4z,arrayplusz3 - 1) and high > array.get(f3ib4z, arrayplusz3 - 1) if fib4b3 and fib4buycross3 fib4x3 := bar_index p3fib4b := true fib4xl3 = label.new(bar_index, low, "0.5 Buy X "+str.tostring(fib4x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib4b3 := false bool fib5buycross3 = na fib5buycross3 := close[1] < array.get(f3ib5z,arrayplusz3 - 1) and high > array.get(f3ib5z, arrayplusz3 - 1) if fib5b3 and fib5buycross3 fib5x3 := bar_index p3fib5b := true firb5xl = label.new(bar_index, low, "1 Buy X "+str.tostring(fib5x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib5b3 := false bool fib6buycross3 = na fib6buycross3 := close[1] < array.get(f3ib6z,arrayplusz3 - 1) and high > array.get(f3ib6z, arrayplusz3 - 1) if fib6b3 and fib6buycross3 fib6x3 := bar_index p3fib6b := true fidb6xl = label.new(bar_index, low, "1.5 Buy X "+str.tostring(fib6x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib6b3 := false bool fib7buycross3 = na fib7buycross3 := close[1] < array.get(f3ib7z,arrayplusz3 - 1) and high > array.get(f3ib7z, arrayplusz3 - 1) if fib7b3 and fib7buycross3 fib7x3 := bar_index p3fib7b := true fidb7xl = label.new(bar_index, low, "2 Buy X "+str.tostring(fib7x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib7b3 := false bool fib8buycross3 = na fib8buycross3 := close[1] < array.get(f3ib8z,arrayplusz3 - 1) and high > array.get(f3ib8z, arrayplusz3 - 1) if fib8b3 and fib8buycross3 fib8x3 := bar_index p3fib8b := true fib8xl = label.new(bar_index, low, "3 Buy X "+str.tostring(fib8x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib8b3 := false var bool top2sellcross3 = na top2sellcross3 := close[1] < array.get(t3op2z,arrayplusz3 - 1) and high > array.get(t3op2z, arrayplusz3 - 1) if top2bb3 and top2sellcross3 and startarray top2xx3 := bar_index p3top2bb := true idsrxx = label.new(bar_index, low, "Top Sell IDR X "+str.tostring(top2bb3)+" "+str.tostring(top2xx3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) top2bb3 := false top2sellcross3 := false bool btm2sellcross3 = na btm2sellcross3 := close[1] < array.get(b3tm2z,arrayplusz3 - 1) and high > array.get(b3tm2z, arrayplusz3 - 1) if btm2bb3 and btm2sellcross3 btm2xx3 := bar_index p3btm2bb := true btm2xxlfr = label.new(bar_index, low, "Btm2 Sell IDR X "+str.tostring(btm2xx3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) btm2bb3 := false //btm2sellcross := false bool fib1sellcross3 = na fib1sellcross3 := close[1] < array.get(f3ib1z,arrayplusz3 - 1) and high > array.get(f3ib1z, arrayplusz3 - 1) if fib1bb3 and fib1sellcross3 fib1xx3 := bar_index p3fib1bb := true fidb1xxl = label.new(bar_index, low, "Mid Sell X "+str.tostring(fib1xx3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib1bb3 := false bool fib2sellcross3 = na fib2sellcross3 := close[1] > array.get(f3ib2z,arrayplusz3 - 1) and low < array.get(f3ib2z, arrayplusz3 - 1) if fib2b3 and fib2sellcross3 fib2x3 := bar_index p3fib2b := true fisb2xl = label.new(bar_index, low, "2.5 Sell cross "+str.tostring(fib2x3)+" "+str.tostring(fib2b3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib2b3 := false bool fib9sellcross3 = na fib9sellcross3 := close[1] > array.get(f3ib9z,arrayplusz3 - 1) and low < array.get(f3ib9z, arrayplusz3 - 1) if fib9b3 and fib9sellcross3 fib9x3 := bar_index p3fib9b := true ficb9xl = label.new(bar_index, low, "0.5 Sell X "+str.tostring(fib9x3)+" "+str.tostring(fib9b3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib9b3 := false bool fib10sellcross3 = na fib10sellcross3 := close[1] > array.get(f3ib10z,arrayplusz3 - 1) and low < array.get(f3ib10z, arrayplusz3 - 1) if fib10b3 and fib10sellcross3 fib10x3 := bar_index p3fib10b := true fifb10xl = label.new(bar_index, low, "1 Sell X "+str.tostring(fib10x3)+" "+str.tostring(fib10b3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib10b3 := false bool fib11sellcross3 = na fib11sellcross3 := close[1] > array.get(f3ib11z,arrayplusz3 - 1) and low < array.get(f3ib11z, arrayplusz3 - 1) if fib11b3 and fib11sellcross3 fib11x3 := bar_index p3fib11b := true fifb11xl = label.new(bar_index, low, "1.5 Sell X "+str.tostring(fib11x3)+" "+str.tostring(fib11b3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib11b3 := false bool fib12sellcross3 = na fib12sellcross3 := close[1] > array.get(f3ib12z,arrayplusz3 - 1) and low < array.get(f3ib12z, arrayplusz3 - 1) if fib12b3 and fib12sellcross3 fib12x3 := bar_index p3fib12b := true fidb12xl = label.new(bar_index, low, "2 Sell X "+str.tostring(fib12x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib12b3 := false bool fib13sellcross3 = na fib13sellcross3 := close[1] > array.get(f3ib13z,arrayplusz3 - 1) and low < array.get(f3ib13z, arrayplusz3 - 1) if fib13b3 and fib13sellcross3 fib13x3 := bar_index p3fib13b := true fib13xl = label.new(bar_index, low, "3 Sell X "+str.tostring(fib13x3),style = label.style_cross, color = tycolor2,textcolor = chart.fg_color) fib13b3 := false if array3off candlecolorup3 := false candlecolordown3 := false if array3off and top2b3//and (indate and tytrue) top2b3 :=false p3top2b := false top2x3 := na if array3off and top2bb3 top2bb3 := false// and (indate and tytrue) p3top2bb := false top2xx3 := na if array3off and btm2b3 btm2b3 := false p3btm2b := false btm2x3 := na if array3off and btm2bb3 //and (indate and tytrue) btm2bb3 := false p3btm2bb := false btm2xx3 := na if array3off and fib1b3//and (indate and tytrue) fib1b3 := false p3fib1b := false fib1x3 := na if array3off and fib1bb3 fib1bb3 := false p3fib1bb := false fib1xx3 := na if array3off and fib3b3 fib3b3 := false p3fib3b := false fib3x3 := na if array3off and fib4b3 fib4b3 := false p3fib4b := false fib4x3 := na if array3off and fib5b3 fib5b3 := false p3fib5b := false fib5x3 := na if array3off and fib6b3 fib6b3 := false p3fib6b := false fib6x3 := na if array3off and fib7b3 fib7b3 := false p3fib7b := false fib7x3 := na if array3off and fib8b3 fib8b3 := false p3fib8b := false fib8x3 := na if array3off and fib2b3 fib2b3 := false p3fib2b := false fib2x3 := na if array3off and fib9b3 fib9b3 := false p3fib9b := false fib9x3 := na if array3off and fib10b3 fib10b3 := false p3fib10b := false fib10x3 := na if array3off and fib11b3 fib11b3 := false p3fib11b := false fib11x3 := na if array3off and fib12b3 fib12b3 := false p3fib12b := false fib12x3 := na if array3off and fib13b3 fib13b3 := false p3fib13b := false fib13x3 := na if array3off and bottomb3 bottomb3 := false p3bottomb := false bottomx3 := na if array3off and topb3 topb3 := false p3topb := false topx3 := na if tycleanarray1 and array3off p3top2b := na top2x3 := na p3btm2b := na btm2x3 := na p3fib1b := na fib1x3 := na p3fib3b := na fib3x3 := na p3fib4b := na fib4x3 := na p3fib5b := na fib5x3 := na p3fib6b := na fib6x3 := na p3fib7b := na fib7x3 := na p3fib8b := na fib8x3 := na p3bottomb := na bottomx3 := na if tycleanarray2 and array3off p3top2bb := na top2xx3 := na p3btm2bb := na btm2xx3 := na p3fib1bb := na fib1xx3 := na p3fib2b := na fib2x3 := na p3fib9b := na fib9x3 := na p3fib10b := na fib10x3 := na p3fib11b := na fib11x3 := na p3fib12b := na fib12x3 := na p3fib13b := na fib13x3 := na p3topb := na topx3 := na if array3off and array3 bartimesignal3 := na signaldir3 := "None" if array3off barcount3 := false //{ ipda var dayarrayhi = array.new_float() var dayarraylo = array.new_float() var dayarray_offsethi = array.new_float() var dayarray_offsetlo = array.new_float() var int daycount = 0 hilo_high = request.security(syminfo.tickerid, "D", ta.highest(high,20)) hilo_low = request.security(syminfo.tickerid, "D", ta.lowest(low,20)) hilo_high59 = request.security(syminfo.tickerid, "D", ta.highest(high,59)) hilo_low59 = request.security(syminfo.tickerid, "D", ta.lowest(low,59)) hilo_offsethi = request.security(syminfo.tickerid, "D", ta.highestbars (high,20)) hilo_offsetlo = request.security(syminfo.tickerid, "D", ta.lowestbars (low,20)) hilo_offsethi59 = request.security(syminfo.tickerid, "D", ta.highestbars (high,59)) hilo_offsetlo59 = request.security(syminfo.tickerid, "D", ta.lowestbars (low,59)) float hilo_44_hi = na float hilo_44_lo = na float hilo_44_offsethi = na float hilo_44_offsetlo = na float hilo_22_hi = na float hilo_22_lo = na float hilo_22_offsethi = na float hilo_22_offsetlo = na float hilo_68_hi = na float hilo_68_lo = na float hilo_68_offsethi = na float hilo_68_offsetlo = na float ipda = na float offset = na colorfg = chart.fg_color //} if time == time("", "0000-0005", "GMT-5") daycount += 1 array.push(dayarrayhi, hilo_high) array.push(dayarraylo, hilo_low) array.push(dayarray_offsethi, hilo_offsethi) array.push(dayarray_offsetlo, hilo_offsetlo) if barstate.islastconfirmedhistory and ipdaon hilo_22_hi := array.get(dayarrayhi, daycount - 1) hilo_22_lo := array.get(dayarraylo, daycount - 1) hilo_22_offsethi := array.get(dayarray_offsethi, daycount - 1) hilo_22_offsetlo := array.get(dayarray_offsetlo, daycount - 1) hilo_22_offsethi := hilo_22_offsethi - 1 hilo_22_offsetlo := hilo_22_offsetlo - 1 high22_line = line.new(bar_index,hilo_22_hi,bar_index[1],hilo_22_hi,xloc.bar_index,extend = extend.both,color = color.new(color.red,30), width = 2) if labelson high22_label = label.new(last_bar_index + 50 ,hilo_22_hi, "20 day High\n"+str.tostring(hilo_22_offsethi)+" Days Since High\n"+str.tostring(hilo_22_hi,format.mintick),color = color.new(color.red,50),textcolor = color.white, size = size.small) low22_line = line.new(bar_index,hilo_22_lo,bar_index[1],hilo_22_lo,xloc.bar_index,extend = extend.both,color = color.new(color.blue,30), width = 2) if labelson low22_label = label.new(last_bar_index + 50 ,hilo_22_lo, "20 day Low\n"+str.tostring(hilo_22_offsetlo)+" Days Since Low\n"+str.tostring(hilo_22_lo,format.mintick),color = color.new(color.blue,50),textcolor = color.white, size = size.small) hilo_44_hi := array.get(dayarrayhi, daycount - 21) hilo_44_lo := array.get(dayarraylo, daycount - 21) hilo_44_offsethi := array.get(dayarray_offsethi, daycount - 21) hilo_44_offsetlo := array.get(dayarray_offsetlo, daycount - 21) hilo_44_offsethi := hilo_44_offsethi - 21 hilo_44_offsetlo := hilo_44_offsetlo - 21 high44_line = line.new(bar_index,hilo_44_hi,bar_index[1],hilo_44_hi,xloc.bar_index,extend = extend.both,color = color.new(color.red,30), width = 2) if labelson high44_label = label.new(last_bar_index + 50 ,hilo_44_hi, "40 day High\n"+str.tostring(hilo_44_offsethi)+" Days Since High\n"+str.tostring(hilo_44_hi,format.mintick),color = color.new(color.red,50),textcolor = color.white, size = size.small) low44_line = line.new(bar_index,hilo_44_lo,bar_index[1],hilo_44_lo,xloc.bar_index,extend = extend.both,color = color.new(color.blue,30), width = 2) if labelson low44_label = label.new(last_bar_index + 50 ,hilo_44_lo, "40 day Low\n"+str.tostring(hilo_44_offsetlo)+" Days Since Low\n"+str.tostring(hilo_44_lo,format.mintick),color = color.new(color.blue,50),textcolor = color.white, size = size.small) hilo_68_hi := array.get(dayarrayhi, daycount - 40) hilo_68_lo := array.get(dayarraylo, daycount - 40) hilo_68_offsethi := array.get(dayarray_offsethi, daycount - 40) hilo_68_offsetlo := array.get(dayarray_offsetlo, daycount - 40) hilo_68_offsethi := hilo_68_offsethi - 40 hilo_68_offsetlo := hilo_68_offsetlo - 40 high68_line = line.new(bar_index,hilo_68_hi,bar_index[1],hilo_68_hi,xloc.bar_index,extend = extend.both,color = color.new(color.red,30), width = 2) if labelson high68_label = label.new(last_bar_index + 50 ,hilo_68_hi, "59 day High\n"+str.tostring(hilo_68_offsethi)+" Days Since High\n"+str.tostring(hilo_68_hi,format.mintick),color = color.new(color.red,50),textcolor = color.white, size = size.small) low68_line = line.new(bar_index,hilo_68_lo,bar_index[1],hilo_68_lo,xloc.bar_index,extend = extend.both,color = color.new(color.blue,30), width = 2) if labelson low68_label = label.new(last_bar_index + 50 ,hilo_68_lo, "59 day Low\n"+str.tostring(hilo_68_offsetlo)+" Days Since Low\n"+str.tostring(hilo_68_lo,format.mintick),color = color.new(color.blue,50),textcolor = color.white, size = size.small) if (hilo_offsethi59 >= hilo_offsetlo59) ipda := hilo_high59 offset := hilo_offsethi59 ipdalinehi = line.new(bar_index[1], ipda, last_bar_index, ipda, extend = extend.both, color = color.new(color.lime,50),width = 5) else if hilo_offsetlo59 >= hilo_offsethi59 ipda := hilo_low59 offset := hilo_offsetlo59 ipdalinelo = line.new(bar_index[1], ipda, last_bar_index, ipda, extend = extend.both, color = color.new(#0bf303, 50),width = 5) ipdalabel = label.new(last_bar_index + 125,ipda, text = "Estimated: "+str.tostring(offset)+" Days Since Quarterly Shift\nEstimated: "+str.tostring(60 + offset)+" Days to next Quarterly Shift",color= colorfg ,style = label.style_label_lower_left,textcolor = chart.bg_color) down = open - (open - close) up = close - (close - open) barcolor(colorcandles and candlecolorup and (close < open) ? color.from_gradient(down, array.get(fib11z, arrayplus1 - 1) , array.get(fib6z, arrayplus1 - 1),tycolor2, nycolor2) : na) barcolor(colorcandles and candlecolorup and (open < close) ? color.from_gradient(up,array.get(fib11z, arrayplus1 - 1),array.get(fib6z, arrayplus1 - 1),tycolor1,ldncolor2) : na) barcolor(colorcandles and candlecolordown and (close < open) ? color.from_gradient(down, array.get(fib11z, arrayplus1 - 1) , array.get(fib6z, arrayplus1 - 1),ldncolor1,nycolor1 ) : na) barcolor(colorcandles and candlecolordown and (open < close) ? color.from_gradient(up,array.get(fib11z, arrayplus1 - 1),array.get(fib6z, arrayplus1 - 1),nycolor2,ldncolor2) : na) barcolor(colorcandles and candlecolorup2 and (close < open) ? color.from_gradient(down, array.get(fib11z, arrayplus2 - 1) , array.get(fib6z, arrayplus2 - 1),tycolor1, nycolor1) : na) barcolor(colorcandles and candlecolorup2 and (open < close) ? color.from_gradient(up,array.get(fib11z, arrayplus2 - 1),array.get(fib6z, arrayplus2 - 1),nycolor2, ldncolor2) : na) barcolor(colorcandles and candlecolordown2 and (close < open) ? color.from_gradient(down, array.get(fib11z, arrayplus2 - 1) , array.get(fib6z, arrayplus2 - 1),ldncolor1,nycolor1 ) : na) barcolor(colorcandles and candlecolordown2 and (open < close) ? color.from_gradient(up,array.get(fib11z, arrayplus2 - 1),array.get(fib6z, arrayplus2 - 1),nycolor2,tycolor1) : na) barcolor(colorcandles and candlecolorup3 and (close < open) ? color.from_gradient(down, array.get(fib11z, arrayplus3 - 1) , array.get(fib6z, arrayplus3 - 1),ldncolor2, ldncolor1) : na) barcolor(colorcandles and candlecolorup3 and (open < close) ? color.from_gradient(up,array.get(fib11z, arrayplus3 - 1),array.get(fib6z, arrayplus3 - 1),tycolor1,nycolor2) : na) barcolor(colorcandles and candlecolordown3 and (close < open) ? color.from_gradient(down, array.get(fib11z, arrayplus3 - 1) , array.get(fib6z, arrayplus3 - 1),ldncolor2,tycolor1 ) : na) barcolor(colorcandles and candlecolordown3 and (open < close) ? color.from_gradient(up,array.get(fib11z, arrayplus3 - 1),array.get(fib6z, arrayplus3 - 1),ldncolor1,tycolor2) : na) //signaldcolorcandles and ir highp lowp 2 3 i3 //NY ALERT if barstate.islast and dataalert and startarray /// alert_text = "Date,sess,symb,DR T,DR B,IDR T,IDR B,sessOO,sessOC,sessCO,sessCC,dayopen,nyC barNo,sigDir,sigbar,highp,lowp,idrbuy,idrbX,midbuy,midbuyx,idrbtmb,idrbtmbX,0.5b,0.5bX,1b,1bX,1.5b,1.5bX,2b,2X,2.5b,2.5X,3b,3bX,BStop,BStopX,idrS,idrSX,midsell,midsellx,idrtopS,idrtopsX,0.5s,0.5sX,1s,1sX,1.5S,1.5sx,2s,2sx,2.5s,2.5sx,3s,3sx,selstop,selstopX;\n" for i = 1 to array.size(dates) - 1 alert_text += str.tostring(array.get(dates , i)) + ","+ str.tostring(array.get(sessionID , i)) + "," + str.tostring(array.get(symbola , i)) + "," + str.tostring(array.get(sesslengtha , i)) + "," + str.tostring(array.get(ptopz , i)) + "," + str.tostring(array.get(pbottomz , i)) + "," + str.tostring(array.get(ptop2z , i)) + "," + str.tostring(array.get(pbtm2z , i)) + "," + str.tostring(array.get(nyopenarray1,i))+ ","+ str.tostring(array.get(nyopenarray2,i))+ ","+ str.tostring(array.get(nyclosearray1,i))+ ","+ str.tostring(array.get(nyclosearray2,i))+ ","+ str.tostring(array.get(nydayopena,i))+ ","+ str.tostring(array.get(nybarindexa, i))+ ","+ str.tostring(array.get(signaldira, i))+ ","+ str.tostring(array.get(signaltimea , i))+ ","+ str.tostring(array.get(highpa, i))+ ","+ str.tostring(array.get(lowpa, i))+ ","+ str.tostring(array.get(top2a, i))+ ","+ str.tostring(array.get(top2xa, i))+ ","+ str.tostring(array.get(fib1a, i))+ ","+ str.tostring(array.get(fib1xa, i))+ ","+ str.tostring(array.get(btm2a, i))+ ","+ str.tostring(array.get(btm2xa, i))+ ","+ str.tostring(array.get(fib4a, i))+ ","+ str.tostring(array.get(fib4xa, i))+ ","+ str.tostring(array.get(fib5a, i))+ ","+ str.tostring(array.get(fib5xa, i))+ ","+ str.tostring(array.get(fib6a, i))+ ","+ str.tostring(array.get(fib6xa, i))+ ","+ str.tostring(array.get(fib7a, i))+ ","+ str.tostring(array.get(fib7xa, i))+ ","+ str.tostring(array.get(fib3a, i))+ ","+ str.tostring(array.get(fib3xa, i))+ ","+ str.tostring(array.get(fib8a, i))+ ","+ str.tostring(array.get(fib8xa, i))+ ","+ str.tostring(array.get(bottoma, i))+ ","+ str.tostring(array.get(bottomxa, i))+ ","+ str.tostring(array.get(btm2aa, i))+ ","+ str.tostring(array.get(btm2xxa, i))+ ","+ str.tostring(array.get(fib1aa, i))+ ","+ str.tostring(array.get(fib1xxa, i))+ ","+ str.tostring(array.get(top2aa, i))+ ","+ str.tostring(array.get(top2xxa, i))+ ","+ str.tostring(array.get(fib9a, i))+ ","+ str.tostring(array.get(fib9xa, i))+ ","+ str.tostring(array.get(fib10a, i))+ ","+ str.tostring(array.get(fib10xa, i))+ ","+ str.tostring(array.get(fib11a, i))+ ","+ str.tostring(array.get(fib11xa, i))+ ","+ str.tostring(array.get(fib12a, i))+ ","+ str.tostring(array.get(fib12xa, i))+ ","+ str.tostring(array.get(fib2a, i))+ ","+ str.tostring(array.get(fib2xa, i))+ ","+ str.tostring(array.get(fib13a, i))+ "," + str.tostring(array.get(fib13xa, i))+ ","+ str.tostring(array.get(topa, i))+ ","+ str.tostring(array.get(topxa, i))+ ";" alert(alert_text, freq = alert.freq_once_per_bar) // LONDON ALERT // if barstate.islast and dataalert and startarray2 // alerttextLDN = "Date,sess,symb,DR T,DR B,IDR T,IDR B,sessOO,sessOC,sessCO,sessCC,dayopen,nyC barNo,sigDir,sigbar,highp,lowp,idrbuy,idrbX,midbuy,midbuyx,idrbtmb,idrbtmbX,0.5b,0.5bX,1b,1bX,1.5b,1.5bX,2b,2X,2.5b,2.5X,3b,3bX,BStop,BStopX,idrS,idrSX,midsell,midsellx,idrtopS,idrtopsX,0.5s,0.5sX,1s,1sX,1.5S,1.5sx,2s,2sx,2.5s,2.5sx,3s,3sx,selstop,selstopX;\n" // for k = 1 to array.size(dates2) - 1 // alerttextLDN += str.tostring(array.get(dates2 , k)) + "," + // str.tostring(array.get(sessionID2 , k)) + "," + // //str.tostring(array.get(symbola , k)) + "," + // str.tostring(array.get(p2topz , k)) + "," + // str.tostring(array.get(p2bottomz , k)) + "," + // str.tostring(array.get(p2top2z , k)) + "," + // str.tostring(array.get(p2btm2z , k)) + "," + // str.tostring(array.get(ldnopenarray1,k))+ ","+ // str.tostring(array.get(ldnopenarray2,k))+ ","+ // str.tostring(array.get(ldnclosearray1,k))+ ","+ // str.tostring(array.get(ldnclosearray2,k))+ ","+ // //str.tostring(array.get(nydayopena,k))+ ","+ // str.tostring(array.get(ldnbarindexa, k))+ ","+ // str.tostring(array.get(signaldira2, k))+ ","+ // str.tostring(array.get(signaltime2, k))+ ","+ // str.tostring(array.get(highpa2, k))+ ","+ // str.tostring(array.get(lowpa2, k))+ ","+ // str.tostring(array.get(top2a2, k))+ ","+ // str.tostring(array.get(top2xa2, k))+ ","+ // str.tostring(array.get(fib1a2, k))+ ","+ // str.tostring(array.get(fib1xa2, k))+ ","+ // str.tostring(array.get(btm2a2, k))+ ","+ // str.tostring(array.get(btm2xa2, k))+ ","+ // str.tostring(array.get(fib4a2, k))+ ","+ // str.tostring(array.get(fib4xa2, k))+ ","+ // str.tostring(array.get(fib5a2, k))+ ","+ // str.tostring(array.get(fib5xa2, k))+ ","+ // str.tostring(array.get(fib6a2, k))+ ","+ // str.tostring(array.get(fib6xa2, k))+ ","+ // str.tostring(array.get(fib7a2, k))+ ","+ // str.tostring(array.get(fib7xa2, k))+ ","+ // str.tostring(array.get(fib3a2, k))+ ","+ // str.tostring(array.get(fib3xa2, k))+ ","+ // str.tostring(array.get(fib8a2, k))+ ","+ // str.tostring(array.get(fib8xa2, k))+ ","+ // str.tostring(array.get(bottoma2, k))+ ","+ // str.tostring(array.get(bottomxa2, k))+ ","+ // str.tostring(array.get(btm2aa2, k))+ ","+ // str.tostring(array.get(btm2xxa2, k))+ ","+ // str.tostring(array.get(fib1aa2, k))+ ","+ // str.tostring(array.get(fib1xxa2, k))+ ","+ // str.tostring(array.get(top2aa2, k))+ ","+ // str.tostring(array.get(top2xxa2, k))+ ","+ // str.tostring(array.get(fib9a2, k))+ ","+ // str.tostring(array.get(fib9xa2, k))+ ","+ // str.tostring(array.get(fib10a2, k))+ ","+ // str.tostring(array.get(fib10xa2, k))+ ","+ // str.tostring(array.get(fib11a2, k))+ ","+ // str.tostring(array.get(fib11xa2, k))+ ","+ // str.tostring(array.get(fib12a2, k))+ ","+ // str.tostring(array.get(fib12xa2, k))+ ","+ // str.tostring(array.get(fib2a2, k))+ ","+ // str.tostring(array.get(fib2xa2, k))+ ","+ // str.tostring(array.get(fib13a2, k))+ "," + // str.tostring(array.get(fib13xa2, k))+ ","+ // str.tostring(array.get(topa2, k))+ ","+ // str.tostring(array.get(topxa2, k))+ ";" // alert(alerttextLDN , freq = alert.freq_once_per_bar) //TOKYO ALERT // if barstate.islast and dataalert // alerttextko = "Date,sess,symb,DR T,DR B,IDR T,IDR B,sessOO,sessOC,sessCO,sessCC,dayopen,nyC barNo,sigDir,sigbar,highp,lowp,idrbuy,idrbX,midbuy,midbuyx,idrbtmb,idrbtmbX,0.5b,0.5bX,1b,1bX,1.5b,1.5bX,2b,2X,2.5b,2.5X,3b,3bX,BStop,BStopX,idrS,idrSX,midsell,midsellx,idrtopS,idrtopsX,0.5s,0.5sX,1s,1sX,1.5S,1.5sx,2s,2sx,2.5s,2.5sx,3s,3sx,selstop,selstopX;\n" // for k = 1 to array.size(dates3) - 1 // alerttextko += str.tostring(array.get(dates3 , k)) + "," + // str.tostring(array.get(sessionID3 , k)) + "," + // str.tostring(array.get(symbola , k)) + "," + // str.tostring(array.get(p3topz , k)) + "," + // str.tostring(array.get(p3bottomz , k)) + "," + // str.tostring(array.get(p3top2z , k)) + "," + // str.tostring(array.get(p3btm2z , k)) + "," + // str.tostring(array.get(tyopenarray1,k))+ ","+ // str.tostring(array.get(tyopenarray2,k))+ ","+ // str.tostring(array.get(tyclosearray1,k))+ ","+ // str.tostring(array.get(tyclosearray2,k))+ ","+ // str.tostring(array.get(nydayopena,k))+ ","+ // str.tostring(array.get(tybarindexa, k))+ ","+ // str.tostring(array.get(signaldira3, k))+ ","+ // str.tostring(array.get(signaltime3, k))+ ","+ // str.tostring(array.get(highpa3, k))+ ","+ // str.tostring(array.get(lowpa3, k))+ ","+ // str.tostring(array.get(top2a3, k))+ ","+ // str.tostring(array.get(top2xa3, k))+ ","+ // str.tostring(array.get(fib1a3, k))+ ","+ // str.tostring(array.get(fib1xa3, k))+ ","+ // str.tostring(array.get(btm2a3, k))+ ","+ // str.tostring(array.get(btm2xa3, k))+ ","+ // str.tostring(array.get(fib4a3, k))+ ","+ // str.tostring(array.get(fib4xa3, k))+ ","+ // str.tostring(array.get(fib5a3, k))+ ","+ // str.tostring(array.get(fib5xa3, k))+ ","+ // str.tostring(array.get(fib6a3, k))+ ","+ // str.tostring(array.get(fib6xa3, k))+ ","+ // str.tostring(array.get(fib7a3, k))+ ","+ // str.tostring(array.get(fib7xa3, k))+ ","+ // str.tostring(array.get(fib3a3, k))+ ","+ // str.tostring(array.get(fib3xa3, k))+ ","+ // str.tostring(array.get(fib8a3, k))+ ","+ // str.tostring(array.get(fib8xa3, k))+ ","+ // str.tostring(array.get(bottoma3, k))+ ","+ // str.tostring(array.get(bottomxa3, k))+ ","+ // str.tostring(array.get(btm2aa3, k))+ ","+ // str.tostring(array.get(btm2xxa3, k))+ ","+ // str.tostring(array.get(fib1aa3, k))+ ","+ // str.tostring(array.get(fib1xxa3, k))+ ","+ // str.tostring(array.get(top2aa3, k))+ ","+ // str.tostring(array.get(top2xxa3, k))+ ","+ // str.tostring(array.get(fib9a3, k))+ ","+ // str.tostring(array.get(fib9xa3, k))+ ","+ // str.tostring(array.get(fib10a3, k))+ ","+ // str.tostring(array.get(fib10xa3, k))+ ","+ // str.tostring(array.get(fib11a3, k))+ ","+ // str.tostring(array.get(fib11xa3, k))+ ","+ // str.tostring(array.get(fib12a3, k))+ ","+ // str.tostring(array.get(fib12xa3, k))+ ","+ // str.tostring(array.get(fib2a3, k))+ ","+ // str.tostring(array.get(fib2xa3, k))+ ","+ // str.tostring(array.get(fib13a3, k))+ "," + // str.tostring(array.get(fib13xa3, k))+ ","+ // str.tostring(array.get(topa3, k))+ ","+ // str.tostring(array.get(topxa3, k))+ ";" // alert(alerttextko, freq = alert.freq_once_per_bar) //save if not sessiontosession if array1off array1 := false if array2off array2 := false if array3off array3 := false if sessiontosession if array1off array2 := false if array2off array3 := false if array3off array1 := false
Price Weighted Volume MA (PWVMA)
https://www.tradingview.com/script/x2esGyO2-Price-Weighted-Volume-MA-PWVMA/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
21
study
5
MPL-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("Price Weighted Volume MA", "PWVMA", false, format.volume, explicit_plot_zorder = true) vma(length = 9, reset = false)=> float price = math.sum(close, length) float vol = math.sum(volume * close, length) var float counter = na counter := session.isfirstbar ? 1 : counter[1] + 1 var float pri = na var float volu = na pri := na(pri[1]) or session.isfirstbar ? close : nz(pri[1]) + close volu := na(volu[1]) or session.isfirstbar ? volume * close : volume * close + nz(volu[1]) reset ? volu/pri : vol/price evma(length = 9, reset = false)=> alpha = 2 / (length + 1) var float smoothed = na var float price = na var float counter = na counter := session.isfirstbar ? 1 : counter[1] + 1 Alpha = reset ? (session.isfirstbar ? 1 : 2 / (counter + 1) ) : alpha price := na(price[1]) or (reset and session.isfirstbar) ? close : Alpha * close + (1 - Alpha) * nz(price[1]) smoothed := na(smoothed[1]) or (reset and session.isfirstbar) ? volume * close : Alpha * (volume * close) + (1 - Alpha) * nz(smoothed[1]) out = smoothed/price select = input.string("VMA", "Select Style", ["VMA","EVMA"]) length = input.int(20, "Length", 2) reset = input.bool(false, "Session Weighting") ma()=> switch select "VMA" => vma(length, reset) "EVMA" => evma(length, reset) plot(volume, "Volume", open < close ? color.new(#26a69a, 30) : color.new(#ef5350, 30), style = plot.style_columns) plot(ma(), "Moving Average", color.blue, 2)
HMA Breakout Buy/Sell indicator for Scalping & Intraday - Shyam
https://www.tradingview.com/script/b4sa4fEj-HMA-Breakout-Buy-Sell-indicator-for-Scalping-Intraday-Shyam/
Shyam_Trades_152
https://www.tradingview.com/u/Shyam_Trades_152/
784
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Shyam_Trades_152 //@version=5 indicator(title="HMA Breakout - Shyam", shorttitle="BO-HMA", overlay=true) var bool bcn = false var bool scn = false var int hma1 = 10 var int hma2 = 20 var int hma3 = 100 t_type = input.string("Scalping","Trade Type",options = ["Scalping","Intraday"]) if t_type == "Scalping" hma1 := 10 hma2 := 20 hma3 := 100 if t_type == "Intraday" hma1 := 20 hma2 := 50 hma3 := 100 ma1 = ta.hma(close,hma1) ma2 = ta.hma(close,hma2) ma3 = ta.hma(close,hma3) l_avg = math.avg(ma1,ma2,ma3) l_col = color.gray //---------------------------- Buy Condition ----------------------------// if ma3 < ma2 and ma3 < ma1 and ma1 > ma2 bcn := true l_col := color.rgb(7, 249, 15) //---------------------------- Sell Condition ----------------------------// if ma3 > ma2 and ma3 > ma1 and ma2 > ma1 scn := true l_col :=color.rgb(247, 8, 8) plot(ma3,color = l_col,linewidth = 2)
Multi-timeframe Harmonic Patterns
https://www.tradingview.com/script/zTQCyFNk-Multi-timeframe-Harmonic-Patterns/
dandrideng
https://www.tradingview.com/u/dandrideng/
1,265
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © dandrideng // ══════════════════════════════════════════════════════════════════════════════════════════════════ // //# * ══════════════════════════════════════════════════════════════════════════════════════════════ //# * //# * Study : Multi-timeframe Harmonic Patterns //# * Author : © dandri deng //# * //# * Revision History //# * Initial : Nov. 24, 2022 Fist release version //# * Update : Dec. 30, 2022 Fist public version //# * //# * ══════════════════════════════════════════════════════════════════════════════════════════════ // ══════════════════════════════════════════════════════════════════════════════════════════════════ // //@version=5 indicator("Multi-timeframe Harmonic Patterns", shorttitle="MTF Harmonic Patterns", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=500, max_bars_back=2000) // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // ZigZag Functions -------------------------------------------------------------------------------- // //calculate zigzag calculate_zigzag(simple string resolution, simple int period, float hsrc, float lsrc, int max_pivots) => newbar = ta.change(time(resolution)) != 0 bi = ta.valuewhen(newbar, bar_index, period - 1) len = bar_index - bi + 1 float ph = na float pl = na ph := ta.highestbars(hsrc, nz(len, 1)) == 0 ? hsrc : na pl := ta.lowestbars(lsrc, nz(len, 1)) == 0 ? lsrc : na var dir = 0 dir := ph and na(pl) ? 1 : pl and na(ph) ? -1 : dir var zigzag = array.new_float(0) oldzigzag = array.copy(zigzag) bool dirchanged = (dir != dir[1]) if ph or pl if dirchanged bindex = bar_index value = dir == 1 ? ph : pl array.unshift(zigzag, bindex) array.unshift(zigzag, value) if array.size(zigzag) > max_pivots array.pop(zigzag) array.pop(zigzag) else bindex = bar_index value = dir == 1 ? ph : pl if array.size(zigzag) == 0 array.unshift(zigzag, bindex) array.unshift(zigzag, value) if array.size(zigzag) > max_pivots array.pop(zigzag) array.pop(zigzag) else if (dir == 1 and value > array.get(zigzag, 0)) or (dir == -1 and value < array.get(zigzag, 0)) array.set(zigzag, 0, value) array.set(zigzag, 1, bindex) [zigzag, oldzigzag, dir] //is new zigzag is_newzigzag(float[] zigzag, float[] oldzigzag) => res = false if array.size(zigzag) >= 4 and array.size(oldzigzag) >= 4 cond1 = array.get(zigzag, 0) != array.get(oldzigzag, 0) or array.get(zigzag, 1) != array.get(oldzigzag, 1) cond2 = array.get(zigzag, 2) == array.get(oldzigzag, 2) and array.get(zigzag, 3) == math.round(array.get(oldzigzag, 3)) res := cond1 and cond2 res // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // 5-point Harmonic Pattern Functions ------------------------------------------------------------- // //draw trading lines draw_trading_lines(draw, start_barindex, entry_price, stop_loss, take_profit1, take_profit2, coluor, horizontal_length) => var line line_ep = na var line line_sl = na var line line_tp1 = na var line line_tp2 = na var label label_ep = na var label label_sl = na var label label_tp1 = na var label label_tp2 = na if draw line.delete(line_ep) line.delete(line_sl) line.delete(line_tp1) line.delete(line_tp2) label.delete(label_ep) label.delete(label_sl) label.delete(label_tp1) label.delete(label_tp2) line_ep := line.new(x1=start_barindex, y1=entry_price, x2=start_barindex + horizontal_length, y2=entry_price, style=line.style_dashed, color=color.new(coluor, 30), width=2) line_sl := line.new(x1=start_barindex, y1=stop_loss, x2=start_barindex + horizontal_length, y2=stop_loss, style=line.style_dashed, color=color.new(coluor, 30), width=2) line_tp1 := line.new(x1=start_barindex, y1=take_profit1, x2=start_barindex + horizontal_length, y2=take_profit1, style=line.style_dashed, color=color.new(coluor, 30), width=2) line_tp2 := line.new(x1=start_barindex, y1=take_profit2, x2=start_barindex + horizontal_length, y2=take_profit2, style=line.style_dashed, color=color.new(coluor, 30), width=2) label_ep := label.new(x=start_barindex + horizontal_length + 1, y=entry_price, style=label.style_label_left, text="ENT: " + str.tostring(entry_price), color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) label_sl := label.new(x=start_barindex + horizontal_length + 1, y=stop_loss, style=label.style_label_left, text="SL: " + str.tostring(stop_loss), color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) label_tp1 := label.new(x=start_barindex + horizontal_length + 1, y=take_profit1, style=label.style_label_left, text="TP1: " + str.tostring(take_profit1), color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) label_tp2 := label.new(x=start_barindex + horizontal_length + 1, y=take_profit2, style=label.style_label_left, text="TP2: " + str.tostring(take_profit2), color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) 0 else if not na(label_ep) and (bar_index - label.get_x(label_ep)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_ep) line.delete(line_sl) line.delete(line_tp1) line.delete(line_tp2) label.delete(label_ep) label.delete(label_sl) label.delete(label_tp1) label.delete(label_tp2) 0 //draw harmonic pattern draw_harmonic_pattern(draw, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) => var line line_XA = na var line line_AB = na var line line_XB = na var line line_BC = na var line line_CD = na var line line_BD = na var line line_XD = na var line line_AC = na var label label_X = na var label label_A = na var label label_B = na var label label_C = na var label label_D = na var label label_XB = na var label label_BD = na var label label_AC = na var label label_XD = na if draw line.delete(line_XA) line.delete(line_AB) line.delete(line_XB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_XD) line.delete(line_AC) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_XB) label.delete(label_BD) label.delete(label_AC) label.delete(label_XD) line_XA := line.new(x1=Xx, y1=Xy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=2) line_AB := line.new(x1=Ax, y1=Ay, x2=Bx, y2=By, color=color.new(coluor, 30), width=2) line_XB := line.new(x1=Xx, y1=Xy, x2=Bx, y2=By, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_BC := line.new(x1=Bx, y1=By, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2) line_CD := line.new(x1=Cx, y1=Cy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=2) line_BD := line.new(x1=Bx, y1=By, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_XD := line.new(x1=Xx, y1=Xy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_AC := line.new(x1=Ax, y1=Ay, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=1, style=line.style_dotted) linefill.new(line_XA, line_XB, color=color.new(coluor, 80)) linefill.new(line_BC, line_BD, color=color.new(coluor, 80)) duration = ((Dx - Xx) * timeframe.multiplier) / (60.0 * 24.0) tooltip = "timeframe: " + reso + "\n" + "pattern: " + name + "\n" + "duration: " + str.tostring(duration, "#.###") + " Day" + "\n" + "trendy: " + (trendy ? "true" : "false") + "\n" label_X := label.new(x=Xx, y=Xy, text="X", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_A := label.new(x=Ax, y=Ay, text="A", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_B := label.new(x=Bx, y=By, text="B", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_C := label.new(x=Cx, y=Cy, text="C", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_D := label.new(x=Dx, y=Dy, text="D", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) label_XB := label.new(x=int((Xx + Bx) / 2), y=(Xy + By) / 2, text=str.tostring(AB / XA, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_BD := label.new(x=int((Bx + Dx) / 2), y=(By + Dy) / 2, text=str.tostring(CD / BC, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_AC := label.new(x=int((Ax + Cx) / 2), y=(Ay + Cy) / 2, text=str.tostring(BC / AB, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_XD := label.new(x=int((Xx + Dx) / 2), y=(Xy + Dy) / 2, text=str.tostring(AD / XA, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) 0 else if not na(label_D) and (bar_index - label.get_x(label_D)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_XA) line.delete(line_AB) line.delete(line_XB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_XD) line.delete(line_AC) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_XB) label.delete(label_BD) label.delete(label_AC) label.delete(label_XD) 0 //get 5-points get_5_points(zigzag, oldzigzag, zigzagdir, confirm) => if array.size(zigzag) >= 10 and ta.barssince(is_newzigzag(zigzag, oldzigzag)) == confirm Xx = math.round(array.get(zigzag, 9)) Xy = array.get(zigzag, 8) Xd = zigzagdir[bar_index - Xx] Ax = math.round(array.get(zigzag, 7)) Ay = array.get(zigzag, 6) Ad = zigzagdir[bar_index - Ax] Bx = math.round(array.get(zigzag, 5)) By = array.get(zigzag, 4) Bd = zigzagdir[bar_index - Bx] Cx = math.round(array.get(zigzag, 3)) Cy = array.get(zigzag, 2) Cd = zigzagdir[bar_index - Cx] Dx = math.round(array.get(zigzag, 1)) Dy = array.get(zigzag, 0) Dd = zigzagdir[bar_index - Dx] [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] else [na, na, na, na, na, na, na, na, na, na, na, na, na, na, na] //gartlay pattern gartlay_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.518 and AB / XA <= 0.718 //best 0.618 (±0.1) cond2 = BC / AB >= 0.382 and BC / AB <= 0.886 cond3 = CD / BC >= 1.272 and CD / BC <= 1.618 cond4 = AD / XA >= 0.686 and AD / XA <= 0.886 //best 0.786 (±0.1) cond5 = CD / AB >= 0.800 and CD / AB <= 1.200 //best 1 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + AD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Gartlay " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //cypher pattern cypher_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.382 and AB / XA <= 0.618 cond2 = XC / XA >= 1.272 and XC / XA <= 1.414 cond3 = CD / XC >= 0.686 and CD / XC <= 0.886 //best 0.786 (±0.1) cond4 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Cypher " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //bat pattern bat_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.382 and AB / XA <= 0.500 cond2 = BC / AB >= 0.382 and BC / AB <= 0.886 cond3 = CD / BC >= 1.618 and CD / BC <= 2.618 cond4 = AD / XA >= 0.786 and AD / XA <= 0.986 //best 0.886 (±0.1) cond5 = CD / AB >= 1.072 and CD / AB <= 1.472 //best 1.272 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + AD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Bat " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //deepcrab pattern deepcrab_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.786 and AB / XA <= 0.986 // best 0.886 (±0.1) cond2 = BC / AB >= 0.382 and BC / AB <= 0.886 cond3 = CD / BC >= 2.242 and CD / BC <= 3.618 cond4 = AD / XA >= 1.518 and AD / XA <= 1.718 //best 1.618 (±0.1) cond5 = CD / AB >= 1.072 and CD / AB <= 1.818 //best 1.272-1.618 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + AD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "DeepCrab " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //crab pattern crab_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.382 and AB / XA <= 0.618 cond2 = BC / AB >= 0.382 and BC / AB <= 0.886 cond3 = CD / BC >= 2.242 and CD / BC <= 3.618 cond4 = AD / XA >= 1.518 and AD / XA <= 1.718 //best 1.618 (±0.1) cond5 = CD / AB >= 1.072 and CD / AB <= 1.818 //best 1.272-1.618 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + AD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Crab " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //butterfly pattern butterfly_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.686 and AB / XA <= 0.886 //best 0.786 (±0.1) cond2 = BC / AB >= 0.382 and BC / AB <= 0.886 cond3 = CD / BC >= 1.618 and CD / BC <= 2.618 cond4 = AD / XA >= 1.272 and AD / XA <= 1.618 cond5 = CD / AB >= 0.800 and CD / AB <= 1.472 //best 1-1.272 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + AD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Butterfly " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //shark pattern shark_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.382 and AB / XA <= 0.618 cond2 = BC / AB >= 1.130 and BC / AB <= 1.618 cond3 = CD / BC >= 1.618 and CD / BC <= 2.240 cond4 = CD / XC >= 0.886 and CD / XC <= 1.130 cond5 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Shark " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //anti-gartlay pattern anti_gartlay_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = BC / CD >= 0.518 and BC / CD <= 0.718 //best 0.618 (±0.1) cond2 = AB / BC >= 0.382 and AB / BC <= 0.886 cond3 = XA / AB >= 1.272 and XA / AB <= 1.618 cond4 = XC / CD >= 0.686 and XC / CD <= 0.886 //best 0.786 (±0.1) cond5 = XA / BC >= 0.800 and XA / BC <= 1.200 //best 1 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Anti-Gartlay " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //anti cypher pattern anti_cypher_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = BC / CD >= 0.382 and BC / CD <= 0.618 cond2 = AD / CD >= 1.272 and AD / CD <= 1.414 cond3 = XA / AD >= 0.686 and XA / AD <= 0.886 //best 0.786 (±0.1) cond4 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 entry_price = Dy stop_loss = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + AD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Anti-Cypher " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //anti_bat pattern anti_bat_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = BC / CD >= 0.382 and BC / CD <= 0.500 cond2 = AB / BC >= 0.382 and AB / BC <= 0.886 cond3 = XA / AB >= 1.618 and XA / AB <= 2.618 cond4 = XC / CD >= 0.786 and XC / CD <= 0.986 //best 0.886 (±0.1) cond5 = XA / BC >= 1.072 and XA / BC <= 1.472 //best 1.272 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Anti-Bat " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //anti crab pattern anti_crab_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = BC / CD >= 0.382 and BC / CD <= 0.618 cond2 = AB / BC >= 0.382 and AB / BC <= 0.886 cond3 = XA / AB >= 2.242 and XA / AB <= 3.618 cond4 = XC / CD >= 1.518 and XC / CD <= 1.718 //best 1.618 (±0.1) cond5 = XA / BC >= 1.072 and XA / BC <= 1.818 //best 1.272-1.618 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Anti-Crab " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //anti butterfly pattern anti_butterfly_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = BC / CD >= 0.686 and BC / CD <= 0.886 //best 0.786 (±0.1) cond2 = AB / BC >= 0.382 and AB / BC <= 0.886 cond3 = XA / AB >= 1.618 and XA / AB <= 2.618 cond4 = XC / CD >= 1.272 and XC / CD <= 1.618 cond5 = XA / BC >= 0.800 and XA / BC <= 1.472 //best 1-1.272 (±0.2) cond6 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Anti-Butterfly " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //anti shark pattern anti_shark_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cond1 = BC / CD >= 0.382 and BC / CD <= 0.618 cond2 = AB / BC >= 1.130 and AB / BC <= 1.618 cond3 = XA / AB >= 1.618 and XA / AB <= 2.240 cond4 = XA / AD >= 0.886 and XA / AD <= 1.130 cond5 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 entry_price = Dy stop_loss = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + AD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + AD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Anti-Shark " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //black swan pattern black_swan_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XB = math.abs(Xy - By) XC = math.abs(Xy - Cy) XD = math.abs(Xy - Dy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _XD = math.abs(Xx - Dx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 0.382 and AB / XA <= 0.724 cond2 = BC / AB >= 2.000 and BC / AB <= 4.237 cond3 = CD / BC >= 0.500 and CD / BC <= 0.886 cond4 = CD / XC >= 0.382 and CD / XC <= 0.886 cond5 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond6 = XB / _XB >= XD / _XD cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "Black-Swan " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] //white swan pattern white_swan_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XB = math.abs(Xy - By) XC = math.abs(Xy - Cy) XD = math.abs(Xy - Dy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _XD = math.abs(Xx - Dx) _BD = math.abs(Bx - Dx) cond1 = AB / XA >= 1.382 and AB / XA <= 2.618 cond2 = BC / AB >= 0.236 and BC / AB <= 0.500 cond3 = CD / BC >= 1.128 and CD / BC <= 2.000 cond4 = AD / XA >= 1.128 and AD / XA <= 2.618 cond5 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond6 = XB / _XB <= XD / _XD cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = Dy stop_loss = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "White-Swan " + (Dd == 1 ? "▼" : "▲") draw_harmonic_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // 0-5 Harmonic Pattern Functions ------------------------------------------------------------------ // //draw 0-5 pattern draw_05_pattern(draw, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) => var line line_ZX = na var line line_XA = na var line line_AB = na var line line_XB = na var line line_BC = na var line line_CD = na var line line_BD = na var line line_ZA = na var line line_AC = na var label label_Z = na var label label_X = na var label label_A = na var label label_B = na var label label_C = na var label label_D = na var label label_ZA = na var label label_XB = na var label label_BD = na var label label_AC = na if draw line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_XB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_ZA) line.delete(line_AC) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_ZA) label.delete(label_XB) label.delete(label_BD) label.delete(label_AC) duration = ((Dx - Zx) * timeframe.multiplier) / (60.0 * 24.0) tooltip = "timeframe: " + reso + "\n" + "pattern: " + name + "\n" + "duration: " + str.tostring(duration, "#.###") + " Day" + "\n" + "trendy: " + (trendy ? "true" : "false") + "\n" line_ZX := line.new(x1=Zx, y1=Zy, x2=Xx, y2=Xy, color=color.new(coluor, 30), width=2, style=line.style_dotted) line_XA := line.new(x1=Xx, y1=Xy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=2) line_AB := line.new(x1=Ax, y1=Ay, x2=Bx, y2=By, color=color.new(coluor, 30), width=2) line_XB := line.new(x1=Xx, y1=Xy, x2=Bx, y2=By, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_BC := line.new(x1=Bx, y1=By, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2) line_CD := line.new(x1=Cx, y1=Cy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=2) line_BD := line.new(x1=Bx, y1=By, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_ZA := line.new(x1=Zx, y1=Zy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_AC := line.new(x1=Ax, y1=Ay, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=1, style=line.style_dotted) linefill.new(line_XA, line_XB, color=color.new(coluor, 80)) linefill.new(line_BC, line_BD, color=color.new(coluor, 80)) label_Z := label.new(x=Zx, y=Zy, text="0", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_X := label.new(x=Xx, y=Xy, text="X", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_A := label.new(x=Ax, y=Ay, text="A", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_B := label.new(x=Bx, y=By, text="B", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_C := label.new(x=Cx, y=Cy, text="C", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_D := label.new(x=Dx, y=Dy, text="D", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) label_ZA := label.new(x=int((Zx + Ax) / 2), y=(Zy + Ay) / 2, text=str.tostring(XA / ZX, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_XB := label.new(x=int((Xx + Bx) / 2), y=(Xy + By) / 2, text=str.tostring(AB / XA, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_BD := label.new(x=int((Bx + Dx) / 2), y=(By + Dy) / 2, text=str.tostring(CD / BC, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_AC := label.new(x=int((Ax + Cx) / 2), y=(Ay + Cy) / 2, text=str.tostring(BC / AB, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) 0 else if not na(label_D) and (bar_index - label.get_x(label_D)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_XB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_ZA) line.delete(line_AC) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_ZA) label.delete(label_XB) label.delete(label_BD) label.delete(label_AC) 0 //get 6-points get_6_points(zigzag, oldzigzag, zigzagdir, confirm) => if array.size(zigzag) >= 12 and ta.barssince(is_newzigzag(zigzag, oldzigzag)) == confirm Zx = math.round(array.get(zigzag, 11)) Zy = array.get(zigzag, 10) Zd = zigzagdir[bar_index - Zx] Xx = math.round(array.get(zigzag, 9)) Xy = array.get(zigzag, 8) Xd = zigzagdir[bar_index - Xx] Ax = math.round(array.get(zigzag, 7)) Ay = array.get(zigzag, 6) Ad = zigzagdir[bar_index - Ax] Bx = math.round(array.get(zigzag, 5)) By = array.get(zigzag, 4) Bd = zigzagdir[bar_index - Bx] Cx = math.round(array.get(zigzag, 3)) Cy = array.get(zigzag, 2) Cd = zigzagdir[bar_index - Cx] Dx = math.round(array.get(zigzag, 1)) Dy = array.get(zigzag, 0) Dd = zigzagdir[bar_index - Dx] [Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] else [na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na] //0-5 Pattern zero5_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_6_points(zigzag, oldzigzag, zigzagdir, confirm) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) cond1 = XA / ZX >= 0.130 and XA / ZX <= 0.618 cond2 = AB / XA >= 1.130 and AB / XA <= 1.618 cond3 = BC / AB >= 1.618 and BC / AB <= 2.24 cond4 = CD / BC >= 0.400 and CD / BC <= 0.600 // best 0.5(±0.1) cond5 = CD / AB >= 0.800 and CD / AB <= 1.200 // best 1(±0.2) cond = cond1 and cond2 and cond3 and cond4 and cond5 entry_price = Dy stop_loss = math.round_to_mintick(Cy + BC * 0.782 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = Dd == 1 ? Xy > Dy : Xy < Dy name = "0-5 " + (Dd == 1 ? "▼" : "▲") draw_05_pattern(cond and show_pattern, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // AB=CD Pattern Functions ---------------------------------------------------------------------- // //draw abcd pattern draw_abcd_pattern(draw, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) => var line line_AB = na var line line_BC = na var line line_CD = na var line line_BD = na var line line_AC = na var label label_A = na var label label_B = na var label label_C = na var label label_D = na var label label_BD = na var label label_AC = na if draw line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_AC) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_BD) label.delete(label_AC) duration = ((Dx - Ax) * timeframe.multiplier) / (60.0 * 24.0) tooltip = "timeframe: " + reso + "\n" + "pattern: " + name + "\n" + "duration: " + str.tostring(duration, "#.###") + " Day" + "\n" + "trendy: " + (trendy ? "true" : "false") + "\n" line_AB := line.new(x1=Ax, y1=Ay, x2=Bx, y2=By, color=color.new(coluor, 30), width=2) line_BC := line.new(x1=Bx, y1=By, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2) line_CD := line.new(x1=Cx, y1=Cy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=2) line_BD := line.new(x1=Bx, y1=By, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_AC := line.new(x1=Ax, y1=Ay, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=1, style=line.style_dotted) label_A := label.new(x=Ax, y=Ay, text="A", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) label_B := label.new(x=Bx, y=By, text="B", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) label_C := label.new(x=Cx, y=Cy, text="C", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) label_D := label.new(x=Dx, y=Dy, text="D", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10)) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) label_BD := label.new(x=int((Bx + Dx) / 2), y=(By + Dy) / 2, text=str.tostring(CD / BC, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_AC := label.new(x=int((Ax + Cx) / 2), y=(Ay + Cy) / 2, text=str.tostring(BC / AB, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) 0 else if not na(label_D) and (bar_index - label.get_x(label_D)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_AC) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_BD) label.delete(label_AC) 0 //get 4-points get_4_points(zigzag, oldzigzag, zigzagdir, confirm) => if array.size(zigzag) >= 8 and ta.barssince(is_newzigzag(zigzag, oldzigzag)) == confirm Ax = math.round(array.get(zigzag, 7)) Ay = array.get(zigzag, 6) Ad = zigzagdir[bar_index - Ax] Bx = math.round(array.get(zigzag, 5)) By = array.get(zigzag, 4) Bd = zigzagdir[bar_index - Bx] Cx = math.round(array.get(zigzag, 3)) Cy = array.get(zigzag, 2) Cd = zigzagdir[bar_index - Cx] Dx = math.round(array.get(zigzag, 1)) Dy = array.get(zigzag, 0) Dd = zigzagdir[bar_index - Dx] [Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] else [na, na, na, na, na, na, na, na, na, na, na, na] //AB=CD Pattern abcd_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_4_points(zigzag, oldzigzag, zigzagdir, confirm) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) _AB = math.abs(Ax - Bx) _CD = math.abs(Cx - Dx) cond1 = BC / AB >= 0.518 and BC / AB <= 0.718 // best 0.618(±0.1) cond2 = CD / BC >= 1.518 and CD / BC <= 1.718 // best 1.618(±0.1) cond3 = CD / AB >= 0.800 and CD / AB <= 1.200 // best 1(±0.2) cond4 = _CD / _AB >= 0.800 and _CD / _AB <= 1.200 // best 1(±0.2) cond = cond1 and cond2 and cond3 and cond4 entry_price = Dy stop_loss = math.round_to_mintick(By + BC * 1.000 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = false name = "AB=CD " + (Dd == 1 ? "▼" : "▲") draw_abcd_pattern(cond and show_pattern, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // 3-Drives Pattern Functions ---------------------------------------------------------------------- // //draw 3-Drives pattern draw_threedrives_pattern(draw, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) => var line line_ZX = na var line line_XA = na var line line_AB = na var line line_XB = na var line line_BC = na var line line_CD = na var line line_BD = na var line line_ZA = na var line line_AC = na var label label_Z = na var label label_X = na var label label_A = na var label label_B = na var label label_C = na var label label_D = na var label label_ZA = na var label label_XB = na var label label_BD = na var label label_AC = na if draw line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_XB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_ZA) line.delete(line_AC) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_ZA) label.delete(label_XB) label.delete(label_BD) label.delete(label_AC) duration = ((Dx - Zx) * timeframe.multiplier) / (60.0 * 24.0) tooltip = "timeframe: " + reso + "\n" + "pattern: " + name + "\n" + "duration: " + str.tostring(duration, "#.###") + " Day" + "\n" + "trendy: " + (trendy ? "true" : "false") + "\n" line_ZX := line.new(x1=Zx, y1=Zy, x2=Xx, y2=Xy, color=color.new(coluor, 30), width=2, style=line.style_dotted) line_XA := line.new(x1=Xx, y1=Xy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=2) line_AB := line.new(x1=Ax, y1=Ay, x2=Bx, y2=By, color=color.new(coluor, 30), width=2) line_XB := line.new(x1=Xx, y1=Xy, x2=Bx, y2=By, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_BC := line.new(x1=Bx, y1=By, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2) line_CD := line.new(x1=Cx, y1=Cy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=2) line_BD := line.new(x1=Bx, y1=By, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_ZA := line.new(x1=Zx, y1=Zy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_AC := line.new(x1=Ax, y1=Ay, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=1, style=line.style_dotted) label_Z := label.new(x=Zx, y=Zy, text="0", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_X := label.new(x=Xx, y=Xy, text="X", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_A := label.new(x=Ax, y=Ay, text="A", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_B := label.new(x=Bx, y=By, text="B", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_C := label.new(x=Cx, y=Cy, text="C", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_D := label.new(x=Dx, y=Dy, text="D", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) label_ZA := label.new(x=int((Zx + Ax) / 2), y=(Zy + Ay) / 2, text=str.tostring(XA / ZX, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_XB := label.new(x=int((Xx + Bx) / 2), y=(Xy + By) / 2, text=str.tostring(AB / XA, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_BD := label.new(x=int((Bx + Dx) / 2), y=(By + Dy) / 2, text=str.tostring(CD / BC, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_AC := label.new(x=int((Ax + Cx) / 2), y=(Ay + Cy) / 2, text=str.tostring(BC / AB, "#.###"), style=label.style_label_center, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) 0 else if not na(label_D) and (bar_index - label.get_x(label_D)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_XB) line.delete(line_BC) line.delete(line_CD) line.delete(line_BD) line.delete(line_ZA) line.delete(line_AC) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) label.delete(label_ZA) label.delete(label_XB) label.delete(label_BD) label.delete(label_AC) 0 //3-Drive Pattern threedrives_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_6_points(zigzag, oldzigzag, zigzagdir, confirm) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) _ZX = math.abs(Zx - Xx) _AB = math.abs(Ax - Bx) _CD = math.abs(Cx - Dx) cond1 = XA / ZX >= 0.518 and XA / ZX <= 0.718 // best 0.618(±0.1) cond2 = BC / AB >= 0.518 and BC / AB <= 0.718 // best 0.618(±0.1) cond3 = AB / XA >= 1.518 and AB / XA <= 1.718 // best 1.618(±0.1) cond4 = CD / BC >= 1.518 and CD / BC <= 1.718 // best 1.618(±0.1) cond5 = AB / ZX >= 0.800 and AB / ZX <= 1.200 // best 1(±0.2) cond6 = CD / AB >= 0.800 and CD / AB <= 1.200 // best 1(±0.2) cond7 = _AB / _ZX >= 0.800 and _AB / _ZX <= 1.200 // best 1(±0.2) cond8 = _CD / _AB >= 0.800 and _CD / _AB <= 1.200 // best 1(±0.2) cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 and cond7 and cond8 entry_price = Dy stop_loss = math.round_to_mintick(By + BC * 1.000 * (Dd == 1 ? 1 : -1)) take_profit1 = math.round_to_mintick(Dy + CD * 0.382 * (Dd == 1 ? -1 : 1)) take_profit2 = math.round_to_mintick(Dy + CD * 0.618 * (Dd == 1 ? -1 : 1)) coluor = Dd == 1 ? bearcolor : bullcolor trendy = false name = "Three-Drives " + (Dd == 1 ? "▼" : "▲") draw_threedrives_pattern(cond and show_pattern, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, -Dd, trendy] // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // Triangle Pattern Functions ---------------------------------------------------------------------- // //draw triangle pattern draw_triangle_pattern(draw, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) => var line line_ZX = na var line line_XA = na var line line_AB = na var line line_BC = na var line line_CD = na var label label_Z = na var label label_X = na var label label_A = na var label label_B = na var label label_C = na var label label_D = na var line line_XN = na var line line_MC = na if draw line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) line.delete(line_XN) line.delete(line_MC) duration = ((Dx - Zx) * timeframe.multiplier) / (60.0 * 24.0) tooltip = "timeframe: " + reso + "\n" + "pattern: " + name + "\n" + "duration: " + str.tostring(duration, "#.###") + " Day" + "\n" + "trendy: " + (trendy ? "true" : "false") + "\n" line_ZX := line.new(x1=Zx, y1=Zy, x2=Xx, y2=Xy, color=color.new(coluor, 30), width=2) line_XA := line.new(x1=Xx, y1=Xy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=2) line_AB := line.new(x1=Ax, y1=Ay, x2=Bx, y2=By, color=color.new(coluor, 30), width=2) line_BC := line.new(x1=Bx, y1=By, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2) line_CD := line.new(x1=Cx, y1=Cy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=2) label_Z := label.new(x=Zx, y=Zy, text="0", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_X := label.new(x=Xx, y=Xy, text="X", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_A := label.new(x=Ax, y=Ay, text="A", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_B := label.new(x=Bx, y=By, text="B", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_C := label.new(x=Cx, y=Cy, text="C", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_D := label.new(x=Dx, y=Dy, text="D", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) xb_a = (Xy - By) / (Xx - Bx) xb_b = Xy - xb_a * Xx ac_a = (Ay - Cy) / (Ax - Cx) ac_b = Ay - ac_a * Ax cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx zx_a = (Zy - Xy) / (Zx - Xx) zx_b = Zy - zx_a * Zx Mx = math.floor(-(zx_b - ac_b) / (zx_a - ac_a)) My = Mx * zx_a + zx_b Nx = math.ceil(-(cd_b - xb_b) / (cd_a - xb_a)) Ny = Nx * cd_a + cd_b line_XN := line.new(x1=Xx, y1=Xy, x2=Nx, y2=Ny, color=color.new(coluor, 30), width=2, style=line.style_dotted) line_MC := line.new(x1=Mx, y1=My, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2, style=line.style_dotted) linefill.new(line_XN, line_MC, color=color.new(coluor, 80)) 0 else if not na(label_D) and (bar_index - label.get_x(label_D)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) line.delete(line_XN) line.delete(line_MC) 0 //descending triangle desc_triangle_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_6_points(zigzag, oldzigzag, zigzagdir, confirm) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) xb_a = (Xy - By) / (Xx - Bx) xb_b = Xy - xb_a * Xx ac_a = (Ay - Cy) / (Ax - Cx) ac_b = Ay - ac_a * Ax cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx zx_a = (Zy - Xy) / (Zx - Xx) zx_b = Zy - zx_a * Zx Mx = math.floor(-(zx_b - ac_b) / (zx_a - ac_a)) My = Mx * zx_a + zx_b Nx = math.ceil(-(cd_b - xb_b) / (cd_a - xb_a)) Ny = Nx * cd_a + cd_b cond = false if Dd == 1 cond1 = XA / ZX >= 0.328 and XA / ZX <= 0.886 cond2 = AB / XA >= 0.618 and AB / XA <= 0.886 cond3 = BC / AB >= 1.130 and BC / AB <= 1.618 cond4 = CD / BC >= 1.242 and CD / BC <= 1.382 cond5 = Zy <= My and Dy >= Ny cond6 = ac_a < 0 and xb_a < 0 and xb_a / ac_a > 1 cond := cond1 and cond2 and cond3 and cond4 and cond5 and cond6 else cond1 = XA / ZX >= 0.328 and XA / ZX <= 0.886 cond2 = AB / XA >= 1.130 and AB / XA <= 1.618 cond3 = BC / AB >= 0.618 and BC / AB <= 0.886 cond4 = CD / BC >= 1.242 and CD / BC <= 1.382 cond5 = Zy >= My and Dy <= Ny cond6 = ac_a < 0 and xb_a < 0 and ac_a / xb_a > 1 cond := cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = math.round_to_mintick(Ny) stop_loss = Cy take_profit1 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.000 * (Dd == 1 ? 1 : -1)) take_profit2 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.500 * (Dd == 1 ? 1 : -1)) coluor = Dd == 1 ? bullcolor : bearcolor trendy = Dd == 1 ? Cy > Zy : Dd == -1 ? Cy < Zy : false name = "Descending-Triangle " + (Dd == 1 ? "▲" : "▼") draw_triangle_pattern(cond and show_pattern, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, Dd, trendy] //ascending triangle asc_triangle_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_6_points(zigzag, oldzigzag, zigzagdir, confirm) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) xb_a = (Xy - By) / (Xx - Bx) xb_b = Xy - xb_a * Xx ac_a = (Ay - Cy) / (Ax - Cx) ac_b = Ay - ac_a * Ax cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx zx_a = (Zy - Xy) / (Zx - Xx) zx_b = Zy - zx_a * Zx Mx = math.floor(-(zx_b - ac_b) / (zx_a - ac_a)) My = Mx * zx_a + zx_b Nx = math.ceil(-(cd_b - xb_b) / (cd_a - xb_a)) Ny = Nx * cd_a + cd_b cond = false if Dd == 1 cond1 = XA / ZX >= 0.328 and XA / ZX <= 0.886 cond2 = AB / XA >= 1.130 and AB / XA <= 1.618 cond3 = BC / AB >= 0.618 and BC / AB <= 0.886 cond4 = CD / BC >= 1.242 and CD / BC <= 1.382 cond5 = Zy <= My and Dy >= Ny cond6 = ac_a > 0 and xb_a > 0 and xb_a / ac_a < 1 cond := cond1 and cond2 and cond3 and cond4 and cond5 and cond6 else cond1 = XA / ZX >= 0.328 and XA / ZX <= 0.886 cond2 = AB / XA >= 0.618 and AB / XA <= 0.886 cond3 = BC / AB >= 1.130 and BC / AB <= 1.618 cond4 = CD / BC >= 1.242 and CD / BC <= 1.382 cond5 = Zy >= My and Dy <= Ny cond6 = ac_a > 0 and xb_a > 0 and ac_a / xb_a < 1 cond := cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = math.round_to_mintick(Ny) stop_loss = Cy take_profit1 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.000 * (Dd == 1 ? 1 : -1)) take_profit2 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.500 * (Dd == 1 ? 1 : -1)) coluor = Dd == 1 ? bullcolor : bearcolor trendy = Dd == 1 ? Cy > Zy : Dd == -1 ? Cy < Zy : false name = "Ascending-Triangle " + (Dd == 1 ? "▲" : "▼") draw_triangle_pattern(cond and show_pattern, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, Dd, trendy] //symmetrical triangle sym_triangle_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_6_points(zigzag, oldzigzag, zigzagdir, confirm) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) xb_a = (Xy - By) / (Xx - Bx) xb_b = Xy - xb_a * Xx ac_a = (Ay - Cy) / (Ax - Cx) ac_b = Ay - ac_a * Ax cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx zx_a = (Zy - Xy) / (Zx - Xx) zx_b = Zy - zx_a * Zx Mx = math.floor(-(zx_b - ac_b) / (zx_a - ac_a)) My = Mx * zx_a + zx_b Nx = math.ceil(-(cd_b - xb_b) / (cd_a - xb_a)) Ny = Nx * cd_a + cd_b cond1 = XA / ZX >= 0.328 and XA / ZX <= 0.886 cond2 = AB / XA >= 0.618 and AB / XA <= 0.886 cond3 = BC / AB >= 0.618 and BC / AB <= 0.886 cond4 = CD / BC >= 1.242 and CD / BC <= 1.382 cond5 = ac_a * xb_a < 0 cond6 = Dd == 1 ? Zy <= My : Zy >= My cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 entry_price = math.round_to_mintick(Ny) stop_loss = Cy take_profit1 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.000 * (Dd == 1 ? 1 : -1)) take_profit2 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.500 * (Dd == 1 ? 1 : -1)) coluor = Dd == 1 ? bullcolor : bearcolor trendy = true name = "Symmetrical-Triangle " + (Dd == 1 ? "▲" : "▼") draw_triangle_pattern(cond and show_pattern, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, Dd, trendy] // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // Header&Shoulders Functions ---------------------------------------------------------------------- // //draw header&shoulder pattern draw_hs_pattern(draw, Sx, Sy, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) => var line line_SZ = na var line line_ZX = na var line line_XA = na var line line_AB = na var line line_BC = na var line line_CD = na var line line_XB = na var line line_MX = na var line line_BN = na var label label_S = na var label label_Z = na var label label_X = na var label label_A = na var label label_B = na var label label_C = na var label label_D = na if draw line.delete(line_SZ) line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) line.delete(line_XB) line.delete(line_MX) line.delete(line_BN) label.delete(label_S) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) duration = ((Dx - Sx) * timeframe.multiplier) / (60.0 * 24.0) tooltip = "timeframe: " + reso + "\n" + "pattern: " + name + "\n" + "duration: " + str.tostring(duration, "#.###") + " Day" + "\n" + "trendy: " + (trendy ? "true" : "false") + "\n" line_SZ := line.new(x1=Sx, y1=Sy, x2=Zx, y2=Zy, color=color.new(coluor, 30), width=2) line_ZX := line.new(x1=Zx, y1=Zy, x2=Xx, y2=Xy, color=color.new(coluor, 30), width=2) line_XA := line.new(x1=Xx, y1=Xy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=2) line_AB := line.new(x1=Ax, y1=Ay, x2=Bx, y2=By, color=color.new(coluor, 30), width=2) line_BC := line.new(x1=Bx, y1=By, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2) line_CD := line.new(x1=Cx, y1=Cy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=2) label_S := label.new(x=Sx, y=Sy, text="S", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_Z := label.new(x=Zx, y=Zy, text="0", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_X := label.new(x=Xx, y=Xy, text="X", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_A := label.new(x=Ax, y=Ay, text="A", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_B := label.new(x=Bx, y=By, text="B", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_C := label.new(x=Cx, y=Cy, text="C", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_D := label.new(x=Dx, y=Dy, text="D", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) xb_a = (Xy - By) / (Xx - Bx) xb_b = Xy - xb_a * Xx sz_a = (Sy - Zy) / (Sx - Zx) sz_b = Sy - sz_a * Sx cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx Mx = math.floor(-(xb_b - sz_b) / (xb_a - sz_a)) My = Mx * xb_a + xb_b Nx = math.ceil(-(xb_b - cd_b) / (xb_a - cd_a)) Ny = Nx * xb_a + xb_b line_XB := line.new(x1=Xx, y1=Xy, x2=Bx, y2=By, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_MX := line.new(x1=Mx, y1=My, x2=Xx, y2=Xy, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_BN := line.new(x1=Bx, y1=By, x2=Nx, y2=Ny, color=color.new(coluor, 30), width=1, style=line.style_dotted) linefill.new(line_SZ, line_MX, color=color.new(coluor, 80)) linefill.new(line_XA, line_XB, color=color.new(coluor, 80)) linefill.new(line_BC, line_BN, color=color.new(coluor, 80)) 0 else if not na(label_D) and (bar_index - label.get_x(label_D)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_SZ) line.delete(line_ZX) line.delete(line_XA) line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) line.delete(line_XB) line.delete(line_MX) line.delete(line_BN) label.delete(label_S) label.delete(label_Z) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) 0 //get 7-points get_7_points(zigzag, oldzigzag, zigzagdir, confirm) => if array.size(zigzag) >= 14 and ta.barssince(is_newzigzag(zigzag, oldzigzag)) == confirm Sx = math.round(array.get(zigzag, 13)) Sy = array.get(zigzag, 12) Sd = zigzagdir[bar_index - Sx] Zx = math.round(array.get(zigzag, 11)) Zy = array.get(zigzag, 10) Zd = zigzagdir[bar_index - Zx] Xx = math.round(array.get(zigzag, 9)) Xy = array.get(zigzag, 8) Xd = zigzagdir[bar_index - Xx] Ax = math.round(array.get(zigzag, 7)) Ay = array.get(zigzag, 6) Ad = zigzagdir[bar_index - Ax] Bx = math.round(array.get(zigzag, 5)) By = array.get(zigzag, 4) Bd = zigzagdir[bar_index - Bx] Cx = math.round(array.get(zigzag, 3)) Cy = array.get(zigzag, 2) Cd = zigzagdir[bar_index - Cx] Dx = math.round(array.get(zigzag, 1)) Dy = array.get(zigzag, 0) Dd = zigzagdir[bar_index - Dx] [Sx, Sy, Sd, Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] else [na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na, na] //header and shoulder pattern norm_hs_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Sx, Sy, Sd, Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_7_points(zigzag, oldzigzag, zigzagdir, confirm) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) ZB = math.abs(Zy - By) XC = math.abs(Xy - Cy) xb_a = (Xy - By) / (Xx - Bx) xb_b = Xy - xb_a * Xx sz_a = (Sy - Zy) / (Sx - Zx) sz_b = Sy - sz_a * Sx cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx Mx = math.floor(-(xb_b - sz_b) / (xb_a - sz_a)) My = Mx * xb_a + xb_b Nx = math.ceil(-(xb_b - cd_b) / (xb_a - cd_a)) Ny = Nx * xb_a + xb_b cond1 = XA / ZX >= 1.272 and XA / ZX <= 2.618 cond2 = ZB / ZX >= 0.786 and ZB / ZX <= 1.272 cond3 = AB / BC >= 1.272 and AB / BC <= 2.618 cond4 = XC / BC >= 0.786 and XC / BC <= 1.272 cond5 = CD / BC >= 1.242 and CD / BC <= 1.382 cond6 = Dd == -1 cond7 = Mx >= Sx and My >= Sy cond8 = Nx <= Dx and Ny >= Dy cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 and cond7 and cond8 entry_price = math.round_to_mintick(Ny) stop_loss = Cy take_profit1 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.000 * (Dd == 1 ? 1 : -1)) take_profit2 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.500 * (Dd == 1 ? 1 : -1)) coluor = bearcolor trendy = true name = "Header&Shoulder ▼" draw_hs_pattern(cond and show_pattern, Sx, Sy, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, Dd, trendy] //header and shoulder pattern inve_hs_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Sx, Sy, Sd, Zx, Zy, Zd, Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_7_points(zigzag, oldzigzag, zigzagdir, confirm) ZX = math.abs(Zy - Xy) XA = math.abs(Xy - Ay) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) ZB = math.abs(Zy - By) XC = math.abs(Xy - Cy) xb_a = (Xy - By) / (Xx - Bx) xb_b = Xy - xb_a * Xx sz_a = (Sy - Zy) / (Sx - Zx) sz_b = Sy - sz_a * Sx cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx Mx = math.floor(-(xb_b - sz_b) / (xb_a - sz_a)) My = Mx * xb_a + xb_b Nx = math.ceil(-(xb_b - cd_b) / (xb_a - cd_a)) Ny = Nx * xb_a + xb_b cond1 = XA / ZX >= 1.272 and XA / ZX <= 2.618 cond2 = ZB / ZX >= 0.786 and ZB / ZX <= 1.272 cond3 = AB / BC >= 1.272 and AB / BC <= 2.618 cond4 = XC / BC >= 0.786 and XC / BC <= 1.272 cond5 = CD / BC >= 1.242 and CD / BC <= 1.382 cond6 = Dd == 1 cond7 = Mx >= Sx and My <= Sy cond8 = Nx <= Dx and Ny <= Dy cond = cond1 and cond2 and cond3 and cond4 and cond5 and cond6 and cond7 and cond8 entry_price = math.round_to_mintick(Ny) stop_loss = Cy take_profit1 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.000 * (Dd == 1 ? 1 : -1)) take_profit2 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.500 * (Dd == 1 ? 1 : -1)) coluor = bullcolor trendy = true name = "Inverse-Header&Shoulder ▲" draw_hs_pattern(cond and show_pattern, Sx, Sy, Zx, Zy, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, Dd, trendy] // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // Double-top/bottom Pattern Functions ------------------------------------------------------------- // //draw double top/btm pattern draw_double_top_btm_pattern(draw, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) => var line line_XA = na var line line_AB = na var line line_BC = na var line line_CD = na var line line_MB = na var line line_BN = na var label label_X = na var label label_A = na var label label_B = na var label label_C = na var label label_D = na if draw line.delete(line_XA) line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) line.delete(line_MB) line.delete(line_BN) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) duration = ((Dx - Xx) * timeframe.multiplier) / (60.0 * 24.0) tooltip = "timeframe: " + reso + "\n" + "pattern: " + name + "\n" + "duration: " + str.tostring(duration, "#.###") + " Day" + "\n" + "trendy: " + (trendy ? "true" : "false") + "\n" line_XA := line.new(x1=Xx, y1=Xy, x2=Ax, y2=Ay, color=color.new(coluor, 30), width=2) line_AB := line.new(x1=Ax, y1=Ay, x2=Bx, y2=By, color=color.new(coluor, 30), width=2) line_BC := line.new(x1=Bx, y1=By, x2=Cx, y2=Cy, color=color.new(coluor, 30), width=2) line_CD := line.new(x1=Cx, y1=Cy, x2=Dx, y2=Dy, color=color.new(coluor, 30), width=2) label_X := label.new(x=Xx, y=Xy, text="X", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_A := label.new(x=Ax, y=Ay, text="A", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_B := label.new(x=Bx, y=By, text="B", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_C := label.new(x=Cx, y=Cy, text="C", style=Dd == -1 ? label.style_label_down : label.style_label_up, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) label_D := label.new(x=Dx, y=Dy, text="D", style=Dd == -1 ? label.style_label_up : label.style_label_down, color=color.new(color.blue, 100), textcolor=color.new(coluor, 10), tooltip=tooltip) xa_a = (Xy - Ay) / (Xx - Ax) xa_b = Xy - xa_a * Xx cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx Mx = math.floor((By - xa_b) / xa_a) Nx = math.ceil((By - cd_b) / cd_a) line_MB := line.new(x1=Mx, y1=By, x2=Bx, y2=By, color=color.new(coluor, 30), width=1, style=line.style_dotted) line_BN := line.new(x1=Bx, y1=By, x2=Nx, y2=By, color=color.new(coluor, 30), width=1, style=line.style_dotted) linefill.new(line_MB, line_XA, color=color.new(coluor, 80)) linefill.new(line_BN, line_BC, color=color.new(coluor, 80)) 0 else if not na(label_D) and (bar_index - label.get_x(label_D)) * timeframe.multiplier > 30 * 24 * 60 line.delete(line_XA) line.delete(line_AB) line.delete(line_BC) line.delete(line_CD) line.delete(line_MB) line.delete(line_BN) label.delete(label_X) label.delete(label_A) label.delete(label_B) label.delete(label_C) label.delete(label_D) 0 //double top pattern double_top_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx Nx = (By - cd_b) / cd_a Ny = By cond1 = AB / XA >= 0.382 and AB / XA <= 0.886 cond2 = BC / AB >= 0.786 and BC / AB <= 1.000 cond3 = CD / BC >= 1.242 and CD / BC <= 1.382 cond4 = Dd == -1 cond5 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 entry_price = math.round_to_mintick(Ny) stop_loss = Cy take_profit1 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.000 * (Dd == 1 ? 1 : -1)) take_profit2 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.500 * (Dd == 1 ? 1 : -1)) coluor = bearcolor trendy = true name = "Double-Top ▼" draw_double_top_btm_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, Dd, trendy] //double bottom pattern double_btm_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcolor, bearcolor, show_pattern, show_price) => [Xx, Xy, Xd, Ax, Ay, Ad, Bx, By, Bd, Cx, Cy, Cd, Dx, Dy, Dd] = get_5_points(zigzag, oldzigzag, zigzagdir, confirm) XA = math.abs(Xy - Ay) XC = math.abs(Xy - Cy) AB = math.abs(Ay - By) BC = math.abs(By - Cy) CD = math.abs(Cy - Dy) AD = math.abs(Ay - Dy) _XB = math.abs(Xx - Bx) _BD = math.abs(Bx - Dx) cd_a = (Cy - Dy) / (Cx - Dx) cd_b = Cy - cd_a * Cx Nx = (By - cd_b) / cd_a Ny = By cond1 = AB / XA >= 0.382 and AB / XA <= 0.886 cond2 = BC / AB >= 0.786 and BC / AB <= 1.000 cond3 = CD / BC >= 1.242 and CD / BC <= 1.382 cond4 = Dd == 1 cond5 = _XB / _BD >= 0.333 and _XB / _BD <= 3.000 cond = cond1 and cond2 and cond3 and cond4 and cond5 entry_price = math.round_to_mintick(Ny) stop_loss = Cy take_profit1 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.000 * (Dd == 1 ? 1 : -1)) take_profit2 = math.round_to_mintick(Ny + math.abs(Ny - Cy) * 1.500 * (Dd == 1 ? 1 : -1)) coluor = bullcolor trendy = true name = "Double-Bottom ▲" draw_double_top_btm_pattern(cond and show_pattern, Xx, Xy, Ax, Ay, Bx, By, Cx, Cy, Dx, Dy, Dd, reso, name, trendy, coluor) draw_trading_lines(cond and show_price, Dx, entry_price, stop_loss, take_profit1, take_profit2, coluor, 20) [cond, Dd, trendy] // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // Multi-Timeframe Zigzag -------------------------------------------------------------------------- // zz_reso1 = input.timeframe(defval="30", title="timeframe resolution", group="Multi-Timeframe A") zz_src1 = input.string(defval="HM2/LM2", title="pivot high/low source", options=["HIGH/LOW", "CLOSE", "HM2/LM2"], tooltip="HM2 = (high + max(open, close)) / 2\nLM2 = (low + min(open, close)) / 2", group="Multi-Timeframe A") zz_perd1 = input.int(defval=5, title="timeframe pivot period", minval=0, group="Multi-Timeframe A") zz_confirm1 = input.int(defval=3, title="delay for confirmations", minval=0, group="Multi-Timeframe A") zz_bull_color1 = input.color(defval=color.new(#9FEE01, 30), title="bullish/bearish colors  ", inline="ZZAA", group="Multi-Timeframe A") zz_bear_color1 = input.color(defval=color.new(#CC0074, 30), title="", inline="ZZAA", group="Multi-Timeframe A") zz_enable_tf1 = input.bool(defval=true, title="enable harmonic patterns", group="Multi-Timeframe A") zz_show_ptrn1 = input.bool(defval=true, title="show harmonic patterns", tooltip="All drawings in each timeframe will be preserved for 30 days, and only the last pattern of each pattern will be shown", group="Multi-Timeframe A") zz_show_prce1 = input.bool(defval=false, title="show trading prices of patterns", tooltip="Including entry price, take profit 1, take profit 2, and stop loss price", group="Multi-Timeframe A") zz_reso2 = input.timeframe(defval="45", title="timeframe resolution", group="Multi-Timeframe B") zz_src2 = input.string(defval="HM2/LM2", title="pivot high/low source", options=["HIGH/LOW", "CLOSE", "HM2/LM2"], tooltip="HM2 = (high + max(open, close)) / 2\nLM2 = (low + min(open, close)) / 2", group="Multi-Timeframe B") zz_perd2 = input.int(defval=5, title="timeframe pivot period", minval=0, group="Multi-Timeframe B") zz_confirm2 = input.int(defval=3, title="delay for confirmations", minval=0, group="Multi-Timeframe B") zz_bull_color2 = input.color(defval=color.new(#00CC00, 30), title="bullish/bearish colors  ", inline="ZZBB", group="Multi-Timeframe B") zz_bear_color2 = input.color(defval=color.new(#FF0101, 30), title="", inline="ZZBB", group="Multi-Timeframe B") zz_enable_tf2 = input.bool(defval=true, title="enable harmonic patterns", group="Multi-Timeframe B") zz_show_ptrn2 = input.bool(defval=true, title="show harmonic patterns", tooltip="All drawings in each timeframe will be preserved for 30 days, and only the last pattern of each pattern will be shown", group="Multi-Timeframe B") zz_show_prce2 = input.bool(defval=false, title="show trading prices of patterns", tooltip="Including entry price, take profit 1, take profit 2, and stop loss price", group="Multi-Timeframe B") zz_reso3 = input.timeframe(defval="60", title="timeframe resolution", group="Multi-Timeframe C") zz_src3 = input.string(defval="HM2/LM2", title="pivot high/low source", options=["HIGH/LOW", "CLOSE", "HM2/LM2"], tooltip="HM2 = (high + max(open, close)) / 2\nLM2 = (low + min(open, close)) / 2", group="Multi-Timeframe C") zz_perd3 = input.int(defval=5, title="timeframe pivot period", minval=0, group="Multi-Timeframe C") zz_confirm3 = input.int(defval=3, title="delay for confirmations", minval=0, group="Multi-Timeframe C") zz_bull_color3 = input.color(defval=color.new(#009999, 30), title="bullish/bearish colors  ", inline="ZZAA", group="Multi-Timeframe C") zz_bear_color3 = input.color(defval=color.new(#FF7401, 30), title="", inline="ZZAA", group="Multi-Timeframe C") zz_enable_tf3 = input.bool(defval=true, title="enable harmonic patterns", group="Multi-Timeframe C") zz_show_ptrn3 = input.bool(defval=true, title="show harmonic patterns", tooltip="All drawings in each timeframe will be preserved for 30 days, and only the last pattern of each pattern will be shown", group="Multi-Timeframe C") zz_show_prce3 = input.bool(defval=false, title="show trading prices of patterns", tooltip="Including entry price, take profit 1, take profit 2, and stop loss price", group="Multi-Timeframe C") zz_reso4 = input.timeframe(defval="120", title="timeframe resolution", group="Multi-Timeframe D") zz_src4 = input.string(defval="HM2/LM2", title="pivot high/low source", options=["HIGH/LOW", "CLOSE", "HM2/LM2"], tooltip="HM2 = (high + max(open, close)) / 2\nLM2 = (low + min(open, close)) / 2", group="Multi-Timeframe D") zz_perd4 = input.int(defval=5, title="timeframe pivot period", minval=0, group="Multi-Timeframe D") zz_confirm4 = input.int(defval=3, title="delay for confirmations", minval=0, group="Multi-Timeframe D") zz_bull_color4 = input.color(defval=color.new(#1240AB, 30), title="bullish/bearish colors  ", inline="ZZBB", group="Multi-Timeframe D") zz_bear_color4 = input.color(defval=color.new(#FFAA01, 30), title="", inline="ZZBB", group="Multi-Timeframe D") zz_enable_tf4 = input.bool(defval=true, title="enable harmonic patterns", group="Multi-Timeframe D") zz_show_ptrn4 = input.bool(defval=true, title="show harmonic patterns", tooltip="All drawings in each timeframe will be preserved for 30 days, and only the last pattern of each pattern will be shown", group="Multi-Timeframe D") zz_show_prce4 = input.bool(defval=false, title="show trading prices of patterns", tooltip="Including entry price, take profit 1, take profit 2, and stop loss price", group="Multi-Timeframe D") zz_reso5 = input.timeframe(defval="180", title="timeframe resolution", group="Multi-Timeframe E") zz_src5 = input.string(defval="HM2/LM2", title="pivot high/low source", options=["HIGH/LOW", "CLOSE", "HM2/LM2"], tooltip="HM2 = (high + max(open, close)) / 2\nLM2 = (low + min(open, close)) / 2", group="Multi-Timeframe E") zz_perd5 = input.int(defval=5, title="timeframe pivot period", minval=0, group="Multi-Timeframe E") zz_confirm5 = input.int(defval=3, title="delay for confirmations", minval=0, group="Multi-Timeframe E") zz_bull_color5 = input.color(defval=color.new(#3715B0, 30), title="bullish/bearish colors  ", inline="ZZBB", group="Multi-Timeframe E") zz_bear_color5 = input.color(defval=color.new(#FFD201, 30), title="", inline="ZZBB", group="Multi-Timeframe E") zz_enable_tf5 = input.bool(defval=true, title="enable harmonic patterns", group="Multi-Timeframe E") zz_show_ptrn5 = input.bool(defval=true, title="show harmonic patterns", tooltip="All drawings in each timeframe will be preserved for 30 days, and only the last pattern of each pattern will be shown", group="Multi-Timeframe E") zz_show_prce5 = input.bool(defval=false, title="show trading prices of patterns", tooltip="Including entry price, take profit 1, take profit 2, and stop loss price", group="Multi-Timeframe E") zz_reso6 = input.timeframe(defval="240", title="timeframe resolution", group="Multi-Timeframe F") zz_src6 = input.string(defval="HM2/LM2", title="pivot high/low source", options=["HIGH/LOW", "CLOSE", "HM2/LM2"], tooltip="HM2 = (high + max(open, close)) / 2\nLM2 = (low + min(open, close)) / 2", group="Multi-Timeframe F") zz_perd6 = input.int(defval=5, title="timeframe pivot period", minval=0, group="Multi-Timeframe F") zz_confirm6 = input.int(defval=3, title="delay for confirmations", minval=0, group="Multi-Timeframe F") zz_bull_color6 = input.color(defval=color.new(#7109AA, 30), title="bullish/bearish colors  ", inline="ZZBB", group="Multi-Timeframe F") zz_bear_color6 = input.color(defval=color.new(#FFFF01, 30), title="", inline="ZZBB", group="Multi-Timeframe F") zz_enable_tf6 = input.bool(defval=true, title="enable harmonic patterns", group="Multi-Timeframe F") zz_show_ptrn6 = input.bool(defval=true, title="show harmonic patterns", tooltip="All drawings in each timeframe will be preserved for 30 days, and only the last pattern of each pattern will be shown", group="Multi-Timeframe F") zz_show_prce6 = input.bool(defval=false, title="show trading prices of patterns", tooltip="Including entry price, take profit 1, take profit 2, and stop loss price", group="Multi-Timeframe F") hm = (math.max(open, close) + high) / 2 lm = (math.min(open, close) + low) / 2 zz_hsrc1 = zz_src1 == "CLOSE" ? close : zz_src1 == "HM2/LM2" ? hm : high zz_hsrc2 = zz_src2 == "CLOSE" ? close : zz_src2 == "HM2/LM2" ? hm : high zz_hsrc3 = zz_src3 == "CLOSE" ? close : zz_src3 == "HM2/LM2" ? hm : high zz_hsrc4 = zz_src4 == "CLOSE" ? close : zz_src4 == "HM2/LM2" ? hm : high zz_hsrc5 = zz_src5 == "CLOSE" ? close : zz_src5 == "HM2/LM2" ? hm : high zz_hsrc6 = zz_src6 == "CLOSE" ? close : zz_src6 == "HM2/LM2" ? hm : high zz_lsrc1 = zz_src1 == "CLOSE" ? close : zz_src1 == "HM2/LM2" ? lm : low zz_lsrc2 = zz_src2 == "CLOSE" ? close : zz_src2 == "HM2/LM2" ? lm : low zz_lsrc3 = zz_src3 == "CLOSE" ? close : zz_src3 == "HM2/LM2" ? lm : low zz_lsrc4 = zz_src4 == "CLOSE" ? close : zz_src4 == "HM2/LM2" ? lm : low zz_lsrc5 = zz_src5 == "CLOSE" ? close : zz_src5 == "HM2/LM2" ? lm : low zz_lsrc6 = zz_src6 == "CLOSE" ? close : zz_src6 == "HM2/LM2" ? lm : low [zigzag1, oldzigzag1, zigzagdir1] = calculate_zigzag(zz_reso1, zz_perd1, zz_hsrc1, zz_lsrc1, 50) [zigzag2, oldzigzag2, zigzagdir2] = calculate_zigzag(zz_reso2, zz_perd2, zz_hsrc2, zz_lsrc2, 50) [zigzag3, oldzigzag3, zigzagdir3] = calculate_zigzag(zz_reso3, zz_perd3, zz_hsrc3, zz_lsrc3, 50) [zigzag4, oldzigzag4, zigzagdir4] = calculate_zigzag(zz_reso4, zz_perd4, zz_hsrc4, zz_lsrc4, 50) [zigzag5, oldzigzag5, zigzagdir5] = calculate_zigzag(zz_reso5, zz_perd5, zz_hsrc5, zz_lsrc5, 50) [zigzag6, oldzigzag6, zigzagdir6] = calculate_zigzag(zz_reso6, zz_perd6, zz_hsrc6, zz_lsrc6, 50) // ══════════════════════════════════════════════════════════════════════════════════════════════════ // // Harmonic Patterns -------------------------------------------------------------------------- // hp_enable_gartlay = input.bool(defval=true, title="enable Gartlay pattern", group="Harmonic Patterns") hp_enable_cypher = input.bool(defval=true, title="enable Cypher pattern", group="Harmonic Patterns") hp_enable_bat = input.bool(defval=true, title="enable Bat pattern", group="Harmonic Patterns") hp_enable_deepcrab = input.bool(defval=true, title="enable Deepcrab pattern", group="Harmonic Patterns") hp_enable_crab = input.bool(defval=true, title="enable Crab pattern", group="Harmonic Patterns") hp_enable_butterfly = input.bool(defval=true, title="enable Butterfly pattern", group="Harmonic Patterns") hp_enable_shark = input.bool(defval=true, title="enable Shark pattern", group="Harmonic Patterns") hp_enable_zero5 = input.bool(defval=true, title="enable 0-5 pattern", group="Harmonic Patterns") hp_enable_abcd = input.bool(defval=true, title="enable AB=CD pattern", group="Harmonic Patterns") hp_enable_3drives = input.bool(defval=true, title="enable 3-Drives pattern", group="Harmonic Patterns") hp_enable_anti_gartlay = input.bool(defval=true, title="enable Anti-Gartlay pattern", group="Harmonic Patterns") hp_enable_anti_cypher = input.bool(defval=true, title="enable Anti-Cypher pattern", group="Harmonic Patterns") hp_enable_anti_bat = input.bool(defval=true, title="enable Anti-Bat pattern", group="Harmonic Patterns") hp_enable_anti_crab = input.bool(defval=true, title="enable Anti-Crab pattern", group="Harmonic Patterns") hp_enable_anti_butterfly = input.bool(defval=true, title="enable Anti-Butterfly pattern", group="Harmonic Patterns") hp_enable_anti_shark = input.bool(defval=true, title="enable Anti-Shark pattern", group="Harmonic Patterns") hp_enable_black_swan = input.bool(defval=true, title="enable Black-Swan pattern", group="Harmonic Patterns") hp_enable_white_swan = input.bool(defval=true, title="enable White-Swan pattern", group="Harmonic Patterns") hp_enable_desc_triangle = input.bool(defval=false, title="enable Descending-Triangle pattern", group="Harmonic Patterns") hp_enable_asc_triangle = input.bool(defval=false, title="enable Ascending-Triangle pattern", group="Harmonic Patterns") hp_enable_sym_triangle = input.bool(defval=false, title="enable Symmetrical-Triangle pattern", group="Harmonic Patterns") hp_enable_norm_hs = input.bool(defval=false, title="enable Headers&Shoulders pattern", group="Harmonic Patterns") hp_enable_inve_hs = input.bool(defval=false, title="enable Inverse-Headers&Shoulders pattern", group="Harmonic Patterns") hp_enable_double_top = input.bool(defval=false, title="enable Double-Top pattern", group="Harmonic Patterns") hp_enable_double_btm = input.bool(defval=false, title="enable Double-Bottom pattern", group="Harmonic Patterns") get_harmonic_patterns(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) => patterns = matrix.new<int>(25, 3, na) if hp_enable_gartlay [cond, dir, trend] = gartlay_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 0, 0, cond ? 1 : 0) matrix.set(patterns, 0, 1, dir) matrix.set(patterns, 0, 2, trend ? 1 : 0) if hp_enable_bat [cond, dir, trend] = bat_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 1, 0, cond ? 1 : 0) matrix.set(patterns, 1, 1, dir) matrix.set(patterns, 1, 2, trend ? 1 : 0) if hp_enable_cypher [cond, dir, trend] = cypher_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 2, 0, cond ? 1 : 0) matrix.set(patterns, 2, 1, dir) matrix.set(patterns, 2, 2, trend ? 1 : 0) if hp_enable_deepcrab [cond, dir, trend] = deepcrab_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 3, 0, cond ? 1 : 0) matrix.set(patterns, 3, 1, dir) matrix.set(patterns, 3, 2, trend ? 1 : 0) if hp_enable_crab [cond, dir, trend] = crab_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 4, 0, cond ? 1 : 0) matrix.set(patterns, 4, 1, dir) matrix.set(patterns, 4, 2, trend ? 1 : 0) if hp_enable_butterfly [cond, dir, trend] = butterfly_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 5, 0, cond ? 1 : 0) matrix.set(patterns, 5, 1, dir) matrix.set(patterns, 5, 2, trend ? 1 : 0) if hp_enable_shark [cond, dir, trend] = shark_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 6, 0, cond ? 1 : 0) matrix.set(patterns, 6, 1, dir) matrix.set(patterns, 6, 2, trend ? 1 : 0) if hp_enable_zero5 [cond, dir, trend] = zero5_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 7, 0, cond ? 1 : 0) matrix.set(patterns, 7, 1, dir) matrix.set(patterns, 7, 2, trend ? 1 : 0) if hp_enable_abcd [cond, dir, trend] = abcd_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 8, 0, cond ? 1 : 0) matrix.set(patterns, 8, 1, dir) matrix.set(patterns, 8, 2, trend ? 1 : 0) if hp_enable_3drives [cond, dir, trend] = threedrives_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 9, 0, cond ? 1 : 0) matrix.set(patterns, 9, 1, dir) matrix.set(patterns, 9, 2, trend ? 1 : 0) if hp_enable_anti_gartlay [cond, dir, trend] = anti_gartlay_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 10, 0, cond ? 1 : 0) matrix.set(patterns, 10, 1, dir) matrix.set(patterns, 10, 2, trend ? 1 : 0) if hp_enable_anti_bat [cond, dir, trend] = anti_bat_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 11, 0, cond ? 1 : 0) matrix.set(patterns, 11, 1, dir) matrix.set(patterns, 11, 2, trend ? 1 : 0) if hp_enable_anti_cypher [cond, dir, trend] = anti_cypher_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 12, 0, cond ? 1 : 0) matrix.set(patterns, 12, 1, dir) matrix.set(patterns, 12, 2, trend ? 1 : 0) if hp_enable_anti_crab [cond, dir, trend] = anti_crab_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 13, 0, cond ? 1 : 0) matrix.set(patterns, 13, 1, dir) matrix.set(patterns, 13, 2, trend ? 1 : 0) if hp_enable_anti_butterfly [cond, dir, trend] = anti_butterfly_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 14, 0, cond ? 1 : 0) matrix.set(patterns, 14, 1, dir) matrix.set(patterns, 14, 2, trend ? 1 : 0) if hp_enable_anti_shark [cond, dir, trend] = anti_shark_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 15, 0, cond ? 1 : 0) matrix.set(patterns, 15, 1, dir) matrix.set(patterns, 15, 2, trend ? 1 : 0) if hp_enable_black_swan [cond, dir, trend] = black_swan_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 16, 0, cond ? 1 : 0) matrix.set(patterns, 16, 1, dir) matrix.set(patterns, 16, 2, trend ? 1 : 0) if hp_enable_white_swan [cond, dir, trend] = white_swan_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 17, 0, cond ? 1 : 0) matrix.set(patterns, 17, 1, dir) matrix.set(patterns, 17, 2, trend ? 1 : 0) if hp_enable_desc_triangle [cond, dir, trend] = desc_triangle_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 18, 0, cond ? 1 : 0) matrix.set(patterns, 18, 1, dir) matrix.set(patterns, 18, 2, trend ? 1 : 0) if hp_enable_asc_triangle [cond, dir, trend] = asc_triangle_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 19, 0, cond ? 1 : 0) matrix.set(patterns, 19, 1, dir) matrix.set(patterns, 19, 2, trend ? 1 : 0) if hp_enable_sym_triangle [cond, dir, trend] = sym_triangle_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 20, 0, cond ? 1 : 0) matrix.set(patterns, 20, 1, dir) matrix.set(patterns, 20, 2, trend ? 1 : 0) if hp_enable_norm_hs [cond, dir, trend] = norm_hs_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 21, 0, cond ? 1 : 0) matrix.set(patterns, 21, 1, dir) matrix.set(patterns, 21, 2, trend ? 1 : 0) if hp_enable_inve_hs [cond, dir, trend] = inve_hs_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 22, 0, cond ? 1 : 0) matrix.set(patterns, 22, 1, dir) matrix.set(patterns, 22, 2, trend ? 1 : 0) if hp_enable_double_top [cond, dir, trend] = double_top_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 23, 0, cond ? 1 : 0) matrix.set(patterns, 23, 1, dir) matrix.set(patterns, 23, 2, trend ? 1 : 0) if hp_enable_double_btm [cond, dir, trend] = double_btm_pattern(reso, zigzag, oldzigzag, zigzagdir, confirm, bullcol, bearcol, show_pattern, show_price) if cond matrix.set(patterns, 24, 0, cond ? 1 : 0) matrix.set(patterns, 24, 1, dir) matrix.set(patterns, 24, 2, trend ? 1 : 0) patterns patterns_reso1 = zz_enable_tf1 ? get_harmonic_patterns(zz_reso1, zigzag1, oldzigzag1, zigzagdir1, zz_confirm1, zz_bull_color1, zz_bear_color1, zz_show_ptrn1, zz_show_prce1) : matrix.new<int>(25, 3, na) patterns_reso2 = zz_enable_tf2 ? get_harmonic_patterns(zz_reso2, zigzag2, oldzigzag2, zigzagdir2, zz_confirm2, zz_bull_color2, zz_bear_color2, zz_show_ptrn2, zz_show_prce2) : matrix.new<int>(25, 3, na) patterns_reso3 = zz_enable_tf3 ? get_harmonic_patterns(zz_reso3, zigzag3, oldzigzag3, zigzagdir3, zz_confirm3, zz_bull_color3, zz_bear_color3, zz_show_ptrn3, zz_show_prce3) : matrix.new<int>(25, 3, na) patterns_reso4 = zz_enable_tf4 ? get_harmonic_patterns(zz_reso4, zigzag4, oldzigzag4, zigzagdir4, zz_confirm4, zz_bull_color4, zz_bear_color4, zz_show_ptrn4, zz_show_prce4) : matrix.new<int>(25, 3, na) patterns_reso5 = zz_enable_tf5 ? get_harmonic_patterns(zz_reso5, zigzag5, oldzigzag5, zigzagdir5, zz_confirm5, zz_bull_color5, zz_bear_color5, zz_show_ptrn5, zz_show_prce5) : matrix.new<int>(25, 3, na) patterns_reso6 = zz_enable_tf6 ? get_harmonic_patterns(zz_reso6, zigzag6, oldzigzag6, zigzagdir6, zz_confirm6, zz_bull_color6, zz_bear_color6, zz_show_ptrn6, zz_show_prce6) : matrix.new<int>(25, 3, na) get_events(patterns) => simple_bull = 0 simple_bear = 0 trendy_bull = 0 trendy_bear = 0 for i = 0 to matrix.rows(patterns) - 1 cond = matrix.get(patterns, i, 0) dir = matrix.get(patterns, i, 1) trend = matrix.get(patterns, i, 2) if cond == 1 if dir == 1 simple_bull := simple_bull + 1 else if dir == -1 simple_bear := simple_bear + 1 if dir == 1 and trend == 1 trendy_bull := trendy_bull + 1 else if dir == -1 and trend == 1 trendy_bear := trendy_bear + 1 [simple_bull, simple_bear, trendy_bull, trendy_bear] [simple_bull_reso1, simple_bear_reso1, trendy_bull_reso1, trendy_bear_reso1] = get_events(patterns_reso1) [simple_bull_reso2, simple_bear_reso2, trendy_bull_reso2, trendy_bear_reso2] = get_events(patterns_reso2) [simple_bull_reso3, simple_bear_reso3, trendy_bull_reso3, trendy_bear_reso3] = get_events(patterns_reso3) [simple_bull_reso4, simple_bear_reso4, trendy_bull_reso4, trendy_bear_reso4] = get_events(patterns_reso4) [simple_bull_reso5, simple_bear_reso5, trendy_bull_reso5, trendy_bear_reso5] = get_events(patterns_reso5) [simple_bull_reso6, simple_bear_reso6, trendy_bull_reso6, trendy_bear_reso6] = get_events(patterns_reso6) simple_bull_case = (simple_bull_reso1 + simple_bull_reso2 + simple_bull_reso3 + simple_bull_reso4 + simple_bull_reso5 + simple_bull_reso6) > 0 trendy_bull_case = (trendy_bull_reso1 + trendy_bull_reso2 + trendy_bull_reso3 + trendy_bull_reso4 + trendy_bull_reso5 + trendy_bull_reso6) > 0 simple_bear_case = (simple_bear_reso1 + simple_bear_reso2 + simple_bear_reso3 + simple_bear_reso4 + simple_bear_reso5 + simple_bear_reso6) > 0 trendy_bear_case = (trendy_bear_reso1 + trendy_bear_reso2 + trendy_bear_reso3 + trendy_bear_reso4 + trendy_bear_reso5 + trendy_bear_reso6) > 0 simple_bull_bear_case_color = simple_bull_case and simple_bear_case ? color.purple : simple_bull_case ? color.green : simple_bear_case ? color.red : na plotshape(simple_bull_case and simple_bear_case, style=shape.circle, location=location.bottom, color=color.new(simple_bull_bear_case_color, 20), size=size.tiny) plotshape(simple_bull_case and not simple_bear_case, style=shape.circle, location=location.bottom, color=color.new(simple_bull_bear_case_color, 20), size=size.tiny) plotshape(not simple_bull_case and simple_bear_case, style=shape.circle, location=location.bottom, color=color.new(simple_bull_bear_case_color, 20), size=size.tiny) // trendy_bull_bear_case_color = trendy_bull_case and trendy_bear_case ? color.purple : trendy_bull_case ? color.green : trendy_bear_case ? color.red : na // plotshape(trendy_bull_case and trendy_bear_case, style=shape.circle, location=location.bottom, color=color.new(trendy_bull_bear_case_color, 20), size=size.tiny) // plotshape(trendy_bull_case and not trendy_bear_case, style=shape.circle, location=location.bottom, color=color.new(trendy_bull_bear_case_color, 20), size=size.tiny) // plotshape(not trendy_bull_case and trendy_bear_case, style=shape.circle, location=location.bottom, color=color.new(trendy_bull_bear_case_color, 20), size=size.tiny) int encode = (simple_bull_case ? 1 : 0) * 8 + (trendy_bull_case ? 1 : 0) * 4 + (simple_bear_case ? 1 : 0) * 2 + (trendy_bear_case ? 1 : 0) * 1 plot(encode, title="bincode", display=display.none) //end of file
Accumulated Put/Call Ratio V2
https://www.tradingview.com/script/8VYaMrDh-Accumulated-Put-Call-Ratio-V2/
skiviz
https://www.tradingview.com/u/skiviz/
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/ // © skiviz //@version=5 //Works in daily, weekly and monthly charts indicator("Accumulated P/C Ratio") aggregation = input (5, title = "N bars of accumulation") call_vol_lowerTF = request.security("CVOL", '', close) put_vol_lowerTF = request.security("PVOL", '', close) //call_vol_higherTF & put_vol_higherTF only used for weekly and monthly timeframes call_vol_higherTF = request.security_lower_tf("CVOL", 'D', close) put_vol_higherTF = request.security_lower_tf("PVOL",'D',close) higher_timeframe = timeframe.isweekly or timeframe.ismonthly call_vol = higher_timeframe ? array.sum(call_vol_higherTF) : call_vol_lowerTF put_vol = higher_timeframe ? array.sum(put_vol_higherTF) : put_vol_lowerTF float call_agg = 0.0 float put_agg = 0.0 for i = 0 to aggregation call_agg := call_agg + call_vol[i] put_agg := put_agg + put_vol[i] PCR = put_agg/call_agg //Put Call Ratio PCR_array = array.new_float(0) lookback = input(20, title = "Lookback Period") for i = 0 to lookback array.push(PCR_array, PCR[i]) max = array.max(PCR_array) min = array.min(PCR_array) diff_max = max - PCR //when this approaches 0, P/C ratio is near max, which is bearish; diff_min = min - PCR //when this approaches 0, P/C ratio is near min, which is bullish; STDEV_period = input (200, title = "STDEV Period") diffmax_array = array.new_float(0) diffmin_array = array.new_float(0) for i = 0 to STDEV_period array.push(diffmax_array, diff_max[i]) array.push(diffmin_array, diff_min[i]) diffmax_STDEV = array.stdev(diffmax_array) diffmin_STDEV = array.stdev(diffmin_array) diffmax_mean = array.avg(diffmax_array) diffmin_mean =array.avg(diffmin_array) //Color for difference from max diffmax_in_1stdev = diff_max > diffmax_mean and diff_max < diffmax_mean + diffmax_STDEV diffmax_in_2stdev = diff_max > diffmax_mean + diffmax_STDEV and diff_max < diffmax_mean + 2*diffmax_STDEV diffmax_in_3stdev = diff_max > diffmax_mean + 2*diffmax_STDEV and diff_max < diffmax_mean + 3*diffmax_STDEV diffmax_in_mean = diff_max < diffmax_mean color_max = if diffmax_in_mean color.new(color.green, 80) else if diffmax_in_1stdev color.new(color.green, 60) else if diffmax_in_2stdev color.new(color.green, 40) else if diffmax_in_3stdev color.new(color.green, 20) else color.new(color.green, 0) //Beyond 3 STDEV //Color for difference from min diffmin_in_1stdev = diff_min < diffmin_mean and diff_min > diffmin_mean - diffmin_STDEV diffmin_in_2stdev = diff_min < diffmin_mean - diffmin_STDEV and diff_min > diffmin_mean - 2*diffmin_STDEV diffmin_in_3stdev = diff_min < diffmin_mean - 2*diffmin_STDEV and diff_min > diffmin_mean - 3*diffmin_STDEV diffmin_in_mean = diff_min > diffmin_mean color_min = if diffmin_in_mean color.new(color.red, 80) else if diffmin_in_1stdev color.new(color.red, 60) else if diffmin_in_2stdev color.new(color.red, 40) else if diffmin_in_3stdev color.new(color.red, 20) else color.new(color.red, 0) //Beyond 3 STDEV plot (diff_max , color=color_max, style = plot.style_columns, title="Diff. From Max") plot (diff_min , color=color_min, style = plot.style_columns, title="Diff. From Min") total = diff_max + diff_min plot (total,"Total", color=color.black)
Financial Data Spreadsheet [By MUQWISHI]
https://www.tradingview.com/script/0l1rsf0J-Financial-Data-Spreadsheet-By-MUQWISHI/
MUQWISHI
https://www.tradingview.com/u/MUQWISHI/
132
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://Mozilla.org/MPL/2.0/ // Developed By © MUQWISHI //@version=5 indicator("Financial Data Spreadsheet", overlay = true) // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // | INPUT | // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // Table Style // Position tablePos = input.string("Top Right", "Location  ‏ ", ["Top Right" , "Middle Right" , "Bottom Right" , "Top Center", "Middle Center" , "Bottom Center", "Top Left" , "Middle Left" , "Bottom Left" ], group = "Table Location & Size", inline = "1") // Size tableSiz = input.string("Small", " Size", ["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group = "Table Location & Size", inline = "1") // Horizontal & Vertical Adjustment hrzAdj = input.float(0, "Adjustment", step = 0.2, group = "Table Location & Size", inline = "2") vrtAdj = input.float(0, "  - ", step = 0.2, group = "Table Location & Size", inline = "2", tooltip = "To Adjust Table Location (Horizontally - Vertically)\n" + "First filed for Horizontal adjustment.\nSecond field for Vertical adjustment.\n\n" + "From its default location\n" + "- Positive Horizontal value to move it Right.\n- Negative Horizontal value to move it Left.\n" + "- Positive Vertical value to move it Up.\n- Negative Vertical value to move it Down.") hidTitl = input.bool(false, "Hide Columns Title?", group = "Table Location & Size") hidsyms = input.bool(false, "Hide Instrument Column?", group = "Table Location & Size") // Main Colors tBgCol = input.color(#696969, "Column Title", group = "Tbale Color", inline = "4") cClCol = input.color(#A9A9A9, " Cell", group = "Tbale Color", inline = "4") txtCol = input.color(color.white, " Text", group = "Tbale Color", inline = "4") cShdCol = input.bool(true, "Shade Alternate Rows", group = "Tbale Color") // ++++++ Technical prid = input.string("Quarter", "Financial Period     ‏", ["Year", "Quarter"], group = "Technical") curn = input.string("USD", "Currency", group = "Technical") // ++++++ Columns // Col#1 col01 = input.string("Total Revenue", "Column №1", ["None", "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ BALANCE SHEET ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Accounts Payable","Accounts Receivable - Trade, Net","Accrued Payroll","Accumulated Depreciation, Total","Additional Paid-in Capital/Capital Surplus","Book Value Per Share","Capital and Operating Lease Obligations","Capitalized Lease Obligations","Cash & Equivalents","Cash and Short Term Investments","Common Equity, Total","Common Stock Par/Carrying Value","Current Portion of LT debt and Capital Leases","Deferred Income, Current","Deferred Income, Non-current","Deferred Tax Assets","Deferred Tax Liabilities","Dividends Payable","Goodwill, Net","Gross Property/Plant/Equipment","Income Tax Payable","Inventories - Finished Goods","Inventories - Progress Payments & Other","Inventories - Raw Materials","Inventories - Work in Progress","Investments in Unconsolidated Subsidiaries","Long Term Debt","Long Term Debt Excl. Lease Liabilities","Long Term Investments","Minority Interest","Net Debt","Net Intangible Assets","Net Property/Plant/Equipment","Note Receivable - Long Term","Notes Payable","Operating Lease Liabilities","Other Common Equity","Other Current Assets, Total","Other Current Liabilities","Other Intangibles, Net","Other Investments","Other Long Term Assets, Total","Other Non-current Liabilities, Total","Other Receivables","Other Short Term Debt","Paid in Capital","Preferred Stock, Carrying Value","Prepaid Expenses","Provision for Risks & Charge","Retained Earnings","Shareholders' Equity","Short Term Debt","Short Term Debt Excl. Current Portion of LT debt","Short Term Investments","Tangible Book Value Per Share","Total Assets","Total Current Assets","Total Current Liabilities","Total Debt","Total Equity","Total Inventory","Total Liabilities","Total Liabilities & Shareholders' Equities","Total Non-current Assets","Total Non-current Liabilities","Total Receivables, Net","Treasury Stock - Common", "", "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ CASH FLOW ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Amortization","Capital Expenditures","Capital Expenditures - Fixed Assets","Capital Expenditures - Other Assets","Cash From Financing Activities","Cash From Investing Activities","Cash From Operating Activities","Change in Accounts Payable","Change in Accounts Receivable","Change in Accrued Expenses","Change in Inventories","Change in Other Assets/Liabilities","Change in Taxes Payable","Changes in Working Capital","Common Dividends Paid","Deferred Taxes (Cash Flow)","Depreciation & Amortization (Cash Flow)","Depreciation/depletion","Financing Activities – Other Sources","Financing Activities – Other Uses","Free Cash Flow","Funds From Operations","Investing Activities – Other Sources","Investing Activities – Other Uses","Issuance of Long Term Debt","Issuance/Retirement of Debt, Net","Issuance/Retirement of Long Term Debt","Issuance/Retirement of Other Debt","Issuance/Retirement of Short Term Debt","Issuance/Retirement of Stock, Net","Net Income (Cash Flow)","Non-cash Items","Other Financing Cash Flow Items, Total","Other Investing Cash Flow Items, Total","Preferred Dividends Paid","Purchase of Investments","Purchase/Acquisition of Business","Purchase/Sale of Business, Net","Purchase/Sale of Investments, Net","Reduction of Long Term Debt","Repurchase of Common & Preferred Stock","Sale of Common & Preferred Stock","Sale of Fixed Assets & Businesses","Sale/Maturity of Investments","Total Cash Dividends Paid", " ", "≡≡≡≡≡≡≡≡≡≡≡≡≡ INCOME STATEMENTS ≡≡≡≡≡≡≡≡≡≡≡≡≡", "After Tax Other Income/Expense","Average Basic Shares Outstanding","Basic Earnings Per Share (Basic EPS)","Cost of Goods Sold","Deprecation and Amortization","Diluted Earnings Per Share (Diluted EPS)","Diluted Net Income Available to Common Stockholders","Diluted Shares Outstanding","Dilution Adjustment","Discontinued Operations","EBIT","EBITDA","Equity in Earnings","Gross Profit","Interest Capitalized","Interest Expense on Debt","Interest Expense, Net of Interest Capitalized","Miscellaneous Non-operating Expense","Net Income","Net Income Before Discontinued Operations","Non-controlling/Minority Interest","Non-operating Income, Excl. Interest Expenses","Non-operating Income, Total","Non-operating Interest Income","Operating Expenses (Excl. COGS)","Operating Income","Other Cost of Goods Sold","Other Operating Expenses, Total","Preferred Dividends","Pretax Equity in Earnings","Pretax Income","Research & Development","Selling/General/Admin Expenses, Other","Selling/General/Admin Expenses, Total","Taxes","Total Operating Expenses","Total Revenue","Unusual Income/Expense", " ", "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ STATISTICS ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ ", "Accruals","Altman Z-score","Asset Turnover","Beneish M-score","Buyback Yield %","COGS to Revenue Ratio","Cash Conversion Cycle","Cash to Debt Ratio","Current Ratio","Days Inventory","Days Payable","Days Sales Outstanding","Debt to EBITDA Ratio","Debt to Assets Ratio","Debt to Equity Ratio","Debt to Revenue Ratio","Dividend Payout Ratio %","Dividend Yield %","Dividends Per Share - Common Stock Primary Issue","EBITDA Margin %","EPS Basic One Year Growth","EPS Diluted One Year Growth","EPS Estimates","Effective Interest Rate on Debt %","Enterprise Value","Enterprise Value to EBIT Ratio","Enterprise Value to EBITDA Ratio","Enterprise Value to Revenue Ratio","Equity to Assets Ratio","Float Shares Outstanding","Free Cash Flow Margin %","Fulmer H Factor","Goodwill to Assets Ratio","Graham's Number","Gross Margin %","Gross Profit to Assets Ratio","Interest Coverage","Inventory to Revenue Ratio","Inventory Turnover","KZ Index","Long Term Debt to Total Assets Ratio","Net Current Asset Value Per Share","Net Income Per Employee","Net Margin %","Number of Employees","Operating Earnings Yield %","Operating Margin %","PEG Ratio","Piotroski F-score","Price Earnings Ratio Forward","Price Sales Ratio Forward","Quality Ratio","Quick Ratio","Research & Development to Revenue Ratio","Return on Assets %","Return on Common Equity %","Return on Equity %","Return on Equity Adjusted to Book Value %","Return on Invested Capital %","Return on Tangible Assets %","Return on Tangible Equity %","Revenue Estimates","Revenue One Year Growth","Revenue Per Employee","Shares Buyback Ratio %","Sloan Ratio %","Springate Score","Sustainable Growth Rate","Tangible Common Equity Ratio","Tobin's Q (Approximate)","Total Common Shares Outstanding","Zmijewski Score"], group = "Column №1") chk01 = input.bool(false, "HL", group = "Column №1", inline = "0") h01mn = input.float(-1000000000000, "", group = "Column №1", inline = "0") h01mx = input.float( 1000000000000, "-", group = "Column №1", inline = "0", tooltip = "Highlight Value between MIN and MAX") clr01 = input.color(color.aqua, "", group = "Column №1", inline = "0") // Col#2 col02 = input.string("Gross Profit", "Column №2", ["None", "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ BALANCE SHEET ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Accounts Payable","Accounts Receivable - Trade, Net","Accrued Payroll","Accumulated Depreciation, Total","Additional Paid-in Capital/Capital Surplus","Book Value Per Share","Capital and Operating Lease Obligations","Capitalized Lease Obligations","Cash & Equivalents","Cash and Short Term Investments","Common Equity, Total","Common Stock Par/Carrying Value","Current Portion of LT debt and Capital Leases","Deferred Income, Current","Deferred Income, Non-current","Deferred Tax Assets","Deferred Tax Liabilities","Dividends Payable","Goodwill, Net","Gross Property/Plant/Equipment","Income Tax Payable","Inventories - Finished Goods","Inventories - Progress Payments & Other","Inventories - Raw Materials","Inventories - Work in Progress","Investments in Unconsolidated Subsidiaries","Long Term Debt","Long Term Debt Excl. Lease Liabilities","Long Term Investments","Minority Interest","Net Debt","Net Intangible Assets","Net Property/Plant/Equipment","Note Receivable - Long Term","Notes Payable","Operating Lease Liabilities","Other Common Equity","Other Current Assets, Total","Other Current Liabilities","Other Intangibles, Net","Other Investments","Other Long Term Assets, Total","Other Non-current Liabilities, Total","Other Receivables","Other Short Term Debt","Paid in Capital","Preferred Stock, Carrying Value","Prepaid Expenses","Provision for Risks & Charge","Retained Earnings","Shareholders' Equity","Short Term Debt","Short Term Debt Excl. Current Portion of LT debt","Short Term Investments","Tangible Book Value Per Share","Total Assets","Total Current Assets","Total Current Liabilities","Total Debt","Total Equity","Total Inventory","Total Liabilities","Total Liabilities & Shareholders' Equities","Total Non-current Assets","Total Non-current Liabilities","Total Receivables, Net","Treasury Stock - Common", "", "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ CASH FLOW ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Amortization","Capital Expenditures","Capital Expenditures - Fixed Assets","Capital Expenditures - Other Assets","Cash From Financing Activities","Cash From Investing Activities","Cash From Operating Activities","Change in Accounts Payable","Change in Accounts Receivable","Change in Accrued Expenses","Change in Inventories","Change in Other Assets/Liabilities","Change in Taxes Payable","Changes in Working Capital","Common Dividends Paid","Deferred Taxes (Cash Flow)","Depreciation & Amortization (Cash Flow)","Depreciation/depletion","Financing Activities – Other Sources","Financing Activities – Other Uses","Free Cash Flow","Funds From Operations","Investing Activities – Other Sources","Investing Activities – Other Uses","Issuance of Long Term Debt","Issuance/Retirement of Debt, Net","Issuance/Retirement of Long Term Debt","Issuance/Retirement of Other Debt","Issuance/Retirement of Short Term Debt","Issuance/Retirement of Stock, Net","Net Income (Cash Flow)","Non-cash Items","Other Financing Cash Flow Items, Total","Other Investing Cash Flow Items, Total","Preferred Dividends Paid","Purchase of Investments","Purchase/Acquisition of Business","Purchase/Sale of Business, Net","Purchase/Sale of Investments, Net","Reduction of Long Term Debt","Repurchase of Common & Preferred Stock","Sale of Common & Preferred Stock","Sale of Fixed Assets & Businesses","Sale/Maturity of Investments","Total Cash Dividends Paid", " ", "≡≡≡≡≡≡≡≡≡≡≡≡≡ INCOME STATEMENTS ≡≡≡≡≡≡≡≡≡≡≡≡≡", "After Tax Other Income/Expense","Average Basic Shares Outstanding","Basic Earnings Per Share (Basic EPS)","Cost of Goods Sold","Deprecation and Amortization","Diluted Earnings Per Share (Diluted EPS)","Diluted Net Income Available to Common Stockholders","Diluted Shares Outstanding","Dilution Adjustment","Discontinued Operations","EBIT","EBITDA","Equity in Earnings","Gross Profit","Interest Capitalized","Interest Expense on Debt","Interest Expense, Net of Interest Capitalized","Miscellaneous Non-operating Expense","Net Income","Net Income Before Discontinued Operations","Non-controlling/Minority Interest","Non-operating Income, Excl. Interest Expenses","Non-operating Income, Total","Non-operating Interest Income","Operating Expenses (Excl. COGS)","Operating Income","Other Cost of Goods Sold","Other Operating Expenses, Total","Preferred Dividends","Pretax Equity in Earnings","Pretax Income","Research & Development","Selling/General/Admin Expenses, Other","Selling/General/Admin Expenses, Total","Taxes","Total Operating Expenses","Total Revenue","Unusual Income/Expense", " ", "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ STATISTICS ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ ", "Accruals","Altman Z-score","Asset Turnover","Beneish M-score","Buyback Yield %","COGS to Revenue Ratio","Cash Conversion Cycle","Cash to Debt Ratio","Current Ratio","Days Inventory","Days Payable","Days Sales Outstanding","Debt to EBITDA Ratio","Debt to Assets Ratio","Debt to Equity Ratio","Debt to Revenue Ratio","Dividend Payout Ratio %","Dividend Yield %","Dividends Per Share - Common Stock Primary Issue","EBITDA Margin %","EPS Basic One Year Growth","EPS Diluted One Year Growth","EPS Estimates","Effective Interest Rate on Debt %","Enterprise Value","Enterprise Value to EBIT Ratio","Enterprise Value to EBITDA Ratio","Enterprise Value to Revenue Ratio","Equity to Assets Ratio","Float Shares Outstanding","Free Cash Flow Margin %","Fulmer H Factor","Goodwill to Assets Ratio","Graham's Number","Gross Margin %","Gross Profit to Assets Ratio","Interest Coverage","Inventory to Revenue Ratio","Inventory Turnover","KZ Index","Long Term Debt to Total Assets Ratio","Net Current Asset Value Per Share","Net Income Per Employee","Net Margin %","Number of Employees","Operating Earnings Yield %","Operating Margin %","PEG Ratio","Piotroski F-score","Price Earnings Ratio Forward","Price Sales Ratio Forward","Quality Ratio","Quick Ratio","Research & Development to Revenue Ratio","Return on Assets %","Return on Common Equity %","Return on Equity %","Return on Equity Adjusted to Book Value %","Return on Invested Capital %","Return on Tangible Assets %","Return on Tangible Equity %","Revenue Estimates","Revenue One Year Growth","Revenue Per Employee","Shares Buyback Ratio %","Sloan Ratio %","Springate Score","Sustainable Growth Rate","Tangible Common Equity Ratio","Tobin's Q (Approximate)","Total Common Shares Outstanding","Zmijewski Score"], group = "Column №2") chk02 = input.bool(false, "HL", group = "Column №2", inline = "0") h02mn = input.float(-1000000000000, "", group = "Column №2", inline = "0") h02mx = input.float( 1000000000000, "-", group = "Column №2", inline = "0", tooltip = "Highlight Value between MIN and MAX") clr02 = input.color(color.aqua, "", group = "Column №2", inline = "0") // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // | SYMBOLS | // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // Symbols Checkmark // [1] Symbol c01 = input.bool(true, title = "", group = "Instruments", inline = "s01") c02 = input.bool(true, title = "", group = "Instruments", inline = "s02") c03 = input.bool(true, title = "", group = "Instruments", inline = "s03") c04 = input.bool(true, title = "", group = "Instruments", inline = "s04") c05 = input.bool(true, title = "", group = "Instruments", inline = "s05") c06 = input.bool(true, title = "", group = "Instruments", inline = "s06") c07 = input.bool(true, title = "", group = "Instruments", inline = "s07") c08 = input.bool(true, title = "", group = "Instruments", inline = "s08") c09 = input.bool(true, title = "", group = "Instruments", inline = "s09") c10 = input.bool(true, title = "", group = "Instruments", inline = "s10") c11 = input.bool(true, title = "", group = "Instruments", inline = "s11") c12 = input.bool(true, title = "", group = "Instruments", inline = "s12") c13 = input.bool(true, title = "", group = "Instruments", inline = "s13") c14 = input.bool(true, title = "", group = "Instruments", inline = "s14") c15 = input.bool(true, title = "", group = "Instruments", inline = "s15") c16 = input.bool(true, title = "", group = "Instruments", inline = "s16") c17 = input.bool(true, title = "", group = "Instruments", inline = "s17") c18 = input.bool(true, title = "", group = "Instruments", inline = "s18") c19 = input.bool(true, title = "", group = "Instruments", inline = "s19") c20 = input.bool(true, title = "", group = "Instruments", inline = "s20") // [2] Symbol Input s01 = input.symbol("BA", title = "", group = "Instruments", inline = "s01") s02 = input.symbol("TSLA", title = "", group = "Instruments", inline = "s02") s03 = input.symbol("AAPL", title = "", group = "Instruments", inline = "s03") s04 = input.symbol("META", title = "", group = "Instruments", inline = "s04") s05 = input.symbol("AMZN", title = "", group = "Instruments", inline = "s05") s06 = input.symbol("MSFT", title = "", group = "Instruments", inline = "s06") s07 = input.symbol("NVDA", title = "", group = "Instruments", inline = "s07") s08 = input.symbol("AMD", title = "", group = "Instruments", inline = "s08") s09 = input.symbol("F", title = "", group = "Instruments", inline = "s09") s10 = input.symbol("BAC", title = "", group = "Instruments", inline = "s10") s11 = input.symbol("INTC", title = "", group = "Instruments", inline = "s11") s12 = input.symbol("GOOG", title = "", group = "Instruments", inline = "s12") s13 = input.symbol("SHOP", title = "", group = "Instruments", inline = "s13") s14 = input.symbol("UBER", title = "", group = "Instruments", inline = "s14") s15 = input.symbol("BABA", title = "", group = "Instruments", inline = "s15") s16 = input.symbol("OXY", title = "", group = "Instruments", inline = "s16") s17 = input.symbol("PLUG", title = "", group = "Instruments", inline = "s17") s18 = input.symbol("KO", title = "", group = "Instruments", inline = "s18") s19 = input.symbol("SQ", title = "", group = "Instruments", inline = "s19") s20 = input.symbol("JPM", title = "", group = "Instruments", inline = "s20") // [3] Get Symbol Name only_symbol(s) => array.get(str.split(s, ":"), 1) // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // | FINANCIAL ID | // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| finId(id) => switch id // Balance Sheet "Accounts Payable" => "ACCOUNTS_PAYABLE" "Accounts Receivable - Trade, Net" => "ACCOUNTS_RECEIVABLES_NET" "Accrued Payroll" => "ACCRUED_PAYROLL" "Accumulated Depreciation, Total" => "ACCUM_DEPREC_TOTAL" "Additional Paid-in Capital/Capital Surplus" => "ADDITIONAL_PAID_IN_CAPITAL" "Book Value Per Share" => "BOOK_VALUE_PER_SHARE" "Capital and Operating Lease Obligations" => "CAPITAL_OPERATING_LEASE_OBLIGATIONS" "Capitalized Lease Obligations" => "CAPITAL_LEASE_OBLIGATIONS" "Cash & Equivalents" => "CASH_N_EQUIVALENTS" "Cash and Short Term Investments" => "CASH_N_SHORT_TERM_INVEST" "Common Equity, Total" => "COMMON_EQUITY_TOTAL" "Common Stock Par/Carrying Value" => "COMMON_STOCK_PAR" "Current Portion of LT debt and Capital Leases" => "CURRENT_PORT_DEBT_CAPITAL_LEASES" "Deferred Income, Current" => "DEFERRED_INCOME_CURRENT" "Deferred Income, Non-current" => "DEFERRED_INCOME_NON_CURRENT" "Deferred Tax Assets" => "DEFERRED_TAX_ASSESTS" "Deferred Tax Liabilities" => "DEFERRED_TAX_LIABILITIES" "Dividends Payable" => "DIVIDENDS_PAYABLE" "Goodwill, Net" => "GOODWILL" "Gross Property/Plant/Equipment" => "PPE_TOTAL_GROSS" "Income Tax Payable" => "INCOME_TAX_PAYABLE" "Inventories - Finished Goods" => "INVENTORY_FINISHED_GOODS" "Inventories - Progress Payments & Other" => "INVENTORY_PROGRESS_PAYMENTS" "Inventories - Raw Materials" => "INVENTORY_RAW_MATERIALS" "Inventories - Work in Progress" => "INVENTORY_WORK_IN_PROGRESS" "Investments in Unconsolidated Subsidiaries" => "INVESTMENTS_IN_UNCONCSOLIDATE" "Long Term Debt" => "LONG_TERM_DEBT" "Long Term Debt Excl. Lease Liabilities" => "LONG_TERM_DEBT_EXCL_CAPITAL_LEASE" "Long Term Investments" => "LONG_TERM_INVESTMENTS" "Minority Interest" => "MINORITY_INTEREST" "Net Debt" => "NET_DEBT" "Net Intangible Assets" => "INTANGIBLES_NET" "Net Property/Plant/Equipment" => "PPE_TOTAL_NET" "Note Receivable - Long Term" => "LONG_TERM_NOTE_RECEIVABLE" "Notes Payable" => "NOTES_PAYABLE_SHORT_TERM_DEBT" "Operating Lease Liabilities" => "OPERATING_LEASE_LIABILITIES" "Other Common Equity" => "OTHER_COMMON_EQUITY" "Other Current Assets, Total" => "OTHER_CURRENT_ASSETS_TOTAL" "Other Current Liabilities" => "OTHER_CURRENT_LIABILITIES" "Other Intangibles, Net" => "OTHER_INTANGIBLES_NET" "Other Investments" => "OTHER_INVESTMENTS" "Other Long Term Assets, Total" => "LONG_TERM_OTHER_ASSETS_TOTAL" "Other Non-current Liabilities, Total" => "OTHER_LIABILITIES_TOTAL" "Other Receivables" => "OTHER_RECEIVABLES" "Other Short Term Debt" => "OTHER_SHORT_TERM_DEBT" "Paid in Capital" => "PAID_IN_CAPITAL" "Preferred Stock, Carrying Value" => "PREFERRED_STOCK_CARRYING_VALUE" "Prepaid Expenses" => "PREPAID_EXPENSES" "Provision for Risks & Charge" => "PROVISION_F_RISKS" "Retained Earnings" => "RETAINED_EARNINGS" "Shareholders' Equity" => "SHRHLDRS_EQUITY" "Short Term Debt" => "SHORT_TERM_DEBT" "Short Term Debt Excl. Current Portion of LT debt" => "SHORT_TERM_DEBT_EXCL_CURRENT_PORT" "Short Term Investments" => "SHORT_TERM_INVEST" "Tangible Book Value Per Share" => "BOOK_TANGIBLE_PER_SHARE" "Total Assets" => "TOTAL_ASSETS" "Total Current Assets" => "TOTAL_CURRENT_ASSETS" "Total Current Liabilities" => "TOTAL_CURRENT_LIABILITIES" "Total Debt" => "TOTAL_DEBT" "Total Equity" => "TOTAL_EQUITY" "Total Inventory" => "TOTAL_INVENTORY" "Total Liabilities" => "TOTAL_LIABILITIES" "Total Liabilities & Shareholders' Equities" => "TOTAL_LIABILITIES_SHRHLDRS_EQUITY" "Total Non-current Assets" => "TOTAL_NON_CURRENT_ASSETS" "Total Non-current Liabilities" => "TOTAL_NON_CURRENT_LIABILITIES" "Total Receivables, Net" => "TOTAL_RECEIVABLES_NET" "Treasury Stock - Common" => "TREASURY_STOCK_COMMON" // Cash flow "Amortization" => "AMORTIZATION" "Capital Expenditures" => "CAPITAL_EXPENDITURES" "Capital Expenditures - Fixed Assets" => "CAPITAL_EXPENDITURES_FIXED_ASSETS" "Capital Expenditures - Other Assets" => "CAPITAL_EXPENDITURES_OTHER_ASSETS" "Cash From Financing Activities" => "CASH_F_FINANCING_ACTIVITIES" "Cash From Investing Activities" => "CASH_F_INVESTING_ACTIVITIES" "Cash From Operating Activities" => "CASH_F_OPERATING_ACTIVITIES" "Change in Accounts Payable" => "CHANGE_IN_ACCOUNTS_PAYABLE" "Change in Accounts Receivable" => "CHANGE_IN_ACCOUNTS_RECEIVABLE" "Change in Accrued Expenses" => "CHANGE_IN_ACCRUED_EXPENSES" "Change in Inventories" => "CHANGE_IN_INVENTORIES" "Change in Other Assets/Liabilities" => "CHANGE_IN_OTHER_ASSETS" "Change in Taxes Payable" => "CHANGE_IN_TAXES_PAYABLE" "Changes in Working Capital" => "CHANGES_IN_WORKING_CAPITAL" "Common Dividends Paid" => "COMMON_DIVIDENDS_CASH_FLOW" "Deferred Taxes (Cash Flow)" => "CASH_FLOW_DEFERRED_TAXES" "Depreciation & Amortization (Cash Flow)" => "CASH_FLOW_DEPRECATION_N_AMORTIZATION" "Depreciation/depletion" => "DEPRECIATION_DEPLETION" "Financing Activities – Other Sources" => "OTHER_FINANCING_CASH_FLOW_SOURCES" "Financing Activities – Other Uses" => "OTHER_FINANCING_CASH_FLOW_USES" "Free Cash Flow" => "FREE_CASH_FLOW" "Funds From Operations" => "FUNDS_F_OPERATIONS" "Investing Activities – Other Sources" => "OTHER_INVESTING_CASH_FLOW_SOURCES" "Investing Activities – Other Uses" => "OTHER_INVESTING_CASH_FLOW_USES" "Issuance of Long Term Debt" => "SUPPLYING_OF_LONG_TERM_DEBT" "Issuance/Retirement of Debt, Net" => "ISSUANCE_OF_DEBT_NET" "Issuance/Retirement of Long Term Debt" => "ISSUANCE_OF_LONG_TERM_DEBT" "Issuance/Retirement of Other Debt" => "ISSUANCE_OF_OTHER_DEBT" "Issuance/Retirement of Short Term Debt" => "ISSUANCE_OF_SHORT_TERM_DEBT" "Issuance/Retirement of Stock, Net" => "ISSUANCE_OF_STOCK_NET" "Net Income (Cash Flow)" => "NET_INCOME_STARTING_LINE" "Non-cash Items" => "NON_CASH_ITEMS" "Other Financing Cash Flow Items, Total" => "OTHER_FINANCING_CASH_FLOW_ITEMS_TOTAL" "Other Investing Cash Flow Items, Total" => "OTHER_INVESTING_CASH_FLOW_ITEMS_TOTAL" "Preferred Dividends Paid" => "PREFERRED_DIVIDENDS_CASH_FLOW" "Purchase of Investments" => "PURCHASE_OF_INVESTMENTS" "Purchase/Acquisition of Business" => "PURCHASE_OF_BUSINESS" "Purchase/Sale of Business, Net" => "PURCHASE_SALE_BUSINESS" "Purchase/Sale of Investments, Net" => "PURCHASE_SALE_INVESTMENTS" "Reduction of Long Term Debt" => "REDUCTION_OF_LONG_TERM_DEBT" "Repurchase of Common & Preferred Stock" => "PURCHASE_OF_STOCK" "Sale of Common & Preferred Stock" => "SALE_OF_STOCK" "Sale of Fixed Assets & Businesses" => "SALES_OF_BUSINESS" "Sale/Maturity of Investments" => "SALES_OF_INVESTMENTS" "Total Cash Dividends Paid" => "TOTAL_CASH_DIVIDENDS_PAID" // Income statements "After Tax Other Income/Expense" => "AFTER_TAX_OTHER_INCOME" "Average Basic Shares Outstanding" => "BASIC_SHARES_OUTSTANDING" "Basic Earnings Per Share (Basic EPS)" => "EARNINGS_PER_SHARE_BASIC" "Cost of Goods Sold" => "COST_OF_GOODS" "Deprecation and Amortization" => "DEP_AMORT_EXP_INCOME_S" "Diluted Earnings Per Share (Diluted EPS)" => "EARNINGS_PER_SHARE_DILUTED" "Diluted Net Income Available to Common Stockholders" => "DILUTED_NET_INCOME" "Diluted Shares Outstanding" => "DILUTED_SHARES_OUTSTANDING" "Dilution Adjustment" => "DILUTION_ADJUSTMENT" "Discontinued Operations" => "DISCONTINUED_OPERATIONS" "EBIT" => "EBIT" "EBITDA" => "EBITDA" "Equity in Earnings" => "EQUITY_IN_EARNINGS" "Gross Profit" => "GROSS_PROFIT" "Interest Capitalized" => "INTEREST_CAPITALIZED" "Interest Expense on Debt" => "INTEREST_EXPENSE_ON_DEBT" "Interest Expense, Net of Interest Capitalized" => "NON_OPER_INTEREST_EXP" "Miscellaneous Non-operating Expense" => "OTHER_INCOME" "Net Income" => "NET_INCOME" "Net Income Before Discontinued Operations" => "NET_INCOME_BEF_DISC_OPER" "Non-controlling/Minority Interest" => "MINORITY_INTEREST_EXP" "Non-operating Income, Excl. Interest Expenses" => "NON_OPER_INCOME" "Non-operating Income, Total" => "TOTAL_NON_OPER_INCOME" "Non-operating Interest Income" => "NON_OPER_INTEREST_INCOME" "Operating Expenses (Excl. COGS)" => "OPERATING_EXPENSES" "Operating Income" => "OPER_INCOME" "Other Cost of Goods Sold" => "COST_OF_GOODS_EXCL_DEP_AMORT" "Other Operating Expenses, Total" => "OTHER_OPER_EXPENSE_TOTAL" "Preferred Dividends" => "PREFERRED_DIVIDENDS" "Pretax Equity in Earnings" => "PRETAX_EQUITY_IN_EARNINGS" "Pretax Income" => "PRETAX_INCOME" "Research & Development" => "RESEARCH_AND_DEV" "Selling/General/Admin Expenses, Other" => "SELL_GEN_ADMIN_EXP_OTHER" "Selling/General/Admin Expenses, Total" => "SELL_GEN_ADMIN_EXP_TOTAL" "Taxes" => "INCOME_TAX" "Total Operating Expenses" => "TOTAL_OPER_EXPENSE" "Total Revenue" => "TOTAL_REVENUE" "Unusual Income/Expense" => "UNUSUAL_EXPENSE_INC" // Statistics "Accruals" => "ACCRUALS_RATIO" "Altman Z-score" => "ALTMAN_Z_SCORE" "Asset Turnover" => "ASSET_TURNOVER" "Beneish M-score" => "BENEISH_M_SCORE" "Buyback Yield %" => "BUYBACK_YIELD" "COGS to Revenue Ratio" => "COGS_TO_REVENUE" "Cash Conversion Cycle" => "CASH_CONVERSION_CYCLE" "Cash to Debt Ratio" => "CASH_TO_DEBT" "Current Ratio" => "CURRENT_RATIO" "Days Inventory" => "DAYS_INVENT" "Days Payable" => "DAYS_PAY" "Days Sales Outstanding" => "DAY_SALES_OUT" "Debt to EBITDA Ratio" => "DEBT_TO_EBITDA" "Debt to Assets Ratio" => "DEBT_TO_ASSET" "Debt to Equity Ratio" => "DEBT_TO_EQUITY" "Debt to Revenue Ratio" => "DEBT_TO_REVENUE" "Dividend Payout Ratio %" => "DIVIDEND_PAYOUT_RATIO" "Dividend Yield %" => "DIVIDENDS_YIELD" "Dividends Per Share - Common Stock Primary Issue" => "DPS_COMMON_STOCK_PRIM_ISSUE" "EBITDA Margin %" => "EBITDA_MARGIN" "EPS Basic One Year Growth" => "EARNINGS_PER_SHARE_BASIC_ONE_YEAR_GROWTH" "EPS Diluted One Year Growth" => "EARNINGS_PER_SHARE_DILUTED_ONE_YEAR_GROWTH" "EPS Estimates" => "EARNINGS_ESTIMATE" "Effective Interest Rate on Debt %" => "EFFECTIVE_INTEREST_RATE_ON_DEBT" "Enterprise Value" => "ENTERPRISE_VALUE" "Enterprise Value to EBIT Ratio" => "EV_EBIT" "Enterprise Value to EBITDA Ratio" => "ENTERPRISE_VALUE_EBITDA" "Enterprise Value to Revenue Ratio" => "EV_REVENUE" "Equity to Assets Ratio" => "EQUITY_TO_ASSET" "Float Shares Outstanding" => "FLOAT_SHARES_OUTSTANDING" "Free Cash Flow Margin %" => "FREE_CASH_FLOW_MARGIN" "Fulmer H Factor" => "FULMER_H_FACTOR" "Goodwill to Assets Ratio" => "GOODWILL_TO_ASSET" "Graham's Number" => "GRAHAM_NUMBERS" "Gross Margin %" => "GROSS_MARGIN" "Gross Profit to Assets Ratio" => "GROSS_PROFIT_TO_ASSET" "Interest Coverage" => "INTERST_COVER" "Inventory to Revenue Ratio" => "INVENT_TO_REVENUE" "Inventory Turnover" => "INVENT_TURNOVER" "KZ Index" => "KZ_INDEX" "Long Term Debt to Total Assets Ratio" => "LONG_TERM_DEBT_TO_ASSETS" "Net Current Asset Value Per Share" => "NCAVPS_RATIO" "Net Income Per Employee" => "NET_INCOME_PER_EMPLOYEE" "Net Margin %" => "NET_MARGIN" "Number of Employees" => "NUMBER_OF_EMPLOYEES" "Operating Earnings Yield %" => "OPERATING_EARNINGS_YIELD" "Operating Margin %" => "OPERATING_MARGIN" "PEG Ratio" => "PEG_RATIO" "Piotroski F-score" => "PIOTROSKI_F_SCORE" "Price Earnings Ratio Forward" => "PRICE_EARNINGS_FORWARD" "Price Sales Ratio Forward" => "PRICE_SALES_FORWARD" "Quality Ratio" => "QUALITY_RATIO" "Quick Ratio" => "QUICK_RATIO" "Research & Development to Revenue Ratio" => "RESEARCH_AND_DEVELOP_TO_REVENUE" "Return on Assets %" => "RETURN_ON_ASSETS" "Return on Common Equity %" => "RETURN_ON_COMMON_EQUITY" "Return on Equity %" => "RETURN_ON_EQUITY" "Return on Equity Adjusted to Book Value %" => "RETURN_ON_EQUITY_ADJUST_TO_BOOK" "Return on Invested Capital %" => "RETURN_ON_INVESTED_CAPITAL" "Return on Tangible Assets %" => "RETURN_ON_TANG_ASSETS" "Return on Tangible Equity %" => "RETURN_ON_TANG_EQUITY" "Revenue Estimates" => "SALES_ESTIMATES" "Revenue One Year Growth" => "REVENUE_ONE_YEAR_GROWTH" "Revenue Per Employee" => "REVENUE_PER_EMPLOYEE" "Shares Buyback Ratio %" => "SHARE_BUYBACK_RATIO" "Sloan Ratio %" => "SLOAN_RATIO" "Springate Score" => "SPRINGATE_SCORE" "Sustainable Growth Rate" => "SUSTAINABLE_GROWTH_RATE" "Tangible Common Equity Ratio" => "TANGIBLE_COMMON_EQUITY_RATIO" "Tobin's Q (Approximate)" => "TOBIN_Q_RATIO" "Total Common Shares Outstanding" => "TOTAL_SHARES_OUTSTANDING" "Zmijewski Score" => "ZMIJEWSKI_SCORE" => na // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // | COMPUTING | // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // Cell Color highCol(chk, min, mix, val, col, x) => out = x % 2 == 0 ? cClCol : (cShdCol ? color.new(cClCol, 20) : cClCol) if chk out := min <= val and mix >= val ? col : out out // String Format fmt(a, x) => str.contains(a, "%") ? str.tostring(x, format.percent) : math.abs(x) < 100000 ? str.tostring(x, "#.###") : str.tostring(x, format.volume) // Input Columns inCol = array.from("Instruments", col01, col02) // Title Columns titlCol = array.new<string>(na) array.push(titlCol, "Instruments") for i = 1 to array.size(inCol) - 1 if not na(finId(array.get(inCol, i))) array.push(titlCol, array.get(inCol, i)) // Importing Financial Values spreadSheet = matrix.new<string>(na, array.size(titlCol), na) spreadSheetClr = matrix.new<color> (na, array.size(titlCol) , cClCol) finVals(sym, chk) => out = array.new<string>(na) outCl = array.new<color>(na) out01 = request.financial(sym, finId(col01), prid == "Year" ? "FY" : "FQ", ignore_invalid_symbol = true, currency = curn) out02 = request.financial(sym, finId(col02), prid == "Year" ? "FY" : "FQ", ignore_invalid_symbol = true, currency = curn) if chk numRow = matrix.rows(spreadSheet) val = array.from(out01, out02) valCl = array.from( highCol(chk01, h01mn, h01mx, out01, clr01, numRow), highCol(chk02, h02mn, h02mx, out02, clr02, numRow)) // Output array.push(out, only_symbol(sym)) array.push(outCl, not hidsyms ? (numRow % 2 == 0 ? cClCol : (cShdCol ? color.new(cClCol, 20) : cClCol)) : na) for i = 1 to array.size(inCol) - 1 if not na(finId(array.get(inCol, i))) array.push(out, fmt(array.get(inCol, i), array.get(val, i - 1))) array.push(outCl, array.get(valCl, i - 1)) if array.size(inCol) > 0 matrix.add_row(spreadSheet, numRow, out) matrix.add_row(spreadSheetClr, numRow, outCl) finVals(s01, c01), finVals(s02, c02), finVals(s03, c03), finVals(s04, c04), finVals(s05, c05), finVals(s06, c06), finVals(s07, c07), finVals(s08, c08), finVals(s09, c09), finVals(s10, c10), finVals(s11, c11), finVals(s12, c12), finVals(s13, c13), finVals(s14, c14), finVals(s15, c15), finVals(s16, c16), finVals(s17, c17), finVals(s18, c18), finVals(s19, c19), finVals(s20, c20), // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // | TABLE | // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // Get Tbale Location & Size locNsze(x) => y = str.split(str.lower(x), " ") out = "" for i = 0 to array.size(y) - 1 out := out + array.get(y, i) if i != array.size(y) - 1 out := out + "_" out // New Line for Long Title Name title(x) => y = str.split(x, " ") n = 0 out = "" if x == "Instruments" out := "‏\n" + x +"\n‏ " else for i = 0 to array.size(y) - 1 n += str.length(array.get(y, i)) if n > 12 out := out + array.get(y, i) + "\n" n := 0 else out := out + array.get(y, i) + " " while str.length(out) < 9 out := "‏ " + out + " ‏" out // Define Table var tbl = table.new(locNsze(tablePos), array.size(titlCol) + 1, matrix.rows(spreadSheet) + 2, frame_width = 1, frame_color = color.new(tBgCol, 100), border_width = 1, border_color = color.new(tBgCol, 100)) // Cell cell(col, row, txt, color) => table.cell(tbl, col, row, txt, text_color = na(color) ? na : txtCol, bgcolor = color, text_size = locNsze(tableSiz)) // Plot Table if barstate.islast table.clear(tbl, 0, 0, array.size(titlCol), matrix.rows(spreadSheet) + 1) k = 0, w = 0 if vrtAdj < 0 table.cell(tbl, 0, k, "", height = math.abs(vrtAdj)) k += 1 else if vrtAdj > 0 table.cell(tbl, 0, matrix.rows(spreadSheet) + 1, "", height = math.abs(vrtAdj)) if hrzAdj < 0 table.cell(tbl, array.size(titlCol), 0, "", width = math.abs(hrzAdj)) else if hrzAdj > 0 table.cell(tbl, w, 0, "", width = math.abs(hrzAdj)) w += 1 for i = 0 to array.size(titlCol) - 1 cell(i + w , k, title(array.get(titlCol, i)), hidTitl ? na : (i == 0 and hidsyms) ? na : tBgCol) k += 1 for j = 0 to matrix.rows(spreadSheet) - 1 for i = 0 to matrix.columns(spreadSheet) - 1 cell(i + w, k, matrix.get(spreadSheet, j, i), matrix.get(spreadSheetClr, j, i)) k += 1
Harmonic Pattern Table UDT
https://www.tradingview.com/script/jzNP6kMU-Harmonic-Pattern-Table-UDT/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
116
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © RozaniGhani-RG // Credits to Scott M Carney, author of Harmonic Trading Volume 3: Reaction vs. Reversal // Alt Bat - Page 101 // Bat - Page 98 // Crab - Page 104 // Gartley - Page 92 // Butterfly - Page 113 // Deep Crab - Page 107 // Shark - Page 119 - 220 // Point D and Stop Loss - Page 174 //@version=5 indicator('Harmonic Pattern Table UDT', 'HPT', true) // 0. Inputs // 1. Switch // 2. Variable // 3. Arrays // 4. Type // 5. Construct //#region ———————————————————— 0. Inputs T0 = 'Small font size recommended for mobile app or multiple layout' T1 = 'Untick to hide' T2 = 'Tick to hide' G0 = 'Titles' G1 = 'Harmonic Animals' i_s_font = input.string('normal', 'Font size', tooltip = T0, options = ['tiny', 'small', 'normal', 'large', 'huge']) i_s_Y = input.string( 'top', 'Table Position', inline = '0', options = ['top', 'middle', 'bottom']) i_s_X = input.string( 'right', '', inline = '0', options = ['left', 'center', 'right']) i_s_rng = input.string( ' to ', 'Range Text', options = [' to ', ' - ', ' ; ']) i_b_title = input.bool( true, 'Title', inline = '1', group = G0, tooltip = 'Untick to hide column') i_b_no = input.bool( true, 'No     ', inline = '2', group = G0) i_b_xab = input.bool( true, 'Point B', inline = '2', group = G0) i_b_abc = input.bool( true, 'Point C  ', inline = '2', group = G0) i_b_dbc = input.bool( true, 'Layering', inline = '3', group = G0) i_b_prz = input.bool( true, 'PRZ   ', inline = '3', group = G0) i_b_sl = input.bool( true, 'Stop Loss', inline = '3', group = G0) i_s_pet = input.string( 'Both', 'Animal Display', options = ['Text', 'Emoji', 'Both']) i_b_abat = input.bool( true, 'Alt Bat    ', inline = '4', group = G1, tooltip = 'Untick to hide row') i_b_bat = input.bool( true, 'Bat      ', inline = '4', group = G1) i_b_crab = input.bool( true, 'Crab      ', inline = '4', group = G1) i_b_gart = input.bool( true, 'Gartley    ', inline = '5', group = G1) i_b_bfly = input.bool( true, 'Butterfly ', inline = '5', group = G1) i_b_dcrab = input.bool( true, 'Deep Crab', inline = '5', group = G1) i_b_shark = input.bool( true, 'Shark', inline = '6', group = G1) i_i_shark = input.float( 0.886, '', inline = '6', group = G1, options = [0.886, 1.13]) //#endregion //#region ———————————————————— 1. Switch [str_ABAT, str_BAT, str_CRAB, str_GART, str_BFLY, str_DCRAB, str_SHARK] = switch i_s_pet // [ str_ABAT, str_BAT, str_CRAB, str_GART, str_BFLY, str_DCRAB, str_SHARK] 'Text' => ['ALT BAT', 'BAT', 'CRAB', 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB', 'SHARK'] 'Emoji' => [ '🦇', '🦇', '🦀', '👨', '🦋', '🦞', '🦈'] 'Both' => ['ALT BAT 🦇', 'BAT 🦇', 'CRAB 🦀', 'GARTLEY 👨', 'BUTTERFLY 🦋', 'DEEP CRAB 🦞', 'SHARK 🦈'] sl_shark = switch i_i_shark 0.886 => 1.13 1.13 => 1.27 //#endregion //#region ———————————————————— 2. Variable var TBL = table.new(i_s_Y + '_' + i_s_X, 7, 8, border_width = 1) //#endregion //#region ———————————————————— 3. Arrays bool_pet = array.new_bool(7) bool_title = array.new_bool(7) pet = array.new_string(7) // Pet name BXA1 = array.new_float(7), BXA2 = array.new_float(7) // BXA CAB1 = array.new_float(7), CAB2 = array.new_float(7) // CAB DBC1 = array.new_float(7), DBC2 = array.new_float(7) // DBC DXA = array.new_float(7), ESL = array.new_float(7) // DXA, SL col_bg = array.from(color.white, color.white, color.red, color.red, color.blue, color.blue, color.blue) str_title = array.from( 'NO', 'HARMONIC\nPATTERN', 'B = XA', 'C = AB\n(POINT C)', 'D = BC\n(LAYERING)', 'D = XA\n(PRZ)', 'SL = XA\n(STOP LOSS)') array.set(bool_pet, 0, i_b_abat), array.set(bool_title, 0, i_b_title) array.set(bool_pet, 1, i_b_bat), array.set(bool_title, 1, i_b_no) array.set(bool_pet, 2, i_b_crab), array.set(bool_title, 2, i_b_xab) array.set(bool_pet, 3, i_b_gart), array.set(bool_title, 3, i_b_abc) array.set(bool_pet, 4, i_b_bfly), array.set(bool_title, 4, i_b_dbc) array.set(bool_pet, 5, i_b_dcrab), array.set(bool_title, 5, i_b_prz) array.set(bool_pet, 6, i_b_shark), array.set(bool_title, 6, i_b_sl) //#endregion //#region ———————————————————— 4. Type type animal int index = 0 // Reference number string name = 'ALT BAT' // Pet name float B_XA_min = 0.371 // B = XA Min float B_XA_max = 0.382 // Max float C_AB_min = 0.382 // C = AB Min float C_AB_max = 0.886 // Max float D_BC_min = 2.000 // D = BC Min float D_BC_max = 3.618 // Max float D_XA_nom = 1.130 // D = XA float E_SL_nom = 1.270 // SL harmonicDB(animal spec) => array.set( pet, spec.index, spec.name) array.set(BXA1, spec.index, spec.B_XA_min) array.set(BXA2, spec.index, spec.B_XA_max) array.set(CAB1, spec.index, spec.C_AB_min) array.set(CAB2, spec.index, spec.C_AB_max) array.set(DBC1, spec.index, spec.D_BC_min) array.set(DBC2, spec.index, spec.D_BC_max) array.set( DXA, spec.index, spec.D_XA_nom) array.set( ESL, spec.index, spec.E_SL_nom) // Animal BXA1 BXA2 CAB1 CAB2 DBC1 DBC2 DXA SL ABAT = animal.new(0, str_ABAT, 0.371, 0.382, 0.382, 0.886, 2.000, 3.618, 1.130, 1.270) BAT = animal.new(1, str_BAT, 0.382, 0.500, 0.382, 0.886, 1.618, 2.618, 0.886, 1.130) CRAB = animal.new(2, str_CRAB, 0.382, 0.618, 0.382, 0.886, 2.618, 3.618, 1.618, 2.000) GART = animal.new(3, str_GART, 0.599, 0.637, 0.382, 0.886, 1.130, 1.618, 0.786, 1.000) BFLY = animal.new(4, str_BFLY, 0.762, 0.810, 0.382, 0.886, 1.618, 2.240, 1.270, 1.414) DCRAB = animal.new(5, str_DCRAB , 0.886, 0.930, 0.382, 0.886, 2.000, 3.618, 1.618, 2.000) SHARK = animal.new(6, str_SHARK , 0.382, 0.618, 1.130, 1.618, 1.618, 2.240, i_i_shark, sl_shark) harmonicDB(ABAT) harmonicDB(BAT) harmonicDB(CRAB) harmonicDB(GART) harmonicDB(BFLY) harmonicDB(DCRAB) harmonicDB(SHARK) //#endregion //#region ———————————————————— 5. Custom functions floatToString( float[] id, int index) => str.tostring(array.get(id, index), '0.000') doubleToString(float[] id1, float[] id2, int index) => str.tostring(array.get(id1, index), '0.000') + i_s_rng + str.tostring(array.get(id2, index), '0.000') tertiaryColor( float[] id, int index) => array.get(id, index) >= 1 ? color.blue : color.red //#endregion //#region ———————————————————— 6. Construct if barstate.islast for i = 0 to 6 if array.get(bool_title, i) table.cell( TBL, i, 0, array.get(str_title, i), text_size = i_s_font, bgcolor = array.get(col_bg, i)) if array.get(bool_pet, i) table.cell( TBL, 1, i + 1, array.get(pet, i), text_size = i_s_font, bgcolor = color.white, text_halign = text.align_right) if i_b_no table.cell(TBL, 0, i + 1, str.tostring(i + 1), text_size = i_s_font, bgcolor = color.white) if i_b_xab table.cell(TBL, 2, i + 1, doubleToString(BXA1, BXA2, i), text_size = i_s_font, bgcolor = tertiaryColor(BXA1, i)) if i_b_abc table.cell(TBL, 3, i + 1, doubleToString(CAB1, CAB2, i), text_size = i_s_font, bgcolor = tertiaryColor(CAB1, i)) if i_b_dbc table.cell(TBL, 4, i + 1, doubleToString(DBC1, DBC2, i), text_size = i_s_font, bgcolor = tertiaryColor(DBC1, i)) if i_b_prz table.cell(TBL, 5, i + 1, floatToString(DXA, i), text_size = i_s_font, bgcolor = tertiaryColor(DXA, i)) if i_b_sl table.cell(TBL, 6, i + 1, floatToString(ESL, i), text_size = i_s_font, bgcolor = tertiaryColor(ESL, i)) //#endregion
OECD CLI Diffusion Index
https://www.tradingview.com/script/mgE1JRVy-OECD-CLI-Diffusion-Index/
sl-wk
https://www.tradingview.com/u/sl-wk/
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/ // © sl-wk //@version=5 indicator("OECD CLI Diffusion Index") getDiff(_data) => _diff_yoy = na(_data[11]) ? 0 : (_data - _data[11] > 0 ? 1 : 0) _count = na(_data[11]) ? 0 : 1 [_diff_yoy, _count] AUS = request.quandl("OECD/MEI_CLI_LOLITONO_AUS_M", barmerge.gaps_off, 0) [AUS_Diff, AUS_count] = getDiff(AUS) AUT = request.quandl("OECD/MEI_CLI_LOLITONO_AUT_M", barmerge.gaps_off, 0) [AUT_Diff, AUT_count] = getDiff(AUT) BEL = request.quandl("OECD/MEI_CLI_LOLITONO_BEL_M", barmerge.gaps_off, 0) [BEL_Diff, BEL_count] = getDiff(BEL) BRA = request.quandl("OECD/MEI_CLI_LOLITONO_BRA_M", barmerge.gaps_off, 0) [BRA_Diff, BRA_count] = getDiff(BRA) CAN = request.quandl("OECD/MEI_CLI_LOLITONO_CAN_M", barmerge.gaps_off, 0) [CAN_Diff, CAN_count] = getDiff(CAN) CHE = request.quandl("OECD/MEI_CLI_LOLITONO_CHE_M", barmerge.gaps_off, 0) [CHE_Diff, CHE_count] = getDiff(CHE) CHL = request.quandl("OECD/MEI_CLI_LOLITONO_CHL_M", barmerge.gaps_off, 0) [CHL_Diff, CHL_count] = getDiff(CHL) CHN = request.quandl("OECD/MEI_CLI_LOLITONO_CHN_M", barmerge.gaps_off, 0) [CHN_Diff, CHN_count] = getDiff(CHN) COL = request.quandl("OECD/MEI_CLI_LOLITONO_COL_M", barmerge.gaps_off, 0) [COL_Diff, COL_count] = getDiff(COL) CZE = request.quandl("OECD/MEI_CLI_LOLITONO_CZE_M", barmerge.gaps_off, 0) [CZE_Diff, CZE_count] = getDiff(CZE) DEU = request.quandl("OECD/MEI_CLI_LOLITONO_DEU_M", barmerge.gaps_off, 0) [DEU_Diff, DEU_count] = getDiff(DEU) DNK = request.quandl("OECD/MEI_CLI_LOLITONO_DNK_M", barmerge.gaps_off, 0) [DNK_Diff, DNK_count] = getDiff(DNK) ESP = request.quandl("OECD/MEI_CLI_LOLITONO_ESP_M", barmerge.gaps_off, 0) [ESP_Diff, ESP_count] = getDiff(ESP) EST = request.quandl("OECD/MEI_CLI_LOLITONO_EST_M", barmerge.gaps_off, 0) [EST_Diff, EST_count] = getDiff(EST) FIN = request.quandl("OECD/MEI_CLI_LOLITONO_FIN_M", barmerge.gaps_off, 0) [FIN_Diff, FIN_count] = getDiff(FIN) FRA = request.quandl("OECD/MEI_CLI_LOLITONO_FRA_M", barmerge.gaps_off, 0) [FRA_Diff, FRA_count] = getDiff(FRA) GBR = request.quandl("OECD/MEI_CLI_LOLITONO_GBR_M", barmerge.gaps_off, 0) [GBR_Diff, GBR_count] = getDiff(GBR) GRC = request.quandl("OECD/MEI_CLI_LOLITONO_GRC_M", barmerge.gaps_off, 0) [GRC_Diff, GRC_count] = getDiff(GRC) HUN = request.quandl("OECD/MEI_CLI_LOLITONO_HUN_M", barmerge.gaps_off, 0) [HUN_Diff, HUN_count] = getDiff(HUN) IDN = request.quandl("OECD/MEI_CLI_LOLITONO_IDN_M", barmerge.gaps_off, 0) [IDN_Diff, IDN_count] = getDiff(IDN) IRL = request.quandl("OECD/MEI_CLI_LOLITONO_IRL_M", barmerge.gaps_off, 0) [IRL_Diff, IRL_count] = getDiff(IRL) ISL = request.quandl("OECD/MEI_CLI_LOLITONO_ISL_M", barmerge.gaps_off, 0) [ISL_Diff, ISL_count] = getDiff(ISL) ISR = request.quandl("OECD/MEI_CLI_LOLITONO_ISR_M", barmerge.gaps_off, 0) [ISR_Diff, ISR_count] = getDiff(ISR) ITA = request.quandl("OECD/MEI_CLI_LOLITONO_ITA_M", barmerge.gaps_off, 0) [ITA_Diff, ITA_count] = getDiff(ITA) JPN = request.quandl("OECD/MEI_CLI_LOLITONO_JPN_M", barmerge.gaps_off, 0) [JPN_Diff, JPN_count] = getDiff(JPN) KOR = request.quandl("OECD/MEI_CLI_LOLITONO_KOR_M", barmerge.gaps_off, 0) [KOR_Diff, KOR_count] = getDiff(KOR) MEX = request.quandl("OECD/MEI_CLI_LOLITONO_MEX_M", barmerge.gaps_off, 0) [MEX_Diff, MEX_count] = getDiff(MEX) NLD = request.quandl("OECD/MEI_CLI_LOLITONO_NLD_M", barmerge.gaps_off, 0) [NLD_Diff, NLD_count] = getDiff(NLD) NOR = request.quandl("OECD/MEI_CLI_LOLITONO_NOR_M", barmerge.gaps_off, 0) [NOR_Diff, NOR_count] = getDiff(NOR) POL = request.quandl("OECD/MEI_CLI_LOLITONO_POL_M", barmerge.gaps_off, 0) [POL_Diff, POL_count] = getDiff(POL) PRT = request.quandl("OECD/MEI_CLI_LOLITONO_PRT_M", barmerge.gaps_off, 0) [PRT_Diff, PRT_count] = getDiff(PRT) RUS = request.quandl("OECD/MEI_CLI_LOLITONO_RUS_M", barmerge.gaps_off, 0) [RUS_Diff, RUS_count] = getDiff(RUS) SVK = request.quandl("OECD/MEI_CLI_LOLITONO_SVK_M", barmerge.gaps_off, 0) [SVK_Diff, SVK_count] = getDiff(SVK) SVN = request.quandl("OECD/MEI_CLI_LOLITONO_SVN_M", barmerge.gaps_off, 0) [SVN_Diff, SVN_count] = getDiff(SVN) SWE = request.quandl("OECD/MEI_CLI_LOLITONO_SWE_M", barmerge.gaps_off, 0) [SWE_Diff, SWE_count] = getDiff(SWE) TUR = request.quandl("OECD/MEI_CLI_LOLITONO_TUR_M", barmerge.gaps_off, 0) [TUR_Diff, TUR_count] = getDiff(TUR) USA = request.quandl("OECD/MEI_CLI_LOLITONO_USA_M", barmerge.gaps_off, 0) [USA_Diff, USA_count] = getDiff(USA) ZAF = request.quandl("OECD/MEI_CLI_LOLITONO_ZAF_M", barmerge.gaps_off, 0) [ZAF_Diff, ZAF_count] = getDiff(ZAF) diffusion = AUS_Diff+AUT_Diff+BEL_Diff+BRA_Diff+CAN_Diff+CHE_Diff+CHL_Diff+CHN_Diff+COL_Diff+CZE_Diff+DEU_Diff+DNK_Diff+ESP_Diff+EST_Diff+FIN_Diff+FRA_Diff+GBR_Diff+GRC_Diff+HUN_Diff+IDN_Diff+IRL_Diff+ISL_Diff+ISR_Diff+ITA_Diff+JPN_Diff+KOR_Diff+MEX_Diff+NLD_Diff+NOR_Diff+POL_Diff+PRT_Diff+RUS_Diff+SVK_Diff+SVN_Diff+SWE_Diff+TUR_Diff+USA_Diff+ZAF_Diff count = AUS_count+AUT_count+BEL_count+BRA_count+CAN_count+CHE_count+CHL_count+CHN_count+COL_count+CZE_count+DEU_count+DNK_count+ESP_count+EST_count+FIN_count+FRA_count+GBR_count+GRC_count+HUN_count+IDN_count+IRL_count+ISL_count+ISR_count+ITA_count+JPN_count+KOR_count+MEX_count+NLD_count+NOR_count+POL_count+PRT_count+RUS_count+SVK_count+SVN_count+SWE_count+TUR_count+USA_count+ZAF_count diffusion_index = diffusion/count * 100 plot(diffusion_index, color=color.rgb(221,34,255), linewidth=2)
Assassin's Grid
https://www.tradingview.com/script/18AQOuc3/
Good-Vibe
https://www.tradingview.com/u/Good-Vibe/
223
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Good-Vibe //@version=5 indicator(title = "Assassin's Grid", shorttitle = "AAGG💥", overlay = true, max_labels_count = 500) // 1.0 INPUTS // 1.1 Grid parameters WOption = input.string('Geometric (% Sell)', 'Width Type', ['Arithmetic (Price)', 'Geometric (% Sell)', 'Geometric (% Fall)'], group = "GRID") Width = input.float(6.5, 'Width Parameter', minval = 0, step = 0.5, group = "GRID") ppPeriod = input.timeframe('W', 'Pivot Point Resolution', group = "GRID") MARes = input.timeframe('240', 'EMA Resolution', group = "GRID") MALength = input.int(200, 'MA Length', minval = 1, group = "GRID") // 1.2 Buy BuyType = input.string('Cash / n Buys +', 'Buy Type', ['Contracts', 'Cash', '% Cash', 'Cash / n Buys', 'Cash / n Buys +'], group = "BUY") BuyQ = input.float(10.0, 'Contracts / Cash / % Cash', minval = 0, group = "BUY") NBuysUp = input.int(6, 'N Buys over MA', minval = 1, maxval = 30, group = "BUY") NBuysDown = input.int(6, 'N Buys under MA (Max.)', minval = 1, maxval = 30, group = "BUY") LastXtrades = input.int(2, 'Buy all in last Trades', minval = 0, maxval = 10, group = "BUY") // 1.3 Sel SellType = input.string('Position / n Sells', 'Sell Type', ['Contracts', 'Cash', '% Position', 'Position / n Sells', 'Position / n Sells +'], group = "SELL") SellQ = input.float(5.0, 'Contracts / Cash / % Position', minval = 0, group = "SELL") NSellsUp = input.int(21, 'N Sells over MA (Max.)', minval = 1, maxval = 30, group = "SELL") NSellsDown = input.int(3, 'N Sells under MA', minval = 1, maxval = 30, group = "SELL") LossAllowed = input.string('Last buy', 'Loss Allowed', ['Never', 'Last buy', 'Always'], group = "SELL") // 1.4 Trading TradingType = input.string('Spot', 'Trading Type', ['Spot', 'Margin'], group = "TRADING") InitialCapital = input(10000.0, 'Initial Capital', group = "TRADING") InitialContracts = input.float(10.0, '% Initial Capital 1st Trade', minval = 1, maxval = 100, group = "TRADING") / 100 CommissionValue = input.float(0.1, '% Comission Value', minval = 0, maxval = 100, step = 0.1, group = "TRADING") / 100 MarginRate = input.float(10.0, '% Margin Rate', minval = 0, maxval = 100, step = 0.5, group = "TRADING") / 100 OrdersType = input.string('Limit', 'Orders Type on Alerts', ['Limit', 'Market'], group = "TRADING") StartDate = timestamp( '01 Jan 1990 01:00 +000') testPeriodStart = input.time(StartDate, 'Start of Trading', group = "TRADING") LabelSizeInput = input.string('Tiny', 'Labels Size', ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group = "PLOTTING") TableSizeInput = input.string('Tiny', 'Table Size', ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group = "PLOTTING") ShowGrid = input(true, 'Level Grid', group = "PLOTTING") ShowPanel = input(true, 'Information Panel', group = "PLOTTING") ShowMarginCall = input(false, 'Margin Call Price', group = "PLOTTING") Account = input.string("OKEX", 'Input Account') // 2.0 VARIABLES // 2.1 Grid levels on buys var float _ldown = na bool _pb = false bool _buy = false // 2.2 Grid levels on sells var float _lup = na bool _ps = false bool _sell = false // 2.3 First Buy CloseFirstBar = ta.valuewhen(bar_index == 0, open, 0) TimeFirstBar = ta.valuewhen(bar_index == 0, time, 0) CloseStart = ta.valuewhen(time <= testPeriodStart, open, 0) FirstClose = testPeriodStart > TimeFirstBar ? CloseStart : CloseFirstBar TimeFirstClose = testPeriodStart > TimeFirstBar ? testPeriodStart : TimeFirstBar // 2.4 Buy and Sell prices var float FinalBuyPrice = na var float FinalSellPrice = na var float FinalOpenPrice = na var float BuyLimitPrice = na var float SellLimitPrice = na // 2.5 Number of trades var int nBuys = na nBuys := nz(nBuys[1]) var int nSells = na nSells := nz(nSells[1]) var int NBuys = NBuysDown var int NSells = NSellsDown // 2.6 Quantities var float BuyQuantity = 0 var float BuyAmount = 0 var float SellQuantity = 0 var float SellAmount = 0 var float Commission = 0 var float Gains = 0 var float Losses = 0 // 2.7 Position calculation var float PositionCashS = 0 var float PositionCash = 0 var float PositionSizeS = 0 var float PositionSize = 0 var int BarIndex = 0 // 2.8 Average Price Calculation var float AvgPrice0 = 0 var float AvgPrice = 0 var float hl2Bar = 0 // 2.9 Backtest information var float Balance = InitialCapital var float Equity = 0 var float RealizedPnL = 0 var float PRealizedPnL = 0 var float Floating = 0 var float PFloating = 0 var float URealizedPnL = 0 var float PURealizedPnL = 0 var float Cash = InitialCapital var float Margin = 0 var float BuyAndHold = 0 var float PBuyAndHold = 0 var float CLeverage = 0 var float MarginCallPrice = 0 var bool MarginCall = false var float ProfitFactor = 0 var int TradingTime = 0 // 2.10 Fibonacci Pivots level calculation var float PP = open // 2.11 Information panel label labelBalance = na // 2.12 Analyzing when the period changes bool PeriodChange = false // 2.13 Grid with arrays aGrid = array.new_float(30) aDown = array.new_float(30) aUp = array.new_float(30) aPb = array.new_bool(30) aBuy = array.new_bool(30) aPs = array.new_bool(30) aSell = array.new_bool(30) // 2.14 Labels size fTextSize(_SizeInput)=> if _SizeInput == 'Auto' size.auto else if _SizeInput == 'Tiny' size.tiny else if _SizeInput == 'Small' size.small else if _SizeInput == 'Normal' size.normal else if _SizeInput == 'Normal' size.normal else if _SizeInput == 'Large' size.large else if _SizeInput == 'Huge' size.huge // 2.15 Variable reference var float MaxFinalOpenPrice = open // 2.16 Value of the MA var float sMAValue = na // 3.0 GRID // 3.1 Function to calculate the Width fWidth(_Width) => // 3.1.1 If price is constant if WOption == 'Arithmetic (Price)' math.round_to_mintick(_Width) // 3.1.2 If price is the Max % of the next Sell else if WOption == 'Geometric (% Sell)' if na(FinalOpenPrice) math.round_to_mintick((PP * (_Width / 100))) else math.round_to_mintick(MaxFinalOpenPrice * (_Width / 100)) // 3.1.3 If price is a part of the % of the maximum fall else if WOption == 'Geometric (% Fall)' if na(FinalOpenPrice) math.round_to_mintick((PP * (_Width / 100))) else math.round_to_mintick(MaxFinalOpenPrice / NBuysDown * (_Width / 100)) // 3.2 Grid Calculation fGrid(_Origin, _GridWidth, _Index) => for _i = 1 to _Index array.insert(aGrid, _i, _Origin + (_GridWidth * (_i-1))) array.get(aGrid, _Index) // 3.3.1 Origin from Rounded Pivot Points or last Sell fDownOrigin(_GridWidth) => if FinalSellPrice[1] <= PP if nSells < NSells if na(FinalBuyPrice[1]) (math.floor(FinalSellPrice / _GridWidth) * _GridWidth) - _GridWidth else FinalBuyPrice[1] else if nSells == NSells (math.floor(PP / _GridWidth) * _GridWidth) else if na(FinalBuyPrice[1]) math.floor(PP / _GridWidth) * _GridWidth else FinalBuyPrice[1] // 3.3.2 Origin for sells from Rounded Position Price fUpOrigin(_GridWidth) => if na(FinalSellPrice[1]) if LossAllowed == 'Never' math.ceil(math.max(AvgPrice0, AvgPrice, hl2Bar) / _GridWidth) * _GridWidth else if LossAllowed == 'Last buy' if nBuys == NBuys math.ceil(FinalBuyPrice / _GridWidth) * _GridWidth else math.ceil(math.max(AvgPrice0, AvgPrice, hl2Bar) / _GridWidth) * _GridWidth else if LossAllowed == 'Always' math.ceil(FinalBuyPrice / _GridWidth) * _GridWidth else FinalSellPrice[1] // 4.0 FUNCTIONS // 4.1 Function to sum factorial fSum(_Num)=> (math.pow(_Num, 2) + _Num) / 2 // 4.2.1 Function when "Cash / n Buys" or "Position / n Sells" fCaPo_N(_N, _n) => 1 / (_N - nz(_n)) // 4.2.2 Function when "Cash / n Buys +" or "Position / n Sells +" fCaPo_Nplus(_OnSells, _N, _n) => if TradingType == 'Spot' or _OnSells == 1 (nz(_n)+1) / (fSum(_N) - fSum(nz(_n))) else (nz(_n)+1) / fSum(_N) // 4.3 One of the correct ways to use security f_security(_sym, _res, _src, _rep) => request.security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1] // 4.3.1 Pivot points PP := f_security(syminfo.tickerid, ppPeriod, hlc3, false) // 4.3.2 Moving Average MA = ta.ema(close, MALength) sMA = f_security(syminfo.tickerid, MARes, MA, false) // 4.4 Analyzing when the period changes PeriodChange := ta.change(time(ppPeriod)) != 0 // 4.5.1 On Bullish trend, less Number of Buys and more amounts per trade; // on Bearish more Number of Buys and less amounts per trade // Max. number of buys NBuys := if (BuyType == "Cash / n Buys" or BuyType == "Cash / n Buys +") if BuyLimitPrice >= sMAValue[1] NBuysUp else NBuysDown else NBuysDown // 4.5.2 On Bullish trend, more Number of Sells and less amounts per trade; // on Bearish less Number of Sells and more amounts per trade // Max. number of sells NSells := if (SellType == "Position / n Sells" or SellType == "Position / n Sells +") if SellLimitPrice < sMAValue[1] NSellsDown else NSellsUp else NSellsUp // 5.0 ALERTS // 5.1 Triggering alerts more than once in the same bar fBuySell30Alerts(_nBuySell, _BuySellMessage) => if _nBuySell == 0 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 1 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 2 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 3 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 4 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 5 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 6 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 7 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 8 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 9 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 10 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 11 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 12 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 13 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 14 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 15 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 16 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 17 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 18 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 19 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 20 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 21 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 22 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 23 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 24 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 25 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 26 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 27 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 28 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 29 alert(_BuySellMessage, alert.freq_once_per_bar) if _nBuySell == 30 alert(_BuySellMessage, alert.freq_once_per_bar) // 5.2.1 Alert Function with syntax to buy fAlertsOnBuys(_Account, _CancelBuy, _FinalBuyPrice, _nBuys, _nSells, _BuyLimitPrice, _SellLimitPrice) => // Previous Messages var string _PrevBuyMessage = na var string _PrevCancelSellMessage = na var string _PrevSellMessage = na var string _PrevCancelBuyMessage = na var string _BuyMessage = na var string _SellMessage = na var string _BuyLimitOnSellMessage = na var string _SellLimitOnBuyMessage = na // _Symbol var string _Symbol = na _Symbol := " | a=" + _Account + " s=" + syminfo.basecurrency + "-" + syminfo.currency // Previous Messages _PrevCancelBuyMessage := _Symbol + " c=order b=buy | delay=1" if _CancelBuy == 1 _PrevBuyMessage := "BUY " + str.tostring(nz(_nBuys)) + " @ " + str.tostring(_FinalBuyPrice, '#.#####') + _PrevCancelBuyMessage + _Symbol + " b=buy q=" else _PrevBuyMessage := "BUY " + str.tostring(nz(_nBuys)) + " @ " + str.tostring(_FinalBuyPrice, '#.#####') + _Symbol + " b=buy q=" if nz(_nBuys) > 0 _PrevCancelSellMessage := _Symbol + " c=order b=sell | delay=1" // Sell limit orders on buys if SellType == "Contracts" and nz(_nBuys) > 0 _SellLimitOnBuyMessage := _Symbol + " b=sell q=" + str.tostring(SellQ) + " u=contracts t=limit fp=" + str.tostring(_SellLimitPrice) else if SellType == "Currency" and nz(_nBuys) > 0 _SellLimitOnBuyMessage := _Symbol + " b=sell q=" + str.tostring(SellQ) + " u=currency t=limit fp=" + str.tostring(_SellLimitPrice) else if SellType == "% Position" and nz(_nBuys) > 0 _SellLimitOnBuyMessage := _Symbol + " b=sell q=" + str.tostring(SellQ) + "% t=limit fp=" + str.tostring(_SellLimitPrice) else if SellType == "Position / n Sells" and nz(_nBuys) > 0 _SellLimitOnBuyMessage := _Symbol + " b=sell q=" + str.tostring(fCaPo_N(NSells, nz(_nSells)) * 100) + "% t=limit fp=" + str.tostring(_SellLimitPrice) else if SellType == "Position / n Sells +" and nz(_nBuys) > 0 _SellLimitOnBuyMessage := _Symbol + " b=sell q=" + str.tostring(fCaPo_Nplus(1, NSells, nz(_nSells)) * 100) + "% t=limit fp=" + str.tostring(_SellLimitPrice) // Buy alerts according to inputs if BuyType == "Contracts" if OrdersType == 'Limit' _BuyMessage := _PrevBuyMessage + str.tostring(BuyQ) + " u=contracts t=limit fp=" + str.tostring(_BuyLimitPrice) + _PrevCancelSellMessage + _SellLimitOnBuyMessage else if OrdersType == 'Market' and nz(_nBuys) > 0 _BuyMessage := _PrevBuyMessage + str.tostring(BuyQ) + " u=contracts t=market" fBuySell30Alerts(nz(_nBuys), _BuyMessage) else if BuyType == "Cash" if OrdersType == 'Limit' _BuyMessage := _PrevBuyMessage + str.tostring(BuyQ) + " u=currency t=limit fp=" + str.tostring(_BuyLimitPrice) + _PrevCancelSellMessage + _SellLimitOnBuyMessage else if OrdersType == 'Market' and nz(_nBuys) > 0 _BuyMessage := _PrevBuyMessage + str.tostring(BuyQ) + " u=currency t=market" fBuySell30Alerts(nz(_nBuys), _BuyMessage) else if BuyType == "% Cash" if OrdersType == 'Limit' _BuyMessage := _PrevBuyMessage + str.tostring(BuyQ) + "% t=limit fp=" + str.tostring(_BuyLimitPrice) + _PrevCancelSellMessage + _SellLimitOnBuyMessage else if OrdersType == 'Market' and nz(_nBuys) > 0 _BuyMessage := _PrevBuyMessage + str.tostring(BuyQ) + "% t=market" fBuySell30Alerts(nz(_nBuys), _BuyMessage) else if BuyType == "Cash / n Buys" if OrdersType == 'Limit' _BuyMessage := _PrevBuyMessage + str.tostring(fCaPo_N(NBuys, nz(_nBuys)) * 100) + "% t=limit fp=" + str.tostring(_BuyLimitPrice) + _PrevCancelSellMessage + _SellLimitOnBuyMessage else if OrdersType == 'Market' and nz(_nBuys) > 0 _BuyMessage := _PrevBuyMessage + str.tostring(fCaPo_N(NBuys+1, nz(_nBuys)) * 100) + "% t=market" fBuySell30Alerts(nz(_nBuys), _BuyMessage) else if BuyType == "Cash / n Buys +" if OrdersType == 'Limit' _BuyMessage := _PrevBuyMessage + str.tostring(fCaPo_Nplus(0, NBuys, nz(_nBuys)) * 100) + "% t=limit fp=" + str.tostring(_BuyLimitPrice) + _PrevCancelSellMessage + _SellLimitOnBuyMessage else if OrdersType == 'Market' and nz(_nBuys) > 0 _BuyMessage := _PrevBuyMessage + str.tostring(fCaPo_Nplus(0, NBuys, nz(_nBuys)-1) * 100) + "% t=market" fBuySell30Alerts(nz(_nBuys), _BuyMessage) // 5.2.2 Alert Function with syntax to sell fAlertsOnSells(_Account, _FinalSellPrice, _nBuys, _nSells, _BuyLimitPrice, _SellLimitPrice) => // Previous Messages var string _PrevBuyMessage = na var string _PrevCancelSellMessage = na var string _PrevSellMessage = na var string _PrevCancelBuyMessage = na var string _BuyMessage = na var string _SellMessage = na var string _BuyLimitOnSellMessage = na var string _SellLimitOnBuyMessage = na // Symbol var string _Symbol = na _Symbol := " | a=" + _Account + " s=" + syminfo.basecurrency + "-" + syminfo.currency // Previous Messages _PrevSellMessage := "SELL " + str.tostring(nz(_nSells)) + " @ " + str.tostring(_FinalSellPrice, '#.#####') + _Symbol + " b=sell q=" _PrevCancelBuyMessage := _Symbol + " c=order b=buy | delay=1" // Buy limit orders on sells if BuyType == "Contracts" _BuyLimitOnSellMessage := _Symbol + " b=buy q=" + str.tostring(BuyQ) + " u=contracts t=limit fp=" + str.tostring(_BuyLimitPrice) else if BuyType == "Currency" _BuyLimitOnSellMessage := _Symbol + " b=buy q=" + str.tostring(BuyQ) + " u=currency t=limit fp=" + str.tostring(_BuyLimitPrice) else if BuyType == "% Cash" _BuyLimitOnSellMessage := _Symbol + " b=buy q=" + str.tostring(BuyQ) + "% t=limit fp=" + str.tostring(_BuyLimitPrice) else if BuyType == "Cash / n Buys" _BuyLimitOnSellMessage := _Symbol + " b=buy q=" + str.tostring(fCaPo_N(NBuys, nz(_nBuys)) * 100) + "% t=limit fp=" + str.tostring(_BuyLimitPrice) else if BuyType == "Cash / n Buys +" _BuyLimitOnSellMessage := _Symbol + " b=buy q=" + str.tostring(fCaPo_Nplus(0, NBuys, nz(_nBuys)) * 100) + "% t=limit fp=" + str.tostring(_BuyLimitPrice) // Sell alerts according to input if SellType == "Contracts" if OrdersType == 'Limit' _SellMessage := _PrevSellMessage + str.tostring(SellQ) + " u=contracts t=limit fp=" + str.tostring(_SellLimitPrice) + _PrevCancelBuyMessage + _BuyLimitOnSellMessage else if OrdersType == 'Market' and nz(_nSells) > 0 _SellMessage := _PrevSellMessage + str.tostring(SellQ) + " u=contracts t=market" fBuySell30Alerts(nz(_nSells), _SellMessage) else if SellType == "Cash" if OrdersType == 'Limit' _SellMessage := _PrevSellMessage + str.tostring(SellQ) + " u=currency t=limit fp=" + str.tostring(_SellLimitPrice) + _PrevCancelBuyMessage + _BuyLimitOnSellMessage else if OrdersType == 'Market' and nz(_nSells) > 0 _SellMessage := _PrevSellMessage + str.tostring(SellQ) + " u=currency t=market" fBuySell30Alerts(nz(_nSells), _SellMessage) else if SellType == "% Position" if OrdersType == 'Limit' _SellMessage := _PrevSellMessage + str.tostring(SellQ) + "% t=limit fp=" + str.tostring(_SellLimitPrice) + _PrevCancelBuyMessage + _BuyLimitOnSellMessage else if OrdersType == 'Market' and nz(_nSells) > 0 _SellMessage := _PrevSellMessage + str.tostring(SellQ) + "% t=market" fBuySell30Alerts(nz(_nSells), _SellMessage) else if SellType == "Position / n Sells" if OrdersType == 'Limit' _SellMessage := _PrevSellMessage + str.tostring(fCaPo_N(NSells, nz(_nSells)) * 100) + "% t=limit fp=" + str.tostring(_SellLimitPrice) + _PrevCancelBuyMessage + _BuyLimitOnSellMessage else if OrdersType == 'Market' and nz(_nSells) > 0 _SellMessage := _PrevSellMessage + str.tostring(fCaPo_N(NSells+1, nz(_nSells)) * 100) + "% t=market" fBuySell30Alerts(nz(_nSells), _SellMessage) else if SellType == "Position / n Sells +" if OrdersType == 'Limit' _SellMessage := _PrevSellMessage + str.tostring(fCaPo_Nplus(1, NSells, nz(_nSells)) * 100) + "% t=limit fp=" + str.tostring(_SellLimitPrice) + _PrevCancelBuyMessage + _BuyLimitOnSellMessage else if OrdersType == 'Market' and nz(_nSells) > 0 _SellMessage := _PrevSellMessage + str.tostring(fCaPo_Nplus(1, NSells, nz(_nSells)-1) * 100) + "% t=market" fBuySell30Alerts(nz(_nSells), _SellMessage) // 6.0 TRADING // 6.1. Start of trading if time >= TimeFirstClose // 6.2. Final Trade Price, Average Price & Backtest for _i = 1 to 30 // 6.2.1.1 Grid on Buys array.insert(aDown, _i, fGrid(fDownOrigin(fWidth(Width)), fWidth(-Width), _i)) // 6.2.1.2 Crossing between price and levels of grid array.insert(aPb, _i, (((ta.cross(low, array.get(aDown, _i)) or ta.cross(high, array.get(aDown, _i))) and high >= array.get(aDown, _i)) or (open <= array.get(aDown, _i))) and low <= array.get(aDown, _i)) // 6.2.1.3 Buy only when price is better array.insert(aBuy, _i, (na(FinalOpenPrice) or (NSells == nSells and array.get(aPb, _i)) or (array.get(aPb, _i) and array.get(aDown, _i) <= (FinalOpenPrice - fWidth(Width)))) and nBuys <= NBuys-1) // 6.2.2.1 Grid on Sells array.insert(aUp, _i, fGrid(fUpOrigin(fWidth(Width)), fWidth(Width), _i)) // 6.2.2.2 Crossing between price and levels of grid array.insert(aPs, _i, (((ta.cross(low, array.get(aUp, _i)) or ta.cross(high, array.get(aUp, _i))) and low <= array.get(aUp, _i)) or (open >= array.get(aUp, _i))) and high >= array.get(aUp, _i)) // 6.2.2.3 Sell only with profit array.insert(aSell, _i, ((na(FinalOpenPrice) and array.get(aPs, _i)) or (array.get(aPs, _i) and array.get(aUp, _i) >= (FinalOpenPrice + fWidth(Width)))) and nSells <= NSells-1) // 6.2.3 Financial Data RealizedPnL := Balance - InitialCapital PRealizedPnL := (RealizedPnL / InitialCapital) * 100 Floating := ((close - AvgPrice) / AvgPrice) * PositionSize * AvgPrice PFloating := (Floating / Balance) * 100 URealizedPnL := RealizedPnL + Floating PURealizedPnL := (URealizedPnL / InitialCapital) * 100 Equity := Balance + Floating Margin := TradingType == 'Spot' ? 0 : (PositionSize * AvgPrice * MarginRate) Cash := TradingType == 'Spot' ? math.max(0, Balance - (PositionSize * AvgPrice)) : math.max(0, Balance - Margin) BuyAndHold := ((close - FirstClose) / FirstClose) * InitialCapital PBuyAndHold := (BuyAndHold / InitialCapital) * 100 CLeverage := (PositionSize * AvgPrice) / Balance MarginCallPrice := TradingType == 'Spot' ? 0 : AvgPrice - ((Balance - (Margin * 0.8)) / PositionSize) MarginCall := (ta.valuewhen(MarginCallPrice >= low, time , 0) <= timenow) ProfitFactor := Gains / Losses TradingTime := timenow - TimeFirstClose // 6.2.4.1 Quantities to buy according to inputs if BuyType == "Contracts" if na(FinalOpenPrice) BuyQuantity := ((Cash * InitialContracts) / FirstClose) else BuyQuantity := math.min((Cash / AvgPrice), BuyQ) else if BuyType == "Cash" if na(FinalOpenPrice) BuyQuantity := (Cash * InitialContracts) else BuyQuantity := math.min(Cash, BuyQ) else if BuyType == "% Cash" if na(FinalOpenPrice) BuyQuantity := (Cash * InitialContracts) else if nBuys >= NBuys - LastXtrades BuyQ := (1 / (NBuys - nz(nBuys))) * 100 BuyQuantity := math.min(Cash, (BuyQ / 100) * Cash) else if BuyType == "Cash / n Buys" if na(FinalOpenPrice) BuyQuantity := (Cash * InitialContracts) else BuyQuantity := math.min(Cash, fCaPo_N(NBuys, nBuys) * Cash) else if BuyType == "Cash / n Buys +" if na(FinalOpenPrice) BuyQuantity := (Cash * InitialContracts) else BuyQuantity := math.min(Cash, fCaPo_Nplus(0, NBuys, nBuys) * Cash) // 6.2.4.2 Quantities to sell according to inputs if SellType == "Contracts" SellQuantity := math.min(PositionSize, SellQ) else if SellType == "Cash" SellQuantity := math.min((PositionSize * AvgPrice), SellQ) else if SellType == "% Position" SellQuantity := math.min(PositionSize, (SellQ / 100) * PositionSize) else if SellType == "Position / n Sells" SellQuantity := math.min(PositionSize, fCaPo_N(NSells, nSells) * PositionSize) else if SellType == "Position / n Sells +" SellQuantity := math.min(PositionSize, fCaPo_Nplus(1, NSells, nSells) * PositionSize) // 6.2.5.1 First buy limit order from every change of the period if (PP != PP[1]) and nz(nBuys) == 0 and not nz(nSells) == 0 and not na(nBuys) and not na(fDownOrigin(fWidth(Width))) // Value of the MA sMAValue := sMA // Buy price of the limit order if (math.floor(PP / fWidth(Width)) * fWidth(Width)) <= (FinalOpenPrice - fWidth(Width)) BuyLimitPrice := (math.floor(PP / fWidth(Width)) * fWidth(Width)) else BuyLimitPrice := (math.floor(PP / fWidth(Width)) * fWidth(Width)) - fWidth(Width) // Alert Function with syntax to buy if OrdersType == 'Limit' fAlertsOnBuys(Account, 1, close, nBuys, nSells, BuyLimitPrice, SellLimitPrice) // 6.2.5.2 Buying at better Price if array.get(aBuy, _i) and BuyQuantity > 0 // Value of the MA sMAValue := sMA // Price of buy orders and resetting sales FinalBuyPrice := time == TimeFirstClose ? FirstClose : math.min(open, array.get(aDown, _i)) FinalSellPrice := na FinalOpenPrice := FinalBuyPrice // Number of buys and resetting sales nBuys += 1 nSells := na // Redefining buy quantity if BuyType == "Contracts" BuyAmount := BuyQuantity else BuyAmount := (BuyQuantity / FinalBuyPrice) // Calculating the priority and secondary price average PositionCashS += FinalBuyPrice * BuyAmount PositionCash += FinalBuyPrice * BuyAmount PositionSizeS += BuyAmount PositionSize += BuyAmount AvgPrice0 := PositionCashS / PositionSizeS AvgPrice := PositionCash / PositionSize // Calculating net profit Balance -= (BuyAmount * FinalBuyPrice * CommissionValue) // Comissions losses Losses += (BuyAmount * FinalBuyPrice * CommissionValue) // Fees paid Commission += (BuyAmount * FinalBuyPrice * CommissionValue) // Avoiding overlap BarIndex := bar_index hl2Bar := hl2 // Variable reference MaxFinalOpenPrice := math.max(FinalBuyPrice, nz(MaxFinalOpenPrice)) // Buy & Sell price of the limit orders if nBuys <= NBuys-1 BuyLimitPrice := FinalBuyPrice - fWidth(Width) else BuyLimitPrice := na if fUpOrigin(fWidth(Width)) >= (FinalBuyPrice + fWidth(Width)) SellLimitPrice := fUpOrigin(fWidth(Width)) else SellLimitPrice := fUpOrigin(fWidth(Width)) + fWidth(Width) // Alerts with syntax to buy fAlertsOnBuys(Account, 0, FinalBuyPrice, nBuys, nSells, BuyLimitPrice, SellLimitPrice) // Buy shapes string BuyText = str.tostring(BuyAmount,'#.####') + "\n" + str.tostring(((BuyAmount * FinalBuyPrice) / Cash) * 100, '#.##') + "%" c_BuyGrad = color.from_gradient(((NBuys - nBuys) / NBuys) * 100, 1, 100, color.lime, color.blue) label.new(bar_index, FinalBuyPrice, BuyText, textcolor = #9598a1, color = c_BuyGrad, style = label.style_diamond, size = fTextSize(LabelSizeInput)) // 6.2.5.3 Selling at better Price else if array.get(aSell, _i) and SellQuantity > 0 and BarIndex != bar_index // Value of the MA sMAValue := sMA // Price of sale orders and resetting buys FinalBuyPrice := na FinalSellPrice := math.max(open, array.get(aUp, _i)) FinalOpenPrice := FinalSellPrice // Number of sales and resetting buys nBuys := na nSells += 1 // Redefining sell quantity if SellType == "Cash" SellAmount := SellQuantity / FinalSellPrice else SellAmount := SellQuantity // Calculating the priority and resetting secondary price average PositionCashS := 0 PositionCash -= AvgPrice * SellAmount PositionSizeS := 0 PositionSize -= SellAmount // Calculating net profit Balance += ((((FinalSellPrice - AvgPrice) / AvgPrice) * SellAmount) * FinalSellPrice) Balance -= (SellAmount * FinalSellPrice * CommissionValue) // Gains and Losses if FinalSellPrice >= AvgPrice Gains += ((((FinalSellPrice - AvgPrice) / AvgPrice) * SellAmount) * FinalSellPrice) else Losses -= ((((FinalSellPrice - AvgPrice) / AvgPrice) * SellAmount) * FinalSellPrice) // Comission losses Losses += (SellAmount * FinalSellPrice * CommissionValue) // Fees paid Commission += (SellAmount * FinalSellPrice * CommissionValue) // Variable reference MaxFinalOpenPrice := math.max(FinalSellPrice, nz(MaxFinalOpenPrice)) // Buy & Sell price of the limit orders if FinalSellPrice <= PP BuyLimitPrice := fDownOrigin(fWidth(Width)) - fWidth(Width) else if (math.floor(PP / fWidth(Width)) * fWidth(Width)) <= (FinalOpenPrice - fWidth(Width)) BuyLimitPrice := (math.floor(PP / fWidth(Width)) * fWidth(Width)) else BuyLimitPrice := (math.floor(PP / fWidth(Width)) * fWidth(Width)) - fWidth(Width) if nSells <= NSells-1 SellLimitPrice := FinalSellPrice + fWidth(Width) else SellLimitPrice := na // Alerts with syntax to sell fAlertsOnSells(Account, FinalSellPrice, nBuys, nSells, BuyLimitPrice, SellLimitPrice) // Sell shapes string SellText = str.tostring(SellAmount,'#.####') + "\n" + str.tostring((SellAmount / (PositionSize + SellAmount)) * 100, '#.##') + "%" c_SellGrad = color.from_gradient(((NSells - nSells) / NSells) * 100, 1, 100, color.yellow, color.red) label.new(bar_index, FinalSellPrice, SellText, textcolor = #9598a1, color = c_SellGrad, style = label.style_diamond, size = fTextSize(LabelSizeInput)) // 7.0 PLOTTING // 7.1 Price of the limit orders bool LastBar = (time >= timenow - (timeframe.multiplier * 1000 * 60)) plotshape(OrdersType == 'Limit' and LastBar ? BuyLimitPrice : na, "Buy limit", shape.cross, location.absolute, color.new(color.blue, 30), size = size.small) plotshape(OrdersType == 'Limit' and LastBar ? SellLimitPrice : na, "Sell limit", shape.cross, location.absolute, color.new(color.red, 30), size = size.small) plotshape(ShowGrid ? BuyLimitPrice : na, "Buy level", shape.cross, location.absolute, color.new(color.blue, 30), size = size.auto) plotshape(ShowGrid ? SellLimitPrice : na, "Sell level", shape.cross, location.absolute, color.new(color.red, 30), size = size.auto) // 7.2 Table var InfoPanel = table.new(position = position.bottom_left, columns = 2, rows = 12, border_width = 1) ftable(_table_id, _column, _row, _text, _bgcolor) => table.cell(_table_id, _column, _row, _text, 0, 0, color.black, text.align_left, text.align_center, fTextSize(TableSizeInput), _bgcolor) tfString(int timeInMs) => // @function Produces a string corresponding to the input time in days, hours, and minutes. // @param (series int) A time value in milliseconds to be converted to a string variable. // @returns (string) A string variable reflecting the amount of time from the input time. float s = timeInMs / 1000 float m = s / 60 float h = m / 60 float d = h / 24 float mo = d / 30.416 int tm = math.floor(m % 60) int th = math.floor(h % 24) int td = math.floor(d % 30.416) int tmo = math.floor(mo % 12) int ys = math.floor(d / 365) string result = switch d == 30 and th == 10 and tm == 30 => "1M" d == 7 and th == 0 and tm == 0 => "1W" => string yStr = ys ? str.tostring(ys) + "Y " : "" string moStr = tmo ? str.tostring(tmo) + "M " : "" string dStr = td ? str.tostring(td) + "D " : "" string hStr = th ? str.tostring(th) + "H " : "" string mStr = tm ? str.tostring(tm) + "min" : "" yStr + moStr + dStr + hStr + mStr if ShowPanel and barstate.islast ftable(InfoPanel, 0, 0, 'Equity: ' , #9598a1) ftable(InfoPanel, 0, 1, 'Position: ' , #9598a1) ftable(InfoPanel, 0, 2, 'Cash: ' , #9598a1) ftable(InfoPanel, 0, 3, 'Margin: ' , #9598a1) ftable(InfoPanel, 0, 4, 'Current Leverage: ' , #9598a1) ftable(InfoPanel, 0, 5, 'Commission: ' , #9598a1) ftable(InfoPanel, 0, 6, 'Floating: ' , #9598a1) ftable(InfoPanel, 0, 7, 'Realized PnL: ' , #9598a1) ftable(InfoPanel, 0, 8, 'Unrealized PnL: ' , #9598a1) ftable(InfoPanel, 0, 9, 'Buy n Hold: ' , #9598a1) ftable(InfoPanel, 0, 10, 'Profit Factor: ' , #9598a1) ftable(InfoPanel, 0, 11, 'Time of Trading: ' , #9598a1) ftable(InfoPanel, 1, 0, MarginCall ? 'Margin Call️' : str.tostring(Equity, '#.####') + ' ' + syminfo.currency , MarginCall ? color.red : #9598a1) ftable(InfoPanel, 1, 1, str.tostring(PositionSize, '#.####') + ' ' + syminfo.basecurrency , #9598a1) ftable(InfoPanel, 1, 2, str.tostring(Cash, '#.####') + ' ' + syminfo.currency , #9598a1) ftable(InfoPanel, 1, 3, str.tostring(Margin, '#.####') + ' ' + syminfo.currency , #9598a1) ftable(InfoPanel, 1, 4, TradingType == 'Spot' ? 'Spot' : str.tostring(CLeverage, '#.##') + 'x' , #9598a1) ftable(InfoPanel, 1, 5, str.tostring(CommissionValue * 100, '#.##') + ' %' , #9598a1) ftable(InfoPanel, 1, 6, str.tostring(PFloating, '#.##') + ' %' , PFloating >= 0 ? color.green : color.red) ftable(InfoPanel, 1, 7, str.tostring(PRealizedPnL, '#.##') + ' %' , PRealizedPnL >= 0 ? color.green : color.red) ftable(InfoPanel, 1, 8, str.tostring(PURealizedPnL, '#.##') + ' %' , PURealizedPnL >= 0 ? color.green : color.red) ftable(InfoPanel, 1, 9, str.tostring(PBuyAndHold, '#.##') + ' %' , PBuyAndHold >= 0 ? color.green : color.red) ftable(InfoPanel, 1, 10, str.tostring(ProfitFactor, '#.##') , ProfitFactor >= 1 ? color.green : color.red) ftable(InfoPanel, 1, 11, tfString(TradingTime) , #9598a1) // 7.3 Plotting pivot points plot(PP, title = "PP", style = plot.style_circles, color = color.silver, linewidth = 1) // 7.4 Plotting the average price plotshape(barstate.isrealtime and ta.change(AvgPrice0) != 0 and (nz(nBuys) > 1) ? AvgPrice0 : na, "AvgPricesr", shape.diamond, location.absolute, color.new(color.fuchsia, 40), size = size.tiny) plotshape(barstate.isrealtime and ta.change(AvgPrice) != 0 ? AvgPrice : na, "AvgPricepr", shape.diamond, location.absolute, color.new(color.yellow, 10), size = size.tiny) plotshape( ta.change(AvgPrice0[1]) != 0 and (nz(nBuys) > 1) ? AvgPrice0[1] : na, "AvgPrices", shape.diamond, location.absolute, color.new(color.fuchsia, 10), size = size.tiny) plotshape( ta.change(AvgPrice[1]) != 0 ? AvgPrice[1] : na, "AvgPricep", shape.diamond, location.absolute, color.new(color.yellow, 40), size = size.tiny) plotshape(TimeFirstClose == time ? FirstClose : na, "FirstClose", shape.diamond, location.absolute, color.new(color.yellow, 40), size = size.tiny) // 7.5 Plotting the moving average plot((BuyType == "Cash / n Buys" or BuyType == "Cash / n Buys +") and NBuysUp != NBuysDown ? sMA : na, title = "Moving Average Buys", color = color.new(color.blue, 50), linewidth = 2) plot((SellType == "Position / n Sells" or SellType == "Position / n Sells +") and NSellsUp != NSellsDown ? sMA : na, title = "Moving Average Sells", color = color.new(color.red, 50), linewidth = 2) // 7.6 Plotting the liquidation price plot(ShowMarginCall and MarginCallPrice > 0 ? MarginCallPrice : na, "Liquidation Price", MarginCall ? color.new(color.red, 30) : color.new(color.lime, 30), 2) barcolor(MarginCall ? color.red : na) // 8.0 NOTE // Certain Risks of Live Algorithmic Trading: // 1. Backtesting Cannot Assure Actual Results. // 2. The relevant market might fail or behave unexpectedly. // 3. Your broker may experience failures in its infrastructure, fail to execute your orders in a correct or timely fashion or reject your orders. // 4. The system you use for generating trading orders, communicating those orders to your broker, and receiving queries and trading results from your broker may fail. // 5. Time lag at various point in live trading might cause unexpected behavior. // 6. The systems of third parties in addition to those of the provider from which we obtain various services, your broker, and the applicable securities market may fail or malfunction.
Aggregated Volume Spot & Futures
https://www.tradingview.com/script/T6dlVzTV-Aggregated-Volume-Spot-Futures/
HALDRO
https://www.tradingview.com/u/HALDRO/
848
study
5
MPL-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 Project // —————— https://www.tradingview.com/script/T6dlVzTV-Aggregated-Volume-CVD-Liquidations-Delta/ // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // @version=5 indicator(title='Aggregated Volume Spot & Futures', shorttitle='Aggregated Volume', format=format.volume) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— Tips TTmode = '𝐕𝐨𝐥𝐮𝐦𝐞 ➖ Shows the volume selected in tab "𝐕𝐨𝐥𝐮𝐦𝐞 𝐁𝐲" \n𝐕𝐨𝐥𝐮𝐦𝐞 (𝐂𝐨𝐥𝐨𝐫𝐞𝐝) ➖ Shows aggregated volume but applying different volume colors for different exchanges. \n𝐃𝐞𝐥𝐭𝐚 ➖ Displays the difference between the number of buyers and sellers. ❢ \n𝐂𝐮𝐦𝐮𝐥𝐚𝐭𝐢𝐯𝐞 𝐃𝐞𝐥𝐭𝐚 ➖ Displays the cumulative delta between sellers and buyers. ❢ \n𝐒𝐩𝐨𝐭 & 𝐏𝐞𝐫𝐩 ➖ Shows Spot and Futures volume at the same time. \n𝐃𝐞𝐥𝐭𝐚 (𝐒𝐩𝐨𝐭 - 𝐏𝐞𝐫𝐩) ➖ Shows the difference between Spot and Futures volume. \n𝐋𝐢𝐪𝐮𝐢𝐝𝐚𝐭𝐢𝐨𝐧𝐬 ➖ Displays potential Liquidations(The difference in volume between Futures and Spots). ❢ \n𝐎𝐁𝐕 ➖ On Balance Volume. \n𝐌𝐅𝐈 ➖ Money Flow Indicator. \n𝐃𝐚𝐭𝐚 𝐓𝐲𝐩𝐞 ➖ Choose Single or Aggregated data \n\n ❢ ➖ With this sign I marked the functions that are calculated by Me, it is not exactly the original data from the exchange. It is impossible to calculate them perfectly because TV gives only the total volume from the exchanges.' TTtype = 'Be Careful, Reacts to every mode.' TTvol = 'Show Current Volume.' TTtable = 'Table shows the current volume of the last candle. Also in the mode "Colored" shows the color of exchanges if they have volume.' TTlen = "Lookback period for 'Cumulative Delta' and for 'MFI'." TTspot = 'Spot Volume' TTperp = 'Futures Volume' TTEX = 'You can write any name of the exchange in any field in the Exchanges group and get the result. Example: BITMEX\nHUOBI\nMEXC\nGATEIO and others. \n*Be careful and check if there is such a ticker on TV.' // —————— Inputs groupset = '➤ SETTINGS' mode = input.string('Volume', ' Mode     ', group = groupset, inline = 'MODE', options = ['Volume', 'Volume (Colored)', 'Delta', 'Cumulative Delta', 'Spot & Perp', 'Delta (Spot - Perp)', 'Liquidations', 'OBV', 'MFI']) datatype = input.string('Aggregated', ' Data Type   ', group = groupset, inline = 'MODE', options = ['Aggregated', 'Single'], tooltip = TTmode) coinusd = input.string('USD', ' Volume By ', group = groupset, inline = 'VOLM', options = ['COIN', 'USD', 'EUR', 'RUB']) calctype = input.string('SUM', ' Calculate By ', group = groupset, inline = 'VOLM', options = ['SUM', 'AVG', 'MEDIAN', 'VARIANCE'], tooltip = TTtype) malen = input.int (21, ' MA Period ', group = groupset, inline = 'CIPS', minval=1) showMA = input.bool (false, ' Show MA', group = groupset, inline = 'CIPS') universalen = input.int (14, ' Lookback  ', group = groupset, inline = 'OTHR') FilterPeriod = input.int (100, ' Liquidation Filter', group = groupset, inline = 'OTHR', minval=1, tooltip = TTlen) showtable = input.bool (true, ' Show Table', group = groupset, inline = 'CIPS', tooltip = TTtable) groupexc = '➤ EXCHANGES' EX_NO1 = input.bool (true, '1', group = groupexc, inline = 'EX1') IN_NO1 = input.string('BINANCE', '', group = groupexc, inline = 'EX1') EX_NO2 = input.bool (true, '2', group = groupexc, inline = 'EX1') IN_NO2 = input.string('BYBIT', '', group = groupexc, inline = 'EX1') EX_NO3 = input.bool (true, '3', group = groupexc, inline = 'EX1') IN_NO3 = input.string('OKEX', '', group = groupexc, inline = 'EX1') EX_NO4 = input.bool (true, '4', group = groupexc, inline = 'EX2') IN_NO4 = input.string('COINBASE', '', group = groupexc, inline = 'EX2') EX_NO5 = input.bool (true, '5', group = groupexc, inline = 'EX2') IN_NO5 = input.string('BITFINEX', '', group = groupexc, inline = 'EX2') EX_NO6 = input.bool (true, '6', group = groupexc, inline = 'EX2') IN_NO6 = input.string('BITSTAMP', '', group = groupexc, inline = 'EX2') EX_NO7 = input.bool (true, '7', group = groupexc, inline = 'EX3') IN_NO7 = input.string('DERIBIT', '', group = groupexc, inline = 'EX3') EX_NO8 = input.bool (true, '8', group = groupexc, inline = 'EX3') IN_NO8 = input.string('PHEMEX', '', group = groupexc, inline = 'EX3') EX_NO9 = input.bool (true, '9', group = groupexc, inline = 'EX3') IN_NO9 = input.string('MEXC', '', group = groupexc, inline = 'EX3', tooltip = TTEX) groupcur = '➤ CURRENCY' PERP1 = input.bool (true, '  USD.P     ', group = groupcur, inline = 'CUR1') PERP2 = input.bool (true, '  USDT.P ', group = groupcur, inline = 'CUR1', tooltip = TTperp) SPOT1 = input.bool (true, '  USDT   ', group = groupcur, inline = 'CUR2') SPOT2 = input.bool (true, '᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎᠎', group = groupcur, inline = 'CUR2') XSPOT2 = input.string('USD', '᠎', group = groupcur, inline = 'CUR2', options = ['USD', 'USDC', 'BUSD', 'DAI', 'EUR'], tooltip = TTspot) VAREUR = request.security('FX_IDC:EURUSD', timeframe.period, close) VARRUB = request.security('(MOEX:USDRUB_TOM+MOEX:USDRUB_TOD)/2', timeframe.period, close) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— Aggregated Volume Calculate Vtype = str.lower(syminfo.volumetype) CurrentVolume = Vtype=='tick' or Vtype=='quote' or Vtype=='usd' ? volume / close : volume GetTicker(exchange, typeSymbol) => GetTicker = exchange + ':' + syminfo.basecurrency + typeSymbol FixBitmex = exchange == 'BITMEX' ? str.replace(GetTicker, 'BTC', 'XBT') : GetTicker Ticker = FixBitmex GetRequest(Ticker) => GetVolume = request.security(Ticker, timeframe.period, CurrentVolume, ignore_invalid_symbol=true) CheckVolume = GetVolume[1] > 0 ? GetVolume : 0 GetExchange(typeSymbol)=> EX_1 = EX_NO1 ? GetRequest( GetTicker(IN_NO1, typeSymbol) ) : 0 EX_2 = EX_NO2 ? GetRequest( GetTicker(IN_NO2, typeSymbol) ) : 0 EX_3 = EX_NO3 ? GetRequest( GetTicker(IN_NO3, typeSymbol) ) : 0 EX_4 = EX_NO4 ? GetRequest( GetTicker(IN_NO4, typeSymbol) ) : 0 EX_5 = EX_NO5 ? GetRequest( GetTicker(IN_NO5, typeSymbol) ) : 0 EX_6 = EX_NO6 ? GetRequest( GetTicker(IN_NO6, typeSymbol) ) : 0 EX_7 = EX_NO7 ? GetRequest( GetTicker(IN_NO7, typeSymbol) ) : 0 EX_8 = EX_NO8 ? GetRequest( GetTicker(IN_NO8, typeSymbol) ) : 0 EX_9 = EX_NO9 ? GetRequest( GetTicker(IN_NO9, typeSymbol) ) : 0 [EX_1, EX_2, EX_3, EX_4, EX_5, EX_6, EX_7, EX_8, EX_9] EditVolume(type)=> Type = calctype == 'AVG' ? array.avg(type) : calctype == 'MEDIAN' ? array.median(type) : calctype == 'VARIANCE' ? array.variance(type) : array.sum(type) Volume = coinusd == 'USD' ? Type*close : coinusd == 'EUR' ? Type*(1/VAREUR)*close : coinusd == 'RUB' ? Type*(VARRUB/1)*close : Type Volume // —————— Get Volume [PERP2_1, PERP2_2, PERP2_3, PERP2_4, PERP2_5, PERP2_6, PERP2_7, PERP2_8, PERP2_9] = GetExchange(PERP1 ? 'USDT.P' : '0') [PERP1_1, PERP1_2, PERP1_3, PERP1_4, PERP1_5, PERP1_6, PERP1_7, PERP1_8, PERP1_9] = GetExchange(PERP2 ? 'USD.P' : '0') [SPOT1_1, SPOT1_2, SPOT1_3, SPOT1_4, SPOT1_5, SPOT1_6, SPOT1_7, SPOT1_8, SPOT1_9] = GetExchange(SPOT1 ? 'USDT' : '0') [SPOT2_1, SPOT2_2, SPOT2_3, SPOT2_4, SPOT2_5, SPOT2_6, SPOT2_7, SPOT2_8, SPOT2_9] = GetExchange(SPOT2 ? XSPOT2 : '0') // —————— Processing Volume GetSpotEX_1 = EditVolume(array.from(SPOT1_1, SPOT2_1)), GetPerpEX_1 = EditVolume(array.from(PERP1_1, PERP2_1)) GetSpotEX_2 = EditVolume(array.from(SPOT1_2, SPOT2_2)), GetPerpEX_2 = EditVolume(array.from(PERP1_2, PERP2_2)) GetSpotEX_3 = EditVolume(array.from(SPOT1_3, SPOT2_3)), GetPerpEX_3 = EditVolume(array.from(PERP1_3, PERP2_3)) GetSpotEX_4 = EditVolume(array.from(SPOT1_4, SPOT2_4)), GetPerpEX_4 = EditVolume(array.from(PERP1_4, PERP2_4)) GetSpotEX_5 = EditVolume(array.from(SPOT1_5, SPOT2_5)), GetPerpEX_5 = EditVolume(array.from(PERP1_5, PERP2_5)) GetSpotEX_6 = EditVolume(array.from(SPOT1_6, SPOT2_6)), GetPerpEX_6 = EditVolume(array.from(PERP1_6, PERP2_6)) GetSpotEX_7 = EditVolume(array.from(SPOT1_7, SPOT2_7)), GetPerpEX_7 = EditVolume(array.from(PERP1_7, PERP2_7)) GetSpotEX_8 = EditVolume(array.from(SPOT1_8, SPOT2_8)), GetPerpEX_8 = EditVolume(array.from(PERP1_8, PERP2_8)) GetSpotEX_9 = EditVolume(array.from(SPOT1_9, SPOT2_9)), GetPerpEX_9 = EditVolume(array.from(PERP1_9, PERP2_9)) SPOT = GetSpotEX_1 + GetSpotEX_2 + GetSpotEX_3 + GetSpotEX_4 + GetSpotEX_5 + GetSpotEX_6 + GetSpotEX_7 + GetSpotEX_8 + GetSpotEX_9 PERP = GetPerpEX_1 + GetPerpEX_2 + GetPerpEX_3 + GetPerpEX_4 + GetPerpEX_5 + GetPerpEX_6 + GetPerpEX_7 + GetPerpEX_8 + GetPerpEX_9 Volume = datatype == 'Single' ? EditVolume(array.from(CurrentVolume)) : SPOT + PERP + (EditVolume(array.from(CurrentVolume))) // —————— Color Setup bull_color = #00d4b1bb bear_color = #e91e71bb // —————— Plot Volume plot(mode == 'Volume' ? Volume : na, 'Volume', color = open < close ? bull_color : bear_color, style=plot.style_columns) // —————— Plot MA plot(showMA and mode == 'Volume' ? ta.ema(Volume, malen) : na, 'Volume MA', color = #884feb, style = plot.style_line) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— OBV OBV = ta.cum(math.sign(ta.change(close)) * Volume) plot(mode == 'OBV' ? OBV : na, 'OBV', color = #7E57C2, style=plot.style_line) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— MFI float upperMFI = math.sum(Volume * (ta.change(hlc3) <= 0.0 ? 0.0 : hlc3), universalen) float lowerMFI = math.sum(Volume * (ta.change(hlc3) >= 0.0 ? 0.0 : hlc3), universalen) MFI = 100.0 - (100.0 / (1.0 + upperMFI / lowerMFI)) plot(mode == 'MFI' ? MFI : na, 'MFI', color = #7E57C2, style=plot.style_line) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— SPOT / FUTURES Calculate DeltaSP = SPOT - PERP plot(mode == 'Spot & Perp' ? SPOT : na, 'SPOT', color = bull_color, style = plot.style_line) plot(mode == 'Spot & Perp' ? PERP : na, 'PERP', color = bear_color, style = plot.style_line) plot(mode == 'Delta (Spot - Perp)' ? DeltaSP : na, 'Delta (Spot - Perp)', color = SPOT > PERP ? bull_color : bear_color, style = plot.style_columns) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— Liquidations Calculate // Credit @Thomas_Davison timePeriodMean = FilterPeriod // —————— Calculate liquidations as the difference between futures volume and spot volume difference = (PERP - SPOT) direction = close > open ? bear_color : bull_color // (RED = Short Liquidation) differenceSum = math.sum(difference, timePeriodMean) differenceMean = differenceSum / timePeriodMean if difference < differenceMean or difference < 0 difference := 0 plot(mode == 'Liquidations' ? difference : na, 'Liquidations (RED = Short Liquidation)', color = difference == 0 ? na : direction, style = plot.style_columns) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— DELTA Calculation deltalen = universalen // —————— Check Candles bullCandle = (open < close) price_spread = (high - low) // —————— Set lengths upper_wick = (open < close) ? (high - close) : (high - open) lower_wick = (open < close) ? (open - low) : (close - low) body = (high - low) - (upper_wick + lower_wick) // —————— Convert lengths to percents upper_wick_percent = upper_wick / (high - low) lower_wick_percent = lower_wick / (high - low) body_percent = body / (high - low) // —————— Calculate Delta volume_buy = Volume * ((open < close) ? (body_percent + (upper_wick_percent + lower_wick_percent) / 2) : (upper_wick_percent + lower_wick_percent) / 2) volume_sell = Volume * ((open < close) ? (upper_wick_percent + lower_wick_percent) / 2 : (body_percent + (upper_wick_percent + lower_wick_percent) / 2)) Delta = volume_buy - volume_sell // —————— Calculate Cumulative Delta volume_buy_cum_sum = math.sum(volume_buy, deltalen) volume_sell_cum_sum = math.sum(volume_sell, deltalen) CumDelta = (volume_buy_cum_sum - volume_sell_cum_sum) plot( mode == 'Delta' ? Delta : na, 'Delta', style=plot.style_columns, color= Delta > 0 ? bull_color : bear_color ) plot( mode == 'Cumulative Delta' ? CumDelta : na, 'Cumulative Delta', color=CumDelta > 0 ? bull_color : bear_color, style=plot.style_line) hline(mode != 'OBV' and mode != 'MFI' ? 0 : na, 'Zero Line', linestyle=hline.style_dotted) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— Get Volume Colored EXv1 = (GetSpotEX_1 + GetPerpEX_1) EXv2 = EXv1 + (GetSpotEX_2 + GetPerpEX_2) EXv3 = EXv2 + (GetSpotEX_3 + GetPerpEX_3) EXv4 = EXv3 + (GetSpotEX_4 + GetPerpEX_4) EXv5 = EXv4 + (GetSpotEX_5 + GetPerpEX_5) EXv6 = EXv5 + (GetSpotEX_6 + GetPerpEX_6) EXv7 = EXv6 + (GetSpotEX_7 + GetPerpEX_7) EXv8 = EXv7 + (GetSpotEX_8 + GetPerpEX_8) EXv9 = EXv8 + (GetSpotEX_9 + GetPerpEX_9) // —————— Plot Volume Colored colEXv1 = input.color(#e1d14d, 'EX 1', group ='Volume (Colored)', inline = 'VC') colEXv2 = input.color(#db7602, 'EX 2', group ='Volume (Colored)', inline = 'VC') colEXv3 = input.color(#4289db, 'EX 3', group ='Volume (Colored)', inline = 'VC') colEXv4 = input.color(#ca43f7, 'EX 4', group ='Volume (Colored)', inline = 'VC') colEXv5 = input.color(#7104ff, 'EX 5', group ='Volume (Colored)', inline = 'VC') colEXv6 = input.color(#001aff, 'EX 6', group ='Volume (Colored)', inline = 'VC') colEXv7 = input.color(#1d813e, 'EX 7', group ='Volume (Colored)', inline = 'VC') colEXv8 = input.color(#02C99A, 'EX 8', group ='Volume (Colored)', inline = 'VC') colEXv9 = input.color(#ff3f3c, 'EX 9', group ='Volume (Colored)', inline = 'VC') plot(EXv9, 'EX 9', style = plot.style_columns, color = colEXv9, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv8, 'EX 8', style = plot.style_columns, color = colEXv8, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv7, 'EX 7', style = plot.style_columns, color = colEXv7, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv6, 'EX 6', style = plot.style_columns, color = colEXv6, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv5, 'EX 5', style = plot.style_columns, color = colEXv5, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv4, 'EX 4', style = plot.style_columns, color = colEXv4, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv3, 'EX 3', style = plot.style_columns, color = colEXv3, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv2, 'EX 2', style = plot.style_columns, color = colEXv2, display = mode=='Volume (Colored)' ? na : display.none, editable = false) plot(EXv1, 'EX 1', style = plot.style_columns, color = colEXv1, display = mode=='Volume (Colored)' ? na : display.none, editable = false) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\ // —————— DEBUG Tools // Check on Errors var cumVol = 0. cumVol += nz(Volume) checkerror = barstate.islast and cumVol == 0 ? "Received error, Volume not found ! 🙄" : na // —————— PANEL convertVol = str.format("{0,number}", math.round(Volume)) var table panel = table.new(position = position.bottom_right, columns = 2, rows = 11, bgcolor = #363A45) if barstate.islast and showtable table.cell(panel, 0, 9, text=checkerror+str.tostring(convertVol), text_color = #ffa726, bgcolor = #363A45) // —————— Volume Colored Table if mode=='Volume (Colored)' and barstate.islast and showtable table.cell(panel, 0, 0, text=IN_NO1, text_color = GetSpotEX_1+GetPerpEX_1>=1 ? colEXv1 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 1, text=IN_NO2, text_color = GetSpotEX_2+GetPerpEX_2>=1 ? colEXv2 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 2, text=IN_NO3, text_color = GetSpotEX_3+GetPerpEX_3>=1 ? colEXv3 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 3, text=IN_NO4, text_color = GetSpotEX_4+GetPerpEX_4>=1 ? colEXv4 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 4, text=IN_NO5, text_color = GetSpotEX_5+GetPerpEX_5>=1 ? colEXv5 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 5, text=IN_NO6, text_color = GetSpotEX_6+GetPerpEX_6>=1 ? colEXv6 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 6, text=IN_NO7, text_color = GetSpotEX_7+GetPerpEX_7>=1 ? colEXv7 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 7, text=IN_NO8, text_color = GetSpotEX_8+GetPerpEX_8>=1 ? colEXv8 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) table.cell(panel, 0, 8, text=IN_NO9, text_color = GetSpotEX_9+GetPerpEX_9>=1 ? colEXv9 : na, bgcolor = #1e222d, text_size = size.normal, text_font_family = font.family_monospace, height = 7) // ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— \\
Correlation Coefficient: Visible Range Dynamic Average R
https://www.tradingview.com/script/rnJeVlAo-Correlation-Coefficient-Visible-Range-Dynamic-Average-R/
twingall
https://www.tradingview.com/u/twingall/
38
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //Correlation Coefficient with Dynamic Average R (shows R average for the visible chart only, changes as you zoom in or out) //the Correlation Coefficient function for Pearson's R is taken directly from "BA🐷 CC" indicator by @balipour //wrote this primarily to get a dynamic measure of Bond vs Stock (ZB1! vs ES1!) correlation for arbitrary start times; whether it be the last month, last year, last 5yrs etc // © twingall //@version=5 indicator("Correlation Coefficient Visible Average", 'CC Visible Avg', overlay =false, precision =2, max_bars_back = 5000) src = input(close, "source") length = input(100, "R lookback length") // I prefer 100 for daily chart; 20 for weekly chart userSymbol = input.symbol("DXY", "Asset to compare") userSymbolClose =request.security(userSymbol, "", src) backtestMode = input.bool(true, "Backtest mode: both RHS and LHS cut-off", tooltip = "default on: shows the Average R for whatever is visible on the chart only") manual = input.bool(false, "manual input #bars back", group = "manual (NOT visible-chart/not dynamic)") inputBarsBack = input.int(100, "bars back (for manual mode only)", group = "manual (NOT visible-chart/not dynamic)") //--// // Correlation Coefficent function :-borrowed directly from "BA🐷 CC", @balipour cc(x, y, len) => lenMinusOne = len - 1 meanx = 0.0, meany = 0.0 for i=0.0 to lenMinusOne meanx := meanx + nz(x[i]) meany := meany + nz(y[i]) meanx := meanx / len meany := meany / len sumxy=0.0, sumx=0.0, sumy=0.0 for i=0 to lenMinusOne sumxy := sumxy + (nz(x[i]) - meanx) * (nz(y[i]) - meany) sumx := sumx + math.pow(nz(x[i]) - meanx, 2) sumy := sumy + math.pow(nz(y[i]) - meany, 2) sumxy / math.sqrt(sumy * sumx) //--// //plotting R = cc(src, userSymbolClose, length) manualCond =bar_index> last_bar_index - inputBarsBack plot(manual?(manualCond?R:na):R, title = "correlation coefficient") hline(1.0, color= color.black) hline(0.0, color= color.red) hline(-1.0, color= color.black) // ~~ dynamic average R ~~ VisibleBars = ta.barssince(time == chart.left_visible_bar_time) AvCC(_R, _visBars)=> meancc =0.0 for i=1.0 to (_visBars) meancc:=meancc +nz(_R[i]) meancc:= meancc/_visBars // backtest version of this function (RHS cutoff as well as the default LHS cutoff) _startVis = ta.barssince(time == chart.left_visible_bar_time) _endVis = nz(ta.barssince(time == chart.right_visible_bar_time)) //add nz() function to fix error where NaN returns when white-space to RHS of last bar startVis= manual?inputBarsBack:_startVis endVis=manual?0:_endVis VisibleBars_backtest = startVis-endVis AvCC_backtest(_R, _rhs, _lhs, _visBars)=> meancc =0.0 for i=_rhs to _lhs meancc:=meancc +nz(_R[i]) meancc:= meancc/_visBars _avg = AvCC(R,VisibleBars) _avg_backtest = AvCC_backtest(R,endVis,startVis,VisibleBars_backtest) backtestLabelPos =chart.left_visible_bar_time+ ((chart.right_visible_bar_time -chart.left_visible_bar_time)/2) pos = str.pos(userSymbol, ":") //get only the ticker part out of the string tkr= str.substring(userSymbol, pos+1) //get only the ticker part out of the string if barstate.islastconfirmedhistory and backtestMode and not manual label.new(backtestLabelPos, 1.2, text=tkr +" Vis-Avg-R = "+ str.tostring(_avg_backtest, '0.00'), color=color.new(color.white, 80), textcolor=color.red, size=size.large, style=label.style_label_left, xloc=xloc.bar_time, textalign=text.align_right) if barstate.islastconfirmedhistory and not backtestMode and not manual label.new(bar_index, 1.2, text=tkr+ " Vis-Avg-R = "+ str.tostring(_avg, '0.00'), color=color.new(color.white, 100), textcolor=color.red, size=size.large, style=label.style_label_right, xloc=xloc.bar_index, textalign=text.align_right) if barstate.islastconfirmedhistory and manual label.new(bar_index, 1.2, text=tkr +" Vis-Avg-R = "+ str.tostring(_avg_backtest, '0.00'), color=color.new(color.white, 80), textcolor=color.red, size=size.large, style=label.style_label_right, xloc=xloc.bar_index, textalign=text.align_right)
CVD - Cumulative Volume Delta (Chart)
https://www.tradingview.com/script/hFcy7CIq-CVD-Cumulative-Volume-Delta-Chart/
TradingView
https://www.tradingview.com/u/TradingView/
2,890
study
5
MPL-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 - Cumulative Volume Delta (Chart)", "CVD Chart", true, format = format.volume, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500) // CVD - Cumulative Volume Delta (Chart) // v2, 2023.03.25 // 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/4 as PCtime import PineCoders/lower_tf/4 as PCltf import TradingView/ta/4 as TVta import PineCoders/VisibleChart/4 as chart //#region ———————————————————— 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 string LBL_TXT = " \n \n \n \n \n \n \n \n \n " // Default colors color LIME = color.lime color PINK = color.fuchsia color WHITE = color.white color ORANGE = color.orange color GRAY = #808080ff color LIME_LINE = color.new(LIME, 30) color LIME_BG = color.new(LIME, 95) color LIME_HI = color.new(LIME, 80) color PINK_LINE = color.new(PINK, 30) color PINK_BG = color.new(PINK, 95) color PINK_LO = color.new(PINK, 80) color BG_DIV = color.new(ORANGE, 90) color BG_RESETS = color.new(GRAY, 90) // Reset conditions 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 RST7 = "On trend changes..." // Trends string TR01 = "Supertrend" string TR02 = "Aroon" string TR03 = "Parabolic SAR" // Volume Delta Calculation Mode string VD01 = "Volume Delta" string VD02 = "Volume Delta Percent" // CVD Line Type string LN01 = "Line" string LN02 = "Histogram" // Label Size string LS01 = "tiny" string LS02 = "small" string LS03 = "normal" string LS04 = "large" string LS05 = "huge" // LTF distinction string LTF1 = "Covering most chart bars (least precise)" string LTF2 = "Covering some chart bars (less precise)" string LTF3 = "Covering less chart bars (more precise)" string LTF4 = "Covering few chart bars (very precise)" string LTF5 = "Covering the least chart bars (most precise)" string LTF6 = "~12 intrabars per chart bar" string LTF7 = "~24 intrabars per chart bar" string LTF8 = "~50 intrabars per chart bar" string LTF9 = "~100 intrabars per chart bar" string LTF10 = "~250 intrabars per chart bar" // Tooltips string TT_RST = "This is where you specify how you want the cumulative volume delta to reset. If you select one of the last three choices, you must also specify the relevant additional information below." 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." string TT_RST_TREND = "These values only matter when '" + RST7 +"' is selected.\n For Supertrend, the first value is the length of ATR, the second is the multiplier. For Aroon, the first value is the lookback length." string TT_LINE = "Select the style and color of CVD lines to display." string TT_LTF = "Your selection here controls how many intrabars will be analyzed for each chart bar. The more intrabars you analyze, the more precise the calculations will be, but the less chart bars will be covered by the indicator's calculations because a maximum of 100K intrabars can be analyzed.\n\n The first five choices determine the lower timeframe used for intrabars using how much chart coverage you want. The last five choices allow you to select approximately how many intrabars you want analyzed per chart bar." string TT_CVD = "Shows a cumulative volume delta value summed from the reset point. Disabling this will show the raw volume delta for each bar." string TT_YSPCE = "Scales the height of all oscillator zones using a percentage of the largest zone's y-range." // ————— Inputs string resetInput = input.string(RST2, "CVD Resets", inline = "00", options = [RST1, RST2, RST5, RST6, RST3, RST4, RST7], tooltip = TT_RST) string fixedTfInput = input.timeframe("D", "  Fixed Higher Timeframe:", inline = "01", tooltip = TT_RST_HTF) int hourInput = input.int(9, "  Fixed Time: Hour", inline = "02", minval = 0, maxval = 23) int minuteInput = input.int(30, "Minute", inline = "02", minval = 0, maxval = 59, tooltip = TT_RST_TIME) string trendInput = input.string(TR01, "  Trend: ", inline = "03", options = [TR02, TR03, TR01]) int trendPeriodInput = input.int(14, " Length", inline = "03", minval = 2) float trendValue2Input = input.float(3.0, "", inline = "03", minval = 0.25, step = 0.25, tooltip = TT_RST_TREND) string ltfModeInput = input.string(LTF3, "Intrabar Precision", inline = "04", options = [LTF1, LTF2, LTF3, LTF4, LTF5, LTF6, LTF7, LTF8, LTF9, LTF10], tooltip = TT_LTF) string vdCalcModeInput = input.string(VD01, "Volume Delta Calculation", inline = "05", options = [VD01, VD02]) bool cumulativeInput = input.bool(true, "Cumulative Values", inline = "06", tooltip = TT_CVD) string GRP1 = "Visuals" string lineTypeInput = input.string(LN01, "CVD", inline = "00", group = GRP1, options = [LN01, LN02]) color upColorInput = input.color(LIME_LINE, "🡓", inline = "01", group = GRP1) color dnColorInput = input.color(PINK_LINE, "🡓", inline = "01", group = GRP1, tooltip = TT_LINE) float percentYRangeInput = input.float(100, "Zone Height (%)", inline = "02", group = GRP1, tooltip = TT_YSPCE) / 100.0 bool showBgAreaInput = input.bool(true, "  Color background area ", inline = "05", group = GRP1) color upBgColorInput = input.color(LIME_BG, "🡑", inline = "05", group = GRP1) color dnBgColorInput = input.color(PINK_BG, "🡓", inline = "05", group = GRP1) bool showHiLoInput = input.bool(true, "  Hi/Lo Lines ", inline = "06", group = GRP1) color hiColorInput = input.color(LIME_HI, "🡑", inline = "06", group = GRP1) color loColorInput = input.color(PINK_LO, "🡓", inline = "06", group = GRP1) bool showZeroLineInput = input.bool(true, "  Zero Line", inline = "07", group = GRP1) color zeroLineColorInput = input.color(GRAY, "🡓", inline = "07", group = GRP1) bool labelInput = input.bool(true, "Hi/Lo Labels", inline = "03", group = GRP1) string labelSizeInput = input.string(LS03, "", inline = "03", group = GRP1, options = [LS01, LS02, LS03, LS04, LS05]) bool tooltipInput = input.bool(true, "Value Tooltips", inline = "04", group = GRP1) bool colorDivBodiesInput = input.bool(true, "Color bars on divergences ", inline = "08", group = GRP1) color upDivColorInput = input.color(LIME, "🡑", inline = "08", group = GRP1) color dnDivColorInput = input.color(PINK, "🡓", inline = "08", group = GRP1) bool bgDivInput = input.bool(false, "Color background on divergences ", inline = "09", group = GRP1) color bgDivColorInput = input.color(BG_DIV, "", inline = "09", group = GRP1) bool bgResetInput = input.bool(true, "Color background on resets ", inline = "10", group = GRP1) color bgResetColorInput = input.color(BG_RESETS, "", inline = "10", group = GRP1) bool showInfoBoxInput = input.bool(true, "Show information box ", inline = "11", group = GRP1) string infoBoxSizeInput = input.string("small", "Size ", inline = "12", group = GRP1, options = ["tiny", "small", "normal", "large", "huge", "auto"]) string infoBoxYPosInput = input.string("bottom", "↕", inline = "12", group = GRP1, options = ["top", "middle", "bottom"]) string infoBoxXPosInput = input.string("left", "↔", inline = "12", group = GRP1, options = ["left", "center", "right"]) color infoBoxColorInput = input.color(GRAY, "", inline = "12", group = GRP1) color infoBoxTxtColorInput = input.color(WHITE, "T", inline = "12", group = GRP1) //#endregion //#region ———————————————————— Functions // @function Determines if the volume for an intrabar is upward or downward. // @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 Detects 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, 0) bool timeInBar = time <= openTime and time_close > openTime bool result = timeframe.isintraday and not timeInBar[1] and timeInBar // @function Produces a value that is scaled to a new range relative to the `oldValue` within the original range. // @param oldValue (series float) The value to scale. // @param oldMin (series float) The low value of the original range. // @param oldMax (series float) The high value of the original range. // @param newMin (series float) The low value of the new range. // @param newMax (series float) The high value of the new range. // @returns (float) A value that is scaled between the `newMin` and `newMax` based on the scaling of the `oldValue` within the `oldMin` and `oldMax` range. scale(series float oldValue, series float oldMin, series float oldMax, series float newMin, series float newMax) => float oldRange = oldMax - oldMin float newRange = newMax - newMin float newValue = (((oldValue - oldMin) * newRange) / oldRange) + newMin // @function Produces a value for histogram line width using a stepped logistic curve based on visible bar count. // @param bars (series int) Number of bars in the visible range. // @param maxWidth (series int) Maximum line width. // @param decayLength (series int) Distance from 0 required for the curve to decay to the minimum value. // @param offset (series int) Offset of the curve along the x-axis. // @returns (int) A line width value that is nonlinearly scaled according to the number of visible bars. scaleHistoWidth(series int bars, simple int maxWidth, simple int decayLength, simple int offset) => int result = math.ceil(2 * maxWidth / (1 + math.exp(6 * (bars - offset) / decayLength))) //#endregion //#region ———————————————————— Calculations // Lower timeframe (LTF) used to mine intrabars. var string ltfString = PCltf.ltf(ltfModeInput, LTF1, LTF2, LTF3, LTF4, LTF5, LTF6, LTF7, LTF8, LTF9, LTF10) // Get upward and downward volume arrays. [upVolumes, dnVolumes] = request.security_lower_tf(syminfo.tickerid, ltfString, upDnIntrabarVolumes()) // Create conditions for lines and labels from user inputs. bool useVdPct = vdCalcModeInput == VD02 bool useHisto = lineTypeInput == LN02 // Find visible chart attributes. int leftBar = chart.leftBarIndex() int rightBar = chart.rightBarIndex() bool isVisible = chart.barIsVisible() bool isLastBar = chart.isLastVisibleBar() int totalBars = chart.bars() // Calculate line width for histogram display. int lineWidth = scaleHistoWidth(totalBars, 29, 391, -63) // Calculate the maximum volumes, total volume, and volume delta, and assign the result to the `barDelta` variable. float totalUpVolume = nz(upVolumes.sum()) float totalDnVolume = nz(dnVolumes.sum()) float maxUpVolume = nz(upVolumes.max()) float maxDnVolume = nz(dnVolumes.min()) float totalVolume = totalUpVolume - totalDnVolume float delta = totalUpVolume + totalDnVolume float deltaPct = delta / totalVolume float barDelta = useVdPct ? deltaPct : delta // Track cumulative volume. [reset, trendIsUp, resetDescription] = switch resetInput RST1 => [false, na, "No resets"] RST2 => [timeframe.change(htfStep()), na, "Resets every " + htfStep()] RST3 => [timeframe.change(fixedTfInput), na, "Resets every " + fixedTfInput] RST4 => [timeReset(hourInput, minuteInput), na, str.format("Resets at {0,number,00}:{1,number,00}", hourInput, minuteInput)] RST5 => [session.isfirstbar_regular, na, "Resets at the beginning of the session"] RST6 => [time == chart.left_visible_bar_time, na, "Resets at the beginning of visible bars"] RST7 => switch trendInput TR01 => [_, direction] = ta.supertrend(trendValue2Input, trendPeriodInput) [ta.change(direction, 1) != 0, direction == -1, "Resets on Supertrend changes"] TR02 => [up, dn] = TVta.aroon(trendPeriodInput) [ta.cross(up, dn), ta.crossover(up, dn), "Resets on Aroon changes"] TR03 => float psar = ta.sar(0.02, 0.02, 0.2) [ta.cross(psar, close), ta.crossunder(psar, close), "Resets on PSAR changes"] => [na, na, na] // Get the qty of intrabars per chart bar and the average. int intrabars = upVolumes.size() int chartBarsCovered = int(ta.cum(math.sign(intrabars))) float avgIntrabars = ta.cum(intrabars) / chartBarsCovered // Detect divergences between volume delta and the bar's polarity. bool divergence = delta != 0 and math.sign(delta) != math.sign(close - open) // Segment's values, price range and start management. var array<float> segCvdValues = array.new<float>() var array<float> rawCvdValues = array.new<float>() var array<float> barCenters = array.new<float>() var array<float> zeroLevels = array.new<float>() var array<float> priceRanges = array.new<float>() var array<float> highCvd = array.new<float>() var array<float> lowCvd = array.new<float>() var array<int> resetBars = array.new<int>() var float priceHi = high var float priceLo = low var float cvd = 0.0 priceHi := isVisible ? math.max(priceHi, high) : high priceLo := isVisible ? math.min(priceLo, low) : low // Store values for the visible segment on the reset bar, or last bar. if reset or isLastBar if isVisible segCvdValues.push(cumulativeInput ? cvd + barDelta : barDelta) resetBars.push(bar_index) zeroLevels.push(math.avg(priceHi, priceLo) - (priceHi - priceLo)) priceRanges.push((priceHi - priceLo) / 2) highCvd.push(segCvdValues.max()) lowCvd.push(segCvdValues.min()) barCenters.push(hl2) rawCvdValues.concat(segCvdValues) segCvdValues.clear() priceHi := high priceLo := low cvd := reset ? 0 : cvd // Cumulate CVD. float cvdO = cvd cvd += barDelta // Draw CVD objects on the last visible bar. if isLastBar // Initialize `startBar` to the leftmost bar, find the highest Y value and greatest absolute CVD Value. int startBar = leftBar int step = 0 float yRangeMax = priceRanges.max() * percentYRangeInput float highScale = useVdPct and not cumulativeInput ? 1 : array.max(rawCvdValues.abs()) for [i, resetBar] in resetBars // For each reset bar, find the segment's zero level, Y range, high/low CVD, and scale the CVD values. float zero = zeroLevels.get(i) float yRange = priceRanges.get(i) float highValue = highCvd.get(i) float lowValue = lowCvd.get(i) float highLevel = scale(highValue, 0, highScale, zero, zero + yRangeMax) float offset = zero + yRange - (useHisto ? math.max(highLevel, zero) : highLevel) float zeroLevel = zero + offset float hiLevel = zeroLevel + yRangeMax float loLevel = zeroLevel - yRangeMax // If enabled, draw the zero level, high and low bounds, and fill range background when there is LTF data for the segment. if showZeroLineInput line.new(startBar, zeroLevel, resetBar, zeroLevel, color = zeroLineColorInput, style = line.style_dashed) if showHiLoInput line.new(startBar, hiLevel, resetBar, hiLevel, color = hiColorInput) line.new(startBar, loLevel, resetBar, loLevel, color = loColorInput) if showBgAreaInput box.new(startBar, hiLevel, resetBar, zeroLevel, border_color = color(na), bgcolor = upBgColorInput) box.new(startBar, loLevel, resetBar, zeroLevel, border_color = color(na), bgcolor = dnBgColorInput) // Initialize the `bar` variable and track the last price value and high and low label placements for the segment. int bar = startBar float lastPriceValue = na bool placeHigh = true bool placeLow = true for x = step to resetBar - startBar + step // For each CVD value in the segment, calculate and scale the price level. Determine line color and label text. float cvdValue = rawCvdValues.get(x) float eachCvd = cvdValue != 0 ? cvdValue : na float priceLvl = scale(eachCvd, 0, highScale, zero, zero + yRangeMax) + offset color lineColor = priceLvl > zeroLevel ? upColorInput : dnColorInput string labelStr = labelInput ? useVdPct ? str.format("{0, number, percent}", eachCvd) : str.tostring(eachCvd, format.volume) : string(na) bool isHiCvd = eachCvd == highValue bool isLoCvd = eachCvd == lowValue // Draw a label for the highest or lowest CVD in the segment if "Hi/Lo Labels" is enabled. if labelInput and (isHiCvd or isLoCvd) bool drawHiLbl = isHiCvd and placeHigh and bar != leftBar bool drawLoLbl = isLoCvd and placeLow and bar != leftBar string labelStyle = isHiCvd ? label.style_label_down : label.style_label_up float labelPrice = useHisto ? highValue < 0 and isHiCvd or lowValue > 0 and isLoCvd ? zeroLevel : priceLvl : priceLvl // Check that a high or low label has not already been drawn. if drawHiLbl or drawLoLbl label.new(bar, labelPrice, labelStr, color = color(na), style = labelStyle, textcolor = lineColor, size = labelSizeInput) placeHigh := drawHiLbl ? false : placeHigh placeLow := drawLoLbl ? false : placeLow // Draw an invisible label with a CVD value tooltip over each chart bar if "Value Tooltips" is enabled. if tooltipInput label.new(bar, barCenters.get(x), LBL_TXT, color = color(na), size = size.tiny, style = label.style_label_center, tooltip = labelStr) // Draw a line for the CVD value on each bar, using the current and previous bar values for line display, or the current bar and zero level for histogram display. switch useHisto => line.new(bar, zeroLevel, bar, priceLvl, color = lineColor, width = lineWidth) bar > startBar => line.new(bar - 1, lastPriceValue, bar, priceLvl, color = lineColor, width = 2) // Increment `bar` by one, set last price level to the price on this iteration. bar += 1 lastPriceValue := priceLvl // Increment the step counter by the number of bars in the current segment, set the start bar to the reset bar for the next iteration. step += resetBar - startBar + 1 startBar := resetBar // Store values for visible bars. if isVisible segCvdValues.push(cumulativeInput ? cvd : barDelta) barCenters.push(hl2) //#endregion //#region ———————————————————— Visuals color candleColor = colorDivBodiesInput and divergence ? delta > 0 ? upDivColorInput : dnDivColorInput : na // Display key values in indicator values and Data Window. displayDataWindow = display.data_window plot(delta, "Volume delta for the bar", candleColor, display = displayDataWindow) plot(totalUpVolume, "Up volume for the bar", upColorInput, display = displayDataWindow) plot(totalDnVolume, "Dn volume for the bar", dnColorInput, display = displayDataWindow) plot(totalVolume, "Total volume", display = displayDataWindow) plot(na, "═════════════════", display = displayDataWindow) plot(cvdO, "CVD before this bar", display = displayDataWindow) plot(cvd, "CVD after this bar", display = displayDataWindow) plot(maxUpVolume, "Max intrabar up volume", upColorInput, display = displayDataWindow) plot(maxDnVolume, "Max intrabar dn volume", dnColorInput, display = displayDataWindow) plot(intrabars, "Intrabars in this bar", display = displayDataWindow) plot(avgIntrabars, "Average intrabars", display = displayDataWindow) plot(chartBarsCovered, "Chart bars covered", display = displayDataWindow) plot(bar_index + 1, "Chart bars", display = displayDataWindow) plot(na, "═════════════════", display = displayDataWindow) plot(totalBars, "Total visible bars", display = displayDataWindow) plot(leftBar, "First visible bar index", display = displayDataWindow) plot(rightBar, "Last visible bar index", display = displayDataWindow) plot(na, "═════════════════", display = displayDataWindow) // Up/Dn arrow used when resets occur on trend changes. plotchar(reset and not na(trendIsUp) ? trendIsUp : na, "Up trend", "▲", location.top, upColorInput) plotchar(reset and not na(trendIsUp) ? not trendIsUp : na, "Dn trend", "▼", location.top, dnColorInput) // Background on resets and divergences. bgcolor(bgResetInput and reset ? bgResetColorInput : bgDivInput and divergence ? bgDivColorInput : na) barcolor(candleColor) // 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) color infoBoxBgColor = infoBoxColorInput string txt = str.format( "{0}\nUses intrabars at {1}\nAvg intrabars per chart bar: {2,number,#.##}\nChart bars covered: {3} / {4} ({5,number,percent})", resetDescription, PCtime.formattedNoOfPeriods(timeframe.in_seconds(ltfString) * 1000), avgIntrabars, chartBarsCovered, bar_index + 1, chartBarsCovered / (bar_index + 1)) if avgIntrabars < 5 txt += "\nThis quantity of intrabars is dangerously small.\nResults will not be as reliable with so few." infoBoxBgColor := color.red table.cell(infoBox, 0, 0, txt, text_color = infoBoxTxtColorInput, text_size = infoBoxSizeInput, bgcolor = infoBoxBgColor) //#endregion //#region ———————————————————— 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 resetInput == RST5 and not timeframe.isintraday runtime.error("Resets at the begining of session work on intraday charts only.") else if ta.cum(totalVolume) == 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 '" + ltfString + "' timeframe.") //#endregion
Squeeze Momentum MTF [LPWN]
https://www.tradingview.com/script/DW6z0ffm-Squeeze-Momentum-MTF-LPWN/
Lupown
https://www.tradingview.com/u/Lupown/
359
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Lupown //@version=5 indicator(shorttitle='Squeeze Momentum MTF [LPWN]', title='Squeeze Momentum MTF [LPWN]', overlay=false) //squeeze momoentum by lazy bear import hapharmonic/ConverterTF/1 as X cipher = "------------------------ CIPHER DOTS ------------------------" rsiGrp = "---------------------------- RSI ----------------------------" szqGrp = "-------------------------- Squeeze --------------------------" adxGrp = "---------------------------- ADX ----------------------------" divGrp = "------------------------- Divergences -------------------------" htfGrp = "---------------------------- HTF ----------------------------" momGrp = "---------------------------- Momentums ----------------------------" pryGrp = "---------------------------- Proyection ----------------------------" tblGrp = "---------------------------- Table ----------------------------" // —————————— PineCoders MTF Selection Framework functions // ————— Converts current "timeframe.multiplier" plus the TF into minutes of type float. f_resInMinutes() => _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60. : timeframe.isminutes ? 1. : timeframe.isdaily ? 1440. : timeframe.isweekly ? 10080. : timeframe.ismonthly ? 43800. : na) _resInMinutes // ————— Returns resolution of _resolution period in minutes. f_tfResInMinutes(_resolution) => // _resolution: resolution of any TF (in "timeframe.period" string format). request.security(syminfo.tickerid, _resolution, f_resInMinutes()) // ————— Given current resolution, returns next step of HTF. f_resNextStep(_res,mom2,info) => // _res: current TF in fractional minutes. if mom2 or info _res <= 1 ? '5' : _res <= 5 ? '9' : _res <= 15 ? '30' : _res <= 30 ? '60' : _res <= 60 ? '240' : _res <= 360 ? '1D' : _res <= 1440 ? '1W' : '2W'//_res <= 10080 ? '1M' : '1M' else str.tostring(_res) f_resNextStep2(_res,mom3,info) => // _res: current TF in fractional minutes. if mom3 or info _res <= 1 ? '9' : _res <= 5 ? '15' : _res <= 15 ? '45' : _res <= 30 ? '120' : _res <= 60 ? '480' : _res <= 360 ? '2D' : _res <= 1440 ? '1W' : '2W'//_res <= 10080 ? '1M' : '2M' else str.tostring(_res) // ————— ORIGINAL // f_resNextStep(_res) => // // _res: current TF in fractional minutes. // _res <= 1 ? "15" : // _res <= 5 ? "60" : // _res <= 30 ? "240" : // _res <= 60 ? "1D" : // _res <= 360 ? "3D" : // _res <= 1440 ? "1W" : // _res <= 10080 ? "1M" : "12M" // ————— Returns a multiple of current resolution as a string in "timeframe.period" format usable with "security()". f_multipleOfRes(_res, _mult) => // _res: current resolution in minutes, in the fractional format supplied by f_resInMinutes() companion function. // _mult: Multiple of current TF to be calculated. // Convert current float TF in minutes to target string TF in "timeframe.period" format. _targetResInMin = _res * math.max(_mult, 1) _targetResInMin <= 0.083 ? '5S' : _targetResInMin <= 0.251 ? '15S' : _targetResInMin <= 0.501 ? '30S' : _targetResInMin <= 1440 ? str.tostring(math.round(_targetResInMin)) : _targetResInMin <= 43800 ? str.tostring(math.round(math.min(_targetResInMin / 1440, 365))) + 'D' : str.tostring(math.round(math.min(_targetResInMin / 43800, 12))) + 'M' // ————— Print a label at end of chart. f_htfLabel(_txt, _y, _color, _offsetLabels) => _t = int(time + f_resInMinutes() * _offsetLabels * 60000) var _lbl = label.new(_t, _y, _txt, xloc.bar_time, yloc.price, #00000000, label.style_none, color.gray, size.large) if barstate.islast label.set_xy(_lbl, _t, _y) label.set_text(_lbl, _txt) label.set_textcolor(_lbl, _color) // } // ————— INPUTS TF0 = 'None' TF1 = 'Auto-Steps (15min, 60min, 4H, 1D, 3D, 1W, 1M, 12M)' TF2 = 'Multiple Of Current TF' TF3 = 'Fixed TF' i_htfType = input.string(TF1, 'Higher Timeframe Selection', options=[TF0, TF1, TF2, TF3],group = htfGrp) i_htfType2 = input.float(3., '  Multiple of Current TF 1', minval=1,group = htfGrp) i_htfType22 = input.float(5., '  Multiple of Current TF 2', minval=1,group = htfGrp) i_htfType3 = input.timeframe('240', '  Fixed TF 1',group = htfGrp) i_htfType33 = input.timeframe('D', '  Fixed TF 2',group = htfGrp) useHistorial = true//input(true, 'Usar historial') historial = 500//input(500, 'Historial') proyec = false//input(false, 'Mostrar proyeccion') predict = input(true, 'Show predict') armoniColor = input(false, 'Momentum color') colorbar = input(true, 'Candle color with') int lengthM = input.int(20, title='MOM Length', minval=1, step=1, group = momGrp) srcM = input(close, title='MOM Source', group = momGrp) mom2 = input(true, title='Momentum HTF 1 ', group = momGrp) doble2 = input(true, 'Show momentum 1 histogram', group = momGrp) smoothM2 = input(1, 'Smooth momentum 1', group = momGrp) farMom2 = input(0, title='Away from 0 point 1 momentum', group = momGrp) mom3 = input(true, title='Momentum HTF 2', group = momGrp) doble3 = input(true, 'Show momentum 2 histogram', group = momGrp) smoothM3 = input(1, 'Smooth Momentum 2', group = momGrp) farMom3 = input(0, title='Away from 0 point 2 momentum', group = momGrp) int length = input.int(20, title='SQZ Length', minval=1, step=1,group = szqGrp) src = input(close, title='SQZ Source',group = szqGrp) lengths = input(20, title='BB Length',group = szqGrp) mult = input(2.0,title="BB MultFactor",group = szqGrp) lengthKC = input(20, title='KC Length',group = szqGrp) multKC = input(1.5, title='KC MultFactor',group = szqGrp) scale = input(75.0, title='General scale',group = szqGrp) //DivergenceS BUENNNNNNNAS show_div = input(true, title='Show Divergences',group = divGrp) lbR = input(title='Pivot Lookback Right', defval=1,group = divGrp) lbL = input(title='Pivot Lookback Left', defval=1,group = divGrp) rangeUpper = input(title='Max of Lookback Range', defval=60,group = divGrp) rangeLower = input(title='Min of Lookback Range', defval=1,group = divGrp) plotBull = input(title='Plot Bullish', defval=true,group = divGrp) plotHiddenBull = input(title='Plot Hidden Bullish', defval=true,group = divGrp) plotBear = input(title='Plot Bearish', defval=true,group = divGrp) plotHiddenBear = input(title='Plot Hidden Bearish', defval=true,group = divGrp) show_ADX = input(false, title='Show ADX',group = adxGrp) scaleADX = input(2.0, title='ADX scale',group = adxGrp) show_di = input(false, title=' Show +DI -DI',group = adxGrp) show_aa = input.bool(false, 'Show 23 level apart', inline='adx line',group = adxGrp) far = input.int(-7, 'Separation', inline='adx line',group = adxGrp) adxlen = input(14, title='ADX Smoothing',group = adxGrp) dilen = input(14, title='DI Length',group = adxGrp) keyLevel = input(23, title='Key level for ADX',group = adxGrp) show_bg = input(false, title='Show bg color',group = adxGrp) //RSI show_rsi = input(false, title='Show RSI',group = rsiGrp) show_RSIfondo = input(true, title='Show RSI background',group = rsiGrp) rsiApart = input(0, title='RSI separation',group = rsiGrp) len = input.int(14, minval=1, title='Length RSI ',group = rsiGrp) upperR = input(70, title='Upper band',group = rsiGrp) middleR = input(50, title='Middle band',group = rsiGrp) lowerR = input(30, title='Lower band',group = rsiGrp) show_cphr = input(true, title='Show Cipher dots',group = cipher) n1 = input(9, title='Channel Length',group = cipher) n2 = input(12, title='Average Length',group = cipher) smooth = input(3, title='Smooth Factor',group = cipher) showTable = input.bool(true,"Show Table",group = tblGrp) showAdxTbl = input.bool(true,"Show ADX info",group = tblGrp) showMomInfo = input.bool(false,"Show MOM info always",group = tblGrp) TblY = input.string('top', 'Table Position', inline='11', options=['top', 'middle', 'bottom'],group = tblGrp) TblX = input.string('right', '', inline='11', options=['left', 'center', 'right'],group = tblGrp) // STEP 1. Make an input with drop-down menu sizeOption = input.string(title="Table Size",options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], defval="Normal",group = tblGrp) // STEP 2. Convert the input to valid label sizes labelSize = (sizeOption == "Huge") ? size.huge : (sizeOption == "Large") ? size.large : (sizeOption == "Small") ? size.small : (sizeOption == "Tiny") ? size.tiny : (sizeOption == "Auto") ? size.auto : size.normal ca1 = input.color(#00FF00,title = "Bullish 1",group = "Colors",inline = "mom1") cb1 = input.color(#FF0000,title = "Bearish 1",group = "Colors",inline = "mom1") crs1 = input.color(#008000,title = "sideway-Bulish 1",group = "Colors",inline = "mom1") crc1 = input.color(#800000,title = "sideway-Bearish 1",group = "Colors",inline = "mom1") ca2 = input.color(#66bb6a,title = "Bullish 2",group = "Colors",inline = "mom2") cb2 = input.color(#f75555,title = "Bearish 2",group = "Colors",inline = "mom2") crs2 = input.color(#056656,title = "sideway-Bulish 2",group = "Colors",inline = "mom2") crc2 = input.color(#a90044,title = "sideway-Bearish 2",group = "Colors",inline = "mom2") ca3 = input.color(#74d18b,title = "Bullish 3",group = "Colors",inline = "mom3") cb3 = input.color(#ff8888,title = "Bearish 3",group = "Colors",inline = "mom3") crs3 = input.color(#406640,title = "sideway-Bulish 3",group = "Colors",inline = "mom3") crc3 = input.color(#8d0707,title = "sideway-Bearish 3",group = "Colors",inline = "mom3") show_Momen = true //input(true, title='-----------Show squeeze momentum-------') // HTF is being used. var htfOn = i_htfType != TF0 // ————— HTF calcs // Get current resolution in float minutes. var resInMinutes = f_resInMinutes() // Get HTF from user-defined mode. var htf = i_htfType == TF0 ? timeframe.period : i_htfType == TF1 ? f_resNextStep(resInMinutes,mom2,showMomInfo) : i_htfType == TF2 ? f_multipleOfRes(resInMinutes, i_htfType2) : i_htfType3 var htf2 = i_htfType == TF0 ? timeframe.period : i_htfType == TF1 ? f_resNextStep2(resInMinutes,mom3,showMomInfo) : i_htfType == TF2 ? f_multipleOfRes(resInMinutes, i_htfType22) : i_htfType33 //plotshape(show_Momen?0:na,style=shape.xcross,color=scolor,location=location.absolute) ///// ADX //SQUEEZE useTrueRange = true // Calculate BB source = close basis = ta.sma(source, lengths) dev = multKC * ta.stdev(source, lengths) upperBB = basis + dev lowerBB = basis - dev // Calculate KC ma = ta.sma(source, lengthKC) range_1 = useTrueRange ? ta.tr : high - low rangema = ta.sma(range_1, lengthKC) upperKC = ma + rangema * multKC lowerKC = ma - rangema * multKC sqzOn = lowerBB > lowerKC and upperBB < upperKC sqzOff = lowerBB < lowerKC and upperBB > upperKC noSqz = sqzOn == false and sqzOff == false scolor = noSqz ? color.blue : sqzOn ? #000000 : color.gray //plotshape(show_Momen? true : na, color=scolor, style=shape.xcross) plot(show_Momen ? 0 : na, title='Squeeze Zero Line', color=scolor, linewidth=2, style=plot.style_cross) dirmov(len) => up = ta.change(high) down = -ta.change(low) truerange = ta.rma(ta.tr, len) plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, len) / truerange) minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, len) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) [adx, plus, minus] [adxValue, diplus, diminus] = adx(dilen, adxlen) biggest(series) => max = 0.0 max := nz(max[1], series) if series > max max := series max max //FUNCTIONS plFound(osc) => na(ta.pivotlow(osc, lbL, lbR)) ? false : true phFound(osc) => na(ta.pivothigh(osc, lbL, lbR)) ? false : true sz = ta.linreg(srcM - math.avg(math.avg(ta.highest(high, lengthM), ta.lowest(low, lengthM)), ta.sma(close, lengthM)), lengthM, 0) // Calculate ADX Scale ni = biggest(sz) far1 = far * ni / scale adx_scale = (adxValue - keyLevel) * ni / scale adx_scale2 = (adxValue - keyLevel + far) * ni / scale sz2 = request.security(syminfo.tickerid, htf, ta.linreg(srcM - math.avg(math.avg(ta.highest(high, lengthM), ta.lowest(low, lengthM)), ta.sma(close, lengthM)), lengthM, 0)) sz3 = request.security(syminfo.tickerid, htf2, ta.linreg(srcM - math.avg(math.avg(ta.highest(high, lengthM), ta.lowest(low, lengthM)), ta.sma(close, lengthM)), lengthM, 0)) adx2 = request.security(syminfo.tickerid, htf, adxValue) adx3 = request.security(syminfo.tickerid, htf2, adxValue) sz2ws = sz2 + farMom2 * ni / scale sz3ws = sz3 + farMom3 * ni / scale sz22 = ta.ema(ta.ema(ta.ema(sz2ws, smoothM2), smoothM2), smoothM2) sz33 = ta.ema(ta.ema(ta.ema(sz3ws, smoothM3), smoothM3), smoothM3) sc1 = sz >= 0 sc2 = sz < 0 sc3 = sz >= sz[1] sc4 = sz < sz[1] clr = sc1 and sc3 ? ca1 : sc1 and sc4 ? crs1 : sc2 and sc4 ? cb1 : sc2 and sc3 ? crc1 : color.gray clr1 = sc1 and sc3 ? ca1 : sc1 and sc4 ? crc1 : sc2 and sc4 ? cb1 : sc2 and sc3 ? crs1 : color.gray iMom = sc1 and sc3 ? '↗️' : sc1 and sc4 ? '↘️' : sc2 and sc4 ? '↘️' : sc2 and sc3 ? '↗️' : '-' //ORIGNAL sc12 = sz2 >= 0 sc22 = sz2 < 0 sc32 = plFound(sz2) sc42 = phFound(sz2) iMom2 = '' iMom3 = '' clr2 = color.gray clr3 = color.white clr22 = color.gray clr33 = color.white clr2 := sc12 and sc32 ? ca2 : sc12 and sc42 ? crs2 : sc22 and sc42 ? cb2 : sc22 and sc32 ? crc2 : clr2[1] clr22 := sc12 and sc32 ? ca1 : sc12 and sc42 ? crc1 : sc22 and sc42 ? cb1 : sc22 and sc32 ? crs1 : clr22[1] color2 = clr22 color21 = clr2 iMom2 := sc12 and sc32 ? '↗️' : sc12 and sc42 ? '↘️' : sc22 and sc42 ? '↘️' : sc22 and sc32 ? '↗️' : iMom2[1] //ORIGNAL sc13 = sz3 >= 0 sc23 = sz3 < 0 sc33 = plFound(sz3) sc43 = phFound(sz3) clr3 := sc13 and sc33 ? ca3 : sc13 and sc43 ? crs3 : sc23 and sc43 ? cb3 : sc23 and sc33 ? crc3 : clr3[1] clr33 := sc13 and sc33 ? ca1 : sc13 and sc43 ? crc1 : sc23 and sc43 ? cb1 : sc23 and sc33 ? crs1 : clr33[1] color3 = clr33 color31 = clr3 iMom3 := sc13 and sc33 ? '↗️' : sc13 and sc43 ? '↘️' : sc23 and sc43 ? '↘️' : sc23 and sc33 ? '↗️' : iMom3[1] //ORIGNAL clr3Av = clr3 == ca3 clr2Av = clr2 == ca2 clrAv = clr == ca1 clr3Ar = clr3 == crc3 clr2Ar = clr2 == crc2 clrAr = clr == crc1 clr3Av2 = clr3 == cb3 clr2Av2 = clr2 == cb2 clrAv2 = clr == cb1 clr3Ar2 = clr3 == crs3 clr2Ar2 = clr2 == crs2 clrAr2 = clr == crs1 clrA = clr3Av and clr2Av and clrAv or clr3Ar and clr2Ar and clrAr or clr3Av and clr2Av and clrAr or clrAv and clr2Av and clr3Ar or clr3Av and clrAv and clr2Ar or clr3Ar and clr2Ar and clrAv or clrAr and clr2Ar and clr3Av or clr3Ar and clrAr and clr2Av ? ca1 : clr3Av2 and clr2Av2 and clrAv2 or clr3Ar2 and clr2Ar2 and clrAr2 or clr3Av2 and clr2Av2 and clrAr2 or clrAv2 and clr2Av2 and clr3Ar2 or clr3Av2 and clrAv2 and clr2Ar2 or clr3Ar2 and clr2Ar2 and clrAv2 or clrAr2 and clr2Ar2 and clr3Av2 or clr3Ar2 and clrAr2 and clr2Av2 ? cb1 : #e4e4e4 //clrA = sz > sz[1] and sz2 >= sz2[1] and sz3 >= sz3[1] ? ca1 : sz < sz[1] and sz2 <= sz2[1] and sz3 <= sz3[1] ? cb1 : #423432 barcolor(colorbar ? clrA : na) plot(doble3 and mom3 ? sz33 : na, title='Momentum 3 doble', style=plot.style_histogram, color=color31) plot(doble2 and mom2 ? sz22 : na, title='Momentum 2 doble', style=plot.style_histogram, color=color21) plot(show_Momen ? sz : na, title='Squeeze Momentum', color=armoniColor ? clrA : clr, style=plot.style_area) plotmom2 = plot(mom2 ? sz22 : na, title='Squeeze Momentum 2', color=clr2, style=plot.style_line, linewidth=3) band2 = plot(mom2 ? farMom2 * ni / scale : na, color=color.new(color.white, 60)) fill(plotmom2, band2, color=mom2 ? color.new(clr2,90) : na, title='MOM2 Fill') plotmom3 = plot(mom3 ? sz33 : na, title='Squeeze Momentum 3', color=color.new(clr3, 0), style=plot.style_line, linewidth=4) band3 = plot(mom3 ? farMom3 * ni / scale : na, color=color.new(color.white, 60)) fill(plotmom3, band3, color=mom2 ? color.new(clr3,90) : na, title='MOM3 Fill') var npl = array.new_float(historial, 0) var nph = array.new_float(historial, 0) var hh = 1 var ll = 1 var contH = 0 var contL = 0 var totH = 1 var totL = 1 var promH = 0.0 var promL = 0.0 szint = math.round(sz) contH += 1 contL += 1 if phFound(sz) hh += contH contH := 0 //contL := 0 totH += 1 totH if plFound(sz) ll += contL contL := 0 //contH := 0 totL += 1 totL //label.new(bar_index,0,tostring(ll[0])) //label.new(bar_index[1],0,tostring(ll[1])) //label.new(bar_index[2],0,tostring(ll[2])) //label.new(bar_index[3],0,tostring(ll[3])) promH := hh / totH promL := ll / totL var al = line.new(0, 0, 0, 0) var bl = line.new(0, 0, 0, 0) if phFound(sz) and predict //label.new(bar_index + round(promL),0,text = "🤑",color = color.green ) al := line.new(bar_index + math.round(promL), 0, bar_index + math.round(promL), 0.001, extend=extend.both, color=color.green) line.delete(bl) if plFound(sz) and predict bl := line.new(bar_index + math.round(promH), 0, bar_index + math.round(promH), 0.001, extend=extend.both, color=color.red) line.delete(al) //label.new(bar_index + round(promH),0,text = "🤑" ,color = color.red) // if barstate.islast // for i = historial to 0 // hh := hh + sz[i] // plot (sma(hh,historial),style = plot.style_columns,show_last = historial) //////////////////////////////////// //ADX ///////////////////////////// dip = (diplus - keyLevel) * ni / scale dim = (diminus - keyLevel) * ni / scale plot(show_di ? dip * scaleADX : na, color=color.new(color.green, 0), title='DI+') plot(show_di ? dim * scaleADX : na, color=color.new(color.red, 0), title='DI-') color_ADX = adxValue > adxValue[1] ? #ffffff : #a09a9a bgcolor(adxValue > adxValue[1] and adxValue > 23 and show_Momen and show_bg ? clr : na) rsi = ta.rsi(src, len) rsiColor = rsi <= lowerR ? color.green : rsi >= upperR ? color.red : #da00ff rsi_scale = (rsi + rsiApart) * ni / scale b1s = (rsiApart + upperR) * ni / scale bm = (rsiApart + middleR) * ni / scale b0s = (rsiApart + lowerR) * ni / scale //rsiColor2 = divergence > 0 ? color.lime:color.red plot(show_rsi ? rsi_scale : na, 'RSI', color=show_rsi ? rsiColor : na) band1 = plot(show_rsi ? b1s : na, color=bar_index % 2 == 0 ? color.rgb(255, 255, 255, 38) : #00000000) band0 = plot(show_rsi ? b0s : na, color=bar_index % 2 == 0 ? color.rgb(255, 255, 255, 38) : #00000000) bandm = plot(show_rsi ? bm : na, color=bar_index % 2 == 0 ? color.rgb(255, 255, 255, 38) : #00000000) fill(band1, band0, color=show_rsi and show_RSIfondo ? color.rgb(155, 39, 176, 84) : na, title='RSI background') ////////////////////// //////////////////////////////////////////// ////////////////////// //WT the cipher dots use a indicator by lazy bear //wt CALC(n1, n2, smooth) => ap = hlc3 esa = ta.ema(ap, n1) dw = ta.ema(math.abs(ap - esa), n1) ci = (ap - esa) / (0.015 * dw) tci = ta.ema(ci, n2) wt1 = tci wt2 = ta.sma(wt1, smooth) wave = wt1 - wt2 wavecolor = wave >= 0 ? color.lime : color.red [wave, wavecolor] //CIPHERR [wave, wavecolor] = CALC(n1, n2, smooth) middle = 0 condWt = ta.cross(wave, middle) ? true : na wtjeje = sz //show_Momen ? : show_ao ? ao : show_macd ? macd : na plot(condWt and show_cphr ? wtjeje : na, title='Buy and sell circle', color=wavecolor, style=plot.style_circles, linewidth=3) /////plot ADX plot(show_aa ? far1 * scaleADX : na, color=color.new(color.white, 0), title='Punto 23') p1 = plot(show_aa ? adx_scale2 * scaleADX : show_ADX ? adx_scale * scaleADX : na, color=color_ADX, title='ADX', linewidth=2) /// /////////////// // ESTADOOO show_status = input(false, title='------Show STATUS----------') dist = input(10, title='Monitor distance') dashColor = input.color(color.new(#696969, 90), 'label Color', inline='Dash Line') dashTextColor = input.color(color.new(#ffffff, 0), 'Text Color', inline='Dash Line') if adxValue > adxValue[1] and adxValue > 23 iadx = 'ADX con pendiente positiva por encima punto 23' iadx if adxValue > adxValue[1] and adxValue < 23 iadx = 'ADX con pendiente positiva por debajo punto 23' iadx if adxValue < adxValue[1] and adxValue < 23 iadx = 'ADX con pendiente negativa por debajo punto 23' iadx if adxValue < adxValue[1] and adxValue > 23 iadx = 'ADX con pendiente negativa por encima punto 23' iadx a1 = adxValue >= 23 a2 = adxValue < 23 a3 = adxValue >= adxValue[1] a4 = adxValue < adxValue[1] iAdx = a1 and a3 ? 'Pendiente positiva ↑ 23' : a1 and a4 ? 'Pendiente negativa ↑ 23' : a2 and a4 ? 'Pendiente negativa ↓ 23' : a2 and a3 ? 'Pendiente positiva ↓ 23' : '-' iAdx1 = a1 and a3 ? '↗️ ↑ 23' : a1 and a4 ? '↘️ ↑ 23' : a2 and a4 ? '↘️ ↓ 23' : a2 and a3 ? '↗️ ↓ 23' : '-' iAdx2 = a1 and a3 ? '↗️ ↑ 23' : a1 and a4 ? '↘️ ↑ 23' : a2 and a4 ? '↘️ ↓ 23' : a2 and a3 ? '↗️ ↓ 23' : '-' iAdx3 = a1 and a3 ? '↗️ ↑ 23' : a1 and a4 ? '↘️ ↑ 23' : a2 and a4 ? '↘️ ↓ 23' : a2 and a3 ? '↗️ ↓ 23' : '-' // iMom = sc1 and sc3 ? 'Direccionalidad Bullish' : sc1 and sc4 ? 'Direccionalidad Bearish' : // sc2 and sc4 ? 'Direccionalidad Bearish' : sc2 and sc3 ? 'Direccinalidad Bullish' : '-' igral = a1 and a3 and sc1 and sc3 ? 'Fuerte movimiento Bullish' : a1 and a3 and sc1 and sc4 ? 'Monitor muestra sideway-Bearish pero\nel movimiento tiene fuerza' : a1 and a3 and sc2 and sc4 ? 'Fuerte movimiento Bearish' : a1 and a3 and sc2 and sc3 ? 'Monitor muestra sideway-Bulish pero\nel movimiento tiene fuerza' : a1 and a4 and sc1 and sc3 ? 'Movimiento Bullish sin fuerza' : a1 and a4 and sc1 and sc4 ? 'Monitor muestra sideway-Bearish\n pendiente negativa en ADX ' : a1 and a4 and sc2 and sc4 ? 'Movimiento Bearish sin fuerza' : a1 and a4 and sc2 and sc3 ? 'Monitor muestra sideway-Bulish con \npendiente negativa en ADX ' : a2 and a4 and sc1 and sc3 ? 'Movimiento Bullish sin fuerza' : a2 and a4 and sc1 and sc4 ? 'Monitor muestra sideway-Bearish sin fuerza ' : a2 and a4 and sc2 and sc4 ? 'Movimiento Bearish sin fuerza' : a2 and a4 and sc2 and sc3 ? 'Monitor muestra sideway-Bulish sin fuerza ' : a2 and a3 and sc1 and sc3 ? 'Movimiento Bullish que \n quiere agarrar fuerza' : a2 and a3 and sc1 and sc4 ? 'Monitor muestra sideway-Bearish,\n el movimiento quiere agarrar fuerza' : a2 and a3 and sc2 and sc4 ? 'Movimiento Bearish que \n quiere agarrar fuerza' : a2 and a3 and sc2 and sc3 ? 'Monitor muestra sideway-Bulish,\n el movimiento quiere agarrar fuerza' : '-' s = '\n' scr_label = 'Info ADX: ' + iAdx + s + 'Info monitor: ' + iMom + s + 'Info general:' + s + igral // Plot Label on the chart // Plot Label on the chart if show_status lab_l = label.new(bar_index + dist, 0, '\t Estatus segun estrategia\n\t' + scr_label, color=dashColor, textcolor=dashTextColor, style=label.style_label_left, yloc=yloc.price) label.delete(lab_l[1]) // Send alert only if screener is not empty if scr_label != '' alert('Estatus segun estrategia\n' + scr_label, freq=alert.freq_once_per_bar_close) ////////////////////////////////// bearColor = cb1 bullColor = #1bff00 hiddenBullColor = #a4ff99 hiddenBearColor = #ff9e9e textColor = color.white noneColor = color.new(color.white, 100) _inRange(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper _findDivRB(osc) => // Osc: Higher Low oscHL = osc[lbR] > ta.valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1]) // Price: Lower Low priceLL = low[lbR] < ta.valuewhen(plFound(osc), low[lbR], 1) bullCond = plotBull and priceLL and oscHL and plFound(osc) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL = osc[lbR] < ta.valuewhen(plFound(osc), osc[lbR], 1) and _inRange(plFound(osc)[1]) // Price: Higher Low priceHL = low[lbR] > ta.valuewhen(plFound(osc), low[lbR], 1) hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound(osc) //------------------------------------------------------------------------------ // Regular Bearish // Osc: Lower High oscLH = osc[lbR] < ta.valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1]) // Price: Higher High priceHH = high[lbR] > ta.valuewhen(phFound(osc), high[lbR], 1) bearCond = plotBear and priceHH and oscLH and phFound(osc) //------------------------------------------------------------------------------ // Hidden Bearish // Osc: Higher High oscHH = osc[lbR] > ta.valuewhen(phFound(osc), osc[lbR], 1) and _inRange(phFound(osc)[1]) // Price: Lower High priceLH = high[lbR] < ta.valuewhen(phFound(osc), high[lbR], 1) hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound(osc) [bullCond, hiddenBullCond, bearCond, hiddenBearCond] [sz_bullCond, sz_hiddenBullCond, sz_bearCond, sz_hiddenBearCond] = _findDivRB(sz) foundDivBSZ = plFound(sz) and show_Momen and show_div ? true : false colordivBSZ = sz_bullCond ? bullColor : sz_hiddenBullCond ? hiddenBullColor : noneColor foundDivBeSZ = phFound(sz) and show_Momen and show_div ? true : false colordivBeSZ = sz_bearCond ? bearColor : sz_hiddenBearCond ? hiddenBearColor : noneColor plot(foundDivBSZ ? sz[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=1, color=colordivBSZ) plot(foundDivBeSZ ? sz[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=1, color=colordivBeSZ) ////////////////////RSI DIV////////////////// [rsi_bullCond, rsi_hiddenBullCond, rsi_bearCond, rsi_hiddenBearCond] = _findDivRB(rsi_scale) foundDivBRSI = plFound(rsi_scale) and show_rsi and show_div ? true : false colordivBRSI = rsi_bullCond ? bullColor : rsi_hiddenBullCond ? hiddenBullColor : noneColor foundDivBeRSI = phFound(rsi_scale) and show_rsi and show_div ? true : false colordivBeRSI = rsi_bearCond ? bearColor : rsi_hiddenBearCond ? hiddenBearColor : noneColor plot(foundDivBRSI ? rsi_scale[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=1, color=colordivBRSI) plot(foundDivBeRSI ? rsi_scale[lbR] : na, offset=-lbR, title='Regular Bullish', linewidth=1, color=colordivBeRSI) //Table tTable = table.new(TblY + '_' + TblX, columns=4, rows=4, border_width=1, border_color=color.rgb(255, 255, 255), frame_width=1, frame_color=color.rgb(255, 255, 255), bgcolor=color.gray) if (barstate.islastconfirmedhistory or barstate.isrealtime) and showTable // SMA table // X.GetTF( timeframe.period ) // X.GetTF( htf ) // X.GetTF( htf2 ) table.cell(table_id=tTable, column=0, row=0, text='🎩', text_color=color.rgb(0, 0, 0),text_size= labelSize) table.cell(table_id=tTable, column=1, row=0, text=X.CTF( str.tostring(resInMinutes) ), text_color=color.rgb(0, 0, 0),text_size= labelSize) table.cell(table_id=tTable, column=0, row=1, text='MOM', text_color=color.rgb(0, 0, 0),text_size= labelSize) if showAdxTbl table.cell(table_id=tTable, column=0, row=2, text='ADX', text_color=color.rgb(0, 0, 0),text_size= labelSize) table.cell(table_id=tTable, column=1, row=1, text=iMom, bgcolor=clr1, text_color=color.rgb(0, 0, 0),text_size= labelSize) if showAdxTbl table.cell(table_id=tTable, column=1, row=2, text=iAdx1, bgcolor=clr1, text_color=color.rgb(0, 0, 0),text_size= labelSize) if mom2 or showMomInfo table.cell(table_id=tTable, column=2, row=0, text=X.CTF( htf ), text_color=color.rgb(0, 0, 0),text_size= labelSize) table.cell(table_id=tTable, column=2, row=1, text=iMom2, bgcolor=color2, text_color=color.rgb(0, 0, 0),text_size= labelSize) if showAdxTbl table.cell(table_id=tTable, column=2, row=2, text=iAdx2, bgcolor=color2, text_color=color.rgb(0, 0, 0),text_size= labelSize) if mom3 or showMomInfo table.cell(table_id=tTable, column=3, row=0, text=X.CTF( htf2 ), text_color=color.rgb(0, 0, 0),text_size= labelSize) table.cell(table_id=tTable, column=3, row=1, text=iMom3, bgcolor=color3, text_color=color.rgb(0, 0, 0),text_size= labelSize) if showAdxTbl table.cell(table_id=tTable, column=3, row=2, text=iAdx3, bgcolor=color3, text_color=color.rgb(0, 0, 0),text_size= labelSize)
Big Poppa Code Strat & Momentum Strategy Indicator
https://www.tradingview.com/script/8vnIlXAa-Big-Poppa-Code-Strat-Momentum-Strategy-Indicator/
bigpoppacode97964
https://www.tradingview.com/u/bigpoppacode97964/
238
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © BigPoppaCode //@version=5 indicator(title='Big Poppa Codes ATR Levels, Strat Price Action & Momentum Strategy', shorttitle='ATR Levels, Strat & Momentum Strategy', overlay=true) // Global Variables stockTicker = ticker.new(syminfo.prefix, syminfo.ticker, session.extended) price = close timeFrame = 'D' openPrice = request.security(stockTicker, timeFrame, open, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on, ignore_invalid_symbol = true) day_high = request.security(stockTicker, timeFrame, high, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) day_low = request.security(stockTicker, timeFrame, low, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) atr = request.security(symbol = stockTicker, timeframe = "D", expression = ta.atr(14), gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on, ignore_invalid_symbol = true) trueRange = day_high - day_low trueRangePercent = trueRange / atr * 100 vwap = ta.vwap(source = close) vwma = ta.vwma(source = close, length = 21) hull = ta.wma(2 * ta.wma(close, 7) - ta.wma(close, 14), math.round(math.sqrt(14))) currentHULL = hull[0] previousHULL = hull[2] youngKobeEMA = ta.ema(source = close, length = 8) savageModeEMA = ta.ema(source = close, length = 21) drizzyEMA = ta.ema(source = close, length = 34) jayZEMA = ta.ema(source = close, length = 55) bullishTrend = price >= youngKobeEMA and youngKobeEMA >= savageModeEMA and savageModeEMA >= drizzyEMA and drizzyEMA >= jayZEMA and price >= vwma or (currentHULL >= previousHULL and price >= vwma and price >= youngKobeEMA and price >= vwap) bearishTrend = price <= youngKobeEMA and youngKobeEMA <= savageModeEMA and savageModeEMA <= drizzyEMA and drizzyEMA <= jayZEMA and price <= vwma or (currentHULL <= previousHULL and price <= vwma and price <= youngKobeEMA and price <= vwap) trendColor = color.new(color.orange, 75) if bullishTrend trendColor := color.new(color.green, 75) trendColor else if bearishTrend trendColor := color.new(color.red, 75) trendColor else trendColor := color.new(color.orange, 75) trendColor trVsATRColor = color.green if trueRangePercent <= 70 trVsATRColor := color.green trVsATRColor else if trueRangePercent >= 90 trVsATRColor := color.red trVsATRColor else trVsATRColor := color.orange trVsATRColor // atr level 1 - baby money callLevel = openPrice + (atr * 0.146) putLevel = openPrice - (atr * 0.146) callMoneyLevel = openPrice + (atr * 0.236) putMoneyLevel = openPrice - (atr * 0.236) callMidLevel = openPrice + (atr * 0.382) putMidLevel = openPrice - (atr * 0.382) callMidLevel2 = openPrice + (atr * 0.5) putMidLevel2 = openPrice - (atr * 0.5) callProfitLevel = openPrice + (atr * 0.618) putProfitLevel = openPrice - (atr * 0.618) callProfitLevel2 = openPrice + (atr * 0.764) putProfitLevel2 = openPrice - (atr * 0.764) callPrintingLevel = openPrice + atr putPrintingLevel = openPrice - atr // atr level 2 - super money superCallMoneyLevel = callPrintingLevel + (atr * 0.236) superPutMoneyLevel = putPrintingLevel - (atr * 0.236) superCallMidLevel = callPrintingLevel + (atr * 0.382) superPutMidLevel = putPrintingLevel - (atr * 0.382) superCallMidLevel2 = callPrintingLevel + (atr * 0.5) superPutMidLevel2 = putPrintingLevel - (atr * 0.5) superCallProfitLevel = callPrintingLevel + (atr * 0.618) superPutProfitLevel = putPrintingLevel - (atr * 0.618) superCallProfitLevel2 = callPrintingLevel + (atr * 0.764) superPutProfitLevel2 = putPrintingLevel - (atr * 0.764) superCallPrintingLevel = callPrintingLevel + atr superPutPrintingLevel = putPrintingLevel - atr // atr level 3 - ultra money ultraCallMoneyLevel = superCallPrintingLevel + (atr * 0.236) ultraPutMoneyLevel = superPutPrintingLevel - (atr * 0.236) ultraCallMidLevel = superCallPrintingLevel + (atr * 0.382) ultraPutMidLevel = superPutPrintingLevel - (atr * 0.382) ultraCallProfitLevel = superCallPrintingLevel + (atr * 0.618) ultraPutProfitLevel = superPutPrintingLevel - (atr * 0.618) ultraCallPrintingLevel = superCallPrintingLevel + atr ultraPutPrintingLevel = superPutPrintingLevel - atr // atr level 4 - mega money megaCallMoneyLevel = ultraCallPrintingLevel + (atr * 0.236) megaPutMoneyLevel = ultraPutPrintingLevel - (atr * 0.236) megaCallMidLevel = ultraCallPrintingLevel + (atr * 0.382) megaPutMidLevel = ultraPutPrintingLevel - (atr * 0.382) megaCallProfitLevel = ultraCallPrintingLevel + (atr * 0.618) megaPutProfitLevel = ultraPutPrintingLevel - (atr * 0.618) megaCallPrintingLevel = ultraCallPrintingLevel + atr megaPutPrintingLevel = ultraPutPrintingLevel - atr // Calculating Candles float candleSize = math.abs(high - low) float bodySize = math.abs(open - close) float hammerLowerShadow = math.abs(low - open) float hammerUpperShadow = math.abs(high - close) float starLowerShadow = math.abs(low - close) float starUpperShadow = math.abs(high - open) oneBar = high <= high[1] and low >= low[1] twoBarV1 = (high > high[1]) and (low >= low[1]) // high is higher and low is higher or equal twoBarV2 = (low < low[1]) and (high <= high[1]) // low is lower and high is lower or equal threeBar = high > high[1] and low < low[1] twoBarUp = (high > high[1] and low > low[1]) and close > open twoBarDown = (high < high[1] and low < low[1]) and close < open hammer = hammerLowerShadow > bodySize * 2 and low <= ta.lowest(low, 10) and hammerLowerShadow > hammerUpperShadow * 2 and close <= open star = starUpperShadow > bodySize * 2 and high >= ta.highest(high, 10) and starUpperShadow > starLowerShadow * 2 and open <= close bigAssCandle = candleSize >= candleSize[1] * 3 or (candleSize[0] >= candleSize[1] * 2 and candleSize[1] >= candleSize[2] * 1.75) or (math.abs(candleSize[0] - candleSize[1]) > 0.25 * atr and timeframe.period == '1') // User Input Values showATRFibLevels = input(true, title = "Show ATR Fibonacci Levels on Chart") showStratSetUps = input(true, title = "Show Strat Candle Setups and Indicators") showMomentumBand = input(true, title = "Show Momentum Bands") showInfoTable = input(true, title = "Show Table With Strat & Momentum Strategy Information Table on Chart") showFullTable = input(true, title = "Toggle Showing The Full Table or Smaller Table For Mobile Devices") colorCandles = input(false, title = "Color Candles to Match Momentum Trend Color") // Plotting Hull Momentum band currentHULLPlot = plot(currentHULL, title = 'Hull Line 1', color = color.new(trendColor, 35), linewidth = 2, editable = false, display = display.pane) previousHULLPlot = plot(previousHULL, title = 'Hull Line 2', color = color.new(trendColor, 35), editable = false, display = display.pane) fill(currentHULLPlot, previousHULLPlot, title = 'Momentum Band Filler', color = color.new(trendColor, 75)) barcolor(color = colorCandles? color.new(trendColor, 75): na, editable = false) // Creating Table Data momentumContinuity = '' ftfcContinuity = '' // vwma Over or Under Hull Over or Under Slow EMA Over or Under Fast EMA Over or Under. Pivot EMA Over or Under if price >= vwap momentumContinuity += 'VWAP ⬆ | ' else momentumContinuity += 'VWAP ⬇ | ' if price >= vwma momentumContinuity += 'VWMA ⬆ | ' else momentumContinuity += 'VWMA ⬇ | ' if currentHULL >= previousHULL momentumContinuity += 'HULL ⬆ | ' else momentumContinuity += 'HULL ⬇ | ' if price >= youngKobeEMA momentumContinuity += '8EMA ⬆ | ' else momentumContinuity += '8EMA ⬇ | ' if youngKobeEMA >= savageModeEMA momentumContinuity += '21EMA ⬆ | ' else momentumContinuity += '21EMA ⬇ | ' if savageModeEMA >= drizzyEMA momentumContinuity += '34EMA ⬆' else momentumContinuity += '34EMA ⬇ | ' if drizzyEMA >= jayZEMA momentumContinuity += '55EMA ⬆' else momentumContinuity += '55EMA ⬇' checkTimeFrame(currentClose, previousClose) => upOrDown = currentClose > previousClose ? '⬆| ' : '⬇| ' upOrDown getPreviousClose(timeframe) => previousClose = request.security(syminfo.tickerid, timeframe, close[1], lookahead=barmerge.lookahead_on) previousClose getCurrentClose(timeframe) => currentClose = request.security(syminfo.tickerid, timeframe, close, lookahead=barmerge.lookahead_on) currentClose getPriceTarget(op) => val = request.security(stockTicker, timeFrame, op, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on, ignore_invalid_symbol = true) val ftfcContinuity += '5' + checkTimeFrame(getCurrentClose('5'), getPreviousClose('5')) ftfcContinuity += '15' + checkTimeFrame(getCurrentClose('15'), getPreviousClose('15')) ftfcContinuity += '30' + checkTimeFrame(getCurrentClose('30'), getPreviousClose('30')) ftfcContinuity += 'H' + checkTimeFrame(getCurrentClose('60'), getPreviousClose('60')) ftfcContinuity += 'D' + checkTimeFrame(getCurrentClose('D'), getPreviousClose('D')) ftfcContinuity += 'W' + checkTimeFrame(getCurrentClose('W'), getPreviousClose('W')) ftfcContinuity += 'M' + checkTimeFrame(getCurrentClose('M'), getPreviousClose('M')) ftfcContinuity += 'Y' + checkTimeFrame(getCurrentClose('12M'), getPreviousClose('12M')) // Plotting ATR Fibonacci Levels // Up Fib ATR lineWidth = 2 callPrintingLvlColor = color.rgb(76, 175, 163) callProfitLvlColor = color.rgb(0, 230, 192) callMidLvlColor = color.new(#049fcf, 1) callLvlColor = color.aqua openLvlColor = color.purple putLvlColor = color.new(#fdfcd0, 1) putMidLvlColor = color.yellow putProfitLvlColor = color.rgb(255, 213, 0) putPrintingLvlColor = color.new(#ff8867, 1) fill(plot1 = plot(showATRFibLevels ? openPrice : na, title = 'Open Level', style = plot.style_line, color=openLvlColor, editable = false, linewidth = lineWidth, display = display.price_scale), plot2 = plot(showATRFibLevels ? callLevel : na, title = 'Call Level', style = plot.style_line, color = callLvlColor, editable = false, linewidth = lineWidth, display = display.pane), fillgaps = true, color = (color.new(color.gray, 91)), editable = false) fill(plot1 = plot(showATRFibLevels ? callLevel : na , title = 'Call Level', style = plot.style_line, color=callLvlColor, editable = false, linewidth= lineWidth, display = display.price_scale), plot2 = plot(showATRFibLevels ? callMidLevel : na, title = 'Call Mid Level', style = plot.style_line, color = callMidLvlColor, editable = false, linewidth = lineWidth, display = display.pane), fillgaps = false, color = (color.new(color.aqua, 91))) fill(plot1 = plot(showATRFibLevels ? callMidLevel : na, title = 'Call Mid Level', style = plot.style_line, editable = false, linewidth= lineWidth, color = callMidLvlColor, display = display.price_scale), plot2 = plot(showATRFibLevels ? callProfitLevel : na, title = 'Call Profit Level', style = plot.style_line, editable = false, linewidth = lineWidth, color=callProfitLvlColor, display = display.pane), fillgaps = false, color = (color.new(color.green, 91))) fill(plot1 = plot(showATRFibLevels ? callProfitLevel : na, title = 'Call Profit Level', style = plot.style_line, editable = false, linewidth= lineWidth, color = callProfitLvlColor, display = display.price_scale), plot2 = plot(showATRFibLevels ? callPrintingLevel : na, title = 'Call Printing Level', style = plot.style_line, color = callPrintingLvlColor, editable = false, linewidth= lineWidth, display = display.pane + display.price_scale), fillgaps = false, color = (color.new(color.red, 91))) plot(showATRFibLevels ? callMoneyLevel : na , title = 'Call Money Level', style = plot.style_line, color=callLvlColor, editable = false, linewidth= lineWidth * 2, display = display.price_scale + display.pane) // Down Fib ATR fill(plot1 = plot(showATRFibLevels ? openPrice : na, title = 'Open Level', style = plot.style_circles, editable = false, linewidth = lineWidth, color = openLvlColor, display = display.pane), plot2 = plot(showATRFibLevels ? putLevel : na, title = 'Put Level', style = plot.style_line, editable = false, linewidth = lineWidth, color = putLvlColor, display = display.pane), fillgaps = false, color = (color.new(color.gray, 91))) fill(plot1 = plot(showATRFibLevels ? putLevel : na, title = 'Put Level', style = plot.style_line, editable = false, linewidth = lineWidth, color = putLvlColor, display = display.price_scale), plot2 = plot(showATRFibLevels ? putMidLevel : na, title = 'Put Mid Level',style = plot.style_line, editable = false, linewidth = lineWidth, color = putMidLvlColor, display = display.pane), fillgaps = false, color = (color.new(color.aqua, 91))) fill(plot1 = plot(showATRFibLevels ? putMidLevel : na, title = 'Put Mid Level', style = plot.style_line, editable = false, linewidth = lineWidth, color = putMidLvlColor, display = display.price_scale), plot2 = plot(showATRFibLevels ? putProfitLevel : na, title = 'Put Profit Level', style = plot.style_line, editable = false, linewidth = lineWidth, color = putProfitLvlColor, display = display.pane), fillgaps = false, color = (color.new(color.green, 91))) fill(plot1 = plot(showATRFibLevels ? putProfitLevel : na, title = 'Put Profit Level', style = plot.style_line, editable = false, linewidth = lineWidth, color = putProfitLvlColor, display = display.price_scale), plot2 = plot(showATRFibLevels ? putPrintingLevel : na, title = 'Put Priniting Level', style = plot.style_line, editable = false, linewidth = lineWidth, color = putPrintingLvlColor, display = display.pane + display.price_scale), fillgaps = false, color = (color.new(color.red, 91))) plot(showATRFibLevels ? putMoneyLevel : na, title = 'Put Money Level', style = plot.style_line, editable = false, linewidth = lineWidth * 2, color = putLvlColor, display = display.price_scale + display.pane) // Creating Alerts // ----------------------// // 2bar Up - 1bar - 2bar Up twoOneTwoUpBullCont = twoBarUp[2] and oneBar[1] and twoBarUp[0] // // 2bar Down - 1bar - 2bar Up twoOneTwoUpBullRev = twoBarDown[2] and oneBar[1] and twoBarUp[0] // // 2bar Down - 1bar - 2bar Down twoOneTwoDownBearCont = twoBarDown[2] and oneBar[1] and twoBarDown[0] // // 2bar Up - 1 bar - 2bar Down twoOneTwoDownBearRev = twoBarUp[2] and oneBar[1] and twoBarDown[0] // // 2bar Down - 2bar Up twoDowntwoUpBullRev = twoBarDown[1] and twoBarUp[0] // // 2bar Up - 2bar Down twoUpTwoDownRevBearish = twoBarUp[1] and twoBarDown[0] // //---------------------------// // //---------------------------// // // 3bar Up - 1bar - 2bar Down threeOneTwoBearRev = threeBar[2] and oneBar[1] and twoBarDown[0] and close[2] > open[2] // // 3bar Down - 2bar Down - 2bar Up threeTwoTwoBullRev = threeBar[2] and twoBarDown[1] and twoBarUp[0] and close[2] < open[2] // // 3bar Up - 2bar Down - 2bar Down threeTwoTwoBearRev = threeBar[2] and twoBarDown[1] and twoBarDown[0] and close[2] > open[2] // // 2bar - 1bar Setup twoOneSetUp = (twoBarV1[1] or twoBarV2[1]) and oneBar[0] // // 3bar - 1bar Setup threeOneSetUp = threeBar[1] and oneBar[0] // // 3bar - 2bar Setup threeTwoSetup = threeBar[1] and (twoBarV1[0] or twoBarV2[0]) // // 2up - 2up - 2up twoUpContinuation = twoBarUp[2] and twoBarUp[1] and twoBarUp[0] // // 2down - 2down - 2down twoDownContinuation = twoBarDown[2] and twoBarDown[1] and twoBarDown[0] setup = twoOneSetUp or threeOneSetUp or threeTwoSetup or twoUpContinuation or twoDownContinuation alertcondition(threeBar, '3 Bar', '3 Bar Alert') alertcondition(oneBar, '1 Bar', '1 Bar Alert') alertcondition(twoOneTwoUpBullCont, '2bar Up - 1bar - 2bar Up', '2-1-2 bullish continuation confirmed') alertcondition(twoOneTwoUpBullRev, '2bar Down - 1bar - 2bar Up', '2-1-2 bullish reversal confirmed') alertcondition(twoOneTwoDownBearCont, '2bar Down - 1bar - 2bar Down', '2-1-2 bearish continuation confirmed') alertcondition(twoOneTwoDownBearRev, '2bar Up - 1 bar - 2bar Down', '2-1-2 bearish reversal confirmed') alertcondition(twoOneSetUp, ' 2bar - 1bar Setup', '2-1 setup') alertcondition(threeOneSetUp, '3bar - 1bar Setup', '3-1 setup') alertcondition(threeTwoSetup, '3bar - 2bar Setup', '3-2 setup') alertcondition(twoUpContinuation, '2 - 2 - 2 Up', 'Bullish Continuation') alertcondition(twoDownContinuation, '2 - 2 - 2 Down', 'Bearish Continuation') alertcondition(hammer, 'Hammer Candle', 'Hammer Signal') alertcondition(star, 'Star Candle', 'Star Signal') alertcondition(bigAssCandle, title='Big Ass Candle detected for', message='{{ticker}}') // Plotting Strat Setups //---------------------------// plotshape(showStratSetUps ? twoUpContinuation : na, title='Two Up 3x', text='2\n2\n2\n⬆', style=shape.labeldown, location=location.belowbar, color=color.new(color.green, 50), textcolor=color.white, display = display.pane) plotshape(showStratSetUps ? twoDownContinuation : na, title='Two Down 3x', text='2\n2\n\2\n⬇', style=shape.labeldown, location=location.belowbar, color=color.new(color.red, 50), textcolor=color.white, display = display.pane) plotshape(showStratSetUps ? twoOneSetUp : na, title='Two One', text='2\n1', style=shape.labeldown, location=location.belowbar, color=color.new(color.green, 50), textcolor=color.white, display = display.pane) plotshape(showStratSetUps ? threeOneSetUp : na, title='Three One', text='3\n1', style=shape.labeldown, location=location.belowbar, color=color.new(color.red, 50), textcolor=color.white, display = display.pane) plotshape(showStratSetUps ? threeTwoSetup : na, title='Three Two', text='3\n2', style=shape.labeldown, location=location.belowbar, color=color.new(color.green, 50), textcolor=color.white, display = display.pane) //---------------------------// plotchar(showStratSetUps and not setup ? (twoBarV1 or twoBarV2) : na , title='2 bar', char='2', location=location.belowbar, color=color.new(color.white, 0), display = display.pane) plotchar(showStratSetUps and not setup ? oneBar: na, title='1 bar', char='1', location=location.belowbar, color=color.new(color.yellow, 0), display = display.pane) plotchar(showStratSetUps and not setup ? threeBar: na, title='3 bar', char='3', location=location.belowbar, color=color.new(color.blue, 0), display = display.pane) plotshape(bigAssCandle and not hammer and not star, style=shape.labeldown, location=location.abovebar, text='Big \n Ass \n Candle', color=color.new(trendColor, 50), textcolor=color.white, display = display.pane) plotshape(showStratSetUps and not bigAssCandle ? hammer : na, style=shape.labeldown, location=location.abovebar, color=color.rgb(76, 175, 79, 71), text='Hammer \n 🔨', textcolor=color.white, display = display.pane) plotshape(showStratSetUps and not bigAssCandle ? star: na, style=shape.labeldown, location=location.abovebar, color=color.rgb(255, 82, 82, 71), text='Star \n 🌟', textcolor=color.white, display = display.pane ) plotshape(showStratSetUps and bigAssCandle ? hammer : na, style=shape.labeldown, location=location.abovebar, color=color.rgb(76, 175, 79, 71), text='🔨🔨\n Big \n Ass \n Candle \n🔨🔨', textcolor=color.white, display = display.pane ) plotshape(showStratSetUps and bigAssCandle ? star: na, style=shape.labeldown, location=location.abovebar, color=color.rgb(255, 82, 82, 71), text='🌟🌟\n Big \n Ass \n Candle \n🌟🌟', textcolor=color.white, display = display.pane ) last5Candles = '' last5Candles += oneBar[4] ? '| 1 | ' : twoBarUp[4] ? '| 2⬆ | ' : twoBarDown[4] ? '| 2⬇ | ': (twoBarV1[4] or twoBarV2[4])? '| 2 | ' : threeBar[4] ? '| 3 | ': na last5Candles += oneBar[3] ? '1 | ' : twoBarUp[3] ? '2⬆ | ' : twoBarDown[3] ? '2⬇ | ': (twoBarV1[3] or twoBarV2[3])? '2 | ' : threeBar[3] ? '3 | ': na last5Candles += oneBar[2] ? '1 | ' : twoBarUp[2] ? '2⬆ | ' : twoBarDown[2] ? '2⬇ | ': (twoBarV1[2] or twoBarV2[2])? '2 | ' : threeBar[2] ? '3 | ': na last5Candles += oneBar[1] ? '1 | ' : twoBarUp[1] ? '2⬆ | ' : twoBarDown[1] ? '2⬇ | ': (twoBarV1[1] or twoBarV2[1])? '2 | ' : threeBar[1] ? '3 | ': na last5Candles += oneBar[0] ? '1 | ' : twoBarUp[0] ? '2⬆ | ' : twoBarDown[0] ? '2⬇ | ': (twoBarV1[0] or twoBarV2[2])? '2 | ' : threeBar[0] ? '3 | ': na last5Candles += hammer[0] ? ' 🔨🔨' : star[0] ? ' 🌟🌟' : na // Plotting Tables last5Candles += setup or hammer or star or (bigAssCandle[1] and (twoBarUp[0] or twoBarDown[0])) ? ' Setup or Actionable Signal' : 'No Current Setup or Actionable Signal' profitLvl = 0.618 midLvl = 0.382 moneyLvl = 0.236 entryLvl = 0.146 atrLvl = 1.0 entryLvlReached = 0 midLvlReached = 0 moneyLvlReached = 0 profitLvlReached = 0 atrLvlReached = 0 // get true range for Day 10, Day 9, Day 8, Day 7, Day 6, Day 5, Day 4, Day 3, Day 2, Day 1 // Get an avg of 10 - 6 and assign it to atr5 // Get an avg of 9 - 5 and assign it to atr4 // Get an avg of 8 - 4 and assign it to atr3 // Get an avg of 7 - 3 and assign it to atr2 // Get an avg of 6 - 2 and assign it to atr1 // open5 high5 low5 // open4 high4 low4 // open3 high3 low3 // open2 high2 low2 // open1 high1 low1 // Not charted ad don next update open5 = getPriceTarget(open[5]) high5 = getPriceTarget(high[5]) low5 = getPriceTarget(low[5]) open4 = getPriceTarget(open[4]) high4 = getPriceTarget(high[4]) low4 = getPriceTarget(low[4]) open3 = getPriceTarget(open[3]) high3 = getPriceTarget(high[3]) low3 = getPriceTarget(low[3]) open2 = getPriceTarget(open[2]) high2 = getPriceTarget(high[2]) low2 = getPriceTarget(low[2]) open1 = getPriceTarget(open[1]) high1 = getPriceTarget(high[1]) low1 = getPriceTarget(low[1]) day1EntryLevelsReached = (open1 + (atr * entryLvl) <= high1) or (open1 - (atr * entryLvl) >= low1) ? true : false day2EntryLevelsReached = (open2 + (atr * entryLvl) <= high2) or (open2 - (atr * entryLvl) >= low2) ? true : false day3EntryLevelsReached = (open3 + (atr * entryLvl) <= high3) or (open3 - (atr * entryLvl) >= low3) ? true : false day4EntryLevelsReached = (open4 + (atr * entryLvl) <= high4) or (open4 - (atr * entryLvl) >= low4) ? true : false day5EntryLevelsReached = (open5 + (atr * entryLvl) <= high5) or (open5 - (atr * entryLvl) >= low5) ? true : false day1MoneyLevelsReached = (open1 + (atr * moneyLvl) <= high1) or (open1 - (atr * moneyLvl) >= low1) ? true : false day2MoneyLevelsReached = (open2 + (atr * moneyLvl) <= high2) or (open2 - (atr * moneyLvl) >= low2) ? true : false day3MoneyLevelsReached = (open3 + (atr * moneyLvl) <= high3) or (open3 - (atr * moneyLvl) >= low3) ? true : false day4MoneyLevelsReached = (open4 + (atr * moneyLvl) <= high4) or (open4 - (atr * moneyLvl) >= low4) ? true : false day5MoneyLevelsReached = (open5 + (atr * moneyLvl) <= high5) or (open5 - (atr * moneyLvl) >= low5) ? true : false day1MidLevelsReached = (open1 + (atr * midLvl) <= high1) or (open1 - (atr * midLvl) >= low1) ? true : false day2MidLevelsReached =(open2 + (atr * midLvl) <= high2) or (open2 - (atr * midLvl) >= low2) ? true : false day3MidLevelsReached = (open3 + (atr * midLvl) <= high3) or (open3 - (atr * midLvl) >= low3) ? true : false day4MidLevelsReached = (open4 + (atr * midLvl) <= high4) or (open4 - (atr * midLvl) >= low4) ? true : false day5MidLevelsReached = (open5 + (atr * midLvl) <= high5) or (open5 - (atr * midLvl) >= low5) ? true : false day1ProfitLevelsReached = (open1 + (atr * profitLvl) <= high1) or (open1 - (atr * profitLvl) >= low1) ? true : false day2ProfitLevelsReached =(open2 + (atr * profitLvl) <= high2) or (open2 - (atr * profitLvl) >= low2) ? true : false day3ProfitLevelsReached = (open3 + (atr * profitLvl) <= high3) or (open3 - (atr * profitLvl) >= low3) ? true : false day4ProfitLevelsReached = (open4 + (atr * profitLvl) <= high4) or (open4 - (atr * profitLvl) >= low4) ? true : false day5ProfitLevelsReached = (open5 + (atr * profitLvl) <= high5) or (open5 - (atr * profitLvl) >= low5) ? true : false day1ATRLevelsReached = (open1 + (atr) <= high1) or (open1 - (atr) >= low1) ? true : false day2ATRLevelsReached =(open2 + (atr) <= high2) or (open2 - (atr) >= low2) ? true : false day3ATRLevelsReached = (open3 + (atr) <= high3) or (open3 - (atr) >= low3) ? true : false day4ATRLevelsReached = (open4 + (atr) <= high4) or (open4 - (atr) >= low4) ? true : false day5ATRLevelsReached = (open5 + (atr) <= high5) or (open5 - (atr) >= low5) ? true : false // .146 if day1EntryLevelsReached entryLvlReached += 1 if day2EntryLevelsReached entryLvlReached += 1 if day3EntryLevelsReached entryLvlReached += 1 if day4EntryLevelsReached entryLvlReached += 1 if day5EntryLevelsReached entryLvlReached += 1 // .236 if day1MoneyLevelsReached moneyLvlReached += 1 if day2MoneyLevelsReached moneyLvlReached += 1 if day3MoneyLevelsReached moneyLvlReached += 1 if day4MoneyLevelsReached moneyLvlReached += 1 if day5MoneyLevelsReached moneyLvlReached += 1 // .382 if day1MidLevelsReached midLvlReached += 1 if day2MidLevelsReached midLvlReached += 1 if day3MidLevelsReached midLvlReached += 1 if day4MidLevelsReached midLvlReached += 1 if day5MidLevelsReached midLvlReached += 1 // .618 if day1ProfitLevelsReached profitLvlReached += 1 if day2ProfitLevelsReached profitLvlReached += 1 if day3ProfitLevelsReached profitLvlReached += 1 if day4ProfitLevelsReached profitLvlReached += 1 if day5ProfitLevelsReached profitLvlReached += 1 // 1.0 if day1ATRLevelsReached atrLvlReached += 1 if day2ATRLevelsReached atrLvlReached += 1 if day3ATRLevelsReached atrLvlReached += 1 if day4ATRLevelsReached atrLvlReached += 1 if day5ATRLevelsReached atrLvlReached += 1 plot(showATRFibLevels ? high1 : na, title = 'Previous Day High', style = plot.style_line, editable = false, linewidth = lineWidth, color = trendColor, display = display.price_scale) plot(showATRFibLevels ? low1 : na, title = 'Previous Day Low', style = plot.style_line, editable = false, linewidth = lineWidth, color = trendColor, display = display.price_scale) plot(showATRFibLevels ? open1 : na, title = 'Previous Day Open', style = plot.style_line, editable = false, linewidth = lineWidth, color = trendColor, display = display.price_scale) atrLevelsString = 'Prev Day H|0|L: ' + str.tostring(high1, '#.##') + '|' + str.tostring(open1, '#.##') + '|' + str.tostring(low1, '#.##') var tbl = table.new(position.top_right, columns = 1, rows = 14) if barstate.islast and showInfoTable currentZoneColor = color.white if close >= callLevel currentZoneColor := color.aqua if close <= putLevel currentZoneColor := color.yellow trend = bullishTrend ? ' Trend is Bullish 🐂' : bearishTrend ? 'Trend is Bearish 🐻': 'Trend is Sideways/Choppy ✖️' if showFullTable table.cell(tbl, 0, 0, 'THE STRAT & MOMENTUM Strategy ' + trend, bgcolor = color.new(trendColor, 10), text_color=color.white) table.cell(tbl, 0, 1, ftfcContinuity, bgcolor=color.new(color.black, 80), text_color=color.white) table.cell(tbl, 0, 2, momentumContinuity, bgcolor=color.new(color.black, 80), text_color=color.white) table.cell(tbl, 0, 3, 'Day Open | ' + str.tostring(openPrice) + ' | Day Range ($' + str.tostring(trueRange, '#.##') + ') is ' + str.tostring(trueRangePercent, '#.##') + '% of ATR ($' + str.tostring(atr, '#.##') + ')', bgcolor=color.new(trVsATRColor, 80), text_color=color.white) table.cell(tbl, 0, close > callLevel ? 4 : 5, close >= callLevel ? 'In Call Zone': close <= putLevel ? ' In Put Zone' : 'Patience is a Virtue Not In Call or Put Zone', bgcolor = color.new(currentZoneColor, 80), text_color = color.white) table.cell(tbl, 0, close >callLevel ? 5 : 4, 'Call Entry $' + str.tostring(callLevel, '#.##') + ' | Money$ $' + str.tostring(callMoneyLevel,'#.##') + ' | Good$ $' + str.tostring(callMidLevel,'#.##') + ' | Great$ $' + str.tostring(callProfitLevel, '#.##'), bgcolor=color.new(color.aqua, 80), text_color=color.white) table.cell(tbl, 0, 6,' Put Entry $' + str.tostring(putLevel, '#.##') + ' | Money$ $' + str.tostring(putMoneyLevel, '#.##') + ' | Good$ $' + str.tostring(putMidLevel, '#.##') + ' | Great$ $' + str.tostring(putProfitLevel, '#.##'), bgcolor=color.new(color.yellow, 80), text_color=color.white) table.cell(tbl, 0, 7, 'Price Action ' + last5Candles, text_color = color.white, bgcolor = color.new(trendColor, 1)) table.cell(tbl, 0, 8, str.tostring(entryLvl, '#.###') + '+/- Entry Level Reached ' + str.tostring(entryLvlReached, '#') + ' of Last 5 trading days ', text_color = color.white, bgcolor = color.new(trendColor, 1)) table.cell(tbl, 0, 9, str.tostring(moneyLvl, '#.###') + '+/- Money$ Level Reached ' + str.tostring(moneyLvlReached, '#') + ' of Last 5 trading days ', text_color = color.white, bgcolor = color.new(trendColor, 1)) table.cell(tbl, 0, 10, str.tostring(midLvl, '#.###') + '+/- Good$ Level Reached ' + str.tostring(midLvlReached, '#') + ' of Last 5 trading days ', text_color = color.white, bgcolor = color.new(trendColor, 1)) table.cell(tbl, 0, 11, str.tostring(profitLvl, '#.###') + '+/- Great$ Level Reached ' + str.tostring(profitLvlReached, '#') + ' of Last 5 trading days ', text_color = color.white, bgcolor = color.new(trendColor, 1)) table.cell(tbl, 0, 12, str.tostring(atrLvl, '#.###') + '+/- Baller$ $ Level Reached ' + str.tostring(atrLvlReached, '#') + ' of Last 5 trading days ', text_color = color.white, bgcolor = color.new(trendColor, 1)) table.cell(tbl, 0,13, atrLevelsString, text_color = color.white) else table.cell(tbl, 0, 0, ftfcContinuity, bgcolor=color.new(color.black, 80), text_color=color.white) table.cell(tbl, 0, 1, trend, bgcolor= trendColor, text_color=color.white) table.cell(tbl, 0, 2, 'The first # is your potential entry +/-', bgcolor=color.new(color.black, 80), text_color=color.white) table.cell(tbl, 0, 3, 'Call$' + str.tostring(callLevel, '#.##') + ' --> $' + str.tostring(callMoneyLevel,'#.##') + ' | $' + str.tostring(callMidLevel,'#.##') + ' | $' + str.tostring(callProfitLevel, '#.##'), bgcolor=color.new(color.aqua, 80), text_color=color.white) table.cell(tbl, 0, 4, 'Put$' + str.tostring(putLevel, '#.##') + ' --> $' + str.tostring(putMoneyLevel,'#.##') + ' | $' + str.tostring(putMidLevel,'#.##') + ' | $' + str.tostring(putProfitLevel, '#.##'), bgcolor=color.new(color.yellow, 80), text_color=color.white) table.cell(tbl, 0, 5, atrLevelsString + '| ATR is ' + str.tostring(atr, '#.##'), text_color = color.white) // Atributions // All code was written by me, but I was informed by the following // Significant changes to all code listed below but this code was built with the help of 3 indicators // Basic HULL MA Pack, The Strat Info Box by Xpul and SATY ATR Levels by Saty Mahajan // Basic Hull Ma Pack tinkered by InSilico // Strat Algos from The Strat info box by Xpul // ATR Levels from // Saty ATR Levels added by Big Poppa code // Copyright (C) 2022 Saty Mahajan // Author is not responsible for your trading using this script. // Data provided in this script is not financial advice. // // Special thanks to Gabriel Viana. // Based on my own ideas and ideas from Ripster, drippy2hard, // Adam Sliver, and others. // Strategy developed from CallMe100K, TrustMyLevels, JrGreatness, FaithInTheStrat and various Youtube Research // DYOR
BankNifty Dash
https://www.tradingview.com/script/X4wUNEg1-BankNifty-Dash/
tradeblinks
https://www.tradingview.com/u/tradeblinks/
134
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tradeblinks //@version=5 indicator(title="Nifty/Banknifty Dash", overlay=true) // Dash Settings max = 120 //Maximum Length min = 10 //Minimum Length dash_loc = input.session("Top Right","Dashboard Location" ,options=["Top Right", "Bottom Right", "Middle Right", "Top Left", "Bottom Left"] ,group='Dash Settings') text_size = input.session('Small',"Dashboard Size" ,options=["Small","Big"] ,group='Dash Settings') cell_up = color.green cell_dn = color.red cell_neutral = color.black row_col = color.blue col_col = color.blue txt_col = color.white cell_transp = 80 // Index & Symbols _Index = input.string('BankNifty', 'Dashboard for Index', options=['BankNifty', 'Nifty'], group='Dash Settings') t1 = _Index == 'BankNifty' ? 'NSE:NIFTY': 'NSE:INDIAVIX' t2 = _Index == 'BankNifty' ? 'NSE:BANKNIFTY':'NSE:NIFTY' t3 = _Index == 'BankNifty' ? 'NSE:HDFCBANK':'NSE:RELIANCE' t4 = _Index == 'BankNifty' ? 'NSE:ICICIBANK':'NSE:HDFCBANK' t5 = _Index == 'BankNifty' ? 'NSE:KOTAKBANK':'NSE:ICICIBANK' t6 = _Index == 'BankNifty' ? 'NSE:AXISBANK':'NSE:INFY' t7 = _Index == 'BankNifty' ? 'NSE:SBIN':'NSE:HDFC' t8 = _Index == 'BankNifty' ? 'NSE:INDUSINDBK':'NSE:TCS' t9 = _Index == 'BankNifty' ? 'NSE:BANKBARODA':'NSE:ITC' t10 = _Index == 'BankNifty' ? 'NSE:AUBANK':'NSE:LT' // Participation [indexLTP] = request.security(_Index == 'BankNifty' ?'NSE:BANKNIFTY':'NSE:NIFTY', 'D', [close]) //HDFC BANK = 28.66 //ICICI BANK = 23.54 //KOTAK BANK = 10.18 //AXIS BANK = 10.01 //SBI =9.85 //INDUSIND BANK = 5.91 //BANK OF BARODA = 2.62 //AU BANK = 2.49 //RELIANCE = 10.41 //HDFC BANK = 9.06 //ICICI BANK = 7.44 //INFOSYS = 7.20 //HDFC = 6.06 //TCS = 4.41 //ITC = 3.98 //LT = 3.29 s1= _Index == 'BankNifty' ? 0.2866 : 0.1041 s2= _Index == 'BankNifty' ? 0.2354 : 0.0906 s3= _Index == 'BankNifty' ? 0.1018 : 0.0744 s4= _Index == 'BankNifty' ? 0.1001 : 0.0720 s5= _Index == 'BankNifty' ? 0.0985 : 0.0606 s6= _Index == 'BankNifty' ? 0.0591 : 0.0441 s7= _Index == 'BankNifty' ? 0.0262 : 0.0398 s8= _Index == 'BankNifty' ? 0.0249 : 0.0329 //Calculate IPV, Change & %Change [ts1ltp,ts1high,ts1low,ts1PDH,ts1PDL,ts1pclose] = request.security(t1,'D',[close,high,low,high[1],low[1],close[1]]) ts1Chng = (ts1ltp-ts1pclose) [ts2ltp,ts2high,ts2low,ts2PDH,ts2PDL,ts2pclose] = request.security(t2,'D',[close,high,low,high[1],low[1],close[1]]) ts2Chng = (ts2ltp-ts2pclose) [ts3ltp,ts3high,ts3low,ts3PDH,ts3PDL,ts3pclose] = request.security(t3,'D',[close,high,low,high[1],low[1],close[1]]) changeValue3 = (ts3ltp-ts3pclose) changePer3 = (changeValue3/ts3pclose) IPV1 = (indexLTP*s1*changePer3) [ts4ltp,ts4high,ts4low,ts4PDH,ts4PDL,ts4pclose] = request.security(t4,'D',[close,high,low,high[1],low[1],close[1]]) changeValue4 = (ts4ltp-ts4pclose) changePer4 = (changeValue4/ts4pclose) IPV2 = (indexLTP*s2*changePer4) [ts5ltp,ts5high,ts5low,ts5PDH,ts5PDL,ts5pclose] = request.security(t5,'D',[close,high,low,high[1],low[1],close[1]]) changeValue5 = (ts5ltp-ts5pclose) changePer5 = (changeValue5/ts5pclose) IPV3 = (indexLTP*s3*changePer5) [ts6ltp,ts6high,ts6low,ts6PDH,ts6PDL,ts6pclose] = request.security(t6,'D',[close,high,low,high[1],low[1],close[1]]) changeValue6 = (ts6ltp-ts6pclose) changePer6 = (changeValue6/ts6pclose) IPV4 = (indexLTP*s4*changePer6) [ts7ltp,ts7high,ts7low,ts7PDH,ts7PDL,ts7pclose] = request.security(t7,'D',[close,high,low,high[1],low[1],close[1]]) changeValue7 = (ts7ltp-ts7pclose) changePer7 = (changeValue7/ts7pclose) IPV5 = (indexLTP*s5*changePer7) [ts8ltp,ts8high,ts8low,ts8PDH,ts8PDL,ts8pclose] = request.security(t8,'D',[close,high,low,high[1],low[1],close[1]]) changeValue8 = (ts8ltp-ts8pclose) changePer8 = (changeValue8/ts8pclose) IPV6 = (indexLTP*s6*changePer8) [ts9ltp,ts9high,ts9low,ts9PDH,ts9PDL,ts9pclose] = request.security(t9,'D',[close,high,low,high[1],low[1],close[1]]) changeValue9 = (ts9ltp-ts9pclose) changePer9 = (changeValue9/ts9pclose) IPV7 = (indexLTP*s7*changePer9) [ts10ltp,ts10high,ts10low,ts10PDH,ts10PDL,ts10pclose] = request.security(t10,'D',[close,high,low,high[1],low[1],close[1]]) changeValue10 = (ts10ltp-ts10pclose) changePer10 = (changeValue10/ts10pclose) IPV8 = (indexLTP*s8*changePer10) // Indicators var PColor = color.white var PText = '' //ATR Input atr_length = input(14, 'ATR Length') use_current_close = false period_index = use_current_close ? 0 : 1 //ATR calc t1atr = request.security(t1, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t1ATR = math.round(t1atr,2) t1dtr = request.security(t1,'D', math.round(high - low,2)) t1atrp = math.round(t1dtr/t1atr * 100) t2atr = request.security(t2, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t2ATR = math.round(t2atr,2) t2dtr = request.security(t2,'D', math.round(high - low,2)) t2atrp = math.round(t2dtr/t2atr * 100) t3atr = request.security(t3, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t3ATR = math.round(t3atr,2) t3dtr = request.security(t3,'D', math.round(high - low,2)) t3atrp = math.round(t3dtr/t3atr * 100) t4atr = request.security(t4, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t4ATR = math.round(t4atr,2) t4dtr = request.security(t4,'D', math.round(high - low,2)) t4atrp = math.round(t4dtr/t4atr * 100) t5atr = request.security(t5, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t5ATR = math.round(t5atr,2) t5dtr = request.security(t5,'D', math.round(high - low,2)) t5atrp = math.round(t5dtr/t5atr * 100) t6atr = request.security(t6, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t6ATR = math.round(t6atr,2) t6dtr = request.security(t6,'D', math.round(high - low,2)) t6atrp = math.round(t6dtr/t6atr * 100) t7atr = request.security(t7, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t7ATR = math.round(t7atr,2) t7dtr = request.security(t7,'D', math.round(high - low,2)) t7atrp = math.round(t7dtr/t7atr * 100) t8atr = request.security(t8, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t8ATR = math.round(t8atr,2) t8dtr = request.security(t8,'D', math.round(high - low,2)) t8atrp = math.round(t8dtr/t8atr * 100) t9atr = request.security(t9, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t9ATR = math.round(t9atr,2) t9dtr = request.security(t9,'D', math.round(high - low,2)) t9atrp = math.round(t9dtr/t9atr * 100) t10atr = request.security(t10, 'D', ta.atr(atr_length)[period_index], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) t10ATR = math.round(t10atr,2) t10dtr = request.security(t10,'D', math.round(high - low,2)) t10atrp = math.round(t10dtr/t10atr * 100) //EMA Cloud EMA = input.color(color.black) len = input.int(200, minval=1, title=" EMA Length") src = close ema = ta.ema(src, len) tema=plot(ema, title="EMA", color=EMA, linewidth=1) FEMA = input.color(color.aqua,title="Fast EMA",group='EMA Cloud') len1 = input.int(5, minval=1, title=" Fast EMA Length",group='EMA Cloud') src1 = close ema1 = ta.ema(src1, len1) fema1=plot(ema1, title="Fast EMA", color=FEMA, linewidth=1) SEMA = input.color(color.blue,title="Slow EMA",group='EMA Cloud') len2 = input.int(21, minval=1, title=" Slow EMA Length",group='EMA Cloud') src2 = close ema2 = ta.ema(src2, len2) fema2=plot(ema2, title="Slow EMA", color=SEMA, linewidth=1) Bull = ema1 > ema2 Bear = ema1 < ema2 cloud = Bull ? input.color(color.new(color.green,85),"Bullish",group='EMA Cloud') : Bear ? input.color(color.new(color.red,85),"Bearish",group='EMA Cloud') : na fill(fema1,fema2, color = cloud) //ADR side of script below text_ADR1_high = 'ADR1 Upper' text_ADR2_high = 'ADR2 Upper' text_ADR1_low = 'ADR1 Lower' text_ADR2_low = 'ADR2 Lower' //***Start of Inputs var labels_enabled = input.bool(defval=true, title='Show labels') var adr_1 = input.int(title='ADR 1 Period', defval = 10, minval = 1, group='ADR') var adr_2 = input.int(title='ADR 2 Period', defval = 5, minval = 1, group='ADR') var color_ADR1_high = input.color(defval=color.new(color.red ,0), title=text_ADR1_high, group='ADR') var color_ADR2_high = input.color(defval=color.new(color.red,0), title=text_ADR2_high, group='ADR') var color_ADR1_low = input.color(defval=color.new(color.green ,0), title=text_ADR1_low, group='ADR') var color_ADR2_low = input.color(defval=color.new(color.green,0), title=text_ADR2_low, group='ADR') adrUppercolorfill = input.color(color.red, "Upper Zone Fill",group='ADR',tooltip="Color of zone between Upper Adr 1 and 2") adrlowercolorfill = input.color(color.green, "Lower Zone Fill",group='ADR',tooltip="Color of zone between Lower Adr 1 and 2") var plot_history = input.bool(defval=true, group='ADR',title='Historical levels') //***Start of local functions definiton*** draw_line(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) => dline = line.new(x1=_x1, y1=_y1, x2=_x2, y2=_y2, xloc=_xloc, extend=_extend, color=_color, style=_style, width=_width) line.delete(dline[1]) //If security is futures - replace the ticker with continuous contract tickerid_func() => tickerid = syminfo.tickerid if syminfo.type == 'futures' tickerid := syminfo.root + '1!' //Function to calculate ADR levels //Parameters: // * lengthInput - ADR period // * hi_low - true-->High, else-->Low adr_func(lengthInput,hi_low) => float result = 0 float adr = 0 open_ = request.security(tickerid_func(), "D", open, barmerge.gaps_off, barmerge.lookahead_on) adr_High = request.security(tickerid_func(), "D", ta.sma(high[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on) adr_Low = request.security(tickerid_func(), "D", ta.sma(low[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on) adr := (adr_High - adr_Low) if hi_low//High result := adr/2 + open_ else //Low result := open_ - adr/2 transp_func() => transp_0 = 0 //***End of local functions definiton*** //***Start of getting data start_time = request.security(tickerid_func(), "D", time_close[1],barmerge.gaps_off,barmerge.lookahead_on) adr1_high = adr_func(adr_1,true) adr1_low = adr_func(adr_1,false) adr2_high = adr_func(adr_2,true) adr2_low = adr_func(adr_2,false) //***End of getting data float _adr1_high = na float _adr1_low = na float _adr2_high = na float _adr2_low = na var show_chart = false if timeframe.isintraday show_chart := true //Plot all days if show_chart and plot_history _adr1_high := adr1_high _adr1_low := adr1_low _adr2_high := adr2_high _adr2_low := adr2_low ADR1H = plot(_adr1_high, title=text_ADR1_high, color=color_ADR1_high, style=plot.style_circles,linewidth = 1) ADR2H = plot(_adr2_high, title=text_ADR2_high, color=color_ADR2_high, style=plot.style_circles,linewidth = 1) ADR1L = plot(_adr1_low, title=text_ADR1_low, color=color_ADR1_low, style=plot.style_circles,linewidth = 1) ADR2L = plot(_adr2_low, title=text_ADR2_low, color=color_ADR2_low, style=plot.style_circles,linewidth = 1) fill(ADR1H,ADR2H,color.new(adrUppercolorfill,80)) fill(ADR1L,ADR2L,color.new(adrlowercolorfill,80)) if show_chart and not plot_history draw_line1 = line.new(start_time, adr1_high, time, adr1_high, xloc.bar_time, extend.none, color_ADR1_high, line.style_dotted, 2) line.delete(draw_line1[1]) draw_line2 = line.new(start_time, adr2_high, time, adr2_high, xloc.bar_time, extend.none, color_ADR2_high, line.style_dotted, 2) line.delete(draw_line2[1]) draw_line3 = line.new(start_time, adr1_low, time, adr1_low, xloc.bar_time, extend.none, color_ADR1_low, line.style_dotted, 2) line.delete(draw_line3[1]) draw_line4 = line.new(start_time, adr2_low, time, adr2_low, xloc.bar_time, extend.none, color_ADR2_low, line.style_dotted, 2) line.delete(draw_line4[1]) linefill.new(draw_line1, draw_line2, color.new(adrUppercolorfill,80)) linefill.new(draw_line3, draw_line4, color.new(adrlowercolorfill, 80)) // PDH / PDL PHPL = input(title='PDH/PDL', defval=true,group='pivot') PH = high PL = low PDH = request.security(syminfo.tickerid, 'D', PH[1], barmerge.gaps_off, barmerge.lookahead_on) PDL = request.security(syminfo.tickerid, 'D', PL[1], barmerge.gaps_off, barmerge.lookahead_on) PDHColour = PDH != PDH[1] ? na : color.black PDLColour = PDL != PDL[1] ? na : color.black plot(PHPL ? PDH : na, title='PDH', color=PDHColour, style=plot.style_line, linewidth=2) plot(PHPL ? PDL : na, title='PDL', color=PDLColour, style=plot.style_line, linewidth=2) // Table // Table Position & Size var table_position = dash_loc == 'Top Right' ? position.top_right : dash_loc == 'Bottom Right' ? position.bottom_right : dash_loc == 'Middle Right' ? position.middle_right : dash_loc == 'Top Left' ? position.top_left : position.bottom_left var table_text_size = text_size == 'Small' ? size.small : size.normal var t = table.new(table_position,11,math.abs(max-min)+2, frame_color=color.new(color.gray,0), frame_width=1, border_color=color.new(#000000,0), border_width=1) // Table Column & Rows if (barstate.islast) // Table Main Column Headers table.cell(t,1,0,_Index == 'BankNifty' ? 'tradeblinks - BankNifty':'tradeblinks - Nifty',text_color=color.aqua,text_size=size.normal,bgcolor=color.new(color.blue,cell_transp)) table.merge_cells(t,1,0,9,0) table.cell(t,1,1,'Symbol',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,1,'LTP',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,3,1,' D High',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,4,1,'D Low',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,5,1,'I.Points',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,6,1,'PH-PL',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,7,1,'ATR',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,8,1,'DTR',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,9,1,'DTR %',text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) // Display NIFTY/VIX table.cell(t,1,2, str.replace_all(t1, 'NSE:', ''), text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,2, str.tostring(ts1ltp, '#.##') ,text_color=color.new(ts1ltp >= ts1pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts1ltp >= ts1pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,2, str.tostring(ts1high, '#.##'),text_color=color.new(ts1high >= ts1pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts1high >= ts1pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,2, str.tostring(ts1low, '#.##') ,text_color=color.new(ts1low >= ts1pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts1low >= ts1pclose ? cell_up : cell_dn ,cell_transp)) if ts1ltp > ts1PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts1ltp < ts1PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts1ltp < ts1PDH and ts1ltp > ts1PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,5,2, str.tostring(ts1Chng, '#.##'),text_color=color.new(ts1Chng >= 0 ? cell_up : cell_dn,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,6,2, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,2, str.tostring(t1ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,2, str.tostring(t1dtr, '#.##'),text_color=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,2, str.tostring(t1atrp, '#.##') + "%",text_color=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t1atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display BANKNIFTY/NIFTY table.cell(t,1,3, str.replace_all(t2, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,3, str.tostring(ts2ltp, '#.##') ,text_color=color.new(ts2ltp >= ts2pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts2ltp >= ts2pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,3, str.tostring(ts2high, '#.##'),text_color=color.new(ts2high >= ts2pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts2high >= ts2pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,3, str.tostring(ts2low, '#.##'),text_color=color.new(ts2low >= ts2pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts2low >= ts2pclose ? cell_up : cell_dn ,cell_transp)) if ts2ltp > ts2PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts2ltp < ts2PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts2ltp < ts2PDH and ts2ltp > ts2PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,5,3, str.tostring(ts2Chng, '#.##'),text_color=color.new(ts2Chng >= 0 ? cell_up : cell_dn,0),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) table.cell(t,6,3, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,3, str.tostring(t2ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,3, str.tostring(t2dtr, '#.##'),text_color=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,3, str.tostring(t2atrp, '#.##') + "%",text_color=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t2atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S1 table.cell(t,1,4, str.replace_all(t3, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,4, str.tostring(ts3ltp, '#.##') ,text_color=color.new(ts3ltp >= ts3pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts3ltp >= ts3pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,4, str.tostring(ts3high, '#.##'),text_color=color.new(ts3high >= ts3pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts3high >= ts3pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,4, str.tostring(ts3low, '#.##') ,text_color=color.new(ts3low >= ts3pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts3low >= ts3pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,4, str.tostring(IPV1, '#.##'),text_color=color.new(IPV1 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV1 > 0 ? cell_up : cell_dn ,cell_transp)) if ts3ltp > ts3PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts3ltp < ts3PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts3ltp < ts3PDH and ts3ltp > ts3PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,4, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,4, str.tostring(t3ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,4, str.tostring(t3dtr, '#.##'),text_color=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,4, str.tostring(t3atrp, '#.##') + "%",text_color=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t3atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S2 table.cell(t,1,5, str.replace_all(t4, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,5, str.tostring(ts4ltp, '#.##') ,text_color=color.new(ts4ltp >= ts4pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts4ltp >= ts4pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,5, str.tostring(ts4high, '#.##'),text_color=color.new(ts4high >= ts4pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts4high >= ts4pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,5, str.tostring(ts4low, '#.##') ,text_color=color.new(ts4low >= ts4pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts4low >= ts4pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,5, str.tostring(IPV2, '#.##'),text_color=color.new(IPV2 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV2 > 0 ? cell_up : cell_dn ,cell_transp)) if ts4ltp > ts4PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts4ltp < ts4PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts4ltp < ts4PDH and ts4ltp > ts4PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,5, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,5, str.tostring(t4ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,5, str.tostring(t4dtr, '#.##'),text_color=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,5, str.tostring(t4atrp, '#.##') + "%",text_color=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t4atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S3 table.cell(t,1,6, str.replace_all(t5, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,6, str.tostring(ts5ltp, '#.##') ,text_color=color.new(ts5ltp >= ts5pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts5ltp >= ts5pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,6, str.tostring(ts5high, '#.##'),text_color=color.new(ts5high >= ts5pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts5high >= ts5pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,6, str.tostring(ts5low, '#.##') ,text_color=color.new(ts5low >= ts5pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts5low >= ts5pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,6, str.tostring(IPV3, '#.##'),text_color=color.new(IPV3 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV3 > 0 ? cell_up : cell_dn ,cell_transp)) if ts5ltp > ts5PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts5ltp < ts5PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts5ltp < ts5PDH and ts5ltp > ts5PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,6, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,6, str.tostring(t5ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,6, str.tostring(t5dtr, '#.##'),text_color=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,6, str.tostring(t5atrp, '#.##') + "%",text_color=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t5atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S4 table.cell(t,1,7, str.replace_all(t6, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,7, str.tostring(ts6ltp, '#.##') ,text_color=color.new(ts6ltp >= ts6pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts6ltp >= ts6pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,7, str.tostring(ts6high, '#.##'),text_color=color.new(ts6high >= ts6pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts6high >= ts6pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,7, str.tostring(ts6low, '#.##') ,text_color=color.new(ts6low >= ts6pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts6low >= ts6pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,7, str.tostring(IPV4, '#.##'),text_color=color.new(IPV4 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV4 > 0 ? cell_up : cell_dn ,cell_transp)) if ts6ltp > ts6PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts6ltp < ts6PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts6ltp < ts6PDH and ts6ltp > ts6PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,7, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,7, str.tostring(t6ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,7, str.tostring(t6dtr, '#.##'),text_color=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,7, str.tostring(t6atrp, '#.##') + "%",text_color=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t6atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S5 table.cell(t,1,8, str.replace_all(t7, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,8, str.tostring(ts7ltp, '#.##') ,text_color=color.new(ts7ltp >= ts7pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts7ltp >= ts7pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,8, str.tostring(ts7high, '#.##'),text_color=color.new(ts7high >= ts7pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts7high >= ts7pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,8, str.tostring(ts7low, '#.##') ,text_color=color.new(ts7low >= ts7pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts7low >= ts7pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,8, str.tostring(IPV5, '#.##'),text_color=color.new(IPV5 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV5 > 0 ? cell_up : cell_dn ,cell_transp)) if ts7ltp > ts7PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts7ltp < ts7PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts7ltp < ts7PDH and ts7ltp > ts7PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,8, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,8, str.tostring(t7ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,8, str.tostring(t7dtr, '#.##'),text_color=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,8, str.tostring(t7atrp, '#.##') + "%",text_color=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t7atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S6 table.cell(t,1,9, str.replace_all(t8, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,9, str.tostring(ts8ltp, '#.##') ,text_color=color.new(ts8ltp >= ts8pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts8ltp >= ts8pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,9, str.tostring(ts8high, '#.##'),text_color=color.new(ts8high >= ts8pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts8high >= ts8pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,9, str.tostring(ts8low, '#.##') ,text_color=color.new(ts8low >= ts8pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts8low >= ts8pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,9, str.tostring(IPV6, '#.##'),text_color=color.new(IPV6 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV6 > 0 ? cell_up : cell_dn ,cell_transp)) if ts8ltp > ts8PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts8ltp < ts8PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts8ltp < ts8PDH and ts8ltp > ts8PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,9, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,9, str.tostring(t8ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,9, str.tostring(t8dtr, '#.##'),text_color=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,9, str.tostring(t8atrp, '#.##') + "%",text_color=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t8atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S7 table.cell(t,1,10, str.replace_all(t9, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,10, str.tostring(ts9ltp, '#.##') ,text_color=color.new(ts9ltp >= ts9pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts9ltp >= ts9pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,10, str.tostring(ts9high, '#.##'),text_color=color.new(ts9high >= ts9pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts9high >= ts9pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,10, str.tostring(ts9low, '#.##') ,text_color=color.new(ts9low >= ts9pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts9low >= ts9pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,10, str.tostring(IPV7, '#.##'),text_color=color.new(IPV7 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV7 > 0 ? cell_up : cell_dn ,cell_transp)) if ts9ltp > ts9PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts9ltp < ts9PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts9ltp < ts9PDH and ts9ltp > ts9PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,10, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,10, str.tostring(t9ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,10, str.tostring(t9dtr, '#.##'),text_color=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,10, str.tostring(t9atrp, '#.##') + "%",text_color=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t9atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // Display S8 table.cell(t,1,11, str.replace_all(t10, 'NSE:', ''),text_color=col_col,text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) table.cell(t,2,11, str.tostring(ts10ltp, '#.##') ,text_color=color.new(ts10ltp >= ts10pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts10ltp >= ts10pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,3,11, str.tostring(ts10high, '#.##'),text_color=color.new(ts10high >= ts10pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts10high >= ts10pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,11, str.tostring(ts10low, '#.##') ,text_color=color.new(ts10low >= ts10pclose ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(ts10low >= ts10pclose ? cell_up : cell_dn ,cell_transp)) table.cell(t,5,11, str.tostring(IPV8, '#.##'),text_color=color.new(IPV8 > 0 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(IPV8 > 0 ? cell_up : cell_dn ,cell_transp)) if ts10ltp > ts10PDH PColor:= color.new( cell_up ,cell_transp) PText:= '+ PH' else if ts10ltp < ts10PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '- PL' else if ts10ltp < ts10PDH and ts10ltp > ts10PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= 'PH-PL' table.cell(t,6,11, str.tostring(PText),text_color=color.new(PColor,0),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) table.cell(t,7,11, str.tostring(t10ATR, '#.##'),text_color=color.new(cell_neutral,0),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) table.cell(t,8,11, str.tostring(t10dtr, '#.##'),text_color=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) table.cell(t,9,11, str.tostring(t10atrp, '#.##') + "%",text_color=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,0),text_size=table_text_size, bgcolor=color.new(t10atrp < 61.8 ? cell_up : cell_dn ,cell_transp)) // END //
CMO with ATR and LagF Filtering - RevNR - 12-27-22
https://www.tradingview.com/script/UTmfIHwd-CMO-with-ATR-and-LagF-Filtering-RevNR-12-27-22/
hockeydude84
https://www.tradingview.com/u/hockeydude84/
43
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © hockeydude84 //@version=5 indicator("Chande Momentum Oscillator (CMO) ATR - Laguerre Filtered - RevNR - 12-27-22", shorttitle= "CMO with LagF Rev NR -12-27-22", format=format.price) //Rev NR of the CMO ATR, with LagF Filtering - Released 12-27-22 //This code takes Chande Momentum Oscillator (CMO), adds a coded ATR option and then filters the result through a Laguerre Filter (LagF) to reduce eronious signals. //This code also has an option for self adjusting alpha on the Lag, via a lookback table and monitoring the price rate of change (ROC) in the lookback length. //Faster ROC will allow the LagF to move faster, slower price action will slow down LagF reaction. //Pausing of signals is also present pased on Rate of Change of the LagF Curve //Agressive signals and Base signaling is allowed - agressive bases signals on increase/decrease of previous LagF curve value point, Base is greather or less than 0 //Original Code credits; Lost some of this due to time and multiple script manipulations, I beleive the CMO orgin code is from @TradingView, and the LagF from @KıvançÖzbilgiç //CMO Code var CMO ="Chande Momentum Oscillator (CMO) Inputs" intval1CMO = input.string('Chart', 'CMO ATR', options=['Chart', '30S', 'M01', 'M02', 'M03', 'M04', 'M05', 'M10', 'M15', 'M30', 'M45', 'H01', 'H02', 'H03', 'H04', 'H06', 'H08', 'H12', 'Day', 'Week', 'Month', 'Year'], group=CMO ) srcType = input(close, "CMO Source", group=CMO) //Obtain the correct Time Period for the CMO Code getRezCMO(intvalCMO) => iff_1CMO = intvalCMO == 'Year' ? '12M' : '60' iff_2CMO = intvalCMO == 'Month' ? 'M' : iff_1CMO iff_3CMO = intvalCMO == 'Week' ? 'W' : iff_2CMO iff_4CMO = intvalCMO == 'Day' ? 'D' : iff_3CMO iff_5CMO = intvalCMO == 'H12' ? '720' : iff_4CMO iff_6CMO = intvalCMO == 'H08' ? '480' : iff_5CMO iff_7CMO = intvalCMO == 'H06' ? '360' : iff_6CMO iff_8CMO = intvalCMO == 'H04' ? '240' : iff_7CMO iff_9CMO = intvalCMO == 'H03' ? '180' : iff_8CMO iff_10CMO = intvalCMO == 'H02' ? '120' : iff_9CMO iff_11CMO = intvalCMO == 'H01' ? '60' : iff_10CMO iff_12CMO = intvalCMO == 'M45' ? '45' : iff_11CMO iff_13CMO = intvalCMO == 'M30' ? '30' : iff_12CMO iff_14CMO = intvalCMO == 'M15' ? '15' : iff_13CMO iff_15CMO = intvalCMO == 'M10' ? '10' : iff_14CMO iff_16CMO = intvalCMO == 'M05' ? '5' : iff_15CMO iff_17CMO = intvalCMO == 'M04' ? '4' : iff_16CMO iff_18CMO = intvalCMO == 'M03' ? '3' : iff_17CMO iff_19CMO = intvalCMO == 'M02' ? '2' : iff_18CMO iff_20CMO = intvalCMO == 'M01' ? '1' : iff_19CMO iff_21CMO = intvalCMO == '30S' ? '30S' : iff_20CMO int_1CMO = intvalCMO == 'Chart' ? timeframe.period : iff_21CMO int_1CMO resCMO = getRezCMO(intval1CMO) //final timeperiod obtained //use security to get the timperiod data - non repaintcoded security srcCMOx = request.security(syminfo.ticker, resCMO, srcType[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on) srcCMO = ta.tsi(srcCMOx,7,21) //DO NOT MODIFY - this TSI filters the values from ATR's to prvoide usable data for the LAGF (if you change this HTF's will look wonky) lengthCMO = input.int(14,"CMO Length (Default = 14)", minval=1, group=CMO) momm = ta.change(srcCMO) f1(m) => m >= 0.0 ? m : 0.0 f2(m) => m >= 0.0 ? 0.0 : -m m1 = f1(momm) m2 = f2(momm) sm1 = math.sum(m1, lengthCMO) sm2 = math.sum(m2, lengthCMO) percent(nom, div) => 100 * nom / div chandeMO = percent(sm1-sm2, sm1+sm2) //plot(chandeMO, "Chande MO", color=color.aqua) //uncomment if you want the CMO plot /////////////////////////////// /////////////////////////////// //LagF Filter Code (By @KıvançÖzbilgiç with some minor modifications by @Hockeydude84) var lf = "Laguerre Filter (LagF) Inputs" srcCMOL = chandeMO //Chande Momentum is the input for the for LagF to filter for use (vs close as would be typical) UseAG_LagF = input(true, title='Use Agressive LagF Signaling (Default = Yes) ', group=lf) UseAC_Alpha = input(true, title='Use Auto Correcting Alpha (Default = Yes) ', group=lf) alpha_1 = input.float(title='Alpha (For Non-Auto Correcting)', minval=0, maxval=1, step=0.1, defval=0.2, group=lf) size_1 = 1 max_1 = 3 var fib_1 = array.from(1,1) var dist_1 = 0.,var avg_1 = 0.,var fib_n_1 = 1 n_1 = bar_index if barstate.isfirst for i_1 = 1 to max_1 array.push(fib_1,array.get(fib_1,i_1-1) + array.get(fib_1,i_1)) dist_1 := ta.atr(14)*size_1*array.get(fib_1,fib_n_1) fib_n_1 := math.abs(srcCMOL-avg_1) > dist_1 ? fib_n_1+1 : fib_n_1 avg_1 := nz(fib_n_1 > max_1+1 ? srcCMOL : avg_1[1],srcCMOL) fib_n_1 := fib_n_1 > max_1+1 ? 1 : fib_n_1 //Rate of Change (ROC) rcF = input(14, 'For AutoCorrecting Alpha - ROC Filter Fast Length (Default=14)', group=lf) rcS = input(100, 'For AutoCorrecting Alpha - ROC Filter Slow Length (Default=100)', group=lf) //AutoCorrecting Gamma Code (@Hockedude84) rise_ROC= ta.highest(close,rcF)- ta.lowest(close, rcF) slope_ROC = (rise_ROC/rcF) pre_normalized_ROC= math.abs(slope_ROC/(ta.highest(slope_ROC,rcS) - ta.lowest(slope_ROC,rcS))) //normalizing to "1" noramlized_ROC = pre_normalized_ROC>1 ? 1 : pre_normalized_ROC //Due to moving target, any values above 1 get equated to 1 //Final Gamma determination gamma_AC = noramlized_ROC //Autocorrecting Gamma (0-1 with 1 being fastes ROC) gamma_Locked = 1 - alpha_1 //Locked Gamma (typical for LagF Code) - 1 is fastest responding, 0 would be slowest gamma_1 = UseAC_Alpha ? gamma_AC : gamma_Locked //choose which gamma to use //LAGF Curve Code L0_1 = 0.0 L0_1 := (1 - gamma_1) * srcCMOL + gamma_1 * nz(L0_1[1]) L1_1 = 0.0 L1_1 := -gamma_1 * L0_1 + nz(L0_1[1]) + gamma_1 * nz(L1_1[1]) L2_1 = 0.0 L2_1:= -gamma_1 * L1_1 + nz(L1_1[1]) + gamma_1 * nz(L2_1[1]) L3_1 = 0.0 L3_1 := -gamma_1 * L2_1 + nz(L2_1[1]) + gamma_1 * nz(L3_1[1]) LagF_1 = (L0_1 + 2 * L1_1 + 2 * L2_1 + L3_1) / 6 //Final LagF Output //Pause Code - if LagF curve isn't moving "quickly" (such as an inactive/stagnant market) - it will pause signals UsePause = input(true, title='Enable Pause in Signals if LagF ROC is Slow (Defualt = Yes) ', group=lf) threshold_Pause = input.float(0.3, 'Pause Value (0-1) - Default = 0.3', minval = 0, maxval=1, step = 0.1) rise_Pause= ta.highest(LagF_1,rcF)- ta.lowest(LagF_1, rcF) slope_Pause = (rise_Pause/rcF) pre_normalize_Pause = math.abs(slope_Pause/(ta.highest(slope_Pause,rcS) - ta.lowest(slope_Pause,rcS))) //normalize Pause value to 1 normalized_Pause= pre_normalize_Pause>1 ? 1 : pre_normalize_Pause //Final Pause determinations pause = normalized_Pause > threshold_Pause ? 1: 0 // 1 enables trade, 0 inhibits pause_Final = UsePause==true ? pause : 1 //Colarize Signals and Final Plot Color_AG = pause_Final ==0 ? color.orange : LagF_1 > LagF_1[1] ? color.lime : color.fuchsia //embrace the darkside with fuchsia Color_Base = pause_Final ==0 ? color.orange : LagF_1 >0 ? color.lime : color.fuchsia //embrace the darkside with fuchsia Color_Final = UseAG_LagF == true ? Color_AG : Color_Base plot(LagF_1, title='LagF', linewidth=3, color=Color_Final) //final chart output
Position Size Tool
https://www.tradingview.com/script/yWaPZJrs-Position-Size-Tool/
shaaah10
https://www.tradingview.com/u/shaaah10/
190
study
5
MPL-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("Position Size Tool", overlay = true) // INPUT var string gp1 = "CANDLE" boolTable = input.bool(defval=false, title="Remove", tooltip = "Remove the the related table", group = gp1) AccountSize = input(title="Account Size", defval=100000, group = gp1) AccountRisk = input.float(title="Account Risk %", defval=1, group = gp1) var string gp2 = "LINE" boolLine = input.bool(defval=false, title="Remove", tooltip = "Remove the movable line and related table", group = gp2) AccountSizeDt = input(title="Account Size", defval=100000, group = gp2) AccountRiskDt = input.float(title="Account Risk %", defval=1, group = gp2) // VARIABLE riskHigh = close - high percentHigh = math.abs((riskHigh / close) * 100) sharesHigh = math.round((AccountSize * (AccountRisk/100)) / riskHigh) valueMid = (open + close) / 2 riskMid = close - valueMid percentMid = math.abs((riskMid / close) * 100) sharesMid = math.round((AccountSize * (AccountRisk/100)) / riskMid) riskLow = close - low percentLow = math.abs((riskLow / close) * 100) sharesLow = math.round((AccountSize * (AccountRisk/100)) / riskLow) changeOpen = close - open // CUSTOM LINE test(x)=> str.tostring(x) var int dec = str.length(str.tostring(syminfo.mintick))-2 trace(value) => factor = math.pow(10, dec) int(value * factor) / factor trace_(value) => factor = math.pow(10, 0) int(value * factor) / factor sl_value = input.price(100, "Line", group = gp2) line_color = sl_value > close ? color.green : sl_value < close ? color.red : color.black line_table_color = sl_value > close ? color.red : sl_value < close ? color.green : na riskLine = close - sl_value percentLine = math.abs((riskLine / close) * 100) sharesLine = math.round((AccountSizeDt * (AccountRiskDt/100)) / riskLine) if (boolLine == false) sl_line = line.new(bar_index, sl_value, bar_index+10, sl_value, extend=extend.left,color=line_color) price_label = label.new(bar_index+10, sl_value, test(trace(sl_value)), textcolor=line_color, color=color.white, style=label.style_label_left) line.delete (sl_line[1]) label.delete(price_label[1]) // TABLE var string Layout = 'Display' string tableSize = input.string("normal", "Table Size", inline = "1", options = ["huge", "large", "normal", "small", "tiny"], group = Layout) string tableY = input.string("top", "Position ", inline = "2", options = ["top", "middle", "bottom"], group = Layout) string tableX = input.string("right", "", inline = "2", options = ["left", "center", "right"], group = Layout) var table sizeDisplay = table.new(tableY + "_" + tableX, columns = 4, rows = 4, border_width = 1, border_color = color.black, frame_width = 1, frame_color = color.black) if (boolTable == false) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 0, row = 2, text = "L", text_color = color.white, bgcolor = color.green) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 0, row = 1, text = "M", text_color = color.white, bgcolor = (changeOpen > 0 ? color.green : color.red)) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 0, row = 0, text = "H", text_color = color.white, bgcolor = color.red) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 1, row = 2, text = str.tostring(low, "#.##"), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 1, row = 1, text = str.tostring(valueMid, "#.##"), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 1, row = 0, text = str.tostring(high, "#.##"), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 2, row = 2, text = str.tostring(percentLow, "#.##"), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 2, row = 1, text = str.tostring(percentMid, "#.##"), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 2, row = 0, text = str.tostring(percentHigh, "#.##"), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 3, row = 2, text = str.tostring(sharesLow), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 3, row = 1, text = str.tostring(sharesMid), text_color = color.black, bgcolor = color.white) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 3, row = 0, text = str.tostring(sharesHigh), text_color = color.black, bgcolor = color.white) if (boolLine == false) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 0, row = 3, text = "─", text_color = color.black, bgcolor = color.rgb(120, 123, 134, 97)) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 1, row = 3, text = str.tostring(sl_value, "#.##"), text_color = color.black, bgcolor = color.rgb(120, 123, 134, 97)) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 2, row = 3, text = str.tostring(percentLine, "#.##"), text_color = color.black, bgcolor = color.rgb(120, 123, 134, 97)) table.cell(table_id = sizeDisplay, text_size = tableSize, column = 3, row = 3, text = str.tostring(sharesLine), text_color = color.black, bgcolor = color.rgb(120, 123, 134, 97))
Remaining ATR [vnhilton]
https://www.tradingview.com/script/kdKnnY6M-Remaining-ATR-vnhilton/
vnhilton
https://www.tradingview.com/u/vnhilton/
104
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © vnhilton //@version=5 indicator("Remaining ATR [vnhilton]", "RATR", overlay=true, max_lines_count=500) //Visible only on intraday timeframes //RTH Session rth = time(timeframe.period, session.regular, syminfo.timezone) //Parameters length = input(20, "Day ATR period", "Previous Day ATR will be used in calculations as it's static", group="ATR Parameters") atrRTHM1 = input.float(1, "ATR Multiplier #1", 0, group="ATR Parameters") atrRTHM2 = input.float(2, "ATR Multiplier #2", 0, group="ATR Parameters") atrRTHM3 = input.float(3, "ATR Multiplier #3", 0, group="ATR Parameters") irYAxis = input(close, "Intraday Range Y-Axis", group="Intraday Range Label Parameters") irForm = input.string("Multiplier", "Intraday Range Form", ["Multiplier", "Percent", "Price"], tooltip="ATR Multiplier; Intraday Price; Percentage of ATR", group="Intraday Range Label Parameters") irLabelOffset = input(0, "Intraday Label Offset", "Offsets to the right of the current candle", group="Intraday Range Label Parameters") irLabelSize = input.string("Tiny", "Label Size", ["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], group="Intraday Range Label Parameters") irLabelTextColor = input.color(color.new(#ffffff, 0), "Intraday Range Label Text Color", group="Intraday Range Label Parameters") extension = input(false, "Extend Current Lines to The Right?", group="Line Parameters") recentLinesOnly = input(false, "Show Recent Lines Only?", group="Line Parameters") insideLineHide = input(false, "Hide RATR Lines When RATR <= 0?", "When RATR Lines go within the intraday high/low range, the lines will be hidden", group="Line Parameters") lineStyle = input.string("Solid", "Line Style", ["Dashed", "Dotted", "Solid"], group="Line Parameters") insideLabelHide = input(false, "Hide RATR Labels When RATR <= 0?", "When RATR Lines go within the intraday high/low range, the labels will be hidden", group="Label Parameters") labelOffset = input(0, "Label Offset", "Offsets to the right of lines", group="Label Parameters") labelSize = input.string("Normal", "Label Size", ["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], group="Label Parameters") openLineColor = input.color(color.new(#b2b5be, 0), "Open line Color", group = "Open Line Parameters") openLineThickness = input.int(1, "Open Line's thickness", 1, group="Open Line Parameters") openLabelTextColor = input.color(color.new(#b2b5be, 0), "Open Label Text Color", group="Open Line Parameters") baseLineThickness = input.int(1, "Baselines' thickness", 1, tooltip="Baselines are high & low lines", group="Baselines Parameters") highDLineColor = input.color(color.new(#bfd08c, 0), "High Line Color", group = "Baselines Parameters") highDLabelTextColor = input.color(color.new(#bfd08c, 0), "High Label Text Color", group="Baselines Parameters") highDPlotFillColor = input.color(color.new(#bfd08c, 90), "High Line Plot Fill Color", group = "Baselines Parameters") lowDLineColor = input.color(color.new(#e35542, 0), "Low Line Color", group = "Baselines Parameters") lowDLabelTextColor = input.color(color.new(#e35542, 0), "Low Label Text Color", group="Baselines Parameters") lowDPlotFillColor = input.color(color.new(#e35542, 90), "Low Line Plot Fill Color", group = "Baselines Parameters") atrThickness = input.int(1, "ATR lines' thickness", 1, group="ATR Lines Parameters") atr1LineColor = input.color(color.new(#4deeea, 0), "ATR #1 Lines Color", group="ATR Lines Parameters") atr1LineInsideColor = input.color(color.new(#4deeea, 80), "ATR #1 Lines Inside Color", "When RATR <= 0, then lines will change to a different color", group="ATR Lines Parameters") atr1LabelTextColor = input.color(color.new(#4deeea, 0), "ATR #1 Label Text Color", group="ATR Lines Parameters") atr1LabelTextInsideColor = input.color(color.new(#4deeea, 80), "ATR #1 Label Text Inside Color", "When RATR <= 0, then label will change to a different color", group="ATR Lines Parameters") atr1PlotFillColor = input.color(color.new(#4deeea, 90), "ATR #1 Line Plot Fill Color", "For the cleanest plot fills, make sure the ATR multipliers are as follows: M3 > M2 > M1", group = "ATR Lines Parameters") atr2LineColor = input.color(color.new(#8a00ff, 0), "ATR #2 Lines Color", group="ATR Lines Parameters") atr2LineInsideColor = input.color(color.new(#8a00ff, 80), "ATR #2 Lines Inside Color", group="ATR Lines Parameters") atr2LabelTextColor = input.color(color.new(#8a00ff, 0), "ATR #2 Label Text Color", group="ATR Lines Parameters") atr2LabelTextInsideColor = input.color(color.new(#8a00ff, 80), "ATR #2 Label Text Inside Color", group="ATR Lines Parameters") atr2PlotFillColor = input.color(color.new(#8a00ff, 90), "ATR #2 Line Plot Fill Color", group = "ATR Lines Parameters") atr3LineColor = input.color(color.new(#f000ff, 0), "ATR #3 Lines Color", group="ATR Lines Parameters") atr3LineInsideColor = input.color(color.new(#f000ff, 80), "ATR #3 Lines Inside Color", group="ATR Lines Parameters") atr3LabelTextColor = input.color(color.new(#f000ff, 0), "ATR #3 Label Text Color", group="ATR Lines Parameters") atr3LabelTextInsideColor = input.color(color.new(#f000ff, 80), "ATR #3 Label Text Inside Color", group="ATR Lines Parameters") atr3PlotFillColor = input.color(color.new(#f000ff, 90), "ATR #3 Line Plot Fill Color", group = "ATR Lines Parameters") //hl2 Range Function hl2Range(h, l) => (h + l) / 2 //Values Gathering atr = ta.atr(length) [yAtrD, yHighD, yLowD] = request.security(syminfo.tickerid, "D", [atr[1], high[1], low[1]], lookahead=barmerge.lookahead_on) //Daily data as ATR values consistent across daily/intraday TFs, & HL only used as conditions //Obtain OHL via intraday data due to daily/intraday data inconsistencies //Counting RTH Bars rthBars = int(na) //Reset On New Day isNewDay = time("D") != time("D")[1] rthBars := isNewDay ? 1 : rth ? nz(rthBars[1]) + 1 : 0 //Getting Open Value & Resetting rthBars For RTH Only var float openD = na if rthBars == 1 openD := open //Getting HL Values (This Leads to Warning But Extracting Functions Out Prevents Script From Working) highD = rthBars < 1 ? ta.highest(high, 1) : ta.highest(high, rthBars) lowD = rthBars < 1 ? ta.lowest(low, 1) : ta.lowest(low, rthBars) CATR = highD - lowD //Current ATR //ATR Calculations remainingATR(multiplier) => RATR = multiplier * yAtrD - CATR //Remaining ATR //Yesterday's & Today's HL2 yRange = hl2Range(yHighD, yLowD) //Used to detect new day tRange = hl2Range(highD, lowD) //Used to detect intraday new highs/lows //Label Size Selection labelSizing(choice) => switch labelSize "Auto" => size.auto "Tiny" => size.tiny "Small" => size.small "Normal" => size.normal "Large" => size.large "Huge" => size.huge //Line Style Selection lineStyling(choice) => switch lineStyle "Dashed" => line.style_dashed "Dotted" => line.style_dotted "Solid" => line.style_solid //Intraday Range Label Form Calculation irRangeFormSelection(choice) => switch irForm "Multiplier" => str.tostring(CATR / yAtrD, '#0.00') + "x" "Percent" => str.tostring(CATR * 100 / yAtrD, '#0.00') + "%" "Price" => str.tostring(CATR, format.mintick) //Line Style Assignments style = lineStyling(lineStyle) //Labels Size Assignment size = labelSizing(labelSize) irSize = labelSizing(irLabelSize) //Intraday Range Assignment irPrice = irRangeFormSelection(irForm) //Setup Lines var line openLine = na var line highLine = na var line lowLine = na var line atr1LineU = na var line atr1LineD = na var line atr2LineU = na var line atr2LineD = na var line atr3LineU = na var line atr3LineD = na //Setup Line Plot Fills var linefill atr1FillUp = na var linefill atr1FillDown = na var linefill atr2FillUp = na var linefill atr2FillDown = na var linefill atr3FillUp = na var linefill atr3FillDown = na //Setup Labels var label openLabel = na var label highLabel = na var label lowLabel = na var label irLabel = na var label atr1LabelU = na var label atr1LabelD = na var label atr2LabelU = na var label atr2LabelD = na var label atr3LabelU = na var label atr3LabelD = na //Code to Clean Up RATR Lines When RATR < 0 ratrCleanUp(ratr, pLinePrice, linePrice, line, label) => if ratr < 0 and pLinePrice != linePrice line.set_color(line, color.new(#000000, 100)) label.set_textcolor(label, color.new(#000000, 100)) //Code to Detect New Day if yRange[1] != yRange and timeframe.isintraday //Stop Old Lines Extensions If There're Any line.set_extend(openLine, extend.none) line.set_extend(highLine, extend.none) line.set_extend(lowLine, extend.none) line.set_extend(atr1LineU, extend.none) line.set_extend(atr1LineD, extend.none) line.set_extend(atr2LineU, extend.none) line.set_extend(atr2LineD, extend.none) line.set_extend(atr3LineU, extend.none) line.set_extend(atr3LineD, extend.none) //Delete Old Labels to Keep Charts Clean If There're Any label.delete(openLabel) label.delete(highLabel) label.delete(lowLabel) label.delete(irLabel) label.delete(atr1LabelU) label.delete(atr1LabelD) label.delete(atr2LabelU) label.delete(atr2LabelD) label.delete(atr3LabelU) label.delete(atr3LabelD) //Create New Lines openLine := line.new(bar_index, openD, bar_index, openD, color=openLineColor, style=style, width=openLineThickness) highLine := line.new(bar_index, highD, bar_index, highD, color=highDLineColor, style=style, width=baseLineThickness) lowLine := line.new(bar_index, lowD, bar_index, lowD, color=lowDLineColor, style=style, width=baseLineThickness) atr1LineU := line.new(bar_index, highD + remainingATR(atrRTHM1), bar_index, highD + remainingATR(atrRTHM1), color=atr1LineColor, style=style, width=atrThickness) atr1LineD := line.new(bar_index, lowD - remainingATR(atrRTHM1), bar_index, lowD - remainingATR(atrRTHM1), color=atr1LineColor, style=style, width=atrThickness) atr2LineU := line.new(bar_index, highD + remainingATR(atrRTHM2), bar_index, highD + remainingATR(atrRTHM2), color=atr2LineColor, style=style, width=atrThickness) atr2LineD := line.new(bar_index, lowD - remainingATR(atrRTHM2), bar_index, lowD - remainingATR(atrRTHM2), color=atr2LineColor, style=style, width=atrThickness) atr3LineU := line.new(bar_index, highD + remainingATR(atrRTHM3), bar_index, highD + remainingATR(atrRTHM3), color=atr3LineColor, style=style, width=atrThickness) atr3LineD := line.new(bar_index, lowD - remainingATR(atrRTHM3), bar_index, lowD - remainingATR(atrRTHM3), color=atr3LineColor, style=style, width=atrThickness) //Line Fills linefill.new(openLine, highLine, highDPlotFillColor) linefill.new(openLine, lowLine, lowDPlotFillColor) atr1FillUp := linefill.new(highLine, atr1LineU, atr1PlotFillColor) atr1FillDown := linefill.new(lowLine, atr1LineD, atr1PlotFillColor) atr2FillUp := linefill.new(highLine, atr2LineU, atr2PlotFillColor) atr2FillDown := linefill.new(lowLine, atr2LineD, atr2PlotFillColor) atr3FillUp := linefill.new(highLine, atr3LineU, atr3PlotFillColor) atr3FillDown := linefill.new(lowLine, atr3LineD, atr3PlotFillColor) //Create Labels openLabel := label.new(bar_index + labelOffset, openD, 'Open: ' + str.tostring(openD, format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=openLabelTextColor, size=size) highLabel := label.new(bar_index + labelOffset, highD, 'High: ' + str.tostring(highD, format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=highDLabelTextColor, size=size) lowLabel := label.new(bar_index + labelOffset, lowD, 'Low: ' + str.tostring(lowD, format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=lowDLabelTextColor, size=size) irLabel := label.new(bar_index + irLabelOffset, irYAxis, 'IR: ' + irPrice, color=color.new(#000000, 100), style=label.style_label_left, textcolor=irLabelTextColor, size=irSize) atr1LabelU := label.new(bar_index + labelOffset, highD + remainingATR(atrRTHM1), 'RATR #1: ' + str.tostring(highD + remainingATR(atrRTHM1), format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=atr1LabelTextColor, size=size) atr1LabelD := label.new(bar_index + labelOffset, lowD - remainingATR(atrRTHM1), 'RATR #1: ' + str.tostring(lowD - remainingATR(atrRTHM1), format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=atr1LabelTextColor, size=size) atr2LabelU := label.new(bar_index + labelOffset, highD + remainingATR(atrRTHM2), 'RATR #2: ' + str.tostring(highD + remainingATR(atrRTHM2), format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=atr2LabelTextColor, size=size) atr2LabelD := label.new(bar_index + labelOffset, lowD - remainingATR(atrRTHM2), 'RATR #2: ' + str.tostring(lowD - remainingATR(atrRTHM2), format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=atr2LabelTextColor, size=size) atr3LabelU := label.new(bar_index + labelOffset, highD + remainingATR(atrRTHM3), 'RATR #3: ' + str.tostring(highD + remainingATR(atrRTHM3), format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=atr3LabelTextColor, size=size) atr3LabelD := label.new(bar_index + labelOffset, lowD - remainingATR(atrRTHM3), 'RATR #3: ' + str.tostring(lowD - remainingATR(atrRTHM3), format.mintick), color=color.new(#000000, 100), style=label.style_label_left, textcolor=atr3LabelTextColor, size=size) //If Only Want Recent Lines On Chart if recentLinesOnly line.delete(openLine[1]) line.delete(highLine[1]) line.delete(lowLine[1]) line.delete(atr1LineU[1]) line.delete(atr1LineD[1]) line.delete(atr2LineU[1]) line.delete(atr2LineD[1]) line.delete(atr3LineU[1]) line.delete(atr3LineD[1]) //Extending lines if extension line.set_extend(openLine, extend.right) line.set_extend(highLine, extend.right) line.set_extend(lowLine, extend.right) line.set_extend(atr1LineU, extend.right) line.set_extend(atr1LineD, extend.right) line.set_extend(atr2LineU, extend.right) line.set_extend(atr2LineD, extend.right) line.set_extend(atr3LineU, extend.right) line.set_extend(atr3LineD, extend.right) //Code to Detect Intraday Range Change if tRange[1] != tRange and rth and timeframe.isintraday //Delete Line Plot Fills linefill.delete(atr1FillUp) linefill.delete(atr1FillDown) linefill.delete(atr2FillUp) linefill.delete(atr2FillDown) linefill.delete(atr3FillUp) linefill.delete(atr3FillDown) //Create & Update Line Plot Fills atr1FillUp := linefill.new(highLine, atr1LineU, atr1PlotFillColor) atr1FillDown := linefill.new(lowLine, atr1LineD, atr1PlotFillColor) atr2FillUp := linefill.new(highD >= line.get_y1(atr1LineU) ? highLine : atr1LineU, atr2LineU, atr2PlotFillColor) atr2FillDown := linefill.new(lowD <= line.get_y1(atr1LineD) ? lowLine : atr1LineD, atr2LineD, atr2PlotFillColor) atr3FillUp := linefill.new(highD >= line.get_y1(atr2LineU) ? highLine : atr2LineU, atr3LineU, atr3PlotFillColor) atr3FillDown := linefill.new(lowD <= line.get_y1(atr2LineD) ? lowLine : atr2LineD, atr3LineD, atr3PlotFillColor) linefill.set_color(atr1FillUp, remainingATR(atrRTHM1) >= 0 ? atr1PlotFillColor : na) linefill.set_color(atr1FillDown, remainingATR(atrRTHM1) >= 0 ? atr1PlotFillColor : na) linefill.set_color(atr2FillUp, remainingATR(atrRTHM2) >= 0 ? atr2PlotFillColor : na) linefill.set_color(atr2FillDown, remainingATR(atrRTHM2) >= 0 ? atr2PlotFillColor : na) linefill.set_color(atr3FillUp, remainingATR(atrRTHM3) >= 0 ? atr3PlotFillColor : na) linefill.set_color(atr3FillDown, remainingATR(atrRTHM3) >= 0 ? atr3PlotFillColor : na) //Code For When RATR <= 0? i.e. RATR Lines Are Inside Range if remainingATR(atrRTHM1) <= 0 line.set_color(atr1LineU, atr1LineInsideColor) line.set_color(atr1LineD, atr1LineInsideColor) label.set_textcolor(atr1LabelU, atr1LabelTextInsideColor) label.set_textcolor(atr1LabelD, atr1LabelTextInsideColor) if insideLineHide line.set_color(atr1LineU, color.new(#000000, 100)) line.set_color(atr1LineD, color.new(#000000, 100)) if insideLabelHide label.set_textcolor(atr1LabelU, color.new(#000000, 100)) label.set_textcolor(atr1LabelD, color.new(#000000, 100)) if remainingATR(atrRTHM2) <= 0 line.set_color(atr2LineU, atr2LineInsideColor) line.set_color(atr2LineD, atr2LineInsideColor) label.set_textcolor(atr2LabelU, atr2LabelTextInsideColor) label.set_textcolor(atr2LabelD, atr2LabelTextInsideColor) if insideLineHide line.set_color(atr2LineU, color.new(#000000, 100)) line.set_color(atr2LineD, color.new(#000000, 100)) if insideLabelHide label.set_textcolor(atr2LabelU, color.new(#000000, 100)) label.set_textcolor(atr2LabelD, color.new(#000000, 100)) if remainingATR(atrRTHM3) <= 0 line.set_color(atr3LineU, atr3LineInsideColor) line.set_color(atr3LineD, atr3LineInsideColor) label.set_textcolor(atr3LabelU, atr3LabelTextInsideColor) label.set_textcolor(atr3LabelD, atr3LabelTextInsideColor) if insideLineHide line.set_color(atr3LineU, color.new(#000000, 100)) line.set_color(atr3LineD, color.new(#000000, 100)) if insideLabelHide label.set_textcolor(atr3LabelU, color.new(#000000, 100)) label.set_textcolor(atr3LabelD, color.new(#000000, 100)) //Remove Moving RATR Lines To Prevent Visual Confusion when RATR < 0 ratrCleanUp(remainingATR(atrRTHM1), line.get_y1(atr1LineU)[1], line.get_y1(atr1LineU), atr1LineU, atr1LabelU) ratrCleanUp(remainingATR(atrRTHM1), line.get_y1(atr1LineD)[1], line.get_y1(atr1LineD), atr1LineD, atr1LabelD) ratrCleanUp(remainingATR(atrRTHM2), line.get_y1(atr2LineU)[1], line.get_y1(atr2LineU), atr2LineU, atr2LabelU) ratrCleanUp(remainingATR(atrRTHM2), line.get_y1(atr2LineD)[1], line.get_y1(atr2LineD), atr2LineD, atr2LabelD) ratrCleanUp(remainingATR(atrRTHM3), line.get_y1(atr3LineU)[1], line.get_y1(atr3LineU), atr3LineU, atr3LabelU) ratrCleanUp(remainingATR(atrRTHM3), line.get_y1(atr3LineD)[1], line.get_y1(atr3LineD), atr3LineD, atr3LabelD) //Update Line Coordinates line.set_x2(openLine, bar_index) line.set_x2(highLine, bar_index) line.set_x2(lowLine, bar_index) line.set_x2(atr1LineU, bar_index) line.set_x2(atr1LineD, bar_index) line.set_x2(atr2LineU, bar_index) line.set_x2(atr2LineD, bar_index) line.set_x2(atr3LineU, bar_index) line.set_x2(atr3LineD, bar_index) line.set_y1(highLine, highD) line.set_y2(highLine, highD) line.set_y1(lowLine, lowD) line.set_y2(lowLine, lowD) line.set_y1(atr1LineU, highD + remainingATR(atrRTHM1)) line.set_y2(atr1LineU, highD + remainingATR(atrRTHM1)) line.set_y1(atr1LineD, lowD - remainingATR(atrRTHM1)) line.set_y2(atr1LineD, lowD - remainingATR(atrRTHM1)) line.set_y1(atr2LineU, highD + remainingATR(atrRTHM2)) line.set_y2(atr2LineU, highD + remainingATR(atrRTHM2)) line.set_y1(atr2LineD, lowD - remainingATR(atrRTHM2)) line.set_y2(atr2LineD, lowD - remainingATR(atrRTHM2)) line.set_y1(atr3LineU, highD + remainingATR(atrRTHM3)) line.set_y2(atr3LineU, highD + remainingATR(atrRTHM3)) line.set_y1(atr3LineD, lowD - remainingATR(atrRTHM3)) line.set_y2(atr3LineD, lowD - remainingATR(atrRTHM3)) //Update Label Coordinates label.set_x(openLabel, bar_index + labelOffset) label.set_x(highLabel, bar_index + labelOffset) label.set_x(lowLabel, bar_index + labelOffset) label.set_x(irLabel, bar_index + irLabelOffset) label.set_x(atr1LabelU, bar_index + labelOffset) label.set_x(atr1LabelD, bar_index + labelOffset) label.set_x(atr2LabelU, bar_index + labelOffset) label.set_x(atr2LabelD, bar_index + labelOffset) label.set_x(atr3LabelU, bar_index + labelOffset) label.set_x(atr3LabelD, bar_index + labelOffset) label.set_y(highLabel, highD) label.set_y(lowLabel, lowD) label.set_y(irLabel, irYAxis) label.set_y(atr1LabelU, highD + remainingATR(atrRTHM1)) label.set_y(atr1LabelD, lowD - remainingATR(atrRTHM1)) label.set_y(atr2LabelU, highD + remainingATR(atrRTHM2)) label.set_y(atr2LabelD, lowD - remainingATR(atrRTHM2)) label.set_y(atr3LabelU, highD + remainingATR(atrRTHM3)) label.set_y(atr3LabelD, lowD - remainingATR(atrRTHM3)) //Update Label Text label.set_text(highLabel, 'High: ' + str.tostring(highD, format.mintick)) label.set_text(lowLabel, 'Low: ' + str.tostring(lowD, format.mintick)) label.set_text(irLabel, 'IR: ' + irPrice) label.set_text(atr1LabelU, 'RATR #1: ' + str.tostring(highD + remainingATR(atrRTHM1), format.mintick)) label.set_text(atr1LabelD, 'RATR #1: ' + str.tostring(lowD - remainingATR(atrRTHM1), format.mintick)) label.set_text(atr2LabelU, 'RATR #2: ' + str.tostring(highD + remainingATR(atrRTHM2), format.mintick)) label.set_text(atr2LabelD, 'RATR #2: ' + str.tostring(lowD - remainingATR(atrRTHM2), format.mintick)) label.set_text(atr3LabelU, 'RATR #3: ' + str.tostring(highD + remainingATR(atrRTHM3), format.mintick)) label.set_text(atr3LabelD, 'RATR #3: ' + str.tostring(lowD - remainingATR(atrRTHM3), format.mintick)) //Code to Detect No Intraday Range Change if tRange[1] == tRange and rth and timeframe.isintraday //Update Line Coordinates line.set_x2(openLine, bar_index) line.set_x2(highLine, bar_index) line.set_x2(lowLine, bar_index) line.set_x2(atr1LineU, bar_index) line.set_x2(atr1LineD, bar_index) line.set_x2(atr2LineU, bar_index) line.set_x2(atr2LineD, bar_index) line.set_x2(atr3LineU, bar_index) line.set_x2(atr3LineD, bar_index) //Update Label Coordinates label.set_x(openLabel, bar_index + labelOffset) label.set_x(highLabel, bar_index + labelOffset) label.set_x(lowLabel, bar_index + labelOffset) label.set_x(irLabel, bar_index + irLabelOffset) label.set_y(irLabel, irYAxis) label.set_x(atr1LabelU, bar_index + labelOffset) label.set_x(atr1LabelD, bar_index + labelOffset) label.set_x(atr2LabelU, bar_index + labelOffset) label.set_x(atr2LabelD, bar_index + labelOffset) label.set_x(atr3LabelU, bar_index + labelOffset) label.set_x(atr3LabelD, bar_index + labelOffset) //Code to Detect ETH Range if not rth and timeframe.isintraday //Stop Old Lines Extensions If There're Any line.set_extend(openLine, extend.none) line.set_extend(highLine, extend.none) line.set_extend(lowLine, extend.none) line.set_extend(atr1LineU, extend.none) line.set_extend(atr1LineD, extend.none) line.set_extend(atr2LineU, extend.none) line.set_extend(atr2LineD, extend.none) line.set_extend(atr3LineU, extend.none) line.set_extend(atr3LineD, extend.none)
OHLC Tool
https://www.tradingview.com/script/6mogvnfN-OHLC-Tool/
SamRecio
https://www.tradingview.com/u/SamRecio/
185
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SamRecio //@version=5 indicator("OHLC Tool",shorttitle = "📏", overlay = true, max_bars_back = 5000) //User Inputs lb = input.int(1, title = "Lookback", minval = 0, maxval = 1000, step = 1, tooltip = "Displays Data from [Input] Bars Ago.\n0 = Current Bar\n1 = Previous Bar\n\nNote: Errors will appear when trying to get data from a bar before your chart's available data. This can be cause by too high of a timeframe along with too high of a lookback, Lowering either will resolve these issues.", group = "[General Settings]") tf = input.timeframe("", title = "Timeframe", tooltip = "Only Use Higher Timeframes than the Current Chart. \nUsing a Lower Timeframe than your Chart's Timeframe is likely to produce Inaccurate Data!\n\nTip: It is reccomended to only input timeframes that are multiples of your current chart's timeframe so that the line origins align with the bars.", group = "[General Settings]") open_color = input.color(color.orange, title = "Open", inline = "o_1", group = "[Line Display Settings]     Color | Style | Width") open_style = input.string(". . .", title = "", options = ["___","- - -",". . ."], group = "[Line Display Settings]     Color | Style | Width", inline = "o_1") open_thickness = input.int(1, minval = 1, title = "", group = "[Line Display Settings]     Color | Style | Width", inline = "o_1") high_color = input.color(color.green, title = "High ", inline = "h_1", group = "[Line Display Settings]     Color | Style | Width") high_style = input.string("- - -", title = "", options = ["___","- - -",". . ."], group = "[Line Display Settings]     Color | Style | Width", inline = "h_1") high_thickness = input.int(1, minval = 1, title = "", group = "[Line Display Settings]     Color | Style | Width", inline = "h_1") low_color = input.color(color.red, title = "Low  ", inline = "l_1", group = "[Line Display Settings]     Color | Style | Width") low_style = input.string("- - -", title = "", options = ["___","- - -",". . ."], group = "[Line Display Settings]     Color | Style | Width", inline = "l_1") low_thickness = input.int(1, minval = 1, title = "", group = "[Line Display Settings]     Color | Style | Width", inline = "l_1") close_color = input.color(color.aqua, title = "Close", inline = "c_1", group = "[Line Display Settings]     Color | Style | Width") close_style = input.string(". . .", title = "", options = ["___","- - -",". . ."], group = "[Line Display Settings]     Color | Style | Width", inline = "c_1") close_thickness = input.int(1, minval = 1, title = "", group = "[Line Display Settings]     Color | Style | Width", inline = "c_1") //Pulling OHLC Data for the Timeframe Requested [o,h,l,c] = request.security("", tf, [open[lb],high[lb],low[lb],close[lb]], lookahead = barmerge.lookahead_on) //Plotting OHLC Values ONLY for display on the price scale plot(o, title = "Open", display = display.price_scale, color = open_color, editable = false) plot(h, title = "High", display = display.price_scale, color = high_color, editable = false) plot(l, title = "Low", display = display.price_scale, color = low_color, editable = false) plot(c, title = "Close", display = display.price_scale, color = close_color, editable = false) // This is done, because using the "trackprice" feature draws the line extending to the left AND right, we only want the line going to the right. //Finding where the lines should start from. origin_bar = ta.valuewhen(timeframe.change(tf),bar_index,lb) // This is for when a user uses data from a higher timeframe, this will locate the place on the chart where that bar started. //Note: It is impossible for this value to be perfectly on the bar the candle started if the HTF requested is not perfect a multiple of the current chart's timeframe. // ex. looking at a 3 min, requesting a 15 min IDEAL, 15/3 = 5 // ex. looking at a 3 min, requesting a 10 min NOT IDEAL, 10/3 = 3.3..., The OHLC Values will always be accurate, regardless of this factor. This is meerly visual. //LineStyle Function to translate user inputs into proper line style format. linestyle(_input) => _input == "___"?line.style_solid: _input == "- - -"?line.style_dashed: _input == ". . ."?line.style_dotted: na //Initial Creation of the Lines var open_line = line.new(origin_bar,o, bar_index+1,o, extend = extend.right, style = linestyle(open_style), color = open_color, width = open_thickness) var high_line = line.new(origin_bar,h, bar_index+1,h, extend = extend.right, style = linestyle(high_style), color = high_color, width = high_thickness) var low_line = line.new(origin_bar,l, bar_index+1,l, extend = extend.right, style = linestyle(low_style), color = low_color, width = low_thickness) var close_line = line.new(origin_bar,c, bar_index+1,c, extend = extend.right, style = linestyle(close_style), color = close_color, width = close_thickness) //Updating the Open Line Values line.set_xy1(open_line,origin_bar,o) line.set_xy2(open_line,bar_index+1,o) //Updating the High Line Values line.set_xy1(high_line,origin_bar,h) line.set_xy2(high_line,bar_index+1,h) //Updating the Low Line Values line.set_xy1(low_line,origin_bar,l) line.set_xy2(low_line,bar_index+1,l) //Updating the Close Line Values line.set_xy1(close_line,origin_bar,c) line.set_xy2(close_line,bar_index+1,c)
3 indicators in another time frame
https://www.tradingview.com/script/OM2QTbmq-3-indicators-in-another-time-frame/
AryaNirooRadAsa
https://www.tradingview.com/u/AryaNirooRadAsa/
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/ // © aryaniroo //@version=5 indicator(" 3 indicators in another time frame " , overlay= true ,max_boxes_count=20,max_bars_back=500 ) timferm=input.string("15",title=" tim pivot " ) timfermici=input.string("15",title=" tim ichimoku " ) BARINDEX= bar_index TIMBOLINGER= input.string("15", title="tim bollinger ") [open1D, high1D, low1D, close1D,volume1D,ohlc41D,hlc31D,hl21D] = request.security(syminfo.tickerid,timferm, [open, high, low, close,volume,ohlc4,hlc3,hl2]) // plotcandle( open1D, high1D, low1D, close1D,title='kandel', color = close1D > open1D ? color.green : color.red, // wickcolor=color.rgb(83, 78, 83) , display= display.all) /////////// اوردر بلوک /////// sens = input.int(28, minval=1, title='Pivot precision adjustment', group='Order Block') sens /= 100 //OB Colors col_bullish = input.color(#a7b3b0, title="Bullish OB Border", inline="a", group="Order Block") col_bullish_ob = input.color(color.new(#a9c2bc, 85), title="Background", inline="a", group="Order Block") col_bearish = input.color(#9c6c6c, title="Bearish OB Border", inline="b", group="Order Block") col_bearish_ob = input.color(color.new(#8d7070, 85), title="Background", inline="b", group="Order Block") // Alerts buy_alert = input.bool(title='Buy Signal', defval=true, group='Alerts', tooltip='An alert will be sent when price goes below the top of a bullish order block.') sell_alert = input.bool(title='Sell Signal', defval=true, group='Alerts', tooltip='An alert will be sent when price goes above the bottom of a bearish order block.') ONICHIMOCO=input.bool(title='ایچیموکو ', defval=true) BOXOIVOT()=> bool ob_created = false bool ob_created_bull = false var int cross_index = na var box drawlongBox = na var longBoxes = array.new_box() var box drawShortBox = na var shortBoxes = array.new_box() pc = (open1D - open1D[3]) / open1D[3] * 100 if ta.crossunder(pc, -sens) ob_created := true cross_index := BARINDEX cross_index if ta.crossover(pc, sens) ob_created_bull := true cross_index := BARINDEX cross_index if ob_created and cross_index - cross_index[1] > 5 float last_green = 0 float highest = 0 for i = 4 to 15 by 1 if close1D[i] > open1D[i] last_green := i break drawShortBox := box.new(left=BARINDEX[last_green], top=high1D[last_green], bottom=low1D[last_green], right=BARINDEX[last_green], bgcolor=col_bearish_ob, border_color=col_bearish, extend=extend.right) array.push(shortBoxes, drawShortBox) if ob_created_bull and cross_index - cross_index[1] > 5 float last_red = 0 float highest = 0 for i = 4 to 15 by 1 if close1D[i] < open1D[i] last_red := i break drawlongBox := box.new(left=BARINDEX[last_red], top=high1D[last_red], bottom=low1D[last_red], right=BARINDEX[last_red], bgcolor=col_bullish_ob, border_color=col_bullish, extend=extend.right) array.push(longBoxes, drawlongBox) [shortBoxes,longBoxes] [shortBoxes,longBoxes]=BOXOIVOT() // ----------------- Bearish Order Block ------------------- // Clean up OB boxes and place alerts if array.size(shortBoxes) > 0 for i = array.size(shortBoxes) - 1 to 0 by 1 sbox = array.get(shortBoxes, i) top = box.get_top(sbox) bot = box.get_bottom(sbox) // If the two last closes are above the high of the bearish OB - Remove the OB if close1D[1] > top and close1D[2] > top array.remove(shortBoxes, i) box.delete(sbox) // Alerts if high1D > bot and sell_alert alert('قیمت در حمایت ', alert.freq_once_per_bar) // ----------------- Bullish Clean Up ------------------- // Clean up OB boxes and place alerts if array.size(longBoxes) > 0 for i = array.size(longBoxes) - 1 to 0 by 1 sbox = array.get(longBoxes, i) bot = box.get_bottom(sbox) top = box.get_top(sbox) // If the two last closes are below the low of the bullish OB - Remove the OB if close1D[1] < bot and close1D[2] < bot array.remove(longBoxes, i) box.delete(sbox) // Alerts if low1D < top and buy_alert alert('قیمت در مقاومت', alert.freq_once_per_bar) ////////////////قسمت دوم قیمت کندل ایچیموکو ////////////// conversionPeriodsICH = input.int(9, minval=1, title="Conversion Line Length") basePeriodsICH = input.int(26, minval=1, title="Base Line Length") laggingSpan2PeriodsICH = input.int(52, minval=1, title="Leading Span B Length") displacementICH = input.int(26, minval=1, title="Displacement") [openICH, highICH, lowICH, closeICH,volumeICH,ohlc4ICH,hlc3ICH,hl2ICH] = request.security(syminfo.tickerid,timferm, [open, high, low, close,volume,ohlc4,hlc3,hl2]) Ichi ()=> conversionLine = math.avg(ta.lowest(conversionPeriodsICH), ta.highest(conversionPeriodsICH)) baseLine = math.avg(ta.lowest(basePeriodsICH), ta.highest(basePeriodsICH)) leadLine1 = math.avg(conversionLine, baseLine) leadLine2 = math.avg(ta.lowest(laggingSpan2PeriodsICH), ta.highest(laggingSpan2PeriodsICH)) [conversionLine,baseLine,leadLine1,leadLine2] [conversionLineICH,baseLineICH,leadLine1ICH,leadLine2ICH]=request.security("",timfermici,Ichi () ) baseLlineICH = math.avg(ta.lowest(conversionPeriodsICH), ta.highest(conversionPeriodsICH)) p1ichi = plot(leadLine1ICH, offset = displacementICH - 1,color=#0aec11) p2ichi = plot(leadLine2ICH, offset = displacementICH - 1, color=#700606) fill(p1ichi, p2ichi, color = leadLine1ICH > leadLine2ICH ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90)) ////////////////////باند بولینگر تایم جدا گانه /////////////// length = input.int(20, minval=1) src = input(close, title="Source") mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev") BOLINGERTIM()=> basis = ta.sma(src, length) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev [basis,upper,lower] [basis,upper,lower]=request.security("",TIMBOLINGER,BOLINGERTIM() ) offset = input.int(0, "Offset", minval = -500, maxval = 500) plot(basis, "Basis", color=#FF6D00, offset = offset) p1bb = plot(upper, "Upper", color=#b68c64, offset = offset) p2bb = plot(lower, "Lower", color=#b68c64, offset = offset) // fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
Monthly Returns
https://www.tradingview.com/script/nfQRnX2G-Monthly-Returns/
iravan
https://www.tradingview.com/u/iravan/
107
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © iravan //@version=5 indicator("Monthly Returns", max_boxes_count=500) var matched = timeframe.ismonthly and timeframe.multiplier == 1 var lbl = label.new(na, na, "Please change timeframe to 1M", color=color.yellow, style=label.style_label_center) if not matched and barstate.islast label.set_xy(lbl, bar_index - 10, close) var start_year = year var years = year(timenow) - start_year + 1 var returns = matrix.new<float>(13, years) matrix.set(returns, month(time_close) - 1, year(time_close) - start_year, (close - close[1])/math.abs(close[1])*100) if month(time_close) == 12 matrix.set(returns, 12, year(time_close) - start_year, (close - close[12])/math.abs(close[12])*100) var width = 12 var height = 10 var box_count = 0 var months = array.from("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") if barstate.islast and matched month_max = array.new<float>() month_min = array.new<float>() month_avg = array.new<float>() month_std_dev = array.new<float>() for i = 0 to 11 month_row = matrix.row(returns, i) array.push(month_max, array.max(month_row)) array.push(month_min, array.min(month_row)) array.push(month_avg, array.avg(month_row)) array.push(month_std_dev, array.stdev(month_row)) max = array.max(month_max) min = array.min(month_min) year_row = matrix.row(returns, 12) year_max = array.max(year_row) year_min = array.min(year_row) year_avg = array.avg(year_row) year_std_dev = array.stdev(year_row) for c = years - 1 to 0 for r = 0 to 11 _left = last_bar_index - (years - c - 1) * width - month(time_close) + 1 left = _left < 0 ? 0 : _left right = left + (c == 0 ? width - month[last_bar_index] + 1: width) val = matrix.get(returns, r, c) val_str = na(val) ? "": (str.tostring(val, "0.00") + "%") bgcolor = val >= 0? color.from_gradient(val, 0, max, color.gray, color.green): color.from_gradient(val, min, 0, color.red, color.gray) if (c == years - 1) box.new(_left + width, (12 - r + 1) * height, right + width, (12 - r) * height, text=array.get(months, r), border_width=0, bgcolor=color.from_gradient(r % 2, 0, 1, color.blue, color.new(color.blue, 20)), text_color=color.white, text_size=size.normal) box_count := box_count + 1 if r == 0 box.new(_left + 2 * width, (12 - r + 2) * height, right + 2 * width, (12 - r + 1) * height, text="Max", border_width=0, bgcolor=color.new(color.blue, 20), text_color=color.white, text_size=size.normal) box.new(_left + 3 * width, (12 - r + 2) * height, right + 3 * width, (12 - r + 1) * height, text="Min", border_width=0, bgcolor=color.blue, text_color=color.white, text_size=size.normal) box.new(_left + 4 * width, (12 - r + 2) * height, right + 4 * width, (12 - r + 1) * height, text="Avg", border_width=0, bgcolor=color.new(color.blue, 20), text_color=color.white, text_size=size.normal) box.new(_left + 5 * width, (12 - r + 2) * height, right + 5 * width, (12 - r + 1) * height, text="Std Dev", border_width=0, bgcolor=color.blue, text_color=color.white, text_size=size.normal) box_count := box_count + 4 if r == 11 box.new(_left + width, (12 - r) * height, right + width, (12 - r - 1) * height, text="Year", border_width=0, bgcolor=color.rgb(45, 69, 122), text_color=color.white, text_size=size.normal) box_count := box_count + 1 if not na(year_avg) box.new(_left + 2 * width, (12 - r) * height, right + 2 * width, (12 - r - 1) * height, text=str.tostring(year_max, "0.00") + "%", border_width=0, bgcolor=color.from_gradient(year_max, year_min, year_max, color.purple, color.blue), text_color=color.white, text_size=size.normal) box.new(_left + 3 * width, (12 - r) * height, right + 3 * width, (12 - r - 1) * height, text=str.tostring(year_min, "0.00") + "%", border_width=0, bgcolor=color.from_gradient(year_min, year_min, year_max, color.purple, color.blue), text_color=color.white, text_size=size.normal) box.new(_left + 4 * width, (12 - r) * height, right + 4 * width, (12 - r - 1) * height, text=str.tostring(year_avg, "0.00") + "%", border_width=0, bgcolor=color.from_gradient(year_avg, year_min, year_max, color.purple, color.blue), text_color=color.white, text_size=size.normal) box.new(_left + 5 * width, (12 - r) * height, right + 5 * width, (12 - r - 1) * height, text=str.tostring(year_std_dev, "0.00"), border_width=0, bgcolor=color.from_gradient(year_std_dev, year_min, year_max, color.purple, color.blue), text_color=color.white, text_size=size.normal) box_count := box_count + 4 monthly_max = array.get(month_max, r) monthly_min = array.get(month_min, r) monthly_avg = array.get(month_avg, r) monthly_std_dev = array.get(month_std_dev, r) if not na(monthly_avg) box.new(_left + 2 * width, (12 - r + 1) * height, right + 2 * width, (12 - r) * height, text=str.tostring(monthly_max, "0.00") + "%", border_width=0, bgcolor=color.from_gradient(monthly_max, array.min(month_max), array.max(month_max), color.gray, color.green), text_color=color.black, text_size=size.normal) box.new(_left + 3 * width, (12 - r + 1) * height, right + 3 * width, (12 - r) * height, text=str.tostring(monthly_min, "0.00") + "%", border_width=0, bgcolor=color.from_gradient(monthly_min, array.min(month_min), array.max(month_min), color.rgb(175, 75, 75), color.gray), text_color=color.black, text_size=size.normal) box.new(_left + 4 * width, (12 - r + 1) * height, right + 4 * width, (12 - r) * height, text=str.tostring(monthly_avg, "0.00") + "%", border_width=0, bgcolor=color.from_gradient(monthly_avg, array.min(month_avg), array.max(month_avg), color.rgb(175, 100, 100), color.green), text_color=color.black, text_size=size.normal) box.new(_left + 5 * width, (12 - r + 1) * height, right + 5 * width, (12 - r) * height, text=str.tostring(monthly_std_dev, "0.00"), border_width=0, bgcolor=color.from_gradient(monthly_std_dev, array.min(month_std_dev), array.max(month_std_dev), color.gray, color.silver), text_color=color.black, text_size=size.normal) box_count := box_count + 4 if (box_count <= 500) box.new(left, (12 - r + 1) * height, right, (12 - r) * height, text=val_str, border_width=0, bgcolor=bgcolor, text_color=color.black, text_size=size.normal) box_count := box_count + 1 if val == max label.new(right - 1, (12 - r + 1) * height - 4, "*", style=label.style_text_outline, size=size.normal, textcolor=color.white) else if val == min label.new(right - 1, (12 - r + 1) * height - 4, "*", style=label.style_text_outline, size=size.normal, textcolor=color.white) if r == 0 and box_count <= 500 box.new(left, (12 - r + 2) * height, right, (12 - r + 1) * height, text=str.tostring(year(timenow) - (years - 1 - c)), border_width=0, bgcolor=color.new(color.blue, c%2==0?20:0), text_color=color.white, text_size=size.normal) box_count := box_count + 1 if r == 11 and box_count <= 500 y_val = matrix.get(returns, 12, c) y_val_str = na(y_val) ? "": (str.tostring(y_val, "0.00") + "%") box.new(left, (12 - r) * height, right, (12 - r - 1) * height, text=y_val_str, border_width=0, bgcolor=color.from_gradient(y_val, year_min, year_max, color.purple, color.blue), text_color=color.white, text_size=size.normal) box_count := box_count + 1
Renko Emulator - Rev NR - Released - 12-29-22
https://www.tradingview.com/script/OLiAjGGm-Renko-Emulator-Rev-NR-Released-12-29-22/
hockeydude84
https://www.tradingview.com/u/hockeydude84/
56
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © hockeydude84 //@version=5 indicator("Renko Emulator - Rev NR - Released - 12-29-22", overlay=true) //Renko Emulator - Rev NR - Released 12-29-22 //By Hockeydude84 //Emulates Renko behavior on a standard candle stick chart. Proides "brick" options and inhibiting, with various plotting options. //inputs for emulator var emulator = "Renko Emulator Settings" var emulatorInputs = "Renko Emulator Inputs" var emulatorPlots = "Emulator Plot Settings" sourceBrick = input(close, "Brick Source (Default is Close)", group = emulator) brickType =input(true, "Choose Brick Size - Default (True) is Standard Bricks; False is ATR", group = emulator) atrInhib = input(false, "For ATR Emulator Settings - Use 'Standard Brick Size (in Percent)' as an Inhibitor", group = emulator) standardBrick = input.float(1, "Standard Brick Size (In Percent)", minval=0, step=0.1, maxval=100, group = emulatorInputs)/100 atrLength = input.int(100, "ATR Length for Renko (Default = 100)", minval=1, step=1, group = emulatorInputs) atrMod = input.int(5, "ATR Modifier (Default = 5)", minval=1, step=1, group = emulatorInputs) useBrickPlots =input(true, "Plot Emulated Bricks", group = emulatorPlots) useFill =input(true, "Fill between Emulated Bricks", group = emulatorPlots) useSmoothingPlots = input(false, "Plot 'Smoothed' Emulated Bricks (Helpful with determining trends)", group = emulatorPlots) smoothingLength = input.int(7, "Smoothing Length", minval=1, group = emulatorPlots) //Get data for the ATR atrGet = ta.atr(atrLength) atrHigh = ta.highest(atrGet,atrLength) atrLow = ta.lowest(atrGet, atrLength) //Calculate ATR valuesand if we're doing any inhibiting atrBrick = ((atrHigh-atrLow)/sourceBrick) *atrMod atrBrickInhib = atrBrick > standardBrick ? atrBrick : standardBrick atrBrickFinal = atrInhib==false ? atrBrick : atrBrickInhib brick = brickType == true ? standardBrick : atrBrickFinal //initialize variables for emulated Renko Blocks/sections.... whatever we're gonna call them float baseValue = sourceBrick var updateBase = 1 //determine base (center) and upper/lower extremes baseValue := updateBase==1 ? sourceBrick : baseValue[1] brickUpper = baseValue*(1+brick) brickLower = baseValue*(1-brick) //determine if candle values put us above/below limits, and update if we break range calculateUpper = sourceBrick > brickUpper ? 1 : 0 calculateLower = sourceBrick < brickLower ? -1 : 0 updateBase := calculateUpper==1 or calculateLower==-1 ? 1 : 0 //Generate Moving Averages to help define trend baseMA= ta.vwma(baseValue, smoothingLength) upperMA = ta.vwma(brickUpper, smoothingLength) lowerMA = ta.vwma(brickLower, smoothingLength) //Plot our emulated renko plots plot(useBrickPlots == true ? baseValue : na, color=color.aqua, linewidth=1) plot(useBrickPlots == true and useFill==false ? brickUpper : na, color=color.lime, linewidth=1) plot(useBrickPlots == true and useFill==false ? brickLower : na, color=color.fuchsia, linewidth=1) U = plot(useBrickPlots == true and useFill==true ? brickUpper : na, color=color.black, linewidth=1) L = plot(useBrickPlots == true and useFill==true ? brickLower : na, color=color.black, linewidth=1) //fill plotting for emulated bricks var getFillColor = 0 getFillColor := baseValue > baseValue[1] ? 1 : baseValue < baseValue[1] ? -1 : getFillColor[1] fillColor = getFillColor == 1 ? color.lime : getFillColor ==-1 ? color.fuchsia : color.orange //theres probably a cleaner way to perform this with the [1] and colors, but I dont know it and I'm lazy fill(U, L, color=fillColor) //plot smoothed versions of emulator plots plot(useSmoothingPlots == true ? baseMA : na, color=color.blue, linewidth=2) plot(useSmoothingPlots == true ? upperMA : na, color=color.green, linewidth=2) plot(useSmoothingPlots == true ? lowerMA : na, color=color.red, linewidth=2) //EOF - Done baby :P
Support Resistance - Dynamic v2 w/ Timeframe option
https://www.tradingview.com/script/p3KRhhoQ-Support-Resistance-Dynamic-v2-w-Timeframe-option/
PtGambler
https://www.tradingview.com/u/PtGambler/
812
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © platsn // I take no credit for this, but I think this modification is very useful when using this script created by © LonesomeTheBlue // Copied directly from © LonesomeTheBlue's Support Resistance - Dynamic v2 code but with modification to allow option // to choose different timeframe to calculate S/R levels. // Very often, we don't want to use S/R levels on the same timeframe that we are trading at. ie. if trading at 5min, we often use 15min, 30min or 1hr timeframe to define // our S/R levels. //@version=5 indicator('[Pt] Support Resistance - Dynamic v2 w/ Timeframe option', '[Pt]SRv2 - custom tf', overlay=true) tf = input.timeframe('D', "Timeframe", group='Setup', tooltip = 'Please note that if a higher timeframe chosen is "too far" from the chart timeframe, the S/R may not necessaryily match to that of the S/R generated if they were created at that higher timeframe.') // option to choose which timeframe to calculate S/R levels prd = input.int(defval=10, title='Pivot Period', minval=1, group='Setup', tooltip = 'With respect to higher timeframe') ppsrc = input.string(defval='High/Low', title='Source', options=['High/Low', 'Close/Open'], group='Setup') maxnumpp = input.int(defval=100, title=' Maximum Number of Pivot', minval=5, 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='Display', tooltip='Positive numbers reference future bars, negative numbers reference histical bars') labelloc2 = input.int(defval=-100, title='TF Label Location', group='Display', tooltip='Positive numbers reference future bars, negative numbers reference histical bars') linestyle = input.string(defval='Dashed', title='Line Style', options=['Solid', 'Dotted', 'Dashed'], group='Display') linewidth = input.int(defval=2, title='Line Width', minval=1, maxval=4, group='Display') resistancecolor = input.color(defval=color.red, title='Resistance Color', group='Display', inline = 'resist') resist_lbl_col = input.color(defval = color.red, title='', group = 'Display', inline = 'resist') resist_lbl_text_col = input.color(defval = color.white, title='', group = 'Display', inline = 'resist') supportcolor = input.color(defval=color.lime, title='Support Color', group='Display', inline = 'supp') supp_lbl_col = input.color(defval = color.lime, title='', group = 'Display', inline = 'supp') supp_lbl_text_col = input.color(defval = color.black, title='', group = 'Display', inline = 'supp') showpp = input.bool(false, title='Show Pivot Points', group='Display') showtf = input.bool(true, title = 'Show Timeframe label', group='Display') showloc = input.bool(true, title = 'Show Price level', group='Display') // get data on ticker based on chosen timeframe src_h = request.security(syminfo.tickerid,tf,high, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off) src_l = request.security(syminfo.tickerid,tf,low, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off) src_c = request.security(syminfo.tickerid,tf,close, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off) src_o = request.security(syminfo.tickerid,tf,open, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off) 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) _resInMinutes f_tfResInMinutes(_res) => request.security(syminfo.tickerid, _res, f_resInMinutes()) f_tfIsIntraday(_res) => [intraday, daily, weekly, monthly] = request.security(syminfo.tickerid, _res, [timeframe.isintraday, timeframe.isdaily, timeframe.isweekly, timeframe.ismonthly]) check = intraday ? "Intraday" : daily ? "Daily" : weekly ? "Weekly" : monthly ? "Monthly" : "Error" check mtf_multiplier = int (f_tfResInMinutes(tf) / f_resInMinutes()) prd := prd * mtf_multiplier float src1 = ppsrc == 'High/Low' ? src_h : math.max(src_c, src_o) float src2 = ppsrc == 'High/Low' ? src_l : math.min(src_c, src_o) float src3 = ppsrc == 'High/Low' ? high : math.max(close, open) float src4 = ppsrc == 'High/Low' ? low : math.min(close, open) float ph = ta.pivothigh(src1, prd, prd) float pl = ta.pivotlow(src2, prd, prd) float ph_chart = ta.pivothigh(src3, prd, prd) float pl_chart = ta.pivotlow(src4, prd, prd) plotshape(ph_chart and showpp, text = "H", style = shape.labeldown, color = na, textcolor = color.red, location = location.abovebar, offset = -prd) plotshape(pl_chart and showpp, text = "L", style = shape.labelup, color = na, textcolor = color.lime, location = location.belowbar, offset = -prd) Lstyle = linestyle == 'Dashed' ? line.style_dashed : linestyle == 'Solid' ? line.style_solid : line.style_dotted tf_res = f_tfIsIntraday(tf) tf_text = str.tostring(tf) if str.tostring(tf) == ""//tf is equal to chart tf_text := na(timeframe.multiplier / 60) ? timeframe.period : timeframe.multiplier < 60 ? timeframe.period + " min" : str.tostring(timeframe.multiplier / 60) + " hour" else if tf_res == "Intraday" tf_text := na(str.tonumber(tf) / 60) ? str.tostring(tf) : str.tonumber(tf) < 60 ? str.tostring(tf) + " min" : str.tostring(str.tonumber(tf) / 60) + " hour" else tf_text := str.tostring(tf) //calculate maximum S/R channel zone width prdhighest = request.security(syminfo.tickerid, tf, ta.highest(300)) prdlowest = request.security(syminfo.tickerid, tf, 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) var tf_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 ? resist_lbl_col : supp_lbl_col) label.set_textcolor(array.get(sr_labels, x), textcolor=label.get_y(array.get(sr_labels, x)) >= close ? resist_lbl_text_col : supp_lbl_text_col) 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) label.set_text(array.get(tf_labels, x), text=tf_text) label.set_x(array.get(tf_labels, x), x=bar_index + labelloc2) label.set_color(array.get(tf_labels, x), color=label.get_y(array.get(tf_labels, x)) >= close ? resist_lbl_col : supp_lbl_col) label.set_textcolor(array.get(tf_labels, x), textcolor=label.get_y(array.get(tf_labels, x)) >= close ? resist_lbl_text_col : supp_lbl_text_col) label.set_style(array.get(tf_labels, x), style=label.get_y(array.get(tf_labels, x)) >= close ? label.style_label_down : label.style_label_up) 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)) label.delete(array.get(tf_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 if showloc 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)) if showtf array.set(tf_labels, x + 1, label.new(x=bar_index + labelloc2, y=mid, text=tf_text, 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')
RSI Candle Advanced V2
https://www.tradingview.com/script/kvP8BO4N-RSI-Candle-Advanced-V2/
Dicargo_Beam
https://www.tradingview.com/u/Dicargo_Beam/
145
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Dicargo_Beam //@version=5 indicator('RSI Candle Advanced V2') src = close description = input.bool(false, "description about 'RSI Advanced'", tooltip = "Period below 14 reduce the volatility of RSI , and period above 14 increase the volatility of RSI, allowing overbought and oversold zones to work properly and give you a better view of the trend.\n\nby applying the custom algorithm so that the 'RSI Advanced' with period[ 168 (=14*12) ] on a 5-minute timeframe has the same value as the 'original RSI' with period[ 14 ] on a 60-minute timeframe.\n\nAs another example, an 'RSI Advanced' with a period[ 56 (=14*4) ] in a 60-minute time frame has the same value as an 'original RSI' with a period[ 14 ] in a 240-minute time frame.") // fixed_security(_sym, _res, _src) => // request.security(_sym, _res, _src[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1] // another_timeframe_rsilen = input.int(14,"another_timeframe RSI Length") // another_timeframe = input.timeframe("60", "another_timeframe") // another_timeframe_rsi = fixed_security(syminfo.tickerid, another_timeframe, ta.rsi(close,another_timeframe_rsilen)) // plot(another_timeframe_rsi[1] != another_timeframe_rsi? another_timeframe_rsi:na) len = input(14, 'RSI Length') ad = input(true, 'RSI Advanced ?? (Recommend)') cdob = input.string('Candle', title='Candle or Bar or Line?', options=['Candle', 'Bar', 'Line']) uc = input(color.green, 'Up Color') dc = input(color.red, 'Down Color') u = math.max(src - src[1], 0) d = math.max(src[1] - src, 0) ru = ta.rma(u, len) rd = ta.rma(d, len) a = 1 / len ruh = a * math.max(high - close[1], 0) + (1 - a) * ta.rma(u, len)[1] rdh = a * math.max(close[1] - high, 0) + (1 - a) * ta.rma(d, len)[1] rul = a * math.max(low - close[1], 0) + (1 - a) * ta.rma(u, len)[1] rdl = a * math.max(close[1] - low, 0) + (1 - a) * ta.rma(d, len)[1] ruo = a * math.max(open - close[1], 0) + (1 - a) * ta.rma(u, len)[1] rdo = a * math.max(close[1] - open, 0) + (1 - a) * ta.rma(d, len)[1] function(rsi, len) => f = -math.pow(math.abs(math.abs(rsi - 50) - 50), 1 + math.pow(len / 14, 0.618) - 1) / math.pow(50, math.pow(len / 14, 0.618) - 1) + 50 rsiadvanced = if rsi > 50 f + 50 else -f + 50 rsiadvanced rsiha = 100 - 100 / (1 + ruh / rdh) rsila = 100 - 100 / (1 + rul / rdl) rsia = 100 - 100 / (1 + ru / rd) rsioa = 100 - 100 / (1 + ruo / rdo) rsih = if ad function(rsiha, len) else rsiha rsil = if ad function(rsila, len) else rsila rsi = if ad function(rsia, len) else rsia rsio = if ad function(rsioa, len) else rsioa col = open<close ? uc : dc colc = if cdob == 'Candle' col colb = if cdob == 'Bar' col cold = if cdob == 'Line' col plotcandle(rsio, rsih, rsil, rsi, color=colc, wickcolor=colc, bordercolor=colc) plotbar(rsio, rsih, rsil, rsi, color=colb) plot(rsi, color=cold) hline(50, 'Balance', linestyle = hline.style_dotted) h1 = hline(70, 'Overbought', linestyle = hline.style_dotted) h2 = hline(30, 'Oversold', linestyle = hline.style_dotted) fill(h1, h2, color=color.new(#643779, 87)) bblen = input.int(20,"RSI BB Length") bbplot = input.bool(false,"RSI BB display?") [bbm, bbu, bbl] = ta.bb(rsi, bblen, 2) plot(bbplot?bbm:na,'Middle line', color=color.blue) plot(bbplot?bbu:na,"Upper BB", color=color.rgb(0, 162, 255)) plot(bbplot?bbl:na,'Lower BB', color=color.rgb(0, 162, 255)) emalen1 = input.int(20,"EMA 1 Length") emalen2 = input.int(50,"EMA 2 Length") emaplot = input.bool(false,"RSI EMA display?") ema1 = ta.ema(rsi, emalen1) ema2 = ta.ema(rsi, emalen2) plot(emaplot?ema1:na,"EMA 1", color=color.rgb(255, 230, 0)) plot(emaplot?ema2:na,"EMA 2", color=color.rgb(68, 196, 255))
Z-Score Buy and Sell Signals
https://www.tradingview.com/script/hp7oxjcQ-Z-Score-Buy-and-Sell-Signals/
Steversteves
https://www.tradingview.com/u/Steversteves/
271
study
5
MPL-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("Z-Score Buy and Sell Signals", overlay=true, max_labels_count = 500) lengthInput = input.int(75, "Length", minval = 2) // Calculating High Z Score a = ta.sma(close, lengthInput) b = ta.stdev(close, lengthInput) c = (close - a) / b // Highest and Lowest highz = ta.highest(c, lengthInput) lowz = ta.lowest(c, lengthInput) // Condition Alerts var wait = 0 wait := wait + 1 if (c <= lowz) and (wait > 30) wait := 10 label.new(x=bar_index, y=high, text="Buy", size = size.tiny, color=color.green) alert("Buy The Dip "+syminfo.ticker, alert.freq_once_per_bar) if (c >= highz) and (wait > 30) wait := 10 label.new(x=bar_index, y=high, text="Sell", size = size.tiny, color=color.red) alert("Sell The Rally "+syminfo.ticker, alert.freq_once_per_bar) // Colors color bear = color.new(color.orange, 0) color bull = color.new(color.lime, 0) bool overbought = c >= 2 bool oversold = c <= -2 brcolor = overbought ? bear : oversold ? bull : na barcolor(brcolor)
Price Change Alerts
https://www.tradingview.com/script/aAOEehRd-Price-Change-Alerts/
domsito
https://www.tradingview.com/u/domsito/
63
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © domsito // To enable alerts do this: // - Click on alerts clock icon in top right corner of the screen // - Click on "Create alert button" // - In Condition dropdown select "alerts" // - In the next dropdown select "Any alert function() call" and click on "Create" button // Script uses repainting on purpose to display daily percentage changes since the previous day's closing //@version=5 indicator("Price Change Alerts", "alerts", overlay = true) max_bars_back(time, 5000) var bool showDailyChange = input.bool(true, "Show change since previous day close", group = "General") var bool showPrevDayLine = input.bool(true, "Prevous day's closing line", group = "line", inline = "0") var lineColor = input(color.blue, "", inline = "0", group = "line") var bool showPrevWeekCloseLine = input.bool(true, "Prevous week's closing line", group = "line", inline = "1") var lineColor2 = input(color.lime, "", inline = "1", group = "line") var float alertDelta = input.float(5.0, "Alert delta", 0.01, 10000, tooltip = "Alerts will be triggered only after price changes by 'delta' amount from the last alert price") var int minSeconds = input.int(60, "Minimum number of seconds between alerts", 10, 10000) varip float lastAlertValue = 0.0 varip int lastAlertTime = 0 var lbl = label.new(na, na, na, style = label.style_label_left) var lineDay = line.new(na, na, na, na, color = lineColor, style = line.style_solid, width = 2) var lineWeek = line.new(na, na, na, na, color = lineColor2, style = line.style_solid, width = 2) varip float change = 0.0 varip float changeSign = na delta(float v1, float v2) => (((v2 / v1)-1) * 100.0) var float prevDayClose = na var int bar_time_prev_day_close = 0 var int bar_time_prev_week_close = 0 var float prevWeekClose = 0 if (ta.change(dayofmonth)) prevDayClose := close[2] //previous bar close is previous day's closing price, since we just entered after hours bar_time_prev_day_close := bar_index[2] if (ta.change(weekofyear)) bar_time_prev_week_close := bar_index[2] prevWeekClose := close[2] if barstate.islast change := delta(prevDayClose, close) backColor = change < 0.0 ? color.red : color.green if showPrevDayLine line.set_x1(lineDay, bar_time_prev_day_close ) line.set_x2(lineDay, bar_index) line.set_y1(lineDay, prevDayClose) line.set_y2(lineDay, prevDayClose) if showPrevWeekCloseLine line.set_x1(lineWeek, bar_time_prev_week_close) line.set_x2(lineWeek, bar_index) line.set_y1(lineWeek, prevWeekClose) line.set_y2(lineWeek, prevWeekClose) if showDailyChange label.set_text(lbl, str.tostring(change, "0.00") + "% ") label.set_color(lbl, backColor) label.set_x(lbl, bar_index+1) label.set_y(lbl, close) if (barstate.islastconfirmedhistory) change := delta(prevDayClose, close) changeSign := math.sign(change) lastAlertValue := math.round(close / alertDelta) * alertDelta if (math.abs(close-lastAlertValue) >= alertDelta) and ((time - lastAlertTime)/1000.0 >= minSeconds) alert(syminfo.ticker + ((close-lastAlertValue) > 0 ? " UP" : " DOWN") + " to " + str.tostring(close, "0.00"), alert.freq_all) //lastAlertValue:= close lastAlertValue := math.round(close / alertDelta) * alertDelta lastAlertTime := time plot(lastAlertValue, "last alert value", display = display.data_window) plot((time - lastAlertTime)/1000.0, "Seconds since last alert", display = display.data_window)
Slope Normalizer
https://www.tradingview.com/script/fLqPoYZg-Slope-Normalizer/
Electrified
https://www.tradingview.com/u/Electrified/
360
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Electrified //@version=5 //@description This oscillator style indicator takes another indicator as its source and measures the change over time (the slope). It then isolates the positive slope values from the negative slope values to determine a 'normal' slope value for each. [i]A 'normal' value of 1.0 is determined by the sum of the average slope plus the standard deviation of that slope.[/i] indicator("Slope Normalizer") hot = color.orange, hot_line = color.new(hot, 50), hot_bg = color.new(hot, 75) cold = color.rgb(128,128,255), cold_line = color.new(cold, 50), cold_bg = color.new(cold, 75) import Electrified/Time/7 MINUTES = "Minutes", DAYS = "Days", BARS = "Bars" SOURCE = "Source", LENGTH = "Length" src = input.source(hlc3, SOURCE, "The source to measure the slope.") len = input.int(1, LENGTH, 1, tooltip = "The number of bars to measure the slope.") change = ta.change(src, len) DEVIATION = "Deviation Calculation" var mLen = Time.spanToIntLen( input.float(400, LENGTH, minval=0.5, step=0.5, inline=LENGTH, group=DEVIATION), input.string(BARS, "", options = [BARS, MINUTES, DAYS], inline=LENGTH, group=DEVIATION, tooltip = "The length of the deviation measurement.")) trim(float[] a, len) => if array.size(a) > len array.shift(a) var pos = array.new_float() var neg = array.new_float() if(change > 0) array.push(pos, change) trim(pos, mLen) if(change < 0) array.push(neg, change) trim(neg, mLen) type Levels float level1 float level2 float stdev // reamaining should scale linearly. getLevels(float[] values) => avg = math.abs(array.avg(values)) stdev = array.stdev(values) level1 = avg + stdev level2 = level1 + stdev Levels.new(level1, level2, stdev) posLevels = getLevels(pos) negLevels = getLevels(neg) normalized = if change > 0 if(change < posLevels.level1) change / posLevels.level1 else (change - posLevels.level1) / posLevels.stdev + 1 else if change < 0 if(change > -negLevels.level1) change / negLevels.level1 else (change + negLevels.level1) / negLevels.stdev - 1 else 0 plot(normalized, "Slope Normalized", color.white, 2) plot(normalized > 0 ? normalized : 0, "Slope Normalized, Positive", hot_line, 0, style = plot.style_area, display = display.pane) plot(normalized < 0 ? normalized : 0, "Slope Normalized, Negative", cold_line, 0, style = plot.style_area, display = display.pane) bgcolor(normalized> 0 ? hot_bg : cold_bg, title = "Up/Down Highlight") hline(+4, "+4", hot_line, display = display.none) hline(+3, "+3", hot_line) hline(+2, "+2", hot_line) hline(+1, "+1", hot_line) hline(0, "0") hline(-1, "-1", cold_line) hline(-2, "-2", cold_line) hline(-3, "-3", cold_line) hline(-4, "-4", cold_line, display = display.none)
Sinusoidal High Pass Filter (SHPF)
https://www.tradingview.com/script/LR8QV2Tp-Sinusoidal-High-Pass-Filter-SHPF/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
17
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © peacefulLizard50262 //@version=5 indicator("Sinusoidal High Pass Filter") sinusoidal_hpf(_series, _period, _phase_shift) => ma = 0.0 for i = 0 to _period - 1 weight = math.sin(i * 2 * math.pi / _period + _phase_shift * math.pi / 180) ma := ma + weight * _series[i] ma / _period source = input.source(close, "Source") length = input.int(10, "Length", 1) shift = input.float(90, "Phase Shift", 0, 360, 0.5) plot(0, "0", color.silver) plot(sinusoidal_hpf(source, length, shift), "Sinusoidal High Pass Filter", color.new(color.purple, 10))
The Price of Hard Money
https://www.tradingview.com/script/6Z1nf125-The-Price-of-Hard-Money/
capriole_charles
https://www.tradingview.com/u/capriole_charles/
84
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © capriole_charles //@version=5 indicator("The Price of Hard Money",overlay=true) output = input.string("Hard Money Price (in Gold)", options=["Hard Money Price (in Gold)", "Hard Money Price (in Bitcoin)", "Hard Money Mcap", "Gold Mcap"]) // DATA gld = request.security("TVC:GOLD",timeframe.period,close) btc = request.security("BNC:BLX",timeframe.period,close) btc_mcap = request.security("CRYPTOCAP:BTC",timeframe.period,close) // INPUTS FOR TODAY: https://www.google.com/search?q=gold+market+cap&oq=gold+market+cap today_gld_mcap = 12.127*1000000000000 today_gld_price = 1838 today = timestamp(2022, 12, 28, 00, 00) inf = 0.017 // inflation rate of gold: https://www.cmegroup.com/insights/economic-research/2022/goldsilver-the-understated-importance-of-supply.html // CALCULATE GOLD MCAP days_since_data = (time - today)/(60*60*24*1000*1440/timeframe.multiplier) units_of_gold = (today_gld_mcap/today_gld_price) * math.pow(1+inf,days_since_data/365) est_gld_mcap = units_of_gold * gld // HARD MONEY = Gold + Bitcoin hm_mcap = est_gld_mcap + btc_mcap hm_price_in_gld = hm_mcap / units_of_gold units_of_btc = btc_mcap/btc hm_price_in_btc = hm_mcap / units_of_btc plot =output=="Hard Money Mcap" ? hm_mcap : output=="Hard Money Price (in Gold)" ? hm_price_in_gld : output=="Hard Money Price (in Bitcoin)" ? hm_price_in_btc : output=="Gold Mcap" ? est_gld_mcap : na plot(plot, linewidth = 2) // Sourcing var table_source = table(na) table_source := table.new(position=position.bottom_left, columns=1, rows=1, bgcolor=color.white, border_width=1) table.cell(table_source, 0, 0, text="Source: Capriole Investments Limited", bgcolor=color.white, text_color=color.black, width=20, height=7, text_size=size.normal, text_halign=text.align_left)
Price Heat Map
https://www.tradingview.com/script/b3bqlnar-Price-Heat-Map/
Jomy
https://www.tradingview.com/u/Jomy/
191
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Jomy //@version=5 indicator("Price Heat Map",overlay=true) rng=input.int(200,"bars back",step=50,maxval=500) modifier=input.float(.5,"brightness modifier",step=.1) hh=ta.highest(high,rng) ll=ta.lowest(low,rng) chunk=(hh-ll)/20 level=0.0 count1=0.0 count2=0.0 count3=0.0 count4=0.0 count5=0.0 count6=0.0 count7=0.0 count8=0.0 count9=0.0 count10=0.0 count11=0.0 count12=0.0 count13=0.0 count14=0.0 count15=0.0 count16=0.0 count17=0.0 count18=0.0 count19=0.0 count20=0.0 for j = 1 to rng count1 := low[j] <= (ll+(chunk*1)) and high[j] >= (ll+(chunk*0))? count1 + 1 : count1 count2 := low[j] <= (ll+(chunk*2)) and high[j] >= (ll+(chunk*1))? count2 + 1: count2 count3 := low[j] <= (ll+(chunk*3)) and high[j] >= (ll+(chunk*2))? count3 + 1 : count3 count4 := low[j] <= (ll+(chunk*4)) and high[j] >= (ll+(chunk*3))? count4 + 1 : count4 count5 := low[j] <= (ll+(chunk*5)) and high[j] >= (ll+(chunk*4))? count5 + 1: count5 count6 := low[j] <= (ll+(chunk*6)) and high[j] >= (ll+(chunk*5))? count6 + 1: count6 count7 := low[j] <= (ll+(chunk*7)) and high[j] >= (ll+(chunk*6))? count7 + 1 : count7 count8 := low[j] <= (ll+(chunk*8)) and high[j] >= (ll+(chunk*7))? count8 + 1 : count8 count9 := low[j] <= (ll+(chunk*9)) and high[j] >= (ll+(chunk*8))? count9 + 1: count9 count10 := low[j] <= (ll+(chunk*10)) and high[j] >= (ll+(chunk*9))? count10 + 1 : count10 count11 := low[j] <= (ll+(chunk*11)) and high[j] >= (ll+(chunk*10))? count11 + 1 : count11 count12 := low[j] <= (ll+(chunk*12)) and high[j] >= (ll+(chunk*11))? count12 + 1 : count12 count13 := low[j] <= (ll+(chunk*13)) and high[j] >= (ll+(chunk*12))? count13 + 1 : count13 count14 := low[j] <= (ll+(chunk*14)) and high[j] >= (ll+(chunk*13))? count14 + 1 : count14 count15 := low[j] <= (ll+(chunk*15)) and high[j] >= (ll+(chunk*14))? count15 + 1 : count15 count16 := low[j] <= (ll+(chunk*16)) and high[j] >= (ll+(chunk*15))? count16 + 1: count16 count17 := low[j] <= (ll+(chunk*17)) and high[j] >= (ll+(chunk*16))? count17 + 1 : count17 count18 := low[j] <= (ll+(chunk*18)) and high[j] >= (ll+(chunk*17))? count18 + 1 : count18 count19 := low[j] <= (ll+(chunk*19)) and high[j] >= (ll+(chunk*18))? count19 + 1 : count19 count20 := low[j] <= (ll+(chunk*20)) and high[j] >= (ll+(chunk*19))? count20 + 1 : count20 l1=ll l2=ll+chunk*1 l3=ll+chunk*2 l4=ll+chunk*3 l5=ll+chunk*4 l6=ll+chunk*5 l7=ll+chunk*6 l8=ll+chunk*7 l9=ll+chunk*8 l10=ll+chunk*9 l11=ll+chunk*10 l12=ll+chunk*11 l13=ll+chunk*12 l14=ll+chunk*13 l15=ll+chunk*14 l16=ll+chunk*15 l17=ll+chunk*16 l18=ll+chunk*17 l19=ll+chunk*18 l20=ll+chunk*19 hz = math.max(count1,count2,count3,count4,count5,count6,count7,count8,count9,count10,count11,count12,count13,count14,count15,count16,count17,count18,count19,count20) lev=0.0 lev:= hz==count1?ll+(chunk*0.5):lev lev:= hz==count2?ll+(chunk*1.5):lev lev:= hz==count3?ll+(chunk*2.5):lev lev:= hz==count4?ll+(chunk*3.5):lev lev:= hz==count5?ll+(chunk*4.5):lev lev:= hz==count6?ll+(chunk*5.5):lev lev:= hz==count7?ll+(chunk*6.5):lev lev:= hz==count8?ll+(chunk*7.5):lev lev:= hz==count9?ll+(chunk*8.5):lev lev:= hz==count10?ll+(chunk*9.5):lev lev:= hz==count11?ll+(chunk*10.5):lev lev:= hz==count12?ll+(chunk*11.5):lev lev:= hz==count13?ll+(chunk*12.5):lev lev:= hz==count14?ll+(chunk*13.5):lev lev:= hz==count15?ll+(chunk*14.5):lev lev:= hz==count16?ll+(chunk*15.5):lev lev:= hz==count17?ll+(chunk*16.5):lev lev:= hz==count18?ll+(chunk*17.5):lev lev:= hz==count19?ll+(chunk*18.5):lev lev:= hz==count20?ll+(chunk*19.5):lev p1=plot(l1,color=color.rgb(255,255,255,100)) p2=plot(l2,color=color.rgb(0,0,0,100)) p3=plot(l3,color=color.rgb(0,0,0,100)) p4=plot(l4,color=color.rgb(0,0,0,100)) p5=plot(l5,color=color.rgb(0,0,0,100)) p6=plot(l6,color=color.rgb(0,0,0,100)) p7=plot(l7,color=color.rgb(0,0,0,100)) p8=plot(l8,color=color.rgb(0,0,0,100)) p9=plot(l9,color=color.rgb(0,0,0,100)) p10=plot(l10,color=color.rgb(0,0,0,100)) p11=plot(l11,color=color.rgb(0,0,0,100)) p12=plot(l12,color=color.rgb(0,0,0,100)) p13=plot(l13,color=color.rgb(0,0,0,100)) p14=plot(l14,color=color.rgb(0,0,0,100)) p15=plot(l15,color=color.rgb(0,0,0,100)) p16=plot(l16,color=color.rgb(0,0,0,100)) p17=plot(l17,color=color.rgb(0,0,0,100)) p18=plot(l18,color=color.rgb(0,0,0,100)) p19=plot(l19,color=color.rgb(0,0,0,100)) p20=plot(l20,color=color.rgb(255,255,255,100)) fill(p1,p2,color.rgb(255,0,0,100-count1*500/rng*modifier)) fill(p2,p3,color.rgb(255,0,0,100-count2*500/rng*modifier)) fill(p3,p4,color.rgb(255,0,0,100-count3*500/rng*modifier)) fill(p4,p5,color.rgb(255,0,0,100-count4*500/rng*modifier)) fill(p5,p6,color.rgb(255,0,0,100-count5*500/rng*modifier)) fill(p6,p7,color.rgb(255,0,0,100-count6*500/rng*modifier)) fill(p7,p8,color.rgb(255,0,0,100-count7*500/rng*modifier)) fill(p8,p9,color.rgb(255,0,0,100-count8*500/rng*modifier)) fill(p9,p10,color.rgb(255,0,0,100-count9*500/rng*modifier)) fill(p10,p11,color.rgb(255,0,0,100-count10*500/rng*modifier)) fill(p11,p12,color.rgb(255,0,0,100-count11*500/rng*modifier)) fill(p12,p13,color.rgb(255,0,0,100-count12*500/rng*modifier)) fill(p13,p14,color.rgb(255,0,0,100-count13*500/rng*modifier)) fill(p14,p15,color.rgb(255,0,0,100-count14*500/rng*modifier)) fill(p15,p16,color.rgb(255,0,0,100-count15*500/rng*modifier)) fill(p16,p17,color.rgb(255,0,0,100-count16*500/rng*modifier)) fill(p17,p18,color.rgb(255,0,0,100-count17*500/rng*modifier)) fill(p18,p19,color.rgb(255,0,0,100-count18*500/rng*modifier)) fill(p19,p20,color.rgb(255,0,0,100-count19*500/rng*modifier)) plot(lev) plot(ta.ema(close,rng),color=color.yellow)
ZigCycleBarCount [MsF]
https://www.tradingview.com/script/IvEXl5k9/
Trader_Morry
https://www.tradingview.com/u/Trader_Morry/
366
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/ // © Trader_Morry //@version=4 //////// // Title study("ZigCycleBarCount", "ZigCyclBarCnt", true, format.price, max_labels_count=51, max_lines_count=50) //////// // Input values // [ Depth = input(12, "Depth", input.integer, minval=1, step=1) Deviation = input(5, "Deviation", input.integer, minval=1, step=1) Backstep = input(3, "Backstep", input.integer, minval=2, step=1) line_thick = input(2, "Line Thickness", input.integer, minval=1, maxval=4) upcolor = input(color.aqua, "Bull Color") dncolor = input(color.red, "Bear Color") repaint = input(true, "Repaint Levels") price = input(true, "Price Values") Label_Style = input(title="Label Style", type=input.string, defval="TEXT", options=["BALLOON", "TEXT"]) // ] //////// // Hidden input values // [ // ] //////// // Making // [ var last_h = 1, last_h := last_h + 1 var last_l = 1, last_l := last_l + 1 var lw = 1, var hg = 1 lw := lw + 1, hg := hg + 1 p_lw = -lowestbars(Depth), p_hg = -highestbars(Depth) lowing = lw == p_lw or low - low[p_lw] > Deviation*syminfo.mintick highing = hg == p_hg or high[p_hg] - high > Deviation*syminfo.mintick lh = barssince(not highing[1]), ll = barssince(not lowing[1]) down = barssince(not (lh > ll)) >= Backstep, lower = low[lw] > low[p_lw], higher = high[hg] < high[p_hg] if lw != p_lw and (not down[1] or lower) lw := p_lw < hg ? p_lw : 0 if hg != p_hg and (down[1] or higher) hg := p_hg < lw ? p_hg : 0 line zz = na label point = na x1 = down ? lw : hg y1 = down ? low[lw] : high[hg] var zigBarCount = 0 // once at init var t_zigBarCount = 0 // once at init if down == down[1] if repaint label.delete(point[1]) line.delete(zz[1]) down if down != down[1] if down last_h := hg else last_l := lw if not repaint nx = down?last_h:last_l zigBarCount := (bar_index-nx) - (bar_index-(down?last_l:last_h)) zz := line.new(bar_index-nx, down ? high[nx] : low[nx], bar_index-(down?last_l:last_h), down ? low[last_l] : high[last_h], width=line_thick, color=down?upcolor:dncolor) if price if Label_Style == "BALLOON" point := label.new(bar_index-nx, down ? high[nx] : low[nx], down ? tostring(high[nx])+"\n"+"C="+tostring(zigBarCount) : tostring(low[nx])+"\n"+"C="+tostring(zigBarCount), style=down?label.style_label_down:label.style_label_up, size=size.normal, color=down?upcolor:dncolor, textcolor=color.black, tooltip = down ? (high[nx] > high[last_h[1]]?"Higher High":"Lower High") : (low[nx] < low[last_l[1]] ? "Lower Low" : "Higher Low")) else point := label.new(bar_index-nx, na, down ? tostring(high[nx])+"\n"+"C="+tostring(zigBarCount) : tostring(low[nx])+"\n"+"C="+tostring(zigBarCount), style=label.style_none, yloc=down?yloc.abovebar:yloc.belowbar, size=size.normal, color=down?upcolor:dncolor, textcolor=color.blue, tooltip = down ? (high[nx] > high[last_h[1]]?"Higher High":"Lower High") : (low[nx] < low[last_l[1]] ? "Lower Low" : "Higher Low")) else if Label_Style == "BALLOON" point := label.new(bar_index-nx, down ? high[nx] : low[nx], tostring(zigBarCount), style=down?label.style_label_down:label.style_label_up, size=size.normal, color=down?upcolor:dncolor, textcolor=color.black, tooltip = down ? (high[nx] > high[last_h[1]]?"Higher High":"Lower High") : (low[nx] < low[last_l[1]] ? "Lower Low" : "Higher Low")) else point := label.new(bar_index-nx, na, tostring(zigBarCount), style=label.style_none, yloc=down?yloc.abovebar:yloc.belowbar, size=size.normal, color=down?upcolor:dncolor, textcolor=color.blue, tooltip = down ? (high[nx] > high[last_h[1]]?"Higher High":"Lower High") : (low[nx] < low[last_l[1]] ? "Lower Low" : "Higher Low")) down if repaint // last_h:last_lのどちらかが0なら縦に線を引くように変更する // if (last_h==0) or (last_l==0) // zigBarCount := (bar_index-x1) - (bar_index-(down?last_h:last_l))-1 // if zigBarCount < 0 // zz := line.new(bar_index-(down?last_h:last_l)-1, down ? high[last_h]-1 : low[last_l]-1, bar_index-x1, y1, width=line_thick, color=down?dncolor:upcolor) // t_zigBarCount := 0 // else // zz := line.new(bar_index-(down?last_h:last_l), down ? high[last_h]-1 : low[last_l]-1, bar_index-x1, y1, width=line_thick, color=down?dncolor:upcolor) // t_zigBarCount := zigBarCount // else zigBarCount := (bar_index-x1) - (bar_index-(down?last_h:last_l)) if zigBarCount < 0 zz := line.new(bar_index-(down?last_h:last_l)-1, down ? high[last_h] : low[last_l], bar_index-x1, y1, width=line_thick, color=down?dncolor:upcolor) t_zigBarCount := 0 else zz := line.new(bar_index-(down?last_h:last_l), down ? high[last_h] : low[last_l], bar_index-x1, y1, width=line_thick, color=down?dncolor:upcolor) t_zigBarCount := zigBarCount zigBarCount := t_zigBarCount if price if Label_Style == "BALLOON" point := label.new(bar_index-x1, y1, down ? tostring(low[x1])+"\n"+"C="+tostring(zigBarCount) : tostring(high[x1])+"\n"+"C="+tostring(zigBarCount), style=down?label.style_label_up:label.style_label_down, size=size.normal, color=down?dncolor:upcolor, textcolor=color.black, tooltip = down ? (low[x1] < low[last_l] ? "Lower Low" : "Higher Low") : (high[x1] > high[last_h]?"Higher High":"Lower High")) else point := label.new(bar_index-x1, na, down ? tostring(low[x1])+"\n"+"C="+tostring(zigBarCount) : tostring(high[x1])+"\n"+"C="+tostring(zigBarCount), style=label.style_none, yloc=down?yloc.belowbar:yloc.abovebar, size=size.normal, color=down?dncolor:upcolor, textcolor=color.blue, tooltip = down ? (low[x1] < low[last_l] ? "Lower Low" : "Higher Low") : (high[x1] > high[last_h]?"Higher High":"Lower High")) else if Label_Style == "BALLOON" point := label.new(bar_index-x1, y1, tostring(zigBarCount), style=down?label.style_label_up:label.style_label_down, size=size.normal, color=down?dncolor:upcolor, textcolor=color.black, tooltip = down ? (low[x1] < low[last_l] ? "Lower Low" : "Higher Low") : (high[x1] > high[last_h]?"Higher High":"Lower High")) else point := label.new(bar_index-x1, na, tostring(zigBarCount), style=label.style_none, yloc=down?yloc.belowbar:yloc.abovebar, size=size.normal, color=down?dncolor:upcolor, textcolor=color.blue, tooltip = down ? (low[x1] < low[last_l] ? "Lower Low" : "Higher Low") : (high[x1] > high[last_h]?"Higher High":"Lower High")) // ] //////// // Bull or Bear notifications // [ bear = down //bgcolor(bear?color.red:color.lime, title="Scanning Direction") alertcondition(bear!=bear[1], "Direction Changed", 'Zigzag on {{ticker}} direction changed at {{time}}') alertcondition(bear!=bear[1] and not bear, "Bullish Direction", 'Zigzag on {{ticker}} bullish direction at {{time}}') alertcondition(bear!=bear[1] and bear, "Bearish Direction", 'Zigzag on {{ticker}} bearish direction at {{time}}') // ]
AlexD Market annual seasonality
https://www.tradingview.com/script/B8gl1N6S-alexd-market-annual-seasonality/
AlexD169
https://www.tradingview.com/u/AlexD169/
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/ // © Aleksey Demchenko / AlexD //@version=5 indicator(title="AlexD Market annual seasonality", shorttitle="MAS", timeframe="D", format=format.price, precision=2, max_bars_back=5000) YearsN = input.int(10, title="Number of years", minval=1, maxval=16) Depth = input.int(1, title="Depth", minval=0, maxval=16) Smooth = input.int(8, title="Smooth", minval=1, maxval=64) var int Offset = (Smooth == 1) ? 0 : math.round(Smooth/2.0) hline(50, "Middle Band", color=color.gray) i = Depth k = 0.0 DayVal = 0.0 timestampI = 0 step = 0 for YearI = 1 to YearsN //Finding a day in previous years timestampI := timestamp(year-YearI,month,dayofmonth,00,00,00) + Offset*24*60*60*1000 step := 200 while timestamp(year[i],month[i],dayofmonth[i],00,00,00) > timestampI i := i + step if (step > 1) and (timestamp(year[i],month[i],dayofmonth[i],00,00,00) < timestampI) i := i - step step := math.round(step / 2) if na(close[i]) DayVal := -1 break //Bullish day probability calculation k := 0 if close[i] > close[i+1] k := 2 else if close[i] == close[i+1] k := 1 if Depth > 0 for j=1 to Depth if close[i+j] > close[i+j+1] k := j < Depth ? k + 2 : k + 1 else if close[i+j] == close[i+j+1] k := j < Depth ? k + 1 : k + 0.5 if close[i-j] > close[i-j+1] k := j < Depth ? k + 2 : k + 1 else if close[i-j] == close[i-j+1] k := j < Depth ? k + 1 : k + 0.5 k := k/(Depth*4) else k := k/2 DayVal := DayVal+k //Final smoothing of indicator MAS = ta.sma(DayVal / YearsN * 100,Smooth) if DayVal == -1 MAS := na plot(MAS, title="MAS", color = MAS >= 50 ? color.rgb(0, 255, 0) : color.rgb(255, 0, 0))