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

Southbreeze Modified for Amibroker (AFL)

Rating:
3 / 5 (Votes 10)
Tags:
Southbreeze, amibroker, pivots, advanced

This is a modified Southbreeze indicator which includes the following:

1. Candle Pattern Analyser ( appear as commentry )
2. Auto FIBO based on last active wave of the selected period
3. Better Volume
4. Volume Spread Analyser
5. 20EMA Channel as guide for your trading decision
6. 10 indicator auto analyser feedback

Additionally, I have added Beta Trailing Stoploss line ( in GOLD color ).

Happy trading!!

Screenshots

Similar Indicators / Formulas

Boll Fibo Ashi Band
Submitted by Rushabh about 14 years ago
VSM TREND
Submitted by krishna9260 over 11 years ago
VSM TREND NO1 WITH GANNA INDICATOR
Submitted by krishna9260 over 11 years ago
super trend tracker
Submitted by jaipal7786 over 11 years ago
TTS system
Submitted by jaipal7786 about 12 years ago
TTS system V 2
Submitted by jaipal7786 about 12 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
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
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
_SECTION_BEGIN("CandleStick Analysis");
/*Body Colors*/
whiteBody=C>=O;
blackBody=O>C;
  
/*Body Size*/
smallBodyMaximum=0.0025;//less than 0.25%
LargeBodyMinimum=0.01;//greater than 1.0%
smallBody=(O>=C*(1-smallBodyMaximum) AND whiteBody)
         OR (C>=O*(1-smallBodyMaximum) AND blackBody);
largeBody=(C>=O*(1+largeBodyMinimum) AND whiteBody)
         OR C<=O*(1-largeBodyMinimum) AND blackBody;
mediumBody=NOT LargeBody AND NOT smallBody;
identicalBodies=abs(abs(Ref(O,-1)-Ref(C,-1))-abs(O-C)) <
          abs(O-C)*smallBodyMaximum;
realBodySize=abs(O-C);
  
  
/*Shadows*/
smallUpperShadow=(whiteBody AND H<=C*(1+smallBodyMaximum))
               OR (blackBody AND H<=O*(1+smallBodyMaximum));
smallLowerShadow=(whiteBody AND L>=O*(1-smallBodyMaximum))
               OR (blackBody AND L>=C*(1-smallBodyMaximum));
largeUpperShadow=(whiteBody AND H>=C*(1+largeBodyMinimum))
               OR (blackBody AND H>=O*(1+largeBodyMinimum));
largeLowerShadow=(whiteBody AND L<=O*(1-largeBodyMinimum))
              OR (blackBody AND L<=C*(1-largeBodyMinimum));
  
/*Gaps*/
upGap=  IIf(Ref(blackBody,-1)AND whiteBody AND O>Ref(O,-1),1,
        IIf(Ref(blackbody,-1) AND blackBody AND C>Ref(O,-1),1,
        IIf(Ref(whiteBody,-1) AND whiteBody AND O>Ref(C,-1),1,
        IIf(Ref(whiteBody,-1) AND blackBody AND C>Ref(C,-1),1,0))));
  
downGap=IIf(Ref(blackBody,-1)AND whiteBody AND C<Ref(C,-1),1,
        IIf(Ref(blackbody,-1) AND blackBody AND O<Ref(C,-1),1,
        IIf(Ref(whiteBody,-1) AND whiteBody AND C<Ref(O,-1),1,
        IIf(Ref(whiteBody,-1) AND blackBody AND O<Ref(O,-1),1,0))));
  
  
/*Candle Definitions*/
spinningTop=mediumBody;
doji=CdDoji(threshold=0.05);/*abs(C-O) <= (C*smallBodyMaximum) OR
(abs(O-C)<=((H-L)*0.1));*/
dojiStar=doji AND (upgap OR downgap)AND Ref(LargeBody,-1);
marabuzu=LargeBody AND smallUpperShadow AND smallLowerShadow;
  
shootingStar=/*(NOT largeBody AND smallLowerShadow AND LargeUpperShadow) OR*/
    smallLowerShadow AND NOT doji AND
   ((blackBody AND abs(O-H)>2*realBodySize) OR
   (whiteBody AND abs(H-C)>2*realBodySize));
  
Hammer=smallUpperShadow AND NOT doji AND
   ((blackBody AND abs(C-L)>2*realBodySize) OR
   (whiteBody AND abs(L-O)>2*realBodySize));
  
tweezerTop=abs(H-Ref(H,-1))<=H*0.0025;
tweezerBottom=abs(L-Ref(L,-1))<=L*0.0025;
engulfing=
   IIf(blackBody AND Ref(blackbody,-1) AND C<Ref(C,-1) AND O>Ref(O,-1),1,
   IIf(blackBody AND Ref(whiteBody,-1) AND O>Ref(C,-1) AND C<Ref(O,-1),1,
   IIf(whitebody AND Ref(whitebody,-1) AND C>Ref(C,-1) AND O<Ref(O,-1),1,
   IIf(whiteBody AND Ref(blackBody,-1) AND C>Ref(O,-1)AND O<Ref(C,-1),1,0))));
Harami=
   IIf(blackbody AND Ref(blackBody,-1) AND O<Ref(O,-1) AND C>Ref(C,-1),1,
   IIf(blackBody AND Ref(whiteBody,-1) AND C>Ref(O,-1) AND O<Ref(C,-1),1,
   IIf(whiteBody AND Ref(whiteBody,-1) AND C<Ref(C,-1) AND O>Ref(O,-1),1,
   IIf(whiteBody AND Ref(blackBody,-1) AND O>Ref(C,-1) AND C<Ref(O,-1),1,0))));
  
  
/*Maximum High Today - (MHT)
Today is the maximum High in the last 5 days*/
MHT=  HHV(H,5)==H;
  
/*Maximum High Yesterday - (MHY)
Yesterday is the maximum High in the last 5 days*/
MHY=   HHV(H,5)==Ref ( H, -1);
  
/*Minimum Low Today - (MLT)
Today is the minimum Low in the last 5 days*/
MLT=   LLV(L,5)==L;
  
/*Minimum Low Yesterday - (MLY)
Yesterday is the minimum Low in the last 5 days*/
MLY=   LLV(L,5)==Ref(L,-1);
  
/*DOJI definitions*/
  
/*Doji Today - (DT)*/
DT = abs(C-O) <= (C*smallBodyMaximum) OR
(abs(O-C)<=((H-L)*0.1));
  
/* Doji Yesterday - (DY)*/
DY = abs(Ref ( C, -1)-Ref(O,-1)) <= Ref ( C, -1) *smallBodyMaximum OR
abs (Ref ( O, -1)-Ref(C,-1)) <= (Ref ( H, -1 ) - Ref ( L, -1 ) )*0.1;
  
/**************************************************
             BULLISH CANDLESTICKS
*************************************************** */
  
/* Abandoned Baby Bullish*/
abandonedBabybullish =Ref(largeBody,-2) AND Ref(blackBody,-2)//Large black candle
             AND Ref(GapDown(),-1)
             AND whiteBody AND LargeBody AND GapUp();//Large white candle
  
/* Belt Hold*///Bad formula
beltHoldBullish = largeBody AND smallLowerShadow AND whiteBody AND MLT;
  
  
/*BreakAway Bullish*/
breakAwayBullish=Ref(Largebody,-4) AND Ref(blackBody,-4)
              AND Ref(blackBody,-3) AND Ref(O,-3)<Ref(C,-4)
              AND Ref(smallbody,-2) AND Ref(C,-2)<Ref(C,-3)
              AND Ref(C,-1)<Ref(C,-2)
              AND LargeBody AND whiteBody AND C>Ref(O, -3)
              AND C<Ref(C,-4);
  
/*Concealing Baby Swallow only one trade */
ConcealingBabySwallow=Ref(marabuzu,-3) AND Ref(blackbody,-3) AND
                      Ref(MArabuzu,-2) AND Ref(blackBody,-2) AND
                      Ref(blackBody,-1) AND Ref(downGap,-1) AND
                      Ref(H,-1)>Ref(C,-2)AND Ref(blackbody,-1)AND
                      blackBody AND engulfing;
  
/*Doji Star Bullish*/
dojiStarBullish=(dojiStar AND (MLT OR MLY))OR
   (doji AND (C<Ref(C,-1) OR O<Ref(C,-1))AND Ref(blackBody,-1)
    AND Ref(LargeBody,-1));
  
/*Engulfing Bullish*/ 
engulfingBullish =
    engulfing AND largeBody AND whiteBody AND
    (Ref(blackbody,-1) OR Ref(Doji,-1)) AND MLT;
  
/*Hammer Bullish*/
hammerBullish=Hammer AND (MLT OR MLY);
  
/*Dragonfly Doji Bullish*/
dragonflyDoji=smallBody AND LargeLowerShadow AND smallUpperShadow AND MLT;
  
/* Harami Bullish*/
haramiBullish = harami AND Ref (LargeBody,-1) AND Ref(blackBody,-1) AND
                NOT LargeBody AND whiteBody;
  
/*Harami Cross*/
HaramiCross=harami AND Ref(LargeBody,-1) AND Ref(blackBody,-1) AND doji;
         
/* Homing Pigeon*/
homingPigeon =  Ref(largeBody,-1) AND Ref(blackBody,-1) AND
                H<= Ref ( O, -1 ) AND L>=Ref( C, -1) AND C<O AND MLY;
  
/*Inverted Hammer*/
invertedHammer=shootingStar AND (MLT OR MLY);
  
/* Meeting LinesBullish*/
meetingLinesbullish= Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
                     LargeBody AND whiteBody AND
                     C>Ref(C,-1)*0.9975 AND C< Ref(C,-1)*1.0025;
  
/*Morning Doji Star*/
morningDojiStar= Ref(LargeBody,-2) AND Ref(blackBody,-2) AND
                 Ref(doji,-1) AND Ref(O,-1)<Ref(C,-2) AND
                 whiteBody AND C>Ref(C,-2) AND MLY;
  
/* Morning Star*/
morningStar =Ref(largeBody,-2) AND Ref(blackBody,-2)//Large black candle
             AND Ref(downGap,-1)//Gap down yesterday
             AND whiteBody AND LargeBody AND C>Ref(C,-2)//Large white candle today
             AND MLY; //Yesterday was the low
  
/* Piercing Line*/
piercingLine= Ref(largeBody,-1) AND Ref(blackBody,-1)AND
               O<Ref(L,-1) AND C>=(Ref(O,-1)+Ref(C,-1))/2 AND C<Ref(O,-1) AND MLT;
  
/* Stick Sandwich*/
stickSandwich=Ref(largeBody,-2) AND Ref(blackbody,-2) AND
              Ref(largeBody,-1) AND Ref(whiteBody,-1) AND
              Ref(O,-1)>=Ref(C,-2) AND O>=Ref(C,-1) AND
              abs(C-Ref(C,-2))<=C*0.0025;
  
/*Three Inside Up harami confirming*/
threeInsideUp =Ref(Haramibullish,-1) AND whiteBody AND
    largeBody AND C>Ref(C,-1);
  
  
/* Three Outside Up Engulfing confirmation*/
threeOutsideUp =Ref(engulfingBullish,-1) AND whiteBody AND C>Ref(C,-1);
  
/* Three Stars in the South*///Rewrite???
threeStarsInTheSouth=
   Ref(LargeBody,-2) AND Ref(blackBody,-2) AND Ref(largelowerShadow,-2)
   AND Ref(blackBody,-1) AND Ref(largeLowerShadow,-1) AND
   Ref(L,-1)>Ref(L,-2) AND blackBody AND smallUpperShadow AND
   smallLowerShadow AND L>Ref(L,-1) AND H<Ref(H,-1);
  
/* Tri-Star Bullish*/
triStarBullish=Ref(doji,-2) AND Ref(doji,-1) AND doji AND MLY AND
   Ref(downgap,-1) AND upGap;
  
/* Three River Bottom Bad formula*/
threeriverBottom=Ref(largeBody,-2) AND Ref(blackBody,-2) AND
                 Ref(blackbody,-1) AND Ref(Largelowershadow,-1) AND
                 Ref(O,-1)<Ref(O,-2) AND Ref(C,-1)>Ref(C,-2) AND
                 whiteBody AND C<Ref(C,-1) AND MLY; 
                    
/* Mat Hold Bullish*/
MAtHoldBullish=Ref(LargeBody,-4) AND Ref(whiteBody,-4)//1st day
   AND Ref(blackBody,-3) AND Ref(upGap,-3) AND NOT Ref(LargeBody,-3)
   AND NOT Ref(LargeBody,-2) AND Ref(C,-2)<Ref(C,-3) AND Ref (O,-2)<Ref(O,-3) AND
   Ref(C,-2)>Ref(O,-4) AND NOT Ref(LargeBody,-1) AND Ref(C,-1)<Ref(C,-2)
   AND LargeBody AND whiteBody AND C>Ref(C,-4);
  
/*RisingThreeMethods*/
risingThreeMethods=Ref(LargeBody,-4) AND Ref(whiteBody,-4) AND NOT
  Ref(LargeBody,-3) AND NOT Ref(LargeBody,-2)AND NOT Ref(LargeBody,-1) AND
  Ref(C,-3)<Ref(C,-4) AND Ref(C,-2)<Ref(C,-3) AND Ref(C,-1)<Ref(C,-2) AND
  LargeBody AND whitebody AND C>Ref(C,-4);
  
/* Seperating Lines Bullish*/
separatingLinesBullish=Ref(blackBody,-1) AND whiteBody AND LargeBody AND
smallLowerShadow AND MHT AND abs(O-Ref(O,-1))<=O*0.0025;
  
/*Side by Side White Lines*/
sideBySideWhiteLines=NOT Ref(smallBody,-2) AND Ref(whiteBody,-2)
   AND Ref(upGap,-1) AND Ref(whitebody,-1)AND whiteBody AND
   identicalBodies AND abs(O-Ref(O,-1))<O*0.0025;
  
  
/*Three White Soldiers*/
threeWhiteSoldiers=NOT Ref(smallbody,-2) AND Ref(whiteBody,-2) AND NOT
   Ref(smallBody,-1) AND Ref(whiteBody,-1) AND NOT
   smallBody AND whiteBody AND C>Ref(C,-1) AND Ref(C,-1)>Ref(C,-2) AND
   Ref(O,-1)>Ref(O,-2) AND Ref(O,-1)<Ref(C,-2) AND O<Ref(C,-1) AND
   O>Ref(O,-1) AND Ref(smallUpperShadow,-2) AND
   Ref(smallUpperShadow,-1) AND smallUppershadow AND LLV(L,12)==Ref(L,-2);
  
/*Upside Gap Three Methods not very good*/
upsideGapThreeMethods=Ref(Largebody,-2) AND Ref(whiteBody,-2) AND
   Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND Ref(upGap,-1) AND
   blackBody AND O>Ref(O,-1) AND C<Ref(C,-2)AND C>Ref(O,-2) AND
  MHY;
  
/*Three Line Strike not good signals*/
threeLineStrike=NOT Ref(smallBody,-3) AND NOT Ref(smallBody,-2) AND
   NOT Ref(smallBody,-1) AND Ref(whiteBody,-3) AND Ref(whiteBody,-2) AND
   Ref(whiteBody,-1) AND Ref(C,-1)>Ref(C,-2) AND Ref(C,-2)>Ref(C,-3) AND
   blackBody AND O>Ref(C,-1) AND C<Ref(O,-3);
  
/*Tweezer Bottom*/
tweezerBottom= (abs(L-Ref(L,-1))/L<0.0025 OR
               abs(L-Ref(L,-2))/L<0.0025)
               AND (MLT OR MLY);
  
/*Upside Tasuki Gap*/
upsideTasukiGap=Ref(largeBody,-2) AND Ref(largeBody,1) AND
   Ref(whiteBody,-2) AND Ref(whiteBody,-1) AND Ref(upGap,-1) AND
   blackBody AND O>Ref(O,-1) AND C<Ref(O,-1) AND C>Ref(C,-2) AND
   identicalBodies AND O<Ref(C,-1);
   //AND HHV(H,5)==Ref(H,-1); Do not use this line
  
  
/*****************************************
            BEARISH CANDLESTICKS
******************************************/
  
/*Abandoned Baby Bearish*/
AbandonedBabyBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(smallBody,-1) AND Ref(GapUp(),-1) AND GapDown() AND
   NOT smallBody AND blackBody AND MHY;
  
/*Advance Block Bearish*/
AdvanceBlockBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2)
    AND Ref(whiteBody,-1) AND
   whiteBody AND Ref(O,-1)>Ref(O,-2) AND Ref(O,-1)<Ref(C,-2) AND
   Ref(C,-1)>Ref(C,-2) AND C>Ref(C,-1) AND
   O<Ref(C,-1) AND O>Ref(O,-1) AND Ref(LargeUpperShadow,-1) AND LargeUpperShadow
   AND C-O<Ref(C,-1)-Ref(O,-1) AND Ref(C,-1)-Ref(O,-1) < Ref(C,-2)-Ref(O,-2);
  
/*Belt Hold Bearish*/
beltHoldBearish=LargeBody AND BlackBody AND smalluppershadow AND MHT;
  
/*Breakaway Bearish*/
breakAwayBearish=Ref(LargeBody,-4) AND Ref(whiteBody,-4) AND
   Ref(GapUp(),-3) AND Ref(whiteBody,-3) AND
   Ref(smallbody,-2) AND Ref(smallBody,-1) AND
   blackBody AND O>Ref(O,-3) AND C<Ref(C,-4);
  
/*Dark Cloud Cover*/
darkCloudCover=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
   blackBody AND O>Ref(H,-1) AND C>Ref(O,-1) AND C<(Ref(O,-1)+Ref(C,-1))/2
   AND MHT;
  
/*Deliberation Bearish: needs confirmation*/
deliberationBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND Ref(C,-1)>Ref(C,-2) AND
   smallbody AND upGap;
  
/*CounterAttackBearish*/
CounterAttackBearish=MHT AND LargeBody AND blackbody AND
   Ref(largeBody,-1) AND Ref(whiteBody,-1) AND
   C<Ref(C,-1)*1.0025 AND C>Ref(C,-1)*0.9975;;
  
/*Doji Star Bearish*/
dojiStarBearish=(dojiStar AND (MHT OR MHY))OR
   (doji AND (C>Ref(C,-1) OR O>Ref(C,-1))AND Ref(whiteBody,-1)
    AND Ref(LargeBody,-1));
  
/*Engulfing Bearish*/
engulfingBearish=engulfing AND largeBody AND blackBody AND
    (Ref(whitebody,-1) OR Ref(Doji,-1))AND (MHT OR MHY);
  
/*Evening Doji Star check formula???*/
eveningDojiStar=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(dojiStar,-1) AND Ref(GapUp(),-1) AND (MHY OR MHT);
  
/*Evening Star*/
eveningStar=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
   Ref(upGap,-1) AND NOT Ref(largeBody,-1) AND blackBody AND NOT smallBody AND
   (MHT OR MHY);
  
/*Hammer Bearish*/
HammerBearish=Hammer AND HHV(H,8)==H;
  
/*hangingMan*/
HangingMan=NOT largeBody AND smallUpperShadow AND LargeLowerShadow AND MHT;
  
/*dragonfly Doji Bearish*/
dragonflyDojiBearish=doji AND smallUpperShadow AND LargeLowerShadow AND MHT;
     
/*Harami Bearish-*/
HaramiBearish=harami AND Ref(Largebody,-1) AND Ref(whiteBody,-1)AND blackBody
AND (MHY OR MHT);
  
/*HaramiCross Bearish*/
HaramiCrossBearish=harami AND doji AND Ref(whiteBody,-1) AND Ref(Largebody,-1);
  
/*Identical three black crows*/
idendicalThreeBlackCrows=Ref(blackBody,-2) AND Ref(blackBody,-1) AND blackBody AND
   abs(Ref(C,-2)-Ref(O,-1))<Ref(C,-1)*0.0025 AND abs(Ref(C,-1)-O)<O*0.0025 AND
   HHV(H,20)==Ref(H,-2) AND NOT Ref(doji,-2) AND NOT Ref(doji,-1) AND NOT doji AND
   Ref(smallLowerShadow,-2) AND Ref(smallLowerShadow,-1) AND smallLowerShadow;
  
/*Kicking Bearish No trades*/
kickingBearish=Ref(whiteBody,-1) AND Ref(MArabuzu,-1) AND blackBody AND MArabuzu    AND GapDown();
  
/*Meeting Lines Bearish*/
MeetingLinesBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
  HHV(C,8)==Ref(C,-1) AND LargeBody AND blackBody AND
  abs(C-Ref(C,-1))<C*0.0025;
  
/*ShootingStar*/
shootingStarGap=shootingStar AND GapUp() AND MHT;
  
/*Gravestone Doji*/
gravestoneDoji=doji AND largeUpperShadow AND smallLowerShadow AND GapUp()AND MHT;
  
/*Three Inside Down Bearish*/
threeInsideDownBearish=Ref(HaramiBearish,-1) AND blackBody AND C<Ref(C,-1)AND    smallUpperShadow;
  
/*Three Outside Down Bearish*/
threeoutsideDownBearish=Ref(engulfingBearish,-1) AND blackBody AND C<Ref(C,-1)AND
   NOT LargeUpperShadow;
  
/*Tri Star Bearish*/
triStarBearish=Ref(doji,-2) AND Ref(doji,-1) AND doji AND MHY AND Ref(upGap,-1)AND    downGap;
  
/*Two Crows Bearish*/
twoCrows=Ref(whiteBody,-2) AND Ref(LargeBody,-2) //first day
   AND Ref(blackBody,-1) AND Ref(upGap,-1)//Second Day
   AND blackBody AND O<Ref(O,-1) AND O>Ref(C,-1)AND C<Ref(C,-2) AND
   C>Ref(O,-2) AND MHY;//Third day
  
/*Upside Gap Two Crows*/
upsideGapTwoCrows= Ref(whiteBody,-2) AND Ref(LargeBody,-2)// first day
   AND Ref(upGap,-1) AND Ref(blackBody,-1) // 2nd day
   AND blackbody AND O>Ref(O,-1) AND C<Ref(C,-1) AND C>Ref(C,-2);
  
/*Doji Star Bearish needs confirmation
dojiStarBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) // first day
   AND doji AND upGap AND MHT;*/
  
/* Downside Gap Three Methods*/
downsideGapThreeMethods=
     Ref(LargeBody,-2) AND Ref(blackBody,-2) AND Ref(downGap,-2) //first day
     AND Ref(LargeBody,-1) AND Ref(blackBody,-1)//2nd day
     AND whitebody AND O<Ref(O,-1) AND C>Ref(C,-2)
     AND LLV(L,8)==Ref(L,-1);
  
/*Downside Tasuki Gap*/
downsideTasukiGap=
   Ref(blackBody,-2)//first day
   AND Ref(blackbody,-1) AND Ref(downgap,-1) //2nd day
   AND whiteBody AND O<Ref(O,-1) AND O>Ref(C,-1) AND C>Ref(O,-1) AND C<Ref(C,-2)
   AND Ref(identicalBodies,-1)                                                                                                                 
   AND LLV(L,15)==Ref(L,-1);
  
  
/*Falling Three Meothods*/
fallingThreeMethods=Ref(LargeBody,-4) AND Ref(blackBody,-4) AND
  /*Ref(doji,-3) AND Ref(doji,-2) AND Ref(doji,-1) AND*/ Ref(C,-1)>Ref(C,-2)
  AND Ref(C,-2)>Ref(C,-3) AND LargeBody AND blackBody AND O>Ref(C,-4) AND
  O<Ref(O,-4) AND C<Ref(O,-4)AND C<Ref(C,-4);
  
/*In Neck Bearish not good*/
inNeckBearish=Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
   whiteBody AND O<Ref(L,-1) AND C<Ref(C,-1)*1.0005 AND C>=Ref(C,-1);
  
/*On Neck Bearish not good*/
OnNeckBearish=Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
   whiteBody AND O<Ref(L,-1) AND C<Ref(L,-1)*1.0025 AND C>=Ref(L,-1)*0.9975;
  
/*separating Lines Bearish*/
separatingLinesBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
   blackBody AND O>Ref(O,-1)*0.9975 AND O<=Ref(O,-1)*1.0025;
  
/*Side By Side White Lines Bearish*/
sideBySideWhiteLinesBearish=NOT Ref(smallBody,-2) AND Ref(blackBody,-2) AND
   Ref(whiteBody,-1) AND whiteBody AND Ref(downGap,-1) AND identicalBodies
  AND abs(C-Ref(C,-1)<C*0.0025);
  
/*Three Black Crows*/
threeBlackCrows=Ref(blackBody,-2) AND Ref(blackBody,-1) AND blackBody  AND Ref(C,-1)<Ref(C,-2) AND C<Ref(C,-1) AND HHV(H,8)==Ref(H,-2) AND NOT Ref(doji,-2) AND NOT Ref(doji,-1) AND NOT doji;;
     
/*Three Line Strike no trades*/
threeLineStrike=threeBlackCrows AND whiteBody AND O<Ref(C,-1) AND C>Ref(O,-3);
  
/*Thrusting Bearish*/
thrustingBearish=Ref(blackBody,-1) AND Ref(LargeBody,-1) AND LargeBody AND
   whitebody AND O<Ref(L,-1) AND C<(Ref(O,-1)+Ref(C,-1))/2 AND C>Ref(C,-1);
  
/*Tweezer Top*/
tweezerTop= (abs(H-Ref(H,-1))/H<0.0025 OR
               abs(H-Ref(H,-2))/H<0.0025)
               AND (MHT OR MHY);
  
  
  
/* ***********************************************
                  Buy Rules
**************************************************/
Buy=
abandonedBabybullish OR
beltHoldBullish OR
breakAwayBullish OR
ConcealingBabySwallow OR
engulfingBullish OR
hammerBullish OR
dragonflyDoji OR
dojiStarBullish OR
haramiBullish OR
HaramiCross OR
homingPigeon OR
invertedHammer OR
meetingLinesbullish OR
morningDojiStar OR
morningStar OR
piercingLine OR
stickSandwich OR
threeInsideUp OR
threeOutsideUp OR
threeStarsInTheSouth OR 
triStarBullish OR
threeriverBottom OR
MAtHoldBullish OR
risingThreeMethods OR
separatingLinesBullish OR
sideBySideWhiteLines OR
threeWhiteSoldiers OR
upsideGapThreeMethods OR
threeLineStrike OR
tweezerBottom OR
upsideTasukiGap;
  
/************************************
                    Sell Rules
*************************************/
Sell=
AbandonedBabyBearish OR
advanceBlockBearish OR
beltHoldBearish OR
breakAwayBearish OR
darkCloudCover OR
deliberationBearish OR
CounterAttackBearish OR
engulfingBearish OR
eveningDojiStar OR
eveningStar OR
HangingMan OR
dragonflyDojiBearish OR
HammerBearish OR
HaramiBearish OR
HaramiCrossBearish OR
idendicalThreeBlackCrows OR
kickingBearish OR
MeetingLinesBearish OR
shootingStarGap OR
gravestoneDoji OR
threeInsideDownBearish OR
threeoutsideDownBearish OR
triStarBearish OR
twoCrows OR
upsideGapTwoCrows OR
dojiStarBearish OR
downsideGapThreeMethods OR
downsideTasukiGap OR
fallingThreeMethods OR
inNeckBearish OR
OnNeckBearish OR
separatingLinesBearish OR
sideBySideWhiteLinesBearish OR
threeBlackCrows OR
threeLineStrike OR
thrustingBearish OR
tweezerTop;
  
  
/***************************************
              Commentary
***************************************
            Bullish Candles
****************************************/
WriteIf(Buy,"Bullish\n=======\n","")+
WriteIf(abandonedBabybullish,"Abandoned Baby Bullish. \nA reversal pattern.\n\\c16LiWick reliability : High.","")+
WriteIf(beltHoldBullish,"Belt Hold Bullish. \nA reversal pattern.\nNison:The larger the candlestick, the more significant it is.\nLitWick Reliability: Low.","")+
WriteIf(breakAwayBullish,"Break Away Bullish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(ConcealingBabySwallow,"Concealing Baby Swallow. \nA reversal pattern.\n LitWick reliability: high.","")+
WriteIf(dojiStarBullish,"Bullish doji Star. A reversal pattern.\nNison: Needs confirmation. Better at calling tops.\nLitWick reliability: moderate.","")+
WriteIf(engulfingBullish,"Bullish Engulfing. \nA reversal pattern.\nNison: Factors increasing the pattern's effectiveness are\n1) The first day has a small real body and the second day has a large real body.\n2) Pattern appears after protracted or very fast move.\n3) Heavy volume on second real body.\n4) The second day engulfs more than one real body.\nLitWick reliability: moderate","")+
WriteIf(hammerBullish,"Bullish Hammer. \nA reversal pattern.\nNison: The longer the lower shadow, the smaller the upper shadow, and the smaller the real body, the more significant the pattern.White real body more bullish than black body.\nLitWick reliability: low.","")+
WriteIf(dragonflyDoji,"Dragonfly Doji. \nLitWick reliability: moderate.","")+
WriteIf(haramiBullish, "Harami Bullish. \nA reversal pattern.\nNison: Less significant. Pattern needs confirmation.\nLitWick reliability: low.","")+
WriteIf(HaramiCross,"Harami Cross. \nA reversal pattern.\nNison: Better indicator than Harami. Better at calling tops than bottoms.\nLitWick reliability: low.","")+
WriteIf(homingPigeon,"Homing Pigeon. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(invertedHammer,"Inverted Hammer. \nA reversal pattern.\nNison:Needs bullish verification.\nLitWick reliability: low.","")+
WriteIf(meetingLinesbullish,"Meeting Lines bullish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(morningDojiStar,"Morning Doji Star. \nA reversal pattern.\nImportant reversal signal.\nLitWick reliability: high.","")+
WriteIf(morningStar,"Morning Star. \nA reversal pattern.\nNison: The stronger the white third body the better.\nLitWick reliability: high.","")+
WriteIf(piercingLine,"Piercing Line. \nA reversal pattern.\nNison: A stron reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(stickSandwich,"Stick Sandwich. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeInsideUp,"3 Inside Up. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(threeOutsideUp,"3 Outside Up. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(threeStarsInTheSouth,"3 Stars in the South. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(triStarBullish,"Tri-Star Bullish. \nA reversal pattern.\nNison: Significant reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeriverBottom,"3 River Bottom. \nA reversal pattern.\nNison: Selling pressure drying up.\nLit Wick reliability: moderate.","")+
WriteIf(MAtHoldBullish,"Mat Hold Bullish. \nA continuation pattern.\nNison: May have 2-4 black candles.\nLitWick reliability: high. ","")+
WriteIf(risingThreeMethods,"Rising Three Methods. \nA continuation pattern>\nNison: Has more significance if volume of white candle sticks is greater than on black candlesticks.\nLitWick reliability: high.","")+
WriteIf(separatingLinesBullish,"Separating Lines Bullish. \nA continuation pattern.\nNison:    \nLitWick reliability: low.","")+
WriteIf(sideBySideWhiteLines,"Side by Side White Lines. \nA continuation pattern.\nNison: If occurring during a downtrend may only be short covering.\nLitWick reliability: high.","")+
WriteIf(threeWhiteSoldiers,"3 White Soldiers. \nA continuation pattern.\nNison: Positive, but be aware of negative similar stalled pattern and advance block pattern.\nLitWick reliability: high.","")+
WriteIf(upsideGapThreeMethods,"Upside Gap 3 Methods. \nA continuation pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeLineStrike,"3 Line Strike. \nA continuation pattern.\nLitWick reliability: low.","")+
WriteIf(tweezerBottom,"Tweezer Bottom.\nA reversal pattern. With other reversal candles it could indicate a support level.\nNison: Needs confirmation.","")+
WriteIf(upsideTasukiGap,"Upside Tasuki Gap. \nA continuation pattern.\nNison: the real bodies of the two candlesticks in the gap should be about the same size.\nLitWick reliability: moderate.","")+
WriteIf(Buy,"\n-------------------------------------------","");;                                      /***************************************
                 Bearish Candles
********************************************/
WriteIf(Sell,"Bearish\n=======\n","")+
WriteIf(AbandonedBabyBearish,"Abandoned Baby Bearish. \nA reversal pattern.\nNison: Extremely rare.\nLitWick reliability: high.","")+
WriteIf(advanceBlockBearish,"Advancing Block Bearish. \nA reversal pattern.\nNison: Rally is in trouble. Signs of weakening could be progressively smaller white read bodies or relatibvely long upper shadows on the last two white candlesticks.Not necessarily a reversal pattern.\nLitWick Reliability: moderate.","")+
WriteIf(beltHoldBearish,"Belt Hold Bearish. \nA reversal pattern.\nNison: The longer the height of the belt-hold candle the more significant the pattern.\nLitWick reliability: low.","")+
WriteIf(breakAwayBearish,"Break Away Bearish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(darkCloudCover,"Dark Cloud Cover. \nA reversal pattern.\nNison: Factors indicating the importance of this signal are/n1)The greater the penetration of the first candle by the second.\n2)Both candles are marabozus.\n3)The second body opens above a major resistance level.\n4)High volume on the second day.\nLitWick Reliability: high.","")+
WriteIf(deliberationBearish,"Deliberation Bearish. \nA reversal pattern.\nNison: Not a reversal pattern, but a sign the rally is weakening.\nLitWick reliability: moderate.","")+
WriteIf(CounterAttackBearish,"Counter Attack Bearish.\nNison: A potential stalling of the rally.","")+
WriteIf(engulfingBearish,"Engulfing Bearish. \nA reversal pattern.\nNison: Major reversal signal. Factors increasing patterns importance are\n1) The first day has a very small real body and the second day a very large real body.\n2) The pattern apears after a protracted or very fast move.\n3) Heavy volume on the second day.\n4) The second day engulfs more than one real body.\nLitWick reliability: moderate.","")+
WriteIf(eveningDojiStar,"Evening Doji Star \nA reversal pattern.\nNison: Must be confirmed by long black candle.\nLit Wick reliability: high","")+
WriteIf(eveningStar,"Evening Star. \nA reversal pattern.\nNison: Gap between Second AND third bodies does NOT always occur.\nLitWick reliability: High.","")+
WriteIf(HammerBearish,"Bearish Hammer. \nA reversal pattern.\nNison: More bearish if hammer is black. Needs bearish confirmation. A large gap down on the following day would be a good confirmation.","")+
WriteIf(HangingMan,"Hanging Man. \nA reversal pattern.\nNison: Same as bearish hammer with a large gap down the following day.\nLitWick reliability: low.","")+
WriteIf(dragonflyDojiBearish,"Dragonfly Bearish. \nA reversal pattern.\nNison: Same as Hanging Man.\nLitWick reliability: moderate.","")+
WriteIf(HaramiBearish,"Harami Bearish. \nA reversal pattern.\nNison: Not as significant a reversal pattern as hanging man or engulfing.\nLitWick reliability: low.","")+
WriteIf(HaramiCrossBearish,"Harami Cross Bearish. \nA reversal pattern.\nNison: More significant reversal pattern than Harami. Second day can be white or black.\nLitWick reliability: moderate.","")+
WriteIf(idendicalThreeBlackCrows,"Identical 3 Black Crows. \nA reversal pattern in an uptrend.\nNison:Very bearish.\nLitWick reliability: high. ","")+
WriteIf(kickingBearish,"Kicking Bearish. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(MeetingLinesBearish,"Meeting Lines Bearish. \nA reversal pattern.\nNison:  \nLitWick reliability: moderate, but not as strong as Dark cloud Cover.","")+
WriteIf(shootingStarGap,"Shooting Star. \nA reversal pattern.\nNison:Not major reversal signal as evening star. Ideally real body would gap away from previous body. Needs to appear after an uptrend.\nLitWick reliability: low.","")+
WriteIf(gravestoneDoji,"Gravestone Doji. \nA reversal pattern.\nNison: more significant if it hits new high.\nLitWick reliability: moderate.","")+
WriteIf(threeInsideDownBearish,"3 Inside Down. \nA reversal pattern.\nNison:  \nLitWick reliability: high.","")+
WriteIf(threeoutsideDownBearish,"3 Outside Down. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(triStarBearish,"Tri-Star Bearish. \nA reversal pattern.\nNison: Very significant reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(twoCrows,"2 Crows. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(upsideGapTwoCrows,"Upside Gap 2 Crows. \nA reversal pattern.\nNison:Needs confirmation of a continued reversal on third day.\nLitWick reliability: high.","")+
WriteIf(dojiStarBearish,"Doji Star Bearish. \nA reversal pattern.\nNison: needs confirmation.\nLitWick reliability: moderate.","")+
WriteIf(downsideGapThreeMethods,"Downside Gap 3 Methods. A continuation pattern.\nNison: \nLitWick reliability: moderate.","")+
WriteIf(downsideTasukiGap,"Downside Tasuki Gap. \nA continuation method.\nNison: If last day closes window, continuation pattern is negated.\nLitWick reliability: moderate.","")+
WriteIf(fallingThreeMethods,"Falling 3 Methods. \nA continuation pattern.\nNison:  \nLitWick reliability: high.","")+
WriteIf(inNeckBearish,"In Neck Bearish. A continuatin pattern.\nNison: Similar to piercing pattern but bearish because there is no penetration of second day.\nLitWick reliability: moderate.","")+
WriteIf(OnNeckBearish,"On Neck Bearish. \nA continuation pattern. Similar to piercing pattern but bearish beccause there is no penetration of the second day.\nLitWick reliability: moderate.","")+
WriteIf(separatingLinesBearish,"Separating Lines Bearish","");
WriteIf(sideBySideWhiteLinesBearish,"Side by Side White Lines Bearish. \nA continuation pattern.\nNison: very rare.\nLitWick reliability: moderate.","")+
WriteIf(threeBlackCrows,"3 Black Crows. \nA reversal pattern.\nNison: Need to appear after a mature advance.\nLitWick reliability: high.","")+
WriteIf(threeLineStrike,"3 Line Strike. \nA continuation pattern.\nLitWick reliability: low.","")+
WriteIf(thrustingBearish,"Thrusting. \nA continuation pattern.\nNison: Not a reversal day because second day does not pierce midpoint of first day.\nLitWick reliability: low.","")+
WriteIf(tweezerTop,"Tweezer Top. \nA reversal pattern.\nNison: Needs confirmation.","")+
WriteIf(Sell,"\n---------------------------------------------------","");
 
/***********************************************
               End Commentary
************************************************/
_SECTION_END();
 
 
_SECTION_END();
 
_SECTION_BEGIN("VSA by Mr.Karthik");
 
DTL=Param("Linear regression period",60,10,100,10);
 
wbf=Param("WRB factor",1.5,1.3,2.5,.1);
 
nbf=Param("NRB factor",0.7,0.3,0.9,0.1);
 
TL=LinRegSlope(MA(C, DTL),2);
 
 Vlp=Param("Volume lookback period",30,20,300,10);
 
Vrg=MA(V,Vlp);
 
St = StDev(Vrg,Vlp);
 
Vp3 = Vrg + 3*st;
 
Vp2 = Vrg + 2*st;;
 
Vp1 = Vrg + 1*st;;
 
Vn1 = Vrg -1*st;
 
Vn2 = Vrg -2*st;
 
rg=(H-L);
 
arg=Wilders(rg,30);
 
wrb=rg>(wbf*arg);
 
nrb=rg<(nbf*arg);
 
Vl=V<Ref(V,-1) AND V<Ref(V,-2);
 
upbar=C>Ref(C,-1);
 
dnbar=C<Ref(C,-1);
 
Vh=V>Ref(V,-1) AND Ref(V,-1)>Ref(V,-2);
 
Cloc=C-L;
 
x=rg/Cloc;
 
x1=IIf(Cloc==0,arg,x);
 
Vb=V>Vrg OR V>Ref(V,-1);
 
ucls=x1<2;
 
dcls=x1>2;
 
mcls=x1<2.2 AND x1>1.8 ;
 
Vlcls=x1>4;
 
Vhcls=x1<1.35;
 
j=MA(C,5);
 
TLL=LinRegSlope(j,40) ;
 
Tlm=LinRegSlope(j,15) ;
 
tls=LinRegSlope(j,5);
 
mp=(H+L)/2;
 
  
 
Pp1=Param("NumberOfDays",30,1,200,1);
 
Pp2=Param("VolOfDays",15,1,200,1);
 
  
 
numDays = Pp1;
 
dwWideSpread = 1.8;
 
dwNarrowSpread = 0.8;
 
dwSpreadMiddle = 0.5;
 
dwHighClose = 0.7;
 
dwLowClose = 0.3;
 
  
 
volNumDays = Pp2;
 
dwUltraHighVol = 2;
 
dwVeryHighVol = 1.75; // was 1.8
 
dwHighVol = 1.75; // was 1.8
 
dwmoderateVol = 1.10; // was 1.8
 
dwLowVol = 0.75; // was 0.8
 
  
 
////////////////////////////////////////////////////////////////////////////////////
 
// Classify each bar...
 
///////////////////////////////////////////////////////////////////////////////////
 
  
 
upBar = C > Ref(C,-1);
 
downBar = C < Ref(C,-1);
 
spread = H-L;
 
avgRange = Sum(spread, numDays) / numDays;
 
wideRange = spread >= (dwWideSpread * avgRange);
 
narrowRange = spread <= (dwNarrowSpread * avgRange);
 
testHighClose = L + (spread * dwHighClose);
 
testLowClose = L + (spread * dwLowClose);
 
testCloseMiddle = L + (spread * dwSpreadMiddle);
 
  
 
upClose = C > testHighClose;
 
downClose = C < testLowClose;
 
middleClose = C >= testLowClose AND C <= testHighClose;
 
  
 
avgVolume = EMA(V, volNumDays);
 
  
 
highVolume = V > (avgVolume * dwHighVol);
 
moderateVol= V > (avgVolume * dwmoderateVol);
 
veryHighVolume = V > (avgVolume * dwVeryHighVol);
 
ultraHighVolume = V > (avgVolume * dwUltraHighVol);
 
LowVolume = V < (avgVolume * dwLowVol);
 
  
 
////////////////////////////////////////////////////////////////////////////////////
 
// direction and title
 
////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////
 
//
 
// Basic patterns...
 
//
 
////////////////////////////////////////////////////////////////////////////////////
 
  
 
upThrustBar = downClose AND H > Ref(H,-1) AND (C == L) AND downClose AND (NOT narrowRange);
 
noDemandBar = narrowRange AND LowVolume AND upBar AND (NOT upClose);
 
//noDemandBar = narrowRange AND LowVolume AND upBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));
 
noSupplyBar = narrowRange AND LowVolume AND downBar AND (V < Ref(V,-1)) AND (V < Ref(V,-2));
 
absorption = Ref(downbar, -1) AND Ref(highVolume, -1) AND upBar;
 
support = Ref(downBar,-1) AND (NOT Ref(downClose,-1)) AND Ref(highVolume,-1) AND upBar;
 
stoppingVolume = Ref(downBar,-1) AND Ref(highVolume,-1) AND C > testCloseMiddle AND (NOT downBar);
 
bullishsign=moderateVol+UpThrustBar;//OR moderateVol+upBar;
 
//rallyEnd = (Ref(highVolume,-1) AND Ref(upBar,-1) AND wideRange AND downBar) OR
 
// (narrowRange AND highVolume AND H > Ref(HHV(H, 250), -1));
 
  
 
  
 
////////////////////////////////////////////////////////////////////////////////////
 
//
 
// Strength and Weakness
 
//
 
////////////////////////////////////////////////////////////////////////////////////
 
  
 
weakness = upThrustBar OR noDemandBar OR (narrowRange AND (H > Ref(H,-1)) AND highVolume) OR (Ref(highVolume,-1) AND Ref(upBar,-1) AND downBar AND (H < Ref(H,-1)));
 
  
 
/////////////////////////////////////////////////////////////////////////////////////////////
 
  
 
C1 = Ref(C, -1);
 
uc = C > C1; dc = C <= C1;
 
ud = C > O; dd = C <= O;
 
  
 
green = 1; blue = 2; yellow = 3; red = 4; white = 5;
 
VType = IIf(ud, IIf(uc, green, yellow), IIf(dd,IIf(dc, red, blue), white));
 
  
 
/* green volume: up-day and up-close*/
 
gv = IIf(VType == green, V, 0);
 
/* yellow volume: up-day but down-close */
 
yv = IIf(VType == yellow, V, 0);
 
/* red volume: down-day and down-close */
 
rv = IIf(VType == red, V, 0);
 
/* blue volume: down-day but up-close */
 
bv = IIf(VType == blue, V, 0);
 
  
 
uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
 
dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */
 
  
 
/* create moving average period parameters */
 
VolPer = Param("Adjust Vol. MA per.", 34, 1, 255, 1);
 
ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);
 
  
 
/* create triple exponential moving avearges of separate up and down volume
 
moving averages */
 
MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
 
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
 
MAtv = TEMA(V, VolPer );//total volume
 
  
 
/* Switch for Horizontal lines indicating current level of positive and
 
negative volume for ease in comparing to past highs/lows - toggle via
 
parmameter window */
 
OscillatorOnly = Param("Show Oscillator Only", 0, 0, 1, 1);
 
CompareBullVolume = Param("Show Bull Level", 1, 0, 1, 1);
 
if(CompareBullvolume AND !OscillatorOnly){
 
//Plot(SelectedValue(MAuv), "", colorGreen, styleLine);
 
}
 
  
 
CompareBearVolume = Param("Show Bear Level", 1, 0, 1, 1);
 
if(CompareBearVolume AND !OscillatorOnly){
 
//Plot(SelectedValue(MAdv), "", colorRed, styleLine);
 
}
 
  
 
/* Volume Segment Switches - toggle via parameter window */
 
bullvolume = Param("Show Bull Volume", 1, 0, 1, 1);
 
bearvolume = Param("Show Bear Volume", 1, 0, 1, 1);
 
totalvolume = Param("Show Total Volume", 1, 0, 1, 1);
 
  
 
/* plot volume lines and histograms if toggled on: */
 
bearToFront = Param("Show Bear Vol in Front", 0, 0, 1, 1);
 
if(bearToFront AND !OscillatorOnly){
 
//Plot(MAdv, "", colorRed, styleHistogram|styleNoLabel);
 
}
 
if(bullvolume AND !OscillatorOnly){
 
//Plot(MAuv, "Average Bull Volume", colorGreen, styleHistogram|styleNoLabel);
 
}
 
if(bearvolume AND !OscillatorOnly){
 
//Plot(MAdv, "Average Bear Volume", colorRed, styleHistogram|styleNoLabel);
 
}
 
if(totalVolume AND !OscillatorOnly){
 
//Plot(MAtv, "Total Volume", colorWhite, styleHistogram|styleNoLabel);
 
//Plot(MAtv, "", colorWhite, styleLine);
 
}
 
if(bullvolume AND !OscillatorOnly){
 
//Plot(MAuv, "", colorGreen, styleLine);
 
}
 
if(bearvolume AND !OscillatorOnly){
 
//Plot(MAdv, "", colorRed, styleLine);
 
}
 
  
 
/* better visibility of zero line: */
 
//Plot(0, "", colorBlue, 1);
 
  
 
/* Rise/Fall Convergence variables:  */
 
Converge = (TEMA(MAuv - MAdv, ConvPer));
 
Converge1 = Ref(Converge, -1);
 
ConvergeUp = Converge > Converge1;
 
ConvergeOver = Converge > 0;
 
rising = ConvergeUp AND ConvergeOver;
 
falling = !ConvergeUp AND ConvergeOver;
 
  
 
/* Rise/Fall Convergence Oscillator Switch  - toggle via parameter window - (provides a better view of resulting combination of battling bull/bear volume forces) */
 
convergenceOscillator = Param("Show Oscillator", 0, 0, 1, 1);
 
if(convergenceOscillator OR OscillatorOnly){
 
//Plot(Converge, "Bull/Bear Volume Convergence/Divergence", colorViolet,1|styleLeftAxisScale|styleNoLabel|styleThick);
 
//Plot(0,"", colorYellow, 1|styleLeftAxisScale|styleNoLabel);
 
}
 
  
 
/********************************************************
 
 Convergence Rise/Fall Shadows:
 
  
 
 (provides a more easily visible display of rising and falling  bull/bear
 
volume convergence) - toggle via parameter window
 
  
 
-posiitive Volume exceeding negative Volume: Light shadow
 
-negative volume exceeding positive volume: dark shadow
 
-if you use standard gray background - best shadows are:
 
-my greys: 14 = (216, 216, 216); 15 = (168, 168, 168));
 
-best substitute? using AB color constants?
 
-light: colorpalegreen; dark: colorRose;?
 
-(depends on your color scheme - customize to your tastes)
 
**********************************************************/
 
  
 
/* uncomment if you use my custom color greys: */
 
riseFallColor = IIf(rising, 14,15); //my custom shadow greys
 
  
 
/* comment out if you use my custom color gray shadows: */
 
/* riseFallColor = IIf(rising, colorPaleGreen,colorRose); */
 
  
 
/* Rise/Fall Convergence Plot Switch - toggle via parameter window */
 
riseFallShadows = Param("Show RiseFallShadows", 0, 0, 1, 1);
 
if(riseFallShadows){
 
//Plot(IIf(rising OR falling, 1, 0), "", riseFallColor,styleHistogram|styleArea|styleOwnScale|styleNoLabel);
 
}
 
_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,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 Buy pivots %g", PIVOT_BUY);
//printf("\n Sell pivots %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();
 
/**********************************************************
 /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);
 
_SECTION_BEGIN("Chart Settings");
    SetChartOptions(0,chartShowArrows|chartShowDates);
    SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
    SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkGrey),ParamColor("Lower Chart",colorDarkGrey));
    GraphXSpace=Param("GraphXSpace",10,0,100,1);
    dec = (Param("Decimals",2,0,7,1)/10)+1;
    bi = BarIndex();
    Lbi = LastValue(BarIndex());
    sbi = SelectedValue(bi);
    x1= BarCount-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(52)+ WriteVal(C,dec)+
    EncodeColor(55)+ "    Volume = "+ EncodeColor(52)+ WriteVal(V,1) +
 
"\n"+EncodeColor(colorPink)+"----------------------------------------"
 
+"\n"+EncodeColor(07)+"Volume: "+WriteIf(V>Vp2,EncodeColor(colorLime)+"Very High",WriteIf(V>Vp1,EncodeColor(colorLime)+" High",WriteIf(V>Vrg,EncodeColor(colorLime)+"Above Average",
 
WriteIf(V<Vrg AND V>Vn1,EncodeColor(colorRed)+"Less than Average",WriteIf(V<Vn1,EncodeColor(colorRed)+"Low","")))))
 
  
 
+"\n"+EncodeColor(colorYellow)+"Spread: "+WriteIf(rg >(arg*2),EncodeColor(colorLime)+" Wide",WriteIf(rg>arg,EncodeColor(colorLime)+" Above Average",EncodeColor(colorRed)+" Narrow"))
 
  
 
+"\n"+(EncodeColor(colorYellow)+"Close: ")+WriteIf(Vhcls,EncodeColor(colorLime)+"Very High",WriteIf(ucls,EncodeColor(colorLime)+"High",WriteIf(mcls,EncodeColor(colorYellow)+"Mid",
 
WriteIf(dcls,EncodeColor(colorRed)+"Down","Very Low"))))
 
  
 
+"\n"+EncodeColor(colorYellow) + "Zone : " +WriteIf(rising , EncodeColor(colorBrightGreen) + "Accumulation",WriteIf(falling , EncodeColor(colorCustom12) + "Distirbution",EncodeColor(colorAqua) + "Flat")) + " "
 
+"\n"+
 
EncodeColor(colorYellow) + "Status : " +
 
WriteIf(Weakness , EncodeColor(colorRed) + "Weak",
 
WriteIf(stoppingVolume , EncodeColor(colorCustom12) + "StoppingVol",
 
WriteIf(noSupplyBar , EncodeColor(colorLightOrange) + "NoSupply",
 
WriteIf(support , EncodeColor(colorLightBlue) + "SupportVol",
 
WriteIf(noDemandBar , EncodeColor(colorPink) + "NoDemand",
 
WriteIf(absorption, EncodeColor(colorSkyblue) + "Absorption",
 
WriteIf(upThrustBar, EncodeColor(colorBlue) + "Upthrust",
 
WriteIf(bullishsign, EncodeColor(colorPaleGreen) + "STRONG",
 
EncodeColor(colorTan) + "Neutral")))))))) + " "
 
+"\n"+EncodeColor(colorPink)+"----------------------------------------"
 
+"\n"+EncodeColor(colorYellow) +"----------------------------------------"
+"\n"+EncodeColor(colorGold)+   "                   Analysis                "
+"\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();
//========================================================================
  
  
SetChartOptions(2,chartShowArrows|chartShowDates|chartWrapTitle);
SetChartOptions(0,chartShowArrows|chartShowDates);
  
  
//GfxGradientRect( 180, 30, 1759, 735, ColorRGB(40,40,40), ColorRGB(0,0,40) );
GfxSetOverlayMode(1);
//GfxSelectPen( ColorRGB(150,0,0), 1 );
GfxSelectSolidBrush( ColorRGB(0,0,40) );
//GfxRectangle=( 0,750, 1807, 35 );
  
//GfxSelectPen( ColorRGB(150,0,0), 2 );
GfxSelectSolidBrush( ColorRGB(65,65,65) );
//GfxPolygon(250,200,200,250,250,20,200,50);
  
//GfxSelectPen( ColorRGB(125,0,0), 1 );
//GfxSelectSolidBrush( ColorRGB(0,0,40) );
//GfxRectangle( 10,100, 190, 160 );
  
//GfxSelectPen=( ColorRGB(0,0,0) ,1 );
GfxSelectSolidBrush( ColorRGB(0,0,0) );
//GfxSetTextAlign( 250 );// center alignment
  
GfxSetOverlayMode(1);
//GfxSelectFont=("Times New Roman", 30, 400, True );
GfxSetTextColor( ColorRGB( 105, 105, 105 ) );
GfxSetBkMode(0); // transparent
//GfxTextOut=("Pathfinder", 15 , 35 );
  
  
_SECTION_BEGIN("Flower");
si=Param("Zoom/In Out",5,-50,100,1);
GraphXSpace=si; 
  
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );
  
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, ColorRGB(155,155,155),IIf(m1>0 AND m1>s1,ColorRGB(0,125,0),IIf(m1>0 AND m1<s1,ColorRGB(180,30,160),ColorRGB(100,0,0))));
  
Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);
barColor=IIf(Close>Open,ColorRGB(0,245,0),ColorRGB(255,0,0));
  
Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
total = 0;
total = total  + IIf(tskp_colortmplcnd0 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd1 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd2 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd3 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd4 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd5 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd6 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd7 > 0, 1, -1);
total = total  + IIf(tskp_colortmplcnd8 > 0, 1, -1);
  
  
for( i = 0; i < BarCount; i++ )
{
  
    if( total[i] >= 5 )
        Color[i] = colorLime;
    else if(  total[i] <= -5 )
        Color[i] = colorRed;
    else
        Color[i] = colorWhite;
}
  
Candle=ParamList("Candle","Modified Candlestick,Modified Heikin Ashi,Normal Candlestick",1);
if(Candle=="Modified Candlestick")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
Plot (Close,"- Modified Candlestick", Color,ParamStyle( "Style", styleCandle|styleLine | styleThick, maskAll));
}
if(Candle=="Modified Heikin Ashi")
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, flowerOpen), "Modified Heikin Ashi", Color, styleCandle|styleLine);
}
if(Candle=="Normal Candlestick")
{
//ColorHighliter = myColor;
//SetBarFillColor( ColorHighliter );
PlotOHLC(O,H,L,C,"Normal Candlestick",barcolor,styleCandle|styleLine);
}
  
  
_SECTION_END();
  
_SECTION_BEGIN("TSKPPIVOT");
  
if(Candle=="Modified Heikin Ashi")
{
CHiPr = 0;
CLoPr = 9999999;
blsLong = 0;
PrevCOBar = 0;
NumBars = 0;
PrePP = 0;
PrevLowVal = 9999999;
BuySig = 0;
blsShort = 0;
PrevHiVal = 0;
blsNewCO = 0;
BarDif   = 0;
  
KPA900Val = E_TSKPA900(Close);
KPAutoStopVal = E_TSKPAUTOSTOP(High,Low,Close);
  
// -- Create 0-initialized arrays the size of barcount
aHPivs = flowerHigh - flowerHigh;
aLPivs = flowerLow - flowerLow;
aHiVal = flowerHigh - flowerHigh;
aLoVal = flowerLow - flowerLow;
  
  
Ctmpl = E_TSKPCOLORTMPL(Open,High,Low,Close,Volume);
sctotal = 0;
sctotal = sctotal  + IIf(tskp_colortmplcnd0 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd1 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd2 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd3 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd4 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd5 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd6 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd7 > 0, 1, -1);
sctotal = sctotal  + IIf(tskp_colortmplcnd8 > 0, 1, -1);
  
  
for (curBar=0; curBar < BarCount-1; curBar++)
{
  
    if ( curBar == 0 )
    {
        CHiPr = flowerHigh[curBar];
        CHiBar = curBar;
        CLoPr = flowerLow[curBar];
        CLoBar = curBar;
        blsLong = 0;
        blsShort = 0;
        blsNewCO = 0;
        PrePP = 0;
        PrevCOBar = 0;
        PrevHiVal = flowerHigh[curBar];
        PrevLowVal = flowerLow[curBar];
        BuySig = 0;
        SellSig = 0;
        blsLL  = 0;
    }
  
    if (flowerHigh[CurBar] >= CHiPr) {
        CHiPr = flowerHigh[CurBar];
        ChiBar = CurBar;
    }
  
    if (flowerLow[CurBar] <= CLoPr) {
        CLoPr = flowerLow[CurBar];
        CLoBar = CurBar;
    }
  
    if ( (KPA900Val[curBar] >= KPAutoStopVal[curbar]) AND (PrePP != -1) AND (blsLong != 1) ){
        BarDif = CurBar - PrevCOBar;
        if (BarDif >= NumBars) {
            blsLong = 1;
            blsShort = 0;
            blsNewCO = 1;
            PrevCOBar = CurBar;
        }
    }
  
    if ( (KPA900Val[curBar] <= KPAutoStopVal[curbar]) AND (PrePP != 1) AND (blsShort != 1) ){
        BarDif = CurBar - PrevCOBar;
        if (BarDif >= NumBars) {
            blsLong = 0;
            blsShort = 1;
            blsNewCO = 1;
            PrevCOBar = CurBar;
        }
    }
  
    if ( (blsNewCO == 1) AND (sctotal[CurBar] >= 5) AND (blsLong == 1) ) {
        LVal = CurBar - CLoBar;
        for (j= CLoBar-1; j <= CLoBar+1; j++)
        {
            if (j >=0) {
                aLPivs[j] = 1;
                aLoVal[j] = CLoPr;
            }
        }
        PrePP = -1;
        blsNewCO = 0;
        CHiPr = flowerHigh[CurBar];
        CHiBar = CurBar;
        CLoPr = flowerLow[Curbar];
        CLoBar = CurBar;
        }
        else if ((blsNewCO == 1) AND (sctotal[CurBar] <= -5) AND (blsShort == 1) ) {
        HVal = CurBar - CHiBar;
        for (j= CHiBar-1; j <= CHiBar+1; j++)
        {      
            if (j >=0) {
                aHPivs[j] = 1;
                aHiVal[j] = CHiPr;
            }
        }
        PrePP = 1;
        blsNewCO = 0;
        CHiPr = flowerHigh[CurBar];
        CHiBar = CurBar;
        CLoPr = flowerLow[Curbar];
        CLoBar = CurBar;
        }
}
  
PlotShapes(IIf(aHPivs == 1, 21,shapeNone), ColorRGB(255,0,145),0,   aHiVal,Offset = 20);
PlotShapes(IIf(aHPivs == 1, 15,shapeNone), ColorRGB(200,50,75),0,   aHiVal,Offset = 20);
PlotShapes(IIf(aLPivs == 1, 21,shapeNone), ColorRGB(0,125,225),0, aLoVal, Offset = -20);
PlotShapes(IIf(aLPivs == 1, 15,shapeNone), ColorRGB(0,125,255),0, aLoVal, Offset = -20);
}
  
  
_SECTION_END();
  
_SECTION_BEGIN("Resistance");
supres=ParamToggle("Sup_Res","No|Yes",1);
if(supres)
{
  
Prd1=Param("Res_Period1",2,0,200,1);
                     
test   = TEMA  ( High , Prd1 ) ;  
  
PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,flowerHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,flowerHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,flowerHigh,2);//PeakValue2
  
MPK = PKV2 < PKV1 AND PKV1 > PKV0 ;//MajorPeak
  
RsColor=ParamColor("ResistColor",ColorRGB(225,0,0));
BrCount=Param("ResistBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor[i] = colorBlack;
}
  
  
  
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"ColorRGB(200,0,0),ParamStyle("ResStyle1",styleDashed|styleNoTitle,maskAll));
  
RsColor2=ParamColor("Resist2Color",ColorRGB(225,0,0));
BrCount=Param("Resist2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor2[i] = colorBlack;
}
  
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", RsColor2,ParamStyle("ResStyle2",styleDashed|styleNoTitle,maskAll));
  
RsColor3=ParamColor("Resist3Color",ColorRGB(225,0,0));
BrCount=Param("Resist3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    RsColor3[i] = colorBlack;
}
  
  
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", RsColor3,ParamStyle("ResStyle3",styleThick|styleDots|styleNoTitle,maskAll));
  
  
  
_SECTION_END();
  
  
_SECTION_BEGIN("Support");
  
Prd2=Param("Sup_Period1",2,0,200,1);
                     
test2   = TEMA ( Low , Prd2 ) ;  
  
SP = Ref(test2,1) > Low AND test2 < Ref(test2,-1);//Peak
SPV0 = ValueWhen(SP,flowerLow,0);//PeakValue0
SPV1 = ValueWhen(SP,flowerLow,1);//PeakValue1
SPV2 = ValueWhen(SP,flowerLow,2);//PeakValue2
  
MSP = SPV2 > SPV1 AND SPV1 < SPV0 ;//MajorPeak
  
SpColor=ParamColor("SupColor",ColorRGB(0,225,0));
BrCount=Param("SupBarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor[i] = colorBlack;
}
  
  
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",SpColor,ParamStyle("SupportLine1",styleDashed|styleNoTitle,maskAll));
  
SpColor2=ParamColor("SupColor2",ColorRGB(0,200,0));
BrCount=Param("Sup2BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor2[i] = colorBlack;
}
  
  
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",Spcolor2,ParamStyle("SupportLine2",styleDashed|styleNoTitle,maskAll));
  
SpColor3=ParamColor("SupColor3",ColorRGB(0,175,0));
BrCount=Param("Sup3BarLength",8,1,500,1);
for (i=0;i<BarCount-BrCount;i++) //hide the line except most recent 10 bars
{
    SpColor3[i] = colorBlack;
}
  
  
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",SpColor3,ParamStyle("SupportLine3",styleThick|styleDots|styleNoTitle,maskAll));
}
_SECTION_END();
  
/*
  
_SECTION_BEGIN("TSKPEBand");
 
Periods = Param("Standard Error", 20, 3, 200, 1);
Smooth  = Param("Smooth",12,2,100,1);
  
  
LRCurve = LinearReg( C, periods );
MALRCurve  = MA(LRCurve, Smooth);
SEValue = StdErr( C, periods );
SErrorAvg =  MA(SEValue, Smooth);
  
LowerBand = MALRCurve - SErrorAvg ;
UpperBand = MALRCurve + SErrorAvg ;
  
Plot( MALRCurve , "MidBand", ParamColor("ColorMB",ColorRGB(0,200,0))  , ParamStyle("StyleMB", style=styleDashed, Mask=maskDefault ));
Plot( UpperBand , "UpperBand", ParamColor("ColorUp",colorTeal)  , ParamStyle("StyleUp", style=styleDashed, Mask=maskDefault ));
Plot( LowerBand , "LowerBand", ParamColor("ColorLo",colorTeal), ParamStyle("StyleLo", style=styleDashed, Mask=maskDefault ));
_SECTION_END();
 
_SECTION_BEGIN("Cloud Setting");
//Cloud
ParmCloud = ParamToggle("Cloud", "No|Yes", 1);
  
CloudResColor=ParamColor("CloudResColor",ColorRGB(15,15,15));
CR=Upperband;
CS=Lowerband;
  
if(parmCloud == 1)
{
    PlotOHLC( CS, CS, CR,CR, "Band", CloudResColor, styleCloud | styleNoLabel|styleNoTitle);
}
  
_SECTION_END();
*/
  
_SECTION_BEGIN("20EMA High");
Ph = ParamField("Price field",1);
Periods1 = Param("Periods", 20, 2, 400, 1 );
bbt=MA( Ph, Periods1 );
//Plot( bbt, "20EMA(H)", ParamColor( "Color", colorAqua ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();
 
_SECTION_BEGIN("20EMA Low");
Pl = ParamField("Price field",2);
Periods2 = Param("Periods", 20, 2, 400, 1 );
bbb=MA( Pl, Periods2 );
//Plot( bbb, "20EMA(L)", ParamColor( "Color", colorAqua ), ParamStyle("Style", styleLine | styleNoLabel ) | styleNoRescale );
_SECTION_END();
 
_SECTION_BEGIN("EMA Channel");
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( ParamColor("Color", ColorRGB(15,15,15) ), ColorRGB(15,15,15), 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();
  
_SECTION_BEGIN("Supertrend");
procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
{
    global buffer_line_down;
    global buffer_line_up;
    buffer_line_down = Null;
    buffer_line_up = Null;
  
    PHASE_NONE = 0;
    PHASE_BUY = 1;
    PHASE_SELL = -1;
  
    phase=PHASE_NONE;
    band_upper = 0;band_lower = 0;
  
    for(i = ATR_Period + 1; i < BarCount; i++)
    {
        band_upper = CalcPrice[i] + ATR_Multiplier * tr[i];
        band_lower = CalcPrice[i] - ATR_Multiplier * tr[i];
  
        if(phase==PHASE_NONE)
        {
            buffer_line_up[i] = CalcPrice[i];
            buffer_line_down[i] = CalcPrice[i];
        }
        if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
        {
            phase = PHASE_BUY;
            buffer_line_up[i] = band_lower;
            buffer_line_up[i-1] = buffer_line_down[i-1];
        }
        if(phase!=PHASE_SELL && Close[i]<buffer_line_up[i-1] && !IsEmpty(buffer_line_up[i-1]))
        {
            phase = PHASE_SELL;
            buffer_line_down[i] = band_upper;
            buffer_line_down[i-1] = buffer_line_up[i-1];
        }
        if(phase==PHASE_BUY && ((TrendMode==0 && !IsEmpty(buffer_line_up[i-2])) || TrendMode==1) )
        {
            if(band_lower>buffer_line_up[i-1])
            {
                buffer_line_up[i] = band_lower;
            }
            else
            {
                buffer_line_up[i] = buffer_line_up[i-1];
            }
        }
        if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
        {
            if(band_upper<buffer_line_down[i-1])
            {
                buffer_line_down[i] = band_upper;
            }
            else
            {
                buffer_line_down[i] = buffer_line_down[i-1];
            }
        }
    }
}
  
TrendMode = ParamToggle("TrendMode","Off|On",1);
ATR_Multiplier = Param("ATR_Multiplier",2,0.1,10,0.1);
ATR_Period = Param( "ATR_Period",5,1,20,1);
tr = ATR(ATR_Period);
  
CalcPrice = (H+L)/2;
calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice);
 
st = ParamToggle("Supertrend","Show|Hide",0);
if(st==1)  {
Plot(buffer_line_up,"\ntu",ColorRGB(28,134,238),styleThick);
Plot(buffer_line_down,"\ntd",ColorRGB(205,51,51),styleThick);
  
//Plot( 2,"",IIf(buffer_line_up,colorGreen,colorDarkOliveGreen),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
//Plot( 4,"",IIf(buffer_line_down,colorRed,colorDarkOliveGreen),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
}
_SECTION_END();
 
_SECTION_BEGIN("Auto Pivot");
Offset = 5; //use two sheets: one with 5 and another with 7, or maybe other offset value
Avgmov = Offset*MA(abs( ROC(C,1)) ,20);
per = LastValue(Avgmov) ;
x=Cum(1);
Range = 0.01;
PS = TroughBars(L, per,1) == 0;
xa = LastValue(ValueWhen (PS,x,1)) ;//x from last trough
Ya = LastValue(ValueWhen (PS,L,1)) ;//y (Low) last trough
PR = PeakBars(H,per, 1) == 0;
xb = LastValue(ValueWhen (PR,x,1)) ;//x from last peak
Yb = LastValue(ValueWhen (PR,H,1)) ;//y (High) last peak
Trough_ReTest = abs((L/ya)-1) <Range;
Peak_ReTest = abs((H/yb)-1) <Range;
Trough_Cross = Cross(ya,C);
Peak_Cross = Cross(C,yb);
//UP = upSwing DN = downSwing
UP = xb>xa;//upSwing
DN = xa>xb;//DownSwing
RT23_6 = IIf(UP,yb-(yb- ya)*0.236, IIf(DN,ya+ (yb-ya)*0.236,-1e10) );
RT38_2 = IIf(UP,yb-(yb- ya)*0.382, IIf(DN,ya+ (yb-ya)*0.382,-1e10) );
RT50_0 = IIf(UP,yb-(yb- ya)*0.500, IIf(DN,ya+ (yb-ya)*0.500,-1e10) );
RT61_8 = IIf(UP,yb-(yb- ya)*0.618, IIf(DN,ya+ (yb-ya)*0.618,-1e10) );
RT78_6 = IIf(UP,yb-(yb- ya)*0.786, IIf(DN,ya+ (yb-ya)*0.786,-1e10) );
  
RT12_7 = IIf(UP,yb-(yb- ya)*1.27, IIf(DN,ya+ (yb-ya)*1.27,-1e10) );
RT16_1 = IIf(UP,yb-(yb- ya)*1.61, IIf(DN,ya+ (yb-ya)*1.61,-1e10) );
  
RT=IIf(UP,-100* (yb-L)/(yb- ya),100*(H-ya)/( yb-ya));//Retracement_ Value
InZone = C<yb & C>ya;//use it for filter to receive only signals that are in in the Retracement zone.
Buy = Trough_ReTest OR peak_Cross;
Sell = Peak_ReTest OR trough_Cross;
Filter = 1;
AddColumn(RT, "RT%");
AddColumn(Trough_ReTest,"TR- Test",1.0) ;
AddColumn(Peak_ReTest,"PK-Test",1.0) ;
AddColumn(Trough_Cross,"TR-Cross",1.0);
AddColumn(Peak_Cross,"PK-Cross",1.0);
//AddColumn(CdDoji( )OR CHammer(),"Candle" ,1.0);
//Plot(C,"C",1, 64);
Plot(IIf(x>xa, ya,-1e10) ,"Bottom" ,colorBrown, 1+8);
Plot(IIf(x>xb, yb,-1e10) ,"Top",colorBrown,1+8);
xab = IIf(xb>xa,xb, xa);
//Retracements
Plot(IIf(x>= xab+1,RT23_6,-1e10), "\n23,6% Retr.",5,1);
Plot(IIf(x>= xab+1,RT38_2,-1e10), "38,2% Retr.",5,1);
Plot(IIf(x>= xab+1,RT50_0,-1e10), "\n50,0% Retr.",colorBlue, 1);
Plot(IIf(x>= xab+1,RT61_8,-1e10), "\n61,8% Retr.",colorBrown, 1);
Plot(IIf(x>= xab+1,RT78_6,-1e10), "78,6% Retr.",colorBrown, 1);
  
Plot(IIf(x>= xab+1,RT12_7,-1e10), "\n127% ext.",colorBrightGreen, styleDots);
Plot(IIf(x>= xab+1,RT16_1,-1e10), "161% ext.",colorBrightGreen, styleDots);
 
CondA=IIf(x>= xab+1,RT12_7,-1e10);
CondB=IIf(x>= xab+1,RT16_1,-1e10);
 
PlotOHLC(Condb,Condb,Conda,Conda,"",ColorRGB(30,130,30),styleCloud,styleNoLabel);
 
GraphXSpace = 0.5;
  
_SECTION_END( );
 
_SECTION_BEGIN("Better Volume");
 
Period = Param("Period", 13, 2, 300, 1, 10 );;
 
LowColor = colorYellow;
ClimaxColor = colorRed;
ChurnColor = colorGreen;
ClimaxChurnColor=colorBlue;
LowChurnColor= colorWhite;
 
Value1 = V;
Value2 = V*(H-L);
Value3 = V/(H-L);
 
BarColor = IIf( (Value1 == LLV(Value1,Period)), LowColor, IIf( (Value2 == HHV(Value2,Period)), ClimaxColor, IIf( (Value3 == HHV(Value3,Period)), ChurnColor, IIf( ((Value2 == HHV(Value2,Period) AND (Value3 == HHV(Value3,Period)))), ClimaxChurnColor, IIf( (Value3 == LLV(Value3,Period)), LowChurnColor, colorBlueGrey)))));
 
Plot( Volume, _DEFAULT_NAME(), BarColor, ParamStyle( "Style", styleHistogram  | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
 
_SECTION_END();
 
_SECTION_BEGIN("Beta Adjusted Trailing Stops by Southwind");
//Concept from Bulkowski’s Stop Placement
  
  
dif=Ref(High,0)-Ref(Low,0);
dif1=Ref(High,-1)-Ref(Low,-1);
dif2=Ref(High,-2)-Ref(Low,-2);
dif3=Ref(High,-3)-Ref(Low,-3);
dif4=Ref(High,-4)-Ref(Low,-4);
dif5=Ref(High,-5)-Ref(Low,-5);
dif6=Ref(High,-6)-Ref(Low,-6);
dif7=Ref(High,-7)-Ref(Low,-7);
dif8=Ref(High,-8)-Ref(Low,-8);
dif9=Ref(High,-9)-Ref(Low,-9);
dif10=Ref(High,-10)-Ref(Low,-10);
dif11=Ref(High,-11)-Ref(Low,-11);
dif12=Ref(High,-12)-Ref(Low,-12);
dif13=Ref(High,-13)-Ref(Low,-13);
dif14=Ref(High,-14)-Ref(Low,-14);
dif15=Ref(High,-15)-Ref(Low,-15);
  
Sumdif=(dif+dif1+dif2+dif3+dif4+dif5+dif6+dif7+dif8+dif9+dif10+dif11+dif12+dif13+dif14+dif15)/16;
  
mp = Param("Multiplier",2,0.25,5,0.25);
Sumdifml=(Sumdif*1);
Sumdifml2=(Sumdif*1.6);
Sumdifml3=(Sumdif*mp);
  
Betastops=HHV(C,20) - Sumdifml;
Betastops2=HHV(C,15) - Sumdifml2;
  
  
//BetastopsO=Ref(L,-1)-sumdifml;
//Plot(betastopsO,"BATS",ParamColor("", colorGreen) ,ParamStyle("",styleLine|styleThick|styleStaircase,maskAll));
//Plot(Betastops, "A", ParamColor( "Color", colorPink ),ParamStyle("Style",styleThick,maskAll));
Plot(Betastops2, "B", ParamColor( "Color2", colorGold ),ParamStyle("Style2",styleThick,maskAll));
  
//Plot(Sumdifml,"DifferenceX",3,styleNoLine |styleNoLabel);
//Plot(sumdif,"AvgDifference",25,styleNoLine |styleNoLabel);
//Plot(dif10,"AvgDifference1",26,styleNoLine |styleNoLabel);
_SECTION_END();

13 comments

1. kv_maligi

Hi Mr.Niladri
Vert Good. Exspecially you have clubbed fibo projections.

Is it possible to add buy/sell signals & exploration ?

what are conditions for buy /sell ? and also is it possible rank the signals strong buy & weak buy like that…

Thanks
Viswanath MK

2. worldastro

error on line no-2017

3. niladri

I have found “Signal Panel” one of my earlier indicator is using FIBO for plotting TGT’s on the same chart, I also noted if we keep " Better Volume" indicator in the same chart window, for some scripts chart looks bad.

So worked out my latest version of this indicator, replaced “Better Volume” indicator with Heiken Ashi Muti-Time-Frame bars ( HAS-MTF like seen in MT4 ) at the bootom of the chart window. Better Volume should be added as a seperate chart in the window & if added with wave trend charts, this now looks like a killer combo.

Wave trend: http://www.wisestocktrader.com/indicators/372-mikes-wave-trend-clone

I will post my new code later today.

4. kv_maligi

Hi Niladri,

wave trend clone is very good.
Awaiting for new code

thanks
viswanath

5. niladri

New version here: http://www.wisestocktrader.com/indicators/3276-southbreeze-modified-v2

With links to all other indicators for the system.

6. kv_maligi

Hi Niladri,

I think, the bars at bottom are indication of Multi Time Frame information. At present they are 3,6 & 12.

what are best values for daily TF ?

Thanks
Viswanath

7. niladri

The multi TF multipliers > TF , TF x 3, TF x 6, TF x 12 ( is meant for 5Min charts )

That way you get idea abt the HA trend on 5M/15M/30M/1H in a single 5M chart itself.

This why it is made part of v2.

8. itzvarma

Dear Friends,
I tried to use this indicator on my Amibroker system,but it is showing an error called “Error 29 variable ‘kpautostopval’ used without having been initialized”
What is the remedy?
Can anyone reply please?

9. Nazrulcpa

PLZ SEND ME THIS AFL FOR AMIBROKER 5.6V . WOULD U PLZ TO DO SOMETHING BETTER FOR DSE/CSE. HERE IS MY EMAIL nazrulcpa@gmail.com

10. spectremind

yes plz send me AFL code for amibroker v5.6 too. it isn’t working for me. thx. fatcatstarvingdog@gmail.com

11. mrdzenli

научись писать формулы

12. pk55

very good nice working

13. tuanhoangplus

It is not run. Would you can fix and send me tuanhoangplus@gmail.com.
Thanks you so much !!!

Leave Comment

Please login here to leave a comment.

Back