Liquidity Spike Pool
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AleSaira

//==============================/////////////==========================}
 //  _____  .__           _________      .__               
 // /  _  \ |  |   ____  /   _____/____  |__|___________   
 ///  /_\  \|  | _/ __ \ \_____  \\__  \ |  \_  __ \__  \  
///    |    \  |_\  ___/ /        \/ __ \|  ||  | \// __ \_
//\____|__  /____/\___  >_______  (____  /__||__|  (____  /
//        \/          \/        \/     \/               \/ 
//==============================/////////////==========================}
//@version=5
indicator("Liquidity Spike Pool", overlay=true)
//==============================/////////////==========================}
Pwick          =         input.int      (55, minval=1, maxval=99, title="% The Wick Of Candle")
look_back      =         input.int      (6, minval=1, maxval=100, title="Look Back Period")
rangelb        =         input.int      (5, minval=1, maxval=99, title=" Percent of Range")
colorlineup    =         input.color    (color.blue, "Liquidity up")
colorlineup1   =         input.color    (color.rgb(169, 9, 9), "Liquidity up big candle")
colorlinedown  =         input.color    (color.rgb(6, 6, 6), "Liquidity down")
colorlinedown1 =         input.color    (color.rgb(255, 255, 255), "Liquidity down big candle")
// Define the percentage for big candles
bigCandleThreshold =     input.int      (70, minval=1, maxval=99, title="Big Candle Threshold Percentage")
bigCandleThreshold1 =    input.int      (80, minval=1, maxval=99, title="Big Candle Threshold Percentage")
bars01 = true
//==============================/////////////==========================}
// PBar Percentages
tot01O = Pwick * 0.01
tot01OO = 1 - tot01O
range1 = high - low
//==============================/////////////==========================}
// PinBars
pBarUp() =>  open > high - (range1 * tot01OO) and close > high - (range1 * tot01OO)
pBarDn() => open < high - (range1 * tot01O) and close < high - (range1 * tot01O)
//==============================/////////////==========================}
// Calculate the moving average of the range of previous candles
avgRange = ta.sma(range1, look_back)
//==============================/////////////==========================}
// Create a condition to identify big candles
isBigCandle = range1 > (avgRange * bigCandleThreshold / 100)
isBigCandle1 = range1 > (avgRange * bigCandleThreshold1 / 100)
//==============================/////////////==========================}
// Find the price of the top wick of pBarUp only for big candles
var float pBarUpWickTopPrice = na
if (pBarUp() and isBigCandle)
    line.new(x1=bar_index, y1=low, x2=bar_index + 20, y2=low, color=colorlinedown, width=1)
if (pBarUp() and isBigCandle1)
    line.new(x1=bar_index, y1=low, x2=bar_index + 20, y2=low, color=colorlinedown1, width=2)
//==============================/////////////==========================}
// Find the price of the bottom wick of pBarDn only for big candles
var float pBarDnWickBottomPrice = na
if (pBarDn() and isBigCandle)
    line.new(x1=bar_index, y1=high, x2=bar_index + 20, y2=high, color=colorlineup, width=1)
if (pBarDn() and isBigCandle1)
    line.new(x1=bar_index, y1=high, x2=bar_index + 20, y2=high, color=colorlineup1, width=2)
//==============================/////////////==========================}
//==============================/////////////==========================}
