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 ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
cloke+jig jag for Amibroker (AFL)
Copy & Paste Friendly
Back
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 | _SECTION_BEGIN ( "Chaloke.com Peak" ); //Chaloke.com Peak-Trough System + Auto ATR + Position sizing+Varible Sensitivity// // Last Update 16 Oct 05 By Kook// PctVlt=( ATR (14)/ C )*100; //PercentVolatility PK= IIf (PctVlt<0.5, Peak ( Close ,0.5,1), IIf ( PctVlt>=0.5 AND PctVlt< 1.0 , Peak ( Close ,0.70,1), IIf ( PctVlt>=1.0 AND PctVlt< 1.5 , Peak ( Close ,0.90,1), IIf ( PctVlt>=1.5 AND PctVlt< 2.0 , Peak ( Close ,1.10,1), IIf ( PctVlt>=2.0 AND PctVlt< 2.5 , Peak ( Close ,1.30,1), IIf ( PctVlt>=2.5 AND PctVlt< 3.0 , Peak ( Close ,1.50,1), IIf ( PctVlt>=3.0 AND PctVlt< 3.5 , Peak ( Close ,1.70,1), IIf ( PctVlt>=3.5 AND PctVlt< 4.0 , Peak ( Close ,2.00,1), Peak ( Close ,2.20,1) )))))))); TGH= IIf (PctVlt<0.5, Trough ( Close ,0.5,1), IIf ( PctVlt>=0.5 AND PctVlt< 1.0 , Trough ( Close ,0.75,1), IIf ( PctVlt>=1.0 AND PctVlt< 1.5 , Trough ( Close ,1.00,1), IIf ( PctVlt>=1.5 AND PctVlt< 2.0 , Trough ( Close ,1.25,1), IIf ( PctVlt>=2.0 AND PctVlt< 2.5 , Trough ( Close ,1.50,1), IIf ( PctVlt>=2.5 AND PctVlt< 3.0 , Trough ( Close ,1.75,1), IIf ( PctVlt>=3.0 AND PctVlt< 3.5 , Trough ( Close ,2.00,1), IIf ( PctVlt>=3.5 AND PctVlt< 4.0 , Trough ( Close ,2.25,1), Trough ( Close ,2.50,1) )))))))); Sens= IIf (PctVlt<0.5,0.5, IIf ( PctVlt>=0.5 AND PctVlt< 1.0 ,0.75, IIf ( PctVlt>=1.0 AND PctVlt< 1.5 ,1.00, IIf ( PctVlt>=1.5 AND PctVlt< 2.0 ,1.25, IIf ( PctVlt>=2.0 AND PctVlt< 2.5 ,1.50, IIf ( PctVlt>=2.5 AND PctVlt< 3.0 ,1.75, IIf ( PctVlt>=3.0 AND PctVlt< 3.5 ,2.00, IIf ( PctVlt>=3.5 AND PctVlt< 4.0 ,2.25, 2.50 )))))))); Color= IIf ( BarsSince ( Cross ( C , Ref (PK,-1)))< BarsSince ( Cross ( Ref (TGH,-1), C )), colorBrightGreen , colorRed ); Plot ( C , "Chaloke.com Peak-Trough" ,Color, styleCandle ); ///////////////////////////////////////////////////////////////////////////////////////////////// Odd=13; //enter Odd numbers only CoefOdd= round (Odd/2); Even=12; //enter Even numbers only Coefeven=Even/2; Coefeven2=Coefeven+1; CongestionPercent=2.8; /*Set % above/below Moving average for congestion / sideways market*/ TriangularOdd= MA ( MA ( C ,CoefOdd),CoefOdd); TriangularEven= MA ( MA ( C ,Coefeven),Coefeven2); finalMov_avg= IIf (Odd > even,triangularOdd,TriangularEven); Color= colorBrightGreen ; //select Moving average line color tickercolor= colorBlack ; //select price color Plot (finalMov_avg, "" , IIf ( C < finalmov_avg, colorRed ,Color), styleDots | styleThick ) ; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Previous Days HI LO // DayH = TimeFrameGetPrice ( "H" , inDaily , -1); DayHI = LastValue (DayH,1); // yesterdays high DayL = TimeFrameGetPrice ( "L" , inDaily , -1); DayLI = LastValue (DayL,1); // yesterdays low DayC = TimeFrameGetPrice ( "C" , inDaily , -1); // yesterdays close DayO = TimeFrameGetPrice ( "O" , inDaily ); // current day open DayH2= TimeFrameGetPrice ( "H" , inDaily , -2); DayH2I = LastValue (DayH2,1); // Two days before high DayL2= TimeFrameGetPrice ( "L" , inDaily , -2); DayL2I = LastValue (DayL2,1); // Two days before low DayH3= TimeFrameGetPrice ( "H" , inDaily , -3); DayH3I = LastValue (DayH3,1); // Three days before high DayL3= TimeFrameGetPrice ( "L" , inDaily , -3); DayL3I = LastValue (DayL3,1); // Three days before low numbars = LastValue ( Cum ( Status ( "barvisible" ))); hts = -33.5; YHL = ParamToggle ( "Yesterday HI LO" , "Show|Hide" ,1); if (YHL==1) { Plot (DayL, "YL" , colorTurquoise , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (DayH, "YH" , colorTurquoise , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); PlotText ( " YH " , LastValue ( BarIndex ())-(numbars/Hts), DayHI, colorTurquoise ); PlotText ( " YL " , LastValue ( BarIndex ())-(numbars/Hts), DayLI, colorTurquoise ); } TDBHL = ParamToggle ( "2/3Days before HI LO" , "Show|Hide" ,0); if (TDBHL==1) { Plot (DayL2, "2DBL" , colorTurquoise , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (DayH2, "2DBH" , colorTurquoise , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (DayL3, "3DBL" , colorTurquoise , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (DayH3, "3DBH" , colorTurquoise , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); PlotText ( " 2DBH " , LastValue ( BarIndex ())-(numbars/Hts), DayH2I, colorTurquoise ); PlotText ( " 2DBL " , LastValue ( BarIndex ())-(numbars/Hts), DayL2I, colorTurquoise ); PlotText ( " 3DBH " , LastValue ( BarIndex ())-(numbars/Hts), DayH3I, colorTurquoise ); PlotText ( " 3DBL " , LastValue ( BarIndex ())-(numbars/Hts), DayL3I, colorTurquoise ); } // Pivot Levels // PP = (DayL + DayH + DayC)/3; PPI = LastValue (PP,1); // Pivot R1 = (PP * 2) - DayL; R1I = LastValue (R1,1); // Resistance 1 S1 = (PP * 2) - DayH; S1I = LastValue (S1,1); // Support 1 R2 = PP + R1 - S1; R2I = LastValue (R2,1); // Resistance 2 S2 = PP - R1 + S1; S2I = LastValue (S2,1); // Support 2 R3 = PP + R2 - S1; R3I = LastValue (R3,1); // Resistance 3 S3 = PP - R2 + S1; S3I = LastValue (S3,1); // Support 3 ppl = ParamToggle ( "Pivot Levels" , "Show|Hide" ,1); if (ppl==1) { Plot (PP, "PP" , colorRed , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (R1, "R1" , colorGreen , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (S1, "S1" , colorGreen , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (R2, "R2" , colorGreen , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (S2, "S2" , colorGreen , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (R3, "R3" , colorGreen , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (S3, "S3" , colorViolet , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); PlotText ( " Pivot " , LastValue ( BarIndex ())-(numbars/Hts), PPI, colorRed ); PlotText ( " R1 " , LastValue ( BarIndex ())-(numbars/Hts), R1I, colorGreen ); PlotText ( " S1 " , LastValue ( BarIndex ())-(numbars/Hts), S1I, colorGreen ); PlotText ( " R2 " , LastValue ( BarIndex ())-(numbars/Hts), R2I, colorGreen ); PlotText ( " S2 " , LastValue ( BarIndex ())-(numbars/Hts), S2I, colorGreen ); PlotText ( " R3 " , LastValue ( BarIndex ())-(numbars/Hts), R3I, colorGreen ); PlotText ( " S3 " , LastValue ( BarIndex ())-(numbars/Hts), S3I, colorGreen ); } // Camerilla Levels // rg = (DayH - DayL); H5=DayC+1.1*rg; H5I = LastValue (H5,1); H4=DayC+1.1*rg/2; H4I = LastValue (H4,1); H3=DayC+1.1*rg/4; H3I = LastValue (H3,1); H2=DayC+1.1*rg/6; H2I = LastValue (H2,1); H1=DayC+1.1*rg/12; H1I = LastValue (H1,1); L1=DayC-1.1*rg/12; L1I = LastValue (L1,1); L2=DayC-1.1*rg/6; L2I = LastValue (L2,1); L3=DayC-1.1*rg/4; L3I = LastValue (L3,1); L4=DayC-1.1*rg/2; L4I = LastValue (L4,1); L5=DayC-1.1*rg; L5I = LastValue (L5,1); pcl = ParamToggle ( "Camerilla Levels" , "Show|Hide" ,0); if (pcl==1) { Plot (H5, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (H4, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (H3, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (H2, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (H1, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (L1, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (L2, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (L3, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (L4, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); Plot (L5, "" , colorRose , styleLine | styleNoLine | styleNoRescale | styleNoTitle ); PlotText ( " H5 = " , LastValue ( BarIndex ())-(numbars/Hts), H5I +0.05, colorRose ); PlotText ( " H4 = " , LastValue ( BarIndex ())-(numbars/Hts), H4I +0.05, colorRose ); PlotText ( " H3 = " , LastValue ( BarIndex ())-(numbars/Hts), H3I +0.05, colorRose ); PlotText ( " H2 = " , LastValue ( BarIndex ())-(numbars/Hts), H2I +0.05, colorRose ); PlotText ( " H1 = " , LastValue ( BarIndex ())-(numbars/Hts), H1I +0.05, colorRose ); PlotText ( " L1 = " , LastValue ( BarIndex ())-(numbars/Hts), L1I +0.05, colorRose ); PlotText ( " L2 = " , LastValue ( BarIndex ())-(numbars/Hts), L2I +0.05, colorRose ); PlotText ( " L3 = " , LastValue ( BarIndex ())-(numbars/Hts), L3I +0.05, colorRose ); PlotText ( " L4 = " , LastValue ( BarIndex ())-(numbars/Hts), L4I +0.05, colorRose ); PlotText ( " L5 = " , LastValue ( BarIndex ())-(numbars/Hts), L5I +0.05, colorRose ); } // Current Days Hi Lo // THL = ParamToggle ( "Todays Hi Lo" , "Show|Hide" ,1); if (THL==1) { isRth = TimeNum () >= 084500 & TimeNum () <= 085959; isdRth = TimeNum () >= 084500 & TimeNum () <= 160000; aRthL = IIf (isRth, L , 1000000); aRthH = IIf (isdRth, H , Null ); aRthLd = IIf (isdRth, L , 1000000); DayH = TimeFrameCompress ( aRthH, inDaily , compressHigh ); DayH = TimeFrameExpand ( DayH, inDaily , expandFirst ); DayL = TimeFrameCompress ( aRthLd, inDaily , compressLow ); DayL = TimeFrameExpand ( DayL, inDaily , expandFirst ); Bars = BarsSince ( TimeNum () >= 94500 AND TimeNum () < 095959); //,BarIndex(),1); // AND DateNum()==LastValue(DateNum()); x0 = BarCount - LastValue (Bars); x1 = BarCount -1; DayHline= LineArray (x0, LastValue (DayH),x1, LastValue (DayH),0); DayLline= LineArray (x0, LastValue (DayL),x1, LastValue (DayL),0); DayHlineI = LastValue (DayHline,1); DayLlineI = LastValue (DayLline,1); Plot (DayHline, "DayH" , colorRed , styleBar | styleNoRescale | styleNoTitle ); Plot (DayLline, "DayL" , colorBrightGreen , styleBar | styleNoRescale | styleNoTitle ); PlotText ( " Day Hi " , LastValue ( BarIndex ())-(numbars/Hts), DayHlineI +0.05, colorRed ); PlotText ( " Day Lo " , LastValue ( BarIndex ())-(numbars/Hts), DayLlineI +0.05, colorBrightGreen ); } /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////// _SECTION_BEGIN ( "Break Outs" ); //{Buy} x1=5; x2=4; x3=3; x4=2; x5=1; x6=.5; //{Lowest price stock <5} AA= IIf ( C <5, Cross ( C , ValueWhen ( Peak ( H ,x1,1) != Ref ( Peak ( H ,x1,1),-1), H ,1)), //{Price between 5 AND 20} IIf ( C >5 AND C <20, Cross ( C , ValueWhen ( Peak ( H ,x2,1) != Ref ( Peak ( H ,x2,1),-1), H ,1)), //{Price between 20 AND 70} IIf ( C >20 AND C <70, Cross ( C , ValueWhen ( Peak ( H ,x3,1) != Ref ( Peak ( H ,x3,1),-1), H ,1)), //{Price between 70 AND 150} IIf ( C >70 AND C <150, Cross ( C , ValueWhen ( Peak ( H ,x4,1) != Ref ( Peak ( H ,x4,1),-1), H ,1)), //{Price between 150 AND 300} IIf ( C >150 AND C <300, Cross ( C , ValueWhen ( Peak ( H ,x5,1) != Ref ( Peak ( H ,x5,1),-1), H ,1)), //{Price over 300} Cross ( C , ValueWhen ( Peak ( H ,x6,1)!= Ref ( Peak ( H ,x6,1),-1), H ,1))))))); //{Sell } x1=5; x2=4; x3=3; x4=2; x5=1; x6=.5; //{Lowest price stock <5} BB= IIf ( C <5, Cross ( ValueWhen ( Trough ( L ,x1,1) != Ref ( Trough ( L ,x1,1),-1), L ,1), C ), //{Price between 5 AND 20} IIf ( C >5 AND C <20, Cross ( ValueWhen ( Trough ( L ,x2,1) != Ref ( Trough ( L ,x2,1),-1), L ,1), C ), //{Price between 20 AND 70} IIf ( C >20 AND C <70, Cross ( ValueWhen ( Trough ( L ,x3,1) != Ref ( Trough ( L ,x3,1),-1), L ,1), C ), //{Price between 70 AND 150} IIf ( C >70 AND C <150, Cross ( ValueWhen ( Trough ( L ,x4,1) != Ref ( Trough ( L ,x4,1),-1), L ,1), C ), //{Price between 150 AND 300} IIf ( C >150 AND C <300, Cross ( ValueWhen ( Trough ( L ,x5,1) != Ref ( Trough ( L ,x5,1),-1), L ,1), C ), //{Price over 300} Cross ( ValueWhen ( Trough ( L ,x6,1)!= Ref ( Trough ( L ,x6,1) ,-1), L ,1), C )))))); Color= IIf ( BarsSince (AA)> BarsSince (BB), colorRed , IIf ( RSI ()>70, colorCustom11 , colorDarkGreen )); ///////////////////////////////////////////////////////////////////////////////////////////////// ///// Trailing Stop Module ///// P6= Param ( "Trailing Stop Risk" ,2.5,2,3.5,0.1); P7= Param ( "Trailing Stop LookBack" ,2,5,25,1); P8= Param ( "Trailing Stop PrevLow Switch" ,0,0,1,1); PrevLow= IIf (P8==1, Ref ( C ,- TroughBars ( C ,3,1)) , Null ); //Plot(PrevLow,"",colorRed); //Position sizing// MyTotalPort = Param ( "MyTotalPort" ,1000000,10000,10000000,100000) ; AcceptableRisk = Param ( "AcceptableRisk" ,0.5,0.1,3,0.1); BarsFromStart = BarsSince ( Cross (AA,BB) AND Ref (Color,-1)== colorRed ) ; InitialStopLoss = Ref ( H - P6* ATR (P7),-BarsFromStart); PositionSizing = 0.01*AcceptableRisk*MyTotalPort/( C - InitialStopLoss ); PPP = IIf ( HHV ( H - P6* ATR (P7),BarsFromStart+1) < C , HHV ( H - P6* ATR (P7),BarsFromStart+1), Null ); Plot ( PPP , "" , colorGold ); _SECTION_END (); _SECTION_BEGIN ( "Magnified Market Price" ); //by Vidyasagar, vkunisetty@yahoo.com// FS= Param ( "Font Size" ,30,30,100,1); GfxSelectFont ( "Arial" , FS, 900, italic = False , underline = False , True ); GfxSetBkMode ( colorWhite ); GfxSetTextColor ( ParamColor ( "Color" , colorYellow ) ); Hor= Param ( "Horizontal Position" ,800,800,800,800); Ver= Param ( "Vertical Position" ,17,17,17,17); GfxTextOut ( "" + C ,Hor , Ver ); YC= TimeFrameGetPrice ( "C" , inDaily ,-1); DD= Prec ( C -YC,2); xx= Prec ((DD/YC)*100,2); GfxSelectFont ( "Arial" , 12, 700, italic = False , underline = False , True ); GfxSetBkMode ( colorWhite ); GfxSetTextColor ( ParamColor ( "Color" , colorYellow ) ); GfxTextOut ( "" +DD+ " (" +xx+ "%)" , Hor+5, Ver+45 ); _SECTION_END (); ///////////////////////////////////////////////////////////////////////////////////////////////// _N (Title = StrFormat ( "{{NAME}} - {{INTERVAL}} {{DATE}} - " + EncodeColor ( colorBlue )+ "Open = " + EncodeColor ( colorBlue ) + "%g " + EncodeColor ( colorBrightGreen )+ "High = " + EncodeColor ( colorBrightGreen ) + "%g - " + EncodeColor ( colorRed )+ "Low = " + EncodeColor ( colorRed ) + "%g " + EncodeColor ( colorBlue ) + "Close = " + EncodeColor ( colorBlue ) + " %g (%.1f%%) Vol " + WriteVal ( V , 1.0 ) + " {{VALUES}}" , O , H , L , C , SelectedValue ( ROC ( C , 1 )) )); ///////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// //Support and resistance levels using RSI. //graham Kavanagh May 2003 //Load into Indicator Builder //Sensitivity of the levels can be changed with the variables //Can test different numbers live with the Param function ctrl-R with open pane RSIperiod = 5; // Param("RSI p",3,14,30,1); Percent = 5; // Param("ZIG %",8,9,15,1); EMAperiod = 5; //Param("EMA p",4,5,10,1); HHVperiod = 5; //Param("HHV p",3,5,10,1); NumLine = 1; //Param("Num Lines",3,1,20,1); Base = DEMA ( RSI (RSIperiod),EMAperiod); for ( i = 1; i <= numline; i++ ) { ResBase = LastValue ( Peak (Base,Percent,i)); SupBase = LastValue ( Trough (Base,Percent,i)); Plot ( ValueWhen ( ResBase==Base, HHV ( H ,HHVperiod) ), "Resist Level" , colorGreen , styleDots ); Plot ( ValueWhen ( supbase==Base, LLV ( L ,HHVperiod) ), "Support Level" , colorDarkGreen , styleDots ); } Title = Name () + "; " + Date () + ": Support & Resistance Levels using RSI: " + /*EncodeColor(colorGreen)+ "Support Levels are Green; "+EncodeColor(colorRed)+ "Resistance Levels are Red: "+EncodeColor(colorBlack)+*/ "Num lines =" + WriteVal (numline,1) ; ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// _SECTION_BEGIN ( "Pivot_Finder" ); /* ********************************** Code to automatically identify pivots ********************************** */ // -- what will be our lookback range for the hh and ll? farback= Param ( "How Far back to go" ,100,0,100,10); nBars = Param ( "Number of bars" , 12, 5, 40); // -- Create 0-initialized arrays the size of barcount aHPivs = H - H ; aLPivs = L - L ; // -- More for future use, not necessary for basic plotting aHPivHighs = H - H ; aLPivLows = L - L ; aHPivIdxs = H - H ; aLPivIdxs = L - L ; nHPivs = 0; nLPivs = 0; lastHPIdx = 0; lastLPIdx = 0; lastHPH = 0; lastLPL = 0; curPivBarIdx = 0; // -- looking back from the current bar, how many bars // back were the hhv and llv values of the previous // n bars, etc.? aHHVBars = HHVBars ( H , nBars); aLLVBars = LLVBars ( L , nBars); aHHV = HHV ( H , nBars); aLLV = LLV ( L , nBars); // -- Would like to set this up so pivots are calculated back from // last visible bar to make it easy to "go back" and see the pivots // this code would find. However, the first instance of // _Trace output will show a value of 0 aVisBars = Status ( "barvisible" ); nLastVisBar = LastValue ( Highest ( IIf (aVisBars, BarIndex (), 0))); _TRACE ( "Last visible bar: " + nLastVisBar); // -- Initialize value of curTrend curBar = ( BarCount -1); curTrend = "" ; if (aLLVBars[curBar] < aHHVBars[curBar]) { curTrend = "D" ; } else { curTrend = "U" ; } // -- Loop through bars. Search for // entirely array-based approach // in future version for (i=0; i<farback; i++) { curBar = ( BarCount - 1) - i; // -- Have we identified a pivot? If trend is down... if (aLLVBars[curBar] < aHHVBars[curBar]) { // ... and had been up, this is a trend change if (curTrend == "U" ) { curTrend = "D" ; // -- Capture pivot information curPivBarIdx = curBar - aLLVBars[curBar]; aLPivs[curPivBarIdx] = 1; aLPivLows[nLPivs] = L [curPivBarIdx]; aLPivIdxs[nLPivs] = curPivBarIdx; nLPivs++; } // -- or current trend is up } else { if (curTrend == "D" ) { curTrend = "U" ; curPivBarIdx = curBar - aHHVBars[curBar]; aHPivs[curPivBarIdx] = 1; aHPivHighs[nHPivs] = H [curPivBarIdx]; aHPivIdxs[nHPivs] = curPivBarIdx; nHPivs++; } // -- If curTrend is up...else... } // -- loop through bars } // -- Basic attempt to add a pivot this logic may have missed // -- OK, now I want to look at last two pivots. If the most // recent low pivot is after the last high, I could // still have a high pivot that I didn't catch // -- Start at last bar curBar = ( BarCount -1); candIdx = 0; candPrc = 0; lastLPIdx = aLPivIdxs[0]; lastLPL = aLPivLows[0]; lastHPIdx = aHPivIdxs[0]; lastHPH = aHPivHighs[0]; if (lastLPIdx > lastHPIdx) { // -- Bar and price info for candidate pivot candIdx = curBar - aHHVBars[curBar]; candPrc = aHHV[curBar]; if ( lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aHPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nHPivs; j++) { aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs- (j+1)]; aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)]; } aHPivHighs[0] = candPrc ; aHPivIdxs[0] = candIdx; nHPivs++; } } else { // -- Bar and price info for candidate pivot candIdx = curBar - aLLVBars[curBar]; candPrc = aLLV[curBar]; if ( lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aLPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nLPivs; j++) { aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)]; aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)]; } aLPivLows[0] = candPrc; aLPivIdxs[0] = candIdx; nLPivs++; } } // -- Dump inventory of high pivots for debugging for (k=0; k<nHPivs; k++) { _TRACE ( "High pivot no. " + k + " at barindex: " + aHPivIdxs[k] + ", " + WriteVal ( ValueWhen ( BarIndex ()==aHPivIdxs[k], DateTime (), 1), formatDateTime) + ", " + aHPivHighs[k]); } ////////////////////////////////////////////////////////////////////////////// // -- OK, let's plot the pivots using arrows PlotShapes ( IIf (aHPivs==1, shapeStar , shapeNone ), colorBrightGreen , 0, H , 15); PlotShapes ( IIf (aLPivs==1, shapeStar , shapeNone ), colorCustom12 , 0, L , -20); ////////////////////////////////////////////////////////////////////////////// SetChartOptions (0, chartShowArrows | chartShowDates ); _N (Title = StrFormat ( "{{NAME}} - {{INTERVAL}} {{DATE}} - " + EncodeColor ( colorBlue )+ "Open = " + EncodeColor ( colorBlue ) + "%g " + EncodeColor ( colorBrightGreen )+ "High = " + EncodeColor ( colorBrightGreen ) + "%g - " + EncodeColor ( colorRed )+ "Low = " + EncodeColor ( colorRed ) + "%g " + EncodeColor ( colorBlue ) + "Close = " + EncodeColor ( colorBlue ) + " %g (%.1f%%) Vol " + WriteVal ( V , 1.0 ) + " {{VALUES}}" , O , H , L , C , SelectedValue ( ROC ( C , 1 )) )); ////////////////////////////////////////////////////////////////////////////// /* ********************************** Code to automatically identify pivots ********************************** */ // -- what will be our lookback range for the hh and ll? farback= Param ( "How Far back to go" ,100,12,30,1); nBars = Param ( "Number of bars" , 12, 1, 30, 1); // -- Create 0-initialized arrays the size of barcount aHPivs = H - H ; aLPivs = L - L ; // -- More for future use, not necessary for basic plotting aHPivHighs = H - H ; aLPivLows = L - L ; aHPivIdxs = H - H ; aLPivIdxs = L - L ; nHPivs = 0; nLPivs = 0; lastHPIdx = 0; lastLPIdx = 0; lastHPH = 0; lastLPL = 0; curPivBarIdx = 0; // -- looking back from the current bar, how many bars // back were the hhv and llv values of the previous // n bars, etc.? aHHVBars = HHVBars ( H , nBars); aLLVBars = LLVBars ( L , nBars); aHHV = HHV ( H , nBars); aLLV = LLV ( L , nBars); // -- Would like to set this up so pivots are calculated back from // last visible bar to make it easy to "go back" and see the pivots // this code would find. However, the first instance of // _Trace output will show a value of 0 aVisBars = Status ( "barvisible" ); nLastVisBar = LastValue ( Highest ( IIf (aVisBars, BarIndex (), 0))); _TRACE ( "Last visible bar: " + nLastVisBar); // -- Initialize value of curTrend curBar = ( BarCount -1); curTrend = "" ; if (aLLVBars[curBar] < aHHVBars[curBar]) { curTrend = "D" ; } else { curTrend = "U" ; } // -- Loop through bars. Search for // entirely array-based approach // in future version for (i=0; i<farback; i++) { curBar = ( BarCount - 1) - i; // -- Have we identified a pivot? If trend is down... if (aLLVBars[curBar] < aHHVBars[curBar]) { // ... and had been up, this is a trend change if (curTrend == "U" ) { curTrend = "D" ; // -- Capture pivot information curPivBarIdx = curBar - aLLVBars[curBar]; aLPivs[curPivBarIdx] = 1; aLPivLows[nLPivs] = L [curPivBarIdx]; aLPivIdxs[nLPivs] = curPivBarIdx; nLPivs++; } // -- or current trend is up } else { if (curTrend == "D" ) { curTrend = "U" ; curPivBarIdx = curBar - aHHVBars[curBar]; aHPivs[curPivBarIdx] = 1; aHPivHighs[nHPivs] = H [curPivBarIdx]; aHPivIdxs[nHPivs] = curPivBarIdx; nHPivs++; } // -- If curTrend is up...else... } // -- loop through bars } // -- Basic attempt to add a pivot this logic may have missed // -- OK, now I want to look at last two pivots. If the most // recent low pivot is after the last high, I could // still have a high pivot that I didn't catch // -- Start at last bar curBar = ( BarCount -1); candIdx = 0; candPrc = 0; lastLPIdx = aLPivIdxs[0]; lastLPL = aLPivLows[0]; lastHPIdx = aHPivIdxs[0]; lastHPH = aHPivHighs[0]; if (lastLPIdx > lastHPIdx) { // -- Bar and price info for candidate pivot candIdx = curBar - aHHVBars[curBar]; candPrc = aHHV[curBar]; if ( lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aHPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nHPivs; j++) { aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs- (j+1)]; aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)]; } aHPivHighs[0] = candPrc ; aHPivIdxs[0] = candIdx; nHPivs++; } } else { // -- Bar and price info for candidate pivot candIdx = curBar - aLLVBars[curBar]; candPrc = aLLV[curBar]; if ( lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aLPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j<nLPivs; j++) { aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)]; aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)]; } aLPivLows[0] = candPrc; aLPivIdxs[0] = candIdx; nLPivs++; } } // -- Dump inventory of high pivots for debugging /* for (k=0; k<nHPivs; k++) { _TRACE("High pivot no. " + k + " at barindex: " + aHPivIdxs[k] + ", " + WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k], DateTime(), 1), formatDateTime) + ", " + aHPivHighs[k]); } */ // -- OK, let's plot the pivots using arrows PlotShapes ( IIf (aHPivs==1, shapeSmallDownTriangle , shapeNone ), colorCustom12 , 0, High , Offset=-5); PlotShapes ( IIf (aLPivs==1, shapeSmallUpTriangle , shapeNone ), colorCustom11 , 0, Low , Offset=-5); Sell = aHPivs == 1 ; Buy = aLPivs == 1 ; Filter = Buy OR Sell ; Sell = ExRem ( Sell , Buy ); Buy = ExRem ( Buy , Sell ); /////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// //_SECTION_BEGIN("trending ribbon"); //uptrend=PDI()>MDI()AND Signal()<MACD(); //downtrend=MDI()>PDI()AND Signal()>MACD(); //Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon", //IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorRed )), /* choose color */ //styleOwnScale|styleArea|styleNoLabel, -0.5, 100 ); //_SECTION_END(); //GraphXSpace=15; // Zig-Hi-Zag-Lo formula VolON = ParamToggle ( "Plot Volume" , "Off|On" , 1 ); ZigON = ParamToggle ( "Plot Zig" , "Off|On" , 1 ); pr = Param ( "ZigZag change amount" , 3.0, 0.05, 20, 0.05 ); pk = PeakBars ( H , pr ) == 0; tr = TroughBars ( L , pr ) == 0; zzHi = Zig ( H , pr ); zzLo = Zig ( L , pr ); Avg = ( zzHi + zzLo ) / 2; x = IIf ( pk, zzHi, IIf ( tr, zzLo, IIf ( Avg > Ref ( Avg, -1 ), H , L ) ) ); zzHiLo = Zig ( x, pr ); zzup = zzHiLo > Ref ( zzHiLo, -1 ) ; zzdn = zzHiLo < Ref ( zzHiLo, -1 ); ribboncol = IIf ( zzup , colorGreen , colorRed ); // Plot the Zig ribbon Plot ( 1, "" , ribboncol, styleArea | styleOwnScale | styleNoLabel , 0, 100 ); if ( ZigON == 1 ) Plot ( zzHiLo, "" , ribboncol , styleNoLabel ); //Swing Volume Volswing = Sum ( V , BarsSince ( zzup != Ref ( zzup, -1 ) ) + 1 ); SwingBar = BarsSince ( zzHiLo != Ref ( zzHiLo, -1 ) ); // plot Volume at 5% from bottom's pane percent = Param ( "PositTextVol%" , 5, 2, 90, 0.5 ); xshift = Param ( "xshift %" , 4, 1, 90, 0.5 ); //4,1 yshift = Param ( "yshift %" , 3, 1, 90, 0.5 ); //3,1 Miny = Status ( "axisminy" ); Maxy = Status ( "axismaxy" ); y = Maxy + ( Maxy - Miny ) * percent / 100; // at 5 % above bottom of the pane FirstVisibleBar = Status ( "FirstVisibleBar" ); Lastvisiblebar = Status ( "LastVisibleBar" ); for ( i = Firstvisiblebar + 1; i <= Lastvisiblebar AND i < BarCount - 1; i++ ) { if ( zzup [i] AND zzup [ i+1] == 0 ) { if ( VolON == 1 ) { PlotText ( "" + Volswing [ i] , i - xshift , H [i] + yshift , colorGreen ); } } if ( zzup [i] == 0 AND zzup [ i+1] == 1 ) { if ( VolON == 1 ) { PlotText ( "" + Volswing [ i] , i - xshift , L [i] - yshift , colorRed ); } } } if ( VolON == 1 ) { PlotText ( "" + Volswing , i + 2 , zzHiLo[ BarCount -1], LastValue ( ribboncol) ); } xspace = Param ( "GraphXSpace " , 10, 1, 20, 1 ); GraphXSpace = xspace; ////////////////////////////////////////////////////////////////////////////// // test divergence // with linearray // to draw a divergence line on price // http://www.amibroker.com/guide/afl/afl_view.php?id=250 // adapted by reinsley /* _SECTION_BEGIN("ZIG - Zig"); P = ParamField( "Price field" ); change = Param("% change",0.5,0.1,25,0.1); Plot( Zig(P, change), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); _SECTION_END(); */ _SECTION_BEGIN ( "ZigHiLo" ); //added Title = EncodeColor ( 4 ) + _DEFAULT_NAME () + "; " + EncodeColor ( 1 ) + StrFormat ( "{{NAME}} - {{INTERVAL}}; {{DATE}}; \nO=%g, \nH=%g, \nL=%g, \nC=%g (%.1f%%){{VALUES}}" , O , H , L , C , SelectedValue ( ROC ( C , 1 ) ) ); SetChartOptions ( 0, chartShowArrows | chartShowDates ); //Plot( C, "", 1, 64 ); ZigPerc = Param ( "ZigZag-HL %" , 0.2, 0.01, 10, 0.01 ); change = ZigPerc ; //Param("% change",0.5,0.1,25,0.1); HHLLSel = ParamToggle ( "Each Pk/Tr|HH/LL" , "Each Pk/Tr|HH/LL Only" , 1 ); Both_Versions = ParamToggle ( "Modified Only|Both" , "Modified Only|Both" , 1 ); ATRmult = Param ( "Text Shift (in ATR)" , 0.6, 0.1, 3, 0.1 ); Show_Arrows = ParamToggle ( "Show Arrows" , "No|Yes" , 1 ); Arrowadj = Param ( "Arrowadj; " , 12, 2, 25, 1 ); pk = PeakBars ( H , ZigPerc ) == 0; tr = TroughBars ( L , ZigPerc ) == 0; pkbars = PeakBars ( H , ZigPerc ); trbars = TroughBars ( L , ZigPerc ); zHi = Zig ( H , ZigPerc ); zLo = Zig ( L , ZigPerc ); HLAvg = ( zHi + zLo ) / 2; zp1 = IIf ( pk, zHi, IIf ( tr, zLo, IIf ( HLAvg > Ref ( HLAvg, -1 ), H , L ) ) ); //Reinsley original zp2 = IIf ( pk, zHi, IIf ( tr, zLo, IIf ( pkbars <= trbars, L , H ) ) ); //Modified zp to reduce occasional erroneous Pk/Tr connections at very small ZigPerc values //=========Modified version================ za2 = Zig ( zp2, ZigPerc ); Slopeza2 = za2 - Ref ( za2, -1 ); Plot ( za2, "\nZig Modified" , 11, 5 | styleNoLabel ); //Zig H-L Modified if ( Show_Arrows ) { pR = Ref ( za2, -1 )<za2 AND za2> Ref ( za2, 1 ); pS = Ref ( za2, -1 ) > za2 AND za2 < Ref ( za2, 1 ); PlotShapes ( shapeDownArrow *pR, colorGreen , 0, H , -Arrowadj ); PlotShapes ( shapeUpArrow *pS, colorRed , 0, L , -Arrowadj ); } if ( Both_Versions ) { // Original Reinsley Version================= za1 = Zig ( zp1, ZigPerc ); Slopeza1 = za1 - Ref ( za1, -1 ); Plot ( za1, "ZiG Original" , 1, 5 | styleNoLabel ); //Zig H-L Reinsley original if ( Show_Arrows ) { pR = Ref ( za1, -1 )<za1 AND za1> Ref ( za1, 1 ); pS = Ref ( za1, -1 ) > za1 AND za1 < Ref ( za1, 1 ); PlotShapes ( shapeDownArrow *pR, colorGreen , 0, H , -Arrowadj ); PlotShapes ( shapeUpArrow *pS, colorRed , 0, L , -Arrowadj ); } } //modified from Tomasco // ORIGINAL uses H AND L values for next bar after Zig pk/tr instead at Zig pk/tr and is based on Zig(C); // occasionally, that value is lower/higher than the correct ZigLo/ZigHi values, since the Zig is based on C, NOT on H and L //added additional bells and whistles if ( HHLLSel ) { HH = ( ( za2 > Ref ( za2, - 1 ) AND za2 > Ref ( za2, 1 ) ) AND ( Peak ( za2, ZigPerc, 1 ) > Peak ( za2, ZigPerc, 2 ) ) ); //HH LL = ( ( za2 < Ref ( za2, - 1 ) AND za2 < Ref ( za2, 1 ) ) AND ( Trough ( za2, ZigPerc, 1 ) < Trough ( za2, ZigPerc, 2 ) ) ); //LL dist = ATRmult * ATR ( 20 ); //might not want that for ( i = 0; i < BarCount ; i++ ) { if ( HH [i] ) PlotText ( "HH" + "\n" + H [ i ], i, H [ i ] + dist[i], colorGreen ); if ( LL [i] ) PlotText ( "" + L [ i ] + "\nLL" , i, L [ i ] - dist[i], colorRed ); } } if ( !HHLLSel ) { HH = ( ( za2 > Ref ( za2, - 1 ) AND za2 > Ref ( za2, 1 ) ) ); LL = ( ( za2 < Ref ( za2, - 1 ) AND za2 < Ref ( za2, 1 ) ) ); } dist = ATRmult * ATR ( 20 ); //might not want that for ( i = 0; i < BarCount ; i++ ) { if ( HH [i] ) PlotText ( "H" + "\n" + H [ i ], i, H [ i ] + dist[i], colorGreen ); if ( LL [i] ) PlotText ( "" + L [ i ] + "\nL" , i, L [ i ] - dist[i], colorRed ); } _SECTION_END (); y2t = LastValue ( Trough ( L , change , 2 ) ) - 4; //_TRACE("y2t = "+y2t); y1t = LastValue ( Trough ( L , change , 1 ) ) - 4; //_TRACE("y1t = "+y1t); x2t = BarCount - 1 - LastValue ( TroughBars ( L , change , 2 ) ); //_TRACE("x2t = "+x2t); x1t = BarCount - 1 - LastValue ( TroughBars ( L , change , 1 ) ); //_TRACE("x1t = "+x1t); LineLo = LineArray ( x2t, y2t, x1t, y1t, 0 ); // a = ( low2 - low1 ) / ( bars2 - bars1 ) pat = ( y2t - y1t ) / ( x2t - x1t ); //_TRACE("slope price trough = "+pat); DivColorLo = IIf ( pat >= 0, 27, 32 ); y2p = LastValue ( Peak ( H , change , 2 ) ) + 4; //_TRACE("y2p = "+y2p); y1p = LastValue ( Peak ( H , change , 1 ) ) + 4; //_TRACE("y1p = "+y1p); x2p = BarCount - 1 - LastValue ( PeakBars ( H , change , 2 ) ); //_TRACE("x2p = "+x2p); x1p = BarCount - 1 - LastValue ( PeakBars ( H , change , 1 ) ); //_TRACE("x1p = "+x1p); LineHi = LineArray ( x2p, y2p, x1p, y1p, 0 ); // a = ( low2 - low1 ) / ( bars2 - bars1 ) // price a (slope) peak pap = ( y2p - y1p ) / ( x2p - x1p ); //_TRACE("slope price = "+pap); DivColorHi = IIf ( pap >= 0, 27, 32 ); Plot ( C , "Cl" , colorBlack , styleCandle ); Plot ( LineHi, "TLhi" , DivColorHi, styleLine + styleDots ); Plot ( LineLo, "TLlo" , DivColorLo, styleLine + styleDots + styleThick ); //_TRACE("BC = "+BarCount); //Le 01/03/2011 08:40, reinsley a écrit : // MACD fast no cross // v 1.1 by reinsley // to display the no cross signal ( white bar ) // draw up & down divergence lines |