0% found this document useful (0 votes)
653 views16 pages

Joker

The document is a script for a trading indicator named 'Joker | Remake Series' that calculates various volatility measures such as Close to Close, Parkinson, Garman Klass, and others. It includes user inputs for customizing settings, functions for calculating historical volatility, and options for signal presets and chart features. The script is designed to assist traders in analyzing market volatility and making informed trading decisions.

Uploaded by

notoriousop.exe
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)
653 views16 pages

Joker

The document is a script for a trading indicator named 'Joker | Remake Series' that calculates various volatility measures such as Close to Close, Parkinson, Garman Klass, and others. It includes user inputs for customizing settings, functions for calculating historical volatility, and options for signal presets and chart features. The script is designed to assist traders in analyzing market volatility and making informed trading decisions.

Uploaded by

notoriousop.exe
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
You are on page 1/ 16

//@version=5

indicator("Joker | Remake Series", shorttitle="Joker | Remake Series",


overlay=true, precision=0, explicit_plot_zorder=true, max_labels_count=500)

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ---------------------------------------------- User Inputs
-----------------------------------------------------

// Volatility Calculator Functions


symInfoCheck = false
symInfo = syminfo.ticker + ' | ' + timeframe.period + (timeframe.isminutes ? 'M' :
na)
date = str.tostring(dayofmonth(time_close)) + '/' + str.tostring(month(time_close))
+ '/' + str.tostring(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 = color.new(color.blue, 100)

// Close to Close Volatility


f_coc(x, period, sqrtAnnual) =>
mean = ta.sma(x, period)
s = array.new_float(0)
for i = 0 to period - 1 by 1
array.push(s, math.pow(x[i] - mean, 2))
sqrtAnnual * math.sqrt(array.sum(s) / (period - 1))

// Parkinson Volatility
f_park(period, sqrtAnnual) =>
var LOG2 = math.log(2)
powLogHighLow = math.pow(math.log(high / low), 2)
sqrtAnnual * math.sqrt(1.0 / period * math.sum(1.0 / (4.0 * LOG2) *
powLogHighLow, period))

// Garman Klass Volatility


f_gk(period, sqrtAnnual) =>
var LOG2 = math.log(2)
var SQRT_1_PERIOD = math.sqrt(1 / period)
powLogHighLow = math.pow(math.log(high / low), 2)
powLogCloseOpen = math.pow(math.log(close / open), 2)
tmp = 0.5 * powLogHighLow - (2.0 * LOG2 - 1.0) * powLogCloseOpen
sqrtAnnual * math.sqrt(math.sum(tmp, period)) * SQRT_1_PERIOD

// Rogers Satchell Volatility


f_rsv(period, sqrtAnnual) =>
tmp = math.log(high / close) * math.log(high / open) + math.log(low / close) *
math.log(low / open)
sqrtAnnual * math.sqrt(math.sum(tmp, period) / period)
// Garman Klass Yang Zhang Extension Volatility
f_gkyz(period, sqrtAnnual) =>
var LOG2 = math.log(2)
var SQRT_1_PERIOD = math.sqrt(1 / period)
powLogHighLow = math.pow(math.log(high / low), 2)
powLogCloseOpen = math.pow(math.log(close / open), 2)
lastClose = nz(close[1], close)
powLogOpenClose1 = math.pow(math.log(open / lastClose), 2)
tmp = powLogOpenClose1 + 0.5 * powLogHighLow - (2.0 * LOG2 - 1.0) *
powLogCloseOpen
sqrtAnnual * math.sqrt(math.sum(tmp, period)) * SQRT_1_PERIOD

// Yang Zhang Volatility


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

// Exponentially Weighted Volatility


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

// Mean Absolute Deviation (Adjusted)


f_mad(source, period, sqrtAnnual) =>
var SQRT_HALF_PI = math.sqrt(math.asin(1))
mean = ta.sma(source, period)
S = array.new_float(0)
for i = 0 to period - 1 by 1
array.push(S, math.abs(source[i] - mean))
sumS = array.sum(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 += math.abs(source[i] - median)
E
sqrtAnnual * math.sqrt(2) * (E / period)

// Rescale Function
f_rescale(_src, _size) =>
math.max(0, math.min(_size, int(_src / 100 * _size)))

// Label Panel Function


_label(T, color_PnL) =>
label PnL_Label = na
label.delete(PnL_Label[1])
PnL_Label := label.new(time, 0, text=T, color=color_PnL, textcolor=color.white,
size=size.normal, style=label.style_label_left, xloc=xloc.bar_time,
textalign=text.align_left)
label.set_x(PnL_Label, label.get_x(PnL_Label) + math.round(ta.change(time) *
3))

// Round Function
Round(src, digits) =>
p = math.pow(10, digits)
math.round(math.abs(src) * p) / p * math.sign(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

var sqrtAnnual = math.sqrt(Annual) * 100

logr = math.log(close / close[1])


// Historical Volatility 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
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

// Hv Stats
avgHV = ta.sma(Hv, malen)
HVP = ta.percentrank(Hv, Plen)
NearZero = HVP < 1.5 ? 1 : 0
HV50 = ta.percentile_nearest_rank(Hv, Plen, 50)

// Custom MAs
maa = avgHV / 100 * 140
mab = avgHV / 100 * 180
mac = avgHV / 100 * 240
mad = avgHV / 100 * 60
mae = avgHV / 100 * 20

// Auto Sensitivity Volatility Band Settings


float volatility = 0.0
if Hv < maa and Hv > avgHV
volatility := 6
else if Hv < mab and Hv > maa
volatility := 7
else if Hv < mac and Hv > mab
volatility := 7.8
else if Hv > mac
volatility := 9
else if Hv < maa and Hv > mad
volatility := 5
else if Hv < mad and Hv > mae
volatility := 4
else if Hv < mae
volatility := 3

// Basic Settings
signalPreset = input.string('None', 'Signal Preset', ['None', 'Trend Only'],
group='basic settings')
signalLogic = input.string('Pro Scalper', 'Signal Logic', ['Pro Scalper',
'Normal'], group='basic settings')
signalStyle = input.string('Normal', 'Signal Style', ['Normal', 'Minimal'],
group='basic settings')
signalAgility = input.string('Auto Pilot', 'Agility%', ['Auto Pilot', 'Manual'],
group='basic settings')
signalMode = signalStyle == 'Normal' ? 'Simple Entry + Exits' : 'Minimized Entry +
Exits'
normalsensitivity = input.float(15, "Normal Sensitivity", 5.1, 50.1, step=0.1,
group="basic settings", tooltip='Change Your Signal Sensitivity And Accuracy')
sensitivity = input.float(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

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

// Basic Chart Features


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 = input.string('Gradient Confirmation', 'Candle Stick Coloring',
['Gradient Confirmation', 'Off'], group='basic chart features')
Plot_MAs = input.bool(defval=true, title="Trend Cloud", group='basic chart
features')

// EK Cloud
gr_MA = "📈Moving Average 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 = request.security(syminfo.tickerid, Timeframe, MA_S1_Input[Repaint ? 0 :
barstate.isrealtime ? 1 : 0])[Repaint ? 0 : barstate.isrealtime ? 0 : 1]
MA_S2 = request.security(syminfo.tickerid, Timeframe, MA_S2_Input[Repaint ? 0 :
barstate.isrealtime ? 1 : 0])[Repaint ? 0 : barstate.isrealtime ? 0 : 1]
MA_1 = switch MA_T1
"Simple" => ta.sma(MA_S1, MA_L1)
"Exponential" => ta.ema(MA_S1, MA_L1)
"Double Exponential" => 2 * ta.ema(MA_S1, MA_L1) - ta.ema(ta.ema(MA_S1, MA_L1),
MA_L1)
"Triple Exponential" => 3 * (ta.ema(MA_S1, MA_L1) - ta.ema(ta.ema(MA_S1,
MA_L1), MA_L1)) + ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1)
"Quadruple Exponential" => 5 * ta.ema(MA_S1, MA_L1) - 10 * ta.ema(ta.ema(MA_S1,
MA_L1), MA_L1) + 10 * ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1) - 5 *
ta.ema(ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1), MA_L1) +
ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(MA_S1, MA_L1), MA_L1), MA_L1), MA_L1), MA_L1)
"Weighted" => ta.wma(MA_S1, MA_L1)
"Volume-weighted" => ta.vwma(MA_S1, MA_L1)
"Hull" => ta.hma(MA_S1, MA_L1)
"Symmetrical" => ta.swma(MA_S1)
"Arnaud Legoux" => ta.alma(MA_S1, MA_L1, 0.85, 6)
"Least Squares" => ta.linreg(MA_S1, MA_L1, 0)
"Relative Strength" => ta.rma(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" => ta.sma(ta.sma(MA_S1, MA_L1), MA_L1)
"Ehlers Kaufman" =>
KA_D1 = .0
for int i = 0 to 80 - 1 by 1
KA_D1 += math.abs(nz(MA_S1[i]) - nz(MA_S1[i + 1]))
KA_EF1 = KA_D1 != 0 ? math.min(math.abs(MA_S1 - nz(MA_S1[80 - 1])) / KA_D1,
1) : 0
KAMA1 = .0
KAMA1 := (math.pow((0.6667 * KA_EF1) + 0.0645, 2) * MA_S1) + ((1 -
math.pow((0.6667 * KA_EF1) + 0.0645, 2)) * nz(KAMA1[1]))

MA_2 = switch MA_T2


"Simple" => ta.sma(MA_S2, MA_L2)
"Exponential" => ta.ema(MA_S2, MA_L2)
"Double Exponential" => 2 * ta.ema(MA_S2, MA_L2) - ta.ema(ta.ema(MA_S2, MA_L2),
MA_L2)
"Triple Exponential" => 3 * (ta.ema(MA_S2, MA_L2) - ta.ema(ta.ema(MA_S2,
MA_L2), MA_L2)) + ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2)
"Quadruple Exponential" => 5 * ta.ema(MA_S2, MA_L2) - 10 * ta.ema(ta.ema(MA_S2,
MA_L2), MA_L2) + 10 * ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2) - 5 *
ta.ema(ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2), MA_L2) +
ta.ema(ta.ema(ta.ema(ta.ema(ta.ema(MA_S2, MA_L2), MA_L2), MA_L2), MA_L2), MA_L2)
"Weighted" => ta.wma(MA_S2, MA_L2)
"Volume-weighted" => ta.vwma(MA_S2, MA_L2)
"Hull" => ta.hma(MA_S2, MA_L2)
"Symmetrical" => ta.swma(MA_S2)
"Arnaud Legoux" => ta.alma(MA_S2, MA_L2, 0.85, 6)
"Least Squares" => ta.linreg(MA_S2, MA_L2, 0)
"Relative Strength" => ta.rma(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" => ta.sma(ta.sma(MA_S2, MA_L2), MA_L2)
"Ehlers Kaufman" =>
KA_D2 = .0
for int i = 0 to 135 - 1 by 1
KA_D2 += math.abs(nz(MA_S2[i]) - nz(MA_S2[i + 1]))
KA_EF2 = KA_D2 != 0 ? math.min(math.abs(MA_S2 - nz(MA_S2[135 - 1])) /
KA_D2, 1) : 0
KAMA2 = .0
KAMA2 := (math.pow((0.6667 * KA_EF2) + 0.0645, 2) * MA_S2) + ((1 -
math.pow((0.6667 * KA_EF2) + 0.0645, 2)) * nz(KAMA2[1]))

MA_Color = Plot_MAs ? MA_1 > MA_2 ? color.new(#04994b, 80) : color.new(#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)
fill(P1, P2, color=MA_Color)

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

src = close
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(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] = ta.kc(close, 90, 6.8)


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

shorttop = ta.sma(close, 13)


longtop = ta.ema(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
TM_Long = ta.cci(close, 20) > 50
TM_Short = ta.cci(close, 20) < -50

lenadx = 21
lensig = 21
limadx = 34

ADX_up = ta.change(high)
ADX_down = -ta.change(low)
trur = ta.rma(ta.tr, lenadx)
plus = fixnan(100 * ta.rma(ADX_up > ADX_down and ADX_up > 0 ? ADX_up : 0, lenadx) /
trur)
minus = fixnan(100 * ta.rma(ADX_down > ADX_up and ADX_down > 0 ? ADX_down : 0,
lenadx) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)

macol = adx > limadx and plus > minus ? color.lime : adx > limadx and plus <
minus ? color.red : color.black

ADX_Long = adx > limadx and plus > minus


ADX_Short = adx > limadx and plus < minus

ACC_Dist = ta.sma(ta.accdist, 21)


ACC_Long = ta.accdist > ACC_Dist
ACC_Short = ta.accdist < ACC_Dist

MFI = ta.mfi(close, 14)


MFI_SMA = ta.sma(MFI, 9)
MFI_Long = MFI > MFI_SMA
MFI_Short = MFI < MFI_SMA

mom = ta.mom(close, 21)


lrmom = ta.linreg(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
length = 20
incr = 100
resetOn = 'CHoCH'
showMS = false

bullCss = color.teal
bearCss = color.red
retCss = #ff5d00
areaTransp = 100

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

n = bar_index
ph = ta.pivothigh(length, length)
pl = ta.pivotlow(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

if close > ph_y and not ph_cross


if resetOn == 'CHoCH'
ms := os == -1 ? 1 : 0
else
ms := 1
ph_cross := true
if showMS
line.new(ph_x, ph_y, n, ph_y, color=bullCss, style=os == -1 ?
line.style_dashed : line.style_dotted)
os := 1
btmaman := low
for i = 0 to (n - ph_x) - 1
btmaman := math.min(low[i], btmaman)

if close < pl_y and not pl_cross


if resetOn == 'CHoCH'
ms := os == 1 ? -1 : 0
else
ms := -1
pl_cross := true
if showMS
line.new(pl_x, pl_y, n, pl_y, color=bearCss, style=os == 1 ?
line.style_dashed : line.style_dotted)
os := -1
topaman := high
for i = 0 to (n - pl_x) - 1
topaman := math.max(high[i], topaman)

if ms == 1
maxaman := close
else if ms == -1
minaman := close
else
maxaman := math.max(close, maxaman)
minaman := math.min(close, minaman)

ts := ms == 1 ? btmaman : ms == -1 ? topaman : os == 1 ? ts + (maxaman -


maxaman[1]) * incr / 100 : ts + (minaman - minaman[1]) * incr / 100

cssaman = ms ? na : os == 1 ? bullCss : bearCss

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

smartbuysigtex = "Strong\n" + str.tostring(Long_Signal_Strength) + "★"


smartbuyminimal = "▲+\n" + str.tostring(Long_Signal_Strength) + "★"
smartselsigtex = str.tostring(Short_Signal_Strength) + "★\n" + "Strong"
smartselminimal = str.tostring(Short_Signal_Strength) + "★\n" + "▼+"
buysigtex = "Buy\n" + str.tostring(Long_Signal_Strength) + "★"
buyminimal = "▲\n" + str.tostring(Long_Signal_Strength) + "★"
selsigtex = str.tostring(Short_Signal_Strength) + "★\n" + "Sell"
selsminimal = str.tostring(Short_Signal_Strength) + "★\n" + "▼"

if noRepainting
buyCond := buyCond and barstate.isconfirmed
strongBuyCond1 := strongBuyCond1 and barstate.isconfirmed
sellCond := sellCond and barstate.isconfirmed
strongSellCond1 := strongSellCond1 and barstate.isconfirmed

BuySignal = signalMode == 'Simple Entry + Exits' and buyCond and not


strongSignalOnly ? label.new(bar_index, low, buysigtex, xloc.bar_index,
yloc.belowbar, #00cf4b8c, label.style_label_up, color.white, size.normal) : na
MinimalBuy = signalMode == 'Minimized Entry + Exits' and buyCond and not
strongSignalOnly ? label.new(bar_index, low, buyminimal, xloc.bar_index,
yloc.belowbar, #00cf4b8c, label.style_label_up, color.white, size.normal) : na
StrongBuy = signalMode == 'Simple Entry + Exits' and strongBuyCond1 ?
label.new(bar_index, low, smartbuysigtex, xloc.bar_index, yloc.belowbar, #00cf4b8c,
label.style_label_up, color.white, size.normal) : na
MinimalStrongBuy = signalMode == 'Minimized Entry + Exits' and strongBuyCond1 ?
label.new(bar_index, low, smartbuyminimal, xloc.bar_index, yloc.belowbar,
#00cf4b8c, label.style_label_up, color.white, size.normal) : na
SellSignal = signalMode == 'Simple Entry + Exits' and sellCond and not
strongSignalOnly ? label.new(bar_index, high, selsigtex, xloc.bar_index,
yloc.abovebar, #ff00008c, label.style_label_down, color.white, size.normal) : na
MinimalSell = signalMode == 'Minimized Entry + Exits' and sellCond and not
strongSignalOnly ? label.new(bar_index, high, selsminimal, xloc.bar_index,
yloc.abovebar, #ff00008c, label.style_label_down, color.white, size.normal) : na
StrongSell = signalMode == 'Simple Entry + Exits' and strongSellCond1 ?
label.new(bar_index, high, smartselsigtex, xloc.bar_index, yloc.abovebar,
#ff00008c, label.style_label_down, color.white, size.normal) : na
MinimalStrongSell = signalMode == 'Minimized Entry + Exits' and strongSellCond1 ?
label.new(bar_index, high, smartselminimal, xloc.bar_index, yloc.abovebar,
#ff00008c, label.style_label_down, color.white, size.normal) : na

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Candle Color
----------------------------------------------------

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

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

u1 = plot(ReversalCloud ? ta.sma(u, 1) : na, transp=100, editable=false)


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

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------- Trend Catcher
--------------------------------------------------
filtcolor = upward > 0 ? color.rgb(0, 255, 85) : downward > 0 ? color.new(#ff0000,
0) : color.new(#56328f, 0)
plot(TrendTracer ? filt : na, color=filtcolor, linewidth=3, title='Trend Tracer')

//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ------------------------------------------------ Frequency 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)
eqCloudColor = ta.sma(close, 26) < ta.sma(close, 48) ? color.new(#9f0700, 80) :
shorttop < longtop ? color.new(#ff1100, 80) : ta.sma(close, 26) > ta.sma(close, 48)
? color.new(#10253b, 80) : shorttop > longtop ? color.new(#0d67c2, 80) :
ta.sma(close, 34) > ta.sma(close, 56) ? color.new(#549de6, 80) : na
fill(plot_eq_closing_price, plot_eq_external_value, color=eqCloudColor,
title='Frequency Cloud Fill')

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

const color colup = #089981


const color coldn = #f23645

obshow = input.bool(true, "Show Last", group="Order Blocks")


oblast = input.int(3, "", 0, 50, 1, inline='1', group="Order Blocks")
obupcs = input.color(color.new(colup, 90), "", inline='1', group="Order Blocks")
obdncs = input.color(color.new(coldn, 90), "", inline='1', group="Order Blocks")
obshowactivity = input.bool(true, "Show Buy/Sell Activity", inline='2',
group="Order Blocks")
obactup = input.color(color.new(colup, 50), "", inline='2', group="Order Blocks")
obactdn = input.color(color.new(coldn, 50), "", inline='2', group="Order Blocks")
obmode = input.string("Length", "Construction", ["Length", "Full"], group="Order
Blocks")
len = input.int(5, "", 1, 20, 1, inline='3', group="Order Blocks")
obmiti = input.string("Close", "Mitigation Method", ["Close", "Wick", "Avg"],
group="Order Blocks")
obtxt = input.string("Normal", "Metric Size", ["Tiny", "Small", "Normal", "Large",
"Huge"], group="Order Blocks")
showmetric = input.bool(true, "Show Metrics", group="Order Blocks")
showline = input.bool(true, "Show Mid-Line", group="Order Blocks")
overlap = input.bool(true, "Hide Overlap", group="Order Blocks", tooltip="Most
recent order block will be preserved")

blcreated = input.bool(false, "Bullish OB Formed", inline="Formed", group="ANY


ALERT")
brcreated = input.bool(false, "Bearish OB Formed", inline="Formed", group="ANY
ALERT")
blmitigated = input.bool(false, "Bullish OB Mitigated", inline="Mitigated",
group="ANY ALERT")
brmitigated = input.bool(false, "Bearish OB Mitigated", inline="Mitigated",
group="ANY ALERT")
blinside = input.bool(false, "Price Inside Bullish OB", inline="Inside", group="ANY
ALERT")
brinside = input.bool(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 = alert.new()
alert bral = alert.new()
var cross blIS = cross.new()
var cross brIS = cross.new()

method txSz(string s) =>


out = switch s
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
out

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


// Créer ou mettre à jour les boîtes et lignes
box.new(top=id.top, bottom=id.btm, left=id.loc, right=b.t, border_color=na,
bgcolor=id.css, xloc=xloc.bar_time)
box.new(top=id.top, bottom=id.btm, left=b.t, right=b.t + 1, border_color=na,
bgcolor=id.css, xloc=xloc.bar_time, extend=extend.right)
if obshowactivity
box.new(top=id.top, bottom=id.avg, left=id.loc, right=id.xlocbl,
border_color=na, bgcolor=obactup, xloc=xloc.bar_time)
box.new(top=id.avg, bottom=id.btm, left=id.loc, right=id.xlocbr,
border_color=na, bgcolor=obactdn, xloc=xloc.bar_time)
if showline
line.new(x1=id.loc, x2=b.t, y1=id.avg, y2=id.avg, color=color.new(id.css,
0), xloc=xloc.bar_time, style=line.style_dashed)
if showmetric and i == math.min(oblast - 1, full.size() - 1)
// Supprimer les anciennes étiquettes avant d'en créer de nouvelles
if barstate.isconfirmed
for lbl in label.all
label.delete(lbl)
float tV = 0
float[] dV = array.new<float>()
seq = math.min(oblast - 1, full.size() - 1)
for j = 0 to seq
cV = full.get(j)
tV += cV.vol
if j == seq
for y = 0 to seq
dV.push(math.floor((full.get(y).vol / tV) * 100))
id = full.get(y)
float y_offset = (id.top - id.btm) * 0.1 * (y - seq / 2) //
Décalage vertical
label.new(b.i + 1, id.avg + y_offset,
textcolor=color.new(id.css, 0), style=label.style_label_left, size=obtxt.txSz(),
color=#ffffff00, text=str.tostring(math.round(full.get(y).vol, 3),
format=format.volume) + " (" + str.tostring(dV.get(y)) + "%)")

method overlap(ob[] id) =>


if id.size() > 1
for i = id.size() - 1 to 1
stuff = id.get(i)
current = id.get(0)
switch
stuff.btm > current.btm and stuff.btm < current.top => id.remove(i)
stuff.top < current.top and stuff.btm > current.btm => id.remove(i)
stuff.top > current.top and stuff.btm < current.btm => id.remove(i)
stuff.top < current.top and stuff.top > current.btm => id.remove(i)

method umt(ob metric) =>


switch metric.dir
1 =>
switch metric.move
1 => metric.blPOS := metric.blPOS + 1, metric.move := 2
2 => metric.blPOS := metric.blPOS + 1, metric.move := 3
3 => metric.brPOS := metric.brPOS + 1, metric.move := 1
-1 =>
switch metric.move
1 => metric.brPOS := metric.brPOS + 1, metric.move := 2
2 => metric.brPOS := metric.brPOS + 1, metric.move := 3
3 => metric.blPOS := metric.blPOS + 1, metric.move := 1
if (b.t - b.t[1]) == (b.t[1] - b.t[2])
metric.xlocbl := metric.loc + (b.t - b.t[1]) * metric.blPOS
metric.xlocbr := metric.loc + (b.t - b.t[1]) * metric.brPOS

fnOB() =>
var ob[] blob = array.new<ob>()
var ob[] brob = array.new<ob>()
var int dir = 0
up = ta.highest(len)
dn = ta.lowest(len)
pv = ta.pivothigh(b.v, len, len)
dir := b.h[len] > up ? -1 : b.l[len] < dn ? 1 : dir[1]
atr = ta.atr(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
blob.unshift(ob.new(topP, b.l[len], math.avg(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]))
blal.created := true
blIS.reset := false
if pv and dir == -1
brob.unshift(ob.new(b.h[len], btmP, math.avg(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]))
bral.created := true
brIS.reset := false
if blob.size() > 0 and barstate.isconfirmed
for [i, ob] in blob
for j = 0 to len - 1
if obmiti == "Close" ? math.min(b.c[j], b.o[j]) < ob.btm : obmiti
== "Wick" ? b.l < ob.btm : obmiti == "Avg" ? b.l < ob.avg : na
blob.remove(i)
blal.mitigated := true
break
if brob.size() > 0 and barstate.isconfirmed
for [i, ob] in brob
for j = 0 to len - 1
if obmiti == "Close" ? math.max(b.c[j], b.o[j]) > ob.top : obmiti
== "Wick" ? b.h > ob.top : obmiti == "Avg" ? b.h > ob.avg : na
brob.remove(i)
bral.mitigated := true
break
if blob.size() > 0
for [i, metric] in blob
metric.umt()
if brob.size() > 0
for [i, metric] in brob
metric.umt()
if overlap
blob.overlap()
brob.overlap()
if barstate.isconfirmed
if blob.size() > 0
ob = blob.get(0)
if low < ob.top and blIS.reset == false
blal.inside := true
blIS.reset := true
if brob.size() > 0
ob = brob.get(0)
if high > ob.btm and brIS.reset == false
bral.inside := true
brIS.reset := true
if barstate.islast
for bx in box.all
bx.delete()
for ln in line.all
ln.delete()
for lbl in label.all // Réactivé pour supprimer toutes les étiquettes
anciennes
label.delete(lbl)
if blob.size() > 0
for i = 0 to math.min(oblast - 1, blob.size() - 1)
blob.get(i).display(blob, i)
if brob.size() > 0
for i = 0 to math.min(oblast - 1, brob.size() - 1)
brob.get(i).display(brob, i)

if obshow
fnOB()

if blinside and blal.inside


alert("Price Inside Bullish OB")
if blcreated and blal.created
alert("Bullish OB Formed")
if blmitigated and blal.mitigated
alert("Bullish OB Mitigated")
if brinside and bral.inside
alert("Price Inside Bearish OB")
if brcreated and bral.created
alert("Bearish OB Formed")
if brmitigated and bral.mitigated
alert("Bearish OB Mitigated")

buyalert = input.bool(false, "Buy Alert", group='ALERTS')


sellalert = input.bool(false, "Sell Alert", group='ALERTS')

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)

You might also like