-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMarketMind.pine
2362 lines (2075 loc) · 118 KB
/
MarketMind.pine
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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// @ EzAlgo
//@version=5
indicator("Market Mind", overlay=true, max_bars_back=5000, max_lines_count=500, max_boxes_count=500, max_labels_count=500)
//-----------------------------------------------------------------------------
// Input Settings
//-----------------------------------------------------------------------------
i_1 = "Order Blocks represent significant price levels where large orders were executed, potentially indicating future support or resistance areas."
i_2 = "Market Structure refers to the overall trend and key price levels, such as Higher Highs, Higher Lows, Lower Highs, and Lower Lows."
i_3 = "FVGs represent price areas where a significant gap occurred between two trading sessions, indicating a potential continuation or reversal point."
i_4 = "Liquidity Levels indicate price areas where there is a significant increase in trading volume and potential support or resistance."
i_5 = "Key Levels represent significant price levels based on different timeframes, such as Previous Day High/Low, Weekly Open, Monthly Open, etc."
i_6 = "Session Levels indicate the High, Low, and Open prices of different trading sessions, such as London, New York, and Tokyo."
i_7 = "Dealing Range represents the area between the highest high and lowest low over a specified period, indicating the current trading range."
i_8 = "POC represents the price level with the highest trading volume over a specified period, often considered as a key support or resistance level."
i_9 = "Displacement represents a significant price move or gap that occurs within a single candle, often indicating a strong shift in market sentiment."
i_10 = "Trend Lines are diagonal lines drawn on a chart to connect a series of highs or lows, used to identify and confirm the direction of the market trend, and to indicate potential support and resistance levels."
//----------------------------------------
// Order Blocks
//----------------------------------------
in_ob_1 = input.bool(true, "Order Blocks", group="Order Blocks", inline="ob1", tooltip = i_1)
in_ob_2 = input.color(#b2b5be19, "", inline="ob1", group="Order Blocks")
in_ob_3 = input.color(#b2b5be19, "", inline="ob1", group="Order Blocks")
in_ob_4 = "All"//input.string("All", "", options=["All", "Internal", "External"], group="Order Blocks", inline="ob1")
in_ob_5 = input.timeframe("", "Timeframe", group="Order Blocks", inline="ob2")
in_ob_6 = input.string("Average", "Mitigation Method", options=["Touch", "Wicks", "Close", "Average"], group="Order Blocks", inline="ob3")
in_ob_7 = input(true, "Hide Overlap", inline="ob3", group="Order Blocks")
in_ob_8 = input.int(5, "Max OBs", minval=3, group="Order Blocks", inline="ob4")
in_ob_9 = input.int(defval=22, title="Length", minval=0, maxval=500, group="Order Blocks", inline="ob4")
in_ob_10 = input.bool(false, "Extend", group="Order Blocks", inline="ob4")
in_ob_11 = input.string("Medium", options=["Small", "Medium", "Large"], title="Text Size", inline="ob1_t", group="Order Blocks")
in_ob_12 = in_ob_11 == "Small" ? size.tiny : in_ob_11 == "Medium" ? size.small : size.normal
in_ob_13 = input.color(#b2b5be, "", inline="ob1_t", group="Order Blocks")
in_ob_14 = input.bool(true, "Volume", group="Order Blocks", inline="ob1_t")
in_ob_15 = input.bool(true, "Percentage", group="Order Blocks", inline="ob1_t")
in_ob_16 = input.string("Off", title="Mid Line", options=["On", "Off"], group="Order Blocks", inline="ob1_l")
in_ob_17 = in_ob_16 == "On"
in_ob_18 = input.string("Solid", title="Line Style", options=["Solid", "Dashed", "Dotted"], group="Order Blocks", inline="ob1_l")
in_ob_19 = in_ob_18 == "Solid" ? line.style_solid : in_ob_18 == "Dashed" ? line.style_dashed : line.style_dotted
in_ob_20 = input.bool(false, "MTF Order Blocks", group="Order Blocks", inline="m_ob1", tooltip = i_1)
in_ob_21 = input.color(#b2b5be19, "", inline="m_ob1", group="Order Blocks")
in_ob_22 = input.color(#b2b5be19, "", inline="m_ob1", group="Order Blocks")
in_ob_23 = "All"//input.string("All", "", options=["All", "Internal", "External"], group="Order Blocks", inline="m_ob1")
in_ob_24 = input.timeframe("240", "Timeframe", group="Order Blocks", inline="mob2")
in_ob_25 = input.string("Average", "Mitigation Method", options=["Touch", "Wicks", "Close", "Average"], group="Order Blocks", inline="mob3")
in_ob_26 = input(false, "Hide Overlap", inline="mob3", group="Order Blocks")
in_ob_27 = input.int(3, "Max OBs", minval=3, group="Order Blocks", inline="mob4")
in_ob_28 = input.int(defval=22, title="Length", minval=0, maxval=500, group="Order Blocks", inline="mob4")
in_ob_29 = input.bool(false, "Extend", group="Order Blocks", inline="mob4")
in_ob_30 = input.string("Medium", options=["Small", "Medium", "Large"], title="Text Size", inline="ob2_t", group="Order Blocks")
in_ob_31 = in_ob_30 == "Small" ? size.tiny : in_ob_30 == "Medium" ? size.small : size.normal
in_ob_32 = input.color(#b2b5be, "", inline="ob2_t", group="Order Blocks")
in_ob_33 = input.bool(true, "Volume", group="Order Blocks", inline="ob2_t")
in_ob_34 = input.bool(true, "Percentage", group="Order Blocks", inline="ob2_t")
in_ob_35 = input.string("Off", title="Mid Line", options=["On", "Off"], group="Order Blocks", inline="ob2_l")
in_ob_36 = in_ob_35 == "On"
in_ob_37 = input.string("Solid", title="Line Style", options=["Solid", "Dashed", "Dotted"], group="Order Blocks", inline="ob2_l")
in_ob_38 = in_ob_37 == "Solid" ? line.style_solid : in_ob_37 == "Dashed" ? line.style_dashed : line.style_dotted
in_ob_39 = input.bool(true, 'Internal Bull/Bear Activity', group='Order Blocks',inline = 'volume')
in_ob_40 = input.color(color.new(color.green, 60), "", inline="volume", group="Order Blocks")
in_ob_41 = input.color(color.new(color.red, 60), "", inline="volume", group="Order Blocks")
in_ob_42 = input.string("Lines", "OB Style", options=["Zones", "Lines"], group="Order Blocks", inline="ob_s")
in_ob_43 = input.string("Dotted", "Line Style", options=["Solid", "Dashed","Dotted"], group="Order Blocks", inline="ob_line_style")
in_ob_44 = in_ob_43 == "Solid" ? line.style_solid : in_ob_43 == "Dashed" ? line.style_dashed : line.style_dotted
in_ob_45 = input.int(2, "Line Width", minval=1,maxval = 4, group="Order Blocks", inline="ob_line_style")
in_ob_46 = input.color(#b2b5be, "Line Color", inline="l_c", group="Order Blocks")
in_ob_47 = input.color(#b2b5be, "", inline="l_c", group="Order Blocks")
if in_ob_42 == "Lines"
in_ob_2 := in_ob_46
in_ob_3 := in_ob_47
in_ob_21 := in_ob_46
in_ob_22 := in_ob_47
var_ob_1 = in_ob_24 == "" ? timeframe.period : in_ob_24
var_ob_2 = not (str.contains(var_ob_1, "S") or str.contains(var_ob_1, "D") or str.contains(var_ob_1, "W") or str.contains(var_ob_1, "M")) ? str.tonumber(var_ob_1) >= 60 ? str.tostring(str.tonumber(var_ob_1) / 60) + "H" : var_ob_1 + "M" : var_ob_1
var_ob_3 = var_ob_2 + " : "
var_ob_4 = in_ob_4 == "All" or in_ob_4 == "Internal"
var_ob_5 = in_ob_4 == "All" or in_ob_4 == "External"
var_ob_6 = in_ob_23 == "All" or in_ob_23 == "Internal"
var_ob_7 = in_ob_23 == "All" or in_ob_23 == "External"
var_ob_8 = 5
var_ob_9 = 5
var_ob_10 = 3
var_ob_10 := var_ob_10 == 3 ? 20 : var_ob_10
style = "Colored"
var_ob_11 = 10
var_ob_12 = 10
var_ob_13 = (time[1] - time[101]) / 100
//----------------------------------------
// BOS and MSS
//----------------------------------------
// Constants
color CLEAR = color.rgb(0, 0, 0, 100)
// Inputs
in_ms_1 = input(true, title="Market Structure ", inline="0", group="Market Structure", tooltip = i_2)
in_ms_2 = input.color(#b2b5be9a, "", group="Market Structure", inline="0")
in_ms_3 = input.color(#b2b5be9a, "", group="Market Structure", inline="0")
in_ms_4 = input.string("All", options=["All", "External", "Internal"], title="", group="Market Structure", inline="0")
length = 50//input.int(50, "Lookback", minval=0, maxval=100, group="Market Structure", inline="01")
in_ms_5 = input(false, "Equal Highs & Lows", group="Market Structure", inline="equilibrium_zone")
in_ms_6 = input.color(#e91e63, "", group="Market Structure", inline="equilibrium_zone")
in_ms_7 = input.color(#2962ff, "", group="Market Structure", inline="equilibrium_zone")
in_ms_8 = input.float(0.05, "", minval=0, maxval=0.5, step=0.1, group="Market Structure", inline="equilibrium_zone")
in_ms_9 = input.bool(false, "Swing Points", group="Market Structure", inline="3")
in_ms_10 = input.int(10, "Swing Point Period", inline="4", group="Market Structure")
in_ms_11 = input.string("Medium", options=["Small", "Medium", "Large"], title="Label Size", inline="4", group="Market Structure")
in_ms_12 = in_ms_11 == "Small" ? size.tiny : in_ms_11 == "Medium" ? size.small : size.normal
in_ms_13 = in_ms_11 == "Small" ? size.tiny : in_ms_11 == "Medium" ? size.small : size.normal
in_ms_14 = input.color(color.new(color.white, 40), "", group="Market Structure", inline="3")
in_ms_15 = 3
in_ms_16 = 3
//----------------------------------------
// Displacement
//----------------------------------------
in_dis_1 = input(defval=true, title='Show Displacement Candles', group="Displacement",inline = '1', tooltip = i_9)
in_dis_2 = input.color(#e91e63, "", group="Displacement",inline = '1')
in_dis_3 = input.color(#2962ff, "", group="Displacement",inline = '1')
in_dis_4 = input.string("Candle Body", "Type", options = ['Candle Body', 'Full Candle'], group="Displacement",inline = '2')
in_dis_5 = input.int(2, minval = 0,maxval = 3, title = "Strength", group="Displacement",inline = '2')
mss_filter_disp = input(defval=true, title='Structure Filter', group="Displacement",inline = '3')
//----------------------------------------
// Fair Value Gaps (FVG)
//----------------------------------------
in_fvg_1 = input(true, "Fair Value Gaps (FVG)", group="Fair Value Gaps", inline="fvg_css", tooltip = i_3)
in_fvg_2 = input.timeframe("", "Timeframe", group="Fair Value Gaps", inline="tf")
in_fvg_op = input.int(defval=12, title="Opacity %", minval=0, maxval=100, group="Fair Value Gaps", inline="tf")
in_fvg_3 = input.float(2, "Max Width", minval=0, maxval=5.0, step=0.1, group="Fair Value Gaps", inline="width")
in_fvg_4 = input.bool(true, "Filter FVG", group="Fair Value Gaps", inline="width")
in_fvg_5 = input.string("Average", "Mitigation Method", options=["Touch", "Wicks", "Close", "Average"], group="Fair Value Gaps", inline="mt")
in_fvg_6 = input.bool(true, "Fill", group="Fair Value Gaps", inline="mt")
in_fvg_7 = input.bool(false, "Shade", group="Fair Value Gaps", inline="mt")
in_fvg_8 = input.int(defval=5, title="Max FVG", minval=0, maxval=50, group="Fair Value Gaps", inline="OS")
in_fvg_9 = input.int(defval=20, title="Length", minval=0, maxval=100, group="Fair Value Gaps", inline="OS")
in_fvg_10 = input.bool(false, "Extend", group="Fair Value Gaps", inline="OS")
in_fvg_11 = input.color(#4346511e, "", group="Fair Value Gaps", inline="fvg_css")
in_fvg_12 = input.color(#4346511e, "", group="Fair Value Gaps", inline="fvg_css")
mid_line_show = input.string("Off", " Mid Line", ["On", "Off"], group="Fair Value Gaps", inline="mid")
in_fvg_13 = input.string("Solid", " Style", ["Solid", "Dashed", "Dotted"], group="Fair Value Gaps", inline="mid")
in_fvg_14 = input.color(color.new(color.white, 40), "", group="Fair Value Gaps", inline="mid")
in_fvg_14_2 = input.color(color.new(color.white, 40), "", group="Fair Value Gaps", inline="mid")
in_fvg_16 = input.int(defval=2, title="Line Width", minval=1, maxval=5, group="Fair Value Gaps", inline="mid_w")
in_fvg_15 = input.bool(true, "Extend (Current)", group="Fair Value Gaps", inline="mid_w")
var_fvg_1 = color.new(color.green, 100)
var_fvg_2 = color.new(color.green, 90)
var_fvg_3 = true
var_fvg_4 = true
var_fvg_5 = color.white
var_fvg_6 = "HTF"
var_fvg_7 = 10
var_fvg_8 = 50
in_fvg_op := 100 - in_fvg_op
//----------------------------------------
// Liquidity Levels
//----------------------------------------
liquidity_level_group = "Liquidity Levels"
in_liq_1 = input.bool(true, title="Liquidity Levels", group=liquidity_level_group, inline="1", tooltip = i_4)
in_liq_2 = input.timeframe("", title="Timeframe", inline="1_", group=liquidity_level_group)
in_liq_3 = input.int(10, title="Pivot Length", group=liquidity_level_group, inline="2")
in_liq_4 = input.string("Remove", title="Mitigated", inline="3", options=["Remove", "Show"], group=liquidity_level_group)
in_liq_5 = input.string("Close", title="Method", options=["Close", "Wick"], group=liquidity_level_group, inline="3")
in_liq_6 = input.int(4, title="Max Levels", group=liquidity_level_group, inline="4")
in_liq_7 = input.int(defval=20, title="Length", minval=0, maxval=500, group=liquidity_level_group, inline="4")
in_liq_8 = "Solid"
in_liq_9 = in_liq_8 == "Solid" ? line.style_solid : in_liq_8 == "Dashed" ? line.style_dashed : line.style_dotted
in_liq_10 = 2.5
in_liq_11 = input.color(#b2b5be, "", group=liquidity_level_group, inline="1")
in_liq_12 = input.color(#00ddff, "", group=liquidity_level_group, inline="1")
in_liq_13 = input.bool(true, title="Show Text", group=liquidity_level_group, inline="5")
in_liq_14 = input.color(#b2b5be, "", inline="5", group=liquidity_level_group)
in_liq_14_2 = input.color(#00ddff, "", inline="5", group=liquidity_level_group)
in_liq_15 = color.new(in_liq_12, 90)
in_liq_16 = color.new(in_liq_11, 90)
in_liq_17 = input.string("Lines", "", options=["Boxes", "Lines"], group=liquidity_level_group, inline="1")
in_liq_18 = input.int(defval=1, title="Line Width", minval=0, maxval=5, group=liquidity_level_group, inline="6")
in_liq_19 = input.bool(false, title="Extend", group=liquidity_level_group, inline="6")
//'Lines'//"Boxes"
//----------------------------------------
// Key Levels
//----------------------------------------
var in_kl_1 = input.bool(defval=false, title="4H", group="Key Levels", inline="4H", tooltip = i_5)
in_kl_2 = input.color(title="", defval=color.orange, group="Key Levels", inline="4H")
in_kl_3 = input.string("Dotted", " Style", ["Solid", "Dashed", "Dotted"], group="Key Levels", inline="4H")
in_kl_4 = input.bool(defval=true, title="Shorten", group="Key Levels", inline="4H")
var in_kl_5 = input.bool(defval=false, title="Daily", group="Key Levels", inline="Daily", tooltip = i_5)
in_kl_6 = input.color(title="", defval=color.purple, group="Key Levels", inline="Daily")
in_kl_7 = input.string("Dotted", " Style", ["Solid", "Dashed", "Dotted"], group="Key Levels", inline="Daily")
in_kl_8 = input.bool(defval=true, title="Shorten", group="Key Levels", inline="Daily")
var in_kl_9 = input.bool(defval=false, title="Monday", group="Key Levels", inline="Monday", tooltip = i_5)
in_kl_10 = input.color(title="", defval=color.white, group="Key Levels", inline="Monday")
in_kl_11 = input.string("Dotted", " Style", ["Solid", "Dashed", "Dotted"], group="Key Levels", inline="Monday")
in_kl_12 = input.bool(defval=true, title="Shorten", group="Key Levels", inline="Monday")
var in_kl_13 = input.bool(defval=false, title="Weekly", group="Key Levels", inline="Weekly", tooltip = i_5)
in_kl_14 = input.color(title="", defval=color.yellow, group="Key Levels", inline="Weekly")
in_kl_15 = input.string("Dotted", " Style", ["Solid", "Dashed", "Dotted"], group="Key Levels", inline="Weekly")
in_kl_16 = input.bool(defval=true, title="Shorten", group="Key Levels", inline="Weekly")
var in_kl_17 = input.bool(defval=false, title="Monthly", group="Key Levels", inline="Monthly", tooltip = i_5)
in_kl_18 = input.color(title="", defval=color.green, group="Key Levels", inline="Monthly")
in_kl_19 = input.string("Dotted", " Style", ["Solid", "Dashed", "Dotted"], group="Key Levels", inline="Monthly")
in_kl_20 = input.bool(defval=true, title="Shorten", group="Key Levels", inline="Monthly")
var in_kl_21 = input.bool(defval=false, title="Quarterly", group="Key Levels", inline="Quarterly", tooltip = i_5)
in_kl_22 = input.color(title="", defval=color.new(color.white, 80), group="Key Levels", inline="Quarterly")
in_kl_23 = input.string("Dotted", " Style", ["Solid", "Dashed", "Dotted"], group="Key Levels", inline="Quarterly")
in_kl_24 = input.bool(defval=true, title="Shorten", group="Key Levels", inline="Quarterly")
var in_kl_25 = input.bool(defval=false, title="Yearly", group="Key Levels", inline="Yearly", tooltip = i_5)
in_kl_26 = input.color(title="", defval=color.new(color.white, 90), group="Key Levels", inline="Yearly")
in_kl_27 = input.string("Dotted", " Style", ["Solid", "Dashed", "Dotted"], group="Key Levels", inline="Yearly")
in_kl_28 = input.bool(defval=true, title="Shorten", group="Key Levels", inline="Yearly")
in_kl_29 = input.string(defval="Medium", title="Text Size", options=["Small", "Medium", "Large"], group="Key Levels", inline="H")
var var_kl_1 = in_kl_8 ? "PDH" : "Prev Day High"
var var_kl_2 = in_kl_8 ? "PDL" : "Prev Day Low"
var var_kl_3 = in_kl_8 ? "DO" : "Daily Open"
var var_kl_4 = in_kl_8 ? "PDM" : "Prev Day Mid"
var var_kl_5 = in_kl_16 ? "PWH" : "Prev Week High"
var var_kl_6 = in_kl_16 ? "PWL" : "Prev Week Low"
var var_kl_7 = in_kl_16 ? "WO" : "Weekly Open"
var var_kl_8 = in_kl_16 ? "PWM" : "Prev Week Mid"
var var_kl_9 = in_kl_20 ? "PMH" : "Prev Month High"
var var_kl_10 = in_kl_20 ? "PML" : "Prev Month Low"
var var_kl_11 = in_kl_20 ? "MO" : "Monthly Open"
var var_kl_12 = in_kl_20 ? "PMM" : "Prev Month Mid"
var var_kl_13 = in_kl_24 ? "PQH" : "Prev Quarter High"
var var_kl_14 = in_kl_24 ? "PQL" : "Prev Quarter Low"
var var_kl_15 = in_kl_24 ? "QO" : "Quarterly Open"
var var_kl_16 = in_kl_24 ? "PQM" : "Prev Quarter Mid"
var var_kl_17 = in_kl_28 ? "CYH" : "Current Year High"
var var_kl_18 = in_kl_28 ? "CYL" : "Current Year Low"
var var_kl_19 = in_kl_28 ? "YO" : "Yearly Open"
var var_kl_20 = in_kl_28 ? "CYM" : "Current Year Mid"
var var_kl_21 = in_kl_4 ? "P-4H-H" : "Prev 4H High"
var var_kl_22 = in_kl_4 ? "P-4H-L" : "Prev 4H Low"
var var_kl_23 = in_kl_4 ? "4H-O" : "4H Open"
var var_kl_24 = in_kl_4 ? "P-4H-M" : "Prev 4H Mid"
var var_kl_25 = in_kl_12 ? "MDAY-H" : "Monday High"
var var_kl_26 = in_kl_12 ? "MDAY-L" : "Monday Low"
var var_kl_27 = in_kl_12 ? "MDAY-M" : "Monday Mid"
var_kl_28 = "Standard"
var_kl_29 = 25
var_kl_30 = 250
linesize = "Small"
linestyle = "Solid"
var var_kl_31 = false
//----------------------------------------
// Session Levels
//----------------------------------------
var in_sl_1 = input.bool(defval=false, title="London", group="Session Levels", inline="london", tooltip = i_6)
var in_sl_2 = input.bool(defval=true, title="O/C", group="Session Levels", inline="london")
var in_sl_3 = input.bool(defval=true, title="H/L", group="Session Levels", inline="london")
var in_sl_4 = input.bool(defval=false, title="New York", group="Session Levels", inline="US", tooltip = i_6)
var in_sl_5 = input.bool(defval=true, title="O/C", group="Session Levels", inline="US")
var in_sl_6 = input.bool(defval=true, title="H/L", group="Session Levels", inline="US")
var in_sl_7 = input.bool(defval=false, title="Tokyo", group="Session Levels", inline="asia", tooltip = i_6)
var in_sl_8 = input.bool(defval=true, title="O/C", group="Session Levels", inline="asia")
var in_sl_9 = input.bool(defval=true, title="H/L", group="Session Levels", inline="asia")
in_sl_10 = false
in_sl_11 = "0800-1600"
in_sl_12 = "1400-2100"
in_sl_13 = "0000-0900"
in_sl_14 = input.color(title="", defval=color.white, group="Session Levels", inline="london")
in_sl_15 = input.color(title="", defval=color.white, group="Session Levels", inline="US")
in_sl_16 = input.color(title="", defval=color.white, group="Session Levels", inline="asia")
in_sl_17 = input.bool(defval=true, title="Shorten", group="Session Levels", inline="london")
in_sl_18 = input.bool(defval=true, title="Shorten", group="Session Levels", inline="US")
in_sl_19 = input.bool(defval=true, title="Shorten", group="Session Levels", inline="asia")
var var_sl_1 = in_sl_17 ? "Lon-H" : "London High"
var var_sl_2 = in_sl_17 ? "Lon-L" : "London Low"
var var_sl_3 = in_sl_17 ? "Lon-O" : "London Open"
var var_sl_4 = in_sl_18 ? "NY-H" : "New York High"
var var_sl_5 = in_sl_18 ? "NY-L" : "New York Low"
var var_sl_6 = in_sl_18 ? "NY-O" : "New York Open"
var var_sl_7 = in_sl_19 ? "TK-H" : "Tokyo High"
var var_sl_8 = in_sl_19 ? "TK-L" : "Tokyo Low"
var var_sl_9 = in_sl_19 ? "TK-O" : "Tokyo Open"
//----------------------------------------
// Dealing Range
//----------------------------------------
in_dr_1 = input.bool(defval=true, title="Dealing Range", group="Dealing Range", inline="1", tooltip = i_7)
in_dr_2 = input.color(#00ddff1b,"", inline="1", group="Dealing Range")
in_dr_3 = input.color(#b2b5be27, "", inline="1", group="Dealing Range")
in_dr_4 = input.int(50, minval = 0, title = "Offset", inline="2", group="Dealing Range")
//----------------------------------------
// Point of Control
//----------------------------------------
in_poc_1 = input(defval=true, title='Show POC Line', group="POINT OF CONTROL",inline = '1', tooltip = i_8)
in_poc_2 = input(defval=#fff176, title='', group="POINT OF CONTROL",inline = '1')
in_poc_3 = input.string("Solid", title="Line Style", options=["Solid", "Dashed", "Dotted"], group="POINT OF CONTROL", inline="22")
in_poc_4 = in_poc_3 == "Solid" ? line.style_solid : in_poc_3 == "Dashed" ? line.style_dashed : line.style_dotted
in_poc_5 = input.int(2, minval = 0, title = "Width", group="POINT OF CONTROL",inline = '2')
in_poc_6 = input.int(20, minval = 0, title = "Line Length", group="POINT OF CONTROL",inline = '2')
in_poc_7 = input.string("Medium", options=["Small", "Medium", "Large"], title="Text Size", inline="3", group="POINT OF CONTROL")
in_poc_8 = in_poc_7 == "Small" ? size.tiny : in_poc_7 == "Medium" ? size.small : size.normal
in_poc_9 = input(defval=true, title='Show Text', group="POINT OF CONTROL",inline = '3')
//----------------------------------------
// TrendLines
//----------------------------------------
in_trl_1 = input.bool(true, 'Show Trendlines', inline = 'tl_1',group='Trendlines',tooltip = i_10)
in_trl_2 = input.color(#9598a1, '', inline = 'tl_1',group='Trendlines')
in_trl_3 = input.color(#9598a1, '', inline = 'tl_1',group='Trendlines')
in_trl_4 = input.bool(true, 'Extend', inline = 'tl_1',group='Trendlines')
in_trl_5 = input.string(defval = 'Solid', title = "Style", options = ['Solid', 'Dotted', 'Dashed'],inline = "tl_3",group='Trendlines')
in_trl_6 = input.int(1, 'Width', step = 1, minval = 1,maxval = 4,inline = "tl_3",group='Trendlines')
in_trl_7 = input.int(25, 'Lookback', step = 1, minval = 1, inline ='tl_5',group='Trendlines')
in_trl_8 = in_trl_7//input.int(20, '/', step = 1, minval = 1, inline ='tl_5',group='Trendlines')
in_trl_9 = not(input.bool(true, 'Show Broken', inline = 'tl_2',group='Trendlines'))
in_trl_10 = input.color(#9598a1, '', inline = 'tl_2',group='Trendlines')
in_trl_11 = input.color(#9598a1, '', inline = 'tl_2',group='Trendlines')
in_trl_12 = input.bool(true, 'Extend', inline = 'tl_2',group='Trendlines')
in_trl_13 = input.bool(false, 'Show Signals', inline = 'tl_s',group='Trendlines')
in_trl_14 = input.color(color.yellow, '', inline = 'tl_s',group='Trendlines')
in_trl_15 = input.color(color.yellow, '', inline = 'tl_s',group='Trendlines')
in_trl_16 = input.int(1, 'Max Broken', step = 1, minval = 1, maxval = 50, inline = 'tl_2_B',group='Trendlines')
in_trl_17 = input.string('Close', 'Mitigation', options = ['Close', 'High/Low'], inline ='tl_2_B',group='Trendlines')
in_trl_18 = input.string(defval = 'Dashed', title = "Style (Broken)", options = ['Solid', 'Dotted', 'Dashed'],inline = "tl_2-1",group='Trendlines')
in_trl_19 = input.int(1, 'Width', step = 1, minval = 1,maxval = 4,inline = "tl_2-1",group='Trendlines')
in_trl_20= in_trl_5 == 'Solid' ? line.style_solid : in_trl_5 == 'Dotted' ? line.style_dotted : line.style_dashed
in_trl_21= in_trl_18 == 'Solid' ? line.style_solid : in_trl_18 == 'Dotted' ? line.style_dotted : line.style_dashed
//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
color transparent = #ffffff00
custom_func_1(res) =>
t = time(res)
not na(t) and (na(t[1]) or t > t[1])
custom_func_2(x, y, txt, css, dashed, down, lbl_size) =>
label.new(int(math.avg(x, bar_index)), y, txt, color=transparent, textcolor=css, style=down ? label.style_label_down : label.style_label_up, size=lbl_size)
line.new(x, y, bar_index, y, color=css, style=dashed ? line.style_dotted : line.style_solid)
custom_func_3(_cond, _count) =>
_barssince = bar_index - ta.valuewhen(_cond, bar_index, _count)
_barssince
// Swing Detection/Measurements
custom_func_4(length) =>
var prev = 0
prev := high[length] > ta.highest(length) ? 0 : low[length] < ta.lowest(length) ? 1 : prev[1]
t = prev == 0 and prev[1] != 0 ? high[length] : 0
b = prev == 1 and prev[1] != 1 ? low[length] : 0
[t, b]
var variable_ms_1 = 0, var variable_ms_2 = 0
var variable_ms_3 = 0., var variable_ms_4 = 0, var variable_ms_5 = 0., var variable_ms_6 = 0
var variable_ms_7 = 0., var variable_ms_8 = 0, var variable_ms_9 = 0., var variable_ms_10 = 0
var variable_ms_11 = true, var variable_ms_12 = true
var variable_ms_13 = true, var variable_ms_14 = true
var variable_ms_15 = high, var variable_ms_16 = low
var up_trailing_x = 0, var down_trailing_x = 0
var high_text = "", var low_text = ""
variable_ms_17 = false
variable_ms_18 = false
//-----------------------------------------------------------------------------
// Market Structure
//-----------------------------------------------------------------------------
variable_ms_19 = "Candle High"
MSS = true
// Functions
lineStyle(x) =>
switch x
"Solid" => line.style_solid
"Dashed" => line.style_dashed
"Dotted" => line.style_dotted
variable_ms_20 = ta.pivothigh(high, in_ms_10, in_ms_10)
variable_ms_21 = ta.pivotlow(low, in_ms_10, in_ms_10)
var float variable_ms_22 = na, var float variable_ms_23 = na, var int variable_ms_24 = na, var int variable_ms_25 = na
bool variable_ms_26 = false, bool variable_ms_27 = false, bool variable_ms_28 = false, bool variable_ms_29 = false
var int variable_ms_30 = 0
if not na(variable_ms_20)
if variable_ms_20 >= variable_ms_22
variable_ms_26 := true
variable_ms_30 := 2
else
variable_ms_27 := true
variable_ms_30 := 1
variable_ms_22 := variable_ms_20
variable_ms_24 := bar_index - in_ms_10
if not na(variable_ms_21)
if variable_ms_21 >= variable_ms_23
variable_ms_28 := true
variable_ms_30 := -1
else
variable_ms_29 := true
variable_ms_30 := -2
variable_ms_23 := variable_ms_21
variable_ms_25 := bar_index - in_ms_10
if variable_ms_26 and in_ms_9
label.new(bar_index - in_ms_10, variable_ms_20, "HH", color=CLEAR, style=label.style_label_down, textcolor=in_ms_14, size=in_ms_12)
if variable_ms_27 and in_ms_9
label.new(bar_index - in_ms_10, variable_ms_20, "LH", color=CLEAR, style=label.style_label_down, textcolor=in_ms_14, size=in_ms_12)
if variable_ms_28 and in_ms_9
label.new(bar_index - in_ms_10, variable_ms_21, "HL", color=CLEAR, style=label.style_label_up, textcolor=in_ms_14, size=in_ms_12)
if variable_ms_29 and in_ms_9
label.new(bar_index - in_ms_10, variable_ms_21, "LL", color=CLEAR, style=label.style_label_up, textcolor=in_ms_14, size=in_ms_12)
//-----------------------------------------------------------------------------
// Fair Value Gaps
//-----------------------------------------------------------------------------
// Global Data
var htfH = open
var htfL = open
if close > htfH
htfH := close
if close < htfL
htfL := close
// Security Data, used for HTF Bar Data reference
sClose = request.security(ticker.standard(syminfo.tickerid), in_fvg_2, close[1], barmerge.gaps_off, barmerge.lookahead_on)
sHighP2 = request.security(ticker.standard(syminfo.tickerid), in_fvg_2, high[2], barmerge.gaps_off, barmerge.lookahead_on)
sLowP2 = request.security(ticker.standard(syminfo.tickerid), in_fvg_2, low[2], barmerge.gaps_off, barmerge.lookahead_on)
sOpen = request.security(ticker.standard(syminfo.tickerid), in_fvg_2, open[1], barmerge.gaps_off, barmerge.lookahead_on)
sBar = request.security(ticker.standard(syminfo.tickerid), in_fvg_2, bar_index, barmerge.gaps_off, barmerge.lookahead_on)
// Array variables to hold data in memory
var variable_fvg_1 = array.new_box(0)
var variable_fvg_2 = array.new_box(0)
var variable_fvg_3 = array.new_box(0)
var variable_fvg_4 = array.new_box(0)
var variable_fvg_5 = array.new_line(0)
var variable_fvg_6 = array.new_line(0)
var variable_fvg_7 = array.new_line(0)
var variable_fvg_8 = array.new_line(0)
var variable_fvg_9 = array.new_line(0)
var variable_fvg_10 = array.new_line(0)
var variable_fvg_11 = array.new_label(0)
var variable_fvg_12 = array.new_label(0)
var variable_fvg_13 = color.new(color.white, 100)
var variable_fvg_14 = false
var variable_fvg_15 = false
variable_fvg_14 := false
variable_fvg_15 := false
// Functions
custom_func_5(_upperlimit, _lowerlimit, _midlimit, _bar, _boxholder, _boxholder_fill, _midholder, _highholder, _lowholder, _labelholder, _boxcolor, _mtfboxcolor, _htf, line_color_mid) =>
variable_fvg_16 = str.tostring(in_fvg_2)
offset = var_fvg_8
variable_fvg_17 = _mtfboxcolor
bg_color = color.new(_mtfboxcolor, in_fvg_op)
if _htf == false
variable_fvg_16 := str.tostring(timeframe.period)
offset := var_fvg_7
variable_fvg_17 := _boxcolor
array.push(_boxholder, box.new(_bar, _upperlimit, _bar + (var_ob_13) * in_fvg_9, _lowerlimit, border_color=in_fvg_6 ? bg_color : na, bgcolor=in_fvg_6 ? bg_color : na, extend=in_fvg_10 ? extend.right : extend.none, xloc=xloc.bar_time, text="", text_color=#787b86, text_halign=text.align_right, text_size=size.small))
array.push(_boxholder_fill, box.new(_bar, _upperlimit, _bar + (var_ob_13) * in_fvg_9, _lowerlimit, border_color=in_fvg_6 ? bg_color : na, bgcolor=in_fvg_6 ? bg_color : na, extend=in_fvg_10 ? extend.right : extend.none, xloc=xloc.bar_time))
array.push(_midholder, line.new(_bar, (_lowerlimit + _upperlimit) / 2.0, _bar + (var_ob_13) * in_fvg_9, _midlimit, color=mid_line_show == "On" ? line_color_mid : #363a4500, extend=in_fvg_10 ? extend.right : extend.none, style=lineStyle(in_fvg_13), width=in_fvg_16, xloc=xloc.bar_time))
array.push(_lowholder, line.new(_bar, _lowerlimit, _bar + (var_ob_13) * in_fvg_9, _lowerlimit, color=var_fvg_3 ? variable_fvg_17 : na, extend=in_fvg_10 ? extend.right : extend.none, width=1, xloc=xloc.bar_time))
array.push(_highholder, line.new(_bar, _upperlimit, _bar + (var_ob_13) * in_fvg_9, _upperlimit, color=var_fvg_3 ? variable_fvg_17 : na, extend=in_fvg_10 ? extend.right : extend.none, width=1, xloc=xloc.bar_time))
// Checks for gap between current candle and 2 previous candle (Fair Value Gap)
custom_func_6(_close, _high, _highp2, _low, _lowp2, _open, _bar, _htf) =>
gap = 0
thold_ = (ta.highest(_high, 300) - ta.lowest(_low, 300)) * math.max(in_fvg_3, 0.1) / 100.
if _open > _close // Red candle
if _lowp2 > _high
if not (in_fvg_4) or math.abs(_lowp2 - _high) > thold_
upperlimit = _high
lowerlimit = _lowp2
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap := 1
if in_fvg_1
custom_func_5(upperlimit, lowerlimit, midlimit, _bar, variable_fvg_1, variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11, var_fvg_1, in_fvg_12, _htf,in_fvg_14_2)
else
if _low > _highp2
if not (in_fvg_4) or math.abs(_low - _highp2) > thold_
upperlimit = _low
lowerlimit = _highp2
midlimit = lowerlimit + ((upperlimit - lowerlimit) / 2.)
gap := -1
if in_fvg_1
custom_func_5(upperlimit, lowerlimit, midlimit, _bar, variable_fvg_2, variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12, var_fvg_2, in_fvg_11, _htf,in_fvg_14)
gap
// Removes the gap from its relevant array if it has been filled
custom_func_7(_currentgap, _currentgap_fill, _i, _boxholder, _boxholder_fill, _midholder, _highholder, _lowholder, _labelholder) =>
array.remove(_boxholder, _i)
array.remove(_boxholder_fill, _i)
currentmid = array.get(_midholder, _i)
currenthigh = array.get(_highholder, _i)
currentlow = array.get(_lowholder, _i)
array.remove(_midholder, _i)
array.remove(_highholder, _i)
array.remove(_lowholder, _i)
if var_fvg_4
line.delete(currentmid)
line.delete(currenthigh)
line.delete(currentlow)
else
line.set_extend(currentmid, extend.none)
line.set_x2(currentmid, time)
line.set_extend(currenthigh, extend.none)
line.set_x2(currenthigh, time)
line.set_extend(currentlow, extend.none)
line.set_x2(currentlow, time)
if var_fvg_4
box.delete(_currentgap)
box.delete(_currentgap_fill)
else
box.set_extend(_currentgap, extend.none)
box.set_right(_currentgap, time)
// Checks if gap has been filled either by 0.5 fill (var_fvg_3) or SHRINKS the gap to reflect the true value gap left
custom_func_8(_high, _low) =>
variable_fvg_19 = 0
if array.size(variable_fvg_1) > 0
for i = array.size(variable_fvg_1) - 1 to 0
if in_fvg_15
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
cmid = array.get(variable_fvg_9, i)
chigh = array.get(variable_fvg_5, i)
clow = array.get(variable_fvg_7, i)
line.set_x2(cmid, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(chigh, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(clow, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap_fill, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap, timenow + (var_ob_13) * in_fvg_9)
if in_fvg_5 == "Touch"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenthigh = array.get(variable_fvg_5, i)
currentlow = array.get(variable_fvg_7, i)
currenttop = box.get_top(currentgap)
if high > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1, variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if in_fvg_5 == "Wicks"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenthigh = array.get(variable_fvg_5, i)
currentlow = array.get(variable_fvg_7, i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_3, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, high)
else
box.set_bottom(currentgap_f, math.max(cur_bottom, high))
box.set_bgcolor(currentgap_f, #787b865e)
if high > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1, variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if in_fvg_5 == "Close"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenthigh = array.get(variable_fvg_5, i)
currentlow = array.get(variable_fvg_7, i)
currenttop = box.get_bottom(currentgap)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_3, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, high)
else
box.set_bottom(currentgap_f, math.max(cur_bottom, high))
box.set_bgcolor(currentgap_f, #787b865e)
if close > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1, variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if in_fvg_5 == "Average"
currentgap_fill = array.get(variable_fvg_3, i)
currentgap = array.get(variable_fvg_1, i)
currentmid = array.get(variable_fvg_9, i)
currenttop = line.get_y1(currentmid)
currentbottom = box.get_top(currentgap_fill)
if high > currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_3, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, high)
else
box.set_bottom(currentgap_f, math.max(cur_bottom, high))
box.set_bgcolor(currentgap_f, #787b865e)
if high > currenttop
variable_fvg_19 := 1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_1, variable_fvg_3, variable_fvg_9, variable_fvg_5, variable_fvg_7, variable_fvg_11)
if array.size(variable_fvg_2) > 0
for i = array.size(variable_fvg_2) - 1 to 0
if in_fvg_15
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
cmid = array.get(variable_fvg_10, i)
chigh = array.get(variable_fvg_6, i)
clow = array.get(variable_fvg_8, i)
line.set_x2(cmid, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(chigh, timenow + (var_ob_13) * in_fvg_9)
line.set_x2(clow, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap_fill, timenow + (var_ob_13) * in_fvg_9)
box.set_right(currentgap, timenow + (var_ob_13) * in_fvg_9)
if in_fvg_5 == "Touch"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currenttop = box.get_top(currentgap)
currentmid = array.get(variable_fvg_10, i)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
if low < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2, variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
if in_fvg_5 == "Wicks"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(variable_fvg_10, i)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_4, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, low)
else
box.set_bottom(currentgap_f, math.min(cur_bottom, low))
box.set_bgcolor(currentgap_f, #787b865e)
if low < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2, variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
if in_fvg_5 == "Close"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currenttop = box.get_bottom(currentgap)
currentmid = array.get(variable_fvg_10, i)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_4, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, low)
else
box.set_bottom(currentgap_f, math.min(cur_bottom, low))
box.set_bgcolor(currentgap_f, #787b865e)
if close < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2, variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
if in_fvg_5 == "Average"
currentgap_fill = array.get(variable_fvg_4, i)
currentgap = array.get(variable_fvg_2, i)
currentmid = array.get(variable_fvg_10, i)
currenttop = line.get_y1(currentmid)
currenthigh = array.get(variable_fvg_6, i)
currentlow = array.get(variable_fvg_8, i)
currentbottom = box.get_top(currentgap_fill)
if low < currentbottom and in_fvg_7
currentgap_f = array.get(variable_fvg_4, i)
cur_bottom = box.get_bottom(currentgap_f)
_bottom = box.get_bottom(currentgap)
if _bottom == cur_bottom
box.set_bottom(currentgap_f, low)
else
box.set_bottom(currentgap_f, math.min(cur_bottom, low))
box.set_bgcolor(currentgap_f, #787b865e)
if low < currenttop
variable_fvg_19 := -1
custom_func_7(currentgap, currentgap_fill, i, variable_fvg_2, variable_fvg_4, variable_fvg_10, variable_fvg_6, variable_fvg_8, variable_fvg_12)
variable_fvg_19
// Pine provided function to determine a new bar
if custom_func_1(in_fvg_2)
htfH := high
htfL := low
variable_fvg_18 = 0
// User Input, allow MTF data calculations
if custom_func_1(in_fvg_2) and (var_fvg_6 == "Current + HTF" or var_fvg_6 == "HTF") and barstate.isconfirmed
variable_fvg_18 := custom_func_6(sClose, htfH, sHighP2, htfL, sLowP2, sOpen, time[2], true)
alertcondition(variable_fvg_18 == 1 or variable_fvg_18 == -1, "Bullish FVG", "Bullish FVG Found Ez-SMC")
variable_fvg_19 = custom_func_8(high, low)
alertcondition(variable_fvg_19 == 1 or variable_fvg_19 == -1, "Fair Value Gap Break", "FVG Broken Ez-SMC")
if array.size(variable_fvg_1) > in_fvg_8
d_box = array.shift(variable_fvg_1)
box.delete(d_box)
if array.size(variable_fvg_3) > in_fvg_8
d_box = array.shift(variable_fvg_3)
box.delete(d_box)
if array.size(variable_fvg_9) > in_fvg_8
d_line = array.shift(variable_fvg_9)
line.delete(d_line)
if array.size(variable_fvg_5) > in_fvg_8
d_line = array.shift(variable_fvg_5)
line.delete(d_line)
if array.size(variable_fvg_7) > in_fvg_8
d_line = array.shift(variable_fvg_7)
line.delete(d_line)
if array.size(variable_fvg_2) > in_fvg_8
d_box_ = array.shift(variable_fvg_2)
box.delete(d_box_)
if array.size(variable_fvg_4) > in_fvg_8
d_box_ = array.shift(variable_fvg_4)
box.delete(d_box_)
if array.size(variable_fvg_10) > in_fvg_8
d_line_ = array.shift(variable_fvg_10)
line.delete(d_line_)
if array.size(variable_fvg_6) > in_fvg_8
d_line_ = array.shift(variable_fvg_6)
line.delete(d_line_)
if array.size(variable_fvg_8) > in_fvg_8
d_line_ = array.shift(variable_fvg_8)
line.delete(d_line_)
n = bar_index
//-----------------------------------------------------------------------------
// Liquidity Levels
//-----------------------------------------------------------------------------
highLineColor = in_liq_12
lowLineColor = in_liq_11
highBoxBgColor = in_liq_12
highBoxBorderColor = in_liq_15
lowBoxBgColor = in_liq_11
lowBoxBorderColor = in_liq_16
atr_liq = ta.atr(300)
float thold_liq = atr_liq * (in_liq_10 / 10)
// Functions
custom_func_9(tf) =>
ts = timeframe.in_seconds("")
htfs = timeframe.in_seconds(tf)
htfs / ts
custom_func_10(_array) =>
if array.size(_array) > in_liq_6 / 2
a = array.shift(_array)
line.delete(a)
custom_func_11(_array) =>
if array.size(_array) > in_liq_6 / 2
a = array.shift(_array)
box.delete(a)
custom_func_12(_array, _hl) =>
m = false
if array.size(_array) > 0
for i = array.size(_array) - 1 to 0 by 1
l = array.get(_array, i)
hh = in_liq_5 == "Close" ? close[1] : high
ll = in_liq_5 == "Close" ? close[1] : low
if _hl == "High" and hh > line.get_y1(l)
array.remove(_array, i)
if in_liq_4 == "Show"// and in_liq_17 == "Lines"
line.new(line.get_x1(l), line.get_y1(l), time, line.get_y1(l), xloc=xloc.bar_time, color=in_liq_12, style=line.style_dotted, width=in_liq_18)
line.delete(l)
m := true
if _hl == "Low" and ll < line.get_y1(l)
array.remove(_array, i)
if in_liq_4 == "Show"// and in_liq_17 == "Lines"
line.new(line.get_x1(l), line.get_y1(l), time, line.get_y1(l), xloc=xloc.bar_time, color=in_liq_11, style=line.style_dotted, width=in_liq_18)
line.delete(l)
m := true
custom_func_10(_array)
m
custom_func_13(_array, _hl) =>
m = false
if array.size(_array) > 0
for i = array.size(_array) - 1 to 0 by 1
l = array.get(_array, i)
hh = in_liq_5 == "Close" ? close[1] : high
ll = in_liq_5 == "Close" ? close[1] : low
if _hl == "High" and hh > box.get_top(l)
array.remove(_array, i)
if in_liq_4 == "Show" and in_liq_17 == "Boxes"
box.new(box.get_left(l), box.get_top(l), time, box.get_bottom(l), xloc=xloc.bar_time, bgcolor=color.new(highBoxBgColor, 90), border_color=color.new(highBoxBorderColor, 90), border_style=line.style_dotted)
box.delete(l)
m := true
if _hl == "Low" and ll < box.get_top(l)
array.remove(_array, i)
if in_liq_4 == "Show" and in_liq_17 == "Boxes"
box.new(box.get_left(l), box.get_top(l), time, box.get_bottom(l), xloc=xloc.bar_time, bgcolor=color.new(lowBoxBgColor, 90), border_color=color.new(lowBoxBorderColor, 90), border_style=line.style_dotted)
box.delete(l)
m := true
custom_func_11(_array)
m
custom_func_14(lineArray) =>
if array.size(lineArray) > 0
for i = array.size(lineArray) - 1 to 0 by 1
l = array.get(lineArray, i)
timeExt = timenow + ((var_ob_13) * in_liq_7)
line.set_x2(l, timeExt)
custom_func_15(boxArray) =>
if array.size(boxArray) > 0
for i = array.size(boxArray) - 1 to 0 by 1
b = array.get(boxArray, i)
timeExt = timenow + ((var_ob_13) * in_liq_7)
box.set_right(b, timeExt)
// Higher TimeFrame
// Variables
var highLineArrayHTF = array.new_line()
var lowLineArrayHTF = array.new_line()
// Boxes
var highBoxArrayHTF = array.new_box()
var lowBoxArrayHTF = array.new_box()
// Get HTF
[_index_time, _open, _high, _low, _close] = request.security(syminfo.tickerid, in_liq_2, [time, open, high, low, close])
// Pivots
pivotHighHTF = ta.pivothigh(_high, in_liq_3 * custom_func_9(in_liq_2), in_liq_3 + custom_func_9(in_liq_2))
pivotLowHTF = ta.pivotlow(_low, in_liq_3 * custom_func_9(in_liq_2), in_liq_3 + custom_func_9(in_liq_2))
if in_liq_1
timeExt = time + ((time[1] - time[2]) * 10)
dis = in_liq_3 + custom_func_9(in_liq_2)
if pivotHighHTF
text_liq = in_liq_13 ? "BSL": " "
if in_liq_17 == "Lines"
array.push(highLineArrayHTF, line.new(_index_time[dis], _high[dis], _index_time[+1], _high[dis], color=in_liq_12, style=in_liq_9, xloc=xloc.bar_time, extend=in_liq_19 ? extend.right : extend.none, width=in_liq_18))
y1 = _high[dis] + thold_liq*2
y2 = _high[dis]
array.push(highBoxArrayHTF, box.new(_index_time[dis], y2, _index_time[+1], y1, bgcolor=#00000000, border_color=#00000000, xloc=xloc.bar_time, border_style=in_liq_9, extend=in_liq_19 ? extend.right : extend.none, border_width=in_liq_18, text=text_liq, text_halign=text.align_right, text_color=in_liq_14_2, text_size=size.small))
else
y1 = _high[dis]
y2 = _high[dis] - thold_liq
array.push(highBoxArrayHTF, box.new(_index_time[dis], y2, _index_time[+1], y1, bgcolor=in_liq_12, border_color=in_liq_12, xloc=xloc.bar_time, border_style=in_liq_9, extend=in_liq_19 ? extend.right : extend.none, border_width=in_liq_18, text=text_liq, text_halign=text.align_right, text_color=in_liq_14_2, text_size=size.small))
if pivotLowHTF
text_liq = in_liq_13 ? "SSL": " "
if in_liq_17 == "Lines"
array.push(lowLineArrayHTF, line.new(_index_time[dis], _low[dis], _index_time[+1], _low[dis], color=in_liq_11, style=in_liq_9, xloc=xloc.bar_time, extend=in_liq_19 ? extend.right : extend.none, width=in_liq_18))
y1 = _low[dis]
y2 = _low[dis] - thold_liq*2
array.push(lowBoxArrayHTF, box.new(_index_time[dis], y2, _index_time[+1], y1, bgcolor=#00000000, border_color=#00000000, xloc=xloc.bar_time, border_style=in_liq_9, extend=in_liq_19 ? extend.right : extend.none, border_width=in_liq_18, text=text_liq, text_halign=text.align_right, text_color=in_liq_14, text_size=size.small))
else
y1 = _low[dis] + thold_liq
y2 = _low[dis]
array.push(lowBoxArrayHTF, box.new(_index_time[dis], y2, _index_time[+1], y1, bgcolor=in_liq_11, border_color=in_liq_11, xloc=xloc.bar_time, border_style=in_liq_9, extend=in_liq_19 ? extend.right : extend.none, border_width=in_liq_18, text=text_liq, text_halign=text.align_right, text_color=in_liq_14, text_size=size.small))
// Run Functions
highLineAlertHTF = custom_func_12(highLineArrayHTF, "High")
lowLineAlertHTF = custom_func_12(lowLineArrayHTF, "Low")
highBoxAlertHTF = custom_func_13(highBoxArrayHTF, "High")
lowBoxAlertHTF = custom_func_13(lowBoxArrayHTF, "Low")
custom_func_14(highLineArrayHTF)
custom_func_14(lowLineArrayHTF)
custom_func_15(highBoxArrayHTF)
custom_func_15(lowBoxArrayHTF)
// Alerts
alertcondition(pivotHighHTF or pivotLowHTF, "Liquidity Level", "Liquidity Level Found Ez-SMC")
alertcondition(highLineAlertHTF or highBoxAlertHTF or lowLineAlertHTF or lowBoxAlertHTF, "Liquidity Level Break", "Liquidity Level Broken Ez-SMC")
//-----------------------------------------------------------------------------
// Key Levels
//-----------------------------------------------------------------------------
var var_klvl_1 = time
var var_klvl_2 = high
var var_klvl_3 = low
var_klvl_4 = request.security(syminfo.tickerid, "D", high, lookahead=barmerge.lookahead_on)
var_klvl_5 = request.security(syminfo.tickerid, "D", low, lookahead=barmerge.lookahead_on)
[var_klvl_6, var_klvl_7] = request.security(syminfo.tickerid, "D", [time, open], lookahead=barmerge.lookahead_on)
[var_klvl_8, var_klvl_9] = request.security(syminfo.tickerid, "D", [time[1], high[1]], lookahead=barmerge.lookahead_on)
[var_klvl_10, var_klvl_11] = request.security(syminfo.tickerid, "D", [time[1], low[1]], lookahead=barmerge.lookahead_on)
[var_klvl_12, var_klvl_13] = request.security(syminfo.tickerid, "W", [time, open], lookahead=barmerge.lookahead_on)
[var_klvl_14, var_klvl_15] = request.security(syminfo.tickerid, "W", [time[1], high[1]], lookahead=barmerge.lookahead_on)
[var_klvl_16, var_klvl_17] = request.security(syminfo.tickerid, "W", [time[1], low[1]], lookahead=barmerge.lookahead_on)
[var_klvl_18, var_klvl_19] = request.security(syminfo.tickerid, "M", [time, open], lookahead=barmerge.lookahead_on)
[var_klvl_20, var_klvl_21] = request.security(syminfo.tickerid, "M", [time[1], high[1]], lookahead=barmerge.lookahead_on)
[var_klvl_22, var_klvl_23] = request.security(syminfo.tickerid, "M", [time[1], low[1]], lookahead=barmerge.lookahead_on)
[var_klvl_24, var_klvl_25] = request.security(syminfo.tickerid, "240", [time, open], lookahead=barmerge.lookahead_on)
[var_klvl_26, var_klvl_27] = request.security(syminfo.tickerid, "240", [time[1], high[1]], lookahead=barmerge.lookahead_on)
[var_klvl_28, var_klvl_29] = request.security(syminfo.tickerid, "240", [time[1], low[1]], lookahead=barmerge.lookahead_on)
[var_klvl_30, var_klvl_31] = request.security(syminfo.tickerid, "3M", [time, open], lookahead=barmerge.lookahead_on)
[var_klvl_32, var_klvl_33] = request.security(syminfo.tickerid, "3M", [time[1], high[1]], lookahead=barmerge.lookahead_on)
[var_klvl_34, var_klvl_35] = request.security(syminfo.tickerid, "3M", [time[1], low[1]], lookahead=barmerge.lookahead_on)
[var_klvl_36, var_klvl_37] = request.security(syminfo.tickerid, "12M", [time, open], lookahead=barmerge.lookahead_on)
[var_klvl_38, var_klvl_39] = request.security(syminfo.tickerid, "12M", [time, high], lookahead=barmerge.lookahead_on)
[var_klvl_40, var_klvl_41] = request.security(syminfo.tickerid, "12M", [time, low], lookahead=barmerge.lookahead_on)
if var_klvl_12 != var_klvl_12[1]
var_kl_31 := false
var_kl_31
if in_kl_9 == true and var_kl_31 == false
var_kl_31 := true