Indicator Luxalgo Price Action Concept For TradingView
Indicator Luxalgo Price Action Concept For TradingView
0
at https://mozilla.org/MPL/2.0/
//---------------------------------------------------------------------------------
------------------------------------}
// Settings
//---------------------------------------------------------------------------------
------------------------------------{
spTP = 'displays the sentiment, the dominat party over a specified time period at
the specific price levels\n\n' +
' - bullish node rows : buying trading activity/money flow is higher\n'
+
' - barish node rows : selling trading activity/money flow is higher\n\n'
+
'row lengths, indicates the strength of the buyers/sellers at the
specific price levels'
spSH = input.bool(false, 'Sentiment Profile', group = vpGR, tooltip = spTP)
pcTP = 'displays the price level of the highest traded activity/money flow or the
changes of the price levels with the highest traded activity/money flow'
rpPC = input.string('Last(Zone)', ' Level of Significance', options =
['Developing', 'Last(Line)', 'Last(Zone)', 'None'], inline='PoC', group = othGR,
tooltip = pcTP, display = disp)
spTT = 'displays the price zone of the highest bullish or bearish sentiment zone'
spPC = input.bool(false, 'Highest Sentiment Zone', inline = 'spP', group = othGR,
tooltip = spTT)
rpNR = input.int(25, ' Number of Rows' , minval = 10, maxval = 100 ,step = 5,
group = otGR, tooltip = 'option range [10-100]', display = disp)
rpW = input.int(13, ' Profile Width %', minval = 10, maxval = 50, group =
otGR, tooltip = 'option range [10-50]', display = disp) / 100
vpLS = input.string('Auto', " Profile Text Size", options=['Auto', 'Tiny',
'Small'], group = otGR, display = disp)
vpHO = input.int(13, ' Profile Horizontal Offset', group = otGR, tooltip =
'option allows negative numbers as well, in case of a use the profiles will overlap
with the price chart', display = disp)
//---------------------------------------------------------------------------------
------------------------------------}
// User Defined Types
//---------------------------------------------------------------------------------
------------------------------------{
type bar
float o = open
float h = high
float l = low
float c = close
float v = volume
int i = bar_index
int n = bar_index
int t = time
//---------------------------------------------------------------------------------
------------------------------------}
// Variables
//---------------------------------------------------------------------------------
------------------------------------{
bar b = bar.new()
//---------------------------------------------------------------------------------
------------------------------------}
// Functions/Methods
//---------------------------------------------------------------------------------
------------------------------------{
// @function creates new label object and updates existing label objects
//
// @param details in Pine Script™ language reference manual
//
// @returns none, updated visual objects (labels)
f_gTS(_t) =>
switch _t
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal
'Auto' => size.auto
//---------------------------------------------------------------------------------
------------------------------------}
// Calculations
//---------------------------------------------------------------------------------
------------------------------------{
bull = spPTY == spPT1 ? b.c > b.o : (b.c - b.l) > (b.h - b.c)
nzV = nz(b.v)
rpS = f_gTS(rpLS)
vpS = f_gTS(vpLS)
if barstate.islast and not na(nzV) and not timeframe.isseconds and rpLN > 0 and
pSTP > 0 and nzV > 0
if dRP.size() > 0
for i = 0 to dRP.size() - 1
box.delete(dRP.shift())
if pocPoints.size() > 0
pocPoints.clear()
a_allPolylines = polyline.all
if array.size(a_allPolylines) > 0
for i = 0 to array.size(a_allPolylines) - 1
polyline.delete(a_allPolylines.get(i))
for bI = rpLN to 0
l = 0
for pLL = pLST to pHST - pSTP by pSTP
if b.h[bI] >= pLL and b.l[bI] < pLL + pSTP
if rpPC == 'Developing'
if bI == rpLN
pocPoints.push(chart.point.from_index(b.i[bI], pLST +
(rpVST.indexof(rpVST.max()) + .5) * pSTP))
else
pocPoints.push(chart.point.from_index(b.i[bI], pLST +
(rpVST.indexof(rpVST.max()) + .5) * pSTP))
for l = 0 to rpNR - 1
bbp = 2 * rpVSB.get(l) - rpVST.get(l)
rpVSD.set(l, rpVSD.get(l) + bbp * (bbp > 0 ? 1 : -1) )
if vpSH and Showprofle or spSH and Showprofle
sBI = b.i + (spSH ? rpLN * rpW : 7) + int(rpLN * rpW / 3)
dRP.push(box.new(sBI - 1 + vpHO, pLST + (l + .1) * pSTP, sBI - int(rpLN
* rpW / 3) + 1 + vpHO, pLST + (l + .9) * pSTP, #2962ff80, bgcolor = #2962ff10,
text = str.tostring(pLST + (l + .5) * pSTP,
format.mintick), text_color = chart.fg_color, text_size = vpS ))
for l = 0 to rpNR - 1
if dRP.size() < 500
vtLV = rpVST.get(l)
vtMX = rpVST.max()
LpM = vtLV / vtMX
vdMX = rpVSD.max()
DpM = rpVSD.get(l) / vdMX
if vaSH and LpM > vaTH and LpM < 1 and Showprofle
dRP.push(box.new(b.i[rpLN], pLST + (l + .0) * pSTP, b.i, pLST + (l
+ 1.) * pSTP, color(na), bgcolor = vaC ))
//---------------------------------------------------------------------------------
------------------------------------}
//---------------------------------------------------------------------------------
------------------------------------}
//---------------------------------------------------------------------------------
------------------------------------}
//---------------------------------------------------------------------------------
------------------------------------}
//---------------------------------------------------------------------------------
------------------------------------}
//---------------------------------------------------------------------------------
------------------------------------}
showRevBands = input.bool(true, "Show Reversal Bands", group='Indicator
option')
lenRevBands = input.int(30, "Length", group="REVERSAL BANDS")
f_kc(src, len, sensitivity) =>
basis = ta.sma(src, len)
span = ta.atr(len)
[basis + span * sensitivity, basis - span * sensitivity]
BULLISH = +1
BEARISH = -1
GREEN = #089981
RED = #F23645
BLUE = #2157f3
GRAY = #878b94
MONO_BULLISH = #b2b5be
MONO_BEARISH = #5d606b
HISTORICAL = 'Historical'
PRESENT = 'Present'
COLORED = 'Colored'
MONOCHROME = 'Monochrome'
ALL = 'All'
BOS = 'BOS'
CHOCH = 'CHoCH'
TINY = size.tiny
SMALL = size.small
NORMAL = size.normal
ATR = 'Atr'
RANGE = 'Cumulative Mean Range'
CLOSE = 'Close'
HIGHLOW = 'High/Low'
SOLID = '⎯⎯⎯'
DASHED = '----'
DOTTED = '····'
//---------------------------------------------------------------------------------
------------------------------------}
//DATA STRUCTURES & VARIABLES
//---------------------------------------------------------------------------------
------------------------------------{
// @type UDT representing alerts as bool fields
// @field internalBullishBOS internal structure custom alert
// @field internalBearishBOS internal structure custom alert
// @field internalBullishCHoCH internal structure custom alert
// @field internalBearishCHoCH internal structure custom alert
// @field swingBullishBOS swing structure custom alert
// @field swingBearishBOS swing structure custom alert
// @field swingBullishCHoCH swing structure custom alert
// @field swingBearishCHoCH swing structure custom alert
// @field internalBullishOrderBlock internal order block custom alert
// @field internalBearishOrderBlock internal order block custom alert
// @field swingBullishOrderBlock swing order block custom alert
// @field swingBearishOrderBlock swing order block custom alert
// @field equalHighs equal high low custom alert
// @field equalLows equal high low custom alert
// @field bullishFairValueGap fair value gap custom alert
// @field bearishFairValueGap fair value gap custom alert
type alerts
bool internalBullishBOS = false
bool internalBearishBOS = false
bool internalBullishCHoCH = false
bool internalBearishCHoCH = false
bool swingBullishBOS = false
bool swingBearishBOS = false
bool swingBullishCHoCH = false
bool swingBearishCHoCH = false
bool internalBullishOrderBlock = false
bool internalBearishOrderBlock = false
bool swingBullishOrderBlock = false
bool swingBearishOrderBlock = false
bool equalHighs = false
bool equalLows = false
bool bullishFairValueGap = false
bool bearishFairValueGap = false
bool chochswing = false
bool chochplusswing = false
bool swingbos = false
bool chochplus = false
bool choch = false
bool bos = false
bool ob = false
bool swingob = false
bool obtouch = false
//---------------------------------------------------------------------------------
------------------------------------}
//USER-DEFINED FUNCTIONS
//---------------------------------------------------------------------------------
------------------------------------{
// @function Get the value of the current leg, it can be 0 (bearish) or
1 (bullish)
// @returns int
leg(int size) =>
var leg = 0
newLegHigh = high[size] > ta.highest( size)
newLegLow = low[size] < ta.lowest( size)
if newLegHigh
leg := BEARISH_LEG
else if newLegLow
leg := BULLISH_LEG
leg
if modeInput == PRESENT
l_abel.delete()
l_abel :=
label.new(chart.point.new(labelTime,na,labelPrice),tag,xloc.bar_time,color=color(na
),textcolor=labelColor,style = labelStyle,size = size.small)
if equalHigh
tag := 'EQH'
equalColor := swingBearishColor
labelStyle := label.style_label_down
if modeInput == PRESENT
line.delete( e_qualDisplay.l_ine)
label.delete( e_qualDisplay.l_abel)
e_qualDisplay.l_ine :=
line.new(chart.point.new(p_ivot.barTime,na,p_ivot.currentLevel),
chart.point.new(time[size],na,level), xloc = xloc.bar_time, color = equalColor,
style = line.style_dotted)
labelPosition = math.round(0.5*(p_ivot.barIndex + bar_index - size))
e_qualDisplay.l_abel := label.new(chart.point.new(na,labelPosition,level),
tag, xloc.bar_index, color = color(na), textcolor = equalColor, style = labelStyle,
size = equalHighsLowsSizeInput)
// @function store current structure and trailing swing points, and also
display swing points and equal highs/lows
// @param size (int) structure size
// @param equalHighLow (bool) true for displaying current highs/lows
// @param internal (bool) true for getting internal structures
// @returns label ID
getCurrentStructure(int size,bool equalHighLow = false, bool internal = false) =>
currentLeg = leg(size)
newPivot = startOfNewLeg(currentLeg)
pivotLow = startOfBullishLeg(currentLeg)
pivotHigh = startOfBearishLeg(currentLeg)
if newPivot
if pivotLow
pivot p_ivot = equalHighLow ? equalLow : internal ? internalLow :
swingLow
p_ivot.lastLevel := p_ivot.currentLevel
p_ivot.currentLevel := low[size]
p_ivot.crossed := false
p_ivot.barTime := time[size]
p_ivot.barIndex := bar_index[size]
p_ivot.lastLevel := p_ivot.currentLevel
p_ivot.currentLevel := high[size]
p_ivot.crossed := false
p_ivot.barTime := time[size]
p_ivot.barIndex := bar_index[size]
if modeInput == PRESENT
l_ine.delete()
l_abel.delete()
l_ine := line.new(chart.point.new(p_ivot.barTime,na,p_ivot.currentLevel),
chart.point.new(time,na,p_ivot.currentLevel), xloc.bar_time, color=structureColor,
style=lineStyle)
l_abel :=
label.new(chart.point.new(na,math.round(0.5*(p_ivot.barIndex+bar_index)),p_ivot.cur
rentLevel), tag, xloc.bar_index, color=color(na), textcolor=structureColor,
style=labelStyle, size = labelSize)
// @function detect and draw structures, also detect and store order
blocks
// @param internal true for internal structures or order blocks
// @returns void
displayStructure(bool internal = false) =>
var bullishBar = true
var bearishBar = true
if internalFilterConfluenceInput
bullishBar := high - math.max(close, open) > math.min(close, open - low)
bearishBar := high - math.max(close, open) < math.min(close, open - low)
if internal
currentAlerts.internalBullishCHoCH := tag == CHOCH
currentAlerts.internalBullishBOS := tag == BOS
else
currentAlerts.swingBullishCHoCH := tag == CHOCH
currentAlerts.swingBullishBOS := tag == BOS
p_ivot.crossed := true
t_rend.bias := BULLISH
if displayCondition
drawStructure(p_ivot,tag,bullishColor,lineStyle,label.style_label_down,labelSize)
if internal
currentAlerts.internalBearishCHoCH := tag == CHOCH
currentAlerts.internalBearishBOS := tag == BOS
else
currentAlerts.swingBearishCHoCH := tag == CHOCH
currentAlerts.swingBearishBOS := tag == BOS
p_ivot.crossed := true
t_rend.bias := BEARISH
if displayCondition
drawStructure(p_ivot,tag,bearishColor,lineStyle,label.style_label_up,labelSize)
// @function get line style from string
// @param style line style
// @returns string
getStyle(string style) =>
switch style
SOLID => line.style_solid
DASHED => line.style_dashed
DOTTED => line.style_dotted
if not sameTimeframe
int leftIndex = times.binary_search_rightmost(parsedLeftTime)
int rightIndex =
times.binary_search_rightmost(parsedRightTime)
var line topLine = line.new(na, na, na, na, xloc = xloc.bar_time, color
= levelColor, style = getStyle(style))
var line bottomLine = line.new(na, na, na, na, xloc = xloc.bar_time, color
= levelColor, style = getStyle(style))
var label topLabel = label.new(na, na, xloc = xloc.bar_time, text =
str.format('P{0}H',timeframe), color=color(na), textcolor = levelColor, size =
size.small, style = label.style_label_left)
var label bottomLabel = label.new(na, na, xloc = xloc.bar_time, text =
str.format('P{0}L',timeframe), color=color(na), textcolor = levelColor, size =
size.small, style = label.style_label_left)
topLine.set_first_point( chart.point.new(parsedTopTime,na,parsedTop))
topLine.set_second_point( chart.point.new(last_bar_time + 20 * (time-
time[1]),na,parsedTop))
topLabel.set_point( chart.point.new(last_bar_time + 20 * (time-
time[1]),na,parsedTop))
bottomLine.set_first_point( chart.point.new(parsedBottomTime,na,parsedBottom))
bottomLine.set_second_point(chart.point.new(last_bar_time + 20 * (time-
time[1]),na,parsedBottom))
bottomLabel.set_point( chart.point.new(last_bar_time + 20 * (time-
time[1]),na,parsedBottom))
b_ox.set_top_left_point( chart.point.new(trailing.barTime,na,top))
b_ox.set_bottom_right_point(chart.point.new(last_bar_time,na,bottom))
l_abel.set_point( chart.point.new(na,labelIndex,labelLevel))
//---------------------------------------------------------------------------------
------------------------------------}
//MUTABLE VARIABLES & EXECUTION
//---------------------------------------------------------------------------------
------------------------------------{
parsedOpen = showTrendInput ? open : na
candleColor = internalTrend.bias == BULLISH ? swingBullishColor : swingBearishColor
plotcandle(parsedOpen,high,low,close,color = candleColor, wickcolor = candleColor,
bordercolor = candleColor)
if showHighLowSwingsInput or showPremiumDiscountZonesInput
updateTrailingExtremes()
if showHighLowSwingsInput
drawHighLowSwings()
if showPremiumDiscountZonesInput
drawPremiumDiscountZones()
getCurrentStructure(swingsLengthInput,false)
getCurrentStructure(5,false,true)
if showEqualHighsLowsInput
getCurrentStructure(equalHighsLowsLengthInput,true)
if showInternalsInput or showTrendInput
displayStructure(true)
if showStructureInput or showHighLowSwingsInput
displayStructure()
lastBarIndex := currentBarIndex
currentBarIndex := bar_index
newBar = currentBarIndex != lastBarIndex
drawLevels('D',timeframe.isdaily,dailyLevelsStyleInput,dailyLevelsColorInput)
drawLevels('W',timeframe.isweekly,weeklyLevelsStyleInput,weeklyLevelsColorInput)
drawLevels('M',timeframe.ismonthly,monthlyLevelsStyleInput,monthlyLevelsColorInput)
//---------------------------------------------------------------------------------
------------------------------------}
//ALERTS
//---------------------------------------------------------------------------------
------------------------------------{
alertcondition(currentAlerts.internalBullishBOS, 'Internal Bullish BOS',
'Internal Bullish BOS formed')
alertcondition(currentAlerts.internalBullishCHoCH, 'Internal Bullish CHoCH',
'Internal Bullish CHoCH formed')
alertcondition(currentAlerts.internalBearishBOS, 'Internal Bearish BOS',
'Internal Bearish BOS formed')
alertcondition(currentAlerts.internalBearishCHoCH, 'Internal Bearish CHoCH',
'Internal Bearish CHoCH formed')
//---------------------------------------------------------------------------------
------------------------------------}
//-----------------------------------------------------------------------------
// Input Settings
//-----------------------------------------------------------------------------
i_3 = "FVGs represent price areas where a significant gap occurred between two
trading sessions, indicating a potential continuation or reversal point."
//----------------------------------------
// Order Blocks
//----------------------------------------
var_ob_13 = (time[1] - time[101]) / 100
//----------------------------------------
// Constants
color CLEAR = color.rgb(0, 0, 0, 100)
//----------------------------------------
// Fair Value Gaps (FVG)
//----------------------------------------
// Swing Detection/Measurements
custom_func_4(length) =>
var prev = 0
prev := high[length] > ta.highest(length) ? 0 : low[length] < ta.lowest(length)
? 1 : prev[1]
t = prev == 0 and prev[1] != 0 ? high[length] : 0
b = prev == 1 and prev[1] != 1 ? low[length] : 0
[t, b]
// Functions
lineStyle(x) =>
switch x
"Solid" => line.style_solid
"Dashed" => line.style_dashed
"Dotted" => line.style_dotted
variable_ms_20 = ta.pivothigh(high, 10, 10)
variable_ms_21 = ta.pivotlow(low, 10, 10)
//-----------------------------------------------------------------------------
// Fair Value Gaps
//-----------------------------------------------------------------------------
// Global Data
var htfH = open
var htfL = open
if close > htfH
htfH := close
if close < htfL
htfL := close
variable_fvg_14 := false
variable_fvg_15 := false
// Functions
custom_func_5(_upperlimit, _lowerlimit, _midlimit, _bar, _boxholder,
_boxholder_fill, _midholder, _highholder, _lowholder, _labelholder, _boxcolor,
_mtfboxcolor, _htf, line_color_mid) =>
variable_fvg_16 = str.tostring(in_fvg_2)
offset = var_fvg_8
variable_fvg_17 = _mtfboxcolor
bg_color = color.new(_mtfboxcolor, in_fvg_op)
if _htf == false
variable_fvg_16 := str.tostring(timeframe.period)
offset := var_fvg_7
variable_fvg_17 := _boxcolor
array.push(_boxholder, box.new(_bar, _upperlimit, _bar + (var_ob_13) *
in_fvg_9, _lowerlimit, border_color= na, bgcolor=in_fvg_6 ? bg_color : na,
extend=in_fvg_10 ? extend.right : extend.none, xloc=xloc.bar_time, text="",
text_color=#787b86, text_halign=text.align_right, text_size=size.small))
array.push(_boxholder_fill, box.new(_bar, _upperlimit, _bar + (var_ob_13) *
in_fvg_9, _lowerlimit, border_color= na, bgcolor=in_fvg_6 ? bg_color : na,
extend=in_fvg_10 ? extend.right : extend.none, xloc=xloc.bar_time))
array.push(_midholder, line.new(_bar, (_lowerlimit + _upperlimit) / 2.0, _bar +
(var_ob_13) * in_fvg_9, _midlimit, color=mid_line_show == "On" ? line_color_mid :
#363a4500, extend=in_fvg_10 ? extend.right : extend.none,
style=lineStyle(in_fvg_13), width=in_fvg_16, xloc=xloc.bar_time))
array.push(_lowholder, line.new(_bar, _lowerlimit, _bar + (var_ob_13) *
in_fvg_9, _lowerlimit, color=var_fvg_3 ? variable_fvg_17 : na, extend=in_fvg_10 ?
extend.right : extend.none, width=1, xloc=xloc.bar_time))
array.push(_highholder, line.new(_bar, _upperlimit, _bar + (var_ob_13) *
in_fvg_9, _upperlimit, color=var_fvg_3 ? variable_fvg_17 : na, extend=in_fvg_10 ?
extend.right : extend.none, width=1, xloc=xloc.bar_time))
// Checks for gap between current candle and 2 previous candle (Fair Value Gap)
custom_func_6(_close, _high, _highp2, _low, _lowp2, _open, _bar, _htf) =>
gap = 0
thold_ = (ta.highest(_high, 300) - ta.lowest(_low, 300)) * math.max(in_fvg_3,
0.1) / 100.
if _open > _close // Red candle
if _lowp2 > _high
if not (in_fvg_4) or math.abs(_lowp2 - _high) > thold_
upperlimit = _high
lowerlimit = _lowp2
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap := 1
if in_fvg_1
custom_func_5(upperlimit, lowerlimit, midlimit, _bar,
variable_fvg_1, variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7,
variable_fvg_11, var_fvg_1, in_fvg_12, _htf,in_fvg_14_2)
else
if _low > _highp2
if not (in_fvg_4) or math.abs(_low - _highp2) > thold_
upperlimit = _low
lowerlimit = _highp2
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap := -1
if in_fvg_1
custom_func_5(upperlimit, lowerlimit, midlimit, _bar,
variable_fvg_2, variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8,
variable_fvg_12, var_fvg_2, in_fvg_11, _htf,in_fvg_14)
gap
// Removes the gap from its relevant array if it has been filled
custom_func_7(_currentgap, _currentgap_fill, _i, _boxholder, _boxholder_fill,
_midholder, _highholder, _lowholder, _labelholder) =>
array.remove(_boxholder, _i)
array.remove(_boxholder_fill, _i)
currentmid = array.get(_midholder, _i)
currenthigh = array.get(_highholder, _i)
currentlow = array.get(_lowholder, _i)
array.remove(_midholder, _i)
array.remove(_highholder, _i)
array.remove(_lowholder, _i)
if var_fvg_4
line.delete(currentmid)
line.delete(currenthigh)
line.delete(currentlow)
else
line.set_extend(currentmid, extend.none)
line.set_x2(currentmid, time)
line.set_extend(currenthigh, extend.none)
line.set_x2(currenthigh, time)
line.set_extend(currentlow, extend.none)
line.set_x2(currentlow, time)
if var_fvg_4
box.delete(_currentgap)
box.delete(_currentgap_fill)
else
box.set_extend(_currentgap, extend.none)
box.set_right(_currentgap, time)
// Checks if gap has been filled either by 0.5 fill (var_fvg_3) or SHRINKS the gap
to reflect the true value gap left
custom_func_8(_high, _low) =>
variable_fvg_19 = 0
if array.size(variable_fvg_1) > 0
for i = array.size(variable_fvg_1) - 1 to 0
if in_fvg_15
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
cmid = array.get(variable_fvg_9, i)
chigh = array.get(variable_fvg_5, i)
clow = array.get(variable_fvg_7, i)
line.set_x2(cmid, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(chigh, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(clow, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap_fill, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap, timenow + (var_ob_13) * in_fvg_9)
if in_fvg_5 == "Touch"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenthigh = array.get(variable_fvg_5, i)
currentlow = array.get(variable_fvg_7, i)
currenttop = box.get_top(currentgap)
if high > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1,
variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if in_fvg_5 == "Wicks"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenthigh = array.get(variable_fvg_5, i)
currentlow = array.get(variable_fvg_7, i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_3, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, high)
else
box.set_bottom(currentgap_f, math.max(cur_bottom, high))
box.set_bgcolor(currentgap_f, #787b865e)
if high > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1,
variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if in_fvg_5 == "Close"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenthigh = array.get(variable_fvg_5, i)
currentlow = array.get(variable_fvg_7, i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_3, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, high)
else
box.set_bottom(currentgap_f, math.max(cur_bottom, high))
box.set_bgcolor(currentgap_f, #787b865e)
if close > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1,
variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if in_fvg_5 == "Average"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenttop = line.get_y1(currentmid)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_3, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, high)
else
box.set_bottom(currentgap_f, math.max(cur_bottom, high))
box.set_bgcolor(currentgap_f, #787b865e)
if high > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1,
variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if array.size(variable_fvg_2) > 0
for i = array.size(variable_fvg_2) - 1 to 0
if in_fvg_15
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
cmid = array.get(variable_fvg_10, i)
chigh = array.get(variable_fvg_6, i)
clow = array.get(variable_fvg_8, i)
line.set_x2(cmid, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(chigh, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(clow, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap_fill, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap, timenow + (var_ob_13) * in_fvg_9)
if in_fvg_5 == "Touch"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currenttop = box.get_top(currentgap)
currentmid = array.get(variable_fvg_10, i)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
if low < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2,
variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
if in_fvg_5 == "Wicks"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(variable_fvg_10, i)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_4, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, low)
else
box.set_bottom(currentgap_f, math.min(cur_bottom, low))
box.set_bgcolor(currentgap_f, #787b865e)
if low < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2,
variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
if in_fvg_5 == "Close"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(variable_fvg_10, i)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_4, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, low)
else
box.set_bottom(currentgap_f, math.min(cur_bottom, low))
box.set_bgcolor(currentgap_f, #787b865e)
if close < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2,
variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
if in_fvg_5 == "Average"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currentmid = array.get(variable_fvg_10, i)
currenttop = line.get_y1(currentmid)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_4, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, low)
else
box.set_bottom(currentgap_f, math.min(cur_bottom, low))
box.set_bgcolor(currentgap_f, #787b865e)
if low < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2,
variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
variable_fvg_19
variable_fvg_18 = 0
n = bar_index
//-----------------------------------------------------------------------------{
//Boolean set
//-----------------------------------------------------------------------------{
s_BOS = 0
s_CHoCH = 1
i_BOS = 2
i_CHoCH = 3
i_pp_CHoCH = 4
green_candle = 5
red_candle = 6
s_CHoCHP = 7
i_CHoCHP = 8
boolean =
array.from(
false
, false
, false
, false
, false
, false
, false
, false
, false
)
//-----------------------------------------------------------------------------{
// User inputs
//-----------------------------------------------------------------------------{
type Zphl
line top
line bottom
label top_label
label bottom_label
bool stopcross
bool sbottomcross
bool itopcross
bool ibottomcross
string txtup
string txtdn
float topy
float bottomy
float topx
float bottomx
float tup
float tdn
int tupx
int tdnx
float itopy
float itopx
float ibottomy
float ibottomx
float uV
float dV
type ms
float[] p
int [] n
float[] l
type msDraw
int n
float p
color css
string txt
bool bull
type obC
float[] top
float[] btm
int [] left
float[] avg
float[] dV
float[] cV
int [] wM
int [] blVP
int [] brVP
int [] dir
float[] h
float[] l
int [] n
type obD
box [] ob
box [] eOB
box [] blB
box [] brB
line[] mL
type pattern
string found = "None"
switch
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - Market Structure
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
var line id = na
var label lbl = na
id := line.new(
d.n
, d.p
, b.n
, d.p
, color = d.css
, width = 1
, style = style
)
line.delete(msline.shift())
msDraw drw = na
n = bar_index
var ms up = ms.new(
array.new<float>()
, array.new< int >()
, array.new<float>()
)
var ms dn = ms.new(
array.new<float>()
, array.new< int >()
, array.new<float>()
)
switch show_swing_ms
switch show_internal_ms
switch
iH =>
up.p.unshift(b.h[iLen])
up.l.unshift(b.h[iLen])
up.n.unshift(n [iLen])
iL =>
dn.p.unshift(b.l[iLen])
dn.l.unshift(b.l[iLen])
dn.n.unshift(n [iLen])
sL =>
sdn.p.unshift(b.l[sLen])
sdn.l.unshift(b.l[sLen])
sdn.n.unshift(n [sLen])
sH =>
sup.p.unshift(b.h[sLen])
sup.l.unshift(b.h[sLen])
sup.n.unshift(n [sLen])
if ta.crossover(b.c, up.p.first())
bool CHoCH = na
string txt = na
if itrend < 0
CHoCH := true
switch
txt := "BOS"
css := i_ms_up_BOS
blalert.bos := true
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS
, txt
, true
)
CHoCH =>
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS.darkcss(0.25, true)
, txt
, true
)
if mtf == false
switch
itrend := 1
up.n.clear()
up.p.clear()
if ta.crossunder(b.c, dn.p.first())
bool CHoCH = na
string txt = na
if itrend > 0
CHoCH := true
switch
bralert.bos := true
txt := "BOS"
css := i_ms_dn_BOS
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS
, txt
, false
)
CHoCH =>
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
itrend := -1
dn.n.clear()
dn.p.clear()
if ta.crossover(b.c, sup.p.first())
bool CHoCH = na
string txt = na
if trend < 0
CHoCH := true
switch
blalert.swingbos := true
txt := "BOS"
icss := s_ms_up_BOS
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BOS
, txt
, true
)
CHoCH =>
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BOS.darkcss(0.25, true)
, txt
, true
)
if mtf == false
switch
trend := 1
sup.n.clear()
sup.p.clear()
if ta.crossunder(b.c, sdn.p.first())
bool CHoCH = na
string txt = na
if trend > 0
CHoCH := true
switch
bralert.swingbos := true
txt := "BOS"
icss := s_ms_dn_BOS
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS
, txt
, false
)
CHoCH =>
if sup.l.first() < sup.l.get(1)
bralert.chochplusswing := true
else
bralert.chochswing := true
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
trend := -1
sdn.n.clear()
sdn.p.clear()
[css, bear_ob, bull_ob, itrend, drw, isdrw, s_bear_ob, s_bull_ob, trend, icss,
isdrwS]
[css, bear_ob, bull_ob, itrend, drw, isdrw, s_bear_ob, s_bull_ob, trend, icss,
isdrwS] = structure(false)
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - End
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//{ - Volumetric Order Block
}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
//
{----------------------------------------------------------------------------------
------------------------------------------------------------}
method drawVOB(bool cdn, bool bull, color css, int loc, bool swing) =>
, [
close
, open
, high
, low
, volume
, lookahead = barmerge.lookahead_off
)
var obC obj = obC.new(
array.new<float>()
, array.new<float>()
, array.new< int >()
, array.new<float>()
, array.new<float>()
, array.new<float>()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new<float>()
, array.new<float>()
, array.new< int >()
)
if barstate.isfirst
for i = 0 to ob_num - 1
if cdn
obj.h.clear()
obj.l.clear()
obj.n.clear()
obj.h.push(hH[i])
obj.l.push(lL[i])
obj.n.push(b.t[i])
// obj.h.reverse()
// obj.l.reverse()
int iU = obj.l.indexof(obj.l.min()) + 1
int iD = obj.h.indexof(obj.h.max()) + 1
obj.dir.unshift(
bull
? (b.c[iU] > b.o[iU] ? 1 : -1)
: (b.c[iD] > b.o[iD] ? 1 : -1)
)
obj.top.unshift(
bull
? pos[iU]
: obj.h.max()
)
obj.btm.unshift(
bull
? obj.l.min()
: pos[iD]
)
obj.left.unshift(
bull
? obj.n.get(obj.l.indexof(obj.l.min()))
: obj.n.get(obj.h.indexof(obj.h.max()))
)
obj.avg.unshift(
math.avg(obj.top.first(), obj.btm.first())
)
obj.cV.unshift(
bull
? b.v[iU]
: b.v[iD]
)
if ob_pos == "Precise"
switch bull
true =>
if obj.avg.get(0) < (b.c[iU] < b.o[iU] ? b.c[iU] : b.o[iU]) and
obj.top.get(0) > hlcc4[iU]
obj.top.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
false =>
if obj.avg.get(0) > (b.c[iU] < b.o[iU] ? b.o[iD] : b.c[iD]) and
obj.btm.get(0) < hlcc4[iD]
obj.btm.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
obj.blVP.unshift ( 0 )
obj.brVP.unshift ( 0 )
obj.wM .unshift ( 1 )
if use_overlap
if obj.avg.size() > 1
if bull
if barstate.isconfirmed
for x = 0 to ob_num - 1
tg = switch ob_mitigation
"Middle" => obj.avg
"Absolute" => bull ? obj.btm : obj.top
if barstate.islast
if obj.avg.size() > 0
// Alert
if bull
? ta.crossunder(low , obj.top.get(0))
: ta.crossover (high, obj.btm.get(0))
switch bull
true => blalert.obtouch := true
false => bralert.obtouch := true
float tV = 0
obj.dV.clear()
seq = math.min(ob_num - 1, obj.avg.size() - 1)
for j = 0 to seq
tV += obj.cV.get(j)
if j == seq
for y = 0 to seq
obj.dV.unshift(
math.floor(
(obj.cV.get(y) / tV) * 100)
)
obj.dV.reverse()
if use_middle_line
dmL.set_xy1(obj.left.get(i), obj.avg.get(i))
dmL.set_xy2(b.t , obj.avg.get(i))
if ob_metrics_show
rpBL = dblB.get_right()
rpBR = dbrB.get_right()
dbrB.set_right(rpBR + (b.t - b.t[1]) * obj.brVP.get(i))
dblB.set_right(rpBL + (b.t - b.t[1]) * obj.blVP.get(i))
if use_show_metric
txt = switch
deOB.set_text(
str.tostring(
txt + " (" + str.tostring(obj.dV.get(i)) + "%)")
)
deOB.set_text_size (obtxt.txSz())
deOB.set_text_halign(text.align_left)
deOB.set_text_color (use_grayscale or styleInput ==
MONOCHROME ? color.silver : color.new(css, 0))
if obj.wM.size() > 0
for i = 0 to obj.avg.size() - 1
switch obj.dir.get(i)
1 =>
switch obj.wM.get(i)
switch obj.wM.get(i)
if iH
hN.pop()
hN.unshift(int(b.n[iLen]))
if iL
lN.pop()
lN.unshift(int(b.n[iLen]))
if sH
hS.pop()
hS.unshift(int(b.n[sLen]))
if sL
lS.pop()
lS.unshift(int(b.n[sLen]))
if ob_show
if ob_swings
if bull_ob
blalert.ob := true
if bear_ob
bralert.ob := true
if s_bull_ob
blalert.swingob := true
if s_bear_ob
blalert.swingob := true
//
===================================================================================
=======