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 ....
Smarttrade with Tradelines 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 | x = Ref ( H ,-1); Y = Ref ( L ,-1); a=x+5; b=y-5; uptrend= StochK (39,3) > StochD (39,3,3); downtrend= StochK (39,3) < StochD (39,3,3); Buy = Cover = H > a AND uptrend; Sell = Short = L < b AND downtrend; Buy = ExRem ( Buy , Sell ); Sell = ExRem ( Sell , Buy ); PlotShapes ( IIf ( Buy , shapeUpArrow , shapeNone ), colorBrightGreen ,0, L ,-15); PlotShapes ( IIf ( Sell , shapeDownArrow , shapeNone ), colorRed ,0, H ,-15); _SECTION_BEGIN ( "Price" ); Graph0 = Close ; Graph0Style = 128; barcolor = IIf ( downtrend, 4, IIf ( uptrend, 5, 1 ) ); Graph0BarColor = ValueWhen ( barcolor != 0, barcolor ); SetBarFillColor ( IIf ( Close > Open , colorBlack , colorBlack ) ); SetChartBkGradientFill ( ParamColor ( "BgTop" , colorBlack ), ParamColor ( "BgBottom" , colorBlack ), ParamColor ( "Titleblock" , colorBlack )); SetChartOptions (0, chartShowArrows | chartShowDates ); _N (Title = StrFormat ( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}" , O , H , L , C , SelectedValue ( ROC ( C , 1 ) ) )); Plot ( C , "Close" , ParamColor ( "Color" , colorBlack ), styleNoTitle | ParamStyle ( "Style" ) | GetPriceStyle () ); _SECTION_END (); _SECTION_BEGIN ( "Background" ); SetChartOptions (0, chartShowArrows | chartShowDates ); SetChartBkColor ( ParamColor ( "Outer panel" , colorBlack )); // color of outer border SetChartBkGradientFill ( ParamColor ( "Inner panel upper" , colorBlack ), ParamColor ( "Inner panel lower" , colorBlack )); tchoice= Param ( "Title Selection " ,2,1,2,1); Plot ( C , "" , IIf ( O >= C , colorBlack , colorBlack ), ParamStyle ( "Price Style" , styleNoTitle ,maskPrice)); ////////////////////////////////////////////////////////////////// _SECTION_BEGIN ( "Advanced Trend Lines" ); function TD_Supply() { return ( H > Ref ( H , 1) AND H > Ref ( H , -1) AND H > Ref ( C , -2)); } function TD_Demand() { return ( L < Ref ( L , 1) AND L < Ref ( L , -1) AND L < Ref ( C , -2)); } function IsTD_Supply(n) { n = ( BarCount - 1) - n; return LastValue ( Ref ( H , -n) > Ref ( H , -n+1) AND Ref ( H , -n) > Ref ( H , -n-1) AND Ref ( H , -n) > Ref ( C , -n-2)); } function IsTD_Demand(n) { n = ( BarCount - 1) - n; return LastValue ( Ref ( L , -n) < Ref ( L , -n+1) AND Ref ( L , -n) < Ref ( L , -n-1) AND Ref ( L , -n) < Ref ( C , -n-2)); } function GetXSupport(Lo, Percentage, Back) { return (( BarCount - 1) - LastValue ( TroughBars (Lo, Percentage,Back))); } function GetYSupport(Lo, Percentage, Back) { return ( LastValue ( Trough (Lo, Percentage, back))); } function GetXResistance(Hi, Percentage, Back) { return (( BarCount - 1) - LastValue ( PeakBars (Hi, Percentage, Back))); } function GetYResistance(Hi, Percentage, Back) { return ( LastValue ( Peak (Hi, Percentage, Back))); } //////////////////////////////////////////////////////////////////////// //Parameters Percentage = Param ( "Percentage" , 0.5, 0.01, 100. ,0.01); Lines = Param ( "Lines?" , 5, 1, BarCount -2); DrawR = ParamList ( "Resistance Points" , "Off|High to High|High to Low" , 1); DrawS = ParamList ( "Support Points" , "Off|Low to Low|Low to High" , 1); DrawAllLines = ParamToggle ( "Draw All Lines?" , "No|Yes" , 1); Method = ParamToggle ( "Method" , "TD Points|ZigZag" ,1); ShowTDP = ParamToggle ( "Show TD Pionts" , "No|Yes" ); AllOrDownR = ParamToggle ( "Resistance Direction" , "All|Down" ); AllOrUpS = ParamToggle ( "Support Direction" , "All|Up" ); //////////////////////////////////////////////////////////////////////// Main = C ; Con = ConS = ConR = 1; if (DrawS== "Low to Low" ) { Support1 = L ; Support2 = L ; } else { Support1 = L ; Support2 = H ; } if (DrawR== "High to High" ) { Resistance1 = H ; Resistance2 = H ; } else { Resistance1 = H ; Resistance2 = L ; } //////////////////////////////////////////////////////////////////////// //Plotting Area Plot (Main, "" , IIf ( C > O , colorBlack , colorBlack ), styleBar ); if (DrawAllLines) for (i = 2; i<=Lines+1; i++) { if (DrawS!= "Off" ) { x0 = GetXSupport(Support1, Percentage, i); x1 = GetXSupport(Support2, Percentage, i-1); y0 = GetYSupport(Support1, Percentage, i); y1 = GetYSupport(Support2, Percentage, i-1); x = LineArray (x0, y0, x1, y1, 1); if (!Method) Con = (IsTD_Demand(x0) AND IsTD_Demand(x1)); if (AllOrUpS) ConS = y0 < y1; if (Con AND ConS) Plot (x, "" , colorLightBlue , styleLine | styleThick ); } if (DrawR!= "Off" ) { x0 = GetXResistance(Resistance1, Percentage, i); x1 = GetXResistance(Resistance2, Percentage, i-1); y0 = GetYResistance(Resistance1, Percentage, i); y1 = GetYResistance(Resistance2, Percentage, i-1); x = LineArray (x0, y0, x1, y1, 1); if (!Method) Con = (IsTD_Supply(x0) AND IsTD_Supply(x1)); if (AllOrDownR) ConR = y0 > y1; if (Con AND ConR) Plot (x, "" , colorRed , styleLine | styleThick ); } } else { if (DrawS!= "Off" ) { x0 = GetXSupport(Support1, Percentage, Lines+1); x1 = GetXSupport(Support2, Percentage, Lines); y0 = GetYSupport(Support1, Percentage, Lines+1); y1 = GetYSupport(Support2, Percentage, Lines); x = LineArray (x0, y0, x1, y1, 1); if (!Method) Con = (IsTD_Demand(x0) AND IsTD_Demand(x1)); if (AllOrUpS) ConS = y0 < y1; if (Con AND ConS) Plot (x, "" , colorLightBlue , styleLine | styleThick ); } if (DrawR!= "Off" ) { x0 = GetXResistance(Resistance1, Percentage, Lines+1); x1 = GetXResistance(Resistance2, Percentage, Lines); y0 = GetYResistance(Resistance1, Percentage, Lines+1); y1 = GetYResistance(Resistance2, Percentage, Lines); x = LineArray (x0, y0, x1, y1, 1); if (!Method) Con = (IsTD_Supply(x0) AND IsTD_Supply(x1)); if (AllOrDownR) ConR = y0 > y1; if (Con AND ConR) Plot (x, "" , colorRed , styleLine | styleThick ); } } if (ShowTDP) { PlotShapes (TD_Supply()* shapeSmallCircle , colorRed , 0, H , H *.001); PlotShapes (TD_Demand()* shapeSmallCircle , colorGreen , 0, L , - L *.001); } Title = FullName ()+ " ({{NAME}})\n{{DATE}}\n" + "Open: " + O + ", Hi: " + H + ", Lo: " + L + ", Close: " + C ; _SECTION_END (); _SECTION_END (); |