0% found this document useful (0 votes)
63 views31 pages

Prueba

The document is a script written in Pine Script for TradingView that allows users to customize trading signals and indicators. It includes various settings for signal modes, sensitivity, and overlays, as well as options for displaying trading sessions and dashboards. The script also contains functions for calculating averages, trendlines, and VWAP for different trading sessions.

Uploaded by

fipada7863
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)
63 views31 pages

Prueba

The document is a script written in Pine Script for TradingView that allows users to customize trading signals and indicators. It includes various settings for signal modes, sensitivity, and overlays, as well as options for displaying trading sessions and dashboards. The script also contains functions for calculating averages, trendlines, and VWAP for different trading sessions.

Uploaded by

fipada7863
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/ 31

//@version=5

//Import libraries
import ayvaliktrading/EyopsTelegram/1 as LAF
import ayvali ktradi ng/JoinUsEyopsTelegram/1 as kernels
// # ============================[GET USERS I NPUT] ============================
# //
groupBasic = "BASIC SETTINGS"
showSignals = input(true, "Show Signals", in line = "1", group = groupBasi c, tool
t i p
= "Enables or disables the signals")
signalPresets = input.string("None", "Presets / Filters", ["None", "Trend Trader
[Preset] ", "Scalper (Preset] ", "Swing Trader [Preset] ", "Contrarian Trader
(Preset] ", "Smart Trail [Filter]", "Trend Tracer (Filter]", "Trend Strength
[Filter]", "Trend catcher [Filter]", "Neo Cloud ( Filter]"],tooltip =
"Automatically
sets setti ngs or filters for a given category", group= groupBasic)
signalMode = input.string("Confirmation + Exits", "Signal Mode", ("Confirmation+
Exits", "Contrarian + Exits", "None"], tooltip = "Changes the Mode of the
signals" ,group= groupBasic)
signalClassifier = input(true,"AI Signal Classif er",tooltip - "Shows signal
quality
from 1 -4 on signals" ,group= groupBasic)
sensitivity = input.float(5, "Si gnal Sensitivity", minval - 1, maxval -
26,step=l, tooltip = "Changes the sensetivity of the signals, the lower this
setting the more short term signals you will get, while a higher number will result
i n longer term signals.",group = groupBasic)
atrLength = input.int(10, "Signal Tuner", minval = 1, maxval = 25,step=l,tooltip
= "Alows you to tune your signals, the higher the number the more refined but
laggier the signal" ,group = groupBasic)
candleColorType = i nput. string( "Confirmation Simple", "Candle Coloring",
["Confirmation Simple","Confirmation Gradient","Contrarian
Gradient", "None" ] , tool tip = "Changes the type of signal coloring", group -
groupBasic)
Indicator overlay Settings
groupoverlay = " INDICATOR OVERLAY"
smartTrai l = input ( true, "Smart Trail", in line = "1", group = groupOverlay)
trendCatcher = input(false, "Trend Catcher", inline = "2", group = groupOverlay)
neoCloud = input(false, "Neo Cloud", inline = "3", group = groupOverlay)
reversalZone = input(true, "Reversal Zones", inline = "1", group = groupOverlay)
trendTracer = input(false, "Trend Tracer", in line = "2", group = groupOverlay)
showDashboard = input(true, "Dashboard", inline = "3", group = groupoverlay)
showTrai lingStoploss = input(false, "Trailing Stop loss", i n line = "4", group -
groupOverlay)
showMovingAverage = input(false, "AI Moving Average", inline = "4", group=
groupOverlay)
showSessions = input(false, "Sessi ons", inline = "5", group= groupOverlay)
// Advanced Settings
groupAdvanced = "ADVANCED SETTINGS"
takeProfitBoxes = input. string( "Off", "TP/SL Points", options=("Off", "On"], in
line
= "2", tooltip = "Shows Take Profit and stop Loss areas",group = groupAdvanced)
takeProfitStopLossDi stance = input.int(5,"", minval = 1, maxval = 10, inline =
"2",
group=groupAdvanced)
autopilotMode = input.string("Off", "Autopilot Sensivity", ["Off", "Short -Term",
"Mid-Term", "Long-Term"],tooltip = "Sets automatic settings for signals and
i mproves their quality" ,inline = "3", group= groupAdvanced)
dashboard Location = input. string( "Bottom Right", "Dashboard Location", ("Top
Right","Bottom Right","Bottom Left"], inline = "4",tooltip = "Changes dashboard
positions" ,group= groupAdvanced)
dashboardSize = input.string("Normal","Dashboard Size",
(
11Tiny11 ,"Small11
,
11 Normal11
,
11 Large 11
], inline = 11511 ,tooltip = "Changes the size of the
dashboard" ,group = groupAdvanced)
if (signalPresets == "Trend Trader [Preset]")
smartTrail := true
trendcatcher := true
neoCloud := true
trendTracer := true
smartTrail := true
if (signalPresets == "Scalper [Preset]")
sensitivity := 4
smartTrail := true
trendTracer := true
candleColorType := "Confirmation Gradient"
if (signalPresets == "Swing Trader (Preset]")
sensitivity := 18
neoCloud := t rue
candleColorType := "Confirmation Simple"
if (signalPresets == "Contrarian Trader (Preset]")
reversalZone := true
smartTrail := true
candleColorType := "Contrarian Gradient"
n - bar_index
II # -----------------------------------------------------(-B-U- Y/SELL SIGNALS-
J------------------------------------------------------- #
/ I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//Settings
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
//-----------------------------------------------------------------------------}
II# ============================[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 = t rue
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
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
//Functions
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
//Get session average
get_avg(session}=>
var len = 1
var float csma = na
var float sma = na
i f session> session[l]
len := 1
csma := close
if session and session
len += 1
csma += close
sma := csma / len
sma
//Get trendline coordinates
get_linreg(session}=>
var len = 1
var float cwma - na
var float csma - na
var float csma2 = na
var float yl = na
var float y2 = na
var float stdev - na
var float r2 - na
if session > session[l]
len .• -- 1
cwma .. -- close
csma .. - close
csma2 .. -- close * close
session [l]
if session and session == session[l]
len += 1
csma += close
csma2 +=close * close
cwma +=close* len
sma = csma I len
wma - cwma / (len * (len + 1) / 2)
cov = (wma - sma) * (len+l)/2
stdev := math.sqrt(csma2 / len - sma * sma)
r2 := cov / (stdev * (math .sqrt(len*len - 1) / (2 * math.sqrt(3))))
yl := 4 * sma
y2 := 3 * wma
[yl , y2, stdev, r2]
//Session Vwap
get_vwap(session) =>
var float num - na
var float den= na
3 * wma
2 * sma
if session> session[l]
num :=close * volume
den := volume
else if session and session
num +=close* volume
den+= volume
else
num := na
[ num, den]
//Set line
session[l]
set_line(session, yl, y2, session_css)=>
var line tl = na
if session> session[l]
tl := line.new(n, close, n, close, color - session_css)
if session and session== session[l]
line.set_yl(tl, yl)
line.set_xy2(tl, n, y2)
//Set session range
get_range(session, session_name, session_css)=>
var t = 0
var max = high
var min = low
var box bx= na
var label lbl = na
if session> session[l] and showsessions
t := time
max := high
min := low
bx := box.new(n, max, n, min
, bgcolor = color.new(session_css, bg_transp)
, border_color - show_outline? session_css na
, border_style - line . style_dotted)
if show_txt and showsessions
lbl
'
'
'
'
'
:= label .new(t, max, session name
xloc = xloc.bar_time
textcolor = session_css
style= label.style_label_down
color = color.new(color.white, 100)
size = size .tiny)
if session and session== session[l] and showSessions
max := math .max(high, max)
min := math.min(low, min)
box.set_top(bx, max)
box.set_rightbottom(bx, n, min)
if show_txt
label.set_xy(lbl, int(math.avg{t, time)), max)
[session? na : max, session? na : min)
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
//Sessions
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
tf = timeframe.period
var tz = use_exchange? syminfo.timezone
str .format{' UTC{0}{1} ', tz_incr >= 0? '+' : '-', math.abs(tz_incr))
is_sesa - math.sign(nz(time(tf, sesa_ses, tz)))
is_sesb - math.sign(nz(time(tf, sesb_ses, tz)))
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
//Dashboard
//-----------------------------------------------------------------------------{
var float max sesa -- na
var float min - sesa -- na
var float max - sesb -- na
var float min sesb -- na
var float max_sesc -- na
var float min - sesc -- na
var float max - sesd -- na
var float min_sesd -- na
//Ranges
if show_sesa and sesa_range
[max, min] = get_range(is_sesa, sesa_txt, sesa_css)
max_sesa := max
min sesa := min
if show_sesb and sesb_range
[max, min) = get_range(is_sesb, sesb_txt, sesb_css)
max_sesb := max
min sesb := min
//Trendlines
//Mean
if show_sesa and sesa_avg
avg = get_avg(is_sesa)
set_ line(is_sesa, avg, avg, sesa_css)
if show_sesb and sesb_avg
avg = get_avg(is_sesb)
set_line(is_sesb, avg, avg, sesb_css)
//VWAP
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
//Plots
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
//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(showsessions and sesb maxmin? max_sesb
1, plot.style_linebr, editable= false)
plot(showSessions and sesb_maxmin? min sesb
1, plot.style_linebr, editable = false)
na, 'Session B Maximum', sesb_css,
na, 'Session B Minimum', sesb_css,
//Plot Divider A
plotshape(is_sesa and show_ses_div and show_sesa and showSessions,
, shape.square
, location.bottom
, na
text = 11

, 11
, textcolor = sesa_css
, size= size.tiny
, display= display.all - display.status_line
, editable = false)
II II •
plotshape(is_sesa 1- is_sesa[l] and show_ses div and show_sesa and showsessions,
II NYE II
, shape.labelup
, location.bottom
, na
, text= 11 ? 11
, 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 = 11

11
, textcolor = sesb css
, size= size.tiny
, display = display.all - display.status_line
, editable= false)
II II •
plotshape(is_sesb != is_sesb[l] and show_ses div and show_sesb and showSessions,
II LDN II
, shape . labelup
, location.bottom
, na
tex t ="?" ' , textcolor = sesb_css
, s i ze = s i ze .tiny
, display= display.all - display.status_line
, editable = false)
II # ============================[FUNCTIONS] ============================ #
type bar
float 0 -- open
float h -- high
float l -- low
float C -- close
float V -- volume
i nt 1 -- bar_ i ndex
barb - bar.new()
nzv - nz (b.v)
f_calcV() =>
uV - 0.0
dV = 0.0
switch
(b .c - b.l) > (b .h
(b.c - b . l) < (b.h
b.c > b.o => UV .. - -
b.c < b.o => dV . - • -
b.c > nz(b.c[l]) =>
b.c < nz(b .c[l]) =>
nz(uV[l]) > 0 => UV
nz(dV[l]) < 0 => dV
[uV, dV]
- b.c) => UV .. --
- b .c) => dV .. --
nzv
-nzv
uv .. -- nzv
d.V .. -- -nzv . -- UV + nzv .. -- dV - nzv
II # ============================[CONSTANT
sma4 = ta.sma(close, 4)
sma5 = t a .sma (close, 5)
sma9 = ta.sma(close, 9)
ema50 = ta .ema(close, 50)
ema200 = ta.ema(close, 200)
bullishSignalColor - #59e08a
beari shSi gnalColor = #ff5959
dashboardRedText = #ee787d
dashboardGreenText = #42bda8
dashboardGreenBackground = #284444
dashboardRedBackground = #49343e
nzv
-nzv
VARIABLES] -------------------------------------------------------- #
II# ============================[CANDLE COLORING] ============================ #
macdFastLength = 12
macdSlowLength = 26
macdSi gnalLength = 9
i f (candleColorType != 'Confirmation Simple ' )
macdFastLength := 10
macdSlowLength := 25
macdSignalLength :=8
[MacdX, signalx, histX] - ta .macd(close, macdFastLength, macdSlowLength,
macdSignalLength}
//candle color scheme
greenHigh = #4ce653
greenMidHigh =#4ce653
greenMi dLow =#4ce653
green Low = #56328f
// Yellow
yellowLow = #56328f
II 4 level of red
redHi gh = #ff0000
redMidHigh = #ff0000
redMidLow = #ff0000
redLow = #56328f
i f (candleColorType == 'Confirmation Gradient')
greenHi gh := #01d70c
greenMidHigh := #269444
greenMidLow :=#4f966c
greenLow := #425970
// Yellow
yellowLow := #513a88
II 4 level of red
redHigh := #ff0000
redMi dHi gh := #c21637
redMidLow := #c33252
redLow := #8e215f
i f (candleColorType == 'Contrarian Gradient')
redHigh := #01d70C
redMidHigh := #269444
redMidLow :=#4f966c
redLow := #425970
// Yellow
yellowLow := #513a88
II 4 level of red
greenHigh := #ff0000
greenMi dHi gh := #C21637
greenMidLow := #c33252
greenLow := #8e215f
II Default color
candl eBody = yellowLow
i f histX > 0
if histX > histX[l] and histX[l] > 0
candleBody := greenLow
i f histX < 0
if histX < histX[l] and histX[l] < 0
candleBody := redLow
II Bullish trend
if MacdX > 0 and histX > 0
candleBody := greenMidLow
if histX > histX[l] and MacdX[l] > 0 and histX[l] > 0
candleBody := greenMidHigh
if histX > histX[2) and MacdX[2) > 0 and histX[2) > 0
candleBody := greenHigh
II Bearish trend
if MacdX < 0 and histX < 0
candleBody := redMidLow
if histX < histX[l) and MacdX[l) < 0 and histX[l) < 0
candleBody := redMidHigh
if histX < histX[2] and MacdX[2] < 0 and histX[2] < 0
candleBody := redHi gh
barcolor(candleColorType == 'None' ? na : candleBody, editable= false)
II# ============================[SMART TRAIL)============================ #
[smartTrailLine, fillerLine, smartTrailDirection) = LAF.getSmartTrail(10, 4, 8)
smartTraill = plot(smartTrail? smartTrailLine : na, "Smart Trail", style=
plot.style_line, color = smartTrailDirection== ' l ong' ? color.new( #2157f9, 0) :
smartTrailDirection == 'short' ? color . new(#ff1100, 0) : na, editable = false)
smartTrail2 = plot(smartTrail? fillerLine : na, "Fib 2", style= plot.style_line,
transp = 100, editable = false)
fil l(smartTraill, smartTrail2, color = smartTrail Direction == 'long' ?
color.new(#2157f9, 80) : smartTrailDirection == 'short' ? color .new(#f f1100 , 80)
na, edit able = false)
II# ============================[TREND CATCHER]============================#
[trendCatcherLine, trendcatchercolor] = LAF.getTrendCatcher()
newTrendCatcherColor = trendCatcherColor == col or.blue? #02ff65 : #ffll00
plot(trendCatcher? trendCatcherLine : na, title='Trend Catcher', l inewidth=2,
color=newTrendcatchercolor, editable= false)
II# ============================[NEO CLOUD)============================#
II # ============================ [REVERSAL ZONES) ============================ #
II# ============================[TREND TRACER] ============================#
[trendTracerLine, trendTracerDirection] = LAF.getTrendTracer()
plot(trendTracer? trendTracerLine : na, t i tle='Trend Tracer', l i newi dt h=2,
style=plot.style_cross, col or = trendTracerDirection , editable = fal se)
II # -------------------------------------------------------- [DASHBOARD
COMPONENTS I]--------------------------------------------------------#
trendStrengthMetric = math.abs(LAF.getTrendStrengthMetric(14, 'RMA', 21, 'EMA'))
trendStrengthMetric := trendStrengthMetric*2.5
trendlndication = trendStrengthMetric > 30? "??" : "??"
trendStrengthCellColor = newTrendCatcherColor == #02ff65? dashboardGreenBackground
: dashboardRedBackground
trendStrengthTextColor = trendStrengthCellColor == dashboardGreenBackground?
dashboardGreenText : dashboardRedText
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
squeezeMetric = LAF.getSqueezeMetric(45, 20)
squeezeisHigh = squeezeMetric >= 80? true
squeezeCellColor - trendTracerDirection
squeezeTextColor = trendTracerDirection !=
false
#02ff65?
#02ff65?
[uV, dV] = f_calcV()
totalvolume = uv + math.abs(dV)
//volumecolor = totalVolume >= 50? bullish : bearish
volumeCellColor = dashboardRedBackground
#1a3a3e
#ed3544
#482632
#0a907a
volumeTextcolor = totalVolume >= 50? dashboardGreenText
if (totalVolume >= 50)
dashboardRedText
totalVolume := totalVolume*2
volumecellColor := dashboardGreenBackground
else
totalVolume := totalVolume*-2
volumesentiment = totalVolume
table_position = dashboardLocation == 'Bottom Left' ? position.bottom_left
dashboardLocation == 'Top Right' ? position.top_right
: position.bottom_right
table_size = dashboardSize == 'Tiny' ? size.tiny
dashboardSize == 'Small' ? size.small
: size.normal
tb = table.new(table_position, 7, 7
, bgcolor = #1e222d
, 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)
tb. eel 1(0, 3, str. tostring(trendindication) + "Trend Strength", text_color
- color.white, text_size = table_size, text_halign = text.align_left)
tb.cell(0, 4, volatilityEmoji+" Lux Volatility", text_color = color.white,
text_size = table_size, text_halign = text.align_left)
tb.cell( 0, 5, "?? Squeeze", text_color = color.white, text_size =
table_size, text_halign = text.align_left)
tb.cell(0, 6, "?? Volume Sentiment" , text_color = color .white, text size -
table_size, text_halign = text.align_left)
tb.cell(l, 2, autopilotMode, text_color = color .white, text_size -
table_size)
tb.cell(l, 3, str.tostring(trendStrengthMetric, format.percent),
text_color=trendstrengthTextcolor, text_size=table_size, bgcolor =
trendStrengthCellColor)
tb.cell(l, 4, volatilityText, text_color = VolatilityTextColor, text size -
table_size, bgcolor = volatilityCellColor)
tb .cell(l, 5, str . tostring(squeezeMetric, format.percent), text_color=
squeezeTextColor, text_size=table_size, bgcolor = squeezeCellColor)
tb.cell(l, 6, str.tostring(math.min(volumeSentiment, 100.),
format.percent), text_color = volumeTextcolor, text_size = table_size, bgcolor -
volumeCellColor)
II
***********************************************************************************
*************************
II REV ZONES
II
***********************************************************************************
*************************
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_lvll - 'D'
mtf_ lvl2 = 'W'
II
***********************************************************************************
*************************
II Functions Start {
II
************* * * * *** * ****************** * * * * * * * ******************** * *
* * * *************
*************************
var pi= 2 * math.asin(l)
var mult =pi* innermult
var mult2 = pi* outermult
var gradsize = 0.5
var gradtransp = zonetransp
//-----------------------
// Ehler SwissArmyKnife Function
//------- -- -- -- -- -- -- -- --
SAK_smoothing(_type, _src, _length) =>
C0 - 1.0
cl - 0.0
b0 - 1.0
bl - 0.0
b2 - 0.0
al = 0.0
a2 - 0 .0
alpha= 0 .0
beta = 0.0
gamma - 0.0
cycle= 2 *pi/ _length
if _type == 'Ehlers EMA'
alpha := (math.cos(cycle) + math.sin(cycle) - 1) I math.cos(cycle)
b0 := alpha
al := 1 - alpha
al
if _type == 'Gaussian'
beta := 2.415 * (1 - math.cos(cycle))
alpha := -beta + math.sqrt(beta *beta + 2 * beta)
C0 :=alpha* alpha
al := 2 * (1 - alpha)
a2 := -(1 - alpha) * (1 - alpha)
a2
if _type == 'Butterworth'
beta := 2.415 * (1 - math.cos(cycle))
alpha := -beta + math.sqrt(beta *beta + 2 * beta)
c0 :=alpha* alpha/ 4
bl := 2
b2 := 1
al := 2 * (1 - alpha)
a2 := -(1 - alpha) * (1 - alpha)
a2
if _type== 'Bandstop'
beta := math.cos(cycle)
gamma := 1 I math.cos(cycle * 2 * 0.1) // delta default to 0.1. Acceptable
delta - - 0.05<d<0.5
alpha := gamma - math . sqrt(gamma * gamma - 1)
c0 := (1 + alpha) / 2
bl := -2 * beta
b2 := 1
al :=beta* (1 + alpha)
a2 := -alpha
a2
if _type== 'SMA'
cl := 1 I _length
b0 := 1 I _length
al := 1
al
if _type== 'EMA'
alpha := 2 /(_length+ 1)
b0 := alpha
al := 1 - alpha
al
if _type == 'RMA'
alpha := 1 / _length
b0 := alpha
al := 1 - alpha
al
_Input - src
_Output= 0.0
_Output := c0 * (b0 * _Input+ bl * nz{ _Input[l]) + b2 * nz( _Input[2])) +al *
nz( _Output[l]) + a2 * nz{ _Output[2]) - cl* nz( _Input[_length])
_Output
// ------- - - - - - - - - - - - - - - - -
// SuperSmoother Function
1/-----------------------
supersmoother(_src, _length)=>
s_al - math.exp(-math.sqrt{2) * pi / _length )
s bl = 2 * s_al * math.cos( math.sqrt( 2) *pi/ _length)
s_c3 - -math.pow(s_al, 2)
s_c2 - s_bl
s_cl - 1 - s_c2 - s c3
SS - 0.0
ss := s_cl * _src + s_c2 * nz(ss[l], _src [l]) + 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'
z
else if y <= 3
z := l vl == 1? '5'
z
else if y <= 10
z := lvl == 1? '15'
z
else if y <= 30
z := l vl == 1? '60'
z
else if y <= 120
lvl 2? '5' z
lvl 2? '15' z
lvl 2? '60' z
l vl 2? '240' z
z .. -- lvl ---- 1 ? '240'
z
else if y <= 240
z .. -- lvl ---- 1 ? I DI
z
else if y <= 1440
z .. -- lvl -- -- 1 ? Iw I
z
else if y <= 10080
z .. -- lvl ---- 1 ? I MI
z
else
z . - z • -
z
else
z ..- - lvl 1 ? mtf lvll
z
z
//----------- ------------
// Mean Reversion Channel Function
1/- - -- - - - - - - - - - - - - - - - - - - -
get_mrc() =>
v_condition = 0
v_meanline = source
lvl 2
lvl 2 ?
lvl 2 ?
z
lvl 2
v_meanrange = supersmoother(ta.tr, length)
//-- Get Line value
if type== 'Supersmoother'
? I D I
I w I
IM I
? mtf -
v_meanline := supersmoother(source, length)
v_meanline
if type != 'SuperSmoother'
z
z
z
lvl2
v_meanline := SAK_smoothing(type, source, length)
v_meanline
v_upbandl -- v_meanline + v_meanrange * mult
V - lobandl -- v_meanline v_meanrange * mult
v_upband2 -- v_meanline + v_meanrange * mult2
V - loband2 -- v_meanline V _mean range * mult2
//-- Check condition
if close> v_meanline
z
v_upband2_1 = v_upband2 + v_meanrange * gradsize * 4
v_upband2_9 = v_upband2 + v_meanrange * gradsize * -4
if high>= v_upband2_9 and high< v_upband2
v_condition := 1
v_condition
else if high>= v_upband2 and high< v_upband2_1
v_condition := 2
v_condition
else if high>= v_upband2_1
v_condition := 3
v_condition
else if close<= v_meanline + v_meanrange
v_condition := 4
v_condition
else
v_condition := 5
v_condition
if close< v_meanline
v_loband2_1 = v_loband2
v_loband2_9 = v_loband2
if low<= v_loband2_9 and
v_condition := -1
v_condition
v_meanrange * gradsize * 4
v_meanrange * gradsize * -4
low> v_loband2
else if low<= v_loband2 and low> v_loband2_1
v_condition := -2
v_condition
else if low<= v_loband2_1
v_condition := -3
v_condition
else if close>= v_meanline + v_meanrange
v_condition := -4
else
v_condition
v_condition := -5
v_condition
[v_meanline, v_meanrange, v_upbandl, v_lobandl, v_upband2, v_ loband2,
v_condition]
// ------- - - - - - - - - - - - - - - - -
// 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
ret := 'Price Below Mean\n'
ret
11-----------------------
11 Chart Drawing Function
11-----------------------
format_price(x) =>
y = str.tostring(x, '0.00000'}
if X > 10
y := str.tostring(x, '0.000'}
y
if X > 1000
y
y := str.tostring(x, '0.00'}
y
f_Priceline(_ref, linecol) =>
l ine.new{xl=bar_index, x2=bar index - 1, yl=_ref, y2=_ref, extend=extend.left,
color=linecol)
f_MTFLabel{_txt, _yloc) =>
label.new(x=time + math.round(ta.change(time) * 20), y=_yloc,
xloc=xloc.bar_time, text=mtf_disp_typ == 'Always Display' ? _txt : 'Check
tooltip=mtf_disp_typ == 'Always Display' ? '' : _txt, color=color.black,
textcolor=color .white, size=size.normal, style=mtf_disp_typ == 'On Hover'
displayline? label.style_labe l_ lower_left : label.style_label_left,
textalign=text.align_left)
II} Function End
II
MTF' I
and
*** **** * **************** ************************* ***************************
***** **
*************************
II Calculate Channel
II
***********************************************************************************
*************************
var tf_0 - timeframe .period
var tf_l - get_tf(l}
var tf_2 - get_tf{2}
[meanline, meanrange, upbandl, lobandl, upband2, loband2, condition] = get_mrc()
[mtfl_meanline, mtfl_meanrange, mtfl_upbandl, mtfl_lobandl, mtfl_upband2,
mtfl_loband2, mtfl_condition] = request.security(syminfo.tickerid, tf_l, get_mrc())
[mtf2_meanline, mtf2_meanrange, mtf2_upband1, mtf2_loband1, mtf2_upband2,
mtf2_loband2, mtf2_condition] = request.security(syminfo.tickerid, tf_2, get_mrc())
II
***********************************************************************************
*************************
II Drawing Start {
II
***********************************************************************************
*************************
float
float
float
float
p_meanline = drawchannel? meanline : na
p_upbandl - drawchannel? upbandl na
p_lobandl = drawchannel? lobandl na
p_upband2 - drawchannel? upband2 na
float p_loband2 = drawchannel? loband2 : na
1/z = plot(p_meanline, color=color.new(#FFCD00, 0), style=plot.style_line, title='
Mean', linewidth=2)
//xl = plot(p_upbandl, color=color.new(color.green, 50), styl e=plot .
style_circles,
title=' Rl', linewidth=l)
//x2 = plot(p_lobandl, color=color.new(color.green, 50), style=plot.style_ci rcles,
title=' S1', linewidth=l)
//yl = plot(p_upband2, color=color.new(color.red, 50), style=plot.style_line,
title=' R2', linewidth=l )
//y2 = plot(p_loband2, color=color.new(color.red, 50), style=plot.style_line,
title=' S2', linewidth=l)
//-----------------------
// Draw zone
// -----------------------
//---
var colorl = #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 -
3 : na
float loband2_2 -
3 : na
float upband2_3 -
2 : na
float loband2_3 -
2 : na
float upband2_4 -
1 : na
float loband2_4 -
1 : na
float upband2_5 -
0 : na
float loband2_5 =
0 : na
float upband2_6 -
: na
drawchannel and displayzone? upband2 + meanrange * gradsize *
drawchannel and displayzone? loband2 meanrange * gradsize *
drawchannel and displayzone? upband2 + meanrange * gradsize *
drawchannel and displayzone? loband2 meanrange * gradsize *
drawchannel and displayzone? upband2 + meanrange * gradsize *
drawchannel and displayzone? loband2 meanrange * gradsize *
drawchannel and displayzone? upband2 + meanrange * gradsize *
drawchannel and displ ayzone? loband2 meanrange * gradsize *
drawchannel and displayzone? upband2 + meanrange * gradsize * -1
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
upl = plot(reversalZone ? upband2_1 .• na, color = color . bl ack, transp = 100,
editable= false)
up2 = plot(reversalZone ?upband2_5:na, color -- color. black, transp --
= false)
up3 = plot(reversalZone ?upband2_9:na, color -- color. black, transp --
= false)
dpl = plot(reversalZone ?loband2_1:na, color -- color. black, transp --
= false)
dp2 = plot(reversalzone ?loband2_5:na, color -- color. black, transp --
= false)
dp3 = plot(reversalZone ?loband2_9:na, color -- color. black, transp --
= false)
fill(upl, up2, color -- #56202d, transp -- 20, editable -- false)
fill(up2, up3, color -- #3fld29, transp -- 60, editable -- false)
fill(dpl, dp2, color -- #0f3e3f, transp -- 20 editable -- false) I
fill(dp2, dp3, color -- #113135, transp -- 60, editable -- false)
//[upband2_1, upband2_5, upband2_9, loband2_1, loband2_5, loband2_9]
tenkan_len - 365
tenkan_mult = 3
kijun_len - 365
ki jun_mult - 7
spanB_len - 365
spanB_mult - 15
offset = 2
100 I editable
100 I editable
100 I editable
100
'
editable
100, editable
/1------------------------------------------------------------------------------
avg(src, length,mult}=>
atr = ta.atr(length)*mult
up= hl2 + atr
dn = hl2 - atr
upper = 0 . , lower= 0.
upper := src[l) < upper[l) ? math .min(up,upper[l)} up
lower := src[l] > lower[l] ? math. max(dn, lower[l]} dn
os = 0,max = 0.,mi n = 0 .
os := src >upper? 1 : src <lower? 0 : os[l]
spt = os == 1? lower : upper
max := ta.cross(src,spt)? math.max(src,max[l)}
math.max(src,max[l]} : spt
min := ta.cross(src,spt)? math.min(src,min[l]}
math.min(src,min[l]) : spt
math.avg(max,min)
OS
OS
1 ?
0 ?
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
tenkan = avg(close,tenkan_len,tenkan_mult)
ki jun = avg(close,kijun_len,kijun_mult)
senkouA = math.avg(kijun,tenkan)
senkouB = avg(close,spanB_len,spanB_mult)
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
tenkan_css = #2156f300
kijun_css = #ff5e0000
cloud_a - color.new{ #006989, 47}
cloud b - color.new{ #ff5252, 66)
chikou_css - #7blfa2
plot(neoCloud? tenkan : na, 'Tenkan-Sen',tenkan_css, editable = false)
plot(neoCloud ? kijun : na, 'Kijun-Sen' ,kijun_css, editable = false)
plot(neoCloud and ta.crossover(tenkan,kijun)? ki jun :
na, 'Crossover',#2156f300,3,plot.style_circles, editable = false)
plot(neocloud and ta.crossunder(tenkan,kijun)? ki jun :
na, 'Crossunder',#ff5e0000,3,plot.style_circles, edi table = false)
A= plot(neoCloud? senkouA: na, 'Senkou Span A',na,offset=offset-1, editable=
fa l se)
B = plot(neoCloud? senkouB : na, 'Senkou Span B',na,offset=offset-1, editable =
false)
fill{A,B,senkouA > senkouB? cloud_a : cloud_b)
lastNeo = int(senkouA + senkouB)
last5Neo = ta.sma(lastNeo, 2}
plot(close, 'Chikou',chikou_css,offset=-offset+l,display=display.none, editable -
false)
// Wylicz pozycje kwadratu
ltpl - bar_index
rtpl = bar_index + 40
[lowBound, midBound, highBound] - LAF.getTPSLBoxes(6.0}
// Stw6rz rzeczywisty kwadrat
//tplbox = box.new(left=ltpl, top=ttpl, right=rtpl, bottom=btpl,
border_color=#3666f5, border_width=2, border_style=line.style_solid,
bgcolor=color . new{#3666f5, 53), text=11TPl : 11 + str.tostring(close),
text_size=size.large, text_color=color.new{#3666f5, 0}, text_wrap=text .wrap_auto)
//var boxes= array.new<box>{}
//boxes.push(box .new(left = ltpl, top = close+highBound, right = rtpl, bottom =
close + midBound, border_color=#3666f5, border_width=2,
border_style=line.style_solid, bgcolor=co lo r.new{ #3666f5, 70), text=11TP/SL 2 :
+ str.tostring(close), text_size=size . large, text_color=color . new{#3666f5, 0),
text_wrap=text.wrap_auto))
II
llboxes . push(box .new(left = l tpl, top = close+midBound, right= rtpl, bot tom -
close+ lowBound, border_color=#3666f5, border_width=2,
border_style=line.style_solid, bgcolor=color.new{#3666f5, 40), text="TPISL 1
+ str.tostring(close), text_size=size.large, text_color=color.new{ #3666f5, 0),
text_wrap=text .wrap_auto))
II
IISL1 = box.new(left = ltpl, top= close-highBound, right= rtpl, bottom= close -
midBound, border_color=#3666f5, border_width=2, border_style=line.style_solid,
bgcolor=color . new{#3666f5, 70), text="TPISL 2 : 11 + str.tostring(close),
text_size=size.large, text_color=color . new{ #3666f5, 0),
text_wrap=text.wrap_auto)
IISL2 = box.new(left = ltpl, top= close-midBound, right= rtpl, bottom = close -
l owBound, border_color=#3666f5, border_width=2, border_styl e=line.style_solid,
bgcolor=color . new{ #3666f5, 40), text=11TPISL 1 : 11 + str.tostring(close),
text_size=size.large, text_color=color.new{#3666f5, 0), text_wrap=text .wrap_auto)
II Usun poprzednie ramki
llbox.delete(boxes . shi ft())
llbox.delete{SL1[1])
llbox.delete{SL2(1])
llbox.delete(boxes .shif t())
II ==== Overview ====
II
II WaveTrend 3D {WT3D) is a novel implementation of the famous WaveTrend {WT)
indi cator and has been completely redesigned from the ground up to address some
II of the inherent shortcomings associated with the traditional WT algorithm,
including:
II (1) unbounded extremes
II (2) susceptibility to whi psaw
II (3) lack of insight into other timeframes
II Furthermore, WT3D expands upon the original functionality of WT by providing:
II (1) first -class support for multi-timeframe {MTF) analysis
II (2) kernel-based regression for trend reversal confirmation
II (3) various options for signal smoothing and transformation
II (4) a unique mode for visualizing an input series as a symme t r i cal, three
dimensional
waveform useful for pattern identi fication and cycle -related analysis
II Fundamental Assumptions:
II (1) There exists a probability densi ty function that describes t he relative
l ike l ihood for a price to visit a gi ven value.
II (2) The probability densi ty function for pri ce i s a funct i on of time .
II (3) The probability density function can approximate a Gaussian distribution
{shown below).
II
II
II
II
II
II
II
II
[PRICE]
II
• • - I •
0 0 0 • 0 0 I
.·? . ?. ?. ?. - 1. ?. ?. ?. 1. .
.?J????-!????JI\
:J??????-!?????JI\
:J???????- !????????.
:J????????- !????????JI\
: J?????????- !?????????JI\
. .· - ?. ?. ?. ?. ?. ?. ?. ?. ?. ?. -1.? . ?.? .? .? .? .? .? .? .1 .1 . -
I
I
I
I
I
I
II
II
II
II
II
II
.• ?. -/\?. ?. ?. ?. ?. ?. ?. ?. ?. ?. -1. ?. ?. ?. ?. ?. ?. ?. ?. ?.1 ./ \?. I.
- ;/\/\/\??????????-!?????????!/\/\!?.
. ?. 1. /\/\/\/.\ ?. ?. ?. ?. ?.? .? .? .? .? -
1. ?. ?. ?. ?. ?. ?. ?. ?. ?.1 ./ \/\/\-?. -
-?-/\/\/\/\/\??????????-1?????????1/\/\/\/\/\I? •
0 • • • • • • • • • • • • • • • • • • • • • • • • I
. - ?. -/\/\/\/\/\/\/\?. ?. ?. ?. ?. ?. ?. ?. ?. ?. - 1. .? .? .? ?. ?. ?. ?. ?. ?.
1. /\/\/\/\/\/\-1. 1. /\ .
. . . . .· .• /\/\ .l --/\/\/\/\/\/\/\/\/.\ .? ?. ?. ?. ?. ?. ?.? .? .? -
1. .? .? ?. ?. ?. ?. ?. ?. ?. 1. /\/\/\/\/\/\/\/\/\-1. /\/\ .• .· . . . . . .
I I .. : : : /\/\/\/\/\/\/\: : : : : : : : : : : : : : ? ?????????- ! ????????? ! :
: : : : : : : : : : : /\/\/\/\/\/\/\/\: : : ..
II
II [TIME] ------------------------------- 1
// How to use this indicator:
I
I
I
I
I
I
I
II - The basic usage of WT3D is similar to how one would use the traditional WT
indicator .
II - Divergences can be spotted by finding "trigger waves", which are small waves
that immediately follow a larger wave. These can also be thought of as Lower -Highs
and Higher -Lows in the oscillator.
II - Instead of the SMA-cross in the original WT, the primary mechanism for
identifying potential pivots are the crossovers of the fast/normal speed
oscillators, denoted by the small red/green circles.
II - The larger red/green circles represent poi nts where there could be a
potential
trigger wave for a Divergence. Settings related to Divergence detection can be
configured in the "Divergence" section.
II - For overbought/oversold conditions, the 0.5 and -0.5 levels are convenient
since the normal -speed oscillator will only exceed this level -25% of the time.
II - For less experienced users, focusing on the three oscillators is recommended
since they give critical information from multiple timeframes that can help to
identify trends and spot potential divergences.
II - For more experienced users, this indicator also has many other valuable
features, such as Center of Gravity (CoG} smoothing, Kernel Estimate Crossovers, a
mirrored mode for cycle analysis, and more.
II - Note: Additional resources for learning/using the more advanced features of
this indicator are a work in progress, but in the meantime, I am happy to answer
any questions.
II ----------------
//
II
-------- Inputs --------
// 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
// Oscillator Settings
offset := 0
showosc = true
showOsc := showOsc
float f_length = 0.75
float f_smoothing = 0.45
float n_length = 1.0
float n_smoothing = 1.0
float s_length = 1.75
float s_smoothing = 2.5
II Divergence Detection
divThreshold = 30
sizePercent = 40
II Overbought/Oversold Zones (Reversal Zones)
showObOs = false
invertoboscolors = false
// Transparencies and Gradients
areaBackgroundTrans - 128.
areaForegroundTrans - 64.
lineBackgroundTrans = 2.6
l ineForegroundTrans - 2.
customTransparency = 30
maxStepsForGradient = 8
II 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
lineBackgroundTrans := lineBackgroundTrans * customTransparency
areaBackgroundTrans := areaBackgroundTrans * customTransparency
l ineForegroundTrans := lineForegroundTrans * customTransparency
areaForegroundTrans := areaForegroundTrans * customTransparency
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
l ineslowTrans := lineForegroundTrans
"Normal"=>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaForegroundTrans
lineNormalTrans := lineForegroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
"Fast" =>
areaFastTrans := areaForegroundTrans
lineFastTrans := lineForegroundTrans
areaNormalTrans := areaBackgroundTrans
l i neNormalTrans := lineBackgroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := lineBackgroundTrans
"None" =>
areaFastTrans := areaBackgroundTrans
lineFastTrans := lineBackgroundTrans
areaNormalTrans := areaBackgroundTrans
l i neNormalTrans := lineBackgroundTrans
areaSlowTrans := areaBackgroundTrans
lineSlowTrans := l i neBackgroundTrans
II---------------------------------
11
II
==== Colar Helper Functions =====
getPlotColor(signal, bullColor, bearColor) =>
signal>= 0 .0? bullColor : bearColor
getAreaColor(signal, useMomen t um, bullColor, bearColor) =>
if useMomentum
ta.ri s i ng(si gnal, 1)? bullColor : bearColor
else
signal>= 0.0? bullColor : bearColor
getColorGradientFromsteps( _source, _center, _steps , weakcolor, strongcolor) =>
var float _qt yAdvDec = 0.
var float _maxsteps = math .max{l, _steps)
bool _xup = ta .crossover(_source, _center)
bool _xDn = ta.crossunder( _source, _center)
float _chg = ta.change(_source)
bool _up = _chg> 0
bool _dn = _chg< 0
bool srcBul l = source> _center
bool srcBear - source< _cent er
_qtyAdvDec := _srcBull? _xup? 1 : _up? math .min( _maxsteps, _qtyAdvDec + 1}
dn? math .max{l, _qtyAdvDec - 1} : _qtyAdvDec : _srcBear? _xDn? 1 _dn?
math.min{_maxSteps, _qtyAdvDec + 1) : _up? math .max{l, _qtyAdvDec - 1}
_qtyAdvDec : _qtyAdvDec
color colorGradient = color.from_gradient(_qtyAdvDec, 1, _maxsteps, weakColor,
strongColor)
colorGradi ent
getColorGradient FromSource(series, _mi n, _max, weakColor, strongColor) =>
var float baseLineseri es = _min + (_max - _mi n) I 2
color colorGradient = series>= baseLineseries?
color.from_gradient(value=series, bo t tom_value=baseLineSeries, top_value=_max,
bo t tom_color=weakColor, top_color=st rongColor) : color.from_gradient(seri es,
_mi n,
bas eLi neseri es, strongcolor, weakcolor )
colorGradi ent
II --------------------------------
11
II
==== Main Helper Functions=====
normalizeDeriv(_src, _quadraticMeanlength) =>
float derivative = _src - _src[2]
quadrati cMean = math.sqrt(nz (math.sum(math.pow(derivati ve, 2),
_quadraticMeanLength) / _quadraticMeanLength))
derivative/quadraticMean
tanh(series float _src) =>
-1 + 2/{1 + math.exp( -2*_src))
dualPoleFilter(float _src, float _lookback) =>
float _omega= -99 * math.pi I (70 * _lookback)
float _alpha = math.exp(_omega)
float _beta= -math . pow{ _alpha, 2)
float _gamma= math.cos( _omega) * 2 * _alpha
float _delta = 1 - _gamma - beta
float _slidingAvg = 0.5 * {_src + nz{ _src[l], _src))
float _filter= na
_filter := (_delta*_slidingAvg) + _gamma*nz{_filter[l]) + _beta*nz(_filter[2])
filter
getOscillator(float src, float smoothingFrequency, int quadraticMeanLength) =>
nDeriv = normalizeDeriv(src, quadraticMeanLength)
hyperboli cTangent = tanh(nDeri v)
result= dualPoleFilter(hyperbolicTangent, smoothingFrequency)
II ---------------------------------
11
II
==== Oscillator Calculations====
II Fast oscillator + Mirror
offsetFast - offset
f _lookback - f_smoothing * osci llatorlookback
signalFast - getoscillator(src, f _lookback, quadrati cMeanLength)
seriesFast - f _length*signalFast+offsetFast
seriesFastMirror = useMirror? -seriesFast + 2*offsetFast : na
II Normal oscillator + Mirror
offsetNormal = 0
n_lookback = n_smoothing * oscillatorlookback
signalNormal = getOscillator(src, n_lookback, quadraticMeanLength)
seriesNormal = n_length *signalNormal+offsetNormal
seriesNormalMirror - useMirror? -seriesNormal + 2*offsetNormal : na
II Slow Oscillator + Mirror
offsetSlow = -offset
s_lookback - s_smoothing * osci llatorLookback
signalSlow - getOscillator(src, s_lookback, quadraticMeanLength)
seriesSlow - s_length*signalSlow+offsetSlow
seri esSlowMi rror = useMi rror? -seriesslow + 2*offsetSlow: na
II - - - - - - - - - - - - - - - - - - - - - ---- - - - - - - - - - - - -
11
II
==== Color Gradient Calculations ====
II Fast Color Gradients {Areas and Lines)
fastBaseColor = getPlotColor(si gnalFast, fas t Bulli shColor, fastBearishColor)
fastBaseColorinverse = getPlotColor(signalFast, fastBearishColor, fastBullishColor)
fastAreaGradientFromSource = getColorGradientFromSource(seriesFast, -1.+offsetFast,
l+offsetFast, color.new(fastBaseColor, areaFastTrans), fastBaseColor)
fastAreaGradientFromSteps = getColorGradientFromSteps(seriesFast, offset Fast,
maxStepsForGradient, color . new( f astBaseColor, areaFastTrans), fastBaseColor)
fastLineGradientFromsource = getColorGradientFromsource(seri esFast, - l
+offsetFast,
l+offsetFast, color.new(fastBaseColor, lineFastTrans), fastBaseColor)
fastLineGradientFromSteps = getColorGradientFromSteps(seriesFast, offsetFast,
maxStepsForGradient, color.new(fastBaseColor, lineFastTrans), fastBaseColor)
fastAreaGradient FromSourceinverse = getColorGradientFromSource(seri esFast, -
1.+offsetFast, l+offsetFast, color .new(fastBaseColorinverse, areaFastTrans),
fastBaseColorinverse)
fastAreaGradient FromStepsi nverse = getColorGradientFromsteps(seriesFast,
offsetFast, maxStepsForGradient, color.new(fastBaseColorinverse, areaFastTrans),
fastBaseColorinverse)
II Normal Color Gradients (Areas and Lines)
normalBaseColor = getPlotColor(signalNormal, normalBullishColor,
normalBearishColor)
normalBasecolori nverse = getPlotColor(signalNormal, normalBearishColor,
normalBullishColor)
normalAreaGradientFromSource = getColorGradientFromSource(seriesNormal, -
1. +offsetNormal, 1 .+offsetNormal, color . new(normalBasecolor, areaNormalTrans),
normalBaseColor)
normalAreaGradientFromSteps = getColorGradientFromSteps(seriesNormal, offsetNormal,
maxstepsForGradi ent, color.new(normalBaseColor, areaNormalTrans), normalBaseColor)
normalLineGradient FromSource = getColorGradi entFromSource(seriesNormal, -
l +offsetNormal, l +offsetNormal, color . new(normalBaseColor, lineNormalTrans),
normalBaseColor)
normalLineGradientFromSteps = getColorGradi entFromSteps(seriesNormal,
offsetNormal,
maxStepsForGradient, color.new(normalBaseColor, lineNormalTrans), normalBaseColor)
normalAreaGradientFromsourceinverse = getColorGradientFromsource(seriesNormal, -
1. +offsetNormal, 1 .+offsetNormal, color . new(normalBasecolori nverse,
areaNormalTrans), normalBaseColorinverse)
normalAreaGradientFromStepsinverse = getColorGradi entFromSteps(seriesNormal,
offsetNormal, maxstepsForGradient, color.new(normalBasecolorinverse,
areaNorma l Trans), nor ma lBaseCo lorinverse)
II Slow Color Gradi ents (Areas and Lines)
slowBasecolor = getPlotColor(signalSlow, slowBullishColor, slowBearishColor)
slowBaseColorinverse = getPlotColor(signalSlow, slowBearishColor, s l owBul l
ishColor)
slowAreaGradientFromSource = getColorGradientFromSource(seriesSlow, -
1.75+offsetSlow, 1.75+offsetSlow, color.new(slowBaseColor, areaSlowTrans),
slowBaseColor)
slowAreaGradientFromSteps = getColorGradientFromSteps(seriesSlow, offsetSlow,
maxStepsForGradient, color . new(slowBasecolor, areaSlowTrans), slowBasecolor)
slowLineGradient FromSource = getColorGradi entFromSource(seriesSlow, -
1.75+offsetSlow, 1.75+offsetSlow, color . new(sl owBaseColor, lineSlowTrans),
slowBasecolor)
slowLineGradientFromSteps = getColorGradientFromSteps(seriesSlow, offsetSlow,
maxStepsForGradient, color . new(slowBaseColor, l i neSlowTrans), slowBaseColor)
slowAreaGradientFromsourceinverse = getColorGradi entFromsource(seriesSlow, -
1.75+offsetSlow, 1 . 75+offsetslow, color.new(slowBasecolor i nverse,
areaslowTrans),
slowBaseColorinverse)
slowAreaGradientFromStepsinverse = getColorGradientFromSteps(seriesSlow,
offsetslow, maxstepsForGradient, color .new(slowBasecolorinverse, areaslowTrans),
slowBaseColorinverse)
II -----------------------------------------
11
II
==== Plot Parameters and Logic Gates====
II Speed Booleans
isSlow = speedToEmphasize == "Slow"
isNormal = speedToEmphasize == "Normal"
isFast = speedToEmphasize == "Fast"
II 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
ser iesslowMirrorcolor = useMirror? seriesslowcolor : na
seriesNormalMirrorColor = useMirror? seriesNormalColor : na
seriesFastMirrorColor - useMirror? seriesFastColor : na
II series Line Widths
seriesSlowWidth = isSlow? emphasisWidth : 1
seriesNormalWidth = isNormal? emphasisWidth : 1
seriesFastWidth = isFast? emphasisWidth : 1
seriesSlowMirrorWidth = useMirror? seriesSlowWidth : na
seriesNormalMirrorWidth = useMirror? seriesNormalWidth : na
seriesFastMirrorWidth = useMirror? seriesFastWidth : na
II Speed Related Switches
seriesEmphasis = switch
isFast => seriesFast
isNormal => seriesNormal
isSlow => seriesslow
=> na
colorLineEmphasis = switch
isFast => fastLineGradientFromsource
isNormal => normalLineGradientFromSource
isSlow => slowLineGradientFromSource
=> na
colorAreaEmphasis = switch
isFast => fastAreaGradientFromSource
isNormal => normalAreaGradientFromSource
isSlow => slowAreaGradientFromSource
=> na
II 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)
II Last Crossover Values
lastBearishCrossValue - ta.valuewhen(condition=bearishCross, source=seriesNormal,
occurrence=l)
lastBullishCrossValue - ta.valuewhen(condition=bullishCross, source=seriesNormal,
occurrence=l)
II Trigger Wave Size Comparison
triggerwaveFactor = sizePercentl100
isSmallerBearishCross - bearishcross and seriesNormal < lastBearishCrossValue *
triggerWaveFactor
isSmallerBullishCross = bullishCross and seriesNormal > lastBullishCrossValue *
triggerwaveFactor
II---------------------------
11
II
==== Kernel Estimators====
II The following kernel estimators are based on the Gaussian Kernel.
II They are used for:
II (1) Confirming directional changes in the slow oscillator (i.e. a type of
trend filter)
II (2) Visualizing directional changes as a dynamic ribbon (i.e. an additional
oscillator that can crossover with the user specified oscillator of interest)
II (3) Visualizing transient directional changes while in the midst of a larger
uptrend or downtrend (i.e. via color changes on t he ribbon)
II Gaussian Kernel with a lookback of 6 bars, starting on bar 6 of the chart
(medium fit)
yhat0 = kernels.gaussian(seriesEmphasis, 6, 6)
II Gaussian Kernel with a lookback of 3 bars, starting on bar 2 of the chart (tight
fit)
yhatl = kernels.gaussian(seriesEmphasis, 3, 2)
II Trend Assessment based on the relative position of the medium fit kernel to the
slow oscillator
isBearishKernelTrend - yhat0 < seriesSlow
isBullishKernelTrend - yhat0 > seriesslow
II Divergence Signals
isBearishDivZone - ta.barssince(bearishcross[l]) < divThreshold
isBullishDivZone = ta.barssince(bullishCross[l]) < divThreshold
II Crossover Detection
isBearishTriggerWave - isSmallerBearishCross and isBearishDivZone and
isBearishKernelTrend
isBullishTriggerwave - isSmallerBullishcross and isBullishDivZone and
isBullishKernelTrend
II-----------------------
11 ==== Plots & Fills====
var position= 0
length := atrlength
minMult - math.max(sensitivity -4, 1)
maxMult - math .min(sensitivity, 26)
if (autopilotMode == "Short Term")
minMult: =1
maxMult := 4
i f (autopi lotMode
minMult := 5
maxMult := 10
i f (autopilotMode
minMult :=8
maxMult :=13
float step - .5
//Trigger error
i f minMult > maxMult
'Mid Term')
' Long-Term')
runtime .error('Minimum factor is greater than maximum factor in the range')
float perfAlpha = 10
fromcluster = 'Best'
//Optimization
maxlter - 250
maxData = 2500
//Style
bearcss - color.red
bullCss - color.teal
amaBearCss - color.new(color.red, 50)
amaBullCss - color.new(color.teal, 50)
showGradient = true
//Dashboard
showDash - true
I I dashboard Location = input.string ( 'Top Right' , ' Location' , options -
[ 'Top
Right', 'Bottom Right', 'Bottom Left'], group = 'Dashboard')
textSize = 'Small'
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
//UDT's
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
type supertrend
float upper= hl2
float lower = hl2
float output
float perf = 0
float factor
int trend = 0
type vector
array<float> out
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
//Supertrend
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
var holder= array . new<supertrend>{0)
var factors= array.new<float>{0)
//Populate supertrend type array
if barstate.isfirst
for i = 0 to int((maxMult - minMult) / step)
factors.push(minMult + i * step)
holder.push(supertrend.new())
atr = ta.atr(length)
//Compute Supertrend for multiple factors
k = 0
for factor in factors
get_spt = holder . get(k)
up = hl2 + atr * factor
dn = hl2 - atr * factor
get_spt.trend := close> get_spt.upper? 1 : close< get_spt.lower? 0 :
get_spt.trend
get_spt . upper := close[l] < get_spt . upper? math.min(up, get_spt.upper) up
get_spt.lower := close[l] > get_spt . lower? math .max(dn, get_spt.lower) dn
diff = nz(math.sign(close[l] - get_spt.output))
get_spt.perf += 2/(perfAlpha+l) * (nz(close - close[l]) * diff - get_spt.perf)
get_spt.output := get_spt.trend == 1? get_spt.lower : get_spt.upper
get_spt.factor := factor
k += 1
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
//K-means clustering
factor_array = array.new<float>(0)
data = array.new<float>(0)
//Populate data arrays
if last_bar_index - bar_index <= maxData
for element in holder
data .push(element.perf)
factor_array.push(element.factor)
//Intitalize centroids using quartiles
centroids = array .new<float>(0)
centroids.push(data.percentile_linear_interpolation(25))
centroids.push(data.percentile_linear_interpolation(50))
centroids.push(data.percentile_linear_interpolation(75))
//Intialize clusters
var array<vector> factors_c l usters = na
var array<vector> perfclusters = na
if last_bar_index - bar_index <= maxData
for _ = 0 to maxiter
factors_clusters := array . from(vector.new(array . new<float>(0)),
vector.new(array.new<float>(0)), vector.new(array.new<float>(0)))
perfclusters := array.from(vector.new(array.new<float>(0)),
vector.new(array .new<float>(0)), vector.new(array.new<float>(0)))
//Assign value to cluster
1 = 0
for value in data
dist = array .new<float>(0)
for centroid in centroids
dist.push(math.abs(value - centroid))
idx = dist.indexof(dist.min())
perfclusters.get(idx}.out.push(value)
factors_clusters.get(idx).out.push(factor_array.get(i))
i += 1
//Update centroids
new_centroids = array.new<float>(0}
for cluster_ in perfclusters
new_centroids.push(cluster_.out.avg())
//Test if centroid changed
if new_centroids.get(0} == centroids.get(0} and new_centroids.get(l)
centroids.get(l} and new_centroids.get(2} == centroids.get(2}
break
centroids := new_centroids
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - }
//Signals and trailing stop
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
//Get associated supertrend
var float target_factor = na
var float perf_idx = na
var float perf_ama = na
var from= switch fromCluster
'Best' => 2
'Average' => 1
'Worst' => 0
//Performance i ndex denominator
den = ta.ema(math.abs(close - close[l]}, int(perfAlpha))
if not na(perfclusters)
//Get average factors within target cluster
target_factor := nz(factors_clusters.get(from).out.avg(}, target_factor)
//Get performance index of target cluster
perf_idx := math.max(nz(perfclusters.get(from).out.avg(}), 0) / den
//Get new supertrend
var upper - hl2
var lower = hl2
var os = 0
up= hl2 + atr * target_factor
dn = hl2 - atr * target_factor
upper := close[l) <upper? math.min(up, upper) : up
lower := close[l] >lower? math.max(dn, lower) : dn
os :=close> upper? 1 : close< lower? 0 : os
ts = os? lower : upper
//Get trailing stop adaptive MA
if na(ts[l)} and not na(ts)
perf_ama := ts
else
perf_ama += perf_idx * (ts - perf_ama)
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -}
//Dashboard
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
I I - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {
css = os? bullCss : bearcss
plot(showTrailingStoploss? ts
editable = false)
na, 'Trailing Stop', os ! = os [1] ? na
plot ( showMovingAverage? perf _ama: na, 'Trailing Stop AMA',
ta .cross(close, perf_ama)? na
: close> perf_ama? amaBullCss: amaBearCss, editable = false)
//Candle coloring
css,
//barcolor(showGradient? color .from_gradient(perf_idx, 0, 1, color . new(css, 80},
css) : na)
//Signals
i f showSignals
if os > os[l) and (s i gnalPresets != "Smart Trail [Fi lter]" or
smartTrailDirection == 'long') and (signalPresets != "Trend Tracer [Fi lter]" or
trendTracerDirection==#02ff65} and (signalPresets != "Trend Strength [Filter)" or
trendStrengthMetri c >= 25) and (signalPresets != "Trend Catcher [Filter)" or
newTrendCatcherColor == #02ff65} and (signalPresets != "Neo Cloud [Filter]" or
int(lastNeo) >= last5Neo)
int s i gnalStrength = int(perf_idx*10} < 2? 1 : i nt(perf_idx*10} < 4? 2
int(perf_idx*10} < 5? 3 : 4
label.new(n, low-ta.atr{30}/2, signalClassifier?
str. tostri ng(signalStrengt h) : ema50 > ema200 ? "11+" : "11 "
, color = bullCss
, style = label.style_label_up
, textcolor = color.white
, size = s i ze.small)
position := 1
if os < os[l] 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)
int signalStrength = int(perf_idx*10} < 2? 1 : int(perf_idx*10} < 4? 2
int(perf_i dx*10} < 5? 3 : 4
label.new(n, high+ta.atr{30}/2, signalClassifier?
str.tostring(signalStrength} : ema50 < ema200? "i +" : "i"
, color = bearcss
, style = label .style_label_down
, textcolor = color.white
, size = size.small)
position := -1
II -----------------------
// Signal Plots
//plot(position 1 and bearishCross? high+5 na, title="Bearish Cross",
style=plot.style_cross, linewidth=2, color=c_bearish, offset =-1}
//plot(position == -1 and bearishCross? high+5 : na, title="Bearish Cross",
style=plot.style_circles, linewidth=2, color=c_bearish, offset=-1)
//plot(position == 1 and isBearishTriggerWave? hi gh+5 : na, title="Bearish Trigger
Cross", style=plot.style_cross, linewidth=3, color=c_beari sh, offset=- 1}
//plot(position == -1 and isBearishTriggerWave? high+5 : na, title="Bearish
Trigger Cross", style=plot.style_circles, linewidt h=3, color=c_bearish, offset= -
1)
plotchar(bearishCross and position== 1, "Long", "?", location.abovebar, col or =
#4774f5, size = size.tiny, editable = false)
//plotchar(bearishcross and position == -1, "Long", "i", location.abovebar, color -
c_bearish, size= size.tiny)
plotchar(isBearishTriggerWave and position == 1, "Long", "?", location.abovebar,
color=#4774f5, size= size.tiny, editable = false)
/ /p lotchar ( is Bear ishTr iggerwave and position == -1, "Long", " i ", location.
above bar,
color=c_bearish, size = size.small)
//plot(position == 1 and bullishCross? low -5 : na, title="Bullish Cross", style=
plot.style_circles, linewi dth=2, color=c_bullish, offset=-1}
//plot(position == -1 and bullishCross? low -5 : na, title="Bull ish Cross", style=
plot.style_cross, linewidth=2, color=c_bullish, offset=-1}
//plot(posi tion == 1 and i sBulli shTri ggerwave? low -5 : na, t i tle="Bulli sh
Trigger
Cross", style=plot . style_circles, linewidth=3, color=c_bullish, offset= -1)
//plot(position == -1 and isBullishTriggerWave? l ow -5 : na, title="Bull ish
Trigger Cross", style=plot.style_cross, linewidth=3, color=c_bullish, offset=-1)
//plotchar(bullishCross and position == 1 "Long" "A" locat ion belowbar color - I I
I • I
c_bulli sh, size= size.ti ny)
plotchar(bullishcross and position == -1, "Long", "?", location .belowbar, color =
#ff7322, size= size.tiny, editable= false)
//plotchar( i sBul l i shTriggerwave and position == 1, "Long", "A", locat ion.
belowbar,
color=c_bullish, size= size.small)
plotchar(isBullishTriggerwave and position == -1, "Long", "?", location.belowbar,
color=#ff7322, size = size . tiny, editable = f alse)
// Shit
atrMultiplier = input(2, title="ATR Multiplier")
boxHeighti nAtr = atrMultiplier * ta .atr{10}
// Box TP 1
[lowb, midb, highb] = LAF.getTPSLBoxes{6.0}
i f (takeProfi tBoxes == 'On')
tplbox = box.new(left=bar_index + 1, top=close + midb, right=bar_index + 18,
bottom=close + lowb, border_color=color.new{ #3666f5, 0), border_width=2,
border_style=line.style_soli d, bgcolor=color.new( #3666f5, 55), text="TP/SL 1
+ str . tostring(close), text_size=size .normal, text_color=color . new{ #3666f5,
0}}
bottom_tpl = box.get_bottom(tplbox)
box.delete(tplbox[l]}
// Box TP 2
tp2box = box . new(left=bar_index + 1, top=close+highb, right=bar_index + 18,
bo t tom=close+midb, border_color=color.new{ #3666f5, 0), border_wi dth=2,
border_style=line.st yle_solid, bgcolor=color.new{ #3666f5, 65) , text="TP/SL 2 :
+ str.tostring(close), 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_t p2, right=bar_index + 200,
bottom=bottom_tpl, 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[l])
// SL Box
slBox = box . new(left=bar_index + 3, top=close-lowb, right=bar_index + 18,
bottom=close-midb, border_color=color.new(color . red, 0}, border_width=2,
border_style=line.style_solid, bgcolor=color.new(color.red, 66}, text="TP/SL 2
"+ str.tostring(close), text_size=size.normal, text_color=color .new(color.red, 0))
bottom_sl = box.get_top(slBox)
box.delete(slBox[l])
// SL2 Box
sl2Box = box . new(left=bar_index + 3, top=close-midb, right=bar_index + 18,
bottom=close-highb, border_color=color.new(color . red, 0), border_width=2,
border_style=line.style_solid, bgcolor=color.new(color.red, 65), text="TP/SL 1
" + str.tostring(close}, 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 +
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[l]}
II Line tp Bottom
var line tpb = na
i sLastBar = barstate. i slast
if (isLastBar)
200 I
tpb := line.new(na, bottom_tpl, na, bottom_tpl, color=color.new{#3666f5,
0}, width=2, style=line.style_dashed)
line.set_xyl{tpb, bar_index[50], bottom_tpl)
line.set_xy2{tpb, bar_index + 200, bottom_tpl}
line.delete(tpb[l]}
// Line tp top
var line tp2Line = na
if (isLastBar)
tp2Line := l i ne.new(na, top_tp2, na, top_tp2, color=color.new{ #3666f5, 0},
width=2, style=line.style_dashed}
line.set_xy1{tp2Line, bar_index[50], top_tp2)
line.set_xy2{tp2Line, bar_index + 200, top_tp2)
line.delete(tp2Line[1]}
// Line SL
var line slLine - na
i f (isLastBar)
slLine := line.new(na, bottom_sl, na, bottom_sl, color=color.new(color.red,
0), width=2, style=line.style_dashed}
line.set_xyl{slLine, bar_index[50], bottom_sl)
line.set_xy2{slLine, bar_index + 400, bottom_sl)
l i ne.delete(slLi ne[l])
// 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)
line.set_xyl{sl2Line, bar_index[50], bottom_sl2)
line.set_xy2{sl2Line, bar_index + 200, bottom_sl2)
l i ne.delet e(sl2Li ne [1])

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy