-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathNebula v1.52.txt
More file actions
executable file
·746 lines (571 loc) · 30.4 KB
/
Nebula v1.52.txt
File metadata and controls
executable file
·746 lines (571 loc) · 30.4 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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
//@version=5
indicator(title="Nebula", shorttitle="Nebula v1.52", overlay=true)
I_Like_Big_Butts_And_I_Cannot_Lie = input.bool(false, title="NOTE: Uncheck body/wick/border in your Settings for this indicator to display properly")
bShowCloud = input.bool(true, "Show the Cloud", group="Basic Settings")
cloudType = input.string(title="Cloud Type: ", options=["Relative Strength", "Money Flow", "Commodity Channel"], defval="Relative Strength", group="Basic Settings")
sCandleType = input.string(title="Candle Coloring: ", options=["None", "Vector", "Waddah", "Squeeze", "MACD", "Volume Delta"], defval="Waddah", group="Basic Settings")
Theme = input.string(title="Color Theme: ", options=["Standard", "Pinky and the Brain", "Color Blind", "Eye Popper"], defval="Standard", group="Basic Settings")
bShowSqueeze = input.bool(true, "Show Squeeze Relaxer Dots", group="Basic Settings", tooltip="Reversal indicator, based upon the TTM Squeeze")
bShowShark = input.bool(false, "Show Shark Icons", group="Basic Settings")
bShowTramp = input.bool(true, "Show Trampoline", group="Basic Settings", tooltip="Reversal indicator")
bShowEarlyReversal = input.bool(false, title="Show Early Reversal", group="Basic Settings", tooltip="Shows rejection of a higher/lower zone")
BnoShw = input.bool(false, title="Show LuxAlgo reversal signals", group="Basic Settings")
bDSR = input.bool(false, title="Show Dead Simple Reversal signals", group="Basic Settings", tooltip="This is my conversion of Dead Simple Reversal inside of Tradovate")
bUseBB = input.bool(false, "Show when bollinger bands are wicked", group="Basic Settings")
bTrackBar = input.bool(false, "Track bar gaps like FVG", group="Volume Imbalance Settings")
iBarExtend = input.int(50, "Number of bars to extend line", maxval=500, minval=10, group="Volume Imbalance Settings")
lWidth = input.int(3, "Line Width", group="Volume Imbalance Settings")
lStyle = input.string(title="Line Style", options=["Solid", "Dotted", "Dashed"], defval="Dotted", group="Volume Imbalance Settings")
sStyle = lStyle=="Solid" ? line.style_solid : lStyle=="Dashed" ? line.style_dashed : line.style_dotted
bExtend = lWidth==500 ? extend.right : extend.none
iLowCloud = input.int(80, title="Cloud Opacity Lower Limit (0=brightest, 100=invisible)", group="Advanced")
iHighCloud = input.int(50, title="Cloud Opacity Upper Limit (0=brightest, 100=invisible)", group="Advanced")
iTopBody = input.int(80, title="Top WAE Body Value", group="Advanced")
iTopBorder = input.int(33, title="Top WAE Border Value", group="Advanced")
iVolDeltaTop = input.int(300, title="Cumulative Volume Delta top end", group="Advanced")
ADX_Length = input.int(2, title="ADX_Length", group="Fantail VMA")
Weighting = input.float(10.0, title="Weighting", group="Fantail VMA")
MA_Length = input.int(6, minval=1, title="MA_Length", group="Fantail VMA")
colorBigGreen = Theme == "Standard" ? color.new(#00ff00, 0) : Theme == "Pinky and the Brain" ? color.new(#00f5f1, 0) : Theme == "Color Blind" ? color.new(#03fcf4, 0) : Theme == "Eye Popper" ? color.new(#00FF00, 0) : na
colorBigRed = Theme == "Standard" ? color.new(#ff0000, 0) : Theme == "Pinky and the Brain" ? color.new(#fc03f8, 0) : Theme == "Color Blind" ? color.new(#fca903, 0) : Theme == "Eye Popper" ? color.new(#FF0000, 0) : na
float iSource = 0.0
float MIN_CLOUD = 0.0
float MID_CLOUD = 0.0
float MAX_CLOUD = 0.0
var line[] ll = array.new_line()
redCandle = close < open
greenCandle = close > open
for [index, line] in ll
if (high > line.get_y1(line) and low < line.get_y1(line))
line.delete(array.get(ll, index))
if (redCandle and barstate.isconfirmed and bTrackBar)
if (redCandle[1] and open < close[1])
array.push(ll, line.new(bar_index, open, bar_index + iBarExtend, open, color=color.new(color.red, 50), width=lWidth, style=sStyle, extend=bExtend))
if (greenCandle and barstate.isconfirmed and bTrackBar)
if (greenCandle[1] and open > close[1])
array.push(ll, line.new(bar_index, open, bar_index + iBarExtend, open, color=color.new(color.lime, 50), width=lWidth, style=sStyle, extend=bExtend))
// =-=-=-=-=-=-=-=-=-=-=-=-= Cumulative Volume Delta © Ankit_1618 =-=-=-=-=-=-=-=-=-=-=-=-=-= //
upper_wick = close>open ? high-close : high-open
lower_wick = close>open ? open-low : close-low
spread = high-low
body_length = spread - (upper_wick + lower_wick)
percent_upper_wick = upper_wick/spread
percent_lower_wick = lower_wick/spread
percent_body_length = body_length/spread
buying_volume = close>open ? (percent_body_length + (percent_upper_wick + percent_lower_wick)/2)*volume : ((percent_upper_wick + percent_lower_wick)/2) * volume
selling_volume = close<open ? (percent_body_length + (percent_upper_wick + percent_lower_wick)/2)*volume : ((percent_upper_wick + percent_lower_wick)/2) * volume
cumulative_buying_volume = ta.ema(buying_volume,14)
cumulative_selling_volume = ta.ema(selling_volume,14)
cumulative_volume_delta = cumulative_buying_volume - cumulative_selling_volume
//plot(cumulative_volume_delta, color= cumulative_volume_delta>0 ? color.green : color.red, style=plot.style_columns, transp=61)
cCVDColor = color.white
cCVDBorder = color.white
cCVDWick = color.white
if cumulative_volume_delta > 0
cCVDColor := color.from_gradient(math.abs(cumulative_volume_delta), 0, iVolDeltaTop, color.new(colorBigGreen, 70), color.new(colorBigGreen, 0))
cCVDBorder := cCVDColor
cCVDWick := cCVDColor
else if cumulative_volume_delta < 0
cCVDColor := color.from_gradient(math.abs(cumulative_volume_delta), 0, iVolDeltaTop, color.new(colorBigRed, 70), color.new(colorBigRed, 0))
cCVDBorder := cCVDColor
cCVDWick := cCVDColor
plotcandle(sCandleType=="Volume Delta" ? open : na, high, low, close, color=cCVDColor, wickcolor=cCVDWick, bordercolor=cCVDBorder)
// =-=-=-=-=-=-=-=-=-=-=-=-= Dead Simple Reversal =-=-=-=-=-=-=-=-=-=-=-=-=-= //
c1 = close[1] < open[1] and close > open
c2 = close > open[1]
c3 = ta.lowest(low,3) < ta.lowest(low,50)[1] or ta.lowest(low,3) < ta.lowest(low,50)[2] or ta.lowest(low,3) < ta.lowest(low,50)[3]
buyDSR = c1 and c2 and c3
c4 = close[1] > open[1] and close < open
c5 = close < open[1]
c6 = ta.highest(high,3) > ta.highest(high,50)[1] or ta.highest(high,3) > ta.highest(high,50)[2] or ta.highest(high,3) > ta.highest(high,50)[3]
sellDSR = c4 and c5 and c6
plotshape(bDSR ? buyDSR : na, location=location.belowbar, style=shape.square, size=size.tiny)
plotshape(bDSR ? sellDSR : na, location=location.abovebar, style=shape.square, size=size.tiny)
// =-=-=-=-=-=-=-=-=-=-=-=-= Reversal Signals [LuxAlgo] =-=-=-=-=-=-=-=-=-=-=-=-=-= //
bSh = 'Completed'
ptLT = 'Step Line w/ Diamonds'
ptSR = 'Circles'
eSh = 'Completed'
Bcmpltd = bSh == 'Completed'
var noShw = false
cmpltd = eSh == 'Completed'
noShw := eSh == 'None' ? false : true
type bar
float o = open
float h = high
float l = low
float c = close
int i = bar_index
type trb
int bSC
float bSH
float bSL
int sSC
float sSH
float sSL
type tre
int bCC
float bC8
float bCHt
float bCH
float bCL
float bCLt
float bCD
int sCC
float sC8
float sCHt
float sCH
float sCL
float sCLt
float sCT
bar b = bar.new()
var trb S = trb.new()
var tre C = tre.new()
noC = #00000000
rdC = #f23645
gnC = #089981
whC = #ffffff
blC = #2962ff
grC = #787b86
bgC = #00bcd4
shpD = shape.labeldown
shpU = shape.labelup
locA = location.abovebar
locB = location.belowbar
dspN = false
pltL = plot.style_circles
pltS = size.tiny
f_xLX(_p, _l) =>
(_l > _p and _l < _p[1]) or (_l < _p and _l > _p[1])
f_lnS(_s) =>
s = switch _s
'Circles' => plot.style_circles
'Step Line' => plot.style_steplinebr
'Step Line w/ Diamonds' => plot.style_steplinebr
ptLB = f_lnS(ptLT)
ptRS = f_lnS(ptSR)
con = b.c < b.c[4]
if con
S.bSC := S.bSC == 9 ? 1 : S.bSC + 1
S.sSC := 0
else
S.sSC := S.sSC == 9 ? 1 : S.sSC + 1
S.bSC := 0
pbS = (b.l <= b.l[3] and b.l <= b.l[2]) or (b.l[1] <= b.l[3] and b.l[1] <= b.l[2])
bShowUppies = ((S.bSC == 9 and not pbS) or (S.bSC == 9 and pbS) or (S.bSC[1] == 8 and S.sSC == 1)) and (BnoShw and barstate.isconfirmed)
plotshape(bShowUppies ? 1 : na, title="Reversal Approaching", style=shape.xcross, location=location.belowbar, color=color.rgb(0, 255, 132), size=size.tiny)
bC8 = S.bSC[1] == 8 and S.sSC == 1
sR = ta.highest(9)
bSR = 0.0
bSR := S.bSC == 9 or bC8 ? sR : b.c > bSR[1] ? 0 : bSR[1]
if S.bSC == 1
S.bSL := b.l
if S.bSC > 0
S.bSL := math.min(b.l, S.bSL)
if b.l == S.bSL
S.bSH := b.h
bSD = 0.0
bSD := S.bSC == 9 ? 2 * S.bSL - S.bSH : b.c < bSD[1] or S.sSC == 9 ? 0 : bSD[1]
psS = (b.h >= b.h[3] and b.h >= b.h[2]) or (b.h[1] >= b.h[3] and b.h[1] >= b.h[2])
//if (S.sSC == 9 and not psS) or (S.sSC == 9 and psS) or (S.sSC[1] == 8 and S.bSC == 1) and BnoShw and barstate.isconfirmed
// f_AddCharStd(bar_index, "Down", colorBigRed, label.style_xcross, 2)
bShowDownies = ((S.sSC == 9 and not psS) or (S.sSC == 9 and psS) or (S.sSC[1] == 8 and S.bSC == 1)) and (BnoShw and barstate.isconfirmed)
plotshape(bShowDownies ? 1 : na, title="Reversal Approaching", style=shape.xcross, location=location.abovebar, color=color.rgb(255, 0, 0), size=size.tiny)
// =-=-=-=-=-=-=-=-=-=-=-=-= LuxAlgo - Market Structure (Fractal) =-=-=-=-=-=-=-=-=-=-=-=-=-= //
var float upOpen = na
var float upClose = na
var float downOpen = na
var float downClose = na
bGreenSignal = false
bRedSignal = false
length = 5 // default, min 3
type fractal
float value
int loc
bool iscrossed
var pT = int(length / 2)
n = bar_index
dhT = math.sum(math.sign(high - high[1]), pT)
dlT = math.sum(math.sign(low - low[1]), pT)
bullf = dhT == -pT and dhT[pT] == pT and high[pT] == ta.highest(length)
bearf = dlT == pT and dlT[pT] == -pT and low[pT] == ta.lowest(length)
bullf_count = ta.cum(bullf ? 1 : 0)
bearf_count = ta.cum(bearf ? 1 : 0)
var upperT = fractal.new()
var line lower_lvl = na
var label ms_lbl = na
var bull_ms_count = 0
var broken_sup = false
var os = 0
if bullf
upperT.value := high[pT]
upperT.loc := n-pT
upperT.iscrossed := false
if ta.crossover(close, upperT.value) and not upperT.iscrossed
upOpen := open
upClose := close
else if not broken_sup
lower_lvl.set_x2(n)
if close < lower_lvl.get_y2()
broken_sup := true
var lowerT = fractal.new()
var line upper_lvl = na
var broken_res = false
var bear_ms_count = 0
if bearf
lowerT.value := low[pT]
lowerT.loc := n-pT
lowerT.iscrossed := false
if ta.crossunder(close, lowerT.value) and not lowerT.iscrossed
downOpen := open
downClose := close
else if not broken_res
upper_lvl.set_x2(n)
if close > upper_lvl.get_y2()
broken_res := true
// ========================== MACD ================================
fast_ma = request.security(syminfo.tickerid, "", ta.ema(close, 12))
slow_ma = request.security(syminfo.tickerid, "", ta.ema(close, 26))
macd = fast_ma - slow_ma
signal = request.security(syminfo.tickerid, "", ta.ema(macd, 9))
float hist = macd - signal
trend_up = macd > signal
trend_dn = macd < signal
cross_UP = signal[1] >= macd[1] and signal < macd
cross_DN = signal[1] <= macd[1] and signal > macd
cross_UP_A = (signal[1] >= macd[1] and signal < macd) and macd > 0
cross_DN_B = (signal[1] <= macd[1] and signal > macd) and macd < 0
//trend_col = trend_up ? col_trnd_Up : trend_up ? col_macd : show_trend and trend_dn ? col_trnd_Dn: trend_dn ? col_macd : na
var bool histA_IsUp = false
var bool histA_IsDown = false
var bool histB_IsDown = false
var bool histB_IsUp = false
histA_IsUp := hist == hist[1] ? histA_IsUp[1] : hist > hist[1] and hist > 0
histA_IsDown := hist == hist[1] ? histA_IsDown[1] : hist < hist[1] and hist > 0
histB_IsDown := hist == hist[1] ? histB_IsDown[1] : hist < hist[1] and hist <= 0
histB_IsUp := hist == hist[1] ? histB_IsUp[1] : hist > hist[1] and hist <= 0
//hist_col = histA_IsUp ? col_grow_above : histA_IsDown ? col_fall_above : histB_IsDown ? col_grow_below : histB_IsUp ? col_fall_below :color.silver
cMDColor = color.white
cMDBorder = color.white
cMDWick = color.white
if histA_IsUp
cMDColor := color.from_gradient(math.abs(hist), 0, 3, color.new(colorBigGreen, 30), color.new(colorBigGreen, 0))
cMDBorder := colorBigGreen
cMDWick := cMDColor
else if histA_IsDown
cMDColor := color.from_gradient(math.abs(hist), 0, 3, color.new(colorBigGreen, 80), color.new(colorBigGreen, 30))
cMDBorder := colorBigGreen
cMDWick := cMDColor
if histB_IsUp
cMDColor := color.from_gradient(math.abs(hist), 0, 4, color.new(colorBigRed, 30), color.new(colorBigRed, 0))
cMDBorder := colorBigRed
cMDWick := cMDColor
else if histB_IsDown
cMDColor := color.from_gradient(math.abs(hist), 0, 4, color.new(colorBigRed, 80), color.new(colorBigRed, 30))
cMDBorder := colorBigRed
cMDWick := cMDColor
plotcandle(sCandleType=="MACD" ? open : na, high, low, close, color=cMDColor, wickcolor=cMDWick, bordercolor=cMDBorder)
// ========================== Bixord: FantailVMA ================================
rsi = ta.rsi(close, 14)
mfi = ta.mfi(hlc3, 14)
maCCI = ta.sma(hlc3, 20)
cci = (hlc3 - maCCI) / (0.015 * ta.dev(hlc3, 20))
if cloudType=="Relative Strength"
iSource := rsi
MIN_CLOUD := 20
MID_CLOUD := 50
MAX_CLOUD := 80
if cloudType=="Money Flow"
iSource := mfi
MIN_CLOUD := 20
MID_CLOUD := 50
MAX_CLOUD := 80
if cloudType=="Commodity Channel"
iSource := cci
MIN_CLOUD := 20
MID_CLOUD := -100
MAX_CLOUD := 100
VMA=close
VarMA=close
MA=close
STR = high-low
sPDI = 0.0
sMDI = 0.0
ADX=0.0
ADXR=0.0
Hi = high
Hi1 = high[1]
Lo = low
Lo1 = low[1]
Close1= close[1]
Bulls1 = 0.5*(math.abs(Hi-Hi1)+(Hi-Hi1))
Bears1 = 0.5*(math.abs(Lo1-Lo)+(Lo1-Lo))
Bears = Bulls1 > Bears1 ? 0 : (Bulls1 == Bears1 ? 0 : Bears1)
Bulls = Bulls1 < Bears1 ? 0 : (Bulls1 == Bears1 ? 0 : Bulls1)
if (bar_index > 0)
sPDI := (Weighting*sPDI[1] + Bulls)/(Weighting+1)
sMDI := (Weighting*sMDI[1] + Bears)/(Weighting+1)
TR = math.max(Hi-Lo,Hi-Close1)
if (bar_index > 0)
STR := (Weighting*STR[1] + TR)/(Weighting+1)
PDI = STR > 0 ? sPDI/STR : 0
MDI = STR > 0 ? sMDI/STR: 0
DX = (PDI + MDI) > 0 ? math.abs(PDI - MDI)/(PDI + MDI) : 0
if (bar_index > 0)
ADX := (Weighting*ADX[1] + DX)/(Weighting+1)
vADX = ADX
adxlow = ta.lowest(ADX, ADX_Length)
adxmax = ta.highest(ADX, ADX_Length)
ADXmin = math.min(1000000.0, adxlow)
ADXmax = math.max(-1.0, adxmax)
Diff = ADXmax - ADXmin
Const = Diff > 0 ? (vADX- ADXmin)/Diff : 0
if (bar_index > 0)
VarMA:=((2-Const)*VarMA[1]+Const*close)/2
FanVMA = ta.sma(VarMA,MA_Length)
// ========================== McGinley Dynamic ================================
mg = 0.0
mg := na(mg[1]) ? ta.ema(close, 14) : mg[1] + (close - mg[1]) / (14 * math.pow(close/mg[1], 4))
// ========================== Waddah Attar Explosion v1 by LazyBear ================================
sensitivity = input.int(150, title="Sensitivity", group="WAE")
fastLength = input.int(20, title="FastEMA Length", group="WAE")
slowLength = input.int(40, title="SlowEMA Length", group="WAE")
channelLength = input.int(20, title="BB Channel Length", group="WAE")
multWAE = input.float(2.0, title="BB Stdev Multiplier", group="WAE")
calc_macd(source, fastLength, slowLength) =>
fastMA = ta.ema(source, fastLength)
slowMA = ta.ema(source, slowLength)
fastMA - slowMA
calc_BBUpper(source, length, mult) =>
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
basis + dev
calc_BBLower(source, length, mult) =>
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
basis - dev
upper = calc_BBUpper(close, channelLength, multWAE)
lower = calc_BBLower(close, channelLength, multWAE)
t1 = (calc_macd(close, fastLength, slowLength) - calc_macd(close[1], fastLength, slowLength))*sensitivity
e1 = (upper - lower)
trendUpWAE = (t1 >= 0) ? t1 : 0
trendDownWAE = (t1 < 0) ? (-1*t1) : 0
cBodyColor = color.white
cBorderColor = color.white
cWickColor = color.white
if (trendUpWAE > e1 and trendUpWAE > 0)
cBodyColor := color.from_gradient(math.abs(trendUpWAE - e1), 1, iTopBody, color.new(colorBigGreen, 70), color.new(colorBigGreen, 0))
cBorderColor := color.from_gradient(math.abs(trendUpWAE - e1), 1, iTopBorder, color.new(colorBigGreen, 70), color.new(colorBigGreen, 0))
cWickColor := color.new(colorBigGreen, 0)
if (trendUpWAE < e1 and trendUpWAE > 0)
cBodyColor := color.new(colorBigGreen, 90)
cBorderColor := color.from_gradient(math.abs(e1 - trendUpWAE), 1, iTopBody, color.new(colorBigGreen, 70), color.new(colorBigGreen, 0))
cWickColor := color.new(colorBigGreen, 30)
if (trendDownWAE > e1 and trendDownWAE > 0)
cBodyColor := color.from_gradient(math.abs(trendDownWAE - e1), 1, iTopBody, color.new(colorBigRed, 50), color.new(colorBigRed, 0))
cBorderColor := color.from_gradient(math.abs(trendDownWAE - e1), 1, iTopBorder, color.new(colorBigRed, 50), color.new(colorBigRed, 0))
cWickColor := color.new(colorBigRed, 0)
if (trendDownWAE < e1 and trendDownWAE > 0)
cBodyColor := color.new(colorBigRed, 90)
cBorderColor := color.from_gradient(math.abs(e1 - trendDownWAE), 1, iTopBody, color.new(colorBigRed, 50), color.new(colorBigRed, 0))
cWickColor := color.new(colorBigRed, 30)
plotcandle(sCandleType=="Waddah" ? open : na, high, low, close, "", color=cBodyColor, wickcolor=cWickColor, bordercolor=cBorderColor)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= TRAMPOLINE =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
// Idea from "Serious Backtester" - https://www.youtube.com/watch?v=2hX7qTamOAQ
// Defaults are optimized for 30 min candles
iBBThreshold = input.float(0.0015, minval=0.0, title="Bollinger Lower Threshold", tooltip="0.003 for daily, 0.0015 for 30 min candles", group="TRAMPOLINE Settings")
RSIThreshold = input.int(25, minval=1, title="RSI Lower Threshold", tooltip="Normally 25", group="TRAMPOLINE Settings")
RSIDown = input.int(72, minval=1, title="RSI Upper Threshold", tooltip="Normally 75", group="TRAMPOLINE Settings")
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="TRAMPOLINE Settings")
rsiSourceInput = input(close, "RSI Source", group="TRAMPOLINE Settings")
lengthBB = input.int(20, minval=1, group="TRAMPOLINE Bollinger Bands")
srcBB = input(close, title="Source", group="TRAMPOLINE Bollinger Bands")
multBB = input.float(2.0, minval=0.001, maxval=50, title="StdDev", group="TRAMPOLINE Bollinger Bands")
offsetBB = input.int(0, "Offset", minval = -500, maxval = 500, group="TRAMPOLINE Bollinger Bands")
isRed = close < open
isGreen = close > open
basisBB = ta.sma(srcBB, lengthBB)
devBB = multBB * ta.stdev(srcBB, lengthBB)
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(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsiM = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
back1 = isRed[1] and rsiM[1] <= RSIThreshold and close[1] < lowerBB[1] and bbw[1] > iBBThreshold
back2 = isRed[2] and rsiM[2] <= RSIThreshold and close[2] < lowerBB[2] and bbw[2] > iBBThreshold
back3 = isRed[3] and rsiM[3] <= RSIThreshold and close[3] < lowerBB[3] and bbw[3] > iBBThreshold
back4 = isRed[4] and rsiM[4] <= RSIThreshold and close[4] < lowerBB[4] and bbw[4] > iBBThreshold
back5 = isRed[5] and rsiM[5] <= RSIThreshold and close[5] < lowerBB[5] and bbw[5] > iBBThreshold
for1 = isGreen[1] and rsiM[1] >= RSIDown and close[1] > upperBB[1] and bbw[1] > iBBThreshold
for2 = isGreen[2] and rsiM[2] >= RSIDown and close[2] > upperBB[2] and bbw[2] > iBBThreshold
for3 = isGreen[3] and rsiM[3] >= RSIDown and close[3] > upperBB[3] and bbw[3] > iBBThreshold
for4 = isGreen[4] and rsiM[4] >= RSIDown and close[4] > upperBB[4] and bbw[4] > iBBThreshold
for5 = isGreen[5] and rsiM[5] >= RSIDown and close[5] > upperBB[5] and bbw[5] > iBBThreshold
weGoUp = isGreen and (back1 or back2 or back3 or back4 or back5) and (high > high[1]) and barstate.isconfirmed
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]) and barstate.isconfirmed
downThrust = weGoDown and not weGoDown[1] and not weGoDown[2] and not weGoDown[3] and not weGoDown[4]
plotshape(bShowTramp and upThrust ? hl2 : na, title="Trampoline", text="T", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.new(colorBigGreen, 50), textcolor=color.white)
plotshape(bShowTramp and downThrust ? hl2 : na, title="Trampoline", text="T", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.new(colorBigRed, 50), textcolor=color.white)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Squeeze Relaxer version 2.1 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
// Average Directional Index
sqTolerance = input.int(2, title="Squeeze Tolerance (lower = more sensitive)", group="Relaxing Settings", tooltip="How many bars to look back on the squeeze indicator")
adxSqueeze = input.int(21, title="ADX Threshold for TTM Squeeze", group="Relaxing Settings", tooltip="Anything over 19 filters out low volume periods. Set to 11 as a default, feel free to increase to get less noise")
adxlen = input(14, title="ADX Smoothing", group="ADX")
dilen = input(14, title="DI Length", group="ADX")
dirmov(len) =>
up5 = ta.change(high)
down5 = -ta.change(low)
plusDM = na(up5) ? na : (up5 > down5 and up5 > 0 ? up5 : 0)
minusDM = na(down5) ? na : (down > up5 and down5 > 0 ? down5 : 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(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
adxValue = adx(dilen, adxlen)
sigabove19 = adxValue > adxSqueeze
var cGreen = 0
var cRed = 0
var pos = false
var neg = false
sqlength = 20
multQ = 2.0
lengthKC = 20
multKC = 1.5
useTrueRange = true
source = close
basis = ta.sma(source, sqlength)
dev1 = multKC * ta.stdev(source, sqlength)
upperBBsq = basis + dev1
lowerBBsq = basis - dev1
ma = ta.sma(source, lengthKC)
rangeQ = high - low
rangema = ta.sma(rangeQ, lengthKC)
upperKC = ma + rangema * multKC
lowerKC = ma - rangema * multKC
sqzOn = (lowerBBsq > lowerKC) and (upperBBsq < upperKC)
sqzOff = (lowerBBsq < lowerKC) and (upperBBsq > upperKC)
noSqz = (sqzOn == false) and (sqzOff == false)
avg1 = math.avg(ta.highest(high, lengthKC), ta.lowest(low, lengthKC))
avg2 = math.avg(avg1, ta.sma(close, lengthKC))
val = ta.linreg(close - avg2, lengthKC, 0)
pos := false
neg := false
// if squeeze is bright RED, increment by one
if (val < nz(val[1]) and val < 5 and not sqzOn)
cRed := cRed + 1
// if squeeze is bright GREEN, increment by one
if (val > nz(val[1]) and val > 5 and not sqzOn)
cGreen := cGreen + 1
// if bright RED squeeze is now dim, momentum has changed. Is ADX also above 19? - add a marker to chart
if (val > nz(val[1]) and cRed > sqTolerance and val < 5 and not pos[1] and sigabove19 == true)
cRed := 0
pos := true
// if bright GREEN squeeze is now dim, momentum has changed. Is ADX also above 19? - add a marker to chart
if (val < nz(val[1]) and cGreen > sqTolerance and val > 5 and not neg[1] and sigabove19 == true)
cGreen := 0
neg := true
buySignal1 = pos and barstate.isconfirmed
sellSignal1 = neg and barstate.isconfirmed
plotshape(bShowSqueeze and pos ? pos : na, title="Squeeze Buy Signal", style=shape.diamond, location=location.belowbar, color=color.rgb(255, 230, 0), size=size.tiny)
plotshape(bShowSqueeze and neg ? neg : na, title="Squeeze Sell Signal", style=shape.diamond, location=location.abovebar, color=color.rgb(255, 230, 0), size=size.tiny)
cSQColor = color.white
cSQBorder = color.white
cSQWick = color.white
if val > 0
if val > nz(val[1])
cSQColor := color.from_gradient(math.abs(val), 0, 30, color.new(colorBigGreen, 50), color.new(colorBigGreen, 0))
cSQBorder := colorBigGreen
cSQWick := cSQColor
if val < nz(val[1])
cSQColor := color.new(colorBigGreen, 70)
cSQBorder := color.new(color.black, 100)
cSQWick := cSQColor
else
if val < nz(val[1])
cSQColor := color.from_gradient(math.abs(val), 0, 30, color.new(colorBigRed, 50), color.new(colorBigRed, 0))
cSQBorder := colorBigRed
cSQWick := cSQColor
if val > nz(val[1])
cSQColor := color.new(colorBigRed, 50)
cSQBorder := color.new(color.black, 100)
cSQWick := cSQColor
plotcandle(sCandleType=="Squeeze" ? open : na, high, low, close, color=cSQColor, wickcolor=cSQWick, bordercolor=cSQBorder)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= VECTOR CANDLES =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
import TradersReality/Traders_Reality_Lib/2 as trLib
color redVectorColor = colorBigRed
color greenVectorColor = colorBigGreen
color violetVectorColor = input.color(title='Violet',defval=color.fuchsia, inline='vectors', group="Vector Candle Settings")
color blueVectorColor = input.color(title='Blue', defval=color.rgb(83, 144, 249), inline='vectors', tooltip='Bull bars are green and bear bars are red when the bar is with volume >= 200% of the average volume of the 10 previous bars, or bars where the product of candle spread x candle volume is >= the highest for the 10 previous bars.\n Bull bars are blue and bear are violet when the bar is with with volume >= 150% of the average volume of the 10 previous bars.', group="Vector Candle Settings")
color regularCandleUpColor = input.color(title='Regular: Up Candle', defval=color.new(#02a433, 99), inline='nonVectors', group="Vector Candle Settings")
color regularCandleDownColor = input.color(title='Regular: Down Candle', defval=color.new(#a10101, 99), inline='nonVectors', tooltip='Bull bars are light gray and bear are dark gray when none of the red/green/blue/violet vector conditions are met.', group="Vector Candle Settings")
bool overrideSym = false
string pvsraSym = ''
bool colorOverride = true
pvsraVolume(overrideSymbolX, pvsraSymbolX, tickerIdX) =>
request.security(overrideSymbolX ? pvsraSymbolX : tickerIdX, '', [volume,high,low,close,open], barmerge.gaps_off, barmerge.lookahead_off)
[pvsraVolume, pvsraHigh, pvsraLow, pvsraClose, pvsraOpen] = pvsraVolume(overrideSym, pvsraSym, syminfo.tickerid)
[pvsraColor, alertFlag, averageVolume, volumeSpread, highestVolumeSpread] = trLib.calcPvsra(pvsraVolume, pvsraHigh, pvsraLow, pvsraClose, pvsraOpen, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor, regularCandleDownColor, regularCandleUpColor)
bVectorGreen = pvsraColor == greenVectorColor
bVectorRed = pvsraColor == redVectorColor
plotcandle(sCandleType=="Vector" ? open : na, high, low, close, color=pvsraColor, wickcolor=pvsraColor, bordercolor=pvsraColor)
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= TOTAL RECALL =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
if (bVectorGreen and (close[0] == upClose[0] or close[1] == upClose[1] or close[2] == upClose[2] or close[3] == upClose[3]))
bGreenSignal := true
plotshape(bGreenSignal and bShowEarlyReversal and barstate.isconfirmed ? 1 : na, title="Reversal Approaching", style=shape.cross, location=location.abovebar, color=color.yellow, size=size.tiny)
//plotcandle(open, high, low, close, "", color=pvsraColor, wickcolor=pvsraColor, bordercolor=color.rgb(255, 0, 0))
if (bVectorRed and (close[0] == downClose[0] or close[1] == downClose[1] or close[2] == downClose[2] or close[3] == downClose[3]))
bRedSignal := true
plotshape(bRedSignal and bShowEarlyReversal and barstate.isconfirmed ? 1 : na, title="Reversal Approaching", style=shape.cross, location=location.belowbar, color=color.yellow, size=size.tiny)
//plotcandle(open, high, low, close, "", color=pvsraColor, wickcolor=pvsraColor, bordercolor=color.rgb(0, 255, 132))
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= THE SHARK =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
bApply25and75 = input(false, title="Apply 25/75 RSI rule", group="Shark Settings")
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
ema400 = ta.ema(close, 400)
ema800 = ta.ema(close, 800)
wapwap = ta.vwap(close)
bTouchedLine = (ema50<high and ema50>low) or (ema200<high and ema200>low) or (ema400<high and ema400>low) or (ema800<high and ema800>low) or (wapwap<high and wapwap>low)
basis5 = ta.sma(rsiM, 30)
dev = 2.0 * ta.stdev(rsiM, 30)
upper7 = basis5 + dev
lower7 = basis5 - dev
bBelow25 = rsiM < 26
bAbove75 = rsiM > 74
if not bApply25and75
bBelow25 := true
bAbove75 := true
bShowSharkDown = (rsiM > upper7 and bAbove75) and barstate.isconfirmed
bShowSharkUp = (rsiM < lower7 and bBelow25) and barstate.isconfirmed
plotchar(bShowShark and bShowSharkUp ? hlcc4 : na, char="🦈", title="Shark", location=location.belowbar, size=size.tiny)
plotchar(bShowShark and bShowSharkDown ? hlcc4 : na, char="🦈", title="Shark", location=location.abovebar, size=size.tiny)
// ===================================== JOHN WICK SETTINGS ==================================================================
upWick50PercentLarger = close > open and math.abs(high - close) > math.abs(open - close)
downWick50PercentLarger = close < open and math.abs(low - close) > math.abs(open - close)
// JOHN WICK BOLLINGER BANDS
wlengthBB = input.int(20, minval=1, group="Wicking Bollinger Bands")
wsrcBB = input(close, title="Source", group="Wicking Bollinger Bands")
wmultBB = input.float(2.5, minval=0.001, maxval=50, title="StdDev", group="Wicking Bollinger Bands")
woffsetBB = input.int(0, "Offset", minval = -500, maxval = 500, group="Wicking Bollinger Bands")
wbasisBB = ta.sma(wsrcBB, wlengthBB)
wdevBB = wmultBB * ta.stdev(wsrcBB, wlengthBB)
wupperBB = wbasisBB + wdevBB
wlowerBB = wbasisBB - wdevBB
plotchar(low <= wlowerBB and close >= wlowerBB and close < open and bUseBB ? 1 : na, char="ß", title="Bollinger Bands", location=location.belowbar, size=size.tiny, color=colorBigGreen)
plotchar(high >= wupperBB and close < wupperBB and close > open and bUseBB ? 1 : na, char="ß", title="Bollinger Bands", location=location.abovebar, size=size.tiny, color=colorBigRed)
// ========================== PLOTS ================================
transparencyValue= math.abs(FanVMA - mg)
cColor = if FanVMA > mg
color.from_gradient(iSource, MID_CLOUD, MAX_CLOUD, color.new(colorBigGreen, iLowCloud), color.new(colorBigGreen, iHighCloud))
else
color.from_gradient(iSource, MIN_CLOUD, MID_CLOUD, color.new(colorBigRed, iLowCloud), color.new(colorBigRed, iHighCloud))
lineMD = plot(bShowCloud ? mg : na, title="", color=color.new(color.blue, 100))
FVMA = plot(bShowCloud ? FanVMA : na, color=color.new(color.white, 100), title="Bixord FVMA")
fill(FVMA, lineMD, color=cColor, title="Cloud")