0% found this document useful (0 votes)
161 views26 pages

Elite AlgoPoint Trading Indicator

This document contains a Pine Script™ code for a trading indicator called 'BUY/SELL AlgoPoint Remake Elite Algo'. It includes various volatility calculation functions and user input settings to customize the indicator's behavior. The script is designed to analyze market volatility and provide trading signals based on user-defined parameters.

Uploaded by

menoob1999
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)
161 views26 pages

Elite AlgoPoint Trading Indicator

This document contains a Pine Script™ code for a trading indicator called 'BUY/SELL AlgoPoint Remake Elite Algo'. It includes various volatility calculation functions and user input settings to customize the indicator's behavior. The script is designed to analyze market volatility and provide trading signals based on user-defined parameters.

Uploaded by

menoob1999
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

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.

0
at [Link]

//@version=5
indicator("BUY/SELL AlgoPoint Remake Elite Algo", shorttitle="BUY/SELL AlgoPoint
Remake Elite Algo", overlay = true, precision=0, explicit_plot_zorder=true,
max_labels_count=500, max_lines_count = 500, max_bars_back=500)

// ########## Elite Algo | AlgoPoint Remake Series ##########

// ---------------------------------------------- User Inputes


-----------------------------------------------------
// Volatility Calculater
// FUNCTIONS
title = '[Link]
subtitle = '@simpleforextools'
symInfoCheck = false
symInfo = [Link] + ' | ' + [Link] + ([Link] ? 'M' :
na)
date = [Link](dayofmonth(time_close)) + '/' + [Link](month(time_close))
+ '/' + [Link](year(time_close))
textVPosition = 'middle'
textHPosition = 'center'
symVPosition = 'top'
symHPosition = 'left'
width = 0
height = 0
c_title = #b2b5be80
s_title = 'large'
a_title = 'center'
c_subtitle = #b2b5be80
s_subtitle = 'normal'
a_subtitle = 'center'
c_bg = [Link]([Link], 100)
// Close to Close Volatility
f_coc(x, period, sqrtAnnual) =>
mean = [Link](x, period)
s = array.new_float(0)
for i = 0 to period - 1 by 1
[Link](s, [Link](x[i] - mean, 2))
sqrtAnnual * [Link]([Link](s) / (period - 1))

// Parkinson Volatility
f_park(period, sqrtAnnual) =>
var LOG2 = [Link](2)
powLogHighLow = [Link]([Link](high / low), 2)
sqrtAnnual * [Link](1.0 / period * [Link](1.0 / (4.0 * LOG2) *
powLogHighLow, period))

// Garman Klass Volatility


f_gk(period, sqrtAnnual) =>
var LOG2 = [Link](2)
var SQRT_1_PERIOD = [Link](1 / period)
powLogHighLow = [Link]([Link](high / low), 2)
powLogCloseOpen = [Link]([Link](close / open), 2)
tmp = 0.5 * powLogHighLow - (2.0 * LOG2 - 1.0) * powLogCloseOpen
sqrtAnnual * [Link]([Link](tmp, period)) * SQRT_1_PERIOD
// Rogers Satchell Volatility
f_rsv(period, sqrtAnnual) =>
tmp = [Link](high / close) * [Link](high / open) + [Link](low / close) *
[Link](low / open)
sqrtAnnual * [Link]([Link](tmp, period) / period)

// Garman Klass Yang Zhang Extension Volatility


f_gkyz(period, sqrtAnnual) =>
var LOG2 = [Link](2)
var SQRT_1_PERIOD = [Link](1 / period)
powLogHighLow = [Link]([Link](high / low), 2)
powLogCloseOpen = [Link]([Link](close / open), 2)
lastClose = nz(close[1], close)
powLogOpenClose1 = [Link]([Link](open / lastClose), 2)
tmp = powLogOpenClose1 + 0.5 * powLogHighLow - (2.0 * LOG2 - 1.0) *
powLogCloseOpen
sqrtAnnual * [Link]([Link](tmp, period)) * SQRT_1_PERIOD

// Yang Zhang Volatility


f_yz(a, period, sqrtAnnual) =>
oaman = [Link](open) - [Link](nz(close[1], close))
u = [Link](high) - [Link](open)
d = [Link](low) - [Link](open)
caman = [Link](close) - [Link](open)
nMinusOne = period - 1
avgo = [Link](oaman, period)
avgc = [Link](caman, period)
so = array.new_float(0)
sc = array.new_float(0)
for i = 0 to period - 1 by 1
[Link](so, [Link](oaman[i] - avgo, 2))
[Link](sc, [Link](caman[i] - avgc, 2))
sumo = [Link](so)
sumc = [Link](sc)
Vo = sumo / nMinusOne
Vc = sumc / nMinusOne
Vrs = [Link](u * (u - caman) + d * (d - caman), period) / period
k = (a - 1.0) / (a + (period + 1.0) / nMinusOne)
sqrtAnnual * [Link](Vo + k * Vc + (1.0 - k) * Vrs)

// Exponentially Weighted Volatility


f_ewma(source, period, sqrtAnnual) =>
var lambda = (period - 1) / (period + 1)
squared = [Link](source, 2)
float v = na
v := lambda * nz(v[1], squared) + (1.0 - lambda) * squared
sqrtAnnual * [Link](v)

// Mean Absolute Deviation (Adjusted)


f_mad(source, period, sqrtAnnual) =>
var SQRT_HALF_PI = [Link]([Link](1))
mean = [Link](source, period)
S = array.new_float(0)
for i = 0 to period - 1 by 1
[Link](S, [Link](source[i] - mean))
sumS = [Link](S)
sqrtAnnual * (sumS / period) * SQRT_HALF_PI
// Median Absolute Deviation
f_mead(source, period, sqrtAnnual) =>
median = ta.percentile_nearest_rank(source, period, 50)
E = 0.0
for i = 0 to period - 1 by 1
E += [Link](source[i] - median)
E
sqrtAnnual * [Link](2) * (E / period)

//Rescale Function
f_rescale(_src, _size) =>
[Link](0, [Link](_size, int(_src / 100 * _size)))

// label Panel Function


_label(T, color_PnL) =>
label PnL_Label = na
[Link](PnL_Label[1])
PnL_Label := [Link](time, 0, text=T, color=color_PnL, textcolor=[Link],
size=[Link], style=label.style_label_left, xloc=xloc.bar_time,
textalign=text.align_left)
label.set_x(PnL_Label, label.get_x(PnL_Label) + [Link]([Link](time) *
3))

// Round Function
Round(src, digits) =>
p = [Link](10, digits)
[Link]([Link](src) * p) / p * [Link](src)

//Options for Inputs


ON = 'On'
OFF = 'Off'
CTC = 'Close to Close'
PKS = 'Parkinson'
GK = 'Garman Klass'
RS = 'Rogers Satchell'
GKYZ = 'Garman Klass Yang Zhang Extension'
YZ = 'Yang Zhang'
EWMA = 'EWMA'
MAD = 'Mean Absolute Deviation'
MAAD = 'Median Absolute Deviation'
L = 'Line'
SL = 'StepLine'
Ar = 'Area'
CL = 'Columns'

// Settings
Haman = EWMA
period = 10
Annual = 365
a = 1.34
Plen = 365
Pco = ON
sma = ON
malen = 55
bsg = OFF
stl = CL
lT = 3
i_invert = OFF
bg = OFF
sp = OFF

// bgcolor(bg ? [Link](#000000, 20) : na, title='Dark Background', transp=90)

var sqrtAnnual = [Link](Annual) * 100

logr = [Link](close / close[1])

// Historical Volatiity Models


Hv = if Haman == CTC
f_coc(logr, period, sqrtAnnual)
else if Haman == PKS
f_park(period, sqrtAnnual)
else if Haman== RS
f_rsv(period, sqrtAnnual)
else if Haman == GK
f_gk(period, sqrtAnnual)
else if Haman == GKYZ
f_gkyz(period, sqrtAnnual)
else if Haman == EWMA
f_ewma(logr, period, sqrtAnnual)
else if Haman == YZ
f_yz(a, period, sqrtAnnual)
else if Haman == MAD
f_mad(logr, period, sqrtAnnual)
else
// H == "Median Absolute Deviation"
f_mead(logr, period, sqrtAnnual)

pstyle = stl == L ? plot.style_linebr : stl == SL ? plot.style_stepline : stl == Ar


? plot.style_area : stl == CL ? plot.style_columns : plot.style_line
textWatermark = [Link](textVPosition + '_' + textHPosition, 1, 3)
//Hv Stats
avgHV = [Link](Hv, malen)
HVP = [Link](Hv, Plen)
NearZero = HVP < 1.5 ? 1 : 0
HV50 = ta.percentile_nearest_rank(Hv, Plen, 50)

// // Text Functions
// texthv() =>
// ' HV: ' + [Link](Round(Hv, 2))

// textphv() =>
// 'HV 50ᵗʰ Percentile: ' + [Link](Round(HV50, 2))

// texthvp() =>
// 'HV Percentile: ' + [Link](Round(HVP, 2)) + 'ᵗʰ'

// // Coloring
// var c_ = array.new_color(na)
// if [Link]
// [Link](c_, #0effff)
// [Link](c_, #00fdf6)
// [Link](c_, #00fbee)
// [Link](c_, #00f9e4)
// [Link](c_, #00f6db)
// [Link](c_, #00f4d1)
// [Link](c_, #13f1c6)
// [Link](c_, #24efbc)
// [Link](c_, #31ecb1)
// [Link](c_, #3ce9a6)
// [Link](c_, #47e69b)
// [Link](c_, #51e390)
// [Link](c_, #5adf85)
// [Link](c_, #62dc7a)
// [Link](c_, #6ad96e)
// [Link](c_, #72d563)
// [Link](c_, #7ad157)
// [Link](c_, #81cd4b)
// [Link](c_, #88ca3f)
// [Link](c_, #8fc532)
// [Link](c_, #96c123)
// [Link](c_, #9cbd0e)
// [Link](c_, #a3b800)
// [Link](c_, #a9b300)
// [Link](c_, #b0ae00)
// [Link](c_, #b6a900)
// [Link](c_, #bca300)
// [Link](c_, #c29e00)
// [Link](c_, #c29e00)
// [Link](c_, #c89800)
// [Link](c_, #ce9100)
// [Link](c_, #d48b00)
// [Link](c_, #da8400)
// [Link](c_, #df7c00)
// [Link](c_, #e57400)
// [Link](c_, #ea6c00)
// [Link](c_, #ef6200)
// [Link](c_, #f35800)
// [Link](c_, #f74c00)
// [Link](c_, #fb3e00)
// [Link](c_, #ff2d00)

// if i_invert
// [Link](c_)
// var sizeOf = [Link](c_) - 1
// colorHV = Pco ? [Link](c_, f_rescale(HVP, sizeOf)) : [Link]

// Plots

// plot(Hv, 'HV', color=colorHV, linewidth=lT, style=plot.style_line)


// plot(sma ? avgHV : na, 'sma', color=[Link](#FFFFFF, 25), linewidth=2)

//bgcolor(Hv > avgHV ? [Link] : na)

// if sp
// _label(H + texthv() + '\n' + textphv() + '\n' + texthvp() + '\n\n',
#000000c0)

// col2 = HVP >= 1 ? [Link] : HVP <= 1 and HVP >= 0.5 ? [Link] : HVP <=
0.5 ? #8D0000 : [Link]
// // bgcolor(bsg and NearZero ? col2 : na, transp=50)

//Custrom MAS
maa = avgHV / 100 * 140
mab = avgHV / 100 * 180
mac = avgHV / 100 * 240
mad = avgHV / 100 * 60
mae = avgHV / 100 * 20

// Auto Sensivity Volatility Band Settings

float volatility = 0.0

if Hv < maa and Hv > avgHV // ilk band ust


volatility := 6
else if Hv < mab and Hv > maa // ikinci band ust
volatility := 7
else if Hv < mac and Hv > mab // ucuncu band ust
volatility := 7.8
else if Hv > mac // volatilite en ust degerde
volatility := 9
else if Hv < maa and Hv > mad // altdaki ilk band
volatility := 5
else if Hv < mad and Hv > mae // altdaki ikinci band
volatility := 4
else if Hv < mae // volatilite butun bandlarin anltinda
volatility := 3

//plot(volatility,color = [Link])

// plot(maa, 'maa', color=[Link]([Link], 25))


// plot(mab, 'mab', color=[Link]([Link], 25))
// plot(mac, 'mac', color=[Link]([Link], 25))
// plot(mad, 'mad', color=[Link]([Link], 25))
// plot(mae, 'mae', color=[Link]([Link], 25))

// basic settings
signalPreset = [Link]('None', 'Signal Preset⠀⠀⠀⠀⠀⠀⠀⠀⠀', ['None',
'Trend Only'], group='basic settings')
signalLogic = [Link]('Pro Scalper', 'Signal Logic⠀⠀⠀⠀⠀⠀⠀⠀⠀', ['Pro
Scalper', 'Normal'], group='basic settings')
signalStyle = [Link]('Normal', 'Signal Style⠀⠀⠀⠀⠀⠀⠀⠀⠀', ['Normal',
'Minimal'], group='basic settings')
signalAgility = [Link]('Auto Pilot', 'Agility%⠀⠀⠀⠀⠀⠀⠀⠀⠀', ['Auto
Pilot', 'Manual'], group='basic settings')
signalMode = signalStyle == 'Normal' ? 'Simple Entry + Exits' : 'Minimized
Entry + Exits'
normalsensitivity = [Link](15, "Normal Sensitivity⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
5.1, 50.1, step=0.1, group="basic settings", tooltip='Change Your Signal
Sensitivity And Accuracy')
sensitivity = [Link](5, "Pro Scalper Sensitivity⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀", 0.6,
15.1, step=0.1, group="basic settings", tooltip='Change Your Signal Sensitivity And
Accuracy')
strongSignalOnly = signalPreset == 'Trend Only' ? true : false
noRepainting = true
auto_button = signalAgility == 'Auto Pilot' ? true : false
// basic chart features
normalsignalsmode = normalsensitivity / 4.4
normalsignalvolatility = volatility - 1.7
if signalLogic == 'Pro Scalper'
sensitivity
else if signalLogic == 'Normal'
sensitivity := normalsignalsmode
//
if signalLogic == 'Pro Scalper'
volatility
else if signalLogic == 'Normal'
volatility := normalsignalvolatility
//
if auto_button == false
sensitivity
else if auto_button == true
sensitivity := volatility
//

ReversalCloud = input(false, 'Reversal Cloud⠀⠀⠀', group='basic chart


features', inline='feature [R, 1]')
LongTrendAverage = input(false, 'Long Trend Average', group='basic chart
features', inline='feature [R, 1]', tooltip='Places A Reversal Channel In Which
Reversals Can Be Predicted \n \nTrend Cloud Line (EMA), Will Be Shown On The
Chart')
ReversalBands = input(false, 'Reversal Bands⠀⠀⠀', group='basic chart
features', inline='feature [R, 2]')
TrendTracer = true
frequencyCloud = input(false, 'Frequency Cloud⠀⠀', 'Displays Short Trend
Cloud', group='basic chart features', inline='feature [R, 2]')
CandleColor = [Link]('Gradient Confirmation', 'Candle Stick Coloring',
['Gradient Confirmation', 'Off'], group='basic chart features')
Plot_MAs = [Link]( defval = true, title = "Trend Cloud", group = 'basic chart
features')

// leading features

//
//=============================================================================
// EK Cloud
//=============================================================================
//Moving Average
gr_MA = "📈Moving Average Settings📈"
// ---- User Settings ----
Timeframe = ''
Repaint = false
MA_T1 = "Ehlers Kaufman"
MA_S1_Input = close
MA_L1 = 200
MA_T2 = "Ehlers Kaufman"
MA_S2_Input = close
MA_L2 = 350
MA_S1 = [Link]([Link], Timeframe, MA_S1_Input[Repaint ? 0
: [Link] ? 1 : 0])[Repaint ? 0 : [Link] ? 0 : 1]
MA_S2 = [Link]([Link], Timeframe, MA_S2_Input[Repaint ? 0
: [Link] ? 1 : 0])[Repaint ? 0 : [Link] ? 0 : 1]

// ---- Moving Averages ----


MA_1 = switch MA_T1
"Simple" => [Link](MA_S1,MA_L1)
"Exponential" => [Link](MA_S1,MA_L1)
"Double Exponential" => 2 * [Link](MA_S1, MA_L1) - [Link]([Link](MA_S1,
MA_L1), MA_L1)
"Triple Exponential" => 3 * ([Link](MA_S1, MA_L1) - [Link]([Link](MA_S1,
MA_L1), MA_L1)) + [Link]([Link]([Link](MA_S1, MA_L1), MA_L1), MA_L1)
"Quadruple Exponential" => 5 * [Link](MA_S1,MA_L1) - 10 * [Link]([Link](MA_S1,
MA_L1), MA_L1) + 10 * [Link]([Link]([Link](MA_S1, MA_L1), MA_L1), MA_L1) - 5 *
[Link]([Link]([Link]([Link](MA_S1, MA_L1), MA_L1), MA_L1), MA_L1) +
[Link]([Link]([Link]([Link]([Link](MA_S1, MA_L1), MA_L1), MA_L1), MA_L1), MA_L1)
"Weighted" => [Link](MA_S1,MA_L1)
"Volume-weighted" => [Link](MA_S1,MA_L1)
"Hull" => [Link](MA_S1,MA_L1)
"Symmetrical" => [Link](MA_S1)
"Arnaud Legoux" => [Link](MA_S1, MA_L1, 0.85, 6)
"Least Squares" => [Link](MA_S1, MA_L1, 0)
"Relative Strength" => [Link](MA_S1,MA_L1)
"Welles Wilder" =>
Wilder_MA1 = .0
Wilder_MA1 := 1 / MA_L1 * MA_S1 + (1 - 1 / MA_L1) * nz(Wilder_MA1[1])
"Triangular" => [Link]([Link](MA_S1,MA_L1),MA_L1)
"Ehlers Kaufman" =>
KA_D1 = .0
for int i = 0 to 80 - 1 by 1
KA_D1 += [Link](nz(MA_S1[i]) - nz(MA_S1[i + 1]))
KA_EF1 = KA_D1 != 0 ? [Link]([Link](MA_S1 - nz(MA_S1[80 - 1])) / KA_D1,
1) : 0
KAMA1 = .0
KAMA1 := ([Link]((0.6667 * KA_EF1) + 0.0645, 2) * MA_S1) + ((1 -
[Link]((0.6667 * KA_EF1) + 0.0645, 2)) * nz(KAMA1[1]))

MA_2 = switch MA_T2


"Simple" => [Link](MA_S2,MA_L2)
"Exponential" => [Link](MA_S2,MA_L2)
"Double Exponential" => 2 * [Link](MA_S2, MA_L2) - [Link]([Link](MA_S2,
MA_L2), MA_L2)
"Triple Exponential" => 3 * ([Link](MA_S2, MA_L2) - [Link]([Link](MA_S2,
MA_L2), MA_L2)) + [Link]([Link]([Link](MA_S2, MA_L2), MA_L2), MA_L2)
"Quadruple Exponential" => 5 * [Link](MA_S2,MA_L2) - 10 * [Link]([Link](MA_S2,
MA_L2), MA_L2) + 10 * [Link]([Link]([Link](MA_S2, MA_L2), MA_L2), MA_L2) - 5 *
[Link]([Link]([Link]([Link](MA_S2, MA_L2), MA_L2), MA_L2), MA_L2) +
[Link]([Link]([Link]([Link]([Link](MA_S2, MA_L2), MA_L2), MA_L2), MA_L2), MA_L2)
"Weighted" => [Link](MA_S2,MA_L2)
"Volume-weighted" => [Link](MA_S2,MA_L2)
"Hull" => [Link](MA_S2,MA_L2)
"Symmetrical" => [Link](MA_S2)
"Arnaud Legoux" => [Link](MA_S2, MA_L2, 0.85, 6)
"Least Squares" => [Link](MA_S2, MA_L2, 0)
"Relative Strength" => [Link](MA_S2,MA_L2)
"Welles Wilder" =>
Wilder_MA2 = .0
Wilder_MA2 := 1 / MA_L2 * MA_S2 + (1 - 1 / MA_L2) * nz(Wilder_MA2[1])
"Triangular" => [Link]([Link](MA_S2,MA_L2),MA_L2)
"Ehlers Kaufman" =>
KA_D2 = .0
for int i = 0 to 135 - 1 by 1
KA_D2 += [Link](nz(MA_S2[i]) - nz(MA_S2[i + 1]))
KA_EF2 = KA_D2 != 0 ? [Link]([Link](MA_S2 - nz(MA_S2[135 - 1])) /
KA_D2, 1) : 0
KAMA2 = .0
KAMA2 := ([Link]((0.6667 * KA_EF2) + 0.0645, 2) * MA_S2) + ((1 -
[Link]((0.6667 * KA_EF2) + 0.0645, 2)) * nz(KAMA2[1]))
MA_Color = Plot_MAs ? MA_1 > MA_2 ? [Link](#04994b, 80) : [Link](#b4060d, 80)
: na
P1 = plot(Plot_MAs ? MA_1 : na, title="Fast MA", color=MA_Color)
P2 = plot(Plot_MAs ? MA_2 : na, title="Slow MA", color=MA_Color)
// [Link](textWatermark, 0, 0, title, width, height, c_title, a_title,
text_size=s_title, bgcolor=c_bg)
fill(P1, P2, color = MA_Color)

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ----------------------------------------------- Buy & Sell
-----------------------------------------------------

src = close
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = [Link]([Link](x - x[1]), t)
smoothrng = [Link](avrng, wper) * m
smoothrng
smrng = smoothrng(close, 100, sensitivity)

rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
: x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])

[mi, u, lo] = [Link](close, 90, 6.8)


[mid, upp, loww] = [Link](close, 90, 5.3)
[midd, ups, lowe] = [Link](close, 90, 4)

shorttop = [Link](close, 13)


longtop = [Link](close, 65)
eq_cloud_is_bullish = shorttop > longtop

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

hband = filt + smrng


lband = filt - smrng
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or src > filt and src <
src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or src < filt and src
> src[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

// Candle Rating
//=============================================================================
// INDICATOR 11 - Trend Confidence
//============================================================================

// CCI

TM_Long = [Link](close, 20) > 50


TM_Short = [Link](close, 20) < -50

//color1 = [Link](close, 5) >= 0 ? #0022FC : #FC0400


//plot(MagicTrend, color=color1, linewidth=3)

// ADX
lenadx = 21
lensig = 21
limadx = 34

ADX_up = [Link](high)
ADX_down = -[Link](low)
trur = [Link]([Link], lenadx)
plus = fixnan(100 * [Link](ADX_up > ADX_down and ADX_up > 0 ? ADX_up : 0, lenadx) /
trur)
minus = fixnan(100 * [Link](ADX_down > ADX_up and ADX_down > 0 ? ADX_down : 0,
lenadx) / trur)
sum = plus + minus
adx = 100 * [Link]([Link](plus - minus) / (sum == 0 ? 1 : sum), lensig)

macol = adx > limadx and plus > minus ? [Link] : adx > limadx and plus <
minus ? [Link] : [Link]

ADX_Long = adx > limadx and plus > minus


ADX_Short = adx > limadx and plus < minus

//Acumulation/Distribution
ACC_Dist = [Link]([Link], 21)

ACC_Long = [Link] > ACC_Dist


ACC_Short = [Link] < ACC_Dist
// MFI

MFI = [Link](close , 14)


MFI_SMA = [Link] (MFI, 9)

MFI_Long = MFI > MFI_SMA


MFI_Short = MFI < MFI_SMA

// Momentum Linear Regression

mom = [Link](close, 21)


lrmom = [Link](mom, 28, 0)

MOML_Long = lrmom > lrmom[1]


MOML_Short = lrmom < lrmom[1]

//
entry_long = true
entry_short = true

Long_Signal_Strength = 0
Short_Signal_Strength = 0

if entry_long
if TM_Long
Long_Signal_Strength += 1
if ADX_Long
Long_Signal_Strength += 1
if ACC_Long
Long_Signal_Strength += 1
if MFI_Long
Long_Signal_Strength += 1
if MOML_Long
Long_Signal_Strength += 1

if entry_short
if TM_Short
Short_Signal_Strength += 1
if ADX_Short
Short_Signal_Strength += 1
if ACC_Short
Short_Signal_Strength += 1
if MFI_Short
Short_Signal_Strength += 1
if MOML_Short
Short_Signal_Strength += 1
// Trend Detecting
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
length = 20
incr = 100
resetOn = 'CHoCH'
showMS = false

//Style
bullCss = [Link]
bearCss = [Link]
retCss = #ff5d00
areaTransp = 100

//------------------------------------------------------------------------------
//Global variables
//-----------------------------------------------------------------------------{
var float ph_y = na , var int ph_x = na
var float pl_y = na , var int pl_x = na
var float topaman = na , var float btmaman = na
var ph_cross = false, var pl_cross = false

var float maxaman = na


var float minaman = na
var float ts = na

var os = 0
ms = 0

//------------------------------------------------------------------------------
//Detect pivots and get coordinates
//-----------------------------------------------------------------------------{
n = bar_index
ph = [Link](length, length)
pl = [Link](length, length)

if ph
ph_y := ph
ph_x := n - length
ph_cross := false

if pl
pl_y := pl
pl_x := n - length
pl_cross := false

//-----------------------------------------------------------------------------}
//Bullish structures
//-----------------------------------------------------------------------------{
if close > ph_y and not ph_cross
if resetOn == 'CHoCH'
ms := os == -1 ? 1 : 0
else
ms := 1

ph_cross := true

//Highilight bullish MS
if showMS
[Link](ph_x, ph_y, n, ph_y
, color = bullCss
, style = os == -1 ? line.style_dashed : line.style_dotted)

os := 1

//Search for local minima


btmaman := low
for i = 0 to (n - ph_x)-1
btmaman := [Link](low[i], btmaman)
//-----------------------------------------------------------------------------}
//Bearish structures
//-----------------------------------------------------------------------------{
if close < pl_y and not pl_cross
if resetOn == 'CHoCH'
ms := os == 1 ? -1 : 0
else
ms := -1

pl_cross := true

//Highilight bearish MS
if showMS
[Link](pl_x, pl_y, n, pl_y
, color = bearCss
, style = os == 1 ? line.style_dashed : line.style_dotted)

os := -1

//Search for local maxima


topaman := high
for i = 0 to (n - pl_x)-1
topaman := [Link](high[i], topaman)

//-----------------------------------------------------------------------------}
//Trailing stop
//-----------------------------------------------------------------------------{
//Trailing max/min
if ms == 1
maxaman := close
else if ms == -1
minaman := close
else
maxaman := [Link](close, maxaman)
minaman := [Link](close, minaman)

//Trailing stop
ts := ms == 1 ? btmaman
: ms == -1 ? topaman
: os == 1 ? ts + (maxaman - maxaman[1]) * incr / 100
: ts + (minaman - minaman[1]) * incr / 100

//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
cssaman = ms ? na
: os == 1 ? bullCss
: bearCss

// plot_price = plot(close, editable = false, display = [Link])


// plot_ts = plot(ts, 'Trailing Stop', color = css)

// css_area = (close - ts) * os < 0 ? retCss


// : css

// fill(plot_price, plot_ts, [Link](css_area, areaTransp))

//-----------------------------------------------------------------------------}
//Plot Buy/Sell Signals on chart

buyCond = longCond and CondIni[1] == -1 and cssaman == bearCss


strongBuyCond1 = longCond and CondIni[1] == -1 and cssaman == bullCss
sellCond = shortCond and CondIni[1] == 1 and cssaman == bullCss
strongSellCond1 = shortCond and CondIni[1] == 1 and cssaman == bearCss

enter_pluslong = [Link](Long_Signal_Strength)
enter_plussell = [Link](Short_Signal_Strength)
enter_longtrt = [Link](Long_Signal_Strength)
enter_selltrtt = [Link](Short_Signal_Strength)

smartbuysigtex = "Strong\n" + [Link](Long_Signal_Strength) + "★"


smartbuyminimal = "▲+\n" + [Link](Long_Signal_Strength) + "★"

smartselsigtex = [Link](Short_Signal_Strength) + "★\n" + "Strong"


smartselminimal = [Link](Short_Signal_Strength) + "★\n" + "▼+"

buysigtex = "Buy\n" + [Link](Long_Signal_Strength) + "★"


buyminimal = "▲\n" + [Link](Long_Signal_Strength) + "★"

selsigtex = [Link](Short_Signal_Strength) + "★\n" + "Sell"


selsminimal = [Link](Short_Signal_Strength) + "★\n" + "▼"

//
if noRepainting
buyCond := buyCond and [Link]
strongBuyCond1 := strongBuyCond1 and [Link]
sellCond := sellCond and [Link]
strongSellCond1 := strongSellCond1 and [Link]
// Buy Signals
BuySignal = signalMode == 'Simple Entry + Exits' and buyCond and not
strongSignalOnly ? [Link](bar_index, low ,buysigtex , xloc.bar_index,
[Link], #00cf4b8c, label.style_label_up , [Link], [Link]) : na
MinimalBuy = signalMode == 'Minimized Entry + Exits' and buyCond and not
strongSignalOnly ? [Link](bar_index, low ,buyminimal , xloc.bar_index,
[Link], #00cf4b8c, label.style_label_up , [Link], [Link]) : na

StrongBuy = signalMode == 'Simple Entry + Exits' and strongBuyCond1 ?


[Link](bar_index, low ,smartbuysigtex , xloc.bar_index, [Link],
#00cf4b8c, label.style_label_up , [Link], [Link]) : na
MinimalStrongBuy = signalMode == 'Minimized Entry + Exits' and strongBuyCond1 ?
[Link](bar_index, low ,smartbuyminimal , xloc.bar_index, [Link],
#00cf4b8c, label.style_label_up , [Link], [Link]) : na
//Sell Signals
SellSignal = signalMode == 'Simple Entry + Exits' and sellCond and not
strongSignalOnly ? [Link](bar_index, high,selsigtex , xloc.bar_index,
[Link], #ff00008c , label.style_label_down, [Link], [Link]) : na
MinimalSell = signalMode == 'Minimized Entry + Exits' and sellCond and not
strongSignalOnly ? [Link](bar_index, high,selsminimal , xloc.bar_index,
[Link], #ff00008c , label.style_label_down, [Link], [Link]) : na

StrongSell = signalMode == 'Simple Entry + Exits' and strongSellCond1 ?


[Link](bar_index, high,smartselsigtex , xloc.bar_index, [Link], #ff00008c
, label.style_label_down, [Link], [Link]) : na
MinimalStrongSell = signalMode == 'Minimized Entry + Exits' and strongSellCond1 ?
[Link](bar_index, high,smartselminimal , xloc.bar_index, [Link],
#ff00008c , label.style_label_down, [Link], [Link]) : na

//plotshape(signalMode == 'Simple Entry + Exits' ? buyCond and not strongSignalOnly


: na,
// 'Buy', [Link], [Link], [Link](#00cf4b, 45),
size=[Link], textcolor=[Link], text= buysigtex)

//plotshape(signalMode == 'Minimized Entry + Exits' ? buyCond and not


strongSignalOnly : na,
// 'Minimized Buy', [Link], [Link], [Link](#00cf4b, 45),
size=[Link], textcolor=[Link], text= buyminimal)

//plotshape(signalMode == 'Simple Entry + Exits' ? strongBuyCond1 : na, 'Strong


Buy',
// [Link], [Link], #00cf4b8c, size=[Link],
textcolor=[Link], text= smartbuysigtex)

//plotshape(signalMode == 'Minimized Entry + Exits' ? strongBuyCond1 : na,


'Minimized Strong Buy',
// [Link], [Link], [Link](#00cf4b, 45), size=[Link],
textcolor=[Link], text= smartbuyminimal)

//plotshape(signalMode == 'Simple Entry + Exits' ? sellCond and not


strongSignalOnly : na, 'Sell',
// [Link], [Link], [Link](#ff0000, 45),
size=[Link], textcolor=[Link], text= selsigtex)

//plotshape(signalMode == 'Minimized Entry + Exits' ? sellCond and not


strongSignalOnly : na,
// 'Minimized Sell', [Link], [Link], [Link](#ff0000,
45), size=[Link], textcolor=[Link], text= selsminimal)

//plotshape(signalMode == 'Simple Entry + Exits' ? strongSellCond1 : na, 'Strong


Sell',
// [Link], [Link], #ff00008c, size=[Link],
textcolor=[Link], text= smartselsigtex)

//plotshape(signalMode == 'Minimized Entry + Exits' ? strongSellCond1 : na,


'Minimized Strong Sell',
// [Link], [Link], [Link](#ff0000, 45),
size=[Link], textcolor=[Link], text= smartselminimal)

//MA_Color = Plot_MAs ? MA_1 > MA_2 ? [Link](#04994b, 80) : [Link](#b4060d,


80) : na
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Candle Color
----------------------------------------------------

barcolor = src > filt and src > src[1] and upward > 0 ? [Link](#00db0a, 5) : src
> filt and src <
src[1] and upward > 0 ? [Link](#00db05, 5) : src < filt and src < src[1]
and downward > 0 ? [Link](#c90505, 5) :
src < filt and src > src[1] and downward > 0 ? [Link](#ff0000 , 5) :
[Link](#3ebe48, 5) // 442886
barcolor(CandleColor == 'Gradient Confirmation' ? barcolor : na, title='Candle
Colors')

//
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Reversal Cloud
--------------------------------------------------

u1 = plot(ReversalCloud ? [Link](u, 1) : na, transp=100, editable=false)


u2 = plot(ReversalCloud ? [Link](upp, 5) : na, transp=100, editable=false)
u3 = plot(ReversalCloud ? [Link](ups, 10) : na, transp=100, editable=false)
l1 = plot(ReversalCloud ? [Link](lo, 1) : na, transp=100, editable=false)
l2 = plot(ReversalCloud ? [Link](loww, 5) : na, transp=100, editable=false)
l3 = plot(ReversalCloud ? [Link](lowe, 10) : na, transp=100, editable=false)
plot(ReversalBands ? [Link](u, 1) : na, transp=50, editable=false, offset=2,
color=[Link](#f23645, 60))
plot(ReversalBands ? [Link](upp, 5) : na, transp=50, editable=false, offset=3,
color=[Link](#f23645, 70))
plot(ReversalBands ? [Link](ups, 10) : na, transp=50, editable=false, offset=3,
color=[Link](#f23645, 65))
plot(ReversalBands ? [Link](lowe, 10) : na, transp=50, editable=false, offset=3,
color=[Link](#089981, 65))
plot(ReversalBands ? [Link](loww, 5) : na, transp=50, editable=false, offset =3,
color=[Link](#089981, 70))
plot(ReversalBands ? [Link](lo, 1) : na, transp=50, editable=false, offset =2 ,
color=[Link](#089981, 60))
fill(u1, u2, color=[Link](#f23645, 65), title='Reversal Zones [R3, R2]')
fill(u2, u3, color=[Link](#f23645, 75), title='Reversal Zones [R2, R1]')
fill(l2, l3, color=[Link](#089981, 75), title='Reversal Zones [S2, S1]')
fill(l1, l2, color=[Link](#089981, 65), title='Reversal Zones [S3, S2]')

//
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------- Trend Catcher
--------------------------------------------------

filtcolor = upward > 0 ? [Link](0, 255, 85) : downward > 0 ? [Link](#ff0000,


0) : [Link](#56328f, 0)

plot(TrendTracer ? filt : na, color=filtcolor, linewidth=3, title='Trend Tracer')

//
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Frquency Cloud
--------------------------------------------------

plot_eq_closing_price = plot(frequencyCloud ? shorttop : na, transp=100,


editable=false)
plot_eq_external_value = plot(frequencyCloud ? longtop : na, transp=100,
editable=false)
// [Link](textWatermark, 0, 1, subtitle, width, height, c_subtitle, a_subtitle,
text_size=s_subtitle, bgcolor=c_bg)
eqCloudColor = [Link](close, 26) < [Link](close, 48) ? [Link](#9f0700, 80) :
shorttop < longtop ? [Link](#ff1100, 80) :
[Link](close, 26) > [Link](close, 48) ? [Link](#10253b, 80) :
shorttop > longtop ? [Link](#0d67c2, 80) : [Link](close, 34) >
[Link](close, 56) ? [Link](#549de6, 80) : na

fill(plot_eq_closing_price, plot_eq_external_value, color = eqCloudColor,


title='Frequency Cloud Fill')

//
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ---------------------------------------------- Order Blocks
------------------------------------------------
// Order Blocks

const color colup = #089981


const color coldn = #f23645

const string tm = "[Length] Use Length to adjust cordinate of the orderblocks\


n[Full] Use whole candle body"
const string tn = "Mitigation method for when to trigger order blocks"
const string tj = "Order block Metrics text size"
const string ta = 'Display internal buy & sell activity'
const string tsorder = 'Show Last number of orderblocks'
const string gv = "Volumetric Order Blocks"

obshow = [Link] (true , "Show Last"


, tsorder, '1', gv)
oblast = [Link] (3 , ""
, 0, 50, 1 , inline = '1', group = gv)
obupcs = [Link] ([Link](colup, 90), ""
, inline = '1', group = gv)
obdncs = [Link] ([Link](coldn, 90), ""
, inline = '1', group = gv)
obshowactivity = [Link] (true , "Show Buy/Sell
Activity ", ta, '2',
gv)
obactup = [Link] ([Link](colup, 50), ""
, inline = '2', group = gv)
obactdn = [Link] ([Link](coldn, 50), ""
, inline = '2', group = gv)
obmode = [Link]("Length" , "Construction "
, ["Length", "Full"], tm, '3', gv)
len = [Link] (5 , ""
, 1, 20, 1 , inline = '3', group = gv)
obmiti = [Link]("Close" , "Mitigation Method"
, ["Close", "Wick", "Avg"], tn, group = gv)
obtxt = [Link]("Normal" , "Metric Size"
, ["Tiny", "Small", "Normal", "Large", "Huge"], tj, group = gv)
showmetric = [Link] (true , "Show Metrics"
, group = gv)
showline = [Link] (true , "Show Mid-Line"
, group = gv)
overlap = [Link] (true , "Hide Overlap"
, group = gv,
tooltip = "Most recent order block will be preserved")
blcreated = [Link](false , "Bullish OB Formed "
, inline = "Formed" , group = "ANY
ALERT")
brcreated = [Link](false , "Bearish OB Formed"
, inline = "Formed" , group = "ANY
ALERT")
blmitigated = [Link](false , "Bullish OB Mitigated "
, inline = "Mitigated" , group = "ANY
ALERT")
brmitigated = [Link](false , "Bearish OB Mitigated"
, inline = "Mitigated" , group = "ANY
ALERT")
blinside = [Link](false , "Price Inside Bullish OB"
, inline = "Inside" , group = "ANY
ALERT")
brinside = [Link](false , "Price Inside Bearish OB"
, inline = "Inside" , group = "ANY
ALERT")

type bar
float o = open
float h = high
float l = low
float c = close
float v = volume
int i = bar_index
int t = time

type ob
float top
float btm
float avg
int loc
color css
float vol
int dir
int move
int blPOS
int brPOS
int xlocbl
int xlocbr

type alert
bool created = false
bool inside = false
bool mitigated = false

type cross
bool reset = false

bar b = bar .new()


alert blal = [Link]()
alert bral = [Link]()

var cross blIS = [Link]()


var cross brIS = [Link]()
method txSz(string s) =>
out = switch s
"Tiny" => [Link]
"Small" => [Link]
"Normal" => [Link]
"Large" => [Link]
"Huge" => [Link]
out

method display(ob id, ob[] full, int i) =>

[Link] (top = [Link], bottom = [Link], left = [Link], right = b.t ,


border_color = na, bgcolor = [Link], xloc = xloc.bar_time)
[Link] (top = [Link], bottom = [Link], left = b.t , right = b.t + 1 ,
border_color = na, bgcolor = [Link], xloc = xloc.bar_time, extend = [Link])

if obshowactivity

[Link](top = [Link], bottom = [Link], left = [Link], right = [Link],


border_color = na, bgcolor = obactup, xloc = xloc.bar_time)
[Link](top = [Link], bottom = [Link], left = [Link], right = [Link],
border_color = na, bgcolor = obactdn, xloc = xloc.bar_time)

if showline

[Link](
x1 = [Link]
, x2 = b.t
, y1 = [Link]
, y2 = [Link]
, color = [Link]([Link], 0)
, xloc = xloc.bar_time
, style = line.style_dashed
)

if showmetric

if i == [Link](oblast - 1, [Link]() - 1)

float tV = 0
float[] dV = [Link]<float>()

seq = [Link](oblast - 1, [Link]() - 1)

for j = 0 to seq

cV = [Link](j)

tV += [Link]

if j == seq

for y = 0 to seq

[Link](
[Link](
([Link](y).vol / tV) * 100)
)

id = [Link](y)

[Link](
b.i + 1
, [Link]
, textcolor = [Link]([Link], 0)
, style = label.style_label_left
, size = [Link]()
, color = #ffffff00
, text =
[Link](
[Link]([Link](y).vol, 3), format =
[Link]) + " (" + [Link]([Link](y)) + "%)"
)

method overlap(ob[] id) =>

if [Link]() > 1

for i = [Link]() - 1 to 1

stuff = [Link](i)
current = [Link](0)

switch

[Link] > [Link] and [Link] < [Link] => [Link](i)


[Link] < [Link] and [Link] > [Link] => [Link](i)
[Link] > [Link] and [Link] < [Link] => [Link](i)
[Link] < [Link] and [Link] > [Link] => [Link](i)

method umt(ob metric) =>

switch [Link]

1 =>

switch [Link]

1 => [Link] := [Link] + 1, [Link] := 2


2 => [Link] := [Link] + 1, [Link] := 3
3 => [Link] := [Link] + 1, [Link] := 1

-1 =>

switch [Link]

1 => [Link] := [Link] + 1, [Link] := 2


2 => [Link] := [Link] + 1, [Link] := 3
3 => [Link] := [Link] + 1, [Link] := 1

if (b.t - b.t[1]) == (b.t[1] - b.t[2])

[Link] := [Link] + (b.t - b.t[1]) * [Link]


[Link] := [Link] + (b.t - b.t[1]) * [Link]
fnOB() =>

var ob[] blob = [Link]<ob>()


var ob[] brob = [Link]<ob>()

var int dir = 0

up = [Link] ( len )
dn = [Link] ( len )
pv = [Link](b.v, len, len)

dir := b.h[len] > up ? -1 : b.l[len] < dn ? 1 : dir[1]

atr = [Link](len)

btmP = obmode == "Length" ? (b.h[len] - 1 * atr[len]) < b.l[len] ? b.l[len] :


(b.h[len] - 1 * atr[len]) : b.l[len]

topP = obmode == "Length" ? (b.l[len] + 1 * atr[len]) > b.h[len] ? b.h[len] :


(b.l[len] + 1 * atr[len]) : b.h[len]

if pv and dir == 1

[Link](
[Link](topP, b.l[len], [Link](topP, b.l[len]), b.t[len], obupcs,
b.v[len], b.c[len] > b.o[len] ? 1 : -1, 1, 0, 0, b.t[len]))

[Link] := true
[Link] := false

if pv and dir == -1

[Link](
[Link](
b.h[len]
, btmP
, [Link](btmP, b.h[len])
, b.t[len]
, obdncs
, b.v[len]
, b.c[len] > b.o[len] ? 1 : -1
, 1
, 0
, 0
, b.t[len]
)
)

[Link] := true
[Link] := false

if [Link]() > 0 and [Link]

for [i, ob] in blob

for j = 0 to len - 1
if obmiti == "Close" ? [Link](b.c[j], b.o[j]) < [Link] : obmiti
== "Wick" ? b.l < [Link] : obmiti == "Avg" ? b.l < [Link] : na

[Link](i)
[Link] := true
break

if [Link]() > 0 and [Link]

for[i, ob] in brob

for j = 0 to len - 1

if obmiti == "Close" ? [Link](b.c[j], b.o[j]) > [Link] : obmiti


== "Wick" ? b.h > [Link] : obmiti == "Avg" ? b.h > [Link] : na

[Link](i)
[Link] := true
break

if [Link]() > 0

for [i, metric] in blob

[Link]()

if [Link]() > 0

for [i, metric] in brob

[Link]()

if overlap

[Link]()
[Link]()

if [Link]

if [Link]() > 0

ob = [Link](0)

if low < [Link] and [Link] == false


[Link] := true
[Link] := true

if [Link]() > 0

ob = [Link](0)

if high > [Link] and [Link] == false


[Link] := true
[Link] := true

if [Link]

for bx in [Link]
[Link]()
for ln in [Link]
[Link]()

// for lb in [Link] //Razzere Fixed!


// [Link]() //Razzere Fixed!

if [Link]() > 0
for i = 0 to [Link](oblast - 1, [Link]() - 1)
[Link](i).display(blob, i)

if [Link]() > 0
for i = 0 to [Link](oblast - 1, [Link]() - 1)
[Link](i).display(brob, i)

if obshow
fnOB()

if blinside and [Link]


alert("Price Inside Bullish OB")

if blcreated and [Link]


alert("Bullish OB Formed")

if blmitigated and [Link]


alert("Bullish OB Mitigated")

if brinside and [Link]


alert("Price Inside Bearish OB")

if brcreated and [Link]


alert("Bearish OB Formed")

if brmitigated and [Link]


alert("Bearish OB Mitigated")

//
buyalert = [Link](false, "Buy Alert", group = 'ALERTS')
sellalert = [Link](false, "Sell Alert", group = 'ALERTS')
// Buy alert
if buyalert and buyCond or strongBuyCond1
alert('Buy',alert.freq_once_per_bar_close)
if sellalert and sellCond or strongSellCond1
alert('Sell',alert.freq_once_per_bar_close)

// ########## BUY/SELL 1 min timeframe ##########

h = [Link](5.,'Bandwidth', minval = 0)
srcBS = input(close,'Source')
repaint = input(true, 'Smooth Signals', tooltip = 'Repainting is an effect where
the indicators historical output is subject to change over time. Disabling
repainting will cause the indicator to output the endpoint of the estimator')

//Style
upCss = [Link]([Link](4, 255, 0), 'Colors', inline = 'inline1', group =
'Style')
dnCss = [Link]([Link](255, 146, 146), '', inline = 'inline1', group =
'Style')

//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Gaussian window
gauss(x, h) => [Link](-([Link](x, 2)/(h * h * 2)))

//-----------------------------------------------------------------------------}
//Append lines
//-----------------------------------------------------------------------------{
nBS = bar_index

var ln = array.new_line(0)

if [Link] and repaint


for i = 0 to 499
[Link](ln,[Link](na,na,na,na))

//-----------------------------------------------------------------------------}
//End point method
//-----------------------------------------------------------------------------{
var coefs = array.new_float(0)
var den = 0.

if [Link] and not repaint


for i = 0 to 499
w = gauss(i, h)
[Link](w)

den := [Link]()

out = 0.
if not repaint
for i = 0 to 499
out += srcBS[i] * [Link](i)
out /= den

//-----------------------------------------------------------------------------}
//Compute and display NWE
//-----------------------------------------------------------------------------{
float y2 = na
float y1 = na
float y1_d = na
line l = na
label lb = na

var bool buySignal = false


var bool sellSignal = false

if [Link] and repaint


//Compute and set NWE point
for i = 0 to [Link](499,nBS - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to [Link](499,nBS - 1)
w = gauss(i - j, h)
sum += srcBS[j] * w
sumw += w

y2 := sum / sumw
d = y2 - y1

//Set coordinate line


l := [Link](ln,i)
line.set_xy1(l,nBS-i+1,y1)
line.set_xy2(l,nBS-i,y2)
line.set_color(l,y2 > y1 ? dnCss : upCss)
line.set_width(l,2)

if d * y1_d < 0
if y1_d < 0
buySignal := true
[Link](nBS-i+1, srcBS[i], 'BUY'
, color = color(na)
, style = label.style_label_up
, textcolor = upCss
, textalign = text.align_center)
else
sellSignal := true
[Link](nBS-i+1, srcBS[i], 'SELL'
, color = color(na)
, style = label.style_label_down
, textcolor = dnCss
, textalign = text.align_center)

y1 := y2
y1_d := d

// Alert conditions
alertcondition(buySignal, title='Buy Alert', message='Buy signal detected.')
alertcondition(sellSignal, title='Sell Alert', message='Sell signal detected.')

// Reset signals for the next bar


if [Link]
buySignal := false
sellSignal := false

//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var tb = [Link](position.top_right, 1, 1
, bgcolor = [Link](30, 34, 45)
, border_color = [Link](55, 58, 70)
, border_width = 1
, frame_color = [Link](55, 58, 70)
, frame_width = 1)

if repaint
[Link](0, 0, 'Smooth Signals', text_color = [Link], text_size =
[Link])

//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------}
plot(repaint ? na : out, 'Colors', out > out[1] ? upCss : dnCss)

You might also like