Mad Liquidity
Mad Liquidity
indicator(title='MadLiquidity', shorttitle='ML')
//Stochastic Calculation
k = ta.sma(ta.stoch(close, high, low, length), smoothK)
//Stochastic Plots
plot(k, title='Stochastic', style=plot.style_line, linewidth=4, color=col)
p1 = plot(uline, title='Upper Line', style=plot.style_line, linewidth=4,
color=color.new(color.green, 0))
p2 = plot(100, title='100 Line', color=color.new(color.white, 0))
fill(p1, p2, title='Long Trade Fill Color', color=color.new(color.green, 90))
p3 = plot(lline, title='Lower Line', style=plot.style_line, linewidth=4,
color=color.new(color.red, 0))
p4 = plot(0, title='0 Line', color=color.new(color.white, 0))
fill(p1, p3, title='No Trade Fill Color', color=color.new(color.blue, 90))
fill(p3, p4, title='Short Trade Fill Color', color=color.new(color.red, 90))
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
hi_band = rng_filt1 + r
lo_band = rng_filt1 - r
rng_filt = rng_filt1
[hi_band, lo_band, rng_filt]
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Inputs
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Range Source
rng_src = input(defval=close, title='Swing Source')
//Range Period
rng_per = input.int(defval=20, minval=1, title='Swing Period')
//Bar Colors
use_barcolor = input(defval=false, title='Bar Colors On/Off')
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Definitions
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Direction Conditions
var fdir = 0.0
fdir := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir
upward = fdir == 1 ? 1 : 0
downward = fdir == -1 ? 1 : 0
//Trading Condition
longCond = rng_src > filt and rng_src > rng_src[1] and upward > 0 or rng_src > filt
and rng_src < rng_src[1] and upward > 0
shortCond = rng_src < filt and rng_src < rng_src[1] and downward > 0 or rng_src <
filt and rng_src > rng_src[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1
//Colors
filt_color = upward ? #05ff9b : downward ? #ff0583 : #cccccc
bar_color = upward and rng_src > filt ? rng_src > rng_src[1] ? #05ff9b : #00b36b :
downward and rng_src < filt ? rng_src < rng_src[1] ? #ff0583 : #b8005d : #cccccc
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Outputs
//---------------------------------------------------------------------------------
--------------------------------------------------------------------------------
//Filter Plot
filt_plot = plot(filt, color=filt_color, linewidth=3, title='Filter',
transp=67,force_overlay = true)
//Band Plots
h_band_plot = plot(h_band, color=color.new(#05ff9b, 100), title='High
Band',force_overlay = true)
l_band_plot = plot(l_band, color=color.new(#ff0583, 100), title='Low
Band',force_overlay = true)
//Band Fills
fill(h_band_plot, filt_plot, color=color.new(#00b36b, 92), title='High Band Fill')
fill(l_band_plot, filt_plot, color=color.new(#b8005d, 92), title='Low Band Fill')
//Bar Color
barcolor(use_barcolor ? bar_color : na)
//Alerts
alertcondition(longCondition, title='Buy Alert', message='BUY')
alertcondition(shortCondition, title='Sell Alert', message='SELL')
//---------------------------------------------------------------------------------
------------------------------------}
//Settings
//---------------------------------------------------------------------------------
------------------------------------{
//Styling
//---------------------------------------------------------------------------------
------------------------------------}
//Functions
//---------------------------------------------------------------------------------
------------------------------------{
//Swings detection/measurements
n = bar_index
swings(len)=>
var os = 0
upper = ta.highest(len)
lower = ta.lowest(len)
//---------------------------------------------------------------------------------
------------------------------------}
//Swings
//---------------------------------------------------------------------------------
------------------------------------{
var os = 0
//---------------------------------------------------------------------------------
------------------------------------}
//CHoCH Detection
//---------------------------------------------------------------------------------
------------------------------------{
if top
topy := top
top_crossed := false
if btm
btmy := btm
btm_crossed := false
os := 1
top_crossed := true
os := 0
btm_crossed := true
//Display CHoCH
if os != os[1]
max := high
min := low
max_x1 := n
min_x1 := n
stop_crossed := false
sbtm_crossed := false
if os == 1 and showChoch
else if showChoch
stopy = fixnan(stop)
sbtmy = fixnan(sbtm)
//---------------------------------------------------------------------------------
------------------------------------}
//Bullish BOS
//---------------------------------------------------------------------------------
------------------------------------{
//IDM
if low < sbtmy and not sbtm_crossed and os == 1 and sbtmy != btmy
if showIdm
sbtm_crossed := true
//BOS
if showBos
sbtm_crossed := false
//---------------------------------------------------------------------------------
------------------------------------}
//Bearish BOS
//---------------------------------------------------------------------------------
------------------------------------{
//IDM
if high > stopy and not stop_crossed and os == 0 and stopy != topy
if showIdm
stop_crossed := true
//BOS
if showBos
stop_crossed := false
//---------------------------------------------------------------------------------
------------------------------------}
//Sweeps
//---------------------------------------------------------------------------------
------------------------------------{
if high > max and close < max and os == 1 and n - max_x1 > 1 and showSweeps
if low < min and close > min and os == 0 and n - min_x1 > 1 and showSweeps
//Trailing max/min
max_x1 := n
min_x1 := n
//---------------------------------------------------------------------------------
------------------------------------}
//Extensions
//---------------------------------------------------------------------------------
------------------------------------{
if os == 1
ext_choch_lbl.set_xy(n, btmy),
ext_choch_lbl.set_style(label.style_label_up), ext_choch_lbl.set_textcolor(bearCss)
if not sbtm_crossed
ext_idm_lbl.set_xy(n+15, sbtmy),
ext_idm_lbl.set_style(label.style_label_up)
ext_idm.set_color(idmCss), ext_idm_lbl.set_textcolor(idmCss)
else
ext_idm.set_color(na)
ext_idm_lbl.set_textcolor(na)
else
ext_choch_lbl.set_xy(n, topy),
ext_choch_lbl.set_style(label.style_label_down),
ext_choch_lbl.set_textcolor(bullCss)
if not stop_crossed
ext_idm_lbl.set_xy(n+15, stopy),
ext_idm_lbl.set_style(label.style_label_down)
ext_idm.set_color(idmCss), ext_idm_lbl.set_textcolor(idmCss)
else
ext_idm.set_color(na)
ext_idm_lbl.set_textcolor(na)
//---------------------------------------------------------------------------------
------------------------------------}
//Plots
//---------------------------------------------------------------------------------
------------------------------------{
//---------------------------------------------------------------------------------
------------------------------------}
///////////////////////////////////////////////////////////////////////////////////
///////////////
FVG//////////////////////////////////////////////////////////////////
//
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
n12 = bar_index
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//UDT's
//-----------------------------------------------------------------------------{
type piv
line lin
type boxBr
box bx
line ln
bool br
int dr
//-----------------------------------------------------------------------------}
//Variables
//-----------------------------------------------------------------------------{
//-----------------------------------------------------------------------------}
//Methods - functions
//-----------------------------------------------------------------------------{
method p(piv piv, float val) => float out = (100 / piv.prc * val) - 100
=> line.style_solid
y1 = d == 1 ? high : get.prc
y2 = d == 1 ? get.prc : low
boxBr.new(
, border_color
= color.new(
na, na )
, bgcolor=c3,force_overlay = true)
, line.new(n12 , y1, n12, y2, color=c, width=3,force_overlay = true)
, false
, d)
//-----------------------------------------------------------------------------}
//Execution
//-----------------------------------------------------------------------------{
ph = ta.pivothigh(len12, len12)
if ph.n()
if pl.n()
for i = aPivH.size() -1 to 0
get = aPivH.get(i)
if not get.mit
if not get.brk
if not oW
get.brk := true
else
get.mit := true
get.wic := true
else
if close < get.prc
get.mit := true
get.tak := true
aPivH.remove(i).lin.delete()
for i = aPivL.size() -1 to 0
get = aPivL.get(i)
if not get.mit
if not get.brk
get.brk := true
else
get.mit := true
get.wic := true
else
get.mit := true
aPivL.remove(i).lin.delete()
if extend
for bx in aBoxBr
bx.bx.set_right(bar_index)
bx.br := true
bx.br := true
//-----------------------------------------------------------------------------}
// Inputs
src = close
// MA Functions
x = ta.sma(data, u1)
a = math.sum(volume, u1)
r = 0.0
//
b = -a + math.sqrt(math.pow(a, 2) + 2 * a)
r = 0.0
//
a = u1 < 3 ? 1 : u1 / 2
b = u1 < 3 ? 1 : u1 / 3
//
a = ta.ema(data, u1)
r = 0.0
//
// TSF [Time Series Function]
// MA Return
na
//
// Variables
x = factor
y = factor + 1
z = f_ma(src, length2)
n1 = f_ma(z, length2)
a0 = f_ma(n1, length2)
a1 = f_ma(a0, length2)
b0 = -1 * 1 * math.pow(x, 1) * math.pow(y, 0)
b1 = +1 * 1 * math.pow(x, 0) * math.pow(y, 1)
r = b0 * a1 + b1 * a0
//
a0 = f_ma(n1, length2)
a1 = f_ma(a0, length2)
a2 = f_ma(a1, length2)
b0 = +1 * 1 * math.pow(x, 2) * math.pow(y, 0)
b1 = -1 * 2 * math.pow(x, 1) * math.pow(y, 1)
b2 = +1 * 1 * math.pow(x, 0) * math.pow(y, 2)
r = b0 * a2 + b1 * a1 + b2 * a0
//
a0 = f_ma(n1, length2)
a1 = f_ma(a0, length2)
a2 = f_ma(a1, length2)
a3 = f_ma(a2, length2)
b0 = -1 * 1 * math.pow(x, 3) * math.pow(y, 0)
b1 = +1 * 3 * math.pow(x, 2) * math.pow(y, 1)
b2 = -1 * 3 * math.pow(x, 1) * math.pow(y, 2)
b3 = +1 * 1 * math.pow(x, 0) * math.pow(y, 3)
r = b0 * a3 + b1 * a2 + b2 * a1 + b3 * a0
//
a0 = f_ma(n1, length2)
a1 = f_ma(a0, length2)
a2 = f_ma(a1, length2)
a3 = f_ma(a2, length2)
a4 = f_ma(a3, length2)
b0 = +1 * 1 * math.pow(x, 4) * math.pow(y, 0)
b1 = -1 * 4 * math.pow(x, 3) * math.pow(y, 1)
b2 = +1 * 6 * math.pow(x, 2) * math.pow(y, 2)
b3 = -1 * 4 * math.pow(x, 1) * math.pow(y, 3)
b4 = +1 * 1 * math.pow(x, 0) * math.pow(y, 4)
r = b0 * a4 + b1 * a3 + b2 * a2 + b3 * a1 + b4 * a0
//
a0 = f_ma(n1, length2)
a1 = f_ma(a0, length2)
a2 = f_ma(a1, length2)
a3 = f_ma(a2, length2)
a4 = f_ma(a3, length2)
a5 = f_ma(a4, length2)
b0 = -1 * 1 * math.pow(x, 5) * math.pow(y, 0)
b1 = +1 * 5 * math.pow(x, 4) * math.pow(y, 1)
b2 = -1 * 10 * math.pow(x, 3) * math.pow(y, 2)
b3 = +1 * 10 * math.pow(x, 2) * math.pow(y, 3)
b4 = -1 * 5 * math.pow(x, 1) * math.pow(y, 4)
b5 = +1 * 1 * math.pow(x, 0) * math.pow(y, 5)
r = b0 * a5 + b1 * a4 + b2 * a3 + b3 * a2 + b4 * a1 + b5 * a0
//
// Out
out =
//
Out3 = Call_out('3')
Out15 = Call_out('15')
Out5 = Call_out('5')
Out1 = Call_out('1')
// Print
// Bitti