-
Notifications
You must be signed in to change notification settings - Fork 4
/
AlphaTrend - Screener
236 lines (217 loc) · 12.4 KB
/
AlphaTrend - Screener
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// UYARI
// Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez.
// ALPHATREND SCREENER çoğumuza ilham veren sevgili Kıvanç özbilgiç'e naçizane bir teşekkür için kodlandı.
// Umarım herkese faydası dokunur...
// © dg_factor [04.09.2022, İstanbul]
// https://twitter.com/dg_factor/status/1661484012236595202?s=20
// ALPHATREND SCREENER has been coded as a humble thanks to dear Kıvanç Özbilgiç who inspired many of us.
// I hope it helps everyone...
// Created & Developed by : Kıvanç Özbilgiç (@KivancOzbilgic)
// Screener Panel & Adjustments : @dg_factor
//@version=5
indicator('AlphaTrend [Screener]', overlay=true, format=format.price, precision=2)
// AlphaTrend Inputs
src = input.source(title='Source', defval=close, group='ALPHATREND')
AP = input.int(title='Length', defval=14, group='ALPHATREND')
coeff = input.float(title='Multiplier', defval=1.0, step=0.1, group='ALPHATREND')
novolumedata = input.bool(title='Change Calculation (No Volume Data)', defval=false, group='ALPHATREND')
showsignalsk = input(title='Show Signals ', defval=true, group='ALPHATREND')
// AlphaTrend Calcs
ATR = ta.sma(ta.tr, AP)
upT = low - ATR * coeff
downT = high + ATR * coeff
rsi = ta.rsi(src, AP)
mfi = ta.mfi(hlc3, AP)
filter = novolumedata ? rsi >= 50 : mfi >= 50
AlphaTrend = 0.0
AlphaTrend := filter ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT
color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B
buySignalk = ta.crossover(AlphaTrend, AlphaTrend[2])
sellSignalk = ta.crossunder(AlphaTrend, AlphaTrend[2])
K1 = ta.barssince(buySignalk)
K2 = ta.barssince(sellSignalk)
O1 = ta.barssince(buySignalk[1])
O2 = ta.barssince(sellSignalk[1])
direction = 0
direction := buySignalk and O1 > K2 ? 1 : sellSignalk and O2 > K1 ? -1 : direction[1]
// Plots
k1 = plot(AlphaTrend, title='AlphaTrend', color=#0022fc, linewidth=3)
k2 = plot(AlphaTrend[2], title='Trigger', color=#fc0400, linewidth=3)
fill(k1, k2, title='Fill Color', color=color1)
// Shapes
plotshape(showsignalsk and buySignalk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=#0022FC, textcolor=color.white)
plotshape(showsignalsk and sellSignalk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.maroon, textcolor=color.white)
// Screener Inputs
string gr_sc = 'SCREENER'
string gr_sy = 'SYMBOL'
string t00 = 'Alpha Trend Screener'
color c00 = #686868
lb_sh = input.bool(title='Show Label', defval=true, group=gr_sc)
lb_xa = input.int(title='Horizontal Axis', defval=20, group=gr_sc, tooltip='Label Position x Axis')
lb_ya = input.int(title='Vertical Axis', defval=1, group=gr_sc, tooltip='Label Position y Axis')
lb_sz = input.string(title='Label Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], defval='Normal', group=gr_sc)
lb_cl = input.color(title='Colours', defval=#00bb00, group=gr_sc, inline='0')
lb_cs = input.color(title='', defval=#ff0000, group=gr_sc, inline='0')
// Confirm Inputs
sh01 = input.bool(title='01', defval=true, group=gr_sy, inline="01")
sh02 = input.bool(title='02', defval=true, group=gr_sy, inline="02")
sh03 = input.bool(title='03', defval=true, group=gr_sy, inline="03")
sh04 = input.bool(title='04', defval=true, group=gr_sy, inline="04")
sh05 = input.bool(title='05', defval=true, group=gr_sy, inline="05")
sh06 = input.bool(title='06', defval=true, group=gr_sy, inline="06")
sh07 = input.bool(title='07', defval=true, group=gr_sy, inline="07")
sh08 = input.bool(title='08', defval=true, group=gr_sy, inline="08")
sh09 = input.bool(title='09', defval=true, group=gr_sy, inline="09")
sh10 = input.bool(title='10', defval=true, group=gr_sy, inline="10")
sh11 = input.bool(title='11', defval=false, group=gr_sy, inline="11")
sh12 = input.bool(title='12', defval=false, group=gr_sy, inline="12")
sh13 = input.bool(title='13', defval=false, group=gr_sy, inline="13")
sh14 = input.bool(title='14', defval=false, group=gr_sy, inline="14")
sh15 = input.bool(title='15', defval=false, group=gr_sy, inline="15")
sh16 = input.bool(title='16', defval=false, group=gr_sy, inline="16")
sh17 = input.bool(title='17', defval=false, group=gr_sy, inline="17")
sh18 = input.bool(title='18', defval=false, group=gr_sy, inline="18")
sh19 = input.bool(title='19', defval=false, group=gr_sy, inline="19")
sh20 = input.bool(title='20', defval=false, group=gr_sy, inline="20")
// TimeFrame Inputs
tf01 = input.timeframe(title='', defval='', group=gr_sy, inline="01")
tf02 = input.timeframe(title='', defval='', group=gr_sy, inline="02")
tf03 = input.timeframe(title='', defval='', group=gr_sy, inline="03")
tf04 = input.timeframe(title='', defval='', group=gr_sy, inline="04")
tf05 = input.timeframe(title='', defval='', group=gr_sy, inline="05")
tf06 = input.timeframe(title='', defval='', group=gr_sy, inline="06")
tf07 = input.timeframe(title='', defval='', group=gr_sy, inline="07")
tf08 = input.timeframe(title='', defval='', group=gr_sy, inline="08")
tf09 = input.timeframe(title='', defval='', group=gr_sy, inline="09")
tf10 = input.timeframe(title='', defval='', group=gr_sy, inline="10")
tf11 = input.timeframe(title='', defval='', group=gr_sy, inline="11")
tf12 = input.timeframe(title='', defval='', group=gr_sy, inline="12")
tf13 = input.timeframe(title='', defval='', group=gr_sy, inline="13")
tf14 = input.timeframe(title='', defval='', group=gr_sy, inline="14")
tf15 = input.timeframe(title='', defval='', group=gr_sy, inline="15")
tf16 = input.timeframe(title='', defval='', group=gr_sy, inline="16")
tf17 = input.timeframe(title='', defval='', group=gr_sy, inline="17")
tf18 = input.timeframe(title='', defval='', group=gr_sy, inline="18")
tf19 = input.timeframe(title='', defval='', group=gr_sy, inline="19")
tf20 = input.timeframe(title='', defval='', group=gr_sy, inline="20")
// Symbol Inputs
s01 = input.symbol(title='', group=gr_sy, inline='01', defval='BINANCE:BTCUSDT')
s02 = input.symbol(title='', group=gr_sy, inline='02', defval='BINANCE:ETHUSDT')
s03 = input.symbol(title='', group=gr_sy, inline='03', defval='BINANCE:BNBUSDT')
s04 = input.symbol(title='', group=gr_sy, inline='04', defval='BINANCE:ADAUSDT')
s05 = input.symbol(title='', group=gr_sy, inline='05', defval='BINANCE:AVAXUSDT')
s06 = input.symbol(title='', group=gr_sy, inline='06', defval='BINANCE:CHZUSDT')
s07 = input.symbol(title='', group=gr_sy, inline='07', defval='BINANCE:DOGEUSDT')
s08 = input.symbol(title='', group=gr_sy, inline='08', defval='BINANCE:SOLUSDT')
s09 = input.symbol(title='', group=gr_sy, inline='09', defval='BINANCE:TRXUSDT')
s10 = input.symbol(title='', group=gr_sy, inline='10', defval='BINANCE:XRPUSDT')
s11 = input.symbol(title='', group=gr_sy, inline='11', defval='NASDAQ:AAPL')
s12 = input.symbol(title='', group=gr_sy, inline='12', defval='NASDAQ:TSLA')
s13 = input.symbol(title='', group=gr_sy, inline='13', defval='NASDAQ:AMZN')
s14 = input.symbol(title='', group=gr_sy, inline='14', defval='NASDAQ:GOOGL')
s15 = input.symbol(title='', group=gr_sy, inline='15', defval='NASDAQ:NVDA')
s16 = input.symbol(title='', group=gr_sy, inline='16', defval='NASDAQ:META')
s17 = input.symbol(title='', group=gr_sy, inline='17', defval='NYSE:C')
s18 = input.symbol(title='', group=gr_sy, inline='18', defval='NASDAQ:NFLX')
s19 = input.symbol(title='', group=gr_sy, inline='19', defval='NYSE:BABA')
s20 = input.symbol(title='', group=gr_sy, inline='20', defval='NASDAQ:ABNB')
// Functions
f_screener(s) =>
int x = na
int y = na
z = color(na)
if s
x := direction
y := ta.barssince(x != x[1])
z := x == 1 ? lb_cl : x == -1 ? lb_cs : c00
[x, y, z]
//
f_bars(x) =>
r = ' [' + str.tostring(x) + '] '
//
f_size(x) =>
x == 'Tiny' ? size.tiny :
x == 'Small' ? size.small :
x == 'Normal' ? size.normal :
x == 'Large' ? size.large :
x == 'Huge' ? size.huge : size.auto
//
f_label(l, t, c) =>
r = string(na)
for i = l*2 to 0
r += '\n\n'
r += t
var label lb = na
label.delete(lb)
fix_allign = ta.highest(200)
lb := lb_sh ? label.new(
x=bar_index + lb_xa,
y=bar_index > 200 ? fix_allign * (1 + lb_ya / 1000) : hl2 * (1 + lb_ya / 1000),
text=r, textcolor=c, textalign=text.align_right,
style=label.style_label_left, size=f_size(lb_sz), color=#00000000) : na
//
// Variables
[a01, b01, c01] = request.security(s01, tf01, f_screener(sh01))
[a02, b02, c02] = request.security(s02, tf02, f_screener(sh02))
[a03, b03, c03] = request.security(s03, tf03, f_screener(sh03))
[a04, b04, c04] = request.security(s04, tf04, f_screener(sh04))
[a05, b05, c05] = request.security(s05, tf05, f_screener(sh05))
[a06, b06, c06] = request.security(s06, tf06, f_screener(sh06))
[a07, b07, c07] = request.security(s07, tf07, f_screener(sh07))
[a08, b08, c08] = request.security(s08, tf08, f_screener(sh08))
[a09, b09, c09] = request.security(s09, tf09, f_screener(sh09))
[a10, b10, c10] = request.security(s10, tf10, f_screener(sh10))
[a11, b11, c11] = request.security(s11, tf11, f_screener(sh11))
[a12, b12, c12] = request.security(s12, tf12, f_screener(sh12))
[a13, b13, c13] = request.security(s13, tf13, f_screener(sh13))
[a14, b14, c14] = request.security(s14, tf14, f_screener(sh14))
[a15, b15, c15] = request.security(s15, tf15, f_screener(sh15))
[a16, b16, c16] = request.security(s16, tf16, f_screener(sh16))
[a17, b17, c17] = request.security(s17, tf17, f_screener(sh17))
[a18, b18, c18] = request.security(s18, tf18, f_screener(sh18))
[a19, b19, c19] = request.security(s19, tf19, f_screener(sh19))
[a20, b20, c20] = request.security(s20, tf20, f_screener(sh20))
// Text
t01 = a01 == 1 ? '▲' + f_bars(b01) + s01 : a01 == -1 ? '▼' + f_bars(b01) + s01 : '■' + f_bars(b01) + s01
t02 = a02 == 1 ? '▲' + f_bars(b02) + s02 : a02 == -1 ? '▼' + f_bars(b02) + s02 : '■' + f_bars(b02) + s02
t03 = a03 == 1 ? '▲' + f_bars(b03) + s03 : a03 == -1 ? '▼' + f_bars(b03) + s03 : '■' + f_bars(b03) + s03
t04 = a04 == 1 ? '▲' + f_bars(b04) + s04 : a04 == -1 ? '▼' + f_bars(b04) + s04 : '■' + f_bars(b04) + s04
t05 = a05 == 1 ? '▲' + f_bars(b05) + s05 : a05 == -1 ? '▼' + f_bars(b05) + s05 : '■' + f_bars(b05) + s05
t06 = a06 == 1 ? '▲' + f_bars(b06) + s06 : a06 == -1 ? '▼' + f_bars(b06) + s06 : '■' + f_bars(b06) + s06
t07 = a07 == 1 ? '▲' + f_bars(b07) + s07 : a07 == -1 ? '▼' + f_bars(b07) + s07 : '■' + f_bars(b07) + s07
t08 = a08 == 1 ? '▲' + f_bars(b08) + s08 : a08 == -1 ? '▼' + f_bars(b08) + s08 : '■' + f_bars(b08) + s08
t09 = a09 == 1 ? '▲' + f_bars(b09) + s09 : a09 == -1 ? '▼' + f_bars(b09) + s09 : '■' + f_bars(b09) + s09
t10 = a10 == 1 ? '▲' + f_bars(b10) + s10 : a10 == -1 ? '▼' + f_bars(b10) + s10 : '■' + f_bars(b10) + s10
t11 = a11 == 1 ? '▲' + f_bars(b11) + s11 : a11 == -1 ? '▼' + f_bars(b11) + s11 : '■' + f_bars(b11) + s11
t12 = a12 == 1 ? '▲' + f_bars(b12) + s12 : a12 == -1 ? '▼' + f_bars(b12) + s12 : '■' + f_bars(b12) + s12
t13 = a13 == 1 ? '▲' + f_bars(b13) + s13 : a13 == -1 ? '▼' + f_bars(b13) + s13 : '■' + f_bars(b13) + s13
t14 = a14 == 1 ? '▲' + f_bars(b14) + s14 : a14 == -1 ? '▼' + f_bars(b14) + s14 : '■' + f_bars(b14) + s14
t15 = a15 == 1 ? '▲' + f_bars(b15) + s15 : a15 == -1 ? '▼' + f_bars(b15) + s15 : '■' + f_bars(b15) + s15
t16 = a16 == 1 ? '▲' + f_bars(b16) + s16 : a16 == -1 ? '▼' + f_bars(b16) + s16 : '■' + f_bars(b16) + s16
t17 = a17 == 1 ? '▲' + f_bars(b17) + s17 : a17 == -1 ? '▼' + f_bars(b17) + s17 : '■' + f_bars(b17) + s17
t18 = a18 == 1 ? '▲' + f_bars(b18) + s18 : a18 == -1 ? '▼' + f_bars(b18) + s18 : '■' + f_bars(b18) + s18
t19 = a19 == 1 ? '▲' + f_bars(b19) + s19 : a19 == -1 ? '▼' + f_bars(b19) + s19 : '■' + f_bars(b19) + s19
t20 = a20 == 1 ? '▲' + f_bars(b20) + s20 : a20 == -1 ? '▼' + f_bars(b20) + s20 : '■' + f_bars(b20) + s20
// Return
f_label(0, t00, c00)
f_label(1, t01, c01)
f_label(2, t02, c02)
f_label(3, t03, c03)
f_label(4, t04, c04)
f_label(5, t05, c05)
f_label(6, t06, c06)
f_label(7, t07, c07)
f_label(8, t08, c08)
f_label(9, t09, c09)
f_label(10, t10, c10)
f_label(11, t11, c11)
f_label(12, t12, c12)
f_label(13, t13, c13)
f_label(14, t14, c14)
f_label(15, t15, c15)
f_label(16, t16, c16)
f_label(17, t17, c17)
f_label(18, t18, c18)
f_label(19, t19, c19)
f_label(20, t20, c20)