-
Notifications
You must be signed in to change notification settings - Fork 7
/
MACD
1048 lines (947 loc) · 45.7 KB
/
MACD
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
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//@version=4
// This source code is subject to the terms of the Creative Commons Zero v1.0 Universal license
// https://github.com/fikira12/Divergences
// Copyright (c) 2019 @fikira
study(title="[fikira] MACD + Divergences 2", shorttitle="MACD + DIV 2", max_bars_back=500)
Pick = input(false, title="-<><><><><><>[Pick Your Poison]<><><><><><>-")
input = input("macd", options=["macd", "signal", "hist"], title="Source Divergences")
ST = input(false, title="-<><><><><><>[Calculation Period]<><><><><><>-")
// Because the script is heavy in calculation it is limited in time
// (= inspired from a script of "Che_Trader")
_Year = input(2019, "Start calculation (Year)")
_Month = input(1, "Start calculation (Month)")
_Start = timestamp(_Year, _Month, 1, 1, 1)
//_Start = timeframe.isintraday ? timestamp(year, month, dayofweek, 0, 0) : timestamp(_Year, _Month, _Day, 0, 0)
Year_ = input(2099, "Stop calculation (Year)")
Stop_ = timestamp(Year_, 12, 31, 23, 59)
Period = time >= _Start and time <= Stop_ ? true : false
// MACD
MACD = input(false, title="-<><><><><><>[MACD]<><><><><><>-")
fast_length = input(title="MACD Fast Length", type=input.integer, defval=12)
slow_length = input(title="MACD Slow Length", type=input.integer, defval=26)
src = input(title="MACD Source", type=input.source, defval=close)
signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)
sma_source = input(title="SMA(Oscillator) instead of EMA ?", type=input.bool, defval=false)
sma_signal = input(title="SMA(Signal Line) instead of EMA ?", type=input.bool, defval=false)
// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00
// Calculating
fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)
slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)
hist = macd - signal
plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below) ), transp=30 )
plot(macd, title="MACD", color=col_macd, linewidth=2, transp=0)
plot(signal, title="Signal", color=col_signal, linewidth=2, transp=0)
plot(crossunder(macd, signal) ? signal : na, color=col_signal, style = plot.style_cross, linewidth = 2, transp = 0, title="X MACD under signal")
plot(crossover(macd, signal) ? signal : na, color=col_macd, style = plot.style_cross, linewidth = 2, transp = 0, title="X MACD over signal")
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DIV = input(false, title="-<><><><><><>[Divergences]<><><><><><>-")
nwh = close > open ? close : close < open ? open : na
nwl = close > open ? open : close < open ? close : na
show_div = input(true, title="Show Regular Divergences")
show_hiddiv = input(true, title="Show Hidden Divergences")
arrows = input(true, title="Just Show Arrows (No Lines)")
dot = input(title="[Divergences] Line Type", defval="solid", options=["solid", "dashed", "dotted"])
lw = input(1, minval=0, maxval=10, title="[Divergences] linewidth")
_dot = line.style_solid
if dot == "solid"
_dot := line.style_solid
else
if dot == "dashed"
_dot := line.style_dashed
else
if dot == "dotted"
_dot := line.style_dotted
//solid = input(title="Line Type [Connections]", defval="solid", options=["solid", "dashed", "dotted"])
//_solid = line.style_solid
//if solid == "solid"
// _solid := line.style_solid
//else
// if solid == "dashed"
// _solid := line.style_dashed
// else
// if solid == "dotted"
// _solid := line.style_dotted
symbl = input(title="[Divergences] Bullish Labels", defval="Label Up",
options=["Label Up", "Arrow Up", "Triangle Up", "Circle", "Square", "Xcross", "Cross", "Flag", "Diamond"])
_symbl = label.style_labelup
if symbl == "Label Up"
_symbl := label.style_labelup
else
if symbl == "Arrow Up"
_symbl := label.style_arrowup
else
if symbl == "Triangle Up"
_symbl := label.style_triangleup
else
if symbl == "Circle"
_symbl := label.style_circle
else
if symbl == "Square"
_symbl := label.style_square
else
if symbl == "Xcross"
_symbl := label.style_xcross
else
if symbl == "Cross"
_symbl := label.style_cross
else
if symbl == "Flag"
_symbl := label.style_flag
else
if symbl == "Diamond"
_symbl := label.style_diamond
symbr = input(title="[Divergences] Bearish Labels", defval="Label Down",
options=["Label Down", "Arrow Down", "Triangle Down", "Circle", "Square", "Xcross", "Cross", "Flag", "Diamond"])
_symbr = label.style_labeldown
if symbr == "Label Down"
_symbr := label.style_labeldown
else
if symbr == "Arrow Down"
_symbr := label.style_arrowdown
else
if symbr == "Triangle Down"
_symbr := label.style_triangledown
else
if symbr == "Circle"
_symbr := label.style_circle
else
if symbr == "Square"
_symbr := label.style_square
else
if symbr == "Xcross"
_symbr := label.style_xcross
else
if symbr == "Cross"
_symbr := label.style_cross
else
if symbr == "Flag"
_symbr := label.style_flag
else
if symbr == "Diamond"
_symbr := label.style_diamond
size = input(title="[Divergences] Label Size", defval="Auto",
options=["Tiny", "Small", "Normal", "Auto"])
_size = size.auto
if size == "Tiny"
_size := size.tiny
else
if size == "Small"
_size := size.small
else
if size == "Normal"
_size := size.normal
else
if size == "Auto"
_size := size.auto
Bars = input(false, title="-<><><><><><>[LeftBars RightBars]<><><><><><>-")
LB = input(5, title = "LeftBars")
RB = input(0, title = "RightBars")
_x = input(false, title="Custom Div Period?")
x = _x ? input(7, minval=7, title="Custom Div Period:") : na
rsi = 0.0
if Period and input == "macd"
rsi := macd
else
if Period and input == "signal"
rsi := signal
else
if Period and input == "hist"
rsi := hist
ph = Period ? pivothigh(nwh, LB, RB) : na
pl = Period ? pivotlow(nwl, LB, RB) : na
rh = Period and macd <= macd[1] and macd[1] >= macd[2] ? pivothigh(rsi, LB, RB) : na
rl = Period and macd >= macd[1] and macd[1] <= macd[2] ? pivotlow(rsi, LB, RB) : na
//plot(rl, color=color.lime, linewidth=2, offset=-1)
//plot(rh, color=color.red, linewidth=2, offset=-1)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rsih0 = Period ? valuewhen(rh, rsi[1], 0) : na
rsil0 = Period ? valuewhen(rl, rsi[1], 0) : na
hh0 = Period and rsih0 ? valuewhen(rh, nwh[1], 0) : na
ll0 = Period and rsil0 ? valuewhen(rl, nwl[1], 0) : na
rsih1 = Period ? valuewhen(rh, rsi[1], 1) : na
rsil1 = Period ? valuewhen(rl, rsi[1], 1) : na
hh1 = Period and rsih1 ? valuewhen(rh, nwh[1], 1) : na
ll1 = Period and rsil1 ? valuewhen(rl, nwl[1], 1) : na
rsih2 = Period ? valuewhen(rh, rsi[1], 2) : na
rsil2 = Period ? valuewhen(rl, rsi[1], 2) : na
hh2 = Period and rsih2 ? valuewhen(rh, nwh[1], 2) : na
ll2 = Period and rsil2 ? valuewhen(rl, nwl[1], 2) : na
rsih3 = Period ? valuewhen(rh, rsi[1], 3) : na
rsil3 = Period ? valuewhen(rl, rsi[1], 3) : na
hh3 = Period and rsih3 ? valuewhen(rh, nwh[1], 3) : na
ll3 = Period and rsil3 ? valuewhen(rl, nwl[1], 3) : na
rsih4 = Period ? valuewhen(rh, rsi[1], 4) : na
rsil4 = Period ? valuewhen(rl, rsi[1], 4) : na
hh4 = Period and rsih4 ? valuewhen(rh, nwh[1], 4) : na
ll4 = Period and rsil4 ? valuewhen(rl, nwl[1], 4) : na
rsih5 = Period ? valuewhen(rh, rsi[1], 5) : na
rsil5 = Period ? valuewhen(rl, rsi[1], 5) : na
hh5 = Period and rsih5 ? valuewhen(rh, nwh[1], 5) : na
ll5 = Period and rsil5 ? valuewhen(rl, nwl[1], 5) : na
rsih6 = Period ? valuewhen(rh, rsi[1], 6) : na
rsil6 = Period ? valuewhen(rl, rsi[1], 6) : na
hh6 = Period and rsih6 ? valuewhen(rh, nwh[1], 6) : na
ll6 = Period and rsil6 ? valuewhen(rl, nwl[1], 6) : na
rsihx = Period ? valuewhen(rh, rsi[1], x) : na
rsilx = Period ? valuewhen(rl, rsi[1], x) : na
hhx = Period and rsihx ? valuewhen(rh, nwh[1], x) : na
llx = Period and rsilx ? valuewhen(rl, nwl[1], x) : na
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////// Bullish Divergences = close LL - RSI HL /////////////////////////////
rsi_HL1 = rsil0 > rsil1
close_LL1 = ll0 < ll1
rsi_HL2 = rsil0 > rsil2
and rsil1 > (rsil2 + ((rsil0 - rsil2) / 2))
close_LL2 = ll0 < ll2
rsi_HL3 = rsil0 > rsil3
and rsil1 > (rsil3 + ((rsil0 - rsil3) / 2))
and rsil2 > (rsil3 + ((rsil0 - rsil3) / 2))
close_LL3 = ll0 < ll3
rsi_HL4 = rsil0 > rsil4
and rsil1 > (rsil4 + ((rsil0 - rsil4) / 2))
and rsil2 > (rsil4 + ((rsil0 - rsil4) / 2))
and rsil3 > (rsil4 + ((rsil0 - rsil4) / 2))
close_LL4 = ll0 < ll4
rsi_HL5 = rsil0 > rsil5
and rsil1 > (rsil5 + ((rsil0 - rsil5) / 2))
and rsil2 > (rsil5 + ((rsil0 - rsil5) / 2))
and rsil3 > (rsil5 + ((rsil0 - rsil5) / 2))
and rsil4 > (rsil5 + ((rsil0 - rsil5) / 2))
close_LL5 = ll0 < ll5
rsi_HL6 = rsil0 > rsil6
and rsil1 > (rsil6 + ((rsil0 - rsil6) / 2))
and rsil2 > (rsil6 + ((rsil0 - rsil6) / 2))
and rsil3 > (rsil6 + ((rsil0 - rsil6) / 2))
and rsil4 > (rsil6 + ((rsil0 - rsil6) / 2))
and rsil5 > (rsil6 + ((rsil0 - rsil6) / 2))
close_LL6 = ll0 < ll6
rsi_HLx = rsil0 > rsilx
and rsil1 > (rsilx + ((rsil0 - rsilx) / 2))
and rsil2 > (rsilx + ((rsil0 - rsilx) / 2))
and rsil3 > (rsilx + ((rsil0 - rsilx) / 2))
and rsil4 > (rsilx + ((rsil0 - rsilx) / 2))
and rsil5 > (rsilx + ((rsil0 - rsilx) / 2))
and rsil6 > (rsilx + ((rsil0 - rsilx) / 2))
close_LLx = ll0 < llx
div_bull_1 = close_LL1 and rsi_HL1
div_bull_2 = close_LL2 and rsi_HL2
div_bull_3 = close_LL3 and rsi_HL3
div_bull_4 = close_LL4 and rsi_HL4
div_bull_5 = close_LL5 and rsi_HL5
div_bull_6 = close_LL6 and rsi_HL6
div_bull_x = close_LLx and rsi_HLx
////////// Bearish Divergences = close HH - RSI LH /////////////////////////////
rsi_LH1 = rsih0 < rsih1
close_HH1 = hh0 > hh1
rsi_LH2 = rsih0 < rsih2
and rsih1 < (rsih2 - ((rsih2 - rsih0) / 2))
close_HH2 = hh0 > hh2
rsi_LH3 = rsih0 < rsih3
and rsih1 < (rsih3 - ((rsih3 - rsih0) / 2))
and rsih2 < (rsih3 - ((rsih3 - rsih0) / 2))
close_HH3 = hh0 > hh3
rsi_LH4 = rsih0 < rsih4
and rsih1 < (rsih4 - ((rsih4 - rsih0) / 2))
and rsih2 < (rsih4 - ((rsih4 - rsih0) / 2))
and rsih3 < (rsih4 - ((rsih4 - rsih0) / 2))
close_HH4 = hh0 > hh4
rsi_LH5 = rsih0 < rsih5
and rsih1 < (rsih5 - ((rsih5 - rsih0) / 2))
and rsih2 < (rsih5 - ((rsih5 - rsih0) / 2))
and rsih3 < (rsih5 - ((rsih5 - rsih0) / 2))
and rsih4 < (rsih5 - ((rsih5 - rsih0) / 2))
close_HH5 = hh0 > hh5
rsi_LH6 = rsih0 < rsih6
and rsih1 < (rsih6 - ((rsih6 - rsih0) / 2))
and rsih2 < (rsih6 - ((rsih6 - rsih0) / 2))
and rsih3 < (rsih6 - ((rsih6 - rsih0) / 2))
and rsih4 < (rsih6 - ((rsih6 - rsih0) / 2))
and rsih5 < (rsih6 - ((rsih6 - rsih0) / 2))
close_HH6 = hh0 > hh6
rsi_LHx = rsih0 < rsihx
and rsih1 < (rsihx - ((rsihx - rsih0) / 2))
and rsih2 < (rsihx - ((rsihx - rsih0) / 2))
and rsih3 < (rsihx - ((rsihx - rsih0) / 2))
and rsih4 < (rsihx - ((rsihx - rsih0) / 2))
and rsih5 < (rsihx - ((rsihx - rsih0) / 2))
and rsih6 < (rsihx - ((rsihx - rsih0) / 2))
close_HHx = hh0 > hhx
div_bear_1 = close_HH1 and rsi_LH1
div_bear_2 = close_HH2 and rsi_LH2
div_bear_3 = close_HH3 and rsi_LH3
div_bear_4 = close_HH4 and rsi_LH4
div_bear_5 = close_HH5 and rsi_LH5
div_bear_6 = close_HH6 and rsi_LH6
div_bear_x = close_HHx and rsi_LHx
////////// Hidden Bullish Divergences = close HL - RSI LL //////////////////////
rsi_LL1 = rsil0 < rsil1
close_HL1 = ll0 > ll1
rsi_LL2 = rsil0 < rsil2
and rsil1 > (rsil2 + ((rsil2 - rsil0) / 2))
close_HL2 = ll0 > ll2
rsi_LL3 = rsil0 < rsil3
and rsil1 > (rsil3 + ((rsil3 - rsil0) / 2))
and rsil2 > (rsil3 + ((rsil3 - rsil0) / 2))
close_HL3 = ll0 > ll3
rsi_LL4 = rsil0 < rsil4
and rsil1 > (rsil4 + ((rsil4 - rsil0) / 2))
and rsil2 > (rsil4 + ((rsil4 - rsil0) / 2))
and rsil3 > (rsil4 + ((rsil4 - rsil0) / 2))
close_HL4 = ll0 > ll4
rsi_LL5 = rsil0 < rsil5
and rsil1 > (rsil5 + ((rsil5 - rsil0) / 2))
and rsil2 > (rsil5 + ((rsil5 - rsil0) / 2))
and rsil3 > (rsil5 + ((rsil5 - rsil0) / 2))
and rsil4 > (rsil5 + ((rsil5 - rsil0) / 2))
close_HL5 = ll0 > ll5
rsi_LL6 = rsil0 < rsil6
and rsil1 > (rsil6 + ((rsil6 - rsil0) / 2))
and rsil2 > (rsil6 + ((rsil6 - rsil0) / 2))
and rsil3 > (rsil6 + ((rsil6 - rsil0) / 2))
and rsil4 > (rsil6 + ((rsil6 - rsil0) / 2))
and rsil5 > (rsil6 + ((rsil6 - rsil0) / 2))
close_HL6 = ll0 > ll6
rsi_LLx = rsil0 < rsilx
and rsil1 > (rsilx + ((rsilx - rsil0) / 2))
and rsil2 > (rsilx + ((rsilx - rsil0) / 2))
and rsil3 > (rsilx + ((rsilx - rsil0) / 2))
and rsil4 > (rsilx + ((rsilx - rsil0) / 2))
and rsil5 > (rsilx + ((rsilx - rsil0) / 2))
and rsil6 > (rsilx + ((rsilx - rsil0) / 2))
close_HLx = ll0 > llx
hid_div_bull_1 = close_HL1 and rsi_LL1
hid_div_bull_2 = close_HL2 and rsi_LL2
hid_div_bull_3 = close_HL3 and rsi_LL3
hid_div_bull_4 = close_HL4 and rsi_LL4
hid_div_bull_5 = close_HL5 and rsi_LL5
hid_div_bull_6 = close_HL6 and rsi_LL6
hid_div_bull_x = close_HLx and rsi_LLx
////////// Hidden Bearish Divergences = close LH - RSI HH //////////////////////
rsi_HH1 = rsih0 > rsih1
close_LH1 = hh0 < hh1
rsi_HH2 = rsih0 > rsih2
and rsih1 < (rsih2 + ((rsih0 - rsih2) / 2))
close_LH2 = hh0 < hh2
rsi_HH3 = rsih0 > rsih3
and rsih1 < (rsih3 + ((rsih0 - rsih3) / 2))
and rsih2 < (rsih3 + ((rsih0 - rsih3) / 2))
close_LH3 = hh0 < hh3
rsi_HH4 = rsih0 > rsih4
and rsih1 < (rsih4 + ((rsih0 - rsih4) / 2))
and rsih2 < (rsih4 + ((rsih0 - rsih4) / 2))
and rsih3 < (rsih4 + ((rsih0 - rsih4) / 2))
close_LH4 = hh0 < hh4
rsi_HH5 = rsih0 > rsih5
and rsih1 < (rsih5 + ((rsih0 - rsih5) / 2))
and rsih2 < (rsih5 + ((rsih0 - rsih5) / 2))
and rsih3 < (rsih5 + ((rsih0 - rsih5) / 2))
and rsih4 < (rsih5 + ((rsih0 - rsih5) / 2))
close_LH5 = hh0 < hh5
rsi_HH6 = rsih0 > rsih6
and rsih1 < (rsih6 + ((rsih0 - rsih6) / 2))
and rsih2 < (rsih6 + ((rsih0 - rsih6) / 2))
and rsih3 < (rsih6 + ((rsih0 - rsih6) / 2))
and rsih4 < (rsih6 + ((rsih0 - rsih6) / 2))
and rsih5 < (rsih6 + ((rsih0 - rsih6) / 2))
close_LH6 = hh0 < hh6
rsi_HHx = rsih0 > rsihx
and rsih1 < (rsihx + ((rsih0 - rsihx) / 2))
and rsih2 < (rsihx + ((rsih0 - rsihx) / 2))
and rsih3 < (rsihx + ((rsih0 - rsihx) / 2))
and rsih4 < (rsihx + ((rsih0 - rsihx) / 2))
and rsih5 < (rsihx + ((rsih0 - rsihx) / 2))
and rsih6 < (rsihx + ((rsih0 - rsihx) / 2))
close_LHx = hh0 < hhx
hid_div_bear_1 = close_LH1 and rsi_HH1
hid_div_bear_2 = close_LH2 and rsi_HH2
hid_div_bear_3 = close_LH3 and rsi_HH3
hid_div_bear_4 = close_LH4 and rsi_HH4
hid_div_bear_5 = close_LH5 and rsi_HH5
hid_div_bear_6 = close_LH6 and rsi_HH6
hid_div_bear_x = close_LHx and rsi_HHx
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
plotchar(arrows and div_bull_1 and not div_bull_1[1] and show_div, char="↑︎︎", title="Bull Div 1",
location=location.bottom, color= color.green, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and div_bull_2 and not div_bull_2[1] and show_div, char="↑︎︎", title="Bull Div 2",
location=location.bottom, color= color.green, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and div_bull_3 and not div_bull_3[1] and show_div, char="↑︎︎", title="Bull Div 3",
location=location.bottom, color= color.green, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and div_bull_4 and not div_bull_4[1] and show_div, char="↑︎︎", title="Bull Div 4",
location=location.bottom, color= color.lime, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and div_bull_5 and not div_bull_5[1] and show_div, char="↑︎︎", title="Bull Div 5",
location=location.bottom, color= color.lime, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and div_bull_6 and not div_bull_6[1] and show_div, char="↑︎︎", title="Bull Div 6",
location=location.bottom, color= color.lime, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and div_bull_x and not div_bull_x[1] and show_div, char="↑︎︎", title="Bull Div x",
location=location.bottom, color= color.aqua, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and div_bear_1 and not div_bear_1[1] and show_div, char="↓︎︎", title="Bear Div 1",
location=location.top, color= color.orange, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and div_bear_2 and not div_bear_2[1] and show_div, char="↓︎︎", title="Bear Div 2",
location=location.top, color= color.orange, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and div_bear_3 and not div_bear_3[1] and show_div, char="↓︎︎", title="Bear Div 3",
location=location.top, color= color.orange, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and div_bear_4 and not div_bear_4[1] and show_div, char="↓︎︎", title="Bear Div 4",
location=location.top, color= color.red, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and div_bear_5 and not div_bear_5[1] and show_div, char="↓︎︎", title="Bear Div 5",
location=location.top, color= color.red, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and div_bear_6 and not div_bear_6[1] and show_div, char="↓︎︎", title="Bear Div 6",
location=location.top, color= color.red, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and div_bear_x and not div_bear_x[1] and show_div, char="↓︎︎", title="Bear Div x",
location=location.top, color= color.purple, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bull_1 and not hid_div_bull_1[1] and show_hiddiv, char="↑︎︎", title="Hidden Bull Div 1",
location=location.bottom, color= color.white, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and hid_div_bull_2 and not hid_div_bull_2[1] and show_hiddiv, char="↑︎︎", title="Hidden Bull Div 2",
location=location.bottom, color= color.white, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and hid_div_bull_3 and not hid_div_bull_3[1] and show_hiddiv, char="↑︎︎", title="Hidden Bull Div 3",
location=location.bottom, color= color.white, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and hid_div_bull_4 and not hid_div_bull_4[1] and show_hiddiv, char="↑︎︎", title="Hidden Bull Div 4",
location=location.bottom, color= color.white, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bull_5 and not hid_div_bull_5[1] and show_hiddiv, char="↑︎︎", title="Hidden Bull Div 5",
location=location.bottom, color= color.white, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bull_6 and not hid_div_bull_6[1] and show_hiddiv, char="↑︎︎", title="Hidden Bull Div 6",
location=location.bottom, color= color.white, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bull_x and not hid_div_bull_x[1] and show_hiddiv, char="↑︎︎", title="Hidden Bull Div x",
location=location.bottom, color= color.yellow, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bear_1 and not hid_div_bear_1[1] and show_hiddiv, char="↓︎", title="Hidden Bear Div 1",
location=location.top, color= color.white, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and hid_div_bear_2 and not hid_div_bear_2[1] and show_hiddiv, char="↓︎︎", title="Hidden Bear Div 2",
location=location.top, color= color.white, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and hid_div_bear_3 and not hid_div_bear_3[1] and show_hiddiv, char="↓︎︎", title="Hidden Bear Div 3",
location=location.top, color= color.white, size=size.tiny, transp=20, offset=-1)
plotchar(arrows and hid_div_bear_4 and not hid_div_bear_4[1] and show_hiddiv, char="↓︎︎", title="Hidden Bear Div 4",
location=location.top, color= color.white, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bear_5 and not hid_div_bear_5[1] and show_hiddiv, char="↓︎︎", title="Hidden Bear Div 5",
location=location.top, color= color.white, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bear_6 and not hid_div_bear_6[1] and show_hiddiv, char="↓︎︎", title="Hidden Bear Div 6",
location=location.top, color= color.white, size=size.tiny, transp=0, offset=-1)
plotchar(arrows and hid_div_bear_x and not hid_div_bear_x[1] and show_hiddiv, char="↓︎︎", title="Hidden Bear Div x",
location=location.top, color= color.yellow, size=size.tiny, transp=0, offset=-1)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
lime = color.new(color.lime, 20)
green = color.new(color.green, 20)
aqua = color.new(color.aqua, 20)
orange = color.new(color.orange, 20)
red = color.new(color.red, 20)
purple = color.new(color.purple, 20)
white = color.new(color.white, 20)
yellow = color.new(color.yellow, 20)
// Bullish Divergences = close LL - RSI HL
bl1 = 0
bl_1 = 0
bl2 = 0
bl_2 = 0
bl3 = 0
bl_3 = 0
bl4 = 0
bl_4 = 0
bl5 = 0
bl_5 = 0
bl6 = 0
bl_6 = 0
blx = 0
bl_x = 0
// Bearish Divergences = close HH - RSI LH
br1 = 0
br_1 = 0
br2 = 0
br_2 = 0
br3 = 0
br_3 = 0
br4 = 0
br_4 = 0
br5 = 0
br_5 = 0
br6 = 0
br_6 = 0
brx = 0
br_x = 0
// Hidden Bullish Divergences = close HL - RSI LL
hbl1 = 0
hbl_1 = 0
hbl2 = 0
hbl_2 = 0
hbl3 = 0
hbl_3 = 0
hbl4 = 0
hbl_4 = 0
hbl5 = 0
hbl_5 = 0
hbl6 = 0
hbl_6 = 0
hblx = 0
hbl_x = 0
// Hidden Bearish Divergences = close LH - RSI HH
hbr1 = 0
hbr_1 = 0
hbr2 = 0
hbr_2 = 0
hbr3 = 0
hbr_3 = 0
hbr4 = 0
hbr_4 = 0
hbr5 = 0
hbr_5 = 0
hbr6 = 0
hbr_6 = 0
hbrx = 0
hbr_x = 0
for i = 0 to 1
if not arrows and Period and div_bull_1 and rsi[i] == rsil0
break
bl_1 := bl_1 + 1
if not arrows and Period and div_bull_2 and rsi[i] == rsil0
break
bl_2 := bl_2 + 1
if not arrows and Period and div_bull_3 and rsi[i] == rsil0
break
bl_3 := bl_3 + 1
if not arrows and Period and div_bull_4 and rsi[i] == rsil0
break
bl_4 := bl_4 + 1
if not arrows and Period and div_bull_5 and rsi[i] == rsil0
break
bl_5 := bl_5 + 1
if not arrows and Period and div_bull_6 and rsi[i] == rsil0
break
bl_6 := bl_6 + 1
if not arrows and Period and div_bull_x and rsi[i] == rsil0
break
bl_x := bl_x + 1
if not arrows and Period and hid_div_bull_1 and rsi[i] == rsil0
break
hbl_1 := hbl_1 + 1
if not arrows and Period and hid_div_bull_2 and rsi[i] == rsil0
break
hbl_2 := hbl_2 + 1
if not arrows and Period and hid_div_bull_3 and rsi[i] == rsil0
break
hbl_3 := hbl_3 + 1
if not arrows and Period and hid_div_bull_4 and rsi[i] == rsil0
break
hbl_4 := hbl_4 + 1
if not arrows and Period and hid_div_bull_5 and rsi[i] == rsil0
break
hbl_5 := hbl_5 + 1
if not arrows and Period and hid_div_bull_6 and rsi[i] == rsil0
break
hbl_6 := hbl_6 + 1
if not arrows and Period and hid_div_bull_x and rsi[i] == rsil0
break
hbl_x := hbl_x + 1
for i = 0 to 1
if not arrows and Period and div_bear_1 and rsi[i] == rsih0
break
br_1 := br_1 + 1
if not arrows and Period and div_bear_2 and rsi[i] == rsih0
break
br_2 := br_2 + 1
if not arrows and Period and div_bear_3 and rsi[i] == rsih0
break
br_3 := br_3 + 1
if not arrows and Period and div_bear_4 and rsi[i] == rsih0
break
br_4 := br_4 + 1
if not arrows and Period and div_bear_5 and rsi[i] == rsih0
break
br_5 := br_5 + 1
if not arrows and Period and div_bear_6 and rsi[i] == rsih0
break
br_6 := br_6 + 1
if not arrows and Period and div_bear_x and rsi[i] == rsih0
break
br_x := br_x + 1
if not arrows and Period and hid_div_bear_1 and rsi[i] == rsih0
break
hbr_1 := hbr_1 + 1
if not arrows and Period and hid_div_bear_2 and rsi[i] == rsih0
break
hbr_2 := hbr_2 + 1
if not arrows and Period and hid_div_bear_3 and rsi[i] == rsih0
break
hbr_3 := hbr_3 + 1
if not arrows and Period and hid_div_bear_4 and rsi[i] == rsih0
break
hbr_4 := hbr_4 + 1
if not arrows and Period and hid_div_bear_5 and rsi[i] == rsih0
break
hbr_5 := hbr_5 + 1
if not arrows and Period and hid_div_bear_6 and rsi[i] == rsih0
break
hbr_6 := hbr_6 + 1
if not arrows and Period and hid_div_bear_x and rsi[i] == rsih0
break
hbr_x := hbr_x + 1
for i = 0 to 100
if not arrows and Period and div_bull_1 and rsi[i] == rsil1
break
bl1 := bl1 + 1
if not arrows and Period and hid_div_bull_1 and rsi[i] == rsil1
break
hbl1 := hbl1 + 1
for i = 0 to 150
if not arrows and Period and div_bull_2 and rsi[i] == rsil2
break
bl2 := bl2 + 1
if not arrows and Period and hid_div_bull_2 and rsi[i] == rsil2
break
hbl2 := hbl2 + 1
for i = 0 to 200
if not arrows and Period and div_bull_3 and rsi[i] == rsil3
break
bl3 := bl3 + 1
if not arrows and Period and hid_div_bull_3 and rsi[i] == rsil3
break
hbl3 := hbl3 + 1
for i = 0 to 200
if not arrows and Period and div_bull_4 and rsi[i] == rsil4
break
bl4 := bl4 + 1
if not arrows and Period and hid_div_bull_4 and rsi[i] == rsil4
break
hbl4 := hbl4 + 1
for i = 0 to 300
if not arrows and Period and div_bull_5 and rsi[i] == rsil5
break
bl5 := bl5 + 1
if not arrows and Period and hid_div_bull_5 and rsi[i] == rsil5
break
hbl5 := hbl5 + 1
for i = 0 to 400
if not arrows and Period and div_bull_6 and rsi[i] == rsil6
break
bl6 := bl6 + 1
if not arrows and Period and hid_div_bull_6 and rsi[i] == rsil6
break
hbl6 := hbl6 + 1
for i = 0 to 500
if not arrows and Period and div_bull_x and rsi[i] == rsilx
break
blx := blx + 1
if not arrows and Period and hid_div_bull_x and rsi[i] == rsilx
break
hblx := hblx + 1
for i = 0 to 100
if not arrows and Period and div_bear_1 and rsi[i] == rsih1
break
br1 := br1 + 1
if not arrows and Period and hid_div_bear_1 and rsi[i] == rsih1
break
hbr1 := hbr1 + 1
for i = 0 to 150
if not arrows and Period and div_bear_2 and rsi[i] == rsih2
break
br2 := br2 + 1
if not arrows and Period and hid_div_bear_2 and rsi[i] == rsih2
break
hbr2 := hbr2 + 1
for i = 0 to 200
if not arrows and Period and div_bear_3 and rsi[i] == rsih3
break
br3 := br3 + 1
if not arrows and Period and hid_div_bear_3 and rsi[i] == rsih3
break
hbr3 := hbr3 + 1
for i = 0 to 200
if not arrows and Period and div_bear_4 and rsi[i] == rsih4
break
br4 := br4 + 1
if not arrows and Period and hid_div_bear_4 and rsi[i] == rsih4
break
hbr4 := hbr4 + 1
for i = 0 to 300
if not arrows and Period and div_bear_5 and rsi[i] == rsih5
break
br5 := br5 + 1
if not arrows and Period and hid_div_bear_5 and rsi[i] == rsih5
break
hbr5 := hbr5 + 1
for i = 0 to 400
if not arrows and Period and div_bear_6 and rsi[i] == rsih6
break
br6 := br6 + 1
if not arrows and Period and hid_div_bear_6 and rsi[i] == rsih6
break
hbr6 := hbr6 + 1
for i = 0 to 500
if not arrows and Period and div_bear_x and rsi[i] == rsihx
break
brx := brx + 1
if not arrows and Period and hid_div_bear_x and rsi[i] == rsihx
break
hbrx := hbrx + 1
// Bullish Divergences = close LL - RSI HL
if not arrows and Period and show_div and div_bull_1 and not div_bull_2 and not div_bull_3
and not div_bull_4 and not div_bull_5 and not div_bull_6
ln = line.new(bar_index[bl_1], rsi[bl_1], bar_index[bl1], rsi[bl1], xloc =
xloc.bar_index, extend=extend.none, color=color.green)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[bl_1], rsi[bl_1], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=green, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_div and div_bull_2 and not div_bull_3 and not div_bull_4
and not div_bull_5 and not div_bull_6
ln = line.new(bar_index[bl_2], rsi[bl_2], bar_index[bl2], rsi[bl2], xloc =
xloc.bar_index, extend=extend.none, color=color.green)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[bl_2], rsi[bl_2], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=green, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_div and div_bull_3 and not div_bull_4 and not div_bull_5
and not div_bull_6
ln = line.new(bar_index[bl_3], rsi[bl_3], bar_index[bl3], rsi[bl3], xloc =
xloc.bar_index, extend=extend.none, color=color.green)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[bl_3], rsi[bl_3], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=green, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_div and div_bull_4 and not div_bull_5 and not div_bull_6
ln = line.new(bar_index[bl_4], rsi[bl_4], bar_index[bl4], rsi[bl4], xloc =
xloc.bar_index, extend=extend.none, color=color.lime)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[bl_4], rsi[bl_4], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=lime, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_div and div_bull_5 and not div_bull_6
ln = line.new(bar_index[bl_5], rsi[bl_5], bar_index[bl5], rsi[bl5], xloc =
xloc.bar_index, extend=extend.none, color=color.lime)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[bl_5], rsi[bl_5], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=lime, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_div and div_bull_6
ln = line.new(bar_index[bl_6], rsi[bl_6], bar_index[bl6], rsi[bl6], xloc =
xloc.bar_index, extend=extend.none, color=color.lime)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[bl_6], rsi[bl_6], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=lime, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_div and div_bull_x
ln = line.new(bar_index[bl_x], rsi[bl_x], bar_index[blx], rsi[blx], xloc =
xloc.bar_index, extend=extend.none, color=color.aqua)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[bl_x], rsi[bl_x], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=aqua, size=_size)
label.delete(not rl ? lb : na)
// Bearish Divergences = close HH - RSI LH
if not arrows and Period and show_div and div_bear_1 and not div_bear_2 and not div_bear_3
and not div_bear_4 and not div_bear_5 and not div_bear_6
ln = line.new(bar_index[br_1], rsi[br_1], bar_index[br1], rsi[br1], xloc =
xloc.bar_index, extend=extend.none, color=color.orange)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[br_1], rsi[br_1], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=orange, size=_size)
label.delete(not rh ? lb : na)
if not arrows and Period and show_div and div_bear_2 and not div_bear_3 and not div_bear_4
and not div_bear_5 and not div_bear_6
ln = line.new(bar_index[br_2], rsi[br_2], bar_index[br2], rsi[br2], xloc =
xloc.bar_index, extend=extend.none, color=color.orange)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[br_2], rsi[br_2], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=orange, size=_size)
label.delete(not rh ? lb : na)
if not arrows and Period and show_div and div_bear_3 and not div_bear_4 and not div_bear_5
and not div_bear_6
ln = line.new(bar_index[br_3], rsi[br_3], bar_index[br3], rsi[br3], xloc =
xloc.bar_index, extend=extend.none, color=color.orange)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[br_3], rsi[br_3], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=orange, size=_size)
label.delete(not rh ? lb : na)
if not arrows and Period and show_div and div_bear_4 and not div_bear_5 and not div_bear_6
ln = line.new(bar_index[br_4], rsi[br_4], bar_index[br4], rsi[br4], xloc =
xloc.bar_index, extend=extend.none, color=color.red)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[br_4], rsi[br_4], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=red, size=_size)
label.delete(not rh ? lb : na)
if not arrows and Period and show_div and div_bear_5 and not div_bear_6
ln = line.new(bar_index[br_5], rsi[br_5], bar_index[br5], rsi[br5], xloc =
xloc.bar_index, extend=extend.none, color=color.red)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[br_5], rsi[br_5], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=red, size=_size)
label.delete(not rh ? lb : na)
if not arrows and Period and show_div and div_bear_6
ln = line.new(bar_index[br_6], rsi[br_6], bar_index[br6], rsi[br6], xloc =
xloc.bar_index, extend=extend.none, color=color.red)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[br_6], rsi[br_6], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=red, size=_size)
label.delete(not rh ? lb : na)
if not arrows and Period and show_div and div_bear_x
ln = line.new(bar_index[br_x], rsi[br_x], bar_index[brx], rsi[brx], xloc =
xloc.bar_index, extend=extend.none, color=color.purple)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[br_x], rsi[br_x], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=purple, size=_size)
label.delete(not rh ? lb : na)
// Hidden Bullish Divergences = close HL - RSI LL
if not arrows and Period and show_hiddiv and hid_div_bull_1 and not hid_div_bull_2 and not hid_div_bull_3
and not hid_div_bull_4 and not hid_div_bull_5 and not hid_div_bull_6
ln = line.new(bar_index[hbl_1], rsi[hbl_1], bar_index[hbl1], rsi[hbl1], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[hbl_1], rsi[hbl_1], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=white, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_hiddiv and hid_div_bull_2 and not hid_div_bull_3 and not hid_div_bull_4
and not hid_div_bull_5 and not hid_div_bull_6
ln = line.new(bar_index[hbl_2], rsi[hbl_2], bar_index[hbl2], rsi[hbl2], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[hbl_2], rsi[hbl_2], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=white, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_hiddiv and hid_div_bull_3 and not hid_div_bull_4 and not hid_div_bull_5
and not hid_div_bull_6
ln = line.new(bar_index[hbl_3], rsi[hbl_3], bar_index[hbl3], rsi[hbl3], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[hbl_3], rsi[hbl_3], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=white, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_hiddiv and hid_div_bull_4 and not hid_div_bull_5 and not hid_div_bull_6
ln = line.new(bar_index[hbl_4], rsi[hbl_4], bar_index[hbl4], rsi[hbl4], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[hbl_4], rsi[hbl_4], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=white, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_hiddiv and hid_div_bull_5 and not hid_div_bull_6
ln = line.new(bar_index[hbl_5], rsi[hbl_5], bar_index[hbl5], rsi[hbl5], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[hbl_5], rsi[hbl_5], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=white, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_hiddiv and hid_div_bull_6
ln = line.new(bar_index[hbl_6], rsi[hbl_6], bar_index[hbl6], rsi[hbl6], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[hbl_6], rsi[hbl_6], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=white, size=_size)
label.delete(not rl ? lb : na)
if not arrows and Period and show_hiddiv and hid_div_bull_x
ln = line.new(bar_index[hbl_x], rsi[hbl_x], bar_index[hblx], rsi[hblx], xloc =
xloc.bar_index, extend=extend.none, color=color.yellow)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rl ? ln : na)
lb = label.new(bar_index[hbl_x], rsi[hbl_x], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbl, color=yellow, size=_size)
label.delete(not rl ? lb : na)
// Hidden Bearish Divergences = close LH - RSI HH
if not arrows and Period and show_hiddiv and hid_div_bear_1 and not hid_div_bear_2 and not hid_div_bear_3
and not hid_div_bear_4 and not hid_div_bear_5 and not hid_div_bear_6
ln = line.new(bar_index[hbr_1], rsi[hbr_1], bar_index[hbr1], rsi[hbr1], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[hbr_1], rsi[hbr_1], xloc = xloc.bar_index, yloc=yloc.price,
style=_symbr, color=white, size=_size)
label.delete(not rh ? lb : na)
if not arrows and Period and show_hiddiv and hid_div_bear_2 and not hid_div_bear_3 and not hid_div_bear_4
and not hid_div_bear_5 and not hid_div_bear_6
ln = line.new(bar_index[hbr_2], rsi[hbr_2], bar_index[hbr2], rsi[hbr2], xloc =
xloc.bar_index, extend=extend.none, color=color.white)
line.set_width(ln, lw)
line.set_style(ln, _dot)
line.delete(not rh ? ln : na)
lb = label.new(bar_index[hbr_2], rsi[hbr_2], xloc = xloc.bar_index, yloc=yloc.price,