### Matrix Setup and Row Addition Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Displacement Candles/[Scanner] ICT Displacement Candles.txt Initializes a matrix to store string data and defines a function to add rows to this matrix with symbol and calculated indicator values. ```pinescript // Matrix setup var matrix = matrix.new(0, 6, na) // Add Rows Function rows_to_matix(symbol, _time, bars, _range, pchg, signal) => matrix.add_row(matrix, 0, array.from(symbol, _time, bars, _range, pchg, signal)) ``` -------------------------------- ### Matrix Setup and Row Addition in Pine Script Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Liquidity Sweep Pattern Scanner/Scanner - ICT Liquidity Sweep Pattern Scanner.txt Initializes a matrix to store data and provides a function to add rows with symbol, time, price, and signal information. ```pinescript var matrix = matrix.new(0, 6, na) mtxFun(symbol, _time, price, _cum_pchg, _cum_vol_pchg, signal) => matrix.add_row(matrix, 0, array.from(symbol, _time, price, _cum_pchg, _cum_vol_pchg, signal)) ``` -------------------------------- ### Table Setup and Cell Formatting Source: https://github.com/arunkbhaskar/pinescript/blob/main/Trend Following Setup - Sideways Market Skipper Scanner/Scanner - Trend Following Setup - Sideways Market Skipper Scanner.txt Initializes a table for displaying scanner data and defines functions for formatting table cells, including titles and data cells with conditional coloring. ```pinescript var table scr_tbl = table.new(position=i_scr_tbl_position, columns=5, rows=102, border_width=1, force_overlay=true) scr_cell_title(col, row, txt) => table.cell(scr_tbl, col, row, text = txt, text_color = i_neu_color, text_halign=text.align_center, bgcolor=i_neu_dark_color, text_size=i_scr_tbl_text_size) scr_cell(col, row, txt, _text_color, _bgcolor) => table.cell(scr_tbl, col, row, text = txt, text_color = _text_color, text_halign=text.align_left, bgcolor=_bgcolor, text_size=i_scr_tbl_text_size) ``` -------------------------------- ### Indicator Declaration and Menu Setup Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - Vijay Thakare Option Buying Scalping Setup/Momentum Setup - Vijay Thakare Option Buying Scalping Setup with Scanner.txt Declares the indicator with its properties and sets up the user interface menus for screener and indicator configurations. This includes input options for symbols, screening methods, and display preferences for various technical indicators. ```pinescript //@version=5 indicator(title='Momentum Setup: Vijay Thakare Option Buying Scalping Setup Scanner', shorttitle='VT Scalp Scan', overlay=true, max_bars_back=500, max_lines_count=500, max_boxes_count=500) ``` ```pinescript g_scrtb = '█████████████████ Screener █████████████████' string i_scr_choose = input.string(defval='Continuous Signals', title='Screening Method', options=['Continuous Signals', 'Flip Signals'], group=g_scrtb) ``` ```pinescript tt_is = "• Reads only up to first 40 symbols." + "\n• Total characters cannot exceed 4096." + "\n• Use comma as delimiter without any space." + "\n• Eg: EXCHANGE:SYMBOL_A,EXCHANGE:SYMBOL_B" string i_symbols = input.text_area( defval="NSE:NIFTY,NSE:NIFTYJR,NSE:BANKNIFTY,NSE:CNXFINANCE,NSE:NIFTY_MID_SELECT,BSE:SENSEX,BSE:SNSX50,BSE:BANK,NSE:ASHOKLEY,NSE:BANKBARODA,NSE:BANKINDIA,NSE:BEL,NSE:BHEL,NSE:CANBK,NSE:COALINDIA,NSE:ENGINERSIN,NSE:GAIL,NSE:HINDCOPPER,NSE:HUDCO,NSE:IEX,NSE:IRCON,NSE:IRFC,NSE:JSWINFRA,NSE:MOTHERSON,NSE:NATIONALUM,NSE:NBCC,NSE:NCC,NSE:NHPC,NSE:NMDC,NSE:NTPC,NSE:ONGC,NSE:PFC,NSE:PNB,NSE:POWERGRID,NSE:RAILTEL,NSE:RVNL,NSE:SAIL,NSE:SJVN,NSE:UNIONBANK,NSE:VEDL,NSE:ZEEL,NSE:ZOMATO", title="Paste Symbols", tooltip=tt_is, group=g_scrtb) ``` ```pinescript string i_scr_direction = input.string(defval='Both', title='Direction', options=['Both', 'Long', 'Short'], inline='tb_1', group=g_scrtb) bool i_scr_show_bull = input.bool(defval=true, title='Only Long', inline='tb_2', group=g_scrtb) bool i_scr_show_bear = input.bool(defval=true, title='Only Short', inline='tb_2', group=g_scrtb) ``` ```pinescript int i_scr_tbl_disp_rows = input.int(defval=12, title='Display Rows', minval=0, maxval=100, group=g_scrtb) string i_scr_tbl_position = input.string(defval=position.bottom_left, title='Table Position', options=[position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group=g_scrtb) string i_scr_tbl_text_size = input.string(defval=size.small, title='Table Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group=g_scrtb) ``` -------------------------------- ### Matrix and Row Setup for Scanner Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - RSI Directional Momentum/[Scanner] Momentum Setup - RSI Directional Momentum.txt Initializes a matrix to store scanner data and defines a function to add rows with symbol, time, price, and momentum change information. ```pinescript // Matrix setup var matrix = matrix.new(0, 6, na) // Add Rows Function rows_to_matix(symbol, _time, price, pchg, vol_pchg, signal) => matrix.add_row(matrix, 0, array.from(symbol, _time, price, pchg, vol_pchg, signal)) ``` -------------------------------- ### Momentum Setup Indicator Configuration Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - Ankush Bajaj Momentum Investing Setup/Momentum Setup - Ankush Bajaj Momentum Investing Setup with Scanner.txt Configures the main indicator with overlay, bar limits, and line/box counts. It also sets up input parameters for a symbol scanner, including text area for symbols, direction, bullish/bearish display options, table rows, position, and text size. ```pinescript //@version=5 indicator(title='Momentum Setup - Ankush Bajaj Momentum Investing Setup with Scanner', shorttitle='AB Mom Scan', overlay=true, max_bars_back=500, max_lines_count=500, max_boxes_count=500) //_____________________________ Menu Screener Start g_scrtb = '██████████████████ Scanner ██████████████████' tt_is = "• Reads only up to first 40 symbols." + "\n• Total characters cannot exceed 4096." + "\n• Use comma as delimiter without any space." + "\n• Eg: EXCHANGE:SYMBOL_A,EXCHANGE:SYMBOL_B" string i_symbols = input.text_area( defval="NSE:ABCAPITAL,NSE:ABFRL,NSE:AUROPHARMA,NSE:BANDHANBNK,NSE:BEL,NSE:BHEL,NSE:BPCL,NSE:BSOFT,NSE:COLPAL,NSE:CONCOR,NSE:CUB,NSE:DLF,NSE:EICHERMOT,NSE:GAIL,NSE:GNFC,NSE:GODREJCP,NSE:GODREJPROP,NSE:GRANULES,NSE:HINDCOPPER,NSE:HINDPETRO,NSE:IDEA,NSE:IGL,NSE:INDIACEM,NSE:INDUSTOWER,NSE:LAURUSLABS,NSE:MANAPPURAM,NSE:INDHOTEL,NSE:MUTHOOTFIN,NSE:NATIONALUM,NSE:NAUKRI,NSE:NMDC,NSE:OBEROIRLTY,NSE:PETRONET,NSE:PFC,NSE:RECLTD,NSE:SAIL,NSE:TATACHEM,NSE:VEDL,NSE:VOLTAS,NSE:ZEEL", title="Paste Symbols", tooltip=tt_is, group=g_scrtb) string i_scr_direction = input.string(defval='Both', title='Direction', options=['Both', 'Bullish', 'Bearish'], inline='tb_1', group=g_scrtb) bool i_scr_show_bull = input.bool(defval=true, title='Only Bullish', inline='tb_2', group=g_scrtb) bool i_scr_show_bear = input.bool(defval=true, title='Only Bearish', inline='tb_2', group=g_scrtb) int i_scr_tbl_disp_rows = input.int(defval=12, title='Display Rows', minval=0, maxval=100, group=g_scrtb) string i_scr_tbl_position = input.string(defval=position.bottom_left, title='Table Position', options=[position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group=g_scrtb) string i_scr_tbl_text_size = input.string(defval=size.small, title='Table Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group=g_scrtb) //_____________________________ Menu Screener End ``` -------------------------------- ### Table Plotting Setup Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Market Structure Shift (MSS)/ICT Market Structure Shift (MSS) Screener.txt This section initializes a table object for displaying screener data and defines helper functions for formatting table cells, including titles and data cells with conditional coloring. ```pinescript // Plot Table // Create table with specified properties var table tbl = table.new(position=i_tbl_position, columns=3, rows=102, border_width=1) // Function to populate cells in the table cell_title(col, row, txt) => table.cell(tbl, col, row, text = txt, text_color = i_neu_color, text_halign=text.align_center, bgcolor = color.new(i_neu_color, 90), text_size=i_tbl_text_size) cell(col, row, txt, color) => table.cell(tbl, col, row, text = txt, text_color = color, text_halign=text.align_left, bgcolor = color.new(color, 90), text_size=i_tbl_text_size) ``` -------------------------------- ### Table Population and Header Setup Source: https://github.com/arunkbhaskar/pinescript/blob/main/[Screener] ICT Retracement to Order Block with Screener.txt This snippet handles the logic for clearing the table, setting up headers, and populating the table with data from the matrix on the last bar of the chart. It determines cell colors based on the signal direction (positive, negative, or neutral). ```pinescript // Plot Table // Create table with specified properties var table tbl = table.new(position=i_tbl_position, columns=4, rows=102, border_width=1) // Function to populate cells in the table cell(col, row, txt, color) => table.cell(tbl, col, row, text = txt, text_color = color, text_halign=text.align_left, bgcolor = color.new(color, 90), text_size=i_tbl_text_size) // Check if it's the last bar if barstate.islast // Clear existing data in the table table.clear(tbl, 0, 0, 3, 101) // Set headers for the table cell(0, 0, "Symbol", i_neu_col) cell(1, 0, "Time", i_neu_col) cell(2, 0, "Dir" , i_neu_col) cell(3, 0, "Price", i_neu_col) j = 1 // Populate table with matrix data if matrix.rows(matrix) > 0 for i = 0 to matrix.rows(matrix) - 1 // Determine color based on the signal col = matrix.get(matrix, i, 4) == "1" ? i_pos_col : matrix.get(matrix, i, 4) == "-1" ? i_neg_col : i_neu_col // Populate cells in the table cell(0, j, matrix.get(matrix, i, 0), col) cell(1, j, matrix.get(matrix, i, 1), col) cell(2, j, matrix.get(matrix, i, 2), col) cell(3, j, matrix.get(matrix, i, 3), col) j += 1 // _____________________________ Screener End // _____________________________ Code End ``` -------------------------------- ### Initialize and Activate Displacement Candle Sequences Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Displacement Candles/[Indicator] ICT Displacement Candles.txt Initializes variables for tracking bullish and bearish sequences and activates them when the minimum bar count is met. This logic is crucial for starting the detection of potential trend continuations or reversals. ```pinescript // Retracement tracking combined var bool bullActive = false var bool bearActive = false var bool bullDone = false var bool bearDone = false var int bullBar = na var int bearBar = na var int bullStart = na var int bearStart = na var float bullLow = na var float bearHigh = na var line bullLine = na var line bearLine = na // Activate sequences if bullCnt >= i_dc_min_bars and bullCnt[1] < i_dc_min_bars bullActive := true bearActive := false bullDone := false bearDone := false bullStart := bar_index - bullCnt + 1 if bearCnt >= i_dc_min_bars and bearCnt[1] < i_dc_min_bars bearActive := true bullActive := false bearDone := false bullDone := false bearStart := bar_index - bearCnt + 1 ``` -------------------------------- ### Creating and Populating Data Table Source: https://github.com/arunkbhaskar/pinescript/blob/main/Trend Following Setup - Sideways Market Skipper Scanner/Indicator - Trend Following Setup - Sideways Market Skipper.txt Initializes a table and populates it with financial data including percentage change and volume for the current and previous day. The table is only displayed on the last bar if `i_tbl_data_show` is true. Ensure `i_tbl_data_pos`, `i_tbl_data_txt_size`, and related data variables are defined. ```pinescript var table tbl_data = table.new(position=i_tbl_data_pos, columns=2, rows=4, border_width=1, force_overlay=true) if barstate.islast and i_tbl_data_show table.cell(table_id=tbl_data, column=0, row=0, text="%Chg", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size) table.cell(table_id=tbl_data, column=1, row=0, text=day_pchg_str, text_color=pchg_col, text_halign=text.align_right, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size) table.cell(table_id=tbl_data, column=0, row=1, text="Vol %Chg", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size) table.cell(table_id=tbl_data, column=1, row=1, text=volume_pchg_str, text_color=vol_pchg_col, text_halign=text.align_right, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size) table.cell(table_id=tbl_data, column=0, row=2, text="Vol", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size) table.cell(table_id=tbl_data, column=1, row=2, text=day_volume_str, text_color=vol_pchg_col, text_halign=text.align_right, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size) table.cell(table_id=tbl_data, column=0, row=3, text="PD Vol", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size) table.cell(table_id=tbl_data, column=1, row=3, text=prev_day_volume_str, text_color=prev_vol_pchg_col, text_halign=text.align_right, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size) ``` -------------------------------- ### Draw Line Function Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Liquidity Void/ICT Liquidity Void Screener.txt Creates a new horizontal line on the chart. Requires start time, price, and color. ```pinescript draw_line(int x1_time, float y1_price, color _color)=> line.new(x1=x1_time, y1=y1_price, x2=time, y2=y1_price, xloc=xloc.bar_time, color=_color, style=i_lv_ln_style, width=i_lv_ln_width) ``` -------------------------------- ### Get Timeframe Resolution in Minutes Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT External Range Liquidity/ICT External Range Liquidity Static Multi-timeframe (Swing High and Low).txt Retrieves the resolution of a specified timeframe in minutes. This is a helper function for `f_resInMinutes` to work with different timeframes. ```pinescript f_tfResInMinutes(_resolution) => request.security(syminfo.tickerid, _resolution, f_resInMinutes()) ``` -------------------------------- ### Get Source for Zig Zag Calculation Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Market Structure Shift (MSS)/ICT Market Structure Shift (MSS) Screener.txt Determines the price source (high/low or open/close) for Zig Zag calculations based on the 'i_zz_source' input. ```pinescript //_____________________________ Get Source float _high = i_zz_source == 'Open/Close' ? math.max(open, close) : high float _low = i_zz_source == 'Open/Close' ? math.min(open, close) : low ``` -------------------------------- ### Initialize Indicator Settings Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Market Structure Shift (MSS)/ICT Market Structure Shift (MSS) Screener.txt Sets up the basic parameters for the indicator, including its title, overlay preference, and maximum bar count. This is essential for any TradingView indicator. ```pinescript // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Arun_K_Bhaskar //@version=5 i_max_bars_back = 300 indicator(title="ICT Market Structure Shift (MSS) Screener", shorttitle="ICT MSS Scr", overlay=true, max_bars_back=i_max_bars_back, max_lines_count=500, max_boxes_count=500) ``` -------------------------------- ### Calculate Daily Cumulative Percentage Change Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Fair Value Gap (FVG) Scanner/Scanner - ICT Fair Value Gap (FVG) Scanner.txt Calculates the daily cumulative percentage change of the closing price. It resets the calculation at the start of each new day. ```pinescript // Function to calculate Daily Cumulative Percentage Change of Close Price cumulative_percentage_change() => var float _cum_pct_change = na _is_new_day = ta.change(time('D')) != 0 ? 1 : 0 _daily_pct_change = na(close[1]) ? 0 : (close - close[1]) / close[1] * 100 _cum_pct_change := bool(_is_new_day) ? _daily_pct_change : na(_cum_pct_change) ? _daily_pct_change : _cum_pct_change + _daily_pct_change _cum_pct_change // Calculate current cumulative percentage change cum_pchg = cumulative_percentage_change() ``` -------------------------------- ### Daily Cumulative Percentage Change Calculation Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Liquidity Void Fill/[Scanner] ICT Liquidity Void Fill Scanner.txt Calculates the daily cumulative percentage change of the closing price. It resets the calculation at the start of each new day. ```pinescript // Function to calculate Daily Cumulative Percentage Change of Close Price cum_pchg() => var float _cum_pct_change = na _is_new_day = ta.change(time('D')) != 0 ? 1 : 0 _daily_pct_change = na(close[1]) ? 0 : (close - close[1]) / close[1] * 100 _cum_pct_change := bool(_is_new_day) ? _daily_pct_change : na(_cum_vol) ? _daily_pct_change : _cum_pct_change + _daily_pct_change _cum_pct_change // Calculate current cumulative percentage change cum_pchg = cum_pchg() ``` -------------------------------- ### Calculate Performance Metrics Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Displacement Candles/[Indicator] ICT Displacement Candles.txt Calculates cumulative percentage change, cumulative volume, and volume percentage change. Resets calculations at the start of a new day. ```pinescript is_new_day = ta.change(time('D')) != 0 var float cum_pchg = na day_pchg = na(close[1]) ? 0 : (close - close[1]) / close[1] * 100 cum_pchg := is_new_day ? day_pchg : na(cum_pchg) ? day_pchg : cum_pchg + day_pchg var float curr_cum_vol = na var float prev_cum_vol = na if is_new_day prev_cum_vol := curr_cum_vol curr_cum_vol := volume curr_cum_vol else curr_cum_vol := na(curr_cum_vol) ? volume : curr_cum_vol + volume curr_cum_vol prev_vol_safe = nz(prev_cum_vol, curr_cum_vol) cum_vol_pchg = (curr_cum_vol - prev_vol_safe) / prev_vol_safe * 100 ``` -------------------------------- ### Additional Filter Input Settings Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - Vijay Thakare Option Buying Scalping Setup/Momentum Setup - Vijay Thakare Option Buying Scalping Setup.txt Sets up user inputs for various filters including ATR, body percentage, body size, volume, relative volume, and time. Tooltips provide explanations for each filter's purpose. ```pinescript g_af = '███████████████ Additional Fiters ███████████████' tt_atr = "ATR helps filter out longer or more volatile signal candles." tt_atr_mul = "Higher multiplier value filters a longer or more volatile signal candle." tt_bf = "If the input is '80', it means the body covers over 80% of the candle." tt_bs = '2 means the candle is 2 times larger than the previous candle.' tt_vol = "Filter out a candle when its volume is greater than the SMA of the volume." tt_rv = "Filter out a candle when its volume is greater than the Relative Volume." tt_tf = "Filter out a signals between the given Time." bool i_atr_filter = input.bool(defval=false, title='Apply ATR Filter', tooltip=tt_atr, group=g_af) int i_atr_length = input.int(defval=14, minval=1, title='ATR Length', group=g_af) float i_atr_multi = input.float(defval=1, title='ATR Multiplier', minval=1, group=g_af) bool i_body_filter = input.bool(defval=false, title='Apply Body % Filter', tooltip=tt_bf, group=g_af) float i_body_percent = input.float(defval=80, title='Body % Above', minval=0, maxval=100, group=g_af) / 100 bool i_body_size_filter = input.bool(defval=false, title='Apply Body Size Filter', tooltip=tt_bs, group=g_af) int i_body_size_multiplier = input.int(defval=2, title='Body Size Multiplier (x)', minval=0, group=g_af) bool i_volume_filter = input.bool(defval=false, title='Apply Volume Filter', tooltip=tt_vol, group=g_af) int i_vol_sma_length = input.int(defval=20, minval=1, title='Volume SMA Length', group=g_af) bool i_rel_vol_filter = input.bool(defval=false, title='Apply Relative Volume Filter', tooltip=tt_rv, group=g_af) int i_rel_vol_avg_vol_len = input.int(defval=90, title='Relative Volume Length', minval=2, group=g_af) float i_rel_vol_avg_vol_multi = input.float(defval=2, title='Rel Vol SMA Multiplier', minval=0, group=g_af) bool i_time_filter = input.bool(defval=false, title='Apply Time Filter', tooltip=tt_tf, group=g_af) int i_hour_1 = input.int(defval=9, minval=0, title='Time From', inline='t_1', group=g_af) int i_minute_1 = input.int(defval=15, minval=0, title=':', inline='t_1', group=g_af) int i_hour_2 = input.int(defval=10, minval=0, title='Time To
', inline='t_2', group=g_af) int i_minute_2 = input.int(defval=15, minval=0, title=':', inline='t_2', group=g_af) ``` -------------------------------- ### RSI Bands Setup Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - RSI Directional Momentum/[Scanner] Momentum Setup - RSI Directional Momentum.txt Defines horizontal lines for RSI bands (overbought, breakout, middle, breakdown, oversold) and fills the area between the breakout and breakdown bands. ```PineScript float overbought = 70 float breakout = 60 float middle = 50 float breakdown = 40 float oversold = 30 hline(price = overbought, title = 'Band Overbought', color = color.new(i_neg_color, 50), linestyle = hline.style_dotted) band_ub = hline(price = breakout, title = 'Band Bullish', color = color.new(i_neu_color, 50), linestyle = hline.style_dotted) hline(price = middle, title = 'Band Middle', color = color.new(i_neu_color, 50), linestyle = hline.style_dotted) band_lb = hline(price = breakdown, title = 'Band Bearish', color = color.new(i_neu_color, 50), linestyle = hline.style_dotted) hline(price = oversold, title = 'Band Oversold', color = color.new(i_pos_color, 50), linestyle = hline.style_dotted) fill(hline1 = band_ub, hline2 = band_lb, color = color.new(i_neu_color, 95), title = 'Fill Middle') ``` -------------------------------- ### Configure Body Percentage Filter Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Mitigation Block Scanner/[Scanner] ICT Mitigation Block Scanner.txt Sets up inputs for a body percentage filter, enabling the filter and defining the minimum percentage of the candle body to consider. ```Pine Script bool i_body_filter = input.bool(defval=false, title='Apply Body % Filter', tooltip=tt_bf, group=g_af) float i_body_percent = input.float(defval=60, title='Body % Above', minval=0, maxval=100, group=g_af) / 100 ``` -------------------------------- ### Get Resolution in Minutes Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT External Range Liquidity/ICT External Range Liquidity Static Multi-timeframe (Swing High and Low).txt Determines the current chart resolution in minutes. This function accounts for different timeframes (seconds, minutes, daily, weekly, monthly) and returns the equivalent in minutes. ```pinescript f_resInMinutes() => _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60. : timeframe.isminutes ? 1. : timeframe.isdaily ? 1440. : timeframe.isweekly ? 10080. : timeframe.ismonthly ? 43800. : na) _resInMinutes ``` -------------------------------- ### Bullish Liquidity Void Initialization Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Liquidity Void/ICT Liquidity Void Screener.txt Initializes variables for the bullish liquidity void scenario. This includes tracking previous high, price source values, and arrays for lines and boxes. ```pinescript //_____________________________ Liquidity Void Bullish Start var float bull_prev_high = na, var int bull_prev_high_time = na var float bull_price_source_val = na, var float bull_low_val = na var bull_keep_lines = array.new_line(), var bull_all_lines = array.new_line() var bull_keep_boxes = array.new_box(), var bull_all_boxes = array.new_box() ``` -------------------------------- ### Liquidity Void Settings Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Liquidity Void/ICT Liquidity Void Screener.txt Configures the parameters for identifying and displaying liquidity voids. Includes options for the number of past voids to show, the source for void calculation (High/Low, OTE, 50%), and toggles for bullish and bearish voids, with an option to hide crossed voids. ```pinescript //_____________________________ Menu Liquidity Void Start g_lv = '███████████████ Liquidity Void ███████████████' int i_lv_show_last = input.int(defval=2, title='Show Last', minval=0, group=g_lv) string i_lv_line = input.string(defval='High/Low', title='Source', options=['High/Low', 'OTE 0.79%', '50%'], group=g_lv) bool i_lv_bear_show = input.bool(defval=true, title='Bearish', group=g_lv) bool i_lv_bull_show = input.bool(defval=true, title='Bullish', group=g_lv) bool i_lv_hide_crossed = input.bool(defval=false, title='Hide Crossed', group=g_lv) ``` -------------------------------- ### Capture High/Low for Continuous Signals Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - RSI Directional Momentum/[Indicator] Momentum Setup - RSI Directional Momentum.txt Updates the high, low, and bar index when a continuous break signal occurs. This captures the price range associated with the start of a continuous momentum move. ```pinescript if short_cont_break short_signal_high := high short_signal_low := low short_signal_bar := bar_index if long_cont_break long_signal_high := high long_signal_low := low long_signal_bar := bar_index ``` -------------------------------- ### Configure Volume Filters Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Mitigation Block Scanner/[Scanner] ICT Mitigation Block Scanner.txt Sets up boolean and integer inputs for applying and configuring volume-based filters, including volume above a certain threshold and volume percentage change. ```Pine Script bool i_vol_filter = input.bool(defval=false, title='Apply Volume Filter', tooltip=tt_vpchg, group=g_af) int i_vol_above = input.int(defval=500000, title='Volume Above', minval=0, group=g_af) bool i_vol_pchg_filter = input.bool(defval=false, title='Apply Volume % Change Filter', tooltip=tt_vpchg, group=g_af) float i_vol_pchg_above = input.float(defval=0, title='Volume % Change Above', minval=0, group=g_af) ``` -------------------------------- ### Calculate Daily Cumulative Percentage Change of Close Price Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Liquidity Sweep Pattern Scanner/Scanner - ICT Liquidity Sweep Pattern Scanner.txt This function calculates the cumulative percentage change of the closing price on a daily basis. It resets the calculation at the start of each new day. ```pinescript // Function to calculate Daily Cumulative Percentage Change of Close Price cumulative_percentage_change() => var float _cum_pct_change = na _is_new_day = ta.change(time('D')) != 0 ? 1 : 0 _daily_pct_change = na(close[1]) ? 0 : (close - close[1]) / close[1] * 100 _cum_pct_change := _is_new_day ? _daily_pct_change : (na(_cum_pct_change) ? _daily_pct_change : (_cum_pct_change + _daily_pct_change)) _cum_pct_change // Calculate current cumulative percentage change cum_pchg = cumulative_percentage_change() //_____________________________ Cumulative Percentage Change End ``` -------------------------------- ### Calculate Daily Cumulative Volume Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Mitigation Block Scanner/[Scanner] ICT Mitigation Block Scanner.txt Calculates the daily cumulative volume. It resets at the start of a new day and accumulates volume otherwise. Use this to track volume progression within a trading day. ```pinescript // Function to calculate Daily Cumulative Volume cumulative_volume() => var float _cum_vol = na _is_new_day = ta.change(time('D')) != 0 ? 1 : 0 _cum_vol := _is_new_day ? volume : (na(_cum_vol) ? volume : (_cum_vol + volume)) _cum_vol ``` -------------------------------- ### Create and Populate Data Table in PineScript Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Fair Value Gap (FVG) Scanner/Scanner - ICT Fair Value Gap (FVG) Scanner.txt Initializes a table and populates its cells with formatted data and corresponding colors. This snippet is executed only on the last bar if `i_tbl_data_show` is true. Requires a pre-defined table ID `tbl_data` and formatted string variables. ```pinescript var table tbl_data = table.new(position = i_tbl_data_pos, columns = 2, rows = 4, border_width = 1, force_overlay = true) if barstate.islast and i_tbl_data_show table.cell(table_id = tbl_data, column = 0, row = 0, text = '%Chg', text_color = i_neu_color, text_halign = text.align_left, bgcolor = bgcolor_1, text_size = i_tbl_data_txt_size) table.cell(table_id = tbl_data, column = 1, row = 0, text = day_pchg_str, text_color = pchg_col, text_halign = text.align_right, bgcolor = bgcolor_1, text_size = i_tbl_data_txt_size) table.cell(table_id = tbl_data, column = 0, row = 1, text = 'Vol %Chg', text_color = i_neu_color, text_halign = text.align_left, bgcolor = bgcolor_2, text_size = i_tbl_data_txt_size) table.cell(table_id = tbl_data, column = 1, row = 1, text = volume_pchg_str, text_color = vol_pchg_col, text_halign = text.align_right, bgcolor = bgcolor_2, text_size = i_tbl_data_txt_size) table.cell(table_id = tbl_data, column = 0, row = 2, text = 'Vol', text_color = i_neu_color, text_halign = text.align_left, bgcolor = bgcolor_1, text_size = i_tbl_data_txt_size) table.cell(table_id = tbl_data, column = 1, row = 2, text = day_volume_str, text_color = vol_pchg_col, text_halign = text.align_right, bgcolor = bgcolor_1, text_size = i_tbl_data_txt_size) table.cell(table_id = tbl_data, column = 0, row = 3, text = 'PD Vol', text_color = i_neu_color, text_halign = text.align_left, bgcolor = bgcolor_2, text_size = i_tbl_data_txt_size) table.cell(table_id = tbl_data, column = 1, row = 3, text = prev_day_volume_str, text_color = prev_vol_pchg_col, text_halign = text.align_right, bgcolor = bgcolor_2, text_size = i_tbl_data_txt_size) ``` -------------------------------- ### Configure Data Table Display Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Mitigation Block Scanner/[Scanner] ICT Mitigation Block Scanner.txt Sets up inputs for displaying a data table, including options to show/hide the table, set its position, and adjust text size. ```Pine Script string i_tbl_data_pos = input.string(defval=position.bottom_right, title='Position', options=[position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group=g_dtb) string i_tbl_data_txt_size = input.string(defval=size.normal, title='Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group=g_dtb) ``` -------------------------------- ### Fibonacci Levels for Continuous Signals Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - RSI Directional Momentum/[Scanner] Momentum Setup - RSI Directional Momentum.txt Calculates Fibonacci retracement levels based on the high and low prices recorded at the start of a continuous short or long signal. These levels can be used for target setting or further analysis. ```pinescript var float short_signal_high = na var float short_signal_low = na var int short_signal_bar = na var float long_signal_high = na var float long_signal_low = na var int long_signal_bar = na if short_cont_break short_signal_high := high short_signal_low := low short_signal_bar := bar_index if long_cont_break long_signal_high := high long_signal_low := low long_signal_bar := bar_index short_fib_val = not na(short_signal_high) and not na(short_signal_low) ? short_signal_high - (short_signal_high - short_signal_low) * i_rsi_fib_val : na long_fib_val = not na(long_signal_high) and not na(long_signal_low) ? long_signal_low + (long_signal_high - long_signal_low) * i_rsi_fib_val : na ``` -------------------------------- ### Additional Filters Input Configuration Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - Vijay Thakare Option Buying Scalping Setup/Momentum Setup - Vijay Thakare Option Buying Scalping Setup with Scanner.txt Sets up various input filters for trading signals, including ATR, body percentage, body size, volume, relative volume, and time filters. Each filter has specific parameters to adjust its sensitivity. ```pinescript g_af = '███████████████ Additional Fiters ███████████████' tt_atr = "ATR helps filter out longer or more volatile signal candles." tt_atr_mul = "Higher multiplier value filters a longer or more volatile signal candle." tt_bf = "If the input is '80', it means the body covers over 80% of the candle." tt_bs = '2 means the candle is 2 times larger than the previous candle.' tt_vol = "Filter out a candle when its volume is greater than the SMA of the volume." tt_rv = "Filter out a candle when its volume is greater than the Relative Volume." tt_tf = "Filter out a signals between the given Time." bool i_atr_filter = input.bool(defval=false, title='Apply ATR Filter', tooltip=tt_atr, group=g_af) int i_atr_length = input.int(defval=14, minval=1, title='ATR Length', group=g_af) float i_atr_multi = input.float(defval=1, title='ATR Multiplier', minval=1, group=g_af) bool i_body_filter = input.bool(defval=false, title='Apply Body % Filter', tooltip=tt_bf, group=g_af) float i_body_percent = input.float(defval=80, title='Body % Above', minval=0, maxval=100, group=g_af) / 100 bool i_body_size_filter = input.bool(defval=false, title='Apply Body Size Filter', tooltip=tt_bs, group=g_af) int i_body_size_multiplier = input.int(defval=2, title='Body Size Multiplier (x)', minval=0, group=g_af) bool i_volume_filter = input.bool(defval=false, title='Apply Volume Filter', tooltip=tt_vol, group=g_af) int i_vol_sma_length = input.int(defval=20, minval=1, title='Volume SMA Length', group=g_af) bool i_rel_vol_filter = input.bool(defval=false, title='Apply Relative Volume Filter', tooltip=tt_rv, group=g_af) int i_rel_vol_avg_vol_len = input.int(defval=90, title='Relative Volume Length', minval=2, group=g_af) float i_rel_vol_avg_vol_multi = input.float(defval=2, title='Rel Vol SMA Multiplier', minval=0, group=g_af) bool i_time_filter = input.bool(defval=false, title='Apply Time Filter', tooltip=tt_tf, group=g_af) int i_hour_1 = input.int(defval=9, minval=0, title='Time From', inline='t_1', group=g_af) int i_minute_1 = input.int(defval=15, minval=0, title=':', inline='t_1', group=g_af) int i_hour_2 = input.int(defval=10, minval=0, title='Time To ', inline='t_2', group=g_af) int i_minute_2 = input.int(defval=15, minval=0, title=':', inline='t_2', group=g_af) ``` -------------------------------- ### Market Profile Box and Line Stacking Source: https://github.com/arunkbhaskar/pinescript/blob/main/[Screener] Market Profile with Screener (Based on [RS]Market Profile by RicardoSantos).txt Stacks VAH, VAL, and POC boxes, along with open session lines, for a given session. Requires session data and calculated box/line values. ```pinescript if isnewsession f_box_stack(vah_boxes, i_sessions, f_vah_box(previous_session_end, vah_value[1], time_close(i_session_timeframe), val_value[1])) f_box_stack(poc_boxes, i_sessions, f_poc_box(previous_session_end, poc_upper[1], time_close(i_session_timeframe), poc_lower[1])) f_line_stack(open_session_lines, i_sessions, f_open_session_line(previous_session_end, open, time_close(i_session_timeframe), open)) ``` -------------------------------- ### Pine Script Input: Time Filter Configuration Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Liquidity Void Fill/[Indicator] ICT Liquidity Void Fill.txt Allows filtering signals based on a specific time range. Users define the start and end times for the filter. The tooltip explains its use for retracement candles. ```pinescript string tt_tf = "• Applicable only to the retracement candle." + ". Filter out a signals between the given Time." bool i_time_filter = input.bool(defval = false, title = 'Apply Time Filter', tooltip = tt_tf, group = g_af) int i_hour_1 = input.int(defval = 9, minval = 0, title = 'Time From', inline = 't_1', group = g_af) int i_minute_1 = input.int(defval = 15, minval = 0, title = ':', inline = 't_1', group = g_af) int i_hour_2 = input.int(defval = 10, minval = 0, title = 'Time To ', inline = 't_2', group = g_af) int i_minute_2 = input.int(defval = 15, minval = 0, title = ':', inline = 't_2', group = g_af) ``` -------------------------------- ### Get Zig Zag Source High/Low Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT Mitigation Block Scanner/[Scanner] ICT Mitigation Block Scanner.txt Determines the source price (Open/Close, Close, or High) for Zig Zag calculations based on the `i_zz_source` input. This ensures the indicator uses the correct price points for its analysis. ```pinescript //_____________________________ Get Source float _high = i_zz_source == 'Open/Close' ? math.max(open, close) : i_zz_source == 'Close' ? close : high float _low = i_zz_source == 'Open/Close' ? math.max(open, close) : i_zz_source == 'Close' ? close : low ``` -------------------------------- ### Create and Populate Screener Table Source: https://github.com/arunkbhaskar/pinescript/blob/main/Momentum Setup - Ankush Bajaj Momentum Investing Setup/Momentum Setup - Ankush Bajaj Momentum Investing Setup with Scanner.txt Initializes a table for displaying screener data and populates it with indicator values and colors based on predefined thresholds. This code runs only on the last bar. ```pinescript var table tbl = table.new(position=i_tbl_position, columns=2, rows=5, border_width=2) // Color col_pchg = pchg > i_pchg_250 ? i_pos_col : pchg < (-i_pchg_250) ? i_neg_col : i_neu_col col_rsi = rsi > i_rsi_ob ? i_pos_col : rsi < i_rsi_os ? i_neg_col : i_neu_col col_mfi = mfi > i_mfi_ob ? i_pos_col : mfi < i_mfi_os ? i_neg_col : i_neu_col col_cci = cci > i_cci_ob ? i_pos_col : cci < i_cci_os ? i_neg_col : i_neu_col col_vol = volume > vol_sma ? i_pos_col : i_neu_col // Function to populate cells in the table cell(int column, int row, string txt, color color) => table.cell(tbl, column, row, text = txt, text_color = color, text_halign=text.align_left, bgcolor = color.new(color, 90), text_size=i_tbl_text_size) // Check if it's the last bar if barstate.islast cell(0, 0, "%Chg", col_pchg) cell(0, 1, "RSI", col_rsi) cell(0, 2, "MFI", col_mfi) cell(0, 3, "CCI", col_cci) cell(0, 4, "Vol", col_vol) cell(1, 0, str.tostring(pchg, '#.##'), col_pchg) cell(1, 1, str.tostring(rsi, '#.##'), col_rsi) cell(1, 2, str.tostring(mfi, '#.##'), col_mfi) cell(1, 3, str.tostring(cci, '#.##'), col_cci) cell(1, 4, str.tostring((volume / 100000), '#.##') + ' L', col_vol) ``` -------------------------------- ### Pivot High Low 2 Data Fetch and Draw Source: https://github.com/arunkbhaskar/pinescript/blob/main/ICT External Range Liquidity/ICT External Range Liquidity Static Multi-timeframe (Swing High and Low).txt Fetches and draws Pivot High/Low data for the second instance. It uses `request.security` to get data from a specified timeframe and `f_addLines` to draw the identified levels. ```pinescript phl_2_ph_htf = request.security(syminfo.tickerid, i_phl_2_tf, phl_2_ph) phl_2_pl_htf = request.security(syminfo.tickerid, i_phl_2_tf, phl_2_pl) phl_2_ph_new = na(phl_2_ph_htf[1]) and not na(phl_2_ph_htf) phl_2_pl_new = na(phl_2_pl_htf[1]) and not na(phl_2_pl_htf) phl_2_ph_offset = f_offsetToP(_high, phl_2_ph_htf, math.min(i_max_bars_back, math.max(30, phl_2_bars_offset + phl_2_bars_htf + 1))) phl_2_pl_offset = f_offsetToP(_low, phl_2_pl_htf, math.min(i_max_bars_back, math.max(30, phl_2_bars_offset + phl_2_bars_htf + 1))) // Draw if i_phl_2_show and phl_2_bars_offset <= i_max_bars_back f_addLines(i_phl_2_lbl_show, phl_2_ph_htf, phl_2_pl_htf, phl_2_ph_offset, phl_2_pl_offset, phl_2_ph_new, phl_2_pl_new, i_phl_2_h_ln_color, i_phl_2_l_ln_color, i_phl_2_showlast, i_phl_2_ln_width, i_phl_2_ln_stye, phl_2_ln_arr, phl_2_lbl_arr) if i_phl_2_show f_extendArray(phl_2_ln_arr, phl_2_lbl_arr, i_phl_2_ln_extend) ```