Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

HOLY GRAIL for Amibroker (AFL)

Rating:
3 / 5 (Votes 25)
Tags:
trading system, amibroker, exploration, pivots

After lots of requests I received I put it here the 5th version of my programme HOLY GRAIL

I am still refining it in its further 8th version.

Screenshots

Similar Indicators / Formulas

KNP analysis 1
Submitted by kushal over 13 years ago
PRA TTS v1.1
Submitted by jaipal7786 about 12 years ago
PRA TTS
Submitted by jaipal7786 about 12 years ago
PIVOT POINT WITH VPA1 FOR AMIBROKER
Submitted by METHUN over 14 years ago
Market Profile with Volume and Camarilla Pivots
Submitted by bower about 15 years ago
Khichadi_R50_R3212.afl
Submitted by kartmer555 over 14 years ago

Indicator / Formula

Copy & Paste Friendly
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
_SECTION_BEGIN("PRASAD SYSTEMS");
Param("DEDICATED TO MY FATHER",5);
_SECTION_END();
 
_SECTION_BEGIN("BACK COLR");
SetChartBkColor( ParamColor("Chart Color", colorBlack));
SetChartOptions(0,chartShowArrows|chartShowDates);
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/13 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor("Text Color", ColorHSB( 42, 42, 42 ) ));
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/7);
 
GfxSelectFont("Tahoma", Status("pxheight")/17 );
GfxTextOut( "HOLY GRAIL", Status("pxwidth")/2, Status("pxheight")/2.6 );
 
GfxSelectFont("Tahoma", Status("pxheight")/30 );
GfxTextOut( "prasad9rao@gmail.com", Status("pxwidth")/2, Status("pxheight")/2.1);
 
GfxSelectFont("Arial Bold", Status("pxheight")/15);
GfxTextOut( "PRASAD ANALYSTIC ver 5", Status("pxwidth")/2, Status("pxheight")/20);
_SECTION_END();
 
GfxSetTextColor(ColorRGB(200, 150, 100) );
GfxSelectFont("Arial BOLD", Status("pxheight")/60);
 GfxTextOut( "Dedicated to My Father : BALKRISHNA RAO",Status("pxwidth")/5, Status("pxheight")/1.06);
 
SetBarFillColor( IIf(O>C,ColorRGB(217,0,0),ColorRGB(1,149,38)) );
Plot( C, "Price", IIf( O>C,ColorRGB(255,208,82), ColorRGB(255,255,255)), styleCandle );
 
/******************FIXED TITLES**************/
Chg=Ref(C,-1);
Title = EncodeColor(colorYellow)+ "Company :: " +Title = Name() + "    " + EncodeColor(colorLightOrange) + "Date :: "  + Date() +EncodeColor(11) + EncodeColor(colorWhite) + "\n{{INTERVAL}}  " +
   EncodeColor(55)+ "   Open:  "+ EncodeColor(colorWhite)+ WriteVal(O,format=1.2) +
   EncodeColor(55)+ "   High:  "+ EncodeColor(colorWhite) + WriteVal(H,format=1.2) +
   EncodeColor(55)+ "   Low:  "+ EncodeColor(colorWhite)+ WriteVal(L,format=1.2) +
   EncodeColor(55)+ "   Close:  "+ WriteIf(C> Chg,EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(C,format=1.2)+ 
   EncodeColor(55)+ "   Change:  "+ WriteIf(C> Chg,EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(ROC(C,1),format=1.2)+ "%"+
   EncodeColor(55)+ "   Volume: "+ EncodeColor(colorWhite)+ WriteVal(V,1);
 
 
 
 
/************************************************************
             SUPPORTS & RESISTANCE
*************************************************************/
 
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
 
 
_SECTION_BEGIN("Support and Resistance");
 
supres=ParamToggle("Display(ON - OFF)","Off|On",0);
if(supres)
{
 
 
Prd1=Param("Resistance Period",2,0,200,1);
                    
test   = TEMA  ( High , Prd1 ) ;  
 
PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,haHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,haHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,haHigh,2);//PeakValue2
 
MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak
 
MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1",   colorDarkRed,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2",   colorDarkRed,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3"colorDarkRed,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
MPKV4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,4); //MajorPeakValue
MPKD4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),4); //MajorPeakDate
SD4 = IIf(DateNum() < LastValue(MPKD4,lastmode = True ), Null, LastValue(MPKV4,Lastmode = True));//SelectedDate
Plot(SD4, "Resist4",   colorDarkRed,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
 
MPKV5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,5); //MajorPeakValue
MPKD5 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),5); //MajorPeakDate
SD5 = IIf(DateNum() < LastValue(MPKD5,lastmode = True ), Null, LastValue(MPKV5,Lastmode = True));//SelectedDate
Plot(SD5, "Resist5",   colorDarkRed,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
MPKV6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,6); //MajorPeakValue
MPKD6 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),6); //MajorPeakDate
SD6 = IIf(DateNum() < LastValue(MPKD6,lastmode = True ), Null, LastValue(MPKV6,Lastmode = True));//SelectedDate
Plot(SD6, "Resist6", colorDarkRed,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
 
 
//SP=L > Ref(L,-1) AND Ref(L,1) < L;//Peak
 
Prd2=Param("Suppport Period",2,0,200,1);
                    
test2   = TEMA ( Low , Prd2 ) ;  
 
SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
SPV0 = ValueWhen(SP,haLow,0);//PeakValue0
SPV1 = ValueWhen(SP,haLow,1);//PeakValue1
SPV2 = ValueWhen(SP,haLow,2);//PeakValue2
 
//PKV5 = ValueWhen(PK,haHigh,5);//PeakValue5
//PKV6 = ValueWhen(PK,haHigh,6);//PeakValue6
 
MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak
 
MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1"colorYellow,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2"colorYellow,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
 
MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3", colorYellow,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
MSPV4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,4);
MSPD4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),4);
SD4 = IIf(DateNum() < LastValue(MSPD4,lastmode = True ), Null, LastValue(MSPV4,Lastmode = True));
Plot(SD4,"Support4"colorYellow,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
MSPV5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,5);
MSPD5 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),5);
SD5 = IIf(DateNum() < LastValue(MSPD5,lastmode = True ), Null, LastValue(MSPV5,Lastmode = True));
Plot(SD5,"Support5"colorYellow,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
 
MSPV6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,6);
MSPD6 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),6);
SD6 = IIf(DateNum() < LastValue(MSPD6,lastmode = True ), Null, LastValue(MSPV6,Lastmode = True));
Plot(SD6,"Support6", colorYellow,styleDots|styleDashed|styleThick|styleNoTitle,maskAll);
 
 
}
 
_SECTION_END();
 
 
 
  /* **********************************
PIVOTS
********************************** */
 
 
 
 
 
_SECTION_BEGIN("PIVOT Average ");
P = ParamField("Field");
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear Regression-45,Exponential,Double Exponential,Tripple Exponential,Wilders,Simple");
Periods = Param("Periods", 9, 2, 100 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;
 
if( Type == "Weighted" )                m=  WMA( P, Periods );
if( Type == "Lagless-21"  )             m=  2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26"  )                m=  WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45"  ) m=  LinearReg( P, Periods );
if( Type == "Exponential" )             m = EMA( P, Periods );
if( Type == "Double Exponential" )  m = DEMA( P, Periods );
if( Type == "Tripple Exponential" )     m = TEMA( P, Periods );
if( Type == "Wilders" )                 m = Wilders( P, Periods );
if( Type == "Simple" )                  m = MA( P, Periods );
 
 
_SECTION_BEGIN("Pivot Finder");
 
  /* **********************************
 
Code to automatically identify pivots
 
********************************** */
 
// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",100,50,5000,10);
nBars = Param("Number of bars", 12, 5, 40);
 
 
"BIdxJJJ = " + BarIndex() +
 
"\n" + "OGGGGGGGGGGG = " + O + "\n"+"H = "+ H + "\n"+"L = " + L
 
+ "\n"+"C " ;
 
GraphXSpace=7;
 
// -- Create 0-initialized arrays the size of barcount
 
aHPivs = H - H;
 
aLPivs = L - L;
 
// -- More for future use, not necessary for basic plotting
 
aHPivHighs = H - H;
 
aLPivLows = L - L;
 
aHPivIdxs = H - H;
 
aLPivIdxs = L - L;
 
nHPivs = 0;
 
nLPivs = 0;
 
lastHPIdx = 0;
 
lastLPIdx = 0;
 
lastHPH = 0;
 
lastLPL = 0;
 
curPivBarIdx = 0;
 
aHHVBars = HHVBars(H, nBars);
 
aLLVBars = LLVBars(L, nBars);
 
aHHV = HHV(H, nBars);
 
aLLV = LLV(L, nBars);
 
aVisBars = Status("barvisible");
 
nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
 
_TRACE("Last visible bar: " + nLastVisBar);
 
// -- Initialize value of curTrend
 
curBar = (BarCount-1);
 
curTrend = "";
 
if (aLLVBars[curBar] <
 
aHHVBars[curBar]) {
 
curTrend = "D";
 
}
 
else {
 
curTrend = "U";
 
}
 
 
 
 
if (BarCount > farback)
{
for (i=0; i<farback; i++) {
 
curBar = (BarCount - 1) - i;
 
// -- Have we identified a pivot? If trend is down...
 
if (aLLVBars[curBar] < aHHVBars[curBar]) {
 
// ... and had been up, this is a trend change
 
if (curTrend == "U") {
 
curTrend = "D";
 
// -- Capture pivot information
 
curPivBarIdx = curBar - aLLVBars[curBar];
 
aLPivs[curPivBarIdx] = 1;
 
aLPivLows[nLPivs] = L[curPivBarIdx];
 
aLPivIdxs[nLPivs] = curPivBarIdx;
 
nLPivs++;
 
}
 
// -- or current trend is up
 
} else {
 
if (curTrend == "D") {
 
curTrend = "U";
 
curPivBarIdx = curBar - aHHVBars[curBar];
 
aHPivs[curPivBarIdx] = 1;
 
aHPivHighs[nHPivs] = H[curPivBarIdx];
 
aHPivIdxs[nHPivs] = curPivBarIdx;
 
nHPivs++;
 
}
 
// -- If curTrend is up...else...
 
}
 
// -- loop through bars
 
}
}
  
 
curBar = (BarCount-1);
 
candIdx = 0;
 
candPrc = 0;
 
lastLPIdx = aLPivIdxs[0];
 
lastLPL = aLPivLows[0];
 
lastHPIdx = aHPivIdxs[0];
 
lastHPH = aHPivHighs[0];
 
if (lastLPIdx > lastHPIdx) {
 
// -- Bar and price info for candidate pivot
 
candIdx = curBar - aHHVBars[curBar];
 
candPrc = aHHV[curBar];
 
if (
 
lastHPH < candPrc AND
 
candIdx > lastLPIdx AND
 
candIdx < curBar) {
 
 
// -- OK, we'll add this as a pivot...
 
aHPivs[candIdx] = 1;
 
// ...and then rearrange elements in the
 
// pivot information arrays
 
for (j=0; j<nHPivs; j++) {
 
aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-
 
(j+1)];
 
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];
 
}
 
aHPivHighs[0] = candPrc ;
 
aHPivIdxs[0] = candIdx;
 
nHPivs++;
 
}
 
} else {
 
 
// -- Bar and price info for candidate pivot
 
candIdx = curBar - aLLVBars[curBar];
 
candPrc = aLLV[curBar];
 
if (
 
lastLPL > candPrc AND
 
candIdx > lastHPIdx AND
 
candIdx < curBar) {
 
 
// -- OK, we'll add this as a pivot...
 
aLPivs[candIdx] = 1;
 
  
 
for (j=0; j<nLPivs; j++) {
 
aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
 
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
 
}
 
aLPivLows[0] = candPrc;
 
aLPivIdxs[0] = candIdx;
 
nLPivs++;
 
}
 
}
 
 
 
  
PlotShapes(
 
IIf(aHPivs==1,shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-15);
 
PlotShapes(IIf(aLPivs==1,shapeUpArrow , shapeNone), ColorRGB(168,255,0), 0, Low, Offset=-15);
 
 
 
 
printf("\n Buuuy pivotss %g", aLPivs);
printf("\n Seel pivotss %g \n",aHPivs);
 
 
IIf( (aHPivs==1 AND aLPivs==0),PIVOT_SELL = 5, PIVOT_SELL = 0 );
 
IIf( aLPivs==1 AND aHPivs==0, PIVOT_BUY = 0, PIVOT_BUY = 5 );
  
PIVOT_BUY  = IIf(aLPivs==1, 5, 0);
PIVOT_SELL = IIf(aHPivs==1, 5, 0);
 
  
 
printf("\n Buuuy pivotss %g", PIVOT_BUY);
printf("\n Seel pivotss %g \n",PIVOT_SELL);
 
 
 
PIVOT_status = WriteIf(PIVOT_BUY,"Buy["+PIVOT_BUY+"]",WriteIf(PIVOT_SELL,"Sell["+PIVOT_SELL+"]","NA"));
PIVOT_col = IIf (PIVOT_BUY,colorGreen, IIf (PIVOT_SELL,colorRed,colorLightGrey));
 
 
 
 
 
 
 
 
  
_SECTION_END();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/************************************************************
              VOLUMES INCLUDED IN CHART
*************************************************************/
_SECTION_BEGIN("Volume");
VOLUME_TOGGLE = ParamToggle("Plot Volume","Off|On",0);
minimum = LastValue( Lowest( Volume ) );
maximum = LastValue( Highest( Volume ) )*10;
 
  
Period = Param("Period", 10, 2, 300, 1, 10 );
Volumeclimaxup = colorRed;
HighVolumeChurnbars = colorLime;
Lowvolumebars = colorYellow;
Volumeclimaxdn = colorWhite;
ClimaxChurnColor=colorBlue;
  
Value1 = V;
Value2 = V*(H-L);
Value3 = V/(H-L);
 
SetBarFillColor(IIf( (Value2 == HHV(Value2,Period)),ColorRGB(255,0,0),
IIf( (Value3 == HHV(Value3,Period)), ColorRGB(0, 142,0),
IIf( (Value1 == LLV(Value1,Period)), ColorRGB(255,255,0),
IIf( ((Value2 == HHV(Value2,Period) AND (Value3 == HHV(Value3,Period)))), ClimaxChurnColor,
IIf( (Value3 == LLV(Value3,Period)), Volumeclimaxdn, ColorRGB(0, 206, 255 )))))));
 
 
 
BarColor = IIf( (Value2 == HHV(Value2,Period)),ColorRGB(255,0,0),
IIf( (Value3 == HHV(Value3,Period)),ColorRGB(0, 142,0),
IIf( (Value1 == LLV(Value1,Period)), ColorRGB(255,255,0),
IIf( ((Value2 == HHV(Value2,Period) AND (Value3 == HHV(Value3,Period)))), ClimaxChurnColor,
IIf( (Value3 == LLV(Value3,Period)), Volumeclimaxdn,  ColorRGB(0, 206, 255))))));
if(VOLUME_TOGGLE==1)
{
 
Plot( Volume, "Volume", Barcolor, styleCandle | styleThick | styleOwnScale, minimum, maximum);
_SECTION_END();
 
}
 
 
 
 
 
 
 
 
 
 
/************************************************************
              EMA 21 50 crossover
*************************************************************/
_SECTION_BEGIN("EMA");
EMA_TOGGLE = ParamToggle("Plot EMA","Off|On",1);
 
LOW_EMA= Param("Lower EMA",21,21,49,1);
L_EMA = EMA(C,LOW_EMA);
HIGH_EMA= Param("Higher EMA",50,50,199,1);
H_EMA = EMA(C,HIGH_EMA);
HIGHEST_EMA= Param("Highest EMA",200,200,365,1);
HT_EMA = EMA(C,HIGHEST_EMA);
 
if(EMA_TOGGLE==1)
{
Plot( EMA( C, LOW_EMA), _DEFAULT_NAME(), ParamColor("Lower EMA Color", colorPink ), ParamStyle("Style") );
Plot( EMA( C, HIGH_EMA), _DEFAULT_NAME(), ParamColor("Higher EMA Color", colorSkyblue), ParamStyle("Style") );
Plot( EMA( C, HIGHEST_EMA), _DEFAULT_NAME(), ParamColor("Highest EMA Color", colorRed ), ParamStyle("Style") );
 
}
 
_SECTION_END();
 
 
 
/**********************************************************
 /ADX        
***********************************************************/
 
range = Param("Range",14,3,60,1);
 
px = PDI(range);
nx = MDI(range);
ax = ADX(range);
 
Line_Control = 20;
 
up_adx = Ref(ADX(range),-1) < ADX(range);
dw_adx = Ref(ADX(range),-1) > ADX(range);
 
 
// ADX Trends
Notrend = ADX(range) < 20;
 
ModerateTrend =  ADX(range) >= 20 AND ADX(range) < 40 AND up_adx ;
 
StrongTrend =  ADX(range) >= 40 AND ADX(range) < 60 AND up_adx ;
 
VeryStrongTrend =  ADX(range) >= 60 AND ADX(range) < 80 AND up_adx ;
 
ExtremelyStrongTrend =  ADX(range) >= 80 AND up_adx ;
 
 
 
// Buy Conditions
 
bcon1 = Cross(px,ax) AND nx < px AND  ax > Ref(ax,-1);
scon1 = Cross(nx,ax) AND px < nx AND ax > Ref(ax,-1);
 
adbuy = ax < 20 AND ax > Ref(ax,-1) AND ( Cross(px,nx) OR nx < px) ;
adsell = ax < 20 AND ax > Ref(ax,-1) AND ( Cross(nx,px) OR nx > px) ;
 
adbuy1 = Cross(px,ax) AND nx < px AND  ax > Ref(ax,-1) AND px > ax;
adsell1 = Cross(nx,ax) AND nx > px AND  ax > Ref(ax,-1) AND nx > ax;
 
BUY_ADX = bcon1 + adbuy + adbuy1;
SELL_ADX =  scon1 + adsell + adsell1;
 
 
ADX_status = WriteIf(BUY_ADX,"Buy["+BUY_ADX+"]",WriteIf(SELL_ADX,"Sell["+SELL_ADX+"]","NA"));
ADX_col = IIf (BUY_ADX,colorGreen, IIf (SELL_ADX,colorRed,colorLightGrey));
 
 
 
 
 
 
 
 
 
 
 
/**********************************************************
 /MACD Cross
***********************************************************/
_SECTION_BEGIN("MACD");
MACD_TOGGLE = ParamToggle("Plot MACD","Off|On",0);
 
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
 
m1 = MACD(r1, r2);
s1 = Signal(r1,r2,r3);
difference = m1-s1;
 
 
mycolor=IIf(m1<0 AND m1>s1,51,IIf(m1>0 AND m1>s1,colorBrightGreen,IIf(m1>0 AND m1<s1,colorLightOrange,colorRed)));
 
// **********************
//MACD crossing zero
 
B_MACD_0 =  Cross(MACD(r1, r2),0);
 
 
 
S_MACD_0 =  Cross(0,MACD(r1, r2));
 
 
// **********************
//Bullish - Bearish MACD crossing signal above zero or below zero plane
 
 
BULL_CROSS_ABOVE_ZERO = Cross (MACD(r1, r2),Signal(r1,r2,r3)) AND MACD(r1, r2) > 0;
 
 
BEAR_CROSS_ABOVE_ZERO = Cross (Signal(r1,r2,r3),MACD(r1, r2)) AND MACD(r1, r2) > 0;
 
 
// **********************
//bELOW ZERO Bullish - Bearish MACD crossing signal above zero or below zero plane
 
BULL_CROSS_BELOW_ZERO  = Cross (MACD(r1, r2),Signal(r1,r2,r3)) AND MACD(r1, r2)<0;
 
 
BEAR_CROSS_BELOW_ZERO  = Cross(Signal(r1,r2,r3),MACD(r1, r2)) AND MACD(r1, r2)<0;
 
 
// **********************
//Zero line reject ZLR
 
 
BEAR_ZLR = BarsSince(B_MACD_0);
BEAR_ZLR1 = (BEAR_ZLR < 6) AND (S_MACD_0);
 
 
BULL_ZLR = BarsSince(S_MACD_0);
BULL_ZLR1 = (BULL_ZLR < 6) AND (B_MACD_0);
 
 
// **********************
//HOOKS
 
BULL_HOOK1 = BarsSince(BEAR_CROSS_ABOVE_ZERO);
BULL_HOOK = (BULL_HOOK1<6) AND BULL_CROSS_ABOVE_ZERO ;
 
 
BEAR_HOOK1 = BarsSince(BULL_CROSS_ABOVE_ZERO);
BEAR_HOOK = (BEAR_HOOK1<6) AND BEAR_CROSS_ABOVE_ZERO ;
 
 
BUY_MACD = B_MACD_0 + BULL_CROSS_ABOVE_ZERO + BULL_CROSS_BELOW_ZERO + BULL_ZLR1 + BULL_HOOK;
SELL_MACD = S_MACD_0 + BEAR_CROSS_ABOVE_ZERO + BEAR_CROSS_BELOW_ZERO + BEAR_ZLR1 + BEAR_HOOK;
 
/*
if(MACD_TOGGLE==1)
{
GraphX = 5;
Plot( m1, StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ),ParamStyle("MACD style") );
Plot( s1 ,"Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlueGrey ), ParamStyle("Signal style") );
  
Color =IIf(difference > 0,colorLime,colorRed);
 
Plot(m1-s1, "MACD Histogram", mycolor, styleHistogram | styleThick | styleNoLabel, styleOwnScale);
 
PlotShapes(IIf(B_MACD_0,shapeDigit1 ,Null),colorYellow,0,Min(0,0),Min(0,0));
PlotShapes(IIf(B_MACD_0,shapeUpArrow,Null),colorGreen,0,Min(0,0),-20);
 
PlotShapes(IIf(S_MACD_0,shapeDigit2 ,Null),colorOrange,0,Min(0,0),0);
PlotShapes(IIf(S_MACD_0,shapeDownArrow,Null),colorRed,0,Min(0,0),-20);
 
PlotShapes(IIf(BULL_CROSS_ABOVE_ZERO,shapeDigit3 ,Null),colorYellow,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BULL_CROSS_ABOVE_ZERO,shapeUpArrow,Null),colorGreen,0,Min(0,0),-20);
 
PlotShapes(IIf(BEAR_CROSS_ABOVE_ZERO ,shapeDigit4 ,Null),colorOrange,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BEAR_CROSS_ABOVE_ZERO ,shapeDownArrow,Null),colorRed,0,Min(0,0),-20);
 
PlotShapes(IIf(BULL_CROSS_BELOW_ZERO,shapeDigit5 ,Null),colorYellow,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BULL_CROSS_BELOW_ZERO,shapeUpArrow,Null),colorGreen,0,Min(0,0),-20);
 
PlotShapes(IIf(BEAR_CROSS_BELOW_ZERO,shapeDigit6 ,Null),colorOrange,0,Min(0,0),Min(0,0));
PlotShapes(IIf(BEAR_CROSS_BELOW_ZERO,shapeDownArrow,Null),colorRed,0,Min(0,0),-20);
 
PlotShapes(IIf(BEAR_ZLR1,shapeStar+shapePositionAbove,shapeNone),colorRed,0,0,-30);
PlotShapes(IIf(BULL_ZLR1,shapeStar+shapePositionAbove,shapeNone),colorGold,0,0,30);
 
PlotShapes(IIf(BULL_HOOK,shapeStar+shapePositionAbove,shapeNone),colorGold,0,0,30);
PlotShapes(IIf(BEAR_HOOK,shapeStar+shapePositionAbove,shapeNone),colorRed,0,0,-30);
}
*/
_SECTION_END();
 
BUY_MACD = B_MACD_0 + BULL_CROSS_ABOVE_ZERO + BULL_CROSS_BELOW_ZERO + BULL_ZLR1 + BULL_HOOK ;
SELL_MACD = S_MACD_0 + BEAR_CROSS_ABOVE_ZERO + BEAR_CROSS_BELOW_ZERO + BEAR_ZLR1 + BEAR_HOOK ;
 
MACD_status = WriteIf(BUY_MACD,"Buy["+BUY_MACD+"]",WriteIf(SELL_MACD,"Sell["+SELL_MACD+"]","NA"));
MACD_col = IIf (BUY_MACD,colorGreen, IIf (SELL_MACD,colorRed,colorLightGrey));
 
 
 
/**************************************************
                Stochastics
***************************************************/
_SECTION_BEGIN("STOCHASTICS");
STOC_TOGGLE = ParamToggle("Plot STOCHASTICS","Off|On",0);
 
 
SP = Param( "Periods", 10, 1, 200, 1 );
Ksmooth = Param( "%K avg", 5, 1, 200, 1 );
Dsmooth = Param( "%D avg", 5, 1, 200, 1 );
StochDval = StochD( SP , Ksmooth, DSmooth );
StochKval = StochK( SP , Ksmooth);
 
Overbought = 80;
Oversold = 20;
 
/*
if(STOC_TOGGLE==1)
{
GraphX = 5;
Plot( StochD( SP , Ksmooth, DSmooth), _DEFAULT_NAME(), ParamColor( "ColorD", colorTurquoise ), ParamStyle("Style") );
Plot( StochK( SP , Ksmooth), _DEFAULT_NAME(), ParamColor( "ColorK", colorPaleGreen ), ParamStyle("Style") );
 
Plot(Overbought,"Overbought Level",colorRed);
Plot(Oversold,"Oversold Level",colorGreen);
}
*/
 
StochBuy = Cross(StochK(SP,Ksmooth), StochD(SP,Ksmooth, DSmooth)) AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
 
StochSell = Cross (StochD(SP,Ksmooth, DSmooth), StochK(SP,Ksmooth)) AND
(StochD(SP,Ksmooth, DSmooth) > 20) AND (StochK(SP,Ksmooth) > 20) AND
(StochD(SP,Ksmooth, DSmooth) < 80) AND (StochK(SP,Ksmooth) < 80);
 
StochStrongBuy = Cross(StochK(SP,Ksmooth),StochD(SP,Ksmooth, DSmooth)) AND
(StochD(SP,Ksmooth, DSmooth) < 20) AND (StochK(SP,Ksmooth) < 20) ;
 
StochStrongSell = Cross (StochD(SP,Ksmooth,DSmooth), StochK(SP , Ksmooth));
(StochD(SP,Ksmooth, DSmooth) > 80) AND (StochK(SP,Ksmooth) > 80);
 
 
 
BUY_STOCH = StochBuy + StochStrongBuy;
SELL_STOCH = StochSell + StochStrongSell;
printf("sto %g",BUY_STOCH);
 
_SECTION_END();
 
STOCH_status = WriteIf(BUY_STOCH,"Buy["+BUY_STOCH+"]",WriteIf(SELL_STOCH,"Sell["+SELL_STOCH+"]","NA"));
STOCH_col = IIf (BUY_STOCH,colorGreen, IIf (SELL_STOCH,colorRed,colorLightGrey));
 
 
 
 
 
/**************************************************
                TREND DETECTOR
***************************************************/
 
_SECTION_BEGIN("Trend Detector");
TREND_TOGGLE = ParamToggle("Plot Trend","Off|On",0);
A = (H+C+L)/3;
B=MA(A,5)-EMA(A,34);
D = EMA(A,34)-MA(A,5);
Bcolor=IIf(B>D,25,39);
Dcolor=IIf(D<B,25,39);
Up = B > D;
down = B < D;
TREND_B = Cross(B,D);
TREND_S = Cross(D,B);
if(TREND_TOGGLE==1)
{
Plot(B,"B ",Bcolor,styleLine|styleThick);
Plot(D,"D ",Dcolor,styleLine|styleThick);
Plot(B,"",Bcolor,styleHistogram|styleThick);
Plot(D,"",Dcolor,styleHistogram|styleThick);
Plot(0,"",colorWhite,styleLine);
PlotShapes(IIf(TREND_S, shapeHollowDownArrow , shapeNone), colorRed,0,0,-8);
PlotShapes(IIf(TREND_B, shapeHollowUpArrow , shapeNone), colorGreen,0,0,-8);
 
}
 
_SECTION_END();
TREND_status = WriteIf(TREND_B,"Buy",WriteIf(TREND_S ,"Sell","NA"));
TREND_col = IIf (TREND_B,colorGreen, IIf (TREND_S ,colorRed,colorLightGrey));
 
 
 
 
 
/**************************************************
               RSI
***************************************************/
_SECTION_BEGIN("RSI");
 
 
Rperiods = Param( "Periods", 14, 1, 200, 1 );
OB = Param("OverBrought Line",70,70,100,1);
OS = Param("OverSold Line",30,20,40,1);
CentreRSI = 50;
Overbought = OB;
Oversold = OS;
 
RSI_PERIODS = Prec(RSI( Rperiods),1);
 
 
//******* RSI Cross 30 or 70**//
 
B_RSI = RSI_CROSS_30 = Cross(RSI_PERIODS,OS);
 
S_RSI = RSI_CROSS_70 = Cross(OB,RSI_PERIODS);
 
 
//******* RSI < 30 or > 70**//
 
RSI_BELOW_30 = RSI_PERIODS < OS ;
 
RSI_ABOVE_70 = RSI_PERIODS > OB ;
 
 
//******* RSI > OR < IN LAST 14 DAYS***//
 
RSI_14_GREATEST = RSI_PERIODS>=HHV( RSI_PERIODS, 14);
 
RSI_14_LOWEST = RSI_PERIODS<=LLV( RSI_PERIODS, 14);
 
 
//******* RSI DIVERGENCE***//
 
RSI_BEAR_DIV = Close >= HHV( Close, 14 ) AND RSI_PERIODS < HHV( RSI_PERIODS, 14 );
 
RSI_BULL_DIV = RSI_PERIODS >= HHV( RSI_PERIODS, 14 ) AND Close < HHV( Close, 14 );
 
RSI_BULL_DIV1 = Close <= LLV( Close, 14 ) AND RSI_PERIODS > LLV(RSI_PERIODS, 14 );
 
RSI_BEAR_DIV1 = RSI_PERIODS <= LLV( RSI_PERIODS, 14) AND Close > LLV(Close,14);
/*****/////////
 
 
 
RSI_BUY = B_RSI ;
RSI_SELL =S_RSI ;
 
 
_SECTION_END();
RSI_status = WriteIf(RSI_BUY,"Buy["+RSI_BUY+"]",WriteIf(RSI_SELL,"Sell["+RSI_SELL+"]","NA"));
RSI_col = IIf (RSI_BUY,colorGreen, IIf (RSI_SELL,colorRed,colorLightGrey));
 
/**************************************************
             OBV
***************************************************/
_SECTION_BEGIN("OBV");
 
 
MA_OBV_Period = Param("OBV_MA Period",10,10,21,1);
 
 
 
 
/***********OBV CROSS MA************/
OBV_BUY = Cross(OBV(),MA(OBV(),MA_OBV_Period));
OBV_SELL = Cross(MA(OBV(),MA_OBV_Period),OBV());
 
_SECTION_END();
 
 
OBV_status = WriteIf(OBV_BUY,"Buy",WriteIf(OBV_SELL,"Sell","NA"));
OBV_col = IIf (OBV_BUY,colorGreen, IIf (OBV_SELL,colorRed,colorLightGrey));
 
 
 
 
 
 
/**************************************************
            TSV = SIMILAR TO WORDEN
***************************************************/
_SECTION_BEGIN("TSV");
Period = Param("Period for FVE", 22, 5, 80, 1 );
Coeff = Param("Coeff for Cutoff", 0.1, 0, 2, 0.01 );
 
intra=log(H)-log(L);
Vintra = StDev(intra, period );
inter = log(Avg)-log(Ref(Avg,-1));
Vinter = StDev(inter,period);
Cutoff = Coeff * (Vinter+Vintra)*C;
MF = C- (H+L)/2 + Avg - Ref( Avg, -1 );
VC = IIf( MF > Cutoff, V,
IIf( MF < -Cutoff, -V, 0 ));
FVE = 100 * Sum( VC, Period )/(MA( V, Period ) * Period );
 
// Momemtum Indicator by William Blau
 
TSI = 100 * ( EMA( EMA( C - Ref( C, -1 ) ,25 ) ,13)
/ EMA( EMA( abs( C - Ref( C, -1) ),25 ), 13 ) );
 
 
TSI_BUY = Cross(TSI,EMA(TSI,7));
TSI_SELL = Cross(EMA(TSI,7),TSI);
_SECTION_END();
 
TSI_status = WriteIf(TSI_BUY,"Buy",WriteIf(TSI_SELL,"Sell","NA"));
TSI_col = IIf (TSI_BUY,colorGreen, IIf (TSI_SELL,colorRed,colorLightGrey));
 
 
 
 
 
 
 
 
 
/**************************************************
              TRIX
***************************************************/
_SECTION_BEGIN("TRIX");
// TRIX - 15 Periods, 9 Signal Periods
tPeriods = Param("Periods", 15, 2, 100, 1 );
tSig = Param("Signal", 9, 2, 100, 1);
 
Zero = 0;
 
TRIX_VAL = Trix(tPeriods);
SIG_TRIX = EMA(Trix(tPeriods),tSig);
 
 
/***********TRIX & Signal Line cross ************/
TRIX_SIGNAL_BUY = Cross(TRIX_VAL, SIG_TRIX) AND TRIX_VAL < 0;
TRIX_SIGNAL_SELL = Cross(SIG_TRIX, TRIX_VAL)AND TRIX_VAL > 0;
 
 
 
 
/***********TRIX & Zero Line cross ************/
TRIX_ZERO_BUY = Cross(TRIX_VAL, Zero);
TRIX_ZERO_SELL = Cross(Zero, TRIX_VAL);
 
 
 
TRIX_BUY = TRIX_SIGNAL_BUY + TRIX_ZERO_BUY;
TRIX_SELL = TRIX_SIGNAL_SELL + TRIX_ZERO_SELL;
 
 
_SECTION_END();
 
 
TRIX_status = WriteIf(TRIX_BUY,"Buy",WriteIf(TRIX_SELL,"Sell","NA"));
TRIX_col = IIf (TRIX_BUY,colorGreen, IIf (TRIX_SELL,colorRed,colorLightGrey));
 
 
 
 
 
/************************************************
                 Gap
*************************************************/
 
GAP_UP = GapUp();
GAP_DW = GapDown();
 
GAP_status = WriteIf(GAP_UP,"Buy",WriteIf(GAP_DW ,"Sell","NA"));
GAP_col = IIf (GAP_UP,colorGreen, IIf (GAP_DW ,colorRed,colorLightGrey));
 
 
 
 
/************************************************
            Total of Bullish/Bearish
*************************************************/
 
 
 
 
 
Total_Buy  = PIVOT_BUY + BUY_ADX + BUY_MACD + BUY_STOCH+ TREND_B + GAP_UP + RSI_BUY + OBV_BUY + TSI_BUY + TRIX_BUY;
Total_Sell = PIVOT_SELL + SELL_ADX + SELL_MACD + SELL_STOCH + TREND_S + GAP_DW + RSI_SELL + OBV_SELL +TSI_SELL+TRIX_SELL;
 
 
printf("B OIVOTS %g\n",PIVOT_BUY);
printf("SELL PIVOTS %g\n",PIVOT_SELL);
printf("BUY GAP %g\n",TREND_B);
printf("BUY TREND %g\n",GAP_UP);
 
printf("BUY RSI %g\n",B_RSI + RSI_14_GREATEST + RSI_BULL_DIV1 + RSI_BULL_DIV);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/****************************************************
                   CHART TITLES
****************************************************/
_SECTION_BEGIN("ANALYSIS");
ANALYSIS_TOGGLE = ParamToggle("ON - OFF","Off|On",1);
if(ANALYSIS_TOGGLE==1)
{
Chg=Ref(C,-1);
Title = EncodeColor(ColorRGB(109,178,255))+ "Company :: " +Title = Name() + "    " + EncodeColor(colorLightOrange) + "Date :: "  + Date() +EncodeColor(11) + EncodeColor(colorWhite) + "\n{{INTERVAL}}  " +
   EncodeColor(ColorRGB(0,240,255))+ "   Open:  "+ EncodeColor(colorWhite)+ WriteVal(O,format=1.2) +
   EncodeColor(ColorRGB(0,240,255))+ "   High:  "+ EncodeColor(colorWhite) + WriteVal(H,format=1.2) +
   EncodeColor(ColorRGB(0,240,255))+ "   Low:  "+ EncodeColor(colorWhite)+ WriteVal(L,format=1.2) +
   EncodeColor(ColorRGB(0,240,255))+ "   Close:  "+ WriteIf(C> Chg,EncodeColor(ColorRGB(168,255,0)),EncodeColor(colorRed))+ WriteVal(C,format=1.2)+ 
   EncodeColor(ColorRGB(0,240,255))+ "   Change:  "+ WriteIf(C> Chg,EncodeColor(ColorRGB(168,255,0)),EncodeColor(colorRed))+ WriteVal(ROC(C,1),format=1.2)+ "%"+
   EncodeColor(ColorRGB(195,158,255))+ "   Volume: "+ EncodeColor(colorWhite)+ WriteVal(V,1)
 
 
 
+"\n"
+"\n"+EncodeColor(colorYellow) +"---------------------"
+"\n"+EncodeColor(colorGold)+   "       Prasad        "
+"\n"+EncodeColor(colorYellow) +"---------------------"
 
 
/**************** PIVOTS***************************/
+ "\n"
+EncodeColor(colorWhite)+"PIVOTS                      = " +
WriteIf (aLPivs,EncodeColor(ColorRGB(168,255,0))+" BUY("+PIVOT_BUY+")",WriteIf (aHPivs,EncodeColor(colorRed)+ " SELL("+PIVOT_SELL+")","Neutral"))
 
 
 
 
 
/**************** ADX***************************/
+ "\n"
+EncodeColor(colorWhite)+"ADX                            =  " +
WriteIf (BUY_ADX,EncodeColor(ColorRGB(168,255,0))+"BUY("+BUY_ADX+")",WriteIf (SELL_ADX,EncodeColor(colorRed)+ " SELL("+SELL_ADX+")","Neutral"))
 
 
/**************** MACD ***************************/
 
+ "\n" +
EncodeColor(colorWhite)+"MACD "+"["+r1+"]"+" " +"["+r2+"]"+" " +"["+r3+"]    =  " +
WriteIf (BUY_MACD,EncodeColor(ColorRGB(168,255,0))+"BUY("+BUY_MACD+")",WriteIf (SELL_MACD,EncodeColor(colorRed)+ "SELL("+SELL_MACD+")","Neutral"))
  
 
/********************STOChASTICS*********************/
 
+"\n"+EncodeColor(colorWhite)+"Stochastics              =  "
+ WriteIf(BUY_STOCH,EncodeColor(ColorRGB(168,255,0))+"BUY ("+BUY_STOCH+")",WriteIf(SELL_STOCH,EncodeColor(colorRed)+"SELL("+SELL_STOCH+")","Neutral"))
 
 
/********************RSI*********************/
+"\n" + EncodeColor(colorWhite)+"RSI"+"("+Rperiods+")                     =  "
+WriteIf(B_RSI,EncodeColor(ColorRGB(168,255,0))+"BUY("+RSI_BUY+")",WriteIf (S_RSI,EncodeColor(colorRed)+"SELL("+RSI_SELL+")","NEUTRAL"))
 
 
/********************OBV********************/
+"\n"
+EncodeColor(colorWhite)+"OBV                           =  "+
WriteIf(OBV_BUY,EncodeColor(ColorRGB(168,255,0))+"BUY(1)",WriteIf(OBV_SELL,EncodeColor(colorRed)+"SELL(1)",""))+
WriteIf(NOT OBV_BUY AND NOT OBV_SELL,"No Cross","")
 
 
/********************TSV********************/
 
+"\n"
+EncodeColor(colorWhite)+"TSV                            =  "  +
WriteIf(TSI_BUY,EncodeColor(ColorRGB(168,255,0))+"BUY(1)",
WriteIf(TSI_SELL,EncodeColor(colorRed)+"SELL(1)",""))+
WriteIf(NOT TSI_BUY AND NOT TSI_SELL,EncodeColor(colorAqua)+"NA","")
 
 
/********************TRIX*********************/
+"\n"
+EncodeColor(colorWhite)+"TRIX "+ "("+tPeriods+") "+"(" +tSig+ ")            =  "
 
+EncodeColor(ColorRGB(168,255,0))+
WriteIf (TRIX_BUY, "BUY ("+TRIX_BUY+")","")
+EncodeColor(colorRed)+
WriteIf (TRIX_SELL, "SELL("+TRIX_SELL+")","")
+EncodeColor(colorAqua)+
WriteIf (NOT TRIX_SELL AND NOT TRIX_BUY, "No Cross","")
 
 
/**************TREND*********************************/
 
 
+"\n" +EncodeColor(colorWhite)+"Trend                        =  "
+WriteIf(Up AND NOT TREND_B,EncodeColor(ColorRGB(168,255,0))+"Up ",WriteIf(Up AND TREND_B,EncodeColor(colorBrightGreen)+ "BUY(1)",
WriteIf(Down AND NOT TREND_S,EncodeColor(colorRed)+"Down",WriteIf(Down AND TREND_S,EncodeColor(colorRed)+"SELL(1)","."))))
 
 
/**************GAPS *********************************/
 
 
+"\n"+EncodeColor(colorWhite)+"GAP                           =  "
+WriteIf(GAP_UP,EncodeColor(ColorRGB(168,255,0))+"UP (1)",WriteIf(GAP_DW,EncodeColor(colorRed)+"DOWN (1)", EncodeColor(colorAqua)+"Neutral"))
 
 
 
 
 
 
 
 
 
 
 
 
+"\n"+EncodeColor(colorPink) +"======================"
+"\n"+EncodeColor((ColorRGB(242,157,255)))+"BUY    =    "+EncodeColor(colorYellow)+Total_Buy
+"\n"+EncodeColor((ColorRGB(242,157,255)))+"SELL   =    "+EncodeColor(colorYellow)+Total_Sell
+"\n"+EncodeColor(colorPink) +"---------------------";
 
 
 
}
_SECTION_END();
 
 
 
 
 
 
 
 
 
 
 
//**************************************************************************************
//                                              EXPLORATION COLUMNS
//***********************************************************************************/
 
Filter =  Total_Buy OR Total_Sell;
 
 
 
SetOption("NoDefaultColumns", True);
 
AddTextColumn( Name(), "Security", 1, textColor=colorBlack, bkgndColor=colorSkyblue);
 
AddColumn( DateTime(), "Date", formatDateTime, colorBlack, colorTan);
 
AddTextColumn(PIVOT_status, "MACD", 1, colorWhite,PIVOT_col);
 
AddTextColumn(MACD_status, "MACD", 1, colorWhite, MACD_col);
 
AddTextColumn(STOCH_status, "STOCH", 1, colorWhite, STOCH_col);
 
AddTextColumn(RSI_status, "RSI", 1, colorWhite, RSI_col);
 
AddTextColumn(OBV_status, "OBV", 1, colorWhite, OBV_col);
 
AddTextColumn(TSI_status, "TSV", 1, colorWhite, TSI_col);
 
AddTextColumn(TRIX_status, "TRIX", 1, colorWhite, TRIX_col);
 
AddTextColumn(TREND_status, "TREND", 1, colorWhite, TREND_col);
 
AddTextColumn(GAP_status, "GAP", 1, colorWhite, GAP_col);
 
 
AddColumn(Total_Buy,"Ttl Buy",1.2,colorBlack);
AddColumn(Total_Sell,"Ttl Sell",1.2,colorBlack);

33 comments

1. taxxghost

It seems very good!!! Thank you very much!!

2. prakash2009

There is no holy grail available in the earth.

It refers to future quotes.Arrows will disappear.
Not meant for trading.
Admin should remove all the future looking codes from the site.

3. prasadbrao

THere are always some pessimists and sadists available on d earth. People who havent done a deep digging into technical analysis.

As I mentioned this was a very initial version of what I designed. And there are no future looking indicators here in this version.

The Parabolic and Volume Zig Zag are future looking indicators which are not there in this version.

Currently I am refining my 9 th version of HOLY GRAIL and am happy with the results.

I dont have the time to do R&D on the existence of HOLY GRAIL , but I am happy as long it produces profitable trades…. U call it BULL SHIT or HOLY GRAIL is immaterial.

Last but not the least I have not come here to argue or to prove ne thing………..

4. prakash2009

You may happy with your future looking code. ok.

Change the name of afl. Its not holy grail.Its a utter crap.

5. administrator

@prakash2009 There is no need to put down other peoples work.

It was provided here free for everyone. If you do not like it then leave a constructive comment and use the rating system.

Pivots are always future looking. The formula looks like it shows a summary of buy and sell signals from many different systems and also allows you to explore for those signals. Pivots are displayed with arrows and they are future looking.

6. taxxghost

A system must be a risk calculated bet. If you wait for a well confirmed signal you loose half of the gain.

7. rashedbgd

Thanks a lot Prasad for sharing this code.
I strongly agree with admin specially….

//administrator
@prakash2009 There is no need to put down other peoples work.//

Nice comment, we should be make the ppl underestimated…we may differ in our opinion but that should be focused in a polite and nice way.

I am appreciating and encouraging PRASAD for doing and sharing such a nice work. I found this afl is useful with me.

8. classy

thanks a lot for nice afl.volume bar size /length is too small .is there any option to increase volume bar size to clear visualization?

9. hyraj

Dear Prasad B Rao,
I m newbie in Ami paltform as well as in AFL.
But whn i downloaded & saw in Live…it’s showing good results.
Thanks to u as well as admin to support u.
~hyraj

10. wolf

Ghanta Holy Grail Lol Nowadays People Everyday Shout I Found Holy Grail And Put His Name AFter Making Colorfull Some Other’s System

11. morgen

This is something to look at it, but not use it!

12. gajananprofits@yahoo.co.in

Fooly Grail

13. kacem

Bravo

14. samapada

I checked out this code but signals r nt trust worthy as Butterworth with setting 29…….. I changed no’s of bars to 23 & 33…. it given signals low points,but later disappears……which is not gng to happen….pls sir make it more accurate…..

15. tuhin

Prasad,

Thanks you for sharing this formula.
Please design a stock screen AFL based on Holy Grail .

regards
tuhin

16. raghu535

dear peasad rao garu,

i am happy with the results of holy grail , but looking forward to your new version..

pls share your mail-id if you don;t mind..

17. tryingtotrade

Hi Mr. Prasad Rao,
Thanks for sharing the afl, your hard work.

18. Aviator1123

pls share the upgraded version.

19. prasadbrao

Technical Analysis is not a monkeys play…

20. johnnypareek

@prasadbrao,

Hi bhai, Please note that you can check your afl, whether its look into future or not, by opening it in formula editor >tools>code check & profile.

Now, Future looking may be for say two bar, so, if any afl looks in to future for two bar you can delay your trade for 2 bars to check whether it change signal or not.

BTW, Below is the report given by afl check:-

“It seems that the formula references FUTURE quotes.
If you backtest this system you may receive outstanding results
that CAN NOT be reproduced in real trading.

19724 data bars used during this check. Total execution time: 0.142598 sec.
*Approximately ALL past and ALL future quotes are needed *to calculate the formula properly

(This statement is automated rough estimate and does not take into account functions exported by plugins or scripting parts of your formula)".

:( Its fully useless. Please don’t mind but why I am saying is not to feel you down but to save peoples from making losses who are not aware of this.

Hope you understand.

johnnypareek

21. santosh

dear prasad rao

i agree with your hard work and back testing one thing is true there is no indicator in the world which can give more than 70% accuracy if we find that magic indicator it takes lot of effort and market psychology to trade in that time frame and what we behave during intraday only market experience with many many years and with strict money management can only help not with indicators

dear fellow members and dont go for magic indicators and ther is no holy grail

if any fellow members made consistant profit without losing capital plz post your comments to my mail santkmys@yahoo.com

thanks

22. manojin1

Mr Prasad I like your AFL, Pls. share with me on my mail manojin1@gmail.com, Thanks

24. Jean-Pierre

Hi, I am new user to this website. I do not understand people that call this good AFL as shit. For me that work correct at the first try. Then maybe these people not happy have to check their knowledge about how to install AFL in their software. Anyway PRASADBRAO You are a very good person for to share this wonderful AFL. Thank You Very Very Very Much!!!!!!!!!!!!!!!!!

25. marcheur

Using arrows to indicate pivot points (which are not buy signals) may confuse people into thinking this is a real holy grail.

26. imranb_001

dear prasad dont care about what others say they themselves are jealous of you. i like this afl v much. thanku for sharing. i like your work. thnks v much. its v helpful. plz update if possible

27. skyduck

Dear Prasad ! I am really grateful to you for such a beautiful and useful code and really appreciate your hard working. If you have upgraded/updated this system then please let us be beneficieries of the same.

28. kacraj

Hi Prasad,
Can you please share your holy grail system? my mail id kacraj@gmail.com

Regards,
kacraj

29. rcraja2001

Its repainting one……..Not holy Grail its only Tail

30. cadoize

how to scan with this AFL?

31. jais5247

thanks for AFL
signal are late
need to improve
please share new ver.

32. reniko

como se descarga

33. Nareshkumar

really super sir , thank u

34. Fajri

It’s been 7 years or more, have you come out with the 8th version as you promised? Can’t wait to see it coming!

Leave Comment

Please login here to leave a comment.

Back