0% found this document useful (0 votes)
18 views44 pages

Trading Indicator Script Overview

The document contains a script for a trading indicator that utilizes various technical analysis tools such as moving averages, MACD, and supertrend to generate buy and sell signals. It includes functions for calculating different types of moving averages and plotting them on the chart, as well as visual elements like colored candles and labels for buy/sell signals. Additionally, it incorporates parameters for customizing the indicator's appearance and behavior based on user input.

Uploaded by

andrewhany1599
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views44 pages

Trading Indicator Script Overview

The document contains a script for a trading indicator that utilizes various technical analysis tools such as moving averages, MACD, and supertrend to generate buy and sell signals. It includes functions for calculating different types of moving averages and plotting them on the chart, as well as visual elements like colored candles and labels for buy/sell signals. Additionally, it incorporates parameters for customizing the indicator's appearance and behavior based on user input.

Uploaded by

andrewhany1599
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

abel.

new(bar_index,
y1, "▲", xloc.bar_index, [Link], #04994b, label.style_label_up,
[Link], [Link]) : na
//sell = bear and ma02 > ma01 and dif > filter ? [Link](bar_index,
y2, "▼", xloc.bar_index, [Link], #b4060d, label.style_label_down,
[Link], [Link]) : na

buy = bull ? [Link](bar_index, y1, sma44 >= sma55 ? "▲" :


"▲+", xloc.bar_index, [Link], #04994b, label.style_label_up,
[Link], [Link]) : na
sell = bear ? [Link](bar_index, y2, sma44 <= sma55 ? "▼" : "▼+",
xloc.bar_index, [Link], #b4060d, label.style_label_down,
[Link], [Link]) : na
[supertrends, directions] = [Link](factor, atrPeriod)
bodyMiddle = plot((open + close) / 2, display=[Link])
// Trend Catcher Indicator (Example)
ema100 = [Link](close, 10)
ema200 = [Link](close, 20)
trendCatcher = [Link](ema100, ema200) ? 1 :
[Link](ema100, ema200) ? -1 : 0
trendColor = trendCatcher == 1 ? [Link](90, 23, 102) : na
barcolor(trendColor)
// Colored candles
// Take Profit Script
colorsr = 'DARK'
bullcolorr = colorsr == 'DARK' ? [Link](0, 255, 8) : #00DBFF
bearcolorr = colorsr == 'DARK' ? [Link](255,
w = [Link](2 / (frama_SC + 1)) / [Link]
'frama-o' => frama(source, c)
'frama-m' => frama_mod(source, c)
'dema' => calc_dema(source, c)
'tema' => calc_tema(source, c)
'zlema' => calc_zlema(source, c)
'smma' => calc_smma(source, c)
'kma' => calc_kama(source, c)
'tma' => calc_tma(source, c)
'gmma' => calc_gmma(source, c)
'vida' => calc_vida(source, c)
'cma' => calc_cma(source, c)
'rema' => calc_range_ema(source, c)

getMa(c) =>
switch ma2
'sma' => [Link](source,c)
'ema' => [Link](source,c)
'wma' => [Link](source,c)
'vwma' => [Link](source,c)
'rma' => [Link](source,c)
'alma' => [Link](source,c, 0.85, 6)
'hma' => [Link](source,c)
'jma' => calc_jma(source,c, phase, power)
'frama-o' => frama(source, c)
'frama-m' => frama_mod(source, c)
'dema' => calc_dema(source, c)
'tema' => calc_tema(source, c)
'zlema' => calc_zlema(source, c)
'smma' => calc_smma(source, c)
'kma' => calc_kama(source, c)
'tma' => calc_tma(source, c)
'gmma' => calc_gmma(source, c)
'vida' => calc_vida(source, c)
'cma' => calc_cma(source, c)
'rema' => calc_range_ema(source, c)

colour1 = [Link](#008000, 85)


colour2 = [Link](#7f0d0d, 85)
colour3 = [Link](#807800, 85)
colour4 = [Link](#290D7F, 85)
colour5 = [Link](#00807C, 85)
colour6 = [Link](#7F430D, 85)
c01 = Theme == 'Theme 1' ? colour1 : Theme == 'Theme 2' ? colour3 :
Theme == 'Theme 3' ? colour5 : Theme == 'No fill' ? #FFFFFF00 : na
c02 = Theme == 'Theme 1' ? colour2 : Theme == 'Theme 2' ? colour4 :
Theme == 'Theme 3' ? colour6 : Theme == 'N0 fill' ? #FFFFFF00 : na
cl1 = [Link](2, title='Cloud', inline='Cloud', group='MA cloud')
cl2 = [Link](6, title='/2', inline='Cloud', group='MA cloud')
cl3 = [Link](11, title='/3', inline='Cloud', group='MA cloud')
cl4 = [Link](18, title='/4', inline='Cloud', group='MA cloud')
cl5 = [Link](21, title='/5', inline='Cloud', group='MA cloud')
cl6 = [Link](24, title='/6', inline='Cloud', group='MA cloud')
cl7 = [Link](28, title='/7', inline='Cloud', group='MA cloud')
cl8 = [Link](34, title='/8', inline='Cloud', group='MA cloud')

rl1 = [Link](6, title='Ribbon', inline='Ribbon', group='MA Ribbon')


rl2 = [Link](13, title='/2', inline='Ribbon', group='MA Ribbon')
rl3 = [Link](20, title='/3', inline='Ribbon', group='MA Ribbon')
rl4 = [Link](28, title='/4', inline='Ribbon', group='MA Ribbon')
rl5 = [Link](36, title='/5', inline='Ribbon', group='MA Ribbon')
rl6 = [Link](45, title='/6', inline='Ribbon', group='MA Ribbon')
rl7 = [Link](55, title='/7', inline='Ribbon', group='MA Ribbon')
rl8 = [Link](444, title='/8', inline='Ribbon', group='MA Ribbon')

rib1 = getMa1(rl1)
rib2 = getMa1(rl2)
rib3 = getMa1(rl3)
rib4 = getMa1(rl4)
rib5 = getMa1(rl5)
rib6 = getMa1(rl6)
rib7 = getMa1(rl7)
rib8 = getMa1(rl8)
plot(rib1, color=[Link](#F5B771, 0), title='1', linewidth=2,
display=[Link])
plot(rib2, color=[Link](#F5B056, 0), title='2', linewidth=2,
display=[Link])
plot(rib3, color=[Link](#F57B4E, 0), title='3', linewidth=2,
display=[Link])
plot(rib4, color=[Link](#F56D58, 0), title='4', linewidth=2,
display=[Link])
plot(rib5, color=[Link](#F57D51, 0), title='5', linewidth=2,
display=[Link])
plot(rib6, color=[Link](#F55151, 0), title='6', linewidth=2,
display=[Link])
plot(rib7, color=[Link](#AA2707, 0), title='7', linewidth=2,
display=[Link])
plot(rib8, color=[Link](#AA0000, 0), title='8', linewidth=2,
display=[Link])
sma8 = getMa(cl8)
sma7 = getMa(cl7)
sma6 = getMa(cl6)
sma5 = getMa(cl5)
sma4 = getMa(cl4)
sma3 = getMa(cl3)
sma2 = getMa(cl2)
sma1 = getMa(cl1)
l8 = plot(sma8, display=[Link], editable=false)
l7 = plot(sma7, display=[Link], editable=false)
l6 = plot(sma6, display=[Link], editable=false)
l5 = plot(sma5, display=[Link], editable=false)
l4 = plot(sma4, display=[Link], editable=false)
l3 = plot(sma3, display=[Link], editable=false)
l2 = plot(sma2, display=[Link], editable=false)
l1 = plot(sma1, display=[Link], editable=false)
// --> fill
fill(l8, l1, color=sma7 <= source ? c01 : c02, editable=false)
fill(l7, l1, color=sma7 <= source ? c01 : c02, editable=false)
fill(l6, l1, color=sma6 <= source ? c01 : c02, editable=false)
fill(l5, l1, color=sma5 <= source ? c01 : c02, editable=false)
fill(l4, l1, color=sma4 <= source ? c01 : c02, editable=false)
fill(l3, l1, color=sma3 <= source ? c01 : c02, editable=false)

//plotchar(show_seq ? setupCount == 1 : na, char='', text='1',


textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link])
//plotchar(show_seq ? setupCount == 2 : na, char='', text='2',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link], display = [Link])
//plotchar(show_seq ? setupCount == 3 : na, char='', text='3',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link], display = [Link])
//plotchar(show_seq ? setupCount == 4 : na, char='', text='4',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link], display = [Link])
//plotchar(show_seq ? setupCount == 5 : na, char='', text='5',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link], display = [Link])
//plotchar(show_seq ? setupCount == 6 : na, char='', text='6',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link], display = [Link])
//plotchar(show_seq ? setupCount == 7 : na, char='', text='7',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link], display = [Link])
//plotchar(show_seq ? setupCount == 8 : na, char='', text='8',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link])
//plotchar(show_seq ? setupCount == 9 : na, char='', text='9',
textcolor=setupCountColor, color=setupCountColor,
location=[Link], size=[Link])

// ALERTS {
// } ALERTS

// Bar Coloring

// Input
fastLength = input(title="Fast Length", defval=12)
slowLength = input(title="Slow Length", defval=26)
srrrc = input(title="Source", defval=close)
signalLength = [Link](title="Signal Smoothing", minval = 1,
maxval = 50, defval = 9)
// Data reference
[macd, signal, hist] = [Link](srrrc, fastLength, slowLength,
signalLength)
// 4 level of green
greenHigh = #05df09
greenMidHigh = #05df09
greenMidLow = #388E3C
greenLow = #5f3a97
// Yellow
yellowLow = #5f3a97
// 4 level of red
redHigh = #ea0402
redMidHigh = #ea0402
redMidLow = #cc0402
redLow = #5f3a97
// Default color
candleBody = yellowLow
// Ranging trend
if hist > 0
if hist > hist[1] and hist[1] > 0
candleBody := greenLow
if hist < 0
if hist < hist[1] and hist[1] < 0
candleBody := redLow
// Bullish trend
if macd > 0 and hist > 0
candleBody := greenMidLow
if hist > hist[1] and macd[1] > 0 and hist[1] > 0
candleBody := greenMidHigh
if hist > hist[2] and macd[2] > 0 and hist[2] > 0
candleBody := greenHigh
// Bearish trend
if macd < 0 and hist < 0
candleBody := redMidLow
if hist < hist[1] and macd[1] < 0 and hist[1] < 0
candleBody := redMidHigh
if hist < hist[2] and macd[2] < 0 and hist[2] < 0
candleBody := redHigh
barcolor(Barcolloring == "Version 1" ? candleBody : close >
supertrends ? [Link](102, 255, 0) : [Link](255, 0, 0)) // Include
suggestion by Shaheen204
// TP Signals
multiplier = [Link](title='TP', defval=2, minval=1)
src5 = close
len5 = [Link](title='TP length', defval=150, minval=1)
offset = 0
calcSlope(src5, len5) =>
sumX = 0.0
sumY = 0.0
sumXSqr = 0.0
sumXY = 0.0
for i = 1 to len5 by 1
val = src5[len5 - i]
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
sumXY

slope = (len5 * sumXY - sumX * sumY) / (len5 * sumXSqr - sumX *


sumX)
average = sumY / len5
intercept = average - slope * sumX / len5 + slope
[slope, average, intercept]
var float tmp = na
[s, a, i] = calcSlope(src5, len5)
vwap1 = i + s * (len5 - offset)
sdev = [Link](close, len5)
dev = multiplier * sdev
top1 = vwap1 + dev
bott = vwap1 - dev
//
z1 = vwap1 + dev
x1 = vwap1 - dev
low1 = [Link](close, x1)
high1 = [Link](close, z1)
plotshape(tpmode == "Version 2" and close < supertrend ? low1 : na,
title='low', text='TP', color=[Link]([Link], 0),
style=[Link], location=[Link], size=[Link],
textcolor=[Link]([Link], 0)) //plot for buy icon
plotshape(tpmode == "Version 2" and close > supertrend ? high1 :
na, title='high', text='TP', color=[Link]([Link], 0),
style=[Link], location=[Link], size=[Link],
textcolor=[Link]([Link], 0)) //plot for sell icon
// PullBack Signals
start = [Link](title='Start', step=0.00005, defval=0.0134)
increment = [Link](title='Increment', step=0.00005, defval=0.)
maximum = [Link](title='Maximum', step=0.01, defval=0.21)
width = [Link](title='Point Width', minval=1, defval=20)
highlightStartPoints = input(title='Highlight Start Points ?',
defval=true)
Curly_Fries = input(150, title='Fast')
EmaClD
= [Link](true, title="Show TP/SL Points",
tooltip="Show TP | Stop Loss Points")
Popeyes = input(200, title='Medium')
Chicken_Sandwich = input(250, 'Slow')
ema_150 = [Link](close, Curly_Fries)
ema_200 = [Link](close, Popeyes)
ema_250 = [Link](close, Chicken_Sandwich)
//a = plot(ema_150, transp=100)
//b = plot(ema_200, transp=100)
//c = plot(ema_250, transp=100)
up = ema_150 > ema_250
down = ema_150 < ema_250
mycolor = up and EmaClD ? [Link](0, 255, 234, 71) : do
TF5Bull
= securityNoRep1([Link], "5"
, emaBull)
TF15Bull = securityNoRep1([Link], "15" , emaBull)
TF30Bull = securityNoRep1([Link], "30" , emaBull)
TF60Bull = securityNoRep1([Link], "60" , emaBull)
TF120Bull = securityNoRep1([Link], "120" , emaBull)
TF240Bull = securityNoRep1([Link], "240" , emaBull)
TF480Bull = securityNoRep1([Link], "480" , emaBull)
TFDBull
= securityNoRep1([Link], "1440", emaBull)
var dashboard_loc = locationDashboard == "Top Right" ?
position.top_right : locationDashboard == "Middle Right" ?
position.middle_right : locationDashboard == "Bottom Right" ?
position.bottom_right : locationDashboard == "Top Center" ?
position.top_center : locationDashboard == "Middle Center" ?
position.middle_center : locationDashboard == "Bottom Center" ?
position.bottom_center : locationDashboard == "Top Left" ?
position.top_left : locationDashboard == "Middle Left" ?
position.middle_left : position.bottom_left
var dashboard_size = sizeDashboard == "Large" ? [Link] :
sizeDashboard == "Normal" ? [Link] : sizeDashboard == "Small"
? [Link] : [Link]
var dashboard
= showDashboard ? [Link](dashboard_loc, 2,
15, tableBgColor, #404250, 1, tableBgColor, 1) : na
dashboard_cell(column, row, txt, signal=false) =>
[Link](dashboard, column, row, txt, 0, 0, signal ? #737581 :
tableTextColor, text_size=dashboard_size)
dashboard_cell_bg(column, row, col) =>
table.cell_set_bgcolor(dashboard, column, row, col)
if [Link] and showDashboard
dashboard_cell(0, 0 , "Algo elite")
dashboard_cell(0, 1 , "Current Position")
dashboard_cell(0, 2 , "Current Trend")
dashboard_cell(0, 3 , "Volume")
dashboard_cell(0, 4 , "Timeframe")
dashboard_cell(0, 5 , "1 min:")
dashboard_cell(0, 6 , "3 min:")
dashboard_cell(0, 7 , "5 min:")
dashboard_cell(0, 8 , "15 min:")
dashboard_cell(0, 9 , "30 min:")
dashboard_cell(0, 10, "1 H:")
dashboard_cell(0, 11, "2 H:")
dashboard_cell(0, 12, "4 H:")
dashboard_cell(0, 13, "8 H:")
dashboard_cell(0, 14, "Daily:")
dashboard_cell(1, 0 , "Premium")
dashboard_cell(1, 1 , emaBull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 1, emaBull ? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 2 ,
[Link](math.round_to_mintick(volume)))
dashboard_cell(1, 3 , "Trends")
dashboard_cell(1, 4 , TF1Bull
? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 4 , TF1Bull
? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 5 , TF3Bull
? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 5 , TF3Bull
? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 6 , TF5Bull
? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 6 , TF5Bull
? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 7 , TF15Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 7 , TF15Bull ? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 8 , TF30Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 8 , TF30Bull ? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 9, TF60Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 9, TF60Bull ? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 10, TF120Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 10, TF120Bull ? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 11, TF240Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 11, TF240Bull ? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 12, TF480Bull ? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 12, TF480Bull ? [Link](#125e5a, 10) :
[Link](#672230, 10))
dashboard_cell(1, 13, TFDBull
? "Bullish" : "Bearish", true),
dashboard_cell_bg(1, 13, TFDBull
? [Link](#125e5a, 10) :
[Link](#672230, 10))
//
// Ha Market Bias //
tf(_res, _exp, gaps_on) =>
gaps_on == 0 ? [Link]([Link], _res, _exp) :
gaps_on == true ? [Link]([Link], _res, _exp,
barmerge.gaps_on, barmerge.lookahead_off) :
[Link]([Link], _res, _exp, barmerge.gaps_off,
barmerge.lookahead_off)
ha_htf = ''
ha_len = 100
ha_len2 = 100
// Calculations {
o = [Link](open, ha_len)
c = [Link](close, ha_len)
h = [Link](high, ha_len)
l = [Link](low, ha_len)
haclose = tf(ha_htf, (o + h + l + c) / 4, 0)
xhaopen = tf(ha_htf, (o + c) / 2, 0)
haopen = na(xhaopen[1]) ? (o + c) / 2 : (xhaopen[1] + haclose[1]) / 2
hahigh = [Link](h, [Link](haopen, haclose))
halow = [Link](l, [Link](haopen, haclose))

o2 = tf(ha_htf, [Link](haopen, ha_len2), 0)


c2 = tf(ha_htf, [Link](haclose, ha_len2), 0)
h2 = tf(ha_htf, [Link](hahigh, ha_len2), 0)
l22 = tf(ha_htf, [Link](halow, ha_len2), 0)
ha_avg = (h2 + l22) / 2
// }
// Oscillator {
osc_len = 7
osc_bias = 100 *(c2 - o2)
osc_smooth = [Link](osc_bias, osc_len)
sigcolor =
(osc_bias > 0) and (osc_bias >= osc_smooth) ?
[Link]([Link], 35) :
(osc_bias > 0) and (osc_bias < osc_smooth) ? [Link]([Link],
75) :
(osc_bias < 0) and (osc_bias <= osc_smooth) ? [Link]([Link],
35) :
(osc_bias < 0) and (osc_bias > osc_smooth) ? [Link]([Link],
75) :
na
// }
// Plots {
p_h = plot(h2, "Bias High", color=color(na), display=[Link],
editable=false)
p_l = plot(l22, "Bias Low", color=color(na), display=[Link],
editable=false)
p_avg = plot(ha_avg, "Bias Avergae", color=color(na),
display=[Link], editable=false)

fill(p_l, p_h, show_ha ? sigcolor : na)


col = o2 > c2 ? [Link] : [Link]
// }
// Range Filter DW

//---------------------Range
Filter-----------------------------------------------------------------------------
---------------------------------------//Conditional Sampling EMA Function
Cond_EMA(x, cond, n) =>
var val = array.new_float(0)
var ema_val = array.new_float(1)
if cond
[Link](val, x)
if [Link](val) > 1
[Link](val, 0)
if na([Link](ema_val, 0))
[Link](ema_val, [Link](val, 0))
[Link](ema_val, 0, ([Link](val, 0) - [Link](ema_val, 0))
* (2 / (n + 1)) + [Link](ema_val, 0))
EMA = [Link](ema_val, 0)
EMA
//Conditional Sampling SMA Function
Cond_SMA(x, cond, n) =>
var vals = array.new_float(0)
if cond
[Link](vals, x)
if [Link](vals) > n
[Link](vals, 0)
SMA = [Link](vals)
SMA
//Standard Deviation Function
Stdev(x, n) =>
[Link](Cond_SMA([Link](x, 2), 1, n) [Link](Cond_SMA(x, 1, n), 2))
//Range Size Function
rng_size(x, scale, qty, n) =>
ATR = Cond_EMA([Link](true), 1, n)
AC = Cond_EMA([Link](x - x[1]), 1, n)
SD = Stdev(x, n)
rng_size = scale == 'Pips' ? qty * 0.0001 : scale == 'Points' ? qty *
[Link] : scale == '% of Price' ? close * qty / 100 : scale
== 'ATR' ? qty * ATR : scale == 'Average Change' ? qty * AC : scale ==
'Standard Deviation' ? qty * SD : scale == 'Ticks' ? qty *
[Link] : qty
rng_size
//Two Type Range Filter Function
rng_filt(h, l, rng_, n, type, smooth, sn, av_rf, av_n) =>
rng_smooth = Cond_EMA(rng_, 1, sn)
r = smooth ? rng_smooth : rng_
var rfilt = array.new_float(2, (h + l) / 2)
[Link](rfilt, 1, [Link](rfilt, 0))
if type == 'Type 1'
if h - r > [Link](rfilt, 1)
[Link](rfilt, 0, h - r)
if l + r < [Link](rfilt, 1)
[Link](rfilt, 0, l + r)
if type == 'Type 2'
if h >= [Link](rfilt, 1) + r
[Link](rfilt, 0, [Link](rfilt, 1) +
[Link]([Link](h - [Link](rfilt, 1)) / r) * r)
if l <= [Link](rfilt, 1) - r
[Link](rfilt, 0, [Link](rfilt, 1) - [Link]([Link](l
- [Link](rfilt, 1)) / r) * r)
rng_filt1 = [Link](rfilt, 0)
hi_band1 = rng_filt1 + r
lo_band1 = rng_filt1 - r
rng_filt2 = Cond_EMA(rng_filt1, rng_filt1 != rng_filt1[1], av_n)
hi_band2 = Cond_EMA(hi_band1, rng_filt1 != rng_filt1[1], av_n)
lo_band2 = Cond_EMA(lo_band1, rng_filt1 != rng_filt1[1], av_n)
rng_filt = av_rf ? rng_filt2 : rng_filt1
hi_band = av_rf ? hi_band2 : hi_band1
lo_band = av_rf ? lo_band2 : lo_band1
[hi_band, lo_band, rng_filt]
//---------------------------------------------------------------------------------
------------------------------------------------------------------------------//
Inputs
//---------------------------------------------------------------------------------
------------------------------------------------------------------------------//
Filter Type
f_type = 'Type 2'
//Movement Source
mov_src = 'Close'
//Range Size Inputs
rng_qty = 2.618
rng_scale = 'Average Change'
//Range Period
rng_per = 14
//Range Smoothing Inputs
smooth_range = true
smooth_per = 27
//Filter Value Averaging Inputs
av_vals = false
av_samples = 2
//---------------------------------------------------------------------------------
------------------------------------------------------------------------------//
Definitions
//---------------------------------------------------------------------------------
------------------------------
-------------------------------------------------//High And Low Values
h_val = mov_src == 'Wicks' ? high : close
l_val = mov_src == 'Wicks' ? low : close
//Range Filter Values
[h_band, l_band, filt] = rng_filt(h_val, l_val, rng_size((h_val + l_val) / 2,
rng_scale, rng_qty, rng_per), rng_per, f_type, smooth_range,
smooth_per, av_vals, av_samples)
//Direction Conditions
var fdir = 0.0
fdir := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir
upward = fdir == 1 ? 1 : 0
downward = fdir == -1 ? 1 : 0
//Colors
filt_color = upward ? #36db7f : downward ? #be130f : #cccccc
//---------------------------------------------------------------------------------
------------------------------------------------------------------------------//
Outputs
//---------------------------------------------------------------------------------
------------------------------------------------------------------------------//
Filter Plot
filt_plot = plot(Show_rangefilter ? filt : na, color=filt_color,
linewidth=3, title='Filter', transp=0)
//Bar Color
//External Trend Output
plot(fdir, editable=false, display=[Link], title='External Output
- Trend Signal', transp=100)

// Superlchi + TBO
tenkan_len = 6
tenkan_mult = 2
kijun_len

=5
kijun_mult

= 3.

spanB_len
= 26
spanB_mult = 4.
offsett
=0
//-----------------------------------------------------------------------------
avg(srcc,length,mult)=>
atr = [Link](length)*mult
up = hl2 + atr
dn = hl2 - atr
upper = 0.,lower = 0.
upper := srcc[1] < upper[1] ? [Link](up,upper[1]) : up
lower := srcc[1] > lower[1] ? [Link](dn,lower[1]) : dn
os = 0,max = 0.,min = 0.
os := srcc > upper ? 1 : srcc < lower ? 0 : os[1]
spt = os == 1 ? lower : upper
max := [Link](srcc,spt) ? [Link](srcc,max[1]) : os == 1 ?
[Link](srcc,max[1]) : spt
min := [Link](srcc,spt) ? [Link](srcc,min[1]) : os == 0 ?
[Link](srcc,min[1]) : spt
[Link](max,min)
//-----------------------------------------------------------------------------
tenkan = avg(close,tenkan_len,tenkan_mult)
kijun = avg(close,kijun_len,kijun_mult)
senkouA = [Link](kijun,tenkan)
senkouB = avg(close,spanB_len,spanB_mult)
//-----------------------------------------------------------------------------
tenkan_css = #2157f3
kijun_css = #ff5d00
cloud_a = [Link]([Link],80)
cloud_b = [Link]([Link],80)
chikou_css = #7b1fa2
plot(Show_SuperIchi ? tenkan : na,'Tenkan-Sen',tenkan_css)
plot(Show_SuperIchi ? kijun : na,'Kijun-Sen',kijun_css)
plot([Link](tenkan,kijun) and Show_SuperIchi ? kijun :
na,'Crossover',#2157f3,3,plot.style_circles)
plot([Link](tenkan,kijun) and Show_SuperIchi ? kijun :
na,'Crossunder',#ff5d00,3,plot.style_circles)
A = plot(Show_SuperIchi ? senkouA : na,'Senkou Span
A',na,offset=offsett-1)
B = plot(Show_SuperIchi ? senkouB : na,'Senkou Span
B',na,offset=offsett-1)
fill(A,B,senkouA > senkouB ? cloud_a : cloud_b)
plot(close,'Chikou',chikou_css,offset=offsett+1,display=[Link])
//
=========================================================
==============================
// MODULO DE SEÑALES PARA MEGA POWER
//
=========================================================
==============================
signals
= [Link](false, "Buy/Sell Signals?") // SE MUESTRAN
O NO BUY Y SELL SIGNALS
y1signals = low - ([Link](30) * 2)
y2signals = high + ([Link](30) * 2)
Buy

= signals and bull ? [Link](bar_index, y1signals, "BUY 🚀",

xloc.bar_index, [Link], #00d0ff, label.style_label_up, [Link](0,


0, 0), [Link]) : na
Sell = signals and bear ? [Link](bar_index, y2signals, "SELL",
xloc.bar_index, [Link], #ff0088, label.style_label_down,
[Link](255, 255, 255), [Link]) : na
//
=========================================================
==============================
changeCond = bull or bear //NECESARIO PARA EL MODULO DE
TPS
//
=========================================================
==============================
// Módulo - Entrada - SL - TPS mejora enviada por: CRIPTOMAN
SPAIN @CRIPTOTR4DER
//----------------------------------------//
*********************************************************
//*
Módulo
*
//*
Entrada - SL - TPSEND
*
//*********************************************************
// Cálculos
groupEnTpSl = "Módulo - Signals"
plot(na)
//
=========================================================
==============================
//ESTO ES EL CALCULO COMO SE HACIA EN EL PRIMER SCRIPT QUE
ME ENVIASTE
//
=========================================================
==============================
levels_tip = "Habilita etiquetas compra/venta /SL"
atrLen_tip = "Atr para el Calculo de Stoploss y TakeProfit"
atrRisk_tip = "Multiplicador de Riesgo ATR: Recomendado 1.5 o 1.9"
levels = input(title='Mostrar Etiquetas de Entrada/SL/TP',
defval=true, group=groupEnTpSl, tooltip=levels_tip)
atrLen
= [Link](10, "ATR Length SL ", group=groupEnTpSl,
tooltip=atrLen_tip)
atrRisk = [Link](1.9, "ATR Risk SL",
group=groupEnTpSl,tooltip=atrRisk_tip )
trigger = bull ? 1 : 0
atrBand = [Link](atrLen) * atrRisk
atrStop = trigger == 1 ? low - atrBand : high + atrBand
//
=========================================================
==============================
lastTrade(src) => [Link](changeCond, src, 0 )
//
=========================================================
==============================
//
=========================================================
==============================
//ENTRADAS
entry = levels ? [Link](time, close, "ENTRY - " +
[Link](lastTrade(close), "#.######"), xloc.bar_time, [Link],
[Link](0, 145, 255), label.style_label_left, [Link],
[Link]) : na
label.set_y(entry, lastTrade(close))
[Link](entry[1])
stop_y = lastTrade(atrStop)
stop = levels ? [Link](time, close, "STOP LOSS - " +
[Link](stop_y, "#.#####"), xloc.bar_time, [Link], #92080860,
label.style_label_left, [Link](255, 252, 252), [Link]) : na
label.set_y(stop, stop_y)
[Link](stop[1])
tp1_y = (lastTrade(close)-lastTrade(atrStop))*1 + lastTrade(close)
tp1
= levels ? [Link](time, close, "TP 1 - " + [Link](tp1_y,
"#.#####"), xloc.bar_time, [Link], #51ff00, label.style_label_left,
[Link](0, 0, 0), [Link]) : na
label.set_y(tp1, tp1_y)
[Link](tp1[1])
tp2_y = (lastTrade(close)-lastTrade(atrStop))*2 + lastTrade(close)
tp2
= levels ? [Link](time, close, "TP 2 - " + [Link](tp2_y,
"#.#####"), xloc.bar_time, [Link], #51ff00, label.style_label_left,
[Link](0, 0, 0), [Link]) : na
label.set_y(tp2, tp2_y)
[Link](tp2[1])
tp3_y = (lastTrade(close)-lastTrade(atrStop))*3 + lastTrade(close)
tp3
= levels ? [Link](time, close, "TP 3 - " + [Link](tp3_y,
"#.#####"), xloc.bar_time, [Link], #51ff00, label.style_label_left,
[Link](0, 0, 0), [Link]) : na
label.set_y(tp3, tp3_y)
[Link](tp3[1])

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 = [Link]('Historical'
, options = ['Historical', 'Present']
, group = 'Smart Money Concepts'
, tooltip = MODE_TOOLTIP)
style = [Link]('Colored'
, options = ['Colored', 'Monochrome']
, group = 'Smart Money Concepts'
, tooltip = STYLE_TOOLTIP)
show_trend = input(false, 'Color Candles'
, group = 'Smart Money Concepts'
, tooltip = COLOR_CANDLES_TOOLTIP)
//----------------------------------------}
//Internal Structure
//----------------------------------------{
show_internals = input(false, 'Show Internal Structure'
, group = 'Real Time Internal Structure'
, tooltip = SHOW_INTERNAL)
show_ibull = [Link]('All', 'Bullish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'ibull'
, group = 'Real Time Internal Structure')
swing_ibull_css = input(#089981, ''
, inline = 'ibull'
, group = 'Real Time Internal Structure')
//Bear Structure
show_ibear = [Link]('All', 'Bearish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'ibear'
, group = 'Real Time Internal Structure')
swing_ibear_css = input(#ffffff, ''
, inline = 'ibear'
, group = 'Real Time Internal Structure')
ifilter_confluence = input(false, 'Confluence Filter'
, group = 'Real Time Internal Structure'
, tooltip = CONFLUENCE_FILTER)
internal_structure_size = [Link]('Tiny', 'Internal Label Size'
, options = ['Tiny', 'Small', 'Normal']
, group = 'Real Time Internal Structure')
//----------------------------------------}
//Swing Structure
//----------------------------------------{
show_Structure = input(false, 'Show Swing Structure'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING)
//Bull Structure
show_bull = [Link]('All', 'Bullish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'bull'
, group = 'Real Time Swing Structure')
swing_bull_css = input(#ffffff, ''
, inline = 'bull'
, group = 'Real Time Swing Structure')
//Bear Structure
show_bear = [Link]('All', 'Bearish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'bear'
, group = 'Real Time Swing Structure')
swing_bear_css = input(#ffffff, ''
, inline = 'bear'
, group = 'Real Time Swing Structure')
swing_structure_size = [Link]('Small', 'Swing Label Size'
, options = ['Tiny', 'Small', 'Normal']
, group = 'Real Time Swing Structure')
//Swings
show_swings = input(false, 'Show Swings Points'
, inline = 'swings'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING_POINTS)
length = [Link](50, ''
, minval = 10
, inline = 'swings'
, group = 'Real Time Swing Structure')
show_hl_swings = input(false, 'Show Strong/Weak High/Low'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWHL_POINTS)
//----------------------------------------}
//Order Blocks
//----------------------------------------{
show_iob = input(false, 'Internal Order Blocks'
, inline = 'iob'
, group = 'Order Blocks'
, tooltip = INTERNAL_OB)
iob_showlast = [Link](5, ''
, minval = 1
, inline = 'iob'
, group = 'Order Blocks')
show_ob = input(true, 'Swing Order Blocks'
, inline = 'ob'
, group = 'Order Blocks'
, tooltip = SWING_OB)
ob_showlast = [Link](5, ''
, minval = 1
, inline = 'ob'
, group = 'Order Blocks')
ob_filter = [Link]('Atr', 'Order Block Filter'
, options = ['Atr', 'Cumulative Mean Range']
, group = 'Order Blocks'
, tooltip = FILTER_OB)
ibull_ob_css = [Link]([Link](#e5f77c, 80), 'Internal Bullish
OB'
, group = 'Order Blocks')
ibear_ob_css = [Link]([Link](#e5f77c, 80), 'Internal Bearish
OB'
, group = 'Order Blocks')
bull_ob_css = [Link]([Link](#00e2fb, 70), 'Bullish OB'
, group = 'Order Blocks')
bear_ob_css = [Link]([Link](#ff0015, 70), 'Bearish OB'
, group = 'Order Blocks')
//----------------------------------------}
//EQH/EQL
//----------------------------------------{
show_eq = input(false, 'Equal High/Low'
, group = 'EQH/EQL'
, tooltip = SHOW_EQHL)
eq_len = [Link](3, 'Bars Confirmation'
, minval = 1
, group = 'EQH/EQL'
, tooltip = EQHL_BARS)
eq_threshold = [Link](0.1, 'Threshold'
, minval = 0
, maxval = 0.5
, step = 0.1
, group = 'EQH/EQL'
, tooltip = EQHL_THRESHOLD)
eq_size = [Link]('Tiny', 'Label Size'
, options = ['Tiny', 'Small', 'Normal']
, group = 'EQH/EQL')
//----------------------------------------}
//Fair Value Gaps
//----------------------------------------{
show_fvg = input(true, 'Fair Value Gaps'
, group = 'Fair Value Gaps'
, tooltip = SHOW_FVG)
fvg_auto = input(true, "Auto Threshold"
, group = 'Fair Value Gaps'
, tooltip = AUTO_FVG)
fvg_tf = [Link]('', "Timeframe"
, group = 'Fair Value Gaps'
, tooltip = FVG_TF)
bull_fvg_css = [Link]([Link](#ffffff, 53), 'Bullish FVG'
, group = 'Fair Value Gaps')
bear_fvg_css = [Link]([Link](#ffffff, 53), 'Bearish FVG'
, group = 'Fair Value Gaps')
fvg_extend = [Link](10, "Extend FVG"
, minval = 0
, group = 'Fair Value Gaps'
, tooltip = EXTEND_FVG)
//----------------------------------------}
//Previous day/week high/low
//----------------------------------------{
//Daily
show_pdhl = input(true, 'Daily'
, inline = 'daily'
, group = 'Highs & Lows MTF')
pdhl_style = [Link]('⎯⎯⎯', ''
, options = ['⎯⎯⎯', '----', '····']
, inline = 'daily'
, group = 'Highs & Lows MTF')
pdhl_css = input(#ffffff, ''
, inline = 'daily'
, group = 'Highs & Lows MTF')
//Weekly
show_pwhl = input(false, 'Weekly'
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_style = [Link]('⎯⎯⎯', ''
, options = ['⎯⎯⎯', '----', '····']
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_css = input(#ffffff, ''
, inline = 'weekly'
, group = 'Highs & Lows MTF')
//Monthly
show_pmhl = input(false, 'Monthly'
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_style = [Link]('⎯⎯⎯', ''
, options = ['⎯⎯⎯', '----', '····']
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_css = input(#ffffff, ''
, inline = 'monthly'
, group = 'Highs & Lows MTF')
//----------------------------------------}
//Premium/Discount zones
//----------------------------------------{
show_sd = input(true, 'Premium/Discount Zones'
, group = 'Premium & Discount Zones'
, tooltip = PED_ZONES)
premium_css = [Link](#ffffff, 'Premium Zone'
, group = 'Premium & Discount Zones')
eq_css = [Link](#b2b5be, 'Equilibrium Zone'
, group = 'Premium & Discount Zones')
discount_css = [Link](#ffffff, 'Discount Zone'
, group = 'Premium & Discount Zones')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index
atr = [Link](200)
cmean_range = [Link](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)=>
s_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 = [Link](na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label high_lbl = [Link](na,na
, xloc = xloc.bar_time
, text = [Link]('P{0}H', tf)
, color = TRANSP_CSS
, textcolor = css
, size = [Link]
, style = label.style_label_left)
var line low_line = [Link](na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label low_lbl = [Link](na,na
, xloc = xloc.bar_time
, text = [Link]('P{0}L', tf)
, color = TRANSP_CSS
, textcolor = css
, size = [Link]
, style = label.style_label_left)
hy = [Link](h != h[1], h, 1)
hx = [Link](h == high, time, 1)
ly = [Link](l != l[1], l, 1)
lx = [Link](l == low, time, 1)
if [Link]
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 trend4 = 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
//Labels size
var internal_structure_lbl_size = internal_structure_size == 'Tiny'
? [Link]
: internal_structure_size == 'Small'
? [Link]
: [Link]
var swing_structure_lbl_size = swing_structure_size == 'Tiny'
? [Link]
: swing_structure_size == 'Small'
? [Link]
: [Link]
var eqhl_lbl_size = eq_size == 'Tiny'
? [Link]
: eq_size == 'Small'
? [Link]
: [Link]
//Swings
[top, btm] = swings(length)
[itop, ibtm] = swings(5)
//-----------------------------------------------------------------------------}
//Pivot High
//-----------------------------------------------------------------------------{
var line extend_top = na
var label extend_top_lbl = [Link](na, na
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = [Link])
if top
top_cross := true
txt_top := top > top_y ? 'HH' : 'LH'
if show_swings
top_lbl = [Link](n-length, top, txt_top
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = swing_structure_lbl_size)
if mode == 'Present'
[Link](top_lbl[1])
//Extend recent top to last bar
[Link](extend_top[1])
extend_top := [Link](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 := [Link](high, trail_up)
trail_up_x := trail_up == high ? n : trail_up_x
//Set top extension label/line
if [Link] 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, trend4 < 0 ? 'Strong High' : 'Weak
High')
//-----------------------------------------------------------------------------}
//Pivot Low
//-----------------------------------------------------------------------------{
var line extend_btm = na
var label extend_btm_lbl = [Link](na, na
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = [Link])
if btm
btm_cross := true
txt_btm := btm < btm_y ? 'LL' : 'HL'
if show_swings
btm_lbl = [Link](n - length, btm, txt_btm
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = swing_structure_lbl_size)
if mode == 'Present'
[Link](btm_lbl[1])
//Extend recent btm to last bar
[Link](extend_btm[1])
extend_btm := [Link](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 := [Link](low, trail_dn)
trail_dn_x := trail_dn == low ? n : trail_dn_x
//Set btm extension label/line
if [Link] 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, trend4 > 0 ? 'Strong Low' : 'Weak
Low')
//-----------------------------------------------------------------------------}
//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 - [Link](close, open) >
[Link](close, open - low)
//Detect internal bullish Structure
if [Link](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 ? 'CHoCH' : 'BOS'
if show_internals
if show_ibull == 'All' or (show_ibull == 'BOS' and not choch) or
(show_ibull == 'CHoCH' and choch)
display_Structure(itop_x, itop_y, txt, ibull_css, true, true,
internal_structure_lbl_size)
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 [Link](close, top_y) and top_cross
bool choch = na
if trend4 < 0
choch := true
bull_choch_alert := true
else
bull_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bull == 'All' or (show_bull == 'BOS' and not choch) or
(show_bull == 'CHoCH' and choch)
display_Structure(top_x, top_y, txt, bull_css, false, true,
swing_structure_lbl_size)
//Order Block
if show_ob
ob_coord(false, top_x, ob_top, ob_btm, ob_left, ob_type)
top_cross := false
trend4 := 1
//-----------------------------------------------------------------------------}
//Pivot Low BOS/CHoCH
//-----------------------------------------------------------------------------{
var bear_concordant = true
if ifilter_confluence
bear_concordant := high - [Link](close, open) <
[Link](close, open - low)
//Detect internal bearish Structure
if [Link](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 ? 'CHoCH' : 'BOS'
if show_internals
if show_ibear == 'All' or (show_ibear == 'BOS' and not choch)
or (show_ibear == 'CHoCH' and choch)
display_Structure(ibtm_x, ibtm_y, txt, ibear_css, true,
false, internal_structure_lbl_size)
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 [Link](close, btm_y) and btm_cross
bool choch = na
if trend4 > 0
choch := true
bear_choch_alert := true
else
bear_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bear == 'All' or (show_bear == 'BOS' and not choch) or
(show_bear == 'CHoCH' and choch)
display_Structure(btm_x, btm_y, txt, bear_css, false, false,
swing_structure_lbl_size)
//Order Block
if show_ob
ob_coord(true, btm_x, ob_top, ob_btm, ob_left, ob_type)
btm_cross := false
trend4 := -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 = [Link](iob_type, element)
if close < [Link](iob_btm, index) and element == 1
[Link](iob_top, index)
[Link](iob_btm, index)
[Link](iob_left, index)
[Link](iob_type, index)
bull_iob_break := true
else if close > [Link](iob_top, index) and element == -1
[Link](iob_top, index)
[Link](iob_btm, index)
[Link](iob_left, index)
[Link](iob_type, index)
bear_iob_break := true
//Delete internal order blocks box coordinates if top/bottom is broken
for element in ob_type
index = [Link](ob_type, element)
if close < [Link](ob_btm, index) and element == 1
[Link](ob_top, index)
[Link](ob_btm, index)
[Link](ob_left, index)
[Link](ob_type, index)
bull_ob_break := true
else if close > [Link](ob_top, index) and element == -1
[Link](ob_top, index)
[Link](ob_btm, index)
[Link](ob_left, index)
[Link](ob_type, index)
bear_ob_break := true
iob_size = [Link](iob_type)
ob_size = [Link](ob_type)
if [Link]
if show_iob
for i = 0 to iob_showlast-1
[Link](iob_boxes, [Link](na,na,na,na, xloc =
xloc.bar_time))
if show_ob
for i = 0 to ob_showlast-1
[Link](ob_boxes, [Link](na,na,na,na, xloc =
xloc.bar_time))
if iob_size > 0
if [Link]
display_ob(iob_boxes, iob_top, iob_btm, iob_left, iob_type,
iob_showlast, false, iob_size)
if ob_size > 0
if [Link]
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 = [Link](eq_len, eq_len)
eq_btm = [Link](eq_len, eq_len)
if eq_top
max = [Link](eq_top, eq_prev_top)
min = [Link](eq_top, eq_prev_top)
if max < min + atr * eq_threshold
eqh_line = [Link](eq_top_x, eq_prev_top, n-eq_len,
eq_top
, color = bear_css
, style = line.style_dotted)
eqh_lbl = [Link](int([Link](n-eq_len, eq_top_x)),
eq_top, 'EQH'
, color = #00000000
, textcolor = bear_css
, style = label.style_label_down
, size = eqhl_lbl_size)
if mode == 'Present'
[Link](eqh_line[1])
[Link](eqh_lbl[1])
eqh_alert := true
eq_prev_top := eq_top
eq_top_x := n-eq_len
if eq_btm
max = [Link](eq_btm, eq_prev_btm)
min = [Link](eq_btm, eq_prev_btm)
if min > max - atr * eq_threshold
eql_line = [Link](eq_btm_x, eq_prev_btm, n-eq_len,
eq_btm
, color = bull_css
, style = line.style_dotted)
eql_lbl = [Link](int([Link](n-eq_len, eq_btm_x)),
eq_btm, 'EQL'
, color = #00000000
, textcolor = bull_css
, style = label.style_label_up
, size = eqhl_lbl_size)
eql_alert := true
if mode == 'Present'
[Link](eql_line[1])
[Link](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] =
[Link]([Link], fvg_tf, get_ohlc())
if show_fvg
delta_per = (src_c1 - src_o1) / src_o1 * 100
change_tf = [Link](fvg_tf)
threshold = fvg_auto ? [Link]([Link](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
[Link](bullish_fvg_max, [Link](n-1, src_l, n +
fvg_extend, [Link](src_l, src_h2)
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
[Link](bullish_fvg_min, [Link](n-1, [Link](src_l,
src_h2), n + fvg_extend, src_h2
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
if bearish_fvg_cnd
[Link](bearish_fvg_max, [Link](n-1, src_h, n +
fvg_extend, [Link](src_h, src_l2)
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))
[Link](bearish_fvg_min, [Link](n-1, [Link](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)
[Link](bx)
[Link]([Link](bullish_fvg_max,
[Link](bullish_fvg_min, bx)))
for bx in bearish_fvg_max
if high > box.get_top(bx)
[Link](bx)
[Link]([Link](bearish_fvg_min,
[Link](bearish_fvg_max, bx)))
//-----------------------------------------------------------------------------}
//Previous day/week high/lows
//-----------------------------------------------------------------------------{
//Daily high/low
[pdh, pdl] = [Link]([Link], 'D', hl()
, lookahead = barmerge.lookahead_on)
//Weekly high/low
[pwh, pwl] = [Link]([Link], 'W', hl()
, lookahead = barmerge.lookahead_on)
//Monthly high/low
[pmh, pml] = [Link]([Link], '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 = [Link](na, na, na, na
, bgcolor = [Link](premium_css, 50)
, border_color = na)
var premium_lbl = [Link](na, na
, text = '🛒🛒🛒 SELL ZONE 🛒🛒🛒'

, color = TRANSP_CSS
, textcolor = premium_css
, style = label.style_label_down
, size = [Link])
var eq = [Link](na, na, na, na
, bgcolor = [Link](120, 123, 134, 50)
, border_color = na)
var eq_lbl = [Link](na, na
, text = 'Equilibrium'
, color = TRANSP_CSS
, textcolor = eq_css
, style = label.style_label_left
, size = [Link])
var discount = [Link](na, na, na, na
, bgcolor = [Link](discount_css, 80)
, border_color = na)
var discount_lbl = [Link](na, na
, text = '🛒🛒🛒 BUY ZONE 🛒🛒🛒'

, color = TRANSP_CSS
, textcolor = discount_css
, style = label.style_label_up
, size = [Link])
//Show Premium/Discount Areas
if [Link] and show_sd
avg = [Link](trail_up, trail_dn)
box.set_lefttop(premium, [Link](top_x, btm_x), trail_up)
box.set_rightbottom(premium, n, .95 * trail_up + .05 * trail_dn)
label.set_xy(premium_lbl, int([Link]([Link](top_x, btm_x),
n)), trail_up)
box.set_lefttop(eq, [Link](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, [Link](top_x, btm_x), .95 * trail_dn +
.05 * trail_up)
box.set_rightbottom(discount, n, trail_dn)
label.set_xy(discount_lbl, int([Link]([Link](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)

You might also like