-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathShrikeScans.pine
More file actions
357 lines (299 loc) · 15.8 KB
/
ShrikeScans.pine
File metadata and controls
357 lines (299 loc) · 15.8 KB
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
//@version=6
import TradingView/ta/10
indicator("Shrike Scan 1", overlay=true)
// vim: syntax=pine
iBBThreshold = input.float(0.0015, minval=0.0, title="Bollinger Lower Threshold", tooltip="0.003 for daily, 0.0015 for 30 min candles", group="General Settings")
RSILower = input.int(25, minval=1, title="RSI Lower Threshold", tooltip="Normally 25", group="General Settings")
RSIUpper = input.int(72, minval=1, title="RSI Upper Threshold", tooltip="Normally 75", group="General Settings")
smEMA = input.int(21, "Standard EMA", minval=1, group="Indicator Settings")
bigEMA = input.int(200, "Longer EMA", minval=1, group="Indicator Settings")
rsiLen = input.int(14, "RSI Length", minval=1, group="Indicator Settings")
bbLength = input.int(20, "Bollinger Length", minval=1, group="Indicator Settings")
bbMultiplier = input.float(2, "Bollinger Multiplier", minval=0.1, step=0.1, group="Indicator Settings")
sensitivity = input.int(150, title="Sensitivity", group="Indicator Settings")
atrTP = input.float(1.6, title="ATR Multiplier for Take Profit")
//#region SYMBOLS
//#endregion
// <editor-fold desc="FUNCTIONS">
CreateAlert(s, sym, cc, tp) =>
why = s + " on " + sym + " at " + str.tostring(cc) + ". tp: " + str.tostring(tp)
result = "{ content: '" + s + " on " + sym + " at " + str.tostring(cc) + ". tp: " + str.tostring(tp) + "'}"
result
BBUpper0(len, m) =>
float basis = ta.sma(close, len)
float dev = m * ta.stdev(close, len)
basis + dev
BBLower0(len, m) =>
float basis = ta.sma(close, len)
float dev = m * ta.stdev(close, len)
basis - dev
BBUpper1(len, m) =>
float basis = ta.sma(close[1], len)
float dev = m * ta.stdev(close[1], len)
basis + dev
BBLower1(len, m) =>
float basis = ta.sma(close[1], len)
float dev = m * ta.stdev(close[1], len)
basis - dev
calc_macd0() =>
fastMA = ta.ema(close, 20)
slowMA = ta.ema(close, 40)
fastMA - slowMA
calc_macd1() =>
fastMA = ta.ema(close[1], 20)
slowMA = ta.ema(close[1], 40)
fastMA - slowMA
Trampoline() =>
result = 0
isRed = close < open
isGreen = close > open
basisBB = ta.sma(close, 20)
devBB = 2.0 * ta.stdev(close, 20)
upperBB = basisBB + devBB
lowerBB = basisBB - devBB
downBB = low < lowerBB or high < lowerBB
upBB = low > upperBB or high > upperBB
bbw = (upperBB - lowerBB) / basisBB
up = ta.rma(math.max(ta.change(close), 0), 14)
down = ta.rma(-math.min(ta.change(close), 0), 14)
rsiM = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
back1 = isRed[1] and rsiM[1] <= 25 and close[1] < lowerBB[1] and bbw[1] > 0.0015
back2 = isRed[2] and rsiM[2] <= 25 and close[2] < lowerBB[2] and bbw[2] > 0.0015
back3 = isRed[3] and rsiM[3] <= 25 and close[3] < lowerBB[3] and bbw[3] > 0.0015
back4 = isRed[4] and rsiM[4] <= 25 and close[4] < lowerBB[4] and bbw[4] > 0.0015
back5 = isRed[5] and rsiM[5] <= 25 and close[5] < lowerBB[5] and bbw[5] > 0.0015
for1 = isGreen[1] and rsiM[1] >= 72 and close[1] > upperBB[1] and bbw[1] > 0.0015
for2 = isGreen[2] and rsiM[2] >= 72 and close[2] > upperBB[2] and bbw[2] > 0.0015
for3 = isGreen[3] and rsiM[3] >= 72 and close[3] > upperBB[3] and bbw[3] > 0.0015
for4 = isGreen[4] and rsiM[4] >= 72 and close[4] > upperBB[4] and bbw[4] > 0.0015
for5 = isGreen[5] and rsiM[5] >= 72 and close[5] > upperBB[5] and bbw[5] > 0.0015
weGoUp = isGreen and (back1 or back2 or back3 or back4 or back5) and (high > high[1])
upThrust = weGoUp and not weGoUp[1] and not weGoUp[2] and not weGoUp[3] and not weGoUp[4]
weGoDown = isRed and (for1 or for2 or for3 or for4 or for5) and (low < low[1])
downThrust = weGoDown and not weGoDown[1] and not weGoDown[2] and not weGoDown[3] and not weGoDown[4]
result := upThrust ? 1 : downThrust ? -1 : 0
result
findGreenGaps() =>
bool isGreens = close > open and close[1] > open[1] and close[2] > open[2]
bool hasGap = isGreens and open > close[1] and open[1] > close[2]
bool foundTwoMore = false
if hasGap
for i = 2 to 20
// if we find a green gap, leave
bool isGreensR = close[i] > open[i]
bool hasGapG = isGreensR and open[i] > close[i+1]
if (isGreensR and hasGapG)
break
bool isRed0 = close[i] < open[i]
bool isRed1 = close[i+1] < open[i+1]
bool hasGapR = isRed0 and open[i] < close[i+1]
bool hasGapR2 = isRed1 and open[i+1] < close[i+2]
if(hasGapR and hasGapR2)
foundTwoMore := true
break
hasGap and foundTwoMore
findRedGaps() =>
bool isReds = close < open and close[1] < open[1] and close[2] < open[2]
bool hasGap = isReds and open < close[1] and open[1] < close[2]
bool foundTwoMore = false
if hasGap
for i = 2 to 20
// if we find a red gap, leave
bool isRedsR = close[i] < open[i]
bool hasGapR = isRedsR and open[i] < close[i+1]
if (isRedsR and hasGapR)
break
bool isGreen0 = close[i] > open[i]
bool isGreen1 = close[i+1] > open[i+1]
bool hasGapG = isGreen0 and open[i] > close[i+1]
bool hasGapG2 = isGreen1 and open[i+1] > close[i+2]
if(hasGapG and hasGapG2)
foundTwoMore := true
break
hasGap and foundTwoMore
// </editor-fold>
//updateTHIRTY(string sym) =>
// [yoTramp, atr] = request.security(sym, "30", [Trampoline(), ta.atr(14)])
alertcondition(false, "QBuy_", "🚨 Quick Buy ")
updateFIVEminute(sym) =>
tf = timeframe.period
jjjjj
//[basisBB, devBB, Open, Close, High, Low, POpen, PClose, PHigh, PLow, tickVWAP, tickSar, tickEma, tickEma200, tickRSI] = request.security(sym, tf, [ta.sma(close, bbLength), ta.stdev(close, bbLength), open, close, high, low, open-1, close-1, high-1, low-1, ta.vwap(close), ta.sar(start = 0.02, inc = 0.02, max=0.2), ta.ema(close, smEMA), ta.ema(close, bigEMA), ta.rsi(close, rsiLen)])
//[Open, Close, High, Low, POpen, PPOpen, PClose, PPClose,PHigh, PLow, PPLow, VWAP, Ema, Ema200, upper, lower, pupper, plower, macd0, macd1, atr] = request.securjkjity(sym, "5", [open, close, high, low, open[1], open[2], close[1], close[2], high[1], low[1], low[2], ta.vwap(close), ta.ema(close, smEMA), ta.ema(close, bigEMA), BBUpper0(20,2), BBLower0(20,2), BBUpper1(20,2), BBLower1(20,2), calc_macd0(), calc_macd1(), ta.atr(14)])
// Plot shapes for each symbol
[Open, Close, High, Low, POpen, PPOpen, PClose, PPClose,PHigh, PLow, PPLow, VWAP, Ema, Ema200, upper, lower, pupper, plower, macd0, macd1, bShiftG, bShiftR, yoTramp, atr] = request.security(sym, "5", [open, close, high, low, open[1], open[2], close[1], close[2], high[1], low[1], low[2], ta.vwap(close), ta.ema(close, smEMA), ta.ema(close, bigEMA), BBUpper0(20,2), BBLower0(20,2), BBUpper1(20,2), BBLower1(20,2), calc_macd0(), calc_macd1(), findGreenGaps(), findRedGaps(), Trampoline(), ta.atr(14)])
isRed0 = Close < Open
isRed1 = PClose < POpen
isRed2 = PPClose < PPOpen
isGreen0 = Close > Open
isGreen1 = PClose > POpen
isGreen2 = PPClose > PPOpen
// WADDAH EXPLOSION
t1 = (macd0 - macd1) * sensitivity
e1 = (upper - lower)
// GREEN FULLY ABOVE OR BELOW BB
bFullGreenAboveBB = isGreen0 and Close < lower and Open < lower
bFullRedAboveBB = isRed0 and Close > upper and Open > upper
// CANDLE GAP AT THE BOLLINGER BAND
bGreenGapAtBB = isGreen0 and isGreen1 and Open > PClose and PLow < plower
bRedGapAtBB = isRed0 and isRed1 and Open < PClose and PHigh > pupper
// ENGULFING CANDLE OFF THE BOLLINGER BAND
bEngulingBBGreen = Close > PClose and isGreen0 and isGreen1 and isRed2 and PLow < plower and PPLow < plower and math.abs(POpen - PClose) > math.abs(PPOpen - PPClose)
atrUp = High + atr * atrTP
atrDown = Low - atr * atrTP
sGreenGapAtBB = CreateAlert("Candle Gap Buy", sym, Close, atrUp)
//alertcondition(bGreenGapAtBB, "CGBuy_" + sym, "Candle Gap Buy " + sym)
if (bGreenGapAtBB)
alert(sGreenGapAtBB, alert.freq_once_per_bar)
sRedGapAtBB = CreateAlert("Candle Gap Sell", sym, Close, atrDown)
//alertcondition(bRedGapAtBB, "CGSell_" + sym, "Candle Gap Sell " + sym)
if (bRedGapAtBB)
alert(sRedGapAtBB, alert.freq_once_per_bar)
sShiftG = CreateAlert("Direction Shift Green", sym, Close, atrUp)
//alertcondition(bShiftG, "DRGreen_" + sym, "Direction Shift Green " + sym)
if (bShiftG)
alert(sShiftG, alert.freq_once_per_bar)
sShiftR = CreateAlert("Direction Shift Red", sym, Close, atrDown)
//alertcondition(bShiftR, "DRRed_" + sym, "Direction Shift Red " + sym)
if (bShiftR)
alert(sShiftR, alert.freq_once_per_bar)
sFullGreenAboveBB = CreateAlert("🚨 Quick Buy", sym, Close, atrUp)
//alertcondition(bFullGreenAboveBB, "QBuy_" + sym, "🚨 Quick Buy " + sym)
if (bFullGreenAboveBB)
alert(sFullGreenAboveBB, alert.freq_once_per_bar)
sFullRedAboveBB = CreateAlert("🚨 Quick Sell", sym, Close, atrDown)
//alertcondition(bFullRedAboveBB, "QSell_" + sym, "🚨 Quick Sell " + sym)
if (bFullRedAboveBB)
alert(sFullRedAboveBB, alert.freq_once_per_bar)
// Plot shapes for each symbol
//plotshape(bEngulingBBGreen ? hl2 : na, title="EngBB_" + sym, text="EngBB", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.rgb(46, 173, 84), textcolor=color.white)
//plotshape(yoTramp == 1 ? hl2 : na, title="Tramp_" + sym, text="Tramp", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.rgb(46, 173, 84), textcolor=color.white)
//plotshape(yoTramp == -1 ? hl2 : na, title="Tramp_" + sym, text="Tramp", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.rgb(173, 46, 69), textcolor=color.white)
//plotshape(bGreenGapAtBB ? hl2 : na, title="Gap_" + sym, text="Gap", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.rgb(46, 173, 84), textcolor=color.white)
//plotshape(bRedGapAtBB ? hl2 : na, title="Gap_" + sym, text="Gap", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.rgb(173, 46, 69), textcolor=color.white)
//plotshape(bShiftG ? hl2 : na, title="Shift_" + sym, text="Shift", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.rgb(46, 173, 84), textcolor=color.white)
//plotshape(bShiftR ? hl2 : na, title="Shift_" + sym, text="Shift", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.rgb(173, 46, 69), textcolor=color.white)
//plotshape(bFullGreenAboveBB ? hl2 : na, title="Strong Buy_" + sym, text="Strong Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.rgb(46, 173, 84), textcolor=color.white)
//plotshape(bFullRedAboveBB ? hl2 : na, title="Strong Sell_" + sym, text="Strong Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.rgb(173, 46, 69), textcolor=color.white)
if barstate.islast
updateFIVEminute("CME_MINI:ES1!") //
updateFIVEminute("CME_MINI:NQ1!") //
updateFIVEminute("TVC:VIX") //
updateFIVEminute("CBOT_MINI:YM1!") //
updateFIVEminute("NASDAQ:NDX") //
updateFIVEminute("CME_MINI:RTY1!") //
updateFIVEminute("EUREX:FDAX1!") //
updateFIVEminute("COMEX:GC1!") //
updateFIVEminute("COMEX:SI1!") //
updateFIVEminute("COMEX:HG1!") //
updateFIVEminute("NYMEX:PL1!") //
updateFIVEminute("RUS:NG1!") //
updateFIVEminute("NYMEX:CL1!") //
updateFIVEminute("CBOT:ZC1!") //
updateFIVEminute("CBOT:ZF1!") //
updateFIVEminute("CBOT:ZN1!") //
updateFIVEminute("CBOT:ZT1!") //
updateFIVEminute("CBOT:ZB1!") //
// 22 allowed
updateFIVEminute("NASDAQ:MSFT") //
updateFIVEminute("NASDAQ:AAPL") //
updateFIVEminute("NASDAQ:NVDA") //
updateFIVEminute("NASDAQ:AMZN") //
updateFIVEminute("NASDAQ:GOOGL") //
updateFIVEminute("NASDAQ:GOOG") //
updateFIVEminute("NASDAQ:META") //
updateFIVEminute("NASDAQ:AVGO") //
updateFIVEminute("NYSE:LLY") //
updateFIVEminute("NASDAQ:TSLA") //
updateFIVEminute("NYSE:V") //
updateFIVEminute("NYSE:JPM") //
updateFIVEminute("NYSE:WMT") //
updateFIVEminute("NYSE:XOM") //
updateFIVEminute("NYSE:UNH") //
updateFIVEminute("NYSE:MA") //
updateFIVEminute("NYSE:JNJ") //
updateFIVEminute("NYSE:PG") //
updateFIVEminute("NASDAQ:COST") //
updateFIVEminute("NYSE:HD") //
updateFIVEminute("NYSE:MRK") //
updateFIVEminute("NYSE:ABBV") //
updateFIVEminute("NASDAQ:ADBE") //
updateFIVEminute("NYSE:CRM") //
updateFIVEminute("NYSE:KO") //
updateFIVEminute("NASDAQ:PEP") //
updateFIVEminute("NYSE:BAC") //
updateFIVEminute("NASDAQ:CSCO") //
updateFIVEminute("NASDAQ:TSM") // (Taiwan Semiconductor Manufacturing Company Ltd. - ADR)
updateFIVEminute("NASDAQ:NFLX") //
updateFIVEminute("NASDAQ:AMD") //
updateFIVEminute("NYSE:LIN") //
updateFIVEminute("NYSE:ORCL") //
updateFIVEminute("NYSE:SAP") // (SAP SE - ADR)
updateFIVEminute("NYSE:ACN") //
updateFIVEminute("NYSE:MCD") //
updateFIVEminute("NASDAQ:INTC") //
updateFIVEminute("NYSE:TMO") //
updateFIVEminute("NASDAQ:QCOM") //
updateFIVEminute("NYSE:CAT") //
updateFIVEminute("NYSE:DIS") //
updateFIVEminute("NASDAQ:AMAT") //
updateFIVEminute("NYSE:PM") //
updateFIVEminute("NYSE:NEE") //
updateFIVEminute("NASDAQ:TXN") //
updateFIVEminute("NYSE:AXP") //
updateFIVEminute("NYSE:HON") //
updateFIVEminute("NYSE:VZ") //
updateFIVEminute("NASDAQ:INTU") //
updateFIVEminute("NYSE:GE") //
updateFIVEminute("NYSE:UBER") //
updateFIVEminute("NYSE:NVS") // (Novartis AG - ADR)
updateFIVEminute("NASDAQ:AMGN") //
updateFIVEminute("NYSE:BA") //
updateFIVEminute("NYSE:RTX") //
updateFIVEminute("NYSE:IBM") //
updateFIVEminute("NYSE:COP") //
updateFIVEminute("NASDAQ:BKNG") //
updateFIVEminute("NYSE:LOW") //
updateFIVEminute("NYSE:GS") //
updateFIVEminute("NYSE:ELV") // (Elevance Health)
updateFIVEminute("NYSE:PFE") //
updateFIVEminute("NYSE:SPGI") //
updateFIVEminute("NYSE:UNP") //
updateFIVEminute("NASDAQ:ISRG") //
updateFIVEminute("NYSE:CI") //
updateFIVEminute("NYSE:MDT") // (Medtronic plc)
updateFIVEminute("NYSE:BLK") //
updateFIVEminute("NYSE:SONY") // (Sony Group Corporation - ADR)
updateFIVEminute("NYSE:ABT") //
updateFIVEminute("NYSE:PLD") //
updateFIVEminute("NASDAQ:SBUX") //
updateFIVEminute("NYSE:DE") //
updateFIVEminute("NYSE:LMT") //
updateFIVEminute("NYSE:BMY") //
updateFIVEminute("NASDAQ:GILD") //
updateFIVEminute("NYSE:CVS") //
updateFIVEminute("NYSE:SCHW") //
updateFIVEminute("NYSE:TM") // (Toyota Motor Corporation - ADR)
updateFIVEminute("NYSE:MDLZ") // (Mondelez International)
updateFIVEminute("NYSE:TJX") //
updateFIVEminute("NASDAQ:REGN") //
updateFIVEminute("NYSE:MMC") //
updateFIVEminute("NASDAQ:PYPL") //
updateFIVEminute("NYSE:ADP") // (Automatic Data Processing)
updateFIVEminute("NYSE:C") //
updateFIVEminute("NYSE:ETN") //
updateFIVEminute("NYSE:MO") // (Altria Group)
updateFIVEminute("NYSE:ZTS") // (Zoetis Inc.)
updateFIVEminute("NASDAQ:MU") // (Micron Technology)
updateFIVEminute("NYSE:PGR") // (Progressive Corp)
updateFIVEminute("NASDAQ:PANW") // (Palo Alto Networks)
updateFIVEminute("NYSE:DUK") // (Duke Energy)
updateFIVEminute("NYSE:SO") // (Southern Company)
updateFIVEminute("NASDAQ:CSX") // (CSX Corporation)
updateFIVEminute("NYSE:TFC") // (Truist Financial)
updateFIVEminute("NYSE:CB") // (Chubb Limited)
updateFIVEminute("NASDAQ:LRCX") // (Lam Research)
updateFIVEminute("NYSE:AON") //
updateFIVEminute("NYSE:BDX") // (Becton, Dickinson and Company)
updateFIVEminute("NYSE:EOG") // (EOG Resources)
updateFIVEminute("NASDAQ:MAR") // (Marriott International)