Secure Ai 2.5
Secure Ai 2.5
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// @version=5
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ User Inputs
-----------------------------------------------------------------------------------
------ }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ----------------------------------- }}
// ------------- signal settings ----- }}
// ----------------------------------- }}
// ----------------------------------- }}
// ------------- trend dashboard ----- }}
// ----------------------------------- }}
// ----------------------------------- }}
// ------------ color palletes ------- }}
// ----------------------------------- }}
// ----------------------------------- }}
// ------------ risk management ------ }}
// ----------------------------------- }}
TPrisk = 2
TPpoints = true
// ----------------------------------- }}
// ------------- call functions ------ }}
// ----------------------------------- }}
normalbuy = input(false, 'Buy⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀', group = alertGroup,
inline='normal signals')
normalsell = input(false, 'Sell', 'Sends An Alert Everytime A Normal Sell
Signal Is Placed \n\nSends An Alert Evertime A Normal Buy Signal Is Placed'
, group = alertGroup, inline='normal signals')
strongbuy = input(false, 'Strong Buy⠀⠀⠀⠀⠀', group = alertGroup,
inline='strong signals')
strongsell = input(false, 'Strong Sell', 'Sends An Alert Everytime A Strong
Sell Signal Is Placed \n\nSends An Alert Evertime A Strong Buy Signal Is Placed'
, group = alertGroup, inline='strong signals')
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------- Color Schemes
-----------------------------------------------------------------------------------
--- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// Pallet Input
// Pallet Switch
Color_Pallet = switch colorScheme
"Bright Light" => Light_Pallet
"Standard Mode" => Default_Pallet
"Delta Mode" => Delta_Pallet
"Freezer Mode" => Ice_Pallet
"None" => NA_Palett
// Color Assign
color_1 = array.get(Color_Pallet, 0) // Buy - Primary
color_2 = array.get(Color_Pallet, 1) // Buy - Secondary
color_3 = array.get(Color_Pallet, 2) // Sell - Primary
color_4 = array.get(Color_Pallet, 3) // Sell - Secondary
color_5 = array.get(Color_Pallet, 4) // Supporting 1
color_6 = array.get(Color_Pallet, 5) // Supporting 2
color_7 = array.get(Color_Pallet, 6) // Neutral
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Signal Concepts
-----------------------------------------------------------------------------------
-- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ----------------------------------- }}
// ----------- gloabl variables ------ }}
// ----------------------------------- }}
src = close
// ----------------------------------- }}
// ------------- signal concept ------ }}
// ----------------------------------- }}
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
// signal sensitivity
smrng = smoothrng(close, agil, (sensitivity + 12) / 10)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
Periods = 24
Multiplier = 2
atr = ta.sma(ta.tr, Periods)
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1x ? 1 : trend == 1 and close < up1x ? -1 :
trend
Trend = 0.0
TrendUp = 0.0
TrendDown = 0.0
TrendUp := close[1] > TrendUp[1] ? math.max(upx, TrendUp[1]) : upx
TrendDown := close[1] < TrendDown[1] ? math.min(dnx, TrendDown[1]) : dnx
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or src > filt and src <
src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or src < filt and src
> src[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
// ----------------------------------- }}
// ------------ signal conditions ---- }}
// ----------------------------------- }}
Long_Signal_Strength = 0
Short_Signal_Strength = 0
if buyCond or strongBuyCond
if ta.ema(close, 85) < close
Long_Signal_Strength += 1
if alrRevUp
Long_Signal_Strength += 1
if dynamicBull
Long_Signal_Strength += 1
if lowVol
Long_Signal_Strength += 1
if strongBuyCond
Long_Signal_Strength += 1
if sellCond or strongSellCond
if ta.ema(close, 85) > close
Short_Signal_Strength += 1
if alrRevDn
Short_Signal_Strength += 1
if dynamicBear
Short_Signal_Strength += 1
if highVol
Short_Signal_Strength += 1
if strongSellCond
Short_Signal_Strength += 1
// ----------------------------------- }}
// ------------- other variable ------ }}
// ----------------------------------- }}
// ----------------------------------- }}
// ----------- Plotting Signals ------ }}
// ----------------------------------- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Candle Concepts
-----------------------------------------------------------------------------------
-- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
color barcolor = na
// terms
// conditions change
//if CandleColor == 'ConfirmationPlus'
// barcolor := macd2 > 0 and upward > downward ? #00db0a : macd2 < 0 and upward
< downward ? #ff0000 : #56328f
//barcolor := upward > downward and hist > 0 ? #00db0a : upward < downward and
hist < 0 ? #ff0000 : #7e7e7e
if CandleColor == 'TrendEdge'
barcolor := upward > downward ? color.new(color_1, 5) : upward < downward ?
color.new(color_3, 5) : color.new(color_5, 0)
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// -------------------------------------- Ecko Cloud
-----------------------------------------------------------------------------------
---- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------- Trend Sniper
-----------------------------------------------------------------------------------
---- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
sniperUp = 0.0
sniperUp := trndSniper > trndSniper[1] ? nz(sniperUp[1]) + 1 : trndSniper <
trndSniper[1] ? 0 : nz(sniperUp[1])
sniperDn = 0.0
sniperDn := trndSniper < trndSniper[1] ? nz(sniperDn[1]) + 1 : trndSniper >
trndSniper[1] ? 0 : nz(sniperDn[1])
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------- Dyanmics Trend
-----------------------------------------------------------------------------------
-- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
//plot
plot(dynamicTrend ? trailingStop : na, title='Dynamic Trail', color=close <
trailingStop ? color.new(color_3, 0) : color.new(color_1, 0))
// ai stuff
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Radient Assistance
----------------------------------------------------------------------------------
}}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Reversal Cloud
-----------------------------------------------------------------------------------
--- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
s = ta.lowest(10)
r = ta.highest(10)
fill(r1, r2, title = "Reversal Cloud (R1, R2)", color = color.new(#e92d3d, 80))
//#f74444
fill(r2, r3, title = "Reversal Cloud (R2, R3)", color = color.new(#e92d3d, 65))
fill(s1, s2, title = "Reversal Cloud (S1, S2)", color = color.new(#089969, 80))
//#089969
fill(s2, s3, title = "Reversal Cloud (S2, S3)", color = color.new(#089969, 65))
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Dashboard Concepts
----------------------------------------------------------------------------------
}}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
length = 20
smoothing = "RMA"
length_2 = 200
if Volitility == "High"
highVol := true
lowVol := false
if Volitility == "Low"
lowVol := true
lowVol := false
// ------------------------------------------------------------------ }}
// ----------- Trade Backtesting ------------------------------------ }}
// ------------------------------------------------------------------ }}
//tradeBacktest() =>
var trades = 0, var wins = 0, var losses = 0
if (buyCond or strongBuyCond)
trades += 1
if (sellCond or strongSellCond)
lastBuyValue = ta.valuewhen(buyCond or strongBuyCond, close, 0)
currentValue = close
if lastBuyValue < currentValue
wins += 1
else
losses += 1
//trend strength
strength = ta.sma(nz(math.abs((open - close) / (high - low) * 100)), 10)
//plotting dashboard
var dashboard_loc = locationDashboard == "Top Right" ? position.top_right :
locationDashboard == "Middle Right" ? position.middle_right : locationDashboard ==
"Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ?
position.top_center : locationDashboard == "Middle Center" ? position.middle_center
: locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard
== "Top Left" ? position.top_left : locationDashboard == "Middle Left" ?
position.middle_left : position.bottom_left
var dashboard_size = sizeDashboard == "Large" ? size.large : sizeDashboard ==
"Normal" ? size.normal : sizeDashboard == "Small" ? size.small : sizeDashboard ==
"Tiny" ? size.tiny : size.auto
var dashboard = showDashboard ? table.new(dashboard_loc, 4, 6, #1d1c24,
#11121f, 2, color.new(#11121f, 0), 2) : na
dashboard_cell(column, row, txt, signal=false) => table.cell(dashboard, column,
row, txt, 0, 0, signal ? color.new(#ffffff, 5) : color.new(#ffffff, 5),
text_size=dashboard_size)
dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column,
row, col)
dashboard_txt(column, row, col) => table.cell_set_text_color(dashboard, column,
row, col)
dashboard_txt_pos(column, row, align) => table.cell_set_text_halign(dashboard,
column, row, align)
if barstate.islast and showDashboard
dashboard_cell(0, 0 , "Market Strength"), dashboard_txt_pos(0, 0,
text.align_left)//, dashboard_cell_bg(0, 0, color.new(#000000, 25))
dashboard_cell(1, 0 , "Market Volatility"), dashboard_txt_pos(1, 0,
text.align_left)//, dashboard_cell_bg(1, 0, color.new(#000000, 25))
dashboard_cell(0, 1 , str.tostring(strength, format.percent), true)//,
dashboard_txt(1, 0, strength > 80 ? color.new(#7af080, 20) : strength < 20 ?
color.new(#f0675d, 20) : color.new(#ffffff, 5))
dashboard_cell(1, 1 , Volitility), dashboard_cell_bg(1, 1, Volitility ==
"Low" ? #d68812 : #1c51c5)// dashboard_txt_pos(1, 1, text.align_left)
if statisticsDas
dashboard_cell(2, 0, "Profitability")
dashboard_cell(2, 1, str.tostring(trades, "#"))
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ----------------------------------- Reversal Concepts
-----------------------------------------------------------------------------------
- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
reversalUpCond = revU and not revU[1] and not revU[2] and not revU[3] and not
revU[4]and not revU[5]and not revU[6]and not revU[7]and not revU[8]and not
revU[9]and not revU[10]and not revU[11]and not revU[12]and not revU[13]
reversalDownCond = revD and not revD[1] and not revD[2] and not revD[3] and not
revD[4] and not revD[5] and not revD[6] and not revD[7] and not revD[8] and not
revD[9] and not revD[10] and not revD[11] and not revD[12] and not revD[13]
if reversalUpCond
alrRevUp := true
alrRevDn := false
if reversalDownCond
alrRevUp := false
alrRevDn := true
revEbull = rsi < 40 //and open[1] < close and close[1] > open
revEbear = rsi > 58 //and open[1] > close and close[1] < open
eBull = revEbull and open[1] > close[1] and close > open[1]
eBear = revEbear and open[1] < close[1] and close < open[1]
eBull := revEbull and open[1] > close[1] and close > open[1] and not eBull[1] and
not eBull[2] and not eBull[3] and not eBull[4]
eBear := revEbear and open[1] < close[1] and close < open[1] and not eBear[1] and
not eBear[2] and not eBear[3] and not eBear[4]
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ TP/SL Concepts
-----------------------------------------------------------------------------------
--- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// -------------------------------------------------------------- }}
// ---------------- Signal Concepts ----------------------------- }}
// -------------------------------------------------------------- }}
var alrTP1 = false, var alrTPS1 = false, var alrTP2 = false, var alrTPS2 = false,
var alrTP3 = false, var alrTPS3 = false, var alrTP4 = false, var alrTPS4 = false
TP1up = not alrTP1 and ta.crossover(close, tp1lvl) and not sellCond and not
strongSellCond and upward > downward
TP2up = not alrTP2 and ta.crossover(close, tp2lvl) and not sellCond and not
strongSellCond and upward > downward
TP3up = not alrTP3 and ta.crossover(close, tp3lvl) and not sellCond and not
strongSellCond and upward > downward
TP4up = not alrTP4 and ta.crossover(close, tp4lvl) and not sellCond and not
strongSellCond and upward > downward
TP1dn = not alrTPS1 and ta.crossunder(close, tp1lvl) and not buyCond and not
strongBuyCond and upward < downward
TP2dn = not alrTPS2 and ta.crossunder(close, tp2lvl) and not buyCond and not
strongBuyCond and upward < downward
TP3dn = not alrTPS3 and ta.crossunder(close, tp3lvl) and not buyCond and not
strongBuyCond and upward < downward
TP4dn = not alrTPS4 and ta.crossunder(close, tp4lvl) and not buyCond and not
strongBuyCond and upward < downward
if buyCond or strongBuyCond
alrTP1 := false
alrTPS1 := true
alrTP2 := false
alrTPS2 := true
alrTP3 := false
alrTPS3 := true
alrTP4 := false
alrTPS4 := true
if sellCond or strongSellCond
alrTP1 := true
alrTPS1 := false
alrTP2 := true
alrTPS2 := false
alrTP3 := true
alrTPS3 := false
alrTP4 := true
alrTPS4 := false
if TP1up
alrTP1 := true
if TP2up
alrTP2 := true
if TP3up
alrTP3 := true
if TP4up
alrTP4 := true
if TP1dn
alrTPS1 := true
if TP2dn
alrTPS2 := true
if TP3dn
alrTPS3 := true
if TP4dn
alrTPS4 := true
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Alert Concepts
-----------------------------------------------------------------------------------
--- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Ending Barrier
-----------------------------------------------------------------------------------
--- }}
countBull = ta.barssince(bull)
countBear = ta.barssince(bear)
trigger3 = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0
none = close > 0
atr(len) =>
tr = ta.tr
atr = 0.0
atr := nz(atr[1] + (tr - atr[1]) / len, tr)
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
// ------------------------------------ Ending Barrier
-----------------------------------------------------------------------------------
--- }}
//
-----------------------------------------------------------------------------------
------------------------------------------------------- }}
//PIVOTES
////////////////////////////////////////////////////////////////////////////////
//
// ====== ABOUT THIS INDICATOR
//
// - All your common Pivot types in one nifty bundle.
//
// • Have up to three pivot sets.
// • Each pivot set has it's own resolution option.
// • Whatever flavour suits your tastes - each pivot set can be of a
// different type if you truly wish.
//
// ====== SOURCES and CREDITS
//
// - All included pivot calcs were sourced from:
//
// • https://www.tradingview.com/support/solutions/43000521824-pivot-points-
standard/
// • Using the new 'time_close()' function, so thankyou Pine dev's <3
//
// ====== REASON FOR STUDY
//
// - To practice making scalable code for working with similar datasets.
//
// • all the reasons
//
// ====== DISCLAIMER
//
// Any trade decisions you make are entirely your own responsibility.
// I've made an effort to squash all the bugs, but you never know!
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// //
// ====== OPTION LIST VARS ====== //
// //
// * Setting up option list variables outside of the actual input can //
// make them much easier to work with if any comparison checks are //
// required, and can help keep subsequent code clean and readable. //
// //
////////////////////////////////////////////////////////////////////////////////
// -- pivot options
i_piv0 = 'Traditional'
i_piv1 = 'Fibonacci'
i_piv2 = 'Woodie'
i_piv3 = 'Classic'
i_piv4 = 'Demark'
i_piv5 = 'Camarilla'
i_piv6 = 'Fibonacci Extended'
////////////////////////////////////////////////////////////////////////////////
// //
// ====== VAR and ARRAY PRESET ====== //
// //
////////////////////////////////////////////////////////////////////////////////
// -- Preset INT for maximum amount of S|R levels for any single pivot type.
// NOTE - this variable should only be changed if:
// • you extend a pivot to have more than 5 levels of S|R
// • you add a new pivot type wiith more than 5 levels of S|R
var int i_maxLevels = 5
// -- Preset INT for max length of pivot arrays [PP + S max + R max]
// * NOTE: should not be changed.
var int i_maxLength = 1 + i_maxLevels * 2
////////////////////////////////////////////////////////////////////////////////
// //
// ====== INPUTS ====== //
// //
// * Using the new 'inline' feature * //
// //
////////////////////////////////////////////////////////////////////////////////
// -- price labels
// -- styling options
////////////////////////////////////////////////////////////////////////////////
// //
// ====== FUNCTIONS ====== //
// //
////////////////////////////////////////////////////////////////////////////////
f_getResolution(_inputResolution) =>
// string _inputResolution : user selected resolution input
// () Description:
// - Resolver for custom resolution input selection, converts input to
// compatible return string for security, output is also used for less
// verbose label text options.
// Dependencies:
// - i_res1, i_res2, i_res3, i_res4, i_res5, i_res6
// - i_res7, i_res8, i_res9, i_res10, i_res11, i_res12
// Notes:
// - i_res0 excluded as it's a token placeholder for default "60".
f_getLineStyle(_inputStyle) =>
// string _inputStyle : user selected style input
// () resolver for custom line style input selection, returns a usable
// line style type.
// Dependencies:
// - i_line1, i_line2
// Notes:
// * i_line0 omitted as we default to 'line.style_solid' anyway
_return = _array
_return
_return = _array
_return
_return = _array
_return
_return = _array
_return
_return = _array
_return
_return = _array
_return
_return = _array
_return
// set up some temp vars for creating our lines and labels
var line _line = na
var label _labelLeft = na
var label _labelRight = na
var label _labelPrice = na
// clean up old lines and labels before drawing our new set
for i = 1 to array.size(_lines) by 1 // loop and delete 1 by 1
line.delete(array.get(_lines, i - 1))
// the label array is dynamic length, so we..
if array.size(_labels) > 0 // ..check to see if it has content..
for i = 1 to array.size(_labels) by 1 // ..then loop it into the trash
label.delete(array.shift(_labels))
// -- selected resolutions
string _resolutionA = f_getResolution(INP_resolutionA)
//string _resolutionB = f_getResolution( INP_resolutionB )
//string _resolutionC = f_getResolution( INP_resolutionC )
////////////////////////////////////////////////////////////////////////////////
// //
// ====== DRAWING and PLOTTING ====== //
// //
////////////////////////////////////////////////////////////////////////////////
// -- feed in our settings and data to the render function for set A
f_renderPivotArray(_resolutionA, i_settingsA, _pivotFloatsA, _pivotLinesA,
_pivotLabelsA)
//------------------- Money Move TrendLine ----------------------//
// Get user input
var string GROUP_ATL = "Money Moves [TrendLine V2]"
var bool show_tl = input.bool(false, title="Show TrendLine", tooltip="Shows
lower/upper trendlines", group=GROUP_ATL)
var int n = input.int(15, title="Trendline Sensitivity", minval=2, group=GROUP_ATL)
// A Fractal is always a Pivot H/L (but a Pivot H/L is not always a Fractal):
float pivtHigh = ta.pivothigh(n, n)[1]
float PivtLow = ta.pivotlow(n, n)[1]
bool upfract = not na(pivtHigh)
bool downfract = not na(PivtLow)
var string LINE_WIDTH1_STR = "Width 1"
var string LINE_WIDTH2_STR = "Width 2"
// @function : _get_width(), a map {string:int}
_get_width(string str_input) =>
return_int = switch str_input
LINE_WIDTH1_STR => 1
LINE_WIDTH2_STR => 2
return_int
var string subgroup1 = "recent line"
// Inputs:
// {
// Recent fractals.
var float recent_dn1 = low, var int i_recent_dn1 = bar_index
var float recent_up1 = high, var int i_recent_up1 = bar_index
var float recent_dn2 = low, var int i_recent_dn2 = bar_index
var float recent_up2 = high, var int i_recent_up2 = bar_index
// @function cleanup()
// @returns void : To delete excess lines and assign new color to historical lines.
cleanup(line[] arr) =>
if array.size(arr) > 1
line.set_color(array.get(arr, 1), ln_col_prev)
line.set_width(array.get(arr, 1), lnwidth_prev)
while array.size(arr) > math.floor(max_tl/2)
line.delete(array.pop(arr))
// PivtLowotting fractals
bool hh = not na(pivtHigh) and recent_up1 > recent_up2 ? high[n+1] : na
bool lh = not na(pivtHigh) and recent_up1 < recent_up2 ? high[n+1] : na
bool hl = not na(PivtLow) and recent_dn1 > recent_dn2 ? low[n+1] : na
bool ll = not na(PivtLow) and recent_dn1 < recent_dn2 ? low[n+1] : na
float ob = na
array.unshift(ob_top, top)
array.unshift(ob_btm, btm)
array.unshift(ob_avg, avg)
array.unshift(ob_left, time[length])
ob := ob_val
array.remove(ob_top, idx)
array.remove(ob_btm, idx)
array.remove(ob_avg, idx)
array.remove(ob_left, idx)
mitigated
//Functions
//-----------------------------------------------------------------------------{
//Line Style function
get_line_style(style) =>
out = switch style
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
array.unshift(ob_lvl, line.new(na,na,na,na
, xloc = xloc.bar_time
, extend = extend.right
, color = lvl_css
, style = get_line_style(line_style)
, width = line_width))
//-----------------------------------------------------------------------------}
//Global elements
//-----------------------------------------------------------------------------{
var os = 0
var target_bull = 0.
var target_bear = 0.
nn = bar_index
upper = ta.highest(length)
lower = ta.lowest(length)
if mitigation == 'Close'
target_bull := ta.lowest(close, length)
target_bear := ta.highest(close, length)
else
target_bull := lower
target_bear := upper
//-----------------------------------------------------------------------------}
//Get bullish/bearish order blocks coordinates
//-----------------------------------------------------------------------------{
[bull_top , bull_btm , bull_avg , bull_left , bull_ob] = get_coordinates(phv and os
== 1, hl2[length], low[length], low[length])
//-----------------------------------------------------------------------------}
//Remove mitigated order blocks
//-----------------------------------------------------------------------------{
mitigated_bull = remove_mitigated(bull_top , bull_btm , bull_left , bull_avg ,
target_bull , true)
//-----------------------------------------------------------------------------}
//Display order blocks
//-----------------------------------------------------------------------------{
//Set bullish order blocks
set_order_blocks(bull_top , bull_btm , bull_left , bull_avg , bull_ext_last ,
bg_bull_css , bull_css , bull_avg_css)