Signals & Overlays
Signals & Overlays
0
at https://mozilla.org/MPL/2.0/
// © deven0
//@version=5
indicator("Signals & Overlays™", overlay = true, max_labels_count = 500)
//Import libraries
import achirameegasthanne/LuxFunction/18 as LAF
import deven0/KernelFunction/1 as kernels
showDashboard = true
showTrailingStoploss = false
showMovingAverage = false
showSessions = false
// Advanced Settings
groupAdvanced = "TAKE PROFITS/STOP LOSSES"
takeProfitBoxes = input.string("None", "TP/SL Points", options=["None","On"],
inline = "2", tooltip = "Shows Take Profit and Stop Loss areas",group =
groupAdvanced,display = display.none)
takeProfitStopLossDistance = input.int(5,"Distance", minval = 1, maxval = 10,
group=groupAdvanced,display = display.none)
TP1 = input.color(color.new(#3666f5, 0),"TP1",group=groupAdvanced,inline =
"3",display = display.none)
TP2 = input.color(color.new(#3666f5, 0),"TP2",group=groupAdvanced,inline =
"3",display = display.none)
SL1 = input.color(color.new(color.red, 0),"SL1",group=groupAdvanced,inline =
"3",display = display.none)
SL2 = input.color(color.new(color.red, 0),"SL2",group=groupAdvanced,inline =
"3",display = display.none)
dashboard = "DASHBOARD"
dashboardLocation = input.string("Bottom Right","Dashboard Location", ["Top
Right","Bottom Right","Bottom Left"], inline = "3",tooltip = "Changes dashboard
positions" ,group = dashboard,display = display.none)
dashboardSize = input.string("Small","Dashboard Size",
["Tiny","Small","Normal","Large"], inline = "4",tooltip = "Changes the size of the
dashboard" ,group = dashboard,display = display.none)
dashboardbg = input.color(#1e222d,"Dashboard Color",tooltip = "Changes the size of
the dashboard" ,group = dashboard,display = display.none)
trendstrength = input.bool(true,"Trend Strength", inline = "5",tooltip = "Changes
the size of the dashboard" ,group = dashboard,display = display.none)
volatility = input.bool(false,"Volatility", inline = "5",tooltip = "Changes the
size of the dashboard" ,group = dashboard,display = display.none)
squeeze = input.bool(false,"Squeeze", inline = "6",tooltip = "Changes the size of
the dashboard" ,group = dashboard,display = display.none)
volumesentiment = input.bool(false,"Volume Sentiment", inline = "6",tooltip =
"Changes the size of the dashboard" ,group = dashboard,display = display.none)
n = bar_index
// # ============================[SESSIONS]============================ #
show_sesa = true
sesa_txt = 'New York'
sesa_ses = '1300-2200'
sesa_css = #ff5d00
sesa_range = true
sesa_tl = false
sesa_avg = false
sesa_vwap = false
sesa_maxmin = false
//Session B
show_sesb = true
sesb_txt = 'London'
sesb_ses = '0700-1600'
sesb_css = #2157f3
sesb_range = true
sesb_tl = false
sesb_avg = false
sesb_vwap = false
sesb_maxmin = false
//Timezones
tz_incr = 0
use_exchange = false
//Ranges Options
bg_transp = 90
show_outline = true
show_txt = true
//Dashboard
show_ses_div = false
show_day_div = false
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
sma
var float y1 = na
var float y2 = na
var float stdev = na
var float r2 = na
y1 := 4 * sma - 3 * wma
y2 := 3 * wma - 2 * sma
[num, den]
//Set line
set_line(session, y1, y2, session_css)=>
var line tl = na
box.set_top(bx, max)
box.set_rightbottom(bx, n, min)
if show_txt
label.set_xy(lbl, int(math.avg(t, time)), max)
//-----------------------------------------------------------------------------}
//Sessions
//-----------------------------------------------------------------------------{
tf = timeframe.period
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
//Ranges
if show_sesa and sesa_range
[max, min] = get_range(is_sesa, sesa_txt, sesa_css)
max_sesa := max
min_sesa := min
//Trendlines
//Mean
if show_sesa and sesa_avg
avg = get_avg(is_sesa)
set_line(is_sesa, avg, avg, sesa_css)
//VWAP
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
//Plot max/min
plot(showSessions and sesa_maxmin ? max_sesa : na, 'Session A Maximum', sesa_css,
1, plot.style_linebr, editable = false)
plot(showSessions and sesa_maxmin ? min_sesa : na, 'Session A Minimum', sesa_css,
1, plot.style_linebr, editable = false)
//Plot Divider A
plotshape(is_sesa and show_ses_div and show_sesa and showSessions, "·"
, shape.square
, location.bottom
, na
, text = "."
, textcolor = sesa_css
, size = size.tiny
, display = display.all - display.status_line
, editable = false)
//Plot Divider B
plotshape(is_sesb and show_ses_div and show_sesb and showSessions, "·"
, shape.labelup
, location.bottom
, na
, text = "."
, textcolor = sesb_css
, size = size.tiny
, display = display.all - display.status_line
, editable = false)
// # ============================[FUNCTIONS]============================ #
type bar
float o = open
float h = high
float l = low
float c = close
float v = volume
int i = bar_index
bar b = bar.new()
nzV = nz(b.v)
f_calcV() =>
uV = 0.0
dV = 0.0
switch
(b.c - b.l) > (b.h - b.c) => uV := nzV
(b.c - b.l) < (b.h - b.c) => dV := -nzV
b.c > b.o => uV := nzV
b.c < b.o => dV := -nzV
b.c > nz(b.c[1]) => uV := nzV
b.c < nz(b.c[1]) => dV := -nzV
nz(uV[1]) > 0 => uV := uV + nzV
nz(dV[1]) < 0 => dV := dV - nzV
[uV, dV]
// # ============================[CONSTANT VARIABLES]============================ #
sma4 = ta.sma(close, 4)
sma5 = ta.sma(close, 5)
sma9 = ta.sma(close, 9)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
bullishSignalColor = #59e08a
bearishSignalColor = #ff5959
dashboardRedText = #ee787d
dashboardGreenText = #42bda8
dashboardGreenBackground = #284444
dashboardRedBackground = #49343e
// # ============================[CANDLE COLORING]============================ #
macdFastLength = 12
macdSlowLength = 26
macdSignalLength = 9
// Yellow
yellowLow = #56328f
// 4 level of red
redHigh = #ff0000
redMidHigh = #ff0000
redMidLow = #ff0000
redLow = #56328f
// Yellow
yellowLow := #513a88
// 4 level of red
redHigh := #ff0000
redMidHigh := #c21637
redMidLow := #c33252
redLow := #8e215f
if (candleColorType == 'Contrarian Gradient')
redHigh := #30a464
redMidHigh := #269444
redMidLow :=#4f966c
redLow := #425970
// Yellow
yellowLow := #513a88
// 4 level of red
greenHigh := #ff0000
greenMidHigh := #c21637
greenMidLow := #c33252
greenLow := #8e215f
// Default color
candleBody = yellowLow
if histX > 0
if histX > histX[1] and histX[1] > 0
candleBody := greenLow
if histX < 0
if histX < histX[1] and histX[1] < 0
candleBody := redLow
// Bullish trend
if MacdX > 0 and histX > 0
candleBody := greenMidLow
// Bearish trend
if MacdX < 0 and histX < 0
candleBody := redMidLow
// # ============================[SMART TRAIL]============================ #
[supert,supert2,smartTrailDirection] = LAF.getSmartTrail(smartTrailValue)
smb = #347cf8
smre = #f7525f
t = plot(smartTrail ?supert:na, color = close > supert ? smb:smre)
tt = plot(smartTrail ?supert2:na, color = color.new(color.black, 100))
fill(t, tt, close > supert?color.new(smb, 80) : color.new(smre, 80))
// # ============================[TREND CATCHER]============================ #
[trendCatcherLine, trendCatcherColor] = LAF.getTrendCatcher(trendCatcherValue)
newTrendCatcherColor = trendCatcherColor == color.blue ? #02ff65 : #ff1100
plot(trendCatcher ? trendCatcherLine : na, title='Trend Catcher', linewidth=2,
color=newTrendCatcherColor, editable = false)
// # ============================[TREND TRACER]============================ #
[trendTracerLine, trendTracerDirection] = LAF.getTrendTracer(trendTracerValue)
plot(trendTracer ? trendTracerLine : na, title='Trend Tracer', linewidth=2,
style=plot.style_cross, color = trendTracerDirection, editable = false)
// # ============================[DASHBOARD
COMPONENTS|]============================ #
volatilityMetric = LAF.getVolatilityMetric()
volatilityMetric2 = ta.sma(LAF.getVolatilityMetric(), 8)
volatilityText = volatilityMetric < 30 ? 'Stable' : volatilityMetric < 80 ?
'Moderate' : 'Volatile'
volatilityEmoji = volatilityMetric2 > volatilityMetric ? '📉' : '📈'
volatilityCellColor = newTrendCatcherColor == #02ff65 ? dashboardGreenBackground :
dashboardRedBackground
VolatilityTextColor = trendStrengthCellColor == dashboardGreenBackground ?
dashboardGreenText : dashboardRedText
totalVolume = uV + math.abs(dV)
volumeCellColor = dashboardRedBackground
volumeTextColor = totalVolume >= 50 ? dashboardGreenText : dashboardRedText
if (totalVolume >= 50)
totalVolume := totalVolume*2
volumeCellColor := dashboardGreenBackground
else
totalVolume := totalVolume*-2
volumeSentiment = totalVolume
// Optimal Sensitivity
color blockColor = na
color textColor = na
tb = table.new(table_position, 7, 7
, bgcolor = dashboardbg
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if showDashboard
if barstate.islast
tb.cell(0, 2, autopilotMode == 'Off' ? "✈️
Optimal Sensivity" : " Autopilot
Enabled", text_color = color.white, text_size = table_size, text_halign =
text.align_left)
if(trendstrength)
tb.cell(0, 3, str.tostring(trendIndication) + "Trend Strength",
text_color = color.white, text_size = table_size, text_halign = text.align_left)
if(volatility)
tb.cell(0, 4, volatilityEmoji+ " Volatility", text_color = color.white,
text_size = table_size, text_halign = text.align_left)
if(squeeze)
tb.cell(0, 5, "🔃 Squeeze", text_color = color.white, text_size =
table_size, text_halign = text.align_left)
if(volumesentiment)
tb.cell(0, 6, "💧 Volume Sentiment", text_color = color.white, text_size
= table_size, text_halign = text.align_left)
//
***********************************************************************************
*************************
// REV ZONES
//
***********************************************************************************
*************************
indiSet = false
source = hlc3
type = 'SuperSmoother'
length = 100
innermult = 1.0
outermult = 2.415
ChartSet = false
drawchannel = true
displayzone = true
zonetransp = 60
displayline = true
MTFSet = false
enable_mtf = true
mtf_disp_typ = 'On Hover'
mtf_typ = 'Auto'
mtf_lvl1 = 'D'
mtf_lvl2 = 'W'
//
***********************************************************************************
*************************
// Functions Start {
//
***********************************************************************************
*************************
var pi = 2 * math.asin(1)
var mult = pi * innermult * reversalZoneValue
var mult2 = pi * outermult * reversalZoneValue
var gradsize = 0.5
var gradtransp = zonetransp
//-----------------------
// Ehler SwissArmyKnife Function
//-----------------------
SAK_smoothing(_type, _src, _length) =>
c0 = 1.0
c1 = 0.0
b0 = 1.0
b1 = 0.0
b2 = 0.0
a1 = 0.0
a2 = 0.0
alpha = 0.0
beta = 0.0
gamma = 0.0
cycle = 2 * pi / _length
_Input = _src
_Output = 0.0
_Output := c0 * (b0 * _Input + b1 * nz(_Input[1]) + b2 * nz(_Input[2])) + a1 *
nz(_Output[1]) + a2 * nz(_Output[2]) - c1 * nz(_Input[_length])
_Output
//-----------------------
// SuperSmoother Function
//-----------------------
supersmoother(_src, _length) =>
s_a1 = math.exp(-math.sqrt(2) * pi / _length)
s_b1 = 2 * s_a1 * math.cos(math.sqrt(2) * pi / _length)
s_c3 = -math.pow(s_a1, 2)
s_c2 = s_b1
s_c1 = 1 - s_c2 - s_c3
ss = 0.0
ss := s_c1 * _src + s_c2 * nz(ss[1], _src[1]) + s_c3 * nz(ss[2], _src[2])
ss
//-----------------------
// Auto TimeFrame Function
//-----------------------
// ————— Converts current chart resolution into a float minutes value.
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60.
* 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
_resInMinutes
get_tf(_lvl) =>
y = f_resInMinutes()
z = timeframe.period
if mtf_typ == 'Auto'
if y < 1
z := _lvl == 1 ? '1' : _lvl == 2 ? '5' : z
z
else if y <= 3
z := _lvl == 1 ? '5' : _lvl == 2 ? '15' : z
z
else if y <= 10
z := _lvl == 1 ? '15' : _lvl == 2 ? '60' : z
z
else if y <= 30
z := _lvl == 1 ? '60' : _lvl == 2 ? '240' : z
z
else if y <= 120
z := _lvl == 1 ? '240' : _lvl == 2 ? 'D' : z
z
else if y <= 240
z := _lvl == 1 ? 'D' : _lvl == 2 ? 'W' : z
z
else if y <= 1440
z := _lvl == 1 ? 'W' : _lvl == 2 ? 'M' : z
z
else if y <= 10080
z := _lvl == 1 ? 'M' : z
z
else
z := z
z
else
z := _lvl == 1 ? mtf_lvl1 : _lvl == 2 ? mtf_lvl2 : z
z
//-----------------------
// Mean Reversion Channel Function
//-----------------------
get_mrc() =>
v_condition = 0
v_meanline = source
v_meanrange = supersmoother(ta.tr, length)
if type != 'SuperSmoother'
v_meanline := SAK_smoothing(type, source, length)
v_meanline
//-----------------------
// MTF Analysis
//-----------------------
get_stat(_cond) =>
ret = 'Price at Mean Line\n'
if _cond == 1
ret := 'Overbought (Weak)\n'
ret
else if _cond == 2
ret := 'Overbought\n'
ret
else if _cond == 3
ret := 'Overbought (Strong)\n'
ret
else if _cond == 4
ret := 'Price Near Mean\n'
ret
else if _cond == 5
ret := 'Price Above Mean\n'
ret
else if _cond == -1
ret := 'Oversold (Weak)\n'
ret
else if _cond == -2
ret := 'Oversold\n'
ret
else if _cond == -3
ret := 'Oversold (Strong)\n'
ret
else if _cond == -4
ret := 'Price Near Mean\n'
ret
else if _cond == -5
ret := 'Price Below Mean\n'
ret
ret
//-----------------------
// Chart Drawing Function
//-----------------------
format_price(x) =>
y = str.tostring(x, '0.00000')
if x > 10
y := str.tostring(x, '0.000')
y
if x > 1000
y := str.tostring(x, '0.00')
y
y
//
***********************************************************************************
*************************
// Calculate Channel
//
***********************************************************************************
*************************
var tf_0 = timeframe.period
var tf_1 = get_tf(1)
var tf_2 = get_tf(2)
[meanline, meanrange, upband1, loband1, upband2, loband2, condition] = get_mrc()
[mtf1_meanline, mtf1_meanrange, mtf1_upband1, mtf1_loband1, mtf1_upband2,
mtf1_loband2, mtf1_condition] = request.security(syminfo.tickerid, tf_1, get_mrc())
[mtf2_meanline, mtf2_meanrange, mtf2_upband1, mtf2_loband1, mtf2_upband2,
mtf2_loband2, mtf2_condition] = request.security(syminfo.tickerid, tf_2, get_mrc())
//
***********************************************************************************
*************************
// Drawing Start {
//
***********************************************************************************
*************************
float p_meanline = drawchannel ? meanline : na
float p_upband1 = drawchannel ? upband1 : na
float p_loband1 = drawchannel ? loband1 : na
float p_upband2 = drawchannel ? upband2 : na
float p_loband2 = drawchannel ? loband2 : na
//-----------------------
// Draw zone
//-----------------------
//---
var color1 = #FF0000
var color2 = #FF4200
var color3 = #FF5D00
var color4 = #FF7400
var color5 = #FF9700
var color6 = #FFAE00
var color7 = #FFC500
var color8 = #FFCD00
//---
float upband2_1 = drawchannel and displayzone ? upband2 + meanrange * gradsize *
4 : na
float loband2_1 = drawchannel and displayzone ? loband2 - meanrange * gradsize *
4 : na
float upband2_2 = drawchannel and displayzone ? upband2 + meanrange * gradsize *
3 : na
float loband2_2 = drawchannel and displayzone ? loband2 - meanrange * gradsize *
3 : na
float upband2_3 = drawchannel and displayzone ? upband2 + meanrange * gradsize *
2 : na
float loband2_3 = drawchannel and displayzone ? loband2 - meanrange * gradsize *
2 : na
float upband2_4 = drawchannel and displayzone ? upband2 + meanrange * gradsize *
1 : na
float loband2_4 = drawchannel and displayzone ? loband2 - meanrange * gradsize *
1 : na
float upband2_5 = drawchannel and displayzone ? upband2 + meanrange * gradsize *
0 : na
float loband2_5 = drawchannel and displayzone ? loband2 - meanrange * gradsize *
0 : na
float upband2_6 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -1
: na
float loband2_6 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -1
: na
float upband2_7 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -2
: na
float loband2_7 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -2
: na
float upband2_8 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -3
: na
float loband2_8 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -3
: na
float upband2_9 = drawchannel and displayzone ? upband2 + meanrange * gradsize * -4
: na
float loband2_9 = drawchannel and displayzone ? loband2 - meanrange * gradsize * -4
: na
kijun_len = 365
kijun_mult = 7
spanB_len = 365
spanB_mult = 15
offset = 2
//------------------------------------------------------------------------------
avg(src,length,mult)=>
atr = ta.atr(length)*mult
up = hl2 + atr
dn = hl2 - atr
upper = 0.,lower = 0.
upper := src[1] < upper[1] ? math.min(up,upper[1]) : up
lower := src[1] > lower[1] ? math.max(dn,lower[1]) : dn
os = 0,max = 0.,min = 0.
os := src > upper ? 1 : src < lower ? 0 : os[1]
spt = os == 1 ? lower : upper
max := ta.cross(src,spt) ? math.max(src,max[1]) : os == 1 ?
math.max(src,max[1]) : spt
min := ta.cross(src,spt) ? math.min(src,min[1]) : os == 0 ?
math.min(src,min[1]) : spt
math.avg(max,min)
//------------------------------------------------------------------------------
tenkan = avg(close,tenkan_len,tenkan_mult*neoCloudValue)
kijun = avg(close,kijun_len,kijun_mult*neoCloudValue)
senkouA = math.avg(kijun,tenkan)
senkouB = avg(close,spanB_len,spanB_mult*neoCloudValue)
//------------------------------------------------------------------------------
tenkan_css = #2156f300
kijun_css = #ff5e0000
chikou_css = #7b1fa2
plot(close,'Chikou',chikou_css,offset=-offset+1,display=display.none, editable =
false)
// Signal Settings
src = close
useMirror = false
useEma = false
emaLength = 3
useCog = false
cogLength = 6
oscillatorLookback =20
quadraticMeanLength = 50
src := useEma ? ta.ema(src, emaLength) : src
src := useCog ? ta.cog(src, cogLength) : src
speedToEmphasize = 'Normal'
emphasisWidth = 2
useKernelMA = false
useKernelEmphasis = false
ExitSensitivity = 7
// Oscillator Settings
offset := 0
showOsc = true
showOsc := showOsc
float f_length = 0.75 * ExitSensitivity
float f_smoothing = 0.45 * ExitSensitivity
float n_length = 1.0 * ExitSensitivity
float n_smoothing = 1.0 * ExitSensitivity
float s_length = 1.75 * ExitSensitivity
float s_smoothing = 2.5 * ExitSensitivity
// Divergence Detection
divThreshold = 30
sizePercent = 40
// The defaults are colors that Google uses for its Data Science libraries (e.g.
TensorFlow). They are considered to be colorblind-safe.
var color fastBullishColor = color.black
var color normalBullishColor = color.black
var color slowBullishColor = color.black
var color fastBearishColor = color.black
var color normalBearishColor = color.black
var color slowBearishColor =color.black
var color c_bullish = color.black
var color c_bearish = color.black
areaFastTrans = areaBackgroundTrans
lineFastTrans = lineBackgroundTrans
areaNormalTrans = areaBackgroundTrans
lineNormalTrans = lineBackgroundTrans
areaSlowTrans = areaForegroundTrans
lineSlowTrans = lineForegroundTrans
switch speedToEmphasize
"Slow" =>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaBackgroundTrans
lineNormalTrans := lineBackgroundTrans
areaSlowTrans := areaForegroundTrans
lineSlowTrans := lineForegroundTrans
"Normal" =>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaForegroundTrans
lineNormalTrans := lineForegroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
"Fast" =>
areaFastTrans := areaForegroundTrans
lineFastTrans := lineForegroundTrans
areaNormalTrans := areaBackgroundTrans
lineNormalTrans := lineBackgroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
"None" =>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaBackgroundTrans
lineNormalTrans := lineBackgroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
// =================================
// ==== Color Helper Functions =====
// =================================
// ================================
// ==== Main Helper Functions =====
// ================================
// =================================
// ==== Oscillator Calculations ====
// =================================
// =====================================
// ==== Color Gradient Calculations ====
// =====================================
// =========================================
// ==== Plot Parameters and Logic Gates ====
// =========================================
// Speed Booleans
isSlow = speedToEmphasize == "Slow"
isNormal = speedToEmphasize == "Normal"
isFast = speedToEmphasize == "Fast"
// Series Colors
seriesSlowColor = showOsc or isSlow ? color.new(slowLineGradientFromSource,
lineSlowTrans) : na
seriesNormalColor = showOsc or isNormal ? color.new(normalLineGradientFromSource,
lineNormalTrans) : na
seriesFastColor = showOsc or isFast ? color.new(fastLineGradientFromSource,
lineFastTrans) : na
seriesSlowMirrorColor = useMirror ? seriesSlowColor : na
seriesNormalMirrorColor = useMirror ? seriesNormalColor : na
seriesFastMirrorColor = useMirror ? seriesFastColor : na
colorLineEmphasis = switch
isFast => fastLineGradientFromSource
isNormal => normalLineGradientFromSource
isSlow => slowLineGradientFromSource
=> na
colorAreaEmphasis = switch
isFast => fastAreaGradientFromSource
isNormal => normalAreaGradientFromSource
isSlow => slowAreaGradientFromSource
=> na
// Crossover Signals
bearishCross = ta.crossunder(seriesFast, seriesNormal) and seriesNormal > 0
bullishCross = ta.crossover(seriesFast, seriesNormal) and seriesNormal < 0
slowBearishMedianCross = ta.crossunder(seriesSlow, 0)
slowBullishMedianCross = ta.crossover(seriesSlow, 0)
normalBearishMedianCross = ta.crossunder(seriesNormal, 0)
normalBullishMedianCross = ta.crossover(seriesNormal, 0)
fastBearishMedianCross = ta.crossunder(seriesFast, 0)
fastBullishMedianCross = ta.crossover(seriesFast, 0)
// ===========================
// ==== Kernel Estimators ====
// ===========================
// Gaussian Kernel with a lookback of 3 bars, starting on bar 2 of the chart (tight
fit)
yhat1 = kernels.gaussian(seriesEmphasis, 3, 2)
// Trend Assessment based on the relative position of the medium fit kernel to the
slow oscillator
isBearishKernelTrend = yhat0 < seriesSlow
isBullishKernelTrend = yhat0 > seriesSlow
// Divergence Signals
isBearishDivZone = ta.barssince(bearishCross[1]) < divThreshold
isBullishDivZone = ta.barssince(bullishCross[1]) < divThreshold
// Crossover Detection
isBearishTriggerWave = isSmallerBearishCross and isBearishDivZone and
isBearishKernelTrend
isBullishTriggerWave = isSmallerBullishCross and isBullishDivZone and
isBullishKernelTrend
// =======================
// ==== Plots & Fills ====
var position = 0
length := atrLength
Sensitivity=sensitivity/4
minMult = math.max(Sensitivity-4, 1)
maxMult = math.min(Sensitivity, 26)
float step = .5
float perfAlpha = 10
fromCluster = 'Best'
//Optimization
maxIter = 250
maxData = 2500
//Function
[os,perf_idx,lower,upper] = LAF.getSignalClassification(length, minMult, maxMult,
step, perfAlpha,maxIter,maxData,1)
//Signals
if showSignals
if os > os[1] and (signalPresets != "Smart Trail [Filter]" or
smartTrailDirection == 'long') and (signalPresets != "Trend Tracer [Filter]" or
trendTracerDirection==#02ff65) and (signalPresets != "Trend Strength [Filter]" or
trendStrengthMetric >= 25) and (signalPresets != "Trend Catcher [Filter]" or
newTrendCatcherColor == #02ff65) and (signalPresets != "Neo Cloud [Filter]" or
senkouA > senkouB )
int signalStrength = int(perf_idx*10) < 2 ? 1 : int(perf_idx*10) < 4 ? 2 :
int(perf_idx*10) < 5 ? 3 : 4
position := 1
y1 = low - (ta.atr(30) * 2)
y2 = high + (ta.atr(30) * 2)
bull = buy ? label.new(bar_index, y1, signalClassifier ?
str.tostring(signalStrength) : ema50 < ema200 ? "▲+" : "▲", xloc.bar_index,
yloc.price,color.new(#30a464,10), label.style_label_up, color.white, size.normal) :
na
bear = sell ? label.new(bar_index, y2, signalClassifier ?
str.tostring(signalStrength) : ema50 > ema200 ? "▼+" : "▼", xloc.bar_index,
yloc.price, color.new(redHigh,30), label.style_label_down, color.white,
size.normal) : na
// =======================
if buy
blockColor := dashboardGreenBackground
textColor := dashboardGreenText
if sell
blockColor := dashboardRedBackground
textColor := dashboardRedText
// Shit
atrMultiplier = 2
boxHeightInAtr = atrMultiplier * ta.atr(10)
// Box TP 1
if (takeProfitBoxes == 'On')
tp1box = box.new(left=bar_index + 1, top=close + midb, right=bar_index + 18,
bottom=close + lowb, border_color=TP1, border_width=2,
border_style=line.style_solid, bgcolor=color.new(#3666f5, 55), text="TP/SL 1 : "
+ str.tostring(close+ midb,format.mintick), text_size=size.normal,
text_color=color.new(#3666f5, 0))
bottom_tp1 = box.get_bottom(tp1box)
box.delete(tp1box[1])
// Box TP 2
tp2box = box.new(left=bar_index + 1, top=close+highb, right=bar_index + 18,
bottom=close+midb, border_color=TP2, border_width=2, border_style=line.style_solid,
bgcolor=color.new(#3666f5, 65), text="TP/SL 2 : " +
str.tostring(close+highb,format.mintick), text_size=size.normal,
text_color=color.new(#3666f5, 0))
top_tp2 = box.get_top(tp2box)
box.delete(tp2box[1])
// Empty Box
newBox = box.new(left=bar_index + 18, top=top_tp2, right=bar_index + 200,
bottom=bottom_tp1, border_color=color.new(#3666f5, 0), border_width=2,
border_style=line.style_solid, bgcolor=color.new(#3666f5, 50), text=" ",
text_size=size.normal, text_color=color.new(#3666f5, 0))
box.delete(newBox[1])
// SL Box
slBox = box.new(left=bar_index + 3, top=close-lowb, right=bar_index + 18,
bottom=close-midb, border_color=SL1, border_width=2, border_style=line.style_solid,
bgcolor=color.new(color.red, 66), text="TP/SL 2 : " + str.tostring(close-
lowb,format.mintick), text_size=size.normal, text_color=color.new(color.red, 0))
bottom_sl = box.get_top(slBox)
box.delete(slBox[1])
// SL2 Box
sl2Box = box.new(left=bar_index + 3, top=close-midb, right=bar_index + 18,
bottom=close-highb, border_color=SL2, border_width=2,
border_style=line.style_solid, bgcolor=color.new(color.red, 65), text="TP/SL 1 :
" + str.tostring(close-midb,format.mintick), text_size=size.normal,
text_color=color.new(color.red, 0))
bottom_sl2 = box.get_bottom(sl2Box)
box.delete(sl2Box[1])
// Empty Box SL
Slboxem = box.new(left=bar_index + 18, top=bottom_sl, right=bar_index + 200,
bottom=bottom_sl2, border_color=color.new(color.red, 0), border_width=2,
border_style=line.style_solid, bgcolor=color.new(color.red, 50), text=" ",
text_size=size.normal, text_color=color.new(color.red, 0))
box.delete(Slboxem[1])
// Line tp Bottom
var line tpb = na
isLastBar = barstate.islast
if (isLastBar)
tpb := line.new(na, bottom_tp1, na, bottom_tp1, color=color.new(#3666f5,
0), width=2, style=line.style_dashed)
if (isLastBar)
tp2Line := line.new(na, top_tp2, na, top_tp2, color=color.new(#3666f5, 0),
width=2, style=line.style_dashed)
// Line SL
var line slLine = na
if (isLastBar)
slLine := line.new(na, bottom_sl, na, bottom_sl, color=color.new(color.red,
0), width=2, style=line.style_dashed)
line.set_xy1(slLine, bar_index[50], bottom_sl)
line.set_xy2(slLine, bar_index + 400, bottom_sl)
line.delete(slLine[1])
// Line SL2
var line sl2Line = na
if (isLastBar)
sl2Line := line.new(na, bottom_sl2, na, bottom_sl2,
color=color.new(color.red, 0), width=2, style=line.style_dashed)
//alerts-------
sellalert = os > os[1] and (signalPresets != "Smart Trail [Filter]" or
smartTrailDirection == 'long') and (signalPresets != "Trend Tracer [Filter]" or
trendTracerDirection==#02ff65) and (signalPresets != "Trend Strength [Filter]" or
trendStrengthMetric >= 25) and (signalPresets != "Trend Catcher [Filter]" or
newTrendCatcherColor == #02ff65) and (signalPresets != "Neo Cloud [Filter]" or
int(lastNeo) >= last5Neo)
buyalert = os < os[1] and (signalPresets != "Smart Trail [Filter]" or
smartTrailDirection == 'short') and (signalPresets != "Trend Tracer [Filter]" or
trendTracerDirection!=#02ff65) and (signalPresets != "Trend Strength [Filter]" or
trendStrengthMetric >= 25)and (signalPresets != "Trend Catcher [Filter]" or
newTrendCatcherColor != #02ff65) and (signalPresets != "Neo Cloud [Filter]" or
int(lastNeo) <=last5Neo)
sellstop = bullishCross and position == -1
Strongsellstop = isBullishTriggerWave and position == -1
buystop = bearishCross and position == 1
Strongbuystop = isBearishTriggerWave and position == 1
trendchanged = sellalert or buyalert or sellstop or Strongsellstop or buystop or
Strongbuystop
alertcondition(showSignals and buyalert, "Long", "Long")
alertcondition(showSignals and sellalert, "Short", "Short")
alertcondition(showSignals and (sellalert or buyalert), "Short or Long ", "Short or
Long")
alertcondition(buystop and Strongbuystop, "LongStop", "LongStop")
alertcondition(sellstop and Strongsellstop, "ShortStop", "ShortStop")
alertcondition((buystop and Strongbuystop) or (sellstop and Strongsellstop) ,
"ShortStop or LongStop ", "ShortStop or LongStop")
alertcondition(trendchanged , "Trend Status", "Trend Is Changed")