Serum Indicator
Serum Indicator
0
at https://mozilla.org/MPL/2.0/
// © SerumTechnology
//@version=5
indicator('ꜱᴇʀᴜᴍ ᴛᴏᴏʟᴋɪᴛ [ꜱᴛ]', overlay=true, precision = 2, linktoseries = true,
max_bars_back = 5000, max_lines_count = 500, max_boxes_count = 500,
max_labels_count = 500)
import TradingView/ta/7
// VARIBLES GENRERALES
fuenteclose = close
fuenteopen = open
fuentehigh = high
fuentelow = low
fuentevolume = volume
//FUNCIONES GENRERALES
dntd = uppval
uptd = dnval
if cci >= 0
if uptd < uptd[1]
uptd := uptd[1]
else
if cci <= 0
if dntd > dntd[1]
dntd := dntd[1]
float td = 0.
td := cci >= 0 ? uptd : cci <= 0 ? dntd : td[1]
td
// Calcular el DTI
Val1 = 100*xuXA
Val2 = xuXAAbs
DTI_rawx = Val2 != 0 ? Val1 / Val2 : 0
DTI_raw = DTI_rawx * 0.96
//------------------------LONG / SHORT
ZONES----------------------------------------------------
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒
//
SHORT TERM SIGNALS
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒
//-------------------------------------
vstop----------------------------------------------------------------------------
//input variables
//int LengthV= 2 //input.int(title="Look Back Period", defval=3)
int ATRPeriodV= 6 //input.int(title="ATR Period", defval=7)
int MultV= input.int(18, title = 'Sensitivity', minval = 5, step = 1, inline =
'short-term inputs', group = '--- Buy / Sell')
bool showClassifier = input.bool(true, title = 'Classifier', inline = 'cl', group =
'--- Buy / Sell')
bool showtsShortTerm = input.bool(true, title = 'Trailing Stop', inline = 'ts',
group = '--- Buy / Sell')
color tsColorbull = input.color(color.new(#29fff8, 20), title = '', inline = 'ts',
group = '--- Buy / Sell')
color tsColorbear = input.color(color.new(#ff298d, 20), title = '', inline = 'ts',
group = '--- Buy / Sell')
bool showtpShortTerm = input.bool(true, title = 'Take Profit', inline = 'tp', group
= '--- Buy / Sell')
color showtpColor = input.color(#ffffff, title = '', inline = 'tp', group = '---
Buy / Sell')
tbullts = color.t(tsColorbull)
tbearts = color.t(tsColorbear)
//================================================================
int reversens = input.int(12, title = 'Sensitivity', minval = 5, step = 1, group =
'--- Reversal')
tdsignal = tdFunction(1)
if na(shortvs)
shortvs := short_stop
else
shortvs := close > shortvs ? short_stop : math.min(short_stop, shortvs[1])
if na(longvs)
longvs := long_stop
else
longvs := close < longvs ? long_stop : math.max(long_stop, longvs[1])
// Actualizar dirección
direction := na(direction[1]) ? 0 :
(direction[1] <= 0 and close >= shortvs[1] ? 1 :
(direction[1] >= 0 and close <= longvs[1] ? -1 : direction[1]))
var float pc = 0.
var color colorts = na
switch
direction > 0 =>
pc := longvs
colorts := tsColorbull
direction < 0 =>
pc := shortvs
colorts := tsColorbear
=>
pc := 0.
colorts := na
//----------------------------------------------volumen
extra-----------------------------------------------
//volsignal = volume
emaVol = nz(ta.ema(fuentevolume, 200), volume +100)
var volstate = 0
if volConfirm
volstate := 1
if noPlus
volstate := 2
//--------------------------------------------
Classifier--------------------------------
src = ohlc4
angle(_src) =>
rad2degree=180/3.14159265359
ang=rad2degree*math.atan((_src[0] - _src[1])/ta.atr(14))
ma = ta.ema(src, 30)
fil1 = angle(ma)
fil2 = tdFunction(3)
//fil2b = tdFunction(2)
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒
//
REVERSAL SIGNALS
//
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒▒▒▒
//--------------------------------------SHORT TERM-----------------------------
//general conditions
longer = direction > 0
shorter = direction < 0
if longer
shortstatus2 := 1
if shorter
shortstatus2 := 2
//---------------------take profit
//--------------------------------Reversal Signals
//------------------------COLOREADO DE BARRAS---------------------------------
barcolor(signalmode == 'Buy / Sell' and colormode == 'Normal' and showBar?
barcoloredShortTerm :
signalmode == 'Buy / Sell' and colormode == 'Gradient' and showBar?
barColor :
signalmode == 'Reversal' and colormode == 'Normal' and showBar?
coloreadoRevesal :
signalmode == 'Reversal' and colormode == 'Gradient' and showBar?
coloreobarrevers : not showBar? na : color.new(color.white, 50) , editable =
falsevar)
// TREND DIRECTION
tdtrenddash = tdFunction(2)
var float trackdash = 0.
trackdash := tdtrenddash > tdtrenddash[1] ? 1 : tdtrenddash < tdtrenddash[1] ? 2 :
trackdash[1]
var emastate = 0
if emaFast >= emaSlow
emastate := 1
if emaFast < emaSlow
emastate := 2
//-----------------------------------------------
VOLATILIDAD------------------------------------------------
getDynamicLength(maxLength) =>
math.min(maxLength, bar_index + 1)
//-------------------------------
DV(src, vis_atr, vis_std, sed_atr, sed_std) =>
int vis_atrx = math.min(vis_atr, bar_index+1),
int vis_stdx = math.min(vis_std, bar_index+1),
int sed_atrx = math.min(sed_atr, bar_index+1),
int sed_stdx = math.min(sed_std, bar_index+1),
vola = 0.0,
lag_s_K = 0.5,
s1 = nz(vola[1], 0),
s3 = nz(vola[3], 0),
vola := _Atr(vis_atrx) / _Atr(sed_atrx) + lag_s_K * (s1 - s3),
anti_thre = ta.stdev(src, vis_stdx) / ta.stdev(src, sed_stdx),
th = 1.4 - anti_thre,
th := th - vola,
-th * 100
// Fill the array with the last 'length' values, ignoring 'na' values
for i = 0 to length - 1
value = src[i]
if not na(value)
array.push(values, value)
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
truerange = _RMA(ta.tr, len)
plus = fixnan(100 * _RMA(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * _RMA(down > up and down > 0 ? down : 0, len) /
truerange)
[plus, minus]
Adx(int dilen, int adxlen) =>
up = math.max(ta.change(high), 0)
down = math.max(-ta.change(low), 0)
plusDM = up > down ? up : 0
minusDM = down > up ? down : 0
int dilen = 14
int adxlen = 14
int adxbase = 20
scale(x, a, b, c, d) =>
c + (d - c)*(x - a) / (b - a)
// trend strength
int dilens = 14
int adxlens = 6
int adxbases = 23
//---------------------------------------------------------------------------------
-------
TABLES-----------------------------------------------------------------------------
bool showT = input.bool(truevar, 'On / Off', group = '======>> Table <<======')
//tamaño----------------------------------------------------
string tamopc = input.string(defval = 'Small',
title = 'Size',
options = ['Tiny', 'Small', 'Normal', 'Large', 'huge'],
inline = 'tables',
group = '======>> Table <<======')
// posicion-----------------------------------------------------
string posopc = input.string(defval = 'Bottom-Right',
title = 'Position',
options= ['Bottom-Right', 'Bottom-Center', 'Bottom-Left', 'Top-Left', 'Top-
Center', 'Top-Right'],
group = '======>> Table <<======')
// inputs
showVola = input.bool(true, 'Volatility', group = '======>> Table <<======')
showStren = input.bool(true, 'Trend Strength', group = '======>> Table <<======')
showTrend = input.bool(true, 'Trend', group = '======>> Table <<======')
showMTF1 = input.bool(true, 'Timeframe 1', inline = 'm1', group = '======>> Table
<<======')
showMTF2 = input.bool(true, 'Timeframe 2', inline = 'm2', group = '======>> Table
<<======')
// -------------------------------------------------------------------Cálculo del
stop para MTF
convert_timer(tf) =>
pp = tf == '' ? timeframe.period : tf
horax = str.tonumber(pp)
hora = switch
na(horax) => pp
(horax % 60 == 0) => str.tostring(horax/60) + "H"
=> str.tostring(horax) + "m"
hora
var int statemtf = 0
if shortstatus2 == 1 and shortstatus2[1] == 2 and volConfirm
statemtf := 1
if shortstatus2 == 1 and shortstatus2[1] == 2 and noPlus
statemtf := 2
if shortstatus2 == 2 and shortstatus2[1] == 1 and volConfirm
statemtf := 3
if shortstatus2 == 2 and shortstatus2[1] == 1 and noPlus
statemtf := 4
// COLOREADO DE BACKGROUND-----------------------------------------------------
ticker = syminfo.ticker
var table myTable = table.new(tablePos, 5, 6, border_width = 1)
if showStren
table.cell(myTable, 0, 2, text= 'Trend strength' , bgcolor =
color.new(#FFFFFF, 87), text_halign = text.align_left, text_color = color.white,
text_size = textZise)
table.cell(myTable, 1, 2, text= str.tostring(sigx, "#.##") + "%", bgcolor =
strengthcolor, text_halign = text.align_left, text_color = color.white, text_size =
textZise)
if showVola
table.cell(myTable, 0, 3, text= 'Volatility' , bgcolor = color.new(#FFFFFF,
87), text_halign = text.align_left, text_color = color.white, text_size = textZise)
table.cell(myTable, 1, 3, text= volatilityText , bgcolor = backcolor,
text_halign = text.align_left, text_color = color.white, text_size = textZise)
if showMTF1
table.cell(myTable, 0, 4, text= convert_timer(mtf1) , bgcolor =
color.new(#FFFFFF, 87), text_halign = text.align_left, text_color = color.white,
text_size = textZise)
table.cell(myTable, 1, 4, text= signaltextmtf1 , bgcolor = vscolor4h,
text_color = vscolor4htxt, text_size = textZise)
if showMTF2
table.cell(myTable, 0, 5, text= convert_timer(mtf2) , bgcolor =
color.new(#FFFFFF, 87), text_halign = text.align_left, text_color = color.white,
text_size = textZise)
table.cell(myTable, 1, 5, text= signaltextmtf2 , bgcolor = vscolor1d,
text_color = vscolor1dtxt, text_size = textZise)
//---------------------------------------------------------------------------------
------Hyper
Cloud-------------------------------------------------------------------
//------------------------------------------------------------------------------
ATR = ta.atr(AP)
rsi = ta.rsi(close, 21)
rsifast = ta.rsi(close, 6)
//
ti = na(rsi) ? rsifast : rsi
umb = 50
hyper(mult) =>
upH = (math.avg(high, ohlc4)) - ATR * mult
dnH = (math.avg(low, ohlc4)) + ATR * mult
hyperLine = 0.
hyperLine := ti >= umb ? upH < nz(hyperLine[1]) ? nz(hyperLine[1]) : upH : dnH
> nz(hyperLine[1]) ? nz(hyperLine[1]) : dnH
hyperLine
hyperFast = hyper(fastval)
hyperSlow = hyper(slowval)
//------------------------------------------------
tcolorbull = color.t(greencolor)
tcolorbear = color.t(redcolor)
//---------------------------------------------------------------------------------
---------
// Outputs
//---------------------------------------------------------------------------------
---------
hyper1 = plot(hyperFast > 0.00 and showhyper ? hyperFast : na, "", color=na, offset
= offse-1, display = display.pane, editable = false)
hyper2 = plot(hyperSlow > 0.00 and showhyper ? hyperSlow : na ,"", color=na, offset
= offse-1, display = display.pane, editable = false)
MTMid = plot(hyperSlow > 0.00 and showhyper ? midtrend : na ,"",
color=midtrendColor, offset = offse-1, style = plot.style_line, display =
display.pane, editable = false)
if hyperstate != prev_trend
intensity := 0.0
prev_trend := hyperstate
//-------------------------------------------------------------FLEX
TRAILING--------------------------------------------------
tlongdy = color.t(longColor)
tshortdy = color.t(shortColor)
atrlength = 18
colorl = color.white
// Condiciones de cruce
cross_up = ta.crossover(close, top1)
cross_down = ta.crossunder(close, bot1)
//-------------------------------------
//---------------------------------------------band AQUEEZE
lenSQ = movingAverageLength //14 //input.int(20, title="Length", minval=1)
//fill trail
filltop1 = ta.wma(top1filler, 3)
fillbot1 = ta.wma(bot1filler, 3)
//
var float fillstate = 0
fixerfill= fixnan(fillstate[1])
fillstate := microstate ==1 ? 1 : microstate == 2 ? 2 : fixerfill
//-----------------------------------
SWITCH-----------------------------------------------------------------------------
// SQUEEZE PLOTS
var int sqstate = 0
if (rising and falling0) and lastcond and showmicrotrend and showSQ and microstate
== 1
sqstate := 1
if (rising and falling0) and lastcond and showmicrotrend and showSQ and microstate
== 2
sqstate := 2
sqcond = (rising and falling0) and lastcond and showmicrotrend and showSQ and
microstate == 1 ? bot1 :
(rising and falling0) and lastcond and showmicrotrend and showSQ and
microstate == 2 ? top1 : na
plot(sqcond,
style = plot.style_cross, linewidth = widthSQ,
color = microstate == 2 ? color.new(shortColor, tlongdy) : microstate == 1 ?
color.new(longColor, tshortdy) : na,
editable = falsevar,
display = display.pane)
//fills
fillcolorMicrotrend = microstate == 2 ? color.new(shortColor, 70) :
microstate == 1 ? color.new(longColor, 70) : na
if microstate != prev_trenddy
intensitydy := 0.0
prev_trenddy := microstate
//--------------------------------------------------------------MARKET
BIAS-------------------------------------
//----------------------------------------------------------------
ts
//-----calculos
//----plot bias
plotbias = plot(showchbias ? biasvc : na, color = biasvc< signalvc?
color.new(Colorbearvc, tcolorbearM + 20) : biasvc> signalvc? color.new(Colorbullvc,
tcolorbullM + 20): color.new(color.white, 50), editable = falsevar, display =
display.pane)
plotsignal =plot(showchbias ? signalvc : na, color = biasvc< signalvc?
color.new(Colorbearvc, tcolorbearM + 20): biasvc> signalvc? color.new(Colorbullvc,
tcolorbullM + 20) : color.new(color.white, 50), editable = falsevar, display =
display.pane)
// ----------------------------------------------------TREND DRIVER
showtd = input.bool(falsevar, title = 'On / Off', group="======>> Trend Driver
<<======")
periodTD = input.int(3, minval = 1, title = 'Period', group="======>> Trend Driver
<<======" )
bullcolorTD = input.color(#29fff8, inline = 'colortd', title = 'Bullish',
group="======>> Trend Driver <<======" )
bearcolorTD = input.color(#ff298d, inline = 'colortd', title = 'Bearish',
group="======>> Trend Driver <<======" )
thicknessTD = input.int(2, 'thickness', minval = 1, group="======>> Trend Driver
<<======" )
coloreoTD = input.string('Original', title = 'Coloring', options = ['Original',
'Refined'])
tdoriginal = tdFunction(periodTD)
//------------ refined
periodTDref = periodTD - 1
periodTDref := periodTDref == 0 ? 1 : periodTDref
tdrefinado = tdFunction(periodTDref)
//plot(tdR)
var int refinstate = 0
refinstate := tdrefinado> tdoriginal ? 1 : tdrefinado < tdoriginal? 2 :
nz(refinstate)
//---------------------------------------------------------------------------------
----------------
TOOLS------------------------------------------------------------------------------
--------------------
// -------------------------------------------
RIBBON-----------------------------------
st = dema(close, periodoshb)
st1 = dema(close, periodoshb + increhb)
st2 = dema(close, periodoshb + 2* increhb)
st3 = dema(close, periodoshb + 3* increhb)
st4 = dema(close, periodoshb + 4* increhb)
st5 = dema(close, periodoshb + 5* increhb)
//---------------------------------------------------------------------------------
--VOLATITLY BANDS---------------------------------------------------------------
//--------------BASIS
stema = math.avg(upper,lower)
sm = ta.ema(stema, 3)
tsr = 0.47
tsrp = tsr*100
bbs = (spread/maxspread)*100
if bbs>tsrp
sqstatevol := 1
if not(bbs>tsrp)
sqstatevol := 2
//---------------------------------------------------------------------------------
------------------------DONCHIAN
cHANNELS---------------------------------------------------------------------------
--------------
emabase = ta.ema(basis, 9)
//---------------------------------------------------------------------------------
---------SWITCH DE LINE
BASE-------------------------------------------------------------------------------
---------------------
//****************************fill
ribbon---------------------------------------------------------
fill(ta, t1, color = tools == 'Ribbon' and st > st1 ? color.new(Color2, 93) :
tools == 'Ribbon' and st < st1 ? color.new(Color1, 93) : na)
fill(t1, t2, color = tools == 'Ribbon' and st1 > st2 ? color.new(Color2, 78) :
tools == 'Ribbon' and s1 < st2 ? color.new(Color1, 78) : na)
fill(t2, t3, color = tools == 'Ribbon' and st2 > st3 ? color.new(Color2, 65) :
tools == 'Ribbon' and s2 < st3 ? color.new(Color1, 65) : na)
fill(t3, t4, color = tools == 'Ribbon' and st3 > st4 ? color.new(Color2, 52) :
tools == 'Ribbon' and s3 < st4 ? color.new(Color1, 52) : na)
fill(t4, t5, color = tools == 'Ribbon' and st4 > st5 ? color.new(Color2, 39) :
tools == 'Ribbon' and s4 < st5 ? color.new(Color1, 39) : na)
//////-----------------------------------------------
//-----------------------------------------------------------------------------{
//Boolean set
//-----------------------------------------------------------------------------{
s_BOS = 0
s_CHoCH = 1
i_BOS = 2
i_CHoCH = 3
i_pp_CHoCH = 4
green_candle = 5
red_candle = 6
s_CHoCHP = 7
i_CHoCHP = 8
boolean =
array.from(
false
, false
, false
, false
, false
, false
, false
, false
, false
)
//-----------------------------------------------------------------------------{
// User inputs
//-----------------------------------------------------------------------------{
ob_filter = 'None'
ob_mitigation = 'Absolute'
ob_pos = 'Precise'
use_grayscale = false
use_show_metric = true
use_middle_line = true
use_overlap = true
use_overlap_method = 'Previous'
t = color.t(ob_bull_css)
invcol = color.new(color.white, 100)
//{ - UDT
type bar
float o = open
float c = close
float h = high
float l = low
float v = volume
int n = bar_index
int t = time
type ms
float[] p
int [] n
float[] l
type msDraw
int n
float p
color css
string txt
bool bull
type obC
float[] top
float[] btm
int [] left
float[] avg
float[] dV
float[] cV
int [] wM
int [] blVP
int [] brVP
int [] dir
float[] h
float[] l
int [] n
type obD
box [] ob
box [] eOB
box [] blB
box [] brB
line[] mL
type alerts
bool chochswing = false
bool chochplusswing = false
bool swingbos = false
bool chochplus = false
bool choch = false
bool bos = false
bool ob = false
bool swingob = false
bool obtouch = false
// General Setup
bar b = bar.new()
switch
b.c > b.o => boolean.set(green_candle, true)
b.c < b.o => boolean.set(red_candle , true)
//Market Structure
var line id = na
var label lbl = na
id := line.new(
d.n
, d.p
, b.n
, d.p
, color = d.css
, width = 1
, style = style
)
line.delete(msline.shift())
msline.push(id)
lbl := label.new(
int(math.avg(d.n, b.n))
, d.p
, d.txt
, color = invcol
, textcolor = d.css
, style = d.bull ? label.style_label_down : label.style_label_up
, size = size
)
msDraw drw = na
n = bar_index
var ms up = ms.new(
array.new<float>()
, array.new< int >()
, array.new<float>()
)
var ms dn = ms.new(
array.new<float>()
, array.new< int >()
, array.new<float>()
)
switch show_swing_ms
switch show_internal_ms
switch
not na(iH) =>
up.p.unshift((b[iLen]).h)
up.l.unshift((b[iLen]).h)
up.n.unshift(n [iLen])
dn.p.unshift((b[iLen]).l)
dn.l.unshift((b[iLen]).l)
dn.n.unshift(n [iLen])
sdn.p.unshift((b[sLen]).l)
sdn.l.unshift((b[sLen]).l)
sdn.n.unshift(n [sLen])
sup.p.unshift((b[sLen]).h)
sup.l.unshift((b[sLen]).h)
sup.n.unshift(n [sLen])
if ta.crossover(b.c, up.p.first())
if itrend < 0
CHoCH := true
switch
blalert.bos := true
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS
, txt
, true
)
CHoCH =>
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS
, txt
, true
)
if mtf == false
switch
itrend := 1
up.n.clear()
up.p.clear()
if itrend > 0
CHoCH := true
switch
bralert.bos := true
txt := "BOS"
css := i_ms_dn_BOS
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS
, txt
, false
)
CHoCH =>
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS
, txt
, false
)
if mtf == false
switch
itrend := -1
dn.n.clear()
dn.p.clear()
if ta.crossover(b.c, sup.p.first())
if trend < 0
CHoCH := true
switch
blalert.swingbos := true
txt := "BOS"
icss := s_ms_up_BOS
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BOS
, txt
, true
)
CHoCH =>
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BOS
, txt
, true
)
if mtf == false
switch
trend := 1
sup.n.clear()
sup.p.clear()
if ta.crossunder(b.c, sdn.p.first())
if trend > 0
CHoCH := true
switch
bralert.swingbos := true
txt := "BOS"
icss := s_ms_dn_BOS
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS
, txt
, false
)
CHoCH =>
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS
, txt
, false
)
if mtf == false
switch
trend := -1
sdn.n.clear()
sdn.p.clear()
[css, bear_ob, bull_ob, itrend, drw, isdrw, s_bear_ob, s_bull_ob, trend, icss,
isdrwS]
[css, bear_ob, bull_ob, itrend, drw, isdrw, s_bear_ob, s_bull_ob, trend, icss,
isdrwS] = structure(false)
if isdrw
f_line(drw, size.small, line.style_dashed)
if isdrwS
f_line(drw, size.small, line.style_solid)
method drawVOB(bool cdn, bool bull, color css, int loc, bool swing) =>
, [
close
, open
, high
, low
, volume
, lookahead = barmerge.lookahead_off
)
var obC obj = obC.new(
array.new<float>()
, array.new<float>()
, array.new< int >()
, array.new<float>()
, array.new<float>()
, array.new<float>()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new<float>()
, array.new<float>()
, array.new< int >()
)
if barstate.isfirst
for i = 0 to ob_num - 1
if cdn
obj.h.clear()
obj.l.clear()
obj.n.clear()
obj.h.push(hH[i])
obj.l.push(lL[i])
obj.n.push(b.t[i])
int iU = obj.l.indexof(obj.l.min()) + 1
int iD = obj.h.indexof(obj.h.max()) + 1
obj.dir.unshift(
bull
? (b.c[iU] > b.o[iU] ? 1 : -1)
: (b.c[iD] > b.o[iD] ? 1 : -1)
)
obj.top.unshift(
bull
? pos[iU]
: obj.h.max()
)
obj.btm.unshift(
bull
? obj.l.min()
: pos[iD]
)
obj.left.unshift(
bull
? obj.n.get(obj.l.indexof(obj.l.min()))
: obj.n.get(obj.h.indexof(obj.h.max()))
)
obj.avg.unshift(
math.avg(obj.top.first(), obj.btm.first())
)
obj.cV.unshift(
bull
? b.v[iU]
: b.v[iD]
)
if ob_pos == "Precise"
switch bull
true =>
if obj.avg.get(0) < (b.c[iU] < b.o[iU] ? b.c[iU] : b.o[iU]) and
obj.top.get(0) > hlc3[iU]
obj.top.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
false =>
if obj.avg.get(0) > (b.c[iU] < b.o[iU] ? b.o[iD] : b.c[iD]) and
obj.btm.get(0) < hlc3[iD]
obj.btm.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
obj.blVP.unshift ( 0 )
obj.brVP.unshift ( 0 )
obj.wM .unshift ( 1 )
if use_overlap
if obj.avg.size() > 1
if bull
if barstate.isconfirmed
for x = 0 to ob_num - 1
tg = switch ob_mitigation
"Middle" => obj.avg
"Absolute" => bull ? obj.btm : obj.top
if barstate.islast
if obj.avg.size() > 0
// Alert
if bull
? ta.crossunder(low , obj.top.get(0))
: ta.crossover (high, obj.btm.get(0))
switch bull
true => blalert.obtouch := true
false => bralert.obtouch := true
float tV = 0
obj.dV.clear()
seq = math.min(ob_num - 1, obj.avg.size() - 1)
for j = 0 to seq
tV += obj.cV.get(j)
if j == seq
for y = 0 to seq
obj.dV.unshift(
math.floor(
(obj.cV.get(y) / (1.01*tV)) * 100)
)
obj.dV.reverse()
if use_middle_line
dmL.set_xy1(obj.left.get(i), obj.avg.get(i))
dmL.set_xy2(b.t , obj.avg.get(i))
if ob_metrics_show
rpBL = dblB.get_right()
rpBR = dbrB.get_right()
dbrB.set_right(rpBR + (b.t - b.t[1]) * obj.brVP.get(i))
dblB.set_right(rpBL + (b.t - b.t[1]) * obj.blVP.get(i))
if use_show_metric
txt = switch
deOB.set_text(
str.tostring(txt )) //+ " (" + str.tostring(obj.dV.get(i))
+ "%)"))
deOB.set_text_size (size.auto)
deOB.set_text_halign(text.align_left)
deOB.set_text_color (use_grayscale ? color.silver :
color.new(css, 0))
if obj.wM.size() > 0
for i = 0 to obj.avg.size() - 1
switch obj.dir.get(i)
1 =>
switch obj.wM.get(i)
switch obj.wM.get(i)
if iH
hN.pop()
hN.unshift(int(b.n[iLen]))
if iL
lN.pop()
lN.unshift(int(b.n[iLen]))
if ob_show
if bull_ob
blalert.ob := true
if bear_ob
bralert.ob := true
//-------------------------------------------------------------------------------
ALERTS------------------------------------------------------------------
//TAKE PROFIT
bool alertaLongTP = input.bool(falsevar, 'Long Take Profit', inline = 'alerta5',
group="======>> Buy / Sell signals Alerts ⏰ <<======")
bool alertaShortTP = input.bool(falsevar, 'Short Take Profit', inline = 'alerta5',
group="======>> Buy / Sell signals Alerts ⏰ <<======")
//---------------------------REVERSAL ALERTS
bool alertareversalLongBoth = input.bool(falsevar, 'Buy or Buy ✚', inline =
'alerta1', group="======>> reversal signals Alerts ⏰ <<======")
bool alertareversalShortBoth = input.bool(falsevar, 'Sell or Sell ✚', inline =
'alerta1', group="======>> reversal signals Alerts ⏰ <<======")
bool alertareversalLongplus = input.bool(falsevar, 'Buy ✚ (only)', inline =
'alerta2', group="======>> reversal signals Alerts ⏰ <<======")
bool alertareversalShortplus = input.bool(falsevar, 'Sell ✚ (only)', inline =
'alerta2', group="======>> reversal signals Alerts ⏰ <<======")
bool alertareversalLong = input.bool(falsevar, 'Buy (only)', inline = 'alerta3',
group="======>> reversal signals Alerts ⏰ <<======")
bool alertareversalShort = input.bool(falsevar, 'Sell (only)', inline = 'alerta3',
group="======>> reversal signals Alerts ⏰ <<======")
//---------------------------CLASSIFIER ALERTS
bool alertbull1 = input.bool(false, 'Buy 1', inline = 'alerta1', group="======>>
Classifier Alerts ⏰ <<======")
bool alertbear1 = input.bool(false, 'Sell 1', inline = 'alerta1', group="======>>
Classifier Alerts ⏰ <<======")
bool alertbull2 = input.bool(false, 'Buy 2', inline = 'alerta2', group="======>>
Classifier Alerts ⏰ <<======")
bool alertbear2 = input.bool(false, 'Sell 2', inline = 'alerta2', group="======>>
Classifier Alerts ⏰ <<======")
bool alertbull3 = input.bool(false, 'Buy 3', inline = 'alerta3', group="======>>
Classifier Alerts ⏰ <<======")
bool alertbear3 = input.bool(false, 'Sell 3', inline = 'alerta3', group="======>>
Classifier Alerts ⏰ <<======")
bool alertbull4 = input.bool(false, 'Buy 4', inline = 'alerta4', group="======>>
Classifier Alerts ⏰ <<======")
bool alertbear4 = input.bool(false, 'Sell 4', inline = 'alerta4', group="======>>
Classifier Alerts ⏰ <<======")
//--------------------------------TOOLS ALERTS
bool sqzVolalert = input.bool(falsevar, 'Bollinger Bands Squeeze', inline =
'alerta1', group="======>> Tools Alerts ⏰ <<======")
//-------------------------------ORDER BLOCK
bullOBalert = input.bool(false, 'Bullish Order Block', inline = '1', group =
"======>> Order Block Alerts ⏰ <<======")
bearOBalert = input.bool(false, 'Bearish Order Block', inline = '1', group =
"======>> Order Block Alerts ⏰ <<======")
//---------------------------------------------------------------------------------
-------------------------------------
//long short both signals // Buy / Sell
if shortstatus2 == 1 and shortstatus2[1] == 2 and volConfirm and
(alertashorttermLongPlus or alertashorttermLongBoth) and barstate.isconfirmed
alert('✚Buy ✚ 🔼', alert.freq_once_per_bar_close)
if shortstatus2 == 2 and shortstatus2[1] == 1 and volConfirm and
(alertashorttermShortPlus or alertashorttermShortBoth) and barstate.isconfirmed
alert('✚Sell ✚ 🔽', alert.freq_once_per_bar_close)
//long+ short signals // short term
if shortstatus2 == 1 and shortstatus2[1] == 2 and noPlus and (alertashorttermLong
or alertashorttermLongBoth) and barstate.isconfirmed
alert('🔼 Buy 🔼', alert.freq_once_per_bar_close)
if shortstatus2 == 2 and shortstatus2[1] == 1 and noPlus and (alertashorttermShort
or alertashorttermShortBoth) and barstate.isconfirmed
alert('🔽 Sell 🔽', alert.freq_once_per_bar_close)
//--------------------------------------\\
if microstate == 1 and microstate[1] == 2 and bullFlextrail and
barstate.isconfirmed
alert('Bullish Dynamic Trail', alert.freq_once_per_bar_close)
if microstate == 2 and microstate[1] == 1 and bearFlextrail and
barstate.isconfirmed
alert('Bearish Dynamic Trail', alert.freq_once_per_bar_close)
//--------------------DYNAMIC TRAIL SQUEEZE
if sqStateDy ==2 and sqStateDy[1] ==1 and sqzFlextrail and barstate.isconfirmed
alert('Squeeze detected on Dynamic Trail', alert.freq_once_per_bar_close)
//Hyper Cloud
if hyperstate == 1 and hyperstate[1] == 2 and bullhyperclalert and
barstate.isconfirmed
alert('Bullish Hyper Cloud', alert.freq_once_per_bar_close)
if hyperstate == 2 and hyperstate[1] == 1 and bearhyperclalert and
barstate.isconfirmed
alert('Bearish Hyper Cloud', alert.freq_once_per_bar_close)
//Market bias
if ta.crossover(biasvc, signalvc) and bullvcalert and barstate.isconfirmed
alert('Bullish Bias', alert.freq_once_per_bar_close)
if ta.crossunder(biasvc, signalvc) and bearvcalert and barstate.isconfirmed
alert('Bearish Bias', alert.freq_once_per_bar_close)
// trend Driver
if track == 1 and track[1] == 2 and bulltdalert and barstate.isconfirmed
alert('Original Bullish Trend Driver', alert.freq_once_per_bar_close)
if track == 2 and track[1] == 1 and beartdalert and barstate.isconfirmed
alert('Original Bearish Trend Driver', alert.freq_once_per_bar_close)
if refinstate == 1 and refinstate[1] == 2 and bulltdrefinedalert and
barstate.isconfirmed
alert('Refined Bullish Trend Driver', alert.freq_once_per_bar_close)
if refinstate == 2 and refinstate[1] == 1 and beartdrefinedalert and
barstate.isconfirmed
alert('Refined Bearish Trend Driver', alert.freq_once_per_bar_close)
//tools Alerts
if sqstatevol ==1 and sqstatevol[1] ==2 and sqzVolalert and barstate.isconfirmed
alert('Squeeze detected on Bollinger Bands', alert.freq_once_per_bar_close)
//ORDER BLOCK
if bullOBalert and blalert.ob and barstate.isconfirmed
alert('Bullish Order Block Detected', alert.freq_once_per_bar_close)
if bearOBalert and bralert.ob and barstate.isconfirmed
alert('Bearish Order Block Detected', alert.freq_once_per_bar_close)
bool risk = input.bool(true, "It is important to note that trading indicators and
any information related to trading strategies are provided for educational and
informational purposes only **DYOR**. They should not be considered as financial
advice or recommendations for specific trades or investments. The use of trading
indicators carries riks, and PAST PERFORMANCE IS NOT INDICATIVE OF FUTURE RESULTS.
Investors are solely responsible for their investment decisions and should
carefully assess their financial situation, investment objectives, and risk
tolerance before making any trades. Additionally, seeking independent financial
advice is strongly recommended if needed. The use of trading indicators and the
execution of trades are subject to the investor's own discretion and
responsibility. ▄ Sincerely, Serum Technology ▄",
confirm = true,
group = '██████ DISCLAIMER ██████')