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 ....
Kwikpop powerpops 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 | /* ABKPPowerPops In any event, these are the elements needed for the new POWER POP dot. BUY DOT placed below the bar once only. A new dot can only appear when we get an opposite configuration. 1) Triggosc is >0 2) Triggerline is >= Stopline 3) Scorecard is >5 4) Medium is > Medium MA 5) Shorttermtradebias > 0 6) Close is> 18 period Standard error plot. This one is the tricky one because the settings I'm using are 18 periods of the close and a smoothing average of 9 periods. I'm not sure how you can reference that value. Naturally a sell dot would be just the opposite. */ parmPPUpColor = ParamColor ( "Power Pops up color" , colorGreen ); parmPPDnColor = ParamColor ( "Power Pops dn color" , ColorRGB (160, 32, 240)); parmBand = ParamList ( "Use SEBand" , "Upper/Lower|Middle" , 0); parmDetrendPeriod = Param ( "Detrend period" , 8, 1, 20, 1); parmPlotEBand = ParamToggle ( "Plot mini-SEBand" , "No|Yes" , 1); parmSEBandPeriod = Param ( "mini-SEBand period" , 18, 2, 20, 1); parmSEBandSmooth = Param ( "mini-SEBand smooth period" , 9, 1, 20, 1); parmMBColor = ParamColor ( "mini-SEBand MB color" , colorBlack ); parmMBStyle = ParamStyle ( "mini-SEBand MB Style" , style= styleDashed | styleNoLabel , Mask= maskAll ); parmUBColor = ParamColor ( "mini-SEBand MB Color" , colorBlack ); parmUBStyle = ParamStyle ( "mini-SEBand MB Style" , style= styleLine | styleNoLabel , Mask= maskAll ); parmLBColor = ParamColor ( "mini-SEBand MB Color" , colorBlack ); parmLBStyle = ParamStyle ( "mini-SEBand MB Style" , style= styleLine | styleNoLabel , Mask= maskAll ); parmPlotTargets = ParamToggle ( "Plot stop" , "No|Yes" , 0); parmTargetColor = ParamColor ( "Stop color" , colorDarkRed ); parmTargetStyle = ParamStyle ( "Stop style" , styleSwingDots , maskAll ); parmPlotRibbon = ParamToggle ( "Plot as ribbon" , "No|Yes" , 0); parmRibbonSize = Param ( "Ribbon Size" , 1, 0.5, 10, 0.5); ParmSCThreshold = Param ( "ScoreCard Threshold" , 5, 1, 9, 1); parmVoice = ParamToggle ( "Voice" , "No|Yes" , 0); parmDebug = ParamToggle ( "Debug" , "No|Yes" , 0); SetBarsRequired (350, -1); // constants _N (CPaneName = Name () + Interval (2) + _SECTION_NAME ()); _N (CNewBarName = "NewBar" + CPaneName); //functions function CNewBar() { PrevDT = StaticVarGet ( CNewBarName); DT = LastValue ( DateTime ()); StaticVarSet ( CNewBarName,DT); return DT != PrevDT; } function MRoundB(Number, Multiple ) { if (Multiple == 0 ) { xMultiple = 0.01; } else { xMultiple = Multiple; } Divided = Number / xMultiple; intDivided = int (Divided); intDivided = intDivided + round (Divided - intDivided); return intDivided * xMultiple; }; //ObjAB = CreateObject("Broker.Application"); //ticker = objAB.Stocks(Name() ); if ( TickSize == 0) { TickValue = 0.01; //set TickValue to a penney } else { TickValue = TickSize; } NewBarSignal = CNewBar(); //KP indicators sw = E_TSKPUPSELL( Open , High , Low , Close , Volume ); KPTriggerLine = tskp_triggerline; dummya = E_TSKPMEDIUM( Close ); KPMediumUp = tskp_mediumup; KPMediumDn = tskp_mediumdown; KPMediumMA = tskp_mediumma; Ctmpl = E_TSKPCOLORTMPL( Open , High , Low , Close , Volume ); //ScoreCard KPScoreCard = 0; KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd0 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd1 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd2 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd3 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd4 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd5 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd6 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd7 > 0, 1, -1); KPScoreCard = KPScoreCard + IIf (tskp_colortmplcnd8 > 0, 1, -1); KPStopLine = E_TSKPSTOPLINE( High , Low , Close ); dummy = E_TSKPSHORTTERMTRADEBIAS( High , Low , Close ); KPSTTB = tskp_sttb1; if (parmDebug == 1) { printf ( "KBTriggerLine: %g%\nKPSTTB: %g%\nKPMediumUp: %g%\nKPMediumDn: %g%\nKPMediumMa: %g%\nScoreCard: %f1.0%\nStopLine: %g%" , KPTriggerLine, KPSTTB, KPMediumUp, KPMediumDn, KPMediumMa, KPScoreCard, KPStopLine); } // calculations //Detrend = KPTriggerLine - MA(KPTriggerLine, parmDetrendPeriod); //Detrend KPTriggerLine TriggOsc = C - Ref ( MA ( C , parmDetrendPeriod ), -( 1 + parmDetrendPeriod/2 ) ); LRCurve = LinearReg ( C , parmSEBandPeriod ); MALRCurve = MA (LRCurve, parmSEBandSmooth); SEValue = StdErr ( C , parmSEBandPeriod ); SErrorAvg = MA (SEValue, parmSEBandSmooth); LowerBand = MALRCurve - SErrorAvg ; UpperBand = MALRCurve + SErrorAvg ; if (parmBand == "Upper/Lower" ) { UpSignal = TriggOsc >= 0 AND KPTriggerLine > KPStopLine AND KPScoreCard > parmSCThreshold AND KPSTTB >= 0 AND (KPMediumUp > KPMediumMa OR KPMediumDn > KPMediumMa) AND C > UpperBand ; DnSignal = TriggOsc < 0 AND KPTriggerLine < KPStopLine AND KPScoreCard < parmSCThreshold AND KPSTTB < 0 AND (KPMediumUp < KPMediumMA OR KPMediumDn < KPMediumMA) AND C < LowerBand; } else //assume Middle band { UpSignal = TriggOsc >= 0 AND KPTriggerLine > KPStopLine AND KPScoreCard > parmSCThreshold AND KPSTTB >= 0 AND (KPMediumUp > KPMediumMa OR KPMediumDn > KPMediumMa) AND C > MALRCurve ; DnSignal = TriggOsc < 0 AND KPTriggerLine < KPStopLine AND KPScoreCard < parmSCThreshold AND KPSTTB < 0 AND (KPMediumUp < KPMediumMA OR KPMediumDn < KPMediumMA) AND C < MALRCurve; } UpSignal = ExRem (UpSignal, DnSignal); //remove duplicate signals DnSignal = ExRem (DnSignal, UpSignal); if (parmDebug == 1) { printf ( "Detrend: %g%\\UpperBand: %g%\nLowerBand: %g%\n" , Detrend, UpperBand, LowerBand); printf ( WriteIf (UpSignal, "UpSignal: True" , "UpSignal: False" ) + WriteIf (DnSignal, " DnSignal: True\n" , " DnSignal: False\n" ) ); } //plots if (parmPlotRibbon == 0) { PlotShapes ( IIf (UpSignal, shapeCircle , shapeNone ), parmPPUpColor, 0, L , -10); PlotShapes ( IIf (DnSignal, shapeCircle , shapeNone ), parmPPDnColor, 0, H , 10); } else { Plot (parmRibbonSize, "" , IIf (UpSignal, parmPPUpColor, IIf (DnSignal, parmPPDnColor, Null )), styleArea | styleNoLabel | styleOwnScale , 0, 10); } if (parmPlotEBand == 1) { Plot ( MALRCurve , "MidBand" , parmMBColor , parmMBStyle); Plot ( UpperBand , "UpperBand" ,parmUBColor ,parmUBStyle ); Plot ( LowerBand , "LowerBand" , parmLBColor , parmLBStyle); } if (parmVoice == 1) { if (NewBarSignal) { BarUpSince = BarsSince (UpSignal); BarDnSince = BarsSince (DnSignal); Stop = IIf ( BarUpSince <= BarDnSince, Ref ( L , - BarUpSince) - TickSize, Ref ( H , - BarDnSince) + TickSize); if ( LastValue ( Ref (UpSignal, -1)) ) Say ( Interval (2) + " Power pop: up. Stop at " + NumToStr ( Ref ( L , -1) - TickSize, 1.2) + "." ); if ( LastValue ( Ref (DnSignal, -1)) ) Say ( Interval (2) + " Power pop: down. Stop at " + NumToStr ( Ref ( H , -1) + TickSize, 1.2) + "." ); } } if (parmPlotTargets == 1) { //RangeAvg = MRoundB(Ref(MA(H-L, 5), -1) , ticker.ticksize ) ; BarUpSince = BarsSince (UpSignal); BarDnSince = BarsSince (DnSignal); //PT = IIf( BBarUpSince <= BBarDnSince, Ref(O, - BBarUpSince + 1 ) + Ref(RangeAvg, -BBarUpSince -1), Ref(O, - BBarDnSince + 1) - Ref(RangeAvg, -BBarDnSince -1) ); Stop = IIf ( BarUpSince <= BarDnSince, Ref ( L , - BarUpSince) - ticker.TickSize, Ref ( H , - BarDnSince) + ticker.TickSize); Plot (Stop, "Stop" , parmTargetColor, parmTargetStyle); //Plot(PT, "Target", colorGreen, styleLine | styleStaircase); } _SECTION_BEGIN ( "Price" ); SetChartOptions (0, chartShowArrows | chartShowDates ); _N (Title = StrFormat ( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal ( V , 1.0 ) + " {{VALUES}}" , O , H , L , C , SelectedValue ( ROC ( C , 1 )) )); Plot ( C , "Close" , ParamColor ( "Color" , colorBlack ), styleNoTitle | ParamStyle ( "Style" ) | GetPriceStyle () ); if ( ParamToggle ( "Tooltip shows" , "All Values|Only Prices" ) ) { ToolTip= StrFormat ( "Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: " + NumToStr ( V , 1 ), O , H , L , C , SelectedValue ( ROC ( C , 1 ))); } _SECTION_END (); |