You are on page 1of 18

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © TintinTrading

//@version=5
indicator('frala5 v2.1', overlay=true)

////////////
timeframe_period=input.timeframe('15','Timeframe')

_pos = input.string("Top Right", title="Label Position", options=["Top Left", "Top


Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom
Left", "Bottom Center", "Bottom Right"], group="Layout")

rsi_len = input.int(50, title = "RSI Lenght", group = "RSI")


rsi_source=input.source(close, title = "RSI source", group = "RSI")

tooltip_ma = 'A Moving Average is a good way to gauge momentum as well as to


confirm trends, and define areas of support and resistance'
group_ma = 'Trend : Moving Average Settings'
maType = input.string("EMA", "Moving Average : Type", options=["SMA", "EMA",
"RMA", "WMA", "VWMA"], group=group_ma)
fastLength = input.int(10, title='Moving Average : Fast Length', minval=2,
maxval=50, group=group_ma)
slowLength = input.int(134, title='Moving Average : Slow Length', minval=50,
group=group_ma)
source=close

// ADX Params
adx_smooth = input.int( 14, title = "ADX Smoothing", group = 'ADX')
adx_dilen = input.int( 14, title = "ADX DI Length", group = 'ADX')
adx_level = input.float(20, title = "ADX Level", group = 'ADX')

// Discord Webhook Part


import wlhm/DiscordWebhookFunction/1 as ds
import RicardoSantos/FunctionDatestring/3 as ts

discordGroup = "Discord Webhook Settings"

_username = input.string('Tradingview Alerts', title = "Webhook


Username",tooltip = "You can override the webhook username here or you can leave it
empty", group = discordGroup)
_avatarImgUrl = input.string('https://www.tradingview.com/static/images/logo-
151x151.png', title = "Use Avatar", tooltip = "Enable Avatar URL, write
your URL link. Leave it empty to disable.", group = discordGroup)
_authorIconUrl =
input.string('https://user-images.githubusercontent.com/5462382/34194562-e3b467fe-
e51e-11e7-9b91-1759cf466ea9.png',title = "Author block icon URL Link", tooltip =
" Webhook's embed author icon by image URL, Leave it empty to disable.",group =
discordGroup)
_timestamp = input.bool(true,title = "Embed's timestamp", tooltip = "Allows
you to add timestamp to embed. Time stores as String in the next format: 'YYYY-MM-
DDTHH:MM:SS.MSSZ'.",group = discordGroup)

trade_url = input.string("https://www.tradingview.com/chart/IYSXopAZ/", title =


"TV chart link", group = discordGroup)

_bodyUrl = input.string('',title = 'bodyUrl',group = discordGroup)


_authorUrl = input.string('',title = 'authorUrl',group = discordGroup)
_footerText = input.string('',title = 'footerText',group = discordGroup)
_footerIconUrl = input.string('',title = 'footerIconUrl',group = discordGroup)
_imageUrl = input.string('',title = 'imageUrl',group = discordGroup)
_thumbImgUrl = input.string('',title = 'thumbImgUrl',group = discordGroup)

// }

/////////////
// SYMBOLS //
// {
u01 = input.bool(true, title = "", group = 'Symbols', inline = 's01')
u02 = input.bool(true, title = "", group = 'Symbols', inline = 's02')
u03 = input.bool(true, title = "", group = 'Symbols', inline = 's03')
u04 = input.bool(true, title = "", group = 'Symbols', inline = 's04')
u05 = input.bool(true, title = "", group = 'Symbols', inline = 's05')
u06 = input.bool(true, title = "", group = 'Symbols', inline = 's06')
u07 = input.bool(true, title = "", group = 'Symbols', inline = 's07')
u08 = input.bool(true, title = "", group = 'Symbols', inline = 's08')
u09 = input.bool(true, title = "", group = 'Symbols', inline = 's09')
u10 = input.bool(true, title = "", group = 'Symbols', inline = 's10')
u11 = input.bool(true, title = "", group = 'Symbols', inline = 's11')
u12 = input.bool(true, title = "", group = 'Symbols', inline = 's12')
u13 = input.bool(true, title = "", group = 'Symbols', inline = 's13')
u14 = input.bool(true, title = "", group = 'Symbols', inline = 's14')
u15 = input.bool(true, title = "", group = 'Symbols', inline = 's15')
u16 = input.bool(true, title = "", group = 'Symbols', inline = 's16')
u17 = input.bool(true, title = "", group = 'Symbols', inline = 's17')
u18 = input.bool(true, title = "", group = 'Symbols', inline = 's18')
u19 = input.bool(true, title = "", group = 'Symbols', inline = 's19')
u20 = input.bool(true, title = "", group = 'Symbols', inline = 's20')
u21 = input.bool(true, title = "", group = 'Symbols', inline = 's21')
u22 = input.bool(true, title = "", group = 'Symbols', inline = 's22')
u23 = input.bool(true, title = "", group = 'Symbols', inline = 's23')
u24 = input.bool(true, title = "", group = 'Symbols', inline = 's24')
u25 = input.bool(true, title = "", group = 'Symbols', inline = 's25')
u26 = input.bool(true, title = "", group = 'Symbols', inline = 's26')
u27 = input.bool(true, title = "", group = 'Symbols', inline = 's27')
u28 = input.bool(true, title = "", group = 'Symbols', inline = 's28')
u29 = input.bool(true, title = "", group = 'Symbols', inline = 's29')
u30 = input.bool(true, title = "", group = 'Symbols', inline = 's30')
u31 = input.bool(true, title = "", group = 'Symbols', inline = 's31')
u32 = input.bool(true, title = "", group = 'Symbols', inline = 's32')
u33 = input.bool(true, title = "", group = 'Symbols', inline = 's33')
u34 = input.bool(true, title = "", group = 'Symbols', inline = 's34')
u35 = input.bool(true, title = "", group = 'Symbols', inline = 's35')
u36 = input.bool(false, title = "", group = 'Symbols', inline = 's36')
u37 = input.bool(false, title = "", group = 'Symbols', inline = 's37')
u38 = input.bool(false, title = "", group = 'Symbols', inline = 's38')
u39 = input.bool(false, title = "", group = 'Symbols', inline = 's39')
u40 = input.bool(false, title = "", group = 'Symbols', inline = 's40')

s01 = input.symbol('SPY', group = 'Symbols', inline = 's01')


s02 = input.symbol('VIX', group = 'Symbols', inline = 's02')
s03 = input.symbol('FNGU', group = 'Symbols', inline = 's03')
s04 = input.symbol('GOOG', group = 'Symbols', inline = 's04')
s05 = input.symbol('AMZN', group = 'Symbols', inline = 's05')
s06 = input.symbol('NVDA', group = 'Symbols', inline = 's06')
s07 = input.symbol('TSLA', group = 'Symbols', inline = 's07')
s08 = input.symbol('META', group = 'Symbols', inline = 's08')
s09 = input.symbol('AMD', group = 'Symbols', inline = 's09')
s10 = input.symbol('MSFT', group = 'Symbols', inline = 's10')
s11 = input.symbol('AAPL', group = 'Symbols', inline = 's11')
s12 = input.symbol('SNOW', group = 'Symbols', inline = 's12')
s13 = input.symbol('DDOG', group = 'Symbols', inline = 's13')
s14 = input.symbol('CRM', group = 'Symbols', inline = 's14')
s15 = input.symbol('ADBE', group = 'Symbols', inline = 's15')
s16 = input.symbol('ORCL', group = 'Symbols', inline = 's16')
s17 = input.symbol('PANW', group = 'Symbols', inline = 's17')
s18 = input.symbol('ZS', group = 'Symbols', inline = 's18')
s19 = input.symbol('ENPH', group = 'Symbols', inline = 's19')
s20 = input.symbol('ROKU', group = 'Symbols', inline = 's20')
s21 = input.symbol('ABNB', group = 'Symbols', inline = 's21')
s22 = input.symbol('AMZN', group = 'Symbols', inline = 's22')
s23 = input.symbol('CVNA', group = 'Symbols', inline = 's23')
s24 = input.symbol('HD', group = 'Symbols', inline = 's24')
s25 = input.symbol('LEN', group = 'Symbols', inline = 's25')
s26 = input.symbol('LOW', group = 'Symbols', inline = 's26')
s27 = input.symbol('MCD', group = 'Symbols', inline = 's27')
s28 = input.symbol('VLO', group = 'Symbols', inline = 's28')
s29 = input.symbol('MPC', group = 'Symbols', inline = 's29')
s30 = input.symbol('BA', group = 'Symbols', inline = 's30')
s31 = input.symbol('CAT', group = 'Symbols', inline = 's31')
s32 = input.symbol('GS', group = 'Symbols', inline = 's32')
s33 = input.symbol('V', group = 'Symbols', inline = 's33')
s34 = input.symbol('COIN', group = 'Symbols', inline = 's34')
s35 = input.symbol('MRNA', group = 'Symbols', inline = 's35')
s36 = input.symbol('LLY', group = 'Symbols', inline = 's36')
s37 = input.symbol('UNH', group = 'Symbols', inline = 's37')
s38 = input.symbol('DHR', group = 'Symbols', inline = 's38')
s39 = input.symbol('AMGN', group = 'Symbols', inline = 's39')
s40 = input.symbol('EXPE', group = 'Symbols', inline = 's40')
// }
//////////////////

// CALCULATIONS //
// {
// Get only symbol

f_getPosition(_pos) =>
ret = position.top_left
if _pos == "Top Center"
ret := position.top_center
if _pos == "Top Right"
ret := position.top_right
if _pos == "Middle Left"
ret := position.middle_left
if _pos == "Middle Center"
ret := position.middle_center
if _pos == "Middle Right"
ret := position.middle_right
if _pos == "Bottom Left"
ret := position.bottom_left
if _pos == "Bottom Center"
ret := position.bottom_center
if _pos == "Bottom Right"
ret := position.bottom_right
ret

only_symbol(s) =>
array.get(str.split(s, ":"), 1)

Calc10x() =>
len = input.int(14, "Directional Length")
ADX_T = input.int(20, "ADX Length")

//DMI CALCULATIONS - Tradingview Built-In DMI Indicator


up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / trur)
minus = fixnan(100 * ta.rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum),
len)

//10X CALCULATIONS
D_Up = (plus > minus) and (adx > ADX_T)
D_Down = (minus > plus) and (adx > ADX_T)
Neutral = (adx < ADX_T)

D_Up_Color = color.new(color.green, 0)
D_Down_Color = color.new(color.red, 0)
Neutral_Color = color.new(color.yellow, 0)
MTF10_Color = Neutral ? Neutral_Color : D_Up ? D_Up_Color : D_Down ?
D_Down_Color : na

getVWAP(newSession) =>
p = hlc3 * volume
p := newSession ? hlc3 * volume : nz(p[1]) + hlc3 * volume

vol = 0.0
vol := newSession ? volume : nz(vol[1]) + volume

v = p / vol

// Incremental weighted standard deviation (rolling)


// http://people.ds.cam.ac.uk/fanf2/hermes/doc/antiforgery/stats.pdf (part 5)
// x[i] = hlc3[i], w[i] = volume[i], u[i] - v[i]

Sn = 0.0
Sn := newSession ? 0 : nz(Sn[1]) + volume * (hlc3 - nz(v[1])) * (hlc3 - v)
std = math.sqrt(Sn / vol)

[v, std]

// ADX
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)

plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)


minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)

truerange = ta.rma(ta.tr, len)

plus = fixnan(100 * ta.rma(plusDM, len) / truerange)


minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]

adx_func(dilen, adxlen) =>


[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

// CHANGE
change_func()=>

var float openPrice = na


var float percentChange = na

// Check if the current bar is the first bar of the session


isFirstBar = ta.change(time("D")) > 0

// Update open price if it's the first bar


if isFirstBar
openPrice := open

// Calculate the percentage change from the open


if not isFirstBar
percentChange := (close / openPrice - 1) * 100

change_percentage =percentChange

openPercentage=math.round(change_percentage ,2)

//------------------------------------------------------------------------------
// Trend : Moving Averagres
ma(_source, _length, _type) =>
switch _type
"SMA" => ta.sma (_source, _length)
"EMA" => ta.ema (_source, _length)
"RMA" => ta.rma (_source, _length)
"WMA" => ta.wma (_source, _length)
"VWMA" => ta.vwma(_source, _length)

screener_func() =>

cl = change_func()

// RSI
rsi_ = ta.rsi(rsi_source,rsi_len)
maFast = ma(source, fastLength, maType)
maSlow = ma(source, slowLength, maType)

maFastDaily = ma(source, fastLength, maType)


maSlowDaily = ma(source, slowLength, maType)

newSessionD = ta.change(time("D"))
newSessionY = ta.change(time("12M"))

[vD, stdevD] = getVWAP(newSessionD)


//[vY, stdevY] = getVWAP(newSessionY)
color10x = Calc10x()
adx = adx_func(adx_dilen, adx_smooth)
chan = ((close - vD) / vD) * 100
[cl, rsi_, maFastDaily, maSlowDaily, chan, adx,close, chan]

// Security call
[cl01, rsi01, tsi01, adx01, sup01, suy01,cls01, col1] = request.security(s01,
timeframe_period, screener_func())
[cl02, rsi02, tsi02, adx02, sup02, suy02,cls02, col2] = request.security(s02,
timeframe_period, screener_func())
[cl03, rsi03, tsi03, adx03, sup03, suy03,cls03, col3] = request.security(s03,
timeframe_period, screener_func())
[cl04, rsi04, tsi04, adx04, sup04, suy04,cls04, col4] = request.security(s04,
timeframe_period, screener_func())
[cl05, rsi05, tsi05, adx05, sup05, suy05,cls05, col5] = request.security(s05,
timeframe_period, screener_func())
[cl06, rsi06, tsi06, adx06, sup06, suy06,cls06, col6] = request.security(s06,
timeframe_period, screener_func())
[cl07, rsi07, tsi07, adx07, sup07, suy07,cls07, col7] = request.security(s07,
timeframe_period, screener_func())
[cl08, rsi08, tsi08, adx08, sup08, suy08,cls08, col8] = request.security(s08,
timeframe_period, screener_func())
[cl09, rsi09, tsi09, adx09, sup09, suy09,cls09, col9] = request.security(s09,
timeframe_period, screener_func())
[cl10, rsi10, tsi10, adx10, sup10, suy10,cls10, col10] = request.security(s10,
timeframe_period, screener_func())
[cl11, rsi11, tsi11, adx11, sup11, suy11,cls11, col11] = request.security(s11,
timeframe_period, screener_func())
[cl12, rsi12, tsi12, adx12, sup12, suy12,cls12, col12] = request.security(s12,
timeframe_period, screener_func())
[cl13, rsi13, tsi13, adx13, sup13, suy13,cls13, col13] = request.security(s13,
timeframe_period, screener_func())
[cl14, rsi14, tsi14, adx14, sup14, suy14,cls14, col14] = request.security(s14,
timeframe_period, screener_func())
[cl15, rsi15, tsi15, adx15, sup15, suy15,cls15, col15] = request.security(s15,
timeframe_period, screener_func())
[cl16, rsi16, tsi16, adx16, sup16, suy16,cls16, col16] = request.security(s16,
timeframe_period, screener_func())
[cl17, rsi17, tsi17, adx17, sup17, suy17,cls17, col17] = request.security(s17,
timeframe_period, screener_func())
[cl18, rsi18, tsi18, adx18, sup18, suy18,cls18, col18] = request.security(s18,
timeframe_period, screener_func())
[cl19, rsi19, tsi19, adx19, sup19, suy19,cls19, col19] = request.security(s19,
timeframe_period, screener_func())
[cl20, rsi20, tsi20, adx20, sup20, suy20,cls20, col20] = request.security(s20,
timeframe_period, screener_func())
[cl21, rsi21, tsi21, adx21, sup21, suy21,cls21, col21] = request.security(s21,
timeframe_period, screener_func())
[cl22, rsi22, tsi22, adx22, sup22, suy22,cls22, col22] = request.security(s22,
timeframe_period, screener_func())
[cl23, rsi23, tsi23, adx23, sup23, suy23,cls23, col23] = request.security(s23,
timeframe_period, screener_func())
[cl24, rsi24, tsi24, adx24, sup24, suy24,cls24, col24] = request.security(s24,
timeframe_period, screener_func())
[cl25, rsi25, tsi25, adx25, sup25, suy25,cls25, col25] = request.security(s25,
timeframe_period, screener_func())
[cl26, rsi26, tsi26, adx26, sup26, suy26,cls26, col26] = request.security(s26,
timeframe_period, screener_func())
[cl27, rsi27, tsi27, adx27, sup27, suy27,cls27, col27] = request.security(s27,
timeframe_period, screener_func())
[cl28, rsi28, tsi28, adx28, sup28, suy28,cls28, col28] = request.security(s28,
timeframe_period, screener_func())
[cl29, rsi29, tsi29, adx29, sup29, suy29,cls29, col29] = request.security(s29,
timeframe_period, screener_func())
[cl30, rsi30, tsi30, adx30, sup30, suy30,cls30, col30] = request.security(s30,
timeframe_period, screener_func())
[cl31, rsi31, tsi31, adx31, sup31, suy31,cls31, col31] = request.security(s31,
timeframe_period, screener_func())
[cl32, rsi32, tsi32, adx32, sup32, suy32,cls32, col32] = request.security(s32,
timeframe_period, screener_func())
[cl33, rsi33, tsi33, adx33, sup33, suy33,cls33, col33] = request.security(s33,
timeframe_period, screener_func())
[cl34, rsi34, tsi34, adx34, sup34, suy34,cls34, col34] = request.security(s34,
timeframe_period, screener_func())
[cl35, rsi35, tsi35, adx35, sup35, suy35,cls35, col35] = request.security(s35,
timeframe_period, screener_func())
[cl36, rsi36, tsi36, adx36, sup36, suy36,cls36, col36] = request.security(s36,
timeframe_period, screener_func())
[cl37, rsi37, tsi37, adx37, sup37, suy37,cls37, col37] = request.security(s37,
timeframe_period, screener_func())
//[cl38, rsi38, tsi38, adx38, sup38, suy38,cls38] = request.security(s38,
timeframe_period, screener_func())
//[cl39, rsi39, tsi39, adx39, sup39, suy39,cls39] = request.security(s39,
timeframe_period, screener_func())
//[cl40, rsi40, tsi40, adx40, sup40, suy40,cls40] = request.security(s40,
timeframe_period, screener_func())
//cls40// },suy40
////////////

// ARRAYS //
// {
s_arr = array.new_string(0)
u_arr = array.new_bool(0)
cl_arr = array.new_float(0)
rsi_arr = array.new_float(0)
tsi_arr = array.new_float(0)
adx_arr = array.new_float(0)
sup_arr = array.new_float(0)
suy_arr = array.new_float(0)
close_arr = array.new_float(0)
col_arr = array.new_float(0)

// Add Symbols
array.push(s_arr, only_symbol(s01))
array.push(s_arr, only_symbol(s02))
array.push(s_arr, only_symbol(s03))
array.push(s_arr, only_symbol(s04))
array.push(s_arr, only_symbol(s05))
array.push(s_arr, only_symbol(s06))
array.push(s_arr, only_symbol(s07))
array.push(s_arr, only_symbol(s08))
array.push(s_arr, only_symbol(s09))
array.push(s_arr, only_symbol(s10))
array.push(s_arr, only_symbol(s11))
array.push(s_arr, only_symbol(s12))
array.push(s_arr, only_symbol(s13))
array.push(s_arr, only_symbol(s14))
array.push(s_arr, only_symbol(s15))
array.push(s_arr, only_symbol(s16))
array.push(s_arr, only_symbol(s17))
array.push(s_arr, only_symbol(s18))
array.push(s_arr, only_symbol(s19))
array.push(s_arr, only_symbol(s20))
array.push(s_arr, only_symbol(s21))
array.push(s_arr, only_symbol(s22))
array.push(s_arr, only_symbol(s23))
array.push(s_arr, only_symbol(s24))
array.push(s_arr, only_symbol(s25))
array.push(s_arr, only_symbol(s26))
array.push(s_arr, only_symbol(s27))
array.push(s_arr, only_symbol(s28))
array.push(s_arr, only_symbol(s29))
array.push(s_arr, only_symbol(s30))
array.push(s_arr, only_symbol(s31))
array.push(s_arr, only_symbol(s32))
array.push(s_arr, only_symbol(s33))
array.push(s_arr, only_symbol(s34))
array.push(s_arr, only_symbol(s35))
array.push(s_arr, only_symbol(s36))
array.push(s_arr, only_symbol(s37))
array.push(s_arr, only_symbol(s38))
array.push(s_arr, only_symbol(s39))
array.push(s_arr, only_symbol(s40))
// }
///////////

// FLAGS //
// {
array.push(u_arr, u01)
array.push(u_arr, u02)
array.push(u_arr, u03)
array.push(u_arr, u04)
array.push(u_arr, u05)
array.push(u_arr, u06)
array.push(u_arr, u07)
array.push(u_arr, u08)
array.push(u_arr, u09)
array.push(u_arr, u10)
array.push(u_arr, u11)
array.push(u_arr, u12)
array.push(u_arr, u13)
array.push(u_arr, u14)
array.push(u_arr, u15)
array.push(u_arr, u16)
array.push(u_arr, u17)
array.push(u_arr, u18)
array.push(u_arr, u19)
array.push(u_arr, u20)
array.push(u_arr, u21)
array.push(u_arr, u22)
array.push(u_arr, u23)
array.push(u_arr, u24)
array.push(u_arr, u25)
array.push(u_arr, u26)
array.push(u_arr, u27)
array.push(u_arr, u28)
array.push(u_arr, u29)
array.push(u_arr, u30)
array.push(u_arr, u31)
array.push(u_arr, u32)
array.push(u_arr, u33)
array.push(u_arr, u34)
array.push(u_arr, u35)
array.push(u_arr, u36)
array.push(u_arr, u37)
array.push(u_arr, u38)
array.push(u_arr, u39)
array.push(u_arr, u40)
// }

///////////
// CLOSE //
// {
array.push(cl_arr, cl01)
array.push(cl_arr, cl02)
array.push(cl_arr, cl03)
array.push(cl_arr, cl04)
array.push(cl_arr, cl05)
array.push(cl_arr, cl06)
array.push(cl_arr, cl07)
array.push(cl_arr, cl08)
array.push(cl_arr, cl09)
array.push(cl_arr, cl10)
array.push(cl_arr, cl11)
array.push(cl_arr, cl12)
array.push(cl_arr, cl13)
array.push(cl_arr, cl14)
array.push(cl_arr, cl15)
array.push(cl_arr, cl16)
array.push(cl_arr, cl17)
array.push(cl_arr, cl18)
array.push(cl_arr, cl19)
array.push(cl_arr, cl20)
array.push(cl_arr, cl21)
array.push(cl_arr, cl22)
array.push(cl_arr, cl23)
array.push(cl_arr, cl24)
array.push(cl_arr, cl25)
array.push(cl_arr, cl26)
array.push(cl_arr, cl27)
array.push(cl_arr, cl28)
array.push(cl_arr, cl29)
array.push(cl_arr, cl30)
array.push(cl_arr, cl31)
array.push(cl_arr, cl32)
array.push(cl_arr, cl33)
array.push(cl_arr, cl34)
array.push(cl_arr, cl35)
array.push(cl_arr, cl36)
array.push(cl_arr, cl37)
//array.push(cl_arr, cl38)
//array.push(cl_arr, cl39)
//array.push(cl_arr, cl40)
// }
/////////

// RSI //
// {
array.push(rsi_arr, rsi01)
array.push(rsi_arr, rsi02)
array.push(rsi_arr, rsi03)
array.push(rsi_arr, rsi04)
array.push(rsi_arr, rsi05)
array.push(rsi_arr, rsi06)
array.push(rsi_arr, rsi07)
array.push(rsi_arr, rsi08)
array.push(rsi_arr, rsi09)
array.push(rsi_arr, rsi10)
array.push(rsi_arr, rsi11)
array.push(rsi_arr, rsi12)
array.push(rsi_arr, rsi13)
array.push(rsi_arr, rsi14)
array.push(rsi_arr, rsi15)
array.push(rsi_arr, rsi16)
array.push(rsi_arr, rsi17)
array.push(rsi_arr, rsi18)
array.push(rsi_arr, rsi19)
array.push(rsi_arr, rsi20)
array.push(rsi_arr, rsi21)
array.push(rsi_arr, rsi22)
array.push(rsi_arr, rsi23)
array.push(rsi_arr, rsi24)
array.push(rsi_arr, rsi25)
array.push(rsi_arr, rsi26)
array.push(rsi_arr, rsi27)
array.push(rsi_arr, rsi28)
array.push(rsi_arr, rsi29)
array.push(rsi_arr, rsi30)
array.push(rsi_arr, rsi31)
array.push(rsi_arr, rsi32)
array.push(rsi_arr, rsi33)
array.push(rsi_arr, rsi34)
array.push(rsi_arr, rsi35)
array.push(rsi_arr, rsi36)
array.push(rsi_arr, rsi37)
//array.push(rsi_arr, rsi38)
//array.push(rsi_arr, rsi39)
//array.push(rsi_arr, rsi40)
// }
/////////

// TSI //
// {
array.push(tsi_arr, tsi01)
array.push(tsi_arr, tsi02)
array.push(tsi_arr, tsi03)
array.push(tsi_arr, tsi04)
array.push(tsi_arr, tsi05)
array.push(tsi_arr, tsi06)
array.push(tsi_arr, tsi07)
array.push(tsi_arr, tsi08)
array.push(tsi_arr, tsi09)
array.push(tsi_arr, tsi10)
array.push(tsi_arr, tsi11)
array.push(tsi_arr, tsi12)
array.push(tsi_arr, tsi13)
array.push(tsi_arr, tsi14)
array.push(tsi_arr, tsi15)
array.push(tsi_arr, tsi16)
array.push(tsi_arr, tsi17)
array.push(tsi_arr, tsi18)
array.push(tsi_arr, tsi19)
array.push(tsi_arr, tsi20)
array.push(tsi_arr, tsi21)
array.push(tsi_arr, tsi22)
array.push(tsi_arr, tsi23)
array.push(tsi_arr, tsi24)
array.push(tsi_arr, tsi25)
array.push(tsi_arr, tsi26)
array.push(tsi_arr, tsi27)
array.push(tsi_arr, tsi28)
array.push(tsi_arr, tsi29)
array.push(tsi_arr, tsi30)
array.push(tsi_arr, tsi31)
array.push(tsi_arr, tsi32)
array.push(tsi_arr, tsi33)
array.push(tsi_arr, tsi34)
array.push(tsi_arr, tsi35)
array.push(tsi_arr, tsi36)
array.push(tsi_arr, tsi37)
//array.push(tsi_arr, tsi38)
//array.push(tsi_arr, tsi39)
//array.push(tsi_arr, tsi40)
// }
/////////

// ADX //
// {
array.push(adx_arr, adx01)
array.push(adx_arr, adx02)
array.push(adx_arr, adx03)
array.push(adx_arr, adx04)
array.push(adx_arr, adx05)
array.push(adx_arr, adx06)
array.push(adx_arr, adx07)
array.push(adx_arr, adx08)
array.push(adx_arr, adx09)
array.push(adx_arr, adx10)
array.push(adx_arr, adx11)
array.push(adx_arr, adx12)
array.push(adx_arr, adx13)
array.push(adx_arr, adx14)
array.push(adx_arr, adx15)
array.push(adx_arr, adx16)
array.push(adx_arr, adx17)
array.push(adx_arr, adx18)
array.push(adx_arr, adx19)
array.push(adx_arr, adx20)
array.push(adx_arr, adx21)
array.push(adx_arr, adx22)
array.push(adx_arr, adx23)
array.push(adx_arr, adx24)
array.push(adx_arr, adx25)
array.push(adx_arr, adx26)
array.push(adx_arr, adx27)
array.push(adx_arr, adx28)
array.push(adx_arr, adx29)
array.push(adx_arr, adx30)
array.push(adx_arr, adx31)
array.push(adx_arr, adx32)
array.push(adx_arr, adx33)
array.push(adx_arr, adx34)
array.push(adx_arr, adx35)
array.push(adx_arr, adx36)
array.push(adx_arr, adx37)
//array.push(adx_arr, adx38)
//array.push(adx_arr, adx39)
//array.push(adx_arr, adx40)
// }
////////////////

// SUPERTREND //
// {
array.push(sup_arr, sup01)
array.push(sup_arr, sup02)
array.push(sup_arr, sup03)
array.push(sup_arr, sup04)
array.push(sup_arr, sup05)
array.push(sup_arr, sup06)
array.push(sup_arr, sup07)
array.push(sup_arr, sup08)
array.push(sup_arr, sup09)
array.push(sup_arr, sup10)
array.push(sup_arr, sup11)
array.push(sup_arr, sup12)
array.push(sup_arr, sup13)
array.push(sup_arr, sup14)
array.push(sup_arr, sup15)
array.push(sup_arr, sup16)
array.push(sup_arr, sup17)
array.push(sup_arr, sup18)
array.push(sup_arr, sup19)
array.push(sup_arr, sup20)
array.push(sup_arr, sup21)
array.push(sup_arr, sup22)
array.push(sup_arr, sup23)
array.push(sup_arr, sup24)
array.push(sup_arr, sup25)
array.push(sup_arr, sup26)
array.push(sup_arr, sup27)
array.push(sup_arr, sup28)
array.push(sup_arr, sup29)
array.push(sup_arr, sup30)
array.push(sup_arr, sup31)
array.push(sup_arr, sup32)
array.push(sup_arr, sup33)
array.push(sup_arr, sup34)
array.push(sup_arr, sup35)
array.push(sup_arr, sup36)
array.push(sup_arr, sup37)
//array.push(sup_arr, sup38)
//array.push(sup_arr, sup39)
//array.push(sup_arr, sup40)
// }
///////////
array.push(suy_arr, suy01)
array.push(suy_arr, suy02)
array.push(suy_arr, suy03)
array.push(suy_arr, suy04)
array.push(suy_arr, suy05)
array.push(suy_arr, suy06)
array.push(suy_arr, suy07)
array.push(suy_arr, suy08)
array.push(suy_arr, suy09)
array.push(suy_arr, suy10)
array.push(suy_arr, suy11)
array.push(suy_arr, suy12)
array.push(suy_arr, suy13)
array.push(suy_arr, suy14)
array.push(suy_arr, suy15)
array.push(suy_arr, suy16)
array.push(suy_arr, suy17)
array.push(suy_arr, suy18)
array.push(suy_arr, suy19)
array.push(suy_arr, suy20)
array.push(suy_arr, suy21)
array.push(suy_arr, suy22)
array.push(suy_arr, suy23)
array.push(suy_arr, suy24)
array.push(suy_arr, suy25)
array.push(suy_arr, suy26)
array.push(suy_arr, suy27)
array.push(suy_arr, suy28)
array.push(suy_arr, suy29)
array.push(suy_arr, suy30)
array.push(suy_arr, suy31)
array.push(suy_arr, suy32)
array.push(suy_arr, suy33)
array.push(suy_arr, suy34)
array.push(suy_arr, suy35)
array.push(suy_arr, suy36)
array.push(suy_arr, suy37)
//array.push(suy_arr, suy38)
//array.push(suy_arr, suy39)
//array.push(suy_arr, suy40)

///////////
array.push(close_arr, cls01)
array.push(close_arr, cls02)
array.push(close_arr, cls03)
array.push(close_arr, cls04)
array.push(close_arr, cls05)
array.push(close_arr, cls06)
array.push(close_arr, cls07)
array.push(close_arr, cls08)
array.push(close_arr, cls09)
array.push(close_arr, cls10)
array.push(close_arr, cls11)
array.push(close_arr, cls12)
array.push(close_arr, cls13)
array.push(close_arr, cls14)
array.push(close_arr, cls15)
array.push(close_arr, cls16)
array.push(close_arr, cls17)
array.push(close_arr, cls18)
array.push(close_arr, cls19)
array.push(close_arr, cls20)
array.push(close_arr, cls21)
array.push(close_arr, cls22)
array.push(close_arr, cls23)
array.push(close_arr, cls24)
array.push(close_arr, cls25)
array.push(close_arr, cls26)
array.push(close_arr, cls27)
array.push(close_arr, cls28)
array.push(close_arr, cls29)
array.push(close_arr, cls30)
array.push(close_arr, cls31)
array.push(close_arr, cls32)
array.push(close_arr, cls33)
array.push(close_arr, cls34)
array.push(close_arr, cls35)
array.push(close_arr, cls36)
array.push(close_arr, cls37)

array.push(col_arr, col1)
array.push(col_arr, col2)
array.push(col_arr, col3)
array.push(col_arr, col4)
array.push(col_arr, col5)
array.push(col_arr, col6)
array.push(col_arr, col7)
array.push(col_arr, col8)
array.push(col_arr, col9)
array.push(col_arr, col10)
array.push(col_arr, col11)
array.push(col_arr, col12)
array.push(col_arr, col13)
array.push(col_arr, col14)
array.push(col_arr, col15)
array.push(col_arr, col16)
array.push(col_arr, col17)
array.push(col_arr, col18)
array.push(col_arr, col19)
array.push(col_arr, col20)
array.push(col_arr, col21)
array.push(col_arr, col22)
array.push(col_arr, col23)
array.push(col_arr, col24)
array.push(col_arr, col25)
array.push(col_arr, col26)
array.push(col_arr, col27)
array.push(col_arr, col28)
array.push(col_arr, col29)
array.push(col_arr, col30)
array.push(col_arr, col31)
array.push(col_arr, col32)
array.push(col_arr, col33)
array.push(col_arr, col34)
array.push(col_arr, col35)
array.push(col_arr, col36)
array.push(col_arr, col37)
//array.push(close_arr, cls38)
//array.push(close_arr, cls39)
//array.push(close_arr, cls40)
// PLOTS //
// {
var tbl = table.new(f_getPosition(_pos), 8, 41, frame_color=#151715, frame_width=1,
border_width=2, border_color=color.new(color.white, 100))

fix_tf = timeframe.isseconds? timeframe.period + 'S' : timeframe.isminutes and


timeframe.multiplier<60? timeframe.period + 'M' : timeframe.isintraday?
str.tostring(timeframe.multiplier/60) + "H" : timeframe.period

// Timestamp for footer of the message


timetext = ts.datetime(timenow, '{0}-{1}-{2}T{3}:{4}') //timestamp

// We gonna write the text alert with basic information that we need
discDescription = ''
discContentText = ''

_bodyTitleL = 'BUY ALERT'


_bodyTitleS = 'SELL ALERT'

if barstate.islast

table.cell(tbl, 0, 0, 'Symbol', text_halign = text.align_center, bgcolor =


color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 1, 0, 'Change', text_halign = text.align_center, bgcolor =
color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 2, 0, 'RSI', text_halign = text.align_center, bgcolor =
color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 3, 0, '10', text_halign = text.align_center, bgcolor =
color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 4, 0, '130', text_halign = text.align_center, bgcolor =
color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 5, 0, 'VWAP % change', text_halign = text.align_center, bgcolor
= color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 6, 0, 'ADX', text_halign = text.align_center, bgcolor =
color.black, text_color = color.white, text_size = size.small)
table.cell(tbl, 7, 0, 'Final', text_halign = text.align_center, bgcolor =
color.black, text_color = color.white, text_size = size.small)

for i = 0 to 39
if array.get(u_arr, i)
cl_col = array.get(cl_arr, i) > 0
? #04D204 : #FF0000
rsi_col = array.get(rsi_arr, i) > 50
? #04D204 : #FF0000
tsi_col = array.get(close_arr, i) > array.get(tsi_arr, i)
? #04D204 : #FF0000
adx_col = array.get(close_arr, i) > array.get(adx_arr, i)
? #04D204 : #FF0000
//sup_col = array.get(close_arr, i) > 0
? #04D204 : #FF0000
suy_col = array.get(adx_arr, i) > adx_level
? #04D204 : #FF0000
col = array.get(col_arr, i) > 0
? #04D204 : #FF0000

rsi_colL = array.get(rsi_arr, i) > 50


? 1 : 0
tsi_colL = array.get(close_arr, i) > array.get(tsi_arr, i)
? 1 : 0
adx_colL = array.get(close_arr, i) > array.get(adx_arr, i)
? 1 : 0
sup_colL = array.get(close_arr, i) > array.get(sup_arr, i)
? 1 : 0
suy_colL = array.get(adx_arr, i) > adx_level
? 1 : 0

rsi_colS = array.get(rsi_arr, i) < 50


? 1 : 0
tsi_colS = array.get(close_arr, i) < array.get(tsi_arr, i)
? 1 : 0
adx_colS = array.get(close_arr, i) < array.get(adx_arr, i)
? 1 : 0
sup_colS = array.get(close_arr, i) < array.get(sup_arr, i)
? 1 : 0
suy_colS = array.get(adx_arr, i) > adx_level
? 1 : 0

final_textL=(sup_colL+rsi_colL+tsi_colL+adx_colL+suy_colL)==5?'Strong
Buy':(sup_colL+rsi_colL+tsi_colL)==3?'Buy':''
final_textS=(sup_colS+rsi_colS+tsi_colS+adx_colS+suy_colS)==5?'Strong
Sell':(sup_colS+rsi_colS+tsi_colS)==3?'Sell':''

final_colL=(sup_colL+rsi_colL+tsi_colL+adx_colL+suy_colL)==5?
color.lime:(sup_colL+rsi_colL+tsi_colL)==3?color.green:na
final_colS=(sup_colS+rsi_colS+tsi_colS+adx_colS+suy_colS)==5?color.red:
(sup_colS+rsi_colS+tsi_colS)==3?color.maroon:na
table.cell(tbl, 0, i + 1, array.get(s_arr, i),
text_halign = text.align_left, bgcolor = color.black, text_color = color.white,
text_size = size.small)
table.cell(tbl, 1, i + 1, str.tostring(array.get(cl_arr, i))+"%",
text_halign = text.align_center, bgcolor = cl_col, text_color = color.white,
text_size = size.small)
table.cell(tbl, 2, i + 1, '',
text_halign = text.align_center, bgcolor = rsi_col, text_color = color.white,
text_size = size.small)
table.cell(tbl, 3, i + 1, '',
text_halign = text.align_center, bgcolor = tsi_col, text_color = color.white,
text_size = size.small)
table.cell(tbl, 4, i + 1, '', text_halign = text.align_center,
bgcolor = adx_col , text_color = color.white, text_size = size.small)
table.cell(tbl, 5, i + 1, str.tostring(array.get(sup_arr, i), "#.##"),
text_halign = text.align_center, bgcolor = array.get(col_arr, i) < 0
? #FF0000 : #04D204, text_color = color.white, text_size = size.small)
// table.cell(tbl, 6, i + 1, '', text_halign =
text.align_center, bgcolor = suy_col, text_color = color.white, text_size =
size.small)
table.cell(tbl, 6, i + 1, str.tostring(array.get(suy_arr, i), "#.##"),
text_halign = text.align_center, bgcolor = suy_col , text_color = color.white,
text_size = size.small)

table.cell(tbl, 7, i + 1, final_textL==''?final_textS:final_textL,
text_halign = text.align_center, bgcolor = na(final_colL)?final_colS:final_colL,
text_color = color.white, text_size = size.small)

_descText = (final_textL==''?final_textS:final_textL)+' '


+"\\n"+' '
+ "\\nRSI : " + (rsi_colL==1?' Bullish ': rsi_colS==1?' Bearish
':' Neutral ')
+ "\\nSMA 34 : " + (tsi_colL==1?' Bullish ': tsi_colS==1?' Bearish
':' Neutral ')
+ "\\nSMA 200 : " + (adx_colL==1?' Bullish ': adx_colS==1?'
Bearish ':' Neutral ')
+ "\\nMVWAP : " + (sup_colL==1?' Bullish ': sup_colS==1?' Bearish
':' Neutral ')
+ "\\nYVWAP : " + (suy_colL==1?' Bullish ': suy_colS==1?' Bearish
':' Neutral ')
+ "\\nCurrent Price: " + str.tostring(array.get(close_arr, i),
format.mintick)
+ "\\nVOLUME: " + str.tostring(volume,format.volume)+' '
+ "\\nTV:"+trade_url
+"\\nSYMBOL: " + syminfo.ticker+' '+ "TIMEFRAME: "
+ fix_tf

discordText_long = ds.discordWebhookJSON(
_username,
_avatarImgUrl,
discContentText,
_bodyTitleL,
(_descText != '') ? _descText : discDescription,
_bodyUrl,
"65280",
_timestamp ? timetext : "",
'',
_authorUrl,
_authorIconUrl,
_footerText,
_footerIconUrl,
_thumbImgUrl,
_imageUrl)

discordText_short = ds.discordWebhookJSON(
_username,
_avatarImgUrl,
discContentText,
_bodyTitleS,
(_descText != '') ? _descText : discDescription,
_bodyUrl,
"16711680",
_timestamp ? timetext : "",
'',
_authorUrl,
_authorIconUrl,
_footerText,
_footerIconUrl,
_thumbImgUrl,
_imageUrl)

if (final_textL==''?final_textS:final_textL)=='Buy' or
(final_textL==''?final_textS:final_textL)=='Strong Buy'
alert(discordText_long , freq = alert.freq_once_per_bar_close)

if (final_textL==''?final_textS:final_textL)=='Sell' or
(final_textL==''?final_textS:final_textL)=='Strong Sell'
alert(discordText_short , freq = alert.freq_once_per_bar_close)

// }

You might also like