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

NEW AFL for Amibroker (AFL)

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
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
pxh= Status("pxHeight"); pxw=Status("pxWidth");
GfxSelectFont("Tahoma",pxh/30);
GfxSetTextColor(colorWhite);
GfxSetTextAlign(6); GfxSetBkMode(0);
GfxTextOut(FullName(),pxw/2,pxh/12);
GfxSelectFont("Tahoma",pxh/15);
GfxTextOut("",pxw/2,pxh/3);
_SECTION_END();
 
 
_SECTION_BEGIN("Trend Detection");
 
 
function Rise( Pd, perd, Pl, perl )
{
MAD = DEMA(Pd,perd);
MAL = LinearReg(Pl,perl);
CondR = ROC(MAD,1)>0 AND ROC(MAL,1)>0;
CondF = ROC(MAD,1)<0 AND ROC(MAL,1)<0;
R[0] = C[0]>(H[0]+L[0])/2;
 
for(i=1;i<BarCount;i++)
{
if( CondR[i] )
{
R[i] = 1;
}
else
{
if( CondF[i] )
{
R[i] = 0;
}
else
{
R[i] = R[i-1];
}
}
}
return R;
}
 
PrD = C;
PrL = H/2+L/2;
PrdD = PrdL = PrdM = Param("Prd",12,2,40,1);
 
permax = Max(prdd,prdl);
 
Rs = IIf( BarIndex()<permax, 0, Rise(PrD, PrdD, PrL, PrdL) );
Fs = IIf( BarIndex()<permax, 0, 1-Rs );
 
Confirm = MA(C,prdm);
 
function DirBar( dr, df )
{
B[0] = 0;
 
for(i=1;i<BarCount;i++)
{
if( dr[i-1] && df[i] )
{
B[i] = 1;
}
else
{
if( df[i-1] && dr[i] )
{
B[i] = 1;
}
else
{
B[i] = B[i-1] + 1;
}
}
}
return B;
}
 
Bs = DirBar( Rs, Fs );
Direction = ROC(Confirm,1) > 0 AND ROC(Confirm,5) > 0;
Downward = ROC(Confirm,1) < 0 AND ROC(Confirm,5) < 0;
 
Select = Rs AND Ref(Fs,-1);
Caution = Fs AND Ref(Rs,-1);
 
Change = IIf( Rs, H/ValueWhen(Fs,L)*100, L/ValueWhen(Rs,H)*100 );
PlotShapes( shapeSmallCircle* select, colorDarkGreen, 0, H,-14 );
PlotShapes( shapeSmallCircle* Caution, colorDarkRed, 0, L, 14 );
 
_SECTION_BEGIN("Sloping Channel");
//Pattern Recognition graph with shading
/*TRENDLINES BREAKOUT*/
 
x = Cum(1);
per = Param("Percent",3,1,20,1);
s1=L;
s11=H;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
dtS =endt-startt;
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;
 
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
DTR=ENDT1-STARTT1;
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
BEGIN=Min(STARTT,STARTT1);
TRS = IIf(x>BEGIN-10,trendlineS,-1e10);
TRR = IIf(x>BEGIN-10,trendlineR,-1e10);
 
Condcolor=(Cross(C,trendlineR) AND X>ENDT1) OR (Cross(trendlineS,C) AND X>ENDT);
BarColor=IIf(Condcolor,7,1);
 
Plot(TRS,"Support",colorCustom11,styleDots);
Plot(TRR,"Resist",colorCustom11,styleDots);
 
 
 
/////////////////////////////////////
 
// Pattern Recognition in title bar //
///////////////////////////////////////////
Lowline=Ends-starts;
Highline=endr-startr;
Wedge=IIf(Highline <0 AND Lowline > 0,1,0);
DecendingTriangle=IIf(Highline < 0 AND Lowline==0,1,0);
AscendingTriangle=IIf(Highline==0 AND Lowline > 0,1,0);
DownChannel=IIf(Highline<0 AND Lowline<0,1,0);
UpChannel=IIf(Highline>0 AND Lowline>0,1,0);
BroadeningWedge=IIf(Highline > 0 AND Lowline < 0,1,0);
///////////////////////////////////
 
// Bullish or Bearish breakout //
//////////////////////////////////
BullishBreakout=Cross(C,trendlineR);
BearishBreakout=Cross(trendlineS,C);
Breakout =WriteIf(C > trendlineR, "Bullish","Bearish");
PlotShapes(IIf(BullishBreakout,shapeDigit6,Null),C olorRGB(176,176,255),0,L,130);
PlotShapes(IIf(BullishBreakout,shapeUpArrow,Null), ColorRGB(176,176,255),0,L,120);
 
PlotShapes(IIf(BearishBreakout,shapeDigit7,Null),c olorViolet,0,H,120);
PlotShapes(IIf(BearishBreakout,shapeDownArrow,Null ),colorViolet,0,H,-130);
Plot(BullishBreakout,"",ColorRGB(176,176,255),styl eHistogram|styleDashed|styleOwnScale|styleNoLabel, 0,1,0,0);
Plot(BearishBreakout,"",colorViolet,styleHistogram |styleDashed|styleOwnScale|styleNoLabel,0,1,0,0);
 
 
_SECTION_BEGIN("companysympole");
 
_SECTION_BEGIN("companyclos");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorWhite);
GfxTextOut("C="+C+" ",580,1);
}
_SECTION_END();
 
_SECTION_BEGIN("companyhigh");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom13);
GfxTextOut("H="+H+" ",480,1);
}
_SECTION_END();
 
_SECTION_BEGIN("companyopen");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorWhite);
GfxTextOut("O="+O+" ",380,1);
}
_SECTION_END();
 
_SECTION_BEGIN("companylow");
{ GfxSelectFont("french script mt",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorYellow);
GfxTextOut("L="+L+" ",280,1);
}
_SECTION_END();
 
 
_SECTION_BEGIN("CNcP");
Cd1=-(O-C)/(H-L)*100;
Cd=Prec((Cd1),2);
ColorE=IIf(Cd>=68,colorYellow,IIf(Cd<=-68,colorRed,colorCustom12));
_SECTION_END();
_SECTION_BEGIN("Price");
BarColor = IIf((Cd>=68)OR (Cd<=-68),colorYellow,colorCustom12);
Plot(C, "", BarColor, styleNoTitle| styleThick | styleCandle|styleNoLabel);
Plot(C, "",styleCandle, colorBlack, styleThick);
_SECTION_END();
 
_SECTION_BEGIN("");
r= MACD(10, 22);
dd= Signal(10,22,5);
Hist=r-dd;
BuyHist= Cross(Hist,0);
SellHist = Cross( 0, Hist );
 
 
 
_SECTION_BEGIN("MA(20)");
 
BarColor = IIf((C>MA(C,20)),colorWhite,colorRed);
Plot(MA(C,20),"",BarColor,styleThick);
BuyMA= Cross(C,MA(C,20));
SellMA= Cross( MA(C,20), C );
_SECTION_END();
 
 
_SECTION_BEGIN("Magnified Price");
FS=Param("Font Size",15,11,100,1);
GfxSelectFont("Arial", FS, 700, True );
GfxSetBkMode(ColorRGB(255,170,188));
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",390,2,1,2);
Ver=Param("Vertical Position",1,1,1,1);
GfxTextOut("C="+C,Hor , Ver+55 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
 
GfxSelectFont("Arial", 12, 700, True );
GfxSetBkMode( colorYellow );
GfxSetTextColor(ParamColor("Color",colorBlue) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+80 );
 
_SECTION_END();
 
 
_SECTION_BEGIN("Nd");
Nd=((C)-(O))/(L)*10000;
Filter=Close;
AddColumn(Nd , "Nd",1.2,colorBrown);
 
_SECTION_BEGIN(" Nd");
{ GfxSelectFont("Arial",12, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom12);
GfxTextOut("Nd="+WriteVal(Nd,format=1.2)+"% ",750,1);
GfxSetTextColor(colorWhite);
 
}
_SECTION_END();
 
_SECTION_BEGIN("CNcP");
Cd1=-(O-C)/(H-L)*100;
Cd=Prec((Cd1),2);
Filter=Close;
AddColumn(Cd , "Cd",1.2,colorOrange);
_SECTION_END();
 
 
_SECTION_BEGIN(" Cd");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut("Cd="+WriteVal(Cd,format=1.2)+"% ",870,1);
}
_SECTION_END();
 
 
 
 
 
 
_SECTION_BEGIN(" ZigZagTrend ");
array = Close;
amount = Param("Amount", 5, 1, 50, 0.5 );
zz0 = Zig( array, amount );
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
PU = tr + 0.01 * abs(tr)*amount;
PD = pk - 0.01 * abs(pk)*amount;
ZZT = IIf( array >= PU AND zz0 > zz1, 1,
IIf( array <= PD AND zz0 < zz1, -1, 0 ) );
ZZT = ValueWhen( ZZT != 0, ZZT );
Com=IIf(ZZT>0,colorBlue,IIf(ZZT<0,colorRed,colorBl ack));
 
_SECTION_BEGIN("Font Color");
function GfxConvertBarToPixelX(Bar)
{
lvb = Status("lastvisiblebar"); fvb = Status("firstvisiblebar");
pxchartleft = Status("pxchartleft"); pxchartwidth = Status("pxchartwidth");
return pxchartleft + Bar * pxchartwidth / (Lvb-fvb + 1);
}
procedure MultiRibbon(RibbonColor, Position, Label)
{
LineColor =colorWhite;
Position =2* Position;
x2 = Status("pxchartright");
y2 = Status("pxchartbottom");
RibbonColor =IIf(GfxConvertBarToPixelX(BarIndex()-Status("firstvisiblebarindex")) > y2/1.5 *
(2/100)*10,RibbonColor, colorWhite);
Plot(0, "",LineColor, styleOwnScale|styleNoLabel,0,100);
Plot(Position, "",LineColor,styleOwnScale| styleNoLabel,0,100);
Plot(Position, "",RibbonColor,styleArea|styleOwnScale|styleNoLabe l, 0,100);
 
GfxSelectFont("Arial", y2/1 * (2.7/180),200);
GfxDrawText(Label,8, y2 *1.006-(y2 * Position/100) , y2/1.6*
(2/100)*10,y2,2+32+256);
GfxSetTextColor(colorBlue);
}
multiribbon(COM,1, "Trend");
 
 
Buy=Cross(ZZT,0);
Sell=Cross(0,ZZT);
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorBlue,0,L,-15);
PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorRed,0,H,-15);
 
_SECTION_BEGIN("Zig_Zag_");
 
PercentChange = 4;
mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING
 
mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), DateNum(),1));
 
InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), C , 1 ) ) ;
 
 
ZZ = Zig(C,LastValue(PercentChange)) ;
PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1,Null),1);
PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1,Null),1);
 
PlotShapes(IIf(PivotLow, shapeDigit1, shapeNone),colorYellow, 0,L, Offset=-32);
 
PlotShapes(IIf(PivotHigh, shapeDigit1, shapeNone),colorYellow, 0,H, Offset=32);
 
 
 
_SECTION_BEGIN("ZigZag");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut(" ZigZag="+WriteVal(ZZ,format=1.2)+"",75,20);
}
_SECTION_END();
 
_SECTION_BEGIN("MACD");
ml = MACD(6, 13);
dd= Signal(6,13,5);
Hist=ml-dd;
col_hist= IIf(Hist > BBandTop( Hist, 5, 0.5 ),colorLightBlue,IIf(Hist < BBandBot( Hist, 5, 0.5 ),colorBlue,colorRed));
pr=PeakBars(C,5)==0;
ps =TroughBars(C,5)==0;
PlotShapes(IIf(ps,shapeDigit2 ,Null),colorBlue,0,L,-45);
PlotShapes(IIf(pr,shapeDigit2 ,Null),colorBlue,0,H,45);
 
 
 
 
_SECTION_BEGIN("Fibonacci And Gann Projections");
Change = 5;
GannIncrement = 0.0625;
procedure PlotShapeAt( x, y, shape, shift )
{
PlotShapes( IIf( BarIndex() == x, shape, 0 ), colorWhite, 0, y, shift );
}
procedure PlotBlueDot( x, y )
{
 
 
for( i = -2; i <= 2; i++ )
{
if( i != 0 )
{
yGann = ( sqrt( y ) + i * GannIncrement ) ^ 2;
 
}
}
}
bi = BarIndex();
sbi = SelectedValue( bi );
GraphXSpace = 2;
 
upshift =65;
if( SelectedValue( PeakBars( C, Change ) < TroughBars( C, Change ) ) )
{
pt1 = PeakBars( C, Change, 1 ) == 0 ;
pt2 = TroughBars( C, Change, 1 ) == 0 ;
}
else
{
pt1 = TroughBars( C, Change, 1 ) == 0 ;
pt2 = PeakBars( C, Change, 1 ) == 0 ;
upshift = -upshift;
}
bpt1 = SelectedValue( ValueWhen( pt1, bi ) );
bpt2 = SelectedValue( ValueWhen( pt2, bi ) );
bpt3 = SelectedValue( ValueWhen( pt1, bi, 2 ) );
bpt4 = SelectedValue( ValueWhen( pt2, bi, 2 ) );
bpt5 = SelectedValue( ValueWhen( pt1, bi, 3 ) );
bpt6 = SelectedValue( ValueWhen( pt2, bi, 3 ) );
PlotShapeAt( bpt1, C, shapeDigit1, upshift );
PlotShapeAt( bpt2, C, shapeDigit2, -upshift );
PlotShapeAt( bpt3, C, shapeDigit3, upshift );
PlotShapeAt( bpt4, C, shapeDigit4, -upshift );
PlotShapeAt( bpt5, C, shapeDigit5, upshift );
PlotShapeAt( bpt6, C, shapeDigit6, -upshift );
Level = SelectedValue( ValueWhen( pt1, C ) );
PlotBlueDot( round( bpt1 + 1.618 * ( bpt1 - bpt2 ) ), Level );
PlotBlueDot( round( bpt1 + 0.382 * ( bpt1 - bpt2 ) ), Level );
PlotBlueDot( round( bpt1 + 0.5 * ( bpt2 - bpt3 ) ), Level );
PlotBlueDot( round( bpt1 + 1.732 * ( bpt2 - bpt3 ) ), Level );
PlotBlueDot( round( bpt1 + 0.618 * ( bpt4 - bpt5 ) ), Level );
PlotBlueDot( round( bpt1 + 2 * ( bpt4 - bpt5 ) ), Level );
PlotBlueDot( round( bpt2 + 0.6707 * ( bpt4 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 2.618 * ( bpt4 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 1 * ( bpt6 - bpt2 ) ), Level );
PlotBlueDot( round( bpt2 + 3 * ( bpt6 - bpt2 ) ), Level );
 
 
_SECTION_END();
 
 
 
 
 
 
 
 
 
 
 
_SECTION_BEGIN("zzt");
para = ParamToggle("plot zz0","off,on");
cbar = Param("cbar",10,2,50,1);
per = Param("per",5,1,30,1);
zz0 = Zig(C,per);
zz1 = Ref( zz0, -1 );
zz2 = Ref( zz0, -2 );
tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
pu = tr + 0.01 * abs(tr)*per;
pd = pk - 0.01 * abs(pk)*per;
zzt = IIf(C>= pu AND zz0 > zz1, 1,
IIf(C<= pd AND zz0 < zz1, -1, 0 ) );
zzt= ValueWhen( zzt != 0, zzt );
colorp2= IIf((C>O)OR(C<O),colorWhite,colorYellow);
Plot(IIf(para,zz0,Null)," ",colorWhite,styleLine|styleNoTitle);
pr=PeakBars(High,5)==0;
ps =TroughBars(Low,5)==0;
rf=ValueWhen(pr,High);
sf=ValueWhen(ps,Low);
rf1 = IIf(rf AND BarsSince(pr) <=cbar,rf,Null);
sf1 = IIf(sf AND BarsSince(ps ) <=cbar,sf,Null);
Plot(rf1,"",colorRed,styleDots | styleNoLine|styleNoLabel);
Plot(sf1,"",colorBrightGreen,styleDots | styleNoLine|styleNoLabel);
 
 
 
_SECTION_END();
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);
PlotText("" + WriteVal(rf,fraction),
SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(rf),colorWhite,colorRed);
PlotText("" + WriteVal(sf,fraction),
SelectedValue(BarIndex()+6)-(numbars/hts),SelectedValue(sf),colorWhite,colorGreen);
_SECTION_END();
 
 
 
 
Plot( Open, "open", 0, stylehidden| styleNoTitle );
Plot(Close, "close", 0, stylehidden| styleNoTitle );
Plot(High, "high", 0, stylehidden| styleNoTitle );
Plot(Low, "low", 0, stylehidden| styleNoTitle );
 
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("text shift", -50,-100,100,10);
 
_SECTION_END();
 
 
 
 
 
 
_SECTION_BEGIN("MotheCandle");
Mothc=Ref(H,-1)>H AND Ref(L,-1)<L;
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(L,-1))));
TDL = LineArray(0, y0, (BarCount-1), y0);
Plot(TDL, "", colorGold,styleDashed|styleNoLabel);
y0 = StrToNum(NumToStr(ValueWhen(Mothc, Ref(H,-1))));
TDH= LineArray(0, y0, (BarCount-1), y0);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)), colorGold,0,H,5);
PlotShapes(shapeSmallCircle*(Ref(Mothc,1)),colorGo ld,0,L,-5);
Plot(TDH, "", colorCustom12,styleDashed|styleNoLabel);
numbars = SelectedValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);
 
PlotText("" + WriteVal(TDH,fraction),
SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDH),colorCustom12);
PlotText("" + WriteVal(TDL,fraction),
SelectedValue(BarIndex())-(numbars/hts),SelectedValue(TDL),colorGold);
_SECTION_END();
 
 
 
 
 
 
 
_SECTION_BEGIN("AuthorName");
k = (GetPerformanceCounter()/100)%100;
printf("GetPerformance Counter %g",k);
GfxSelectFont("jokerman", 12,800);
GfxSetBkMode(1);
GfxSetTextColor(colorGold);
GfxTextOut("MotherCandle",450,20);
RequestTimedRefresh(10);
_SECTION_END();
 
 
_SECTION_BEGIN("WMA 50");
slope = Param("slope",2,2,100,1);
Color20= IIf(LinRegSlope(WMA(C,50),slope)<0,colorCustom13,c olorCustom13);
event1= LinRegSlope(WMA(C,50),slope)<1;
Plot( WMA( C,50), "",Color20,styleNoLine|styleNoLabel);
 
_SECTION_END();
_SECTION_BEGIN("WMA 50");
{ GfxSelectFont("Bernard MT Condensed",12, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom13);
GfxTextOut("WMA50="+WMA( C,50),250,20);
}
_SECTION_END();
 
_SECTION_BEGIN("Auto trend line Trendline");
 
/*+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++
THIS SECTION DRAWS TD TREND LINES */
 
percent = 0.01 * 1;
firstpointL = 2;
firstpointH = 2;
 
y0=LastValue(Trough(L,percent,firstpointL));
y1=LastValue(Trough(Ref(L,-1),percent,1));
 
for( i = 1; i < BarCount AND y0 >= y1; i++ )
{
 
firstpointL++;
y0=LastValue(Trough(L,percent,firstpointL));
}
 
x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL));
x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1));
LineL = LineArray( x0, y0, x1, y1, 1 );
/*
Plot(C, "C", colorBlack, styleCandle);
*/
Plot( LineL, " Support Trend line", colorBlueGrey,4 +8 );
 
 
yt0=LastValue(Peak(H,percent,firstpointH));
yt1=LastValue(Peak(Ref(H,-1),percent,1));
 
for(i = 1; i < BarCount AND yt0 <= yt1; i++ )
{
 
firstpointH++;
yt0=LastValue(Peak(H,percent,firstpointH));
}
xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH));
xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1));
LineH = LineArray( xt0, yt0, xt1, yt1, 1 );
Plot( lineH, "resistance trend line", colorOrange,4 + 8 );
 
/*+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++*/
_SECTION_END();
 
 
Buy=Cross(C,lineh);
Sell=Cross( linel,C);
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorOrange,0,C,-25);
PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorBlueGrey,0,C,-25);
PlotShapes(IIf(Buy,shapeHollowCircle, shapeNone),colorBlack, 0,C,0);
PlotShapes(IIf(Sell,shapeHollowCircle, shapeNone),colorWhite, 0,C,0);
 
 
 
Filter=Close;
AddColumn(IIf(Sell,C,Null),"sell",1.4,colorBlack);
AddColumn(IIf(Buy,C,Null),"buy",1.4,colorBlue);
 
 
 
 
_SECTION_END();
 
 
 
 
_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,0,5000,10);
nBars = Param("Number of bars", 8, 5, 40);
 
 
// -- 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;
 
// -- looking back from the current bar, how many bars
 
// back were the hhv and llv values of the previous
 
// n bars, etc.?
 
aHHVBars = HHVBars(H, nBars);
 
aLLVBars = LLVBars(L, nBars);
 
aHHV = HHV(H, nBars);
 
aLLV = LLV(L, nBars);
 
// -- Would like to set this up so pivots are calculated back from
 
// last visible bar to make it easy to "go back" and see the pivots
 
// this code would find. However, the first instance of
 
// _Trace output will show a value of 0
 
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";
 
}
 
// -- Loop through bars. Search for
 
// entirely array-based approach
 
// in future version
 
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
 
}
 
// -- Basic attempt to add a pivot this logic may have missed
 
// -- OK, now I want to look at last two pivots. If the most
 
// recent low pivot is after the last high, I could
 
// still have a high pivot that I didn't catch
 
// -- Start at last bar
 
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;
 
// ...and then rearrange elements in the
 
// pivot information arrays
 
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++;
 
}
 
}
 
// -- Dump inventory of high pivots for debugging
 
 
 
for (k=0; k<nHPivs; k++) {
 
_TRACE("High pivot no. " + k
 
+ " at barindex: " + aHPivIdxs[k] + ", "
 
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
 
DateTime(), 1), formatDateTime)
 
+ ", " + aHPivHighs[k]);
 
}
 
//////////////////////////////////////////////////////////////////////////////
 
// -- OK, let's plot the pivots using arrows
 
PlotShapes(IIf(aHPivs==1, shapeSmallDownTriangle, shapeNone), colorRed, 0, High, Offset=-14);
PlotShapes(IIf(aLPivs==1, shapeSmallUpTriangle , shapeNone), colorBrightGreen, 0, Low, Offset=-13);
 
//////////////////////////////////////////////////////////////////////////////
 
 
/* **********************************
 
Code to automatically identify pivots
 
********************************** */
// -- what will be our lookback range for the hh and ll?
farback=Param("How Far back to go",500,12,30,1);
nBars = Param("Number of bars", 8, 1, 30, 1);
// -- 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;
// -- looking back from the current bar, how many bars
// back were the hhv and llv values of the previous
// n bars, etc.?
aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);
// -- Would like to set this up so pivots are calculated back from
// last visible bar to make it easy to "go back" and see the pivots
// this code would find. However, the first instance of
// _Trace output will show a value of 0
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";
}
// -- Loop through bars. Search for
// entirely array-based approach
// in future version
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
}
// -- Basic attempt to add a pivot this logic may have missed
// -- OK, now I want to look at last two pivots. If the most
// recent low pivot is after the last high, I could
// still have a high pivot that I didn't catch
// -- Start at last bar
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;
// ...and then rearrange elements in the
// pivot information arrays
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++;
}
}
// -- Dump inventory of high pivots for debugging
/*
for (k=0; k<nHPivs; k++) {
_TRACE("High pivot no. " + k
+ " at barindex: " + aHPivIdxs[k] + ", "
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
DateTime(), 1), formatDateTime)
+ ", " + aHPivHighs[k]);
}
*/
// -- OK, let's plot the pivots using arrows
PlotShapes(IIf(aHPivs==1, shapeHollowSmallDownTriangle, shapeNone), colorOrange, 0, High, Offset=-25);
PlotShapes(IIf(aLPivs==1, shapeHollowSmallUpTriangle , shapeNone), colorWhite, 0, Low, Offset=-23);
 
Sell = aHPivs == 1 ;
Buy = aLPivs == 1 ;
Filter=Buy OR Sell;
Sell=ExRem(Sell,Buy);
Buy=ExRem(Buy,Sell);
 
 
 
 
 
_SECTION_END();
 
 
 
 
 
 
 
 
 
 
_SECTION_BEGIN("td fractl line");
strength = Param("strength",1,1,15,1);
pr=PeakBars(RSI(14),strength)==0;
 
_SECTION_END();
_SECTION_BEGIN("td fractl line");
ps =TroughBars(RSI(14),strength)==0;
 
_SECTION_END();
_SECTION_BEGIN("price risistance");
rt=SelectedValue(ValueWhen(pr,H));
st=SelectedValue(ValueWhen(ps,L));
 
 
_SECTION_BEGIN("td fractl line");
pr=PeakBars(RSI(14),strength)==0;
pivothigh = Ref(pr,-1)<pr AND pr>Ref(pr,1);
y0=SelectedValue(ValueWhen(pivothigh,H,2));
y1=SelectedValue(ValueWhen(pivothigh,H,1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
linea=LineArray(x0,y0,x1,y1,1);
 
_SECTION_END();
_SECTION_BEGIN("td fractl line");
ps =TroughBars(RSI(14),strength)==0;
pivotlow = Ref(ps,-1)<ps AND ps>Ref(ps,1);
yt0=SelectedValue(ValueWhen(pivotlow,L,2));
yt1=SelectedValue(ValueWhen(pivotlow,L,1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
lineb=LineArray(xt0,yt0,xt1,yt1,1);
 
_SECTION_END();
_SECTION_BEGIN("ema1");
p = ParamField("price field",-1);
_SECTION_END();
 
pi = atan(1.00)* 4 ;
periods = 30;
highhigh = HHV(H, periods);
lowlow = LLV(L, periods);
range = 25 / (highhigh - lowlow) * lowlow;
ma1= EMA(C,200);
x1_ma = 0;
x2_ma= 1;
y1_ma= 0;
y2_ma= (Ref(ma1, -1) - ma1) / Avg * range;
c_ma= sqrt((x2_ma- x1_ma)*(x2_ma- x1_ma) + (y2_ma- y1_ma)*(y2_ma- y1_ma));
angle_ma= round(180 * acos((x2_ma - x1_ma)/c_ma) / pi);
angle_ma= IIf(y2_ma> 3, -angle_ma, angle_ma);
col=IIf(angle_ma>3,colorGreen,IIf(angle_ma<(-3),colorRed,colorCustom12));
Plot(EMA( p,200), _DEFAULT_NAME(), col, styleDots );
buy1=Cross(C,linea) AND RSI(14)>60 AND angle_ma>=1;
buy2=Cross(C,rt)AND RSI(14)>60 AND angle_ma>=1;
Buy=buy1 OR buy2;
sell1=Cross(lineb,C)AND RSI(14)<40 AND angle_ma<=(-1);
sell2=Cross(rt,C)AND RSI(14)<40 AND angle_ma<=(-1);
Sell=sell1 OR sell2;
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone) ,colorBlue,0,L,-20);
PlotShapes(IIf(Sell,shapeSmallDownTriangle, shapeNone),colorYellow,0,H,-20);
 
if (SelectedValue(Buy)==1) Say("super move");
if (SelectedValue(Sell)==1) Say("weake move");
_SECTION_BEGIN("exploration");
Filter=Close;
var = WriteIf(Buy,"buy",WriteIf(Sell,"sell",""));
AddTextColumn( var , "buy/sell", 1.2 , colorWhite, IIf( Buy, colorBlue,IIf(Sell,colorRed,colorWhite) ));
AddColumn(angle_ma,"angle",1.4,colorBlue);
_SECTION_END();
 
 
 
_SECTION_BEGIN("t trend");
{ GfxSelectFont("Arial",12, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorWhite);
GfxTextOut("RSI="+WriteVal(RSI(14),format=1.2)+" ",970,1);
}
_SECTION_END();
 
_SECTION_BEGIN("t trend");
{ GfxSelectFont("Arial",13, 800 );
GfxSetBkMode(1);
GfxSetTextColor(colorCustom11);
GfxTextOut("angle="+angle_ma+"% ",600,20);
}
 
 
_SECTION_END();
 
 
 
 
 
_SECTION_BEGIN("MACD");
r1 = Param("Fast avg", 14, 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);
 
_SECTION_END();
 
//Hook Bullish
Z= Cross(C, EMA(C,5))AND RSI(9)>30;
//Bearish Bullish
t= Cross(EMA(C,5), C)AND RSI(9)<70;
// Histogram
pt = m1-s1;
Tp = Ref(pT,-1) == HHV(pT,3);
Vl = Ref(pT,-1) == LLV(pT,3);
 
//ADX related calculations
plus = EMA(PDI(14),3)>Ref(EMA(PDI(14),3),-5);
ap = EMA(ADX(14),3)>Ref(EMA(ADX(14),3),-5);
Minus = EMA(MDI(14),3)>Ref(EMA(MDI(14),3),-5);
 
//Power Dips - Bullish
PDIp = ADX(14)>MDI(14) AND PDI(14)>MDI(14) AND ap AND Vl AND m1>s1 AND plus;
 
//Power Dips - Bearish
PDIm = ADX(14)>PDI(14) AND MDI(14)>PDI(14) AND ap AND Tp AND m1<s1 AND Minus;
 
//Bullish Crossed up above zero
j1 = Cross(m1,s1)AND m1>0;
 
 
// Bullish crossover up below zero
j2 = Cross(m1,s1)AND m1<0 ;
 
 
//Bearish Crossed down below Zero
j3 = Cross(s1,m1) AND m1>0;
 
 
// Bearish crossover down above zero
j4 = Cross(s1,m1)AND m1<0;
 
 
 
_SECTION_BEGIN("V");
TimeFrameSet(inDaily);
D=V;
TimeFrameRestore();
_SECTION_END();
//Volume Change
 
 
Volma=MA(V,15);
Volchange=(((V-Volma)/Volma)*100);
 
GraphXSpace=Param("GraphXSpace",10,0,100,1);
dec = (Param("Decimals",2,0,7,1)/10)+1;
Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(32) + Date() +
" "+ EncodeColor(5) + "{{INTERVAL}} " +
EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) +
EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
EncodeColor(55)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) +
EncodeColor(55)+ " Close = "+ EncodeColor(7)+ WriteVal(C,dec)+
"\n\n\n"+EncodeColor(colorBrightGreen)+
WriteIf (PDIP, " @Bullish Power Dip","")+EncodeColor(colorRed)+
WriteIf (PDIm, " @Bearish Power Dip","")+EncodeColor(colorBrightGreen)+
WriteIf (z, " @Bullish hook","")+EncodeColor(colorRed)+
WriteIf (t, " @Bearish hook","")+EncodeColor(colorBrightGreen)+
WriteIf (Vl AND m1>s1, "@Histogram peak","")+EncodeColor(colorRed)+
WriteIf (Tp AND m1<s1, " @Histogram troughs","")+EncodeColor(colorBrightGreen)+
WriteIf (j1, " @Bullish Crossed up above zero","")+EncodeColor(colorBrightGreen)+
WriteIf (j2, " @Bullish crossover up below zero","")+EncodeColor(colorRed)+
WriteIf (j4, "@Bearish Crossed down below Zero","")+EncodeColor(colorRed)+
WriteIf (j3, " @Bearish crossover down above zero","")+"\n"+EncodeColor(colorBlue)+
WriteIf (Cross(ZZT,0), "@ BUY ZZT","")+EncodeColor(colorCustom12)+
WriteIf (Cross(0,ZZT), "@ SELL ZZT","")+EncodeColor(colorYellow)+
WriteIf (PivotLow, "@ BUY ZIG ZAG","")+EncodeColor(colorYellow)+
WriteIf (PivotHigh, "@ SELL ZIG ZAG","")+EncodeColor(colorYellow)+
WriteIf (ps, "@ BUY MACD","")+EncodeColor(colorYellow)+
WriteIf (pr, "@ SELL MACD","")+EncodeColor(colorGold)+
WriteIf (aLPivs==1, "@ BUY Pivot_Finder","")+"\n"+EncodeColor(colorGold)+
WriteIf (aHPivs==1, "@ SELL Pivot_Finder","")+EncodeColor(colorOrange)+
WriteIf (Cross(C,lineh), "@ TREND BROKEN UP","")+EncodeColor(colorBlueGrey)+
WriteIf (Cross( linel,C), "@ TREND BROKEN DOWN ","")+EncodeColor(colorCustom12)+
WriteIf (Cross(C,TDH), " @ BUY MOTHER CANDLE","")+"\n"+EncodeColor(colorGold)+
WriteIf (Cross(TDL,C), " @ SELL MOTHER CANDLE","")+EncodeColor(colorGrey50)+
WriteIf (BuyHist, " @ BUY Hist","")+"\n"+EncodeColor(colorRed)+
WriteIf (sellHist, " @ SELL Hist","")+EncodeColor(colorBrightGreen)+
WriteIf (BuyMA, " @ BREAK UP MA(20)","")+EncodeColor(colorBrightGreen)+
WriteIf (sellMA, " @BREAK DOWN MA(20)","")
+ EncodeColor( colorRed)+ WriteIf(DownChannel==1,"& Downward Sloping Channel","")+EncodeColor( colorBrightGreen)+
WriteIf(UpChannel==1," &Upward Sloping Channel","")+EncodeColor( colorWhite)+
WriteIf(wedge==1," &Wedge","")+
WriteIf(DecendingTriangle==1," &Decending Triangle","")+
WriteIf(AscendingTriangle==1,"&Ascending Triangle","")+
WriteIf(broadeningWedge==1," &Broadening Wedge","")+EncodeColor( colorBrightGreen ) +
WriteIf(bullishbreakout==1,"@Bullish Breakout","")+EncodeColor( colorWhite ) +
WriteIf(bearishbreakout==1,"@Bearish Breakout","")+EncodeColor( colorCustom12 )
+"\n"+EncodeColor(colorWhite)+WriteIf(V > Volma," Volume's above MA(15) with ("+WriteVal(Volchange,format=1.2)+")%","" )
 
+"\n"+EncodeColor(colorWhite)+WriteIf(V < Volma, " Volume's below MA(15)with("+WriteVal(Volchange,format=1.2)+")% ","" );
 
 
 
 
 
 
 
 
_SECTION_BEGIN("Target&Trail SL");
 
SetChartOptions(0, chartShowDates | chartWrapTitle);
 
Type = ParamList("Average Type", "Wilders");
P = Param("Averaging Period", 20, 3, 100,1);
Q = Param("%Change", 1, 0.1, 10, 0.1);
BP = Param("BB Period", 20, 3, 100);
BW = Param("BB Width", 2, 0.5, 10, 0.5);
BBOption = ParamToggle("Plot BB", "No I Yes");
 
A=Param( "Swing", 20, 1, 100);
SL = Max(LLV(L, 5), Trough(L, Q, 1));
 
Tgt = 2 * H - SL;
MeanPrice = Prec((O + C) / 2, 2);
 
Part = 100 * (H - A) / (H - L);
 
BBTop = BBandTop(C, BP, BW);
BBBot = BBandBot(C, BP, BW);
 
res=HHV(H,A);
sup=LLV(L,A);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);
 
// line code
Plot(tsl, _DEFAULT_NAME(), ParamColor( "ColorD", colorRed ), styleStaircase|styleNoLabel|styleNoLine);
 
// arrows code
Buy=Cross(C,Ref(res,-1));
Sell=Cross(Ref(sup,-1),C);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
 
Bought = Flip(Buy, Sell);
Sold = Flip(Sell, Buy);
NextTgt = ValueWhen(Buy, Tgt, 1);
 
for(i = 1; i < BarCount; i++)
{
if(Bought[i] AND NOT Buy[i])
{
SL[i] = Max(SL[i], SL[i - 1]);
if(C[i - 1] >= 0.9999 * NextTgt[i - 1]) NextTgt[i] = Tgt[i - 1];
NextTgt[i] = Max(NextTgt[i], NextTgt[i - 1]);
}
}
BuyDate = ValueWhen(Buy, Ref(DateTime(), 1), 1);
BuyPrice = ValueWhen(Buy, Ref(MeanPrice, 1), 1);
SellPrice = ValueWhen(Sell, Ref(MeanPrice, 1), 1);
 
TgtReached = IIf(Bought AND NOT Buy AND C >= 0.9999 * NextTgt, True, False);
SLHit = IIf(Bought AND NOT Buy AND C < SL, True, False);
SLHit = ExRem(SLHit, Buy);
Plot(IIf(Bought, NextTgt, Null), "Target", colorRed,styleNoLine|styleNoTitle|styleNoLabel);
Plot(SL, "Trail SL", colorGrey40, styleNoLine|styleNoTitle|styleNoLabel);
_SECTION_BEGIN(" ");
{ GfxSelectFont("Arial",13, 700 );
GfxSetBkMode(1);
GfxSetTextColor(colorDarkYellow);
GfxTextOut("TR="+WriteVal(NextTgt,format=1.2)+"",7 40,20);
GfxSetTextColor(colorBlue);
GfxTextOut("Trail="+WriteVal(SL,format=1.2)+"",850 ,20);
GfxSetTextColor(colorRed);
GfxTextOut(" SL="+WriteVal(tsl,format=1.2)+"",970,20);
 
}
_SECTION_END();
_SECTION_BEGIN(" Bullish sign & Bearish sign ");
SetChartOptions(0,chartShowArrows|chartShowDates);
 
rg=(H-L);
arg=Wilders(rg,30);
 
Vl=V<Ref(V,-1) AND V<Ref(V,-2);
 
mp=(H+L)/2;
 
 
_SECTION_BEGIN("VSA");
 
eftup=H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1) AND C>=((H-L)*0.7+L) AND rg>arg AND V>Ref(V,-1);
 
eftdn=H<Ref(H,-1) AND L<Ref(L,-1) AND C<Ref(C,-1) AND C<=((H-L)*0.25+L) AND rg>arg AND V>Ref(V,-1);
_SECTION_END();
 
PlotShapes(shapeSmallCircle*eftup, colorDarkTeal, 0, mp, 0 );
PlotShapes(shapeSmallCircle*eftdn, colorBlack, 0, mp, 0 );
 
_SECTION_BEGIN("BB");
bb2top = BBandTop(Close,20,2.25);
bb1top = BBandTop(Close,20,1);
bb2bot = BBandBot(Close,20,2.25);
bb1bot = BBandBot(Close,20,1);
 
Plot (bb1top,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32);
Plot (bb1bot,"",IIf(bb1top > Ref(bb1top,-1) AND bb1bot < Ref(bb1bot,-1),colorYellow,colorYellow),32);
Plot (bb2top,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32);
Plot (bb2bot,"",IIf(bb2top > Ref(bb2top,-1) AND bb2bot < Ref(bb2bot,-1),colorLightGrey,colorLightGrey),32);
PlotOHLC(bb2top,bb2top,bb1top,bb1top,"",ColorRGB(5 6,63,118),styleCloud|styleNoLabel);
PlotOHLC(bb1bot,bb1bot,bb2bot,bb1bot,"",ColorRGB(5 6,63,118),styleCloud|styleNoLabel);
 
 
_SECTION_END();
 
 
_SECTION_BEGIN("EMA Time Frame");
r= RSI(14);
pR=PeakBars(RSI(14),1)==0;
pivothigh = Ref(pR,-1)<pR AND pR>Ref(pR,1);
y0=SelectedValue(ValueWhen(pivothigh,RSI(14),2));
y1=SelectedValue(ValueWhen(pivothigh,RSI(14),1));
x0=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,2));
x1=SelectedValue(ValueWhen(pivothigh,Cum( 1)-1,1));
LineA=LineArray(x0,y0,x1,y1,1);
pS =TroughBars(RSI(14),1)==0;
pivotlow = Ref(pS,-1)<pS AND pS>Ref(pS,1);
yt0=SelectedValue(ValueWhen(pivotlow,RSI(14),2));
yt1=SelectedValue(ValueWhen(pivotlow,RSI(14),1));
xt0=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,2));
xt1=SelectedValue(ValueWhen(pivotlow,Cum( 1)-1,1));
LineB=LineArray(xt0,yt0,xt1,yt1,1);
 
_SECTION_BEGIN("DIV");
u00=LastValue(Peak(H,1,2));
u11=LastValue(Peak(H,1,1));
a00=BarCount - 1 - LastValue(PeakBars(H,1,2));
price_start1=Close[a00];
a11=BarCount - 1 - LastValue(PeakBars(H,1,1));
price_end1=Close[a11];
Line = LineArray(a00,u00,a11,u11, 0 );
LastPointSell = LineArray(a11-1,u11-1,a11,u11,0);
 
GG=u11<u00 AND price_end1>price_start1;
PlotShapes(shapeSmallCircle*GG ,colorDarkRed,0,Line,-2);
 
 
 
 
_SECTION_END();
 
_SECTION_BEGIN("DIV");
u0=LastValue(Trough(L,1,2));
u1=LastValue(Trough(L,1,1));
a0=BarCount - 1 - LastValue(TroughBars(L,1,2));
price_start=Close[a0];
a1=BarCount - 1 - LastValue(TroughBars(L,1,1));
price_end=Close[a1];
Line = LineArray(a0,u0,a1,u1, 0 );
 
TT=u1>u0 AND price_end<price_start;
LastPointBuy = LineArray(a1-1,u1-1,a1,u1,0);
PlotShapes(shapeSmallCircle*TT,colorCustom11,0,Lin e,-2);
 
 
_SECTION_END();
 
SetChartBkColor( ParamColor("background",colorDarkTeal));
Back