You are on page 1of 26

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.

0
International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=5
indicator("‫ "خلطة القط األسود الرقمي‬,"‫" خلطة القط األسود الرقمي‬
, overlay = true
, max_labels_count = 500
, max_lines_count = 500
, max_boxes_count = 500
, max_bars_back = 500)
//-----------------------------------------------------------------------------{
//Constants
//-----------------------------------------------------------------------------{
color TRANSP_CSS = #ffffff00

//Tooltips
string MODE_TOOLTIP = 'Allows to display historical Structure or only the
recent ones'
string STYLE_TOOLTIP = 'Indicator color theme'
string COLOR_CANDLES_TOOLTIP = 'Display additional candles with a color reflecting
the current trend detected by structure'
string SHOW_INTERNAL = 'Display internal market structure'
string CONFLUENCE_FILTER = 'Filter non significant internal structure
breakouts'
string SHOW_SWING = 'Display swing market Structure'
string SHOW_SWING_POINTS = 'Display swing point as labels on the chart'
string SHOW_SWHL_POINTS = 'Highlight most recent strong and weak high/low
points on the chart'
string INTERNAL_OB = 'Display internal order blocks on the chart\n\
nNumber of internal order blocks to display on the chart'
string SWING_OB = 'Display swing order blocks on the chart\n\nNumber
of internal swing blocks to display on the chart'
string FILTER_OB = 'Method used to filter out volatile order blocks \n\
nIt is recommended to use the cumulative mean range method when a low amount of
data is available'
string SHOW_EQHL = 'Display equal highs and equal lows on the chart'
string EQHL_BARS = 'Number of bars used to confirm equal highs and
equal lows'
string EQHL_THRESHOLD = 'Sensitivity threshold in a range (0, 1) used for
the detection of equal highs & lows\n\nLower values will return fewer but more
pertinent results'
string SHOW_FVG = 'Display fair values gaps on the chart'
string AUTO_FVG = 'Filter out non significant fair value gaps'
string FVG_TF = 'Fair value gaps timeframe'
string EXTEND_FVG = 'Determine how many bars to extend the Fair Value
Gap boxes on chart'
string PED_ZONES = 'Display premium, discount, and equilibrium zones on
chart'

//-----------------------------------------------------------------------------{
//Settings
//-----------------------------------------------------------------------------{
//General
//----------------------------------------{
mode = input.string('Historical'
, options = ['Historical', 'Present']
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = MODE_TOOLTIP)
style = input.string('Colored'
, options = ['Colored', 'Monochrome']
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = STYLE_TOOLTIP)

show_trend = input(false, 'Color Candles'


, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = COLOR_CANDLES_TOOLTIP)

//----------------------------------------}
//Internal Structure
//----------------------------------------{
show_internals = input(true, 'Show Internal Structure'
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = SHOW_INTERNAL)

show_ibull = input.string('All', 'Bullish Structure'


, options = ['All', '‫ ' إيجابي‬,'‫]'إيجابي‬
, inline = 'ibull'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

swing_ibull_css = input(#089981, ''


, inline = 'ibull'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

//Bear Structure
show_ibear = input.string('All', 'Bearish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'ibear'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

swing_ibear_css = input(#f23645, ''


, inline = 'ibear'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

ifilter_confluence = input(false, 'Confluence Filter'


, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = CONFLUENCE_FILTER)

//----------------------------------------}
//Swing Structure
//----------------------------------------{
show_Structure = input(true, 'Show Swing Structure'
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = SHOW_SWING)

//Bull Structure
show_bull = input.string('All', 'Bullish Structure'
, options = ['All', '‫ ' إيجابي‬,'‫]'إيجابي‬
, inline = 'bull'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

swing_bull_css = input(#089981, ''


, inline = 'bull'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

//Bear Structure
show_bear = input.string('All', 'Bearish Structure'
, options = ['All', ' ‫ ' سلبي‬,'‫سلبي‬-']
, inline = 'bear'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

swing_bear_css = input(#f23645, ''


, inline = 'bear'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

//Swings
show_swings = input(false, 'Show Swings Points'
, inline = 'swings'
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = SHOW_SWING_POINTS)

length = input.int(50, ''


, minval = 10
, inline = 'swings'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

show_hl_swings = input(true, 'Show Strong/‫مقاومة ضعيفة‬/Low'


, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = SHOW_SWHL_POINTS)

//----------------------------------------}
//Order Blocks
//----------------------------------------{
show_iob = input(true, 'Internal Order Blocks'
, inline = 'iob'
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = INTERNAL_OB)

iob_showlast = input.int(5, ''


, minval = 1
, inline = 'iob'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

show_ob = input(false, 'Swing Order Blocks'


, inline = 'ob'
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = SWING_OB)

ob_showlast = input.int(5, ''


, minval = 1
, inline = 'ob'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

ob_filter = input.string('Atr', 'Order Block Filter'


, options = ['Atr', 'Cumulative Mean Range']
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = FILTER_OB)

ibull_ob_css = input.color(color.new(#44fa4d, 88), 'Internal Bullish OB'


, group = '‫)'مؤشر مفاهيم المال الذكي‬

ibear_ob_css = input.color(color.new(#f77c80, 80), 'Internal Bearish OB'


, group = '‫)'مؤشر مفاهيم المال الذكي‬

bull_ob_css = input.color(color.new(#41d858, 90), 'Bullish OB'


, group = '‫)'مؤشر مفاهيم المال الذكي‬
bear_ob_css = input.color(color.new(#b22833, 80), 'Bearish OB'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

//----------------------------------------}
//EQH/EQL
//----------------------------------------{
show_eq = input(true, 'Equal High/Low'
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = SHOW_EQHL)

eq_len = input.int(3, 'Bars Confirmation'


, minval = 1
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = EQHL_BARS)

eq_threshold = input.float(0.1, 'Threshold'


, minval = 0
, maxval = 0.5
, step = 0.1
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = EQHL_THRESHOLD)

//----------------------------------------}
//Fair Value Gaps
//----------------------------------------{
show_fvg = input(false, 'Fair Value Gaps'
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = SHOW_FVG)

fvg_auto = input(true, "Auto Threshold"


, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = AUTO_FVG)

fvg_tf = input.timeframe('', "Timeframe"


, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = FVG_TF)

bull_fvg_css = input.color(color.new(#00ff68, 70), 'Bullish FVG'


, group = '‫)'مؤشر مفاهيم المال الذكي‬

bear_fvg_css = input.color(color.new(#ff0008, 70), 'Bearish FVG'


, group = '‫)'مؤشر مفاهيم المال الذكي‬

fvg_extend = input.int(1, "Extend FVG"


, minval = 0
, group = '‫'مؤشر مفاهيم المال الذكي‬
, tooltip = EXTEND_FVG)

//----------------------------------------}
//Previous day/week high/low
//----------------------------------------{
//Daily
show_pdhl = input(false, 'Daily'
, inline = 'daily'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

pdhl_style = input.string('⎯⎯⎯', ''


, options = ['⎯⎯⎯', '----', '····']
, inline = 'daily'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

pdhl_css = input(#73a183, ''


, inline = 'daily'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

//Weekly
show_pwhl = input(false, 'Weekly'
, inline = 'weekly'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

pwhl_style = input.string('⎯⎯⎯', ''


, options = ['⎯⎯⎯', '----', '····']
, inline = 'weekly'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

pwhl_css = input(#2157f3, ''


, inline = 'weekly'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

//Monthly
show_pmhl = input(false, 'Monthly'
, inline = 'monthly'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

pmhl_style = input.string('⎯⎯⎯', ''


, options = ['⎯⎯⎯', '----', '····']
, inline = 'monthly'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

pmhl_css = input(#2157f3, ''


, inline = 'monthly'
, group = '‫)'مؤشر مفاهيم المال الذكي‬

//----------------------------------------}
//Premium/Discount zones
//----------------------------------------{
show_sd = input(false, 'Premium/Discount Zones'
, group = 'Premium & Discount Zones'
, tooltip = PED_ZONES)

premium_css = input.color(#f23645, 'Premium Zone'


, group = 'Premium & Discount Zones')

eq_css = input.color(#b2b5be, 'Equilibrium Zone'


, group = 'Premium & Discount Zones')

discount_css = input.color(#089981, 'Discount Zone'


, group = 'Premium & Discount Zones')

//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index

atr = ta.atr(200)
cmean_range = ta.cum(high - low) / n
//HL Output function
hl() => [high, low]

//Get ohlc values function


get_ohlc()=> [close[1], open[1], high, low, high[2], low[2]]

//Display Structure function


display_Structure(x, y, txt, css, dashed, down, lbl_size)=>
structure_line = line.new(x, y, n, y
, color = css
, style = dashed ? line.style_dashed : line.style_solid)

structure_lbl = label.new(int(math.avg(x, n)), y, txt


, color = TRANSP_CSS
, textcolor = css
, style = down ? label.style_label_down : label.style_label_up
, size = lbl_size)

if mode == 'Present'
line.delete(structure_line[1])
label.delete(structure_lbl[1])

//Swings detection/measurements
swings(len)=>
var os = 0

upper = ta.highest(len)
lower = ta.lowest(len)

os := high[len] > upper ? 0 : low[len] < lower ? 1 : os[1]

top = os == 0 and os[1] != 0 ? high[len] : 0


btm = os == 1 and os[1] != 1 ? low[len] : 0

[top, btm]

//Order block coordinates function


ob_coord(use_max, loc, target_top, target_btm, target_left, target_type)=>
min = 99999999.
max = 0.
idx = 1

ob_threshold = ob_filter == 'Atr' ? atr : cmean_range

//Search for highest/lowest high within the structure interval and get range
if use_max
for i = 1 to (n - loc)-1
if (high[i] - low[i]) < ob_threshold[i] * 2
max := math.max(high[i], max)
min := max == high[i] ? low[i] : min
idx := max == high[i] ? i : idx
else
for i = 1 to (n - loc)-1
if (high[i] - low[i]) < ob_threshold[i] * 2
min := math.min(low[i], min)
max := min == low[i] ? high[i] : max
idx := min == low[i] ? i : idx

array.unshift(target_top, max)
array.unshift(target_btm, min)
array.unshift(target_left, time[idx])
array.unshift(target_type, use_max ? -1 : 1)

//Set order blocks


display_ob(boxes, target_top, target_btm, target_left, target_type, show_last,
swing, size)=>
for i = 0 to math.min(show_last-1, size-1)
get_box = array.get(boxes, i)

box.set_lefttop(get_box, array.get(target_left, i), array.get(target_top,


i))
box.set_rightbottom(get_box, array.get(target_left, i),
array.get(target_btm, i))
box.set_extend(get_box, extend.right)

color css = na

if swing
if style == 'Monochrome'
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) :
color.new(#5d606b, 80)
border_css = array.get(target_type, i) == 1 ? #b2b5be : #5d606b
box.set_border_color(get_box, border_css)
else
css := array.get(target_type, i) == 1 ? bull_ob_css : bear_ob_css
box.set_border_color(get_box, css)

box.set_bgcolor(get_box, css)
else
if style == 'Monochrome'
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) :
color.new(#5d606b, 80)
else
css := array.get(target_type, i) == 1 ? ibull_ob_css : ibear_ob_css

box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)

//Line Style function


get_line_style(style) =>
out = switch style
'⎯⎯⎯' => line.style_solid
'----' => line.style_dashed
'····' => line.style_dotted

//Set line/labels function for previous high/lows


phl(h, l, tf, css)=>
var line high_line = line.new(na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))

var label high_lbl = label.new(na,na


, xloc = xloc.bar_time
, text = str.format('P{0}H', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)

var line low_line = line.new(na,na,na,na


, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))

var label low_lbl = label.new(na,na


, xloc = xloc.bar_time
, text = str.format('P{0}L', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)

hy = ta.valuewhen(h != h[1], h, 1)
hx = ta.valuewhen(h == high, time, 1)

ly = ta.valuewhen(l != l[1], l, 1)
lx = ta.valuewhen(l == low, time, 1)

if barstate.islast
ext = time + (time - time[1])*20

//High
line.set_xy1(high_line, hx, hy)
line.set_xy2(high_line, ext, hy)

label.set_xy(high_lbl, ext, hy)

//Low
line.set_xy1(low_line, lx, ly)
line.set_xy2(low_line, ext, ly)

label.set_xy(low_lbl, ext, ly)

//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
var trend = 0, var itrend = 0

var top_y = 0., var top_x = 0


var btm_y = 0., var btm_x = 0

var itop_y = 0., var itop_x = 0


var ibtm_y = 0., var ibtm_x = 0

var trail_up = high, var trail_dn = low


var trail_up_x = 0, var trail_dn_x = 0

var top_cross = true, var btm_cross = true


var itop_cross = true, var ibtm_cross = true

var txt_top = '', var txt_btm = ''

//Alerts
bull_choch_alert = false
bull_bos_alert = false
bear_choch_alert = false
bear_bos_alert = false

bull_ichoch_alert = false
bull_ibos_alert = false

bear_ichoch_alert = false
bear_ibos_alert = false

bull_iob_break = false
bear_iob_break = false

bull_ob_break = false
bear_ob_break = false

eqh_alert = false
eql_alert = false

//Structure colors
var bull_css = style == 'Monochrome' ? #b2b5be
: swing_bull_css

var bear_css = style == 'Monochrome' ? #b2b5be


: swing_bear_css

var ibull_css = style == 'Monochrome' ? #b2b5be


: swing_ibull_css

var ibear_css = style == 'Monochrome' ? #b2b5be


: swing_ibear_css

//Swings
[top, btm] = swings(length)

[itop, ibtm] = swings(5)

//-----------------------------------------------------------------------------}
//Pivot High
//-----------------------------------------------------------------------------{
var line extend_top = na

var label extend_top_lbl = label.new(na, na


, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.large)

if top
top_cross := true
txt_top := top > top_y ? 'HH' : 'LH'

if show_swings
top_lbl = label.new(n-length, top, txt_top
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.large)

if mode == 'Present'
label.delete(top_lbl[1])

//Extend recent top to last bar


line.delete(extend_top[1])
extend_top := line.new(n-length, top, n, top
, color = bear_css)

top_y := top
top_x := n - length

trail_up := top
trail_up_x := n - length

if itop
itop_cross := true

itop_y := itop
itop_x := n - 5

//Trailing maximum
trail_up := math.max(high, trail_up)
trail_up_x := trail_up == high ? n : trail_up_x

//Set top extension label/line


if barstate.islast and show_hl_swings
line.set_xy1(extend_top, trail_up_x, trail_up)
line.set_xy2(extend_top, n + 20, trail_up)

label.set_x(extend_top_lbl, n + 20)
label.set_y(extend_top_lbl, trail_up)
label.set_text(extend_top_lbl, trend < 0 ? '‫ 'مقاومة قوية‬: '‫)'مقاومة ضعيفة‬

//-----------------------------------------------------------------------------}
//Pivot Low
//-----------------------------------------------------------------------------{
var line extend_btm = na

var label extend_btm_lbl = label.new(na, na


, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = size.large)

if btm
btm_cross := true
txt_btm := btm < btm_y ? 'LL' : 'HL'

if show_swings
btm_lbl = label.new(n - length, btm, txt_btm
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = size.large)

if mode == 'Present'
label.delete(btm_lbl[1])
//Extend recent btm to last bar
line.delete(extend_btm[1])
extend_btm := line.new(n - length, btm, n, btm
, color = bull_css)

btm_y := btm
btm_x := n-length

trail_dn := btm
trail_dn_x := n-length

if ibtm
ibtm_cross := true

ibtm_y := ibtm
ibtm_x := n - 5

//Trailing minimum
trail_dn := math.min(low, trail_dn)
trail_dn_x := trail_dn == low ? n : trail_dn_x

//Set btm extension label/line


if barstate.islast and show_hl_swings
line.set_xy1(extend_btm, trail_dn_x, trail_dn)
line.set_xy2(extend_btm, n + 20, trail_dn)

label.set_x(extend_btm_lbl, n + 20)
label.set_y(extend_btm_lbl, trail_dn)
label.set_text(extend_btm_lbl, trend > 0 ? '‫ 'دعم ضعيف‬: ' ‫)'دعم قوي‬

//-----------------------------------------------------------------------------}
//Order Blocks Arrays
//-----------------------------------------------------------------------------{
var iob_top = array.new_float(0)
var iob_btm = array.new_float(0)
var iob_left = array.new_int(0)
var iob_type = array.new_int(0)

var ob_top = array.new_float(0)


var ob_btm = array.new_float(0)
var ob_left = array.new_int(0)
var ob_type = array.new_int(0)

//-----------------------------------------------------------------------------}
//Pivot High BOS/CHoCH
//-----------------------------------------------------------------------------{
//Filtering
var bull_concordant = true

if ifilter_confluence
bull_concordant := high - math.max(close, open) > math.min(close, open - low)

//Detect internal bullish Structure


if ta.crossover(close, itop_y) and itop_cross and top_y != itop_y and
bull_concordant
bool choch = na

if itrend < 0
choch := true
bull_ichoch_alert := true
else
bull_ibos_alert := true

txt = choch ? '‫ ' إيجابي‬: '‫' إيجابي‬

if show_internals
if show_ibull == 'All' or (show_ibull == '‫ 'إيجابي‬and not choch) or
(show_ibull == '‫ 'إيجابي‬and choch)
display_Structure(itop_x, itop_y, txt, ibull_css, true, true,
size.large)

itop_cross := false
itrend := 1

//Internal Order Block


if show_iob
ob_coord(false, itop_x, iob_top, iob_btm, iob_left, iob_type)

//Detect bullish Structure


if ta.crossover(close, top_y) and top_cross
bool choch = na

if trend < 0
choch := true
bull_choch_alert := true
else
bull_bos_alert := true

txt = choch ? '‫ 'إيجابي‬: '‫' إيجابي‬

if show_Structure
if show_bull == 'All' or (show_bull == '‫ 'إيجابي‬and not choch) or (show_bull
== '‫ 'إيجابي‬and choch)
display_Structure(top_x, top_y, txt, bull_css, false, true, size.large)

//Order Block
if show_ob
ob_coord(false, top_x, ob_top, ob_btm, ob_left, ob_type)

top_cross := false
trend := 1

//-----------------------------------------------------------------------------}
//Pivot Low BOS/CHoCH
//-----------------------------------------------------------------------------{
var bear_concordant = true

if ifilter_confluence
bear_concordant := high - math.max(close, open) < math.min(close, open - low)

//Detect internal bearish Structure


if ta.crossunder(close, ibtm_y) and ibtm_cross and btm_y != ibtm_y and
bear_concordant
bool choch = false

if itrend > 0
choch := true
bear_ichoch_alert := true
else
bear_ibos_alert := true

txt = choch ? ' ‫ 'سلبي‬: '‫' سلبي‬

if show_internals
if show_ibear == 'All' or (show_ibear == '‫ 'سلبي‬and not choch) or
(show_ibear == '‫ 'سلبي‬and choch)
display_Structure(ibtm_x, ibtm_y, txt, ibear_css, true, false,
size.large)

ibtm_cross := false
itrend := -1

//Internal Order Block


if show_iob
ob_coord(true, ibtm_x, iob_top, iob_btm, iob_left, iob_type)

//Detect bearish Structure


if ta.crossunder(close, btm_y) and btm_cross
bool choch = na

if trend > 0
choch := true
bear_choch_alert := true
else
bear_bos_alert := true

txt = choch ? '‫'سلبي‬ : '‫' سلبي‬

if show_Structure
if show_bear == 'All' or (show_bear == '‫ 'سلبي‬and not choch) or (show_bear
== '‫ 'سلبي‬and choch)
display_Structure(btm_x, btm_y, txt, bear_css, false, false,
size.large)

//Order Block
if show_ob
ob_coord(true, btm_x, ob_top, ob_btm, ob_left, ob_type)

btm_cross := false
trend := -1

//-----------------------------------------------------------------------------}
//Order Blocks
//-----------------------------------------------------------------------------{
//Set order blocks
var iob_boxes = array.new_box(0)
var ob_boxes = array.new_box(0)

//Delete internal order blocks box coordinates if top/bottom is broken


for element in iob_type
index = array.indexof(iob_type, element)

if close < array.get(iob_btm, index) and element == 1


array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bull_iob_break := true

else if close > array.get(iob_top, index) and element == -1


array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bear_iob_break := true

//Delete internal order blocks box coordinates if top/bottom is broken


for element in ob_type
index = array.indexof(ob_type, element)

if close < array.get(ob_btm, index) and element == 1


array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bull_ob_break := true

else if close > array.get(ob_top, index) and element == -1


array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bear_ob_break := true

iob_size = array.size(iob_type)
ob_size = array.size(ob_type)

if barstate.isfirst
if show_iob
for i = 0 to iob_showlast-1
array.push(iob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
if show_ob
for i = 0 to ob_showlast-1
array.push(ob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))

if iob_size > 0
if barstate.islast
display_ob(iob_boxes, iob_top, iob_btm, iob_left, iob_type, iob_showlast,
false, iob_size)

if ob_size > 0
if barstate.islast
display_ob(ob_boxes, ob_top, ob_btm, ob_left, ob_type, ob_showlast, true,
ob_size)

//-----------------------------------------------------------------------------}
//EQH/EQL
//-----------------------------------------------------------------------------{
var eq_prev_top = 0.
var eq_top_x = 0

var eq_prev_btm = 0.
var eq_btm_x = 0

if show_eq
eq_top = ta.pivothigh(eq_len, eq_len)
eq_btm = ta.pivotlow(eq_len, eq_len)

if eq_top
max = math.max(eq_top, eq_prev_top)
min = math.min(eq_top, eq_prev_top)

if max < min + atr * eq_threshold


eqh_line = line.new(eq_top_x, eq_prev_top, n-eq_len, eq_top
, color = bear_css
, style = line.style_dotted)

eqh_lbl = label.new(int(math.avg(n-eq_len, eq_top_x)), eq_top, '‫'سلبي‬


, color = #00000000
, textcolor = bear_css
, style = label.style_label_down
, size = size.large)

if mode == 'Present'
line.delete(eqh_line[1])
label.delete(eqh_lbl[1])

eqh_alert := true

eq_prev_top := eq_top
eq_top_x := n-eq_len

if eq_btm
max = math.max(eq_btm, eq_prev_btm)
min = math.min(eq_btm, eq_prev_btm)

if min > max - atr * eq_threshold


eql_line = line.new(eq_btm_x, eq_prev_btm, n-eq_len, eq_btm
, color = bull_css
, style = line.style_dotted)

eql_lbl = label.new(int(math.avg(n-eq_len, eq_btm_x)), eq_btm, '‫'إيجابي‬


, color = #00000000
, textcolor = bull_css
, style = label.style_label_up
, size = size.large)

eql_alert := true

if mode == 'Present'
line.delete(eql_line[1])
label.delete(eql_lbl[1])

eq_prev_btm := eq_btm
eq_btm_x := n-eq_len

//-----------------------------------------------------------------------------}
//Fair Value Gaps
//-----------------------------------------------------------------------------{
var bullish_fvg_max = array.new_box(0)
var bullish_fvg_min = array.new_box(0)

var bearish_fvg_max = array.new_box(0)


var bearish_fvg_min = array.new_box(0)
float bullish_fvg_avg = na
float bearish_fvg_avg = na

bullish_fvg_cnd = false
bearish_fvg_cnd = false

[src_c1, src_o1, src_h, src_l, src_h2, src_l2] =


request.security(syminfo.tickerid, fvg_tf, get_ohlc())

if show_fvg
delta_per = (src_c1 - src_o1) / src_o1 * 100

change_tf = timeframe.change(fvg_tf)

threshold = fvg_auto ? ta.cum(math.abs(change_tf ? delta_per : 0)) / n * 2


: 0

//FVG conditions
bullish_fvg_cnd := src_l > src_h2
and src_c1 > src_h2
and delta_per > threshold
and change_tf

bearish_fvg_cnd := src_h < src_l2


and src_c1 < src_l2
and -delta_per > threshold
and change_tf

//FVG Areas
if bullish_fvg_cnd
array.unshift(bullish_fvg_max, box.new(n-1, src_l, n + fvg_extend,
math.avg(src_l, src_h2)
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))

array.unshift(bullish_fvg_min, box.new(n-1, math.avg(src_l, src_h2), n +


fvg_extend, src_h2
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))

if bearish_fvg_cnd
array.unshift(bearish_fvg_max, box.new(n-1, src_h, n + fvg_extend,
math.avg(src_h, src_l2)
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))

array.unshift(bearish_fvg_min, box.new(n-1, math.avg(src_h, src_l2), n +


fvg_extend, src_l2
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))

for bx in bullish_fvg_min
if low < box.get_bottom(bx)
box.delete(bx)
box.delete(array.get(bullish_fvg_max, array.indexof(bullish_fvg_min,
bx)))

for bx in bearish_fvg_max
if high > box.get_top(bx)
box.delete(bx)
box.delete(array.get(bearish_fvg_min, array.indexof(bearish_fvg_max,
bx)))

//-----------------------------------------------------------------------------}
//Previous day/week high/lows
//-----------------------------------------------------------------------------{
//Daily high/low
[pdh, pdl] = request.security(syminfo.tickerid, 'D', hl()
, lookahead = barmerge.lookahead_on)

//Weekly high/low
[pwh, pwl] = request.security(syminfo.tickerid, 'W', hl()
, lookahead = barmerge.lookahead_on)

//Monthly high/low
[pmh, pml] = request.security(syminfo.tickerid, 'M', hl()
, lookahead = barmerge.lookahead_on)

//Display Daily
if show_pdhl
phl(pdh, pdl, 'D', pdhl_css)

//Display Weekly
if show_pwhl
phl(pwh, pwl, 'W', pwhl_css)

//Display Monthly
if show_pmhl
phl(pmh, pml, 'M', pmhl_css)

//-----------------------------------------------------------------------------}
//Premium/Discount/Equilibrium zones
//-----------------------------------------------------------------------------{
var premium = box.new(na, na, na, na
, bgcolor = color.new(premium_css, 80)
, border_color = na)

var premium_lbl = label.new(na, na


, text = 'Premium'
, color = TRANSP_CSS
, textcolor = premium_css
, style = label.style_label_down
, size = size.small)

var eq = box.new(na, na, na, na


, bgcolor = color.rgb(120, 123, 134, 80)
, border_color = na)

var eq_lbl = label.new(na, na


, text = 'Equilibrium'
, color = TRANSP_CSS
, textcolor = eq_css
, style = label.style_label_left
, size = size.small)

var discount = box.new(na, na, na, na


, bgcolor = color.new(discount_css, 80)
, border_color = na)
var discount_lbl = label.new(na, na
, text = 'Discount'
, color = TRANSP_CSS
, textcolor = discount_css
, style = label.style_label_up
, size = size.small)

//Show Premium/Discount Areas


if barstate.islast and show_sd
avg = math.avg(trail_up, trail_dn)

box.set_lefttop(premium, math.max(top_x, btm_x), trail_up)


box.set_rightbottom(premium, n, .95 * trail_up + .05 * trail_dn)

label.set_xy(premium_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_up)

box.set_lefttop(eq, math.max(top_x, btm_x), .525 * trail_up + .475*trail_dn)


box.set_rightbottom(eq, n, .525 * trail_dn + .475 * trail_up)

label.set_xy(eq_lbl, n, avg)

box.set_lefttop(discount, math.max(top_x, btm_x), .95 * trail_dn + .05 *


trail_up)
box.set_rightbottom(discount, n, trail_dn)
label.set_xy(discount_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_dn)

//-----------------------------------------------------------------------------}
//Trend
//-----------------------------------------------------------------------------{
var color trend_css = na

if show_trend
if style == 'Colored'
trend_css := itrend == 1 ? bull_css : bear_css
else if style == 'Monochrome'
trend_css := itrend == 1 ? #b2b5be : #5d606b

plotcandle(open, high, low, close


, color = trend_css
, wickcolor = trend_css
, bordercolor = trend_css
, editable = false)

//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//Internal Structure
alertcondition(bull_ibos_alert, 'Internal Bullish BOS', 'Internal Bullish BOS
formed')
alertcondition(bull_ichoch_alert, 'Internal Bullish CHoCH', 'Internal Bullish CHoCH
formed')

alertcondition(bear_ibos_alert, 'Internal Bearish BOS', 'Internal Bearish BOS


formed')
alertcondition(bear_ichoch_alert, 'Internal Bearish CHoCH', 'Internal Bearish CHoCH
formed')

//Swing Structure
alertcondition(bull_bos_alert, 'Bullish BOS', 'Internal Bullish BOS formed')
alertcondition(bull_choch_alert, 'Bullish CHoCH', 'Internal Bullish CHoCH formed')

alertcondition(bear_bos_alert, 'Bearish BOS', 'Bearish BOS formed')


alertcondition(bear_choch_alert, 'Bearish CHoCH', 'Bearish CHoCH formed')

//order Blocks
alertcondition(bull_iob_break, 'Bullish Internal OB Breakout', 'Price broke bullish
iternal OB')
alertcondition(bear_iob_break, 'Bearish Internal OB Breakout', 'Price broke bearish
iternal OB')

alertcondition(bull_ob_break, 'Bullish OB Breakout', 'Price broke bullish iternal


OB')
alertcondition(bear_ob_break, 'bearish OB Breakout', 'Price broke bearish iternal
OB')

//EQH/EQL
alertcondition(eqh_alert, 'Equal Highs', 'Equal highs detected')
alertcondition(eql_alert, 'Equal Lows', 'Equal lows detected')

//FVG
alertcondition(bullish_fvg_cnd, 'Bullish FVG', 'Bullish FVG formed')
alertcondition(bearish_fvg_cnd, 'Bearish FVG', 'Bearish FVG formed')

//-----------------------------------------------------------------------------}

k = input.float(1.,'Slope',minval=0,step=.1, group = '--------------- ‫مؤشر خطوط‬


‫ اتجاه التراند مع الفواصل‬---------------')
method = input.string('Atr','Slope Calculation Method',
options=['Atr','Stdev','Linreg'])
show = input(false,'Show Only Confirmed Breakouts')
//----
upper = 0.,lower = 0.
slope_ph = 0.,slope_pl = 0.
src = close

//----
ph = ta.pivothigh(length,length)
pl = ta.pivotlow(length,length)
slope = switch method
'Atr' => ta.atr(length)/length*k
'Stdev' => ta.stdev(src,length)/length*k
'Linreg' => math.abs(ta.sma(src*bar_index,length)-
ta.sma(src,length)*ta.sma(bar_index,length))/ta.variance(n,length)/2*k

slope_ph := ph ? slope : slope_ph[1]


slope_pl := pl ? slope : slope_pl[1]

upper := ph ? ph : upper[1] - slope_ph


lower := pl ? pl : lower[1] + slope_pl
//----

//----
var line up_l = na
var line dn_l = na
var label recent_up_break = na
var label recent_dn_break = na
if ph[1]
line.delete(up_l[1])
label.delete(recent_up_break[1])

up_l := line.new(n-length-1,ph[1],n-length,upper,color=#f5f3f3,
extend=extend.right,style=line.style_dashed)
if pl[1]
line.delete(dn_l[1])
label.delete(recent_dn_break[1])

dn_l := line.new(n-length-1,pl[1],n-length,lower,color=#5789e6,
extend=extend.right,style=line.style_dashed)

if ta.crossover(src,upper-slope_ph*length)
label.delete(recent_up_break[1])
recent_up_break := label.new(n,low,'‫'شراء‬,color=#22692c,
textcolor=color.white,style=label.style_label_up,size=size.small)

if ta.crossunder(src,lower+slope_pl*length)
label.delete(recent_dn_break[1])
recent_dn_break := label.new(n,high,'‫'بيع‬,color=#d11212,
textcolor=color.white,style=label.style_label_down,size=size.small)

//----
plot(upper,'Upper',color = ph ? na : #f5f3f3,offset=-length)
plot(lower,'Lower',color = pl ? na : #5789e6,offset=-length)

alertcondition(ta.crossover(src,upper-slope_ph*length),'Upper Breakout','Price
broke upper trendline')
alertcondition(ta.crossunder(src,lower+slope_pl*length),'Lower Breakout','Price
broke lower trendline')
//
//
bool plot_ma_1 = input.bool(false, 'MA 1',inline='ma1',group= " ---- ‫مؤشر عشرة خطوط‬
‫لمعدل الحركة‬----")
string ma_1_type = input.string(defval='EMA', title='',inline='ma1',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_1_val = input.int(8, '', minval=1,inline='ma1')
string ma1_res = input.string(title='', defval='Normal MA',inline='ma1',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_1_colour = input.color(color.rgb(212, 204, 204), '',inline='ma1')

bool plot_ma_2 = input.bool(false, 'MA 2',inline='ma2')


string ma_2_type = input.string(defval='EMA',inline='ma2', title='',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_2_val = input.int(14, '', minval=1,inline='ma2')
string ma2_res = input.string(title='', defval='Normal MA',inline='ma2',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_2_colour = input.color(color.rgb(10, 139, 245), '',inline='ma2')
bool plot_ma_3 = input.bool(false, 'MA 3',inline='ma3')
string ma_3_type = input.string(defval='EMA',inline='ma3', title='',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_3_val = input.int(21, '', minval=1,inline='ma3')
string ma3_res = input.string(title='',inline='ma3', defval='Normal MA',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_3_colour = input.color(color.rgb(250, 166, 10), '',inline='ma3')

bool plot_ma_4 = input.bool(false, 'MA 4',inline='ma4')


string ma_4_type = input.string(defval='EMA', title='',inline='ma4',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_4_val = input.int(35, '', minval=1,inline='ma4')
string ma4_res = input.string(title='', inline='ma4',defval='Normal MA',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_4_colour = input.color(color.rgb(244, 11, 252), '',inline='ma4')

bool plot_ma_5 = input.bool(false, 'MA 5',inline='ma5')


string ma_5_type = input.string(defval='EMA', title='',
inline='ma5',options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_5_val = input.int(50, '', minval=1,inline='ma5')
string ma5_res = input.string(title='', defval='Normal MA',inline='ma5',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_5_colour = input.color(color.rgb(209, 245, 6), '',inline='ma5')

bool plot_ma_6 = input.bool(false, 'MA 6',inline='ma6')


string ma_6_type = input.string(defval='EMA', title='',inline='ma6',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_6_val = input.int(100, '', minval=1,inline='ma6')
string ma6_res = input.string(title='', inline='ma6',defval='Normal MA',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_6_colour = input.color(color.rgb(57, 6, 243), '',inline='ma6')

bool plot_ma_7 = input.bool(true, 'MA 7', inline='ma7')


string ma_7_type = input.string(defval='EMA', title='',
inline='ma7',options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_7_val = input.int(200, '', minval=1,inline='ma7')
string ma7_res = input.string(title='', defval='Normal MA',inline='ma7',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_7_colour = input.color(color.rgb(8, 245, 87), '',inline='ma7')
bool plot_ma_8 = input.bool(false, 'MA 8',inline='ma8')
string ma_8_type = input.string(defval='EMA', title='',inline='ma8',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_8_val = input.int(1, '', minval=1, inline='ma8')
string ma8_res = input.string(title='', defval='Normal MA',inline='ma8', options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_8_colour = input.color(color.black, '',inline='ma8')

bool plot_ma_9 = input.bool(false, 'MA 9', inline='ma9')


string ma_9_type = input.string(defval='EMA', title='', inline='ma9',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_9_val = input.int(1, '', minval=1, inline='ma9')
string ma9_res = input.string(title='', defval='Normal MA', inline='ma9',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_9_colour = input.color(color.black, '', inline='ma9')

bool plot_ma_10 = input.bool(false, 'MA 10', inline='ma10')


string ma_10_type = input.string(defval='EMA', title='',inline='ma10',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
int ma_10_val = input.int(1, '', minval=1,inline='ma10')
string ma10_res = input.string(title='', defval='Normal MA',inline='ma10',options =
["Normal
MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe
MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45
Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"])
color ma_10_colour = input.color(color.black, '', inline='ma10')

bool plot_ma_6_sm = input.bool(false, 'MA 6', inline='sma6')


int sm_ma_6_val = input.int(1, '', minval=1,inline='sma6')
string sm_ma_6 = input.string(defval='EMA',inline='sma6', title='',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
string sh_sm_ma6 = input.string("Show Both MAs",inline='sma6',title = "",options =
["Only Show Smoothed MA ","Show Both MAs"])
color sm_ma_6_colour = input.color(color.black, '', inline='sma6',tooltip
="Activate this if you want a smoother version of MA 6 . To use this you have to
activate MA 6 first.")

bool plot_ma_7_sm = input.bool(false, 'MA 7 ', inline='sma7')


int sm_ma_7_val = input.int(1, '', minval=1, inline='sma7')
string sm_ma_7 = input.string(defval='EMA', inline='sma7', title='',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
string sh_sm_ma7 = input.string("Show Both MAs",title = "", inline='sma7',options =
["Only Show Smoothed MA ","Show Both MAs"])
color sm_ma_7_colour = input.color(color.black, '', inline='sma7',tooltip
="Activate this if you want a smoother version of MA 7 . To use this you have to
activate MA 7 first.")
bool plot_ma_8_sm = input.bool(false, 'MA 8', inline='sma8',tooltip ="Activate this
if you want a smoother version of MA 8 . To use this you have to activate MA 8
first.")
int sm_ma_8_val = input.int(1, '', minval=1, inline='sma8')
string sm_ma_8 = input.string(defval='EMA', title='',
inline='sma8',options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
string sh_sm_ma8 = input.string("Show Both MAs",title = "", inline='sma8',options =
["Only Show Smoothed MA ","Show Both MAs"])
color sm_ma_8_colour = input.color(color.black, '', inline='sma8')

bool plot_ma_9_sm = input.bool(false, 'MA 9', inline='sma9')


int sm_ma_9_val = input.int(1, '', minval=1, inline='sma9')
string sm_ma_9 = input.string(defval='EMA', title='',inline='sma9',
options=['RMA', 'SMA', 'EMA', 'WMA','HMA','VWMA'])
string sh_sm_ma9 = input.string("Show Both MAs",title = "",inline='sma9', options =
["Only Show Smoothed MA ","Show Both MAs"])
color sm_ma_9_colour = input.color(color.black, '',inline='sma9', tooltip
="Activate this if you want a smoother version of MA 9 . To use this you have to
activate MA 9 first.")

ma_function(source, length, type) =>

if type == 'RMA'
ta.rma(source, length)
else if type == 'SMA'
ta.sma(source, length)
else if type == 'EMA'
ta.ema(source, length)
else if type == 'WMA'
ta.wma(source, length)
else if type == 'HMA'
if(length<2)
ta.hma(source,2)
else
ta.hma(source, length)
else
ta.vwma(source, length)

sh(string type) =>


if type == "Only Show Smoothed MA "
false
else
true

type_nor(type)=>
if (type == "Open") or (type == "High") or (type == "Low") or (type == "Close")
or (type == "Normal MA")
true
else
false
tf(res)=>

if (res == "1 Minute")


'1'
else if (res == "3 Minutes")
'3'
else if (res == "5 Minutes")
'5'
else if (res == "15 Minutes")
'15'
else if (res == "30 Minutes")
'30'
else if (res == "45 Minutes")
'45'
else if (res == "1 Hour")
'60'
else if (res == "2 Hours")
'120'
else if (res == "3 Hours")
'180'
else if (res == "4 Hours")
'240'
else if (res == "Day")
'D'
else if (res =="Week" )
'W'
else if (res == "Month")
'M'
else
timeframe.period

pr(res)=>
switch res
"Open" => open
"High" => high
"Low" => low
"Close" => close
"hlc3" => hlc3
"ohlc4" => ohlc4
"hlcc4" => hlcc4
=>close

ma_1 = plot_ma_1 ? (type_nor(ma1_res)?ma_function(pr(ma1_res), ma_1_val,


ma_1_type):request.security(syminfo.tickerid,tf(ma1_res) , ma_function(close,
ma_1_val, ma_1_type))):na
ma_2 = plot_ma_2 ?(type_nor(ma2_res)?ma_function(pr(ma2_res), ma_2_val,
ma_2_type):request.security(syminfo.tickerid, tf(ma2_res), ma_function(close,
ma_2_val, ma_2_type))):na
ma_3 = plot_ma_3 ?(type_nor(ma3_res)?ma_function(pr(ma3_res), ma_3_val,
ma_3_type):request.security(syminfo.tickerid, tf(ma3_res), ma_function(close,
ma_3_val, ma_3_type))):na
ma_4 = plot_ma_4 ?(type_nor(ma4_res)?ma_function(pr(ma4_res), ma_4_val, ma_4_type):
request.security(syminfo.tickerid, tf(ma4_res), ma_function(close, ma_4_val,
ma_4_type))):na
ma_5 = plot_ma_5 ?(type_nor(ma5_res)?ma_function(pr(ma5_res), ma_5_val,
ma_5_type):request.security(syminfo.tickerid, tf(ma5_res), ma_function(close,
ma_5_val, ma_5_type))):na

ma_6 = plot_ma_6 ?(type_nor(ma6_res)?ma_function(pr(ma6_res), ma_6_val,


ma_6_type):request.security(syminfo.tickerid,tf(ma6_res) , ma_function(close,
ma_6_val, ma_6_type))):na
ma_7 = plot_ma_7 ?(type_nor(ma7_res)?ma_function(pr(ma7_res), ma_7_val,
ma_7_type):request.security(syminfo.tickerid,tf(ma7_res) , ma_function(close,
ma_7_val, ma_7_type))):na
ma_8 = plot_ma_8 ?(type_nor(ma8_res)?ma_function(pr(ma8_res), ma_8_val,
ma_8_type):request.security(syminfo.tickerid,tf(ma8_res) , ma_function(close,
ma_8_val, ma_8_type))):na
ma_9 = plot_ma_9 ?(type_nor(ma9_res)?ma_function(pr(ma9_res), ma_9_val,
ma_9_type):request.security(syminfo.tickerid,tf(ma9_res) , ma_function(close,
ma_9_val, ma_9_type))):na

sm_ma6 = plot_ma_6_sm ?ma_function(ma_6,sm_ma_6_val,sm_ma_6):na


sm_ma7 = plot_ma_7_sm ?ma_function(ma_7,sm_ma_7_val,sm_ma_7):na
sm_ma8 = plot_ma_8_sm ?ma_function(ma_8,sm_ma_8_val,sm_ma_8):na
sm_ma9 = plot_ma_9_sm ?ma_function(ma_9,sm_ma_9_val,sm_ma_9):na

plot(plot_ma_1 ? ma_1 : na, 'MA 1', ma_1_colour,linewidth = 1 )


plot(plot_ma_2 ? ma_2 : na, 'MA 2', ma_2_colour,linewidth = 1)
plot(plot_ma_3 ? ma_3 : na, 'MA 3', ma_3_colour,linewidth = 1)
plot(plot_ma_4 ? ma_4 : na, 'MA 4', ma_4_colour,linewidth = 1)
plot(plot_ma_5 ? ma_5 : na, 'MA 5', ma_5_colour,linewidth = 1)

plot(plot_ma_6 and sh(sh_sm_ma6)? ma_6 : na, 'MA 6', ma_6_colour,linewidth = 1)


plot(plot_ma_6_sm ? sm_ma6 : na, 'MA 6 Smoothed', sm_ma_6_colour,linewidth = 1)

plot(plot_ma_7 and sh(sh_sm_ma7) ? ma_7 : na, 'MA 7', ma_7_colour,linewidth = 1)


plot(plot_ma_7_sm ? sm_ma7 : na, 'MA 7 Smoothed', sm_ma_7_colour,linewidth = 1)

plot(plot_ma_8 and sh(sh_sm_ma8)? ma_8 : na, 'MA 8', ma_8_colour,linewidth = 1)


plot(plot_ma_8_sm ? sm_ma8 : na, 'MA 8 Smoothed', sm_ma_8_colour,linewidth = 1)

plot(plot_ma_9 and sh(sh_sm_ma9)? ma_9 : na, 'MA 9', ma_9_colour,linewidth = 1)


plot(plot_ma_9_sm ? sm_ma9 : na, 'MA 9 Smoothed', sm_ma_9_colour,linewidth = 1)

//
//

smma(src, length) =>


smma = 0.0
smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1) + src) /
length
smma

jawLength = input.int(13, minval=1, title="Jaw Length", group =


'-----------------------------------‫مؤشر التمساح‬-----------------------------------')
teethLength = input.int(8, minval=1, title="Teeth Length")
lipsLength = input.int(5, minval=1, title="Lips Length")
jawOffset = input(8, title="Jaw Offset")
teethOffset = input(5, title="Teeth Offset")
lipsOffset = input(3, title="Lips Offset")
jaw = smma(hl2, jawLength)
teeth = smma(hl2, teethLength)
lips = smma(hl2, lipsLength)
plot(jaw, "Jaw", offset = jawOffset, color = input.color(color.new(#f39509, 100)))
plot(teeth, "Teeth", offset = teethOffset, color = input.color(color.new(#f7f6f4,
100)))
plot(lips, "Lips", offset = lipsOffset, color=input.color(color.new(#66BB6A, 100)))

You might also like