New Text Document
New Text Document
source=Site+Profile+Seller
3 Etry ;
// -------------------------------------------------------------------------------
//@version=6
indicator('ZigZag with Retracement Levels', overlay = true, max_bars_back = 500,
max_lines_count = 300)
prd = input.int(defval = 10, title = 'ZigZag Period', minval = 2, maxval = 50)
showzigzag = input(defval = true, title = 'Show Zig Zag')
showfibo = input(defval = true, title = 'Show Retracement Ratios')
labelcol = input(defval = color.white, title = 'Text Color for Levels')
fibolinecol = input(defval = color.white, title = 'Line Color for Levels')
showcurrent = input(defval = true, title = 'Show Retracement Ratios based on latest
pivot')
labelcol2 = input(defval = color.yellow, title = 'Text Color for Current Levels')
fibolinecol2 = input(defval = color.yellow, title = 'Line Color for Current
Levels')
upcol = input.color(defval = color.lime, title = 'Zigzag Colors', inline = 'zzcol')
dncol = input.color(defval = color.red, title = '', inline = 'zzcol')
labelloc = input.string(defval = 'Left', title = 'Label Location', options =
['Left', 'Right'])
// -------------------------------------------------- Inputs
--------------------------------------------------
var g_SET = 'Settings'
show_rfvg = input.bool(true, 'Show Regular FVG', inline = 'RFVG', group = g_SET)
show_ifvg = input.bool(true, 'Show Inverse FVG', inline = 'IFVG', group = g_SET)
extend_right = input.bool(true, 'Extend Boxes', group = g_SET)
auto_selected_tf
// -------------------------------------------------- Logic
--------------------------------------------------
t = not na(time(used_tf, session, 'America/New_York'))
solid_color(color x) =>
color.new(x, 0)
tf_new := true
if inv_fvg.size() > 0
for i = 0 to inv_fvg.size() - 1 by 1
inv_fvg.get(i).set_right(time)
inv_fvg_ce.get(i).set_x2(time)
if i < inv_fvg_labels.size()
inv_fvg_labels.get(i).set_x(time)
bull = c1 > o1
fvg = bull ? h2 < l0 and l1 <= h2 and h1 >= l0 : l2 > h0 and l1 <= h0 and l2 <=
h1
fvg_len = bull ? l0 - h2 : l2 - h0
// Create the FVG box (only showing the relevant quadrant + CE), CE line,
and label
reg_fvg.unshift(box.new(time1, top, time, bottom, xloc = xloc.bar_time,
extend = extend_right ? extend.right : extend.none, bgcolor = show_rfvg ?
rfvg_color : na, border_color = na))
reg_fvg_ce.unshift(line.new(time1, ce_level, time, ce_level, xloc =
xloc.bar_time, extend = extend_right ? extend.right : extend.none, color =
show_rfvg ? solid_color(rfvg_color) : na, style = line.style_dashed))
reg_fvg_side.unshift(bull ? 'bull' : 'bear')
// Add label for quadrant reference - position it at the non-CE edge of the
box
quadrant_text = bull ? "FVG+ " + used_tf : "FVG- " + used_tf
label_pos = bull ? top : bottom // Place at the extreme edge (top for
bullish, bottom for bearish)
tf_new := false
tf_new
if overlap
// Keep the most recent FVG (which is the one with lower
index in our array)
// We'll adjust its visual style to indicate it represents
multiple FVGs
box1.set_border_color(#000000ce)
box1.set_border_width(2)
reg_fvg.remove(j)
reg_fvg_ce.remove(j)
reg_fvg_side.remove(j)
if j < reg_fvg_labels.size()
reg_fvg_labels.remove(j)
if reg_fvg.size() > 0
for i = reg_fvg.size() - 1 to 0 by 1
if i < reg_fvg.size() and i < reg_fvg_side.size() // Safe bounds
checking
remove_bull = reg_fvg_side.get(i) == 'bull' and c0 <
reg_fvg.get(i).get_bottom()
remove_bear = reg_fvg_side.get(i) == 'bear' and c0 >
reg_fvg.get(i).get_top()
if remove_bull or remove_bear
// Get the original FVG side (bull or bear)
original_is_bull = reg_fvg_side.get(i) == 'bull'
// Get the original full FVG dimensions from which we'll create
our IFVG
full_top = original_is_bull ? original_top : ce_level * 2 -
original_bottom
full_bottom = original_is_bull ? ce_level * 2 - original_top :
original_bottom
if original_is_bull
// For inverse of bullish pattern (IFVG-), show lower half
inv_fvg.get(0).set_top(ce_level)
inv_fvg.get(0).set_bottom(full_bottom)
label_pos := full_bottom
else
// For inverse of bearish pattern (IFVG+), show upper half
inv_fvg.get(0).set_top(full_top)
inv_fvg.get(0).set_bottom(ce_level)
label_pos := full_top
reg_fvg.remove(i)
reg_fvg_ce.remove(i)
reg_fvg_side.remove(i)
if i < reg_fvg_labels.size()
reg_fvg_labels.remove(i)
if overlap
// Keep the most recent IFVG (which is the one with lower
index in our array)
// We'll adjust its visual style to indicate it represents
multiple IFVGs
box1.set_border_color(color.new(#000000, 50))
box1.set_border_width(2)
inv_fvg.remove(j)
inv_fvg_ce.remove(j)
inv_fvg_side.remove(j)
if j < inv_fvg_labels.size()
inv_fvg_labels.remove(j)
if inv_fvg.size() > 0
for i = inv_fvg.size() - 1 to 0 by 1
if i < inv_fvg.size() and i < inv_fvg_side.size() // Safe bounds
checking
remove_inv_bear = inv_fvg_side.get(i) == 'inv bear' and c0 <
inv_fvg.get(i).get_bottom()
remove_inv_bull = inv_fvg_side.get(i) == 'inv bull' and c0 >
inv_fvg.get(i).get_top()
if remove_inv_bear or remove_inv_bull
box.delete(inv_fvg.get(i))
line.delete(inv_fvg_ce.get(i))
if i < inv_fvg_labels.size()
label.delete(inv_fvg_labels.get(i))
inv_fvg.remove(i)
inv_fvg_ce.remove(i)
inv_fvg_side.remove(i)
if i < inv_fvg_labels.size()
inv_fvg_labels.remove(i)
inv_fvg.pop()
inv_fvg_ce.pop()
inv_fvg_side.pop()
if inv_fvg_labels.size() > 0
inv_fvg_labels.pop()
// Alert conditions for FVG and IFVG creation - modified to prevent errors
is_new_fvg = false
if tf_new and tf_o.size() >= 3 and tf_h.size() >= 3 and tf_l.size() >= 3 and
tf_t.size() > 2
if tf_t.get(2)
bull = tf_c.get(1) > tf_o.get(1)
fvg = bull ? tf_h.get(2) < tf_l.get(0) and tf_l.get(1) <= tf_h.get(2) and
tf_h.get(1) >= tf_l.get(0) :
tf_l.get(2) > tf_h.get(0) and tf_l.get(1) <= tf_h.get(0) and
tf_l.get(2) <= tf_h.get(1)
fvg_len = bull ? tf_l.get(0) - tf_h.get(2) : tf_l.get(2) - tf_h.get(0)
atr_check = tf_h.size() >= 20 ? fvg_len > avg_over(tf_h, tf_l, 20) * disp_x
/ 10 : false
is_new_fvg := fvg and atr_check
//@version=5
indicator('Smart Money Concepts [LuxAlgo]', 'LuxAlgo - Smart Money Concepts',
overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count =
500)
//---------------------------------------------------------------------------------
------------------------------------}
//CONSTANTS & STRINGS & INPUTS
//---------------------------------------------------------------------------------
------------------------------------{
BULLISH_LEG = 1
BEARISH_LEG = 0
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
// @type UDT representing last swing extremes (top &
bottom)
// @field top last top swing price
// @field bottom last bottom swing price
// @field barTime last swing bar time
// @field barIndex last swing bar index
// @field lastTopTime last top swing time
// @field lastBottomTime last bottom swing time
type trailingExtremes
float top
float bottom
int barTime
int barIndex
int lastTopTime
int lastBottomTime
// we create the needed boxes for displaying order blocks at the first execution
if barstate.isfirst
if showSwingOrderBlocksInput
for index = 1 to swingOrderBlocksSizeInput
swingOrderBlocksBoxes.push(box.new(na,na,na,na,xloc =
xloc.bar_time,extend = extend.right))
if showInternalOrderBlocksInput
for index = 1 to internalOrderBlocksSizeInput
internalOrderBlocksBoxes.push(box.new(na,na,na,na,xloc =
xloc.bar_time,extend = extend.right))
//---------------------------------------------------------------------------------
------------------------------------}
//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)
array<float> a_rray = na
int parsedIndex = na
if bias == BEARISH
a_rray := parsedHighs.slice(p_ivot.barIndex,bar_index)
parsedIndex := p_ivot.barIndex + a_rray.indexof(a_rray.max())
else
a_rray := parsedLows.slice(p_ivot.barIndex,bar_index)
parsedIndex := p_ivot.barIndex + a_rray.indexof(a_rray.min())
orderBlock o_rderBlock =
orderBlock.new(parsedHighs.get(parsedIndex), parsedLows.get(parsedIndex),
times.get(parsedIndex),bias)
array<orderBlock> orderBlocks = internal ? internalOrderBlocks :
swingOrderBlocks
if orderBlocksSize > 0
maxOrderBlocks = internal ?
internalOrderBlocksSizeInput : swingOrderBlocksSizeInput
array<orderBlock> parsedOrdeBlocks = orderBlocks.slice(0,
math.min(maxOrderBlocks,orderBlocksSize))
array<box> b_oxes = internal ? internalOrderBlocksBoxes :
swingOrderBlocksBoxes
b_ox.set_top_left_point( chart.point.new(eachOrderBlock.barTime,na,eachOrderBloc
k.barHigh))
b_ox.set_bottom_right_point(chart.point.new(last_bar_time,na,eachOrderBlock.barLow)
)
b_ox.set_border_color( internal ? na : orderBlockColor)
b_ox.set_bgcolor( orderBlockColor)
// @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
displayCondition = internal ? showInternalsInput and (showInternalBullInput
== ALL or (showInternalBullInput == BOS and tag != CHOCH) or (showInternalBullInput
== CHOCH and tag == CHOCH)) : showStructureInput and (showSwingBullInput == ALL or
(showSwingBullInput == BOS and tag != CHOCH) or (showSwingBullInput == CHOCH and
tag == CHOCH))
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 draw one fair value gap box (each fair value gap has two
boxes)
// @param leftTime left time coordinate
// @param rightTime right time coordinate
// @param topPrice top price level
// @param bottomPrice bottom price level
// @param boxColor box color
// @returns box ID
fairValueGapBox(leftTime,rightTime,topPrice,bottomPrice,boxColor) =>
box.new(chart.point.new(leftTime,na,topPrice),chart.point.new(rightTime +
fairValueGapsExtendInput * (time-time[1]),na,bottomPrice), xloc=xloc.bar_time,
border_color = boxColor, bgcolor = boxColor)
if bullishFairValueGap
currentAlerts.bullishFairValueGap := true
fairValueGaps.unshift(fairValueGap.new(currentLow,last2High,BULLISH,fairValueGapBox
(lastTime,currentTime,currentLow,math.avg(currentLow,last2High),fairValueGapBullish
Color),fairValueGapBox(lastTime,currentTime,math.avg(currentLow,last2High),last2Hig
h,fairValueGapBullishColor)))
if bearishFairValueGap
currentAlerts.bearishFairValueGap := true
fairValueGaps.unshift(fairValueGap.new(currentHigh,last2Low,BEARISH,fairValueGapBox
(lastTime,currentTime,currentHigh,math.avg(currentHigh,last2Low),fairValueGapBearis
hColor),fairValueGapBox(lastTime,currentTime,math.avg(currentHigh,last2Low),last2Lo
w,fairValueGapBearishColor)))
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))
// @function draw premium/discount zones
// @returns void
drawPremiumDiscountZones() =>
drawZone(trailing.top, math.round(0.5*(trailing.barIndex + last_bar_index)),
trailing.top, 0.95*trailing.top + 0.05*trailing.bottom, 'Premium',
premiumZoneColor, label.style_label_down)
//---------------------------------------------------------------------------------
------------------------------------}
//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()
if showFairValueGapsInput
deleteFairValueGaps()
getCurrentStructure(swingsLengthInput,false)
getCurrentStructure(5,false,true)
if showEqualHighsLowsInput
getCurrentStructure(equalHighsLowsLengthInput,true)
if showInternalOrderBlocksInput
deleteOrderBlocks(true)
if showSwingOrderBlocksInput
deleteOrderBlocks()
if showFairValueGapsInput
drawFairValueGaps()
if barstate.islastconfirmedhistory or barstate.islast
if showInternalOrderBlocksInput
drawOrderBlocks(true)
if showSwingOrderBlocksInput
drawOrderBlocks()
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')
//---------------------------------------------------------------------------------
------------------------------------}
startTime = 0
startTime := inSession and not inSession[1] ? time : startTime[1]
//Box lines
var line lowHLine = na
var line topHLine = na
var line leftVLine = na
var line rightVLine = na
var line middleHLine = na
var box bgBox = na
// Plot lines
if inSession and timeframe.isintraday
if inSession[1]
line.delete(lowHLine)
line.delete(topHLine)
line.delete(leftVLine)
line.delete(rightVLine)
line.delete(middleHLine)
box.delete(bgBox)
//Create Box
//x1, y1, x2, y2
if showBackground
bgBox := box.new(startTime, high_val, time, low_val, xloc=xloc.bar_time,
bgcolor=backgroundColor, border_width=0)
if showLines
lowHLine := line.new(startTime, low_val, time, low_val, xloc=xloc.bar_time,
color=boxLineColor, style=line.style_solid, width=linesWidth)
topHLine := line.new(startTime, high_val, time, high_val,
xloc=xloc.bar_time, color=boxLineColor, style=line.style_solid, width=linesWidth)
leftVLine := line.new(startTime, high_val, startTime, low_val,
xloc=xloc.bar_time, color=boxLineColor, style=line.style_solid, width=linesWidth)
rightVLine := line.new(time, high_val, time, low_val, xloc=xloc.bar_time,
color=boxLineColor, style=line.style_solid, width=linesWidth)
else
if inExtend and extendLines and not inSession and timeframe.isintraday
time1 = line.get_x1(lowHLine)
time2 = line.get_x2(lowHLine)
price = line.get_y1(lowHLine)
line.delete(lowHLine)
lowHLine := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=boxLineColor, style=line.style_solid, width=linesWidth)
time1 := line.get_x1(topHLine)
time2 := line.get_x2(topHLine)
price := line.get_y1(topHLine)
line.delete(topHLine)
topHLine := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=boxLineColor, style=line.style_solid, width=linesWidth)
time1 := line.get_x1(middleHLine)
time2 := line.get_x2(middleHLine)
price := line.get_y1(middleHLine)
line.delete(middleHLine)
middleHLine := line.new(time1, price, time, price, xloc=xloc.bar_time,
color=middleLineColor, style=line.style_dotted, width=linesWidth)
middleHLine
// Define EMAs
ema20_close = ta.ema(close, 20)
ema34_close = ta.ema(close, 34)
ema34_high = ta.ema(high, 34)
ema34_low = ta.ema(low, 34)
ema50_close = ta.ema(close, 50)
ema200_high = ta.ema(high, 200)
ema200_low = ta.ema(low, 200)
ema13_close = ta.ema(close, 13)
ema10_close = ta.ema(close, 10)
ema65_close = ta.ema(close, 65)
ema89_close = ta.ema(close, 89)
ema200_close = ta.ema(close, 200)
ema630_close = ta.ema(close,630)
sma5 = ta.sma(close,5)
sma50 = ta.sma(close,50)
sma89 = ta.sma(close,89)
ema5_close = ta.ema(close, 5)
ema100_close = ta.ema(close, 100)
// Plot EMAs
plot(ema20_close, color = #ef8688eb, title = "ema20_close", linewidth = 1)
plot(ema34_close, color = color.rgb(149, 218, 239, 8), title = "ema34_close",
linewidth = 1)
plot(ema50_close, color = color.rgb(109, 109, 232, 8), title = "ema50_close",
linewidth = 1)
plot(ema5_close, color = color.rgb(149, 218, 239, 8), title = "ema5_close",
linewidth = 1)
plot(ema100_close, color = color.rgb(149, 218, 239, 8), title = "ema100_close",
linewidth = 1)
// bolinger band
// bolinger band 2
//Inputs
source = input.string("Wicks", options=['Wicks','Bodys'],
title="Source", group=inputGroupTitle)
ph = ta.pivothigh(phOption,leftLenH, rightLenH)
pl = ta.pivotlow(plOption,leftLenL, rightLenL)
//Variables
var leftBull = bar_index
var rightBull = bar_index
var topBull = close
var bottomBull = close
if (not na(pl))
array.push(_bullBoxes, box.new(left=leftBull, right=rightBull, top=topBull,
bottom=bottomBull, bgcolor=color.new(bullBoxColor,80), border_color=bullBoxColor))
if (not na(ph))
array.push(_bearBoxes, box.new(left=leftBear, right=rightBear, top=topBear,
bottom=bottomBear, bgcolor=color.new(bearBoxColor,80), border_color=bearBoxColor))
extend_boxes(_array, _type)=>
if array.size(_array)>0
for i = 0 to array.size(_array)-1
_box = array.get(_array,i)
_boxLow = box.get_bottom(_box)
_boxHigh = box.get_top(_box)
_boxLeft = box.get_left(_box)
_boxRight = box.get_right(_box)
if extendBox
extend_boxes(_bullBoxes,"bull")
extend_boxes(_bearBoxes,"bear")